storybook 10.1.0-alpha.12 → 10.1.0-alpha.14

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 (99) hide show
  1. package/dist/_browser-chunks/{chunk-74YHFU5B.js → chunk-2XZMBGTA.js} +1 -1
  2. package/dist/_browser-chunks/{chunk-EBHB6RPS.js → chunk-FQ7SLVLR.js} +6 -1
  3. package/dist/_browser-chunks/{chunk-X3DUQ5RA.js → chunk-GFY5R5EY.js} +1 -1
  4. package/dist/_browser-chunks/{chunk-WXP2XJ3O.js → chunk-P4F4UVXX.js} +1 -0
  5. package/dist/_browser-chunks/{chunk-BE2DAXKJ.js → chunk-SS2NHR7W.js} +4 -1
  6. package/dist/_browser-chunks/{syntaxhighlighter-WKBQ5RC7.js → syntaxhighlighter-IQDEPFLK.js} +1 -1
  7. package/dist/_node-chunks/{builder-manager-YUOHSIUB.js → builder-manager-FQ5J6V3U.js} +32 -22
  8. package/dist/_node-chunks/{chunk-B6JWY6PC.js → camelcase-VGUYV77Z.js} +8 -8
  9. package/dist/_node-chunks/{chunk-FZLRAH4N.js → chunk-2JR3QBT2.js} +7 -7
  10. package/dist/_node-chunks/chunk-3EBH66BB.js +23 -0
  11. package/dist/_node-chunks/{chunk-E5FJS66Z.js → chunk-4ZFHN3ZY.js} +6 -6
  12. package/dist/_node-chunks/{chunk-5HV3B5OP.js → chunk-63PL4NNE.js} +1104 -13
  13. package/dist/_node-chunks/{chunk-NAOYEL54.js → chunk-A4KENTXT.js} +7 -7
  14. package/dist/_node-chunks/{chunk-4FT2DHGE.js → chunk-ALIA3J6S.js} +44 -10
  15. package/dist/_node-chunks/{chunk-WFLWJO24.js → chunk-C2HKH2XQ.js} +5710 -2414
  16. package/dist/_node-chunks/{chunk-WA6KZQZ2.js → chunk-DQNBAQYT.js} +6 -6
  17. package/dist/_node-chunks/{chunk-JARUEMEP.js → chunk-F74UHHR6.js} +7 -7
  18. package/dist/_node-chunks/{chunk-WUXQMQCB.js → chunk-H5XWXVWR.js} +6 -6
  19. package/dist/_node-chunks/{chunk-OP3INKUD.js → chunk-JMP7YFX2.js} +6 -6
  20. package/dist/_node-chunks/{chunk-DWXTZT3D.js → chunk-JZR4DHG2.js} +19 -7
  21. package/dist/_node-chunks/{chunk-QCO2ZM7F.js → chunk-KEA7CVMZ.js} +122 -32
  22. package/dist/_node-chunks/{chunk-DUXPWBOK.js → chunk-KF3WTAEP.js} +7 -7
  23. package/dist/_node-chunks/{chunk-2D2IODUU.js → chunk-LPPM7L5D.js} +51 -71
  24. package/dist/_node-chunks/{chunk-2DMESZFJ.js → chunk-MJUDR7HQ.js} +7 -7
  25. package/dist/_node-chunks/chunk-NPB4THZQ.js +18 -0
  26. package/dist/_node-chunks/chunk-NZBK3DSJ.js +29 -0
  27. package/dist/_node-chunks/{chunk-5KLIDWFN.js → chunk-Q2QUNQK6.js} +7 -7
  28. package/dist/_node-chunks/{chunk-EZWWR7AR.js → chunk-TMCKISJR.js} +101 -118
  29. package/dist/_node-chunks/chunk-TWK7AR3U.js +6024 -0
  30. package/dist/_node-chunks/{chunk-CZ5GHJCC.js → chunk-V7CXWJXC.js} +7 -7
  31. package/dist/_node-chunks/chunk-W4F3T6CY.js +3781 -0
  32. package/dist/_node-chunks/{chunk-SEMIAAWG.js → chunk-WACDSFMO.js} +9 -9
  33. package/dist/_node-chunks/{chunk-A4APXFQ2.js → chunk-WVXZFQQU.js} +14 -8
  34. package/dist/_node-chunks/chunk-XBPE4PT7.js +78 -0
  35. package/dist/_node-chunks/chunk-YMM6BYF2.js +61 -0
  36. package/dist/_node-chunks/{chunk-XXPJ7XR3.js → chunk-ZGZKNZ5S.js} +6 -6
  37. package/dist/_node-chunks/{dist-DS2B5A3J.js → dist-DR3AP3RJ.js} +9 -9
  38. package/dist/_node-chunks/{globby-6THB7HVX.js → globby-D4FPSHY2.js} +9 -9
  39. package/dist/_node-chunks/{lib-5NKX4YGG.js → lib-ZEFOVNTK.js} +7 -7
  40. package/dist/_node-chunks/{mdx-N42X6CFJ-ZLT3QOFF.js → mdx-N42X6CFJ-PJF3ICCG.js} +8 -8
  41. package/dist/_node-chunks/{p-limit-PDMWNG7W.js → p-limit-CYQOFYPV.js} +7 -7
  42. package/dist/babel/index.js +10 -11
  43. package/dist/bin/core.js +33 -26
  44. package/dist/bin/dispatcher.js +31 -20
  45. package/dist/bin/loader.js +10 -13
  46. package/dist/cli/index.d.ts +1479 -133
  47. package/dist/cli/index.js +30 -5159
  48. package/dist/common/index.d.ts +139 -62
  49. package/dist/common/index.js +66 -51
  50. package/dist/components/index.d.ts +136 -26
  51. package/dist/components/index.js +3163 -2859
  52. package/dist/core-server/index.d.ts +3 -2
  53. package/dist/core-server/index.js +112 -1486
  54. package/dist/core-server/presets/common-manager.js +5 -5
  55. package/dist/core-server/presets/common-override-preset.js +9 -9
  56. package/dist/core-server/presets/common-preset.js +272 -81
  57. package/dist/csf/index.js +2 -2
  58. package/dist/csf-tools/index.js +9 -9
  59. package/dist/manager/globals-runtime.js +21557 -21133
  60. package/dist/manager/manager-stores.d.ts +1 -0
  61. package/dist/manager/manager-stores.js +23 -0
  62. package/dist/manager/runtime.js +6695 -720
  63. package/dist/manager-api/index.d.ts +1802 -1
  64. package/dist/manager-api/index.js +105 -11
  65. package/dist/manager-errors.d.ts +6 -0
  66. package/dist/manager-errors.js +2 -2
  67. package/dist/mocking-utils/index.d.ts +1126 -0
  68. package/dist/{_node-chunks/chunk-ZXSD6L3S.js → mocking-utils/index.js} +441 -16
  69. package/dist/node-logger/index.d.ts +192 -24
  70. package/dist/node-logger/index.js +23 -3148
  71. package/dist/preview/runtime.js +35 -3
  72. package/dist/preview-api/index.d.ts +69 -68
  73. package/dist/preview-api/index.js +2 -2
  74. package/dist/preview-errors.d.ts +6 -0
  75. package/dist/preview-errors.js +2 -2
  76. package/dist/server-errors.d.ts +31 -1
  77. package/dist/server-errors.js +17 -10
  78. package/dist/telemetry/index.d.ts +24 -3
  79. package/dist/telemetry/index.js +25 -24
  80. package/dist/types/index.d.ts +71 -8
  81. package/dist/types/index.js +25 -1
  82. package/package.json +11 -9
  83. package/dist/_node-chunks/camelcase-JREIL7NV.js +0 -18
  84. package/dist/_node-chunks/chunk-FDXFVHIL.js +0 -1114
  85. package/dist/_node-chunks/chunk-HZG65SU3.js +0 -34
  86. package/dist/_node-chunks/chunk-IXVYNBMD.js +0 -18
  87. package/dist/_node-chunks/chunk-LIH7MTP7.js +0 -3214
  88. package/dist/_node-chunks/chunk-N5GIRUP5.js +0 -1047
  89. package/dist/_node-chunks/chunk-O5DA7YLO.js +0 -3171
  90. package/dist/_node-chunks/chunk-QYQIZBS6.js +0 -26
  91. package/dist/_node-chunks/chunk-TS2UUH2J.js +0 -301
  92. package/dist/_node-chunks/chunk-Y4E6IGQF.js +0 -61
  93. package/dist/_node-chunks/chunk-ZL3AFKRX.js +0 -1029
  94. package/dist/_node-chunks/plugin-6XMWOGPO.js +0 -123
  95. package/dist/_node-chunks/plugin-LTOXVT6A.js +0 -109
  96. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-2SFE5LQS.js +0 -46582
  97. package/dist/_node-chunks/webpack-mock-plugin-CX5J2U56.js +0 -92
  98. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -32
  99. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -28
