storybook 9.0.0-alpha.4 → 9.0.0-alpha.6

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 (40) hide show
  1. package/dist/bin/index.cjs +63 -63
  2. package/dist/bin/index.js +63 -63
  3. package/dist/builder-manager/index.cjs +253 -280
  4. package/dist/builder-manager/index.js +305 -332
  5. package/dist/cli/bin/index.cjs +1 -1
  6. package/dist/cli/bin/index.js +1 -1
  7. package/dist/common/index.cjs +63 -63
  8. package/dist/common/index.js +63 -63
  9. package/dist/components/index.cjs +2102 -2069
  10. package/dist/components/index.js +2311 -2278
  11. package/dist/core-server/index.cjs +10687 -10447
  12. package/dist/core-server/index.d.ts +55 -2
  13. package/dist/core-server/index.js +10824 -10590
  14. package/dist/core-server/presets/common-preset.cjs +59 -59
  15. package/dist/core-server/presets/common-preset.js +57 -57
  16. package/dist/instrumenter/index.cjs +2 -2
  17. package/dist/instrumenter/index.js +2 -2
  18. package/dist/manager/globals-module-info.cjs +12 -4
  19. package/dist/manager/globals-module-info.js +10 -2
  20. package/dist/manager/globals-runtime.js +19573 -19104
  21. package/dist/manager/runtime.js +3254 -3190
  22. package/dist/manager-api/index.cjs +3627 -3368
  23. package/dist/manager-api/index.d.ts +57 -18
  24. package/dist/manager-api/index.js +3182 -2962
  25. package/dist/manager-errors.d.ts +25 -1
  26. package/dist/manager-errors.js +42 -26
  27. package/dist/preview/runtime.js +8055 -7823
  28. package/dist/preview-api/index.cjs +1234 -1683
  29. package/dist/preview-api/index.d.ts +69 -376
  30. package/dist/preview-api/index.js +1360 -1785
  31. package/dist/preview-errors.cjs +98 -81
  32. package/dist/preview-errors.d.ts +25 -1
  33. package/dist/preview-errors.js +109 -93
  34. package/dist/server-errors.cjs +92 -75
  35. package/dist/server-errors.d.ts +25 -1
  36. package/dist/server-errors.js +83 -66
  37. package/dist/test/index.cjs +6697 -6432
  38. package/dist/test/index.js +6069 -5804
  39. package/dist/types/index.d.ts +27 -13
  40. package/package.json +6 -6
@@ -1,22 +1,22 @@
1
- var oe = Object.defineProperty;
2
- var t = (u, n) => oe(u, "name", { value: n, configurable: !0 });
1
+ var re = Object.defineProperty;
2
+ var t = (u, s) => re(u, "name", { value: s, configurable: !0 });
3
3
 
4
4
  // ../node_modules/ts-dedent/esm/index.js
