prettier 3.5.3 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
14
  var __typeError = (msg) => {
15
15
  throw TypeError(msg);
16
16
  };
17
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
18
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
18
19
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
19
20
  }) : x)(function(x) {
@@ -39,10 +40,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
40
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
41
  mod
41
42
  ));
43
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
42
44
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
43
45
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
44
46
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
45
47
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
48
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
46
49
 
47
50
  // node_modules/dashify/index.js
48
51
  var require_dashify = __commonJS({
@@ -121,7 +124,7 @@ var require_minimist = __commonJS({
121
124
  }
122
125
  });
123
126
  var defaults = opts.default || {};
124
- var argv = { _: [] };
127
+ var argv2 = { _: [] };
125
128
  function argDefined(key2, arg2) {
126
129
  return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
127
130
  }
@@ -168,9 +171,9 @@ var require_minimist = __commonJS({
168
171
  }
169
172
  }
170
173
  var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
171
- setKey(argv, key2.split("."), value2);
174
+ setKey(argv2, key2.split("."), value2);
172
175
  (aliases[key2] || []).forEach(function(x) {
173
- setKey(argv, x.split("."), value2);
176
+ setKey(argv2, x.split("."), value2);
174
177
  });
175
178
  }
176
179
  Object.keys(flags.bools).forEach(function(key2) {
@@ -249,30 +252,30 @@ var require_minimist = __commonJS({
249
252
  }
250
253
  } else {
251
254
  if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
252
- argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
255
+ argv2._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
253
256
  }
254
257
  if (opts.stopEarly) {
255
- argv._.push.apply(argv._, args.slice(i + 1));
258
+ argv2._.push.apply(argv2._, args.slice(i + 1));
256
259
  break;
257
260
  }
258
261
  }
259
262
  }
260
263
  Object.keys(defaults).forEach(function(k) {
261
- if (!hasKey(argv, k.split("."))) {
262
- setKey(argv, k.split("."), defaults[k]);
264
+ if (!hasKey(argv2, k.split("."))) {
265
+ setKey(argv2, k.split("."), defaults[k]);
263
266
  (aliases[k] || []).forEach(function(x) {
264
- setKey(argv, x.split("."), defaults[k]);
267
+ setKey(argv2, x.split("."), defaults[k]);
265
268
  });
266
269
  }
267
270
  });
268
271
  if (opts["--"]) {
269
- argv["--"] = notFlags.slice();
272
+ argv2["--"] = notFlags.slice();
270
273
  } else {
271
274
  notFlags.forEach(function(k) {
272
- argv._.push(k);
275
+ argv2._.push(k);
273
276
  });
274
277
  }
275
- return argv;
278
+ return argv2;
276
279
  };
277
280
  }
278
281
  });