@@ -1,17 +1,17 @@
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";
1
+ import CJS_COMPAT_NODE_URL_yntchggdu3k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_yntchggdu3k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_yntchggdu3k from "node:module";
4
4
 
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);
5
+ var __filename = CJS_COMPAT_NODE_URL_yntchggdu3k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_yntchggdu3k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_yntchggdu3k.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
13
  __require
14
- } from "./chunk-OP3INKUD.js";
14
+ } from "./chunk-JMP7YFX2.js";
15
15
 
16
16
  // ../node_modules/@storybook/docs-mdx/dist/chunk-H6DQNFQR.js
17
17
  var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __require2 = ((x) => typeof __require < "u" ? __require : typeof Proxy < "u" ? new Proxy(x, {
@@ -1,47 +1,46 @@
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";
1
+ import CJS_COMPAT_NODE_URL_yntchggdu3k from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_yntchggdu3k from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_yntchggdu3k from "node:module";
4
4
 
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);
5
+ var __filename = CJS_COMPAT_NODE_URL_yntchggdu3k.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_yntchggdu3k.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_yntchggdu3k.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
13
  version
14
- } from "./chunk-IXVYNBMD.js";
14
+ } from "./chunk-NPB4THZQ.js";
15
15
  import {
16
16
  createFileSystemCache,
17
+ execa,
18
+ execaCommand,
19
+ getProjectRoot,
17
20
  resolvePathInStorybookCache,
18
21
  up
19
- } from "./chunk-WFLWJO24.js";
20
- import {
21
- globalSettings
22
- } from "./chunk-4FT2DHGE.js";
23
- import {
24
- execaCommand,
25
- getProjectRoot
26
- } from "./chunk-O5DA7YLO.js";
22
+ } from "./chunk-C2HKH2XQ.js";
27
23
  import {
28
24
  getSessionId,
29
25
  nanoid,
30
26
  set
31
- } from "./chunk-WUXQMQCB.js";
27
+ } from "./chunk-H5XWXVWR.js";
28
+ import {
29
+ globalSettings
30
+ } from "./chunk-ALIA3J6S.js";
32
31
  import {
33
32
  resolvePackageDir
34
- } from "./chunk-A4APXFQ2.js";
33
+ } from "./chunk-WVXZFQQU.js";
35
34
  import {
36
35
  slash
37
- } from "./chunk-E5FJS66Z.js";
36
+ } from "./chunk-4ZFHN3ZY.js";
38
37
  import {
39
- require_picocolors
40
- } from "./chunk-NAOYEL54.js";
38
+ require_dist
39
+ } from "./chunk-KF3WTAEP.js";
41
40
  import {
42
41
  __commonJS,
43
42
  __toESM
44
- } from "./chunk-OP3INKUD.js";
43
+ } from "./chunk-JMP7YFX2.js";
45
44
 
