storybook 9.0.0-beta.8 → 9.0.0-rc.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 (75) hide show
  1. package/assets/server/base-preview-head.html +21 -0
  2. package/assets/server/template.ejs +4 -4
  3. package/dist/actions/preview.cjs +1 -1
  4. package/dist/actions/preview.d.ts +501 -0
  5. package/dist/actions/preview.js +1 -1
  6. package/dist/backgrounds/index.d.ts +501 -0
  7. package/dist/backgrounds/preview.d.ts +501 -0
  8. package/dist/bin/index.cjs +61 -61
  9. package/dist/bin/index.js +59 -59
  10. package/dist/builder-manager/index.cjs +208 -203
  11. package/dist/builder-manager/index.js +492 -487
  12. package/dist/channels/index.js +919 -941
  13. package/dist/cli/bin/index.cjs +1032 -1032
  14. package/dist/cli/bin/index.js +1032 -1032
  15. package/dist/cli/index.cjs +33709 -28783
  16. package/dist/cli/index.js +33641 -28711
  17. package/dist/common/index.cjs +2802 -2789
  18. package/dist/common/index.d.ts +2 -1
  19. package/dist/common/index.js +3250 -3237
  20. package/dist/components/index.cjs +711 -711
  21. package/dist/components/index.d.ts +2 -1
  22. package/dist/components/index.js +2266 -2272
  23. package/dist/controls/preview.d.ts +501 -0
  24. package/dist/core-events/index.cjs +55 -52
  25. package/dist/core-events/index.d.ts +3 -1
  26. package/dist/core-events/index.js +52 -49
  27. package/dist/core-server/index.cjs +3066 -3037
  28. package/dist/core-server/index.d.ts +512 -11
  29. package/dist/core-server/index.js +3271 -3241
  30. package/dist/core-server/presets/common-manager.js +4570 -5779
  31. package/dist/core-server/presets/common-override-preset.cjs +10 -12
  32. package/dist/core-server/presets/common-override-preset.js +3 -5
  33. package/dist/core-server/presets/common-preset.cjs +112 -116
  34. package/dist/core-server/presets/common-preset.js +10 -14
  35. package/dist/csf/index.d.ts +1 -1
  36. package/dist/csf-tools/index.cjs +116 -111
  37. package/dist/csf-tools/index.js +33 -28
  38. package/dist/docs-tools/index.js +596 -603
  39. package/dist/highlight/preview.d.ts +501 -0
  40. package/dist/instrumenter/index.js +1851 -3554
  41. package/dist/manager/globals-module-info.cjs +3 -0
  42. package/dist/manager/globals-module-info.js +3 -0
  43. package/dist/manager/globals-runtime.js +21347 -23051
  44. package/dist/manager/runtime.js +2510 -2498
  45. package/dist/manager-api/index.cjs +2302 -8594
  46. package/dist/manager-api/index.d.ts +501 -0
  47. package/dist/manager-api/index.js +2655 -2715
  48. package/dist/manager-errors.js +37 -41
  49. package/dist/measure/index.d.ts +501 -0
  50. package/dist/measure/preview.d.ts +501 -0
  51. package/dist/outline/index.d.ts +501 -0
  52. package/dist/outline/preview.d.ts +501 -0
  53. package/dist/preview/runtime.js +38393 -40149
  54. package/dist/preview-api/index.cjs +1546 -1459
  55. package/dist/preview-api/index.d.ts +8 -5
  56. package/dist/preview-api/index.js +1273 -1203
  57. package/dist/preview-errors.js +152 -173
  58. package/dist/router/index.cjs +5700 -2327
  59. package/dist/router/index.d.ts +622 -243
  60. package/dist/router/index.js +1297 -870
  61. package/dist/test/index.cjs +1810 -1811
  62. package/dist/test/index.d.ts +53 -5
  63. package/dist/test/index.js +7614 -7703
  64. package/dist/test/preview.cjs +51 -15860
  65. package/dist/test/preview.d.ts +520 -13
  66. package/dist/test/preview.js +44 -14491
  67. package/dist/theming/index.cjs +17 -0
  68. package/dist/theming/index.js +17 -0
  69. package/dist/types/index.d.ts +516 -82
  70. package/dist/viewport/index.d.ts +502 -3
  71. package/dist/viewport/preview.d.ts +501 -0
  72. package/package.json +3 -18
  73. package/dist/test/spy.cjs +0 -258
  74. package/dist/test/spy.d.ts +0 -62
  75. package/dist/test/spy.js +0 -240
