storybook 10.1.0-alpha.11 → 10.1.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/_browser-chunks/{chunk-74YHFU5B.js → chunk-2XZMBGTA.js} +1 -1
  2. package/dist/_browser-chunks/{chunk-EBHB6RPS.js → chunk-FQ7SLVLR.js} +6 -1
  3. package/dist/_browser-chunks/{chunk-X3DUQ5RA.js → chunk-GFY5R5EY.js} +1 -1
  4. package/dist/_node-chunks/{builder-manager-PMPHOSM2.js → builder-manager-DWDUVXZM.js} +27 -22
  5. package/dist/_node-chunks/{chunk-MJ3WOS6F.js → camelcase-EETCRTJX.js} +8 -8
  6. package/dist/_node-chunks/{chunk-UY26MQLT.js → chunk-2W4GZCLE.js} +7 -7
  7. package/dist/_node-chunks/chunk-447655DM.js +20 -0
  8. package/dist/_node-chunks/{chunk-GG2WQZSG.js → chunk-4EJUC2SD.js} +4998 -1685
  9. package/dist/_node-chunks/chunk-4ZJOH2UN.js +61 -0
  10. package/dist/_node-chunks/chunk-654SJIMS.js +23 -0
  11. package/dist/_node-chunks/{chunk-5QK5MSOI.js → chunk-7IAVT2FU.js} +7 -7
  12. package/dist/_node-chunks/{chunk-WLHMN7AP.js → chunk-7KFHRNOT.js} +7 -7
  13. package/dist/_node-chunks/{chunk-6ZOLETQK.js → chunk-AZIPBEBK.js} +6 -6
  14. package/dist/_node-chunks/{chunk-AKTRSR3O.js → chunk-B76FDKVB.js} +6 -6
  15. package/dist/_node-chunks/chunk-B7PGKETD.js +3781 -0
  16. package/dist/_node-chunks/{chunk-QECOQWRJ.js → chunk-CLUBH2LP.js} +55 -36
  17. package/dist/_node-chunks/{chunk-PHOZWZZO.js → chunk-CMYD2JNN.js} +7 -7
  18. package/dist/_node-chunks/{chunk-LR3QITDI.js → chunk-DIPKXLEP.js} +55 -32
  19. package/dist/_node-chunks/{chunk-4GZCFQFG.js → chunk-DPFYWXEA.js} +6 -6
  20. package/dist/_node-chunks/{chunk-LCZO45L7.js → chunk-FCVNHU2F.js} +7 -7
  21. package/dist/_node-chunks/{chunk-R6HWGZWD.js → chunk-JQ7RQS5Q.js} +6 -6
  22. package/dist/_node-chunks/chunk-LEL5OSY3.js +18 -0
  23. package/dist/_node-chunks/{chunk-BBOP3XCK.js → chunk-LPKSBF62.js} +6 -6
  24. package/dist/_node-chunks/chunk-LYEZOJ43.js +78 -0
  25. package/dist/_node-chunks/{chunk-ZZALGOA6.js → chunk-MIA5324I.js} +7 -7
  26. package/dist/_node-chunks/{chunk-SPQXMU2Q.js → chunk-MJM4TEMP.js} +14 -8
  27. package/dist/_node-chunks/{chunk-32NE3UE3.js → chunk-OVVZIUHS.js} +7 -7
  28. package/dist/_node-chunks/{chunk-ZZSRFAC6.js → chunk-RUUNVQ6W.js} +1108 -17
  29. package/dist/_node-chunks/{chunk-YHRFI6BE.js → chunk-URLNGLC2.js} +52 -72
  30. package/dist/_node-chunks/{chunk-XGVLB4UJ.js → chunk-WC2YEQHJ.js} +6 -6
  31. package/dist/_node-chunks/{chunk-JCRM2YVK.js → chunk-XKRVQL2G.js} +8 -8
  32. package/dist/_node-chunks/{chunk-TXZY6V6O.js → chunk-Z2OWEMX3.js} +8 -8
  33. package/dist/_node-chunks/{dist-4DWOCZUD.js → dist-22CLJ4BC.js} +9 -9
  34. package/dist/_node-chunks/{globby-AAARUKEU.js → globby-GR24TGSK.js} +9 -9
  35. package/dist/_node-chunks/{lib-HEUKGL62.js → lib-G2LGVRPC.js} +7 -7
  36. package/dist/_node-chunks/{mdx-N42X6CFJ-DCVRPS6N.js → mdx-N42X6CFJ-W6P6IDDW.js} +8 -8
  37. package/dist/_node-chunks/{p-limit-F5ZKJ6WZ.js → p-limit-K4FZHG2F.js} +7 -7
  38. package/dist/babel/index.js +10 -11
  39. package/dist/bin/core.js +32 -26
  40. package/dist/bin/dispatcher.js +31 -20
  41. package/dist/bin/loader.js +10 -13
  42. package/dist/cli/index.d.ts +692 -133
  43. package/dist/cli/index.js +1005 -177
  44. package/dist/common/index.d.ts +139 -62
  45. package/dist/common/index.js +63 -49
  46. package/dist/core-server/index.d.ts +3 -2
  47. package/dist/core-server/index.js +96 -1413
  48. package/dist/core-server/presets/common-override-preset.js +9 -9
  49. package/dist/core-server/presets/common-preset.js +25 -65
  50. package/dist/csf-tools/index.js +9 -9
  51. package/dist/manager/globals-runtime.js +32 -3
  52. package/dist/manager/runtime.js +1 -1
  53. package/dist/manager-api/index.d.ts +1 -1
  54. package/dist/manager-api/index.js +4 -4
  55. package/dist/manager-errors.d.ts +6 -0
  56. package/dist/manager-errors.js +2 -2
  57. package/dist/mocking-utils/index.d.ts +1126 -0
  58. package/dist/{_node-chunks/chunk-UGDPX5LE.js → mocking-utils/index.js} +441 -16
  59. package/dist/node-logger/index.d.ts +192 -24
  60. package/dist/node-logger/index.js +23 -3148
  61. package/dist/preview/runtime.js +31 -2
  62. package/dist/preview-api/index.d.ts +69 -68
  63. package/dist/preview-errors.d.ts +6 -0
  64. package/dist/preview-errors.js +2 -2
  65. package/dist/server-errors.d.ts +31 -1
  66. package/dist/server-errors.js +17 -10
  67. package/dist/telemetry/index.d.ts +23 -2
  68. package/dist/telemetry/index.js +25 -24
  69. package/dist/types/index.d.ts +71 -8
  70. package/dist/types/index.js +25 -1
  71. package/package.json +7 -9
  72. package/dist/_node-chunks/camelcase-K3IOOFQW.js +0 -18
  73. package/dist/_node-chunks/chunk-7I22Y76Z.js +0 -1047
  74. package/dist/_node-chunks/chunk-C2GQVDWI.js +0 -34
  75. package/dist/_node-chunks/chunk-GQJOWVVR.js +0 -3214
  76. package/dist/_node-chunks/chunk-KK4AT5F3.js +0 -1029
  77. package/dist/_node-chunks/chunk-L7MYXJUM.js +0 -1114
  78. package/dist/_node-chunks/chunk-LXG4DK35.js +0 -3171
  79. package/dist/_node-chunks/chunk-QH4V5YDB.js +0 -20
  80. package/dist/_node-chunks/chunk-WK3EMYK6.js +0 -61
  81. package/dist/_node-chunks/chunk-YK4KVMFW.js +0 -18
  82. package/dist/_node-chunks/chunk-ZZPBSYA5.js +0 -301
  83. package/dist/_node-chunks/plugin-7YY7JXCH.js +0 -123
  84. package/dist/_node-chunks/plugin-SZP3CW6W.js +0 -109
  85. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-TGKNDPO6.js +0 -46623
  86. package/dist/_node-chunks/webpack-mock-plugin-LNTZZFBE.js +0 -92
  87. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -32
  88. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -28
package/dist/cli/index.js CHANGED
@@ -1,85 +1,51 @@
1
- import CJS_COMPAT_NODE_URL_843v2rliy1 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_843v2rliy1 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_843v2rliy1 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_h0pwn2pcb57 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_h0pwn2pcb57 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_h0pwn2pcb57 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_843v2rliy1.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_843v2rliy1.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_843v2rliy1.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_h0pwn2pcb57.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_h0pwn2pcb57.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_h0pwn2pcb57.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
- CommunityBuilder,
14
- CoreBuilder,
15
- CoreWebpackCompilers,
16
- ProjectType,
17
- SUPPORTED_RENDERERS,
18
- SupportedLanguage,
19
- addToDevDependenciesIfNotPresent,
20
- adjustTemplate,
21
- builderNameToCoreBuilder,
22
- cliStoriesTargetPath,
23
- coerceSemver,
24
- compilerNameToCoreCompiler,
25
- copyTemplate,
26
- copyTemplateFiles,
27
- detect,
28
- detectBuilder,
29
- detectFrameworkPreset,
30
- detectLanguage,
31
- detectPnp,
32
- externalFrameworks,
33
- frameworkToDefaultBuilder,
34
- getBabelDependencies,
35
- getRendererDir,
36
- getVersionSafe,
37
- hasStorybookDependencies,
38
- installableProjectTypes,
39
- isNxProject,
40
- isStorybookInstantiated,
41
- readFileAsJson,
42
- supportedTemplates,
43
- unsupportedTemplate,
44
- writeFileAsJson
45
- } from "../_node-chunks/chunk-KK4AT5F3.js";
46
- import {
47
- boxen
48
- } from "../_node-chunks/chunk-7I22Y76Z.js";
49
- import "../_node-chunks/chunk-MJ3WOS6F.js";
13
+ detectPnp
14
+ } from "../_node-chunks/chunk-654SJIMS.js";
50
15
  import {
51
16
  Settings,
52
17
  _clearGlobalSettings,
53
18
  globalSettings
54
- } from "../_node-chunks/chunk-JCRM2YVK.js";
19
+ } from "../_node-chunks/chunk-XKRVQL2G.js";
55
20
  import {
21
+ any,
56
22
  up2 as up
57
- } from "../_node-chunks/chunk-4GZCFQFG.js";
58
- import "../_node-chunks/chunk-R6HWGZWD.js";
59
- import "../_node-chunks/chunk-SPQXMU2Q.js";
60
- import "../_node-chunks/chunk-BBOP3XCK.js";
23
+ } from "../_node-chunks/chunk-DPFYWXEA.js";
24
+ import {
25
+ invariant
26
+ } from "../_node-chunks/chunk-JQ7RQS5Q.js";
61
27
  import {
62
- require_prompts
63
- } from "../_node-chunks/chunk-GQJOWVVR.js";
28
+ resolvePackageDir
29
+ } from "../_node-chunks/chunk-MJM4TEMP.js";
30
+ import "../_node-chunks/chunk-LPKSBF62.js";
64
31
  import {
65
32
  require_dist
66
- } from "../_node-chunks/chunk-PHOZWZZO.js";
33
+ } from "../_node-chunks/chunk-CMYD2JNN.js";
67
34
  import {
68
35
  babelParse,
69
36
  recast,
70
37
  traverse,
71
38
  types
72
- } from "../_node-chunks/chunk-ZZSRFAC6.js";
73
- import "../_node-chunks/chunk-L7MYXJUM.js";
74
- import "../_node-chunks/chunk-LCZO45L7.js";
39
+ } from "../_node-chunks/chunk-RUUNVQ6W.js";
40
+ import "../_node-chunks/chunk-FCVNHU2F.js";
75
41
  import {
76
42
  require_picocolors
77
- } from "../_node-chunks/chunk-32NE3UE3.js";
43
+ } from "../_node-chunks/chunk-OVVZIUHS.js";
78
44
  import {
79
45
  __commonJS,
80
46
  __require,
81
47
  __toESM
82
- } from "../_node-chunks/chunk-XGVLB4UJ.js";
48
+ } from "../_node-chunks/chunk-WC2YEQHJ.js";
83
49
 