46
45
  // ../node_modules/fetch-retry/index.js
47
46
  var require_fetch_retry = __commonJS({
@@ -133,15 +132,16 @@ var require_fetch_retry = __commonJS({
133
132
  import { logger as logger2 } from "storybook/internal/node-logger";
134
133
 
135
134
  // src/telemetry/notify.ts
136
- var import_picocolors = __toESM(require_picocolors(), 1);
135
+ var import_ts_dedent = __toESM(require_dist(), 1);
137
136
  import { cache } from "storybook/internal/common";
138
- import { CLI_COLORS, logger } from "storybook/internal/node-logger";
139
- var TELEMETRY_KEY_NOTIFY_DATE = "telemetry-notification-date", notify = async () => {
140
- await cache.get(TELEMETRY_KEY_NOTIFY_DATE, null) || (cache.set(TELEMETRY_KEY_NOTIFY_DATE, Date.now()), logger.log(
141
- `${CLI_COLORS.info("Attention:")} Storybook now collects completely anonymous telemetry regarding usage. This information is used to shape Storybook's roadmap and prioritize features.`
142
- ), logger.log(
143
- "You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:"
144
- ), logger.log(import_picocolors.default.cyan("https://storybook.js.org/telemetry")), logger.log(""));
137
+ import { logger } from "storybook/internal/node-logger";
138
+ var TELEMETRY_KEY_NOTIFY_DATE = "telemetry-notification-date", called = !1, notify = async () => {
139
+ called || (called = !0, await cache.get(TELEMETRY_KEY_NOTIFY_DATE, null) || (cache.set(TELEMETRY_KEY_NOTIFY_DATE, Date.now()), logger.info(
140
+ import_ts_dedent.dedent`
141
+ Attention: Storybook collects completely anonymous telemetry regarding usage. This information is used to shape Storybook's roadmap and prioritize features. You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
142
+ https://storybook.js.org/telemetry
143
+ `
144
+ )));
145
145
  };
146
146
 
147
147
  // src/telemetry/sanitize.ts
@@ -185,7 +185,7 @@ import { readFile } from "node:fs/promises";
185
185
  import { dirname } from "node:path";
186
186
  import {
187
187
  getStorybookConfiguration,
188
- getStorybookInfo,
188
+ getStorybookInfo as getStorybookInfo2,
189
189
  isCI,
190
190
  loadMainConfig,
191
191
  versions
@@ -197,8 +197,8 @@ import { sep } from "node:path";
197
197
 
198
198
  // src/telemetry/exec-command-count-lines.ts
199
199
  import { createInterface } from "node:readline";
200
- async function execCommandCountLines(command, options) {
201
- let process3 = execaCommand(command, { shell: !0, buffer: !1, ...options });
200
+ async function execCommandCountLines(command, args, options) {
201
+ let process3 = execa(command, args, { buffer: !1, ...options });
202
202
  if (!process3.stdout)
203
203
  throw new Error("Unexpected missing stdout");
204
204
  let lineCount = 0, rl = createInterface(process3.stdout);
@@ -224,11 +224,10 @@ var nameMatches = ["page", "screen"], extensions = ["js", "jsx", "ts", "tsx"], g
224
224
  match,
225
225
  [match[0].toUpperCase(), ...match.slice(1)].join("")
226
226
  ]).flatMap(
227
- (match) => extensions.map((extension) => `"${basePath}${sep}*${match}*.${extension}"`)
227
+ (match) => extensions.map((extension) => `${basePath}${sep}*${match}*.${extension}`)
228
228
  );
229
229
  try {
230
- let command = `git ls-files -- ${globs.join(" ")}`;
231
- return await execCommandCountLines(command);
230
+ return await execCommandCountLines("git", ["ls-files", "--", ...globs]);
232
231
  } catch {
233
232
  return;
234
233
  }
@@ -244,86 +243,17 @@ function getChromaticVersionSpecifier(packageJson) {
244
243
  }
245
244
 
246
245
  // src/telemetry/get-framework-info.ts
247
- import { normalize } from "node:path";
248
- import { frameworkPackages } from "storybook/internal/common";
249
-
250
- // src/telemetry/package-json.ts
251
- import { fileURLToPath, pathToFileURL } from "node:url";
252
- var getActualPackageVersions = async (packages) => {
253
- let packageNames = Object.keys(packages);
254
- return Promise.all(packageNames.map(getActualPackageVersion));
255
- }, getActualPackageVersion = async (packageName) => {
256
- try {
257
- let packageJson = await getActualPackageJson(packageName);
258
- return {
259
- name: packageJson?.name || packageName,
260
- version: packageJson?.version || null
261
- };
262
- } catch {
263
- return {
264
- name: packageName,
265
- version: null
266
- };
267
- }
268
- }, getActualPackageJson = async (packageName) => {
269
- try {
270
- let resolvedPackageJsonPath = up({
271
- cwd: fileURLToPath(import.meta.resolve(packageName, process.cwd()))
272
- });
273
- resolvedPackageJsonPath || (resolvedPackageJsonPath = import.meta.resolve(`${packageName}/package.json`, process.cwd()));
274
- let { default: packageJson } = await import(pathToFileURL(resolvedPackageJsonPath).href, {
275
- with: { type: "json" }
276
- });
277
- return packageJson;
278
- } catch {
279
- return;
280
- }
281
- };
282
-
283
- // src/telemetry/get-framework-info.ts
284
- var knownRenderers = [
285
- "html",
286
- "react",
287
- "svelte",
288
- "vue3",
289
- "preact",
290
- "server",
291
- "vue",
292
- "web-components",
293
- "angular",
294
- "ember"
295
- ], knownBuilders = ["builder-webpack5", "builder-vite"];
296
- function findMatchingPackage(packageJson, suffixes) {
297
- let { name = "", version: version2, dependencies, devDependencies, peerDependencies } = packageJson, allDependencies = {
298
- // We include the framework itself because it may be a renderer too (e.g. angular)
299
- [name]: version2,
300
- ...dependencies,
301
- ...devDependencies,
302
- ...peerDependencies
303
- };
304
- return suffixes.map((suffix) => `@storybook/${suffix}`).find((pkg) => allDependencies[pkg]);
305
- }
306
- var getFrameworkPackageName = (packageNameOrPath) => {
307
- let normalizedPath = normalize(packageNameOrPath).replace(new RegExp(/\\/, "g"), "/");
308
- return Object.keys(frameworkPackages).find((pkg) => normalizedPath.endsWith(pkg)) || cleanPaths(packageNameOrPath).replace(/.*node_modules[\\/]/, "");
309
- };
310
- async function getFrameworkInfo(mainConfig) {
311
- if (!mainConfig?.framework)
312
- return {};
313
- let rawName = typeof mainConfig.framework == "string" ? mainConfig.framework : mainConfig.framework?.name;
314
- if (!rawName)
315
- return {};
316
- let frameworkPackageJson = await getActualPackageJson(rawName);
317
- if (!frameworkPackageJson)
318
- return {};
319
- let builder = findMatchingPackage(frameworkPackageJson, knownBuilders), renderer = findMatchingPackage(frameworkPackageJson, knownRenderers), sanitizedFrameworkName = getFrameworkPackageName(rawName), frameworkOptions = typeof mainConfig.framework == "object" ? mainConfig.framework.options : {};
246
+ import { getStorybookInfo } from "storybook/internal/common";
247
+ var cleanAndSanitizePath = (path3) => cleanPaths(path3).replace(/.*node_modules[\\/]/, "");
248
+ async function getFrameworkInfo(mainConfig, configDir) {
249
+ let { frameworkPackage, rendererPackage, builderPackage } = await getStorybookInfo(configDir), frameworkOptions = typeof mainConfig.framework == "object" ? mainConfig.framework.options : {};
320
250
  return {
321
251
  framework: {
322
- name: sanitizedFrameworkName,
252
+ name: frameworkPackage ? cleanAndSanitizePath(frameworkPackage) : void 0,
323
253
  options: frameworkOptions
324
254
  },
325
- builder,
326
- renderer
255
+ builder: builderPackage ? cleanAndSanitizePath(builderPackage) : void 0,
256
+ renderer: rendererPackage ? cleanAndSanitizePath(rendererPackage) : void 0
327
257
  };
328
258
  }
329
259
 
@@ -643,8 +573,12 @@ var getPackageManagerInfo = async () => {
643
573
  // src/telemetry/get-portable-stories-usage.ts
644
574
  var getPortableStoriesFileCountUncached = async (path3) => {
645
575
  try {
646
- let command = "git grep -l composeStor" + (path3 ? ` -- ${path3}` : "");
647
- return await execCommandCountLines(command);
576
+ return await execCommandCountLines("git", [
577
+ "grep",
578
+ "-l",
579
+ "composeStor",
580
+ ...path3 ? ["--", path3] : []
581
+ ]);
648
582
  } catch (err) {
649
583
  return err.exitCode === 1 ? 0 : void 0;
650
584
  }
@@ -653,6 +587,39 @@ var getPortableStoriesFileCountUncached = async (path3) => {
653
587
  async () => getPortableStoriesFileCountUncached(path3)
654
588
  );
655
589
 
590
+ // src/telemetry/package-json.ts
591
+ import { fileURLToPath, pathToFileURL } from "node:url";
592
+ var getActualPackageVersions = async (packages) => {
593
+ let packageNames = Object.keys(packages);
594
+ return Promise.all(packageNames.map(getActualPackageVersion));
595
+ }, getActualPackageVersion = async (packageName) => {
596
+ try {
597
+ let packageJson = await getActualPackageJson(packageName);
598
+ return {
599
+ name: packageJson?.name || packageName,
600
+ version: packageJson?.version || null
601
+ };
602
+ } catch {
603
+ return {
604
+ name: packageName,
605
+ version: null
606
+ };
607
+ }
608
+ }, getActualPackageJson = async (packageName) => {
609
+ try {
610
+ let resolvedPackageJsonPath = up({
611
+ cwd: fileURLToPath(import.meta.resolve(packageName, process.cwd()))
612
+ });
613
+ resolvedPackageJsonPath || (resolvedPackageJsonPath = import.meta.resolve(`${packageName}/package.json`, process.cwd()));
614
+ let { default: packageJson } = await import(pathToFileURL(resolvedPackageJsonPath).href, {
615
+ with: { type: "json" }
616
+ });
617
+ return packageJson;
618
+ } catch {
619
+ return;
620
+ }
621
+ };
622
+
656
623
  // src/telemetry/storybook-metadata.ts
657
624
  var metaFrameworks = {
658
625
  next: "Next",
@@ -729,7 +696,7 @@ var metaFrameworks = {
729
696
  language
730
697
  };
731
698
  metadata.hasCustomBabel = !!mainConfig.babel, metadata.hasCustomWebpack = !!mainConfig.webpackFinal, metadata.hasStaticDirs = !!mainConfig.staticDirs, typeof mainConfig.typescript == "object" && (metadata.typescriptOptions = mainConfig.typescript);
732
- let frameworkInfo = await getFrameworkInfo(mainConfig);
699
+ let frameworkInfo = await getFrameworkInfo(mainConfig, configDir);
733
700
  typeof mainConfig.refs == "object" && (metadata.refCount = Object.keys(mainConfig.refs).length), typeof mainConfig.features == "object" && (metadata.features = mainConfig.features);
734
701
  let addons = {};
735
702
  mainConfig.addons && mainConfig.addons.forEach((addon) => {
@@ -760,7 +727,7 @@ var metaFrameworks = {
760
727
  version: version2
761
728
  }, storybookPackages[name].version = version2 || void 0;
762
729
  });
763
- let hasStorybookEslint = !!allDependencies["eslint-plugin-storybook"], storybookInfo = await getStorybookInfo(configDir);
730
+ let hasStorybookEslint = !!allDependencies["eslint-plugin-storybook"], storybookInfo = await getStorybookInfo2(configDir);
764
731
  try {
765
732
  let { previewConfigPath: previewConfig } = storybookInfo;
766
733
  if (previewConfig) {
@@ -776,7 +743,7 @@ var metaFrameworks = {
776
743
  portableStoriesFileCount,
777
744
  applicationFileCount,
778
745
  storybookVersion: version,
779
- storybookVersionSpecifier: storybookInfo.version,
746
+ storybookVersionSpecifier: storybookInfo.version ?? "",
780
747
  language,
781
748
  storybookPackages,
782
749
  addons,
@@ -903,6 +870,22 @@ async function sendTelemetry(data, options = { retryDelay: 1e3, immediate: !1 })
903
870
  }
904
871
  }
905
872
 
873
+ // src/telemetry/error-collector.ts
874
+ var ErrorCollector = class _ErrorCollector {
875
+ constructor() {
876
+ this.errors = [];
877
+ }
878
+ static getInstance() {
879
+ return _ErrorCollector.instance || (_ErrorCollector.instance = new _ErrorCollector()), _ErrorCollector.instance;
880
+ }
881
+ static addError(error) {
882
+ this.getInstance().errors.push(error);
883
+ }
884
+ static getErrors() {
885
+ return this.getInstance().errors;
886
+ }
887
+ };
888
+
906
889
  // src/telemetry/index.ts
907
890
  var isExampleStoryId = (storyId) => storyId.startsWith("example-button--") || storyId.startsWith("example-header--") || storyId.startsWith("example-page--"), telemetry = async (eventType, payload = {}, options = {}) => {
908
891
  eventType !== "boot" && options.notify !== !1 && await notify();
@@ -916,8 +899,7 @@ var isExampleStoryId = (storyId) => storyId.startsWith("example-button--") || st
916
899
  payload.metadataErrorMessage = sanitizeError(error).message, options?.enableCrashReports && (payload.metadataError = sanitizeError(error));
917
900
  } finally {
918
901
  let { error } = payload;
919
- error && (payload.error = sanitizeError(error)), (!payload.error || options?.enableCrashReports) && (process.env?.STORYBOOK_TELEMETRY_DEBUG && (logger2.info(`
920
- [telemetry]`), logger2.info(JSON.stringify(telemetryData, null, 2))), await sendTelemetry(telemetryData, options));
902
+ error && (payload.error = sanitizeError(error)), (!payload.error || options?.enableCrashReports) && (process.env?.STORYBOOK_TELEMETRY_DEBUG && (logger2.info("[telemetry]"), logger2.info(JSON.stringify(telemetryData, null, 2))), await sendTelemetry(telemetryData, options));
921
903
  }
922
904
  };
923
905
 
@@ -931,6 +913,7 @@ export {
931
913
  getStorybookMetadata,
932
914
  oneWayHash,
933
915
  addToGlobalContext,
916
+ ErrorCollector,
934
917
  isExampleStoryId,
935
918
  telemetry
936
919
  };