5
- function r(u) {
6
- for (var n = [], e = 1; e < arguments.length; e++)
7
- n[e - 1] = arguments[e];
5
+ function n(u) {
6
+ for (var s = [], e = 1; e < arguments.length; e++)
7
+ s[e - 1] = arguments[e];
8
8
  var a = Array.from(typeof u == "string" ? [u] : u);
9
9
  a[a.length - 1] = a[a.length - 1].replace(/\r?\n([\t ]*)$/, "");
10
- var g = a.reduce(function(i, m) {
10
+ var p = a.reduce(function(i, m) {
11
11
  var y = m.match(/\n([\t ]+|(?!\s).)/g);
12
12
  return y ? i.concat(y.map(function(E) {
13
13
  var l, d;
14
14
  return (d = (l = E.match(/[\t ]/g)) === null || l === void 0 ? void 0 : l.length) !== null && d !== void 0 ? d : 0;
15
15
  })) : i;
16
16
  }, []);
17
- if (g.length) {
17
+ if (p.length) {
18
18
  var h = new RegExp(`
19
- [ ]{` + Math.min.apply(Math, g) + "}", "g");
19
+ [ ]{` + Math.min.apply(Math, p) + "}", "g");
20
20
  a = a.map(function(i) {
21
21
  return i.replace(h, `
22
22
  `);
@@ -24,30 +24,30 @@ function r(u) {
24
24
  }
25
25
  a[0] = a[0].replace(/^\r?\n/, "");
26
26
  var c = a[0];
27
- return n.forEach(function(i, m) {
27
+ return s.forEach(function(i, m) {
28
28
  var y = c.match(/(?:^|\n)( *)$/), E = y ? y[1] : "", l = i;
29
29
  typeof i == "string" && i.includes(`
30
30
  `) && (l = String(i).split(`
31
- `).map(function(d, te) {
32
- return te === 0 ? d : "" + E + d;
31
+ `).map(function(d, se) {
32
+ return se === 0 ? d : "" + E + d;
33
33
  }).join(`
34
34
  `)), c += l + a[m + 1];
35
35
  }), c;
36
36
  }
37
- t(r, "dedent");
37
+ t(n, "dedent");
38
38
 
39
39
  // src/storybook-error.ts
40
- function C({
40
+ function D({
41
41
  code: u,
42
- category: n
42
+ category: s
43
43
  }) {
44
44
  let e = String(u).padStart(4, "0");
45
- return `SB_${n}_${e}`;
45
+ return `SB_${s}_${e}`;
46
46
  }
47
- t(C, "parseErrorCode");
48
- var p = class p extends Error {
47
+ t(D, "parseErrorCode");
48
+ var g = class g extends Error {
49
49
  constructor(e) {
50
- super(p.getFullMessage(e));
50
+ super(g.getFullMessage(e));
51
51
  /**
52
52
  * Data associated with the error. Used to provide additional information in the error message or
53
53
  * to be passed to telemetry.
@@ -58,7 +58,7 @@ var p = class p extends Error {
58
58
  this.category = e.category, this.documentation = e.documentation ?? !1, this.code = e.code;
59
59
  }
60
60
  get fullErrorCode() {
61
- return C({ code: this.code, category: this.category });
61
+ return D({ code: this.code, category: this.category });
62
62
  }
63
63
  /** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */
64
64
  get name() {
@@ -69,11 +69,11 @@ var p = class p extends Error {
69
69
  static getFullMessage({
70
70
  documentation: e,
71
71
  code: a,
72
- category: g,
72
+ category: p,
73
73
  message: h
74
74
  }) {
75
75
  let c;
76
- return e === !0 ? c = `https://storybook.js.org/error/${C({ code: a, category: g })}` : typeof e == "string" ? c = e : Array.isArray(e) &&
76
+ return e === !0 ? c = `https://storybook.js.org/error/${D({ code: a, category: p })}` : typeof e == "string" ? c = e : Array.isArray(e) &&
77
77
  (c = `
78
78
  ${e.map((i) => ` - ${i}`).join(`
79
79
  `)}`), `${h}${c != null ? `
@@ -82,21 +82,21 @@ More info: ${c}
82
82
  ` : ""}`;
83
83
  }
84
84
  };
85
- t(p, "StorybookError");
86
- var o = p;
85
+ t(g, "StorybookError");
86
+ var o = g;
87
87
 
88
88
  // src/preview-errors.ts
89
- var se = /* @__PURE__ */ ((s) => (s.BLOCKS = "BLOCKS", s.DOCS_TOOLS = "DOCS-TOOLS", s.PREVIEW_CLIENT_LOGGER = "PREVIEW_CLIENT-LOGGER", s.PREVIEW_CHANNELS =
90
- "PREVIEW_CHANNELS", s.PREVIEW_CORE_EVENTS = "PREVIEW_CORE-EVENTS", s.PREVIEW_INSTRUMENTER = "PREVIEW_INSTRUMENTER", s.PREVIEW_API = "PREVIEW\
91
- _API", s.PREVIEW_REACT_DOM_SHIM = "PREVIEW_REACT-DOM-SHIM", s.PREVIEW_ROUTER = "PREVIEW_ROUTER", s.PREVIEW_THEMING = "PREVIEW_THEMING", s.RENDERER_HTML =
92
- "RENDERER_HTML", s.RENDERER_PREACT = "RENDERER_PREACT", s.RENDERER_REACT = "RENDERER_REACT", s.RENDERER_SERVER = "RENDERER_SERVER", s.RENDERER_SVELTE =
93
- "RENDERER_SVELTE", s.RENDERER_VUE = "RENDERER_VUE", s.RENDERER_VUE3 = "RENDERER_VUE3", s.RENDERER_WEB_COMPONENTS = "RENDERER_WEB-COMPONENTS",
94
- s.FRAMEWORK_NEXTJS = "FRAMEWORK_NEXTJS", s.ADDON_VITEST = "ADDON_VITEST", s))(se || {}), f = class f extends o {
89
+ var ne = /* @__PURE__ */ ((r) => (r.BLOCKS = "BLOCKS", r.DOCS_TOOLS = "DOCS-TOOLS", r.PREVIEW_CLIENT_LOGGER = "PREVIEW_CLIENT-LOGGER", r.PREVIEW_CHANNELS =
90
+ "PREVIEW_CHANNELS", r.PREVIEW_CORE_EVENTS = "PREVIEW_CORE-EVENTS", r.PREVIEW_INSTRUMENTER = "PREVIEW_INSTRUMENTER", r.PREVIEW_API = "PREVIEW\
91
+ _API", r.PREVIEW_REACT_DOM_SHIM = "PREVIEW_REACT-DOM-SHIM", r.PREVIEW_ROUTER = "PREVIEW_ROUTER", r.PREVIEW_THEMING = "PREVIEW_THEMING", r.RENDERER_HTML =
92
+ "RENDERER_HTML", r.RENDERER_PREACT = "RENDERER_PREACT", r.RENDERER_REACT = "RENDERER_REACT", r.RENDERER_SERVER = "RENDERER_SERVER", r.RENDERER_SVELTE =
93
+ "RENDERER_SVELTE", r.RENDERER_VUE = "RENDERER_VUE", r.RENDERER_VUE3 = "RENDERER_VUE3", r.RENDERER_WEB_COMPONENTS = "RENDERER_WEB-COMPONENTS",
94
+ r.FRAMEWORK_NEXTJS = "FRAMEWORK_NEXTJS", r.ADDON_VITEST = "ADDON_VITEST", r))(ne || {}), f = class f extends o {
95
95
  constructor(e) {
96
96
  super({
97
97
  category: "PREVIEW_API",
98
98
  code: 1,
99
- message: r`
99
+ message: n`
100
100
  Couldn't find story matching id '${e.storyId}' after HMR.
101
101
  - Did you just rename a story?
102
102
  - Did you remove it from your CSF file?
@@ -108,14 +108,14 @@ s.FRAMEWORK_NEXTJS = "FRAMEWORK_NEXTJS", s.ADDON_VITEST = "ADDON_VITEST", s))(se
108
108
  }
109
109
  };
110
110
  t(f, "MissingStoryAfterHmrError");
111
- var D = f, R = class R extends o {
111
+ var j = f, R = class R extends o {
112
112
  constructor(e) {
113
113
  super({
114
114
  category: "PREVIEW_API",
115
115
  code: 2,
116
116
  documentation: "https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#using-implicit-actions-during-rendering-is-deprecated-\
117
117
  for-example-in-the-play-function",
118
- message: r`
118
+ message: n`
119
119
  We detected that you use an implicit action arg while ${e.phase} of your story.
120
120
  ${e.deprecated ? `
121
121
  This is deprecated and won't work in Storybook 8 anymore.
@@ -131,12 +131,12 @@ This is deprecated and won't work in Storybook 8 anymore.
131
131
  }
132
132
  };
133
133
  t(R, "ImplicitActionsDuringRendering");
134
- var j = R, b = class b extends o {
134
+ var L = R, b = class b extends o {
135
135
  constructor() {
136
136
  super({
137
137
  category: "PREVIEW_API",
138
138
  code: 3,
139
- message: r`
139
+ message: n`
140
140
  Cannot call \`storyStore.extract()\` without calling \`storyStore.cacheAllCsfFiles()\` first.
141
141
 
142
142
  You probably meant to call \`await preview.extract()\` which does the above for you.`
@@ -144,12 +144,12 @@ var j = R, b = class b extends o {
144
144
  }
145
145
  };
146
146
  t(b, "CalledExtractOnStoreError");
147
- var L = b, I = class I extends o {
147
+ var G = b, I = class I extends o {
148
148
  constructor() {
149
149
  super({
150
150
  category: "PREVIEW_API",
151
151
  code: 4,
152
- message: r`
152
+ message: n`
153
153
  Expected your framework's preset to export a \`renderToCanvas\` field.
154
154
 
155
155
  Perhaps it needs to be upgraded for Storybook 7.0?`,
@@ -158,12 +158,12 @@ var L = b, I = class I extends o {
158
158
  }
159
159
  };
160
160
  t(I, "MissingRenderToCanvasError");
161
- var G = I, P = class P extends o {
161
+ var Y = I, P = class P extends o {
162
162
  constructor(e) {
163
163
  super({
164
164
  category: "PREVIEW_API",
165
165
  code: 5,
166
- message: r`
166
+ message: n`
167
167
  Called \`Preview.${e.methodName}()\` before initialization.
168
168
 
169
169
  The preview needs to load the story index before most methods can be called. If you want
@@ -176,12 +176,12 @@ var G = I, P = class P extends o {
176
176
  }
177
177
  };
178
178
  t(P, "CalledPreviewMethodBeforeInitializationError");
179
- var Y = P, x = class x extends o {
179
+ var F = P, x = class x extends o {
180
180
  constructor(e) {
181
181
  super({
182
182
  category: "PREVIEW_API",
183
183
  code: 6,
184
- message: r`
184
+ message: n`
185
185
  Error fetching \`/index.json\`:
186
186
 
187
187
  ${e.text}
@@ -196,12 +196,12 @@ var Y = P, x = class x extends o {
196
196
  }
197
197
  };
198
198
  t(x, "StoryIndexFetchError");
199
- var M = x, T = class T extends o {
199
+ var H = x, w = class w extends o {
200
200
  constructor(e) {
201
201
  super({
202
202
  category: "PREVIEW_API",
203
203
  code: 7,
204
- message: r`
204
+ message: n`
205
205
  Tried to render docs entry ${e.storyId} but it is a MDX file that has no CSF
206
206
  references, or autodocs for a CSF file that some doesn't refer to itself.
207
207
 
@@ -211,13 +211,13 @@ var M = x, T = class T extends o {
211
211
  this.data = e;
212
212
  }
213
213
  };
214
- t(T, "MdxFileWithNoCsfReferencesError");
215
- var H = T, w = class w extends o {
214
+ t(w, "MdxFileWithNoCsfReferencesError");
215
+ var K = w, T = class T extends o {
216
216
  constructor() {
217
217
  super({
218
218
  category: "PREVIEW_API",
219
219
  code: 8,
220
- message: r`
220
+ message: n`
221
221
  Couldn't find any stories in your Storybook.
222
222
 
223
223
  - Please check your stories field of your main.js config: does it match correctly?
@@ -225,13 +225,13 @@ var H = T, w = class w extends o {
225
225
  });
226
226
  }
227
227
  };
228
- t(w, "EmptyIndexError");
229
- var F = w, k = class k extends o {
228
+ t(T, "EmptyIndexError");
229
+ var M = T, S = class S extends o {
230
230
  constructor(e) {
231
231
  super({
232
232
  category: "PREVIEW_API",
233
233
  code: 9,
234
- message: r`
234
+ message: n`
235
235
  Couldn't find story matching '${e.storySpecifier}'.
236
236
 
237
237
  - Are you sure a story with that id exists?
@@ -241,13 +241,13 @@ var F = w, k = class k extends o {
241
241
  this.data = e;
242
242
  }
243
243
  };
244
- t(k, "NoStoryMatchError");
245
- var K = k, S = class S extends o {
244
+ t(S, "NoStoryMatchError");
245
+ var X = S, k = class k extends o {
246
246
  constructor(e) {
247
247
  super({
248
248
  category: "PREVIEW_API",
249
249
  code: 10,
250
- message: r`
250
+ message: n`
251
251
  Couldn't find story matching id '${e.storyId}' after importing a CSF file.
252
252
 
253
253
  The file was indexed as if the story was there, but then after importing the file in the browser
@@ -260,13 +260,13 @@ var K = k, S = class S extends o {
260
260
  this.data = e;
261
261
  }
262
262
  };
263
- t(S, "MissingStoryFromCsfFileError");
264
- var X = S, v = class v extends o {
263
+ t(k, "MissingStoryFromCsfFileError");
264
+ var J = k, v = class v extends o {
265
265
  constructor() {
266
266
  super({
267
267
  category: "PREVIEW_API",
268
268
  code: 11,
269
- message: r`
269
+ message: n`
270
270
  Cannot access the Story Store until the index is ready.
271
271
 
272
272
  It is not recommended to use methods directly on the Story Store anyway, in Storybook 9 we will
@@ -275,12 +275,12 @@ var X = S, v = class v extends o {
275
275
  }
276
276
  };
277
277
  t(v, "StoryStoreAccessedBeforeInitializationError");
278
- var U = v, _ = class _ extends o {
278
+ var U = v, V = class V extends o {
279
279
  constructor(e) {
280
280
  super({
281
281
  category: "PREVIEW_API",
282
282
  code: 12,
283
- message: r`
283
+ message: n`
284
284
  Incorrect use of mount in the play function.
285
285
 
286
286
  To use mount in the play function, you must satisfy the following two requirements:
@@ -302,26 +302,26 @@ var U = v, _ = class _ extends o {
302
302
  this.data = e;
303
303
  }
304
304
  };
305
- t(_, "MountMustBeDestructuredError");
306
- var J = _, V = class V extends o {
305
+ t(V, "MountMustBeDestructuredError");
306
+ var q = V, _ = class _ extends o {
307
307
  constructor(e) {
308
308
  super({
309
309
  category: "PREVIEW_API",
310
310
  code: 14,
311
- message: r`
311
+ message: n`
312
312
  No render function available for storyId '${e.id}'
313
313
  `
314
314
  });
315
315
  this.data = e;
316
316
  }
317
317
  };
318
- t(V, "NoRenderFunctionError");
319
- var q = V, N = class N extends o {
318
+ t(_, "NoRenderFunctionError");
319
+ var z = _, N = class N extends o {
320
320
  constructor() {
321
321
  super({
322
322
  category: "PREVIEW_API",
323
323
  code: 15,
324
- message: r`
324
+ message: n`
325
325
  No component is mounted in your story.
326
326
 
327
327
  This usually occurs when you destructure mount in the play function, but forget to call it.
@@ -341,13 +341,28 @@ var q = V, N = class N extends o {
341
341
  }
342
342
  };
343
343
  t(N, "NoStoryMountedError");
344
- var z = N, A = class A extends o {
344
+ var B = N, A = class A extends o {
345
+ constructor(e) {
346
+ super({
347
+ category: "PREVIEW_API",
348
+ code: 16,
349
+ message: `Status has typeId "${e.status.typeId}" but was added to store with typeId "${e.typeId}". Full status: ${JSON.stringify(
350
+ e.status,
351
+ null,
352
+ 2
353
+ )}`
354
+ });
355
+ this.data = e;
356
+ }
357
+ };
358
+ t(A, "StatusTypeIdMismatchError");
359
+ var Q = A, W = class W extends o {
345
360
  constructor() {
346
361
  super({
347
362
  category: "FRAMEWORK_NEXTJS",
348
363
  code: 1,
349
364
  documentation: "https://storybook.js.org/docs/get-started/nextjs#faq",
350
- message: r`
365
+ message: n`
351
366
  You are importing avif images, but you don't have sharp installed.
352
367
 
353
368
  You have to install sharp in order to use image optimization features in Next.js.
@@ -355,27 +370,27 @@ var z = N, A = class A extends o {
355
370
  });
356
371
  }
357
372
  };
358
- t(A, "NextJsSharpError");
359
- var B = A, W = class W extends o {
373
+ t(W, "NextJsSharpError");
374
+ var Z = W, $ = class $ extends o {
360
375
  constructor(e) {
361
376
  super({
362
377
  category: "FRAMEWORK_NEXTJS",
363
378
  code: 2,
364
- message: r`
379
+ message: n`
365
380
  Tried to access router mocks from "${e.importType}" but they were not created yet. You might be running code in an unsupported environment.
366
381
  `
367
382
  });
368
383
  this.data = e;
369
384
  }
370
385
  };
371
- t(W, "NextjsRouterMocksNotAvailable");
372
- var Q = W, $ = class $ extends o {
386
+ t($, "NextjsRouterMocksNotAvailable");
387
+ var ee = $, O = class O extends o {
373
388
  constructor(e) {
374
389
  super({
375
390
  category: "DOCS-TOOLS",
376
391
  code: 1,
377
392
  documentation: "https://github.com/storybookjs/storybook/issues/26606",
378
- message: r`
393
+ message: n`
379
394
  There was a failure when generating detailed ArgTypes in ${e.language} for:
380
395
  ${JSON.stringify(e.type, null, 2)}
381
396
 
@@ -388,15 +403,15 @@ var Q = W, $ = class $ extends o {
388
403
  this.data = e;
389
404
  }
390
405
  };
391
- t($, "UnknownArgTypesError");
392
- var Z = $, O = class O extends o {
406
+ t(O, "UnknownArgTypesError");
407
+ var te = O, C = class C extends o {
393
408
  constructor(e) {
394
409
  super({
395
410
  category: "ADDON_VITEST",
396
411
  code: 1,
397
412
  // TODO: Add documentation about viewports support
398
413
  // documentation: '',
399
- message: r`
414
+ message: n`
400
415
  Encountered an unsupported value "${e.value}" when setting the viewport ${e.dimension} dimension.
401
416
 
402
417
  The Storybook plugin only supports values in the following units:
@@ -408,26 +423,27 @@ var Z = $, O = class O extends o {
408
423
  this.data = e;
409
424
  }
410
425
  };
411
- t(O, "UnsupportedViewportDimensionError");
412
- var ee = O;
426
+ t(C, "UnsupportedViewportDimensionError");
427
+ var oe = C;
413
428
  export {
414
- L as CalledExtractOnStoreError,
415
- Y as CalledPreviewMethodBeforeInitializationError,
416
- se as Category,
417
- F as EmptyIndexError,
418
- j as ImplicitActionsDuringRendering,
419
- H as MdxFileWithNoCsfReferencesError,
420
- G as MissingRenderToCanvasError,
421
- D as MissingStoryAfterHmrError,
422
- X as MissingStoryFromCsfFileError,
423
- J as MountMustBeDestructuredError,
424
- B as NextJsSharpError,
425
- Q as NextjsRouterMocksNotAvailable,
426
- q as NoRenderFunctionError,
427
- K as NoStoryMatchError,
428
- z as NoStoryMountedError,
429
- M as StoryIndexFetchError,
429
+ G as CalledExtractOnStoreError,
430
+ F as CalledPreviewMethodBeforeInitializationError,
431
+ ne as Category,
432
+ M as EmptyIndexError,
433
+ L as ImplicitActionsDuringRendering,
434
+ K as MdxFileWithNoCsfReferencesError,
435
+ Y as MissingRenderToCanvasError,
436
+ j as MissingStoryAfterHmrError,
437
+ J as MissingStoryFromCsfFileError,
438
+ q as MountMustBeDestructuredError,
439
+ Z as NextJsSharpError,
440
+ ee as NextjsRouterMocksNotAvailable,
441
+ z as NoRenderFunctionError,
442
+ X as NoStoryMatchError,
443
+ B as NoStoryMountedError,
444
+ Q as StatusTypeIdMismatchError,
445
+ H as StoryIndexFetchError,
430
446
  U as StoryStoreAccessedBeforeInitializationError,
431
- Z as UnknownArgTypesError,
432
- ee as UnsupportedViewportDimensionError
447
+ te as UnknownArgTypesError,
448
+ oe as UnsupportedViewportDimensionError
433
449
  };