@@ -339,8 +342,8 @@ var require_common_path_prefix = __commonJS({
339
342
  "use strict";
340
343
  var { sep: DEFAULT_SEPARATOR } = __require("path");
341
344
  var determineSeparator = (paths) => {
342
- for (const path12 of paths) {
343
- const match = /(\/|\\)/.exec(path12);
345
+ for (const path13 of paths) {
346
+ const match = /(\/|\\)/.exec(path13);
344
347
  if (match !== null) return match[0];
345
348
  }
346
349
  return DEFAULT_SEPARATOR;
@@ -350,8 +353,8 @@ var require_common_path_prefix = __commonJS({
350
353
  if (first === "" || remaining.length === 0) return "";
351
354
  const parts = first.split(sep);
352
355
  let endOfPrefix = parts.length;
353
- for (const path12 of remaining) {
354
- const compare = path12.split(sep);
356
+ for (const path13 of remaining) {
357
+ const compare = path13.split(sep);
355
358
  for (let i = 0; i < endOfPrefix; i++) {
356
359
  if (compare[i] !== parts[i]) {
357
360
  endOfPrefix = i;
@@ -365,6 +368,444 @@ var require_common_path_prefix = __commonJS({
365
368
  }
366
369
  });
367
370
 
371
+ // node_modules/ci-info/vendors.json
372
+ var require_vendors = __commonJS({
373
+ "node_modules/ci-info/vendors.json"(exports, module) {
374
+ module.exports = [
375
+ {
376
+ name: "Agola CI",
377
+ constant: "AGOLA",
378
+ env: "AGOLA_GIT_REF",
379
+ pr: "AGOLA_PULL_REQUEST_ID"
380
+ },
381
+ {
382
+ name: "Appcircle",
383
+ constant: "APPCIRCLE",
384
+ env: "AC_APPCIRCLE",
385
+ pr: {
386
+ env: "AC_GIT_PR",
387
+ ne: "false"
388
+ }
389
+ },
390
+ {
391
+ name: "AppVeyor",
392
+ constant: "APPVEYOR",
393
+ env: "APPVEYOR",
394
+ pr: "APPVEYOR_PULL_REQUEST_NUMBER"
395
+ },
396
+ {
397
+ name: "AWS CodeBuild",
398
+ constant: "CODEBUILD",
399
+ env: "CODEBUILD_BUILD_ARN",
400
+ pr: {
401
+ env: "CODEBUILD_WEBHOOK_EVENT",
402
+ any: [
403
+ "PULL_REQUEST_CREATED",
404
+ "PULL_REQUEST_UPDATED",
405
+ "PULL_REQUEST_REOPENED"
406
+ ]
407
+ }
408
+ },
409
+ {
410
+ name: "Azure Pipelines",
411
+ constant: "AZURE_PIPELINES",
412
+ env: "TF_BUILD",
413
+ pr: {
414
+ BUILD_REASON: "PullRequest"
415
+ }
416
+ },
417
+ {
418
+ name: "Bamboo",
419
+ constant: "BAMBOO",
420
+ env: "bamboo_planKey"
421
+ },
422
+ {
423
+ name: "Bitbucket Pipelines",
424
+ constant: "BITBUCKET",
425
+ env: "BITBUCKET_COMMIT",
426
+ pr: "BITBUCKET_PR_ID"
427
+ },
428
+ {
429
+ name: "Bitrise",
430
+ constant: "BITRISE",
431
+ env: "BITRISE_IO",
432
+ pr: "BITRISE_PULL_REQUEST"
433
+ },
434
+ {
435
+ name: "Buddy",
436
+ constant: "BUDDY",
437
+ env: "BUDDY_WORKSPACE_ID",
438
+ pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
439
+ },
440
+ {
441
+ name: "Buildkite",
442
+ constant: "BUILDKITE",
443
+ env: "BUILDKITE",
444
+ pr: {
445
+ env: "BUILDKITE_PULL_REQUEST",
446
+ ne: "false"
447
+ }
448
+ },
449
+ {
450
+ name: "CircleCI",
451
+ constant: "CIRCLE",
452
+ env: "CIRCLECI",
453
+ pr: "CIRCLE_PULL_REQUEST"
454
+ },
455
+ {
456
+ name: "Cirrus CI",
457
+ constant: "CIRRUS",
458
+ env: "CIRRUS_CI",
459
+ pr: "CIRRUS_PR"
460
+ },
461
+ {
462
+ name: "Cloudflare Pages",
463
+ constant: "CLOUDFLARE_PAGES",
464
+ env: "CF_PAGES"
465
+ },
466
+ {
467
+ name: "Codefresh",
468
+ constant: "CODEFRESH",
469
+ env: "CF_BUILD_ID",
470
+ pr: {
471
+ any: [
472
+ "CF_PULL_REQUEST_NUMBER",
473
+ "CF_PULL_REQUEST_ID"
474
+ ]
475
+ }
476
+ },
477
+ {
478
+ name: "Codemagic",
479
+ constant: "CODEMAGIC",
480
+ env: "CM_BUILD_ID",
481
+ pr: "CM_PULL_REQUEST"
482
+ },
483
+ {
484
+ name: "Codeship",
485
+ constant: "CODESHIP",
486
+ env: {
487
+ CI_NAME: "codeship"
488
+ }
489
+ },
490
+ {
491
+ name: "Drone",
492
+ constant: "DRONE",
493
+ env: "DRONE",
494
+ pr: {
495
+ DRONE_BUILD_EVENT: "pull_request"
496
+ }
497
+ },
498
+ {
499
+ name: "dsari",
500
+ constant: "DSARI",
501
+ env: "DSARI"
502
+ },
503
+ {
504
+ name: "Earthly",
505
+ constant: "EARTHLY",
506
+ env: "EARTHLY_CI"
507
+ },
508
+ {
509
+ name: "Expo Application Services",
510
+ constant: "EAS",
511
+ env: "EAS_BUILD"
512
+ },
513
+ {
514
+ name: "Gerrit",
515
+ constant: "GERRIT",
516
+ env: "GERRIT_PROJECT"
517
+ },
518
+ {
519
+ name: "Gitea Actions",
520
+ constant: "GITEA_ACTIONS",
521
+ env: "GITEA_ACTIONS"
522
+ },
523
+ {
524
+ name: "GitHub Actions",
525
+ constant: "GITHUB_ACTIONS",
526
+ env: "GITHUB_ACTIONS",
527
+ pr: {
528
+ GITHUB_EVENT_NAME: "pull_request"
529
+ }
530
+ },
531
+ {
532
+ name: "GitLab CI",
533
+ constant: "GITLAB",
534
+ env: "GITLAB_CI",
535
+ pr: "CI_MERGE_REQUEST_ID"
536
+ },
537
+ {
538
+ name: "GoCD",
539
+ constant: "GOCD",
540
+ env: "GO_PIPELINE_LABEL"
541
+ },
542
+ {
543
+ name: "Google Cloud Build",
544
+ constant: "GOOGLE_CLOUD_BUILD",
545
+ env: "BUILDER_OUTPUT"
546
+ },
547
+ {
548
+ name: "Harness CI",
549
+ constant: "HARNESS",
550
+ env: "HARNESS_BUILD_ID"
551
+ },
552
+ {
553
+ name: "Heroku",
554
+ constant: "HEROKU",
555
+ env: {
556
+ env: "NODE",
557
+ includes: "/app/.heroku/node/bin/node"
558
+ }
559
+ },
560
+ {
561
+ name: "Hudson",
562
+ constant: "HUDSON",
563
+ env: "HUDSON_URL"
564
+ },
565
+ {
566
+ name: "Jenkins",
567
+ constant: "JENKINS",
568
+ env: [
569
+ "JENKINS_URL",
570
+ "BUILD_ID"
571
+ ],
572
+ pr: {
573
+ any: [
574
+ "ghprbPullId",
575
+ "CHANGE_ID"
576
+ ]
577
+ }
578
+ },
579
+ {
580
+ name: "LayerCI",
581
+ constant: "LAYERCI",
582
+ env: "LAYERCI",
583
+ pr: "LAYERCI_PULL_REQUEST"
584
+ },
585
+ {
586
+ name: "Magnum CI",
587
+ constant: "MAGNUM",
588
+ env: "MAGNUM"
589
+ },
590
+ {
591
+ name: "Netlify CI",
592
+ constant: "NETLIFY",
593
+ env: "NETLIFY",
594
+ pr: {
595
+ env: "PULL_REQUEST",
596
+ ne: "false"
597
+ }
598
+ },
599
+ {
600
+ name: "Nevercode",
601
+ constant: "NEVERCODE",
602
+ env: "NEVERCODE",
603
+ pr: {
604
+ env: "NEVERCODE_PULL_REQUEST",
605
+ ne: "false"
606
+ }
607
+ },
608
+ {
609
+ name: "Prow",
610
+ constant: "PROW",
611
+ env: "PROW_JOB_ID"
612
+ },
613
+ {
614
+ name: "ReleaseHub",
615
+ constant: "RELEASEHUB",
616
+ env: "RELEASE_BUILD_ID"
617
+ },
618
+ {
619
+ name: "Render",
620
+ constant: "RENDER",
621
+ env: "RENDER",
622
+ pr: {
623
+ IS_PULL_REQUEST: "true"
624
+ }
625
+ },
626
+ {
627
+ name: "Sail CI",
628
+ constant: "SAIL",
629
+ env: "SAILCI",
630
+ pr: "SAIL_PULL_REQUEST_NUMBER"
631
+ },
632
+ {
633
+ name: "Screwdriver",
634
+ constant: "SCREWDRIVER",
635
+ env: "SCREWDRIVER",
636
+ pr: {
637
+ env: "SD_PULL_REQUEST",
638
+ ne: "false"
639
+ }
640
+ },
641
+ {
642
+ name: "Semaphore",
643
+ constant: "SEMAPHORE",
644
+ env: "SEMAPHORE",
645
+ pr: "PULL_REQUEST_NUMBER"
646
+ },
647
+ {
648
+ name: "Sourcehut",
649
+ constant: "SOURCEHUT",
650
+ env: {
651
+ CI_NAME: "sourcehut"
652
+ }
653
+ },
654
+ {
655
+ name: "Strider CD",
656
+ constant: "STRIDER",
657
+ env: "STRIDER"
658
+ },
659
+ {
660
+ name: "TaskCluster",
661
+ constant: "TASKCLUSTER",
662
+ env: [
663
+ "TASK_ID",
664
+ "RUN_ID"
665
+ ]
666
+ },
667
+ {
668
+ name: "TeamCity",
669
+ constant: "TEAMCITY",
670
+ env: "TEAMCITY_VERSION"
671
+ },
672
+ {
673
+ name: "Travis CI",
674
+ constant: "TRAVIS",
675
+ env: "TRAVIS",
676
+ pr: {
677
+ env: "TRAVIS_PULL_REQUEST",
678
+ ne: "false"
679
+ }
680
+ },
681
+ {
682
+ name: "Vela",
683
+ constant: "VELA",
684
+ env: "VELA",
685
+ pr: {
686
+ VELA_PULL_REQUEST: "1"
687
+ }
688
+ },
689
+ {
690
+ name: "Vercel",
691
+ constant: "VERCEL",
692
+ env: {
693
+ any: [
694
+ "NOW_BUILDER",
695
+ "VERCEL"
696
+ ]
697
+ },
698
+ pr: "VERCEL_GIT_PULL_REQUEST_ID"
699
+ },
700
+ {
701
+ name: "Visual Studio App Center",
702
+ constant: "APPCENTER",
703
+ env: "APPCENTER_BUILD_ID"
704
+ },
705
+ {
706
+ name: "Woodpecker",
707
+ constant: "WOODPECKER",
708
+ env: {
709
+ CI: "woodpecker"
710
+ },
711
+ pr: {
712
+ CI_BUILD_EVENT: "pull_request"
713
+ }
714
+ },
715
+ {
716
+ name: "Xcode Cloud",
717
+ constant: "XCODE_CLOUD",
718
+ env: "CI_XCODE_PROJECT",
719
+ pr: "CI_PULL_REQUEST_NUMBER"
720
+ },
721
+ {
722
+ name: "Xcode Server",
723
+ constant: "XCODE_SERVER",
724
+ env: "XCS"
725
+ }
726
+ ];
727
+ }
728
+ });
729
+
730
+ // node_modules/ci-info/index.js
731
+ var require_ci_info = __commonJS({
732
+ "node_modules/ci-info/index.js"(exports) {
733
+ "use strict";
734
+ var vendors = require_vendors();
735
+ var env3 = process.env;
736
+ Object.defineProperty(exports, "_vendors", {
737
+ value: vendors.map(function(v) {
738
+ return v.constant;
739
+ })
740
+ });
741
+ exports.name = null;
742
+ exports.isPR = null;
743
+ exports.id = null;
744
+ vendors.forEach(function(vendor) {
745
+ const envs = Array.isArray(vendor.env) ? vendor.env : [vendor.env];
746
+ const isCI2 = envs.every(function(obj) {
747
+ return checkEnv(obj);
748
+ });
749
+ exports[vendor.constant] = isCI2;
750
+ if (!isCI2) {
751
+ return;
752
+ }
753
+ exports.name = vendor.name;
754
+ exports.isPR = checkPR(vendor);
755
+ exports.id = vendor.constant;
756
+ });
757
+ exports.isCI = !!(env3.CI !== "false" && // Bypass all checks if CI env is explicitly set to 'false'
758
+ (env3.BUILD_ID || // Jenkins, Cloudbees
759
+ env3.BUILD_NUMBER || // Jenkins, TeamCity
760
+ env3.CI || // Travis CI, CircleCI, Cirrus CI, Gitlab CI, Appveyor, CodeShip, dsari, Cloudflare Pages
761
+ env3.CI_APP_ID || // Appflow
762
+ env3.CI_BUILD_ID || // Appflow
763
+ env3.CI_BUILD_NUMBER || // Appflow
764
+ env3.CI_NAME || // Codeship and others
765
+ env3.CONTINUOUS_INTEGRATION || // Travis CI, Cirrus CI
766
+ env3.RUN_ID || // TaskCluster, dsari
767
+ exports.name || false));
768
+ function checkEnv(obj) {
769
+ if (typeof obj === "string") return !!env3[obj];
770
+ if ("env" in obj) {
771
+ return env3[obj.env] && env3[obj.env].includes(obj.includes);
772
+ }
773
+ if ("any" in obj) {
774
+ return obj.any.some(function(k) {
775
+ return !!env3[k];
776
+ });
777
+ }
778
+ return Object.keys(obj).every(function(k) {
779
+ return env3[k] === obj[k];
780
+ });
781
+ }
782
+ function checkPR(vendor) {
783
+ switch (typeof vendor.pr) {
784
+ case "string":
785
+ return !!env3[vendor.pr];
786
+ case "object":
787
+ if ("env" in vendor.pr) {
788
+ if ("any" in vendor.pr) {
789
+ return vendor.pr.any.some(function(key) {
790
+ return env3[vendor.pr.env] === key;
791
+ });
792
+ } else {
793
+ return vendor.pr.env in env3 && env3[vendor.pr.env] !== vendor.pr.ne;
794
+ }
795
+ } else if ("any" in vendor.pr) {
796
+ return vendor.pr.any.some(function(key) {
797
+ return !!env3[key];
798
+ });
799
+ } else {
800
+ return checkEnv(vendor.pr);
801
+ }
802
+ default:
803
+ return null;
804
+ }
805
+ }
806
+ }
807
+ });
808
+
368
809
  // src/cli/index.js
369
810
  import * as prettier2 from "../index.mjs";
370
811
 
@@ -565,7 +1006,8 @@ var {
565
1006
  vnopts,
566
1007
  fastGlob,
567
1008
  createTwoFilesPatch,
568
- mockable
1009
+ picocolors,
1010
+ leven
569
1011
  } = sharedWithCli;
570
1012
 
571
1013
  // src/cli/options/get-context-options.js
@@ -760,9 +1202,9 @@ function sdbm(string) {
760
1202
  // src/cli/utils.js
761
1203
  import { __internal as sharedWithCli2 } from "../index.mjs";
762
1204
  var printToScreen = console.log.bind(console);
763
- function groupBy(array2, iteratee) {
1205
+ function groupBy(array, iteratee) {
764
1206
  const result = /* @__PURE__ */ Object.create(null);
765
- for (const value of array2) {
1207
+ for (const value of array) {
766
1208
  const key = iteratee(value);
767
1209
  if (Array.isArray(result[key])) {
768
1210
  result[key].push(value);
@@ -858,640 +1300,101 @@ function minimistParse(args, options) {
858
1300
  );
859
1301
  }
860
1302
 
861
- // node_modules/chalk/source/vendor/ansi-styles/index.js
862
- var ANSI_BACKGROUND_OFFSET = 10;
863
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
864
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
865
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
866
- var styles = {
867
- modifier: {
868
- reset: [0, 0],
869
- // 21 isn't widely supported and 22 does the same thing
870
- bold: [1, 22],
871
- dim: [2, 22],
872
- italic: [3, 23],
873
- underline: [4, 24],
874
- overline: [53, 55],
875
- inverse: [7, 27],
876
- hidden: [8, 28],
877
- strikethrough: [9, 29]
878
- },
879
- color: {
880
- black: [30, 39],
881
- red: [31, 39],
882
- green: [32, 39],
883
- yellow: [33, 39],
884
- blue: [34, 39],
885
- magenta: [35, 39],
886
- cyan: [36, 39],
887
- white: [37, 39],
888
- // Bright color
889
- blackBright: [90, 39],
890
- gray: [90, 39],
891
- // Alias of `blackBright`
892
- grey: [90, 39],
893
- // Alias of `blackBright`
894
- redBright: [91, 39],
895
- greenBright: [92, 39],
896
- yellowBright: [93, 39],
897
- blueBright: [94, 39],
898
- magentaBright: [95, 39],
899
- cyanBright: [96, 39],
900
- whiteBright: [97, 39]
901
- },
902
- bgColor: {
903
- bgBlack: [40, 49],
904
- bgRed: [41, 49],
905
- bgGreen: [42, 49],
906
- bgYellow: [43, 49],
907
- bgBlue: [44, 49],
908
- bgMagenta: [45, 49],
909
- bgCyan: [46, 49],
910
- bgWhite: [47, 49],
911
- // Bright color
912
- bgBlackBright: [100, 49],
913
- bgGray: [100, 49],
914
- // Alias of `bgBlackBright`
915
- bgGrey: [100, 49],
916
- // Alias of `bgBlackBright`
917
- bgRedBright: [101, 49],
918
- bgGreenBright: [102, 49],
919
- bgYellowBright: [103, 49],
920
- bgBlueBright: [104, 49],
921
- bgMagentaBright: [105, 49],
922
- bgCyanBright: [106, 49],
923
- bgWhiteBright: [107, 49]
924
- }
1303
+ // src/cli/options/normalize-cli-options.js
1304
+ var descriptor = {
1305
+ key: (key) => key.length === 1 ? `-${key}` : `--${key}`,
1306
+ value: (value) => vnopts.apiDescriptor.value(value),
1307
+ pair: ({ key, value }) => value === false ? `--no-${key}` : value === true ? descriptor.key(key) : value === "" ? `${descriptor.key(key)} without an argument` : `${descriptor.key(key)}=${value}`
925
1308
  };
926
- var modifierNames = Object.keys(styles.modifier);
927
- var foregroundColorNames = Object.keys(styles.color);
928
- var backgroundColorNames = Object.keys(styles.bgColor);
929
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
930
- function assembleStyles() {
931
- const codes = /* @__PURE__ */ new Map();
932
- for (const [groupName, group] of Object.entries(styles)) {
933
- for (const [styleName, style] of Object.entries(group)) {
934
- styles[styleName] = {
935
- open: `\x1B[${style[0]}m`,
936
- close: `\x1B[${style[1]}m`
937
- };
938
- group[styleName] = styles[styleName];
939
- codes.set(style[0], style[1]);
940
- }
941
- Object.defineProperty(styles, groupName, {
942
- value: group,
943
- enumerable: false
944
- });
1309
+ var _flags;
1310
+ var FlagSchema = class extends vnopts.ChoiceSchema {
1311
+ constructor({ name, flags }) {
1312
+ super({ name, choices: flags });
1313
+ __privateAdd(this, _flags, []);
1314
+ __privateSet(this, _flags, [...flags].sort());
945
1315
  }
946
- Object.defineProperty(styles, "codes", {
947
- value: codes,
948
- enumerable: false
949
- });
950
- styles.color.close = "\x1B[39m";
951
- styles.bgColor.close = "\x1B[49m";
952
- styles.color.ansi = wrapAnsi16();
953
- styles.color.ansi256 = wrapAnsi256();
954
- styles.color.ansi16m = wrapAnsi16m();
955
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
956
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
957
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
958
- Object.defineProperties(styles, {
959
- rgbToAnsi256: {
960
- value(red, green, blue) {
961
- if (red === green && green === blue) {
962
- if (red < 8) {
963
- return 16;
964
- }
965
- if (red > 248) {
966
- return 231;
967
- }
968
- return Math.round((red - 8) / 247 * 24) + 232;
969
- }
970
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
971
- },
972
- enumerable: false
973
- },
974
- hexToRgb: {
975
- value(hex) {
976
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
977
- if (!matches) {
978
- return [0, 0, 0];
979
- }
980
- let [colorString] = matches;
981
- if (colorString.length === 3) {
982
- colorString = [...colorString].map((character) => character + character).join("");
983
- }
984
- const integer = Number.parseInt(colorString, 16);
985
- return [
986
- /* eslint-disable no-bitwise */
987
- integer >> 16 & 255,
988
- integer >> 8 & 255,
989
- integer & 255
990
- /* eslint-enable no-bitwise */
991
- ];
992
- },
993
- enumerable: false
994
- },
995
- hexToAnsi256: {
996
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
997
- enumerable: false
998
- },
999
- ansi256ToAnsi: {
1000
- value(code) {
1001
- if (code < 8) {
1002
- return 30 + code;
1003
- }
1004
- if (code < 16) {
1005
- return 90 + (code - 8);
1006
- }
1007
- let red;
1008
- let green;
1009
- let blue;
1010
- if (code >= 232) {
1011
- red = ((code - 232) * 10 + 8) / 255;
1012
- green = red;
1013
- blue = red;
1014
- } else {
1015
- code -= 16;
1016
- const remainder = code % 36;
1017
- red = Math.floor(code / 36) / 5;
1018
- green = Math.floor(remainder / 6) / 5;
1019
- blue = remainder % 6 / 5;
1020
- }
1021
- const value = Math.max(red, green, blue) * 2;
1022
- if (value === 0) {
1023
- return 30;
1024
- }
1025
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
1026
- if (value === 2) {
1027
- result += 60;
1028
- }
1029
- return result;
1030
- },
1031
- enumerable: false
1032
- },
1033
- rgbToAnsi: {
1034
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
1035
- enumerable: false
1036
- },
1037
- hexToAnsi: {
1038
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
1039
- enumerable: false
1316
+ preprocess(value, utils) {
1317
+ if (typeof value === "string" && value.length > 0 && !__privateGet(this, _flags).includes(value)) {
1318
+ const suggestion = __privateGet(this, _flags).find((flag) => leven(flag, value) < 3);
1319
+ if (suggestion) {
1320
+ utils.logger.warn(
1321
+ [
1322
+ `Unknown flag ${picocolors.yellow(utils.descriptor.value(value))},`,
1323
+ `did you mean ${picocolors.blue(utils.descriptor.value(suggestion))}?`
1324
+ ].join(" ")
1325
+ );
1326
+ return suggestion;
1327
+ }
1040
1328
  }
1329
+ return value;
1330
+ }
1331
+ expected() {
1332
+ return "a flag";
1333
+ }
1334
+ };
1335
+ _flags = new WeakMap();
1336
+ function normalizeCliOptions(options, optionInfos, opts) {
1337
+ return normalizeOptions(options, optionInfos, {
1338
+ ...opts,
1339
+ isCLI: true,
1340
+ FlagSchema,
1341
+ descriptor
1041
1342
  });
1042
- return styles;
1043
1343
  }
1044
- var ansiStyles = assembleStyles();
1045
- var ansi_styles_default = ansiStyles;
1344
+ var normalize_cli_options_default = normalizeCliOptions;
1046
1345
 
1047
- // node_modules/chalk/source/vendor/supports-color/index.js
1048
- import process2 from "process";
1049
- import os from "os";
1050
- import tty from "tty";
1051
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
1052
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
1053
- const position = argv.indexOf(prefix + flag);
1054
- const terminatorPosition = argv.indexOf("--");
1055
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
1056
- }
1057
- var { env } = process2;
1058
- var flagForceColor;
1059
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
1060
- flagForceColor = 0;
1061
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
1062
- flagForceColor = 1;
1063
- }
1064
- function envForceColor() {
1065
- if ("FORCE_COLOR" in env) {
1066
- if (env.FORCE_COLOR === "true") {
1067
- return 1;
1068
- }
1069
- if (env.FORCE_COLOR === "false") {
1070
- return 0;
1071
- }
1072
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
1073
- }
1074
- }
1075
- function translateLevel(level) {
1076
- if (level === 0) {
1077
- return false;
1346
+ // src/cli/options/parse-cli-arguments.js
1347
+ function parseArgv(rawArguments, detailedOptions, logger, keys2) {
1348
+ var _a;
1349
+ const minimistOptions = createMinimistOptions(detailedOptions);
1350
+ let argv2 = minimistParse(rawArguments, minimistOptions);
1351
+ if (keys2) {
1352
+ detailedOptions = detailedOptions.filter(
1353
+ (option) => keys2.includes(option.name)
1354
+ );
1355
+ argv2 = pick(argv2, keys2);
1078
1356
  }
1357
+ const normalized = normalize_cli_options_default(argv2, detailedOptions, { logger });
1079
1358
  return {
1080
- level,
1081
- hasBasic: true,
1082
- has256: level >= 2,
1083
- has16m: level >= 3
1359
+ ...Object.fromEntries(
1360
+ Object.entries(normalized).map(([key, value]) => {
1361
+ const option = detailedOptions.find(({ name }) => name === key) || {};
1362
+ return [option.forwardToApi || camelCase(key), value];
1363
+ })
1364
+ ),
1365
+ _: (_a = normalized._) == null ? void 0 : _a.map(String),
1366
+ get __raw() {
1367
+ return argv2;
1368
+ }
1084
1369
  };
1085
1370
  }
1086
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
1087
- const noFlagForceColor = envForceColor();
1088
- if (noFlagForceColor !== void 0) {
1089
- flagForceColor = noFlagForceColor;
1090
- }
1091
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
1092
- if (forceColor === 0) {
1093
- return 0;
1094
- }
1095
- if (sniffFlags) {
1096
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
1097
- return 3;
1098
- }
1099
- if (hasFlag("color=256")) {
1100
- return 2;
1101
- }
1102
- }
1103
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
1104
- return 1;
1105
- }
1106
- if (haveStream && !streamIsTTY && forceColor === void 0) {
1107
- return 0;
1371
+ var { detailedOptions: detailedOptionsWithoutPlugins } = getContextOptionsWithoutPlugins();
1372
+ function parseArgvWithoutPlugins(rawArguments, logger, keys2) {
1373
+ return parseArgv(
1374
+ rawArguments,
1375
+ detailedOptionsWithoutPlugins,
1376
+ logger,
1377
+ typeof keys2 === "string" ? [keys2] : keys2
1378
+ );
1379
+ }
1380
+
1381
+ // src/cli/context.js
1382
+ var _stack;
1383
+ var Context = class {
1384
+ constructor({ rawArguments, logger }) {
1385
+ __privateAdd(this, _stack, []);
1386
+ this.rawArguments = rawArguments;
1387
+ this.logger = logger;
1108
1388
  }
1109
- const min = forceColor || 0;
1110
- if (env.TERM === "dumb") {
1111
- return min;
1112
- }
1113
- if (process2.platform === "win32") {
1114
- const osRelease = os.release().split(".");
1115
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
1116
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
1117
- }
1118
- return 1;
1119
- }
1120
- if ("CI" in env) {
1121
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
1122
- return 3;
1123
- }
1124
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
1125
- return 1;
1126
- }
1127
- return min;
1128
- }
1129
- if ("TEAMCITY_VERSION" in env) {
1130
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
1131
- }
1132
- if (env.COLORTERM === "truecolor") {
1133
- return 3;
1134
- }
1135
- if (env.TERM === "xterm-kitty") {
1136
- return 3;
1137
- }
1138
- if ("TERM_PROGRAM" in env) {
1139
- const version2 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
1140
- switch (env.TERM_PROGRAM) {
1141
- case "iTerm.app": {
1142
- return version2 >= 3 ? 3 : 2;
1143
- }
1144
- case "Apple_Terminal": {
1145
- return 2;
1146
- }
1147
- }
1148
- }
1149
- if (/-256(color)?$/i.test(env.TERM)) {
1150
- return 2;
1151
- }
1152
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
1153
- return 1;
1154
- }
1155
- if ("COLORTERM" in env) {
1156
- return 1;
1157
- }
1158
- return min;
1159
- }
1160
- function createSupportsColor(stream, options = {}) {
1161
- const level = _supportsColor(stream, {
1162
- streamIsTTY: stream && stream.isTTY,
1163
- ...options
1164
- });
1165
- return translateLevel(level);
1166
- }
1167
- var supportsColor = {
1168
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
1169
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
1170
- };
1171
- var supports_color_default = supportsColor;
1172
-
1173
- // node_modules/chalk/source/utilities.js
1174
- function stringReplaceAll2(string, substring, replacer) {
1175
- let index = string.indexOf(substring);
1176
- if (index === -1) {
1177
- return string;
1178
- }
1179
- const substringLength = substring.length;
1180
- let endIndex = 0;
1181
- let returnValue = "";
1182
- do {
1183
- returnValue += string.slice(endIndex, index) + substring + replacer;
1184
- endIndex = index + substringLength;
1185
- index = string.indexOf(substring, endIndex);
1186
- } while (index !== -1);
1187
- returnValue += string.slice(endIndex);
1188
- return returnValue;
1189
- }
1190
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
1191
- let endIndex = 0;
1192
- let returnValue = "";
1193
- do {
1194
- const gotCR = string[index - 1] === "\r";
1195
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
1196
- endIndex = index + 1;
1197
- index = string.indexOf("\n", endIndex);
1198
- } while (index !== -1);
1199
- returnValue += string.slice(endIndex);
1200
- return returnValue;
1201
- }
1202
-
1203
- // node_modules/chalk/source/index.js
1204
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
1205
- var GENERATOR = Symbol("GENERATOR");
1206
- var STYLER = Symbol("STYLER");
1207
- var IS_EMPTY = Symbol("IS_EMPTY");
1208
- var levelMapping = [
1209
- "ansi",
1210
- "ansi",
1211
- "ansi256",
1212
- "ansi16m"
1213
- ];
1214
- var styles2 = /* @__PURE__ */ Object.create(null);
1215
- var applyOptions = (object2, options = {}) => {
1216
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
1217
- throw new Error("The `level` option should be an integer from 0 to 3");
1218
- }
1219
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
1220
- object2.level = options.level === void 0 ? colorLevel : options.level;
1221
- };
1222
- var chalkFactory = (options) => {
1223
- const chalk2 = (...strings) => strings.join(" ");
1224
- applyOptions(chalk2, options);
1225
- Object.setPrototypeOf(chalk2, createChalk.prototype);
1226
- return chalk2;
1227
- };
1228
- function createChalk(options) {
1229
- return chalkFactory(options);
1230
- }
1231
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
1232
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
1233
- styles2[styleName] = {
1234
- get() {
1235
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
1236
- Object.defineProperty(this, styleName, { value: builder });
1237
- return builder;
1238
- }
1239
- };
1240
- }
1241
- styles2.visible = {
1242
- get() {
1243
- const builder = createBuilder(this, this[STYLER], true);
1244
- Object.defineProperty(this, "visible", { value: builder });
1245
- return builder;
1246
- }
1247
- };
1248
- var getModelAnsi = (model, level, type, ...arguments_) => {
1249
- if (model === "rgb") {
1250
- if (level === "ansi16m") {
1251
- return ansi_styles_default[type].ansi16m(...arguments_);
1252
- }
1253
- if (level === "ansi256") {
1254
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
1255
- }
1256
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
1257
- }
1258
- if (model === "hex") {
1259
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
1260
- }
1261
- return ansi_styles_default[type][model](...arguments_);
1262
- };
1263
- var usedModels = ["rgb", "hex", "ansi256"];
1264
- for (const model of usedModels) {
1265
- styles2[model] = {
1266
- get() {
1267
- const { level } = this;
1268
- return function(...arguments_) {
1269
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
1270
- return createBuilder(this, styler, this[IS_EMPTY]);
1271
- };
1272
- }
1273
- };
1274
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
1275
- styles2[bgModel] = {
1276
- get() {
1277
- const { level } = this;
1278
- return function(...arguments_) {
1279
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
1280
- return createBuilder(this, styler, this[IS_EMPTY]);
1281
- };
1282
- }
1283
- };
1284
- }
1285
- var proto = Object.defineProperties(() => {
1286
- }, {
1287
- ...styles2,
1288
- level: {
1289
- enumerable: true,
1290
- get() {
1291
- return this[GENERATOR].level;
1292
- },
1293
- set(level) {
1294
- this[GENERATOR].level = level;
1295
- }
1296
- }
1297
- });
1298
- var createStyler = (open, close, parent) => {
1299
- let openAll;
1300
- let closeAll;
1301
- if (parent === void 0) {
1302
- openAll = open;
1303
- closeAll = close;
1304
- } else {
1305
- openAll = parent.openAll + open;
1306
- closeAll = close + parent.closeAll;
1307
- }
1308
- return {
1309
- open,
1310
- close,
1311
- openAll,
1312
- closeAll,
1313
- parent
1314
- };
1315
- };
1316
- var createBuilder = (self, _styler, _isEmpty) => {
1317
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
1318
- Object.setPrototypeOf(builder, proto);
1319
- builder[GENERATOR] = self;
1320
- builder[STYLER] = _styler;
1321
- builder[IS_EMPTY] = _isEmpty;
1322
- return builder;
1323
- };
1324
- var applyStyle = (self, string) => {
1325
- if (self.level <= 0 || !string) {
1326
- return self[IS_EMPTY] ? "" : string;
1327
- }
1328
- let styler = self[STYLER];
1329
- if (styler === void 0) {
1330
- return string;
1331
- }
1332
- const { openAll, closeAll } = styler;
1333
- if (string.includes("\x1B")) {
1334
- while (styler !== void 0) {
1335
- string = stringReplaceAll2(string, styler.close, styler.open);
1336
- styler = styler.parent;
1337
- }
1338
- }
1339
- const lfIndex = string.indexOf("\n");
1340
- if (lfIndex !== -1) {
1341
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
1342
- }
1343
- return openAll + string + closeAll;
1344
- };
1345
- Object.defineProperties(createChalk.prototype, styles2);
1346
- var chalk = createChalk();
1347
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1348
- var source_default = chalk;
1349
-
1350
- // node_modules/leven/index.js
1351
- var array = [];
1352
- var characterCodeCache = [];
1353
- function leven(first, second) {
1354
- if (first === second) {
1355
- return 0;
1356
- }
1357
- const swap = first;
1358
- if (first.length > second.length) {
1359
- first = second;
1360
- second = swap;
1361
- }
1362
- let firstLength = first.length;
1363
- let secondLength = second.length;
1364
- while (firstLength > 0 && first.charCodeAt(~-firstLength) === second.charCodeAt(~-secondLength)) {
1365
- firstLength--;
1366
- secondLength--;
1367
- }
1368
- let start = 0;
1369
- while (start < firstLength && first.charCodeAt(start) === second.charCodeAt(start)) {
1370
- start++;
1371
- }
1372
- firstLength -= start;
1373
- secondLength -= start;
1374
- if (firstLength === 0) {
1375
- return secondLength;
1376
- }
1377
- let bCharacterCode;
1378
- let result;
1379
- let temporary;
1380
- let temporary2;
1381
- let index = 0;
1382
- let index2 = 0;
1383
- while (index < firstLength) {
1384
- characterCodeCache[index] = first.charCodeAt(start + index);
1385
- array[index] = ++index;
1386
- }
1387
- while (index2 < secondLength) {
1388
- bCharacterCode = second.charCodeAt(start + index2);
1389
- temporary = index2++;
1390
- result = index2;
1391
- for (index = 0; index < firstLength; index++) {
1392
- temporary2 = bCharacterCode === characterCodeCache[index] ? temporary : temporary + 1;
1393
- temporary = array[index];
1394
- result = array[index] = temporary > result ? temporary2 > result ? result + 1 : temporary2 : temporary2 > temporary ? temporary + 1 : temporary2;
1395
- }
1396
- }
1397
- return result;
1398
- }
1399
-
1400
- // src/cli/options/normalize-cli-options.js
1401
- var descriptor = {
1402
- key: (key) => key.length === 1 ? `-${key}` : `--${key}`,
1403
- value: (value) => vnopts.apiDescriptor.value(value),
1404
- pair: ({ key, value }) => value === false ? `--no-${key}` : value === true ? descriptor.key(key) : value === "" ? `${descriptor.key(key)} without an argument` : `${descriptor.key(key)}=${value}`
1405
- };
1406
- var _flags;
1407
- var FlagSchema = class extends vnopts.ChoiceSchema {
1408
- constructor({ name, flags }) {
1409
- super({ name, choices: flags });
1410
- __privateAdd(this, _flags, []);
1411
- __privateSet(this, _flags, [...flags].sort());
1412
- }
1413
- preprocess(value, utils) {
1414
- if (typeof value === "string" && value.length > 0 && !__privateGet(this, _flags).includes(value)) {
1415
- const suggestion = __privateGet(this, _flags).find((flag) => leven(flag, value) < 3);
1416
- if (suggestion) {
1417
- utils.logger.warn(
1418
- [
1419
- `Unknown flag ${source_default.yellow(utils.descriptor.value(value))},`,
1420
- `did you mean ${source_default.blue(utils.descriptor.value(suggestion))}?`
1421
- ].join(" ")
1422
- );
1423
- return suggestion;
1424
- }
1425
- }
1426
- return value;
1427
- }
1428
- expected() {
1429
- return "a flag";
1430
- }
1431
- };
1432
- _flags = new WeakMap();
1433
- function normalizeCliOptions(options, optionInfos, opts) {
1434
- return normalizeOptions(options, optionInfos, {
1435
- ...opts,
1436
- isCLI: true,
1437
- FlagSchema,
1438
- descriptor
1439
- });
1440
- }
1441
- var normalize_cli_options_default = normalizeCliOptions;
1442
-
1443
- // src/cli/options/parse-cli-arguments.js
1444
- function parseArgv(rawArguments, detailedOptions, logger, keys2) {
1445
- var _a;
1446
- const minimistOptions = createMinimistOptions(detailedOptions);
1447
- let argv = minimistParse(rawArguments, minimistOptions);
1448
- if (keys2) {
1449
- detailedOptions = detailedOptions.filter(
1450
- (option) => keys2.includes(option.name)
1451
- );
1452
- argv = pick(argv, keys2);
1453
- }
1454
- const normalized = normalize_cli_options_default(argv, detailedOptions, { logger });
1455
- return {
1456
- ...Object.fromEntries(
1457
- Object.entries(normalized).map(([key, value]) => {
1458
- const option = detailedOptions.find(({ name }) => name === key) || {};
1459
- return [option.forwardToApi || camelCase(key), value];
1460
- })
1461
- ),
1462
- _: (_a = normalized._) == null ? void 0 : _a.map(String),
1463
- get __raw() {
1464
- return argv;
1465
- }
1466
- };
1467
- }
1468
- var { detailedOptions: detailedOptionsWithoutPlugins } = getContextOptionsWithoutPlugins();
1469
- function parseArgvWithoutPlugins(rawArguments, logger, keys2) {
1470
- return parseArgv(
1471
- rawArguments,
1472
- detailedOptionsWithoutPlugins,
1473
- logger,
1474
- typeof keys2 === "string" ? [keys2] : keys2
1475
- );
1476
- }
1477
-
1478
- // src/cli/context.js
1479
- var _stack;
1480
- var Context = class {
1481
- constructor({ rawArguments, logger }) {
1482
- __privateAdd(this, _stack, []);
1483
- this.rawArguments = rawArguments;
1484
- this.logger = logger;
1485
- }
1486
- async init() {
1487
- const { rawArguments, logger } = this;
1488
- const { plugins } = parseArgvWithoutPlugins(rawArguments, logger, [
1489
- "plugin"
1490
- ]);
1491
- await this.pushContextPlugins(plugins);
1492
- const argv = parseArgv(rawArguments, this.detailedOptions, logger);
1493
- this.argv = argv;
1494
- this.filePatterns = argv._;
1389
+ async init() {
1390
+ const { rawArguments, logger } = this;
1391
+ const { plugins } = parseArgvWithoutPlugins(rawArguments, logger, [
1392
+ "plugin"
1393
+ ]);
1394
+ await this.pushContextPlugins(plugins);
1395
+ const argv2 = parseArgv(rawArguments, this.detailedOptions, logger);
1396
+ this.argv = argv2;
1397
+ this.filePatterns = argv2._;
1495
1398
  }
1496
1399
  /**
1497
1400
  * @param {string[]} plugins
@@ -1539,33 +1442,35 @@ var context_default = Context;
1539
1442
 
1540
1443
  // src/cli/file-info.js
1541
1444
  var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify(), 1);
1445
+ import path2 from "path";
1542
1446
  import { format, getFileInfo } from "../index.mjs";
1543
1447
  async function logFileInfoOrDie(context) {
1544
1448
  const {
1545
1449
  fileInfo: file,
1546
1450
  ignorePath,
1547
- withNodeModules,
1451
+ withNodeModules: withNodeModules2,
1548
1452
  plugins,
1549
1453
  config
1550
1454
  } = context.argv;
1551
- const fileInfo = await getFileInfo(file, {
1455
+ const fileInfo = await getFileInfo(path2.resolve(file), {
1552
1456
  ignorePath,
1553
- withNodeModules,
1554
- plugins,
1457
+ withNodeModules: withNodeModules2,
1458
+ plugins: plugins.length > 0 ? plugins : void 0,
1555
1459
  resolveConfig: config !== false
1556
1460
  });
1557
- printToScreen(await format((0, import_fast_json_stable_stringify.default)(fileInfo), { parser: "json" }));
1461
+ const result = await format((0, import_fast_json_stable_stringify.default)(fileInfo), { parser: "json" });
1462
+ printToScreen(result.trim());
1558
1463
  }
1559
1464
  var file_info_default = logFileInfoOrDie;
1560
1465
 
1561
1466
  // src/cli/find-config-path.js
1562
- import path2 from "path";
1467
+ import path3 from "path";
1563
1468
  import { resolveConfigFile } from "../index.mjs";
1564
1469
  async function logResolvedConfigPathOrDie(context) {
1565
1470
  const file = context.argv.findConfigPath;
1566
1471
  const configFile = await resolveConfigFile(file);
1567
1472
  if (configFile) {
1568
- printToScreen(normalizeToPosix(path2.relative(process.cwd(), configFile)));
1473
+ printToScreen(normalizeToPosix(path3.relative(process.cwd(), configFile)));
1569
1474
  } else {
1570
1475
  throw new Error(`Can not find configure file for "${file}".`);
1571
1476
  }
@@ -1573,12 +1478,77 @@ async function logResolvedConfigPathOrDie(context) {
1573
1478
  var find_config_path_default = logResolvedConfigPathOrDie;
1574
1479
 
1575
1480
  // src/cli/format.js
1576
- import fs8 from "fs/promises";
1577
- import path11 from "path";
1481
+ import fs9 from "fs/promises";
1482
+ import path12 from "path";
1483
+
1484
+ // node_modules/get-stdin/index.js
1485
+ var { stdin } = process;
1486
+ async function getStdin() {
1487
+ let result = "";
1488
+ if (stdin.isTTY) {
1489
+ return result;
1490
+ }
1491
+ stdin.setEncoding("utf8");
1492
+ for await (const chunk of stdin) {
1493
+ result += chunk;
1494
+ }
1495
+ return result;
1496
+ }
1497
+ getStdin.buffer = async () => {
1498
+ const result = [];
1499
+ let length = 0;
1500
+ if (stdin.isTTY) {
1501
+ return Buffer.concat([]);
1502
+ }
1503
+ for await (const chunk of stdin) {
1504
+ result.push(chunk);
1505
+ length += chunk.length;
1506
+ }
1507
+ return Buffer.concat(result, length);
1508
+ };
1509
+
1510
+ // src/cli/format.js
1578
1511
  import * as prettier from "../index.mjs";
1579
1512
 
1580
1513
  // src/cli/expand-patterns.js
1581
- import path3 from "path";
1514
+ import path5 from "path";
1515
+
1516
+ // src/cli/directory-ignorer.js
1517
+ import path4 from "path";
1518
+ var alwaysIgnoredDirectories = [".git", ".sl", ".svn", ".hg", ".jj"];
1519
+ var withNodeModules = [...alwaysIgnoredDirectories, "node_modules"];
1520
+ var cwd = process.cwd();
1521
+ var _directories;
1522
+ var DirectoryIgnorer = class {
1523
+ constructor(shouldIgnoreNodeModules) {
1524
+ __privateAdd(this, _directories);
1525
+ __publicField(this, "ignorePatterns");
1526
+ const directories = shouldIgnoreNodeModules ? withNodeModules : alwaysIgnoredDirectories;
1527
+ const patterns = directories.map((directory) => `**/${directory}`);
1528
+ __privateSet(this, _directories, new Set(directories));
1529
+ this.ignorePatterns = patterns;
1530
+ }
1531
+ /**
1532
+ * @param {string} absolutePathOrPattern
1533
+ */
1534
+ shouldIgnore(absolutePathOrPattern) {
1535
+ const directoryNames = path4.relative(cwd, absolutePathOrPattern).split(path4.sep);
1536
+ return directoryNames.some(
1537
+ (directoryName) => __privateGet(this, _directories).has(directoryName)
1538
+ );
1539
+ }
1540
+ };
1541
+ _directories = new WeakMap();
1542
+ var directoryIgnorerWithNodeModules = new DirectoryIgnorer(
1543
+ /* shouldIgnoreNodeModules */
1544
+ true
1545
+ );
1546
+ var directoryIgnorerWithoutNodeModules = new DirectoryIgnorer(
1547
+ /* shouldIgnoreNodeModules */
1548
+ false
1549
+ );
1550
+
1551
+ // src/cli/expand-patterns.js
1582
1552
  async function* expandPatterns(context) {
1583
1553
  const seen = /* @__PURE__ */ new Set();
1584
1554
  let noResults = true;
@@ -1590,7 +1560,7 @@ async function* expandPatterns(context) {
1590
1560
  yield { error };
1591
1561
  continue;
1592
1562
  }
1593
- const filename = path3.resolve(filePath);
1563
+ const filename = path5.resolve(filePath);
1594
1564
  if (seen.has(filename)) {
1595
1565
  continue;
1596
1566
  }
@@ -1604,20 +1574,17 @@ async function* expandPatterns(context) {
1604
1574
  }
1605
1575
  }
1606
1576
  async function* expandPatternsInternal(context) {
1607
- const silentlyIgnoredDirs = [".git", ".sl", ".svn", ".hg", ".jj"];
1608
- if (context.argv.withNodeModules !== true) {
1609
- silentlyIgnoredDirs.push("node_modules");
1610
- }
1577
+ const directoryIgnorer = context.argv.withNodeModules === true ? directoryIgnorerWithoutNodeModules : directoryIgnorerWithNodeModules;
1611
1578
  const globOptions = {
1612
1579
  dot: true,
1613
- ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir),
1580
+ ignore: [...directoryIgnorer.ignorePatterns],
1614
1581
  followSymbolicLinks: false
1615
1582
  };
1616
- const cwd2 = process.cwd();
1583
+ const cwd3 = process.cwd();
1617
1584
  const entries = [];
1618
1585
  for (const pattern of context.filePatterns) {
1619
- const absolutePath = path3.resolve(cwd2, pattern);
1620
- if (containsIgnoredPathSegment(absolutePath, cwd2, silentlyIgnoredDirs)) {
1586
+ const absolutePath = path5.resolve(pattern);
1587
+ if (directoryIgnorer.shouldIgnore(absolutePath)) {
1621
1588
  continue;
1622
1589
  }
1623
1590
  const stat = await lstatSafe(absolutePath);
@@ -1639,7 +1606,7 @@ async function* expandPatternsInternal(context) {
1639
1606
  input: pattern
1640
1607
  });
1641
1608
  } else if (stat.isDirectory()) {
1642
- const relativePath = path3.relative(cwd2, absolutePath) || ".";
1609
+ const relativePath = path5.relative(cwd3, absolutePath) || ".";
1643
1610
  const prefix = escapePathForGlob(fixWindowsSlashes(relativePath));
1644
1611
  entries.push({
1645
1612
  type: "dir",
@@ -1690,13 +1657,10 @@ var errorMessages = {
1690
1657
  glob: "No files matching the pattern were found"
1691
1658
  }
1692
1659
  };
1693
- function containsIgnoredPathSegment(absolutePath, cwd2, ignoredDirectories) {
1694
- return path3.relative(cwd2, absolutePath).split(path3.sep).some((dir) => ignoredDirectories.includes(dir));
1695
- }
1696
1660
  function sortPaths(paths) {
1697
1661
  return paths.sort((a, b) => a.localeCompare(b));
1698
1662
  }
1699
- function escapePathForGlob(path12) {
1663
+ function escapePathForGlob(path13) {
1700
1664
  return string_replace_all_default(
1701
1665
  /* isOptionalObject */
1702
1666
  false,
@@ -1707,7 +1671,7 @@ function escapePathForGlob(path12) {
1707
1671
  string_replace_all_default(
1708
1672
  /* isOptionalObject */
1709
1673
  false,
1710
- path12,
1674
+ path13,
1711
1675
  "\\",
1712
1676
  "\0"
1713
1677
  )
@@ -1724,114 +1688,60 @@ var fixWindowsSlashes = normalizeToPosix;
1724
1688
 
1725
1689
  // src/cli/find-cache-file.js
1726
1690
  import fs4 from "fs/promises";
1727
- import os2 from "os";
1728
- import path8 from "path";
1691
+ import os from "os";
1692
+ import path9 from "path";
1729
1693
 
1730
- // node_modules/find-cache-dir/index.js
1694
+ // node_modules/find-cache-directory/index.js
1731
1695
  var import_common_path_prefix = __toESM(require_common_path_prefix(), 1);
1732
- import process4 from "process";
1733
- import path7 from "path";
1696
+ import process3 from "process";
1697
+ import path8 from "path";
1734
1698
  import fs3 from "fs";
1735
1699
 
1736
1700
  // node_modules/pkg-dir/index.js
1737
- import path6 from "path";
1738
-
1739
- // node_modules/pkg-dir/node_modules/find-up/index.js
1740
- import path5 from "path";
1741
- import { fileURLToPath as fileURLToPath2 } from "url";
1701
+ import path7 from "path";
1742
1702
 
1743
- // node_modules/locate-path/index.js
1744
- import process3 from "process";
1745
- import path4 from "path";
1746
- import fs2, { promises as fsPromises } from "fs";
1703
+ // node_modules/find-up-simple/index.js
1704
+ import process2 from "process";
1747
1705
  import { fileURLToPath } from "url";
1748
- var typeMappings = {
1749
- directory: "isDirectory",
1750
- file: "isFile"
1751
- };
1752
- function checkType(type) {
1753
- if (Object.hasOwnProperty.call(typeMappings, type)) {
1754
- return;
1755
- }
1756
- throw new Error(`Invalid type specified: ${type}`);
1757
- }
1758
- var matchType = (type, stat) => stat[typeMappings[type]]();
1706
+ import fs2 from "fs";
1707
+ import path6 from "path";
1759
1708
  var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
1760
- function locatePathSync(paths, {
1761
- cwd: cwd2 = process3.cwd(),
1709
+ function findUpSync(name, {
1710
+ cwd: cwd3 = process2.cwd(),
1762
1711
  type = "file",
1763
- allowSymlinks = true
1712
+ stopAt
1764
1713
  } = {}) {
1765
- checkType(type);
1766
- cwd2 = toPath(cwd2);
1767
- const statFunction = allowSymlinks ? fs2.statSync : fs2.lstatSync;
1768
- for (const path_ of paths) {
1714
+ let directory = path6.resolve(toPath(cwd3) ?? "");
1715
+ const { root } = path6.parse(directory);
1716
+ stopAt = path6.resolve(directory, toPath(stopAt) ?? root);
1717
+ const isAbsoluteName = path6.isAbsolute(name);
1718
+ while (directory) {
1719
+ const filePath = isAbsoluteName ? name : path6.join(directory, name);
1769
1720
  try {
1770
- const stat = statFunction(path4.resolve(cwd2, path_), {
1771
- throwIfNoEntry: false
1772
- });
1773
- if (!stat) {
1774
- continue;
1775
- }
1776
- if (matchType(type, stat)) {
1777
- return path_;
1721
+ const stats = fs2.statSync(filePath, { throwIfNoEntry: false });
1722
+ if (type === "file" && (stats == null ? void 0 : stats.isFile()) || type === "directory" && (stats == null ? void 0 : stats.isDirectory())) {
1723
+ return filePath;
1778
1724
  }
1779
1725
  } catch {
1780
1726
  }
1781
- }
1782
- }
1783
-
1784
- // node_modules/pkg-dir/node_modules/find-up/index.js
1785
- var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
1786
- var findUpStop = Symbol("findUpStop");
1787
- function findUpMultipleSync(name, options = {}) {
1788
- let directory = path5.resolve(toPath2(options.cwd) || "");
1789
- const { root } = path5.parse(directory);
1790
- const stopAt = options.stopAt || root;
1791
- const limit = options.limit || Number.POSITIVE_INFINITY;
1792
- const paths = [name].flat();
1793
- const runMatcher = (locateOptions) => {
1794
- if (typeof name !== "function") {
1795
- return locatePathSync(paths, locateOptions);
1796
- }
1797
- const foundPath = name(locateOptions.cwd);
1798
- if (typeof foundPath === "string") {
1799
- return locatePathSync([foundPath], locateOptions);
1800
- }
1801
- return foundPath;
1802
- };
1803
- const matches = [];
1804
- while (true) {
1805
- const foundPath = runMatcher({ ...options, cwd: directory });
1806
- if (foundPath === findUpStop) {
1807
- break;
1808
- }
1809
- if (foundPath) {
1810
- matches.push(path5.resolve(directory, foundPath));
1811
- }
1812
- if (directory === stopAt || matches.length >= limit) {
1727
+ if (directory === stopAt || directory === root) {
1813
1728
  break;
1814
1729
  }
1815
- directory = path5.dirname(directory);
1730
+ directory = path6.dirname(directory);
1816
1731
  }
1817
- return matches;
1818
- }
1819
- function findUpSync(name, options = {}) {
1820
- const matches = findUpMultipleSync(name, { ...options, limit: 1 });
1821
- return matches[0];
1822
1732
  }
1823
1733
 
1824
1734
  // node_modules/pkg-dir/index.js
1825
- function packageDirectorySync({ cwd: cwd2 } = {}) {
1826
- const filePath = findUpSync("package.json", { cwd: cwd2 });
1827
- return filePath && path6.dirname(filePath);
1735
+ function packageDirectorySync({ cwd: cwd3 } = {}) {
1736
+ const filePath = findUpSync("package.json", { cwd: cwd3 });
1737
+ return filePath && path7.dirname(filePath);
1828
1738
  }
1829
1739
 
1830
- // node_modules/find-cache-dir/index.js
1831
- var { env: env2, cwd } = process4;
1832
- var isWritable = (path12) => {
1740
+ // node_modules/find-cache-directory/index.js
1741
+ var { env, cwd: cwd2 } = process3;
1742
+ var isWritable = (path13) => {
1833
1743
  try {
1834
- fs3.accessSync(path12, fs3.constants.W_OK);
1744
+ fs3.accessSync(path13, fs3.constants.W_OK);
1835
1745
  return true;
1836
1746
  } catch {
1837
1747
  return false;
@@ -1844,22 +1754,22 @@ function useDirectory(directory, options) {
1844
1754
  return directory;
1845
1755
  }
1846
1756
  function getNodeModuleDirectory(directory) {
1847
- const nodeModules = path7.join(directory, "node_modules");
1848
- if (!isWritable(nodeModules) && (fs3.existsSync(nodeModules) || !isWritable(path7.join(directory)))) {
1757
+ const nodeModules = path8.join(directory, "node_modules");
1758
+ if (!isWritable(nodeModules) && (fs3.existsSync(nodeModules) || !isWritable(path8.join(directory)))) {
1849
1759
  return;
1850
1760
  }
1851
1761
  return nodeModules;
1852
1762
  }
1853
1763
  function findCacheDirectory(options = {}) {
1854
- if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
1855
- return useDirectory(path7.join(env2.CACHE_DIR, options.name), options);
1764
+ if (env.CACHE_DIR && !["true", "false", "1", "0"].includes(env.CACHE_DIR)) {
1765
+ return useDirectory(path8.join(env.CACHE_DIR, options.name), options);
1856
1766
  }
1857
- let { cwd: directory = cwd(), files } = options;
1767
+ let { cwd: directory = cwd2(), files } = options;
1858
1768
  if (files) {
1859
1769
  if (!Array.isArray(files)) {
1860
1770
  throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof files}\`.`);
1861
1771
  }
1862
- directory = (0, import_common_path_prefix.default)(files.map((file) => path7.resolve(directory, file)));
1772
+ directory = (0, import_common_path_prefix.default)(files.map((file) => path8.resolve(directory, file)));
1863
1773
  }
1864
1774
  directory = packageDirectorySync({ cwd: directory });
1865
1775
  if (!directory) {
@@ -1869,17 +1779,17 @@ function findCacheDirectory(options = {}) {
1869
1779
  if (!nodeModules) {
1870
1780
  return;
1871
1781
  }
1872
- return useDirectory(path7.join(directory, "node_modules", ".cache", options.name), options);
1782
+ return useDirectory(path8.join(directory, "node_modules", ".cache", options.name), options);
1873
1783
  }
1874
1784
 
1875
1785
  // src/cli/find-cache-file.js
1876
1786
  function findDefaultCacheFile() {
1877
- const cacheDir = findCacheDirectory({ name: "prettier", create: true }) || os2.tmpdir();
1878
- const cacheFilePath = path8.join(cacheDir, ".prettier-cache");
1787
+ const cacheDir = findCacheDirectory({ name: "prettier", create: true }) || os.tmpdir();
1788
+ const cacheFilePath = path9.join(cacheDir, ".prettier-cache");
1879
1789
  return cacheFilePath;
1880
1790
  }
1881
1791
  async function findCacheFileFromOption(cacheLocation) {
1882
- const cacheFile = path8.resolve(cacheLocation);
1792
+ const cacheFile = path9.resolve(cacheLocation);
1883
1793
  const stat = await statSafe(cacheFile);
1884
1794
  if (stat) {
1885
1795
  if (stat.isDirectory()) {
@@ -1910,348 +1820,148 @@ import fs7 from "fs";
1910
1820
  // node_modules/file-entry-cache/dist/index.js
1911
1821
  import crypto2 from "crypto";
1912
1822
  import fs6 from "fs";
1913
- import path10 from "path";
1823
+ import path11 from "path";
1914
1824
 
1915
1825
  // node_modules/file-entry-cache/node_modules/flat-cache/dist/index.js
1916
- import path9 from "path";
1826
+ import path10 from "path";
1917
1827
  import fs5 from "fs";
1918
1828
 
1919
1829
  // node_modules/hookified/dist/node/index.js
1920
- var Eventified = class {
1830
+ var n = class {
1921
1831
  _eventListeners;
1922
1832
  _maxListeners;
1923
- constructor() {
1924
- this._eventListeners = /* @__PURE__ */ new Map();
1925
- this._maxListeners = 100;
1833
+ _logger;
1834
+ constructor(e) {
1835
+ this._eventListeners = /* @__PURE__ */ new Map(), this._maxListeners = 100, this._logger = e == null ? void 0 : e.logger;
1926
1836
  }
1927
- /**
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
1932
- */
1933
- once(eventName, listener) {
1934
- const onceListener = (...arguments_) => {
1935
- this.off(eventName, onceListener);
1936
- listener(...arguments_);
1837
+ once(e, t) {
1838
+ let s = (...r) => {
1839
+ this.off(e, s), t(...r);
1937
1840
  };
1938
- this.on(eventName, onceListener);
1939
- return this;
1841
+ return this.on(e, s), this;
1940
1842
  }
1941
- /**
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
1945
- */
1946
- listenerCount(eventName) {
1947
- if (!eventName) {
1948
- return this.getAllListeners().length;
1949
- }
1950
- const listeners = this._eventListeners.get(eventName);
1951
- return listeners ? listeners.length : 0;
1843
+ listenerCount(e) {
1844
+ if (!e) return this.getAllListeners().length;
1845
+ let t = this._eventListeners.get(e);
1846
+ return t ? t.length : 0;
1952
1847
  }
1953
- /**
1954
- * Gets an array of event names
1955
- * @returns {Array<string | symbol>} An array of event names
1956
- */
1957
1848
  eventNames() {
1958
- return Array.from(this._eventListeners.keys());
1849
+ return [...this._eventListeners.keys()];
1959
1850
  }
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();
1968
- }
1969
- return this._eventListeners.get(event) ?? [];
1851
+ rawListeners(e) {
1852
+ return e ? this._eventListeners.get(e) ?? [] : this.getAllListeners();
1970
1853
  }
1971
- /**
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
1976
- */
1977
- prependListener(eventName, listener) {
1978
- const listeners = this._eventListeners.get(eventName) ?? [];
1979
- listeners.unshift(listener);
1980
- this._eventListeners.set(eventName, listeners);
1981
- return this;
1854
+ prependListener(e, t) {
1855
+ let s = this._eventListeners.get(e) ?? [];
1856
+ return s.unshift(t), this._eventListeners.set(e, s), this;
1982
1857
  }
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_);
1858
+ prependOnceListener(e, t) {
1859
+ let s = (...r) => {
1860
+ this.off(e, s), t(...r);
1993
1861
  };
1994
- this.prependListener(eventName, onceListener);
1995
- return this;
1862
+ return this.prependListener(e, s), this;
1996
1863
  }
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
1864
  maxListeners() {
2002
1865
  return this._maxListeners;
2003
1866
  }
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;
1867
+ addListener(e, t) {
1868
+ return this.on(e, t), this;
2013
1869
  }
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;
1870
+ on(e, t) {
1871
+ this._eventListeners.has(e) || this._eventListeners.set(e, []);
1872
+ let s = this._eventListeners.get(e);
1873
+ return s && (s.length >= this._maxListeners && console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${s.length + 1} ${e} listeners added. Use setMaxListeners() to increase limit.`), s.push(t)), this;
2032
1874
  }
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;
1875
+ removeListener(e, t) {
1876
+ return this.off(e, t), this;
2042
1877
  }
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;
1878
+ off(e, t) {
1879
+ let s = this._eventListeners.get(e) ?? [], r = s.indexOf(t);
1880
+ return r !== -1 && s.splice(r, 1), s.length === 0 && this._eventListeners.delete(e), this;
2059
1881
  }
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;
1882
+ emit(e, ...t) {
1883
+ let s = false, r = this._eventListeners.get(e);
1884
+ if (r && r.length > 0) for (let i of r) i(...t), s = true;
1885
+ return s;
2076
1886
  }
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) ?? [];
1887
+ listeners(e) {
1888
+ return this._eventListeners.get(e) ?? [];
2084
1889
  }
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;
1890
+ removeAllListeners(e) {
1891
+ return e ? this._eventListeners.delete(e) : this._eventListeners.clear(), this;
2097
1892
  }
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
- }
1893
+ setMaxListeners(e) {
1894
+ this._maxListeners = e;
1895
+ for (let t of this._eventListeners.values()) t.length > e && t.splice(e);
2110
1896
  }
2111
- /**
2112
- * Gets all listeners
2113
- * @returns {EventListener[]} An array of listeners
2114
- */
2115
1897
  getAllListeners() {
2116
- let result = new Array();
2117
- for (const listeners of this._eventListeners.values()) {
2118
- result = result.concat(listeners);
2119
- }
2120
- return result;
1898
+ let e = new Array();
1899
+ for (let t of this._eventListeners.values()) e = [...e, ...t];
1900
+ return e;
2121
1901
  }
2122
1902
  };
2123
- var Hookified = class extends Eventified {
1903
+ var l = class extends n {
2124
1904
  _hooks;
2125
1905
  _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
- }
1906
+ constructor(e) {
1907
+ super({ logger: e == null ? void 0 : e.logger }), this._hooks = /* @__PURE__ */ new Map(), (e == null ? void 0 : e.throwHookErrors) !== void 0 && (this._throwHookErrors = e.throwHookErrors);
2132
1908
  }
2133
- /**
2134
- * Gets all hooks
2135
- * @returns {Map<string, Hook[]>}
2136
- */
2137
1909
  get hooks() {
2138
1910
  return this._hooks;
2139
1911
  }
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
1912
  get throwHookErrors() {
2145
1913
  return this._throwHookErrors;
2146
1914
  }
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;
1915
+ set throwHookErrors(e) {
1916
+ this._throwHookErrors = e;
2153
1917
  }
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
- }
1918
+ get logger() {
1919
+ return this._logger;
2167
1920
  }
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
- }
1921
+ set logger(e) {
1922
+ this._logger = e;
2181
1923
  }
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);
1924
+ onHook(e, t) {
1925
+ let s = this._hooks.get(e);
1926
+ s ? s.push(t) : this._hooks.set(e, [t]);
2193
1927
  }
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);
1928
+ onHooks(e) {
1929
+ for (let t of e) this.onHook(t.event, t.handler);
2205
1930
  }
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
- }
1931
+ prependHook(e, t) {
1932
+ let s = this._hooks.get(e);
1933
+ s ? s.unshift(t) : this._hooks.set(e, [t]);
1934
+ }
1935
+ prependOnceHook(e, t) {
1936
+ let s = async (...r) => (this.removeHook(e, s), t(...r));
1937
+ this.prependHook(e, s);
1938
+ }
1939
+ onceHook(e, t) {
1940
+ let s = async (...r) => (this.removeHook(e, s), t(...r));
1941
+ this.onHook(e, s);
1942
+ }
1943
+ removeHook(e, t) {
1944
+ let s = this._hooks.get(e);
1945
+ if (s) {
1946
+ let r = s.indexOf(t);
1947
+ r !== -1 && s.splice(r, 1);
2219
1948
  }
2220
1949
  }
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
- }
1950
+ removeHooks(e) {
1951
+ for (let t of e) this.removeHook(t.event, t.handler);
1952
+ }
1953
+ async hook(e, ...t) {
1954
+ let s = this._hooks.get(e);
1955
+ if (s) for (let r of s) try {
1956
+ await r(...t);
1957
+ } catch (i) {
1958
+ let o = `${e}: ${i.message}`;
1959
+ if (this.emit("error", new Error(o)), this._logger && this._logger.error(o), this._throwHookErrors) throw new Error(o);
2241
1960
  }
2242
1961
  }
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);
1962
+ getHooks(e) {
1963
+ return this._hooks.get(e);
2250
1964
  }
2251
- /**
2252
- * Removes all hooks
2253
- * @returns {void}
2254
- */
2255
1965
  clearHooks() {
2256
1966
  this._hooks.clear();
2257
1967
  }
@@ -2334,6 +2044,26 @@ function hash(object2, algorithm = "sha256") {
2334
2044
  hasher.update(objectString);
2335
2045
  return hasher.digest("hex");
2336
2046
  }
2047
+ function hashToNumber(object2, min = 0, max = 10, algorithm = "sha256") {
2048
+ const objectString = JSON.stringify(object2);
2049
+ if (!crypto.getHashes().includes(algorithm)) {
2050
+ throw new Error(`Unsupported hash algorithm: '${algorithm}'`);
2051
+ }
2052
+ const hasher = crypto.createHash(algorithm);
2053
+ hasher.update(objectString);
2054
+ const hashHex = hasher.digest("hex");
2055
+ const hashNumber = Number.parseInt(hashHex, 16);
2056
+ const range = max - min + 1;
2057
+ return min + hashNumber % range;
2058
+ }
2059
+ function djb2Hash(string_, min = 0, max = 10) {
2060
+ let hash2 = 5381;
2061
+ for (let i = 0; i < string_.length; i++) {
2062
+ hash2 = hash2 * 33 ^ string_.charCodeAt(i);
2063
+ }
2064
+ const range = max - min + 1;
2065
+ return min + Math.abs(hash2) % range;
2066
+ }
2337
2067
  function wrapSync(function_, options) {
2338
2068
  const { ttl, keyPrefix, cache } = options;
2339
2069
  return function(...arguments_) {
@@ -2430,19 +2160,14 @@ var DoublyLinkedList = class {
2430
2160
  return this.nodesMap.size;
2431
2161
  }
2432
2162
  };
2433
- var CacheableMemory = class extends Hookified {
2163
+ var defaultStoreHashSize = 16;
2164
+ var maximumMapSize = 16777216;
2165
+ var CacheableMemory = class extends l {
2434
2166
  _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();
2167
+ _storeHashSize = defaultStoreHashSize;
2168
+ _storeHashAlgorithm = "djb2Hash";
2169
+ // Default is djb2Hash
2170
+ _store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
2446
2171
  _ttl;
2447
2172
  // Turned off by default
2448
2173
  _useClone = true;
@@ -2465,12 +2190,23 @@ var CacheableMemory = class extends Hookified {
2465
2190
  if ((options == null ? void 0 : options.useClone) !== void 0) {
2466
2191
  this._useClone = options.useClone;
2467
2192
  }
2193
+ if ((options == null ? void 0 : options.storeHashSize) && options.storeHashSize > 0) {
2194
+ this._storeHashSize = options.storeHashSize;
2195
+ }
2468
2196
  if (options == null ? void 0 : options.lruSize) {
2469
- this._lruSize = options.lruSize;
2197
+ if (options.lruSize > maximumMapSize) {
2198
+ this.emit("error", new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`));
2199
+ } else {
2200
+ this._lruSize = options.lruSize;
2201
+ }
2470
2202
  }
2471
2203
  if (options == null ? void 0 : options.checkInterval) {
2472
2204
  this._checkInterval = options.checkInterval;
2473
2205
  }
2206
+ if (options == null ? void 0 : options.storeHashAlgorithm) {
2207
+ this._storeHashAlgorithm = options.storeHashAlgorithm;
2208
+ }
2209
+ this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
2474
2210
  this.startIntervalCheck();
2475
2211
  }
2476
2212
  /**
@@ -2503,17 +2239,25 @@ var CacheableMemory = class extends Hookified {
2503
2239
  }
2504
2240
  /**
2505
2241
  * 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.
2242
+ * @returns {number} - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm.
2507
2243
  */
2508
2244
  get lruSize() {
2509
2245
  return this._lruSize;
2510
2246
  }
2511
2247
  /**
2512
2248
  * 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.
2249
+ * @param {number} value - The size of the LRU cache. If set to 0, it will not use LRU cache. Default is 0. If you are using LRU then the limit is based on Map() size 17mm.
2514
2250
  */
2515
2251
  set lruSize(value) {
2252
+ if (value > maximumMapSize) {
2253
+ this.emit("error", new Error(`LRU size cannot be larger than ${maximumMapSize} due to Map limitations.`));
2254
+ return;
2255
+ }
2516
2256
  this._lruSize = value;
2257
+ if (this._lruSize === 0) {
2258
+ this._lru = new DoublyLinkedList();
2259
+ return;
2260
+ }
2517
2261
  this.lruResize();
2518
2262
  }
2519
2263
  /**
@@ -2535,21 +2279,85 @@ var CacheableMemory = class extends Hookified {
2535
2279
  * @returns {number} - The size of the cache
2536
2280
  */
2537
2281
  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;
2282
+ let size = 0;
2283
+ for (const store of this._store) {
2284
+ size += store.size;
2285
+ }
2286
+ return size;
2287
+ }
2288
+ /**
2289
+ * Gets the number of hash stores
2290
+ * @returns {number} - The number of hash stores
2291
+ */
2292
+ get storeHashSize() {
2293
+ return this._storeHashSize;
2294
+ }
2295
+ /**
2296
+ * Sets the number of hash stores. This will recreate the store and all data will be cleared
2297
+ * @param {number} value - The number of hash stores
2298
+ */
2299
+ set storeHashSize(value) {
2300
+ if (value === this._storeHashSize) {
2301
+ return;
2302
+ }
2303
+ this._storeHashSize = value;
2304
+ this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
2305
+ }
2306
+ /**
2307
+ * Gets the store hash algorithm
2308
+ * @returns {StoreHashAlgorithm | StoreHashAlgorithmFunction} - The store hash algorithm
2309
+ */
2310
+ get storeHashAlgorithm() {
2311
+ return this._storeHashAlgorithm;
2312
+ }
2313
+ /**
2314
+ * Sets the store hash algorithm. This will recreate the store and all data will be cleared
2315
+ * @param {StoreHashAlgorithm | StoreHashAlgorithmFunction} value - The store hash algorithm
2316
+ */
2317
+ set storeHashAlgorithm(value) {
2318
+ this._storeHashAlgorithm = value;
2539
2319
  }
2540
2320
  /**
2541
2321
  * Gets the keys
2542
2322
  * @returns {IterableIterator<string>} - The keys
2543
2323
  */
2544
2324
  get keys() {
2545
- return this.concatStores().keys();
2325
+ const keys2 = new Array();
2326
+ for (const store of this._store) {
2327
+ for (const key of store.keys()) {
2328
+ const item = store.get(key);
2329
+ if (item && this.hasExpired(item)) {
2330
+ store.delete(key);
2331
+ continue;
2332
+ }
2333
+ keys2.push(key);
2334
+ }
2335
+ }
2336
+ return keys2.values();
2546
2337
  }
2547
2338
  /**
2548
2339
  * Gets the items
2549
2340
  * @returns {IterableIterator<CacheableStoreItem>} - The items
2550
2341
  */
2551
2342
  get items() {
2552
- return this.concatStores().values();
2343
+ const items = new Array();
2344
+ for (const store of this._store) {
2345
+ for (const item of store.values()) {
2346
+ if (this.hasExpired(item)) {
2347
+ store.delete(item.key);
2348
+ continue;
2349
+ }
2350
+ items.push(item);
2351
+ }
2352
+ }
2353
+ return items.values();
2354
+ }
2355
+ /**
2356
+ * Gets the store
2357
+ * @returns {Array<Map<string, CacheableStoreItem>>} - The store
2358
+ */
2359
+ get store() {
2360
+ return this._store;
2553
2361
  }
2554
2362
  /**
2555
2363
  * Gets the value of the key
@@ -2562,7 +2370,7 @@ var CacheableMemory = class extends Hookified {
2562
2370
  if (!item) {
2563
2371
  return void 0;
2564
2372
  }
2565
- if (item.expires && item.expires && Date.now() > item.expires) {
2373
+ if (item.expires && Date.now() > item.expires) {
2566
2374
  store.delete(key);
2567
2375
  return void 0;
2568
2376
  }
@@ -2745,17 +2553,7 @@ var CacheableMemory = class extends Hookified {
2745
2553
  * @returns {void}
2746
2554
  */
2747
2555
  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();
2556
+ this._store = Array.from({ length: this._storeHashSize }, () => /* @__PURE__ */ new Map());
2759
2557
  this._lru = new DoublyLinkedList();
2760
2558
  }
2761
2559
  /**
@@ -2764,66 +2562,28 @@ var CacheableMemory = class extends Hookified {
2764
2562
  * @returns {CacheableHashStore} - The store
2765
2563
  */
2766
2564
  getStore(key) {
2767
- const hash2 = this.hashKey(key);
2768
- return this.getStoreFromHash(hash2);
2565
+ var _a;
2566
+ const hash2 = this.getKeyStoreHash(key);
2567
+ (_a = this._store)[hash2] || (_a[hash2] = /* @__PURE__ */ new Map());
2568
+ return this._store[hash2];
2769
2569
  }
2770
2570
  /**
2771
- * Get the store based on the hash (internal use)
2772
- * @param {number} hash
2773
- * @returns {Map<string, CacheableStoreItem>}
2571
+ * Hash the key for which store to go to (internal use)
2572
+ * @param {string} key - The key to hash
2573
+ * Available algorithms are: SHA256, SHA1, MD5, and djb2Hash.
2574
+ * @returns {number} - The hashed key as a number
2774
2575
  */
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
- }
2576
+ getKeyStoreHash(key) {
2577
+ if (this._store.length === 1) {
2578
+ return 0;
2807
2579
  }
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;
2580
+ if (this._storeHashAlgorithm === "djb2Hash") {
2581
+ return djb2Hash(key, 0, this._storeHashSize);
2582
+ }
2583
+ if (typeof this._storeHashAlgorithm === "function") {
2584
+ return this._storeHashAlgorithm(key, this._storeHashSize);
2585
+ }
2586
+ return hashToNumber(key, 0, this._storeHashSize, this._storeHashAlgorithm);
2827
2587
  }
2828
2588
  /**
2829
2589
  * Clone the value. This is for internal use
@@ -2859,13 +2619,10 @@ var CacheableMemory = class extends Hookified {
2859
2619
  this._lru.moveToFront(key);
2860
2620
  }
2861
2621
  /**
2862
- * Resize the LRU cache. This is for internal use
2622
+ * Resize the LRU cache. This is for internal use.
2863
2623
  * @returns {void}
2864
2624
  */
2865
2625
  lruResize() {
2866
- if (this._lruSize === 0) {
2867
- return;
2868
- }
2869
2626
  while (this._lru.size > this._lruSize) {
2870
2627
  const oldestKey = this._lru.getOldest();
2871
2628
  if (oldestKey) {
@@ -2879,10 +2636,11 @@ var CacheableMemory = class extends Hookified {
2879
2636
  * @returns {void}
2880
2637
  */
2881
2638
  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);
2639
+ for (const store of this._store) {
2640
+ for (const item of store.values()) {
2641
+ if (item.expires && Date.now() > item.expires) {
2642
+ store.delete(item.key);
2643
+ }
2886
2644
  }
2887
2645
  }
2888
2646
  }
@@ -2911,15 +2669,6 @@ var CacheableMemory = class extends Hookified {
2911
2669
  this._interval = 0;
2912
2670
  this._checkInterval = 0;
2913
2671
  }
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
2672
  /**
2924
2673
  * Wrap the function for caching
2925
2674
  * @param {Function} function_ - The function to wrap
@@ -2944,9 +2693,6 @@ var CacheableMemory = class extends Hookified {
2944
2693
  }
2945
2694
  return result;
2946
2695
  }
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
2696
  setTtl(ttl) {
2951
2697
  if (typeof ttl === "string" || ttl === void 0) {
2952
2698
  this._ttl = ttl;
@@ -2956,6 +2702,12 @@ var CacheableMemory = class extends Hookified {
2956
2702
  this._ttl = void 0;
2957
2703
  }
2958
2704
  }
2705
+ hasExpired(item) {
2706
+ if (item.expires && Date.now() > item.expires) {
2707
+ return true;
2708
+ }
2709
+ return false;
2710
+ }
2959
2711
  };
2960
2712
 
2961
2713
  // node_modules/flatted/esm/index.js
@@ -3031,7 +2783,7 @@ var stringify2 = (value, replacer, space) => {
3031
2783
  };
3032
2784
 
3033
2785
  // node_modules/file-entry-cache/node_modules/flat-cache/dist/index.js
3034
- var FlatCache = class extends Hookified {
2786
+ var FlatCache = class extends l {
3035
2787
  _cache = new CacheableMemory();
3036
2788
  _cacheDir = ".cache";
3037
2789
  _cacheId = "cache1";
@@ -3147,10 +2899,9 @@ var FlatCache = class extends Hookified {
3147
2899
  * @param cacheId {String} the id of the cache, would also be used as the name of the file cache
3148
2900
  * @param cacheDir {String} directory for the cache entry
3149
2901
  */
3150
- // eslint-disable-next-line unicorn/prevent-abbreviations
3151
2902
  load(cacheId, cacheDir) {
3152
2903
  try {
3153
- const filePath = path9.resolve(`${cacheDir ?? this._cacheDir}/${cacheId ?? this._cacheId}`);
2904
+ const filePath = path10.resolve(`${cacheDir ?? this._cacheDir}/${cacheId ?? this._cacheId}`);
3154
2905
  this.loadFile(filePath);
3155
2906
  this.emit(
3156
2907
  "load"
@@ -3182,7 +2933,7 @@ var FlatCache = class extends Hookified {
3182
2933
  */
3183
2934
  all() {
3184
2935
  const result = {};
3185
- const items = Array.from(this._cache.items);
2936
+ const items = [...this._cache.items];
3186
2937
  for (const item of items) {
3187
2938
  result[item.key] = item.value;
3188
2939
  }
@@ -3194,7 +2945,7 @@ var FlatCache = class extends Hookified {
3194
2945
  * @returns {Array}
3195
2946
  */
3196
2947
  get items() {
3197
- return Array.from(this._cache.items);
2948
+ return [...this._cache.items];
3198
2949
  }
3199
2950
  /**
3200
2951
  * Returns the path to the file where the cache is persisted
@@ -3202,7 +2953,7 @@ var FlatCache = class extends Hookified {
3202
2953
  * @returns {String}
3203
2954
  */
3204
2955
  get cacheFilePath() {
3205
- return path9.resolve(`${this._cacheDir}/${this._cacheId}`);
2956
+ return path10.resolve(`${this._cacheDir}/${this._cacheId}`);
3206
2957
  }
3207
2958
  /**
3208
2959
  * Returns the path to the cache directory
@@ -3210,7 +2961,7 @@ var FlatCache = class extends Hookified {
3210
2961
  * @returns {String}
3211
2962
  */
3212
2963
  get cacheDirPath() {
3213
- return path9.resolve(this._cacheDir);
2964
+ return path10.resolve(this._cacheDir);
3214
2965
  }
3215
2966
  /**
3216
2967
  * Returns an array with all the keys in the cache
@@ -3218,7 +2969,7 @@ var FlatCache = class extends Hookified {
3218
2969
  * @returns {Array}
3219
2970
  */
3220
2971
  keys() {
3221
- return Array.from(this._cache.keys);
2972
+ return [...this._cache.keys];
3222
2973
  }
3223
2974
  /**
3224
2975
  * (Legacy) set key method. This method will be deprecated in the future
@@ -3302,7 +3053,7 @@ var FlatCache = class extends Hookified {
3302
3053
  try {
3303
3054
  if (this._changesSinceLastSave || force) {
3304
3055
  const filePath = this.cacheFilePath;
3305
- const items = Array.from(this._cache.items);
3056
+ const items = [...this._cache.items];
3306
3057
  const data = this._stringify(items);
3307
3058
  if (!fs5.existsSync(this._cacheDir)) {
3308
3059
  fs5.mkdirSync(this._cacheDir, { recursive: true });
@@ -3392,8 +3143,8 @@ function createFromFile(filePath, options) {
3392
3143
 
3393
3144
  // node_modules/file-entry-cache/dist/index.js
3394
3145
  function createFromFile2(filePath, useCheckSum, currentWorkingDirectory) {
3395
- const fname = path10.basename(filePath);
3396
- const directory = path10.dirname(filePath);
3146
+ const fname = path11.basename(filePath);
3147
+ const directory = path11.dirname(filePath);
3397
3148
  return create(fname, directory, useCheckSum, currentWorkingDirectory);
3398
3149
  }
3399
3150
  function create(cacheId, cacheDirectory, useCheckSum, currentWorkingDirectory) {
@@ -3421,12 +3172,20 @@ var FileEntryDefault = class {
3421
3172
  var FileEntryCache = class {
3422
3173
  _cache = new FlatCache({ useClone: false });
3423
3174
  _useCheckSum = false;
3175
+ _useModifiedTime = true;
3424
3176
  _currentWorkingDirectory;
3425
3177
  _hashAlgorithm = "md5";
3178
+ /**
3179
+ * Create a new FileEntryCache instance
3180
+ * @param options - The options for the FileEntryCache
3181
+ */
3426
3182
  constructor(options) {
3427
3183
  if (options == null ? void 0 : options.cache) {
3428
3184
  this._cache = new FlatCache(options.cache);
3429
3185
  }
3186
+ if (options == null ? void 0 : options.useModifiedTime) {
3187
+ this._useModifiedTime = options.useModifiedTime;
3188
+ }
3430
3189
  if (options == null ? void 0 : options.useCheckSum) {
3431
3190
  this._useCheckSum = options.useCheckSum;
3432
3191
  }
@@ -3437,27 +3196,73 @@ var FileEntryCache = class {
3437
3196
  this._hashAlgorithm = options.hashAlgorithm;
3438
3197
  }
3439
3198
  }
3199
+ /**
3200
+ * Get the cache
3201
+ * @returns {FlatCache} The cache
3202
+ */
3440
3203
  get cache() {
3441
3204
  return this._cache;
3442
3205
  }
3206
+ /**
3207
+ * Set the cache
3208
+ * @param {FlatCache} cache - The cache to set
3209
+ */
3443
3210
  set cache(cache) {
3444
3211
  this._cache = cache;
3445
3212
  }
3213
+ /**
3214
+ * Use the hash to check if the file has changed
3215
+ * @returns {boolean} if the hash is used to check if the file has changed
3216
+ */
3446
3217
  get useCheckSum() {
3447
3218
  return this._useCheckSum;
3448
3219
  }
3220
+ /**
3221
+ * Set the useCheckSum value
3222
+ * @param {boolean} value - The value to set
3223
+ */
3449
3224
  set useCheckSum(value) {
3450
3225
  this._useCheckSum = value;
3451
3226
  }
3227
+ /**
3228
+ * Use the modified time to check if the file has changed
3229
+ * @returns {boolean} if the modified time is used to check if the file has changed
3230
+ */
3231
+ get useModifiedTime() {
3232
+ return this._useModifiedTime;
3233
+ }
3234
+ /**
3235
+ * Set the useModifiedTime value
3236
+ * @param {boolean} value - The value to set
3237
+ */
3238
+ set useModifiedTime(value) {
3239
+ this._useModifiedTime = value;
3240
+ }
3241
+ /**
3242
+ * Get the hash algorithm
3243
+ * @returns {string} The hash algorithm
3244
+ */
3452
3245
  get hashAlgorithm() {
3453
3246
  return this._hashAlgorithm;
3454
3247
  }
3248
+ /**
3249
+ * Set the hash algorithm
3250
+ * @param {string} value - The value to set
3251
+ */
3455
3252
  set hashAlgorithm(value) {
3456
3253
  this._hashAlgorithm = value;
3457
3254
  }
3255
+ /**
3256
+ * Get the current working directory
3257
+ * @returns {string | undefined} The current working directory
3258
+ */
3458
3259
  get currentWorkingDirectory() {
3459
3260
  return this._currentWorkingDirectory;
3460
3261
  }
3262
+ /**
3263
+ * Set the current working directory
3264
+ * @param {string | undefined} value - The value to set
3265
+ */
3461
3266
  set currentWorkingDirectory(value) {
3462
3267
  this._currentWorkingDirectory = value;
3463
3268
  }
@@ -3467,7 +3272,7 @@ var FileEntryCache = class {
3467
3272
  * @param {Buffer} buffer buffer to calculate hash on
3468
3273
  * @return {String} content hash digest
3469
3274
  */
3470
- // eslint-disable-next-line @typescript-eslint/ban-types
3275
+ // eslint-disable-next-line @typescript-eslint/no-restricted-types
3471
3276
  getHash(buffer) {
3472
3277
  return crypto2.createHash(this._hashAlgorithm).update(buffer).digest("hex");
3473
3278
  }
@@ -3498,7 +3303,7 @@ var FileEntryCache = class {
3498
3303
  * @returns {boolean} if the file path is a relative path, false otherwise
3499
3304
  */
3500
3305
  isRelativePath(filePath) {
3501
- return !path10.isAbsolute(filePath);
3306
+ return !path11.isAbsolute(filePath);
3502
3307
  }
3503
3308
  /**
3504
3309
  * Delete the cache file from the disk
@@ -3533,7 +3338,7 @@ var FileEntryCache = class {
3533
3338
  * @method reconcile
3534
3339
  */
3535
3340
  reconcile() {
3536
- const items = this._cache.items;
3341
+ const { items } = this._cache;
3537
3342
  for (const item of items) {
3538
3343
  const fileDescriptor = this.getFileDescriptor(item.key);
3539
3344
  if (fileDescriptor.notFound) {
@@ -3563,6 +3368,7 @@ var FileEntryCache = class {
3563
3368
  * @param options - The options for getting the file descriptor
3564
3369
  * @returns The file descriptor
3565
3370
  */
3371
+ // eslint-disable-next-line complexity
3566
3372
  getFileDescriptor(filePath, options) {
3567
3373
  var _a, _b, _c;
3568
3374
  let fstat;
@@ -3574,6 +3380,7 @@ var FileEntryCache = class {
3574
3380
  result.meta = this._cache.getKey(result.key) ?? {};
3575
3381
  filePath = this.getAbsolutePath(filePath, { currentWorkingDirectory: options == null ? void 0 : options.currentWorkingDirectory });
3576
3382
  const useCheckSumValue = (options == null ? void 0 : options.useCheckSum) ?? this._useCheckSum;
3383
+ const useModifiedTimeValue = (options == null ? void 0 : options.useModifiedTime) ?? this._useModifiedTime;
3577
3384
  try {
3578
3385
  fstat = fs6.statSync(filePath);
3579
3386
  result.meta = {
@@ -3606,7 +3413,10 @@ var FileEntryCache = class {
3606
3413
  if (result.meta.data === void 0) {
3607
3414
  result.meta.data = metaCache.data;
3608
3415
  }
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)) {
3416
+ if (useModifiedTimeValue && (metaCache == null ? void 0 : metaCache.mtime) !== ((_a = result.meta) == null ? void 0 : _a.mtime)) {
3417
+ result.changed = true;
3418
+ }
3419
+ if ((metaCache == null ? void 0 : metaCache.size) !== ((_b = result.meta) == null ? void 0 : _b.size)) {
3610
3420
  result.changed = true;
3611
3421
  }
3612
3422
  if (useCheckSumValue && (metaCache == null ? void 0 : metaCache.hash) !== ((_c = result.meta) == null ? void 0 : _c.hash)) {
@@ -3707,7 +3517,7 @@ var FileEntryCache = class {
3707
3517
  getAbsolutePath(filePath, options) {
3708
3518
  if (this.isRelativePath(filePath)) {
3709
3519
  const currentWorkingDirectory = (options == null ? void 0 : options.currentWorkingDirectory) ?? this._currentWorkingDirectory ?? process.cwd();
3710
- filePath = path10.resolve(currentWorkingDirectory, filePath);
3520
+ filePath = path11.resolve(currentWorkingDirectory, filePath);
3711
3521
  }
3712
3522
  return filePath;
3713
3523
  }
@@ -3747,13 +3557,15 @@ function getHashOfOptions(options) {
3747
3557
  function getMetadataFromFileDescriptor(fileDescriptor) {
3748
3558
  return fileDescriptor.meta;
3749
3559
  }
3750
- var _fileEntryCache;
3560
+ var _useChecksum, _fileEntryCache, _FormatResultsCache_instances, getFileDescriptor_fn;
3751
3561
  var FormatResultsCache = class {
3752
3562
  /**
3753
3563
  * @param {string} cacheFileLocation The path of cache file location. (default: `node_modules/.cache/prettier/.prettier-cache`)
3754
3564
  * @param {string} cacheStrategy
3755
3565
  */
3756
3566
  constructor(cacheFileLocation, cacheStrategy) {
3567
+ __privateAdd(this, _FormatResultsCache_instances);
3568
+ __privateAdd(this, _useChecksum);
3757
3569
  __privateAdd(this, _fileEntryCache);
3758
3570
  const useChecksum = cacheStrategy === "content";
3759
3571
  try {
@@ -3772,6 +3584,7 @@ var FormatResultsCache = class {
3772
3584
  ));
3773
3585
  }
3774
3586
  }
3587
+ __privateSet(this, _useChecksum, useChecksum);
3775
3588
  }
3776
3589
  /**
3777
3590
  * @param {string} filePath
@@ -3779,7 +3592,7 @@ var FormatResultsCache = class {
3779
3592
  */
3780
3593
  existsAvailableFormatResultsCache(filePath, options) {
3781
3594
  var _a;
3782
- const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
3595
+ const fileDescriptor = __privateMethod(this, _FormatResultsCache_instances, getFileDescriptor_fn).call(this, filePath);
3783
3596
  if (fileDescriptor.notFound || fileDescriptor.changed) {
3784
3597
  return false;
3785
3598
  }
@@ -3791,7 +3604,7 @@ var FormatResultsCache = class {
3791
3604
  * @param {any} options
3792
3605
  */
3793
3606
  setFormatResultsCache(filePath, options) {
3794
- const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
3607
+ const fileDescriptor = __privateMethod(this, _FormatResultsCache_instances, getFileDescriptor_fn).call(this, filePath);
3795
3608
  if (!fileDescriptor.notFound) {
3796
3609
  const meta = getMetadataFromFileDescriptor(fileDescriptor);
3797
3610
  meta.data = { ...meta.data, hashOfOptions: getHashOfOptions(options) };
@@ -3807,20 +3620,290 @@ var FormatResultsCache = class {
3807
3620
  __privateGet(this, _fileEntryCache).reconcile();
3808
3621
  }
3809
3622
  };
3623
+ _useChecksum = new WeakMap();
3810
3624
  _fileEntryCache = new WeakMap();
3625
+ _FormatResultsCache_instances = new WeakSet();
3626
+ getFileDescriptor_fn = function(filePath) {
3627
+ return __privateGet(this, _fileEntryCache).getFileDescriptor(filePath, {
3628
+ useModifiedTime: !__privateGet(this, _useChecksum)
3629
+ });
3630
+ };
3811
3631
  var format_results_cache_default = FormatResultsCache;
3812
3632
 
3813
- // src/cli/is-tty.js
3814
- function isTTY() {
3815
- return process.stdout.isTTY && !mockable.isCI();
3633
+ // src/cli/mockable.js
3634
+ var import_ci_info = __toESM(require_ci_info(), 1);
3635
+ import fs8 from "fs/promises";
3636
+ import { performance } from "perf_hooks";
3637
+ import { __internal as sharedWithCli3 } from "../index.mjs";
3638
+
3639
+ // src/cli/utilities/clear-stream-text.js
3640
+ import readline from "readline";
3641
+
3642
+ // node_modules/ansi-regex/index.js
3643
+ function ansiRegex({ onlyFirst = false } = {}) {
3644
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
3645
+ const pattern = [
3646
+ `[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
3647
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
3648
+ ].join("|");
3649
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
3650
+ }
3651
+
3652
+ // node_modules/strip-ansi/index.js
3653
+ var regex = ansiRegex();
3654
+ function stripAnsi(string) {
3655
+ if (typeof string !== "string") {
3656
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
3657
+ }
3658
+ return string.replace(regex, "");
3659
+ }
3660
+
3661
+ // node_modules/wcwidth.js/combining.js
3662
+ var combining_default = [
3663
+ [768, 879],
3664
+ [1155, 1158],
3665
+ [1160, 1161],
3666
+ [1425, 1469],
3667
+ [1471, 1471],
3668
+ [1473, 1474],
3669
+ [1476, 1477],
3670
+ [1479, 1479],
3671
+ [1536, 1539],
3672
+ [1552, 1557],
3673
+ [1611, 1630],
3674
+ [1648, 1648],
3675
+ [1750, 1764],
3676
+ [1767, 1768],
3677
+ [1770, 1773],
3678
+ [1807, 1807],
3679
+ [1809, 1809],
3680
+ [1840, 1866],
3681
+ [1958, 1968],
3682
+ [2027, 2035],
3683
+ [2305, 2306],
3684
+ [2364, 2364],
3685
+ [2369, 2376],
3686
+ [2381, 2381],
3687
+ [2385, 2388],
3688
+ [2402, 2403],
3689
+ [2433, 2433],
3690
+ [2492, 2492],
3691
+ [2497, 2500],
3692
+ [2509, 2509],
3693
+ [2530, 2531],
3694
+ [2561, 2562],
3695
+ [2620, 2620],
3696
+ [2625, 2626],
3697
+ [2631, 2632],
3698
+ [2635, 2637],
3699
+ [2672, 2673],
3700
+ [2689, 2690],
3701
+ [2748, 2748],
3702
+ [2753, 2757],
3703
+ [2759, 2760],
3704
+ [2765, 2765],
3705
+ [2786, 2787],
3706
+ [2817, 2817],
3707
+ [2876, 2876],
3708
+ [2879, 2879],
3709
+ [2881, 2883],
3710
+ [2893, 2893],
3711
+ [2902, 2902],
3712
+ [2946, 2946],
3713
+ [3008, 3008],
3714
+ [3021, 3021],
3715
+ [3134, 3136],
3716
+ [3142, 3144],
3717
+ [3146, 3149],
3718
+ [3157, 3158],
3719
+ [3260, 3260],
3720
+ [3263, 3263],
3721
+ [3270, 3270],
3722
+ [3276, 3277],
3723
+ [3298, 3299],
3724
+ [3393, 3395],
3725
+ [3405, 3405],
3726
+ [3530, 3530],
3727
+ [3538, 3540],
3728
+ [3542, 3542],
3729
+ [3633, 3633],
3730
+ [3636, 3642],
3731
+ [3655, 3662],
3732
+ [3761, 3761],
3733
+ [3764, 3769],
3734
+ [3771, 3772],
3735
+ [3784, 3789],
3736
+ [3864, 3865],
3737
+ [3893, 3893],
3738
+ [3895, 3895],
3739
+ [3897, 3897],
3740
+ [3953, 3966],
3741
+ [3968, 3972],
3742
+ [3974, 3975],
3743
+ [3984, 3991],
3744
+ [3993, 4028],
3745
+ [4038, 4038],
3746
+ [4141, 4144],
3747
+ [4146, 4146],
3748
+ [4150, 4151],
3749
+ [4153, 4153],
3750
+ [4184, 4185],
3751
+ [4448, 4607],
3752
+ [4959, 4959],
3753
+ [5906, 5908],
3754
+ [5938, 5940],
3755
+ [5970, 5971],
3756
+ [6002, 6003],
3757
+ [6068, 6069],
3758
+ [6071, 6077],
3759
+ [6086, 6086],
3760
+ [6089, 6099],
3761
+ [6109, 6109],
3762
+ [6155, 6157],
3763
+ [6313, 6313],
3764
+ [6432, 6434],
3765
+ [6439, 6440],
3766
+ [6450, 6450],
3767
+ [6457, 6459],
3768
+ [6679, 6680],
3769
+ [6912, 6915],
3770
+ [6964, 6964],
3771
+ [6966, 6970],
3772
+ [6972, 6972],
3773
+ [6978, 6978],
3774
+ [7019, 7027],
3775
+ [7616, 7626],
3776
+ [7678, 7679],
3777
+ [8203, 8207],
3778
+ [8234, 8238],
3779
+ [8288, 8291],
3780
+ [8298, 8303],
3781
+ [8400, 8431],
3782
+ [12330, 12335],
3783
+ [12441, 12442],
3784
+ [43014, 43014],
3785
+ [43019, 43019],
3786
+ [43045, 43046],
3787
+ [64286, 64286],
3788
+ [65024, 65039],
3789
+ [65056, 65059],
3790
+ [65279, 65279],
3791
+ [65529, 65531],
3792
+ [68097, 68099],
3793
+ [68101, 68102],
3794
+ [68108, 68111],
3795
+ [68152, 68154],
3796
+ [68159, 68159],
3797
+ [119143, 119145],
3798
+ [119155, 119170],
3799
+ [119173, 119179],
3800
+ [119210, 119213],
3801
+ [119362, 119364],
3802
+ [917505, 917505],
3803
+ [917536, 917631],
3804
+ [917760, 917999]
3805
+ ];
3806
+
3807
+ // node_modules/wcwidth.js/index.js
3808
+ var DEFAULTS = {
3809
+ nul: 0,
3810
+ control: 0
3811
+ };
3812
+ function bisearch(ucs) {
3813
+ let min = 0;
3814
+ let max = combining_default.length - 1;
3815
+ let mid;
3816
+ if (ucs < combining_default[0][0] || ucs > combining_default[max][1]) return false;
3817
+ while (max >= min) {
3818
+ mid = Math.floor((min + max) / 2);
3819
+ if (ucs > combining_default[mid][1]) min = mid + 1;
3820
+ else if (ucs < combining_default[mid][0]) max = mid - 1;
3821
+ else return true;
3822
+ }
3823
+ return false;
3824
+ }
3825
+ function wcwidth(ucs, opts) {
3826
+ if (ucs === 0) return opts.nul;
3827
+ if (ucs < 32 || ucs >= 127 && ucs < 160) return opts.control;
3828
+ if (bisearch(ucs)) return 0;
3829
+ return 1 + (ucs >= 4352 && (ucs <= 4447 || // Hangul Jamo init. consonants
3830
+ ucs == 9001 || ucs == 9002 || ucs >= 11904 && ucs <= 42191 && ucs != 12351 || // CJK ... Yi
3831
+ ucs >= 44032 && ucs <= 55203 || // Hangul Syllables
3832
+ ucs >= 63744 && ucs <= 64255 || // CJK Compatibility Ideographs
3833
+ ucs >= 65040 && ucs <= 65049 || // Vertical forms
3834
+ ucs >= 65072 && ucs <= 65135 || // CJK Compatibility Forms
3835
+ ucs >= 65280 && ucs <= 65376 || // Fullwidth Forms
3836
+ ucs >= 65504 && ucs <= 65510 || ucs >= 131072 && ucs <= 196605 || ucs >= 196608 && ucs <= 262141));
3837
+ }
3838
+ function wcswidth(str, opts) {
3839
+ let h;
3840
+ let l2;
3841
+ let s = 0;
3842
+ let n2;
3843
+ if (typeof str !== "string") return wcwidth(str, opts);
3844
+ for (let i = 0; i < str.length; i++) {
3845
+ h = str.charCodeAt(i);
3846
+ if (h >= 55296 && h <= 56319) {
3847
+ l2 = str.charCodeAt(++i);
3848
+ if (l2 >= 56320 && l2 <= 57343) {
3849
+ h = (h - 55296) * 1024 + (l2 - 56320) + 65536;
3850
+ } else {
3851
+ i--;
3852
+ }
3853
+ }
3854
+ n2 = wcwidth(h, opts);
3855
+ if (n2 < 0) return -1;
3856
+ s += n2;
3857
+ }
3858
+ return s;
3859
+ }
3860
+ var _ = (str) => wcswidth(str, DEFAULTS);
3861
+ _.config = (opts = {}) => {
3862
+ opts = {
3863
+ ...DEFAULTS,
3864
+ ...opts
3865
+ };
3866
+ return (str) => wcswidth(str, opts);
3867
+ };
3868
+ var wcwidth_default = _;
3869
+
3870
+ // src/cli/utilities/clear-stream-text.js
3871
+ var countLines = (stream, text) => {
3872
+ const columns = stream.columns || 80;
3873
+ let lineCount = 0;
3874
+ for (const line of stripAnsi(text).split("\n")) {
3875
+ lineCount += Math.max(1, Math.ceil(wcwidth_default(line) / columns));
3876
+ }
3877
+ return lineCount;
3878
+ };
3879
+ function clearStreamText(stream, text) {
3880
+ const lineCount = countLines(stream, text);
3881
+ for (let line = 0; line < lineCount; line++) {
3882
+ if (line > 0) {
3883
+ readline.moveCursor(stream, 0, -1);
3884
+ }
3885
+ readline.clearLine(stream, 0);
3886
+ readline.cursorTo(stream, 0);
3887
+ }
3816
3888
  }
3889
+ var clear_stream_text_default = clearStreamText;
3890
+
3891
+ // src/cli/mockable.js
3892
+ var mockable = sharedWithCli3.utils.createMockable({
3893
+ clearStreamText: clear_stream_text_default,
3894
+ getTimestamp: performance.now.bind(performance),
3895
+ isCI: () => import_ci_info.isCI,
3896
+ isStreamTTY: (stream) => stream.isTTY,
3897
+ writeFormattedFile: (file, data) => fs8.writeFile(file, data)
3898
+ });
3899
+ var mockable_default = mockable.mocked;
3817
3900
 
3818
3901
  // src/cli/options/get-options-for-file.js
3819
3902
  var import_dashify2 = __toESM(require_dashify(), 1);
3820
3903
  import { resolveConfig } from "../index.mjs";
3821
- function getOptions(argv, detailedOptions) {
3904
+ function getOptions(argv2, detailedOptions) {
3822
3905
  return Object.fromEntries(
3823
- detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv[name]])
3906
+ detailedOptions.filter(({ forwardToApi }) => forwardToApi).map(({ forwardToApi, name }) => [forwardToApi, argv2[name]])
3824
3907
  );
3825
3908
  }
3826
3909
  function cliifyOptions(object2, apiDetailedOptionMap) {
@@ -3923,7 +4006,6 @@ async function getOptionsForFile(context, filepath) {
3923
4006
  var get_options_for_file_default = getOptionsForFile;
3924
4007
 
3925
4008
  // src/cli/format.js
3926
- var { getStdin, writeFormattedFile } = mockable;
3927
4009
  function diff(a, b) {
3928
4010
  return createTwoFilesPatch("", "", a, b, "", "", { context: 2 });
3929
4011
  }
@@ -3933,21 +4015,16 @@ var DebugError = class extends Error {
3933
4015
  function handleError(context, filename, error, printedFilename, ignoreUnknown) {
3934
4016
  ignoreUnknown || (ignoreUnknown = context.argv.ignoreUnknown);
3935
4017
  const errorIsUndefinedParseError = error instanceof errors.UndefinedParserError;
3936
- if (printedFilename) {
3937
- if ((context.argv.write || ignoreUnknown) && errorIsUndefinedParseError) {
3938
- printedFilename.clear();
3939
- } else {
3940
- process.stdout.write("\n");
3941
- }
4018
+ if (errorIsUndefinedParseError && ignoreUnknown) {
4019
+ printedFilename == null ? void 0 : printedFilename.clear();
4020
+ return true;
4021
+ }
4022
+ if (printedFilename) {
4023
+ process.stdout.write("\n");
3942
4024
  }
3943
4025
  if (errorIsUndefinedParseError) {
3944
- if (ignoreUnknown) {
3945
- return;
3946
- }
3947
- if (!context.argv.check && !context.argv.listDifferent) {
3948
- process.exitCode = 2;
3949
- }
3950
4026
  context.logger.error(error.message);
4027
+ process.exitCode = 2;
3951
4028
  return;
3952
4029
  }
3953
4030
  const isParseError = Boolean(error == null ? void 0 : error.loc);
@@ -4034,50 +4111,35 @@ async function format3(context, input, opt) {
4034
4111
  }
4035
4112
  const { performanceTestFlag } = context;
4036
4113
  if (performanceTestFlag == null ? void 0 : performanceTestFlag.debugBenchmark) {
4037
- let benchmark;
4114
+ let Bench;
4038
4115
  try {
4039
- ({ default: benchmark } = await import("benchmark"));
4116
+ ({ Bench } = await import("tinybench"));
4040
4117
  } catch {
4041
4118
  context.logger.debug(
4042
- "'--debug-benchmark' requires the 'benchmark' package to be installed."
4119
+ "'--debug-benchmark' requires the 'tinybench' package to be installed."
4043
4120
  );
4044
4121
  process.exit(2);
4045
4122
  }
4046
4123
  context.logger.debug(
4047
- "'--debug-benchmark' option found, measuring formatWithCursor with 'benchmark' module."
4124
+ "'--debug-benchmark' option found, measuring formatWithCursor with 'tinybench' module."
4048
4125
  );
4049
- const suite = new benchmark.Suite();
4050
- suite.add("format", {
4051
- defer: true,
4052
- async fn(deferred) {
4053
- await prettier.formatWithCursor(input, opt);
4054
- deferred.resolve();
4055
- }
4056
- });
4057
- const result = await new Promise((resolve) => {
4058
- suite.on("complete", (event) => {
4059
- resolve({
4060
- benchmark: String(event.target),
4061
- hz: event.target.hz,
4062
- ms: event.target.times.cycle * 1e3
4063
- });
4064
- }).run({ async: false });
4065
- });
4126
+ const bench = new Bench();
4127
+ bench.add("Format", () => prettier.formatWithCursor(input, opt));
4128
+ await bench.run();
4129
+ const [result] = bench.table();
4066
4130
  context.logger.debug(
4067
- "'--debug-benchmark' measurements for formatWithCursor: " + JSON.stringify(result, null, 2)
4131
+ "'--debug-benchmark' measurements for formatWithCursor: " + JSON.stringify(result, void 0, 2)
4068
4132
  );
4069
4133
  } else if (performanceTestFlag == null ? void 0 : performanceTestFlag.debugRepeat) {
4070
4134
  const repeat = performanceTestFlag.debugRepeat;
4071
4135
  context.logger.debug(
4072
4136
  `'${performanceTestFlag.name}' found, running formatWithCursor ${repeat} times.`
4073
4137
  );
4074
- let totalMs = 0;
4138
+ const start = mockable_default.getTimestamp();
4075
4139
  for (let i = 0; i < repeat; ++i) {
4076
- const startMs = Date.now();
4077
4140
  await prettier.formatWithCursor(input, opt);
4078
- totalMs += Date.now() - startMs;
4079
4141
  }
4080
- const averageMs = totalMs / repeat;
4142
+ const averageMs = (mockable_default.getTimestamp() - start) / repeat;
4081
4143
  const results = {
4082
4144
  repeat,
4083
4145
  hz: 1e3 / averageMs,
@@ -4108,19 +4170,21 @@ async function formatStdin(context) {
4108
4170
  const { filepath } = context.argv;
4109
4171
  try {
4110
4172
  const input = await getStdin();
4173
+ const absoluteFilepath = filepath ? path12.resolve(filepath) : void 0;
4111
4174
  let isFileIgnored = false;
4112
- if (filepath) {
4175
+ if (absoluteFilepath) {
4113
4176
  const isIgnored = await createIsIgnoredFromContextOrDie(context);
4114
- isFileIgnored = isIgnored(filepath);
4177
+ isFileIgnored = isIgnored(absoluteFilepath);
4115
4178
  }
4116
4179
  if (isFileIgnored) {
4117
4180
  writeOutput(context, { formatted: input });
4118
4181
  return;
4119
4182
  }
4120
- const options = await get_options_for_file_default(
4121
- context,
4122
- filepath ? path11.resolve(filepath) : void 0
4123
- );
4183
+ const options = {
4184
+ ...await get_options_for_file_default(context, absoluteFilepath),
4185
+ // `getOptionsForFile` forwards `--stdin-filepath` directly, which can be a relative path
4186
+ filepath: absoluteFilepath
4187
+ };
4124
4188
  if (await listDifferent(context, input, options, "(stdin)")) {
4125
4189
  return;
4126
4190
  }
@@ -4139,8 +4203,9 @@ async function formatStdin(context) {
4139
4203
  }
4140
4204
  async function formatFiles(context) {
4141
4205
  const isIgnored = await createIsIgnoredFromContextOrDie(context);
4142
- const cwd2 = process.cwd();
4206
+ const cwd3 = process.cwd();
4143
4207
  let numberOfUnformattedFilesFound = 0;
4208
+ let numberOfFilesWithError = 0;
4144
4209
  const { performanceTestFlag } = context;
4145
4210
  if (context.argv.check && !performanceTestFlag) {
4146
4211
  context.logger.log("Checking formatting...");
@@ -4155,9 +4220,10 @@ async function formatFiles(context) {
4155
4220
  } else if (!context.argv.cacheLocation) {
4156
4221
  const stat = await statSafe(cacheFilePath);
4157
4222
  if (stat) {
4158
- await fs8.unlink(cacheFilePath);
4223
+ await fs9.unlink(cacheFilePath);
4159
4224
  }
4160
4225
  }
4226
+ const isTTY = mockable_default.isStreamTTY(process.stdout) && !mockable_default.isCI();
4161
4227
  for await (const { error, filename, ignoreUnknown } of expandPatterns(
4162
4228
  context
4163
4229
  )) {
@@ -4174,9 +4240,9 @@ async function formatFiles(context) {
4174
4240
  ...await get_options_for_file_default(context, filename),
4175
4241
  filepath: filename
4176
4242
  };
4177
- const fileNameToDisplay = normalizeToPosix(path11.relative(cwd2, filename));
4243
+ const fileNameToDisplay = normalizeToPosix(path12.relative(cwd3, filename));
4178
4244
  let printedFilename;
4179
- if (isTTY()) {
4245
+ if (isTTY) {
4180
4246
  printedFilename = context.logger.log(fileNameToDisplay, {
4181
4247
  newline: false,
4182
4248
  clearable: true
@@ -4184,7 +4250,7 @@ async function formatFiles(context) {
4184
4250
  }
4185
4251
  let input;
4186
4252
  try {
4187
- input = await fs8.readFile(filename, "utf8");
4253
+ input = await fs9.readFile(filename, "utf8");
4188
4254
  } catch (error2) {
4189
4255
  context.logger.log("");
4190
4256
  context.logger.error(
@@ -4199,7 +4265,7 @@ ${error2.message}`
4199
4265
  writeOutput(context, { formatted: input }, options);
4200
4266
  continue;
4201
4267
  }
4202
- const start = Date.now();
4268
+ const start = mockable_default.getTimestamp();
4203
4269
  const isCacheExists = formatResultsCache == null ? void 0 : formatResultsCache.existsAvailableFormatResultsCache(
4204
4270
  filename,
4205
4271
  options
@@ -4214,13 +4280,16 @@ ${error2.message}`
4214
4280
  }
4215
4281
  output = result.formatted;
4216
4282
  } catch (error2) {
4217
- handleError(
4283
+ const errorIsIgnored = handleError(
4218
4284
  context,
4219
4285
  fileNameToDisplay,
4220
4286
  error2,
4221
4287
  printedFilename,
4222
4288
  ignoreUnknown
4223
4289
  );
4290
+ if (!errorIsIgnored) {
4291
+ numberOfFilesWithError += 1;
4292
+ }
4224
4293
  continue;
4225
4294
  }
4226
4295
  const isDifferent = output !== input;
@@ -4233,12 +4302,13 @@ ${error2.message}`
4233
4302
  return;
4234
4303
  }
4235
4304
  if (context.argv.write) {
4305
+ const timeToDisplay = `${Math.round(mockable_default.getTimestamp() - start)}ms`;
4236
4306
  if (isDifferent) {
4237
4307
  if (!context.argv.check && !context.argv.listDifferent) {
4238
- context.logger.log(`${fileNameToDisplay} ${Date.now() - start}ms`);
4308
+ context.logger.log(`${fileNameToDisplay} ${timeToDisplay}`);
4239
4309
  }
4240
4310
  try {
4241
- await writeFormattedFile(filename, output);
4311
+ await mockable_default.writeFormattedFile(filename, output);
4242
4312
  shouldSetCache = true;
4243
4313
  } catch (error2) {
4244
4314
  context.logger.error(
@@ -4248,7 +4318,7 @@ ${error2.message}`
4248
4318
  process.exitCode = 2;
4249
4319
  }
4250
4320
  } else if (!context.argv.check && !context.argv.listDifferent) {
4251
- const message = `${source_default.grey(fileNameToDisplay)} ${Date.now() - start}ms (unchanged)`;
4321
+ const message = `${picocolors.gray(fileNameToDisplay)} ${timeToDisplay} (unchanged)`;
4252
4322
  if (isCacheExists) {
4253
4323
  context.logger.log(`${message} (cached)`);
4254
4324
  } else {
@@ -4280,7 +4350,12 @@ ${error2.message}`
4280
4350
  }
4281
4351
  formatResultsCache == null ? void 0 : formatResultsCache.reconcile();
4282
4352
  if (context.argv.check) {
4283
- if (numberOfUnformattedFilesFound === 0) {
4353
+ if (numberOfFilesWithError > 0) {
4354
+ const files = numberOfFilesWithError === 1 ? "the above file" : `${numberOfFilesWithError} files`;
4355
+ context.logger.log(
4356
+ `Error occurred when checking code style in ${files}.`
4357
+ );
4358
+ } else if (numberOfUnformattedFilesFound === 0) {
4284
4359
  context.logger.log("All matched files use Prettier code style!");
4285
4360
  } else {
4286
4361
  const files = numberOfUnformattedFilesFound === 1 ? "the above file" : `${numberOfUnformattedFilesFound} files`;
@@ -4295,255 +4370,9 @@ ${error2.message}`
4295
4370
  }
4296
4371
 
4297
4372
  // src/cli/logger.js
4298
- import readline from "readline";
4299
-
4300
- // node_modules/strip-ansi/node_modules/ansi-regex/index.js
4301
- function ansiRegex({ onlyFirst = false } = {}) {
4302
- const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
4303
- const pattern = [
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=><~]))"
4306
- ].join("|");
4307
- return new RegExp(pattern, onlyFirst ? void 0 : "g");
4308
- }
4309
-
4310
- // node_modules/strip-ansi/index.js
4311
- var regex = ansiRegex();
4312
- function stripAnsi(string) {
4313
- if (typeof string !== "string") {
4314
- throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
4315
- }
4316
- return string.replace(regex, "");
4317
- }
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
-
4528
- // src/cli/logger.js
4529
- var countLines = (stream, text) => {
4530
- const columns = stream.columns || 80;
4531
- let lineCount = 0;
4532
- for (const line of stripAnsi(text).split("\n")) {
4533
- lineCount += Math.max(1, Math.ceil(wcwidth_default(line) / columns));
4534
- }
4535
- return lineCount;
4536
- };
4537
- var clear = (stream, text) => () => {
4538
- const lineCount = countLines(stream, text);
4539
- for (let line = 0; line < lineCount; line++) {
4540
- if (line > 0) {
4541
- readline.moveCursor(stream, 0, -1);
4542
- }
4543
- readline.clearLine(stream, 0);
4544
- readline.cursorTo(stream, 0);
4545
- }
4546
- };
4373
+ var { argv, env: env2 } = process;
4374
+ var isStderrColorSupported = !(Boolean(env2.NO_COLOR) || argv.includes("--no-color")) && (Boolean(env2.FORCE_COLOR) || argv.includes("--color") || process.platform === "win32" || process.stderr.isTTY && env2.TERM !== "dumb" || Boolean(env2.CI));
4375
+ var picocolorsStderr = picocolors.createColors(isStderrColorSupported);
4547
4376
  var emptyLogResult = { clear() {
4548
4377
  } };
4549
4378
  function createLogger(logLevel = "log") {
@@ -4559,8 +4388,8 @@ function createLogger(logLevel = "log") {
4559
4388
  return () => emptyLogResult;
4560
4389
  }
4561
4390
  const stream = process[loggerName === "log" ? "stdout" : "stderr"];
4562
- const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
4563
- const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
4391
+ const colors = loggerName === "log" ? picocolors : picocolorsStderr;
4392
+ const prefix = color ? `[${colors[color](loggerName)}] ` : "";
4564
4393
  return (message, options) => {
4565
4394
  options = {
4566
4395
  newline: true,
@@ -4577,7 +4406,7 @@ function createLogger(logLevel = "log") {
4577
4406
  stream.write(message);
4578
4407
  if (options.clearable) {
4579
4408
  return {
4580
- clear: clear(stream, message)
4409
+ clear: () => mockable_default.clearStreamText(stream, message)
4581
4410
  };
4582
4411
  }
4583
4412
  };
@@ -4611,7 +4440,7 @@ var logger_default = createLogger;
4611
4440
  // src/cli/print-support-info.js
4612
4441
  var import_fast_json_stable_stringify3 = __toESM(require_fast_json_stable_stringify(), 1);
4613
4442
  import { format as format4, getSupportInfo as getSupportInfo2 } from "../index.mjs";
4614
- var sortByName = (array2) => array2.sort((a, b) => a.name.localeCompare(b.name));
4443
+ var sortByName = (array) => array.sort((a, b) => a.name.localeCompare(b.name));
4615
4444
  async function printSupportInfo() {
4616
4445
  const { languages, options } = await getSupportInfo2();
4617
4446
  const supportInfo = {
@@ -4620,7 +4449,8 @@ async function printSupportInfo() {
4620
4449
  (option) => omit(option, ["cliName", "cliCategory", "cliDescription"])
4621
4450
  )
4622
4451
  };
4623
- printToScreen(await format4((0, import_fast_json_stable_stringify3.default)(supportInfo), { parser: "json" }));
4452
+ const result = await format4((0, import_fast_json_stable_stringify3.default)(supportInfo), { parser: "json" });
4453
+ printToScreen(result.trim());
4624
4454
  }
4625
4455
  var print_support_info_default = printSupportInfo;
4626
4456
 
@@ -4816,6 +4646,9 @@ async function run(rawArguments = process.argv.slice(2)) {
4816
4646
  }
4817
4647
  async function main(context) {
4818
4648
  context.logger.debug(`normalized argv: ${JSON.stringify(context.argv)}`);
4649
+ if (context.argv.config === false && context.argv.__raw.config !== false || context.argv.config && context.rawArguments.includes("--no-config")) {
4650
+ throw new Error("Cannot use --no-config and --config together.");
4651
+ }
4819
4652
  if (context.argv.check && context.argv.listDifferent) {
4820
4653
  throw new Error("Cannot use --check and --list-different together.");
4821
4654
  }
@@ -4853,7 +4686,7 @@ async function main(context) {
4853
4686
  return;
4854
4687
  }
4855
4688
  const hasFilePatterns = context.filePatterns.length > 0;
4856
- const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.argv.filepath);
4689
+ const useStdin = !hasFilePatterns && (!mockable_default.isStreamTTY(process.stdin) || context.argv.filepath);
4857
4690
  if (useStdin) {
4858
4691
  if (context.argv.cache) {
4859
4692
  throw new Error("`--cache` cannot be used when formatting stdin.");
@@ -4869,5 +4702,6 @@ async function main(context) {
4869
4702
  printToScreen(createUsage(context));
4870
4703
  }
4871
4704
  export {
4705
+ mockable,
4872
4706
  run
4873
4707
  };