storybook 10.1.0-alpha.9 → 10.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) 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-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
  5. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  6. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  7. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  8. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  9. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  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-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  15. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  16. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  17. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  18. package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
  19. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  20. package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -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-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
  26. package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
  27. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  28. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  29. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  30. package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
  31. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  32. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  33. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -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-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-SM3UWERX.js → builder-manager-BDAQHXFI.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
  41. package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
  42. package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
  43. package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
  44. package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
  45. package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
  46. package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-BG4RDXG7.js} +8 -10
  47. package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
  48. package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
  49. package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
  50. package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-D6ND3TVY.js} +116 -276
  51. package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
  52. package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-EVK2SBW5.js} +292 -688
  53. package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
  54. package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-KVRF22SH.js} +469 -983
  55. package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
  56. package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-MMVV6DGG.js} +8133 -8887
  57. package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
  58. package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
  59. package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
  60. package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
  61. package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
  62. package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
  63. package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
  64. package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
  65. package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
  66. package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
  67. package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
  68. package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-YWV55YW3.js} +15 -24
  69. package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
  70. package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
  71. package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
  73. package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
  74. package/dist/actions/decorator.js +21 -42
  75. package/dist/actions/index.js +3 -3
  76. package/dist/babel/index.d.ts +671 -335
  77. package/dist/babel/index.js +10 -11
  78. package/dist/bin/core.js +601 -1548
  79. package/dist/bin/dispatcher.js +36 -36
  80. package/dist/bin/loader.js +24 -38
  81. package/dist/channels/index.js +98 -234
  82. package/dist/cli/index.d.ts +1479 -133
  83. package/dist/cli/index.js +30 -8540
  84. package/dist/client-logger/index.js +31 -61
  85. package/dist/common/index.d.ts +139 -62
  86. package/dist/common/index.js +66 -51
  87. package/dist/components/index.d.ts +575 -273
  88. package/dist/components/index.js +14863 -4313
  89. package/dist/core-events/index.js +2 -66
  90. package/dist/core-server/index.d.ts +3 -2
  91. package/dist/core-server/index.js +2908 -8518
  92. package/dist/core-server/presets/common-manager.css +2 -2
  93. package/dist/core-server/presets/common-manager.js +2521 -5233
  94. package/dist/core-server/presets/common-override-preset.js +31 -60
  95. package/dist/core-server/presets/common-preset.js +663 -962
  96. package/dist/csf/index.js +534 -1179
  97. package/dist/csf-tools/index.js +9 -9
  98. package/dist/docs-tools/index.js +6 -6
  99. package/dist/highlight/index.js +2 -2
  100. package/dist/instrumenter/index.js +199 -415
  101. package/dist/manager/globals-runtime.js +59044 -67141
  102. package/dist/manager/globals.js +2 -3
  103. package/dist/manager/manager-stores.d.ts +1 -0
  104. package/dist/manager/manager-stores.js +23 -0
  105. package/dist/manager/runtime.js +11511 -10953
  106. package/dist/manager-api/index.d.ts +1811 -2
  107. package/dist/manager-api/index.js +1348 -2401
  108. package/dist/manager-errors.d.ts +9 -0
  109. package/dist/manager-errors.js +3 -3
  110. package/dist/mocking-utils/index.d.ts +1126 -0
  111. package/dist/mocking-utils/index.js +1181 -0
  112. package/dist/node-logger/index.d.ts +192 -24
  113. package/dist/node-logger/index.js +23 -4471
  114. package/dist/preview/globals.js +2 -3
  115. package/dist/preview/runtime.js +10799 -22393
  116. package/dist/preview-api/index.d.ts +68 -69
  117. package/dist/preview-api/index.js +13 -13
  118. package/dist/preview-errors.d.ts +9 -0
  119. package/dist/preview-errors.js +4 -4
  120. package/dist/router/index.js +347 -899
  121. package/dist/server-errors.d.ts +34 -1
  122. package/dist/server-errors.js +17 -10
  123. package/dist/telemetry/index.d.ts +24 -3
  124. package/dist/telemetry/index.js +25 -24
  125. package/dist/test/index.js +6131 -11916
  126. package/dist/theming/create.d.ts +1 -0
  127. package/dist/theming/create.js +4 -4
  128. package/dist/theming/index.d.ts +3366 -2599
  129. package/dist/theming/index.js +501 -1091
  130. package/dist/types/index.d.ts +72 -8
  131. package/dist/types/index.js +27 -12
  132. package/dist/viewport/index.js +3 -3
  133. package/package.json +26 -17
  134. package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
  135. package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
  136. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  137. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  138. package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
  139. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  140. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  141. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  142. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  143. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  144. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  145. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  146. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  147. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  148. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  149. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  150. package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
  151. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  152. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  153. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  154. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  155. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  156. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  157. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  158. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  159. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  160. package/dist/_node-chunks/camelcase-H5QSGQLK.js +0 -18
  161. package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
  162. package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
  163. package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
  164. package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
  165. package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
  166. package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
  167. package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
  168. package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
  169. package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
  170. package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
  171. package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
  172. package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
  173. package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
  174. package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
  175. package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
  176. package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
  177. package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
  178. package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
  179. package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
  180. package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
  181. package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
  182. package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
  183. package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
  184. package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
  185. package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
  186. package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
  187. package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
  188. package/dist/_node-chunks/dist-SL73W244.js +0 -175
  189. package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
  190. package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
  192. package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
  193. package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
  194. package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.js +0 -124
  197. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
  198. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
