storybook 10.1.0-alpha.10 → 10.1.0-alpha.12

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 (192) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  5. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  6. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  7. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  8. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  9. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-74YHFU5B.js} +44 -109
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/chunk-BE2DAXKJ.js +2966 -0
  15. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  16. package/dist/_browser-chunks/chunk-EBHB6RPS.js +61 -0
  17. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  18. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  19. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  20. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-QMY4G4R2.js → chunk-L4RMQ7D7.js} +17 -64
  26. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  27. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  28. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  29. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  30. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  31. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  32. package/dist/_browser-chunks/chunk-WXP2XJ3O.js +950 -0
  33. package/dist/_browser-chunks/chunk-X3DUQ5RA.js +47 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-RJZASWHL.js → syntaxhighlighter-WKBQ5RC7.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-HA7CYFCK.js → builder-manager-YUOHSIUB.js} +475 -1013
  40. package/dist/_node-chunks/camelcase-JREIL7NV.js +18 -0
  41. package/dist/_node-chunks/{chunk-RMHAL25C.js → chunk-2D2IODUU.js} +88 -228
  42. package/dist/_node-chunks/chunk-2DMESZFJ.js +943 -0
  43. package/dist/_node-chunks/chunk-4FT2DHGE.js +3009 -0
  44. package/dist/_node-chunks/chunk-5HV3B5OP.js +45571 -0
  45. package/dist/_node-chunks/{chunk-OVXB5GGT.js → chunk-5KLIDWFN.js} +292 -688
  46. package/dist/_node-chunks/chunk-A4APXFQ2.js +759 -0
  47. package/dist/_node-chunks/chunk-B6JWY6PC.js +37 -0
  48. package/dist/_node-chunks/chunk-CZ5GHJCC.js +603 -0
  49. package/dist/_node-chunks/chunk-DUXPWBOK.js +61 -0
  50. package/dist/_node-chunks/chunk-DWXTZT3D.js +58 -0
  51. package/dist/_node-chunks/chunk-E5FJS66Z.js +20 -0
  52. package/dist/_node-chunks/chunk-EZWWR7AR.js +936 -0
  53. package/dist/_node-chunks/chunk-FDXFVHIL.js +1114 -0
  54. package/dist/_node-chunks/{chunk-F3XOPI6H.js → chunk-FZLRAH4N.js} +469 -983
  55. package/dist/_node-chunks/chunk-HZG65SU3.js +34 -0
  56. package/dist/_node-chunks/chunk-IXVYNBMD.js +18 -0
  57. package/dist/_node-chunks/chunk-JARUEMEP.js +4523 -0
  58. package/dist/_node-chunks/chunk-LIH7MTP7.js +3214 -0
  59. package/dist/_node-chunks/chunk-N5GIRUP5.js +1047 -0
  60. package/dist/_node-chunks/{chunk-X4XU27M6.js → chunk-NAOYEL54.js} +15 -24
  61. package/dist/_node-chunks/chunk-O5DA7YLO.js +3171 -0
  62. package/dist/_node-chunks/chunk-OP3INKUD.js +54 -0
  63. package/dist/_node-chunks/chunk-QCO2ZM7F.js +209 -0
  64. package/dist/_node-chunks/chunk-QYQIZBS6.js +26 -0
  65. package/dist/_node-chunks/chunk-SEMIAAWG.js +1564 -0
  66. package/dist/_node-chunks/chunk-TS2UUH2J.js +301 -0
  67. package/dist/_node-chunks/chunk-WA6KZQZ2.js +119 -0
  68. package/dist/_node-chunks/{chunk-ZHSCUGNP.js → chunk-WFLWJO24.js} +3799 -7849
  69. package/dist/_node-chunks/chunk-WUXQMQCB.js +72 -0
  70. package/dist/_node-chunks/{chunk-VPR5IBMG.js → chunk-XXPJ7XR3.js} +8 -10
  71. package/dist/_node-chunks/chunk-Y4E6IGQF.js +61 -0
  72. package/dist/_node-chunks/chunk-ZL3AFKRX.js +1029 -0
  73. package/dist/_node-chunks/chunk-ZXSD6L3S.js +756 -0
  74. package/dist/_node-chunks/dist-DS2B5A3J.js +121 -0
  75. package/dist/_node-chunks/globby-6THB7HVX.js +3452 -0
  76. package/dist/_node-chunks/lib-5NKX4YGG.js +366 -0
  77. package/dist/_node-chunks/mdx-N42X6CFJ-ZLT3QOFF.js +14329 -0
  78. package/dist/_node-chunks/p-limit-PDMWNG7W.js +116 -0
  79. package/dist/_node-chunks/plugin-6XMWOGPO.js +123 -0
  80. package/dist/_node-chunks/{plugin-6ZPCS4LI.js → plugin-LTOXVT6A.js} +36 -56
  81. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +46582 -0
  82. package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +92 -0
  83. package/dist/actions/decorator.js +21 -42
  84. package/dist/actions/index.js +3 -3
  85. package/dist/babel/index.d.ts +671 -335
  86. package/dist/babel/index.js +11 -11
  87. package/dist/bin/core.js +592 -1546
  88. package/dist/bin/dispatcher.js +26 -37
  89. package/dist/bin/loader.js +23 -34
  90. package/dist/channels/index.js +98 -234
  91. package/dist/cli/index.js +1951 -5308
  92. package/dist/client-logger/index.js +31 -61
  93. package/dist/common/index.js +20 -20
  94. package/dist/components/index.js +4211 -8586
  95. package/dist/core-events/index.js +2 -66
  96. package/dist/core-server/index.js +3054 -7290
  97. package/dist/core-server/presets/common-manager.css +2 -2
  98. package/dist/core-server/presets/common-manager.js +1806 -3427
  99. package/dist/core-server/presets/common-override-preset.js +31 -60
  100. package/dist/core-server/presets/common-preset.js +434 -924
  101. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +15 -19
  102. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +12 -17
  103. package/dist/csf/index.js +534 -1179
  104. package/dist/csf-tools/index.js +9 -9
  105. package/dist/docs-tools/index.js +6 -6
  106. package/dist/highlight/index.js +2 -2
  107. package/dist/instrumenter/index.js +199 -415
  108. package/dist/manager/globals-runtime.js +24150 -47364
  109. package/dist/manager/globals.js +2 -3
  110. package/dist/manager/runtime.js +3961 -8373
  111. package/dist/manager-api/index.js +1231 -2425
  112. package/dist/manager-errors.d.ts +3 -0
  113. package/dist/manager-errors.js +3 -3
  114. package/dist/node-logger/index.js +1253 -2601
  115. package/dist/preview/globals.js +2 -3
  116. package/dist/preview/runtime.js +10364 -21990
  117. package/dist/preview-api/index.d.ts +67 -68
  118. package/dist/preview-api/index.js +13 -13
  119. package/dist/preview-errors.d.ts +3 -0
  120. package/dist/preview-errors.js +4 -4
  121. package/dist/router/index.js +347 -899
  122. package/dist/server-errors.d.ts +3 -0
  123. package/dist/server-errors.js +10 -10
  124. package/dist/telemetry/index.js +24 -24
  125. package/dist/test/index.js +5860 -11645
  126. package/dist/theming/create.js +4 -4
  127. package/dist/theming/index.d.ts +3363 -2597
  128. package/dist/theming/index.js +490 -1086
  129. package/dist/types/index.js +2 -11
  130. package/dist/viewport/index.js +3 -3
  131. package/package.json +5 -5
  132. package/dist/_browser-chunks/Color-FQNEU7YS.js +0 -1695
  133. package/dist/_browser-chunks/WithTooltip-6NHN2GXF.js +0 -2343
  134. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  135. package/dist/_browser-chunks/chunk-AW46NMGV.js +0 -1308
  136. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  137. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  138. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  139. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  140. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  141. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  142. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  143. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  144. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  145. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  146. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  147. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  148. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  149. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  150. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  151. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  152. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  153. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  154. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  155. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  156. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  157. package/dist/_node-chunks/camelcase-QALD4XFE.js +0 -18
  158. package/dist/_node-chunks/chunk-2XY53ALL.js +0 -420
  159. package/dist/_node-chunks/chunk-3CBQMG2A.js +0 -6712
  160. package/dist/_node-chunks/chunk-3WDAPZYQ.js +0 -28
  161. package/dist/_node-chunks/chunk-4ZB555EJ.js +0 -697
  162. package/dist/_node-chunks/chunk-52DXKXY3.js +0 -4272
  163. package/dist/_node-chunks/chunk-5OVB4A6F.js +0 -69
  164. package/dist/_node-chunks/chunk-AGHGNXGH.js +0 -18
  165. package/dist/_node-chunks/chunk-B23X5ZCK.js +0 -1531
  166. package/dist/_node-chunks/chunk-B2DAHWJK.js +0 -220
  167. package/dist/_node-chunks/chunk-CC4PW5MJ.js +0 -34
  168. package/dist/_node-chunks/chunk-D7NIZELR.js +0 -2256
  169. package/dist/_node-chunks/chunk-DO5Q3H4L.js +0 -1250
  170. package/dist/_node-chunks/chunk-ECK7WVFX.js +0 -304
  171. package/dist/_node-chunks/chunk-EUH3NHXA.js +0 -79
  172. package/dist/_node-chunks/chunk-FOQHPHCV.js +0 -1657
  173. package/dist/_node-chunks/chunk-G6EL47NS.js +0 -111
  174. package/dist/_node-chunks/chunk-GFLS4TJB.js +0 -90
  175. package/dist/_node-chunks/chunk-J3XZKWHE.js +0 -1586
  176. package/dist/_node-chunks/chunk-LE63EHJ5.js +0 -1518
  177. package/dist/_node-chunks/chunk-M47XA42S.js +0 -4741
  178. package/dist/_node-chunks/chunk-OOI74AL3.js +0 -61
  179. package/dist/_node-chunks/chunk-PRJHT3GJ.js +0 -61
  180. package/dist/_node-chunks/chunk-Q52PVUSU.js +0 -101
  181. package/dist/_node-chunks/chunk-SDCF5RNN.js +0 -1198
  182. package/dist/_node-chunks/chunk-UJ5SJ23M.js +0 -5029
  183. package/dist/_node-chunks/chunk-UPHK4ETU.js +0 -64658
  184. package/dist/_node-chunks/chunk-V7VURIPB.js +0 -1544
  185. package/dist/_node-chunks/dist-6TXHNR5C.js +0 -175
  186. package/dist/_node-chunks/globby-PBTV6PX6.js +0 -5222
  187. package/dist/_node-chunks/lib-4RTDZVGX.js +0 -518
  188. package/dist/_node-chunks/mdx-N42X6CFJ-COWEH7KR.js +0 -22017
  189. package/dist/_node-chunks/p-limit-PBVZQOFY.js +0 -168
  190. package/dist/_node-chunks/plugin-EOZKYZAG.js +0 -159
  191. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-35HMSMR5.js +0 -69102
  192. package/dist/_node-chunks/webpack-mock-plugin-GT3MA5E2.js +0 -124
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_8vqew0zn9si from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_8vqew0zn9si from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_8vqew0zn9si from "node:module";
1
+ import CJS_COMPAT_NODE_URL_57ru1wfqqjv from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_57ru1wfqqjv from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_57ru1wfqqjv from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_8vqew0zn9si.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_8vqew0zn9si.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_8vqew0zn9si.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_57ru1wfqqjv.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_57ru1wfqqjv.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_57ru1wfqqjv.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -12,60 +12,47 @@ var require = CJS_COMPAT_NODE_MODULE_8vqew0zn9si.createRequire(import.meta.url);
12
12
  import {
13
13
  parseStaticDir,
14
14
  sendTelemetryError
15
- } from "../../_node-chunks/chunk-ECK7WVFX.js";
16
- import "../../_node-chunks/chunk-4ZB555EJ.js";
15
+ } from "../../_node-chunks/chunk-QCO2ZM7F.js";
16
+ import "../../_node-chunks/chunk-CZ5GHJCC.js";
17
17
  import {
18
18
  getLastEvents,
19
19
  getSessionId
20
- } from "../../_node-chunks/chunk-G6EL47NS.js";
20
+ } from "../../_node-chunks/chunk-WUXQMQCB.js";
21
21
  import {
22
22
  invariant
23
- } from "../../_node-chunks/chunk-CC4PW5MJ.js";
23
+ } from "../../_node-chunks/chunk-QYQIZBS6.js";
24
24
  import {
25
25
  resolvePackageDir
26
- } from "../../_node-chunks/chunk-V7VURIPB.js";
26
+ } from "../../_node-chunks/chunk-A4APXFQ2.js";
27
27
  import {
28
28
  isAbsolute,
29
29
  join
30
- } from "../../_node-chunks/chunk-B2DAHWJK.js";
31
- import "../../_node-chunks/chunk-UJ5SJ23M.js";
30
+ } from "../../_node-chunks/chunk-WA6KZQZ2.js";
31
+ import "../../_node-chunks/chunk-LIH7MTP7.js";
32
32
  import {
33
33
  loadConfig
34
- } from "../../_node-chunks/chunk-D7NIZELR.js";
34
+ } from "../../_node-chunks/chunk-SEMIAAWG.js";
35
35
  import {
36
36
  require_dist
37
- } from "../../_node-chunks/chunk-5OVB4A6F.js";
37
+ } from "../../_node-chunks/chunk-DUXPWBOK.js";
38
38
  import {
39
39
  require_picocolors
40
- } from "../../_node-chunks/chunk-X4XU27M6.js";
40
+ } from "../../_node-chunks/chunk-NAOYEL54.js";
41
41
  import {
42
42
  __commonJS,
43
- __name,
44
43
  __require,
45
44
  __toESM
46
- } from "../../_node-chunks/chunk-OOI74AL3.js";
45
+ } from "../../_node-chunks/chunk-OP3INKUD.js";
47
46
 
48
47
  // ../node_modules/shell-quote/quote.js