84
50
  // ../node_modules/esprima/dist/esprima.js
85
51
  var require_esprima = __commonJS({
@@ -412,8 +378,8 @@ var require_esprima = __commonJS({
412
378
  }
413
379
  return result;
414
380
  }, JSXParser2.prototype.lexJSX = function() {
415
- var cp = this.scanner.source.charCodeAt(this.scanner.index);
416
- if (cp === 60 || cp === 62 || cp === 47 || cp === 58 || cp === 61 || cp === 123 || cp === 125) {
381
+ var cp2 = this.scanner.source.charCodeAt(this.scanner.index);
382
+ if (cp2 === 60 || cp2 === 62 || cp2 === 47 || cp2 === 58 || cp2 === 61 || cp2 === 123 || cp2 === 125) {
417
383
  var value = this.scanner.source[this.scanner.index++];
418
384
  return {
419
385
  type: 7,
@@ -424,7 +390,7 @@ var require_esprima = __commonJS({
424
390
  end: this.scanner.index
425
391
  };
426
392
  }
427
- if (cp === 34 || cp === 39) {
393
+ if (cp2 === 34 || cp2 === 39) {
428
394
  for (var start = this.scanner.index, quote = this.scanner.source[this.scanner.index++], str = ""; !this.scanner.eof(); ) {
429
395
  var ch = this.scanner.source[this.scanner.index++];
430
396
  if (ch === quote)
@@ -440,7 +406,7 @@ var require_esprima = __commonJS({
440
406
  end: this.scanner.index
441
407
  };
442
408
  }
443
- if (cp === 46) {
409
+ if (cp2 === 46) {
444
410
  var n1 = this.scanner.source.charCodeAt(this.scanner.index + 1), n2 = this.scanner.source.charCodeAt(this.scanner.index + 2), value = n1 === 46 && n2 === 46 ? "..." : ".", start = this.scanner.index;
445
411
  return this.scanner.index += value.length, {
446
412
  type: 7,
@@ -451,7 +417,7 @@ var require_esprima = __commonJS({
451
417
  end: this.scanner.index
452
418
  };
453
419
  }
454
- if (cp === 96)
420
+ if (cp2 === 96)
455
421
  return {
456
422
  type: 10,
457
423
  value: "",
@@ -460,7 +426,7 @@ var require_esprima = __commonJS({
460
426
  start: this.scanner.index,
461
427
  end: this.scanner.index
462
428
  };
463
- if (character_1.Character.isIdentifierStart(cp) && cp !== 92) {
429
+ if (character_1.Character.isIdentifierStart(cp2) && cp2 !== 92) {
464
430
  var start = this.scanner.index;
465
431
  for (++this.scanner.index; !this.scanner.eof(); ) {
466
432
  var ch = this.scanner.source.charCodeAt(this.scanner.index);
@@ -659,33 +625,33 @@ var require_esprima = __commonJS({
659
625
  };
660
626
  exports2.Character = {
661
627
  /* tslint:disable:no-bitwise */
662
- fromCodePoint: function(cp) {
663
- return cp < 65536 ? String.fromCharCode(cp) : String.fromCharCode(55296 + (cp - 65536 >> 10)) + String.fromCharCode(56320 + (cp - 65536 & 1023));
628
+ fromCodePoint: function(cp2) {
629
+ return cp2 < 65536 ? String.fromCharCode(cp2) : String.fromCharCode(55296 + (cp2 - 65536 >> 10)) + String.fromCharCode(56320 + (cp2 - 65536 & 1023));
664
630
  },
665
631
  // https://tc39.github.io/ecma262/#sec-white-space
666
- isWhiteSpace: function(cp) {
667
- return cp === 32 || cp === 9 || cp === 11 || cp === 12 || cp === 160 || cp >= 5760 && [5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].indexOf(cp) >= 0;
632
+ isWhiteSpace: function(cp2) {
633
+ return cp2 === 32 || cp2 === 9 || cp2 === 11 || cp2 === 12 || cp2 === 160 || cp2 >= 5760 && [5760, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8199, 8200, 8201, 8202, 8239, 8287, 12288, 65279].indexOf(cp2) >= 0;
668
634
  },
669
635
  // https://tc39.github.io/ecma262/#sec-line-terminators
670
- isLineTerminator: function(cp) {
671
- return cp === 10 || cp === 13 || cp === 8232 || cp === 8233;
636
+ isLineTerminator: function(cp2) {
637
+ return cp2 === 10 || cp2 === 13 || cp2 === 8232 || cp2 === 8233;
672
638
  },
673
639
  // https://tc39.github.io/ecma262/#sec-names-and-keywords
674
- isIdentifierStart: function(cp) {
675
- return cp === 36 || cp === 95 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 92 || cp >= 128 && Regex.NonAsciiIdentifierStart.test(exports2.Character.fromCodePoint(cp));
640
+ isIdentifierStart: function(cp2) {
641
+ return cp2 === 36 || cp2 === 95 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122 || cp2 === 92 || cp2 >= 128 && Regex.NonAsciiIdentifierStart.test(exports2.Character.fromCodePoint(cp2));
676
642
  },
677
- isIdentifierPart: function(cp) {
678
- return cp === 36 || cp === 95 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp >= 48 && cp <= 57 || cp === 92 || cp >= 128 && Regex.NonAsciiIdentifierPart.test(exports2.Character.fromCodePoint(cp));
643
+ isIdentifierPart: function(cp2) {
644
+ return cp2 === 36 || cp2 === 95 || cp2 >= 65 && cp2 <= 90 || cp2 >= 97 && cp2 <= 122 || cp2 >= 48 && cp2 <= 57 || cp2 === 92 || cp2 >= 128 && Regex.NonAsciiIdentifierPart.test(exports2.Character.fromCodePoint(cp2));
679
645
  },
680
646
  // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
681
- isDecimalDigit: function(cp) {
682
- return cp >= 48 && cp <= 57;
647
+ isDecimalDigit: function(cp2) {
648
+ return cp2 >= 48 && cp2 <= 57;
683
649
  },
684
- isHexDigit: function(cp) {
685
- return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 70 || cp >= 97 && cp <= 102;
650
+ isHexDigit: function(cp2) {
651
+ return cp2 >= 48 && cp2 <= 57 || cp2 >= 65 && cp2 <= 70 || cp2 >= 97 && cp2 <= 102;
686
652
  },
687
- isOctalDigit: function(cp) {
688
- return cp >= 48 && cp <= 55;
653
+ isOctalDigit: function(cp2) {
654
+ return cp2 >= 48 && cp2 <= 55;
689
655
  }
690
656
  };
691
657
  },
@@ -3049,15 +3015,15 @@ var require_esprima = __commonJS({
3049
3015
  return !1;
3050
3016
  }
3051
3017
  }, Scanner2.prototype.codePointAt = function(i) {
3052
- var cp = this.source.charCodeAt(i);
3053
- if (cp >= 55296 && cp <= 56319) {
3018
+ var cp2 = this.source.charCodeAt(i);
3019
+ if (cp2 >= 55296 && cp2 <= 56319) {
3054
3020
  var second = this.source.charCodeAt(i + 1);
3055
3021
  if (second >= 56320 && second <= 57343) {
3056
- var first = cp;
3057
- cp = (first - 55296) * 1024 + second - 56320 + 65536;
3022
+ var first = cp2;
3023
+ cp2 = (first - 55296) * 1024 + second - 56320 + 65536;
3058
3024
  }
3059
3025
  }
3060
- return cp;
3026
+ return cp2;
3061
3027
  }, Scanner2.prototype.scanHexEscape = function(prefix) {
3062
3028
  for (var len = prefix === "u" ? 4 : 2, code = 0, i = 0; i < len; ++i)
3063
3029
  if (!this.eof() && character_1.Character.isHexDigit(this.source.charCodeAt(this.index)))
@@ -3084,11 +3050,11 @@ var require_esprima = __commonJS({
3084
3050
  }
3085
3051
  return this.source.slice(start, this.index);
3086
3052
  }, Scanner2.prototype.getComplexIdentifier = function() {
3087
- var cp = this.codePointAt(this.index), id = character_1.Character.fromCodePoint(cp);
3053
+ var cp2 = this.codePointAt(this.index), id = character_1.Character.fromCodePoint(cp2);
3088
3054
  this.index += id.length;
3089
3055
  var ch;
3090
- for (cp === 92 && (this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), ++this.index, this.source[this.index] === "{" ? (++this.index, ch = this.scanUnicodeCodePointEscape()) : (ch = this.scanHexEscape("u"), (ch === null || ch === "\\" || !character_1.Character.isIdentifierStart(ch.charCodeAt(0))) && this.throwUnexpectedToken()), id = ch); !this.eof() && (cp = this.codePointAt(this.index), !!character_1.Character.isIdentifierPart(cp)); )
3091
- ch = character_1.Character.fromCodePoint(cp), id += ch, this.index += ch.length, cp === 92 && (id = id.substr(0, id.length - 1), this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), ++this.index, this.source[this.index] === "{" ? (++this.index, ch = this.scanUnicodeCodePointEscape()) : (ch = this.scanHexEscape("u"), (ch === null || ch === "\\" || !character_1.Character.isIdentifierPart(ch.charCodeAt(0))) && this.throwUnexpectedToken()), id += ch);
3056
+ for (cp2 === 92 && (this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), ++this.index, this.source[this.index] === "{" ? (++this.index, ch = this.scanUnicodeCodePointEscape()) : (ch = this.scanHexEscape("u"), (ch === null || ch === "\\" || !character_1.Character.isIdentifierStart(ch.charCodeAt(0))) && this.throwUnexpectedToken()), id = ch); !this.eof() && (cp2 = this.codePointAt(this.index), !!character_1.Character.isIdentifierPart(cp2)); )
3057
+ ch = character_1.Character.fromCodePoint(cp2), id += ch, this.index += ch.length, cp2 === 92 && (id = id.substr(0, id.length - 1), this.source.charCodeAt(this.index) !== 117 && this.throwUnexpectedToken(), ++this.index, this.source[this.index] === "{" ? (++this.index, ch = this.scanUnicodeCodePointEscape()) : (ch = this.scanHexEscape("u"), (ch === null || ch === "\\" || !character_1.Character.isIdentifierPart(ch.charCodeAt(0))) && this.throwUnexpectedToken()), id += ch);
3092
3058
  return id;
3093
3059
  }, Scanner2.prototype.octalToDecimal = function(ch) {
3094
3060
  var octal = ch !== "0", code = octalValue(ch);
@@ -3442,8 +3408,8 @@ var require_esprima = __commonJS({
3442
3408
  start: this.index,
3443
3409
  end: this.index
3444
3410
  };
3445
- var cp = this.source.charCodeAt(this.index);
3446
- return character_1.Character.isIdentifierStart(cp) ? this.scanIdentifier() : cp === 40 || cp === 41 || cp === 59 ? this.scanPunctuator() : cp === 39 || cp === 34 ? this.scanStringLiteral() : cp === 46 ? character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index + 1)) ? this.scanNumericLiteral() : this.scanPunctuator() : character_1.Character.isDecimalDigit(cp) ? this.scanNumericLiteral() : cp === 96 || cp === 125 && this.curlyStack[this.curlyStack.length - 1] === "${" ? this.scanTemplate() : cp >= 55296 && cp < 57343 && character_1.Character.isIdentifierStart(this.codePointAt(this.index)) ? this.scanIdentifier() : this.scanPunctuator();
3411
+ var cp2 = this.source.charCodeAt(this.index);
3412
+ return character_1.Character.isIdentifierStart(cp2) ? this.scanIdentifier() : cp2 === 40 || cp2 === 41 || cp2 === 59 ? this.scanPunctuator() : cp2 === 39 || cp2 === 34 ? this.scanStringLiteral() : cp2 === 46 ? character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index + 1)) ? this.scanNumericLiteral() : this.scanPunctuator() : character_1.Character.isDecimalDigit(cp2) ? this.scanNumericLiteral() : cp2 === 96 || cp2 === 125 && this.curlyStack[this.curlyStack.length - 1] === "${" ? this.scanTemplate() : cp2 >= 55296 && cp2 < 57343 && character_1.Character.isIdentifierStart(this.codePointAt(this.index)) ? this.scanIdentifier() : this.scanPunctuator();
3447
3413
  }, Scanner2;
3448
3414
  })();
3449
3415
  exports2.Scanner = Scanner;
@@ -4742,21 +4708,21 @@ var require_stringify = __commonJS({
4742
4708
  return display_block || is_line_comment ? str + LF + deeper_gap : str;
4743
4709
  }, replacer = null, indent = EMPTY, clean = () => {
4744
4710
  replacer = null, indent = EMPTY;
4745
- }, join2 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY, join_content = (inside, value, gap) => {
4711
+ }, join5 = (one, two, gap) => one ? two ? one + two.trim() + LF + gap : one.trimRight() + LF + gap : two ? two.trimRight() + LF + gap : EMPTY, join_content = (inside, value, gap) => {
4746
4712
  let comment = process_comments(value, PREFIX_BEFORE, gap + indent, !0);
4747
- return join2(comment, inside, gap);
4713
+ return join5(comment, inside, gap);
4748
4714
  }, array_stringify = (value, gap) => {
4749
4715
  let deeper_gap = gap + indent, { length } = value, inside = EMPTY, after_comma = EMPTY;
4750
4716
  for (let i = 0; i < length; i++) {
4751
4717
  i !== 0 && (inside += COMMA);
4752
- let before = join2(
4718
+ let before = join5(
4753
4719
  after_comma,
4754
4720
  process_comments(value, BEFORE(i), deeper_gap),
4755
4721
  deeper_gap
4756
4722
  );
4757
4723
  inside += before || LF + deeper_gap, inside += stringify(i, value, deeper_gap) || STR_NULL, inside += process_comments(value, AFTER_VALUE(i), deeper_gap), after_comma = process_comments(value, AFTER(i), deeper_gap);
4758
4724
  }
4759
- return inside += join2(
4725
+ return inside += join5(
4760
4726
  after_comma,
4761
4727
  process_comments(value, PREFIX_AFTER, deeper_gap),
4762
4728
  deeper_gap
@@ -4769,14 +4735,14 @@ var require_stringify = __commonJS({
4769
4735
  if (sv === UNDEFINED)
4770
4736
  return;
4771
4737
  first || (inside += COMMA), first = !1;
4772
- let before = join2(
4738
+ let before = join5(
4773
4739
  after_comma,
4774
4740
  process_comments(value, BEFORE(key), deeper_gap),
4775
4741
  deeper_gap
4776
4742
  );
4777
4743
  inside += before || LF + deeper_gap, inside += quote(key) + process_comments(value, AFTER_PROP(key), deeper_gap) + COLON + process_comments(value, AFTER_COLON(key), deeper_gap) + SPACE + sv + process_comments(value, AFTER_VALUE(key), deeper_gap), after_comma = process_comments(value, AFTER(key), deeper_gap);
4778
4744
  };
4779
- return keys.forEach(iteratee), inside += join2(
4745
+ return keys.forEach(iteratee), inside += join5(
4780
4746
  after_comma,
4781
4747
  process_comments(value, PREFIX_AFTER, deeper_gap),
4782
4748
  deeper_gap
@@ -4851,39 +4817,727 @@ var require_src2 = __commonJS({
4851
4817
  }
4852
4818
  });
4853
4819
 
4854
- // src/cli/angular/helpers.ts
4855
- import { existsSync, readFileSync, writeFileSync } from "node:fs";
4856
- import { join } from "node:path";
4820
+ // src/cli/helpers.ts
4821
+ var import_picocolors = __toESM(require_picocolors(), 1);
4822
+ import { cpSync, existsSync, readFileSync, writeFileSync } from "node:fs";
4823
+ import { cp, readFile as readFile2, writeFile } from "node:fs/promises";
4824
+ import { join as join3, resolve as resolve2 } from "node:path";
4825
+ import {
4826
+ frameworkToRenderer
4827
+ } from "storybook/internal/common";
4857
4828
  import { logger } from "storybook/internal/node-logger";
4858
- import { MissingAngularJsonError } from "storybook/internal/server-errors";
4859
- var import_prompts = __toESM(require_prompts(), 1), import_ts_dedent = __toESM(require_dist(), 1), ANGULAR_JSON_PATH = "angular.json", compoDocPreviewPrefix = import_ts_dedent.dedent`
4860
- import { setCompodocJson } from "@storybook/addon-docs/angular";
4861
- import docJson from "../documentation.json";
4862
- setCompodocJson(docJson);
4863
- `.trimStart(), promptForCompoDocs = async () => {
4864
- logger.plain(
4865
- // Create a text which explains the user why compodoc is necessary
4866
- boxen(
4867
- import_ts_dedent.dedent`
4868
- Compodoc is a great tool to generate documentation for your Angular projects.
4869
- Storybook can use the documentation generated by Compodoc to extract argument definitions
4870
- and JSDOC comments to display them in the Storybook UI. We highly recommend using Compodoc for
4871
- your Angular projects to get the best experience out of Storybook.
4872
- `,
4873
- { title: "Compodoc", borderStyle: "round", padding: 1, borderColor: "#F1618C" }
4874
- )
4875
- );
4876
- let { useCompoDoc } = await (0, import_prompts.default)({
4877
- type: "confirm",
4878
- name: "useCompoDoc",
4879
- message: "Do you want to use Compodoc for documentation?"
4829
+ import {
4830
+ SupportedLanguage
4831
+ } from "storybook/internal/types";
4832
+ import { Feature } from "storybook/internal/types";
4833
+ import { coerce, satisfies } from "semver";
4834
+
4835
+ // ../node_modules/strip-json-comments/index.js
4836
+ var singleComment = Symbol("singleComment"), multiComment = Symbol("multiComment"), stripWithoutWhitespace = () => "", stripWithWhitespace = (string, start, end) => string.slice(start, end).replace(/[^ \t\r\n]/g, " "), isEscaped = (jsonString, quotePosition) => {
4837
+ let index = quotePosition - 1, backslashCount = 0;
4838
+ for (; jsonString[index] === "\\"; )
4839
+ index -= 1, backslashCount += 1;
4840
+ return !!(backslashCount % 2);
4841
+ };
4842
+ function stripJsonComments(jsonString, { whitespace = !0, trailingCommas = !1 } = {}) {
4843
+ if (typeof jsonString != "string")
4844
+ throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
4845
+ let strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace, isInsideString = !1, isInsideComment = !1, offset = 0, buffer = "", result = "", commaIndex = -1;
4846
+ for (let index = 0; index < jsonString.length; index++) {
4847
+ let currentCharacter = jsonString[index], nextCharacter = jsonString[index + 1];
4848
+ if (!isInsideComment && currentCharacter === '"' && (isEscaped(jsonString, index) || (isInsideString = !isInsideString)), !isInsideString)
4849
+ if (!isInsideComment && currentCharacter + nextCharacter === "//")
4850
+ buffer += jsonString.slice(offset, index), offset = index, isInsideComment = singleComment, index++;
4851
+ else if (isInsideComment === singleComment && currentCharacter + nextCharacter === `\r
4852
+ `) {
4853
+ index++, isInsideComment = !1, buffer += strip(jsonString, offset, index), offset = index;
4854
+ continue;
4855
+ } else if (isInsideComment === singleComment && currentCharacter === `
4856
+ `)
4857
+ isInsideComment = !1, buffer += strip(jsonString, offset, index), offset = index;
4858
+ else if (!isInsideComment && currentCharacter + nextCharacter === "/*") {
4859
+ buffer += jsonString.slice(offset, index), offset = index, isInsideComment = multiComment, index++;
4860
+ continue;
4861
+ } else if (isInsideComment === multiComment && currentCharacter + nextCharacter === "*/") {
4862
+ index++, isInsideComment = !1, buffer += strip(jsonString, offset, index + 1), offset = index + 1;
4863
+ continue;
4864
+ } else trailingCommas && !isInsideComment && (commaIndex !== -1 ? currentCharacter === "}" || currentCharacter === "]" ? (buffer += jsonString.slice(offset, index), result += strip(buffer, 0, 1) + buffer.slice(1), buffer = "", offset = index, commaIndex = -1) : currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== `
4865
+ ` && (buffer += jsonString.slice(offset, index), offset = index, commaIndex = -1) : currentCharacter === "," && (result += buffer + jsonString.slice(offset, index), buffer = "", offset = index, commaIndex = index));
4866
+ }
4867
+ let remaining = isInsideComment === singleComment ? strip(jsonString, offset) : jsonString.slice(offset);
4868
+ return result + buffer + remaining;
4869
+ }
4870
+
4871
+ // src/cli/dirs.ts
4872
+ import { join as join2 } from "node:path";
4873
+ import { Readable as Readable2 } from "node:stream";
4874
+ import { pipeline as pipeline2 } from "node:stream/promises";
4875
+ import { createGunzip } from "node:zlib";
4876
+ import { temporaryDirectory, versions } from "storybook/internal/common";
4877
+ import { SupportedFramework } from "storybook/internal/types";
4878
+
4879
+ // ../node_modules/get-npm-tarball-url/lib/index.mjs
4880
+ function src_default(pkgName, pkgVersion, opts) {
4881
+ let registry;
4882
+ opts?.registry ? registry = opts.registry.endsWith("/") ? opts.registry : `${opts.registry}/` : registry = "https://registry.npmjs.org/";
4883
+ let scopelessName = getScopelessName(pkgName);
4884
+ return `${registry}${pkgName}/-/${scopelessName}-${removeBuildMetadataFromVersion(pkgVersion)}.tgz`;
4885
+ }
4886
+ function removeBuildMetadataFromVersion(version) {
4887
+ let plusPos = version.indexOf("+");
4888
+ return plusPos === -1 ? version : version.substring(0, plusPos);
4889
+ }
4890
+ function getScopelessName(name) {
4891
+ return name[0] !== "@" ? name : name.split("/")[1];
4892
+ }
4893
+
4894
+ // ../node_modules/modern-tar/dist/unpacker-BKKRRs7i.js
4895
+ var FLAGTYPE = {
4896
+ 0: "file",
4897
+ 1: "link",
4898
+ 2: "symlink",
4899
+ 3: "character-device",
4900
+ 4: "block-device",
4901
+ 5: "directory",
4902
+ 6: "fifo",
4903
+ x: "pax-header",
4904
+ g: "pax-global-header",
4905
+ L: "gnu-long-name",
4906
+ K: "gnu-long-link-name"
4907
+ }, ZERO_BLOCK = new Uint8Array(512), encoder = new TextEncoder(), decoder = new TextDecoder();
4908
+ function readString(view, offset, size) {
4909
+ let end = view.indexOf(0, offset), sliceEnd = end === -1 || end > offset + size ? offset + size : end;
4910
+ return decoder.decode(view.subarray(offset, sliceEnd));
4911
+ }
4912
+ function readOctal(view, offset, size) {
4913
+ let value = 0, end = offset + size;
4914
+ for (let i = offset; i < end; i++) {
4915
+ let charCode = view[i];
4916
+ if (charCode === 0) break;
4917
+ charCode !== 32 && (value = (value << 3) + (charCode - 48));
4918
+ }
4919
+ return value;
4920
+ }
4921
+ function readNumeric(view, offset, size) {
4922
+ if (view[offset] & 128) {
4923
+ let result = 0;
4924
+ result = view[offset] & 127;
4925
+ for (let i = 1; i < size; i++) result = result * 256 + view[offset + i];
4926
+ if (!Number.isSafeInteger(result)) throw new Error("TAR number too large");
4927
+ return result;
4928
+ }
4929
+ return readOctal(view, offset, size);
4930
+ }
4931
+ var CHECKSUM_SPACE = 32;
4932
+ function validateChecksum(block) {
4933
+ let stored = readOctal(block, 148, 8), sum = 0;
4934
+ for (let i = 0; i < block.length; i++) i >= 148 && i < 156 ? sum += CHECKSUM_SPACE : sum += block[i];
4935
+ return stored === sum;
4936
+ }
4937
+ function parseUstarHeader(block, strict) {
4938
+ if (strict && !validateChecksum(block)) throw new Error("Invalid tar header checksum.");
4939
+ let typeflag = readString(block, 156, 1), header = {
4940
+ name: readString(block, 0, 100),
4941
+ mode: readOctal(block, 100, 8),
4942
+ uid: readNumeric(block, 108, 8),
4943
+ gid: readNumeric(block, 116, 8),
4944
+ size: readNumeric(block, 124, 12),
4945
+ mtime: new Date(readNumeric(block, 136, 12) * 1e3),
4946
+ type: FLAGTYPE[typeflag] || "file",
4947
+ linkname: readString(block, 157, 100)
4948
+ }, magic = readString(block, 257, 6);
4949
+ return magic.trim() === "ustar" && (header.uname = readString(block, 265, 32), header.gname = readString(block, 297, 32)), magic === "ustar" && (header.prefix = readString(block, 345, 155)), header;
4950
+ }
4951
+ var PAX_MAPPING = {
4952
+ path: ["name", (v) => v],
4953
+ linkpath: ["linkname", (v) => v],
4954
+ size: ["size", (v) => parseInt(v, 10)],
4955
+ mtime: ["mtime", parseFloat],
4956
+ uid: ["uid", (v) => parseInt(v, 10)],
4957
+ gid: ["gid", (v) => parseInt(v, 10)],
4958
+ uname: ["uname", (v) => v],
4959
+ gname: ["gname", (v) => v]
4960
+ };
4961
+ function parsePax(buffer) {
4962
+ let decoder$1 = new TextDecoder("utf-8"), overrides = {}, pax = {}, offset = 0;
4963
+ for (; offset < buffer.length; ) {
4964
+ let spaceIndex = buffer.indexOf(32, offset);
4965
+ if (spaceIndex === -1) break;
4966
+ let length = parseInt(decoder$1.decode(buffer.subarray(offset, spaceIndex)), 10);
4967
+ if (Number.isNaN(length) || length === 0) break;
4968
+ let recordEnd = offset + length, [key, value] = decoder$1.decode(buffer.subarray(spaceIndex + 1, recordEnd - 1)).split("=", 2);
4969
+ if (key && value !== void 0) {
4970
+ pax[key] = value;
4971
+ let mapping = PAX_MAPPING[key];
4972
+ if (mapping) {
4973
+ let [targetKey, parser] = mapping, parsedValue = parser(value);
4974
+ (typeof parsedValue == "string" || !Number.isNaN(parsedValue)) && (overrides[targetKey] = parsedValue);
4975
+ }
4976
+ }
4977
+ offset = recordEnd;
4978
+ }
4979
+ return Object.keys(pax).length > 0 && (overrides.pax = pax), overrides;
4980
+ }
4981
+ function applyOverrides(header, overrides) {
4982
+ overrides.name !== void 0 && (header.name = overrides.name), overrides.linkname !== void 0 && (header.linkname = overrides.linkname), overrides.size !== void 0 && (header.size = overrides.size), overrides.mtime !== void 0 && (header.mtime = new Date(overrides.mtime * 1e3)), overrides.uid !== void 0 && (header.uid = overrides.uid), overrides.gid !== void 0 && (header.gid = overrides.gid), overrides.uname !== void 0 && (header.uname = overrides.uname), overrides.gname !== void 0 && (header.gname = overrides.gname), overrides.pax && (header.pax = Object.assign({}, header.pax ?? {}, overrides.pax));
4983
+ }
4984
+ function getMetaParser(type) {
4985
+ switch (type) {
4986
+ case "pax-global-header":
4987
+ case "pax-header":
4988
+ return parsePax;
4989
+ case "gnu-long-name":
4990
+ return (data) => ({ name: readString(data, 0, data.length) });
4991
+ case "gnu-long-link-name":
4992
+ return (data) => ({ linkname: readString(data, 0, data.length) });
4993
+ default:
4994
+ return;
4995
+ }
4996
+ }
4997
+ var EOF_BUFFER = new Uint8Array(512 * 2);
4998
+ function transformHeader(header, options) {
4999
+ let { strip, filter, map } = options;
5000
+ if (!strip && !filter && !map) return header;
5001
+ let h = { ...header };
5002
+ if (strip && strip > 0) {
5003
+ let components = h.name.split("/").filter(Boolean);
5004
+ if (strip >= components.length) return null;
5005
+ let newName = components.slice(strip).join("/");
5006
+ if (h.name = h.type === "directory" && !newName.endsWith("/") ? `${newName}/` : newName, h.linkname?.startsWith("/")) {
5007
+ let linkComponents = h.linkname.split("/").filter(Boolean);
5008
+ h.linkname = strip >= linkComponents.length ? "/" : `/${linkComponents.slice(strip).join("/")}`;
5009
+ }
5010
+ }
5011
+ if (filter?.(h) === !1) return null;
5012
+ let result = map ? map(h) : h;
5013
+ return result && (!result.name || !result.name.trim() || result.name === "." || result.name === "/") ? null : result;
5014
+ }
5015
+ var STATE_HEADER = 0, STATE_BODY = 1, STATE_PADDING = 2, STATE_AWAIT_EOF = 3;
5016
+ function createTarUnpacker(handler, options = {}) {
5017
+ let strict = options.strict ?? !1, chunkQueue = [], totalAvailable = 0, state = STATE_HEADER, waitingForData = !1, currentEntry = null, paxGlobals = {}, nextEntryOverrides = {};
5018
+ function consume(size, callback) {
5019
+ let remaining = Math.min(size, totalAvailable), initialRemaining = remaining;
5020
+ for (; remaining > 0 && chunkQueue.length > 0; ) {
5021
+ let chunkNode = chunkQueue[0], available = chunkNode.data.length - chunkNode.consumed, toProcess = Math.min(remaining, available);
5022
+ callback && callback(chunkNode.data.subarray(chunkNode.consumed, chunkNode.consumed + toProcess)), chunkNode.consumed += toProcess, remaining -= toProcess, chunkNode.consumed >= chunkNode.data.length && chunkQueue.shift();
5023
+ }
5024
+ return totalAvailable -= initialRemaining - remaining, initialRemaining - remaining;
5025
+ }
5026
+ function read(size) {
5027
+ let toRead = Math.min(size, totalAvailable);
5028
+ if (toRead === 0) return null;
5029
+ let chunk = chunkQueue[0];
5030
+ if (chunk && chunk.data.length - chunk.consumed >= toRead) {
5031
+ let result$1 = chunk.data.subarray(chunk.consumed, chunk.consumed + toRead);
5032
+ return chunk.consumed += toRead, totalAvailable -= toRead, chunk.consumed >= chunk.data.length && chunkQueue.shift(), result$1;
5033
+ }
5034
+ let result = new Uint8Array(toRead), offset = 0;
5035
+ return consume(toRead, (data) => {
5036
+ result.set(data, offset), offset += data.length;
5037
+ }), result;
5038
+ }
5039
+ function process2() {
5040
+ for (; ; ) switch (state) {
5041
+ case STATE_HEADER: {
5042
+ if (totalAvailable < 512) {
5043
+ waitingForData = !0;
5044
+ return;
5045
+ }
5046
+ let headerBlock = read(512);
5047
+ if (!headerBlock) {
5048
+ waitingForData = !0;
5049
+ return;
5050
+ }
5051
+ if (isZeroBlock(headerBlock)) {
5052
+ state = STATE_AWAIT_EOF;
5053
+ continue;
5054
+ }
5055
+ waitingForData = !1;
5056
+ try {
5057
+ let internalHeader = parseUstarHeader(headerBlock, strict), header = {
5058
+ ...internalHeader,
5059
+ name: internalHeader.name
5060
+ }, metaParser = getMetaParser(header.type);
5061
+ if (metaParser) {
5062
+ let paddedSize = header.size + 511 & -512;
5063
+ if (totalAvailable < paddedSize) {
5064
+ waitingForData = !0, chunkQueue.unshift({
5065
+ data: headerBlock,
5066
+ consumed: 0
5067
+ }), totalAvailable += 512;
5068
+ return;
5069
+ }
5070
+ let metaBlock = read(paddedSize);
5071
+ if (!metaBlock) {
5072
+ waitingForData = !0;
5073
+ return;
5074
+ }
5075
+ let overrides = metaParser(metaBlock.subarray(0, header.size));
5076
+ header.type === "pax-global-header" ? Object.assign(paxGlobals, overrides) : Object.assign(nextEntryOverrides, overrides);
5077
+ continue;
5078
+ }
5079
+ internalHeader.prefix && (header.name = `${internalHeader.prefix}/${header.name}`), applyOverrides(header, paxGlobals), applyOverrides(header, nextEntryOverrides), nextEntryOverrides = {}, handler.onHeader(header), header.size > 0 ? (currentEntry = {
5080
+ remaining: header.size,
5081
+ padding: -header.size & 511
5082
+ }, state = STATE_BODY) : handler.onEndEntry();
5083
+ } catch (error) {
5084
+ handler.onError(error);
5085
+ return;
5086
+ }
5087
+ continue;
5088
+ }
5089
+ case STATE_BODY: {
5090
+ if (!currentEntry) throw new Error("No current entry for body");
5091
+ let toForward = Math.min(currentEntry.remaining, totalAvailable);
5092
+ if (toForward > 0) {
5093
+ let consumed = consume(toForward, handler.onData);
5094
+ currentEntry.remaining -= consumed;
5095
+ }
5096
+ if (currentEntry.remaining === 0)
5097
+ state = currentEntry.padding > 0 ? STATE_PADDING : STATE_HEADER, state === STATE_HEADER && (handler.onEndEntry(), currentEntry = null);
5098
+ else if (totalAvailable === 0) {
5099
+ waitingForData = !0;
5100
+ return;
5101
+ }
5102
+ continue;
5103
+ }
5104
+ case STATE_PADDING:
5105
+ if (!currentEntry) throw new Error("No current entry for padding");
5106
+ if (totalAvailable < currentEntry.padding) {
5107
+ waitingForData = !0;
5108
+ return;
5109
+ }
5110
+ currentEntry.padding > 0 && consume(currentEntry.padding), handler.onEndEntry(), currentEntry = null, state = STATE_HEADER;
5111
+ continue;
5112
+ case STATE_AWAIT_EOF: {
5113
+ if (totalAvailable < 512) {
5114
+ waitingForData = !0;
5115
+ return;
5116
+ }
5117
+ let secondBlock = read(512);
5118
+ if (!secondBlock) {
5119
+ waitingForData = !0;
5120
+ return;
5121
+ }
5122
+ if (isZeroBlock(secondBlock)) return;
5123
+ if (strict) {
5124
+ handler.onError(new Error("Invalid EOF"));
5125
+ return;
5126
+ }
5127
+ chunkQueue.unshift({
5128
+ data: secondBlock,
5129
+ consumed: 0
5130
+ }), totalAvailable += 512, state = STATE_HEADER;
5131
+ continue;
5132
+ }
5133
+ default:
5134
+ throw new Error("Invalid state in tar unpacker.");
5135
+ }
5136
+ }
5137
+ return {
5138
+ write(chunk) {
5139
+ if (chunk.length !== 0 && (chunkQueue.push({
5140
+ data: chunk,
5141
+ consumed: 0
5142
+ }), totalAvailable += chunk.length, waitingForData)) {
5143
+ waitingForData = !1;
5144
+ try {
5145
+ process2();
5146
+ } catch (error) {
5147
+ handler.onError(error);
5148
+ }
5149
+ }
5150
+ },
5151
+ end() {
5152
+ try {
5153
+ if (waitingForData || process2(), strict) {
5154
+ if (currentEntry && currentEntry.remaining > 0) {
5155
+ let error = new Error("Tar archive is truncated.");
5156
+ throw handler.onError(error), error;
5157
+ }
5158
+ if (totalAvailable > 0 && read(totalAvailable)?.some((b) => b !== 0)) {
5159
+ let error = new Error("Invalid EOF.");
5160
+ throw handler.onError(error), error;
5161
+ }
5162
+ if (waitingForData) {
5163
+ let error = new Error("Tar archive is truncated.");
5164
+ throw handler.onError(error), error;
5165
+ }
5166
+ } else currentEntry && (handler.onEndEntry(), currentEntry = null);
5167
+ } catch (error) {
5168
+ handler.onError(error);
5169
+ }
5170
+ }
5171
+ };
5172
+ }
5173
+ function isZeroBlock(block) {
5174
+ if (block.byteOffset % 8 === 0) {
5175
+ let view = new BigUint64Array(block.buffer, block.byteOffset, block.length / 8);
5176
+ for (let i = 0; i < view.length; i++) if (view[i] !== 0n) return !1;
5177
+ return !0;
5178
+ }
5179
+ for (let i = 0; i < block.length; i++) if (block[i] !== 0) return !1;
5180
+ return !0;
5181
+ }
5182
+
5183
+ // ../node_modules/modern-tar/dist/fs/index.js
5184
+ import * as fs from "node:fs/promises";
5185
+ import { cpus } from "node:os";
5186
+ import * as path from "node:path";
5187
+ import { PassThrough, Readable, Writable } from "node:stream";
5188
+ import { createWriteStream } from "node:fs";
5189
+ import { pipeline } from "node:stream/promises";
5190
+ var unicodeCache = /* @__PURE__ */ new Map(), normalizeUnicode = (s) => {
5191
+ let result = unicodeCache.get(s);
5192
+ return result !== void 0 && unicodeCache.delete(s), result = result ?? s.normalize("NFD"), unicodeCache.set(s, result), unicodeCache.size > 1e4 && unicodeCache.delete(unicodeCache.keys().next().value), result;
5193
+ };
5194
+ function validateBounds(targetPath, destDir, errorMessage) {
5195
+ let target = normalizeUnicode(path.resolve(targetPath)), dest = path.resolve(destDir);
5196
+ if (target !== dest && !target.startsWith(dest + path.sep)) throw new Error(errorMessage);
5197
+ }
5198
+ var win32Reserved = {
5199
+ ":": "\uF03A",
5200
+ "<": "\uF03C",
5201
+ ">": "\uF03E",
5202
+ "|": "\uF07C",
5203
+ "?": "\uF03F",
5204
+ "*": "\uF02A",
5205
+ '"': "\uF022"
5206
+ };
5207
+ function normalizeName(name) {
5208
+ let path$1 = name.replace(/\\/g, "/");
5209
+ if (path$1.split("/").includes("..") || /^[a-zA-Z]:\.\./.test(path$1)) throw new Error(`${name} points outside extraction directory`);
5210
+ let relative = path$1;
5211
+ return /^[a-zA-Z]:/.test(relative) ? relative = relative.replace(/^[a-zA-Z]:[/\\]?/, "") : relative.startsWith("/") && (relative = relative.replace(/^\/+/, "")), process.platform === "win32" ? relative.replace(/[<>:"|?*]/g, (char) => win32Reserved[char]) : relative;
5212
+ }
5213
+ var normalizeHeaderName = (s) => normalizeUnicode(normalizeName(s.replace(/\/+$/, "")));
5214
+ function unpackTar(directoryPath, options = {}) {
5215
+ let { streamTimeout = 5e3, ...fsOptions } = options, timeoutId = null, { handler, signal } = createFSHandler(directoryPath, fsOptions), unpacker = createTarUnpacker(handler, fsOptions), stream;
5216
+ function resetTimeout() {
5217
+ timeoutId && clearTimeout(timeoutId), streamTimeout !== 1 / 0 && streamTimeout > 0 && (timeoutId = setTimeout(() => {
5218
+ let err = new Error(`Stream timed out after ${streamTimeout}ms of inactivity.`);
5219
+ stream.destroy(err);
5220
+ }, streamTimeout));
5221
+ }
5222
+ return stream = new Writable({
5223
+ write(chunk, _, callback) {
5224
+ if (resetTimeout(), signal.aborted) return callback(signal.reason);
5225
+ try {
5226
+ unpacker.write(chunk), callback();
5227
+ } catch (writeErr) {
5228
+ callback(writeErr);
5229
+ }
5230
+ },
5231
+ async final(callback) {
5232
+ timeoutId && clearTimeout(timeoutId);
5233
+ try {
5234
+ if (signal.aborted) return callback(signal.reason);
5235
+ unpacker.end(), await handler.process(), callback();
5236
+ } catch (finalErr) {
5237
+ callback(finalErr);
5238
+ }
5239
+ }
5240
+ }), stream.on("close", () => {
5241
+ timeoutId && clearTimeout(timeoutId);
5242
+ }), resetTimeout(), stream;
5243
+ }
5244
+ function createFSHandler(directoryPath, options) {
5245
+ let { maxDepth = 1024, dmode, fmode, concurrency = cpus().length || 8 } = options, abortController = new AbortController(), { signal } = abortController, opQueue = [], activeOps = 0, pathPromises = /* @__PURE__ */ new Map(), activeEntryStream = null, processingEnded = !1, resolveDrain, drainPromise = new Promise((resolve3) => {
5246
+ resolveDrain = resolve3;
5247
+ }), processQueue = () => {
5248
+ for (signal.aborted && (opQueue.length = 0); activeOps < concurrency && opQueue.length > 0; ) {
5249
+ activeOps++;
5250
+ let op = opQueue.shift();
5251
+ if (!op) break;
5252
+ op();
5253
+ }
5254
+ processingEnded && activeOps === 0 && opQueue.length === 0 && resolveDrain();
5255
+ }, destDirPromise = (async () => {
5256
+ let symbolic = normalizeUnicode(path.resolve(directoryPath));
5257
+ await fs.mkdir(symbolic, { recursive: !0 });
5258
+ try {
5259
+ let real = await fs.realpath(symbolic);
5260
+ return {
5261
+ symbolic,
5262
+ real
5263
+ };
5264
+ } catch (err) {
5265
+ throw signal.aborted ? signal.reason : err;
5266
+ }
5267
+ })();
5268
+ destDirPromise.catch((err) => {
5269
+ signal.aborted || abortController.abort(err);
5270
+ });
5271
+ let ensureDirectoryExists = (dirPath) => {
5272
+ let promise = pathPromises.get(dirPath);
5273
+ return promise || (promise = (async () => {
5274
+ if (signal.aborted) throw signal.reason;
5275
+ let destDir = await destDirPromise;
5276
+ if (dirPath === destDir.symbolic) return "directory";
5277
+ if (await ensureDirectoryExists(path.dirname(dirPath)), signal.aborted) throw signal.reason;
5278
+ try {
5279
+ let stat2 = await fs.lstat(dirPath);
5280
+ if (stat2.isDirectory()) return "directory";
5281
+ if (stat2.isSymbolicLink()) {
5282
+ let realPath = await fs.realpath(dirPath);
5283
+ if (validateBounds(realPath, destDir.real, `Symlink "${dirPath}" points outside the extraction directory.`), (await fs.stat(realPath)).isDirectory()) return "directory";
5284
+ }
5285
+ throw new Error(`"${dirPath}" is not a valid directory component.`);
5286
+ } catch (err) {
5287
+ if (err.code === "ENOENT")
5288
+ return await fs.mkdir(dirPath, { mode: dmode }), "directory";
5289
+ throw err;
5290
+ }
5291
+ })(), pathPromises.set(dirPath, promise), promise);
5292
+ };
5293
+ return {
5294
+ handler: {
5295
+ onHeader(header) {
5296
+ if (signal.aborted) return;
5297
+ activeEntryStream = new PassThrough({ highWaterMark: header.size > 1048576 ? 524288 : void 0 });
5298
+ let entryStream = activeEntryStream, startOperation = () => {
5299
+ let opPromise;
5300
+ try {
5301
+ let transformed = transformHeader(header, options);
5302
+ if (!transformed) {
5303
+ entryStream.resume(), activeOps--, processQueue();
5304
+ return;
5305
+ }
5306
+ let name = normalizeHeaderName(transformed.name), target = path.join(path.resolve(directoryPath), name);
5307
+ opPromise = (pathPromises.get(target) || Promise.resolve(void 0)).then(async (priorOp) => {
5308
+ if (signal.aborted) throw signal.reason;
5309
+ if (priorOp && (priorOp === "directory" && transformed.type !== "directory" || priorOp !== "directory" && transformed.type === "directory"))
5310
+ throw new Error(`Path conflict ${transformed.type} over existing ${priorOp} at "${transformed.name}"`);
5311
+ try {
5312
+ let destDir = await destDirPromise;
5313
+ if (maxDepth !== 1 / 0 && name.split("/").length > maxDepth) throw new Error("Tar exceeds max specified depth.");
5314
+ let outPath = path.join(destDir.symbolic, name);
5315
+ validateBounds(outPath, destDir.symbolic, `Entry "${transformed.name}" points outside the extraction directory.`);
5316
+ let parentDir = path.dirname(outPath);
5317
+ switch (await ensureDirectoryExists(parentDir), transformed.type) {
5318
+ case "directory":
5319
+ await fs.mkdir(outPath, {
5320
+ recursive: !0,
5321
+ mode: dmode ?? transformed.mode
5322
+ });
5323
+ break;
5324
+ case "file": {
5325
+ let fileStream = createWriteStream(outPath, {
5326
+ mode: fmode ?? transformed.mode,
5327
+ highWaterMark: transformed.size > 1048576 ? 524288 : void 0
5328
+ });
5329
+ await pipeline(entryStream, fileStream);
5330
+ break;
5331
+ }
5332
+ case "symlink": {
5333
+ let { linkname } = transformed;
5334
+ if (!linkname) return transformed.type;
5335
+ let target$1 = path.resolve(parentDir, linkname);
5336
+ validateBounds(target$1, destDir.symbolic, `Symlink "${linkname}" points outside the extraction directory.`), await fs.symlink(linkname, outPath);
5337
+ break;
5338
+ }
5339
+ case "link": {
5340
+ let { linkname } = transformed;
5341
+ if (!linkname) return transformed.type;
5342
+ let normalizedLink = normalizeUnicode(linkname);
5343
+ if (path.isAbsolute(normalizedLink)) throw new Error(`Hardlink "${linkname}" points outside the extraction directory.`);
5344
+ let linkTarget = path.join(destDir.symbolic, normalizedLink);
5345
+ validateBounds(linkTarget, destDir.symbolic, `Hardlink "${linkname}" points outside the extraction directory.`), await ensureDirectoryExists(path.dirname(linkTarget));
5346
+ let realTargetParent = await fs.realpath(path.dirname(linkTarget)), realLinkTarget = path.join(realTargetParent, path.basename(linkTarget));
5347
+ if (validateBounds(realLinkTarget, destDir.real, `Hardlink "${linkname}" points outside the extraction directory.`), linkTarget === outPath) return transformed.type;
5348
+ let targetPromise = pathPromises.get(linkTarget);
5349
+ targetPromise && await targetPromise, await fs.link(linkTarget, outPath);
5350
+ break;
5351
+ }
5352
+ default:
5353
+ return transformed.type;
5354
+ }
5355
+ return transformed.mtime && await (transformed.type === "symlink" ? fs.lutimes : fs.utimes)(outPath, transformed.mtime, transformed.mtime).catch(() => {
5356
+ }), transformed.type;
5357
+ } finally {
5358
+ entryStream.readableEnded || entryStream.resume();
5359
+ }
5360
+ }), pathPromises.set(target, opPromise);
5361
+ } catch (err) {
5362
+ opPromise = Promise.reject(err), abortController.abort(err);
5363
+ }
5364
+ opPromise.catch((err) => abortController.abort(err)).finally(() => {
5365
+ activeOps--, processQueue();
5366
+ });
5367
+ };
5368
+ opQueue.push(startOperation), processQueue();
5369
+ },
5370
+ onData(chunk) {
5371
+ signal.aborted || activeEntryStream?.write(chunk);
5372
+ },
5373
+ onEndEntry() {
5374
+ activeEntryStream?.end(), activeEntryStream = null;
5375
+ },
5376
+ onError(error) {
5377
+ abortController.abort(error);
5378
+ },
5379
+ async process() {
5380
+ if (processingEnded = !0, processQueue(), await drainPromise, signal.aborted) throw signal.reason;
5381
+ }
5382
+ },
5383
+ signal
5384
+ };
5385
+ }
5386
+
5387
+ // src/cli/dirs.ts
5388
+ var externalFrameworks = [
5389
+ { name: SupportedFramework.QWIK, packageName: "storybook-framework-qwik" },
5390
+ {
5391
+ name: SupportedFramework.SOLID,
5392
+ packageName: "storybook-solidjs-vite",
5393
+ frameworks: ["storybook-solidjs-vite"],
5394
+ renderer: "storybook-solidjs-vite"
5395
+ },
5396
+ {
5397
+ name: SupportedFramework.NUXT,
5398
+ packageName: "@storybook-vue/nuxt",
5399
+ frameworks: ["@storybook-vue/nuxt"],
5400
+ renderer: "@storybook/vue3"
5401
+ }
5402
+ ], resolveUsingBranchInstall = async (packageManager, request) => {
5403
+ let tempDirectory = await temporaryDirectory(), version = versions[request] || await packageManager.latestVersion(request), url = (src_default.default || src_default)(request, version, {
5404
+ registry: await packageManager.getRegistryURL()
5405
+ }), response = await fetch(url);
5406
+ if (!response.ok || !response.body)
5407
+ throw new Error(`Failed to download tarball from ${url}`);
5408
+ return await pipeline2(
5409
+ Readable2.fromWeb(response.body),
5410
+ createGunzip(),
5411
+ unpackTar(tempDirectory)
5412
+ ), join2(tempDirectory, "package");
5413
+ };
5414
+ async function getRendererDir(packageManager, renderer) {
5415
+ let externalFramework = externalFrameworks.find((framework) => framework.name === renderer), frameworkPackageName = externalFramework?.packageName || externalFramework?.renderer || `@storybook/${renderer}`, packageJsonPath = join2(frameworkPackageName, "package.json"), errors = [];
5416
+ try {
5417
+ return resolvePackageDir(frameworkPackageName, process.cwd());
5418
+ } catch (e) {
5419
+ invariant(e instanceof Error), errors.push(e);
5420
+ }
5421
+ try {
5422
+ return await resolveUsingBranchInstall(packageManager, frameworkPackageName);
5423
+ } catch (e) {
5424
+ invariant(e instanceof Error), errors.push(e);
5425
+ }
5426
+ throw new Error(`Cannot find ${packageJsonPath}, ${errors.map((e) => e.stack).join(`
5427
+
5428
+ `)}`);
5429
+ }
5430
+
5431
+ // src/cli/helpers.ts
5432
+ function readFileAsJson(jsonPath, allowComments) {
5433
+ let filePath = resolve2(jsonPath);
5434
+ if (!existsSync(filePath))
5435
+ return !1;
5436
+ let fileContent = readFileSync(filePath, "utf8"), jsonContent = allowComments ? stripJsonComments(fileContent) : fileContent;
5437
+ try {
5438
+ return JSON.parse(jsonContent);
5439
+ } catch (e) {
5440
+ throw logger.error(import_picocolors.default.red(`Invalid json in file: ${filePath}`)), e;
5441
+ }
5442
+ }
5443
+ var writeFileAsJson = (jsonPath, content) => {
5444
+ let filePath = resolve2(jsonPath);
5445
+ return existsSync(filePath) ? (writeFileSync(filePath, `${JSON.stringify(content, null, 2)}
5446
+ `), !0) : !1;
5447
+ };
5448
+ async function getBabelDependencies(packageManager) {
5449
+ let dependenciesToAdd = [], babelLoaderVersion = "^8.0.0-0", babelCoreVersion = packageManager.getDependencyVersion("babel-core");
5450
+ if (babelCoreVersion) {
5451
+ let latestCompatibleBabelVersion = await packageManager.latestVersion(
5452
+ "babel-core",
5453
+ babelCoreVersion
5454
+ );
5455
+ latestCompatibleBabelVersion && satisfies(latestCompatibleBabelVersion, "^6.0.0") && (babelLoaderVersion = "^7.0.0");
5456
+ } else if (!packageManager.getDependencyVersion("@babel/core")) {
5457
+ let babelCoreInstallVersion = await packageManager.getVersion("@babel/core");
5458
+ dependenciesToAdd.push(`@babel/core@${babelCoreInstallVersion}`);
5459
+ }
5460
+ if (!packageManager.getDependencyVersion("babel-loader")) {
5461
+ let babelLoaderInstallVersion = await packageManager.getVersion(
5462
+ "babel-loader",
5463
+ babelLoaderVersion
5464
+ );
5465
+ dependenciesToAdd.push(`babel-loader@${babelLoaderInstallVersion}`);
5466
+ }
5467
+ return dependenciesToAdd;
5468
+ }
5469
+ function addToDevDependenciesIfNotPresent(packageJson, name, packageVersion) {
5470
+ !packageJson.dependencies?.[name] && !packageJson.devDependencies?.[name] && (packageJson.devDependencies ? packageJson.devDependencies[name] = packageVersion : packageJson.devDependencies = {
5471
+ [name]: packageVersion
4880
5472
  });
4881
- return useCompoDoc;
4882
- }, AngularJSON = class {
5473
+ }
5474
+ function copyTemplate(templateRoot, destination = ".") {
5475
+ let templateDir = resolve2(templateRoot, "template-csf/");
5476
+ if (!existsSync(templateDir))
5477
+ throw new Error("Couldn't find template dir");
5478
+ cpSync(templateDir, destination, { recursive: !0 });
5479
+ }
5480
+ async function getVersionSafe(packageManager, packageName) {
5481
+ try {
5482
+ let version = await packageManager.getInstalledVersion(packageName);
5483
+ return version || (version = packageManager.getAllDependencies()[packageName] ?? ""), coerce(version, { includePrerelease: !0 })?.toString();
5484
+ } catch {
5485
+ }
5486
+ }
5487
+ var cliStoriesTargetPath = async () => existsSync("./src") ? "./src/stories" : "./stories";
5488
+ async function copyTemplateFiles({
5489
+ packageManager,
5490
+ templateLocation,
5491
+ language,
5492
+ destination,
5493
+ commonAssetsDir,
5494
+ features
5495
+ }) {
5496
+ let languageFolderMapping = {
5497
+ [SupportedLanguage.JAVASCRIPT]: "js",
5498
+ [SupportedLanguage.TYPESCRIPT]: "ts"
5499
+ }, templatePath = async () => {
5500
+ let baseDir = await getRendererDir(packageManager, templateLocation), assetsDir = join3(baseDir, "template", "cli"), assetsLanguage = join3(assetsDir, languageFolderMapping[language]), assetsJS = join3(assetsDir, languageFolderMapping[SupportedLanguage.JAVASCRIPT]), assetsTS = join3(assetsDir, languageFolderMapping.typescript);
5501
+ if (existsSync(assetsLanguage))
5502
+ return assetsLanguage;
5503
+ if (existsSync(assetsTS))
5504
+ return assetsTS;
5505
+ if (existsSync(assetsJS))
5506
+ return assetsJS;
5507
+ if (existsSync(assetsDir))
5508
+ return assetsDir;
5509
+ throw new Error(`Unsupported renderer: ${templateLocation} (${baseDir})`);
5510
+ }, destinationPath = destination ?? await cliStoriesTargetPath(), filter = (file) => features.has(Feature.DOCS) || !file.endsWith(".mdx");
5511
+ if (commonAssetsDir && await cp(commonAssetsDir, destinationPath, { recursive: !0, filter }), await cp(await templatePath(), destinationPath, { recursive: !0, filter }), commonAssetsDir && features.has(Feature.DOCS)) {
5512
+ let rendererType = frameworkToRenderer[templateLocation] || "react";
5513
+ await adjustTemplate(join3(destinationPath, "Configure.mdx"), { renderer: rendererType });
5514
+ }
5515
+ }
5516
+ async function adjustTemplate(templatePath, templateData) {
5517
+ let template = await readFile2(templatePath, { encoding: "utf8" });
5518
+ Object.keys(templateData).forEach((key) => {
5519
+ template = template.replaceAll(`{{${key}}}`, `${templateData[key]}`);
5520
+ }), await writeFile(templatePath, template);
5521
+ }
5522
+ function coerceSemver(version) {
5523
+ let coercedSemver = coerce(version);
5524
+ return invariant(coercedSemver != null, `Could not coerce ${version} into a semver.`), coercedSemver;
5525
+ }
5526
+ function hasStorybookDependencies(packageManager) {
5527
+ let currentPackageDeps = packageManager.getAllDependencies();
5528
+ return Object.keys(currentPackageDeps).some((dep) => dep.includes("storybook"));
5529
+ }
5530
+
5531
+ // src/cli/angular/helpers.ts
5532
+ import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
5533
+ import { join as join4 } from "node:path";
5534
+ import { prompt } from "storybook/internal/node-logger";
5535
+ import { MissingAngularJsonError } from "storybook/internal/server-errors";
5536
+ var ANGULAR_JSON_PATH = "angular.json", AngularJSON = class {
4883
5537
  constructor() {
4884
- if (!existsSync(ANGULAR_JSON_PATH))
4885
- throw new MissingAngularJsonError({ path: join(process.cwd(), ANGULAR_JSON_PATH) });
4886
- let jsonContent = readFileSync(ANGULAR_JSON_PATH, "utf8");
5538
+ if (!existsSync2(ANGULAR_JSON_PATH))
5539
+ throw new MissingAngularJsonError({ path: join4(process.cwd(), ANGULAR_JSON_PATH) });
5540
+ let jsonContent = readFileSync2(ANGULAR_JSON_PATH, "utf8");
4887
5541
  this.json = JSON.parse(jsonContent);
4888
5542
  }
4889
5543
  get projects() {
@@ -4912,19 +5566,13 @@ var import_prompts = __toESM(require_prompts(), 1), import_ts_dedent = __toESM(r
4912
5566
  return this.projects[projectName];
4913
5567
  }
4914
5568
  async getProjectName() {
4915
- if (this.projectsWithoutStorybook.length > 1) {
4916
- let { projectName } = await (0, import_prompts.default)({
4917
- type: "select",
4918
- name: "projectName",
4919
- message: "For which project do you want to generate Storybook configuration?",
4920
- choices: this.projectsWithoutStorybook.map((name) => ({
4921
- title: name,
4922
- value: name
4923
- }))
4924
- });
4925
- return projectName;
4926
- }
4927
- return this.projectsWithoutStorybook[0];
5569
+ return this.projectsWithoutStorybook.length > 1 ? prompt.select({
5570
+ message: "For which project do you want to generate Storybook configuration?",
5571
+ options: this.projectsWithoutStorybook.map((name) => ({
5572
+ label: name,
5573
+ value: name
5574
+ }))
5575
+ }) : this.projectsWithoutStorybook[0];
4928
5576
  }
4929
5577
  addStorybookEntries({
4930
5578
  angularProjectName,
@@ -4953,16 +5601,19 @@ var import_prompts = __toESM(require_prompts(), 1), import_ts_dedent = __toESM(r
4953
5601
  });
4954
5602
  }
4955
5603
  write() {
4956
- writeFileSync(ANGULAR_JSON_PATH, JSON.stringify(this.json, null, 2));
5604
+ writeFileSync2(ANGULAR_JSON_PATH, JSON.stringify(this.json, null, 2));
4957
5605
  }
4958
5606
  };
4959
5607
 
5608
+ // src/cli/projectTypes.ts
5609
+ var ProjectType = /* @__PURE__ */ ((ProjectType2) => (ProjectType2.ANGULAR = "angular", ProjectType2.EMBER = "ember", ProjectType2.HTML = "html", ProjectType2.NEXTJS = "nextjs", ProjectType2.NUXT = "nuxt", ProjectType2.NX = "nx", ProjectType2.PREACT = "preact", ProjectType2.QWIK = "qwik", ProjectType2.REACT = "react", ProjectType2.REACT_NATIVE = "react_native", ProjectType2.REACT_NATIVE_AND_RNW = "react_native_and_rnw", ProjectType2.REACT_NATIVE_WEB = "react_native_web", ProjectType2.REACT_PROJECT = "react_project", ProjectType2.REACT_SCRIPTS = "react_scripts", ProjectType2.SERVER = "server", ProjectType2.SOLID = "solid", ProjectType2.SVELTE = "svelte", ProjectType2.SVELTEKIT = "sveltekit", ProjectType2.UNDETECTED = "undetected", ProjectType2.UNSUPPORTED = "unsupported", ProjectType2.VUE3 = "vue3", ProjectType2.WEB_COMPONENTS = "web_components", ProjectType2))(ProjectType || {});
5610
+
4960
5611
  // src/cli/eslintPlugin.ts
4961
5612
  var import_comment_json = __toESM(require_src2(), 1);
4962
- import { readFile, writeFile } from "node:fs/promises";
5613
+ import { readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
4963
5614
  import { getProjectRoot } from "storybook/internal/common";
4964
5615
  import { readConfig, writeConfig } from "storybook/internal/csf-tools";
4965
- import { logger as logger2, prompt } from "storybook/internal/node-logger";
5616
+ import { logger as logger2, prompt as prompt2 } from "storybook/internal/node-logger";
4966
5617
 
4967
5618
  // ../node_modules/detect-indent/index.js
4968
5619
  var INDENT_REGEX = /^(?:( )+|\t+)/, INDENT_TYPE_SPACE = "space";
@@ -5027,7 +5678,7 @@ function detectIndent(string) {
5027
5678
  }
5028
5679
 
5029
5680
  // src/cli/eslintPlugin.ts
5030
- var import_picocolors = __toESM(require_picocolors(), 1), import_ts_dedent2 = __toESM(require_dist(), 1);
5681
+ var import_picocolors2 = __toESM(require_picocolors(), 1), import_ts_dedent = __toESM(require_dist(), 1);
5031
5682
  var SUPPORTED_ESLINT_EXTENSIONS = ["ts", "mts", "cts", "mjs", "js", "cjs", "json"], UNSUPPORTED_ESLINT_EXTENSIONS = ["yaml", "yml"], findEslintFile = (instanceDir) => {
5032
5683
  let filePrefixes = ["eslint.config", ".eslintrc"];
5033
5684
  for (let prefix of filePrefixes)
@@ -5047,14 +5698,14 @@ function unwrapTSExpression(expr) {
5047
5698
  var configureFlatConfig = async (code) => {
5048
5699
  let ast = babelParse(code), tsEslintLocalName = "", eslintConfigExpression = null;
5049
5700
  return traverse(ast, {
5050
- ImportDeclaration(path) {
5051
- if (path.node.source.value === "typescript-eslint") {
5052
- let defaultSpecifier = path.node.specifiers.find((s) => types.isImportDefaultSpecifier(s));
5701
+ ImportDeclaration(path2) {
5702
+ if (path2.node.source.value === "typescript-eslint") {
5703
+ let defaultSpecifier = path2.node.specifiers.find((s) => types.isImportDefaultSpecifier(s));
5053
5704
  defaultSpecifier && (tsEslintLocalName = defaultSpecifier.local.name);
5054
5705
  }
5055
5706
  },
5056
- ExportDefaultDeclaration(path) {
5057
- let node = path.node;
5707
+ ExportDefaultDeclaration(path2) {
5708
+ let node = path2.node;
5058
5709
  eslintConfigExpression = unwrapTSExpression(node.declaration);
5059
5710
  let storybookConfig = types.memberExpression(
5060
5711
  types.memberExpression(types.identifier("storybook"), types.identifier("configs")),
@@ -5062,15 +5713,15 @@ var configureFlatConfig = async (code) => {
5062
5713
  !0
5063
5714
  );
5064
5715
  if (types.isArrayExpression(eslintConfigExpression) && eslintConfigExpression.elements.push(types.spreadElement(storybookConfig)), types.isCallExpression(eslintConfigExpression) && types.isMemberExpression(eslintConfigExpression.callee) && tsEslintLocalName && types.isIdentifier(eslintConfigExpression.callee.object, { name: tsEslintLocalName }) && types.isIdentifier(eslintConfigExpression.callee.property, { name: "config" }) && eslintConfigExpression.arguments.push(storybookConfig), types.isIdentifier(eslintConfigExpression)) {
5065
- let binding = path.scope.getBinding(eslintConfigExpression.name);
5716
+ let binding = path2.scope.getBinding(eslintConfigExpression.name);
5066
5717
  if (binding && types.isVariableDeclarator(binding.path.node)) {
5067
5718
  let init = unwrapTSExpression(binding.path.node.init);
5068
5719
  types.isArrayExpression(init) && init.elements.push(types.spreadElement(storybookConfig));
5069
5720
  }
5070
5721
  }
5071
5722
  },
5072
- Program(path) {
5073
- if (!path.node.body.some(
5723
+ Program(path2) {
5724
+ if (!path2.node.body.some(
5074
5725
  (node) => types.isImportDeclaration(node) && node.source.value === "eslint-plugin-storybook"
5075
5726
  )) {
5076
5727
  let importDecl = types.importDeclaration(
@@ -5082,7 +5733,7 @@ var configureFlatConfig = async (code) => {
5082
5733
  type: "CommentLine",
5083
5734
  value: " For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format"
5084
5735
  }
5085
- ], path.node.body.unshift(importDecl);
5736
+ ], path2.node.body.unshift(importDecl);
5086
5737
  }
5087
5738
  }
5088
5739
  }), recast.print(ast).code;
@@ -5123,16 +5774,16 @@ async function configureEslintPlugin({
5123
5774
  if (eslintConfigFile)
5124
5775
  if (eslintConfigFile.endsWith("json")) {
5125
5776
  logger2.debug(`Detected JSON config at ${eslintConfigFile}`);
5126
- let eslintFileContents = await readFile(eslintConfigFile, { encoding: "utf8" }), eslintConfig = import_comment_json.default.parse(eslintFileContents);
5777
+ let eslintFileContents = await readFile3(eslintConfigFile, { encoding: "utf8" }), eslintConfig = import_comment_json.default.parse(eslintFileContents);
5127
5778
  if (normalizeExtends(eslintConfig.extends).filter(Boolean).includes("plugin:storybook/recommended"))
5128
5779
  return;
5129
5780
  Array.isArray(eslintConfig.extends) || (eslintConfig.extends = eslintConfig.extends ? [eslintConfig.extends] : []), eslintConfig.extends.push("plugin:storybook/recommended");
5130
5781
  let spaces = detectIndent(eslintFileContents).amount || 2;
5131
- await writeFile(eslintConfigFile, import_comment_json.default.stringify(eslintConfig, null, spaces));
5782
+ await writeFile2(eslintConfigFile, import_comment_json.default.stringify(eslintConfig, null, spaces));
5132
5783
  } else if (isFlatConfig) {
5133
5784
  logger2.debug(`Detected flat config at ${eslintConfigFile}`);
5134
- let code = await readFile(eslintConfigFile, { encoding: "utf8" }), output = await configureFlatConfig(code);
5135
- await writeFile(eslintConfigFile, output);
5785
+ let code = await readFile3(eslintConfigFile, { encoding: "utf8" }), output = await configureFlatConfig(code);
5786
+ await writeFile2(eslintConfigFile, output);
5136
5787
  } else {
5137
5788
  let eslint = await readConfig(eslintConfigFile), existingExtends = normalizeExtends(eslint.getFieldValue(["extends"])).filter(Boolean);
5138
5789
  if (existingExtends.includes("plugin:storybook/recommended"))
@@ -5151,9 +5802,9 @@ async function configureEslintPlugin({
5151
5802
  });
5152
5803
  }
5153
5804
  }
5154
- var suggestESLintPlugin = async () => await prompt.confirm({
5155
- message: import_ts_dedent2.dedent`
5156
- We have detected that you're using ESLint. Storybook provides a plugin that gives the best experience with Storybook and helps follow best practices: ${import_picocolors.default.yellow(
5805
+ var suggestESLintPlugin = async () => await prompt2.confirm({
5806
+ message: import_ts_dedent.dedent`
5807
+ We have detected that you're using ESLint. Storybook provides a plugin that gives the best experience with Storybook and helps follow best practices: ${import_picocolors2.default.yellow(
5157
5808
  "https://storybook.js.org/docs/9/configure/integration/eslint-plugin"
5158
5809
  )}
5159
5810
 
@@ -5161,51 +5812,228 @@ var suggestESLintPlugin = async () => await prompt.confirm({
5161
5812
  `,
5162
5813
  initialValue: !0
5163
5814
  });
5815
+
5816
+ // src/cli/AddonVitestService.ts
5817
+ import fs2 from "node:fs/promises";
5818
+ import * as babel from "storybook/internal/babel";
5819
+ import { getProjectRoot as getProjectRoot2 } from "storybook/internal/common";
5820
+ import { CLI_COLORS } from "storybook/internal/node-logger";
5821
+ import { logger as logger3, prompt as prompt3 } from "storybook/internal/node-logger";
5822
+ import { ErrorCollector } from "storybook/internal/telemetry";
5823
+ var import_ts_dedent2 = __toESM(require_dist(), 1);
5824
+ import { coerce as coerce2, satisfies as satisfies2 } from "semver";
5825
+ var AddonVitestService = class {
5826
+ constructor() {
5827
+ this.supportedFrameworks = [
5828
+ "html-vite" /* HTML_VITE */,
5829
+ "nextjs-vite" /* NEXTJS_VITE */,
5830
+ "preact-vite" /* PREACT_VITE */,
5831
+ "react-native-web-vite" /* REACT_NATIVE_WEB_VITE */,
5832
+ "react-vite" /* REACT_VITE */,
5833
+ "svelte-vite" /* SVELTE_VITE */,
5834
+ "sveltekit" /* SVELTEKIT */,
5835
+ "vue3-vite" /* VUE3_VITE */,
5836
+ "web-components-vite" /* WEB_COMPONENTS_VITE */
5837
+ ];
5838
+ }
5839
+ /**
5840
+ * Collect all dependencies needed for @storybook/addon-vitest
5841
+ *
5842
+ * Returns versioned package strings ready for installation:
5843
+ *
5844
+ * - Base packages: vitest, @vitest/browser, playwright
5845
+ * - Next.js specific: @storybook/nextjs-vite
5846
+ * - Coverage reporter: @vitest/coverage-v8
5847
+ */
5848
+ async collectDependencies(packageManager) {
5849
+ let allDeps = packageManager.getAllDependencies(), dependencies = [], vitestVersionSpecifier = await packageManager.getInstalledVersion("vitest"), basePackages = [
5850
+ "vitest",
5851
+ "playwright",
5852
+ (vitestVersionSpecifier ? satisfies2(vitestVersionSpecifier, ">=4.0.0") : !0) ? "@vitest/browser-playwright" : "@vitest/browser"
5853
+ ];
5854
+ for (let pkg of basePackages)
5855
+ allDeps[pkg] || dependencies.push(pkg);
5856
+ let v8Version = await packageManager.getInstalledVersion("@vitest/coverage-v8"), istanbulVersion = await packageManager.getInstalledVersion("@vitest/coverage-istanbul");
5857
+ return !v8Version && !istanbulVersion && dependencies.push("@vitest/coverage-v8"), dependencies.map((pkg) => pkg.includes("vitest") && vitestVersionSpecifier ? `${pkg}@${vitestVersionSpecifier}` : pkg);
5858
+ }
5859
+ /**
5860
+ * Install Playwright browser binaries for @storybook/addon-vitest
5861
+ *
5862
+ * Installs Chromium with dependencies via `npx playwright install chromium --with-deps`
5863
+ *
5864
+ * @param packageManager - The package manager to use for installation
5865
+ * @param prompt - The prompt instance for displaying progress
5866
+ * @param logger - The logger instance for displaying messages
5867
+ * @param options - Installation options
5868
+ * @returns Array of error messages if installation fails
5869
+ */
5870
+ async installPlaywright(packageManager, options = {}) {
5871
+ let errors = [], playwrightCommand = ["playwright", "install", "chromium", "--with-deps"];
5872
+ try {
5873
+ (options.yes ? !0 : await (async () => (logger3.log(import_ts_dedent2.dedent`
5874
+ Playwright browser binaries are necessary for @storybook/addon-vitest. The download can take some time. If you don't want to wait, you can skip the installation and run the following command manually later:
5875
+ ${CLI_COLORS.cta(`npx ${playwrightCommand.join(" ")}`)}
5876
+ `), prompt3.confirm({
5877
+ message: "Do you want to install Playwright with Chromium now?",
5878
+ initialValue: !0
5879
+ })))()) ? await prompt3.executeTaskWithSpinner(
5880
+ (signal) => packageManager.runPackageCommand({
5881
+ args: playwrightCommand,
5882
+ stdio: ["inherit", "pipe", "pipe"],
5883
+ signal
5884
+ }),
5885
+ {
5886
+ id: "playwright-installation",
5887
+ intro: 'Installing Playwright browser binaries (Press "c" to abort)',
5888
+ error: `An error occurred while installing Playwright browser binaries. Please run the following command later: npx ${playwrightCommand.join(" ")}`,
5889
+ success: "Playwright browser binaries installed successfully",
5890
+ abortable: !0
5891
+ }
5892
+ ) : logger3.warn("Playwright installation skipped");
5893
+ } catch (e) {
5894
+ ErrorCollector.addError(e), e instanceof Error ? errors.push(e.stack ?? e.message) : errors.push(String(e));
5895
+ }
5896
+ return { errors };
5897
+ }
5898
+ /**
5899
+ * Validate full compatibility for @storybook/addon-vitest
5900
+ *
5901
+ * Checks:
5902
+ *
5903
+ * - Webpack configuration compatibility
5904
+ * - Builder compatibility (Vite or Next.js)
5905
+ * - Renderer/framework support
5906
+ * - Vitest version (>=3.0.0)
5907
+ * - MSW version (>=2.0.0 if installed)
5908
+ * - Next.js installation (if using @storybook/nextjs)
5909
+ * - Vitest config files (if configDir provided)
5910
+ */
5911
+ async validateCompatibility(options) {
5912
+ let reasons = [];
5913
+ options.builder !== "vite" /* VITE */ && reasons.push("Non-Vite builder is not supported"), this.supportedFrameworks.some(
5914
+ (framework) => options.framework === framework
5915
+ ) || reasons.push(`Test feature cannot yet be used with ${options.framework}`);
5916
+ let packageVersionResult = await this.validatePackageVersions(options.packageManager);
5917
+ if (!packageVersionResult.compatible && packageVersionResult.reasons && reasons.push(...packageVersionResult.reasons), options.projectRoot) {
5918
+ let configResult = await this.validateConfigFiles(options.projectRoot);
5919
+ !configResult.compatible && configResult.reasons && reasons.push(...configResult.reasons);
5920
+ }
5921
+ return reasons.length > 0 ? { compatible: !1, reasons } : { compatible: !0 };
5922
+ }
5923
+ /**
5924
+ * Validate package versions for addon-vitest compatibility Public method to allow early
5925
+ * validation before framework detection
5926
+ */
5927
+ async validatePackageVersions(packageManager) {
5928
+ let reasons = [], vitestVersionSpecifier = await packageManager.getInstalledVersion("vitest"), coercedVitestVersion = vitestVersionSpecifier ? coerce2(vitestVersionSpecifier) : null;
5929
+ coercedVitestVersion && !satisfies2(coercedVitestVersion, ">=3.0.0") && reasons.push(
5930
+ `The addon requires Vitest 3.0.0 or higher. You are currently using ${vitestVersionSpecifier}.`
5931
+ );
5932
+ let mswVersionSpecifier = await packageManager.getInstalledVersion("msw"), coercedMswVersion = mswVersionSpecifier ? coerce2(mswVersionSpecifier) : null;
5933
+ return coercedMswVersion && !satisfies2(coercedMswVersion, ">=2.0.0") && reasons.push(
5934
+ `The addon uses Vitest behind the scenes, which supports only version 2 and above of MSW. However, we have detected version ${coercedMswVersion.version} in this project.`
5935
+ ), reasons.length > 0 ? { compatible: !1, reasons } : { compatible: !0 };
5936
+ }
5937
+ /**
5938
+ * Validate vitest config files for addon compatibility
5939
+ *
5940
+ * Public method that can be used by both postinstall and create-storybook flows
5941
+ */
5942
+ async validateConfigFiles(directory) {
5943
+ let reasons = [], projectRoot = getProjectRoot2(), vitestWorkspaceFile = any(
5944
+ ["ts", "js", "json"].flatMap((ex) => [`vitest.workspace.${ex}`, `vitest.projects.${ex}`]),
5945
+ { cwd: directory, last: projectRoot }
5946
+ );
5947
+ if (vitestWorkspaceFile?.endsWith(".json"))
5948
+ reasons.push(`Cannot auto-update JSON workspace file: ${vitestWorkspaceFile}`);
5949
+ else if (vitestWorkspaceFile) {
5950
+ let fileContents = await fs2.readFile(vitestWorkspaceFile, "utf8");
5951
+ this.isValidWorkspaceConfigFile(fileContents) || reasons.push(`Found an invalid workspace config file: ${vitestWorkspaceFile}`);
5952
+ }
5953
+ let vitestConfigFile = any(
5954
+ ["ts", "js", "tsx", "jsx", "cts", "cjs", "mts", "mjs"].map((ex) => `vitest.config.${ex}`),
5955
+ { cwd: directory, last: projectRoot }
5956
+ );
5957
+ if (vitestConfigFile?.endsWith(".cts") || vitestConfigFile?.endsWith(".cjs"))
5958
+ reasons.push(`Cannot auto-update CommonJS config file: ${vitestConfigFile}`);
5959
+ else if (vitestConfigFile) {
5960
+ let configContent = await fs2.readFile(vitestConfigFile, "utf8");
5961
+ this.isValidVitestConfig(configContent) || reasons.push(`Found an invalid Vitest config file: ${vitestConfigFile}`);
5962
+ }
5963
+ return reasons.length > 0 ? { compatible: !1, reasons } : { compatible: !0 };
5964
+ }
5965
+ // Private helper methods for Vitest config validation
5966
+ /** Validate workspace config file structure */
5967
+ isValidWorkspaceConfigFile(fileContents) {
5968
+ let isValid = !1, parsedFile = babel.babelParse(fileContents);
5969
+ return babel.traverse(parsedFile, {
5970
+ ExportDefaultDeclaration: (path2) => {
5971
+ let declaration = path2.node.declaration;
5972
+ isValid = this.isWorkspaceConfigArray(declaration) || this.isDefineWorkspaceExpression(declaration);
5973
+ }
5974
+ }), isValid;
5975
+ }
5976
+ /** Validate Vitest config file structure */
5977
+ isValidVitestConfig(configContent) {
5978
+ let parsedConfig = babel.babelParse(configContent), isValidVitestConfig = !1;
5979
+ return babel.traverse(parsedConfig, {
5980
+ ExportDefaultDeclaration: (path2) => {
5981
+ this.isDefineConfigExpression(path2.node.declaration) ? isValidVitestConfig = this.isSafeToExtendWorkspace(
5982
+ path2.node.declaration
5983
+ ) : this.isMergeConfigExpression(path2.node.declaration) && (isValidVitestConfig = path2.node.declaration.arguments.some(
5984
+ (arg) => this.isSafeToExtendWorkspace(arg)
5985
+ ));
5986
+ }
5987
+ }), isValidVitestConfig;
5988
+ }
5989
+ isWorkspaceConfigArray(node) {
5990
+ return babel.types.isArrayExpression(node) && node?.elements.every(
5991
+ (el) => babel.types.isStringLiteral(el) || babel.types.isObjectExpression(el)
5992
+ );
5993
+ }
5994
+ isDefineWorkspaceExpression(node) {
5995
+ return babel.types.isCallExpression(node) && node.callee && node.callee?.name === "defineWorkspace" && this.isWorkspaceConfigArray(node.arguments?.[0]);
5996
+ }
5997
+ isDefineConfigExpression(node) {
5998
+ return babel.types.isCallExpression(node) && node.callee?.name === "defineConfig" && babel.types.isObjectExpression(node.arguments?.[0]);
5999
+ }
6000
+ isMergeConfigExpression(path2) {
6001
+ return babel.types.isCallExpression(path2) && path2.callee?.name === "mergeConfig";
6002
+ }
6003
+ isSafeToExtendWorkspace(node) {
6004
+ return babel.types.isCallExpression(node) && node.arguments.length > 0 && babel.types.isObjectExpression(node.arguments?.[0]) && node.arguments[0]?.properties.every(
6005
+ (p) => p.key?.name !== "test" || babel.types.isObjectExpression(p.value) && p.value.properties.every(
6006
+ ({ key, value }) => key?.name !== "workspace" || babel.types.isArrayExpression(value)
6007
+ )
6008
+ );
6009
+ }
6010
+ };
5164
6011
  export {
5165
6012
  ANGULAR_JSON_PATH,
6013
+ AddonVitestService,
5166
6014
  AngularJSON,
5167
- CommunityBuilder,
5168
- CoreBuilder,
5169
- CoreWebpackCompilers,
5170
6015
  ProjectType,
5171
6016
  SUPPORTED_ESLINT_EXTENSIONS,
5172
- SUPPORTED_RENDERERS,
5173
6017
  Settings,
5174
- SupportedLanguage,
5175
6018
  _clearGlobalSettings,
5176
6019
  addToDevDependenciesIfNotPresent,
5177
6020
  adjustTemplate,
5178
- builderNameToCoreBuilder,
5179
6021
  cliStoriesTargetPath,
5180
6022
  coerceSemver,
5181
- compilerNameToCoreCompiler,
5182
- compoDocPreviewPrefix,
5183
6023
  configureEslintPlugin,
5184
6024
  configureFlatConfig,
5185
6025
  copyTemplate,
5186
6026
  copyTemplateFiles,
5187
- detect,
5188
- detectBuilder,
5189
- detectFrameworkPreset,
5190
- detectLanguage,
5191
6027
  detectPnp,
5192
- externalFrameworks,
5193
6028
  extractEslintInfo,
5194
6029
  findEslintFile,
5195
- frameworkToDefaultBuilder,
5196
6030
  getBabelDependencies,
5197
6031
  getRendererDir,
5198
6032
  getVersionSafe,
5199
6033
  globalSettings,
5200
6034
  hasStorybookDependencies,
5201
- installableProjectTypes,
5202
- isNxProject,
5203
- isStorybookInstantiated,
5204
6035
  normalizeExtends,
5205
- promptForCompoDocs,
5206
6036
  readFileAsJson,
5207
6037
  suggestESLintPlugin,
5208
- supportedTemplates,
5209
- unsupportedTemplate,
5210
6038
  writeFileAsJson
5211
6039
  };