storybook 9.1.3 → 9.1.5

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.
@@ -35,9 +35,9 @@ var $ = Qe((A) => {
35
35
  t[t.length - 1] = t[t.length - 1].replace(/\r?\n([\t ]*)$/, "");
36
36
  var i = t.reduce(function(c, p) {
37
37
  var d = p.match(/\n([\t ]+|(?!\s).)/g);
38
- return d ? c.concat(d.map(function(g) {
39
- var x, h;
40
- return (h = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && h !== void 0 ? h : 0;
38
+ return d ? c.concat(d.map(function(u) {
39
+ var x, E;
40
+ return (E = (x = u.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && E !== void 0 ? E : 0;
41
41
  })) : c;
42
42
  }, []);
43
43
  if (i.length) {
@@ -51,11 +51,11 @@ var $ = Qe((A) => {
51
51
  t[0] = t[0].replace(/^\r?\n/, "");
52
52
  var o = t[0];
53
53
  return e.forEach(function(c, p) {
54
- var d = o.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = c;
54
+ var d = o.match(/(?:^|\n)( *)$/), u = d ? d[1] : "", x = c;
55
55
  typeof c == "string" && c.includes(`
56
56
  `) && (x = String(c).split(`
57
- `).map(function(h, b) {
58
- return b === 0 ? h : "" + g + h;
57
+ `).map(function(E, b) {
58
+ return b === 0 ? E : "" + u + E;
59
59
  }).join(`
60
60
  `)), o += x + t[p + 1];
61
61
  }), o;
@@ -81,7 +81,7 @@ He(dt, {
81
81
  enrichCsfStory: () => we,
82
82
  extractDescription: () => ae,
83
83
  extractSource: () => Te,
84
- formatConfig: () => Pe,
84
+ formatConfig: () => Oe,
85
85
  formatCsf: () => ie,
86
86
  getStorySortParameter: () => ct,
87
87
  isCsfFactoryPreview: () => lt,
@@ -89,8 +89,8 @@ He(dt, {
89
89
  isValidPreviewPath: () => xe,
90
90
  loadConfig: () => Se,
91
91
  loadCsf: () => Q,
92
- printConfig: () => Oe,
93
- printCsf: () => he,
92
+ printConfig: () => Pe,
93
+ printCsf: () => Ee,
94
94
  readConfig: () => ot,
95
95
  readCsf: () => st,
96
96
  vitestTransform: () => Ae,
@@ -101,11 +101,11 @@ module.exports = Ye(dt);
101
101
 
102
102
  // src/csf-tools/CsfFile.ts
103
103
  var J = require("node:fs/promises"), l = require("storybook/internal/babel"), v = require("storybook/internal/csf"), re = require("storybook/internal/node-logger"),
104
- O = z($(), 1);
104
+ P = z($(), 1);
105
105
 
106
106
  // src/csf-tools/findVarInitialization.ts
107
107
  var N = require("storybook/internal/babel");
108
- var P = /* @__PURE__ */ f((s, e) => {
108
+ var O = /* @__PURE__ */ f((s, e) => {
109
109
  let r = null, t = null;
110
110
  return e.body.find((i) => (N.types.isVariableDeclaration(i) ? t = i.declarations : N.types.isExportNamedDeclaration(i) && N.types.isVariableDeclaration(
111
111
  i.declaration) && (t = i.declaration.declarations), t && t.find((a) => N.types.isVariableDeclarator(a) && N.types.isIdentifier(a.id) && a.
@@ -151,7 +151,7 @@ var D = /* @__PURE__ */ f((s, e) => {
151
151
  let { callee: i, arguments: a } = s;
152
152
  if (l.types.isProgram(e) && l.types.isMemberExpression(i) && l.types.isIdentifier(i.object) && l.types.isIdentifier(i.property) && i.property.
153
153
  name === "bind" && (a.length === 0 || a.length === 1 && l.types.isObjectExpression(a[0]) && a[0].properties.length === 0)) {
154
- let o = i.object.name, c = P(o, e);
154
+ let o = i.object.name, c = O(o, e);
155
155
  c && (r._templates[o] = c, t = c);
156
156
  }
157
157
  }
@@ -189,10 +189,10 @@ var D = /* @__PURE__ */ f((s, e) => {
189
189
  }
190
190
  constructor(e, r, t) {
191
191
  let i = e.trim();
192
- super(O.dedent`
192
+ super(P.dedent`
193
193
  CSF: ${i} ${D(r, t)}
194
194
 
195
- More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error
195
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
196
196
  `), this.name = this.constructor.name;
197
197
  }
198
198
  }, X = class extends Error {
@@ -201,10 +201,10 @@ var D = /* @__PURE__ */ f((s, e) => {
201
201
  }
202
202
  constructor(e, r, t) {
203
203
  let i = `${e} ${D(r, t)}`.trim();
204
- super(O.dedent`
204
+ super(P.dedent`
205
205
  CSF: ${e} ${D(r, t)}
206
206
 
207
- More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error
207
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
208
208
  `), this.name = this.constructor.name;
209
209
  }
210
210
  }, L = class extends Error {
@@ -213,10 +213,10 @@ var D = /* @__PURE__ */ f((s, e) => {
213
213
  }
214
214
  constructor(e, r, t) {
215
215
  let i = `${e} ${D(r, t)}`.trim();
216
- super(O.dedent`
216
+ super(P.dedent`
217
217
  CSF: ${e} ${D(r, t)}
218
218
 
219
- More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error
219
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
220
220
  `), this.name = this.constructor.name;
221
221
  }
222
222
  }, M = class extends Error {
@@ -225,10 +225,10 @@ var D = /* @__PURE__ */ f((s, e) => {
225
225
  }
226
226
  constructor(e, r, t) {
227
227
  let i = "".trim();
228
- super(O.dedent`
228
+ super(P.dedent`
229
229
  CSF: ${e} ${D(r, t)}
230
230
 
231
- More info: https://storybook.js.org/docs/writing-stories#default-export?ref=error
231
+ More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
232
232
  `), this.name = this.constructor.name;
233
233
  }
234
234
  }, K = class {
@@ -246,12 +246,12 @@ var D = /* @__PURE__ */ f((s, e) => {
246
246
  f(this, "CsfFile");
247
247
  }
248
248
  _parseTitle(e) {
249
- let r = l.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
249
+ let r = l.types.isIdentifier(e) ? O(e.name, this._ast.program) : e;
250
250
  if (l.types.isStringLiteral(r))
251
251
  return r.value;
252
252
  if (l.types.isTSSatisfiesExpression(r) && l.types.isStringLiteral(r.expression))
253
253
  return r.expression.value;
254
- throw new Error(O.dedent`
254
+ throw new Error(P.dedent`
255
255
  CSF: unexpected dynamic title ${D(r, this._options.fileName)}
256
256
 
257
257
  More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
@@ -272,7 +272,7 @@ var D = /* @__PURE__ */ f((s, e) => {
272
272
  let a = i.value;
273
273
  if (l.types.isIdentifier(a)) {
274
274
  let c = a.name, p = r.body.find(
275
- (d) => l.types.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === c)
275
+ (d) => l.types.isImportDeclaration(d) && d.specifiers.find((u) => u.local.name === c)
276
276
  );
277
277
  if (p) {
278
278
  let { source: d } = p;
@@ -283,7 +283,7 @@ var D = /* @__PURE__ */ f((s, e) => {
283
283
  t.component = o;
284
284
  } else if (i.key.name === "tags") {
285
285
  let a = i.value;
286
- l.types.isIdentifier(a) && (a = P(a.name, this._ast.program)), t.tags = me(a);
286
+ l.types.isIdentifier(a) && (a = O(a.name, this._ast.program)), t.tags = me(a);
287
287
  } else if (i.key.name === "id")
288
288
  if (l.types.isStringLiteral(i.value))
289
289
  t.id = i.value.value;
@@ -313,28 +313,30 @@ var D = /* @__PURE__ */ f((s, e) => {
313
313
  if (e._options.transformInlineMeta && !o && l.types.isExpression(i.declaration)) {
314
314
  let d = t.scope.generateUidIdentifier("meta");
315
315
  e._metaVariableName = d.name;
316
- let g = [
316
+ let u = [
317
317
  l.types.variableDeclaration("const", [l.types.variableDeclarator(d, i.declaration)]),
318
318
  l.types.exportDefaultDeclaration(d)
319
319
  ];
320
- g.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(g);
320
+ u.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(u);
321
321
  return;
322
322
  }
323
323
  let c, p;
324
324
  if (o) {
325
325
  let d = i.declaration.name;
326
326
  e._metaVariableName = d;
327
- let g = /* @__PURE__ */ f((x) => l.types.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
327
+ let u = /* @__PURE__ */ f((x) => l.types.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
328
328
  e._metaStatement = e._ast.program.body.find(
329
- (x) => l.types.isVariableDeclaration(x) && x.declarations.find(g)
329
+ (x) => l.types.isVariableDeclaration(x) && x.declarations.find(u)
330
330
  ), p = (e?._metaStatement?.declarations || []).find(
331
- g
331
+ u
332
332
  )?.init;
333
333
  } else
334
334
  e._metaStatement = i, p = i.declaration;
335
- if (l.types.isObjectExpression(p) ? c = p : (
336
- // export default { ... } as Meta<...>
337
- (l.types.isTSAsExpression(p) || l.types.isTSSatisfiesExpression(p)) && l.types.isObjectExpression(p.expression) && (c = p.expression)
335
+ if (l.types.isObjectExpression(p) ? c = p : /* export default { ... } as Meta<...> */ /* export default { ... } satisfies Meta<...> */ (l.types.
336
+ isTSAsExpression(p) || l.types.isTSSatisfiesExpression(p)) && l.types.isObjectExpression(p.expression) ? c = p.expression : (
337
+ // export default { ... } satisfies Meta as Meta<...>
338
+ l.types.isTSAsExpression(p) && l.types.isTSSatisfiesExpression(p.expression) && l.types.isObjectExpression(p.expression.expression) &&
339
+ (c = p.expression.expression)
338
340
  ), c && l.types.isProgram(a) && e._parseMeta(c, a), e._metaStatement && !e._metaNode)
339
341
  throw new R(
340
342
  "default export must be an object",
@@ -356,14 +358,15 @@ var D = /* @__PURE__ */ f((s, e) => {
356
358
  return;
357
359
  }
358
360
  e._storyExports[d] = c, e._storyPaths[d] = t, e._storyStatements[d] = i;
359
- let g = (0, v.storyNameFromExport)(d);
361
+ let u = (0, v.storyNameFromExport)(d);
360
362
  e._storyAnnotations[d] ? re.logger.warn(
361
363
  `Unexpected annotations for "${d}" before story declaration`
362
364
  ) : e._storyAnnotations[d] = {};
363
365
  let x;
364
- if (l.types.isVariableDeclarator(c) ? x = l.types.isTSAsExpression(c.init) || l.types.isTSSatisfiesExpression(c.init) ? c.init.
365
- expression : c.init : x = c, l.types.isCallExpression(x) && l.types.isMemberExpression(x.callee) && l.types.isIdentifier(x.callee.
366
- property) && (x.callee.property.name === "story" || x.callee.property.name === "extend") && (p = !0, x = x.arguments[0]), e._metaIsFactory &&
366
+ if (l.types.isVariableDeclarator(c) ? l.types.isTSAsExpression(c.init) && l.types.isTSSatisfiesExpression(c.init.expression) ?
367
+ x = c.init.expression.expression : l.types.isTSAsExpression(c.init) || l.types.isTSSatisfiesExpression(c.init) ? x = c.init.expression :
368
+ x = c.init : x = c, l.types.isCallExpression(x) && l.types.isMemberExpression(x.callee) && l.types.isIdentifier(x.callee.property) &&
369
+ (x.callee.property.name === "story" || x.callee.property.name === "extend") && (p = !0, x = x.arguments[0]), e._metaIsFactory &&
367
370
  !p)
368
371
  throw new L(
369
372
  "expected factory story",
@@ -380,17 +383,17 @@ var D = /* @__PURE__ */ f((s, e) => {
380
383
  x,
381
384
  e._options.fileName
382
385
  );
383
- let h = {};
384
- l.types.isObjectExpression(x) ? (h.__isArgsStory = !0, x.properties.forEach((b) => {
386
+ let E = {};
387
+ l.types.isObjectExpression(x) ? (E.__isArgsStory = !0, x.properties.forEach((b) => {
385
388
  if (l.types.isIdentifier(b.key)) {
386
389
  if (b.key.name === "render")
387
- h.__isArgsStory = ue(
390
+ E.__isArgsStory = ue(
388
391
  b.value,
389
392
  a,
390
393
  e
391
394
  );
392
395
  else if (b.key.name === "name" && l.types.isStringLiteral(b.value))
393
- g = b.value.value;
396
+ u = b.value.value;
394
397
  else if (b.key.name === "storyName" && l.types.isStringLiteral(b.value))
395
398
  re.logger.warn(
396
399
  `Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
@@ -399,14 +402,14 @@ var D = /* @__PURE__ */ f((s, e) => {
399
402
  let _ = b.value.properties.find(
400
403
  (W) => l.types.isObjectProperty(W) && l.types.isIdentifier(W.key) && W.key.name === "__id"
401
404
  );
402
- _ && (h.__id = _.value.value);
405
+ _ && (E.__id = _.value.value);
403
406
  }
404
407
  e._storyAnnotations[d][b.key.name] = b.value;
405
408
  }
406
- })) : h.__isArgsStory = ue(x, a, e), e._stories[d] = {
409
+ })) : E.__isArgsStory = ue(x, a, e), e._stories[d] = {
407
410
  id: "FIXME",
408
- name: g,
409
- parameters: h,
411
+ name: u,
412
+ parameters: E,
410
413
  __stats: {
411
414
  factory: p
412
415
  }
@@ -414,18 +417,20 @@ var D = /* @__PURE__ */ f((s, e) => {
414
417
  }
415
418
  }) : i.specifiers.length > 0 && i.specifiers.forEach((c) => {
416
419
  if (l.types.isExportSpecifier(c) && l.types.isIdentifier(c.exported)) {
417
- let { name: p } = c.exported, { name: d } = c.local, g = l.types.isProgram(a) ? P(d, a) : c.local;
420
+ let { name: p } = c.exported, { name: d } = c.local, u = l.types.isProgram(a) ? O(d, a) : c.local;
418
421
  if (p === "default") {
419
422
  let x;
420
- l.types.isObjectExpression(g) ? x = g : (
421
- // export default { ... } as Meta<...>
422
- l.types.isTSAsExpression(g) && l.types.isObjectExpression(g.expression) && (x = g.expression)
423
+ l.types.isObjectExpression(u) ? x = u : /* export default { ... } as Meta<...> */ /* export default { ... } satisfies Meta<...> */ (l.types.
424
+ isTSAsExpression(u) || l.types.isTSSatisfiesExpression(u)) && l.types.isObjectExpression(u.expression) ? x = u.expression : (
425
+ // export default { ... } satisfies Meta as Meta<...>
426
+ l.types.isTSAsExpression(u) && l.types.isTSSatisfiesExpression(u.expression) && l.types.isObjectExpression(u.expression.expression) &&
427
+ (x = u.expression.expression)
423
428
  ), x && l.types.isProgram(a) && e._parseMeta(x, a);
424
429
  } else {
425
- let x = {}, h = g;
426
- l.types.isObjectExpression(h) && h.properties.forEach((b) => {
430
+ let x = {}, E = u;
431
+ l.types.isObjectExpression(E) && E.properties.forEach((b) => {
427
432
  l.types.isIdentifier(b.key) && (x[b.key.name] = b.value);
428
- }), e._storyAnnotations[p] = x, e._storyStatements[p] = g, e._storyPaths[p] = t, e._stories[p] = {
433
+ }), e._storyAnnotations[p] = x, e._storyStatements[p] = u, e._storyPaths[p] = t, e._stories[p] = {
429
434
  id: "FIXME",
430
435
  name: p,
431
436
  localName: d,
@@ -446,10 +451,10 @@ var D = /* @__PURE__ */ f((s, e) => {
446
451
  if (e._storyAnnotations[o] && (c === "story" && l.types.isObjectExpression(p) ? p.properties.forEach((d) => {
447
452
  l.types.isIdentifier(d.key) && (e._storyAnnotations[o][d.key.name] = d.value);
448
453
  }) : e._storyAnnotations[o][c] = p), c === "storyName" && l.types.isStringLiteral(p)) {
449
- let d = p.value, g = e._stories[o];
450
- if (!g)
454
+ let d = p.value, u = e._stories[o];
455
+ if (!u)
451
456
  return;
452
- g.name = d;
457
+ u.name = d;
453
458
  }
454
459
  }
455
460
  }
@@ -458,10 +463,10 @@ var D = /* @__PURE__ */ f((s, e) => {
458
463
  enter(t) {
459
464
  let { node: i } = t, { callee: a } = i;
460
465
  if (l.types.isIdentifier(a) && a.name === "storiesOf")
461
- throw new Error(O.dedent`
466
+ throw new Error(P.dedent`
462
467
  Unexpected \`storiesOf\` usage: ${D(i, e._options.fileName)}.
463
468
 
464
- SB8 does not support \`storiesOf\`.
469
+ SB8 does not support \`storiesOf\`.
465
470
  `);
466
471
  if (l.types.isMemberExpression(a) && l.types.isIdentifier(a.property) && a.property.name === "meta" && l.types.isIdentifier(a.object) &&
467
472
  i.arguments.length > 0) {
@@ -499,19 +504,19 @@ var D = /* @__PURE__ */ f((s, e) => {
499
504
  let o = a.parameters?.__id ?? (0, v.toId)(e._meta?.id || e._meta?.title, (0, v.storyNameFromExport)(i)), c = { ...a.parameters, __id: o },
500
505
  { includeStories: p } = e._meta || {};
501
506
  i === "__page" && (r.length === 1 || Array.isArray(p) && p.length === 1) && (c.docsOnly = !0), t[i] = { ...a, id: o, parameters: c };
502
- let d = e._storyAnnotations[i], { tags: g, play: x } = d;
503
- if (g) {
504
- let _ = l.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
507
+ let d = e._storyAnnotations[i], { tags: u, play: x } = d;
508
+ if (u) {
509
+ let _ = l.types.isIdentifier(u) ? O(u.name, this._ast.program) : u;
505
510
  t[i].tags = me(_);
506
511
  }
507
512
  x && (t[i].tags = [...t[i].tags || [], "play-fn"]);
508
- let h = t[i].__stats;
513
+ let E = t[i].__stats;
509
514
  ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((_) => {
510
- h[_] = !!d[_] || !!e._metaAnnotations[_];
515
+ E[_] = !!d[_] || !!e._metaAnnotations[_];
511
516
  });
512
517
  let b = e.getStoryExport(i);
513
- return h.storyFn = !!(l.types.isArrowFunctionExpression(b) || l.types.isFunctionDeclaration(b)), h.mount = rt(d.play ?? e._metaAnnotations.
514
- play), h.moduleMock = !!e.imports.find((_) => ye(_)), t;
518
+ return E.storyFn = !!(l.types.isArrowFunctionExpression(b) || l.types.isFunctionDeclaration(b)), E.mount = rt(d.play ?? e._metaAnnotations.
519
+ play), E.moduleMock = !!e.imports.find((_) => ye(_)), t;
515
520
  },
516
521
  {}
517
522
  ), Object.keys(e._storyExports).forEach((t) => {
@@ -539,7 +544,7 @@ var D = /* @__PURE__ */ f((s, e) => {
539
544
  let { fileName: e } = this._options;
540
545
  if (!e)
541
546
  throw new Error(
542
- O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
547
+ P.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
543
548
  Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
544
549
  );
545
550
  return Object.entries(this._stories).map(([r, t]) => {
@@ -568,22 +573,22 @@ var D = /* @__PURE__ */ f((s, e) => {
568
573
  }, "loadCsf"), ie = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, r) => {
569
574
  let t = (0, l.generate)(s._ast, e, r);
570
575
  return e.sourceMaps ? t : t.code;
571
- }, "formatCsf"), he = /* @__PURE__ */ f((s, e = {}) => l.recast.print(s._ast, e), "printCsf"), st = /* @__PURE__ */ f(async (s, e) => {
576
+ }, "formatCsf"), Ee = /* @__PURE__ */ f((s, e = {}) => l.recast.print(s._ast, e), "printCsf"), st = /* @__PURE__ */ f(async (s, e) => {
572
577
  let r = (await (0, J.readFile)(s, "utf-8")).toString();
573
578
  return Q(r, { ...e, fileName: s });
574
579
  }, "readCsf"), nt = /* @__PURE__ */ f(async (s, e) => {
575
580
  if (!(e || s._options.fileName))
576
581
  throw new Error("Please specify a fileName for writeCsf");
577
- await (0, J.writeFile)(e, he(s).code);
582
+ await (0, J.writeFile)(e, Ee(s).code);
578
583
  }, "writeCsf");
579
584
 
580
585
  // src/csf-tools/ConfigFile.ts
581
- var te = require("node:fs/promises"), n = require("storybook/internal/babel"), H = require("storybook/internal/node-logger"), Ee = z($(), 1);
586
+ var te = require("node:fs/promises"), n = require("storybook/internal/babel"), H = require("storybook/internal/node-logger"), he = z($(), 1);
582
587
  var se = /* @__PURE__ */ f(({
583
588
  expectedType: s,
584
589
  foundType: e,
585
590
  node: r
586
- }) => Ee.dedent`
591
+ }) => he.dedent`
587
592
  CSF Parsing error: Expected '${s}' but found '${e}' instead in '${r?.type}'.
588
593
  `, "getCsfParsingErrorMessage"), F = /* @__PURE__ */ f((s) => n.types.isIdentifier(s.key) ? s.key.name : n.types.isStringLiteral(s.key) ?
589
594
  s.key.value : null, "propKey"), Y = /* @__PURE__ */ f((s) => n.types.isTSAsExpression(s) || n.types.isTSSatisfiesExpression(s) ? Y(s.expression) :
@@ -1046,13 +1051,13 @@ s, "unwrap"), _e = /* @__PURE__ */ f((s, e) => {
1046
1051
  return d && (r = p.source.value), d;
1047
1052
  }), i = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), a = /* @__PURE__ */ f(
1048
1053
  (p, d) => p.specifiers.find(
1049
- (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === d
1054
+ (u) => n.types.isImportSpecifier(u) && n.types.isIdentifier(u.imported) && u.imported.name === d
1050
1055
  ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1051
- (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1056
+ (u) => n.types.isImportNamespaceSpecifier(u) && n.types.isIdentifier(u.local) && u.local.name === d
1052
1057
  ), "hasNamespaceImportSpecifier");
1053
1058
  e === null ? t || this._ast.program.body.unshift(n.types.importDeclaration([], n.types.stringLiteral(r))) : typeof e == "string" ? t ? (/* @__PURE__ */ f(
1054
1059
  (p, d) => p.specifiers.find(
1055
- (g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1060
+ (u) => n.types.isImportDefaultSpecifier(u) && n.types.isIdentifier(u.local) && u.local.name === d
1056
1061
  ), "hasDefaultImportSpecifier"))(t, e) || t.specifiers.push(
1057
1062
  n.types.importDefaultSpecifier(n.types.identifier(e))
1058
1063
  ) : this._ast.program.body.unshift(
@@ -1079,7 +1084,7 @@ s, "unwrap"), _e = /* @__PURE__ */ f((s, e) => {
1079
1084
  }, Se = /* @__PURE__ */ f((s, e) => {
1080
1085
  let r = (0, n.babelParse)(s);
1081
1086
  return new ee(r, s, e);
1082
- }, "loadConfig"), Pe = /* @__PURE__ */ f((s) => Oe(s).code, "formatConfig"), Oe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
1087
+ }, "loadConfig"), Oe = /* @__PURE__ */ f((s) => Pe(s).code, "formatConfig"), Pe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
1083
1088
  "printConfig"), ot = /* @__PURE__ */ f(async (s) => {
1084
1089
  let e = (await (0, te.readFile)(s, "utf-8")).toString();
1085
1090
  return Se(e, s).parse();
@@ -1087,7 +1092,7 @@ s, "unwrap"), _e = /* @__PURE__ */ f((s, e) => {
1087
1092
  let r = e || s.fileName;
1088
1093
  if (!r)
1089
1094
  throw new Error("Please specify a fileName for writeConfig");
1090
- await (0, te.writeFile)(r, Pe(s));
1095
+ await (0, te.writeFile)(r, Oe(s));
1091
1096
  }, "writeConfig"), lt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((r) => n.types.isImportDeclaration(r) && r.source.value.includes(
1092
1097
  "@storybook") && r.specifiers.some((t) => n.types.isImportSpecifier(t) && n.types.isIdentifier(t.imported) && t.imported.name === "definePre\
1093
1098
  view")), "isCsfFactoryPreview");
@@ -1140,7 +1145,7 @@ TSModifiers"), Ne = /* @__PURE__ */ f((s) => {
1140
1145
  let r = B(s);
1141
1146
  if (y.types.isObjectExpression(r)) {
1142
1147
  let t = ne(r, "parameters");
1143
- if (y.types.isIdentifier(t) && (t = P(t.name, e)), t)
1148
+ if (y.types.isIdentifier(t) && (t = O(t.name, e)), t)
1144
1149
  return Ne(t);
1145
1150
  } else
1146
1151
  C("default", !0);
@@ -1167,7 +1172,7 @@ TSModifiers"), Ne = /* @__PURE__ */ f((s) => {
1167
1172
  ExportDefaultDeclaration: {
1168
1173
  enter({ node: t }) {
1169
1174
  let i = t.declaration;
1170
- y.types.isIdentifier(i) && (i = P(i.name, r.program)), i = B(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1175
+ y.types.isIdentifier(i) && (i = O(i.name, r.program)), i = B(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1171
1176
  e = ve(i.arguments[0], r.program) : y.types.isObjectExpression(i) ? e = ve(i, r.program) : C("default", !1);
1172
1177
  }
1173
1178
  }
@@ -1188,84 +1193,84 @@ TSModifiers"), Ne = /* @__PURE__ */ f((s) => {
1188
1193
  }, "getStorySortParameter");
1189
1194
 
1190
1195
  // src/csf-tools/enrichCsf.ts
1191
- var u = require("storybook/internal/babel");
1196
+ var g = require("storybook/internal/babel");
1192
1197
  var we = /* @__PURE__ */ f((s, e, r, t) => {
1193
- let i = e.getStoryExport(r), a = u.types.isCallExpression(i) && u.types.isMemberExpression(i.callee) && u.types.isIdentifier(i.callee.object) &&
1194
- i.callee.object.name === "meta", o = !t?.disableSource && Te(i), c = !t?.disableDescription && ae(e._storyStatements[r]), p = [], d = a ? u.types.
1195
- memberExpression(u.types.identifier(r), u.types.identifier("input")) : u.types.identifier(r), g = u.types.memberExpression(d, u.types.identifier(
1198
+ let i = e.getStoryExport(r), a = g.types.isCallExpression(i) && g.types.isMemberExpression(i.callee) && g.types.isIdentifier(i.callee.object) &&
1199
+ i.callee.object.name === "meta", o = !t?.disableSource && Te(i), c = !t?.disableDescription && ae(e._storyStatements[r]), p = [], d = a ? g.types.
1200
+ memberExpression(g.types.identifier(r), g.types.identifier("input")) : g.types.identifier(r), u = g.types.memberExpression(d, g.types.identifier(
1196
1201
  "parameters"));
1197
- p.push(u.types.spreadElement(g));
1198
- let x = u.types.optionalMemberExpression(
1199
- g,
1200
- u.types.identifier("docs"),
1202
+ p.push(g.types.spreadElement(u));
1203
+ let x = g.types.optionalMemberExpression(
1204
+ u,
1205
+ g.types.identifier("docs"),
1201
1206
  !1,
1202
1207
  !0
1203
- ), h = [];
1208
+ ), E = [];
1204
1209
  if (o) {
1205
- let b = u.types.optionalMemberExpression(
1210
+ let b = g.types.optionalMemberExpression(
1206
1211
  x,
1207
- u.types.identifier("source"),
1212
+ g.types.identifier("source"),
1208
1213
  !1,
1209
1214
  !0
1210
1215
  );
1211
- h.push(
1212
- u.types.objectProperty(
1213
- u.types.identifier("source"),
1214
- u.types.objectExpression([
1215
- u.types.objectProperty(u.types.identifier("originalSource"), u.types.stringLiteral(o)),
1216
- u.types.spreadElement(b)
1216
+ E.push(
1217
+ g.types.objectProperty(
1218
+ g.types.identifier("source"),
1219
+ g.types.objectExpression([
1220
+ g.types.objectProperty(g.types.identifier("originalSource"), g.types.stringLiteral(o)),
1221
+ g.types.spreadElement(b)
1217
1222
  ])
1218
1223
  )
1219
1224
  );
1220
1225
  }
1221
1226
  if (c) {
1222
- let b = u.types.optionalMemberExpression(
1227
+ let b = g.types.optionalMemberExpression(
1223
1228
  x,
1224
- u.types.identifier("description"),
1229
+ g.types.identifier("description"),
1225
1230
  !1,
1226
1231
  !0
1227
1232
  );
1228
- h.push(
1229
- u.types.objectProperty(
1230
- u.types.identifier("description"),
1231
- u.types.objectExpression([
1232
- u.types.objectProperty(u.types.identifier("story"), u.types.stringLiteral(c)),
1233
- u.types.spreadElement(b)
1233
+ E.push(
1234
+ g.types.objectProperty(
1235
+ g.types.identifier("description"),
1236
+ g.types.objectExpression([
1237
+ g.types.objectProperty(g.types.identifier("story"), g.types.stringLiteral(c)),
1238
+ g.types.spreadElement(b)
1234
1239
  ])
1235
1240
  )
1236
1241
  );
1237
1242
  }
1238
- if (h.length > 0) {
1243
+ if (E.length > 0) {
1239
1244
  p.push(
1240
- u.types.objectProperty(
1241
- u.types.identifier("docs"),
1242
- u.types.objectExpression([u.types.spreadElement(x), ...h])
1245
+ g.types.objectProperty(
1246
+ g.types.identifier("docs"),
1247
+ g.types.objectExpression([g.types.spreadElement(x), ...E])
1243
1248
  )
1244
1249
  );
1245
- let b = u.types.expressionStatement(
1246
- u.types.assignmentExpression("=", g, u.types.objectExpression(p))
1250
+ let b = g.types.expressionStatement(
1251
+ g.types.assignmentExpression("=", u, g.types.objectExpression(p))
1247
1252
  );
1248
1253
  s._ast.program.body.push(b);
1249
1254
  }
1250
1255
  }, "enrichCsfStory"), Fe = /* @__PURE__ */ f((s, e, r) => {
1251
1256
  if (!e.length) {
1252
1257
  s.properties.find(
1253
- (p) => u.types.isObjectProperty(p) && u.types.isIdentifier(p.key) && p.key.name === "component"
1258
+ (p) => g.types.isObjectProperty(p) && g.types.isIdentifier(p.key) && p.key.name === "component"
1254
1259
  ) || s.properties.unshift(r);
1255
1260
  return;
1256
1261
  }
1257
1262
  let [t, ...i] = e, a = s.properties.find(
1258
- (c) => u.types.isObjectProperty(c) && u.types.isIdentifier(c.key) && c.key.name === t && u.types.isObjectExpression(c.value)
1263
+ (c) => g.types.isObjectProperty(c) && g.types.isIdentifier(c.key) && c.key.name === t && g.types.isObjectExpression(c.value)
1259
1264
  ), o;
1260
- a ? o = a.value : (o = u.types.objectExpression([]), s.properties.push(u.types.objectProperty(u.types.identifier(t), o))), Fe(o, i, r);
1265
+ a ? o = a.value : (o = g.types.objectExpression([]), s.properties.push(g.types.objectProperty(g.types.identifier(t), o))), Fe(o, i, r);
1261
1266
  }, "addComponentDescription"), Ce = /* @__PURE__ */ f((s, e, r) => {
1262
1267
  let t = !r?.disableDescription && ae(e._metaStatement);
1263
1268
  if (t) {
1264
1269
  let i = s._metaNode;
1265
- i && u.types.isObjectExpression(i) && Fe(
1270
+ i && g.types.isObjectExpression(i) && Fe(
1266
1271
  i,
1267
1272
  ["parameters", "docs", "description"],
1268
- u.types.objectProperty(u.types.identifier("component"), u.types.stringLiteral(t))
1273
+ g.types.objectProperty(g.types.identifier("component"), g.types.stringLiteral(t))
1269
1274
  );
1270
1275
  }
1271
1276
  }, "enrichCsfMeta"), pt = /* @__PURE__ */ f((s, e, r) => {
@@ -1273,7 +1278,7 @@ var we = /* @__PURE__ */ f((s, e, r, t) => {
1273
1278
  we(s, e, t, r);
1274
1279
  });
1275
1280
  }, "enrichCsf"), Te = /* @__PURE__ */ f((s) => {
1276
- let e = u.types.isVariableDeclarator(s) ? s.init : s, { code: r } = (0, u.generate)(e, {});
1281
+ let e = g.types.isVariableDeclarator(s) ? s.init : s, { code: r } = (0, g.generate)(e, {});
1277
1282
  return r;
1278
1283
  }, "extractSource"), ae = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((r) => r.type === "CommentLine" || !r.value.startsWith(
1279
1284
  "*") ? null : r.value.split(`
@@ -1300,12 +1305,12 @@ async function Ae({
1300
1305
  let o = Q(s, {
1301
1306
  fileName: e,
1302
1307
  transformInlineMeta: !0,
1303
- makeTitle: /* @__PURE__ */ f((E) => {
1308
+ makeTitle: /* @__PURE__ */ f((h) => {
1304
1309
  let S = (0, ke.getStoryTitle)({
1305
1310
  storyFilePath: e,
1306
1311
  configDir: r,
1307
1312
  stories: t,
1308
- userTitle: E
1313
+ userTitle: h
1309
1314
  }) || "unknown";
1310
1315
  return S === "unknown" && le.logger.warn(
1311
1316
  ce.dedent`
@@ -1314,10 +1319,10 @@ async function Ae({
1314
1319
  `
1315
1320
  ), S;
1316
1321
  }, "makeTitle")
1317
- }).parse(), c = o._ast, p = o._metaVariableName, d = o._metaNode, g = d.properties.find(
1318
- (E) => m.types.isObjectProperty(E) && m.types.isIdentifier(E.key) && E.key.name === "title"
1322
+ }).parse(), c = o._ast, p = o._metaVariableName, d = o._metaNode, u = d.properties.find(
1323
+ (h) => m.types.isObjectProperty(h) && m.types.isIdentifier(h.key) && h.key.name === "title"
1319
1324
  ), x = m.types.stringLiteral(o._meta?.title || "unknown");
1320
- if (g ? m.types.isObjectProperty(g) && (g.value = x) : d.properties.push(m.types.objectProperty(m.types.identifier("title"), x)), !d || !o.
1325
+ if (u ? m.types.isObjectProperty(u) && (u.value = x) : d.properties.push(m.types.objectProperty(m.types.identifier("title"), x)), !d || !o.
1321
1326
  _meta)
1322
1327
  throw new Error(
1323
1328
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
@@ -1325,25 +1330,25 @@ async function Ae({
1325
1330
  Please make sure you have a default export with the meta object. If you are using a different export format that is not supported, please fi\
1326
1331
  le an issue with details about your use case.`
1327
1332
  );
1328
- let h = {};
1329
- Object.keys(o._stories).map((E) => {
1333
+ let E = {};
1334
+ Object.keys(o._stories).map((h) => {
1330
1335
  let S = (0, Ve.combineTags)(
1331
1336
  "test",
1332
1337
  "dev",
1333
1338
  ...a,
1334
1339
  ...o.meta?.tags || [],
1335
- ...o._stories[E].tags || []
1340
+ ...o._stories[h].tags || []
1336
1341
  );
1337
- ft(S, i) && (h[E] = o._storyStatements[E]);
1342
+ ft(S, i) && (E[h] = o._storyStatements[h]);
1338
1343
  });
1339
1344
  let b = o._file.path.scope.generateUidIdentifier("test"), _ = o._file.path.scope.generateUidIdentifier("describe");
1340
- if (Object.keys(h).length === 0) {
1341
- let E = m.types.expressionStatement(
1345
+ if (Object.keys(E).length === 0) {
1346
+ let h = m.types.expressionStatement(
1342
1347
  m.types.callExpression(m.types.memberExpression(_, m.types.identifier("skip")), [
1343
1348
  m.types.stringLiteral("No valid tests found")
1344
1349
  ])
1345
1350
  );
1346
- c.program.body.push(E);
1351
+ c.program.body.push(h);
1347
1352
  let S = [
1348
1353
  m.types.importDeclaration(
1349
1354
  [
@@ -1357,7 +1362,7 @@ le an issue with details about your use case.`
1357
1362
  } else {
1358
1363
  let pe = function() {
1359
1364
  let j = o._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), I = m.types.memberExpression(
1360
- m.types.callExpression(m.types.memberExpression(E, m.types.identifier("getState")), []),
1365
+ m.types.callExpression(m.types.memberExpression(h, m.types.identifier("getState")), []),
1361
1366
  m.types.identifier("testPath")
1362
1367
  ), T = m.types.memberExpression(
1363
1368
  m.types.memberExpression(m.types.identifier("globalThis"), m.types.identifier("__vitest_worker__")),
@@ -1386,7 +1391,7 @@ le an issue with details about your use case.`
1386
1391
  };
1387
1392
  var W = pe;
1388
1393
  f(pe, "getTestGuardDeclaration");
1389
- let E = o._file.path.scope.generateUidIdentifier("expect"), S = o._file.path.scope.generateUidIdentifier("testStory"), Re = m.types.identifier(
1394
+ let h = o._file.path.scope.generateUidIdentifier("expect"), S = o._file.path.scope.generateUidIdentifier("testStory"), Re = m.types.identifier(
1390
1395
  JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Le, isRunningFromThisFileId: Me } = pe();
1391
1396
  c.program.body.push(Le);
1392
1397
  let Ue = /* @__PURE__ */ f(({
@@ -1407,7 +1412,7 @@ le an issue with details about your use case.`
1407
1412
  ])
1408
1413
  );
1409
1414
  return G.loc = k.loc, G;
1410
- }, "getTestStatementForStory"), qe = Object.entries(h).map(([j, I]) => {
1415
+ }, "getTestStatementForStory"), qe = Object.entries(E).map(([j, I]) => {
1411
1416
  if (I === null) {
1412
1417
  le.logger.warn(
1413
1418
  ce.dedent`
@@ -1425,7 +1430,7 @@ le an issue with details about your use case.`
1425
1430
  m.types.importDeclaration(
1426
1431
  [
1427
1432
  m.types.importSpecifier(b, m.types.identifier("test")),
1428
- m.types.importSpecifier(E, m.types.identifier("expect"))
1433
+ m.types.importSpecifier(h, m.types.identifier("expect"))
1429
1434
  ],
1430
1435
  m.types.stringLiteral("vitest")
1431
1436
  ),