@@ -1,304 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_jpweijb0qqj from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jpweijb0qqj from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jpweijb0qqj from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_jpweijb0qqj.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jpweijb0qqj.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jpweijb0qqj.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- require_build
14
- } from "./chunk-A7GS4RFT.js";
15
- import {
16
- resolvePackageDir
17
- } from "./chunk-74Z2U7QG.js";
18
- import {
19
- require_prompts
20
- } from "./chunk-WOXXODXP.js";
21
- import {
22
- require_dist
23
- } from "./chunk-45YUOLTU.js";
24
- import {
25
- require_picocolors
26
- } from "./chunk-ATDHMMIZ.js";
27
- import {
28
- __name,
29
- __toESM
30
- } from "./chunk-3THWHQOC.js";
31
-
32
- // src/core-server/utils/server-statics.ts
33
- var import_picocolors = __toESM(require_picocolors(), 1);
34
- var import_sirv = __toESM(require_build(), 1);
35
- var import_ts_dedent = __toESM(require_dist(), 1);
36
- import { existsSync, statSync } from "node:fs";
37
- import { readFile, stat } from "node:fs/promises";
38
- import { basename, isAbsolute, join, posix, resolve, sep, win32 } from "node:path";
39
- import { getDirectoryFromWorkingDir, resolvePathInStorybookCache } from "storybook/internal/common";
40
- import { logger, once } from "storybook/internal/node-logger";
41
- var cacheDir = resolvePathInStorybookCache("", "ignored-sub").split("ignored-sub")[0];
42
- var files = /* @__PURE__ */ new Map();
43
- var readFileOnce = /* @__PURE__ */ __name(async (path) => {
44
- if (files.has(path)) {
45
- return files.get(path);
46
- } else {
47
- const [data, stats] = await Promise.all([readFile(path, "utf-8"), stat(path)]);
48
- const result = { data, mtime: stats.mtimeMs };
49
- files.set(path, result);
50
- return result;
51
- }
52
- }, "readFileOnce");
53
- var faviconWrapperPath = join(
54
- resolvePackageDir("storybook"),
55
- "/assets/browser/favicon-wrapper.svg"
56
- );
57
- var prepareNestedSvg = /* @__PURE__ */ __name((svg) => {
58
- const [, openingTag, contents, closingTag] = svg?.match(/(<svg[^>]*>)(.*?)(<\/svg>)/s) ?? [];
59
- if (!openingTag || !contents || !closingTag) {
60
- return svg;
61
- }
62
- let width;
63
- let height;
64
- let modifiedTag = openingTag.replace(/width=["']([^"']*)["']/g, (_, value) => {
65
- width = parseFloat(value);
66
- return 'width="32px"';
67
- }).replace(/height=["']([^"']*)["']/g, (_, value) => {
68
- height = parseFloat(value);
69
- return 'height="32px"';
70
- });
71
- const hasViewBox = /viewBox=["'][^"']*["']/.test(modifiedTag);
72
- if (!hasViewBox && width && height) {
73
- modifiedTag = modifiedTag.replace(/>$/, ` viewBox="0 0 ${width} ${height}">`);
74
- }
75
- modifiedTag = modifiedTag.replace(/preserveAspectRatio=["'][^"']*["']/g, "").replace(/>$/, ' preserveAspectRatio="xMidYMid meet">');
76
- return modifiedTag + contents + closingTag;
77
- }, "prepareNestedSvg");
78
- async function useStatics(app, options) {
79
- const staticDirs = await options.presets.apply("staticDirs") ?? [];
80
- const faviconPath = await options.presets.apply("favicon");
81
- const faviconDir = resolve(faviconPath, "..");
82
- const faviconFile = basename(faviconPath);
83
- app.use(`/${faviconFile}`, async (req, res, next) => {
84
- const status = req.query.status;
85
- if (status && faviconFile.endsWith(".svg") && ["active", "critical", "negative", "positive", "warning"].includes(status)) {
86
- const [faviconInfo, faviconWrapperInfo] = await Promise.all([
87
- readFileOnce(join(faviconDir, faviconFile)),
88
- readFileOnce(faviconWrapperPath)
89
- ]).catch((e) => {
90
- if (e instanceof Error) {
91
- once.warn(`Failed to read favicon: ${e.message}`);
92
- }
93
- return [null, null];
94
- });
95
- if (faviconInfo && faviconWrapperInfo) {
96
- const svg = faviconWrapperInfo.data.replace('<g id="mask"', `<g mask="url(#${status}-mask)"`).replace('<use id="status"', `<use href="#${status}"`).replace('<use id="icon" />', prepareNestedSvg(faviconInfo.data));
97
- res.setHeader("Content-Type", "image/svg+xml");
98
- res.setHeader("ETag", `"${faviconWrapperInfo.mtime}-${faviconInfo.mtime}"`);
99
- res.end(svg);
100
- return;
101
- }
102
- }
103
- req.url = `/${faviconFile}`;
104
- return sirvWorkaround(faviconDir)(req, res, next);
105
- });
106
- staticDirs.map((dir) => {
107
- try {
108
- const { staticDir, staticPath, targetEndpoint } = mapStaticDir(dir, options.configDir);
109
- if (!targetEndpoint.startsWith("/sb-") && !staticDir.startsWith(cacheDir)) {
110
- logger.info(
111
- `=> Serving static files from ${import_picocolors.default.cyan(staticDir)} at ${import_picocolors.default.cyan(targetEndpoint)}`
112
- );
113
- }
114
- if (existsSync(staticPath) && statSync(staticPath).isFile()) {
115
- const staticPathDir = resolve(staticPath, "..");
116
- const staticPathFile = basename(staticPath);
117
- app.use(targetEndpoint, (req, res, next) => {
118
- req.url = `/${staticPathFile}`;
119
- sirvWorkaround(staticPathDir)(req, res, next);
120
- });
121
- } else {
122
- app.use(targetEndpoint, sirvWorkaround(staticPath));
123
- }
124
- } catch (e) {
125
- if (e instanceof Error) {
126
- logger.warn(e.message);
127
- }
128
- }
129
- });
130
- }
131
- __name(useStatics, "useStatics");
132
- var sirvWorkaround = /* @__PURE__ */ __name((dir, opts = {}) => (req, res, next) => {
133
- const originalParsedUrl = req._parsedUrl;
134
- const maybeNext = next ? () => {
135
- req._parsedUrl = originalParsedUrl;
136
- next();
137
- } : void 0;
138
- (0, import_sirv.default)(dir, { dev: true, etag: true, extensions: [], ...opts })(req, res, maybeNext);
139
- }, "sirvWorkaround");
140
- var parseStaticDir = /* @__PURE__ */ __name((arg) => {
141
- const lastColonIndex = arg.lastIndexOf(":");
142
- const isWindowsAbsolute = win32.isAbsolute(arg);
143
- const isWindowsRawDirOnly = isWindowsAbsolute && lastColonIndex === 1;
144
- const splitIndex = lastColonIndex !== -1 && !isWindowsRawDirOnly ? lastColonIndex : arg.length;
145
- const [from, to] = [arg.slice(0, splitIndex), arg.slice(splitIndex + 1)];
146
- const staticDir = isAbsolute(from) ? from : `./${from}`;
147
- const staticPath = resolve(staticDir);
148
- if (!existsSync(staticPath)) {
149
- throw new Error(
150
- import_ts_dedent.dedent`
151
- Failed to load static files, no such directory: ${import_picocolors.default.cyan(staticPath)}
152
- Make sure this directory exists.
153
- `
154
- );
155
- }
156
- const targetRaw = to || (statSync(staticPath).isFile() ? basename(staticPath) : "/");
157
- const target = targetRaw.split(sep).join(posix.sep);
158
- const targetDir = target.replace(/^\/?/, "./");
159
- const targetEndpoint = targetDir.substring(1);
160
- return { staticDir, staticPath, targetDir, targetEndpoint };
161
- }, "parseStaticDir");
162
- var mapStaticDir = /* @__PURE__ */ __name((staticDir, configDir) => {
163
- const specifier = typeof staticDir === "string" ? staticDir : `${staticDir.from}:${staticDir.to}`;
164
- const normalizedDir = isAbsolute(specifier) ? specifier : getDirectoryFromWorkingDir({ configDir, workingDir: process.cwd(), directory: specifier });
165
- return parseStaticDir(normalizedDir);
166
- }, "mapStaticDir");
167
-
168
- // src/core-server/withTelemetry.ts
169
- var import_prompts = __toESM(require_prompts(), 1);
170
- import { HandledError, cache, isCI, loadAllPresets } from "storybook/internal/common";
171
- import { logger as logger2 } from "storybook/internal/node-logger";
172
- import { getPrecedingUpgrade, oneWayHash, telemetry } from "storybook/internal/telemetry";
173
- var promptCrashReports = /* @__PURE__ */ __name(async () => {
174
- if (isCI() || !process.stdout.isTTY) {
175
- return void 0;
176
- }
177
- const { enableCrashReports } = await (0, import_prompts.default)({
178
- type: "confirm",
179
- name: "enableCrashReports",
180
- message: `Would you like to help improve Storybook by sending anonymous crash reports?`,
181
- initial: true
182
- });
183
- await cache.set("enableCrashReports", enableCrashReports);
184
- return enableCrashReports;
185
- }, "promptCrashReports");
186
- async function getErrorLevel({
187
- cliOptions,
188
- presetOptions,
189
- skipPrompt
190
- }) {
191
- if (cliOptions.disableTelemetry) {
192
- return "none";
193
- }
194
- if (!presetOptions) {
195
- return "full";
196
- }
197
- const presets = await loadAllPresets(presetOptions);
198
- const core = await presets.apply("core");
199
- if (core?.enableCrashReports !== void 0) {
200
- return core.enableCrashReports ? "full" : "error";
201
- }
202
- if (core?.disableTelemetry) {
203
- return "none";
204
- }
205
- const valueFromCache = await cache.get("enableCrashReports") ?? await cache.get("enableCrashreports");
206
- if (valueFromCache !== void 0) {
207
- return valueFromCache ? "full" : "error";
208
- }
209
- if (skipPrompt) {
210
- return "error";
211
- }
212
- const valueFromPrompt = await promptCrashReports();
213
- if (valueFromPrompt !== void 0) {
214
- return valueFromPrompt ? "full" : "error";
215
- }
216
- return "full";
217
- }
218
- __name(getErrorLevel, "getErrorLevel");
219
- async function sendTelemetryError(_error, eventType, options) {
220
- try {
221
- let errorLevel = "error";
222
- try {
223
- errorLevel = await getErrorLevel(options);
224
- } catch (err) {
225
- }
226
- if (errorLevel !== "none") {
227
- const precedingUpgrade = await getPrecedingUpgrade();
228
- const error = _error;
229
- let errorHash;
230
- if ("message" in error) {
231
- errorHash = error.message ? oneWayHash(error.message) : "EMPTY_MESSAGE";
232
- } else {
233
- errorHash = "NO_MESSAGE";
234
- }
235
- const { code, name, category } = error;
236
- await telemetry(
237
- "error",
238
- {
239
- code,
240
- name,
241
- category,
242
- eventType,
243
- precedingUpgrade,
244
- error: errorLevel === "full" ? error : void 0,
245
- errorHash,
246
- // if we ever end up sending a non-error instance, we'd like to know
247
- isErrorInstance: error instanceof Error
248
- },
249
- {
250
- immediate: true,
251
- configDir: options.cliOptions.configDir || options.presetOptions?.configDir,
252
- enableCrashReports: errorLevel === "full"
253
- }
254
- );
255
- }
256
- } catch (err) {
257
- }
258
- }
259
- __name(sendTelemetryError, "sendTelemetryError");
260
- async function withTelemetry(eventType, options, run) {
261
- const enableTelemetry = !(options.cliOptions.disableTelemetry || options.cliOptions.test === true);
262
- let canceled = false;
263
- async function cancelTelemetry() {
264
- canceled = true;
265
- if (enableTelemetry) {
266
- await telemetry("canceled", { eventType }, { stripMetadata: true, immediate: true });
267
- }
268
- process.exit(0);
269
- }
270
- __name(cancelTelemetry, "cancelTelemetry");
271
- if (eventType === "init") {
272
- process.on("SIGINT", cancelTelemetry);
273
- }
274
- if (enableTelemetry) {
275
- telemetry("boot", { eventType }, { stripMetadata: true });
276
- }
277
- try {
278
- return await run();
279
- } catch (error) {
280
- if (canceled) {
281
- return void 0;
282
- }
283
- if (!(error instanceof HandledError)) {
284
- const { printError = logger2.error } = options;
285
- printError(error);
286
- }
287
- if (enableTelemetry) {
288
- await sendTelemetryError(error, eventType, options);
289
- }
290
- throw error;
291
- } finally {
292
- process.off("SIGINT", cancelTelemetry);
293
- }
294
- }
295
- __name(withTelemetry, "withTelemetry");
296
-
297
- export {
298
- useStatics,
299
- parseStaticDir,
300
- mapStaticDir,
301
- getErrorLevel,
302
- sendTelemetryError,
303
- withTelemetry
304
- };
@@ -1,220 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_jpweijb0qqj from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jpweijb0qqj from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jpweijb0qqj from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_jpweijb0qqj.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jpweijb0qqj.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jpweijb0qqj.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "./chunk-3THWHQOC.js";
15
-
16
- // ../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
17
- var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
18
- function normalizeWindowsPath(input = "") {
19
- if (!input) {
20
- return input;
21
- }
22
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
23
- }
24
- __name(normalizeWindowsPath, "normalizeWindowsPath");
25
- var _UNC_REGEX = /^[/\\]{2}/;
26
- var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
27
- var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
28
- var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
29
- var normalize = /* @__PURE__ */ __name(function(path2) {
30
- if (path2.length === 0) {
31
- return ".";
32
- }
33
- path2 = normalizeWindowsPath(path2);
34
- const isUNCPath = path2.match(_UNC_REGEX);
35
- const isPathAbsolute = isAbsolute(path2);
36
- const trailingSeparator = path2[path2.length - 1] === "/";
37
- path2 = normalizeString(path2, !isPathAbsolute);
38
- if (path2.length === 0) {
39
- if (isPathAbsolute) {
40
- return "/";
41
- }
42
- return trailingSeparator ? "./" : ".";
43
- }
44
- if (trailingSeparator) {
45
- path2 += "/";
46
- }
47
- if (_DRIVE_LETTER_RE.test(path2)) {
48
- path2 += "/";
49
- }
50
- if (isUNCPath) {
51
- if (!isPathAbsolute) {
52
- return `//./${path2}`;
53
- }
54
- return `//${path2}`;
55
- }
56
- return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
57
- }, "normalize");
58
- var join = /* @__PURE__ */ __name(function(...arguments_) {
59
- if (arguments_.length === 0) {
60
- return ".";
61
- }
62
- let joined;
63
- for (const argument of arguments_) {
64
- if (argument && argument.length > 0) {
65
- if (joined === void 0) {
66
- joined = argument;
67
- } else {
68
- joined += `/${argument}`;
69
- }
70
- }
71
- }
72
- if (joined === void 0) {
73
- return ".";
74
- }
75
- return normalize(joined.replace(/\/\/+/g, "/"));
76
- }, "join");
77
- function cwd() {
78
- if (typeof process !== "undefined" && typeof process.cwd === "function") {
79
- return process.cwd().replace(/\\/g, "/");
80
- }
81
- return "/";
82
- }
83
- __name(cwd, "cwd");
84
- var resolve = /* @__PURE__ */ __name(function(...arguments_) {
85
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
86
- let resolvedPath = "";
87
- let resolvedAbsolute = false;
88
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
89
- const path2 = index >= 0 ? arguments_[index] : cwd();
90
- if (!path2 || path2.length === 0) {
91
- continue;
92
- }
93
- resolvedPath = `${path2}/${resolvedPath}`;
94
- resolvedAbsolute = isAbsolute(path2);
95
- }
96
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
97
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
98
- return `/${resolvedPath}`;
99
- }
100
- return resolvedPath.length > 0 ? resolvedPath : ".";
101
- }, "resolve");
102
- function normalizeString(path2, allowAboveRoot) {
103
- let res = "";
104
- let lastSegmentLength = 0;
105
- let lastSlash = -1;
106
- let dots = 0;
107
- let char = null;
108
- for (let index = 0; index <= path2.length; ++index) {
109
- if (index < path2.length) {
110
- char = path2[index];
111
- } else if (char === "/") {
112
- break;
113
- } else {
114
- char = "/";
115
- }
116
- if (char === "/") {
117
- if (lastSlash === index - 1 || dots === 1) ;
118
- else if (dots === 2) {
119
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
120
- if (res.length > 2) {
121
- const lastSlashIndex = res.lastIndexOf("/");
122
- if (lastSlashIndex === -1) {
123
- res = "";
124
- lastSegmentLength = 0;
125
- } else {
126
- res = res.slice(0, lastSlashIndex);
127
- lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
128
- }
129
- lastSlash = index;
130
- dots = 0;
131
- continue;
132
- } else if (res.length > 0) {
133
- res = "";
134
- lastSegmentLength = 0;
135
- lastSlash = index;
136
- dots = 0;
137
- continue;
138
- }
139
- }
140
- if (allowAboveRoot) {
141
- res += res.length > 0 ? "/.." : "..";
142
- lastSegmentLength = 2;
143
- }
144
- } else {
145
- if (res.length > 0) {
146
- res += `/${path2.slice(lastSlash + 1, index)}`;
147
- } else {
148
- res = path2.slice(lastSlash + 1, index);
149
- }
150
- lastSegmentLength = index - lastSlash - 1;
151
- }
152
- lastSlash = index;
153
- dots = 0;
154
- } else if (char === "." && dots !== -1) {
155
- ++dots;
156
- } else {
157
- dots = -1;
158
- }
159
- }
160
- return res;
161
- }
162
- __name(normalizeString, "normalizeString");
163
- var isAbsolute = /* @__PURE__ */ __name(function(p) {
164
- return _IS_ABSOLUTE_RE.test(p);
165
- }, "isAbsolute");
166
- var _EXTNAME_RE = /.(\.[^./]+)$/;
167
- var extname = /* @__PURE__ */ __name(function(p) {
168
- const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
169
- return match && match[1] || "";
170
- }, "extname");
171
- var relative = /* @__PURE__ */ __name(function(from, to) {
172
- const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
173
- const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
174
- if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
175
- return _to.join("/");
176
- }
177
- const _fromCopy = [..._from];
178
- for (const segment of _fromCopy) {
179
- if (_to[0] !== segment) {
180
- break;
181
- }
182
- _from.shift();
183
- _to.shift();
184
- }
185
- return [..._from.map(() => ".."), ..._to].join("/");
186
- }, "relative");
187
- var dirname = /* @__PURE__ */ __name(function(p) {
188
- const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
189
- if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
190
- segments[0] += "/";
191
- }
192
- return segments.join("/") || (isAbsolute(p) ? "/" : ".");
193
- }, "dirname");
194
- var basename = /* @__PURE__ */ __name(function(p, extension) {
195
- const lastSegment = normalizeWindowsPath(p).split("/").pop();
196
- return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
197
- }, "basename");
198
- var parse = /* @__PURE__ */ __name(function(p) {
199
- const root = normalizeWindowsPath(p).split("/").shift() || "/";
200
- const base = basename(p);
201
- const extension = extname(base);
202
- return {
203
- root,
204
- dir: dirname(p),
205
- base,
206
- ext: extension,
207
- name: base.slice(0, base.length - extension.length)
208
- };
209
- }, "parse");
210
-
211
- export {
212
- normalize,
213
- join,
214
- resolve,
215
- isAbsolute,
216
- relative,
217
- dirname,
218
- basename,
219
- parse
220
- };
@@ -1,90 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_jpweijb0qqj from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jpweijb0qqj from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jpweijb0qqj from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_jpweijb0qqj.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jpweijb0qqj.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jpweijb0qqj.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- __commonJS
14
- } from "./chunk-3THWHQOC.js";
15
-
16
- // ../node_modules/pretty-hrtime/index.js
17
- var require_pretty_hrtime = __commonJS({
18
- "../node_modules/pretty-hrtime/index.js"(exports, module) {
19
- "use strict";
20
- var minimalDesc = ["h", "min", "s", "ms", "\u03BCs", "ns"];
21
- var verboseDesc = ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"];
22
- var convert = [60 * 60, 60, 1, 1e6, 1e3, 1];
23
- module.exports = function(source, opts) {
24
- var verbose, precise, i, spot, sourceAtStep, valAtStep, decimals, strAtStep, results, totalSeconds;
25
- verbose = false;
26
- precise = false;
27
- if (opts) {
28
- verbose = opts.verbose || false;
29
- precise = opts.precise || false;
30
- }
31
- if (!Array.isArray(source) || source.length !== 2) {
32
- return "";
33
- }
34
- if (typeof source[0] !== "number" || typeof source[1] !== "number") {
35
- return "";
36
- }
37
- if (source[1] < 0) {
38
- totalSeconds = source[0] + source[1] / 1e9;
39
- source[0] = parseInt(totalSeconds);
40
- source[1] = parseFloat((totalSeconds % 1).toPrecision(9)) * 1e9;
41
- }
42
- results = "";
43
- for (i = 0; i < 6; i++) {
44
- spot = i < 3 ? 0 : 1;
45
- sourceAtStep = source[spot];
46
- if (i !== 3 && i !== 0) {
47
- sourceAtStep = sourceAtStep % convert[i - 1];
48
- }
49
- if (i === 2) {
50
- sourceAtStep += source[1] / 1e9;
51
- }
52
- valAtStep = sourceAtStep / convert[i];
53
- if (valAtStep >= 1) {
54
- if (verbose) {
55
- valAtStep = Math.floor(valAtStep);
56
- }
57
- if (!precise) {
58
- decimals = valAtStep >= 10 ? 0 : 2;
59
- strAtStep = valAtStep.toFixed(decimals);
60
- } else {
61
- strAtStep = valAtStep.toString();
62
- }
63
- if (strAtStep.indexOf(".") > -1 && strAtStep[strAtStep.length - 1] === "0") {
64
- strAtStep = strAtStep.replace(/\.?0+$/, "");
65
- }
66
- if (results) {
67
- results += " ";
68
- }
69
- results += strAtStep;
70
- if (verbose) {
71
- results += " " + verboseDesc[i];
72
- if (strAtStep !== "1") {
73
- results += "s";
74
- }
75
- } else {
76
- results += " " + minimalDesc[i];
77
- }
78
- if (!verbose) {
79
- break;
80
- }
81
- }
82
- }
83
- return results;
84
- };
85
- }
86
- });
87
-
88
- export {
89
- require_pretty_hrtime
90
- };