@@ -10170,20 +10170,17 @@ don")), { ...t, removeAddon: r };
10170
10170
  }, JD = /* @__PURE__ */ n((t) => [PP].concat(t || []), "experimental_indexers"), eI = /* @__PURE__ */ n(async (t, e) => {
10171
10171
  let r = await e.presets.apply("framework");
10172
10172
  return typeof r == "string" ? {} : typeof r > "u" ? null : r.options;
10173
- }, "frameworkOptions"), tI = /* @__PURE__ */ n((t, { docs: e }) => t && e !== void 0 ? {
10174
- ...t,
10175
- docsMode: e
10176
- } : t, "docs"), rI = /* @__PURE__ */ n(async (t, e) => {
10173
+ }, "frameworkOptions"), tI = /* @__PURE__ */ n(async (t, e) => {
10177
10174
  let r = ir(e.configDir, "manager-head.html");
10178
10175
  if (zo(r)) {
10179
10176
  let i = fP(r, { encoding: "utf8" }), s = e.presets.apply("env");
10180
10177
  return wP(await i, await s);
10181
10178
  }
10182
10179
  return "";
10183
- }, "managerHead"), iI = /* @__PURE__ */ n(async (t, e) => {
10180
+ }, "managerHead"), rI = /* @__PURE__ */ n(async (t, e) => {
10184
10181
  let r = await e.presets.apply("core");
10185
10182
  return dm(t, e, r), dh(t, e, r), sh(t, e, r), Sa(t, e, r), t;
10186
- }, "experimental_serverChannel"), sI = /* @__PURE__ */ n(async (t) => {
10183
+ }, "experimental_serverChannel"), iI = /* @__PURE__ */ n(async (t) => {
10187
10184
  try {
10188
10185
  return {
10189
10186
  ...t,
@@ -10193,12 +10190,12 @@ don")), { ...t, removeAddon: r };
10193
10190
  } catch {
10194
10191
  return t;
10195
10192
  }
10196
- }, "resolvedReact"), nI = /* @__PURE__ */ n(async (t) => ({
10193
+ }, "resolvedReact"), sI = /* @__PURE__ */ n(async (t) => ({
10197
10194
  ...t,
10198
10195
  "dev-only": { excludeFromDocsStories: !0 },
10199
10196
  "docs-only": { excludeFromSidebar: !0 },
10200
10197
  "test-only": { excludeFromSidebar: !0, excludeFromDocsStories: !0 }
10201
- }), "tags"), oI = /* @__PURE__ */ n(async (t) => [
10198
+ }), "tags"), nI = /* @__PURE__ */ n(async (t) => [
10202
10199
  ir(
10203
10200
  hi(k.resolve("storybook/internal/package.json")),
10204
10201
  "dist/core-server/presets/common-manager.js"
@@ -10209,22 +10206,21 @@ export {
10209
10206
  WD as babel,
10210
10207
  QD as core,
10211
10208
  PP as csfIndexer,
10212
- tI as docs,
10213
10209
  YD as env,
10214
10210
  JD as experimental_indexers,
10215
10211
  XD as experimental_serverAPI,
10216
- iI as experimental_serverChannel,
10212
+ rI as experimental_serverChannel,
10217
10213
  BD as favicon,
10218
10214
  ZD as features,
10219
10215
  eI as frameworkOptions,
10220
10216
  GD as logLevel,
10221
- oI as managerEntries,
10222
- rI as managerHead,
10217
+ nI as managerEntries,
10218
+ tI as managerHead,
10223
10219
  zD as previewBody,
10224
10220
  UD as previewHead,
10225
- sI as resolvedReact,
10221
+ iI as resolvedReact,
10226
10222
  HD as staticDirs,
10227
- nI as tags,
10223
+ sI as tags,
10228
10224
  VD as title,
10229
10225
  KD as typescript
10230
10226
  };
@@ -561,7 +561,7 @@ interface BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> {
561
561
  * `afterEach` can be added to preview, the default export and to a specific story. They are run
562
562
  * (and awaited) reverse order: preview, default export, story
563
563
  */
564
- experimental_afterEach?: AfterEach<TRenderer, TArgs>[] | AfterEach<TRenderer, TArgs>;
564
+ afterEach?: AfterEach<TRenderer, TArgs>[] | AfterEach<TRenderer, TArgs>;
565
565
  /**
566
566
  * Define a custom render function for the story(ies). If not passed, a default render function by
567
567
  * the renderer will be used.
@@ -34,8 +34,8 @@ var R = Je(($) => {
34
34
  var r = Array.from(typeof s == "string" ? [s] : s);
35
35
  r[r.length - 1] = r[r.length - 1].replace(/\r?\n([\t ]*)$/, "");
36
36
  var i = r.reduce(function(a, p) {
37
- var d = p.match(/\n([\t ]+|(?!\s).)/g);
38
- return d ? a.concat(d.map(function(g) {
37
+ var m = p.match(/\n([\t ]+|(?!\s).)/g);
38
+ return m ? a.concat(m.map(function(g) {
39
39
  var x, E;
40
40
  return (E = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && E !== void 0 ? E : 0;
41
41
  })) : a;
@@ -51,7 +51,7 @@ var R = Je(($) => {
51
51
  r[0] = r[0].replace(/^\r?\n/, "");
52
52
  var l = r[0];
53
53
  return e.forEach(function(a, p) {
54
- var d = l.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = a;
54
+ var m = l.match(/(?:^|\n)( *)$/), g = m ? m[1] : "", x = a;
55
55
  typeof a == "string" && a.includes(`
56
56
  `) && (x = String(a).split(`
57
57
  `).map(function(E, b) {
@@ -89,7 +89,7 @@ Qe(dt, {
89
89
  isValidPreviewPath: () => ge,
90
90
  loadConfig: () => je,
91
91
  loadCsf: () => Q,
92
- printConfig: () => Oe,
92
+ printConfig: () => Pe,
93
93
  printCsf: () => be,
94
94
  readConfig: () => nt,
95
95
  readCsf: () => it,
@@ -100,11 +100,11 @@ Qe(dt, {
100
100
  module.exports = He(dt);
101
101
 
102
102
  // src/csf-tools/CsfFile.ts
103
- var J = require("node:fs/promises"), c = require("storybook/internal/babel"), I = require("storybook/internal/csf"), P = z(R(), 1);
103
+ var J = require("node:fs/promises"), c = require("storybook/internal/babel"), I = require("storybook/internal/csf"), O = z(R(), 1);
104
104
 
105
105
  // src/csf-tools/findVarInitialization.ts
106
106
  var w = require("storybook/internal/babel");
107
- var O = /* @__PURE__ */ f((s, e) => {
107
+ var P = /* @__PURE__ */ f((s, e) => {
108
108
  let t = null, r = null;
109
109
  return e.body.find((i) => (w.types.isVariableDeclaration(i) ? r = i.declarations : w.types.isExportNamedDeclaration(i) && w.types.isVariableDeclaration(
110
110
  i.declaration) && (r = i.declaration.declarations), r && r.find((o) => w.types.isVariableDeclarator(o) && w.types.isIdentifier(o.id) && o.
@@ -150,7 +150,7 @@ var D = /* @__PURE__ */ f((s, e) => {
150
150
  let { callee: i, arguments: o } = s;
151
151
  if (c.types.isProgram(e) && c.types.isMemberExpression(i) && c.types.isIdentifier(i.object) && c.types.isIdentifier(i.property) && i.property.
152
152
  name === "bind" && (o.length === 0 || o.length === 1 && c.types.isObjectExpression(o[0]) && o[0].properties.length === 0)) {
153
- let l = i.object.name, a = O(l, e);
153
+ let l = i.object.name, a = P(l, e);
154
154
  a && (t._templates[l] = a, r = a);
155
155
  }
156
156
  }
@@ -188,7 +188,7 @@ var D = /* @__PURE__ */ f((s, e) => {
188
188
  }
189
189
  constructor(e, t, r) {
190
190
  let i = "".trim();
191
- super(P.dedent`
191
+ super(O.dedent`
192
192
  CSF: ${e} ${D(t, r)}
193
193
 
194
194
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -200,7 +200,7 @@ var D = /* @__PURE__ */ f((s, e) => {
200
200
  }
201
201
  constructor(e, t, r) {
202
202
  let i = `${e} ${D(t, r)}`.trim();
203
- super(P.dedent`
203
+ super(O.dedent`
204
204
  CSF: ${e} ${D(t, r)}
205
205
 
206
206
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -212,7 +212,7 @@ var D = /* @__PURE__ */ f((s, e) => {
212
212
  }
213
213
  constructor(e, t, r) {
214
214
  let i = `${e} ${D(t, r)}`.trim();
215
- super(P.dedent`
215
+ super(O.dedent`
216
216
  CSF: ${e} ${D(t, r)}
217
217
 
218
218
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -224,7 +224,7 @@ var D = /* @__PURE__ */ f((s, e) => {
224
224
  }
225
225
  constructor(e, t, r) {
226
226
  let i = "".trim();
227
- super(P.dedent`
227
+ super(O.dedent`
228
228
  CSF: ${e} ${D(t, r)}
229
229
 
230
230
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -245,12 +245,12 @@ var D = /* @__PURE__ */ f((s, e) => {
245
245
  f(this, "CsfFile");
246
246
  }
247
247
  _parseTitle(e) {
248
- let t = c.types.isIdentifier(e) ? O(e.name, this._ast.program) : e;
248
+ let t = c.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
249
249
  if (c.types.isStringLiteral(t))
250
250
  return t.value;
251
251
  if (c.types.isTSSatisfiesExpression(t) && c.types.isStringLiteral(t.expression))
252
252
  return t.expression.value;
253
- throw new Error(P.dedent`
253
+ throw new Error(O.dedent`
254
254
  CSF: unexpected dynamic title ${D(t, this._options.fileName)}
255
255
 
256
256
  More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
@@ -271,18 +271,18 @@ var D = /* @__PURE__ */ f((s, e) => {
271
271
  let o = i.value;
272
272
  if (c.types.isIdentifier(o)) {
273
273
  let a = o.name, p = t.body.find(
274
- (d) => c.types.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === a)
274
+ (m) => c.types.isImportDeclaration(m) && m.specifiers.find((g) => g.local.name === a)
275
275
  );
276
276
  if (p) {
277
- let { source: d } = p;
278
- c.types.isStringLiteral(d) && (this._rawComponentPath = d.value);
277
+ let { source: m } = p;
278
+ c.types.isStringLiteral(m) && (this._rawComponentPath = m.value);
279
279
  }
280
280
  }
281
281
  let { code: l } = c.recast.print(i.value, {});
282
282
  r.component = l;
283
283
  } else if (i.key.name === "tags") {
284
284
  let o = i.value;
285
- c.types.isIdentifier(o) && (o = O(o.name, this._ast.program)), r.tags = de(o);
285
+ c.types.isIdentifier(o) && (o = P(o.name, this._ast.program)), r.tags = de(o);
286
286
  } else if (i.key.name === "id")
287
287
  if (c.types.isStringLiteral(i.value))
288
288
  r.id = i.value.value;
@@ -310,20 +310,20 @@ var D = /* @__PURE__ */ f((s, e) => {
310
310
  enter(r) {
311
311
  let { node: i, parent: o } = r, l = c.types.isIdentifier(i.declaration) && c.types.isProgram(o);
312
312
  if (e._options.transformInlineMeta && !l && c.types.isExpression(i.declaration)) {
313
- let d = r.scope.generateUidIdentifier("meta");
314
- e._metaVariableName = d.name;
313
+ let m = r.scope.generateUidIdentifier("meta");
314
+ e._metaVariableName = m.name;
315
315
  let g = [
316
- c.types.variableDeclaration("const", [c.types.variableDeclarator(d, i.declaration)]),
317
- c.types.exportDefaultDeclaration(d)
316
+ c.types.variableDeclaration("const", [c.types.variableDeclarator(m, i.declaration)]),
317
+ c.types.exportDefaultDeclaration(m)
318
318
  ];
319
319
  g.forEach((x) => x.loc = r.node.loc), r.replaceWithMultiple(g);
320
320
  return;
321
321
  }
322
322
  let a, p;
323
323
  if (l) {
324
- let d = i.declaration.name;
325
- e._metaVariableName = d;
326
- let g = /* @__PURE__ */ f((x) => c.types.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
324
+ let m = i.declaration.name;
325
+ e._metaVariableName = m;
326
+ let g = /* @__PURE__ */ f((x) => c.types.isIdentifier(x.id) && x.id.name === m, "isVariableDeclarator");
327
327
  e._metaStatement = e._ast.program.body.find(
328
328
  (x) => c.types.isVariableDeclaration(x) && x.declarations.find(g)
329
329
  ), p = (e?._metaStatement?.declarations || []).find(
@@ -349,16 +349,16 @@ var D = /* @__PURE__ */ f((s, e) => {
349
349
  c.types.isVariableDeclaration(i.declaration) ? l = i.declaration.declarations.filter((a) => c.types.isVariableDeclarator(a)) : c.types.
350
350
  isFunctionDeclaration(i.declaration) && (l = [i.declaration]), l ? l.forEach((a) => {
351
351
  if (c.types.isIdentifier(a.id)) {
352
- let p = !1, { name: d } = a.id;
353
- if (d === "__namedExportsOrder" && c.types.isVariableDeclarator(a)) {
352
+ let p = !1, { name: m } = a.id;
353
+ if (m === "__namedExportsOrder" && c.types.isVariableDeclarator(a)) {
354
354
  e._namedExportsOrder = et(a.init);
355
355
  return;
356
356
  }
357
- e._storyExports[d] = a, e._storyPaths[d] = r, e._storyStatements[d] = i;
358
- let g = (0, I.storyNameFromExport)(d);
359
- e._storyAnnotations[d] ? fe.warn(
360
- `Unexpected annotations for "${d}" before story declaration`
361
- ) : e._storyAnnotations[d] = {};
357
+ e._storyExports[m] = a, e._storyPaths[m] = r, e._storyStatements[m] = i;
358
+ let g = (0, I.storyNameFromExport)(m);
359
+ e._storyAnnotations[m] ? fe.warn(
360
+ `Unexpected annotations for "${m}" before story declaration`
361
+ ) : e._storyAnnotations[m] = {};
362
362
  let x;
363
363
  if (c.types.isVariableDeclarator(a) ? x = c.types.isTSAsExpression(a.init) || c.types.isTSSatisfiesExpression(a.init) ? a.init.
364
364
  expression : a.init : x = a, c.types.isCallExpression(x) && c.types.isMemberExpression(x.callee) && c.types.isIdentifier(x.callee.
@@ -391,7 +391,7 @@ var D = /* @__PURE__ */ f((s, e) => {
391
391
  g = b.value.value;
392
392
  else if (b.key.name === "storyName" && c.types.isStringLiteral(b.value))
393
393
  fe.warn(
394
- `Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
394
+ `Unexpected usage of "storyName" in "${m}". Please use "name" instead.`
395
395
  );
396
396
  else if (b.key.name === "parameters" && c.types.isObjectExpression(b.value)) {
397
397
  let h = b.value.properties.find(
@@ -399,9 +399,9 @@ var D = /* @__PURE__ */ f((s, e) => {
399
399
  );
400
400
  h && (E.__id = h.value.value);
401
401
  }
402
- e._storyAnnotations[d][b.key.name] = b.value;
402
+ e._storyAnnotations[m][b.key.name] = b.value;
403
403
  }
404
- })) : E.__isArgsStory = me(x, o, e), e._stories[d] = {
404
+ })) : E.__isArgsStory = me(x, o, e), e._stories[m] = {
405
405
  id: "FIXME",
406
406
  name: g,
407
407
  parameters: E,
@@ -412,7 +412,7 @@ var D = /* @__PURE__ */ f((s, e) => {
412
412
  }
413
413
  }) : i.specifiers.length > 0 && i.specifiers.forEach((a) => {
414
414
  if (c.types.isExportSpecifier(a) && c.types.isIdentifier(a.exported)) {
415
- let { name: p } = a.exported, { name: d } = a.local, g = c.types.isProgram(o) ? O(a.local.name, o) : a.local;
415
+ let { name: p } = a.exported, { name: m } = a.local, g = c.types.isProgram(o) ? P(a.local.name, o) : a.local;
416
416
  if (p === "default") {
417
417
  let x;
418
418
  c.types.isObjectExpression(g) ? x = g : (
@@ -423,7 +423,7 @@ var D = /* @__PURE__ */ f((s, e) => {
423
423
  e._storyAnnotations[p] = {}, e._storyStatements[p] = g, e._storyPaths[p] = r, e._stories[p] = {
424
424
  id: "FIXME",
425
425
  name: p,
426
- localName: d,
426
+ localName: m,
427
427
  parameters: {},
428
428
  __stats: {}
429
429
  };
@@ -437,13 +437,13 @@ var D = /* @__PURE__ */ f((s, e) => {
437
437
  if (c.types.isProgram(i) && c.types.isAssignmentExpression(o) && c.types.isMemberExpression(o.left) && c.types.isIdentifier(o.left.
438
438
  object) && c.types.isIdentifier(o.left.property)) {
439
439
  let l = o.left.object.name, a = o.left.property.name, p = o.right;
440
- if (e._storyAnnotations[l] && (a === "story" && c.types.isObjectExpression(p) ? p.properties.forEach((d) => {
441
- c.types.isIdentifier(d.key) && (e._storyAnnotations[l][d.key.name] = d.value);
440
+ if (e._storyAnnotations[l] && (a === "story" && c.types.isObjectExpression(p) ? p.properties.forEach((m) => {
441
+ c.types.isIdentifier(m.key) && (e._storyAnnotations[l][m.key.name] = m.value);
442
442
  }) : e._storyAnnotations[l][a] = p), a === "storyName" && c.types.isStringLiteral(p)) {
443
- let d = p.value, g = e._stories[l];
443
+ let m = p.value, g = e._stories[l];
444
444
  if (!g)
445
445
  return;
446
- g.name = d;
446
+ g.name = m;
447
447
  }
448
448
  }
449
449
  }
@@ -452,7 +452,7 @@ var D = /* @__PURE__ */ f((s, e) => {
452
452
  enter(r) {
453
453
  let { node: i } = r, { callee: o } = i;
454
454
  if (c.types.isIdentifier(o) && o.name === "storiesOf")
455
- throw new Error(P.dedent`
455
+ throw new Error(O.dedent`
456
456
  Unexpected \`storiesOf\` usage: ${D(i, e._options.fileName)}.
457
457
 
458
458
  SB8 does not support \`storiesOf\`.
@@ -493,18 +493,18 @@ var D = /* @__PURE__ */ f((s, e) => {
493
493
  let l = o.parameters?.__id ?? (0, I.toId)(e._meta?.id || e._meta?.title, (0, I.storyNameFromExport)(i)), a = { ...o.parameters, __id: l },
494
494
  { includeStories: p } = e._meta || {};
495
495
  i === "__page" && (t.length === 1 || Array.isArray(p) && p.length === 1) && (a.docsOnly = !0), r[i] = { ...o, id: l, parameters: a };
496
- let d = e._storyAnnotations[i], { tags: g, play: x } = d;
496
+ let m = e._storyAnnotations[i], { tags: g, play: x } = m;
497
497
  if (g) {
498
- let h = c.types.isIdentifier(g) ? O(g.name, this._ast.program) : g;
498
+ let h = c.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
499
499
  r[i].tags = de(h);
500
500
  }
501
501
  x && (r[i].tags = [...r[i].tags || [], "play-fn"]);
502
502
  let E = r[i].__stats;
503
503
  ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((h) => {
504
- E[h] = !!d[h] || !!e._metaAnnotations[h];
504
+ E[h] = !!m[h] || !!e._metaAnnotations[h];
505
505
  });
506
506
  let b = e.getStoryExport(i);
507
- return E.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), E.mount = tt(d.play ?? e._metaAnnotations.
507
+ return E.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), E.mount = tt(m.play ?? e._metaAnnotations.
508
508
  play), E.moduleMock = !!e.imports.find((h) => xe(h)), r;
509
509
  },
510
510
  {}
@@ -533,7 +533,7 @@ var D = /* @__PURE__ */ f((s, e) => {
533
533
  let { fileName: e } = this._options;
534
534
  if (!e)
535
535
  throw new Error(
536
- P.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
536
+ O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
537
537
  Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
538
538
  );
539
539
  return Object.entries(this._stories).map(([t, r]) => {
@@ -696,11 +696,11 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
696
696
  (a) => {
697
697
  let p = C(a);
698
698
  if (p) {
699
- let d = a.value;
700
- n.types.isIdentifier(d) && (d = F(
701
- d.name,
699
+ let m = a.value;
700
+ n.types.isIdentifier(m) && (m = F(
701
+ m.name,
702
702
  r
703
- )), e._exports[p] = d;
703
+ )), e._exports[p] = m;
704
704
  }
705
705
  })) : re.warn(
706
706
  ie({
@@ -747,11 +747,11 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
747
747
  setFieldNode(e, t) {
748
748
  let [r, ...i] = e, o = this._exports[r];
749
749
  if (this._exportsObject) {
750
- let p = this._exportsObject.properties.find((d) => C(d) === r);
750
+ let p = this._exportsObject.properties.find((m) => C(m) === r);
751
751
  if (p && n.types.isIdentifier(p.value)) {
752
- let d = Y(p.value.name, this._ast.program);
753
- if (d && n.types.isObjectExpression(d.init)) {
754
- q(i, t, d.init);
752
+ let m = Y(p.value.name, this._ast.program);
753
+ if (m && n.types.isObjectExpression(m.init)) {
754
+ q(i, t, m.init);
755
755
  return;
756
756
  }
757
757
  }
@@ -1034,12 +1034,12 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
1034
1034
  */
1035
1035
  setImport(e, t) {
1036
1036
  let r = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), i = /* @__PURE__ */ f(
1037
- (p, d) => p.specifiers.find(
1038
- (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === d
1039
- ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1040
- (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1041
- ), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1042
- (g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1037
+ (p, m) => p.specifiers.find(
1038
+ (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === m
1039
+ ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, m) => p.specifiers.find(
1040
+ (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
1041
+ ), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p, m) => p.specifiers.find(
1042
+ (g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
1043
1043
  ), "hasDefaultImportSpecifier"), a = this._ast.program.body.find(
1044
1044
  (p) => n.types.isImportDeclaration(p) && p.source.value === t
1045
1045
  );
@@ -1070,7 +1070,7 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
1070
1070
  }, je = /* @__PURE__ */ f((s, e) => {
1071
1071
  let t = (0, n.babelParse)(s);
1072
1072
  return new Z(t, s, e);
1073
- }, "loadConfig"), Se = /* @__PURE__ */ f((s) => Oe(s).code, "formatConfig"), Oe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
1073
+ }, "loadConfig"), Se = /* @__PURE__ */ f((s) => Pe(s).code, "formatConfig"), Pe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
1074
1074
  "printConfig"), nt = /* @__PURE__ */ f(async (s) => {
1075
1075
  let e = (await (0, ee.readFile)(s, "utf-8")).toString();
1076
1076
  return je(e, s).parse();
@@ -1127,11 +1127,11 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
1127
1127
  T("options", !0);
1128
1128
  }
1129
1129
  }
1130
- }, "parseParameters"), Pe = /* @__PURE__ */ f((s, e) => {
1130
+ }, "parseParameters"), Oe = /* @__PURE__ */ f((s, e) => {
1131
1131
  let t = W(s);
1132
1132
  if (y.types.isObjectExpression(t)) {
1133
1133
  let r = se(t, "parameters");
1134
- if (y.types.isIdentifier(r) && (r = O(r.name, e)), r)
1134
+ if (y.types.isIdentifier(r) && (r = P(r.name, e)), r)
1135
1135
  return De(r);
1136
1136
  } else
1137
1137
  T("default", !0);
@@ -1158,8 +1158,8 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
1158
1158
  ExportDefaultDeclaration: {
1159
1159
  enter({ node: r }) {
1160
1160
  let i = r.declaration;
1161
- y.types.isIdentifier(i) && (i = O(i.name, t.program)), i = W(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1162
- e = Pe(i.arguments[0], t.program) : y.types.isObjectExpression(i) ? e = Pe(i, t.program) : T("default", !1);
1161
+ y.types.isIdentifier(i) && (i = P(i.name, t.program)), i = W(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1162
+ e = Oe(i.arguments[0], t.program) : y.types.isObjectExpression(i) ? e = Oe(i, t.program) : T("default", !1);
1163
1163
  }
1164
1164
  }
1165
1165
  }), !!e) {
@@ -1182,8 +1182,8 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
1182
1182
  var u = require("storybook/internal/babel");
1183
1183
  var ve = /* @__PURE__ */ f((s, e, t, r) => {
1184
1184
  let i = e.getStoryExport(t), o = u.types.isCallExpression(i) && u.types.isMemberExpression(i.callee) && u.types.isIdentifier(i.callee.object) &&
1185
- i.callee.object.name === "meta", l = !r?.disableSource && Fe(i), a = !r?.disableDescription && oe(e._storyStatements[t]), p = [], d = o ? u.types.
1186
- memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(d, u.types.identifier(
1185
+ i.callee.object.name === "meta", l = !r?.disableSource && Fe(i), a = !r?.disableDescription && oe(e._storyStatements[t]), p = [], m = o ? u.types.
1186
+ memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(m, u.types.identifier(
1187
1187
  "parameters"));
1188
1188
  p.push(u.types.spreadElement(g));
1189
1189
  let x = u.types.optionalMemberExpression(
@@ -1276,7 +1276,7 @@ var ve = /* @__PURE__ */ f((s, e, t, r) => {
1276
1276
  var Ae = require("storybook/internal/babel");
1277
1277
 
1278
1278
  // src/csf-tools/vitest-plugin/transformer.ts
1279
- var m = require("storybook/internal/babel"), Te = require("storybook/internal/common"), ke = require("storybook/internal/csf"), ae = z(R(), 1);
1279
+ var d = require("storybook/internal/babel"), Te = require("storybook/internal/common"), ke = require("storybook/internal/csf"), ae = z(R(), 1);
1280
1280
  var Ce = console, ft = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((t) => s?.includes(t)) || e.exclude.some((t) => s?.
1281
1281
  includes(t))), "isValidTest");
1282
1282
  async function Ve({
@@ -1306,10 +1306,10 @@ async function Ve({
1306
1306
  `
1307
1307
  ), S;
1308
1308
  }, "makeTitle")
1309
- }).parse(), p = a._ast, d = a._metaVariableName, g = a._metaNode, x = g.properties.find(
1310
- (_) => m.types.isObjectProperty(_) && m.types.isIdentifier(_.key) && _.key.name === "title"
1311
- ), E = m.types.stringLiteral(a._meta?.title || "unknown");
1312
- if (x ? m.types.isObjectProperty(x) && (x.value = E) : g.properties.push(m.types.objectProperty(m.types.identifier("title"), E)), !g || !a.
1309
+ }).parse(), p = a._ast, m = a._metaVariableName, g = a._metaNode, x = g.properties.find(
1310
+ (_) => d.types.isObjectProperty(_) && d.types.isIdentifier(_.key) && _.key.name === "title"
1311
+ ), E = d.types.stringLiteral(a._meta?.title || "unknown");
1312
+ if (x ? d.types.isObjectProperty(x) && (x.value = E) : g.properties.push(d.types.objectProperty(d.types.identifier("title"), E)), !g || !a.
1313
1313
  _meta)
1314
1314
  throw new Error(
1315
1315
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
@@ -1330,53 +1330,55 @@ le an issue with details about your use case.`
1330
1330
  });
1331
1331
  let h = a._file.path.scope.generateUidIdentifier("test"), v = a._file.path.scope.generateUidIdentifier("describe");
1332
1332
  if (Object.keys(b).length === 0) {
1333
- let _ = m.types.expressionStatement(
1334
- m.types.callExpression(m.types.memberExpression(v, m.types.identifier("skip")), [
1335
- m.types.stringLiteral("No valid tests found")
1333
+ let _ = d.types.expressionStatement(
1334
+ d.types.callExpression(d.types.memberExpression(v, d.types.identifier("skip")), [
1335
+ d.types.stringLiteral("No valid tests found")
1336
1336
  ])
1337
1337
  );
1338
1338
  p.program.body.push(_);
1339
1339
  let S = [
1340
- m.types.importDeclaration(
1340
+ d.types.importDeclaration(
1341
1341
  [
1342
- m.types.importSpecifier(h, m.types.identifier("test")),
1343
- m.types.importSpecifier(v, m.types.identifier("describe"))
1342
+ d.types.importSpecifier(h, d.types.identifier("test")),
1343
+ d.types.importSpecifier(v, d.types.identifier("describe"))
1344
1344
  ],
1345
- m.types.stringLiteral("vitest")
1345
+ d.types.stringLiteral("vitest")
1346
1346
  )
1347
1347
  ];
1348
1348
  p.program.body.unshift(...S);
1349
1349
  } else {
1350
1350
  let le = function() {
1351
- let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = m.types.memberExpression(
1352
- m.types.callExpression(m.types.memberExpression(_, m.types.identifier("getState")), []),
1353
- m.types.identifier("testPath")
1354
- ), k = m.types.memberExpression(
1355
- m.types.memberExpression(m.types.identifier("globalThis"), m.types.identifier("__vitest_worker__")),
1356
- m.types.identifier("filepath")
1357
- ), V = m.types.logicalExpression(
1351
+ let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = d.types.memberExpression(
1352
+ d.types.callExpression(d.types.memberExpression(_, d.types.identifier("getState")), []),
1353
+ d.types.identifier("testPath")
1354
+ ), k = d.types.memberExpression(
1355
+ d.types.memberExpression(d.types.identifier("globalThis"), d.types.identifier("__vitest_worker__")),
1356
+ d.types.identifier("filepath")
1357
+ ), V = d.types.logicalExpression(
1358
1358
  "??",
1359
1359
  // TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
1360
1360
  // https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
1361
1361
  k,
1362
1362
  N
1363
- ), G = m.types.callExpression(
1364
- m.types.memberExpression(
1365
- m.types.memberExpression(
1366
- m.types.memberExpression(m.types.identifier("import"), m.types.identifier("meta")),
1367
- m.types.identifier("url")
1368
- ),
1369
- m.types.identifier("includes")
1363
+ ), G = d.types.callExpression(
1364
+ d.types.memberExpression(
1365
+ d.types.callExpression(d.types.identifier("convertToFilePath"), [
1366
+ d.types.memberExpression(
1367
+ d.types.memberExpression(d.types.identifier("import"), d.types.identifier("meta")),
1368
+ d.types.identifier("url")
1369
+ )
1370
+ ]),
1371
+ d.types.identifier("includes")
1370
1372
  ),
1371
1373
  [V]
1372
1374
  );
1373
- return { isRunningFromThisFileDeclaration: m.types.variableDeclaration("const", [
1374
- m.types.variableDeclarator(j, G)
1375
+ return { isRunningFromThisFileDeclaration: d.types.variableDeclaration("const", [
1376
+ d.types.variableDeclarator(j, G)
1375
1377
  ]), isRunningFromThisFileId: j };
1376
1378
  };
1377
1379
  var mt = le;
1378
1380
  f(le, "getTestGuardDeclaration");
1379
- let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), $e = m.types.identifier(
1381
+ let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), $e = d.types.identifier(
1380
1382
  JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Re, isRunningFromThisFileId: Le } = le();
1381
1383
  p.program.body.push(Re);
1382
1384
  let Me = /* @__PURE__ */ f(({
@@ -1385,13 +1387,13 @@ le an issue with details about your use case.`
1385
1387
  testTitle: k,
1386
1388
  node: V
1387
1389
  }) => {
1388
- let G = m.types.expressionStatement(
1389
- m.types.callExpression(h, [
1390
- m.types.stringLiteral(k),
1391
- m.types.callExpression(S, [
1392
- m.types.stringLiteral(N),
1393
- m.types.identifier(j),
1394
- m.types.identifier(d),
1390
+ let G = d.types.expressionStatement(
1391
+ d.types.callExpression(h, [
1392
+ d.types.stringLiteral(k),
1393
+ d.types.callExpression(S, [
1394
+ d.types.stringLiteral(N),
1395
+ d.types.identifier(j),
1396
+ d.types.identifier(m),
1395
1397
  $e
1396
1398
  ])
1397
1399
  ])
@@ -1409,19 +1411,22 @@ le an issue with details about your use case.`
1409
1411
  }
1410
1412
  let k = a._stories[j].localName ?? j, V = a._stories[j].name ?? j;
1411
1413
  return Me({ testTitle: V, localName: k, exportName: j, node: N });
1412
- }).filter((j) => !!j), qe = m.types.ifStatement(Le, m.types.blockStatement(Ue));
1414
+ }).filter((j) => !!j), qe = d.types.ifStatement(Le, d.types.blockStatement(Ue));
1413
1415
  p.program.body.push(qe);
1414
1416
  let Be = [
1415
- m.types.importDeclaration(
1417
+ d.types.importDeclaration(
1416
1418
  [
1417
- m.types.importSpecifier(h, m.types.identifier("test")),
1418
- m.types.importSpecifier(_, m.types.identifier("expect"))
1419
+ d.types.importSpecifier(h, d.types.identifier("test")),
1420
+ d.types.importSpecifier(_, d.types.identifier("expect"))
1419
1421
  ],
1420
- m.types.stringLiteral("vitest")
1422
+ d.types.stringLiteral("vitest")
1421
1423
  ),
1422
- m.types.importDeclaration(
1423
- [m.types.importSpecifier(S, m.types.identifier("testStory"))],
1424
- m.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1424
+ d.types.importDeclaration(
1425
+ [
1426
+ d.types.importSpecifier(S, d.types.identifier("testStory")),
1427
+ d.types.importSpecifier(d.types.identifier("convertToFilePath"), d.types.identifier("convertToFilePath"))
1428
+ ],
1429
+ d.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1425
1430
  )
1426
1431
  ];
1427
1432
  p.program.body.unshift(...Be);