49
48
  var require_quote = __commonJS({
50
49
  "../node_modules/shell-quote/quote.js"(exports, module) {
51
50
  "use strict";
52
- module.exports = /* @__PURE__ */ __name(function quote(xs) {
51
+ module.exports = function(xs) {
53
52
  return xs.map(function(s) {
54
- if (s === "") {
55
- return "''";
56
- }
57
- if (s && typeof s === "object") {
58
- return s.op.replace(/(.)/g, "\\$1");
59
- }
60
- if (/["\s\\]/.test(s) && !/'/.test(s)) {
61
- return "'" + s.replace(/(['])/g, "\\$1") + "'";
62
- }
63
- if (/["'\s]/.test(s)) {
64
- return '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"';
65
- }
66
- return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
53
+ return s === "" ? "''" : s && typeof s == "object" ? s.op.replace(/(.)/g, "\\$1") : /["\s\\]/.test(s) && !/'/.test(s) ? "'" + s.replace(/(['])/g, "\\$1") + "'" : /["'\s]/.test(s) ? '"' + s.replace(/(["\\$`!])/g, "\\$1") + '"' : String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, "$1\\$2");
67
54
  }).join(" ");
68
- }, "quote");
55
+ };
69
56
  }
70
57
  });
71
58
 
@@ -84,189 +71,88 @@ var require_parse = __commonJS({
84
71
  ">\\&",
85
72
  "<\\&",
86
73
  "[&;()|<>]"
87
- ].join("|") + ")";
88
- var controlRE = new RegExp("^" + CONTROL + "$");
89
- var META = "|&;()<> \\t";
90
- var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
91
- var DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'";
92
- var hash = /^#$/;
93
- var SQ = "'";
94
- var DQ = '"';
95
- var DS = "$";
96
- var TOKEN = "";
97
- var mult = 4294967296;
98
- for (i = 0; i < 4; i++) {
74
+ ].join("|") + ")", controlRE = new RegExp("^" + CONTROL + "$"), META = "|&;()<> \\t", SINGLE_QUOTE = '"((\\\\"|[^"])*?)"', DOUBLE_QUOTE = "'((\\\\'|[^'])*?)'", hash = /^#$/, SQ = "'", DQ = '"', DS = "$", TOKEN = "", mult = 4294967296;
75
+ for (i = 0; i < 4; i++)
99
76
  TOKEN += (mult * Math.random()).toString(16);
100
- }
101
- var i;
102
- var startsWithToken = new RegExp("^" + TOKEN);
77
+ var i, startsWithToken = new RegExp("^" + TOKEN);
103
78
  function matchAll(s, r) {
104
- var origIndex = r.lastIndex;
105
- var matches = [];
106
- var matchObj;
107
- while (matchObj = r.exec(s)) {
108
- matches.push(matchObj);
109
- if (r.lastIndex === matchObj.index) {
110
- r.lastIndex += 1;
111
- }
112
- }
113
- r.lastIndex = origIndex;
114
- return matches;
79
+ for (var origIndex = r.lastIndex, matches = [], matchObj; matchObj = r.exec(s); )
80
+ matches.push(matchObj), r.lastIndex === matchObj.index && (r.lastIndex += 1);
81
+ return r.lastIndex = origIndex, matches;
115
82
  }
116
- __name(matchAll, "matchAll");
117
83
  function getVar(env2, pre, key) {
118
- var r = typeof env2 === "function" ? env2(key) : env2[key];
119
- if (typeof r === "undefined" && key != "") {
120
- r = "";
121
- } else if (typeof r === "undefined") {
122
- r = "$";
123
- }
124
- if (typeof r === "object") {
125
- return pre + TOKEN + JSON.stringify(r) + TOKEN;
126
- }
127
- return pre + r;
84
+ var r = typeof env2 == "function" ? env2(key) : env2[key];
85
+ return typeof r > "u" && key != "" ? r = "" : typeof r > "u" && (r = "$"), typeof r == "object" ? pre + TOKEN + JSON.stringify(r) + TOKEN : pre + r;
128
86
  }
129
- __name(getVar, "getVar");
130
87
  function parseInternal(string, env2, opts) {
131
- if (!opts) {
132
- opts = {};
133
- }
134
- var BS = opts.escape || "\\";
135
- var BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+";
136
- var chunker = new RegExp([
88
+ opts || (opts = {});
89
+ var BS = opts.escape || "\\", BAREWORD = "(\\" + BS + `['"` + META + `]|[^\\s'"` + META + "])+", chunker = new RegExp([
137
90
  "(" + CONTROL + ")",
138
91
  // control chars
139
92
  "(" + BAREWORD + "|" + SINGLE_QUOTE + "|" + DOUBLE_QUOTE + ")+"
140
- ].join("|"), "g");
141
- var matches = matchAll(string, chunker);
142
- if (matches.length === 0) {
93
+ ].join("|"), "g"), matches = matchAll(string, chunker);
94
+ if (matches.length === 0)
143
95
  return [];
144
- }
145
- if (!env2) {
146
- env2 = {};
147
- }
148
- var commented = false;
96
+ env2 || (env2 = {});
97
+ var commented = !1;
149
98
  return matches.map(function(match) {
150
99
  var s = match[0];
151
- if (!s || commented) {
152
- return void 0;
153
- }
154
- if (controlRE.test(s)) {
100
+ if (!s || commented)
101
+ return;
102
+ if (controlRE.test(s))
155
103
  return { op: s };
156
- }
157
- var quote = false;
158
- var esc = false;
159
- var out = "";
160
- var isGlob = false;
161
- var i2;
104
+ var quote = !1, esc = !1, out = "", isGlob = !1, i2;
162
105
  function parseEnvVar() {
163
106
  i2 += 1;
164
- var varend;
165
- var varname;
166
- var char = s.charAt(i2);
107
+ var varend, varname, char = s.charAt(i2);
167
108
  if (char === "{") {
168
- i2 += 1;
169
- if (s.charAt(i2) === "}") {
109
+ if (i2 += 1, s.charAt(i2) === "}")
170
110
  throw new Error("Bad substitution: " + s.slice(i2 - 2, i2 + 1));
171
- }
172
- varend = s.indexOf("}", i2);
173
- if (varend < 0) {
111
+ if (varend = s.indexOf("}", i2), varend < 0)
174
112
  throw new Error("Bad substitution: " + s.slice(i2));
175
- }
176
- varname = s.slice(i2, varend);
177
- i2 = varend;
178
- } else if (/[*@#?$!_-]/.test(char)) {
179
- varname = char;
180
- i2 += 1;
181
- } else {
113
+ varname = s.slice(i2, varend), i2 = varend;
114
+ } else if (/[*@#?$!_-]/.test(char))
115
+ varname = char, i2 += 1;
116
+ else {
182
117
  var slicedFromI = s.slice(i2);
183
- varend = slicedFromI.match(/[^\w\d_]/);
184
- if (!varend) {
185
- varname = slicedFromI;
186
- i2 = s.length;
187
- } else {
188
- varname = slicedFromI.slice(0, varend.index);
189
- i2 += varend.index - 1;
190
- }
118
+ varend = slicedFromI.match(/[^\w\d_]/), varend ? (varname = slicedFromI.slice(0, varend.index), i2 += varend.index - 1) : (varname = slicedFromI, i2 = s.length);
191
119
  }
192
120
  return getVar(env2, "", varname);
193
121
  }
194
- __name(parseEnvVar, "parseEnvVar");
195
122
  for (i2 = 0; i2 < s.length; i2++) {
196
123
  var c = s.charAt(i2);
197
- isGlob = isGlob || !quote && (c === "*" || c === "?");
198
- if (esc) {
199
- out += c;
200
- esc = false;
201
- } else if (quote) {
202
- if (c === quote) {
203
- quote = false;
204
- } else if (quote == SQ) {
205
- out += c;
206
- } else {
207
- if (c === BS) {
208
- i2 += 1;
209
- c = s.charAt(i2);
210
- if (c === DQ || c === BS || c === DS) {
211
- out += c;
212
- } else {
213
- out += BS + c;
214
- }
215
- } else if (c === DS) {
216
- out += parseEnvVar();
217
- } else {
218
- out += c;
219
- }
220
- }
221
- } else if (c === DQ || c === SQ) {
124
+ if (isGlob = isGlob || !quote && (c === "*" || c === "?"), esc)
125
+ out += c, esc = !1;
126
+ else if (quote)
127
+ c === quote ? quote = !1 : quote == SQ ? out += c : c === BS ? (i2 += 1, c = s.charAt(i2), c === DQ || c === BS || c === DS ? out += c : out += BS + c) : c === DS ? out += parseEnvVar() : out += c;
128
+ else if (c === DQ || c === SQ)
222
129
  quote = c;
223
- } else if (controlRE.test(c)) {
224
- return { op: s };
225
- } else if (hash.test(c)) {
226
- commented = true;
227
- var commentObj = { comment: string.slice(match.index + i2 + 1) };
228
- if (out.length) {
229
- return [out, commentObj];
230
- }
231
- return [commentObj];
232
- } else if (c === BS) {
233
- esc = true;
234
- } else if (c === DS) {
235
- out += parseEnvVar();
236
- } else {
237
- out += c;
130
+ else {
131
+ if (controlRE.test(c))
132
+ return { op: s };
133
+ if (hash.test(c)) {
134
+ commented = !0;
135
+ var commentObj = { comment: string.slice(match.index + i2 + 1) };
136
+ return out.length ? [out, commentObj] : [commentObj];
137
+ } else c === BS ? esc = !0 : c === DS ? out += parseEnvVar() : out += c;
238
138
  }
239
139
  }
240
- if (isGlob) {
241
- return { op: "glob", pattern: out };
242
- }
243
- return out;
140
+ return isGlob ? { op: "glob", pattern: out } : out;
244
141
  }).reduce(function(prev, arg) {
245
- return typeof arg === "undefined" ? prev : prev.concat(arg);
142
+ return typeof arg > "u" ? prev : prev.concat(arg);
246
143
  }, []);
247
144
  }
248
- __name(parseInternal, "parseInternal");
249
- module.exports = /* @__PURE__ */ __name(function parse(s, env2, opts) {
145
+ module.exports = function(s, env2, opts) {
250
146
  var mapped = parseInternal(s, env2, opts);
251
- if (typeof env2 !== "function") {
252
- return mapped;
253
- }
254
- return mapped.reduce(function(acc, s2) {
255
- if (typeof s2 === "object") {
147
+ return typeof env2 != "function" ? mapped : mapped.reduce(function(acc, s2) {
148
+ if (typeof s2 == "object")
256
149
  return acc.concat(s2);
257
- }
258
150
  var xs = s2.split(RegExp("(" + TOKEN + ".*?" + TOKEN + ")", "g"));
259
- if (xs.length === 1) {
260
- return acc.concat(xs[0]);
261
- }
262
- return acc.concat(xs.filter(Boolean).map(function(x) {
263
- if (startsWithToken.test(x)) {
264
- return JSON.parse(x.split(TOKEN)[1]);
265
- }
266
- return x;
151
+ return xs.length === 1 ? acc.concat(xs[0]) : acc.concat(xs.filter(Boolean).map(function(x) {
152
+ return startsWithToken.test(x) ? JSON.parse(x.split(TOKEN)[1]) : x;
267
153
  }));
268
154
  }, []);
269
- }, "parse");
155
+ };
270
156
  }
271
157
  });
272
158
 
@@ -323,6 +209,7 @@ var require_linux = __commonJS({
323
209
  code: "code",
324
210
  vscodium: "vscodium",
325
211
  codium: "codium",
212
+ cursor: "cursor",
326
213
  trae: "trae",
327
214
  emacs: "emacs",
328
215
  gvim: "gvim",
@@ -383,81 +270,60 @@ var require_windows = __commonJS({
383
270
  // ../node_modules/launch-editor/guess.js
384
271
  var require_guess = __commonJS({
385
272
  "../node_modules/launch-editor/guess.js"(exports, module) {
386
- var path = __require("path");
387
- var shellQuote = require_shell_quote();
388
- var childProcess = __require("child_process");
389
- var COMMON_EDITORS_MACOS = require_macos();
390
- var COMMON_EDITORS_LINUX = require_linux();
391
- var COMMON_EDITORS_WIN = require_windows();
392
- module.exports = /* @__PURE__ */ __name(function guessEditor(specifiedEditor) {
393
- if (specifiedEditor) {
273
+ var path = __require("path"), shellQuote = require_shell_quote(), childProcess = __require("child_process"), COMMON_EDITORS_MACOS = require_macos(), COMMON_EDITORS_LINUX = require_linux(), COMMON_EDITORS_WIN = require_windows();
274
+ module.exports = function(specifiedEditor) {
275
+ if (specifiedEditor)
394
276
  return shellQuote.parse(specifiedEditor);
395
- }
396
- if (process.env.LAUNCH_EDITOR) {
277
+ if (process.env.LAUNCH_EDITOR)
397
278
  return [process.env.LAUNCH_EDITOR];
398
- }
399
- if (process.versions.webcontainer) {
279
+ if (process.versions.webcontainer)
400
280
  return [process.env.EDITOR || "code"];
401
- }
402
281
  try {
403
282
  if (process.platform === "darwin") {
404
- const output = childProcess.execSync("ps x -o comm=", {
283
+ let output = childProcess.execSync("ps x -o comm=", {
405
284
  stdio: ["pipe", "pipe", "ignore"]
406
- }).toString();
407
- const processNames = Object.keys(COMMON_EDITORS_MACOS);
408
- const processList = output.split("\n");
285
+ }).toString(), processNames = Object.keys(COMMON_EDITORS_MACOS), processList = output.split(`
286
+ `);
409
287
  for (let i = 0; i < processNames.length; i++) {
410
- const processName = processNames[i];
411
- if (processList.includes(processName)) {
288
+ let processName = processNames[i];
289
+ if (processList.includes(processName))
412
290
  return [COMMON_EDITORS_MACOS[processName]];
413
- }
414
- const processNameWithoutApplications = processName.replace("/Applications", "");
291
+ let processNameWithoutApplications = processName.replace("/Applications", "");
415
292
  if (output.indexOf(processNameWithoutApplications) !== -1) {
416
- if (processName !== COMMON_EDITORS_MACOS[processName]) {
293
+ if (processName !== COMMON_EDITORS_MACOS[processName])
417
294
  return [COMMON_EDITORS_MACOS[processName]];
418
- }
419
- const runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications));
420
- if (runningProcess !== void 0) {
295
+ let runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications));
296
+ if (runningProcess !== void 0)
421
297
  return [runningProcess];
422
- }
423
298
  }
424
299
  }
425
300
  } else if (process.platform === "win32") {
426
- const output = childProcess.execSync(
301
+ let runningProcesses = childProcess.execSync(
427
302
  'powershell -NoProfile -Command "[Console]::OutputEncoding=[Text.Encoding]::UTF8;Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
428
303
  {
429
304
  stdio: ["pipe", "pipe", "ignore"]
430
305
  }
431
- ).toString();
432
- const runningProcesses = output.split("\r\n");
306
+ ).toString().split(`\r
307
+ `);
433
308
  for (let i = 0; i < runningProcesses.length; i++) {
434
- const fullProcessPath = runningProcesses[i].trim();
435
- const shortProcessName = path.basename(fullProcessPath);
436
- if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1) {
309
+ let fullProcessPath = runningProcesses[i].trim(), shortProcessName = path.basename(fullProcessPath);
310
+ if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1)
437
311
  return [fullProcessPath];
438
- }
439
312
  }
440
313
  } else if (process.platform === "linux") {
441
- const output = childProcess.execSync("ps x --no-heading -o comm --sort=comm", {
314
+ let output = childProcess.execSync("ps x --no-heading -o comm --sort=comm", {
442
315
  stdio: ["pipe", "pipe", "ignore"]
443
- }).toString();
444
- const processNames = Object.keys(COMMON_EDITORS_LINUX);
316
+ }).toString(), processNames = Object.keys(COMMON_EDITORS_LINUX);
445
317
  for (let i = 0; i < processNames.length; i++) {
446
- const processName = processNames[i];
447
- if (output.indexOf(processName) !== -1) {
318
+ let processName = processNames[i];
319
+ if (output.indexOf(processName) !== -1)
448
320
  return [COMMON_EDITORS_LINUX[processName]];
449
- }
450
321
  }
451
322
  }
452
- } catch (ignoreError) {
453
- }
454
- if (process.env.VISUAL) {
455
- return [process.env.VISUAL];
456
- } else if (process.env.EDITOR) {
457
- return [process.env.EDITOR];
323
+ } catch {
458
324
  }
459
- return [null];
460
- }, "guessEditor");
325
+ return process.env.VISUAL ? [process.env.VISUAL] : process.env.EDITOR ? [process.env.EDITOR] : [null];
326
+ };
461
327
  }
462
328
  });
463
329
 
@@ -465,9 +331,8 @@ var require_guess = __commonJS({
465
331
  var require_get_args = __commonJS({
466
332
  "../node_modules/launch-editor/get-args.js"(exports, module) {
467
333
  var path = __require("path");
468
- module.exports = /* @__PURE__ */ __name(function getArgumentsForPosition(editor, fileName, lineNumber, columnNumber = 1) {
469
- const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, "");
470
- switch (editorBasename) {
334
+ module.exports = function(editor, fileName, lineNumber, columnNumber = 1) {
335
+ switch (path.basename(editor).replace(/\.(exe|cmd|bat)$/i, "")) {
471
336
  case "atom":
472
337
  case "Atom":
473
338
  case "Atom Beta":
@@ -522,136 +387,80 @@ var require_get_args = __commonJS({
522
387
  case "rider64":
523
388
  return ["--line", lineNumber, "--column", columnNumber, fileName];
524
389
  }
525
- if (process.env.LAUNCH_EDITOR) {
526
- return [fileName, lineNumber, columnNumber];
527
- }
528
- return [fileName];
529
- }, "getArgumentsForPosition");
390
+ return process.env.LAUNCH_EDITOR ? [fileName, lineNumber, columnNumber] : [fileName];
391
+ };
530
392
  }
531
393
  });
532
394
 
533
395
  // ../node_modules/launch-editor/index.js
534
396
  var require_launch_editor = __commonJS({
535
397
  "../node_modules/launch-editor/index.js"(exports, module) {
536
- var fs = __require("fs");
537
- var os = __require("os");
538
- var path = __require("path");
539
- var colors = require_picocolors();
540
- var childProcess = __require("child_process");
541
- var guessEditor = require_guess();
542
- var getArgumentsForPosition = require_get_args();
398
+ var fs = __require("fs"), os = __require("os"), path = __require("path"), colors = require_picocolors(), childProcess = __require("child_process"), guessEditor = require_guess(), getArgumentsForPosition = require_get_args();
543
399
  function wrapErrorCallback(cb) {
544
400
  return (fileName, errorMessage) => {
545
- console.log();
546
- console.log(
401
+ console.log(), console.log(
547
402
  colors.red("Could not open " + path.basename(fileName) + " in the editor.")
548
- );
549
- if (errorMessage) {
550
- if (errorMessage[errorMessage.length - 1] !== ".") {
551
- errorMessage += ".";
552
- }
553
- console.log(
554
- colors.red("The editor process exited with an error: " + errorMessage)
555
- );
556
- }
557
- console.log();
558
- if (cb) cb(fileName, errorMessage);
403
+ ), errorMessage && (errorMessage[errorMessage.length - 1] !== "." && (errorMessage += "."), console.log(
404
+ colors.red("The editor process exited with an error: " + errorMessage)
405
+ )), console.log(), cb && cb(fileName, errorMessage);
559
406
  };
560
407
  }
561
- __name(wrapErrorCallback, "wrapErrorCallback");
562
408
  function isTerminalEditor(editor) {
563
409
  switch (editor) {
564
410
  case "vim":
565
411
  case "emacs":
566
412
  case "nano":
567
- return true;
413
+ return !0;
568
414
  }
569
- return false;
415
+ return !1;
570
416
  }
571
- __name(isTerminalEditor, "isTerminalEditor");
572
417
  var positionRE = /:(\d+)(:(\d+))?$/;
573
418
  function parseFile(file) {
574
- if (file.startsWith("file://")) {
575
- file = __require("url").fileURLToPath(file);
576
- }
577
- const fileName = file.replace(positionRE, "");
578
- const match = file.match(positionRE);
579
- const lineNumber = match && match[1];
580
- const columnNumber = match && match[3];
419
+ file.startsWith("file://") && (file = __require("url").fileURLToPath(file));
420
+ let fileName = file.replace(positionRE, ""), match = file.match(positionRE), lineNumber = match && match[1], columnNumber = match && match[3];
581
421
  return {
582
422
  fileName,
583
423
  lineNumber,
584
424
  columnNumber
585
425
  };
586
426
  }
587
- __name(parseFile, "parseFile");
588
427
  var _childProcess = null;
589
428
  function launchEditor(file, specifiedEditor, onErrorCallback) {
590
- const parsed = parseFile(file);
591
- let { fileName } = parsed;
592
- const { lineNumber, columnNumber } = parsed;
593
- if (!fs.existsSync(fileName)) {
429
+ let parsed = parseFile(file), { fileName } = parsed, { lineNumber, columnNumber } = parsed;
430
+ if (!fs.existsSync(fileName))
594
431
  return;
595
- }
596
- if (typeof specifiedEditor === "function") {
597
- onErrorCallback = specifiedEditor;
598
- specifiedEditor = void 0;
599
- }
600
- onErrorCallback = wrapErrorCallback(onErrorCallback);
601
- const [editor, ...args] = guessEditor(specifiedEditor);
432
+ typeof specifiedEditor == "function" && (onErrorCallback = specifiedEditor, specifiedEditor = void 0), onErrorCallback = wrapErrorCallback(onErrorCallback);
433
+ let [editor, ...args] = guessEditor(specifiedEditor);
602
434
  if (!editor) {
603
435
  onErrorCallback(fileName, null);
604
436
  return;
605
437
  }
606
- if (process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release())) {
607
- fileName = path.relative("", fileName);
608
- }
609
- if (lineNumber) {
610
- const extraArgs = getArgumentsForPosition(editor, fileName, lineNumber, columnNumber);
438
+ if (process.platform === "linux" && fileName.startsWith("/mnt/") && /Microsoft/i.test(os.release()) && (fileName = path.relative("", fileName)), lineNumber) {
439
+ let extraArgs = getArgumentsForPosition(editor, fileName, lineNumber, columnNumber);
611
440
  args.push.apply(args, extraArgs);
612
- } else {
441
+ } else
613
442
  args.push(fileName);
614
- }
615
- if (_childProcess && isTerminalEditor(editor)) {
616
- _childProcess.kill("SIGKILL");
617
- }
618
- if (process.platform === "win32") {
443
+ if (_childProcess && isTerminalEditor(editor) && _childProcess.kill("SIGKILL"), process.platform === "win32") {
619
444
  let escapeCmdArgs2 = function(cmdArgs) {
620
445
  return cmdArgs.replace(/([&|<>,;=^])/g, "^$1");
621
446
  }, doubleQuoteIfNeeded2 = function(str) {
622
- if (str.includes("^")) {
623
- return `^"${str}^"`;
624
- } else if (str.includes(" ")) {
625
- return `"${str}"`;
626
- }
627
- return str;
447
+ return str.includes("^") ? `^"${str}^"` : str.includes(" ") ? `"${str}"` : str;
628
448
  };
629
449
  var escapeCmdArgs = escapeCmdArgs2, doubleQuoteIfNeeded = doubleQuoteIfNeeded2;
630
- __name(escapeCmdArgs2, "escapeCmdArgs");
631
- __name(doubleQuoteIfNeeded2, "doubleQuoteIfNeeded");
632
- const launchCommand = [editor, ...args.map(escapeCmdArgs2)].map(doubleQuoteIfNeeded2).join(" ");
450
+ let launchCommand = [editor, ...args.map(escapeCmdArgs2)].map(doubleQuoteIfNeeded2).join(" ");
633
451
  _childProcess = childProcess.exec(launchCommand, {
634
452
  stdio: "inherit",
635
- shell: true
453
+ shell: !0
636
454
  });
637
- } else {
455
+ } else
638
456
  _childProcess = childProcess.spawn(editor, args, { stdio: "inherit" });
639
- }
640
457
  _childProcess.on("exit", function(errorCode) {
641
- _childProcess = null;
642
- if (errorCode) {
643
- onErrorCallback(fileName, "(code " + errorCode + ")");
644
- }
645
- });
646
- _childProcess.on("error", function(error) {
458
+ _childProcess = null, errorCode && onErrorCallback(fileName, "(code " + errorCode + ")");
459
+ }), _childProcess.on("error", function(error) {
647
460
  let { code, message } = error;
648
- if ("ENOENT" === code) {
649
- message = `${message} ('${editor}' command does not exist in 'PATH')`;
650
- }
651
- onErrorCallback(fileName, message);
461
+ code === "ENOENT" && (message = `${message} ('${editor}' command does not exist in 'PATH')`), onErrorCallback(fileName, message);
652
462
  });
653
463
  }
654
- __name(launchEditor, "launchEditor");
655
464
  module.exports = launchEditor;
656
465
  }
657
466
  });
@@ -702,20 +511,13 @@ import { isCsfFactoryPreview } from "storybook/internal/csf-tools";
702
511
  var import_ts_dedent = __toESM(require_dist(), 1);
703
512
 
704
513
  // src/core-server/utils/get-component-variable-name.ts
705
- var getComponentVariableName = /* @__PURE__ */ __name(async (name) => {
706
- const camelCase = await import("../../_node-chunks/camelcase-QALD4XFE.js");
707
- const camelCased = camelCase.default(name.replace(/^[^a-zA-Z_$]*/, ""), { pascalCase: true });
708
- const sanitized = camelCased.replace(/[^a-zA-Z_$]+/, "");
709
- return sanitized;
710
- }, "getComponentVariableName");
514
+ var getComponentVariableName = async (name) => (await import("../../_node-chunks/camelcase-JREIL7NV.js")).default(name.replace(/^[^a-zA-Z_$]*/, ""), { pascalCase: !0 }).replace(/[^a-zA-Z_$]+/, "");
711
515
 
712
516
  // src/core-server/utils/new-story-templates/csf-factory-template.ts
713
517
  async function getCsfFactoryTemplateForNewStoryFile(data) {
714
- const importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName;
715
- const importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
716
- const previewImport = `import preview from '#.storybook/preview';`;
518
+ let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
717
519
  return import_ts_dedent.dedent`
718
- ${previewImport}
520
+ ${"import preview from '#.storybook/preview';"}
719
521
 
720
522
  ${importStatement}
721
523
 
@@ -726,13 +528,11 @@ async function getCsfFactoryTemplateForNewStoryFile(data) {
726
528
  export const ${data.exportedStoryName} = meta.story({});
727
529
  `;
728
530
  }
729
- __name(getCsfFactoryTemplateForNewStoryFile, "getCsfFactoryTemplateForNewStoryFile");
730
531
 
731
532
  // src/core-server/utils/new-story-templates/javascript.ts
732
533
  var import_ts_dedent2 = __toESM(require_dist(), 1);
733
534
  async function getJavaScriptTemplateForNewStoryFile(data) {
734
- const importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName;
735
- const importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
535
+ let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}';` : `import { ${importName} } from './${data.basenameWithoutExtension}';`;
736
536
  return import_ts_dedent2.dedent`
737
537
  ${importStatement}
738
538
 
@@ -745,13 +545,11 @@ async function getJavaScriptTemplateForNewStoryFile(data) {
745
545
  export const ${data.exportedStoryName} = {};
746
546
  `;
747
547
  }
748
- __name(getJavaScriptTemplateForNewStoryFile, "getJavaScriptTemplateForNewStoryFile");
749
548
 
750
549
  // src/core-server/utils/new-story-templates/typescript.ts
751
550
  var import_ts_dedent3 = __toESM(require_dist(), 1);
752
551
  async function getTypeScriptTemplateForNewStoryFile(data) {
753
- const importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName;
754
- const importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}'` : `import { ${importName} } from './${data.basenameWithoutExtension}'`;
552
+ let importName = data.componentIsDefaultExport ? await getComponentVariableName(data.basenameWithoutExtension) : data.componentExportName, importStatement = data.componentIsDefaultExport ? `import ${importName} from './${data.basenameWithoutExtension}'` : `import { ${importName} } from './${data.basenameWithoutExtension}'`;
755
553
  return import_ts_dedent3.dedent`
756
554
  import type { Meta, StoryObj } from '${data.frameworkPackage}';
757
555
 
@@ -768,7 +566,6 @@ async function getTypeScriptTemplateForNewStoryFile(data) {
768
566
  export const ${data.exportedStoryName}: Story = {};
769
567
  `;
770
568
  }
771
- __name(getTypeScriptTemplateForNewStoryFile, "getTypeScriptTemplateForNewStoryFile");
772
569
 
773
570
  // src/core-server/utils/get-new-story-file.ts
774
571
  async function getNewStoryFile({
@@ -777,100 +574,70 @@ async function getNewStoryFile({
777
574
  componentIsDefaultExport,
778
575
  componentExportCount
779
576
  }, options) {
780
- const frameworkPackageName = await getFrameworkName(options);
781
- const sanitizedFrameworkPackageName = extractProperFrameworkName(frameworkPackageName);
782
- const base = basename(componentFilePath);
783
- const extension = extname(componentFilePath);
784
- const basenameWithoutExtension = base.replace(extension, "");
785
- const dir = dirname(componentFilePath);
786
- const { storyFileName, isTypescript, storyFileExtension } = getStoryMetadata(componentFilePath);
787
- const storyFileNameWithExtension = `${storyFileName}.${storyFileExtension}`;
788
- const alternativeStoryFileNameWithExtension = `${basenameWithoutExtension}.${componentExportName}.stories.${storyFileExtension}`;
789
- const exportedStoryName = "Default";
790
- let useCsfFactory = false;
577
+ let frameworkPackageName = await getFrameworkName(options), sanitizedFrameworkPackageName = extractProperFrameworkName(frameworkPackageName), base = basename(componentFilePath), extension = extname(componentFilePath), basenameWithoutExtension = base.replace(extension, ""), dir = dirname(componentFilePath), { storyFileName, isTypescript, storyFileExtension } = getStoryMetadata(componentFilePath), storyFileNameWithExtension = `${storyFileName}.${storyFileExtension}`, alternativeStoryFileNameWithExtension = `${basenameWithoutExtension}.${componentExportName}.stories.${storyFileExtension}`, exportedStoryName = "Default", useCsfFactory = !1;
791
578
  try {
792
- const previewConfig = findConfigFile("preview", options.configDir);
579
+ let previewConfig = findConfigFile("preview", options.configDir);
793
580
  if (previewConfig) {
794
- const previewContent = await readFile(previewConfig, "utf-8");
581
+ let previewContent = await readFile(previewConfig, "utf-8");
795
582
  useCsfFactory = isCsfFactoryPreview(loadConfig(previewContent));
796
583
  }
797
- } catch (err) {
584
+ } catch {
798
585
  }
799
586
  let storyFileContent = "";
800
- if (useCsfFactory) {
801
- storyFileContent = await getCsfFactoryTemplateForNewStoryFile({
802
- basenameWithoutExtension,
803
- componentExportName,
804
- componentIsDefaultExport,
805
- exportedStoryName
806
- });
807
- } else {
808
- storyFileContent = isTypescript && frameworkPackageName ? await getTypeScriptTemplateForNewStoryFile({
809
- basenameWithoutExtension,
810
- componentExportName,
811
- componentIsDefaultExport,
812
- frameworkPackage: sanitizedFrameworkPackageName,
813
- exportedStoryName
814
- }) : await getJavaScriptTemplateForNewStoryFile({
815
- basenameWithoutExtension,
816
- componentExportName,
817
- componentIsDefaultExport,
818
- exportedStoryName
819
- });
820
- }
821
- const storyFilePath = doesStoryFileExist(join2(getProjectRoot(), dir), storyFileName) && componentExportCount > 1 ? join2(getProjectRoot(), dir, alternativeStoryFileNameWithExtension) : join2(getProjectRoot(), dir, storyFileNameWithExtension);
822
- return { storyFilePath, exportedStoryName, storyFileContent, dirname };
587
+ return useCsfFactory ? storyFileContent = await getCsfFactoryTemplateForNewStoryFile({
588
+ basenameWithoutExtension,
589
+ componentExportName,
590
+ componentIsDefaultExport,
591
+ exportedStoryName
592
+ }) : storyFileContent = isTypescript && frameworkPackageName ? await getTypeScriptTemplateForNewStoryFile({
593
+ basenameWithoutExtension,
594
+ componentExportName,
595
+ componentIsDefaultExport,
596
+ frameworkPackage: sanitizedFrameworkPackageName,
597
+ exportedStoryName
598
+ }) : await getJavaScriptTemplateForNewStoryFile({
599
+ basenameWithoutExtension,
600
+ componentExportName,
601
+ componentIsDefaultExport,
602
+ exportedStoryName
603
+ }), { storyFilePath: doesStoryFileExist(join2(getProjectRoot(), dir), storyFileName) && componentExportCount > 1 ? join2(getProjectRoot(), dir, alternativeStoryFileNameWithExtension) : join2(getProjectRoot(), dir, storyFileNameWithExtension), exportedStoryName, storyFileContent, dirname };
823
604
  }
824
- __name(getNewStoryFile, "getNewStoryFile");
825
- var getStoryMetadata = /* @__PURE__ */ __name((componentFilePath) => {
826
- const isTypescript = /\.(ts|tsx|mts|cts)$/.test(componentFilePath);
827
- const base = basename(componentFilePath);
828
- const extension = extname(componentFilePath);
829
- const basenameWithoutExtension = base.replace(extension, "");
830
- const storyFileExtension = isTypescript ? "tsx" : "jsx";
605
+ var getStoryMetadata = (componentFilePath) => {
606
+ let isTypescript = /\.(ts|tsx|mts|cts)$/.test(componentFilePath), base = basename(componentFilePath), extension = extname(componentFilePath), basenameWithoutExtension = base.replace(extension, ""), storyFileExtension = isTypescript ? "tsx" : "jsx";
831
607
  return {
832
608
  storyFileName: `${basenameWithoutExtension}.stories`,
833
609
  storyFileExtension,
834
610
  isTypescript
835
611
  };
836
- }, "getStoryMetadata");
837
- var doesStoryFileExist = /* @__PURE__ */ __name((parentFolder, storyFileName) => {
838
- return existsSync(join2(parentFolder, `${storyFileName}.ts`)) || existsSync(join2(parentFolder, `${storyFileName}.tsx`)) || existsSync(join2(parentFolder, `${storyFileName}.js`)) || existsSync(join2(parentFolder, `${storyFileName}.jsx`));
839
- }, "doesStoryFileExist");
612
+ }, doesStoryFileExist = (parentFolder, storyFileName) => existsSync(join2(parentFolder, `${storyFileName}.ts`)) || existsSync(join2(parentFolder, `${storyFileName}.tsx`)) || existsSync(join2(parentFolder, `${storyFileName}.js`)) || existsSync(join2(parentFolder, `${storyFileName}.jsx`));
840
613
 
841
614
  // src/core-server/server-channel/create-new-story-channel.ts
842
615
  function initCreateNewStoryChannel(channel, options, coreOptions) {
843
- channel.on(
616
+ return channel.on(
844
617
  CREATE_NEW_STORYFILE_REQUEST,
845
618
  async (data) => {
846
619
  try {
847
- const { storyFilePath, exportedStoryName, storyFileContent } = await getNewStoryFile(
620
+ let { storyFilePath, exportedStoryName, storyFileContent } = await getNewStoryFile(
848
621
  data.payload,
849
622
  options
850
- );
851
- const relativeStoryFilePath = relative(process.cwd(), storyFilePath);
852
- const { storyId, kind } = await getStoryId({ storyFilePath, exportedStoryName }, options);
623
+ ), relativeStoryFilePath = relative(process.cwd(), storyFilePath), { storyId, kind } = await getStoryId({ storyFilePath, exportedStoryName }, options);
853
624
  if (existsSync2(storyFilePath)) {
854
625
  channel.emit(CREATE_NEW_STORYFILE_RESPONSE, {
855
- success: false,
626
+ success: !1,
856
627
  id: data.id,
857
628
  payload: {
858
629
  type: "STORY_FILE_EXISTS",
859
630
  kind
860
631
  },
861
632
  error: `A story file already exists at ${relativeStoryFilePath}`
633
+ }), coreOptions.disableTelemetry || telemetry("create-new-story-file", {
634
+ success: !1,
635
+ error: "STORY_FILE_EXISTS"
862
636
  });
863
- if (!coreOptions.disableTelemetry) {
864
- telemetry("create-new-story-file", {
865
- success: false,
866
- error: "STORY_FILE_EXISTS"
867
- });
868
- }
869
637
  return;
870
638
  }
871
- await writeFile(storyFilePath, storyFileContent, "utf-8");
872
- channel.emit(CREATE_NEW_STORYFILE_RESPONSE, {
873
- success: true,
639
+ await writeFile(storyFilePath, storyFileContent, "utf-8"), channel.emit(CREATE_NEW_STORYFILE_RESPONSE, {
640
+ success: !0,
874
641
  id: data.id,
875
642
  payload: {
876
643
  storyId,
@@ -878,30 +645,22 @@ function initCreateNewStoryChannel(channel, options, coreOptions) {
878
645
  exportedStoryName
879
646
  },
880
647
  error: null
648
+ }), coreOptions.disableTelemetry || telemetry("create-new-story-file", {
649
+ success: !0
881
650
  });
882
- if (!coreOptions.disableTelemetry) {
883
- telemetry("create-new-story-file", {
884
- success: true
885
- });
886
- }
887
651
  } catch (e) {
888
652
  channel.emit(CREATE_NEW_STORYFILE_RESPONSE, {
889
- success: false,
653
+ success: !1,
890
654
  id: data.id,
891
655
  error: e?.message
656
+ }), coreOptions.disableTelemetry || await telemetry("create-new-story-file", {
657
+ success: !1,
658
+ error: e
892
659
  });
893
- if (!coreOptions.disableTelemetry) {
894
- await telemetry("create-new-story-file", {
895
- success: false,
896
- error: e
897
- });
898
- }
899
660
  }
900
661
  }
901
- );
902
- return channel;
662
+ ), channel;
903
663
  }
904
- __name(initCreateNewStoryChannel, "initCreateNewStoryChannel");
905
664
 
906
665
  // src/core-server/server-channel/file-search-channel.ts
907
666
  import { readFile as readFile2 } from "node:fs/promises";
@@ -920,9 +679,6 @@ import { telemetry as telemetry2 } from "storybook/internal/telemetry";
920
679
  // src/core-server/utils/parser/generic-parser.ts
921
680
  import { parser, types as t } from "storybook/internal/babel";
922
681
  var GenericParser = class {
923
- static {
924
- __name(this, "GenericParser");
925
- }
926
682
  /**
927
683
  * Parse the content of a file and return the exports
928
684
  *
@@ -930,12 +686,12 @@ var GenericParser = class {
930
686
  * @returns The exports of the file
931
687
  */
932
688
  async parse(content) {
933
- const ast = parser.parse(content, {
934
- allowImportExportEverywhere: true,
935
- allowAwaitOutsideFunction: true,
936
- allowNewTargetOutsideFunction: true,
937
- allowReturnOutsideFunction: true,
938
- allowUndeclaredExports: true,
689
+ let ast = parser.parse(content, {
690
+ allowImportExportEverywhere: !0,
691
+ allowAwaitOutsideFunction: !0,
692
+ allowNewTargetOutsideFunction: !0,
693
+ allowReturnOutsideFunction: !0,
694
+ allowUndeclaredExports: !0,
939
695
  plugins: [
940
696
  // Language features
941
697
  "typescript",
@@ -979,65 +735,39 @@ var GenericParser = class {
979
735
  "sourcePhaseImports",
980
736
  "throwExpressions"
981
737
  ]
982
- });
983
- const exports = [];
984
- ast.program.body.forEach(/* @__PURE__ */ __name(function traverse3(node) {
985
- if (t.isExportNamedDeclaration(node)) {
986
- if (t.isFunctionDeclaration(node.declaration) && t.isIdentifier(node.declaration.id)) {
987
- exports.push({
988
- name: node.declaration.id.name,
989
- default: false
990
- });
991
- }
992
- if (t.isClassDeclaration(node.declaration) && t.isIdentifier(node.declaration.id)) {
993
- exports.push({
994
- name: node.declaration.id.name,
995
- default: false
996
- });
997
- }
998
- if (node.declaration === null && node.specifiers.length > 0) {
999
- node.specifiers.forEach((specifier) => {
1000
- if (t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported)) {
1001
- exports.push({
1002
- name: specifier.exported.name,
1003
- default: false
1004
- });
1005
- }
1006
- });
1007
- }
1008
- if (t.isVariableDeclaration(node.declaration)) {
1009
- node.declaration.declarations.forEach((declaration) => {
1010
- if (t.isVariableDeclarator(declaration) && t.isIdentifier(declaration.id)) {
1011
- exports.push({
1012
- name: declaration.id.name,
1013
- default: false
1014
- });
1015
- }
1016
- });
1017
- }
1018
- } else if (t.isExportDefaultDeclaration(node)) {
1019
- exports.push({
1020
- name: "default",
1021
- default: true
738
+ }), exports = [];
739
+ return ast.program.body.forEach(function(node) {
740
+ t.isExportNamedDeclaration(node) ? (t.isFunctionDeclaration(node.declaration) && t.isIdentifier(node.declaration.id) && exports.push({
741
+ name: node.declaration.id.name,
742
+ default: !1
743
+ }), t.isClassDeclaration(node.declaration) && t.isIdentifier(node.declaration.id) && exports.push({
744
+ name: node.declaration.id.name,
745
+ default: !1
746
+ }), node.declaration === null && node.specifiers.length > 0 && node.specifiers.forEach((specifier) => {
747
+ t.isExportSpecifier(specifier) && t.isIdentifier(specifier.exported) && exports.push({
748
+ name: specifier.exported.name,
749
+ default: !1
1022
750
  });
1023
- }
1024
- }, "traverse"));
1025
- return { exports };
751
+ }), t.isVariableDeclaration(node.declaration) && node.declaration.declarations.forEach((declaration) => {
752
+ t.isVariableDeclarator(declaration) && t.isIdentifier(declaration.id) && exports.push({
753
+ name: declaration.id.name,
754
+ default: !1
755
+ });
756
+ })) : t.isExportDefaultDeclaration(node) && exports.push({
757
+ name: "default",
758
+ default: !0
759
+ });
760
+ }), { exports };
1026
761
  }
1027
762
  };
1028
763
 
1029
764
  // src/core-server/utils/parser/index.ts
1030
765
  function getParser(renderer) {
1031
- switch (renderer) {
1032
- default:
1033
- return new GenericParser();
1034
- }
766
+ return new GenericParser();
1035
767
  }
1036
- __name(getParser, "getParser");
1037
768
 
1038
769
  // src/core-server/utils/search-files.ts
1039
- var FILE_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "mts", "ts", "tsx", "cts"];
1040
- var IGNORED_FILES = [
770
+ var FILE_EXTENSIONS = ["js", "mjs", "cjs", "jsx", "mts", "ts", "tsx", "cts"], IGNORED_FILES = [
1041
771
  "**/node_modules/**",
1042
772
  "**/*.spec.*",
1043
773
  "**/*.test.*",
@@ -1050,81 +780,60 @@ async function searchFiles({
1050
780
  ignoredFiles = IGNORED_FILES,
1051
781
  fileExtensions = FILE_EXTENSIONS
1052
782
  }) {
1053
- const { globby, isDynamicPattern } = await import("../../_node-chunks/globby-PBTV6PX6.js");
1054
- const hasSearchSpecialGlobChars = isDynamicPattern(searchQuery, { cwd });
1055
- const hasFileExtensionRegex = /(\.[a-z]+)$/i;
1056
- const searchQueryHasExtension = hasFileExtensionRegex.test(searchQuery);
1057
- const fileExtensionsPattern = `{${fileExtensions.join(",")}}`;
1058
- const globbedSearchQuery = hasSearchSpecialGlobChars ? searchQuery : searchQueryHasExtension ? [`**/*${searchQuery}*`, `**/*${searchQuery}*/**`] : [
783
+ let { globby, isDynamicPattern } = await import("../../_node-chunks/globby-6THB7HVX.js"), hasSearchSpecialGlobChars = isDynamicPattern(searchQuery, { cwd }), searchQueryHasExtension = /(\.[a-z]+)$/i.test(searchQuery), fileExtensionsPattern = `{${fileExtensions.join(",")}}`, globbedSearchQuery = hasSearchSpecialGlobChars ? searchQuery : searchQueryHasExtension ? [`**/*${searchQuery}*`, `**/*${searchQuery}*/**`] : [
1059
784
  `**/*${searchQuery}*.${fileExtensionsPattern}`,
1060
785
  `**/*${searchQuery}*/**/*.${fileExtensionsPattern}`
1061
786
  ];
1062
- const entries = await globby(globbedSearchQuery, {
787
+ return (await globby(globbedSearchQuery, {
1063
788
  ignore: ignoredFiles,
1064
- gitignore: true,
1065
- caseSensitiveMatch: false,
789
+ gitignore: !0,
790
+ caseSensitiveMatch: !1,
1066
791
  cwd,
1067
- objectMode: true
1068
- });
1069
- return entries.map((entry) => entry.path).filter((entry) => fileExtensions.some((ext) => entry.endsWith(`.${ext}`)));
792
+ objectMode: !0
793
+ })).map((entry) => entry.path).filter((entry) => fileExtensions.some((ext) => entry.endsWith(`.${ext}`)));
1070
794
  }
1071
- __name(searchFiles, "searchFiles");
1072
795
 
1073
796
  // src/core-server/server-channel/file-search-channel.ts
1074
797
  async function initFileSearchChannel(channel, options, coreOptions) {
1075
- channel.on(
798
+ return channel.on(
1076
799
  FILE_COMPONENT_SEARCH_REQUEST,
1077
800
  async (data) => {
1078
- const searchQuery = data.id;
801
+ let searchQuery = data.id;
1079
802
  try {
1080
- if (!searchQuery) {
803
+ if (!searchQuery)
1081
804
  return;
1082
- }
1083
- const frameworkName = await getFrameworkName2(options);
1084
- const rendererName = await extractProperRendererNameFromFramework(
805
+ let frameworkName = await getFrameworkName2(options), rendererName = await extractProperRendererNameFromFramework(
1085
806
  frameworkName
1086
- );
1087
- const files = await searchFiles({
807
+ ), entries = (await searchFiles({
1088
808
  searchQuery,
1089
809
  cwd: getProjectRoot2()
1090
- });
1091
- const entries = files.map(async (file) => {
1092
- const parser3 = getParser(rendererName);
810
+ })).map(async (file) => {
811
+ let parser3 = getParser(rendererName);
1093
812
  try {
1094
- const content = await readFile2(join3(getProjectRoot2(), file), "utf-8");
1095
- const { storyFileName } = getStoryMetadata(join3(getProjectRoot2(), file));
1096
- const dir = dirname2(file);
1097
- const storyFileExists = doesStoryFileExist(join3(getProjectRoot2(), dir), storyFileName);
1098
- const info = await parser3.parse(content);
813
+ let content = await readFile2(join3(getProjectRoot2(), file), "utf-8"), { storyFileName } = getStoryMetadata(join3(getProjectRoot2(), file)), dir = dirname2(file), storyFileExists = doesStoryFileExist(join3(getProjectRoot2(), dir), storyFileName), info = await parser3.parse(content);
1099
814
  return {
1100
815
  filepath: file,
1101
816
  exportedComponents: info.exports,
1102
817
  storyFileExists
1103
818
  };
1104
819
  } catch (e) {
1105
- if (!coreOptions.disableTelemetry) {
1106
- telemetry2("create-new-story-file-search", {
1107
- success: false,
1108
- error: `Could not parse file: ${e}`
1109
- });
1110
- }
1111
- return {
820
+ return coreOptions.disableTelemetry || telemetry2("create-new-story-file-search", {
821
+ success: !1,
822
+ error: `Could not parse file: ${e}`
823
+ }), {
1112
824
  filepath: file,
1113
- storyFileExists: false,
825
+ storyFileExists: !1,
1114
826
  exportedComponents: null
1115
827
  };
1116
828
  }
1117
829
  });
1118
- if (!coreOptions.disableTelemetry) {
1119
- telemetry2("create-new-story-file-search", {
1120
- success: true,
1121
- payload: {
1122
- fileCount: entries.length
1123
- }
1124
- });
1125
- }
1126
- channel.emit(FILE_COMPONENT_SEARCH_RESPONSE, {
1127
- success: true,
830
+ coreOptions.disableTelemetry || telemetry2("create-new-story-file-search", {
831
+ success: !0,
832
+ payload: {
833
+ fileCount: entries.length
834
+ }
835
+ }), channel.emit(FILE_COMPONENT_SEARCH_RESPONSE, {
836
+ success: !0,
1128
837
  id: searchQuery,
1129
838
  payload: {
1130
839
  files: await Promise.all(entries)
@@ -1133,104 +842,77 @@ async function initFileSearchChannel(channel, options, coreOptions) {
1133
842
  });
1134
843
  } catch (e) {
1135
844
  channel.emit(FILE_COMPONENT_SEARCH_RESPONSE, {
1136
- success: false,
845
+ success: !1,
1137
846
  id: searchQuery ?? "",
1138
847
  error: `An error occurred while searching for components in the project.
1139
848
  ${e?.message}`
849
+ }), coreOptions.disableTelemetry || telemetry2("create-new-story-file-search", {
850
+ success: !1,
851
+ error: `An error occured while searching for components: ${e}`
1140
852
  });
1141
- if (!coreOptions.disableTelemetry) {
1142
- telemetry2("create-new-story-file-search", {
1143
- success: false,
1144
- error: `An error occured while searching for components: ${e}`
1145
- });
1146
- }
1147
853
  }
1148
854
  }
1149
- );
1150
- return channel;
855
+ ), channel;
1151
856
  }
1152
- __name(initFileSearchChannel, "initFileSearchChannel");
1153
857
 
1154
858
  // src/core-server/server-channel/open-in-editor-channel.ts
1155
859
  var import_launch_editor = __toESM(require_launch_editor(), 1);
1156
860
  import { OPEN_IN_EDITOR_REQUEST, OPEN_IN_EDITOR_RESPONSE } from "storybook/internal/core-events";
1157
861
  import { telemetry as telemetry3 } from "storybook/internal/telemetry";
1158
862
  async function initOpenInEditorChannel(channel, _options, coreOptions) {
1159
- channel.on(OPEN_IN_EDITOR_REQUEST, async (payload) => {
1160
- const sendTelemetry = /* @__PURE__ */ __name((data) => {
1161
- if (!coreOptions.disableTelemetry) {
1162
- telemetry3("open-in-editor", data);
1163
- }
1164
- }, "sendTelemetry");
863
+ return channel.on(OPEN_IN_EDITOR_REQUEST, async (payload) => {
864
+ let sendTelemetry = (data) => {
865
+ coreOptions.disableTelemetry || telemetry3("open-in-editor", data);
866
+ };
1165
867
  try {
1166
- const { file: targetFile, line, column } = payload;
1167
- if (!targetFile) {
868
+ let { file: targetFile, line, column } = payload;
869
+ if (!targetFile)
1168
870
  throw new Error("No file was provided to open");
1169
- }
1170
- const location = typeof line === "number" ? `${targetFile}:${line}${typeof column === "number" ? `:${column}` : ""}` : targetFile;
871
+ let location = typeof line == "number" ? `${targetFile}:${line}${typeof column == "number" ? `:${column}` : ""}` : targetFile;
1171
872
  await new Promise((resolve, reject) => {
1172
873
  (0, import_launch_editor.default)(location, void 0, (_fileName, errorMessage) => {
1173
- if (errorMessage) {
1174
- reject(new Error(errorMessage));
1175
- } else {
1176
- resolve();
1177
- }
874
+ errorMessage ? reject(new Error(errorMessage)) : resolve();
1178
875
  });
1179
- });
1180
- channel.emit(OPEN_IN_EDITOR_RESPONSE, {
876
+ }), channel.emit(OPEN_IN_EDITOR_RESPONSE, {
1181
877
  file: targetFile,
1182
878
  line,
1183
879
  column,
1184
880
  error: null
1185
- });
1186
- sendTelemetry({ success: true });
881
+ }), sendTelemetry({ success: !0 });
1187
882
  } catch (e) {
1188
- const error = e?.message || "Failed to open in editor";
883
+ let error = e?.message || "Failed to open in editor";
1189
884
  channel.emit(OPEN_IN_EDITOR_RESPONSE, {
1190
885
  error,
1191
886
  ...payload
1192
- });
1193
- sendTelemetry({ success: false, error });
887
+ }), sendTelemetry({ success: !1, error });
1194
888
  }
1195
- });
1196
- return channel;
889
+ }), channel;
1197
890
  }
1198
- __name(initOpenInEditorChannel, "initOpenInEditorChannel");
1199
891
 
1200
892
  // src/core-server/server-channel/preview-initialized-channel.ts
1201
893
  import { PREVIEW_INITIALIZED } from "storybook/internal/core-events";
1202
894
  import { telemetry as telemetry4 } from "storybook/internal/telemetry";
1203
- var makePayload = /* @__PURE__ */ __name((userAgent, lastInit, sessionId) => {
1204
- let timeSinceInit;
1205
- const payload = {
895
+ var makePayload = (userAgent, lastInit, sessionId) => {
896
+ let payload = {
1206
897
  userAgent,
1207
- isNewUser: false,
1208
- timeSinceInit
898
+ isNewUser: !1,
899
+ timeSinceInit: void 0
1209
900
  };
1210
- if (sessionId && lastInit?.body?.sessionId === sessionId) {
1211
- payload.timeSinceInit = Date.now() - lastInit.timestamp;
1212
- payload.isNewUser = !!lastInit.body.payload.newUser;
1213
- }
1214
- return payload;
1215
- }, "makePayload");
901
+ return sessionId && lastInit?.body?.sessionId === sessionId && (payload.timeSinceInit = Date.now() - lastInit.timestamp, payload.isNewUser = !!lastInit.body.payload.newUser), payload;
902
+ };
1216
903
  function initPreviewInitializedChannel(channel, options, _coreConfig) {
1217
904
  channel.on(PREVIEW_INITIALIZED, async ({ userAgent }) => {
1218
- if (!options.disableTelemetry) {
905
+ if (!options.disableTelemetry)
1219
906
  try {
1220
- const sessionId = await getSessionId();
1221
- const lastEvents = await getLastEvents();
1222
- const lastInit = lastEvents.init;
1223
- const lastPreviewFirstLoad = lastEvents["preview-first-load"];
1224
- if (!lastPreviewFirstLoad) {
1225
- const payload = makePayload(userAgent, lastInit, sessionId);
907
+ let sessionId = await getSessionId(), lastEvents = await getLastEvents(), lastInit = lastEvents.init;
908
+ if (!lastEvents["preview-first-load"]) {
909
+ let payload = makePayload(userAgent, lastInit, sessionId);
1226
910
  telemetry4("preview-first-load", payload);
1227
911
  }
1228
- } catch (e) {
912
+ } catch {
1229
913
  }
1230
- }
1231
914
  });
1232
915
  }
1233
- __name(initPreviewInitializedChannel, "initPreviewInitializedChannel");
1234
916
 
1235
917
  // src/core-server/utils/constants.ts
1236
918
  var defaultStaticDirs = [
@@ -1238,8 +920,7 @@ var defaultStaticDirs = [
1238
920
  from: join(resolvePackageDir("storybook"), "assets/browser"),
1239
921
  to: "/sb-common-assets"
1240
922
  }
1241
- ];
1242
- var defaultFavicon = join(resolvePackageDir("storybook"), "assets/browser/favicon.svg");
923
+ ], defaultFavicon = join(resolvePackageDir("storybook"), "assets/browser/favicon.svg");
1243
924
 
1244
925
  // src/core-server/utils/save-story/save-story.ts
1245
926
  import { writeFile as writeFile2 } from "node:fs/promises";
@@ -1260,51 +941,34 @@ import { types as t2, traverse } from "storybook/internal/babel";
1260
941
 
1261
942
  // src/core-server/utils/save-story/utils.ts
1262
943
  var SaveStoryError = class extends Error {
1263
- static {
1264
- __name(this, "SaveStoryError");
1265
- }
1266
944
  };
1267
945
 
1268
946
  // src/core-server/utils/save-story/duplicate-story-with-new-name.ts
1269
- var duplicateStoryWithNewName = /* @__PURE__ */ __name((csfFile, storyName, newStoryName) => {
1270
- const node = csfFile._storyExports[storyName];
1271
- const cloned = t2.cloneNode(node);
1272
- if (!cloned) {
1273
- throw new SaveStoryError(`cannot clone Node`);
1274
- }
1275
- let found = false;
1276
- traverse(cloned, {
947
+ var duplicateStoryWithNewName = (csfFile, storyName, newStoryName) => {
948
+ let node = csfFile._storyExports[storyName], cloned = t2.cloneNode(node);
949
+ if (!cloned)
950
+ throw new SaveStoryError("cannot clone Node");
951
+ let found = !1;
952
+ if (traverse(cloned, {
1277
953
  Identifier(path) {
1278
- if (found) {
1279
- return;
1280
- }
1281
- if (path.node.name === storyName) {
1282
- found = true;
1283
- path.node.name = newStoryName;
1284
- }
954
+ found || path.node.name === storyName && (found = !0, path.node.name = newStoryName);
1285
955
  },
1286
956
  ObjectProperty(path) {
1287
- const key = path.get("key");
1288
- if (key.isIdentifier() && key.node.name === "args") {
1289
- path.remove();
1290
- }
957
+ let key = path.get("key");
958
+ key.isIdentifier() && key.node.name === "args" && path.remove();
1291
959
  },
1292
- noScope: true
1293
- });
1294
- const isCsf4Story = t2.isCallExpression(cloned.init) && t2.isMemberExpression(cloned.init.callee) && t2.isIdentifier(cloned.init.callee.property) && cloned.init.callee.property.name === "story";
1295
- if (!isCsf4Story && (t2.isArrowFunctionExpression(cloned.init) || t2.isCallExpression(cloned.init))) {
1296
- throw new SaveStoryError(`Creating a new story based on a CSF2 story is not supported`);
1297
- }
1298
- traverse(csfFile._ast, {
960
+ noScope: !0
961
+ }), !(t2.isCallExpression(cloned.init) && t2.isMemberExpression(cloned.init.callee) && t2.isIdentifier(cloned.init.callee.property) && cloned.init.callee.property.name === "story") && (t2.isArrowFunctionExpression(cloned.init) || t2.isCallExpression(cloned.init)))
962
+ throw new SaveStoryError("Creating a new story based on a CSF2 story is not supported");
963
+ return traverse(csfFile._ast, {
1299
964
  Program(path) {
1300
965
  path.pushContainer(
1301
966
  "body",
1302
967
  t2.exportNamedDeclaration(t2.variableDeclaration("const", [cloned]))
1303
968
  );
1304
969
  }
1305
- });
1306
- return cloned;
1307
- }, "duplicateStoryWithNewName");
970
+ }), cloned;
971
+ };
1308
972
 
1309
973
  // src/core-server/utils/save-story/update-args-in-csf-file.ts
1310
974
  import { types as t4, traverse as traverse2 } from "storybook/internal/babel";
@@ -1312,16 +976,14 @@ import { types as t4, traverse as traverse2 } from "storybook/internal/babel";
1312
976
  // src/core-server/utils/save-story/valueToAST.ts
1313
977
  import { parser as parser2, types as t3 } from "storybook/internal/babel";
1314
978
  function valueToAST(literal) {
1315
- if (literal === null) {
979
+ if (literal === null)
1316
980
  return t3.nullLiteral();
1317
- }
1318
981
  switch (typeof literal) {
1319
982
  case "function":
1320
- const ast = parser2.parse(literal.toString(), {
1321
- allowReturnOutsideFunction: true,
1322
- allowSuperOutsideMethod: true
1323
- });
1324
- return ast.program.body[0]?.expression;
983
+ return parser2.parse(literal.toString(), {
984
+ allowReturnOutsideFunction: !0,
985
+ allowSuperOutsideMethod: !0
986
+ }).program.body[0]?.expression;
1325
987
  case "number":
1326
988
  return t3.numericLiteral(literal);
1327
989
  case "string":
@@ -1331,65 +993,47 @@ function valueToAST(literal) {
1331
993
  case "undefined":
1332
994
  return t3.identifier("undefined");
1333
995
  default:
1334
- if (Array.isArray(literal)) {
1335
- return t3.arrayExpression(literal.map(valueToAST));
1336
- }
1337
- return t3.objectExpression(
1338
- Object.keys(literal).filter((k) => {
1339
- const value = literal[k];
1340
- return typeof value !== "undefined";
1341
- }).map((k) => {
1342
- const value = literal[k];
996
+ return Array.isArray(literal) ? t3.arrayExpression(literal.map(valueToAST)) : t3.objectExpression(
997
+ Object.keys(literal).filter((k) => typeof literal[k] < "u").map((k) => {
998
+ let value = literal[k];
1343
999
  return t3.objectProperty(t3.stringLiteral(k), valueToAST(value));
1344
1000
  })
1345
1001
  );
1346
1002
  }
1347
1003
  }
1348
- __name(valueToAST, "valueToAST");
1349
1004
 
1350
1005
  // src/core-server/utils/save-story/update-args-in-csf-file.ts
1351
- var updateArgsInCsfFile = /* @__PURE__ */ __name(async (node, input) => {
1352
- let found = false;
1353
- const args = Object.fromEntries(
1354
- Object.entries(input).map(([k, v]) => {
1355
- return [k, valueToAST(v)];
1356
- })
1006
+ var updateArgsInCsfFile = async (node, input) => {
1007
+ let found = !1, args = Object.fromEntries(
1008
+ Object.entries(input).map(([k, v]) => [k, valueToAST(v)])
1357
1009
  );
1358
- const isCsf4Story = t4.isCallExpression(node) && t4.isMemberExpression(node.callee) && t4.isIdentifier(node.callee.property) && node.callee.property.name === "story";
1359
- if (!isCsf4Story && (t4.isArrowFunctionExpression(node) || t4.isCallExpression(node))) {
1360
- throw new SaveStoryError(`Updating a CSF2 story is not supported`);
1361
- }
1010
+ if (!(t4.isCallExpression(node) && t4.isMemberExpression(node.callee) && t4.isIdentifier(node.callee.property) && node.callee.property.name === "story") && (t4.isArrowFunctionExpression(node) || t4.isCallExpression(node)))
1011
+ throw new SaveStoryError("Updating a CSF2 story is not supported");
1362
1012
  if (t4.isObjectExpression(node)) {
1363
- const properties = node.properties;
1364
- const argsProperty = properties.find((property) => {
1013
+ let properties = node.properties, argsProperty = properties.find((property) => {
1365
1014
  if (t4.isObjectProperty(property)) {
1366
- const key = property.key;
1015
+ let key = property.key;
1367
1016
  return t4.isIdentifier(key) && key.name === "args";
1368
1017
  }
1369
- return false;
1018
+ return !1;
1370
1019
  });
1371
1020
  if (argsProperty) {
1372
1021
  if (t4.isObjectProperty(argsProperty)) {
1373
- const a = argsProperty.value;
1022
+ let a = argsProperty.value;
1374
1023
  if (t4.isObjectExpression(a)) {
1375
1024
  a.properties.forEach((p) => {
1376
1025
  if (t4.isObjectProperty(p)) {
1377
- const key = p.key;
1378
- if (t4.isIdentifier(key) && key.name in args) {
1379
- p.value = args[key.name];
1380
- delete args[key.name];
1381
- }
1026
+ let key = p.key;
1027
+ t4.isIdentifier(key) && key.name in args && (p.value = args[key.name], delete args[key.name]);
1382
1028
  }
1383
1029
  });
1384
- const remainder = Object.entries(args);
1385
- if (Object.keys(args).length) {
1386
- remainder.forEach(([key, value]) => {
1387
- a.properties.push(t4.objectProperty(t4.identifier(key), value));
1388
- });
1389
- }
1030
+ let remainder = Object.entries(args);
1031
+ Object.keys(args).length && remainder.forEach(([key, value]) => {
1032
+ a.properties.push(t4.objectProperty(t4.identifier(key), value));
1033
+ });
1390
1034
  }
1391
1035
  }
1392
- } else {
1036
+ } else
1393
1037
  properties.unshift(
1394
1038
  t4.objectProperty(
1395
1039
  t4.identifier("args"),
@@ -1398,46 +1042,38 @@ var updateArgsInCsfFile = /* @__PURE__ */ __name(async (node, input) => {
1398
1042
  )
1399
1043
  )
1400
1044
  );
1401
- }
1402
1045
  return;
1403
1046
  }
1404
1047
  traverse2(node, {
1405
1048
  ObjectExpression(path) {
1406
- if (found) {
1049
+ if (found)
1407
1050
  return;
1408
- }
1409
- found = true;
1410
- const properties = path.get("properties");
1411
- const argsProperty = properties.find((property) => {
1051
+ found = !0;
1052
+ let argsProperty = path.get("properties").find((property) => {
1412
1053
  if (property.isObjectProperty()) {
1413
- const key = property.get("key");
1054
+ let key = property.get("key");
1414
1055
  return key.isIdentifier() && key.node.name === "args";
1415
1056
  }
1416
- return false;
1057
+ return !1;
1417
1058
  });
1418
1059
  if (argsProperty) {
1419
1060
  if (argsProperty.isObjectProperty()) {
1420
- const a = argsProperty.get("value");
1061
+ let a = argsProperty.get("value");
1421
1062
  if (a.isObjectExpression()) {
1422
1063
  a.traverse({
1423
1064
  ObjectProperty(p) {
1424
- const key = p.get("key");
1425
- if (key.isIdentifier() && key.node.name in args) {
1426
- p.get("value").replaceWith(args[key.node.name]);
1427
- delete args[key.node.name];
1428
- }
1065
+ let key = p.get("key");
1066
+ key.isIdentifier() && key.node.name in args && (p.get("value").replaceWith(args[key.node.name]), delete args[key.node.name]);
1429
1067
  },
1430
- noScope: true
1068
+ noScope: !0
1069
+ });
1070
+ let remainder = Object.entries(args);
1071
+ Object.keys(args).length && remainder.forEach(([key, value]) => {
1072
+ a.pushContainer("properties", t4.objectProperty(t4.identifier(key), value));
1431
1073
  });
1432
- const remainder = Object.entries(args);
1433
- if (Object.keys(args).length) {
1434
- remainder.forEach(([key, value]) => {
1435
- a.pushContainer("properties", t4.objectProperty(t4.identifier(key), value));
1436
- });
1437
- }
1438
1074
  }
1439
1075
  }
1440
- } else {
1076
+ } else
1441
1077
  path.unshiftContainer(
1442
1078
  "properties",
1443
1079
  t4.objectProperty(
@@ -1447,77 +1083,51 @@ var updateArgsInCsfFile = /* @__PURE__ */ __name(async (node, input) => {
1447
1083
  )
1448
1084
  )
1449
1085
  );
1450
- }
1451
1086
  },
1452
- noScope: true
1087
+ noScope: !0
1453
1088
  });
1454
- }, "updateArgsInCsfFile");
1089
+ };
1455
1090
 
1456
1091
  // src/core-server/utils/save-story/save-story.ts
1457
- var parseArgs = /* @__PURE__ */ __name((args) => JSON.parse(args, (_, value) => {
1458
- if (value === "__sb_empty_function_arg__") {
1459
- return () => {
1460
- };
1461
- }
1462
- return value;
1463
- }), "parseArgs");
1464
- var removeExtraNewlines = /* @__PURE__ */ __name((code, name) => {
1465
- const anything = "([\\s\\S])";
1466
- const newline = "(\\r\\n|\\r|\\n)";
1467
- const closing = newline + "};" + newline;
1468
- const regex = new RegExp(
1092
+ var parseArgs = (args) => JSON.parse(args, (_, value) => value === "__sb_empty_function_arg__" ? () => {
1093
+ } : value), removeExtraNewlines = (code, name) => {
1094
+ let anything = "([\\s\\S])", newline = "(\\r\\n|\\r|\\n)", closing = newline + "};" + newline, regex = new RegExp(
1469
1095
  // Looks for an export by the given name, considers the first closing brace on its own line
1470
1096
  // to be the end of the story definition.
1471
1097
  `^(?<before>${anything}*)(?<story>export const ${name} =${anything}+?${closing})(?<after>${anything}*)$`
1472
- );
1473
- const { before, story, after } = code.match(regex)?.groups || {};
1098
+ ), { before, story, after } = code.match(regex)?.groups || {};
1474
1099
  return story ? before + story.replaceAll(/(\r\n|\r|\n)(\r\n|\r|\n)([ \t]*[a-z0-9_]+): /gi, "$2$3:") + after : code;
1475
- }, "removeExtraNewlines");
1100
+ };
1476
1101
  function initializeSaveStory(channel, options, coreConfig) {
1477
1102
  channel.on(SAVE_STORY_REQUEST, async ({ id, payload }) => {
1478
- const { csfId, importPath, args, name } = payload;
1479
- let newStoryId;
1480
- let newStoryName;
1481
- let sourceFileName;
1482
- let sourceFilePath;
1483
- let sourceStoryName;
1103
+ let { csfId, importPath, args, name } = payload, newStoryId, newStoryName, sourceFileName, sourceFilePath, sourceStoryName;
1484
1104
  try {
1485
- sourceFileName = basename2(importPath);
1486
- sourceFilePath = join4(process.cwd(), importPath);
1487
- const csf = await readCsf(sourceFilePath, {
1488
- makeTitle: /* @__PURE__ */ __name((userTitle) => userTitle || "myTitle", "makeTitle")
1489
- });
1490
- const parsed = csf.parse();
1491
- const stories = Object.entries(parsed._stories);
1492
- const [componentId, storyId] = csfId.split("--");
1493
- newStoryName = name && storyNameFromExport(name);
1494
- newStoryId = newStoryName && toId(componentId, newStoryName);
1495
- const [storyName] = stories.find(([key, value]) => value.id.endsWith(`--${storyId}`)) || [];
1496
- if (!storyName) {
1497
- throw new SaveStoryError(`Source story not found.`);
1498
- }
1499
- if (name && csf.getStoryExport(name)) {
1500
- throw new SaveStoryError(`Story already exists.`);
1501
- }
1502
- sourceStoryName = storyNameFromExport(storyName);
1503
- await updateArgsInCsfFile(
1105
+ sourceFileName = basename2(importPath), sourceFilePath = join4(process.cwd(), importPath);
1106
+ let csf = await readCsf(sourceFilePath, {
1107
+ makeTitle: (userTitle) => userTitle || "myTitle"
1108
+ }), parsed = csf.parse(), stories = Object.entries(parsed._stories), [componentId, storyId] = csfId.split("--");
1109
+ newStoryName = name && storyNameFromExport(name), newStoryId = newStoryName && toId(componentId, newStoryName);
1110
+ let [storyName] = stories.find(([key, value]) => value.id.endsWith(`--${storyId}`)) || [];
1111
+ if (!storyName)
1112
+ throw new SaveStoryError("Source story not found.");
1113
+ if (name && csf.getStoryExport(name))
1114
+ throw new SaveStoryError("Story already exists.");
1115
+ sourceStoryName = storyNameFromExport(storyName), await updateArgsInCsfFile(
1504
1116
  name ? duplicateStoryWithNewName(parsed, storyName, name) : csf.getStoryExport(storyName),
1505
1117
  args ? parseArgs(args) : {}
1506
1118
  );
1507
- const code = await formatFileContent(
1119
+ let code = await formatFileContent(
1508
1120
  sourceFilePath,
1509
1121
  removeExtraNewlines(printCsf(csf).code, name || storyName)
1510
1122
  );
1511
1123
  await Promise.all([
1512
1124
  new Promise((resolve) => {
1513
- channel.on(STORY_RENDERED, resolve);
1514
- setTimeout(() => resolve(channel.off(STORY_RENDERED, resolve)), 3e3);
1125
+ channel.on(STORY_RENDERED, resolve), setTimeout(() => resolve(channel.off(STORY_RENDERED, resolve)), 3e3);
1515
1126
  }),
1516
1127
  writeFile2(sourceFilePath, code)
1517
- ]);
1518
- channel.emit(SAVE_STORY_RESPONSE, {
1128
+ ]), channel.emit(SAVE_STORY_RESPONSE, {
1519
1129
  id,
1520
- success: true,
1130
+ success: !0,
1521
1131
  payload: {
1522
1132
  csfId,
1523
1133
  newStoryId,
@@ -1530,34 +1140,27 @@ function initializeSaveStory(channel, options, coreConfig) {
1530
1140
  },
1531
1141
  error: null
1532
1142
  });
1533
- const isCLIExample = isExampleStoryId(newStoryId ?? csfId);
1534
- if (!coreConfig.disableTelemetry && !isCLIExample) {
1535
- await telemetry5("save-story", {
1536
- action: name ? "createStory" : "updateStory",
1537
- success: true
1538
- });
1539
- }
1143
+ let isCLIExample = isExampleStoryId(newStoryId ?? csfId);
1144
+ !coreConfig.disableTelemetry && !isCLIExample && await telemetry5("save-story", {
1145
+ action: name ? "createStory" : "updateStory",
1146
+ success: !0
1147
+ });
1540
1148
  } catch (error) {
1541
1149
  channel.emit(SAVE_STORY_RESPONSE, {
1542
1150
  id,
1543
- success: false,
1151
+ success: !1,
1544
1152
  error: error instanceof SaveStoryError ? error.message : "Unknown error"
1545
- });
1546
- logger.error(
1153
+ }), logger.error(
1547
1154
  `Error writing to ${sourceFilePath}:
1548
1155
  ${error.stack || error.message || error.toString()}`
1549
- );
1550
- if (!coreConfig.disableTelemetry && !(error instanceof SaveStoryError)) {
1551
- await telemetry5("save-story", {
1552
- action: name ? "createStory" : "updateStory",
1553
- success: false,
1554
- error
1555
- });
1556
- }
1156
+ ), !coreConfig.disableTelemetry && !(error instanceof SaveStoryError) && await telemetry5("save-story", {
1157
+ action: name ? "createStory" : "updateStory",
1158
+ success: !1,
1159
+ error
1160
+ });
1557
1161
  }
1558
1162
  });
1559
1163
  }
1560
- __name(initializeSaveStory, "initializeSaveStory");
1561
1164
 
1562
1165
  // src/core-server/utils/whats-new.ts
1563
1166
  import { writeFile as writeFile3 } from "node:fs/promises";
@@ -1572,28 +1175,18 @@ import {
1572
1175
  import { printConfig, readConfig } from "storybook/internal/csf-tools";
1573
1176
  import { logger as logger2 } from "storybook/internal/node-logger";
1574
1177
  import { telemetry as telemetry6 } from "storybook/internal/telemetry";
1575
- var WHATS_NEW_CACHE = "whats-new-cache";
1576
- var WHATS_NEW_URL = "https://storybook.js.org/whats-new/v1";
1178
+ var WHATS_NEW_CACHE = "whats-new-cache", WHATS_NEW_URL = "https://storybook.js.org/whats-new/v1";
1577
1179
  function initializeWhatsNew(channel, options, coreOptions) {
1578
1180
  channel.on(SET_WHATS_NEW_CACHE, async (data) => {
1579
- const cache = await options.cache.get(WHATS_NEW_CACHE).catch((e) => {
1580
- logger2.verbose(e);
1581
- return {};
1582
- });
1181
+ let cache = await options.cache.get(WHATS_NEW_CACHE).catch((e) => (logger2.verbose(e), {}));
1583
1182
  await options.cache.set(WHATS_NEW_CACHE, { ...cache, ...data });
1584
- });
1585
- channel.on(REQUEST_WHATS_NEW_DATA, async () => {
1183
+ }), channel.on(REQUEST_WHATS_NEW_DATA, async () => {
1586
1184
  try {
1587
- const post = await fetch(WHATS_NEW_URL).then(async (response) => {
1588
- if (response.ok) {
1185
+ let post = await fetch(WHATS_NEW_URL).then(async (response) => {
1186
+ if (response.ok)
1589
1187
  return response.json();
1590
- }
1591
1188
  throw response;
1592
- });
1593
- const main = await loadMainConfig({ configDir: options.configDir });
1594
- const disableWhatsNewNotifications = main.core?.disableWhatsNewNotifications === true;
1595
- const cache = await options.cache.get(WHATS_NEW_CACHE) ?? {};
1596
- const data = {
1189
+ }), disableWhatsNewNotifications = (await loadMainConfig({ configDir: options.configDir })).core?.disableWhatsNewNotifications === !0, cache = await options.cache.get(WHATS_NEW_CACHE) ?? {}, data = {
1597
1190
  ...post,
1598
1191
  status: "SUCCESS",
1599
1192
  postIsRead: post.url === cache.lastReadPost,
@@ -1602,96 +1195,62 @@ function initializeWhatsNew(channel, options, coreOptions) {
1602
1195
  };
1603
1196
  channel.emit(RESULT_WHATS_NEW_DATA, { data });
1604
1197
  } catch (e) {
1605
- logger2.verbose(e instanceof Error ? e.message : String(e));
1606
- channel.emit(RESULT_WHATS_NEW_DATA, {
1198
+ logger2.verbose(e instanceof Error ? e.message : String(e)), channel.emit(RESULT_WHATS_NEW_DATA, {
1607
1199
  data: { status: "ERROR" }
1608
1200
  });
1609
1201
  }
1610
- });
1611
- channel.on(
1202
+ }), channel.on(
1612
1203
  TOGGLE_WHATS_NEW_NOTIFICATIONS,
1613
1204
  async ({ disableWhatsNewNotifications }) => {
1614
- const isTelemetryEnabled = coreOptions.disableTelemetry !== true;
1205
+ let isTelemetryEnabled = coreOptions.disableTelemetry !== !0;
1615
1206
  try {
1616
- const mainPath = findConfigFile2("main", options.configDir);
1207
+ let mainPath = findConfigFile2("main", options.configDir);
1617
1208
  invariant(mainPath, `unable to find Storybook main file in ${options.configDir}`);
1618
- const main = await readConfig(mainPath);
1619
- if (!main._exportsObject) {
1209
+ let main = await readConfig(mainPath);
1210
+ if (!main._exportsObject)
1620
1211
  throw new Error(
1621
- `Unable to parse Storybook main file while trying to read 'core' property`
1212
+ "Unable to parse Storybook main file while trying to read 'core' property"
1622
1213
  );
1623
- }
1624
- main.setFieldValue(["core", "disableWhatsNewNotifications"], disableWhatsNewNotifications);
1625
- await writeFile3(mainPath, printConfig(main).code);
1626
- if (isTelemetryEnabled) {
1627
- await telemetry6("core-config", { disableWhatsNewNotifications });
1628
- }
1214
+ main.setFieldValue(["core", "disableWhatsNewNotifications"], disableWhatsNewNotifications), await writeFile3(mainPath, printConfig(main).code), isTelemetryEnabled && await telemetry6("core-config", { disableWhatsNewNotifications });
1629
1215
  } catch (error) {
1630
- invariant(error instanceof Error);
1631
- if (isTelemetryEnabled) {
1632
- await sendTelemetryError(error, "core-config", {
1633
- cliOptions: options,
1634
- presetOptions: { ...options, corePresets: [], overridePresets: [] },
1635
- skipPrompt: true
1636
- });
1637
- }
1216
+ invariant(error instanceof Error), isTelemetryEnabled && await sendTelemetryError(error, "core-config", {
1217
+ cliOptions: options,
1218
+ presetOptions: { ...options, corePresets: [], overridePresets: [] },
1219
+ skipPrompt: !0
1220
+ });
1638
1221
  }
1639
1222
  }
1640
- );
1641
- channel.on(TELEMETRY_ERROR, async (error) => {
1642
- const isTelemetryEnabled = coreOptions.disableTelemetry !== true;
1643
- if (isTelemetryEnabled) {
1644
- await sendTelemetryError(error, "browser", {
1645
- cliOptions: options,
1646
- presetOptions: { ...options, corePresets: [], overridePresets: [] },
1647
- skipPrompt: true
1648
- });
1649
- }
1223
+ ), channel.on(TELEMETRY_ERROR, async (error) => {
1224
+ coreOptions.disableTelemetry !== !0 && await sendTelemetryError(error, "browser", {
1225
+ cliOptions: options,
1226
+ presetOptions: { ...options, corePresets: [], overridePresets: [] },
1227
+ skipPrompt: !0
1228
+ });
1650
1229
  });
1651
1230
  }
1652
- __name(initializeWhatsNew, "initializeWhatsNew");
1653
1231
 
1654
1232
  // src/core-server/presets/common-preset.ts
1655
- var interpolate = /* @__PURE__ */ __name((string, data = {}) => Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, "g"), v), string), "interpolate");
1656
- var staticDirs = /* @__PURE__ */ __name(async (values = []) => [
1233
+ var interpolate = (string, data = {}) => Object.entries(data).reduce((acc, [k, v]) => acc.replace(new RegExp(`%${k}%`, "g"), v), string), staticDirs = async (values = []) => [
1657
1234
  ...defaultStaticDirs,
1658
1235
  ...values
1659
- ], "staticDirs");
1660
- var favicon = /* @__PURE__ */ __name(async (value, options) => {
1661
- if (value) {
1236
+ ], favicon = async (value, options) => {
1237
+ if (value)
1662
1238
  return value;
1663
- }
1664
- const staticDirsValue = await options.presets.apply("staticDirs");
1665
- const statics = staticDirsValue ? staticDirsValue.map((dir) => typeof dir === "string" ? dir : `${dir.from}:${dir.to}`) : [];
1666
- const faviconPaths = statics.map((dir) => {
1667
- const results = [];
1668
- const normalizedDir = staticDirsValue && !isAbsolute(dir) ? getDirectoryFromWorkingDir({
1239
+ let staticDirsValue = await options.presets.apply("staticDirs"), faviconPaths = (staticDirsValue ? staticDirsValue.map((dir) => typeof dir == "string" ? dir : `${dir.from}:${dir.to}`) : []).map((dir) => {
1240
+ let results = [], normalizedDir = staticDirsValue && !isAbsolute(dir) ? getDirectoryFromWorkingDir({
1669
1241
  configDir: options.configDir,
1670
1242
  workingDir: process.cwd(),
1671
1243
  directory: dir
1672
- }) : dir;
1673
- const { staticPath, targetEndpoint } = parseStaticDir(normalizedDir);
1674
- if (["/favicon.svg", "/favicon.ico"].includes(targetEndpoint)) {
1675
- results.push(staticPath);
1676
- }
1677
- if (targetEndpoint === "/") {
1678
- results.push(join(staticPath, "favicon.svg"));
1679
- results.push(join(staticPath, "favicon.ico"));
1680
- }
1681
- return results.filter((path) => existsSync3(path));
1244
+ }) : dir, { staticPath, targetEndpoint } = parseStaticDir(normalizedDir);
1245
+ return ["/favicon.svg", "/favicon.ico"].includes(targetEndpoint) && results.push(staticPath), targetEndpoint === "/" && (results.push(join(staticPath, "favicon.svg")), results.push(join(staticPath, "favicon.ico"))), results.filter((path) => existsSync3(path));
1682
1246
  }).reduce((l1, l2) => l1.concat(l2), []);
1683
- if (faviconPaths.length > 1) {
1684
- logger3.warn(import_ts_dedent4.dedent`
1247
+ return faviconPaths.length > 1 && logger3.warn(import_ts_dedent4.dedent`
1685
1248
  Looks like multiple favicons were detected. Using the first one.
1686
1249
 
1687
1250
  ${faviconPaths.join(", ")}
1688
- `);
1689
- }
1690
- return faviconPaths[0] || defaultFavicon;
1691
- }, "favicon");
1692
- var babel = /* @__PURE__ */ __name(async (_, options) => {
1693
- const { presets } = options;
1694
- const babelDefault = await presets.apply("babelDefault", {}, options) ?? {};
1251
+ `), faviconPaths[0] || defaultFavicon;
1252
+ }, babel = async (_, options) => {
1253
+ let { presets } = options, babelDefault = await presets.apply("babelDefault", {}, options) ?? {};
1695
1254
  return {
1696
1255
  ...babelDefault,
1697
1256
  // This override makes sure that we will never transpile babel further down then the browsers that storybook supports.
@@ -1705,7 +1264,7 @@ var babel = /* @__PURE__ */ __name(async (_, options) => {
1705
1264
  [
1706
1265
  "@babel/preset-env",
1707
1266
  {
1708
- bugfixes: true,
1267
+ bugfixes: !0,
1709
1268
  targets: {
1710
1269
  // This is the same browser supports that we use to bundle our manager and preview code.
1711
1270
  chrome: 100,
@@ -1718,124 +1277,82 @@ var babel = /* @__PURE__ */ __name(async (_, options) => {
1718
1277
  }
1719
1278
  ]
1720
1279
  };
1721
- }, "babel");
1722
- var title = /* @__PURE__ */ __name((previous, options) => previous || options.packageJson?.name || false, "title");
1723
- var logLevel = /* @__PURE__ */ __name((previous, options) => previous || options.loglevel || "info", "logLevel");
1724
- var previewHead = /* @__PURE__ */ __name(async (base, { configDir, presets }) => {
1725
- const interpolations = await presets.apply("env");
1280
+ }, title = (previous, options) => previous || options.packageJson?.name || !1, logLevel = (previous, options) => previous || options.loglevel || "info", previewHead = async (base, { configDir, presets }) => {
1281
+ let interpolations = await presets.apply("env");
1726
1282
  return getPreviewHeadTemplate(configDir, interpolations);
1727
- }, "previewHead");
1728
- var env = /* @__PURE__ */ __name(async () => {
1729
- const { raw } = await loadEnvs({ production: true });
1283
+ }, env = async () => {
1284
+ let { raw } = await loadEnvs({ production: !0 });
1730
1285
  return raw;
1731
- }, "env");
1732
- var previewBody = /* @__PURE__ */ __name(async (base, { configDir, presets }) => {
1733
- const interpolations = await presets.apply("env");
1286
+ }, previewBody = async (base, { configDir, presets }) => {
1287
+ let interpolations = await presets.apply("env");
1734
1288
  return getPreviewBodyTemplate(configDir, interpolations);
1735
- }, "previewBody");
1736
- var typescript = /* @__PURE__ */ __name(() => ({
1737
- check: false,
1289
+ }, typescript = () => ({
1290
+ check: !1,
1738
1291
  // 'react-docgen' faster than `react-docgen-typescript` but produces lower quality results
1739
1292
  reactDocgen: "react-docgen",
1740
1293
  reactDocgenTypescriptOptions: {
1741
- shouldExtractLiteralValuesFromEnum: true,
1742
- shouldRemoveUndefinedFromOptional: true,
1743
- propFilter: /* @__PURE__ */ __name((prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : true, "propFilter"),
1294
+ shouldExtractLiteralValuesFromEnum: !0,
1295
+ shouldRemoveUndefinedFromOptional: !0,
1296
+ propFilter: (prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : !0,
1744
1297
  // NOTE: this default cannot be changed
1745
- savePropValueAsString: true
1298
+ savePropValueAsString: !0
1746
1299
  }
1747
- }), "typescript");
1748
- var experimental_serverAPI = /* @__PURE__ */ __name((extension, options) => {
1749
- let removeAddon = removeAddonBase;
1750
- const packageManager = JsPackageManagerFactory.getPackageManager({
1300
+ }), experimental_serverAPI = (extension, options) => {
1301
+ let removeAddon = removeAddonBase, packageManager = JsPackageManagerFactory.getPackageManager({
1751
1302
  configDir: options.configDir
1752
1303
  });
1753
- if (!options.disableTelemetry) {
1754
- removeAddon = /* @__PURE__ */ __name(async (id, opts) => {
1755
- await telemetry7("remove", { addon: id, source: "api" });
1756
- return removeAddonBase(id, { ...opts, packageManager });
1757
- }, "removeAddon");
1758
- }
1759
- return { ...extension, removeAddon };
1760
- }, "experimental_serverAPI");
1761
- var core = /* @__PURE__ */ __name(async (existing, options) => ({
1304
+ return options.disableTelemetry || (removeAddon = async (id, opts) => (await telemetry7("remove", { addon: id, source: "api" }), removeAddonBase(id, { ...opts, packageManager }))), { ...extension, removeAddon };
1305
+ }, core = async (existing, options) => ({
1762
1306
  ...existing,
1763
- disableTelemetry: options.disableTelemetry === true,
1307
+ disableTelemetry: options.disableTelemetry === !0,
1764
1308
  enableCrashReports: options.enableCrashReports || optionalEnvToBoolean(process.env.STORYBOOK_ENABLE_CRASH_REPORTS)
1765
- }), "core");
1766
- var features = /* @__PURE__ */ __name(async (existing) => ({
1309
+ }), features = async (existing) => ({
1767
1310
  ...existing,
1768
- argTypeTargetsV7: true,
1769
- legacyDecoratorFileOrder: false,
1770
- disallowImplicitActionsInRenderV8: true,
1771
- viewport: true,
1772
- highlight: true,
1773
- controls: true,
1774
- interactions: true,
1775
- actions: true,
1776
- backgrounds: true,
1777
- outline: true,
1778
- measure: true
1779
- }), "features");
1780
- var csfIndexer = {
1311
+ argTypeTargetsV7: !0,
1312
+ legacyDecoratorFileOrder: !1,
1313
+ disallowImplicitActionsInRenderV8: !0,
1314
+ viewport: !0,
1315
+ highlight: !0,
1316
+ controls: !0,
1317
+ interactions: !0,
1318
+ actions: !0,
1319
+ backgrounds: !0,
1320
+ outline: !0,
1321
+ measure: !0
1322
+ }), csfIndexer = {
1781
1323
  test: /(stories|story)\.(m?js|ts)x?$/,
1782
- createIndex: /* @__PURE__ */ __name(async (fileName, options) => (await readCsf2(fileName, options)).parse().indexInputs, "createIndex")
1783
- };
1784
- var experimental_indexers = /* @__PURE__ */ __name((existingIndexers) => [csfIndexer].concat(existingIndexers || []), "experimental_indexers");
1785
- var frameworkOptions = /* @__PURE__ */ __name(async (_, options) => {
1786
- const config = await options.presets.apply("framework");
1787
- if (typeof config === "string") {
1788
- return {};
1789
- }
1790
- if (typeof config === "undefined") {
1791
- return null;
1792
- }
1793
- return config.options;
1794
- }, "frameworkOptions");
1795
- var managerHead = /* @__PURE__ */ __name(async (_, options) => {
1796
- const location = join(options.configDir, "manager-head.html");
1324
+ createIndex: async (fileName, options) => (await readCsf2(fileName, options)).parse().indexInputs
1325
+ }, experimental_indexers = (existingIndexers) => [csfIndexer].concat(existingIndexers || []), frameworkOptions = async (_, options) => {
1326
+ let config = await options.presets.apply("framework");
1327
+ return typeof config == "string" ? {} : typeof config > "u" ? null : config.options;
1328
+ }, managerHead = async (_, options) => {
1329
+ let location = join(options.configDir, "manager-head.html");
1797
1330
  if (existsSync3(location)) {
1798
- const contents = readFile3(location, { encoding: "utf8" });
1799
- const interpolations = options.presets.apply("env");
1331
+ let contents = readFile3(location, { encoding: "utf8" }), interpolations = options.presets.apply("env");
1800
1332
  return interpolate(await contents, await interpolations);
1801
1333
  }
1802
1334
  return "";
1803
- }, "managerHead");
1804
- var experimental_serverChannel = /* @__PURE__ */ __name(async (channel, options) => {
1805
- const coreOptions = await options.presets.apply("core");
1806
- initializeWhatsNew(channel, options, coreOptions);
1807
- initializeSaveStory(channel, options, coreOptions);
1808
- initFileSearchChannel(channel, options, coreOptions);
1809
- initCreateNewStoryChannel(channel, options, coreOptions);
1810
- initOpenInEditorChannel(channel, options, coreOptions);
1811
- initPreviewInitializedChannel(channel, options, coreOptions);
1812
- return channel;
1813
- }, "experimental_serverChannel");
1814
- var resolvedReact = /* @__PURE__ */ __name(async (existing) => {
1335
+ }, experimental_serverChannel = async (channel, options) => {
1336
+ let coreOptions = await options.presets.apply("core");
1337
+ return initializeWhatsNew(channel, options, coreOptions), initializeSaveStory(channel, options, coreOptions), initFileSearchChannel(channel, options, coreOptions), initCreateNewStoryChannel(channel, options, coreOptions), initOpenInEditorChannel(channel, options, coreOptions), initPreviewInitializedChannel(channel, options, coreOptions), channel;
1338
+ }, resolvedReact = async (existing) => {
1815
1339
  try {
1816
1340
  return {
1817
1341
  ...existing,
1818
1342
  react: resolvePackageDir("react"),
1819
1343
  reactDom: resolvePackageDir("react-dom")
1820
1344
  };
1821
- } catch (e) {
1345
+ } catch {
1822
1346
  return existing;
1823
1347
  }
1824
- }, "resolvedReact");
1825
- var managerEntries = /* @__PURE__ */ __name(async (existing) => {
1826
- return [
1827
- join(resolvePackageDir("storybook"), "dist/core-server/presets/common-manager.js"),
1828
- ...existing || []
1829
- ];
1830
- }, "managerEntries");
1831
- var viteFinal = /* @__PURE__ */ __name(async (existing, options) => {
1832
- const previewConfigPath = findConfigFile3("preview", options.configDir);
1833
- if (!previewConfigPath) {
1348
+ }, managerEntries = async (existing) => [
1349
+ join(resolvePackageDir("storybook"), "dist/core-server/presets/common-manager.js"),
1350
+ ...existing || []
1351
+ ], viteFinal = async (existing, options) => {
1352
+ let previewConfigPath = findConfigFile3("preview", options.configDir);
1353
+ if (!previewConfigPath)
1834
1354
  return existing;
1835
- }
1836
- const { viteInjectMockerRuntime } = await import("../../_node-chunks/plugin-6ZPCS4LI.js");
1837
- const { viteMockPlugin } = await import("../../_node-chunks/plugin-EOZKYZAG.js");
1838
- const coreOptions = await options.presets.apply("core");
1355
+ let { viteInjectMockerRuntime } = await import("../../_node-chunks/plugin-LTOXVT6A.js"), { viteMockPlugin } = await import("../../_node-chunks/plugin-6XMWOGPO.js"), coreOptions = await options.presets.apply("core");
1839
1356
  return {
1840
1357
  ...existing,
1841
1358
  plugins: [
@@ -1846,16 +1363,12 @@ var viteFinal = /* @__PURE__ */ __name(async (existing, options) => {
1846
1363
  ] : []
1847
1364
  ]
1848
1365
  };
1849
- }, "viteFinal");
1850
- var webpackFinal = /* @__PURE__ */ __name(async (config, options) => {
1851
- const previewConfigPath = findConfigFile3("preview", options.configDir);
1852
- if (!previewConfigPath) {
1366
+ }, webpackFinal = async (config, options) => {
1367
+ let previewConfigPath = findConfigFile3("preview", options.configDir);
1368
+ if (!previewConfigPath)
1853
1369
  return config;
1854
- }
1855
- const { WebpackMockPlugin } = await import("../../_node-chunks/webpack-mock-plugin-GT3MA5E2.js");
1856
- const { WebpackInjectMockerRuntimePlugin } = await import("../../_node-chunks/webpack-inject-mocker-runtime-plugin-35HMSMR5.js");
1857
- config.plugins = config.plugins || [];
1858
- config.module.rules.push({
1370
+ let { WebpackMockPlugin } = await import("../../_node-chunks/webpack-mock-plugin-CX5J2U56.js"), { WebpackInjectMockerRuntimePlugin } = await import("../../_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js");
1371
+ return config.plugins = config.plugins || [], config.module.rules.push({
1859
1372
  test: /preview\.(t|j)sx?$/,
1860
1373
  use: [
1861
1374
  {
@@ -1864,11 +1377,8 @@ var webpackFinal = /* @__PURE__ */ __name(async (config, options) => {
1864
1377
  )
1865
1378
  }
1866
1379
  ]
1867
- });
1868
- config.plugins.push(new WebpackMockPlugin({ previewConfigPath }));
1869
- config.plugins.push(new WebpackInjectMockerRuntimePlugin());
1870
- return config;
1871
- }, "webpackFinal");
1380
+ }), config.plugins.push(new WebpackMockPlugin({ previewConfigPath })), config.plugins.push(new WebpackInjectMockerRuntimePlugin()), config;
1381
+ };
1872
1382
  export {
1873
1383
  babel,
1874
1384
  core,