storybook 10.1.0-alpha.10 → 10.1.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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-PMPHOSM2.js} +475 -1013
  40. package/dist/_node-chunks/camelcase-K3IOOFQW.js +18 -0
  41. package/dist/_node-chunks/{chunk-X4XU27M6.js → chunk-32NE3UE3.js} +15 -24
  42. package/dist/_node-chunks/chunk-4GZCFQFG.js +58 -0
  43. package/dist/_node-chunks/chunk-5QK5MSOI.js +943 -0
  44. package/dist/_node-chunks/{chunk-VPR5IBMG.js → chunk-6ZOLETQK.js} +8 -10
  45. package/dist/_node-chunks/chunk-7I22Y76Z.js +1047 -0
  46. package/dist/_node-chunks/chunk-AKTRSR3O.js +72 -0
  47. package/dist/_node-chunks/chunk-BBOP3XCK.js +119 -0
  48. package/dist/_node-chunks/chunk-C2GQVDWI.js +34 -0
  49. package/dist/_node-chunks/{chunk-ZHSCUGNP.js → chunk-GG2WQZSG.js} +3799 -7849
  50. package/dist/_node-chunks/chunk-GQJOWVVR.js +3214 -0
  51. package/dist/_node-chunks/chunk-JCRM2YVK.js +3009 -0
  52. package/dist/_node-chunks/chunk-KK4AT5F3.js +1029 -0
  53. package/dist/_node-chunks/chunk-L7MYXJUM.js +1114 -0
  54. package/dist/_node-chunks/{chunk-F3XOPI6H.js → chunk-LCZO45L7.js} +469 -983
  55. package/dist/_node-chunks/chunk-LR3QITDI.js +209 -0
  56. package/dist/_node-chunks/chunk-LXG4DK35.js +3171 -0
  57. package/dist/_node-chunks/chunk-MJ3WOS6F.js +37 -0
  58. package/dist/_node-chunks/chunk-PHOZWZZO.js +61 -0
  59. package/dist/_node-chunks/chunk-QECOQWRJ.js +936 -0
  60. package/dist/_node-chunks/chunk-QH4V5YDB.js +20 -0
  61. package/dist/_node-chunks/chunk-R6HWGZWD.js +26 -0
  62. package/dist/_node-chunks/chunk-SPQXMU2Q.js +759 -0
  63. package/dist/_node-chunks/chunk-TXZY6V6O.js +1564 -0
  64. package/dist/_node-chunks/chunk-UGDPX5LE.js +756 -0
  65. package/dist/_node-chunks/chunk-UY26MQLT.js +603 -0
  66. package/dist/_node-chunks/chunk-WK3EMYK6.js +61 -0
  67. package/dist/_node-chunks/{chunk-OVXB5GGT.js → chunk-WLHMN7AP.js} +292 -688
  68. package/dist/_node-chunks/chunk-XGVLB4UJ.js +54 -0
  69. package/dist/_node-chunks/{chunk-RMHAL25C.js → chunk-YHRFI6BE.js} +87 -227
  70. package/dist/_node-chunks/chunk-YK4KVMFW.js +18 -0
  71. package/dist/_node-chunks/chunk-ZZALGOA6.js +4523 -0
  72. package/dist/_node-chunks/chunk-ZZPBSYA5.js +301 -0
  73. package/dist/_node-chunks/chunk-ZZSRFAC6.js +45571 -0
  74. package/dist/_node-chunks/dist-4DWOCZUD.js +121 -0
  75. package/dist/_node-chunks/globby-AAARUKEU.js +3452 -0
  76. package/dist/_node-chunks/lib-HEUKGL62.js +366 -0
  77. package/dist/_node-chunks/mdx-N42X6CFJ-DCVRPS6N.js +14329 -0
  78. package/dist/_node-chunks/p-limit-F5ZKJ6WZ.js +116 -0
  79. package/dist/_node-chunks/plugin-7YY7JXCH.js +123 -0
  80. package/dist/_node-chunks/{plugin-6ZPCS4LI.js → plugin-SZP3CW6W.js} +36 -56
  81. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-TGKNDPO6.js +46623 -0
  82. package/dist/_node-chunks/webpack-mock-plugin-LNTZZFBE.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,304 +0,0 @@
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";
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);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- require_build
14
- } from "./chunk-4ZB555EJ.js";
15
- import {
16
- resolvePackageDir
17
- } from "./chunk-V7VURIPB.js";
18
- import {
19
- require_prompts
20
- } from "./chunk-UJ5SJ23M.js";
21
- import {
22
- require_dist
23
- } from "./chunk-5OVB4A6F.js";
24
- import {
25
- require_picocolors
26
- } from "./chunk-X4XU27M6.js";
27
- import {
28
- __name,
29
- __toESM
30
- } from "./chunk-OOI74AL3.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,79 +0,0 @@
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";
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);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "./chunk-OOI74AL3.js";
15
-
16
- // ../node_modules/empathic/resolve.mjs
17
- import { createRequire } from "node:module";
18
- import { isAbsolute, join, resolve } from "node:path";
19
- import { fileURLToPath } from "node:url";
20
- function absolute(input, root) {
21
- return isAbsolute(input) ? input : resolve(root || ".", input);
22
- }
23
- __name(absolute, "absolute");
24
- function from(root, ident, silent) {
25
- try {
26
- let r = root instanceof URL || root.startsWith("file://") ? join(fileURLToPath(root), "noop.js") : join(absolute(root), "noop.js");
27
- return createRequire(r).resolve(ident);
28
- } catch (err) {
29
- if (!silent) throw err;
30
- }
31
- }
32
- __name(from, "from");
33
-
34
- // ../node_modules/empathic/walk.mjs
35
- import { dirname } from "node:path";
36
- function up(base, options) {
37
- let { last, cwd } = options || {};
38
- let tmp = absolute(base, cwd);
39
- let root = absolute(last || "/", cwd);
40
- let prev, arr = [];
41
- while (prev !== root) {
42
- arr.push(tmp);
43
- tmp = dirname(prev = tmp);
44
- if (tmp === prev) break;
45
- }
46
- return arr;
47
- }
48
- __name(up, "up");
49
-
50
- // ../node_modules/empathic/find.mjs
51
- import { join as join2 } from "node:path";
52
- import { existsSync, statSync } from "node:fs";
53
- function up2(name, options) {
54
- let dir, tmp;
55
- let start = options && options.cwd || "";
56
- for (dir of up(start, options)) {
57
- tmp = join2(dir, name);
58
- if (existsSync(tmp)) return tmp;
59
- }
60
- }
61
- __name(up2, "up");
62
- function any(names, options) {
63
- let dir, start = options && options.cwd || "";
64
- let j = 0, len = names.length, tmp;
65
- for (dir of up(start, options)) {
66
- for (j = 0; j < len; j++) {
67
- tmp = join2(dir, names[j]);
68
- if (existsSync(tmp)) return tmp;
69
- }
70
- }
71
- }
72
- __name(any, "any");
73
-
74
- export {
75
- from,
76
- up,
77
- up2,
78
- any
79
- };