claude-code-wakatime 3.0.2 → 3.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.
package/dist/index.js CHANGED
@@ -324,7 +324,7 @@ var require_utils = __commonJS({
324
324
  }
325
325
  return c >>> 0;
326
326
  });
327
- function Utils2(opts) {
327
+ function Utils(opts) {
328
328
  this.sep = pth.sep;
329
329
  this.fs = fsystem;
330
330
  if (is_Obj(opts)) {
@@ -333,10 +333,10 @@ var require_utils = __commonJS({
333
333
  }
334
334
  }
335
335
  }
336
- module2.exports = Utils2;
337
- Utils2.prototype.makeDir = function(folder) {
336
+ module2.exports = Utils;
337
+ Utils.prototype.makeDir = function(folder) {
338
338
  const self2 = this;
339
- function mkdirSync2(fpath) {
339
+ function mkdirSync3(fpath) {
340
340
  let resolvedPath = fpath.split(self2.sep)[0];
341
341
  fpath.split(self2.sep).forEach(function(name) {
342
342
  if (!name || name.substr(-1, 1) === ":") return;
@@ -350,9 +350,9 @@ var require_utils = __commonJS({
350
350
  if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY(`"${resolvedPath}"`);
351
351
  });
352
352
  }
353
- mkdirSync2(folder);
353
+ mkdirSync3(folder);
354
354
  };
355
- Utils2.prototype.writeFileTo = function(path5, content, overwrite, attr) {
355
+ Utils.prototype.writeFileTo = function(path5, content, overwrite, attr) {
356
356
  const self2 = this;
357
357
  if (self2.fs.existsSync(path5)) {
358
358
  if (!overwrite) return false;
@@ -382,7 +382,7 @@ var require_utils = __commonJS({
382
382
  self2.fs.chmodSync(path5, attr || 438);
383
383
  return true;
384
384
  };
385
- Utils2.prototype.writeFileToAsync = function(path5, content, overwrite, attr, callback) {
385
+ Utils.prototype.writeFileToAsync = function(path5, content, overwrite, attr, callback) {
386
386
  if (typeof attr === "function") {
387
387
  callback = attr;
388
388
  attr = void 0;
@@ -428,7 +428,7 @@ var require_utils = __commonJS({
428
428
  });
429
429
  });
430
430
  };
431
- Utils2.prototype.findFiles = function(path5) {
431
+ Utils.prototype.findFiles = function(path5) {
432
432
  const self2 = this;
433
433
  function findSync(dir, pattern, recursive) {
434
434
  if (typeof pattern === "boolean") {
@@ -448,7 +448,7 @@ var require_utils = __commonJS({
448
448
  }
449
449
  return findSync(path5, void 0, true);
450
450
  };
451
- Utils2.prototype.findFilesAsync = function(dir, cb) {
451
+ Utils.prototype.findFilesAsync = function(dir, cb) {
452
452
  const self2 = this;
453
453
  let results = [];
454
454
  self2.fs.readdir(dir, function(err, list) {
@@ -475,23 +475,23 @@ var require_utils = __commonJS({
475
475
  });
476
476
  });
477
477
  };
478
- Utils2.prototype.getAttributes = function() {
478
+ Utils.prototype.getAttributes = function() {
479
479
  };
480
- Utils2.prototype.setAttributes = function() {
480
+ Utils.prototype.setAttributes = function() {
481
481
  };
482
- Utils2.crc32update = function(crc, byte) {
482
+ Utils.crc32update = function(crc, byte) {
483
483
  return crcTable[(crc ^ byte) & 255] ^ crc >>> 8;
484
484
  };
485
- Utils2.crc32 = function(buf) {
485
+ Utils.crc32 = function(buf) {
486
486
  if (typeof buf === "string") {
487
487
  buf = Buffer.from(buf, "utf8");
488
488
  }
489
489
  let len = buf.length;
490
490
  let crc = ~0;
491
- for (let off = 0; off < len; ) crc = Utils2.crc32update(crc, buf[off++]);
491
+ for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
492
492
  return ~crc >>> 0;
493
493
  };
494
- Utils2.methodToString = function(method) {
494
+ Utils.methodToString = function(method) {
495
495
  switch (method) {
496
496
  case Constants.STORED:
497
497
  return "STORED (" + method + ")";
@@ -501,17 +501,17 @@ var require_utils = __commonJS({
501
501
  return "UNSUPPORTED (" + method + ")";
502
502
  }
503
503
  };
504
- Utils2.canonical = function(path5) {
504
+ Utils.canonical = function(path5) {
505
505
  if (!path5) return "";
506
506
  const safeSuffix = pth.posix.normalize("/" + path5.split("\\").join("/"));
507
507
  return pth.join(".", safeSuffix);
508
508
  };
509
- Utils2.zipnamefix = function(path5) {
509
+ Utils.zipnamefix = function(path5) {
510
510
  if (!path5) return "";
511
511
  const safeSuffix = pth.posix.normalize("/" + path5.split("\\").join("/"));
512
512
  return pth.posix.join(".", safeSuffix);
513
513
  };
514
- Utils2.findLast = function(arr, callback) {
514
+ Utils.findLast = function(arr, callback) {
515
515
  if (!Array.isArray(arr)) throw new TypeError("arr is not array");
516
516
  const len = arr.length >>> 0;
517
517
  for (let i = len - 1; i >= 0; i--) {
@@ -521,7 +521,7 @@ var require_utils = __commonJS({
521
521
  }
522
522
  return void 0;
523
523
  };
524
- Utils2.sanitize = function(prefix, name) {
524
+ Utils.sanitize = function(prefix, name) {
525
525
  prefix = pth.resolve(pth.normalize(prefix));
526
526
  var parts = name.split("/");
527
527
  for (var i = 0, l = parts.length; i < l; i++) {
@@ -532,7 +532,7 @@ var require_utils = __commonJS({
532
532
  }
533
533
  return pth.normalize(pth.join(prefix, pth.basename(name)));
534
534
  };
535
- Utils2.toBuffer = function toBuffer(input, encoder) {
535
+ Utils.toBuffer = function toBuffer(input, encoder) {
536
536
  if (Buffer.isBuffer(input)) {
537
537
  return input;
538
538
  } else if (input instanceof Uint8Array) {
@@ -541,15 +541,15 @@ var require_utils = __commonJS({
541
541
  return typeof input === "string" ? encoder(input) : Buffer.alloc(0);
542
542
  }
543
543
  };
544
- Utils2.readBigUInt64LE = function(buffer, index) {
544
+ Utils.readBigUInt64LE = function(buffer, index) {
545
545
  var slice = Buffer.from(buffer.slice(index, index + 8));
546
546
  slice.swap64();
547
547
  return parseInt(`0x${slice.toString("hex")}`);
548
548
  };
549
- Utils2.fromDOS2Date = function(val) {
549
+ Utils.fromDOS2Date = function(val) {
550
550
  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);
551
551
  };
552
- Utils2.fromDate2DOS = function(val) {
552
+ Utils.fromDate2DOS = function(val) {
553
553
  let date = 0;
554
554
  let time = 0;
555
555
  if (val.getFullYear() > 1979) {
@@ -558,8 +558,8 @@ var require_utils = __commonJS({
558
558
  }
559
559
  return date << 16 | time;
560
560
  };
561
- Utils2.isWin = isWin;
562
- Utils2.crcTable = crcTable;
561
+ Utils.isWin = isWin;
562
+ Utils.crcTable = crcTable;
563
563
  }
564
564
  });
565
565
 
@@ -567,7 +567,7 @@ var require_utils = __commonJS({
567
567
  var require_fattr = __commonJS({
568
568
  "node_modules/adm-zip/util/fattr.js"(exports2, module2) {
569
569
  var pth = require("path");
570
- module2.exports = function(path5, { fs: fs6 }) {
570
+ module2.exports = function(path5, { fs: fs5 }) {
571
571
  var _path = path5 || "", _obj = newAttr(), _stat = null;
572
572
  function newAttr() {
573
573
  return {
@@ -579,8 +579,8 @@ var require_fattr = __commonJS({
579
579
  atime: 0
580
580
  };
581
581
  }
582
- if (_path && fs6.existsSync(_path)) {
583
- _stat = fs6.statSync(_path);
582
+ if (_path && fs5.existsSync(_path)) {
583
+ _stat = fs5.statSync(_path);
584
584
  _obj.directory = _stat.isDirectory();
585
585
  _obj.mtime = _stat.mtime;
586
586
  _obj.atime = _stat.atime;
@@ -657,11 +657,11 @@ var require_util = __commonJS({
657
657
  // node_modules/adm-zip/headers/entryHeader.js
658
658
  var require_entryHeader = __commonJS({
659
659
  "node_modules/adm-zip/headers/entryHeader.js"(exports2, module2) {
660
- var Utils2 = require_util();
661
- var Constants = Utils2.Constants;
660
+ var Utils = require_util();
661
+ var Constants = Utils.Constants;
662
662
  module2.exports = function() {
663
663
  var _verMade = 20, _version = 10, _flags = 0, _method = 0, _time = 0, _crc = 0, _compressedSize = 0, _size = 0, _fnameLen = 0, _extraLen = 0, _comLen = 0, _diskStart = 0, _inattr = 0, _attr = 0, _offset = 0;
664
- _verMade |= Utils2.isWin ? 2560 : 768;
664
+ _verMade |= Utils.isWin ? 2560 : 768;
665
665
  _flags |= Constants.FLG_EFS;
666
666
  const _localHeader = {
667
667
  extraLen: 0
@@ -669,7 +669,7 @@ var require_entryHeader = __commonJS({
669
669
  const uint32 = (val) => Math.max(0, val) >>> 0;
670
670
  const uint16 = (val) => Math.max(0, val) & 65535;
671
671
  const uint8 = (val) => Math.max(0, val) & 255;
672
- _time = Utils2.fromDate2DOS(/* @__PURE__ */ new Date());
672
+ _time = Utils.fromDate2DOS(/* @__PURE__ */ new Date());
673
673
  return {
674
674
  get made() {
675
675
  return _verMade;
@@ -723,10 +723,10 @@ var require_entryHeader = __commonJS({
723
723
  _method = val;
724
724
  },
725
725
  get time() {
726
- return Utils2.fromDOS2Date(this.timeval);
726
+ return Utils.fromDOS2Date(this.timeval);
727
727
  },
728
728
  set time(val) {
729
- this.timeval = Utils2.fromDate2DOS(val);
729
+ this.timeval = Utils.fromDate2DOS(val);
730
730
  },
731
731
  get timeval() {
732
732
  return _time;
@@ -822,7 +822,7 @@ var require_entryHeader = __commonJS({
822
822
  loadLocalHeaderFromBinary: function(input) {
823
823
  var data = input.slice(_offset, _offset + Constants.LOCHDR);
824
824
  if (data.readUInt32LE(0) !== Constants.LOCSIG) {
825
- throw Utils2.Errors.INVALID_LOC();
825
+ throw Utils.Errors.INVALID_LOC();
826
826
  }
827
827
  _localHeader.version = data.readUInt16LE(Constants.LOCVER);
828
828
  _localHeader.flags = data.readUInt16LE(Constants.LOCFLG);
@@ -839,7 +839,7 @@ var require_entryHeader = __commonJS({
839
839
  },
840
840
  loadFromBinary: function(data) {
841
841
  if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
842
- throw Utils2.Errors.INVALID_CEN();
842
+ throw Utils.Errors.INVALID_CEN();
843
843
  }
844
844
  _verMade = data.readUInt16LE(Constants.CENVEM);
845
845
  _version = data.readUInt16LE(Constants.CENVER);
@@ -899,7 +899,7 @@ var require_entryHeader = __commonJS({
899
899
  made: _verMade,
900
900
  version: _version,
901
901
  flags: _flags,
902
- method: Utils2.methodToString(_method),
902
+ method: Utils.methodToString(_method),
903
903
  time: this.time,
904
904
  crc: "0x" + _crc.toString(16).toUpperCase(),
905
905
  compressedSize: bytes(_compressedSize),
@@ -925,8 +925,8 @@ var require_entryHeader = __commonJS({
925
925
  // node_modules/adm-zip/headers/mainHeader.js
926
926
  var require_mainHeader = __commonJS({
927
927
  "node_modules/adm-zip/headers/mainHeader.js"(exports2, module2) {
928
- var Utils2 = require_util();
929
- var Constants = Utils2.Constants;
928
+ var Utils = require_util();
929
+ var Constants = Utils.Constants;
930
930
  module2.exports = function() {
931
931
  var _volumeEntries = 0, _totalEntries = 0, _size = 0, _offset = 0, _commentLength = 0;
932
932
  return {
@@ -965,7 +965,7 @@ var require_mainHeader = __commonJS({
965
965
  },
966
966
  loadFromBinary: function(data) {
967
967
  if ((data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) && (data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)) {
968
- throw Utils2.Errors.INVALID_END();
968
+ throw Utils.Errors.INVALID_END();
969
969
  }
970
970
  if (data.readUInt32LE(0) === Constants.ENDSIG) {
971
971
  _volumeEntries = data.readUInt16LE(Constants.ENDSUB);
@@ -974,10 +974,10 @@ var require_mainHeader = __commonJS({
974
974
  _offset = data.readUInt32LE(Constants.ENDOFF);
975
975
  _commentLength = data.readUInt16LE(Constants.ENDCOM);
976
976
  } else {
977
- _volumeEntries = Utils2.readBigUInt64LE(data, Constants.ZIP64SUB);
978
- _totalEntries = Utils2.readBigUInt64LE(data, Constants.ZIP64TOT);
979
- _size = Utils2.readBigUInt64LE(data, Constants.ZIP64SIZE);
980
- _offset = Utils2.readBigUInt64LE(data, Constants.ZIP64OFF);
977
+ _volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
978
+ _totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
979
+ _size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZE);
980
+ _offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
981
981
  _commentLength = 0;
982
982
  }
983
983
  },
@@ -1218,14 +1218,14 @@ var require_methods = __commonJS({
1218
1218
  // node_modules/adm-zip/zipEntry.js
1219
1219
  var require_zipEntry = __commonJS({
1220
1220
  "node_modules/adm-zip/zipEntry.js"(exports2, module2) {
1221
- var Utils2 = require_util();
1221
+ var Utils = require_util();
1222
1222
  var Headers = require_headers();
1223
- var Constants = Utils2.Constants;
1223
+ var Constants = Utils.Constants;
1224
1224
  var Methods = require_methods();
1225
1225
  module2.exports = function(options2, input) {
1226
1226
  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;
1227
1227
  const opts = options2;
1228
- const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils2.decoder;
1228
+ const decoder = typeof opts.decoder === "object" ? opts.decoder : Utils.decoder;
1229
1229
  _efs = decoder.hasOwnProperty("efs") ? decoder.efs : false;
1230
1230
  function getCompressedDataFromZip() {
1231
1231
  if (!input || !(input instanceof Uint8Array)) {
@@ -1236,14 +1236,14 @@ var require_zipEntry = __commonJS({
1236
1236
  }
1237
1237
  function crc32OK(data) {
1238
1238
  if (!_centralHeader.flags_desc) {
1239
- if (Utils2.crc32(data) !== _centralHeader.localHeader.crc) {
1239
+ if (Utils.crc32(data) !== _centralHeader.localHeader.crc) {
1240
1240
  return false;
1241
1241
  }
1242
1242
  } else {
1243
1243
  const descriptor = {};
1244
1244
  const dataEndOffset = _centralHeader.realDataOffset + _centralHeader.compressedSize;
1245
1245
  if (input.readUInt32LE(dataEndOffset) == Constants.LOCSIG || input.readUInt32LE(dataEndOffset) == Constants.CENSIG) {
1246
- throw Utils2.Errors.DESCRIPTOR_NOT_EXIST();
1246
+ throw Utils.Errors.DESCRIPTOR_NOT_EXIST();
1247
1247
  }
1248
1248
  if (input.readUInt32LE(dataEndOffset) == Constants.EXTSIG) {
1249
1249
  descriptor.crc = input.readUInt32LE(dataEndOffset + Constants.EXTCRC);
@@ -1254,12 +1254,12 @@ var require_zipEntry = __commonJS({
1254
1254
  descriptor.compressedSize = input.readUInt32LE(dataEndOffset + Constants.EXTSIZ - 4);
1255
1255
  descriptor.size = input.readUInt32LE(dataEndOffset + Constants.EXTLEN - 4);
1256
1256
  } else {
1257
- throw Utils2.Errors.DESCRIPTOR_UNKNOWN();
1257
+ throw Utils.Errors.DESCRIPTOR_UNKNOWN();
1258
1258
  }
1259
1259
  if (descriptor.compressedSize !== _centralHeader.compressedSize || descriptor.size !== _centralHeader.size || descriptor.crc !== _centralHeader.crc) {
1260
- throw Utils2.Errors.DESCRIPTOR_FAULTY();
1260
+ throw Utils.Errors.DESCRIPTOR_FAULTY();
1261
1261
  }
1262
- if (Utils2.crc32(data) !== descriptor.crc) {
1262
+ if (Utils.crc32(data) !== descriptor.crc) {
1263
1263
  return false;
1264
1264
  }
1265
1265
  }
@@ -1272,7 +1272,7 @@ var require_zipEntry = __commonJS({
1272
1272
  }
1273
1273
  if (_isDirectory) {
1274
1274
  if (async && callback) {
1275
- callback(Buffer.alloc(0), Utils2.Errors.DIRECTORY_CONTENT_ERROR());
1275
+ callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR());
1276
1276
  }
1277
1277
  return Buffer.alloc(0);
1278
1278
  }
@@ -1283,28 +1283,28 @@ var require_zipEntry = __commonJS({
1283
1283
  }
1284
1284
  if (_centralHeader.encrypted) {
1285
1285
  if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
1286
- throw Utils2.Errors.INVALID_PASS_PARAM();
1286
+ throw Utils.Errors.INVALID_PASS_PARAM();
1287
1287
  }
1288
1288
  compressedData = Methods.ZipCrypto.decrypt(compressedData, _centralHeader, pass);
1289
1289
  }
1290
1290
  var data = Buffer.alloc(_centralHeader.size);
1291
1291
  switch (_centralHeader.method) {
1292
- case Utils2.Constants.STORED:
1292
+ case Utils.Constants.STORED:
1293
1293
  compressedData.copy(data);
1294
1294
  if (!crc32OK(data)) {
1295
- if (async && callback) callback(data, Utils2.Errors.BAD_CRC());
1296
- throw Utils2.Errors.BAD_CRC();
1295
+ if (async && callback) callback(data, Utils.Errors.BAD_CRC());
1296
+ throw Utils.Errors.BAD_CRC();
1297
1297
  } else {
1298
1298
  if (async && callback) callback(data);
1299
1299
  return data;
1300
1300
  }
1301
- case Utils2.Constants.DEFLATED:
1301
+ case Utils.Constants.DEFLATED:
1302
1302
  var inflater = new Methods.Inflater(compressedData, _centralHeader.size);
1303
1303
  if (!async) {
1304
1304
  const result = inflater.inflate(data);
1305
1305
  result.copy(data, 0);
1306
1306
  if (!crc32OK(data)) {
1307
- throw Utils2.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1307
+ throw Utils.Errors.BAD_CRC(`"${decoder.decode(_entryName)}"`);
1308
1308
  }
1309
1309
  return data;
1310
1310
  } else {
@@ -1312,7 +1312,7 @@ var require_zipEntry = __commonJS({
1312
1312
  result.copy(result, 0);
1313
1313
  if (callback) {
1314
1314
  if (!crc32OK(result)) {
1315
- callback(result, Utils2.Errors.BAD_CRC());
1315
+ callback(result, Utils.Errors.BAD_CRC());
1316
1316
  } else {
1317
1317
  callback(result);
1318
1318
  }
@@ -1321,8 +1321,8 @@ var require_zipEntry = __commonJS({
1321
1321
  }
1322
1322
  break;
1323
1323
  default:
1324
- if (async && callback) callback(Buffer.alloc(0), Utils2.Errors.UNKNOWN_METHOD());
1325
- throw Utils2.Errors.UNKNOWN_METHOD();
1324
+ if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD());
1325
+ throw Utils.Errors.UNKNOWN_METHOD();
1326
1326
  }
1327
1327
  }
1328
1328
  function compress(async, callback) {
@@ -1333,14 +1333,14 @@ var require_zipEntry = __commonJS({
1333
1333
  if (uncompressedData.length && !_isDirectory) {
1334
1334
  var compressedData;
1335
1335
  switch (_centralHeader.method) {
1336
- case Utils2.Constants.STORED:
1336
+ case Utils.Constants.STORED:
1337
1337
  _centralHeader.compressedSize = _centralHeader.size;
1338
1338
  compressedData = Buffer.alloc(uncompressedData.length);
1339
1339
  uncompressedData.copy(compressedData);
1340
1340
  if (async && callback) callback(compressedData);
1341
1341
  return compressedData;
1342
1342
  default:
1343
- case Utils2.Constants.DEFLATED:
1343
+ case Utils.Constants.DEFLATED:
1344
1344
  var deflater = new Methods.Deflater(uncompressedData);
1345
1345
  if (!async) {
1346
1346
  var deflated = deflater.deflate();
@@ -1382,7 +1382,7 @@ var require_zipEntry = __commonJS({
1382
1382
  }
1383
1383
  }
1384
1384
  } catch (error) {
1385
- throw Utils2.Errors.EXTRA_FIELD_PARSE_ERROR();
1385
+ throw Utils.Errors.EXTRA_FIELD_PARSE_ERROR();
1386
1386
  }
1387
1387
  }
1388
1388
  function parseZip64ExtendedInformation(data) {
@@ -1420,7 +1420,7 @@ var require_zipEntry = __commonJS({
1420
1420
  return _entryName;
1421
1421
  },
1422
1422
  set entryName(val) {
1423
- _entryName = Utils2.toBuffer(val, decoder.encode);
1423
+ _entryName = Utils.toBuffer(val, decoder.encode);
1424
1424
  var lastChar = _entryName[_entryName.length - 1];
1425
1425
  _isDirectory = lastChar === 47 || lastChar === 92;
1426
1426
  _centralHeader.fileNameLength = _entryName.length;
@@ -1444,9 +1444,9 @@ var require_zipEntry = __commonJS({
1444
1444
  return decoder.decode(_comment);
1445
1445
  },
1446
1446
  set comment(val) {
1447
- _comment = Utils2.toBuffer(val, decoder.encode);
1447
+ _comment = Utils.toBuffer(val, decoder.encode);
1448
1448
  _centralHeader.commentLength = _comment.length;
1449
- if (_comment.length > 65535) throw Utils2.Errors.COMMENT_TOO_LONG();
1449
+ if (_comment.length > 65535) throw Utils.Errors.COMMENT_TOO_LONG();
1450
1450
  },
1451
1451
  get name() {
1452
1452
  var n = decoder.decode(_entryName);
@@ -1462,14 +1462,14 @@ var require_zipEntry = __commonJS({
1462
1462
  compress(true, callback);
1463
1463
  },
1464
1464
  setData: function(value) {
1465
- uncompressedData = Utils2.toBuffer(value, Utils2.decoder.encode);
1465
+ uncompressedData = Utils.toBuffer(value, Utils.decoder.encode);
1466
1466
  if (!_isDirectory && uncompressedData.length) {
1467
1467
  _centralHeader.size = uncompressedData.length;
1468
- _centralHeader.method = Utils2.Constants.DEFLATED;
1469
- _centralHeader.crc = Utils2.crc32(value);
1468
+ _centralHeader.method = Utils.Constants.DEFLATED;
1469
+ _centralHeader.crc = Utils.crc32(value);
1470
1470
  _centralHeader.changed = true;
1471
1471
  } else {
1472
- _centralHeader.method = Utils2.Constants.STORED;
1472
+ _centralHeader.method = Utils.Constants.STORED;
1473
1473
  }
1474
1474
  },
1475
1475
  getData: function(pass) {
@@ -1502,7 +1502,7 @@ var require_zipEntry = __commonJS({
1502
1502
  _centralHeader.flags_efs = this.efs;
1503
1503
  _centralHeader.extraLength = _extra.length;
1504
1504
  var header = _centralHeader.centralHeaderToBinary();
1505
- var addpos = Utils2.Constants.CENHDR;
1505
+ var addpos = Utils.Constants.CENHDR;
1506
1506
  _entryName.copy(header, addpos);
1507
1507
  addpos += _entryName.length;
1508
1508
  _extra.copy(header, addpos);
@@ -1551,7 +1551,7 @@ var require_zipFile = __commonJS({
1551
1551
  "node_modules/adm-zip/zipFile.js"(exports2, module2) {
1552
1552
  var ZipEntry = require_zipEntry();
1553
1553
  var Headers = require_headers();
1554
- var Utils2 = require_util();
1554
+ var Utils = require_util();
1555
1555
  module2.exports = function(inBuffer, options2) {
1556
1556
  var entryList = [], entryTable = {}, _comment = Buffer.alloc(0), mainHeader = new Headers.MainHeader(), loadedEntries = false;
1557
1557
  var password = null;
@@ -1589,14 +1589,14 @@ var require_zipFile = __commonJS({
1589
1589
  function readEntries() {
1590
1590
  loadedEntries = true;
1591
1591
  entryTable = {};
1592
- if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils2.Constants.CENHDR) {
1593
- throw Utils2.Errors.DISK_ENTRY_TOO_LARGE();
1592
+ if (mainHeader.diskEntries > (inBuffer.length - mainHeader.offset) / Utils.Constants.CENHDR) {
1593
+ throw Utils.Errors.DISK_ENTRY_TOO_LARGE();
1594
1594
  }
1595
1595
  entryList = new Array(mainHeader.diskEntries);
1596
1596
  var index = mainHeader.offset;
1597
1597
  for (var i = 0; i < entryList.length; i++) {
1598
1598
  var tmp = index, entry = new ZipEntry(opts, inBuffer);
1599
- entry.header = inBuffer.slice(tmp, tmp += Utils2.Constants.CENHDR);
1599
+ entry.header = inBuffer.slice(tmp, tmp += Utils.Constants.CENHDR);
1600
1600
  entry.entryName = inBuffer.slice(tmp, tmp += entry.header.fileNameLength);
1601
1601
  if (entry.header.extraLength) {
1602
1602
  entry.extra = inBuffer.slice(tmp, tmp += entry.header.extraLength);
@@ -1610,32 +1610,32 @@ var require_zipFile = __commonJS({
1610
1610
  makeTemporaryFolders();
1611
1611
  }
1612
1612
  function readMainHeader(readNow) {
1613
- var i = inBuffer.length - Utils2.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1613
+ var i = inBuffer.length - Utils.Constants.ENDHDR, max = Math.max(0, i - 65535), n = max, endStart = inBuffer.length, endOffset = -1, commentEnd = 0;
1614
1614
  const trailingSpace = typeof opts.trailingSpace === "boolean" ? opts.trailingSpace : false;
1615
1615
  if (trailingSpace) max = 0;
1616
1616
  for (i; i >= n; i--) {
1617
1617
  if (inBuffer[i] !== 80) continue;
1618
- if (inBuffer.readUInt32LE(i) === Utils2.Constants.ENDSIG) {
1618
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
1619
1619
  endOffset = i;
1620
1620
  commentEnd = i;
1621
- endStart = i + Utils2.Constants.ENDHDR;
1622
- n = i - Utils2.Constants.END64HDR;
1621
+ endStart = i + Utils.Constants.ENDHDR;
1622
+ n = i - Utils.Constants.END64HDR;
1623
1623
  continue;
1624
1624
  }
1625
- if (inBuffer.readUInt32LE(i) === Utils2.Constants.END64SIG) {
1625
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
1626
1626
  n = max;
1627
1627
  continue;
1628
1628
  }
1629
- if (inBuffer.readUInt32LE(i) === Utils2.Constants.ZIP64SIG) {
1629
+ if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
1630
1630
  endOffset = i;
1631
- endStart = i + Utils2.readBigUInt64LE(inBuffer, i + Utils2.Constants.ZIP64SIZE) + Utils2.Constants.ZIP64LEAD;
1631
+ endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
1632
1632
  break;
1633
1633
  }
1634
1634
  }
1635
- if (endOffset == -1) throw Utils2.Errors.INVALID_FORMAT();
1635
+ if (endOffset == -1) throw Utils.Errors.INVALID_FORMAT();
1636
1636
  mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
1637
1637
  if (mainHeader.commentLength) {
1638
- _comment = inBuffer.slice(commentEnd + Utils2.Constants.ENDHDR);
1638
+ _comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
1639
1639
  }
1640
1640
  if (readNow) readEntries();
1641
1641
  }
@@ -1663,7 +1663,7 @@ var require_zipFile = __commonJS({
1663
1663
  return decoder.decode(_comment);
1664
1664
  },
1665
1665
  set comment(val) {
1666
- _comment = Utils2.toBuffer(val, decoder.encode);
1666
+ _comment = Utils.toBuffer(val, decoder.encode);
1667
1667
  mainHeader.commentLength = _comment.length;
1668
1668
  },
1669
1669
  getEntryCount: function() {
@@ -1818,7 +1818,7 @@ var require_zipFile = __commonJS({
1818
1818
  }
1819
1819
  const mh = mainHeader.toBinary();
1820
1820
  if (_comment) {
1821
- _comment.copy(mh, Utils2.Constants.ENDHDR);
1821
+ _comment.copy(mh, Utils.Constants.ENDHDR);
1822
1822
  }
1823
1823
  mh.copy(outBuffer, dindex);
1824
1824
  inBuffer = outBuffer;
@@ -1874,7 +1874,7 @@ var require_zipFile = __commonJS({
1874
1874
  });
1875
1875
  const mh = mainHeader.toBinary();
1876
1876
  if (_comment) {
1877
- _comment.copy(mh, Utils2.Constants.ENDHDR);
1877
+ _comment.copy(mh, Utils.Constants.ENDHDR);
1878
1878
  }
1879
1879
  mh.copy(outBuffer, dindex);
1880
1880
  inBuffer = outBuffer;
@@ -1895,20 +1895,20 @@ var require_zipFile = __commonJS({
1895
1895
  // node_modules/adm-zip/adm-zip.js
1896
1896
  var require_adm_zip = __commonJS({
1897
1897
  "node_modules/adm-zip/adm-zip.js"(exports2, module2) {
1898
- var Utils2 = require_util();
1898
+ var Utils = require_util();
1899
1899
  var pth = require("path");
1900
1900
  var ZipEntry = require_zipEntry();
1901
1901
  var ZipFile = require_zipFile();
1902
- var get_Bool = (...val) => Utils2.findLast(val, (c) => typeof c === "boolean");
1903
- var get_Str = (...val) => Utils2.findLast(val, (c) => typeof c === "string");
1904
- var get_Fun = (...val) => Utils2.findLast(val, (c) => typeof c === "function");
1902
+ var get_Bool = (...val) => Utils.findLast(val, (c) => typeof c === "boolean");
1903
+ var get_Str = (...val) => Utils.findLast(val, (c) => typeof c === "string");
1904
+ var get_Fun = (...val) => Utils.findLast(val, (c) => typeof c === "function");
1905
1905
  var defaultOptions = {
1906
1906
  // option "noSort" : if true it disables files sorting
1907
1907
  noSort: false,
1908
1908
  // read entries during load (initial loading may be slower)
1909
1909
  readEntries: false,
1910
1910
  // default method is none
1911
- method: Utils2.Constants.NONE,
1911
+ method: Utils.Constants.NONE,
1912
1912
  // file system
1913
1913
  fs: null
1914
1914
  };
@@ -1923,26 +1923,26 @@ var require_adm_zip = __commonJS({
1923
1923
  }
1924
1924
  if (Buffer.isBuffer(input)) {
1925
1925
  inBuffer = input;
1926
- opts.method = Utils2.Constants.BUFFER;
1926
+ opts.method = Utils.Constants.BUFFER;
1927
1927
  input = void 0;
1928
1928
  }
1929
1929
  }
1930
1930
  Object.assign(opts, options2);
1931
- const filetools = new Utils2(opts);
1931
+ const filetools = new Utils(opts);
1932
1932
  if (typeof opts.decoder !== "object" || typeof opts.decoder.encode !== "function" || typeof opts.decoder.decode !== "function") {
1933
- opts.decoder = Utils2.decoder;
1933
+ opts.decoder = Utils.decoder;
1934
1934
  }
1935
1935
  if (input && "string" === typeof input) {
1936
1936
  if (filetools.fs.existsSync(input)) {
1937
- opts.method = Utils2.Constants.FILE;
1937
+ opts.method = Utils.Constants.FILE;
1938
1938
  opts.filename = input;
1939
1939
  inBuffer = filetools.fs.readFileSync(input);
1940
1940
  } else {
1941
- throw Utils2.Errors.INVALID_FILENAME();
1941
+ throw Utils.Errors.INVALID_FILENAME();
1942
1942
  }
1943
1943
  }
1944
1944
  const _zip = new ZipFile(inBuffer, opts);
1945
- const { canonical, sanitize, zipnamefix } = Utils2;
1945
+ const { canonical, sanitize, zipnamefix } = Utils;
1946
1946
  function getEntry(entry) {
1947
1947
  if (entry && _zip) {
1948
1948
  var item;
@@ -2151,7 +2151,7 @@ var require_adm_zip = __commonJS({
2151
2151
  if (_attr.isDirectory()) zipPath += filetools.sep;
2152
2152
  this.addFile(zipPath, data, comment, _attr);
2153
2153
  } else {
2154
- throw Utils2.Errors.FILE_NOT_FOUND(localPath2);
2154
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2155
2155
  }
2156
2156
  },
2157
2157
  /**
@@ -2218,7 +2218,7 @@ var require_adm_zip = __commonJS({
2218
2218
  }
2219
2219
  }
2220
2220
  } else {
2221
- throw Utils2.Errors.FILE_NOT_FOUND(localPath2);
2221
+ throw Utils.Errors.FILE_NOT_FOUND(localPath2);
2222
2222
  }
2223
2223
  },
2224
2224
  /**
@@ -2236,7 +2236,7 @@ var require_adm_zip = __commonJS({
2236
2236
  var self2 = this;
2237
2237
  filetools.fs.open(localPath2, "r", function(err) {
2238
2238
  if (err && err.code === "ENOENT") {
2239
- callback(void 0, Utils2.Errors.FILE_NOT_FOUND(localPath2));
2239
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath2));
2240
2240
  } else if (err) {
2241
2241
  callback(void 0, err);
2242
2242
  } else {
@@ -2314,7 +2314,7 @@ var require_adm_zip = __commonJS({
2314
2314
  const fileNameFix = (entry) => pth.win32.basename(pth.win32.normalize(namefix(entry)));
2315
2315
  filetools.fs.open(localPath, "r", function(err) {
2316
2316
  if (err && err.code === "ENOENT") {
2317
- callback(void 0, Utils2.Errors.FILE_NOT_FOUND(localPath));
2317
+ callback(void 0, Utils.Errors.FILE_NOT_FOUND(localPath));
2318
2318
  } else if (err) {
2319
2319
  callback(void 0, err);
2320
2320
  } else {
@@ -2441,7 +2441,7 @@ var require_adm_zip = __commonJS({
2441
2441
  outFileName = get_Str(keepOriginalPermission, outFileName);
2442
2442
  var item = getEntry(entry);
2443
2443
  if (!item) {
2444
- throw Utils2.Errors.NO_ENTRY();
2444
+ throw Utils.Errors.NO_ENTRY();
2445
2445
  }
2446
2446
  var entryName = canonical(item.entryName);
2447
2447
  var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
@@ -2451,7 +2451,7 @@ var require_adm_zip = __commonJS({
2451
2451
  if (child.isDirectory) return;
2452
2452
  var content2 = child.getData();
2453
2453
  if (!content2) {
2454
- throw Utils2.Errors.CANT_EXTRACT_FILE();
2454
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2455
2455
  }
2456
2456
  var name = canonical(child.entryName);
2457
2457
  var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
@@ -2461,9 +2461,9 @@ var require_adm_zip = __commonJS({
2461
2461
  return true;
2462
2462
  }
2463
2463
  var content = item.getData(_zip.password);
2464
- if (!content) throw Utils2.Errors.CANT_EXTRACT_FILE();
2464
+ if (!content) throw Utils.Errors.CANT_EXTRACT_FILE();
2465
2465
  if (filetools.fs.existsSync(target) && !overwrite) {
2466
- throw Utils2.Errors.CANT_OVERRIDE();
2466
+ throw Utils.Errors.CANT_OVERRIDE();
2467
2467
  }
2468
2468
  const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2469
2469
  filetools.writeFileTo(target, content, overwrite, fileAttr);
@@ -2506,7 +2506,7 @@ var require_adm_zip = __commonJS({
2506
2506
  keepOriginalPermission = get_Bool(false, keepOriginalPermission);
2507
2507
  pass = get_Str(keepOriginalPermission, pass);
2508
2508
  overwrite = get_Bool(false, overwrite);
2509
- if (!_zip) throw Utils2.Errors.NO_ZIP();
2509
+ if (!_zip) throw Utils.Errors.NO_ZIP();
2510
2510
  _zip.entries.forEach(function(entry) {
2511
2511
  var entryName = sanitize(targetPath, canonical(entry.entryName));
2512
2512
  if (entry.isDirectory) {
@@ -2515,14 +2515,14 @@ var require_adm_zip = __commonJS({
2515
2515
  }
2516
2516
  var content = entry.getData(pass);
2517
2517
  if (!content) {
2518
- throw Utils2.Errors.CANT_EXTRACT_FILE();
2518
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2519
2519
  }
2520
2520
  const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2521
2521
  filetools.writeFileTo(entryName, content, overwrite, fileAttr);
2522
2522
  try {
2523
2523
  filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
2524
2524
  } catch (err) {
2525
- throw Utils2.Errors.CANT_EXTRACT_FILE();
2525
+ throw Utils.Errors.CANT_EXTRACT_FILE();
2526
2526
  }
2527
2527
  });
2528
2528
  },
@@ -2552,7 +2552,7 @@ var require_adm_zip = __commonJS({
2552
2552
  });
2553
2553
  }
2554
2554
  if (!_zip) {
2555
- callback(Utils2.Errors.NO_ZIP());
2555
+ callback(Utils.Errors.NO_ZIP());
2556
2556
  return;
2557
2557
  }
2558
2558
  targetPath = pth.resolve(targetPath);
@@ -2589,7 +2589,7 @@ var require_adm_zip = __commonJS({
2589
2589
  if (err_1) {
2590
2590
  next(err_1);
2591
2591
  } else if (!content) {
2592
- next(Utils2.Errors.CANT_EXTRACT_FILE());
2592
+ next(Utils.Errors.CANT_EXTRACT_FILE());
2593
2593
  } else {
2594
2594
  const fileAttr = keepOriginalPermission ? entry.header.fileAttr : void 0;
2595
2595
  filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function(succ) {
@@ -13998,10 +13998,10 @@ var require_dnssec = __commonJS({
13998
13998
  out += "Exponent2: " + dmodq.toString("base64") + "\n";
13999
13999
  var iqmp = utils.mpDenormalize(key.part["iqmp"].data);
14000
14000
  out += "Coefficient: " + iqmp.toString("base64") + "\n";
14001
- var timestamp = /* @__PURE__ */ new Date();
14002
- out += "Created: " + dnssecTimestamp(timestamp) + "\n";
14003
- out += "Publish: " + dnssecTimestamp(timestamp) + "\n";
14004
- out += "Activate: " + dnssecTimestamp(timestamp) + "\n";
14001
+ var timestamp2 = /* @__PURE__ */ new Date();
14002
+ out += "Created: " + dnssecTimestamp(timestamp2) + "\n";
14003
+ out += "Publish: " + dnssecTimestamp(timestamp2) + "\n";
14004
+ out += "Activate: " + dnssecTimestamp(timestamp2) + "\n";
14005
14005
  return Buffer2.from(out, "ascii");
14006
14006
  }
14007
14007
  function writeECDSA(key, options2) {
@@ -14016,10 +14016,10 @@ var require_dnssec = __commonJS({
14016
14016
  }
14017
14017
  var base64Key = key.part["d"].data.toString("base64");
14018
14018
  out += "PrivateKey: " + base64Key + "\n";
14019
- var timestamp = /* @__PURE__ */ new Date();
14020
- out += "Created: " + dnssecTimestamp(timestamp) + "\n";
14021
- out += "Publish: " + dnssecTimestamp(timestamp) + "\n";
14022
- out += "Activate: " + dnssecTimestamp(timestamp) + "\n";
14019
+ var timestamp2 = /* @__PURE__ */ new Date();
14020
+ out += "Created: " + dnssecTimestamp(timestamp2) + "\n";
14021
+ out += "Publish: " + dnssecTimestamp(timestamp2) + "\n";
14022
+ out += "Activate: " + dnssecTimestamp(timestamp2) + "\n";
14023
14023
  return Buffer2.from(out, "ascii");
14024
14024
  }
14025
14025
  function write(key, options2) {
@@ -27850,7 +27850,7 @@ var require_form_data = __commonJS({
27850
27850
  var http = require("http");
27851
27851
  var https = require("https");
27852
27852
  var parseUrl = require("url").parse;
27853
- var fs6 = require("fs");
27853
+ var fs5 = require("fs");
27854
27854
  var mime = require_mime_types();
27855
27855
  var asynckit = require_asynckit();
27856
27856
  var populate = require_populate();
@@ -27914,7 +27914,7 @@ var require_form_data = __commonJS({
27914
27914
  if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
27915
27915
  callback(null, value.end + 1 - (value.start ? value.start : 0));
27916
27916
  } else {
27917
- fs6.stat(value.path, function(err, stat) {
27917
+ fs5.stat(value.path, function(err, stat) {
27918
27918
  var fileSize;
27919
27919
  if (err) {
27920
27920
  callback(err);
@@ -28794,8 +28794,8 @@ var require_querystring = __commonJS({
28794
28794
  // node_modules/uri-js/dist/es5/uri.all.js
28795
28795
  var require_uri_all = __commonJS({
28796
28796
  "node_modules/uri-js/dist/es5/uri.all.js"(exports2, module2) {
28797
- (function(global, factory) {
28798
- typeof exports2 === "object" && typeof module2 !== "undefined" ? factory(exports2) : typeof define === "function" && define.amd ? define(["exports"], factory) : factory(global.URI = global.URI || {});
28797
+ (function(global2, factory) {
28798
+ typeof exports2 === "object" && typeof module2 !== "undefined" ? factory(exports2) : typeof define === "function" && define.amd ? define(["exports"], factory) : factory(global2.URI = global2.URI || {});
28799
28799
  })(exports2, (function(exports3) {
28800
28800
  "use strict";
28801
28801
  function merge() {
@@ -35980,7 +35980,7 @@ var require_promise = __commonJS({
35980
35980
  var require_har2 = __commonJS({
35981
35981
  "node_modules/request/lib/har.js"(exports2) {
35982
35982
  "use strict";
35983
- var fs6 = require("fs");
35983
+ var fs5 = require("fs");
35984
35984
  var qs = require("querystring");
35985
35985
  var validate = require_promise();
35986
35986
  var extend = require_extend();
@@ -36114,7 +36114,7 @@ var require_har2 = __commonJS({
36114
36114
  return;
36115
36115
  }
36116
36116
  if (param.fileName && !param.value) {
36117
- attachment.value = fs6.createReadStream(param.fileName);
36117
+ attachment.value = fs5.createReadStream(param.fileName);
36118
36118
  } else if (param.value) {
36119
36119
  attachment.value = param.value;
36120
36120
  }
@@ -36610,7 +36610,7 @@ var require_hawk = __commonJS({
36610
36610
  return digest;
36611
36611
  };
36612
36612
  exports2.header = function(uri, method, opts) {
36613
- var timestamp = opts.timestamp || Math.floor((Date.now() + (opts.localtimeOffsetMsec || 0)) / 1e3);
36613
+ var timestamp2 = opts.timestamp || Math.floor((Date.now() + (opts.localtimeOffsetMsec || 0)) / 1e3);
36614
36614
  var credentials = opts.credentials;
36615
36615
  if (!credentials || !credentials.id || !credentials.key || !credentials.algorithm) {
36616
36616
  return "";
@@ -36619,7 +36619,7 @@ var require_hawk = __commonJS({
36619
36619
  return "";
36620
36620
  }
36621
36621
  var artifacts = {
36622
- ts: timestamp,
36622
+ ts: timestamp2,
36623
36623
  nonce: opts.nonce || randomString(6),
36624
36624
  method,
36625
36625
  resource: uri.pathname + (uri.search || ""),
@@ -40690,7 +40690,7 @@ var require_lib6 = __commonJS({
40690
40690
  "node_modules/which/lib/index.js"(exports2, module2) {
40691
40691
  var { isexe, sync: isexeSync } = require_cjs();
40692
40692
  var { join: join3, delimiter, sep, posix } = require("path");
40693
- var isWindows = process.platform === "win32";
40693
+ var isWindows2 = process.platform === "win32";
40694
40694
  var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
40695
40695
  var rRel = new RegExp(`^\\.${rSlash.source}`);
40696
40696
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -40701,11 +40701,11 @@ var require_lib6 = __commonJS({
40701
40701
  }) => {
40702
40702
  const pathEnv = cmd.match(rSlash) ? [""] : [
40703
40703
  // windows always checks the cwd first
40704
- ...isWindows ? [process.cwd()] : [],
40704
+ ...isWindows2 ? [process.cwd()] : [],
40705
40705
  ...(optPath || /* istanbul ignore next: very unusual */
40706
40706
  "").split(optDelimiter)
40707
40707
  ];
40708
- if (isWindows) {
40708
+ if (isWindows2) {
40709
40709
  const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
40710
40710
  const pathExt = pathExtExe.split(optDelimiter).flatMap((item) => [item, item.toLowerCase()]);
40711
40711
  if (cmd.includes(".") && pathExt[0] !== "") {
@@ -40774,117 +40774,220 @@ var require_lib6 = __commonJS({
40774
40774
  });
40775
40775
 
40776
40776
  // src/index.ts
40777
- var import_fs2 = __toESM(require("fs"));
40778
- var import_path2 = __toESM(require("path"));
40779
- var import_os2 = __toESM(require("os"));
40780
40777
  var import_child_process = require("child_process");
40781
40778
 
40782
40779
  // src/options.ts
40783
- var fs2 = __toESM(require("fs"));
40784
- var path = __toESM(require("path"));
40780
+ var fs3 = __toESM(require("fs"));
40781
+ var path3 = __toESM(require("path"));
40785
40782
 
40786
40783
  // src/utils.ts
40787
- var fs = __toESM(require("fs"));
40788
- var os = __toESM(require("os"));
40789
- var Utils = class {
40790
- static quote(str) {
40791
- if (str.includes(" ")) return `"${str.replace('"', '\\"')}"`;
40792
- return str;
40793
- }
40794
- static apiKeyInvalid(key) {
40795
- const err = "Invalid api key... check https://wakatime.com/api-key for your key";
40796
- if (!key) return err;
40797
- const re = new RegExp("^(waka_)?[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$", "i");
40798
- if (!re.test(key)) return err;
40799
- return "";
40800
- }
40801
- static formatDate(date) {
40802
- let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
40803
- let ampm = "AM";
40804
- let hour = date.getHours();
40805
- if (hour > 11) {
40806
- ampm = "PM";
40807
- hour = hour - 12;
40808
- }
40809
- if (hour == 0) {
40810
- hour = 12;
40811
- }
40812
- let minute = date.getMinutes();
40813
- return `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()} ${hour}:${minute < 10 ? `0${minute}` : minute} ${ampm}`;
40814
- }
40815
- static obfuscateKey(key) {
40816
- let newKey = "";
40817
- if (key) {
40818
- newKey = key;
40819
- if (key.length > 4) newKey = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX" + key.substring(key.length - 4);
40820
- }
40821
- return newKey;
40822
- }
40823
- static wrapArg(arg) {
40824
- if (arg.indexOf(" ") > -1) return '"' + arg.replace(/"/g, '\\"') + '"';
40825
- return arg;
40826
- }
40827
- static formatArguments(binary, args) {
40828
- let clone = args.slice(0);
40829
- clone.unshift(this.wrapArg(binary));
40830
- let newCmds = [];
40831
- let lastCmd = "";
40832
- for (let i = 0; i < clone.length; i++) {
40833
- if (lastCmd == "--key") newCmds.push(this.wrapArg(this.obfuscateKey(clone[i])));
40834
- else newCmds.push(this.wrapArg(clone[i]));
40835
- lastCmd = clone[i];
40836
- }
40837
- return newCmds.join(" ");
40838
- }
40839
- static apiUrlToDashboardUrl(url) {
40840
- url = url.replace("://api.", "://").replace("/api/v1", "").replace(/^api\./, "").replace("/api", "");
40841
- return url;
40842
- }
40843
- static isWindows() {
40844
- return os.platform() === "win32";
40845
- }
40846
- static getHomeDirectory() {
40847
- let home = process.env.WAKATIME_HOME;
40848
- if (home && home.trim() && fs.existsSync(home.trim())) return home.trim();
40849
- return process.env[this.isWindows() ? "USERPROFILE" : "HOME"] || process.cwd();
40850
- }
40851
- static buildOptions(stdin) {
40852
- const options2 = {
40853
- windowsHide: true
40854
- };
40855
- if (stdin) {
40856
- options2.stdio = ["pipe", "pipe", "pipe"];
40857
- }
40858
- if (!this.isWindows() && !process.env.WAKATIME_HOME && !process.env.HOME) {
40859
- options2["env"] = { ...process.env, WAKATIME_HOME: this.getHomeDirectory() };
40860
- }
40861
- return options2;
40862
- }
40863
- static timestamp() {
40864
- return Date.now() / 1e3;
40784
+ var fs2 = __toESM(require("fs"));
40785
+ var os2 = __toESM(require("os"));
40786
+ var import_path2 = __toESM(require("path"));
40787
+
40788
+ // src/logger.ts
40789
+ var import_fs = __toESM(require("fs"));
40790
+ var import_path = __toESM(require("path"));
40791
+ var import_os = __toESM(require("os"));
40792
+ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
40793
+ LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
40794
+ LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
40795
+ LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
40796
+ LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
40797
+ return LogLevel2;
40798
+ })(LogLevel || {});
40799
+ var LOG_FILE = import_path.default.join(import_os.default.homedir(), ".wakatime", "claude-code.log");
40800
+ var Logger = class {
40801
+ constructor(level) {
40802
+ this.level = 1 /* INFO */;
40803
+ if (level !== void 0) this.setLevel(level);
40804
+ }
40805
+ getLevel() {
40806
+ return this.level;
40807
+ }
40808
+ setLevel(level) {
40809
+ this.level = level;
40810
+ }
40811
+ log(level, msg) {
40812
+ if (level >= this.level) {
40813
+ msg = `[${(/* @__PURE__ */ new Date()).toISOString()}][${LogLevel[level]}] ${msg}
40814
+ `;
40815
+ import_fs.default.mkdirSync(import_path.default.dirname(LOG_FILE), { recursive: true });
40816
+ import_fs.default.appendFileSync(LOG_FILE, msg);
40817
+ }
40818
+ }
40819
+ debug(msg) {
40820
+ this.log(0 /* DEBUG */, msg);
40821
+ }
40822
+ debugException(msg) {
40823
+ if (msg.message !== void 0) {
40824
+ this.log(0 /* DEBUG */, msg.message);
40825
+ } else {
40826
+ this.log(0 /* DEBUG */, msg.toString());
40827
+ }
40828
+ }
40829
+ info(msg) {
40830
+ this.log(1 /* INFO */, msg);
40831
+ }
40832
+ warn(msg) {
40833
+ this.log(2 /* WARN */, msg);
40834
+ }
40835
+ warnException(msg) {
40836
+ if (msg.message !== void 0) {
40837
+ this.log(2 /* WARN */, msg.message);
40838
+ } else {
40839
+ this.log(2 /* WARN */, msg.toString());
40840
+ }
40841
+ }
40842
+ error(msg) {
40843
+ this.log(3 /* ERROR */, msg);
40844
+ }
40845
+ errorException(msg) {
40846
+ if (msg.message !== void 0) {
40847
+ this.log(3 /* ERROR */, msg.message);
40848
+ } else {
40849
+ this.log(3 /* ERROR */, msg.toString());
40850
+ }
40865
40851
  }
40866
40852
  };
40853
+ var global = globalThis;
40854
+ var logger = global.logger ?? new Logger();
40855
+ global.logger = logger;
40856
+
40857
+ // src/utils.ts
40858
+ var STATE_FILE = import_path2.default.join(os2.homedir(), ".wakatime", "claude-code.json");
40859
+ function parseInput() {
40860
+ try {
40861
+ const stdinData = fs2.readFileSync(0, "utf-8");
40862
+ if (stdinData.trim()) {
40863
+ const input = JSON.parse(stdinData);
40864
+ return input;
40865
+ }
40866
+ } catch (err) {
40867
+ console.error(err);
40868
+ }
40869
+ return void 0;
40870
+ }
40871
+ function shouldSendHeartbeat(inp) {
40872
+ if (inp?.hook_event_name === "Stop") {
40873
+ return true;
40874
+ }
40875
+ try {
40876
+ const last = JSON.parse(fs2.readFileSync(STATE_FILE, "utf-8")).lastHeartbeatAt ?? timestamp();
40877
+ return timestamp() - last >= 60;
40878
+ } catch {
40879
+ return true;
40880
+ }
40881
+ }
40882
+ function updateState() {
40883
+ fs2.mkdirSync(import_path2.default.dirname(STATE_FILE), { recursive: true });
40884
+ fs2.writeFileSync(STATE_FILE, JSON.stringify({ lastHeartbeatAt: timestamp() }, null, 2));
40885
+ }
40886
+ function getEntityFiles(inp) {
40887
+ const entities = /* @__PURE__ */ new Map();
40888
+ let claudeVersion = "";
40889
+ const transcriptPath = inp?.transcript_path;
40890
+ if (!transcriptPath || !fs2.existsSync(transcriptPath)) {
40891
+ return { entities, claudeVersion };
40892
+ }
40893
+ const lastHeartbeatAt = getLastHeartbeat();
40894
+ const content = fs2.readFileSync(transcriptPath, "utf-8");
40895
+ for (const logLine of content.split("\n")) {
40896
+ if (!logLine.trim()) continue;
40897
+ try {
40898
+ const log = JSON.parse(logLine);
40899
+ if (!log.timestamp) continue;
40900
+ if (log.version) claudeVersion = log.version;
40901
+ const timestamp2 = new Date(log.timestamp).getTime() / 1e3;
40902
+ if (timestamp2 < lastHeartbeatAt) continue;
40903
+ const filePath = log.toolUseResult?.filePath;
40904
+ if (!filePath) continue;
40905
+ const patches = log.toolUseResult?.structuredPatch;
40906
+ if (!patches) continue;
40907
+ const lineChanges = patches.map((patch) => patch.newLines - patch.oldLines).reduce((p, c) => p + c, 0);
40908
+ entities.set(filePath, (entities.get(filePath) ?? 0) + lineChanges);
40909
+ } catch (err) {
40910
+ logger.warnException(err);
40911
+ }
40912
+ }
40913
+ return { entities, claudeVersion };
40914
+ }
40915
+ function formatArguments(binary, args) {
40916
+ let clone = args.slice(0);
40917
+ clone.unshift(wrapArg(binary));
40918
+ let newCmds = [];
40919
+ let lastCmd = "";
40920
+ for (let i = 0; i < clone.length; i++) {
40921
+ if (lastCmd == "--key") newCmds.push(wrapArg(obfuscateKey(clone[i])));
40922
+ else newCmds.push(wrapArg(clone[i]));
40923
+ lastCmd = clone[i];
40924
+ }
40925
+ return newCmds.join(" ");
40926
+ }
40927
+ function isWindows() {
40928
+ return os2.platform() === "win32";
40929
+ }
40930
+ function getHomeDirectory() {
40931
+ let home = process.env.WAKATIME_HOME;
40932
+ if (home && home.trim() && fs2.existsSync(home.trim())) return home.trim();
40933
+ return process.env[isWindows() ? "USERPROFILE" : "HOME"] || process.cwd();
40934
+ }
40935
+ function buildOptions(stdin) {
40936
+ const options2 = {
40937
+ windowsHide: true
40938
+ };
40939
+ if (stdin) {
40940
+ options2.stdio = ["pipe", "pipe", "pipe"];
40941
+ }
40942
+ if (!isWindows() && !process.env.WAKATIME_HOME && !process.env.HOME) {
40943
+ options2["env"] = { ...process.env, WAKATIME_HOME: getHomeDirectory() };
40944
+ }
40945
+ return options2;
40946
+ }
40947
+ function getLastHeartbeat() {
40948
+ try {
40949
+ const stateData = JSON.parse(fs2.readFileSync(STATE_FILE, "utf-8"));
40950
+ return stateData.lastHeartbeatAt ?? 0;
40951
+ } catch {
40952
+ return 0;
40953
+ }
40954
+ }
40955
+ function timestamp() {
40956
+ return Date.now() / 1e3;
40957
+ }
40958
+ function wrapArg(arg) {
40959
+ if (arg.indexOf(" ") > -1) return '"' + arg.replace(/"/g, '\\"') + '"';
40960
+ return arg;
40961
+ }
40962
+ function obfuscateKey(key) {
40963
+ let newKey = "";
40964
+ if (key) {
40965
+ newKey = key;
40966
+ if (key.length > 4) newKey = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX" + key.substring(key.length - 4);
40967
+ }
40968
+ return newKey;
40969
+ }
40867
40970
 
40868
40971
  // src/options.ts
40869
40972
  var Options = class {
40870
40973
  constructor() {
40871
- const home = Utils.getHomeDirectory();
40872
- const wakaFolder = path.join(home, ".wakatime");
40974
+ const home = getHomeDirectory();
40975
+ const wakaFolder = path3.join(home, ".wakatime");
40873
40976
  try {
40874
- if (!fs2.existsSync(wakaFolder)) {
40875
- fs2.mkdirSync(wakaFolder, { recursive: true });
40977
+ if (!fs3.existsSync(wakaFolder)) {
40978
+ fs3.mkdirSync(wakaFolder, { recursive: true });
40876
40979
  }
40877
40980
  this.resourcesLocation = wakaFolder;
40878
40981
  } catch (e) {
40879
40982
  console.error(e);
40880
40983
  throw e;
40881
40984
  }
40882
- this.configFile = path.join(home, ".wakatime.cfg");
40883
- this.internalConfigFile = path.join(this.resourcesLocation, "wakatime-internal.cfg");
40884
- this.logFile = path.join(this.resourcesLocation, "wakatime.log");
40985
+ this.configFile = path3.join(home, ".wakatime.cfg");
40986
+ this.internalConfigFile = path3.join(this.resourcesLocation, "wakatime-internal.cfg");
40987
+ this.logFile = path3.join(this.resourcesLocation, "wakatime.log");
40885
40988
  }
40886
40989
  getSetting(section, key, internal) {
40887
- const content = fs2.readFileSync(this.getConfigFile(internal ?? false), "utf-8");
40990
+ const content = fs3.readFileSync(this.getConfigFile(internal ?? false), "utf-8");
40888
40991
  if (content.trim()) {
40889
40992
  let currentSection = "";
40890
40993
  let lines = content.split("\n");
@@ -40905,7 +41008,7 @@ var Options = class {
40905
41008
  }
40906
41009
  setSetting(section, key, val, internal) {
40907
41010
  const configFile = this.getConfigFile(internal);
40908
- fs2.readFile(configFile, "utf-8", (err, content) => {
41011
+ fs3.readFile(configFile, "utf-8", (err, content) => {
40909
41012
  if (err) content = "";
40910
41013
  let contents = [];
40911
41014
  let currentSection = "";
@@ -40941,14 +41044,14 @@ var Options = class {
40941
41044
  }
40942
41045
  contents.push(this.removeNulls(key + " = " + val));
40943
41046
  }
40944
- fs2.writeFile(configFile, contents.join("\n"), (err2) => {
41047
+ fs3.writeFile(configFile, contents.join("\n"), (err2) => {
40945
41048
  if (err2) throw err2;
40946
41049
  });
40947
41050
  });
40948
41051
  }
40949
41052
  setSettings(section, settings, internal) {
40950
41053
  const configFile = this.getConfigFile(internal);
40951
- fs2.readFile(configFile, "utf-8", (err, content) => {
41054
+ fs3.readFile(configFile, "utf-8", (err, content) => {
40952
41055
  if (err) content = "";
40953
41056
  let contents = [];
40954
41057
  let currentSection = "";
@@ -40997,7 +41100,7 @@ var Options = class {
40997
41100
  found[setting.key] = true;
40998
41101
  }
40999
41102
  });
41000
- fs2.writeFile(configFile, contents.join("\n"), (err2) => {
41103
+ fs3.writeFile(configFile, contents.join("\n"), (err2) => {
41001
41104
  if (err2) throw err2;
41002
41105
  });
41003
41106
  });
@@ -41020,14 +41123,14 @@ var Options = class {
41020
41123
  };
41021
41124
 
41022
41125
  // src/version.ts
41023
- var VERSION = "3.0.1";
41126
+ var VERSION = "3.0.2";
41024
41127
 
41025
41128
  // src/dependencies.ts
41026
41129
  var import_adm_zip = __toESM(require_adm_zip());
41027
41130
  var child_process = __toESM(require("child_process"));
41028
- var fs3 = __toESM(require("fs"));
41029
- var os2 = __toESM(require("os"));
41030
- var path2 = __toESM(require("path"));
41131
+ var fs4 = __toESM(require("fs"));
41132
+ var os3 = __toESM(require("os"));
41133
+ var path4 = __toESM(require("path"));
41031
41134
  var request = __toESM(require_request3());
41032
41135
  var semver = __toESM(require_semver2());
41033
41136
  var which = __toESM(require_lib6());
@@ -41051,14 +41154,14 @@ var Dependencies = class {
41051
41154
  if (this.cliLocation) return this.cliLocation;
41052
41155
  const osname = this.osName();
41053
41156
  const arch2 = this.architecture();
41054
- const ext = Utils.isWindows() ? ".exe" : "";
41157
+ const ext = isWindows() ? ".exe" : "";
41055
41158
  const binary = `wakatime-cli-${osname}-${arch2}${ext}`;
41056
- this.cliLocation = path2.join(this.resourcesLocation, binary);
41159
+ this.cliLocation = path4.join(this.resourcesLocation, binary);
41057
41160
  return this.cliLocation;
41058
41161
  }
41059
41162
  getCliLocationGlobal() {
41060
41163
  if (this.cliLocationGlobal) return this.cliLocationGlobal;
41061
- const binaryName = `wakatime-cli${Utils.isWindows() ? ".exe" : ""}`;
41164
+ const binaryName = `wakatime-cli${isWindows() ? ".exe" : ""}`;
41062
41165
  const path5 = which.sync(binaryName, { nothrow: true });
41063
41166
  if (path5) {
41064
41167
  this.cliLocationGlobal = path5;
@@ -41068,7 +41171,7 @@ var Dependencies = class {
41068
41171
  }
41069
41172
  isCliInstalled() {
41070
41173
  if (this.cliInstalled) return true;
41071
- this.cliInstalled = fs3.existsSync(this.getCliLocation());
41174
+ this.cliInstalled = fs4.existsSync(this.getCliLocation());
41072
41175
  return this.cliInstalled;
41073
41176
  }
41074
41177
  checkAndInstallCli(callback) {
@@ -41092,10 +41195,10 @@ var Dependencies = class {
41092
41195
  return;
41093
41196
  }
41094
41197
  let args = ["--version"];
41095
- const options2 = Utils.buildOptions();
41198
+ const options2 = buildOptions();
41096
41199
  try {
41097
41200
  child_process.execFile(this.getCliLocation(), args, options2, (error, _stdout, stderr) => {
41098
- if (!(error != null)) {
41201
+ if (!error) {
41099
41202
  let currentVersion = _stdout.toString().trim() + stderr.toString().trim();
41100
41203
  this.logger.debug(`Current wakatime-cli version is ${currentVersion}`);
41101
41204
  if (currentVersion === "<local-build>") {
@@ -41178,7 +41281,7 @@ var Dependencies = class {
41178
41281
  installCli(callback) {
41179
41282
  this.logger.debug(`Downloading wakatime-cli from GitHub...`);
41180
41283
  const url = this.cliDownloadUrl();
41181
- let zipFile = path2.join(this.resourcesLocation, "wakatime-cli" + this.randStr() + ".zip");
41284
+ let zipFile = path4.join(this.resourcesLocation, "wakatime-cli" + this.randStr() + ".zip");
41182
41285
  this.downloadFile(
41183
41286
  url,
41184
41287
  zipFile,
@@ -41190,7 +41293,7 @@ var Dependencies = class {
41190
41293
  }
41191
41294
  isSymlink(file) {
41192
41295
  try {
41193
- return fs3.lstatSync(file).isSymbolicLink();
41296
+ return fs4.lstatSync(file).isSymbolicLink();
41194
41297
  } catch (_) {
41195
41298
  }
41196
41299
  return false;
@@ -41201,26 +41304,26 @@ var Dependencies = class {
41201
41304
  this.unzip(zipFile, this.resourcesLocation, (unzipped) => {
41202
41305
  if (!unzipped) {
41203
41306
  this.restoreCli();
41204
- } else if (!Utils.isWindows()) {
41307
+ } else if (!isWindows()) {
41205
41308
  this.removeCli();
41206
41309
  const cli = this.getCliLocation();
41207
41310
  try {
41208
41311
  this.logger.debug("Chmod 755 wakatime-cli...");
41209
- fs3.chmodSync(cli, 493);
41312
+ fs4.chmodSync(cli, 493);
41210
41313
  } catch (e) {
41211
41314
  this.logger.warnException(e);
41212
41315
  }
41213
- const ext = Utils.isWindows() ? ".exe" : "";
41214
- const link = path2.join(this.resourcesLocation, `wakatime-cli${ext}`);
41316
+ const ext = isWindows() ? ".exe" : "";
41317
+ const link = path4.join(this.resourcesLocation, `wakatime-cli${ext}`);
41215
41318
  if (!this.isSymlink(link)) {
41216
41319
  try {
41217
41320
  this.logger.debug(`Create symlink from wakatime-cli to ${cli}`);
41218
- fs3.symlinkSync(cli, link);
41321
+ fs4.symlinkSync(cli, link);
41219
41322
  } catch (e) {
41220
41323
  this.logger.warnException(e);
41221
41324
  try {
41222
- fs3.copyFileSync(cli, link);
41223
- fs3.chmodSync(link, 493);
41325
+ fs4.copyFileSync(cli, link);
41326
+ fs4.chmodSync(link, 493);
41224
41327
  } catch (e2) {
41225
41328
  this.logger.warnException(e2);
41226
41329
  }
@@ -41232,20 +41335,20 @@ var Dependencies = class {
41232
41335
  this.logger.debug("Finished extracting wakatime-cli.");
41233
41336
  }
41234
41337
  backupCli() {
41235
- if (fs3.existsSync(this.getCliLocation())) {
41236
- fs3.renameSync(this.getCliLocation(), `${this.getCliLocation()}.backup`);
41338
+ if (fs4.existsSync(this.getCliLocation())) {
41339
+ fs4.renameSync(this.getCliLocation(), `${this.getCliLocation()}.backup`);
41237
41340
  }
41238
41341
  }
41239
41342
  restoreCli() {
41240
41343
  const backup = `${this.getCliLocation()}.backup`;
41241
- if (fs3.existsSync(backup)) {
41242
- fs3.renameSync(backup, this.getCliLocation());
41344
+ if (fs4.existsSync(backup)) {
41345
+ fs4.renameSync(backup, this.getCliLocation());
41243
41346
  }
41244
41347
  }
41245
41348
  removeCli() {
41246
41349
  const backup = `${this.getCliLocation()}.backup`;
41247
- if (fs3.existsSync(backup)) {
41248
- fs3.unlinkSync(backup);
41350
+ if (fs4.existsSync(backup)) {
41351
+ fs4.unlinkSync(backup);
41249
41352
  }
41250
41353
  }
41251
41354
  downloadFile(url, outputFile, callback, error) {
@@ -41264,7 +41367,7 @@ var Dependencies = class {
41264
41367
  this.logger.warn(e.toString());
41265
41368
  error();
41266
41369
  });
41267
- let out = fs3.createWriteStream(outputFile);
41370
+ let out = fs4.createWriteStream(outputFile);
41268
41371
  r.pipe(out);
41269
41372
  r.on("end", () => {
41270
41373
  out.on("finish", () => {
@@ -41273,22 +41376,22 @@ var Dependencies = class {
41273
41376
  });
41274
41377
  } catch (e) {
41275
41378
  this.logger.warnException(e);
41276
- callback();
41379
+ error();
41277
41380
  }
41278
41381
  }
41279
41382
  unzip(file, outputDir, callback) {
41280
- if (fs3.existsSync(file)) {
41383
+ if (fs4.existsSync(file)) {
41281
41384
  try {
41282
41385
  let zip = new import_adm_zip.default(file);
41283
41386
  zip.extractAllTo(outputDir, true);
41284
- fs3.unlinkSync(file);
41387
+ fs4.unlinkSync(file);
41285
41388
  callback(true);
41286
41389
  return;
41287
41390
  } catch (e) {
41288
41391
  this.logger.warnException(e);
41289
41392
  }
41290
41393
  try {
41291
- fs3.unlinkSync(file);
41394
+ fs4.unlinkSync(file);
41292
41395
  } catch (e2) {
41293
41396
  this.logger.warnException(e2);
41294
41397
  }
@@ -41301,7 +41404,7 @@ var Dependencies = class {
41301
41404
  if (!legacyOS) return;
41302
41405
  const version = legacyOS.find((spec) => {
41303
41406
  try {
41304
- return semver.lt(os2.release(), spec.kernelLessThan);
41407
+ return semver.lt(os3.release(), spec.kernelLessThan);
41305
41408
  } catch (e) {
41306
41409
  return false;
41307
41410
  }
@@ -41309,13 +41412,13 @@ var Dependencies = class {
41309
41412
  return version?.tag;
41310
41413
  }
41311
41414
  architecture() {
41312
- const arch2 = os2.arch();
41415
+ const arch2 = os3.arch();
41313
41416
  if (arch2.indexOf("32") > -1) return "386";
41314
41417
  if (arch2.indexOf("x64") > -1) return "amd64";
41315
41418
  return arch2;
41316
41419
  }
41317
41420
  osName() {
41318
- let osname = os2.platform();
41421
+ let osname = os3.platform();
41319
41422
  if (osname == "win32") osname = "windows";
41320
41423
  return osname;
41321
41424
  }
@@ -41369,214 +41472,16 @@ var Dependencies = class {
41369
41472
  }
41370
41473
  };
41371
41474
 
41372
- // src/logger.ts
41373
- var import_fs = __toESM(require("fs"));
41374
- var import_path = __toESM(require("path"));
41375
- var import_os = __toESM(require("os"));
41376
- var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
41377
- LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
41378
- LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
41379
- LogLevel2[LogLevel2["WARN"] = 2] = "WARN";
41380
- LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
41381
- return LogLevel2;
41382
- })(LogLevel || {});
41383
- var LOG_FILE = import_path.default.join(import_os.default.homedir(), ".wakatime", "claude-code.log");
41384
- var Logger = class {
41385
- constructor(level) {
41386
- this.level = 1 /* INFO */;
41387
- if (level !== void 0) this.setLevel(level);
41388
- }
41389
- getLevel() {
41390
- return this.level;
41391
- }
41392
- setLevel(level) {
41393
- this.level = level;
41394
- }
41395
- log(level, msg) {
41396
- if (level >= this.level) {
41397
- msg = `[${(/* @__PURE__ */ new Date()).toISOString()}][${LogLevel[level]}] ${msg}
41398
- `;
41399
- import_fs.default.mkdirSync(import_path.default.dirname(LOG_FILE), { recursive: true });
41400
- import_fs.default.appendFileSync(LOG_FILE, msg);
41401
- }
41402
- }
41403
- debug(msg) {
41404
- this.log(0 /* DEBUG */, msg);
41405
- }
41406
- debugException(msg) {
41407
- if (msg.message !== void 0) {
41408
- this.log(0 /* DEBUG */, msg.message);
41409
- } else {
41410
- this.log(0 /* DEBUG */, msg.toString());
41411
- }
41412
- }
41413
- info(msg) {
41414
- this.log(1 /* INFO */, msg);
41415
- }
41416
- warn(msg) {
41417
- this.log(2 /* WARN */, msg);
41418
- }
41419
- warnException(msg) {
41420
- if (msg.message !== void 0) {
41421
- this.log(2 /* WARN */, msg.message);
41422
- } else {
41423
- this.log(2 /* WARN */, msg.toString());
41424
- }
41425
- }
41426
- error(msg) {
41427
- this.log(3 /* ERROR */, msg);
41428
- }
41429
- errorException(msg) {
41430
- if (msg.message !== void 0) {
41431
- this.log(3 /* ERROR */, msg.message);
41432
- } else {
41433
- this.log(3 /* ERROR */, msg.toString());
41434
- }
41435
- }
41436
- };
41437
-
41438
41475
  // src/index.ts
41439
- var STATE_FILE = import_path2.default.join(import_os2.default.homedir(), ".wakatime", "claude-code.json");
41440
- var logger = new Logger();
41441
41476
  var options = new Options();
41442
41477
  var deps = new Dependencies(options, logger);
41443
- function shouldSendHeartbeat(inp) {
41444
- if (inp?.hook_event_name === "Stop") {
41445
- return true;
41446
- }
41447
- try {
41448
- const last = JSON.parse(import_fs2.default.readFileSync(STATE_FILE, "utf-8")).lastHeartbeatAt ?? Utils.timestamp();
41449
- return Utils.timestamp() - last >= 60;
41450
- } catch {
41451
- return true;
41452
- }
41453
- }
41454
- function parseInput() {
41455
- try {
41456
- const stdinData = import_fs2.default.readFileSync(0, "utf-8");
41457
- if (stdinData.trim()) {
41458
- const input = JSON.parse(stdinData);
41459
- return input;
41460
- }
41461
- } catch (err) {
41462
- console.error(err);
41463
- }
41464
- return void 0;
41465
- }
41466
- function getLastHeartbeat() {
41467
- try {
41468
- const stateData = JSON.parse(import_fs2.default.readFileSync(STATE_FILE, "utf-8"));
41469
- return stateData.lastHeartbeatAt ?? 0;
41470
- } catch {
41471
- return 0;
41472
- }
41473
- }
41474
- function getModifiedFile(transcriptPath) {
41475
- try {
41476
- if (!transcriptPath || !import_fs2.default.existsSync(transcriptPath)) {
41477
- return void 0;
41478
- }
41479
- const content = import_fs2.default.readFileSync(transcriptPath, "utf-8");
41480
- const lines = content.split("\n");
41481
- const fileLineChanges = /* @__PURE__ */ new Map();
41482
- const lastHeartbeatAt = getLastHeartbeat();
41483
- for (const line of lines) {
41484
- if (line.trim()) {
41485
- try {
41486
- const logEntry = JSON.parse(line);
41487
- if (!logEntry.timestamp) continue;
41488
- const entryTimestamp = new Date(logEntry.timestamp).getTime() / 1e3;
41489
- if (entryTimestamp >= lastHeartbeatAt) {
41490
- let filePath;
41491
- if (logEntry.toolUse?.parameters?.file_path) {
41492
- filePath = logEntry.toolUse.parameters.file_path;
41493
- }
41494
- if (logEntry.toolUse?.parameters?.edits) {
41495
- filePath = logEntry.toolUse.parameters.file_path;
41496
- }
41497
- if (logEntry.toolUseResult?.structuredPatch) {
41498
- const patches = logEntry.toolUseResult.structuredPatch;
41499
- for (const patch of patches) {
41500
- if (patch.file) {
41501
- filePath = patch.file;
41502
- if (patch.newLines !== void 0 && patch.oldLines !== void 0) {
41503
- const lineChanges = Math.abs(patch.newLines - patch.oldLines);
41504
- fileLineChanges.set(filePath, (fileLineChanges.get(filePath) || 0) + lineChanges);
41505
- }
41506
- }
41507
- }
41508
- }
41509
- if (filePath && !fileLineChanges.has(filePath)) {
41510
- fileLineChanges.set(filePath, 0);
41511
- }
41512
- }
41513
- } catch {
41514
- }
41515
- }
41516
- }
41517
- if (fileLineChanges.size === 0) {
41518
- return void 0;
41519
- }
41520
- let maxChanges = 0;
41521
- let mostChangedFile;
41522
- for (const [file, changes] of fileLineChanges.entries()) {
41523
- if (changes > maxChanges) {
41524
- maxChanges = changes;
41525
- mostChangedFile = file;
41526
- }
41527
- }
41528
- return mostChangedFile;
41529
- } catch {
41530
- return void 0;
41531
- }
41532
- }
41533
- function calculateLineChanges(transcriptPath) {
41534
- try {
41535
- if (!transcriptPath || !import_fs2.default.existsSync(transcriptPath)) {
41536
- return 0;
41537
- }
41538
- const content = import_fs2.default.readFileSync(transcriptPath, "utf-8");
41539
- const lines = content.split("\n");
41540
- let totalLineChanges = 0;
41541
- const lastHeartbeatAt = getLastHeartbeat();
41542
- for (const line of lines) {
41543
- if (line.trim()) {
41544
- try {
41545
- const logEntry = JSON.parse(line);
41546
- if (logEntry.timestamp && logEntry.toolUseResult?.structuredPatch) {
41547
- const entryTimestamp = new Date(logEntry.timestamp).getTime() / 1e3;
41548
- if (entryTimestamp >= lastHeartbeatAt) {
41549
- const patches = logEntry.toolUseResult.structuredPatch;
41550
- for (const patch of patches) {
41551
- if (patch.newLines !== void 0 && patch.oldLines !== void 0) {
41552
- totalLineChanges += patch.newLines - patch.oldLines;
41553
- }
41554
- }
41555
- }
41556
- }
41557
- } catch {
41558
- }
41559
- }
41560
- }
41561
- return totalLineChanges;
41562
- } catch {
41563
- return 0;
41564
- }
41565
- }
41566
- function updateState() {
41567
- import_fs2.default.mkdirSync(import_path2.default.dirname(STATE_FILE), { recursive: true });
41568
- import_fs2.default.writeFileSync(STATE_FILE, JSON.stringify({ lastHeartbeatAt: Utils.timestamp() }, null, 2));
41569
- }
41570
- function getEntityFile(inp) {
41571
- if (!inp?.transcript_path) return;
41572
- return getModifiedFile(inp.transcript_path);
41573
- }
41574
41478
  function sendHeartbeat(inp) {
41575
41479
  const projectFolder = inp?.cwd;
41576
- try {
41577
- const entity = getEntityFile(inp);
41578
- if (!entity) return;
41579
- const wakatime_cli = deps.getCliLocation();
41480
+ const { entities, claudeVersion } = getEntityFiles(inp);
41481
+ if (entities.size === 0) return false;
41482
+ const wakatime_cli = deps.getCliLocation();
41483
+ for (const [entity, lineChanges] of entities.entries()) {
41484
+ logger.debug(`Entity: ${entity}`);
41580
41485
  const args = [
41581
41486
  "--entity",
41582
41487
  entity,
@@ -41585,44 +41490,40 @@ function sendHeartbeat(inp) {
41585
41490
  "--category",
41586
41491
  "ai coding",
41587
41492
  "--plugin",
41588
- `claude-code-wakatime/${VERSION}`
41493
+ `claude/${claudeVersion} claude-code-wakatime/${VERSION}`
41589
41494
  ];
41590
41495
  if (projectFolder) {
41591
41496
  args.push("--project-folder");
41592
41497
  args.push(projectFolder);
41593
41498
  }
41594
- if (inp?.transcript_path) {
41595
- const lineChanges = calculateLineChanges(inp.transcript_path);
41596
- if (lineChanges) {
41597
- args.push("--ai-line-changes");
41598
- args.push(lineChanges.toString());
41599
- }
41499
+ if (lineChanges) {
41500
+ args.push("--ai-line-changes");
41501
+ args.push(lineChanges.toString());
41600
41502
  }
41601
- logger.debug(`Sending heartbeat: ${wakatime_cli} ${args}`);
41602
- const execOptions = Utils.buildOptions();
41503
+ logger.debug(`Sending heartbeat: ${formatArguments(wakatime_cli, args)}`);
41504
+ const execOptions = buildOptions();
41603
41505
  (0, import_child_process.execFile)(wakatime_cli, args, execOptions, (error, stdout, stderr) => {
41604
41506
  const output = stdout.toString().trim() + stderr.toString().trim();
41605
41507
  if (output) logger.error(output);
41606
41508
  if (error) logger.error(error.toString());
41607
41509
  });
41608
- } catch (err) {
41609
- logger.errorException(err);
41610
41510
  }
41511
+ return true;
41611
41512
  }
41612
41513
  function main() {
41613
41514
  const inp = parseInput();
41614
41515
  const debug = options.getSetting("settings", "debug");
41615
41516
  logger.setLevel(debug === "true" ? 0 /* DEBUG */ : 1 /* INFO */);
41616
- if (inp) {
41617
- try {
41618
- logger.debug(JSON.stringify(inp, null, 2));
41619
- } catch (err) {
41517
+ try {
41518
+ if (inp) logger.debug(JSON.stringify(inp, null, 2));
41519
+ deps.checkAndInstallCli();
41520
+ if (shouldSendHeartbeat(inp)) {
41521
+ if (sendHeartbeat(inp)) {
41522
+ updateState();
41523
+ }
41620
41524
  }
41621
- }
41622
- deps.checkAndInstallCli();
41623
- if (shouldSendHeartbeat(inp)) {
41624
- sendHeartbeat(inp);
41625
- updateState();
41525
+ } catch (err) {
41526
+ logger.errorException(err);
41626
41527
  }
41627
41528
  }
41628
41529
  main();