prettier 4.0.0-alpha.10 → 4.0.0-alpha.11

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/internal/cli.mjs CHANGED
@@ -59,12 +59,12 @@ var require_dashify = __commonJS({
59
59
  var require_minimist = __commonJS({
60
60
  "node_modules/minimist/index.js"(exports, module) {
61
61
  "use strict";
62
- function hasKey(obj, keys) {
62
+ function hasKey(obj, keys2) {
63
63
  var o = obj;
64
- keys.slice(0, -1).forEach(function(key2) {
64
+ keys2.slice(0, -1).forEach(function(key2) {
65
65
  o = o[key2] || {};
66
66
  });
67
- var key = keys[keys.length - 1];
67
+ var key = keys2[keys2.length - 1];
68
68
  return key in o;
69
69
  }
70
70
  function isNumber(x) {
@@ -125,10 +125,10 @@ var require_minimist = __commonJS({
125
125
  function argDefined(key2, arg2) {
126
126
  return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
127
127
  }
128
- function setKey(obj, keys, value2) {
128
+ function setKey(obj, keys2, value2) {
129
129
  var o = obj;
130
- for (var i2 = 0; i2 < keys.length - 1; i2++) {
131
- var key2 = keys[i2];
130
+ for (var i2 = 0; i2 < keys2.length - 1; i2++) {
131
+ var key2 = keys2[i2];
132
132
  if (isConstructorOrProto(o, key2)) {
133
133
  return;
134
134
  }
@@ -143,7 +143,7 @@ var require_minimist = __commonJS({
143
143
  }
144
144
  o = o[key2];
145
145
  }
146
- var lastKey = keys[keys.length - 1];
146
+ var lastKey = keys2[keys2.length - 1];
147
147
  if (isConstructorOrProto(o, lastKey)) {
148
148
  return;
149
149
  }
@@ -295,7 +295,7 @@ var require_fast_json_stable_stringify = __commonJS({
295
295
  };
296
296
  }(opts.cmp);
297
297
  var seen = [];
298
- return function stringify4(node) {
298
+ return function stringify5(node) {
299
299
  if (node && node.toJSON && typeof node.toJSON === "function") {
300
300
  node = node.toJSON();
301
301
  }
@@ -307,7 +307,7 @@ var require_fast_json_stable_stringify = __commonJS({
307
307
  out = "[";
308
308
  for (i = 0; i < node.length; i++) {
309
309
  if (i) out += ",";
310
- out += stringify4(node[i]) || "null";
310
+ out += stringify5(node[i]) || "null";
311
311
  }
312
312
  return out + "]";
313
313
  }
@@ -317,11 +317,11 @@ var require_fast_json_stable_stringify = __commonJS({
317
317
  throw new TypeError("Converting circular structure to JSON");
318
318
  }
319
319
  var seenIndex = seen.push(node) - 1;
320
- var keys = Object.keys(node).sort(cmp && cmp(node));
320
+ var keys2 = Object.keys(node).sort(cmp && cmp(node));
321
321
  out = "";
322
- for (i = 0; i < keys.length; i++) {
323
- var key = keys[i];
324
- var value = stringify4(node[key]);
322
+ for (i = 0; i < keys2.length; i++) {
323
+ var key = keys2[i];
324
+ var value = stringify5(node[key]);
325
325
  if (!value) continue;
326
326
  if (out) out += ",";
327
327
  out += JSON.stringify(key) + ":" + value;
@@ -339,8 +339,8 @@ var require_common_path_prefix = __commonJS({
339
339
  "use strict";
340
340
  var { sep: DEFAULT_SEPARATOR } = __require("path");
341
341
  var determineSeparator = (paths) => {
342
- for (const path10 of paths) {
343
- const match = /(\/|\\)/.exec(path10);
342
+ for (const path12 of paths) {
343
+ const match = /(\/|\\)/.exec(path12);
344
344
  if (match !== null) return match[0];
345
345
  }
346
346
  return DEFAULT_SEPARATOR;
@@ -350,8 +350,8 @@ var require_common_path_prefix = __commonJS({
350
350
  if (first === "" || remaining.length === 0) return "";
351
351
  const parts = first.split(sep);
352
352
  let endOfPrefix = parts.length;
353
- for (const path10 of remaining) {
354
- const compare = path10.split(sep);
353
+ for (const path12 of remaining) {
354
+ const compare = path12.split(sep);
355
355
  for (let i = 0; i < endOfPrefix; i++) {
356
356
  if (compare[i] !== parts[i]) {
357
357
  endOfPrefix = i;
@@ -365,1090 +365,18 @@ var require_common_path_prefix = __commonJS({
365
365
  }
366
366
  });
367
367
 
368
- // node_modules/json-buffer/index.js
369
- var require_json_buffer = __commonJS({
370
- "node_modules/json-buffer/index.js"(exports) {
371
- exports.stringify = function stringify4(o) {
372
- if ("undefined" == typeof o) return o;
373
- if (o && Buffer.isBuffer(o))
374
- return JSON.stringify(":base64:" + o.toString("base64"));
375
- if (o && o.toJSON)
376
- o = o.toJSON();
377
- if (o && "object" === typeof o) {
378
- var s = "";
379
- var array2 = Array.isArray(o);
380
- s = array2 ? "[" : "{";
381
- var first = true;
382
- for (var k in o) {
383
- var ignore = "function" == typeof o[k] || !array2 && "undefined" === typeof o[k];
384
- if (Object.hasOwnProperty.call(o, k) && !ignore) {
385
- if (!first)
386
- s += ",";
387
- first = false;
388
- if (array2) {
389
- if (o[k] == void 0)
390
- s += "null";
391
- else
392
- s += stringify4(o[k]);
393
- } else if (o[k] !== void 0) {
394
- s += stringify4(k) + ":" + stringify4(o[k]);
395
- }
396
- }
397
- }
398
- s += array2 ? "]" : "}";
399
- return s;
400
- } else if ("string" === typeof o) {
401
- return JSON.stringify(/^:/.test(o) ? ":" + o : o);
402
- } else if ("undefined" === typeof o) {
403
- return "null";
404
- } else
405
- return JSON.stringify(o);
406
- };
407
- exports.parse = function(s) {
408
- return JSON.parse(s, function(key, value) {
409
- if ("string" === typeof value) {
410
- if (/^:base64:/.test(value))
411
- return Buffer.from(value.substring(8), "base64");
412
- else
413
- return /^:/.test(value) ? value.substring(1) : value;
414
- }
415
- return value;
416
- });
417
- };
418
- }
419
- });
420
-
421
- // node_modules/keyv/src/index.js
422
- var require_src = __commonJS({
423
- "node_modules/keyv/src/index.js"(exports, module) {
424
- "use strict";
425
- var EventEmitter = __require("events");
426
- var JSONB = require_json_buffer();
427
- var loadStore = (options) => {
428
- const adapters = {
429
- redis: "@keyv/redis",
430
- rediss: "@keyv/redis",
431
- mongodb: "@keyv/mongo",
432
- mongo: "@keyv/mongo",
433
- sqlite: "@keyv/sqlite",
434
- postgresql: "@keyv/postgres",
435
- postgres: "@keyv/postgres",
436
- mysql: "@keyv/mysql",
437
- etcd: "@keyv/etcd",
438
- offline: "@keyv/offline",
439
- tiered: "@keyv/tiered"
440
- };
441
- if (options.adapter || options.uri) {
442
- const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0];
443
- return new (__require(adapters[adapter]))(options);
444
- }
445
- return /* @__PURE__ */ new Map();
446
- };
447
- var iterableAdapters = [
448
- "sqlite",
449
- "postgres",
450
- "mysql",
451
- "mongo",
452
- "redis",
453
- "tiered"
454
- ];
455
- var Keyv = class extends EventEmitter {
456
- constructor(uri, { emitErrors = true, ...options } = {}) {
457
- super();
458
- this.opts = {
459
- namespace: "keyv",
460
- serialize: JSONB.stringify,
461
- deserialize: JSONB.parse,
462
- ...typeof uri === "string" ? { uri } : uri,
463
- ...options
464
- };
465
- if (!this.opts.store) {
466
- const adapterOptions = { ...this.opts };
467
- this.opts.store = loadStore(adapterOptions);
468
- }
469
- if (this.opts.compression) {
470
- const compression = this.opts.compression;
471
- this.opts.serialize = compression.serialize.bind(compression);
472
- this.opts.deserialize = compression.deserialize.bind(compression);
473
- }
474
- if (typeof this.opts.store.on === "function" && emitErrors) {
475
- this.opts.store.on("error", (error) => this.emit("error", error));
476
- }
477
- this.opts.store.namespace = this.opts.namespace;
478
- const generateIterator = (iterator) => async function* () {
479
- for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
480
- const data = await this.opts.deserialize(raw);
481
- if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) {
482
- continue;
483
- }
484
- if (typeof data.expires === "number" && Date.now() > data.expires) {
485
- this.delete(key);
486
- continue;
487
- }
488
- yield [this._getKeyUnprefix(key), data.value];
489
- }
490
- };
491
- if (typeof this.opts.store[Symbol.iterator] === "function" && this.opts.store instanceof Map) {
492
- this.iterator = generateIterator(this.opts.store);
493
- } else if (typeof this.opts.store.iterator === "function" && this.opts.store.opts && this._checkIterableAdaptar()) {
494
- this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store));
495
- }
496
- }
497
- _checkIterableAdaptar() {
498
- return iterableAdapters.includes(this.opts.store.opts.dialect) || iterableAdapters.findIndex((element) => this.opts.store.opts.url.includes(element)) >= 0;
499
- }
500
- _getKeyPrefix(key) {
501
- return `${this.opts.namespace}:${key}`;
502
- }
503
- _getKeyPrefixArray(keys) {
504
- return keys.map((key) => `${this.opts.namespace}:${key}`);
505
- }
506
- _getKeyUnprefix(key) {
507
- return key.split(":").splice(1).join(":");
508
- }
509
- get(key, options) {
510
- const { store } = this.opts;
511
- const isArray = Array.isArray(key);
512
- const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
513
- if (isArray && store.getMany === void 0) {
514
- const promises = [];
515
- for (const key2 of keyPrefixed) {
516
- promises.push(
517
- Promise.resolve().then(() => store.get(key2)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
518
- if (data === void 0 || data === null) {
519
- return void 0;
520
- }
521
- if (typeof data.expires === "number" && Date.now() > data.expires) {
522
- return this.delete(key2).then(() => void 0);
523
- }
524
- return options && options.raw ? data : data.value;
525
- })
526
- );
527
- }
528
- return Promise.allSettled(promises).then((values) => {
529
- const data = [];
530
- for (const value of values) {
531
- data.push(value.value);
532
- }
533
- return data;
534
- });
535
- }
536
- return Promise.resolve().then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
537
- if (data === void 0 || data === null) {
538
- return void 0;
539
- }
540
- if (isArray) {
541
- return data.map((row, index) => {
542
- if (typeof row === "string") {
543
- row = this.opts.deserialize(row);
544
- }
545
- if (row === void 0 || row === null) {
546
- return void 0;
547
- }
548
- if (typeof row.expires === "number" && Date.now() > row.expires) {
549
- this.delete(key[index]).then(() => void 0);
550
- return void 0;
551
- }
552
- return options && options.raw ? row : row.value;
553
- });
554
- }
555
- if (typeof data.expires === "number" && Date.now() > data.expires) {
556
- return this.delete(key).then(() => void 0);
557
- }
558
- return options && options.raw ? data : data.value;
559
- });
560
- }
561
- set(key, value, ttl) {
562
- const keyPrefixed = this._getKeyPrefix(key);
563
- if (typeof ttl === "undefined") {
564
- ttl = this.opts.ttl;
565
- }
566
- if (ttl === 0) {
567
- ttl = void 0;
568
- }
569
- const { store } = this.opts;
570
- return Promise.resolve().then(() => {
571
- const expires = typeof ttl === "number" ? Date.now() + ttl : null;
572
- if (typeof value === "symbol") {
573
- this.emit("error", "symbol cannot be serialized");
574
- }
575
- value = { value, expires };
576
- return this.opts.serialize(value);
577
- }).then((value2) => store.set(keyPrefixed, value2, ttl)).then(() => true);
578
- }
579
- delete(key) {
580
- const { store } = this.opts;
581
- if (Array.isArray(key)) {
582
- const keyPrefixed2 = this._getKeyPrefixArray(key);
583
- if (store.deleteMany === void 0) {
584
- const promises = [];
585
- for (const key2 of keyPrefixed2) {
586
- promises.push(store.delete(key2));
587
- }
588
- return Promise.allSettled(promises).then((values) => values.every((x) => x.value === true));
589
- }
590
- return Promise.resolve().then(() => store.deleteMany(keyPrefixed2));
591
- }
592
- const keyPrefixed = this._getKeyPrefix(key);
593
- return Promise.resolve().then(() => store.delete(keyPrefixed));
594
- }
595
- clear() {
596
- const { store } = this.opts;
597
- return Promise.resolve().then(() => store.clear());
598
- }
599
- has(key) {
600
- const keyPrefixed = this._getKeyPrefix(key);
601
- const { store } = this.opts;
602
- return Promise.resolve().then(async () => {
603
- if (typeof store.has === "function") {
604
- return store.has(keyPrefixed);
605
- }
606
- const value = await store.get(keyPrefixed);
607
- return value !== void 0;
608
- });
609
- }
610
- disconnect() {
611
- const { store } = this.opts;
612
- if (typeof store.disconnect === "function") {
613
- return store.disconnect();
614
- }
615
- }
616
- };
617
- module.exports = Keyv;
618
- }
619
- });
620
-
621
- // node_modules/flatted/cjs/index.js
622
- var require_cjs = __commonJS({
623
- "node_modules/flatted/cjs/index.js"(exports) {
624
- "use strict";
625
- var { parse: $parse, stringify: $stringify } = JSON;
626
- var { keys } = Object;
627
- var Primitive = String;
628
- var primitive = "string";
629
- var ignore = {};
630
- var object = "object";
631
- var noop = (_, value) => value;
632
- var primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
633
- var Primitives = (_, value) => typeof value === primitive ? new Primitive(value) : value;
634
- var revive = (input, parsed, output, $) => {
635
- const lazy = [];
636
- for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
637
- const k = ke[y];
638
- const value = output[k];
639
- if (value instanceof Primitive) {
640
- const tmp = input[value];
641
- if (typeof tmp === object && !parsed.has(tmp)) {
642
- parsed.add(tmp);
643
- output[k] = ignore;
644
- lazy.push({ k, a: [input, parsed, tmp, $] });
645
- } else
646
- output[k] = $.call(output, k, tmp);
647
- } else if (output[k] !== ignore)
648
- output[k] = $.call(output, k, value);
649
- }
650
- for (let { length } = lazy, i = 0; i < length; i++) {
651
- const { k, a } = lazy[i];
652
- output[k] = $.call(output, k, revive.apply(null, a));
653
- }
654
- return output;
655
- };
656
- var set = (known, input, value) => {
657
- const index = Primitive(input.push(value) - 1);
658
- known.set(value, index);
659
- return index;
660
- };
661
- var parse = (text, reviver) => {
662
- const input = $parse(text, Primitives).map(primitives);
663
- const value = input[0];
664
- const $ = reviver || noop;
665
- const tmp = typeof value === object && value ? revive(input, /* @__PURE__ */ new Set(), value, $) : value;
666
- return $.call({ "": tmp }, "", tmp);
667
- };
668
- exports.parse = parse;
669
- var stringify4 = (value, replacer, space) => {
670
- const $ = replacer && typeof replacer === object ? (k, v) => k === "" || -1 < replacer.indexOf(k) ? v : void 0 : replacer || noop;
671
- const known = /* @__PURE__ */ new Map();
672
- const input = [];
673
- const output = [];
674
- let i = +set(known, input, $.call({ "": value }, "", value));
675
- let firstRun = !i;
676
- while (i < input.length) {
677
- firstRun = true;
678
- output[i] = $stringify(input[i++], replace, space);
679
- }
680
- return "[" + output.join(",") + "]";
681
- function replace(key, value2) {
682
- if (firstRun) {
683
- firstRun = !firstRun;
684
- return value2;
685
- }
686
- const after = $.call(this, key, value2);
687
- switch (typeof after) {
688
- case object:
689
- if (after === null) return after;
690
- case primitive:
691
- return known.get(after) || set(known, input, after);
692
- }
693
- return after;
694
- }
695
- };
696
- exports.stringify = stringify4;
697
- var toJSON = (value) => $parse(stringify4(value));
698
- exports.toJSON = toJSON;
699
- var fromJSON = (value) => parse($stringify(value));
700
- exports.fromJSON = fromJSON;
701
- }
702
- });
703
-
704
- // node_modules/flat-cache/src/utils.js
705
- var require_utils = __commonJS({
706
- "node_modules/flat-cache/src/utils.js"(exports, module) {
707
- var fs6 = __require("fs");
708
- var path10 = __require("path");
709
- var flatted = require_cjs();
710
- function tryParse(filePath, defaultValue) {
711
- let result;
712
- try {
713
- result = readJSON(filePath);
714
- } catch {
715
- result = defaultValue;
716
- }
717
- return result;
718
- }
719
- function readJSON(filePath) {
720
- return flatted.parse(
721
- fs6.readFileSync(filePath, {
722
- encoding: "utf8"
723
- })
724
- );
725
- }
726
- function writeJSON(filePath, data) {
727
- fs6.mkdirSync(path10.dirname(filePath), {
728
- recursive: true
729
- });
730
- fs6.writeFileSync(filePath, flatted.stringify(data));
731
- }
732
- module.exports = { tryParse, readJSON, writeJSON };
733
- }
734
- });
735
-
736
- // node_modules/flat-cache/src/del.js
737
- var require_del = __commonJS({
738
- "node_modules/flat-cache/src/del.js"(exports, module) {
739
- var fs6 = __require("fs");
740
- var path10 = __require("path");
741
- function del(targetPath) {
742
- if (!fs6.existsSync(targetPath)) {
743
- return false;
744
- }
745
- try {
746
- if (fs6.statSync(targetPath).isDirectory()) {
747
- for (const file of fs6.readdirSync(targetPath)) {
748
- const currentPath = path10.join(targetPath, file);
749
- if (fs6.statSync(currentPath).isFile()) {
750
- fs6.unlinkSync(currentPath);
751
- }
752
- }
753
- fs6.rmdirSync(targetPath);
754
- } else {
755
- fs6.unlinkSync(targetPath);
756
- }
757
- return true;
758
- } catch (error) {
759
- console.error(`Error while deleting ${targetPath}: ${error.message}`);
760
- }
761
- }
762
- module.exports = { del };
763
- }
764
- });
765
-
766
- // node_modules/flat-cache/src/cache.js
767
- var require_cache = __commonJS({
768
- "node_modules/flat-cache/src/cache.js"(exports, module) {
769
- var path10 = __require("path");
770
- var fs6 = __require("fs");
771
- var Keyv = require_src();
772
- var { writeJSON, tryParse } = require_utils();
773
- var { del } = require_del();
774
- var cache = {
775
- /**
776
- * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
777
- * cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
778
- * then the cache module directory `./cache` will be used instead
779
- *
780
- * @method load
781
- * @param docId {String} the id of the cache, would also be used as the name of the file cache
782
- * @param [cacheDir] {String} directory for the cache entry
783
- */
784
- load(documentId, cacheDir) {
785
- const me = this;
786
- me.keyv = new Keyv();
787
- me.__visited = {};
788
- me.__persisted = {};
789
- me._pathToFile = cacheDir ? path10.resolve(cacheDir, documentId) : path10.resolve(__dirname, "../.cache/", documentId);
790
- if (fs6.existsSync(me._pathToFile)) {
791
- me._persisted = tryParse(me._pathToFile, {});
792
- }
793
- },
794
- get _persisted() {
795
- return this.__persisted;
796
- },
797
- set _persisted(value) {
798
- this.__persisted = value;
799
- },
800
- get _visited() {
801
- return this.__visited;
802
- },
803
- set _visited(value) {
804
- this.__visited = value;
805
- },
806
- /**
807
- * Load the cache from the provided file
808
- * @method loadFile
809
- * @param {String} pathToFile the path to the file containing the info for the cache
810
- */
811
- loadFile(pathToFile) {
812
- const me = this;
813
- const dir = path10.dirname(pathToFile);
814
- const fName = path10.basename(pathToFile);
815
- me.load(fName, dir);
816
- },
817
- /**
818
- * Returns the entire persisted object
819
- * @method all
820
- * @returns {*}
821
- */
822
- all() {
823
- return this._persisted;
824
- },
825
- keys() {
826
- return Object.keys(this._persisted);
827
- },
828
- /**
829
- * Sets a key to a given value
830
- * @method setKey
831
- * @param key {string} the key to set
832
- * @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
833
- */
834
- setKey(key, value) {
835
- this._visited[key] = true;
836
- this._persisted[key] = value;
837
- },
838
- /**
839
- * Remove a given key from the cache
840
- * @method removeKey
841
- * @param key {String} the key to remove from the object
842
- */
843
- removeKey(key) {
844
- delete this._visited[key];
845
- delete this._persisted[key];
846
- },
847
- /**
848
- * Return the value of the provided key
849
- * @method getKey
850
- * @param key {String} the name of the key to retrieve
851
- * @returns {*} the value from the key
852
- */
853
- getKey(key) {
854
- this._visited[key] = true;
855
- return this._persisted[key];
856
- },
857
- /**
858
- * Remove keys that were not accessed/set since the
859
- * last time the `prune` method was called.
860
- * @method _prune
861
- * @private
862
- */
863
- _prune() {
864
- const me = this;
865
- const object = {};
866
- const keys = Object.keys(me._visited);
867
- if (keys.length === 0) {
868
- return;
869
- }
870
- for (const key of keys) {
871
- object[key] = me._persisted[key];
872
- }
873
- me._visited = {};
874
- me._persisted = object;
875
- },
876
- /**
877
- * Save the state of the cache identified by the docId to disk
878
- * as a JSON structure
879
- * @param [noPrune=false] {Boolean} whether to remove from cache the non visited files
880
- * @method save
881
- */
882
- save(noPrune) {
883
- const me = this;
884
- !noPrune && me._prune();
885
- writeJSON(me._pathToFile, me._persisted);
886
- },
887
- /**
888
- * Remove the file where the cache is persisted
889
- * @method removeCacheFile
890
- * @return {Boolean} true or false if the file was successfully deleted
891
- */
892
- removeCacheFile() {
893
- return del(this._pathToFile);
894
- },
895
- /**
896
- * Destroy the file cache and cache content.
897
- * @method destroy
898
- */
899
- destroy() {
900
- const me = this;
901
- me._visited = {};
902
- me._persisted = {};
903
- me.removeCacheFile();
904
- }
905
- };
906
- module.exports = {
907
- /**
908
- * Alias for create. Should be considered depreacted. Will be removed in next releases
909
- *
910
- * @method load
911
- * @param docId {String} the id of the cache, would also be used as the name of the file cache
912
- * @param [cacheDir] {String} directory for the cache entry
913
- * @returns {cache} cache instance
914
- */
915
- load(documentId, cacheDir) {
916
- return this.create(documentId, cacheDir);
917
- },
918
- /**
919
- * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
920
- * cache storage.
921
- *
922
- * @method create
923
- * @param docId {String} the id of the cache, would also be used as the name of the file cache
924
- * @param [cacheDir] {String} directory for the cache entry
925
- * @returns {cache} cache instance
926
- */
927
- create(documentId, cacheDir) {
928
- const object = Object.create(cache);
929
- object.load(documentId, cacheDir);
930
- return object;
931
- },
932
- createFromFile(filePath) {
933
- const object = Object.create(cache);
934
- object.loadFile(filePath);
935
- return object;
936
- },
937
- /**
938
- * Clear the cache identified by the given id. Caches stored in a different cache directory can be deleted directly
939
- *
940
- * @method clearCache
941
- * @param docId {String} the id of the cache, would also be used as the name of the file cache
942
- * @param cacheDir {String} the directory where the cache file was written
943
- * @returns {Boolean} true if the cache folder was deleted. False otherwise
944
- */
945
- clearCacheById(documentId, cacheDir) {
946
- const filePath = cacheDir ? path10.resolve(cacheDir, documentId) : path10.resolve(__dirname, "../.cache/", documentId);
947
- return del(filePath);
948
- },
949
- /**
950
- * Remove all cache stored in the cache directory
951
- * @method clearAll
952
- * @returns {Boolean} true if the cache folder was deleted. False otherwise
953
- */
954
- clearAll(cacheDir) {
955
- const filePath = cacheDir ? path10.resolve(cacheDir) : path10.resolve(__dirname, "../.cache/");
956
- return del(filePath);
957
- }
958
- };
959
- }
960
- });
961
-
962
- // node_modules/file-entry-cache/cache.js
963
- var require_cache2 = __commonJS({
964
- "node_modules/file-entry-cache/cache.js"(exports, module) {
965
- var path10 = __require("path");
966
- var crypto = __require("crypto");
967
- module.exports = {
968
- createFromFile(filePath, useChecksum, currentWorkingDir) {
969
- const fname = path10.basename(filePath);
970
- const dir = path10.dirname(filePath);
971
- return this.create(fname, dir, useChecksum, currentWorkingDir);
972
- },
973
- create(cacheId, _path, useChecksum, currentWorkingDir) {
974
- const fs6 = __require("fs");
975
- const flatCache = require_cache();
976
- const cache = flatCache.load(cacheId, _path);
977
- let normalizedEntries = {};
978
- const removeNotFoundFiles = function removeNotFoundFiles2() {
979
- const cachedEntries = cache.keys();
980
- for (const fPath of cachedEntries) {
981
- try {
982
- let filePath = fPath;
983
- if (currentWorkingDir) {
984
- filePath = path10.join(currentWorkingDir, fPath);
985
- }
986
- fs6.statSync(filePath);
987
- } catch (error) {
988
- if (error.code === "ENOENT") {
989
- cache.removeKey(fPath);
990
- }
991
- }
992
- }
993
- };
994
- removeNotFoundFiles();
995
- return {
996
- /**
997
- * The flat cache storage used to persist the metadata of the `files
998
- * @type {Object}
999
- */
1000
- cache,
1001
- /**
1002
- * To enable relative paths as the key with current working directory
1003
- * @type {string}
1004
- */
1005
- currentWorkingDir: currentWorkingDir ?? void 0,
1006
- /**
1007
- * Given a buffer, calculate md5 hash of its content.
1008
- * @method getHash
1009
- * @param {Buffer} buffer buffer to calculate hash on
1010
- * @return {String} content hash digest
1011
- */
1012
- getHash(buffer) {
1013
- return crypto.createHash("md5").update(buffer).digest("hex");
1014
- },
1015
- /**
1016
- * Return whether or not a file has changed since last time reconcile was called.
1017
- * @method hasFileChanged
1018
- * @param {String} file the filepath to check
1019
- * @return {Boolean} wheter or not the file has changed
1020
- */
1021
- hasFileChanged(file) {
1022
- return this.getFileDescriptor(file).changed;
1023
- },
1024
- /**
1025
- * Given an array of file paths it return and object with three arrays:
1026
- * - changedFiles: Files that changed since previous run
1027
- * - notChangedFiles: Files that haven't change
1028
- * - notFoundFiles: Files that were not found, probably deleted
1029
- *
1030
- * @param {Array} files the files to analyze and compare to the previous seen files
1031
- * @return {[type]} [description]
1032
- */
1033
- analyzeFiles(files) {
1034
- const me = this;
1035
- files || (files = []);
1036
- const res = {
1037
- changedFiles: [],
1038
- notFoundFiles: [],
1039
- notChangedFiles: []
1040
- };
1041
- for (const entry of me.normalizeEntries(files)) {
1042
- if (entry.changed) {
1043
- res.changedFiles.push(entry.key);
1044
- continue;
1045
- }
1046
- if (entry.notFound) {
1047
- res.notFoundFiles.push(entry.key);
1048
- continue;
1049
- }
1050
- res.notChangedFiles.push(entry.key);
1051
- }
1052
- return res;
1053
- },
1054
- getFileDescriptor(file) {
1055
- let fstat;
1056
- try {
1057
- fstat = fs6.statSync(file);
1058
- } catch (error) {
1059
- this.removeEntry(file);
1060
- return { key: file, notFound: true, err: error };
1061
- }
1062
- if (useChecksum) {
1063
- return this._getFileDescriptorUsingChecksum(file);
1064
- }
1065
- return this._getFileDescriptorUsingMtimeAndSize(file, fstat);
1066
- },
1067
- _getFileKey(file) {
1068
- if (this.currentWorkingDir) {
1069
- return file.split(this.currentWorkingDir).pop();
1070
- }
1071
- return file;
1072
- },
1073
- _getFileDescriptorUsingMtimeAndSize(file, fstat) {
1074
- let meta = cache.getKey(this._getFileKey(file));
1075
- const cacheExists = Boolean(meta);
1076
- const cSize = fstat.size;
1077
- const cTime = fstat.mtime.getTime();
1078
- let isDifferentDate;
1079
- let isDifferentSize;
1080
- if (meta) {
1081
- isDifferentDate = cTime !== meta.mtime;
1082
- isDifferentSize = cSize !== meta.size;
1083
- } else {
1084
- meta = { size: cSize, mtime: cTime };
1085
- }
1086
- const nEntry = normalizedEntries[this._getFileKey(file)] = {
1087
- key: this._getFileKey(file),
1088
- changed: !cacheExists || isDifferentDate || isDifferentSize,
1089
- meta
1090
- };
1091
- return nEntry;
1092
- },
1093
- _getFileDescriptorUsingChecksum(file) {
1094
- let meta = cache.getKey(this._getFileKey(file));
1095
- const cacheExists = Boolean(meta);
1096
- let contentBuffer;
1097
- try {
1098
- contentBuffer = fs6.readFileSync(file);
1099
- } catch {
1100
- contentBuffer = "";
1101
- }
1102
- let isDifferent = true;
1103
- const hash = this.getHash(contentBuffer);
1104
- if (meta) {
1105
- isDifferent = hash !== meta.hash;
1106
- } else {
1107
- meta = { hash };
1108
- }
1109
- const nEntry = normalizedEntries[this._getFileKey(file)] = {
1110
- key: this._getFileKey(file),
1111
- changed: !cacheExists || isDifferent,
1112
- meta
1113
- };
1114
- return nEntry;
1115
- },
1116
- /**
1117
- * Return the list o the files that changed compared
1118
- * against the ones stored in the cache
1119
- *
1120
- * @method getUpdated
1121
- * @param files {Array} the array of files to compare against the ones in the cache
1122
- * @returns {Array}
1123
- */
1124
- getUpdatedFiles(files) {
1125
- const me = this;
1126
- files || (files = []);
1127
- return me.normalizeEntries(files).filter((entry) => entry.changed).map((entry) => entry.key);
1128
- },
1129
- /**
1130
- * Return the list of files
1131
- * @method normalizeEntries
1132
- * @param files
1133
- * @returns {*}
1134
- */
1135
- normalizeEntries(files) {
1136
- files || (files = []);
1137
- const me = this;
1138
- const nEntries = files.map((file) => me.getFileDescriptor(file));
1139
- return nEntries;
1140
- },
1141
- /**
1142
- * Remove an entry from the file-entry-cache. Useful to force the file to still be considered
1143
- * modified the next time the process is run
1144
- *
1145
- * @method removeEntry
1146
- * @param entryName
1147
- */
1148
- removeEntry(entryName) {
1149
- delete normalizedEntries[this._getFileKey(entryName)];
1150
- cache.removeKey(this._getFileKey(entryName));
1151
- },
1152
- /**
1153
- * Delete the cache file from the disk
1154
- * @method deleteCacheFile
1155
- */
1156
- deleteCacheFile() {
1157
- cache.removeCacheFile();
1158
- },
1159
- /**
1160
- * Remove the cache from the file and clear the memory cache
1161
- */
1162
- destroy() {
1163
- normalizedEntries = {};
1164
- cache.destroy();
1165
- },
1166
- _getMetaForFileUsingCheckSum(cacheEntry) {
1167
- let filePath = cacheEntry.key;
1168
- if (this.currentWorkingDir) {
1169
- filePath = path10.join(this.currentWorkingDir, filePath);
1170
- }
1171
- const contentBuffer = fs6.readFileSync(filePath);
1172
- const hash = this.getHash(contentBuffer);
1173
- const meta = Object.assign(cacheEntry.meta, { hash });
1174
- delete meta.size;
1175
- delete meta.mtime;
1176
- return meta;
1177
- },
1178
- _getMetaForFileUsingMtimeAndSize(cacheEntry) {
1179
- let filePath = cacheEntry.key;
1180
- if (currentWorkingDir) {
1181
- filePath = path10.join(currentWorkingDir, filePath);
1182
- }
1183
- const stat = fs6.statSync(filePath);
1184
- const meta = Object.assign(cacheEntry.meta, {
1185
- size: stat.size,
1186
- mtime: stat.mtime.getTime()
1187
- });
1188
- delete meta.hash;
1189
- return meta;
1190
- },
1191
- /**
1192
- * Sync the files and persist them to the cache
1193
- * @method reconcile
1194
- */
1195
- reconcile(noPrune) {
1196
- removeNotFoundFiles();
1197
- noPrune = noPrune === void 0 ? true : noPrune;
1198
- const entries = normalizedEntries;
1199
- const keys = Object.keys(entries);
1200
- if (keys.length === 0) {
1201
- return;
1202
- }
1203
- const me = this;
1204
- for (const entryName of keys) {
1205
- const cacheEntry = entries[entryName];
1206
- try {
1207
- const meta = useChecksum ? me._getMetaForFileUsingCheckSum(cacheEntry) : me._getMetaForFileUsingMtimeAndSize(cacheEntry);
1208
- cache.setKey(this._getFileKey(entryName), meta);
1209
- } catch (error) {
1210
- if (error.code !== "ENOENT") {
1211
- throw error;
1212
- }
1213
- }
1214
- }
1215
- cache.save(noPrune);
1216
- }
1217
- };
1218
- }
1219
- };
1220
- }
1221
- });
1222
-
1223
- // node_modules/wcwidth.js/combining.js
1224
- var require_combining = __commonJS({
1225
- "node_modules/wcwidth.js/combining.js"(exports, module) {
1226
- module.exports = [
1227
- [768, 879],
1228
- [1155, 1158],
1229
- [1160, 1161],
1230
- [1425, 1469],
1231
- [1471, 1471],
1232
- [1473, 1474],
1233
- [1476, 1477],
1234
- [1479, 1479],
1235
- [1536, 1539],
1236
- [1552, 1557],
1237
- [1611, 1630],
1238
- [1648, 1648],
1239
- [1750, 1764],
1240
- [1767, 1768],
1241
- [1770, 1773],
1242
- [1807, 1807],
1243
- [1809, 1809],
1244
- [1840, 1866],
1245
- [1958, 1968],
1246
- [2027, 2035],
1247
- [2305, 2306],
1248
- [2364, 2364],
1249
- [2369, 2376],
1250
- [2381, 2381],
1251
- [2385, 2388],
1252
- [2402, 2403],
1253
- [2433, 2433],
1254
- [2492, 2492],
1255
- [2497, 2500],
1256
- [2509, 2509],
1257
- [2530, 2531],
1258
- [2561, 2562],
1259
- [2620, 2620],
1260
- [2625, 2626],
1261
- [2631, 2632],
1262
- [2635, 2637],
1263
- [2672, 2673],
1264
- [2689, 2690],
1265
- [2748, 2748],
1266
- [2753, 2757],
1267
- [2759, 2760],
1268
- [2765, 2765],
1269
- [2786, 2787],
1270
- [2817, 2817],
1271
- [2876, 2876],
1272
- [2879, 2879],
1273
- [2881, 2883],
1274
- [2893, 2893],
1275
- [2902, 2902],
1276
- [2946, 2946],
1277
- [3008, 3008],
1278
- [3021, 3021],
1279
- [3134, 3136],
1280
- [3142, 3144],
1281
- [3146, 3149],
1282
- [3157, 3158],
1283
- [3260, 3260],
1284
- [3263, 3263],
1285
- [3270, 3270],
1286
- [3276, 3277],
1287
- [3298, 3299],
1288
- [3393, 3395],
1289
- [3405, 3405],
1290
- [3530, 3530],
1291
- [3538, 3540],
1292
- [3542, 3542],
1293
- [3633, 3633],
1294
- [3636, 3642],
1295
- [3655, 3662],
1296
- [3761, 3761],
1297
- [3764, 3769],
1298
- [3771, 3772],
1299
- [3784, 3789],
1300
- [3864, 3865],
1301
- [3893, 3893],
1302
- [3895, 3895],
1303
- [3897, 3897],
1304
- [3953, 3966],
1305
- [3968, 3972],
1306
- [3974, 3975],
1307
- [3984, 3991],
1308
- [3993, 4028],
1309
- [4038, 4038],
1310
- [4141, 4144],
1311
- [4146, 4146],
1312
- [4150, 4151],
1313
- [4153, 4153],
1314
- [4184, 4185],
1315
- [4448, 4607],
1316
- [4959, 4959],
1317
- [5906, 5908],
1318
- [5938, 5940],
1319
- [5970, 5971],
1320
- [6002, 6003],
1321
- [6068, 6069],
1322
- [6071, 6077],
1323
- [6086, 6086],
1324
- [6089, 6099],
1325
- [6109, 6109],
1326
- [6155, 6157],
1327
- [6313, 6313],
1328
- [6432, 6434],
1329
- [6439, 6440],
1330
- [6450, 6450],
1331
- [6457, 6459],
1332
- [6679, 6680],
1333
- [6912, 6915],
1334
- [6964, 6964],
1335
- [6966, 6970],
1336
- [6972, 6972],
1337
- [6978, 6978],
1338
- [7019, 7027],
1339
- [7616, 7626],
1340
- [7678, 7679],
1341
- [8203, 8207],
1342
- [8234, 8238],
1343
- [8288, 8291],
1344
- [8298, 8303],
1345
- [8400, 8431],
1346
- [12330, 12335],
1347
- [12441, 12442],
1348
- [43014, 43014],
1349
- [43019, 43019],
1350
- [43045, 43046],
1351
- [64286, 64286],
1352
- [65024, 65039],
1353
- [65056, 65059],
1354
- [65279, 65279],
1355
- [65529, 65531],
1356
- [68097, 68099],
1357
- [68101, 68102],
1358
- [68108, 68111],
1359
- [68152, 68154],
1360
- [68159, 68159],
1361
- [119143, 119145],
1362
- [119155, 119170],
1363
- [119173, 119179],
1364
- [119210, 119213],
1365
- [119362, 119364],
1366
- [917505, 917505],
1367
- [917536, 917631],
1368
- [917760, 917999]
1369
- ];
1370
- }
1371
- });
1372
-
1373
- // node_modules/wcwidth.js/index.js
1374
- var require_wcwidth = __commonJS({
1375
- "node_modules/wcwidth.js/index.js"(exports, module) {
1376
- var combining = require_combining();
1377
- var DEFAULTS = {
1378
- nul: 0,
1379
- control: 0
1380
- };
1381
- function bisearch(ucs) {
1382
- let min = 0;
1383
- let max = combining.length - 1;
1384
- let mid;
1385
- if (ucs < combining[0][0] || ucs > combining[max][1]) return false;
1386
- while (max >= min) {
1387
- mid = Math.floor((min + max) / 2);
1388
- if (ucs > combining[mid][1]) min = mid + 1;
1389
- else if (ucs < combining[mid][0]) max = mid - 1;
1390
- else return true;
1391
- }
1392
- return false;
1393
- }
1394
- function wcwidth2(ucs, opts) {
1395
- if (ucs === 0) return opts.nul;
1396
- if (ucs < 32 || ucs >= 127 && ucs < 160) return opts.control;
1397
- if (bisearch(ucs)) return 0;
1398
- return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
1399
- ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
1400
- ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
1401
- ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
1402
- ucs >= 65040 && ucs <= 65049 || // Vertical forms
1403
- ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
1404
- ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
1405
- ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
1406
- }
1407
- function wcswidth(str, opts) {
1408
- let h;
1409
- let l;
1410
- let s = 0;
1411
- let n;
1412
- if (typeof str !== "string") return wcwidth2(str, opts);
1413
- for (let i = 0; i < str.length; i++) {
1414
- h = str.charCodeAt(i);
1415
- if (h >= 55296 && h <= 56319) {
1416
- l = str.charCodeAt(++i);
1417
- if (l >= 56320 && l <= 57343) {
1418
- h = (h - 55296) * 1024 + (l - 56320) + 65536;
1419
- } else {
1420
- i--;
1421
- }
1422
- }
1423
- n = wcwidth2(h, opts);
1424
- if (n < 0) return -1;
1425
- s += n;
1426
- }
1427
- return s;
1428
- }
1429
- module.exports = (str) => wcswidth(str, DEFAULTS);
1430
- module.exports.config = (opts = {}) => {
1431
- opts = {
1432
- ...DEFAULTS,
1433
- ...opts
1434
- };
1435
- return (str) => wcswidth(str, opts);
1436
- };
1437
- }
1438
- });
1439
-
1440
368
  // src/cli/index.js
1441
369
  import * as prettier2 from "../index.mjs";
1442
370
 
1443
371
  // scripts/build/shims/at.js
1444
- var at = (isOptionalObject, object, index) => {
1445
- if (isOptionalObject && (object === void 0 || object === null)) {
372
+ var at = (isOptionalObject, object2, index) => {
373
+ if (isOptionalObject && (object2 === void 0 || object2 === null)) {
1446
374
  return;
1447
375
  }
1448
- if (Array.isArray(object) || typeof object === "string") {
1449
- return object[index < 0 ? object.length + index : index];
376
+ if (Array.isArray(object2) || typeof object2 === "string") {
377
+ return object2[index < 0 ? object2.length + index : index];
1450
378
  }
1451
- return object.at(index);
379
+ return object2.at(index);
1452
380
  };
1453
381
  var at_default = at;
1454
382
 
@@ -1776,7 +704,7 @@ var postProcess = (input, toUpperCase) => {
1776
704
  (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
1777
705
  ),
1778
706
  SEPARATORS_AND_IDENTIFIER,
1779
- (_, identifier) => toUpperCase(identifier)
707
+ (_2, identifier) => toUpperCase(identifier)
1780
708
  );
1781
709
  };
1782
710
  function camelCase(input, options) {
@@ -1822,11 +750,11 @@ import path from "path";
1822
750
 
1823
751
  // node_modules/sdbm/index.js
1824
752
  function sdbm(string) {
1825
- let hash = 0;
753
+ let hash2 = 0;
1826
754
  for (let i = 0; i < string.length; i++) {
1827
- hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
755
+ hash2 = string.charCodeAt(i) + (hash2 << 6) + (hash2 << 16) - hash2;
1828
756
  }
1829
- return hash >>> 0;
757
+ return hash2 >>> 0;
1830
758
  }
1831
759
 
1832
760
  // src/cli/utils.js
@@ -1844,8 +772,8 @@ function groupBy(array2, iteratee) {
1844
772
  }
1845
773
  return result;
1846
774
  }
1847
- function pick(object, keys) {
1848
- const entries = keys.map((key) => [key, object[key]]);
775
+ function pick(object2, keys2) {
776
+ const entries = keys2.map((key) => [key, object2[key]]);
1849
777
  return Object.fromEntries(entries);
1850
778
  }
1851
779
  function createHash(source) {
@@ -1884,11 +812,7 @@ var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_defa
1884
812
  "\\",
1885
813
  "/"
1886
814
  ) : (filepath) => filepath;
1887
- var {
1888
- isNonEmptyArray,
1889
- partition,
1890
- omit
1891
- } = sharedWithCli2.utils;
815
+ var { omit } = sharedWithCli2.utils;
1892
816
 
1893
817
  // src/cli/options/create-minimist-options.js
1894
818
  function createMinimistOptions(detailedOptions) {
@@ -2194,10 +1118,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
2194
1118
  return 1;
2195
1119
  }
2196
1120
  if ("CI" in env) {
2197
- if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
1121
+ if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
2198
1122
  return 3;
2199
1123
  }
2200
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1124
+ if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
2201
1125
  return 1;
2202
1126
  }
2203
1127
  return min;
@@ -2288,12 +1212,12 @@ var levelMapping = [
2288
1212
  "ansi16m"
2289
1213
  ];
2290
1214
  var styles2 = /* @__PURE__ */ Object.create(null);
2291
- var applyOptions = (object, options = {}) => {
1215
+ var applyOptions = (object2, options = {}) => {
2292
1216
  if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
2293
1217
  throw new Error("The `level` option should be an integer from 0 to 3");
2294
1218
  }
2295
1219
  const colorLevel = stdoutColor ? stdoutColor.level : 0;
2296
- object.level = options.level === void 0 ? colorLevel : options.level;
1220
+ object2.level = options.level === void 0 ? colorLevel : options.level;
2297
1221
  };
2298
1222
  var chalkFactory = (options) => {
2299
1223
  const chalk2 = (...strings) => strings.join(" ");
@@ -2517,15 +1441,15 @@ function normalizeCliOptions(options, optionInfos, opts) {
2517
1441
  var normalize_cli_options_default = normalizeCliOptions;
2518
1442
 
2519
1443
  // src/cli/options/parse-cli-arguments.js
2520
- function parseArgv(rawArguments, detailedOptions, logger, keys) {
1444
+ function parseArgv(rawArguments, detailedOptions, logger, keys2) {
2521
1445
  var _a;
2522
1446
  const minimistOptions = createMinimistOptions(detailedOptions);
2523
1447
  let argv = minimistParse(rawArguments, minimistOptions);
2524
- if (keys) {
1448
+ if (keys2) {
2525
1449
  detailedOptions = detailedOptions.filter(
2526
- (option) => keys.includes(option.name)
1450
+ (option) => keys2.includes(option.name)
2527
1451
  );
2528
- argv = pick(argv, keys);
1452
+ argv = pick(argv, keys2);
2529
1453
  }
2530
1454
  const normalized = normalize_cli_options_default(argv, detailedOptions, { logger });
2531
1455
  return {
@@ -2542,34 +1466,28 @@ function parseArgv(rawArguments, detailedOptions, logger, keys) {
2542
1466
  };
2543
1467
  }
2544
1468
  var { detailedOptions: detailedOptionsWithoutPlugins } = getContextOptionsWithoutPlugins();
2545
- function parseArgvWithoutPlugins(rawArguments, logger, keys) {
1469
+ function parseArgvWithoutPlugins(rawArguments, logger, keys2) {
2546
1470
  return parseArgv(
2547
1471
  rawArguments,
2548
1472
  detailedOptionsWithoutPlugins,
2549
1473
  logger,
2550
- typeof keys === "string" ? [keys] : keys
1474
+ typeof keys2 === "string" ? [keys2] : keys2
2551
1475
  );
2552
1476
  }
2553
1477
 
2554
1478
  // src/cli/context.js
2555
1479
  var _stack;
2556
1480
  var Context = class {
2557
- constructor({
2558
- rawArguments,
2559
- logger
2560
- }) {
1481
+ constructor({ rawArguments, logger }) {
2561
1482
  __privateAdd(this, _stack, []);
2562
1483
  this.rawArguments = rawArguments;
2563
1484
  this.logger = logger;
2564
1485
  }
2565
1486
  async init() {
2566
- const {
2567
- rawArguments,
2568
- logger
2569
- } = this;
2570
- const {
2571
- plugins
2572
- } = parseArgvWithoutPlugins(rawArguments, logger, ["plugin"]);
1487
+ const { rawArguments, logger } = this;
1488
+ const { plugins } = parseArgvWithoutPlugins(rawArguments, logger, [
1489
+ "plugin"
1490
+ ]);
2573
1491
  await this.pushContextPlugins(plugins);
2574
1492
  const argv = parseArgv(rawArguments, this.detailedOptions, logger);
2575
1493
  this.argv = argv;
@@ -2594,10 +1512,7 @@ var Context = class {
2594
1512
  }
2595
1513
  // eslint-disable-next-line getter-return
2596
1514
  get performanceTestFlag() {
2597
- const {
2598
- debugBenchmark,
2599
- debugRepeat
2600
- } = this.argv;
1515
+ const { debugBenchmark, debugRepeat } = this.argv;
2601
1516
  if (debugBenchmark) {
2602
1517
  return {
2603
1518
  name: "--debug-benchmark",
@@ -2610,9 +1525,7 @@ var Context = class {
2610
1525
  debugRepeat
2611
1526
  };
2612
1527
  }
2613
- const {
2614
- PRETTIER_PERF_REPEAT
2615
- } = process.env;
1528
+ const { PRETTIER_PERF_REPEAT } = process.env;
2616
1529
  if (PRETTIER_PERF_REPEAT && /^\d+$/u.test(PRETTIER_PERF_REPEAT)) {
2617
1530
  return {
2618
1531
  name: "PRETTIER_PERF_REPEAT (environment variable)",
@@ -2660,8 +1573,8 @@ async function logResolvedConfigPathOrDie(context) {
2660
1573
  var find_config_path_default = logResolvedConfigPathOrDie;
2661
1574
 
2662
1575
  // src/cli/format.js
2663
- import fs5 from "fs/promises";
2664
- import path9 from "path";
1576
+ import fs8 from "fs/promises";
1577
+ import path11 from "path";
2665
1578
  import * as prettier from "../index.mjs";
2666
1579
 
2667
1580
  // src/cli/expand-patterns.js
@@ -2669,16 +1582,12 @@ import path3 from "path";
2669
1582
  async function* expandPatterns(context) {
2670
1583
  const seen = /* @__PURE__ */ new Set();
2671
1584
  let noResults = true;
2672
- for await (const {
2673
- filePath,
2674
- ignoreUnknown,
2675
- error
2676
- } of expandPatternsInternal(context)) {
1585
+ for await (const { filePath, ignoreUnknown, error } of expandPatternsInternal(
1586
+ context
1587
+ )) {
2677
1588
  noResults = false;
2678
1589
  if (error) {
2679
- yield {
2680
- error
2681
- };
1590
+ yield { error };
2682
1591
  continue;
2683
1592
  }
2684
1593
  const filename = path3.resolve(filePath);
@@ -2686,10 +1595,7 @@ async function* expandPatterns(context) {
2686
1595
  continue;
2687
1596
  }
2688
1597
  seen.add(filename);
2689
- yield {
2690
- filename,
2691
- ignoreUnknown
2692
- };
1598
+ yield { filename, ignoreUnknown };
2693
1599
  }
2694
1600
  if (noResults && context.argv.errorOnUnmatchedPattern !== false) {
2695
1601
  yield {
@@ -2698,7 +1604,7 @@ async function* expandPatterns(context) {
2698
1604
  }
2699
1605
  }
2700
1606
  async function* expandPatternsInternal(context) {
2701
- const silentlyIgnoredDirs = [".git", ".sl", ".svn", ".hg"];
1607
+ const silentlyIgnoredDirs = [".git", ".sl", ".svn", ".hg", ".jj"];
2702
1608
  if (context.argv.withNodeModules !== true) {
2703
1609
  silentlyIgnoredDirs.push("node_modules");
2704
1610
  }
@@ -2722,7 +1628,9 @@ async function* expandPatternsInternal(context) {
2722
1628
  error: `Explicitly specified pattern "${pattern}" is a symbolic link.`
2723
1629
  };
2724
1630
  } else {
2725
- context.logger.debug(`Skipping pattern "${pattern}", as it is a symbolic link.`);
1631
+ context.logger.debug(
1632
+ `Skipping pattern "${pattern}", as it is a symbolic link.`
1633
+ );
2726
1634
  }
2727
1635
  } else if (stat.isFile()) {
2728
1636
  entries.push({
@@ -2750,18 +1658,11 @@ async function* expandPatternsInternal(context) {
2750
1658
  });
2751
1659
  }
2752
1660
  }
2753
- for (const {
2754
- type,
2755
- glob,
2756
- input,
2757
- ignoreUnknown
2758
- } of entries) {
1661
+ for (const { type, glob, input, ignoreUnknown } of entries) {
2759
1662
  let result;
2760
1663
  try {
2761
1664
  result = await fastGlob(glob, globOptions);
2762
- } catch ({
2763
- message
2764
- }) {
1665
+ } catch ({ message }) {
2765
1666
  yield {
2766
1667
  error: `${errorMessages.globError[type]}: "${input}".
2767
1668
  ${message}`
@@ -2770,15 +1671,10 @@ ${message}`
2770
1671
  }
2771
1672
  if (result.length === 0) {
2772
1673
  if (context.argv.errorOnUnmatchedPattern !== false) {
2773
- yield {
2774
- error: `${errorMessages.emptyResults[type]}: "${input}".`
2775
- };
1674
+ yield { error: `${errorMessages.emptyResults[type]}: "${input}".` };
2776
1675
  }
2777
1676
  } else {
2778
- yield* sortPaths(result).map((filePath) => ({
2779
- filePath,
2780
- ignoreUnknown
2781
- }));
1677
+ yield* sortPaths(result).map((filePath) => ({ filePath, ignoreUnknown }));
2782
1678
  }
2783
1679
  }
2784
1680
  }
@@ -2800,7 +1696,7 @@ function containsIgnoredPathSegment(absolutePath, cwd2, ignoredDirectories) {
2800
1696
  function sortPaths(paths) {
2801
1697
  return paths.sort((a, b) => a.localeCompare(b));
2802
1698
  }
2803
- function escapePathForGlob(path10) {
1699
+ function escapePathForGlob(path12) {
2804
1700
  return string_replace_all_default(
2805
1701
  /* isOptionalObject */
2806
1702
  false,
@@ -2811,7 +1707,7 @@ function escapePathForGlob(path10) {
2811
1707
  string_replace_all_default(
2812
1708
  /* isOptionalObject */
2813
1709
  false,
2814
- path10,
1710
+ path12,
2815
1711
  "\\",
2816
1712
  "\0"
2817
1713
  )
@@ -2933,9 +1829,9 @@ function packageDirectorySync({ cwd: cwd2 } = {}) {
2933
1829
 
2934
1830
  // node_modules/find-cache-dir/index.js
2935
1831
  var { env: env2, cwd } = process4;
2936
- var isWritable = (path10) => {
1832
+ var isWritable = (path12) => {
2937
1833
  try {
2938
- fs3.accessSync(path10, fs3.constants.W_OK);
1834
+ fs3.accessSync(path12, fs3.constants.W_OK);
2939
1835
  return true;
2940
1836
  } catch {
2941
1837
  return false;
@@ -3009,112 +1905,1945 @@ var find_cache_file_default = findCacheFile;
3009
1905
 
3010
1906
  // src/cli/format-results-cache.js
3011
1907
  var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify(), 1);
3012
- var import_file_entry_cache = __toESM(require_cache2(), 1);
3013
- import { version as prettierVersion } from "../index.mjs";
3014
- var optionsHashCache = /* @__PURE__ */ new WeakMap();
3015
- var nodeVersion = process.version;
3016
- function getHashOfOptions(options) {
3017
- if (optionsHashCache.has(options)) {
3018
- return optionsHashCache.get(options);
1908
+ import fs7 from "fs";
1909
+
1910
+ // node_modules/file-entry-cache/dist/index.js
1911
+ import crypto2 from "crypto";
1912
+ import fs6 from "fs";
1913
+ import path10 from "path";
1914
+
1915
+ // node_modules/file-entry-cache/node_modules/flat-cache/dist/index.js
1916
+ import path9 from "path";
1917
+ import fs5 from "fs";
1918
+
1919
+ // node_modules/hookified/dist/node/index.js
1920
+ var Eventified = class {
1921
+ _eventListeners;
1922
+ _maxListeners;
1923
+ constructor() {
1924
+ this._eventListeners = /* @__PURE__ */ new Map();
1925
+ this._maxListeners = 100;
3019
1926
  }
3020
- const hash = createHash(
3021
- `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify2.default)(options)}`
3022
- );
3023
- optionsHashCache.set(options, hash);
3024
- return hash;
3025
- }
3026
- function getMetadataFromFileDescriptor(fileDescriptor) {
3027
- return fileDescriptor.meta;
3028
- }
3029
- var _fileEntryCache;
3030
- var FormatResultsCache = class {
3031
1927
  /**
3032
- * @param {string} cacheFileLocation The path of cache file location. (default: `node_modules/.cache/prettier/.prettier-cache`)
3033
- * @param {string} cacheStrategy
1928
+ * Adds a handler function for a specific event that will run only once
1929
+ * @param {string | symbol} eventName
1930
+ * @param {EventListener} listener
1931
+ * @returns {IEventEmitter} returns the instance of the class for chaining
3034
1932
  */
3035
- constructor(cacheFileLocation, cacheStrategy) {
3036
- __privateAdd(this, _fileEntryCache);
3037
- const useChecksum = cacheStrategy === "content";
3038
- __privateSet(this, _fileEntryCache, import_file_entry_cache.default.create(
3039
- /* cacheId */
3040
- cacheFileLocation,
3041
- /* directory */
3042
- void 0,
3043
- useChecksum
3044
- ));
1933
+ once(eventName, listener) {
1934
+ const onceListener = (...arguments_) => {
1935
+ this.off(eventName, onceListener);
1936
+ listener(...arguments_);
1937
+ };
1938
+ this.on(eventName, onceListener);
1939
+ return this;
3045
1940
  }
3046
1941
  /**
3047
- * @param {string} filePath
3048
- * @param {any} options
1942
+ * Gets the number of listeners for a specific event. If no event is provided, it returns the total number of listeners
1943
+ * @param {string} eventName The event name. Not required
1944
+ * @returns {number} The number of listeners
3049
1945
  */
3050
- existsAvailableFormatResultsCache(filePath, options) {
3051
- const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
3052
- if (fileDescriptor.notFound) {
3053
- return false;
1946
+ listenerCount(eventName) {
1947
+ if (!eventName) {
1948
+ return this.getAllListeners().length;
3054
1949
  }
3055
- const hashOfOptions = getHashOfOptions(options);
3056
- const meta = getMetadataFromFileDescriptor(fileDescriptor);
3057
- const changed = fileDescriptor.changed || meta.hashOfOptions !== hashOfOptions;
3058
- return !changed;
1950
+ const listeners = this._eventListeners.get(eventName);
1951
+ return listeners ? listeners.length : 0;
3059
1952
  }
3060
1953
  /**
3061
- * @param {string} filePath
3062
- * @param {any} options
1954
+ * Gets an array of event names
1955
+ * @returns {Array<string | symbol>} An array of event names
3063
1956
  */
3064
- setFormatResultsCache(filePath, options) {
3065
- const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
3066
- const meta = getMetadataFromFileDescriptor(fileDescriptor);
3067
- if (fileDescriptor && !fileDescriptor.notFound) {
3068
- meta.hashOfOptions = getHashOfOptions(options);
1957
+ eventNames() {
1958
+ return Array.from(this._eventListeners.keys());
1959
+ }
1960
+ /**
1961
+ * Gets an array of listeners for a specific event. If no event is provided, it returns all listeners
1962
+ * @param {string} [event] (Optional) The event name
1963
+ * @returns {EventListener[]} An array of listeners
1964
+ */
1965
+ rawListeners(event) {
1966
+ if (!event) {
1967
+ return this.getAllListeners();
3069
1968
  }
1969
+ return this._eventListeners.get(event) ?? [];
3070
1970
  }
3071
1971
  /**
3072
- * @param {string} filePath
1972
+ * Prepends a listener to the beginning of the listeners array for the specified event
1973
+ * @param {string | symbol} eventName
1974
+ * @param {EventListener} listener
1975
+ * @returns {IEventEmitter} returns the instance of the class for chaining
3073
1976
  */
3074
- removeFormatResultsCache(filePath) {
3075
- __privateGet(this, _fileEntryCache).removeEntry(filePath);
1977
+ prependListener(eventName, listener) {
1978
+ const listeners = this._eventListeners.get(eventName) ?? [];
1979
+ listeners.unshift(listener);
1980
+ this._eventListeners.set(eventName, listeners);
1981
+ return this;
3076
1982
  }
3077
- reconcile() {
3078
- __privateGet(this, _fileEntryCache).reconcile();
1983
+ /**
1984
+ * Prepends a one-time listener to the beginning of the listeners array for the specified event
1985
+ * @param {string | symbol} eventName
1986
+ * @param {EventListener} listener
1987
+ * @returns {IEventEmitter} returns the instance of the class for chaining
1988
+ */
1989
+ prependOnceListener(eventName, listener) {
1990
+ const onceListener = (...arguments_) => {
1991
+ this.off(eventName, onceListener);
1992
+ listener(...arguments_);
1993
+ };
1994
+ this.prependListener(eventName, onceListener);
1995
+ return this;
3079
1996
  }
3080
- };
3081
- _fileEntryCache = new WeakMap();
3082
- var format_results_cache_default = FormatResultsCache;
3083
-
3084
- // src/cli/is-tty.js
3085
- function isTTY() {
3086
- return process.stdout.isTTY && !mockable.isCI();
3087
- }
3088
-
3089
- // src/cli/options/get-options-for-file.js
3090
- var import_dashify2 = __toESM(require_dashify(), 1);
3091
- import { resolveConfig } from "../index.mjs";
3092
- function getOptions(argv, detailedOptions) {
3093
- return Object.fromEntries(
3094
- detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
3095
- );
3096
- }
3097
- function cliifyOptions(object, apiDetailedOptionMap) {
3098
- return Object.fromEntries(
3099
- Object.entries(object || {}).map(([key, value]) => {
3100
- const apiOption = apiDetailedOptionMap[key];
3101
- const cliKey = apiOption ? apiOption.name : key;
3102
- return [(0, import_dashify2.default)(cliKey), value];
3103
- })
3104
- );
3105
- }
3106
- function createApiDetailedOptionMap(detailedOptions) {
3107
- return Object.fromEntries(
3108
- detailedOptions.filter(
3109
- (option) => option.forwardToApi && option.forwardToApi !== option.name
3110
- ).map((option) => [option.forwardToApi, option])
3111
- );
3112
- }
3113
- function parseArgsToOptions(context, overrideDefaults) {
3114
- const minimistOptions = createMinimistOptions(context.detailedOptions);
3115
- const apiDetailedOptionMap = createApiDetailedOptionMap(
3116
- context.detailedOptions
3117
- );
1997
+ /**
1998
+ * Gets the maximum number of listeners that can be added for a single event
1999
+ * @returns {number} The maximum number of listeners
2000
+ */
2001
+ maxListeners() {
2002
+ return this._maxListeners;
2003
+ }
2004
+ /**
2005
+ * Adds a listener for a specific event. It is an alias for the on() method
2006
+ * @param {string | symbol} event
2007
+ * @param {EventListener} listener
2008
+ * @returns {IEventEmitter} returns the instance of the class for chaining
2009
+ */
2010
+ addListener(event, listener) {
2011
+ this.on(event, listener);
2012
+ return this;
2013
+ }
2014
+ /**
2015
+ * Adds a listener for a specific event
2016
+ * @param {string | symbol} event
2017
+ * @param {EventListener} listener
2018
+ * @returns {IEventEmitter} returns the instance of the class for chaining
2019
+ */
2020
+ on(event, listener) {
2021
+ if (!this._eventListeners.has(event)) {
2022
+ this._eventListeners.set(event, []);
2023
+ }
2024
+ const listeners = this._eventListeners.get(event);
2025
+ if (listeners) {
2026
+ if (listeners.length >= this._maxListeners) {
2027
+ console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${listeners.length + 1} ${event} listeners added. Use setMaxListeners() to increase limit.`);
2028
+ }
2029
+ listeners.push(listener);
2030
+ }
2031
+ return this;
2032
+ }
2033
+ /**
2034
+ * Removes a listener for a specific event. It is an alias for the off() method
2035
+ * @param {string | symbol} event
2036
+ * @param {EventListener} listener
2037
+ * @returns {IEventEmitter} returns the instance of the class for chaining
2038
+ */
2039
+ removeListener(event, listener) {
2040
+ this.off(event, listener);
2041
+ return this;
2042
+ }
2043
+ /**
2044
+ * Removes a listener for a specific event
2045
+ * @param {string | symbol} event
2046
+ * @param {EventListener} listener
2047
+ * @returns {IEventEmitter} returns the instance of the class for chaining
2048
+ */
2049
+ off(event, listener) {
2050
+ const listeners = this._eventListeners.get(event) ?? [];
2051
+ const index = listeners.indexOf(listener);
2052
+ if (index !== -1) {
2053
+ listeners.splice(index, 1);
2054
+ }
2055
+ if (listeners.length === 0) {
2056
+ this._eventListeners.delete(event);
2057
+ }
2058
+ return this;
2059
+ }
2060
+ /**
2061
+ * Calls all listeners for a specific event
2062
+ * @param {string | symbol} event
2063
+ * @param arguments_ The arguments to pass to the listeners
2064
+ * @returns {boolean} Returns true if the event had listeners, false otherwise
2065
+ */
2066
+ emit(event, ...arguments_) {
2067
+ let result = false;
2068
+ const listeners = this._eventListeners.get(event);
2069
+ if (listeners && listeners.length > 0) {
2070
+ for (const listener of listeners) {
2071
+ listener(...arguments_);
2072
+ result = true;
2073
+ }
2074
+ }
2075
+ return result;
2076
+ }
2077
+ /**
2078
+ * Gets all listeners for a specific event. If no event is provided, it returns all listeners
2079
+ * @param {string} [event] (Optional) The event name
2080
+ * @returns {EventListener[]} An array of listeners
2081
+ */
2082
+ listeners(event) {
2083
+ return this._eventListeners.get(event) ?? [];
2084
+ }
2085
+ /**
2086
+ * Removes all listeners for a specific event. If no event is provided, it removes all listeners
2087
+ * @param {string} [event] (Optional) The event name
2088
+ * @returns {IEventEmitter} returns the instance of the class for chaining
2089
+ */
2090
+ removeAllListeners(event) {
2091
+ if (event) {
2092
+ this._eventListeners.delete(event);
2093
+ } else {
2094
+ this._eventListeners.clear();
2095
+ }
2096
+ return this;
2097
+ }
2098
+ /**
2099
+ * Sets the maximum number of listeners that can be added for a single event
2100
+ * @param {number} n The maximum number of listeners
2101
+ * @returns {void}
2102
+ */
2103
+ setMaxListeners(n) {
2104
+ this._maxListeners = n;
2105
+ for (const listeners of this._eventListeners.values()) {
2106
+ if (listeners.length > n) {
2107
+ listeners.splice(n);
2108
+ }
2109
+ }
2110
+ }
2111
+ /**
2112
+ * Gets all listeners
2113
+ * @returns {EventListener[]} An array of listeners
2114
+ */
2115
+ getAllListeners() {
2116
+ let result = new Array();
2117
+ for (const listeners of this._eventListeners.values()) {
2118
+ result = result.concat(listeners);
2119
+ }
2120
+ return result;
2121
+ }
2122
+ };
2123
+ var Hookified = class extends Eventified {
2124
+ _hooks;
2125
+ _throwHookErrors = false;
2126
+ constructor(options) {
2127
+ super();
2128
+ this._hooks = /* @__PURE__ */ new Map();
2129
+ if ((options == null ? void 0 : options.throwHookErrors) !== void 0) {
2130
+ this._throwHookErrors = options.throwHookErrors;
2131
+ }
2132
+ }
2133
+ /**
2134
+ * Gets all hooks
2135
+ * @returns {Map<string, Hook[]>}
2136
+ */
2137
+ get hooks() {
2138
+ return this._hooks;
2139
+ }
2140
+ /**
2141
+ * Gets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
2142
+ * @returns {boolean}
2143
+ */
2144
+ get throwHookErrors() {
2145
+ return this._throwHookErrors;
2146
+ }
2147
+ /**
2148
+ * Sets whether an error should be thrown when a hook throws an error. Default is false and only emits an error event.
2149
+ * @param {boolean} value
2150
+ */
2151
+ set throwHookErrors(value) {
2152
+ this._throwHookErrors = value;
2153
+ }
2154
+ /**
2155
+ * Adds a handler function for a specific event
2156
+ * @param {string} event
2157
+ * @param {Hook} handler - this can be async or sync
2158
+ * @returns {void}
2159
+ */
2160
+ onHook(event, handler) {
2161
+ const eventHandlers = this._hooks.get(event);
2162
+ if (eventHandlers) {
2163
+ eventHandlers.push(handler);
2164
+ } else {
2165
+ this._hooks.set(event, [handler]);
2166
+ }
2167
+ }
2168
+ /**
2169
+ * Adds a handler function for a specific event that runs before all other handlers
2170
+ * @param {string} event
2171
+ * @param {Hook} handler - this can be async or sync
2172
+ * @returns {void}
2173
+ */
2174
+ prependHook(event, handler) {
2175
+ const eventHandlers = this._hooks.get(event);
2176
+ if (eventHandlers) {
2177
+ eventHandlers.unshift(handler);
2178
+ } else {
2179
+ this._hooks.set(event, [handler]);
2180
+ }
2181
+ }
2182
+ /**
2183
+ * Adds a handler that only executes once for a specific event before all other handlers
2184
+ * @param event
2185
+ * @param handler
2186
+ */
2187
+ prependOnceHook(event, handler) {
2188
+ const hook = async (...arguments_) => {
2189
+ this.removeHook(event, hook);
2190
+ return handler(...arguments_);
2191
+ };
2192
+ this.prependHook(event, hook);
2193
+ }
2194
+ /**
2195
+ * Adds a handler that only executes once for a specific event
2196
+ * @param event
2197
+ * @param handler
2198
+ */
2199
+ onceHook(event, handler) {
2200
+ const hook = async (...arguments_) => {
2201
+ this.removeHook(event, hook);
2202
+ return handler(...arguments_);
2203
+ };
2204
+ this.onHook(event, hook);
2205
+ }
2206
+ /**
2207
+ * Removes a handler function for a specific event
2208
+ * @param {string} event
2209
+ * @param {Hook} handler
2210
+ * @returns {void}
2211
+ */
2212
+ removeHook(event, handler) {
2213
+ const eventHandlers = this._hooks.get(event);
2214
+ if (eventHandlers) {
2215
+ const index = eventHandlers.indexOf(handler);
2216
+ if (index !== -1) {
2217
+ eventHandlers.splice(index, 1);
2218
+ }
2219
+ }
2220
+ }
2221
+ /**
2222
+ * Calls all handlers for a specific event
2223
+ * @param {string} event
2224
+ * @param {T[]} arguments_
2225
+ * @returns {Promise<void>}
2226
+ */
2227
+ async hook(event, ...arguments_) {
2228
+ const eventHandlers = this._hooks.get(event);
2229
+ if (eventHandlers) {
2230
+ for (const handler of eventHandlers) {
2231
+ try {
2232
+ await handler(...arguments_);
2233
+ } catch (error) {
2234
+ const message = `${event}: ${error.message}`;
2235
+ this.emit("error", new Error(message));
2236
+ if (this._throwHookErrors) {
2237
+ throw new Error(message);
2238
+ }
2239
+ }
2240
+ }
2241
+ }
2242
+ }
2243
+ /**
2244
+ * Gets all hooks for a specific event
2245
+ * @param {string} event
2246
+ * @returns {Hook[]}
2247
+ */
2248
+ getHooks(event) {
2249
+ return this._hooks.get(event);
2250
+ }
2251
+ /**
2252
+ * Removes all hooks
2253
+ * @returns {void}
2254
+ */
2255
+ clearHooks() {
2256
+ this._hooks.clear();
2257
+ }
2258
+ };
2259
+
2260
+ // node_modules/cacheable/dist/index.js
2261
+ import * as crypto from "crypto";
2262
+ var structuredClone = globalThis.structuredClone ?? ((value) => JSON.parse(JSON.stringify(value)));
2263
+ var shorthandToMilliseconds = (shorthand) => {
2264
+ let milliseconds;
2265
+ if (shorthand === void 0) {
2266
+ return void 0;
2267
+ }
2268
+ if (typeof shorthand === "number") {
2269
+ milliseconds = shorthand;
2270
+ } else if (typeof shorthand === "string") {
2271
+ shorthand = shorthand.trim();
2272
+ if (Number.isNaN(Number(shorthand))) {
2273
+ const match = /^([\d.]+)\s*(ms|s|m|h|hr|d)$/i.exec(shorthand);
2274
+ if (!match) {
2275
+ throw new Error(
2276
+ `Unsupported time format: "${shorthand}". Use 'ms', 's', 'm', 'h', 'hr', or 'd'.`
2277
+ );
2278
+ }
2279
+ const [, value, unit] = match;
2280
+ const numericValue = Number.parseFloat(value);
2281
+ const unitLower = unit.toLowerCase();
2282
+ switch (unitLower) {
2283
+ case "ms": {
2284
+ milliseconds = numericValue;
2285
+ break;
2286
+ }
2287
+ case "s": {
2288
+ milliseconds = numericValue * 1e3;
2289
+ break;
2290
+ }
2291
+ case "m": {
2292
+ milliseconds = numericValue * 1e3 * 60;
2293
+ break;
2294
+ }
2295
+ case "h": {
2296
+ milliseconds = numericValue * 1e3 * 60 * 60;
2297
+ break;
2298
+ }
2299
+ case "hr": {
2300
+ milliseconds = numericValue * 1e3 * 60 * 60;
2301
+ break;
2302
+ }
2303
+ case "d": {
2304
+ milliseconds = numericValue * 1e3 * 60 * 60 * 24;
2305
+ break;
2306
+ }
2307
+ /* c8 ignore next 3 */
2308
+ default: {
2309
+ milliseconds = Number(shorthand);
2310
+ }
2311
+ }
2312
+ } else {
2313
+ milliseconds = Number(shorthand);
2314
+ }
2315
+ } else {
2316
+ throw new TypeError("Time must be a string or a number.");
2317
+ }
2318
+ return milliseconds;
2319
+ };
2320
+ var shorthandToTime = (shorthand, fromDate) => {
2321
+ fromDate || (fromDate = /* @__PURE__ */ new Date());
2322
+ const milliseconds = shorthandToMilliseconds(shorthand);
2323
+ if (milliseconds === void 0) {
2324
+ return fromDate.getTime();
2325
+ }
2326
+ return fromDate.getTime() + milliseconds;
2327
+ };
2328
+ function hash(object2, algorithm = "sha256") {
2329
+ const objectString = JSON.stringify(object2);
2330
+ if (!crypto.getHashes().includes(algorithm)) {
2331
+ throw new Error(`Unsupported hash algorithm: '${algorithm}'`);
2332
+ }
2333
+ const hasher = crypto.createHash(algorithm);
2334
+ hasher.update(objectString);
2335
+ return hasher.digest("hex");
2336
+ }
2337
+ function wrapSync(function_, options) {
2338
+ const { ttl, keyPrefix, cache } = options;
2339
+ return function(...arguments_) {
2340
+ const cacheKey = createWrapKey(function_, arguments_, keyPrefix);
2341
+ let value = cache.get(cacheKey);
2342
+ if (value === void 0) {
2343
+ try {
2344
+ value = function_(...arguments_);
2345
+ cache.set(cacheKey, value, ttl);
2346
+ } catch (error) {
2347
+ cache.emit("error", error);
2348
+ if (options.cacheErrors) {
2349
+ cache.set(cacheKey, error, ttl);
2350
+ }
2351
+ }
2352
+ }
2353
+ return value;
2354
+ };
2355
+ }
2356
+ function createWrapKey(function_, arguments_, keyPrefix) {
2357
+ if (!keyPrefix) {
2358
+ return `${function_.name}::${hash(arguments_)}`;
2359
+ }
2360
+ return `${keyPrefix}::${function_.name}::${hash(arguments_)}`;
2361
+ }
2362
+ var ListNode = class {
2363
+ // eslint-disable-next-line @typescript-eslint/parameter-properties
2364
+ value;
2365
+ prev = void 0;
2366
+ next = void 0;
2367
+ constructor(value) {
2368
+ this.value = value;
2369
+ }
2370
+ };
2371
+ var DoublyLinkedList = class {
2372
+ head = void 0;
2373
+ tail = void 0;
2374
+ nodesMap = /* @__PURE__ */ new Map();
2375
+ // Add a new node to the front (most recently used)
2376
+ addToFront(value) {
2377
+ const newNode = new ListNode(value);
2378
+ if (this.head) {
2379
+ newNode.next = this.head;
2380
+ this.head.prev = newNode;
2381
+ this.head = newNode;
2382
+ } else {
2383
+ this.head = this.tail = newNode;
2384
+ }
2385
+ this.nodesMap.set(value, newNode);
2386
+ }
2387
+ // Move an existing node to the front (most recently used)
2388
+ moveToFront(value) {
2389
+ const node = this.nodesMap.get(value);
2390
+ if (!node || this.head === node) {
2391
+ return;
2392
+ }
2393
+ if (node.prev) {
2394
+ node.prev.next = node.next;
2395
+ }
2396
+ if (node.next) {
2397
+ node.next.prev = node.prev;
2398
+ }
2399
+ if (node === this.tail) {
2400
+ this.tail = node.prev;
2401
+ }
2402
+ node.prev = void 0;
2403
+ node.next = this.head;
2404
+ if (this.head) {
2405
+ this.head.prev = node;
2406
+ }
2407
+ this.head = node;
2408
+ this.tail || (this.tail = node);
2409
+ }
2410
+ // Get the oldest node (tail)
2411
+ getOldest() {
2412
+ return this.tail ? this.tail.value : void 0;
2413
+ }
2414
+ // Remove the oldest node (tail)
2415
+ removeOldest() {
2416
+ if (!this.tail) {
2417
+ return void 0;
2418
+ }
2419
+ const oldValue = this.tail.value;
2420
+ if (this.tail.prev) {
2421
+ this.tail = this.tail.prev;
2422
+ this.tail.next = void 0;
2423
+ } else {
2424
+ this.head = this.tail = void 0;
2425
+ }
2426
+ this.nodesMap.delete(oldValue);
2427
+ return oldValue;
2428
+ }
2429
+ get size() {
2430
+ return this.nodesMap.size;
2431
+ }
2432
+ };
2433
+ var CacheableMemory = class extends Hookified {
2434
+ _lru = new DoublyLinkedList();
2435
+ _hashCache = /* @__PURE__ */ new Map();
2436
+ _hash0 = /* @__PURE__ */ new Map();
2437
+ _hash1 = /* @__PURE__ */ new Map();
2438
+ _hash2 = /* @__PURE__ */ new Map();
2439
+ _hash3 = /* @__PURE__ */ new Map();
2440
+ _hash4 = /* @__PURE__ */ new Map();
2441
+ _hash5 = /* @__PURE__ */ new Map();
2442
+ _hash6 = /* @__PURE__ */ new Map();
2443
+ _hash7 = /* @__PURE__ */ new Map();
2444
+ _hash8 = /* @__PURE__ */ new Map();
2445
+ _hash9 = /* @__PURE__ */ new Map();
2446
+ _ttl;
2447
+ // Turned off by default
2448
+ _useClone = true;
2449
+ // Turned on by default
2450
+ _lruSize = 0;
2451
+ // Turned off by default
2452
+ _checkInterval = 0;
2453
+ // Turned off by default
2454
+ _interval = 0;
2455
+ // Turned off by default
2456
+ /**
2457
+ * @constructor
2458
+ * @param {CacheableMemoryOptions} [options] - The options for the CacheableMemory
2459
+ */
2460
+ constructor(options) {
2461
+ super();
2462
+ if (options == null ? void 0 : options.ttl) {
2463
+ this.setTtl(options.ttl);
2464
+ }
2465
+ if ((options == null ? void 0 : options.useClone) !== void 0) {
2466
+ this._useClone = options.useClone;
2467
+ }
2468
+ if (options == null ? void 0 : options.lruSize) {
2469
+ this._lruSize = options.lruSize;
2470
+ }
2471
+ if (options == null ? void 0 : options.checkInterval) {
2472
+ this._checkInterval = options.checkInterval;
2473
+ }
2474
+ this.startIntervalCheck();
2475
+ }
2476
+ /**
2477
+ * Gets the time-to-live
2478
+ * @returns {number|string|undefined} - The time-to-live in miliseconds or a human-readable format. If undefined, it will not have a time-to-live.
2479
+ */
2480
+ get ttl() {
2481
+ return this._ttl;
2482
+ }
2483
+ /**
2484
+ * Sets the time-to-live
2485
+ * @param {number|string|undefined} value - The time-to-live in miliseconds or a human-readable format (example '1s' = 1 second, '1h' = 1 hour). If undefined, it will not have a time-to-live.
2486
+ */
2487
+ set ttl(value) {
2488
+ this.setTtl(value);
2489
+ }
2490
+ /**
2491
+ * Gets whether to use clone
2492
+ * @returns {boolean} - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
2493
+ */
2494
+ get useClone() {
2495
+ return this._useClone;
2496
+ }
2497
+ /**
2498
+ * Sets whether to use clone
2499
+ * @param {boolean} value - If true, it will clone the value before returning it. If false, it will return the value directly. Default is true.
2500
+ */
2501
+ set useClone(value) {
2502
+ this._useClone = value;
2503
+ }
2504
+ /**
2505
+ * Gets the size of the LRU cache
2506
+ * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0.
2507
+ */
2508
+ get lruSize() {
2509
+ return this._lruSize;
2510
+ }
2511
+ /**
2512
+ * Sets the size of the LRU cache
2513
+ * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0.
2514
+ */
2515
+ set lruSize(value) {
2516
+ this._lruSize = value;
2517
+ this.lruResize();
2518
+ }
2519
+ /**
2520
+ * Gets the check interval
2521
+ * @returns {number} - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
2522
+ */
2523
+ get checkInterval() {
2524
+ return this._checkInterval;
2525
+ }
2526
+ /**
2527
+ * Sets the check interval
2528
+ * @param {number} value - The interval to check for expired items. If set to 0, it will not check for expired items. Default is 0.
2529
+ */
2530
+ set checkInterval(value) {
2531
+ this._checkInterval = value;
2532
+ }
2533
+ /**
2534
+ * Gets the size of the cache
2535
+ * @returns {number} - The size of the cache
2536
+ */
2537
+ get size() {
2538
+ return this._hash0.size + this._hash1.size + this._hash2.size + this._hash3.size + this._hash4.size + this._hash5.size + this._hash6.size + this._hash7.size + this._hash8.size + this._hash9.size;
2539
+ }
2540
+ /**
2541
+ * Gets the keys
2542
+ * @returns {IterableIterator<string>} - The keys
2543
+ */
2544
+ get keys() {
2545
+ return this.concatStores().keys();
2546
+ }
2547
+ /**
2548
+ * Gets the items
2549
+ * @returns {IterableIterator<CacheableStoreItem>} - The items
2550
+ */
2551
+ get items() {
2552
+ return this.concatStores().values();
2553
+ }
2554
+ /**
2555
+ * Gets the value of the key
2556
+ * @param {string} key - The key to get the value
2557
+ * @returns {T | undefined} - The value of the key
2558
+ */
2559
+ get(key) {
2560
+ const store = this.getStore(key);
2561
+ const item = store.get(key);
2562
+ if (!item) {
2563
+ return void 0;
2564
+ }
2565
+ if (item.expires && item.expires && Date.now() > item.expires) {
2566
+ store.delete(key);
2567
+ return void 0;
2568
+ }
2569
+ this.lruMoveToFront(key);
2570
+ if (!this._useClone) {
2571
+ return item.value;
2572
+ }
2573
+ return this.clone(item.value);
2574
+ }
2575
+ /**
2576
+ * Gets the values of the keys
2577
+ * @param {string[]} keys - The keys to get the values
2578
+ * @returns {T[]} - The values of the keys
2579
+ */
2580
+ getMany(keys2) {
2581
+ const result = new Array();
2582
+ for (const key of keys2) {
2583
+ result.push(this.get(key));
2584
+ }
2585
+ return result;
2586
+ }
2587
+ /**
2588
+ * Gets the raw value of the key
2589
+ * @param {string} key - The key to get the value
2590
+ * @returns {CacheableStoreItem | undefined} - The raw value of the key
2591
+ */
2592
+ getRaw(key) {
2593
+ const store = this.getStore(key);
2594
+ const item = store.get(key);
2595
+ if (!item) {
2596
+ return void 0;
2597
+ }
2598
+ if (item.expires && item.expires && Date.now() > item.expires) {
2599
+ store.delete(key);
2600
+ return void 0;
2601
+ }
2602
+ this.lruMoveToFront(key);
2603
+ return item;
2604
+ }
2605
+ /**
2606
+ * Gets the raw values of the keys
2607
+ * @param {string[]} keys - The keys to get the values
2608
+ * @returns {CacheableStoreItem[]} - The raw values of the keys
2609
+ */
2610
+ getManyRaw(keys2) {
2611
+ const result = new Array();
2612
+ for (const key of keys2) {
2613
+ result.push(this.getRaw(key));
2614
+ }
2615
+ return result;
2616
+ }
2617
+ /**
2618
+ * Sets the value of the key
2619
+ * @param {string} key - The key to set the value
2620
+ * @param {any} value - The value to set
2621
+ * @param {number|string|SetOptions} [ttl] - Time to Live - If you set a number it is miliseconds, if you set a string it is a human-readable.
2622
+ * If you want to set expire directly you can do that by setting the expire property in the SetOptions.
2623
+ * If you set undefined, it will use the default time-to-live. If both are undefined then it will not have a time-to-live.
2624
+ * @returns {void}
2625
+ */
2626
+ set(key, value, ttl) {
2627
+ const store = this.getStore(key);
2628
+ let expires;
2629
+ if (ttl !== void 0 || this._ttl !== void 0) {
2630
+ if (typeof ttl === "object") {
2631
+ if (ttl.expire) {
2632
+ expires = typeof ttl.expire === "number" ? ttl.expire : ttl.expire.getTime();
2633
+ }
2634
+ if (ttl.ttl) {
2635
+ const finalTtl = shorthandToTime(ttl.ttl);
2636
+ if (finalTtl !== void 0) {
2637
+ expires = finalTtl;
2638
+ }
2639
+ }
2640
+ } else {
2641
+ const finalTtl = shorthandToTime(ttl ?? this._ttl);
2642
+ if (finalTtl !== void 0) {
2643
+ expires = finalTtl;
2644
+ }
2645
+ }
2646
+ }
2647
+ if (this._lruSize > 0) {
2648
+ if (store.has(key)) {
2649
+ this.lruMoveToFront(key);
2650
+ } else {
2651
+ this.lruAddToFront(key);
2652
+ if (this._lru.size > this._lruSize) {
2653
+ const oldestKey = this._lru.getOldest();
2654
+ if (oldestKey) {
2655
+ this._lru.removeOldest();
2656
+ this.delete(oldestKey);
2657
+ }
2658
+ }
2659
+ }
2660
+ }
2661
+ const item = { key, value, expires };
2662
+ store.set(
2663
+ key,
2664
+ item
2665
+ );
2666
+ }
2667
+ /**
2668
+ * Sets the values of the keys
2669
+ * @param {CacheableItem[]} items - The items to set
2670
+ * @returns {void}
2671
+ */
2672
+ setMany(items) {
2673
+ for (const item of items) {
2674
+ this.set(item.key, item.value, item.ttl);
2675
+ }
2676
+ }
2677
+ /**
2678
+ * Checks if the key exists
2679
+ * @param {string} key - The key to check
2680
+ * @returns {boolean} - If true, the key exists. If false, the key does not exist.
2681
+ */
2682
+ has(key) {
2683
+ const item = this.get(key);
2684
+ return Boolean(item);
2685
+ }
2686
+ /**
2687
+ * @function hasMany
2688
+ * @param {string[]} keys - The keys to check
2689
+ * @returns {boolean[]} - If true, the key exists. If false, the key does not exist.
2690
+ */
2691
+ hasMany(keys2) {
2692
+ const result = new Array();
2693
+ for (const key of keys2) {
2694
+ const item = this.get(key);
2695
+ result.push(Boolean(item));
2696
+ }
2697
+ return result;
2698
+ }
2699
+ /**
2700
+ * Take will get the key and delete the entry from cache
2701
+ * @param {string} key - The key to take
2702
+ * @returns {T | undefined} - The value of the key
2703
+ */
2704
+ take(key) {
2705
+ const item = this.get(key);
2706
+ if (!item) {
2707
+ return void 0;
2708
+ }
2709
+ this.delete(key);
2710
+ return item;
2711
+ }
2712
+ /**
2713
+ * TakeMany will get the keys and delete the entries from cache
2714
+ * @param {string[]} keys - The keys to take
2715
+ * @returns {T[]} - The values of the keys
2716
+ */
2717
+ takeMany(keys2) {
2718
+ const result = new Array();
2719
+ for (const key of keys2) {
2720
+ result.push(this.take(key));
2721
+ }
2722
+ return result;
2723
+ }
2724
+ /**
2725
+ * Delete the key
2726
+ * @param {string} key - The key to delete
2727
+ * @returns {void}
2728
+ */
2729
+ delete(key) {
2730
+ const store = this.getStore(key);
2731
+ store.delete(key);
2732
+ }
2733
+ /**
2734
+ * Delete the keys
2735
+ * @param {string[]} keys - The keys to delete
2736
+ * @returns {void}
2737
+ */
2738
+ deleteMany(keys2) {
2739
+ for (const key of keys2) {
2740
+ this.delete(key);
2741
+ }
2742
+ }
2743
+ /**
2744
+ * Clear the cache
2745
+ * @returns {void}
2746
+ */
2747
+ clear() {
2748
+ this._hash0.clear();
2749
+ this._hash1.clear();
2750
+ this._hash2.clear();
2751
+ this._hash3.clear();
2752
+ this._hash4.clear();
2753
+ this._hash5.clear();
2754
+ this._hash6.clear();
2755
+ this._hash7.clear();
2756
+ this._hash8.clear();
2757
+ this._hash9.clear();
2758
+ this._hashCache.clear();
2759
+ this._lru = new DoublyLinkedList();
2760
+ }
2761
+ /**
2762
+ * Get the store based on the key (internal use)
2763
+ * @param {string} key - The key to get the store
2764
+ * @returns {CacheableHashStore} - The store
2765
+ */
2766
+ getStore(key) {
2767
+ const hash2 = this.hashKey(key);
2768
+ return this.getStoreFromHash(hash2);
2769
+ }
2770
+ /**
2771
+ * Get the store based on the hash (internal use)
2772
+ * @param {number} hash
2773
+ * @returns {Map<string, CacheableStoreItem>}
2774
+ */
2775
+ getStoreFromHash(hash2) {
2776
+ switch (hash2) {
2777
+ case 1: {
2778
+ return this._hash1;
2779
+ }
2780
+ case 2: {
2781
+ return this._hash2;
2782
+ }
2783
+ case 3: {
2784
+ return this._hash3;
2785
+ }
2786
+ case 4: {
2787
+ return this._hash4;
2788
+ }
2789
+ case 5: {
2790
+ return this._hash5;
2791
+ }
2792
+ case 6: {
2793
+ return this._hash6;
2794
+ }
2795
+ case 7: {
2796
+ return this._hash7;
2797
+ }
2798
+ case 8: {
2799
+ return this._hash8;
2800
+ }
2801
+ case 9: {
2802
+ return this._hash9;
2803
+ }
2804
+ default: {
2805
+ return this._hash0;
2806
+ }
2807
+ }
2808
+ }
2809
+ /**
2810
+ * Hash the key (internal use)
2811
+ * @param key
2812
+ * @returns {number} from 0 to 9
2813
+ */
2814
+ hashKey(key) {
2815
+ const cacheHashNumber = this._hashCache.get(key);
2816
+ if (cacheHashNumber) {
2817
+ return cacheHashNumber;
2818
+ }
2819
+ let hash2 = 0;
2820
+ const primeMultiplier = 31;
2821
+ for (let i = 0; i < key.length; i++) {
2822
+ hash2 = hash2 * primeMultiplier + key.charCodeAt(i);
2823
+ }
2824
+ const result = Math.abs(hash2) % 10;
2825
+ this._hashCache.set(key, result);
2826
+ return result;
2827
+ }
2828
+ /**
2829
+ * Clone the value. This is for internal use
2830
+ * @param {any} value - The value to clone
2831
+ * @returns {any} - The cloned value
2832
+ */
2833
+ clone(value) {
2834
+ if (this.isPrimitive(value)) {
2835
+ return value;
2836
+ }
2837
+ return structuredClone(value);
2838
+ }
2839
+ /**
2840
+ * Add to the front of the LRU cache. This is for internal use
2841
+ * @param {string} key - The key to add to the front
2842
+ * @returns {void}
2843
+ */
2844
+ lruAddToFront(key) {
2845
+ if (this._lruSize === 0) {
2846
+ return;
2847
+ }
2848
+ this._lru.addToFront(key);
2849
+ }
2850
+ /**
2851
+ * Move to the front of the LRU cache. This is for internal use
2852
+ * @param {string} key - The key to move to the front
2853
+ * @returns {void}
2854
+ */
2855
+ lruMoveToFront(key) {
2856
+ if (this._lruSize === 0) {
2857
+ return;
2858
+ }
2859
+ this._lru.moveToFront(key);
2860
+ }
2861
+ /**
2862
+ * Resize the LRU cache. This is for internal use
2863
+ * @returns {void}
2864
+ */
2865
+ lruResize() {
2866
+ if (this._lruSize === 0) {
2867
+ return;
2868
+ }
2869
+ while (this._lru.size > this._lruSize) {
2870
+ const oldestKey = this._lru.getOldest();
2871
+ if (oldestKey) {
2872
+ this._lru.removeOldest();
2873
+ this.delete(oldestKey);
2874
+ }
2875
+ }
2876
+ }
2877
+ /**
2878
+ * Check for expiration. This is for internal use
2879
+ * @returns {void}
2880
+ */
2881
+ checkExpiration() {
2882
+ const stores = this.concatStores();
2883
+ for (const item of stores.values()) {
2884
+ if (item.expires && Date.now() > item.expires) {
2885
+ this.delete(item.key);
2886
+ }
2887
+ }
2888
+ }
2889
+ /**
2890
+ * Start the interval check. This is for internal use
2891
+ * @returns {void}
2892
+ */
2893
+ startIntervalCheck() {
2894
+ if (this._checkInterval > 0) {
2895
+ if (this._interval) {
2896
+ clearInterval(this._interval);
2897
+ }
2898
+ this._interval = setInterval(() => {
2899
+ this.checkExpiration();
2900
+ }, this._checkInterval).unref();
2901
+ }
2902
+ }
2903
+ /**
2904
+ * Stop the interval check. This is for internal use
2905
+ * @returns {void}
2906
+ */
2907
+ stopIntervalCheck() {
2908
+ if (this._interval) {
2909
+ clearInterval(this._interval);
2910
+ }
2911
+ this._interval = 0;
2912
+ this._checkInterval = 0;
2913
+ }
2914
+ /**
2915
+ * Hash the object. This is for internal use
2916
+ * @param {any} object - The object to hash
2917
+ * @param {string} [algorithm='sha256'] - The algorithm to hash
2918
+ * @returns {string} - The hashed string
2919
+ */
2920
+ hash(object2, algorithm = "sha256") {
2921
+ return hash(object2, algorithm);
2922
+ }
2923
+ /**
2924
+ * Wrap the function for caching
2925
+ * @param {Function} function_ - The function to wrap
2926
+ * @param {Object} [options] - The options to wrap
2927
+ * @returns {Function} - The wrapped function
2928
+ */
2929
+ wrap(function_, options) {
2930
+ const wrapOptions = {
2931
+ ttl: (options == null ? void 0 : options.ttl) ?? this._ttl,
2932
+ keyPrefix: options == null ? void 0 : options.keyPrefix,
2933
+ cache: this
2934
+ };
2935
+ return wrapSync(function_, wrapOptions);
2936
+ }
2937
+ isPrimitive(value) {
2938
+ const result = false;
2939
+ if (value === null || value === void 0) {
2940
+ return true;
2941
+ }
2942
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
2943
+ return true;
2944
+ }
2945
+ return result;
2946
+ }
2947
+ concatStores() {
2948
+ return new Map([...this._hash0, ...this._hash1, ...this._hash2, ...this._hash3, ...this._hash4, ...this._hash5, ...this._hash6, ...this._hash7, ...this._hash8, ...this._hash9]);
2949
+ }
2950
+ setTtl(ttl) {
2951
+ if (typeof ttl === "string" || ttl === void 0) {
2952
+ this._ttl = ttl;
2953
+ } else if (ttl > 0) {
2954
+ this._ttl = ttl;
2955
+ } else {
2956
+ this._ttl = void 0;
2957
+ }
2958
+ }
2959
+ };
2960
+
2961
+ // node_modules/flatted/esm/index.js
2962
+ var { parse: $parse, stringify: $stringify } = JSON;
2963
+ var { keys } = Object;
2964
+ var Primitive = String;
2965
+ var primitive = "string";
2966
+ var ignore = {};
2967
+ var object = "object";
2968
+ var noop = (_2, value) => value;
2969
+ var primitives = (value) => value instanceof Primitive ? Primitive(value) : value;
2970
+ var Primitives = (_2, value) => typeof value === primitive ? new Primitive(value) : value;
2971
+ var revive = (input, parsed, output, $) => {
2972
+ const lazy = [];
2973
+ for (let ke = keys(output), { length } = ke, y = 0; y < length; y++) {
2974
+ const k = ke[y];
2975
+ const value = output[k];
2976
+ if (value instanceof Primitive) {
2977
+ const tmp = input[value];
2978
+ if (typeof tmp === object && !parsed.has(tmp)) {
2979
+ parsed.add(tmp);
2980
+ output[k] = ignore;
2981
+ lazy.push({ k, a: [input, parsed, tmp, $] });
2982
+ } else
2983
+ output[k] = $.call(output, k, tmp);
2984
+ } else if (output[k] !== ignore)
2985
+ output[k] = $.call(output, k, value);
2986
+ }
2987
+ for (let { length } = lazy, i = 0; i < length; i++) {
2988
+ const { k, a } = lazy[i];
2989
+ output[k] = $.call(output, k, revive.apply(null, a));
2990
+ }
2991
+ return output;
2992
+ };
2993
+ var set = (known, input, value) => {
2994
+ const index = Primitive(input.push(value) - 1);
2995
+ known.set(value, index);
2996
+ return index;
2997
+ };
2998
+ var parse = (text, reviver) => {
2999
+ const input = $parse(text, Primitives).map(primitives);
3000
+ const value = input[0];
3001
+ const $ = reviver || noop;
3002
+ const tmp = typeof value === object && value ? revive(input, /* @__PURE__ */ new Set(), value, $) : value;
3003
+ return $.call({ "": tmp }, "", tmp);
3004
+ };
3005
+ var stringify2 = (value, replacer, space) => {
3006
+ const $ = replacer && typeof replacer === object ? (k, v) => k === "" || -1 < replacer.indexOf(k) ? v : void 0 : replacer || noop;
3007
+ const known = /* @__PURE__ */ new Map();
3008
+ const input = [];
3009
+ const output = [];
3010
+ let i = +set(known, input, $.call({ "": value }, "", value));
3011
+ let firstRun = !i;
3012
+ while (i < input.length) {
3013
+ firstRun = true;
3014
+ output[i] = $stringify(input[i++], replace, space);
3015
+ }
3016
+ return "[" + output.join(",") + "]";
3017
+ function replace(key, value2) {
3018
+ if (firstRun) {
3019
+ firstRun = !firstRun;
3020
+ return value2;
3021
+ }
3022
+ const after = $.call(this, key, value2);
3023
+ switch (typeof after) {
3024
+ case object:
3025
+ if (after === null) return after;
3026
+ case primitive:
3027
+ return known.get(after) || set(known, input, after);
3028
+ }
3029
+ return after;
3030
+ }
3031
+ };
3032
+
3033
+ // node_modules/file-entry-cache/node_modules/flat-cache/dist/index.js
3034
+ var FlatCache = class extends Hookified {
3035
+ _cache = new CacheableMemory();
3036
+ _cacheDir = ".cache";
3037
+ _cacheId = "cache1";
3038
+ _persistInterval = 0;
3039
+ _persistTimer;
3040
+ _changesSinceLastSave = false;
3041
+ _parse = parse;
3042
+ _stringify = stringify2;
3043
+ constructor(options) {
3044
+ super();
3045
+ if (options) {
3046
+ this._cache = new CacheableMemory({
3047
+ ttl: options.ttl,
3048
+ useClone: options.useClone,
3049
+ lruSize: options.lruSize,
3050
+ checkInterval: options.expirationInterval
3051
+ });
3052
+ }
3053
+ if (options == null ? void 0 : options.cacheDir) {
3054
+ this._cacheDir = options.cacheDir;
3055
+ }
3056
+ if (options == null ? void 0 : options.cacheId) {
3057
+ this._cacheId = options.cacheId;
3058
+ }
3059
+ if (options == null ? void 0 : options.persistInterval) {
3060
+ this._persistInterval = options.persistInterval;
3061
+ this.startAutoPersist();
3062
+ }
3063
+ if (options == null ? void 0 : options.deserialize) {
3064
+ this._parse = options.deserialize;
3065
+ }
3066
+ if (options == null ? void 0 : options.serialize) {
3067
+ this._stringify = options.serialize;
3068
+ }
3069
+ }
3070
+ /**
3071
+ * The cache object
3072
+ * @property cache
3073
+ * @type {CacheableMemory}
3074
+ */
3075
+ get cache() {
3076
+ return this._cache;
3077
+ }
3078
+ /**
3079
+ * The cache directory
3080
+ * @property cacheDir
3081
+ * @type {String}
3082
+ * @default '.cache'
3083
+ */
3084
+ get cacheDir() {
3085
+ return this._cacheDir;
3086
+ }
3087
+ /**
3088
+ * Set the cache directory
3089
+ * @property cacheDir
3090
+ * @type {String}
3091
+ * @default '.cache'
3092
+ */
3093
+ set cacheDir(value) {
3094
+ this._cacheDir = value;
3095
+ }
3096
+ /**
3097
+ * The cache id
3098
+ * @property cacheId
3099
+ * @type {String}
3100
+ * @default 'cache1'
3101
+ */
3102
+ get cacheId() {
3103
+ return this._cacheId;
3104
+ }
3105
+ /**
3106
+ * Set the cache id
3107
+ * @property cacheId
3108
+ * @type {String}
3109
+ * @default 'cache1'
3110
+ */
3111
+ set cacheId(value) {
3112
+ this._cacheId = value;
3113
+ }
3114
+ /**
3115
+ * The flag to indicate if there are changes since the last save
3116
+ * @property changesSinceLastSave
3117
+ * @type {Boolean}
3118
+ * @default false
3119
+ */
3120
+ get changesSinceLastSave() {
3121
+ return this._changesSinceLastSave;
3122
+ }
3123
+ /**
3124
+ * The interval to persist the cache to disk. 0 means no timed persistence
3125
+ * @property persistInterval
3126
+ * @type {Number}
3127
+ * @default 0
3128
+ */
3129
+ get persistInterval() {
3130
+ return this._persistInterval;
3131
+ }
3132
+ /**
3133
+ * Set the interval to persist the cache to disk. 0 means no timed persistence
3134
+ * @property persistInterval
3135
+ * @type {Number}
3136
+ * @default 0
3137
+ */
3138
+ set persistInterval(value) {
3139
+ this._persistInterval = value;
3140
+ }
3141
+ /**
3142
+ * Load a cache identified by the given Id. If the element does not exists, then initialize an empty
3143
+ * cache storage. If specified `cacheDir` will be used as the directory to persist the data to. If omitted
3144
+ * then the cache module directory `.cacheDir` will be used instead
3145
+ *
3146
+ * @method load
3147
+ * @param cacheId {String} the id of the cache, would also be used as the name of the file cache
3148
+ * @param cacheDir {String} directory for the cache entry
3149
+ */
3150
+ // eslint-disable-next-line unicorn/prevent-abbreviations
3151
+ load(cacheId, cacheDir) {
3152
+ try {
3153
+ const filePath = path9.resolve(`${cacheDir ?? this._cacheDir}/${cacheId ?? this._cacheId}`);
3154
+ this.loadFile(filePath);
3155
+ this.emit(
3156
+ "load"
3157
+ /* LOAD */
3158
+ );
3159
+ } catch (error) {
3160
+ this.emit("error", error);
3161
+ }
3162
+ }
3163
+ /**
3164
+ * Load the cache from the provided file
3165
+ * @method loadFile
3166
+ * @param {String} pathToFile the path to the file containing the info for the cache
3167
+ */
3168
+ loadFile(pathToFile) {
3169
+ if (fs5.existsSync(pathToFile)) {
3170
+ const data = fs5.readFileSync(pathToFile, "utf8");
3171
+ const items = this._parse(data);
3172
+ for (const key of Object.keys(items)) {
3173
+ this._cache.set(items[key].key, items[key].value, { expire: items[key].expires });
3174
+ }
3175
+ this._changesSinceLastSave = true;
3176
+ }
3177
+ }
3178
+ /**
3179
+ * Returns the entire persisted object
3180
+ * @method all
3181
+ * @returns {*}
3182
+ */
3183
+ all() {
3184
+ const result = {};
3185
+ const items = Array.from(this._cache.items);
3186
+ for (const item of items) {
3187
+ result[item.key] = item.value;
3188
+ }
3189
+ return result;
3190
+ }
3191
+ /**
3192
+ * Returns an array with all the items in the cache { key, value, ttl }
3193
+ * @method items
3194
+ * @returns {Array}
3195
+ */
3196
+ get items() {
3197
+ return Array.from(this._cache.items);
3198
+ }
3199
+ /**
3200
+ * Returns the path to the file where the cache is persisted
3201
+ * @method cacheFilePath
3202
+ * @returns {String}
3203
+ */
3204
+ get cacheFilePath() {
3205
+ return path9.resolve(`${this._cacheDir}/${this._cacheId}`);
3206
+ }
3207
+ /**
3208
+ * Returns the path to the cache directory
3209
+ * @method cacheDirPath
3210
+ * @returns {String}
3211
+ */
3212
+ get cacheDirPath() {
3213
+ return path9.resolve(this._cacheDir);
3214
+ }
3215
+ /**
3216
+ * Returns an array with all the keys in the cache
3217
+ * @method keys
3218
+ * @returns {Array}
3219
+ */
3220
+ keys() {
3221
+ return Array.from(this._cache.keys);
3222
+ }
3223
+ /**
3224
+ * (Legacy) set key method. This method will be deprecated in the future
3225
+ * @method setKey
3226
+ * @param key {string} the key to set
3227
+ * @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
3228
+ */
3229
+ setKey(key, value, ttl) {
3230
+ this.set(key, value, ttl);
3231
+ }
3232
+ /**
3233
+ * Sets a key to a given value
3234
+ * @method set
3235
+ * @param key {string} the key to set
3236
+ * @param value {object} the value of the key. Could be any object that can be serialized with JSON.stringify
3237
+ * @param [ttl] {number} the time to live in milliseconds
3238
+ */
3239
+ set(key, value, ttl) {
3240
+ this._cache.set(key, value, ttl);
3241
+ this._changesSinceLastSave = true;
3242
+ }
3243
+ /**
3244
+ * (Legacy) Remove a given key from the cache. This method will be deprecated in the future
3245
+ * @method removeKey
3246
+ * @param key {String} the key to remove from the object
3247
+ */
3248
+ removeKey(key) {
3249
+ this.delete(key);
3250
+ }
3251
+ /**
3252
+ * Remove a given key from the cache
3253
+ * @method delete
3254
+ * @param key {String} the key to remove from the object
3255
+ */
3256
+ delete(key) {
3257
+ this._cache.delete(key);
3258
+ this._changesSinceLastSave = true;
3259
+ this.emit("delete", key);
3260
+ }
3261
+ /**
3262
+ * (Legacy) Return the value of the provided key. This method will be deprecated in the future
3263
+ * @method getKey<T>
3264
+ * @param key {String} the name of the key to retrieve
3265
+ * @returns {*} at T the value from the key
3266
+ */
3267
+ getKey(key) {
3268
+ return this.get(key);
3269
+ }
3270
+ /**
3271
+ * Return the value of the provided key
3272
+ * @method get<T>
3273
+ * @param key {String} the name of the key to retrieve
3274
+ * @returns {*} at T the value from the key
3275
+ */
3276
+ get(key) {
3277
+ return this._cache.get(key);
3278
+ }
3279
+ /**
3280
+ * Clear the cache and save the state to disk
3281
+ * @method clear
3282
+ */
3283
+ clear() {
3284
+ try {
3285
+ this._cache.clear();
3286
+ this._changesSinceLastSave = true;
3287
+ this.save();
3288
+ this.emit(
3289
+ "clear"
3290
+ /* CLEAR */
3291
+ );
3292
+ } catch (error) {
3293
+ this.emit("error", error);
3294
+ }
3295
+ }
3296
+ /**
3297
+ * Save the state of the cache identified by the docId to disk
3298
+ * as a JSON structure
3299
+ * @method save
3300
+ */
3301
+ save(force = false) {
3302
+ try {
3303
+ if (this._changesSinceLastSave || force) {
3304
+ const filePath = this.cacheFilePath;
3305
+ const items = Array.from(this._cache.items);
3306
+ const data = this._stringify(items);
3307
+ if (!fs5.existsSync(this._cacheDir)) {
3308
+ fs5.mkdirSync(this._cacheDir, { recursive: true });
3309
+ }
3310
+ fs5.writeFileSync(filePath, data);
3311
+ this._changesSinceLastSave = false;
3312
+ this.emit(
3313
+ "save"
3314
+ /* SAVE */
3315
+ );
3316
+ }
3317
+ } catch (error) {
3318
+ this.emit("error", error);
3319
+ }
3320
+ }
3321
+ /**
3322
+ * Remove the file where the cache is persisted
3323
+ * @method removeCacheFile
3324
+ * @return {Boolean} true or false if the file was successfully deleted
3325
+ */
3326
+ removeCacheFile() {
3327
+ try {
3328
+ if (fs5.existsSync(this.cacheFilePath)) {
3329
+ fs5.rmSync(this.cacheFilePath);
3330
+ return true;
3331
+ }
3332
+ } catch (error) {
3333
+ this.emit("error", error);
3334
+ }
3335
+ return false;
3336
+ }
3337
+ /**
3338
+ * Destroy the cache. This will remove the directory, file, and memory cache
3339
+ * @method destroy
3340
+ * @param [includeCacheDir=false] {Boolean} if true, the cache directory will be removed
3341
+ * @return {undefined}
3342
+ */
3343
+ destroy(includeCacheDirectory = false) {
3344
+ try {
3345
+ this._cache.clear();
3346
+ this.stopAutoPersist();
3347
+ if (includeCacheDirectory) {
3348
+ fs5.rmSync(this.cacheDirPath, { recursive: true, force: true });
3349
+ } else {
3350
+ fs5.rmSync(this.cacheFilePath, { recursive: true, force: true });
3351
+ }
3352
+ this._changesSinceLastSave = false;
3353
+ this.emit(
3354
+ "destroy"
3355
+ /* DESTROY */
3356
+ );
3357
+ } catch (error) {
3358
+ this.emit("error", error);
3359
+ }
3360
+ }
3361
+ /**
3362
+ * Start the auto persist interval
3363
+ * @method startAutoPersist
3364
+ */
3365
+ startAutoPersist() {
3366
+ if (this._persistInterval > 0) {
3367
+ if (this._persistTimer) {
3368
+ clearInterval(this._persistTimer);
3369
+ this._persistTimer = void 0;
3370
+ }
3371
+ this._persistTimer = setInterval(() => {
3372
+ this.save();
3373
+ }, this._persistInterval);
3374
+ }
3375
+ }
3376
+ /**
3377
+ * Stop the auto persist interval
3378
+ * @method stopAutoPersist
3379
+ */
3380
+ stopAutoPersist() {
3381
+ if (this._persistTimer) {
3382
+ clearInterval(this._persistTimer);
3383
+ this._persistTimer = void 0;
3384
+ }
3385
+ }
3386
+ };
3387
+ function createFromFile(filePath, options) {
3388
+ const cache = new FlatCache(options);
3389
+ cache.loadFile(filePath);
3390
+ return cache;
3391
+ }
3392
+
3393
+ // node_modules/file-entry-cache/dist/index.js
3394
+ function createFromFile2(filePath, useCheckSum, currentWorkingDirectory) {
3395
+ const fname = path10.basename(filePath);
3396
+ const directory = path10.dirname(filePath);
3397
+ return create(fname, directory, useCheckSum, currentWorkingDirectory);
3398
+ }
3399
+ function create(cacheId, cacheDirectory, useCheckSum, currentWorkingDirectory) {
3400
+ const options = {
3401
+ currentWorkingDirectory,
3402
+ useCheckSum,
3403
+ cache: {
3404
+ cacheId,
3405
+ cacheDir: cacheDirectory
3406
+ }
3407
+ };
3408
+ const fileEntryCache = new FileEntryCache(options);
3409
+ if (cacheDirectory) {
3410
+ const cachePath = `${cacheDirectory}/${cacheId}`;
3411
+ if (fs6.existsSync(cachePath)) {
3412
+ fileEntryCache.cache = createFromFile(cachePath, options.cache);
3413
+ }
3414
+ }
3415
+ return fileEntryCache;
3416
+ }
3417
+ var FileEntryDefault = class {
3418
+ static create = create;
3419
+ static createFromFile = createFromFile2;
3420
+ };
3421
+ var FileEntryCache = class {
3422
+ _cache = new FlatCache({ useClone: false });
3423
+ _useCheckSum = false;
3424
+ _currentWorkingDirectory;
3425
+ _hashAlgorithm = "md5";
3426
+ constructor(options) {
3427
+ if (options == null ? void 0 : options.cache) {
3428
+ this._cache = new FlatCache(options.cache);
3429
+ }
3430
+ if (options == null ? void 0 : options.useCheckSum) {
3431
+ this._useCheckSum = options.useCheckSum;
3432
+ }
3433
+ if (options == null ? void 0 : options.currentWorkingDirectory) {
3434
+ this._currentWorkingDirectory = options.currentWorkingDirectory;
3435
+ }
3436
+ if (options == null ? void 0 : options.hashAlgorithm) {
3437
+ this._hashAlgorithm = options.hashAlgorithm;
3438
+ }
3439
+ }
3440
+ get cache() {
3441
+ return this._cache;
3442
+ }
3443
+ set cache(cache) {
3444
+ this._cache = cache;
3445
+ }
3446
+ get useCheckSum() {
3447
+ return this._useCheckSum;
3448
+ }
3449
+ set useCheckSum(value) {
3450
+ this._useCheckSum = value;
3451
+ }
3452
+ get hashAlgorithm() {
3453
+ return this._hashAlgorithm;
3454
+ }
3455
+ set hashAlgorithm(value) {
3456
+ this._hashAlgorithm = value;
3457
+ }
3458
+ get currentWorkingDirectory() {
3459
+ return this._currentWorkingDirectory;
3460
+ }
3461
+ set currentWorkingDirectory(value) {
3462
+ this._currentWorkingDirectory = value;
3463
+ }
3464
+ /**
3465
+ * Given a buffer, calculate md5 hash of its content.
3466
+ * @method getHash
3467
+ * @param {Buffer} buffer buffer to calculate hash on
3468
+ * @return {String} content hash digest
3469
+ */
3470
+ // eslint-disable-next-line @typescript-eslint/ban-types
3471
+ getHash(buffer) {
3472
+ return crypto2.createHash(this._hashAlgorithm).update(buffer).digest("hex");
3473
+ }
3474
+ /**
3475
+ * Create the key for the file path used for caching.
3476
+ * @method createFileKey
3477
+ * @param {String} filePath
3478
+ * @return {String}
3479
+ */
3480
+ createFileKey(filePath, options) {
3481
+ let result = filePath;
3482
+ const currentWorkingDirectory = (options == null ? void 0 : options.currentWorkingDirectory) ?? this._currentWorkingDirectory;
3483
+ if (currentWorkingDirectory && filePath.startsWith(currentWorkingDirectory)) {
3484
+ const splitPath = filePath.split(currentWorkingDirectory).pop();
3485
+ if (splitPath) {
3486
+ result = splitPath;
3487
+ if (result.startsWith("/")) {
3488
+ result = result.slice(1);
3489
+ }
3490
+ }
3491
+ }
3492
+ return result;
3493
+ }
3494
+ /**
3495
+ * Check if the file path is a relative path
3496
+ * @method isRelativePath
3497
+ * @param filePath - The file path to check
3498
+ * @returns {boolean} if the file path is a relative path, false otherwise
3499
+ */
3500
+ isRelativePath(filePath) {
3501
+ return !path10.isAbsolute(filePath);
3502
+ }
3503
+ /**
3504
+ * Delete the cache file from the disk
3505
+ * @method deleteCacheFile
3506
+ * @return {boolean} true if the file was deleted, false otherwise
3507
+ */
3508
+ deleteCacheFile() {
3509
+ return this._cache.removeCacheFile();
3510
+ }
3511
+ /**
3512
+ * Remove the cache from the file and clear the memory cache
3513
+ * @method destroy
3514
+ */
3515
+ destroy() {
3516
+ this._cache.destroy();
3517
+ }
3518
+ /**
3519
+ * Remove and Entry From the Cache
3520
+ * @method removeEntry
3521
+ * @param filePath - The file path to remove from the cache
3522
+ */
3523
+ removeEntry(filePath, options) {
3524
+ if (this.isRelativePath(filePath)) {
3525
+ filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options == null ? void 0 : options.currentWorkingDirectory });
3526
+ this._cache.removeKey(this.createFileKey(filePath));
3527
+ }
3528
+ const key = this.createFileKey(filePath, { currentWorkingDirectory: options == null ? void 0 : options.currentWorkingDirectory });
3529
+ this._cache.removeKey(key);
3530
+ }
3531
+ /**
3532
+ * Reconcile the cache
3533
+ * @method reconcile
3534
+ */
3535
+ reconcile() {
3536
+ const items = this._cache.items;
3537
+ for (const item of items) {
3538
+ const fileDescriptor = this.getFileDescriptor(item.key);
3539
+ if (fileDescriptor.notFound) {
3540
+ this._cache.removeKey(item.key);
3541
+ }
3542
+ }
3543
+ this._cache.save();
3544
+ }
3545
+ /**
3546
+ * Check if the file has changed
3547
+ * @method hasFileChanged
3548
+ * @param filePath - The file path to check
3549
+ * @returns {boolean} if the file has changed, false otherwise
3550
+ */
3551
+ hasFileChanged(filePath) {
3552
+ let result = false;
3553
+ const fileDescriptor = this.getFileDescriptor(filePath);
3554
+ if ((!fileDescriptor.err || !fileDescriptor.notFound) && fileDescriptor.changed) {
3555
+ result = true;
3556
+ }
3557
+ return result;
3558
+ }
3559
+ /**
3560
+ * Get the file descriptor for the file path
3561
+ * @method getFileDescriptor
3562
+ * @param filePath - The file path to get the file descriptor for
3563
+ * @param options - The options for getting the file descriptor
3564
+ * @returns The file descriptor
3565
+ */
3566
+ getFileDescriptor(filePath, options) {
3567
+ var _a, _b, _c;
3568
+ let fstat;
3569
+ const result = {
3570
+ key: this.createFileKey(filePath),
3571
+ changed: false,
3572
+ meta: {}
3573
+ };
3574
+ result.meta = this._cache.getKey(result.key) ?? {};
3575
+ filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options == null ? void 0 : options.currentWorkingDirectory });
3576
+ const useCheckSumValue = (options == null ? void 0 : options.useCheckSum) ?? this._useCheckSum;
3577
+ try {
3578
+ fstat = fs6.statSync(filePath);
3579
+ result.meta = {
3580
+ size: fstat.size
3581
+ };
3582
+ result.meta.mtime = fstat.mtime.getTime();
3583
+ if (useCheckSumValue) {
3584
+ const buffer = fs6.readFileSync(filePath);
3585
+ result.meta.hash = this.getHash(buffer);
3586
+ }
3587
+ } catch (error) {
3588
+ this.removeEntry(filePath);
3589
+ let notFound = false;
3590
+ if (error.message.includes("ENOENT")) {
3591
+ notFound = true;
3592
+ }
3593
+ return {
3594
+ key: result.key,
3595
+ err: error,
3596
+ notFound,
3597
+ meta: {}
3598
+ };
3599
+ }
3600
+ const metaCache = this._cache.getKey(result.key);
3601
+ if (!metaCache) {
3602
+ result.changed = true;
3603
+ this._cache.setKey(result.key, result.meta);
3604
+ return result;
3605
+ }
3606
+ if (result.meta.data === void 0) {
3607
+ result.meta.data = metaCache.data;
3608
+ }
3609
+ if ((metaCache == null ? void 0 : metaCache.mtime) !== ((_a = result.meta) == null ? void 0 : _a.mtime) || (metaCache == null ? void 0 : metaCache.size) !== ((_b = result.meta) == null ? void 0 : _b.size)) {
3610
+ result.changed = true;
3611
+ }
3612
+ if (useCheckSumValue && (metaCache == null ? void 0 : metaCache.hash) !== ((_c = result.meta) == null ? void 0 : _c.hash)) {
3613
+ result.changed = true;
3614
+ }
3615
+ this._cache.setKey(result.key, result.meta);
3616
+ return result;
3617
+ }
3618
+ /**
3619
+ * Get the file descriptors for the files
3620
+ * @method normalizeEntries
3621
+ * @param files?: string[] - The files to get the file descriptors for
3622
+ * @returns The file descriptors
3623
+ */
3624
+ normalizeEntries(files) {
3625
+ const result = new Array();
3626
+ if (files) {
3627
+ for (const file of files) {
3628
+ const fileDescriptor = this.getFileDescriptor(file);
3629
+ result.push(fileDescriptor);
3630
+ }
3631
+ return result;
3632
+ }
3633
+ const keys2 = this.cache.keys();
3634
+ for (const key of keys2) {
3635
+ const fileDescriptor = this.getFileDescriptor(key);
3636
+ if (!fileDescriptor.notFound && !fileDescriptor.err) {
3637
+ result.push(fileDescriptor);
3638
+ }
3639
+ }
3640
+ return result;
3641
+ }
3642
+ /**
3643
+ * Analyze the files
3644
+ * @method analyzeFiles
3645
+ * @param files - The files to analyze
3646
+ * @returns {AnalyzedFiles} The analysis of the files
3647
+ */
3648
+ analyzeFiles(files) {
3649
+ const result = {
3650
+ changedFiles: [],
3651
+ notFoundFiles: [],
3652
+ notChangedFiles: []
3653
+ };
3654
+ const fileDescriptors = this.normalizeEntries(files);
3655
+ for (const fileDescriptor of fileDescriptors) {
3656
+ if (fileDescriptor.notFound) {
3657
+ result.notFoundFiles.push(fileDescriptor.key);
3658
+ } else if (fileDescriptor.changed) {
3659
+ result.changedFiles.push(fileDescriptor.key);
3660
+ } else {
3661
+ result.notChangedFiles.push(fileDescriptor.key);
3662
+ }
3663
+ }
3664
+ return result;
3665
+ }
3666
+ /**
3667
+ * Get the updated files
3668
+ * @method getUpdatedFiles
3669
+ * @param files - The files to get the updated files for
3670
+ * @returns {string[]} The updated files
3671
+ */
3672
+ getUpdatedFiles(files) {
3673
+ const result = new Array();
3674
+ const fileDescriptors = this.normalizeEntries(files);
3675
+ for (const fileDescriptor of fileDescriptors) {
3676
+ if (fileDescriptor.changed) {
3677
+ result.push(fileDescriptor.key);
3678
+ }
3679
+ }
3680
+ return result;
3681
+ }
3682
+ /**
3683
+ * Get the not found files
3684
+ * @method getFileDescriptorsByPath
3685
+ * @param filePath - the files that you want to get from a path
3686
+ * @returns {FileDescriptor[]} The not found files
3687
+ */
3688
+ getFileDescriptorsByPath(filePath) {
3689
+ const result = new Array();
3690
+ const keys2 = this._cache.keys();
3691
+ for (const key of keys2) {
3692
+ const absolutePath = this.getAbsolutePath(filePath);
3693
+ if (absolutePath.startsWith(filePath)) {
3694
+ const fileDescriptor = this.getFileDescriptor(key);
3695
+ result.push(fileDescriptor);
3696
+ }
3697
+ }
3698
+ return result;
3699
+ }
3700
+ /**
3701
+ * Get the Absolute Path. If it is already absolute it will return the path as is.
3702
+ * @method getAbsolutePath
3703
+ * @param filePath - The file path to get the absolute path for
3704
+ * @param options - The options for getting the absolute path. The current working directory is used if not provided.
3705
+ * @returns {string}
3706
+ */
3707
+ getAbsolutePath(filePath, options) {
3708
+ if (this.isRelativePath(filePath)) {
3709
+ const currentWorkingDirectory = (options == null ? void 0 : options.currentWorkingDirectory) ?? this._currentWorkingDirectory ?? process.cwd();
3710
+ filePath = path10.resolve(currentWorkingDirectory, filePath);
3711
+ }
3712
+ return filePath;
3713
+ }
3714
+ /**
3715
+ * Rename the absolute path keys. This is used when a directory is changed or renamed.
3716
+ * @method renameAbsolutePathKeys
3717
+ * @param oldPath - The old path to rename
3718
+ * @param newPath - The new path to rename to
3719
+ */
3720
+ renameAbsolutePathKeys(oldPath, newPath) {
3721
+ const keys2 = this._cache.keys();
3722
+ for (const key of keys2) {
3723
+ if (key.startsWith(oldPath)) {
3724
+ const newKey = key.replace(oldPath, newPath);
3725
+ const meta = this._cache.getKey(key);
3726
+ this._cache.removeKey(key);
3727
+ this._cache.setKey(newKey, meta);
3728
+ }
3729
+ }
3730
+ }
3731
+ };
3732
+
3733
+ // src/cli/format-results-cache.js
3734
+ import { version as prettierVersion } from "../index.mjs";
3735
+ var optionsHashCache = /* @__PURE__ */ new WeakMap();
3736
+ var nodeVersion = process.version;
3737
+ function getHashOfOptions(options) {
3738
+ if (optionsHashCache.has(options)) {
3739
+ return optionsHashCache.get(options);
3740
+ }
3741
+ const hash2 = createHash(
3742
+ `${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify2.default)(options)}`
3743
+ );
3744
+ optionsHashCache.set(options, hash2);
3745
+ return hash2;
3746
+ }
3747
+ function getMetadataFromFileDescriptor(fileDescriptor) {
3748
+ return fileDescriptor.meta;
3749
+ }
3750
+ var _fileEntryCache;
3751
+ var FormatResultsCache = class {
3752
+ /**
3753
+ * @param {string} cacheFileLocation The path of cache file location. (default: `node_modules/.cache/prettier/.prettier-cache`)
3754
+ * @param {string} cacheStrategy
3755
+ */
3756
+ constructor(cacheFileLocation, cacheStrategy) {
3757
+ __privateAdd(this, _fileEntryCache);
3758
+ const useChecksum = cacheStrategy === "content";
3759
+ try {
3760
+ __privateSet(this, _fileEntryCache, FileEntryDefault.createFromFile(
3761
+ /* filePath */
3762
+ cacheFileLocation,
3763
+ useChecksum
3764
+ ));
3765
+ } catch {
3766
+ if (fs7.existsSync(cacheFileLocation)) {
3767
+ fs7.unlinkSync(cacheFileLocation);
3768
+ __privateSet(this, _fileEntryCache, FileEntryDefault.createFromFile(
3769
+ /* filePath */
3770
+ cacheFileLocation,
3771
+ useChecksum
3772
+ ));
3773
+ }
3774
+ }
3775
+ }
3776
+ /**
3777
+ * @param {string} filePath
3778
+ * @param {any} options
3779
+ */
3780
+ existsAvailableFormatResultsCache(filePath, options) {
3781
+ var _a;
3782
+ const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
3783
+ if (fileDescriptor.notFound || fileDescriptor.changed) {
3784
+ return false;
3785
+ }
3786
+ const hashOfOptions = (_a = getMetadataFromFileDescriptor(fileDescriptor).data) == null ? void 0 : _a.hashOfOptions;
3787
+ return hashOfOptions && hashOfOptions === getHashOfOptions(options);
3788
+ }
3789
+ /**
3790
+ * @param {string} filePath
3791
+ * @param {any} options
3792
+ */
3793
+ setFormatResultsCache(filePath, options) {
3794
+ const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
3795
+ if (!fileDescriptor.notFound) {
3796
+ const meta = getMetadataFromFileDescriptor(fileDescriptor);
3797
+ meta.data = { ...meta.data, hashOfOptions: getHashOfOptions(options) };
3798
+ }
3799
+ }
3800
+ /**
3801
+ * @param {string} filePath
3802
+ */
3803
+ removeFormatResultsCache(filePath) {
3804
+ __privateGet(this, _fileEntryCache).removeEntry(filePath);
3805
+ }
3806
+ reconcile() {
3807
+ __privateGet(this, _fileEntryCache).reconcile();
3808
+ }
3809
+ };
3810
+ _fileEntryCache = new WeakMap();
3811
+ var format_results_cache_default = FormatResultsCache;
3812
+
3813
+ // src/cli/is-tty.js
3814
+ function isTTY() {
3815
+ return process.stdout.isTTY && !mockable.isCI();
3816
+ }
3817
+
3818
+ // src/cli/options/get-options-for-file.js
3819
+ var import_dashify2 = __toESM(require_dashify(), 1);
3820
+ import { resolveConfig } from "../index.mjs";
3821
+ function getOptions(argv, detailedOptions) {
3822
+ return Object.fromEntries(
3823
+ detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
3824
+ );
3825
+ }
3826
+ function cliifyOptions(object2, apiDetailedOptionMap) {
3827
+ return Object.fromEntries(
3828
+ Object.entries(object2 || {}).map(([key, value]) => {
3829
+ const apiOption = apiDetailedOptionMap[key];
3830
+ const cliKey = apiOption ? apiOption.name : key;
3831
+ return [(0, import_dashify2.default)(cliKey), value];
3832
+ })
3833
+ );
3834
+ }
3835
+ function createApiDetailedOptionMap(detailedOptions) {
3836
+ return Object.fromEntries(
3837
+ detailedOptions.filter(
3838
+ (option) => option.forwardToApi && option.forwardToApi !== option.name
3839
+ ).map((option) => [option.forwardToApi, option])
3840
+ );
3841
+ }
3842
+ function parseArgsToOptions(context, overrideDefaults) {
3843
+ const minimistOptions = createMinimistOptions(context.detailedOptions);
3844
+ const apiDetailedOptionMap = createApiDetailedOptionMap(
3845
+ context.detailedOptions
3846
+ );
3118
3847
  return getOptions(
3119
3848
  normalize_cli_options_default(
3120
3849
  minimistParse(context.rawArguments, {
@@ -3286,11 +4015,11 @@ async function format3(context, input, opt) {
3286
4015
  "prettier(input) !== prettier(prettier(input))\n" + diff(pp, pppp)
3287
4016
  );
3288
4017
  } else {
3289
- const stringify4 = (obj) => JSON.stringify(obj, null, 2);
3290
- const ast = stringify4(
4018
+ const stringify5 = (obj) => JSON.stringify(obj, null, 2);
4019
+ const ast = stringify5(
3291
4020
  (await prettier.__debug.parse(input, opt, { massage: true })).ast
3292
4021
  );
3293
- const past = stringify4(
4022
+ const past = stringify5(
3294
4023
  (await prettier.__debug.parse(pp, opt, { massage: true })).ast
3295
4024
  );
3296
4025
  if (ast !== past) {
@@ -3390,7 +4119,7 @@ async function formatStdin(context) {
3390
4119
  }
3391
4120
  const options = await get_options_for_file_default(
3392
4121
  context,
3393
- filepath ? path9.resolve(filepath) : void 0
4122
+ filepath ? path11.resolve(filepath) : void 0
3394
4123
  );
3395
4124
  if (await listDifferent(context, input, options, "(stdin)")) {
3396
4125
  return;
@@ -3426,7 +4155,7 @@ async function formatFiles(context) {
3426
4155
  } else if (!context.argv.cacheLocation) {
3427
4156
  const stat = await statSafe(cacheFilePath);
3428
4157
  if (stat) {
3429
- await fs5.unlink(cacheFilePath);
4158
+ await fs8.unlink(cacheFilePath);
3430
4159
  }
3431
4160
  }
3432
4161
  for await (const { error, filename, ignoreUnknown } of expandPatterns(
@@ -3445,7 +4174,7 @@ async function formatFiles(context) {
3445
4174
  ...await get_options_for_file_default(context, filename),
3446
4175
  filepath: filename
3447
4176
  };
3448
- const fileNameToDisplay = normalizeToPosix(path9.relative(cwd2, filename));
4177
+ const fileNameToDisplay = normalizeToPosix(path11.relative(cwd2, filename));
3449
4178
  let printedFilename;
3450
4179
  if (isTTY()) {
3451
4180
  printedFilename = context.logger.log(fileNameToDisplay, {
@@ -3455,7 +4184,7 @@ async function formatFiles(context) {
3455
4184
  }
3456
4185
  let input;
3457
4186
  try {
3458
- input = await fs5.readFile(filename, "utf8");
4187
+ input = await fs8.readFile(filename, "utf8");
3459
4188
  } catch (error2) {
3460
4189
  context.logger.log("");
3461
4190
  context.logger.error(
@@ -3568,11 +4297,12 @@ ${error2.message}`
3568
4297
  // src/cli/logger.js
3569
4298
  import readline from "readline";
3570
4299
 
3571
- // node_modules/ansi-regex/index.js
4300
+ // node_modules/strip-ansi/node_modules/ansi-regex/index.js
3572
4301
  function ansiRegex({ onlyFirst = false } = {}) {
4302
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
3573
4303
  const pattern = [
3574
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
3575
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"
4304
+ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
4305
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
3576
4306
  ].join("|");
3577
4307
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
3578
4308
  }
@@ -3586,13 +4316,221 @@ function stripAnsi(string) {
3586
4316
  return string.replace(regex, "");
3587
4317
  }
3588
4318
 
4319
+ // node_modules/wcwidth.js/combining.js
4320
+ var combining_default = [
4321
+ [768, 879],
4322
+ [1155, 1158],
4323
+ [1160, 1161],
4324
+ [1425, 1469],
4325
+ [1471, 1471],
4326
+ [1473, 1474],
4327
+ [1476, 1477],
4328
+ [1479, 1479],
4329
+ [1536, 1539],
4330
+ [1552, 1557],
4331
+ [1611, 1630],
4332
+ [1648, 1648],
4333
+ [1750, 1764],
4334
+ [1767, 1768],
4335
+ [1770, 1773],
4336
+ [1807, 1807],
4337
+ [1809, 1809],
4338
+ [1840, 1866],
4339
+ [1958, 1968],
4340
+ [2027, 2035],
4341
+ [2305, 2306],
4342
+ [2364, 2364],
4343
+ [2369, 2376],
4344
+ [2381, 2381],
4345
+ [2385, 2388],
4346
+ [2402, 2403],
4347
+ [2433, 2433],
4348
+ [2492, 2492],
4349
+ [2497, 2500],
4350
+ [2509, 2509],
4351
+ [2530, 2531],
4352
+ [2561, 2562],
4353
+ [2620, 2620],
4354
+ [2625, 2626],
4355
+ [2631, 2632],
4356
+ [2635, 2637],
4357
+ [2672, 2673],
4358
+ [2689, 2690],
4359
+ [2748, 2748],
4360
+ [2753, 2757],
4361
+ [2759, 2760],
4362
+ [2765, 2765],
4363
+ [2786, 2787],
4364
+ [2817, 2817],
4365
+ [2876, 2876],
4366
+ [2879, 2879],
4367
+ [2881, 2883],
4368
+ [2893, 2893],
4369
+ [2902, 2902],
4370
+ [2946, 2946],
4371
+ [3008, 3008],
4372
+ [3021, 3021],
4373
+ [3134, 3136],
4374
+ [3142, 3144],
4375
+ [3146, 3149],
4376
+ [3157, 3158],
4377
+ [3260, 3260],
4378
+ [3263, 3263],
4379
+ [3270, 3270],
4380
+ [3276, 3277],
4381
+ [3298, 3299],
4382
+ [3393, 3395],
4383
+ [3405, 3405],
4384
+ [3530, 3530],
4385
+ [3538, 3540],
4386
+ [3542, 3542],
4387
+ [3633, 3633],
4388
+ [3636, 3642],
4389
+ [3655, 3662],
4390
+ [3761, 3761],
4391
+ [3764, 3769],
4392
+ [3771, 3772],
4393
+ [3784, 3789],
4394
+ [3864, 3865],
4395
+ [3893, 3893],
4396
+ [3895, 3895],
4397
+ [3897, 3897],
4398
+ [3953, 3966],
4399
+ [3968, 3972],
4400
+ [3974, 3975],
4401
+ [3984, 3991],
4402
+ [3993, 4028],
4403
+ [4038, 4038],
4404
+ [4141, 4144],
4405
+ [4146, 4146],
4406
+ [4150, 4151],
4407
+ [4153, 4153],
4408
+ [4184, 4185],
4409
+ [4448, 4607],
4410
+ [4959, 4959],
4411
+ [5906, 5908],
4412
+ [5938, 5940],
4413
+ [5970, 5971],
4414
+ [6002, 6003],
4415
+ [6068, 6069],
4416
+ [6071, 6077],
4417
+ [6086, 6086],
4418
+ [6089, 6099],
4419
+ [6109, 6109],
4420
+ [6155, 6157],
4421
+ [6313, 6313],
4422
+ [6432, 6434],
4423
+ [6439, 6440],
4424
+ [6450, 6450],
4425
+ [6457, 6459],
4426
+ [6679, 6680],
4427
+ [6912, 6915],
4428
+ [6964, 6964],
4429
+ [6966, 6970],
4430
+ [6972, 6972],
4431
+ [6978, 6978],
4432
+ [7019, 7027],
4433
+ [7616, 7626],
4434
+ [7678, 7679],
4435
+ [8203, 8207],
4436
+ [8234, 8238],
4437
+ [8288, 8291],
4438
+ [8298, 8303],
4439
+ [8400, 8431],
4440
+ [12330, 12335],
4441
+ [12441, 12442],
4442
+ [43014, 43014],
4443
+ [43019, 43019],
4444
+ [43045, 43046],
4445
+ [64286, 64286],
4446
+ [65024, 65039],
4447
+ [65056, 65059],
4448
+ [65279, 65279],
4449
+ [65529, 65531],
4450
+ [68097, 68099],
4451
+ [68101, 68102],
4452
+ [68108, 68111],
4453
+ [68152, 68154],
4454
+ [68159, 68159],
4455
+ [119143, 119145],
4456
+ [119155, 119170],
4457
+ [119173, 119179],
4458
+ [119210, 119213],
4459
+ [119362, 119364],
4460
+ [917505, 917505],
4461
+ [917536, 917631],
4462
+ [917760, 917999]
4463
+ ];
4464
+
4465
+ // node_modules/wcwidth.js/index.js
4466
+ var DEFAULTS = {
4467
+ nul: 0,
4468
+ control: 0
4469
+ };
4470
+ function bisearch(ucs) {
4471
+ let min = 0;
4472
+ let max = combining_default.length - 1;
4473
+ let mid;
4474
+ if (ucs < combining_default[0][0] || ucs > combining_default[max][1]) return false;
4475
+ while (max >= min) {
4476
+ mid = Math.floor((min + max) / 2);
4477
+ if (ucs > combining_default[mid][1]) min = mid + 1;
4478
+ else if (ucs < combining_default[mid][0]) max = mid - 1;
4479
+ else return true;
4480
+ }
4481
+ return false;
4482
+ }
4483
+ function wcwidth(ucs, opts) {
4484
+ if (ucs === 0) return opts.nul;
4485
+ if (ucs < 32 || ucs >= 127 && ucs < 160) return opts.control;
4486
+ if (bisearch(ucs)) return 0;
4487
+ return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
4488
+ ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
4489
+ ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
4490
+ ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
4491
+ ucs >= 65040 && ucs <= 65049 || // Vertical forms
4492
+ ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
4493
+ ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
4494
+ ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
4495
+ }
4496
+ function wcswidth(str, opts) {
4497
+ let h;
4498
+ let l;
4499
+ let s = 0;
4500
+ let n;
4501
+ if (typeof str !== "string") return wcwidth(str, opts);
4502
+ for (let i = 0; i < str.length; i++) {
4503
+ h = str.charCodeAt(i);
4504
+ if (h >= 55296 && h <= 56319) {
4505
+ l = str.charCodeAt(++i);
4506
+ if (l >= 56320 && l <= 57343) {
4507
+ h = (h - 55296) * 1024 + (l - 56320) + 65536;
4508
+ } else {
4509
+ i--;
4510
+ }
4511
+ }
4512
+ n = wcwidth(h, opts);
4513
+ if (n < 0) return -1;
4514
+ s += n;
4515
+ }
4516
+ return s;
4517
+ }
4518
+ var _ = (str) => wcswidth(str, DEFAULTS);
4519
+ _.config = (opts = {}) => {
4520
+ opts = {
4521
+ ...DEFAULTS,
4522
+ ...opts
4523
+ };
4524
+ return (str) => wcswidth(str, opts);
4525
+ };
4526
+ var wcwidth_default = _;
4527
+
3589
4528
  // src/cli/logger.js
3590
- var import_wcwidth = __toESM(require_wcwidth(), 1);
3591
4529
  var countLines = (stream, text) => {
3592
4530
  const columns = stream.columns || 80;
3593
4531
  let lineCount = 0;
3594
4532
  for (const line of stripAnsi(text).split("\n")) {
3595
- lineCount += Math.max(1, Math.ceil((0, import_wcwidth.default)(line) / columns));
4533
+ lineCount += Math.max(1, Math.ceil(wcwidth_default(line) / columns));
3596
4534
  }
3597
4535
  return lineCount;
3598
4536
  };
@@ -3606,10 +4544,8 @@ var clear = (stream, text) => () => {
3606
4544
  readline.cursorTo(stream, 0);
3607
4545
  }
3608
4546
  };
3609
- var emptyLogResult = {
3610
- clear() {
3611
- }
3612
- };
4547
+ var emptyLogResult = { clear() {
4548
+ } };
3613
4549
  function createLogger(logLevel = "log") {
3614
4550
  return {
3615
4551
  logLevel,
@@ -3654,14 +4590,17 @@ function createLogger(logLevel = "log") {
3654
4590
  if (loggerName === "debug") {
3655
4591
  return true;
3656
4592
  }
4593
+ // fall through
3657
4594
  case "log":
3658
4595
  if (loggerName === "log") {
3659
4596
  return true;
3660
4597
  }
4598
+ // fall through
3661
4599
  case "warn":
3662
4600
  if (loggerName === "warn") {
3663
4601
  return true;
3664
4602
  }
4603
+ // fall through
3665
4604
  case "error":
3666
4605
  return loggerName === "error";
3667
4606
  }
@@ -3713,14 +4652,16 @@ function createDefaultValueDisplay(value) {
3713
4652
  }
3714
4653
  function getOptionDefaultValue(context, optionName) {
3715
4654
  var _a;
3716
- const option = context.detailedOptions.find(({
3717
- name
3718
- }) => name === optionName);
4655
+ const option = context.detailedOptions.find(
4656
+ ({ name }) => name === optionName
4657
+ );
3719
4658
  if ((option == null ? void 0 : option.default) !== void 0) {
3720
4659
  return option.default;
3721
4660
  }
3722
4661
  const optionCamelName = camelCase(optionName);
3723
- return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find((option2) => !option2.deprecated && option2.name === optionCamelName)) == null ? void 0 : _a.default);
4662
+ return formatOptionsHiddenDefaults[optionCamelName] ?? ((_a = context.supportOptions.find(
4663
+ (option2) => !option2.deprecated && option2.name === optionCamelName
4664
+ )) == null ? void 0 : _a.default);
3724
4665
  }
3725
4666
  function createOptionUsageHeader(option) {
3726
4667
  const name = `--${option.name}`;
@@ -3754,25 +4695,39 @@ function createOptionUsageType(option) {
3754
4695
  function createChoiceUsages(choices, margin, indentation) {
3755
4696
  const activeChoices = choices.filter((choice) => !choice.deprecated);
3756
4697
  const threshold = Math.max(0, ...activeChoices.map((choice) => choice.value.length)) + margin;
3757
- return activeChoices.map((choice) => indent(createOptionUsageRow(choice.value, choice.description, threshold), indentation));
4698
+ return activeChoices.map(
4699
+ (choice) => indent(
4700
+ createOptionUsageRow(choice.value, choice.description, threshold),
4701
+ indentation
4702
+ )
4703
+ );
3758
4704
  }
3759
4705
  function createOptionUsage(context, option, threshold) {
3760
4706
  const header = createOptionUsageHeader(option);
3761
4707
  const optionDefaultValue = getOptionDefaultValue(context, option.name);
3762
- return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
3763
- Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
4708
+ return createOptionUsageRow(
4709
+ header,
4710
+ `${option.description}${optionDefaultValue === void 0 ? "" : `
4711
+ Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`,
4712
+ threshold
4713
+ );
3764
4714
  }
3765
4715
  function getOptionsWithOpposites(options) {
3766
- const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
3767
- ...option,
3768
- name: `no-${option.name}`,
3769
- type: "boolean",
3770
- description: option.oppositeDescription
3771
- } : null]);
4716
+ const optionsWithOpposites = options.map((option) => [
4717
+ option.description ? option : null,
4718
+ option.oppositeDescription ? {
4719
+ ...option,
4720
+ name: `no-${option.name}`,
4721
+ type: "boolean",
4722
+ description: option.oppositeDescription
4723
+ } : null
4724
+ ]);
3772
4725
  return optionsWithOpposites.flat().filter(Boolean);
3773
4726
  }
3774
4727
  function createUsage(context) {
3775
- const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
4728
+ const sortedOptions = context.detailedOptions.sort(
4729
+ (optionA, optionB) => optionA.name.localeCompare(optionB.name)
4730
+ );
3776
4731
  const options = getOptionsWithOpposites(sortedOptions).filter(
3777
4732
  // remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
3778
4733
  (option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
@@ -3780,10 +4735,18 @@ function createUsage(context) {
3780
4735
  const groupedOptions = groupBy(options, (option) => option.category);
3781
4736
  const firstCategories = categoryOrder.slice(0, -1);
3782
4737
  const lastCategories = categoryOrder.slice(-1);
3783
- const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
3784
- const allCategories = [...firstCategories, ...restCategories, ...lastCategories];
4738
+ const restCategories = Object.keys(groupedOptions).filter(
4739
+ (category) => !categoryOrder.includes(category)
4740
+ );
4741
+ const allCategories = [
4742
+ ...firstCategories,
4743
+ ...restCategories,
4744
+ ...lastCategories
4745
+ ];
3785
4746
  const optionsUsage = allCategories.map((category) => {
3786
- const categoryOptions = groupedOptions[category].map((option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)).join("\n");
4747
+ const categoryOptions = groupedOptions[category].map(
4748
+ (option) => createOptionUsage(context, option, OPTION_USAGE_THRESHOLD)
4749
+ ).join("\n");
3787
4750
  return `${category} options:
3788
4751
 
3789
4752
  ${indent(categoryOptions, 2)}`;
@@ -3794,13 +4757,19 @@ function createPluginDefaults(pluginDefaults) {
3794
4757
  if (!pluginDefaults || Object.keys(pluginDefaults).length === 0) {
3795
4758
  return "";
3796
4759
  }
3797
- const defaults = Object.entries(pluginDefaults).sort(([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)).map(([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`).join("\n");
4760
+ const defaults = Object.entries(pluginDefaults).sort(
4761
+ ([pluginNameA], [pluginNameB]) => pluginNameA.localeCompare(pluginNameB)
4762
+ ).map(
4763
+ ([plugin, value]) => `* ${plugin}: ${createDefaultValueDisplay(value)}`
4764
+ ).join("\n");
3798
4765
  return `
3799
4766
  Plugin defaults:
3800
4767
  ${defaults}`;
3801
4768
  }
3802
4769
  function createDetailedUsage(context, flag) {
3803
- const option = getOptionsWithOpposites(context.detailedOptions).find((option2) => option2.name === flag || option2.alias === flag);
4770
+ const option = getOptionsWithOpposites(context.detailedOptions).find(
4771
+ (option2) => option2.name === flag || option2.alias === flag
4772
+ );
3804
4773
  const header = createOptionUsageHeader(option);
3805
4774
  const description = `
3806
4775
 
@@ -3809,7 +4778,11 @@ ${indent(option.description, 2)}`;
3809
4778
 
3810
4779
  Valid options:
3811
4780
 
3812
- ${createChoiceUsages(option.choices, CHOICE_USAGE_MARGIN, CHOICE_USAGE_INDENTATION).join("\n")}`;
4781
+ ${createChoiceUsages(
4782
+ option.choices,
4783
+ CHOICE_USAGE_MARGIN,
4784
+ CHOICE_USAGE_INDENTATION
4785
+ ).join("\n")}`;
3813
4786
  const optionDefaultValue = getOptionDefaultValue(context, option.name);
3814
4787
  const defaults = optionDefaultValue !== void 0 ? `
3815
4788