storybook 9.1.0-alpha.0 → 9.1.0-alpha.10

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 (112) hide show
  1. package/assets/browser/favicon-wrapper.svg +46 -0
  2. package/assets/browser/favicon.svg +1 -1
  3. package/dist/actions/index.cjs +16 -16
  4. package/dist/actions/index.d.ts +1 -38
  5. package/dist/actions/index.js +12 -12
  6. package/dist/bin/index.cjs +62 -69
  7. package/dist/bin/index.js +43 -50
  8. package/dist/builder-manager/index.cjs +379 -378
  9. package/dist/builder-manager/index.d.ts +567 -2
  10. package/dist/builder-manager/index.js +280 -279
  11. package/dist/cli/bin/index.cjs +945 -945
  12. package/dist/cli/bin/index.js +673 -672
  13. package/dist/cli/index.cjs +14965 -14973
  14. package/dist/cli/index.d.ts +713 -15
  15. package/dist/cli/index.js +13488 -13495
  16. package/dist/common/index.cjs +11211 -11103
  17. package/dist/common/index.d.ts +351 -72
  18. package/dist/common/index.js +18491 -18379
  19. package/dist/components/index.cjs +4606 -4425
  20. package/dist/components/index.d.ts +11 -12
  21. package/dist/components/index.js +3020 -2834
  22. package/dist/controls/index.cjs +16 -16
  23. package/dist/controls/index.d.ts +1 -36
  24. package/dist/core-server/index.cjs +6690 -6624
  25. package/dist/core-server/index.d.ts +14 -2
  26. package/dist/core-server/index.js +6088 -6023
  27. package/dist/core-server/presets/common-manager.js +3582 -3475
  28. package/dist/core-server/presets/common-preset.cjs +85015 -5213
  29. package/dist/core-server/presets/common-preset.js +85107 -5291
  30. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.cjs +28728 -0
  31. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +28729 -0
  32. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.cjs +29339 -0
  33. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +29340 -0
  34. package/dist/csf/index.cjs +3019 -104
  35. package/dist/csf/index.d.ts +301 -18
  36. package/dist/csf/index.js +3031 -98
  37. package/dist/csf-tools/index.cjs +489 -488
  38. package/dist/csf-tools/index.js +311 -309
  39. package/dist/highlight/index.cjs +15 -15
  40. package/dist/highlight/index.d.ts +1 -12
  41. package/dist/highlight/index.js +4 -4
  42. package/dist/instrumenter/index.cjs +1308 -1239
  43. package/dist/instrumenter/index.d.ts +25 -3
  44. package/dist/instrumenter/index.js +1345 -1280
  45. package/dist/manager/globals-module-info.cjs +1 -1
  46. package/dist/manager/globals-module-info.js +1 -1
  47. package/dist/manager/globals-runtime.js +42257 -44665
  48. package/dist/manager/runtime.js +3715 -3536
  49. package/dist/manager-api/index.cjs +74 -74
  50. package/dist/manager-api/index.d.ts +4 -1
  51. package/dist/manager-api/index.js +142 -142
  52. package/dist/node-logger/index.cjs +8520 -994
  53. package/dist/node-logger/index.d.ts +395 -2
  54. package/dist/node-logger/index.js +8535 -995
  55. package/dist/preview/runtime.js +13701 -16331
  56. package/dist/preview-api/index.cjs +1434 -1458
  57. package/dist/preview-api/index.d.ts +13 -10
  58. package/dist/preview-api/index.js +950 -976
  59. package/dist/server-errors.cjs +201 -242
  60. package/dist/server-errors.d.ts +1 -12
  61. package/dist/server-errors.js +182 -223
  62. package/dist/telemetry/index.cjs +1919 -1638
  63. package/dist/telemetry/index.d.ts +4 -2
  64. package/dist/telemetry/index.js +1972 -1690
  65. package/dist/test/index.cjs +9184 -9816
  66. package/dist/test/index.d.ts +8 -1
  67. package/dist/test/index.js +8390 -9029
  68. package/dist/types/index.d.ts +19 -17
  69. package/dist/viewport/index.cjs +17 -24
  70. package/dist/viewport/index.d.ts +9 -532
  71. package/dist/viewport/index.js +9 -16
  72. package/package.json +18 -187
  73. package/templates/mocker-runtime.template.js +89 -0
  74. package/dist/actions/preview.cjs +0 -159
  75. package/dist/actions/preview.d.ts +0 -555
  76. package/dist/actions/preview.js +0 -149
  77. package/dist/backgrounds/index.cjs +0 -148
  78. package/dist/backgrounds/index.d.ts +0 -592
  79. package/dist/backgrounds/index.js +0 -130
  80. package/dist/backgrounds/preview.cjs +0 -143
  81. package/dist/backgrounds/preview.d.ts +0 -555
  82. package/dist/backgrounds/preview.js +0 -127
  83. package/dist/component-testing/index.cjs +0 -23
  84. package/dist/component-testing/index.d.ts +0 -3
  85. package/dist/component-testing/index.js +0 -5
  86. package/dist/component-testing/preview.cjs +0 -40
  87. package/dist/component-testing/preview.d.ts +0 -5
  88. package/dist/component-testing/preview.js +0 -25
  89. package/dist/controls/preview.cjs +0 -26
  90. package/dist/controls/preview.d.ts +0 -555
  91. package/dist/controls/preview.js +0 -9
  92. package/dist/highlight/preview.cjs +0 -590
  93. package/dist/highlight/preview.d.ts +0 -555
  94. package/dist/highlight/preview.js +0 -574
  95. package/dist/measure/index.cjs +0 -476
  96. package/dist/measure/index.d.ts +0 -567
  97. package/dist/measure/index.js +0 -464
  98. package/dist/measure/preview.cjs +0 -466
  99. package/dist/measure/preview.d.ts +0 -560
  100. package/dist/measure/preview.js +0 -450
  101. package/dist/outline/index.cjs +0 -528
  102. package/dist/outline/index.d.ts +0 -567
  103. package/dist/outline/index.js +0 -500
  104. package/dist/outline/preview.cjs +0 -518
  105. package/dist/outline/preview.d.ts +0 -560
  106. package/dist/outline/preview.js +0 -486
  107. package/dist/test/preview.cjs +0 -73
  108. package/dist/test/preview.d.ts +0 -555
  109. package/dist/test/preview.js +0 -66
  110. package/dist/viewport/preview.cjs +0 -35
  111. package/dist/viewport/preview.d.ts +0 -569
  112. package/dist/viewport/preview.js +0 -19
@@ -27,10 +27,10 @@ var U = (s, e, r) => (r = s != null ? ke($e(s)) : {}, Me(
27
27
  ));
28
28
 
29
29
  // ../node_modules/ts-dedent/dist/index.js
30
- var V = Le((k) => {
30
+ var k = Le((T) => {
31
31
  "use strict";
32
- Object.defineProperty(k, "__esModule", { value: !0 });
33
- k.dedent = void 0;
32
+ Object.defineProperty(T, "__esModule", { value: !0 });
33
+ T.dedent = void 0;
34
34
  function se(s) {
35
35
  for (var e = [], r = 1; r < arguments.length; r++)
36
36
  e[r - 1] = arguments[r];
@@ -38,38 +38,38 @@ var V = Le((k) => {
38
38
  t[t.length - 1] = t[t.length - 1].replace(/\r?\n([\t ]*)$/, "");
39
39
  var i = t.reduce(function(l, p) {
40
40
  var d = p.match(/\n([\t ]+|(?!\s).)/g);
41
- return d ? l.concat(d.map(function(m) {
41
+ return d ? l.concat(d.map(function(u) {
42
42
  var x, b;
43
- return (b = (x = m.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && b !== void 0 ? b : 0;
43
+ return (b = (x = u.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && b !== void 0 ? b : 0;
44
44
  })) : l;
45
45
  }, []);
46
46
  if (i.length) {
47
- var o = new RegExp(`
47
+ var a = new RegExp(`
48
48
  [ ]{` + Math.min.apply(Math, i) + "}", "g");
49
49
  t = t.map(function(l) {
50
- return l.replace(o, `
50
+ return l.replace(a, `
51
51
  `);
52
52
  });
53
53
  }
54
54
  t[0] = t[0].replace(/^\r?\n/, "");
55
- var a = t[0];
55
+ var o = t[0];
56
56
  return e.forEach(function(l, p) {
57
- var d = a.match(/(?:^|\n)( *)$/), m = d ? d[1] : "", x = l;
57
+ var d = o.match(/(?:^|\n)( *)$/), u = d ? d[1] : "", x = l;
58
58
  typeof l == "string" && l.includes(`
59
59
  `) && (x = String(l).split(`
60
60
  `).map(function(b, y) {
61
- return y === 0 ? b : "" + m + b;
61
+ return y === 0 ? b : "" + u + b;
62
62
  }).join(`
63
- `)), a += x + t[p + 1];
64
- }), a;
63
+ `)), o += x + t[p + 1];
64
+ }), o;
65
65
  }
66
66
  f(se, "dedent");
67
- k.dedent = se;
68
- k.default = se;
67
+ T.dedent = se;
68
+ T.default = se;
69
69
  });
70
70
 
71
71
  // src/csf-tools/CsfFile.ts
72
- var O = U(V(), 1);
72
+ var O = U(k(), 1);
73
73
  import { readFile as Ue, writeFile as qe } from "node:fs/promises";
74
74
  import {
75
75
  BabelFileClass as Be,
@@ -80,18 +80,19 @@ import {
80
80
  traverse as Ge
81
81
  } from "storybook/internal/babel";
82
82
  import { isExportStory as ne, storyNameFromExport as oe, toId as ze } from "storybook/internal/csf";
83
+ import { logger as ae } from "storybook/internal/node-logger";
83
84
 
84
85
  // src/csf-tools/findVarInitialization.ts
85
- import { types as A } from "storybook/internal/babel";
86
+ import { types as V } from "storybook/internal/babel";
86
87
  var P = /* @__PURE__ */ f((s, e) => {
87
88
  let r = null, t = null;
88
- return e.body.find((i) => (A.isVariableDeclaration(i) ? t = i.declarations : A.isExportNamedDeclaration(i) && A.isVariableDeclaration(i.declaration) &&
89
- (t = i.declaration.declarations), t && t.find((o) => A.isVariableDeclarator(o) && A.isIdentifier(o.id) && o.id.name === s ? (r = o.init, !0) :
89
+ return e.body.find((i) => (V.isVariableDeclaration(i) ? t = i.declarations : V.isExportNamedDeclaration(i) && V.isVariableDeclaration(i.declaration) &&
90
+ (t = i.declaration.declarations), t && t.find((a) => V.isVariableDeclarator(a) && V.isIdentifier(a.id) && a.id.name === s ? (r = a.init, !0) :
90
91
  !1))), r;
91
92
  }, "findVarInitialization");
92
93
 
93
94
  // src/csf-tools/CsfFile.ts
94
- var ae = console, Xe = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, Ke = /* @__PURE__ */ f((s) => Xe.test(s), "isValidPreviewPath");
95
+ var Xe = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, Ke = /* @__PURE__ */ f((s) => Xe.test(s), "isValidPreviewPath");
95
96
  function Je(s) {
96
97
  if (c.isArrayExpression(s))
97
98
  return s.elements.map((e) => {
@@ -126,11 +127,11 @@ var v = /* @__PURE__ */ f((s, e) => {
126
127
  }, "formatLocation"), Qe = /* @__PURE__ */ f((s) => Ze.test(s), "isModuleMock"), ce = /* @__PURE__ */ f((s, e, r) => {
127
128
  let t = s;
128
129
  if (c.isCallExpression(s)) {
129
- let { callee: i, arguments: o } = s;
130
+ let { callee: i, arguments: a } = s;
130
131
  if (c.isProgram(e) && c.isMemberExpression(i) && c.isIdentifier(i.object) && c.isIdentifier(i.property) && i.property.name === "bind" &&
131
- (o.length === 0 || o.length === 1 && c.isObjectExpression(o[0]) && o[0].properties.length === 0)) {
132
- let a = i.object.name, l = P(a, e);
133
- l && (r._templates[a] = l, t = l);
132
+ (a.length === 0 || a.length === 1 && c.isObjectExpression(a[0]) && a[0].properties.length === 0)) {
133
+ let o = i.object.name, l = P(o, e);
134
+ l && (r._templates[o] = l, t = l);
134
135
  }
135
136
  }
136
137
  return c.isArrowFunctionExpression(t) || c.isFunctionDeclaration(t) ? t.params.length > 0 : !1;
@@ -166,9 +167,9 @@ var v = /* @__PURE__ */ f((s, e) => {
166
167
  f(this, "NoMetaError");
167
168
  }
168
169
  constructor(e, r, t) {
169
- let i = "".trim();
170
+ let i = e.trim();
170
171
  super(O.dedent`
171
- CSF: ${e} ${v(r, t)}
172
+ CSF: ${i} ${v(r, t)}
172
173
 
173
174
  More info: https://storybook.js.org/docs/writing-stories#default-export
174
175
  `), this.name = this.constructor.name;
@@ -247,21 +248,21 @@ var v = /* @__PURE__ */ f((s, e) => {
247
248
  else if (["includeStories", "excludeStories"].includes(i.key.name))
248
249
  t[i.key.name] = Je(i.value);
249
250
  else if (i.key.name === "component") {
250
- let o = i.value;
251
- if (c.isIdentifier(o)) {
252
- let l = o.name, p = r.body.find(
253
- (d) => c.isImportDeclaration(d) && d.specifiers.find((m) => m.local.name === l)
251
+ let a = i.value;
252
+ if (c.isIdentifier(a)) {
253
+ let l = a.name, p = r.body.find(
254
+ (d) => c.isImportDeclaration(d) && d.specifiers.find((u) => u.local.name === l)
254
255
  );
255
256
  if (p) {
256
257
  let { source: d } = p;
257
258
  c.isStringLiteral(d) && (this._rawComponentPath = d.value);
258
259
  }
259
260
  }
260
- let { code: a } = de.print(i.value, {});
261
- t.component = a;
261
+ let { code: o } = de.print(i.value, {});
262
+ t.component = o;
262
263
  } else if (i.key.name === "tags") {
263
- let o = i.value;
264
- c.isIdentifier(o) && (o = P(o.name, this._ast.program)), t.tags = le(o);
264
+ let a = i.value;
265
+ c.isIdentifier(a) && (a = P(a.name, this._ast.program)), t.tags = le(a);
265
266
  } else if (i.key.name === "id")
266
267
  if (c.isStringLiteral(i.value))
267
268
  t.id = i.value.value;
@@ -276,8 +277,8 @@ var v = /* @__PURE__ */ f((s, e) => {
276
277
  let { callee: t, arguments: i } = r;
277
278
  if (c.isMemberExpression(t) && c.isIdentifier(t.object) && c.isIdentifier(t.property) && t.property.name === "bind" && (i.length === 0 ||
278
279
  i.length === 1 && c.isObjectExpression(i[0]) && i[0].properties.length === 0)) {
279
- let { name: o } = t.object;
280
- r = this._templates[o];
280
+ let { name: a } = t.object;
281
+ r = this._templates[a];
281
282
  }
282
283
  }
283
284
  return r;
@@ -287,33 +288,33 @@ var v = /* @__PURE__ */ f((s, e) => {
287
288
  if (Ge(this._ast, {
288
289
  ExportDefaultDeclaration: {
289
290
  enter(t) {
290
- let { node: i, parent: o } = t, a = c.isIdentifier(i.declaration) && c.isProgram(o);
291
- if (e._options.transformInlineMeta && !a && c.isExpression(i.declaration)) {
291
+ let { node: i, parent: a } = t, o = c.isIdentifier(i.declaration) && c.isProgram(a);
292
+ if (e._options.transformInlineMeta && !o && c.isExpression(i.declaration)) {
292
293
  let d = t.scope.generateUidIdentifier("meta");
293
294
  e._metaVariableName = d.name;
294
- let m = [
295
+ let u = [
295
296
  c.variableDeclaration("const", [c.variableDeclarator(d, i.declaration)]),
296
297
  c.exportDefaultDeclaration(d)
297
298
  ];
298
- m.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(m);
299
+ u.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(u);
299
300
  return;
300
301
  }
301
302
  let l, p;
302
- if (a) {
303
+ if (o) {
303
304
  let d = i.declaration.name;
304
305
  e._metaVariableName = d;
305
- let m = /* @__PURE__ */ f((x) => c.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
306
+ let u = /* @__PURE__ */ f((x) => c.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
306
307
  e._metaStatement = e._ast.program.body.find(
307
- (x) => c.isVariableDeclaration(x) && x.declarations.find(m)
308
+ (x) => c.isVariableDeclaration(x) && x.declarations.find(u)
308
309
  ), p = (e?._metaStatement?.declarations || []).find(
309
- m
310
+ u
310
311
  )?.init;
311
312
  } else
312
313
  e._metaStatement = i, p = i.declaration;
313
314
  if (c.isObjectExpression(p) ? l = p : (
314
315
  // export default { ... } as Meta<...>
315
316
  (c.isTSAsExpression(p) || c.isTSSatisfiesExpression(p)) && c.isObjectExpression(p.expression) && (l = p.expression)
316
- ), l && c.isProgram(o) && e._parseMeta(l, o), e._metaStatement && !e._metaNode)
317
+ ), l && c.isProgram(a) && e._parseMeta(l, a), e._metaStatement && !e._metaNode)
317
318
  throw new q(
318
319
  "default export must be an object",
319
320
  e._metaStatement,
@@ -324,9 +325,9 @@ var v = /* @__PURE__ */ f((s, e) => {
324
325
  },
325
326
  ExportNamedDeclaration: {
326
327
  enter(t) {
327
- let { node: i, parent: o } = t, a;
328
- c.isVariableDeclaration(i.declaration) ? a = i.declaration.declarations.filter((l) => c.isVariableDeclarator(l)) : c.isFunctionDeclaration(
329
- i.declaration) && (a = [i.declaration]), a ? a.forEach((l) => {
328
+ let { node: i, parent: a } = t, o;
329
+ c.isVariableDeclaration(i.declaration) ? o = i.declaration.declarations.filter((l) => c.isVariableDeclarator(l)) : c.isFunctionDeclaration(
330
+ i.declaration) && (o = [i.declaration]), o ? o.forEach((l) => {
330
331
  if (c.isIdentifier(l.id)) {
331
332
  let p = !1, { name: d } = l.id;
332
333
  if (d === "__namedExportsOrder" && c.isVariableDeclarator(l)) {
@@ -334,14 +335,14 @@ var v = /* @__PURE__ */ f((s, e) => {
334
335
  return;
335
336
  }
336
337
  e._storyExports[d] = l, e._storyPaths[d] = t, e._storyStatements[d] = i;
337
- let m = oe(d);
338
+ let u = oe(d);
338
339
  e._storyAnnotations[d] ? ae.warn(
339
340
  `Unexpected annotations for "${d}" before story declaration`
340
341
  ) : e._storyAnnotations[d] = {};
341
342
  let x;
342
343
  if (c.isVariableDeclarator(l) ? x = c.isTSAsExpression(l.init) || c.isTSSatisfiesExpression(l.init) ? l.init.expression : l.init :
343
- x = l, c.isCallExpression(x) && c.isMemberExpression(x.callee) && c.isIdentifier(x.callee.property) && x.callee.property.name ===
344
- "story" && (p = !0, x = x.arguments[0]), e._metaIsFactory && !p)
344
+ x = l, c.isCallExpression(x) && c.isMemberExpression(x.callee) && c.isIdentifier(x.callee.property) && (x.callee.property.name ===
345
+ "story" || x.callee.property.name === "extend") && (p = !0, x = x.arguments[0]), e._metaIsFactory && !p)
345
346
  throw new B(
346
347
  "expected factory story",
347
348
  x,
@@ -363,26 +364,26 @@ var v = /* @__PURE__ */ f((s, e) => {
363
364
  if (y.key.name === "render")
364
365
  b.__isArgsStory = ce(
365
366
  y.value,
366
- o,
367
+ a,
367
368
  e
368
369
  );
369
370
  else if (y.key.name === "name" && c.isStringLiteral(y.value))
370
- m = y.value.value;
371
+ u = y.value.value;
371
372
  else if (y.key.name === "storyName" && c.isStringLiteral(y.value))
372
373
  ae.warn(
373
374
  `Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
374
375
  );
375
376
  else if (y.key.name === "parameters" && c.isObjectExpression(y.value)) {
376
- let E = y.value.properties.find(
377
- (D) => c.isObjectProperty(D) && c.isIdentifier(D.key) && D.key.name === "__id"
377
+ let _ = y.value.properties.find(
378
+ (L) => c.isObjectProperty(L) && c.isIdentifier(L.key) && L.key.name === "__id"
378
379
  );
379
- E && (b.__id = E.value.value);
380
+ _ && (b.__id = _.value.value);
380
381
  }
381
382
  e._storyAnnotations[d][y.key.name] = y.value;
382
383
  }
383
- })) : b.__isArgsStory = ce(x, o, e), e._stories[d] = {
384
+ })) : b.__isArgsStory = ce(x, a, e), e._stories[d] = {
384
385
  id: "FIXME",
385
- name: m,
386
+ name: u,
386
387
  parameters: b,
387
388
  __stats: {
388
389
  factory: p
@@ -391,18 +392,18 @@ var v = /* @__PURE__ */ f((s, e) => {
391
392
  }
392
393
  }) : i.specifiers.length > 0 && i.specifiers.forEach((l) => {
393
394
  if (c.isExportSpecifier(l) && c.isIdentifier(l.exported)) {
394
- let { name: p } = l.exported, { name: d } = l.local, m = c.isProgram(o) ? P(d, o) : l.local;
395
+ let { name: p } = l.exported, { name: d } = l.local, u = c.isProgram(a) ? P(d, a) : l.local;
395
396
  if (p === "default") {
396
397
  let x;
397
- c.isObjectExpression(m) ? x = m : (
398
+ c.isObjectExpression(u) ? x = u : (
398
399
  // export default { ... } as Meta<...>
399
- c.isTSAsExpression(m) && c.isObjectExpression(m.expression) && (x = m.expression)
400
- ), x && c.isProgram(o) && e._parseMeta(x, o);
400
+ c.isTSAsExpression(u) && c.isObjectExpression(u.expression) && (x = u.expression)
401
+ ), x && c.isProgram(a) && e._parseMeta(x, a);
401
402
  } else {
402
- let x = {}, b = m;
403
+ let x = {}, b = u;
403
404
  c.isObjectExpression(b) && b.properties.forEach((y) => {
404
405
  c.isIdentifier(y.key) && (x[y.key.name] = y.value);
405
- }), e._storyAnnotations[p] = x, e._storyStatements[p] = m, e._storyPaths[p] = t, e._stories[p] = {
406
+ }), e._storyAnnotations[p] = x, e._storyStatements[p] = u, e._storyPaths[p] = t, e._stories[p] = {
406
407
  id: "FIXME",
407
408
  name: p,
408
409
  localName: d,
@@ -416,37 +417,37 @@ var v = /* @__PURE__ */ f((s, e) => {
416
417
  },
417
418
  ExpressionStatement: {
418
419
  enter({ node: t, parent: i }) {
419
- let { expression: o } = t;
420
- if (c.isProgram(i) && c.isAssignmentExpression(o) && c.isMemberExpression(o.left) && c.isIdentifier(o.left.object) && c.isIdentifier(
421
- o.left.property)) {
422
- let a = o.left.object.name, l = o.left.property.name, p = o.right;
423
- if (e._storyAnnotations[a] && (l === "story" && c.isObjectExpression(p) ? p.properties.forEach((d) => {
424
- c.isIdentifier(d.key) && (e._storyAnnotations[a][d.key.name] = d.value);
425
- }) : e._storyAnnotations[a][l] = p), l === "storyName" && c.isStringLiteral(p)) {
426
- let d = p.value, m = e._stories[a];
427
- if (!m)
420
+ let { expression: a } = t;
421
+ if (c.isProgram(i) && c.isAssignmentExpression(a) && c.isMemberExpression(a.left) && c.isIdentifier(a.left.object) && c.isIdentifier(
422
+ a.left.property)) {
423
+ let o = a.left.object.name, l = a.left.property.name, p = a.right;
424
+ if (e._storyAnnotations[o] && (l === "story" && c.isObjectExpression(p) ? p.properties.forEach((d) => {
425
+ c.isIdentifier(d.key) && (e._storyAnnotations[o][d.key.name] = d.value);
426
+ }) : e._storyAnnotations[o][l] = p), l === "storyName" && c.isStringLiteral(p)) {
427
+ let d = p.value, u = e._stories[o];
428
+ if (!u)
428
429
  return;
429
- m.name = d;
430
+ u.name = d;
430
431
  }
431
432
  }
432
433
  }
433
434
  },
434
435
  CallExpression: {
435
436
  enter(t) {
436
- let { node: i } = t, { callee: o } = i;
437
- if (c.isIdentifier(o) && o.name === "storiesOf")
437
+ let { node: i } = t, { callee: a } = i;
438
+ if (c.isIdentifier(a) && a.name === "storiesOf")
438
439
  throw new Error(O.dedent`
439
440
  Unexpected \`storiesOf\` usage: ${v(i, e._options.fileName)}.
440
441
 
441
442
  SB8 does not support \`storiesOf\`.
442
443
  `);
443
- if (c.isMemberExpression(o) && c.isIdentifier(o.property) && o.property.name === "meta" && c.isIdentifier(o.object) && i.arguments.
444
+ if (c.isMemberExpression(a) && c.isIdentifier(a.property) && a.property.name === "meta" && c.isIdentifier(a.object) && i.arguments.
444
445
  length > 0) {
445
- let l = t.scope.getBinding(o.object.name)?.path?.parentPath?.node;
446
+ let l = t.scope.getBinding(a.object.name)?.path?.parentPath?.node;
446
447
  if (c.isImportDeclaration(l))
447
448
  if (Ke(l.source.value)) {
448
449
  let p = i.arguments[0];
449
- e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
450
+ e._metaVariableName = a.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
450
451
  } else
451
452
  throw new W(
452
453
  "meta() factory must be imported from .storybook/preview configuration",
@@ -470,25 +471,25 @@ var v = /* @__PURE__ */ f((s, e) => {
470
471
  let r = Object.entries(e._stories);
471
472
  if (e._meta.title = this._options.makeTitle(e._meta?.title), e._metaAnnotations.play && (e._meta.tags = [...e._meta.tags || [], "play-fn"]),
472
473
  e._stories = r.reduce(
473
- (t, [i, o]) => {
474
+ (t, [i, a]) => {
474
475
  if (!ne(i, e._meta))
475
476
  return t;
476
- let a = o.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, oe(i)), l = { ...o.parameters, __id: a }, { includeStories: p } = e.
477
+ let o = a.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, oe(i)), l = { ...a.parameters, __id: o }, { includeStories: p } = e.
477
478
  _meta || {};
478
- i === "__page" && (r.length === 1 || Array.isArray(p) && p.length === 1) && (l.docsOnly = !0), t[i] = { ...o, id: a, parameters: l };
479
- let d = e._storyAnnotations[i], { tags: m, play: x } = d;
480
- if (m) {
481
- let E = c.isIdentifier(m) ? P(m.name, this._ast.program) : m;
482
- t[i].tags = le(E);
479
+ i === "__page" && (r.length === 1 || Array.isArray(p) && p.length === 1) && (l.docsOnly = !0), t[i] = { ...a, id: o, parameters: l };
480
+ let d = e._storyAnnotations[i], { tags: u, play: x } = d;
481
+ if (u) {
482
+ let _ = c.isIdentifier(u) ? P(u.name, this._ast.program) : u;
483
+ t[i].tags = le(_);
483
484
  }
484
485
  x && (t[i].tags = [...t[i].tags || [], "play-fn"]);
485
486
  let b = t[i].__stats;
486
- ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((E) => {
487
- b[E] = !!d[E] || !!e._metaAnnotations[E];
487
+ ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((_) => {
488
+ b[_] = !!d[_] || !!e._metaAnnotations[_];
488
489
  });
489
490
  let y = e.getStoryExport(i);
490
491
  return b.storyFn = !!(c.isArrowFunctionExpression(y) || c.isFunctionDeclaration(y)), b.mount = Ye(d.play ?? e._metaAnnotations.play),
491
- b.moduleMock = !!e.imports.find((E) => Qe(E)), t;
492
+ b.moduleMock = !!e.imports.find((_) => Qe(_)), t;
492
493
  },
493
494
  {}
494
495
  ), Object.keys(e._storyExports).forEach((t) => {
@@ -500,7 +501,7 @@ var v = /* @__PURE__ */ f((s, e) => {
500
501
  if (t.length !== i.length)
501
502
  throw new Error(
502
503
  `Missing exports after sort: ${t.filter(
503
- (o) => !i.includes(o)
504
+ (a) => !i.includes(a)
504
505
  )}`
505
506
  );
506
507
  }
@@ -542,7 +543,7 @@ var v = /* @__PURE__ */ f((s, e) => {
542
543
  }) => new Be({ filename: e }, { code: s, ast: r ?? fe(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
543
544
  let r = fe(s), t = et({ code: s, filename: e.fileName, ast: r });
544
545
  return new J(r, e, t);
545
- }, "loadCsf"), ue = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, r) => {
546
+ }, "loadCsf"), me = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, r) => {
546
547
  let t = We(s._ast, e, r);
547
548
  return e.sourceMaps ? t : t.code;
548
549
  }, "formatCsf"), tt = /* @__PURE__ */ f((s, e = {}) => de.print(s._ast, e), "printCsf"), Ft = /* @__PURE__ */ f(async (s, e) => {
@@ -555,28 +556,29 @@ var v = /* @__PURE__ */ f((s, e) => {
555
556
  }, "writeCsf");
556
557
 
557
558
  // src/csf-tools/ConfigFile.ts
558
- var ye = U(V(), 1);
559
+ var ye = U(k(), 1);
559
560
  import { readFile as rt, writeFile as it } from "node:fs/promises";
560
561
  import {
561
562
  babelParse as xe,
562
- generate as me,
563
+ generate as ue,
563
564
  recast as st,
564
565
  types as n,
565
566
  traverse as ge
566
567
  } from "storybook/internal/babel";
567
- var H = console, Y = /* @__PURE__ */ f(({
568
+ import { logger as H } from "storybook/internal/node-logger";
569
+ var Y = /* @__PURE__ */ f(({
568
570
  expectedType: s,
569
571
  foundType: e,
570
572
  node: r
571
573
  }) => ye.dedent`
572
574
  CSF Parsing error: Expected '${s}' but found '${e}' instead in '${r?.type}'.
573
- `, "getCsfParsingErrorMessage"), w = /* @__PURE__ */ f((s) => n.isIdentifier(s.key) ? s.key.name : n.isStringLiteral(s.key) ? s.key.value :
575
+ `, "getCsfParsingErrorMessage"), N = /* @__PURE__ */ f((s) => n.isIdentifier(s.key) ? s.key.name : n.isStringLiteral(s.key) ? s.key.value :
574
576
  null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSatisfiesExpression(s) ? G(s.expression) : s, "unwrap"), be = /* @__PURE__ */ f(
575
577
  (s, e) => {
576
578
  if (s.length === 0)
577
579
  return e;
578
580
  if (n.isObjectExpression(e)) {
579
- let [r, ...t] = s, i = e.properties.find((o) => w(o) === r);
581
+ let [r, ...t] = s, i = e.properties.find((a) => N(a) === r);
580
582
  if (i)
581
583
  return be(t, i.value);
582
584
  }
@@ -587,26 +589,26 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
587
589
  throw new Error("Expected object expression");
588
590
  }
589
591
  if (n.isObjectExpression(e)) {
590
- let [r, ...t] = s, i = e.properties.find((o) => w(o) === r);
592
+ let [r, ...t] = s, i = e.properties.find((a) => N(a) === r);
591
593
  if (i)
592
594
  return t.length === 0 ? e.properties : he(t, i.value);
593
595
  }
594
596
  }, "_getPathProperties"), z = /* @__PURE__ */ f((s, e) => {
595
597
  let r = null, t = null;
596
598
  return e.body.find((i) => (n.isVariableDeclaration(i) ? t = i.declarations : n.isExportNamedDeclaration(i) && n.isVariableDeclaration(i.declaration) &&
597
- (t = i.declaration.declarations), t && t.find((o) => n.isVariableDeclarator(o) && n.isIdentifier(o.id) && o.id.name === s ? (r = o, !0) : !1))),
599
+ (t = i.declaration.declarations), t && t.find((a) => n.isVariableDeclarator(a) && n.isIdentifier(a.id) && a.id.name === s ? (r = a, !0) : !1))),
598
600
  r;
599
- }, "_findVarDeclarator"), N = /* @__PURE__ */ f((s, e) => z(s, e)?.init, "_findVarInitialization"), R = /* @__PURE__ */ f((s, e) => {
601
+ }, "_findVarDeclarator"), I = /* @__PURE__ */ f((s, e) => z(s, e)?.init, "_findVarInitialization"), $ = /* @__PURE__ */ f((s, e) => {
600
602
  if (s.length === 0)
601
603
  return e;
602
- let [r, ...t] = s, i = R(t, e);
604
+ let [r, ...t] = s, i = $(t, e);
603
605
  return n.objectExpression([n.objectProperty(n.identifier(r), i)]);
604
- }, "_makeObjectExpression"), $ = /* @__PURE__ */ f((s, e, r) => {
605
- let [t, ...i] = s, o = r.properties.find(
606
- (a) => w(a) === t
606
+ }, "_makeObjectExpression"), A = /* @__PURE__ */ f((s, e, r) => {
607
+ let [t, ...i] = s, a = r.properties.find(
608
+ (o) => N(o) === t
607
609
  );
608
- o ? n.isObjectExpression(o.value) && i.length > 0 ? $(i, e, o.value) : o.value = R(i, e) : r.properties.push(
609
- n.objectProperty(n.identifier(t), R(i, e))
610
+ a ? n.isObjectExpression(a.value) && i.length > 0 ? A(i, e, a.value) : a.value = $(i, e) : r.properties.push(
611
+ n.objectProperty(n.identifier(t), $(i, e))
610
612
  );
611
613
  }, "_updateExportNode"), Z = class {
612
614
  constructor(e, r, t) {
@@ -623,10 +625,10 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
623
625
  }
624
626
  _parseExportsObject(e) {
625
627
  this._exportsObject = e, e.properties.forEach((r) => {
626
- let t = w(r);
628
+ let t = N(r);
627
629
  if (t) {
628
630
  let i = r.value;
629
- n.isIdentifier(i) && (i = N(i.name, this._ast.program)), this._exports[t] = i;
631
+ n.isIdentifier(i) && (i = I(i.name, this._ast.program)), this._exports[t] = i;
630
632
  }
631
633
  });
632
634
  }
@@ -636,7 +638,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
636
638
  ExportDefaultDeclaration: {
637
639
  enter({ node: r, parent: t }) {
638
640
  e.hasDefaultExport = !0;
639
- let i = n.isIdentifier(r.declaration) && n.isProgram(t) ? N(r.declaration.name, t) : r.declaration;
641
+ let i = n.isIdentifier(r.declaration) && n.isProgram(t) ? I(r.declaration.name, t) : r.declaration;
640
642
  i = G(i), n.isCallExpression(i) && n.isObjectExpression(i.arguments[0]) && (i = i.arguments[0]), n.isObjectExpression(i) ? e._parseExportsObject(
641
643
  i) : H.warn(
642
644
  Y({
@@ -652,20 +654,20 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
652
654
  if (n.isVariableDeclaration(r.declaration))
653
655
  r.declaration.declarations.forEach((i) => {
654
656
  if (n.isVariableDeclarator(i) && n.isIdentifier(i.id)) {
655
- let { name: o } = i.id, a = i.init;
656
- n.isIdentifier(a) && (a = N(a.name, t)), e._exports[o] = a, e._exportDecls[o] = i;
657
+ let { name: a } = i.id, o = i.init;
658
+ n.isIdentifier(o) && (o = I(o.name, t)), e._exports[a] = o, e._exportDecls[a] = i;
657
659
  }
658
660
  });
659
661
  else if (n.isFunctionDeclaration(r.declaration)) {
660
662
  let i = r.declaration;
661
663
  if (n.isIdentifier(i.id)) {
662
- let { name: o } = i.id;
663
- e._exportDecls[o] = i;
664
+ let { name: a } = i.id;
665
+ e._exportDecls[a] = i;
664
666
  }
665
667
  } else r.specifiers ? r.specifiers.forEach((i) => {
666
668
  if (n.isExportSpecifier(i) && n.isIdentifier(i.local) && n.isIdentifier(i.exported)) {
667
- let { name: o } = i.local, { name: a } = i.exported, l = z(o, t);
668
- l && (e._exports[a] = l.init, e._exportDecls[a] = l);
669
+ let { name: a } = i.local, { name: o } = i.exported, l = z(a, t);
670
+ l && (e._exports[o] = l.init, e._exportDecls[o] = l);
669
671
  }
670
672
  }) : H.warn(
671
673
  Y({
@@ -679,15 +681,15 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
679
681
  ExpressionStatement: {
680
682
  enter({ node: r, parent: t }) {
681
683
  if (n.isAssignmentExpression(r.expression) && r.expression.operator === "=") {
682
- let { left: i, right: o } = r.expression;
684
+ let { left: i, right: a } = r.expression;
683
685
  if (n.isMemberExpression(i) && n.isIdentifier(i.object) && i.object.name === "module" && n.isIdentifier(i.property) && i.property.
684
686
  name === "exports") {
685
- let a = o;
686
- n.isIdentifier(o) && (a = N(o.name, t)), a = G(a), n.isObjectExpression(a) ? (e._exportsObject = a, a.properties.forEach((l) => {
687
- let p = w(l);
687
+ let o = a;
688
+ n.isIdentifier(a) && (o = I(a.name, t)), o = G(o), n.isObjectExpression(o) ? (e._exportsObject = o, o.properties.forEach((l) => {
689
+ let p = N(l);
688
690
  if (p) {
689
691
  let d = l.value;
690
- n.isIdentifier(d) && (d = N(
692
+ n.isIdentifier(d) && (d = I(
691
693
  d.name,
692
694
  t
693
695
  )), e._exports[p] = d;
@@ -695,8 +697,8 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
695
697
  })) : H.warn(
696
698
  Y({
697
699
  expectedType: "ObjectExpression",
698
- foundType: a?.type,
699
- node: a
700
+ foundType: o?.type,
701
+ node: o
700
702
  })
701
703
  );
702
704
  }
@@ -724,7 +726,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
724
726
  getFieldValue(e) {
725
727
  let r = this.getFieldNode(e);
726
728
  if (r) {
727
- let { code: t } = me(r, {});
729
+ let { code: t } = ue(r, {});
728
730
  return (0, eval)(`(() => (${t}))()`);
729
731
  }
730
732
  }
@@ -735,31 +737,31 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
735
737
  }
736
738
  }
737
739
  setFieldNode(e, r) {
738
- let [t, ...i] = e, o = this._exports[t];
740
+ let [t, ...i] = e, a = this._exports[t];
739
741
  if (this._exportsObject) {
740
- let p = this._exportsObject.properties.find((d) => w(d) === t);
742
+ let p = this._exportsObject.properties.find((d) => N(d) === t);
741
743
  if (p && n.isIdentifier(p.value)) {
742
744
  let d = z(p.value.name, this._ast.program);
743
745
  if (d && n.isObjectExpression(d.init)) {
744
- $(i, r, d.init);
746
+ A(i, r, d.init);
745
747
  return;
746
748
  }
747
749
  }
748
- $(e, r, this._exportsObject), this._exports[e[0]] = r;
750
+ A(e, r, this._exportsObject), this._exports[e[0]] = r;
749
751
  return;
750
752
  }
751
- if (o && n.isObjectExpression(o) && i.length > 0) {
752
- $(i, r, o);
753
+ if (a && n.isObjectExpression(a) && i.length > 0) {
754
+ A(i, r, a);
753
755
  return;
754
756
  }
755
- let a = z(t, this._ast.program);
756
- if (a && n.isObjectExpression(a.init)) {
757
- $(i, r, a.init);
757
+ let o = z(t, this._ast.program);
758
+ if (o && n.isObjectExpression(o.init)) {
759
+ A(i, r, o.init);
758
760
  return;
759
761
  }
760
- if (o && i.length === 0 && this._exportDecls[e[0]]) {
762
+ if (a && i.length === 0 && this._exportDecls[e[0]]) {
761
763
  let l = this._exportDecls[e[0]];
762
- n.isVariableDeclarator(l) && (l.init = R([], r));
764
+ n.isVariableDeclarator(l) && (l.init = $([], r));
763
765
  } else {
764
766
  if (this.hasDefaultExport)
765
767
  throw new Error(
@@ -768,7 +770,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
768
770
  )}" field as the default export is not an object in this file.`
769
771
  );
770
772
  {
771
- let l = R(i, r), p = n.exportNamedDeclaration(
773
+ let l = $(i, r), p = n.exportNamedDeclaration(
772
774
  n.variableDeclaration("const", [n.variableDeclarator(n.identifier(t), l)])
773
775
  );
774
776
  this._exports[t] = l, this._ast.program.body.push(p);
@@ -838,31 +840,31 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
838
840
  return t;
839
841
  }
840
842
  removeField(e) {
841
- let r = /* @__PURE__ */ f((i, o) => {
842
- let a = i.findIndex(
843
- (l) => n.isIdentifier(l.key) && l.key.name === o || n.isStringLiteral(l.key) && l.key.value === o
843
+ let r = /* @__PURE__ */ f((i, a) => {
844
+ let o = i.findIndex(
845
+ (l) => n.isIdentifier(l.key) && l.key.name === a || n.isStringLiteral(l.key) && l.key.value === a
844
846
  );
845
- a >= 0 && i.splice(a, 1);
847
+ o >= 0 && i.splice(o, 1);
846
848
  }, "removeProperty");
847
849
  if (e.length === 1) {
848
850
  let i = !1;
849
- if (this._ast.program.body.forEach((o) => {
850
- if (n.isExportNamedDeclaration(o) && n.isVariableDeclaration(o.declaration)) {
851
- let a = o.declaration.declarations[0];
852
- n.isIdentifier(a.id) && a.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), i = !0);
851
+ if (this._ast.program.body.forEach((a) => {
852
+ if (n.isExportNamedDeclaration(a) && n.isVariableDeclaration(a.declaration)) {
853
+ let o = a.declaration.declarations[0];
854
+ n.isIdentifier(o.id) && o.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(a), 1), i = !0);
853
855
  }
854
- if (n.isExportDefaultDeclaration(o)) {
855
- let a = o.declaration;
856
- if (n.isIdentifier(a) && (a = N(a.name, this._ast.program)), a = G(a), n.isObjectExpression(a)) {
857
- let l = a.properties;
856
+ if (n.isExportDefaultDeclaration(a)) {
857
+ let o = a.declaration;
858
+ if (n.isIdentifier(o) && (o = I(o.name, this._ast.program)), o = G(o), n.isObjectExpression(o)) {
859
+ let l = o.properties;
858
860
  r(l, e[0]), i = !0;
859
861
  }
860
862
  }
861
- if (n.isExpressionStatement(o) && n.isAssignmentExpression(o.expression) && n.isMemberExpression(o.expression.left) && n.isIdentifier(
862
- o.expression.left.object) && o.expression.left.object.name === "module" && n.isIdentifier(o.expression.left.property) && o.expression.
863
- left.property.name === "exports" && n.isObjectExpression(o.expression.right)) {
864
- let a = o.expression.right.properties;
865
- r(a, e[0]), i = !0;
863
+ if (n.isExpressionStatement(a) && n.isAssignmentExpression(a.expression) && n.isMemberExpression(a.expression.left) && n.isIdentifier(
864
+ a.expression.left.object) && a.expression.left.object.name === "module" && n.isIdentifier(a.expression.left.property) && a.expression.
865
+ left.property.name === "exports" && n.isObjectExpression(a.expression.right)) {
866
+ let o = a.expression.right.properties;
867
+ r(o, e[0]), i = !0;
866
868
  }
867
869
  }), i)
868
870
  return;
@@ -894,8 +896,8 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
894
896
  let t = this.getFieldNode(e);
895
897
  if (t)
896
898
  if (n.isArrayExpression(t)) {
897
- let i = t.elements.findIndex((o) => n.isStringLiteral(o) ? o.value === r : n.isObjectExpression(o) ? this._getPresetValue(o, "name") ===
898
- r : this._getPnpWrappedValue(o) === r);
899
+ let i = t.elements.findIndex((a) => n.isStringLiteral(a) ? a.value === r : n.isObjectExpression(a) ? this._getPresetValue(a, "name") ===
900
+ r : this._getPnpWrappedValue(a) === r);
899
901
  if (i >= 0)
900
902
  t.elements.splice(i, 1);
901
903
  else
@@ -916,12 +918,12 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
916
918
  valueToNode(e) {
917
919
  let r = this._inferQuotes(), t;
918
920
  if (r === "single") {
919
- let { code: i } = me(n.valueToNode(e), { jsescOption: { quotes: r } }), o = xe(`const __x = ${i}`);
920
- ge(o, {
921
+ let { code: i } = ue(n.valueToNode(e), { jsescOption: { quotes: r } }), a = xe(`const __x = ${i}`);
922
+ ge(a, {
921
923
  VariableDeclaration: {
922
- enter({ node: a }) {
923
- a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.isIdentifier(a.declarations[0].id) && a.declarations[0].
924
- id.name === "__x" && (t = a.declarations[0].init);
924
+ enter({ node: o }) {
925
+ o.declarations.length === 1 && n.isVariableDeclarator(o.declarations[0]) && n.isIdentifier(o.declarations[0].id) && o.declarations[0].
926
+ id.name === "__x" && (t = o.declarations[0].init);
925
927
  }
926
928
  }
927
929
  });
@@ -959,18 +961,18 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
959
961
  * @param fromImport - The module to import from
960
962
  */
961
963
  setRequireImport(e, r) {
962
- let t = this._ast.program.body.find((a) => {
963
- let l = n.isVariableDeclaration(a) && a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.isCallExpression(a.
964
- declarations[0].init) && n.isIdentifier(a.declarations[0].init.callee) && a.declarations[0].init.callee.name === "require" && n.isStringLiteral(
965
- a.declarations[0].init.arguments[0]) && (a.declarations[0].init.arguments[0].value === r || a.declarations[0].init.arguments[0].value ===
964
+ let t = this._ast.program.body.find((o) => {
965
+ let l = n.isVariableDeclaration(o) && o.declarations.length === 1 && n.isVariableDeclarator(o.declarations[0]) && n.isCallExpression(o.
966
+ declarations[0].init) && n.isIdentifier(o.declarations[0].init.callee) && o.declarations[0].init.callee.name === "require" && n.isStringLiteral(
967
+ o.declarations[0].init.arguments[0]) && (o.declarations[0].init.arguments[0].value === r || o.declarations[0].init.arguments[0].value ===
966
968
  r.split("node:")[1]);
967
- return l && (r = a.declarations[0].init.arguments[0].value), l;
968
- }), i = /* @__PURE__ */ f((a) => n.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
969
- (l) => n.isObjectProperty(l) && n.isIdentifier(l.key) && l.key.name === a
970
- ), "hasRequireSpecifier"), o = /* @__PURE__ */ f((a, l) => a.declarations.length === 1 && n.isVariableDeclarator(a.declarations[0]) && n.
971
- isIdentifier(a.declarations[0].id) && a.declarations[0].id.name === l, "hasDefaultRequireSpecifier");
969
+ return l && (r = o.declarations[0].init.arguments[0].value), l;
970
+ }), i = /* @__PURE__ */ f((o) => n.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
971
+ (l) => n.isObjectProperty(l) && n.isIdentifier(l.key) && l.key.name === o
972
+ ), "hasRequireSpecifier"), a = /* @__PURE__ */ f((o, l) => o.declarations.length === 1 && n.isVariableDeclarator(o.declarations[0]) && n.
973
+ isIdentifier(o.declarations[0].id) && o.declarations[0].id.name === l, "hasDefaultRequireSpecifier");
972
974
  if (typeof e == "string") {
973
- let a = /* @__PURE__ */ f(() => {
975
+ let o = /* @__PURE__ */ f(() => {
974
976
  this._ast.program.body.unshift(
975
977
  n.variableDeclaration("const", [
976
978
  n.variableDeclarator(
@@ -980,17 +982,17 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
980
982
  ])
981
983
  );
982
984
  }, "addDefaultRequireSpecifier");
983
- t && o(t, e) || a();
984
- } else t ? e.forEach((a) => {
985
- i(a) || t.declarations[0].id.properties.push(
986
- n.objectProperty(n.identifier(a), n.identifier(a), void 0, !0)
985
+ t && a(t, e) || o();
986
+ } else t ? e.forEach((o) => {
987
+ i(o) || t.declarations[0].id.properties.push(
988
+ n.objectProperty(n.identifier(o), n.identifier(o), void 0, !0)
987
989
  );
988
990
  }) : this._ast.program.body.unshift(
989
991
  n.variableDeclaration("const", [
990
992
  n.variableDeclarator(
991
993
  n.objectPattern(
992
994
  e.map(
993
- (a) => n.objectProperty(n.identifier(a), n.identifier(a), void 0, !0)
995
+ (o) => n.objectProperty(n.identifier(o), n.identifier(o), void 0, !0)
994
996
  )
995
997
  ),
996
998
  n.callExpression(n.identifier("require"), [n.stringLiteral(r)])
@@ -1027,15 +1029,15 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
1027
1029
  let t = this._ast.program.body.find((p) => {
1028
1030
  let d = n.isImportDeclaration(p) && (p.source.value === r || p.source.value === r.split("node:")[1]);
1029
1031
  return d && (r = p.source.value), d;
1030
- }), i = /* @__PURE__ */ f((p) => n.importSpecifier(n.identifier(p), n.identifier(p)), "getNewImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.
1032
+ }), i = /* @__PURE__ */ f((p) => n.importSpecifier(n.identifier(p), n.identifier(p)), "getNewImportSpecifier"), a = /* @__PURE__ */ f((p, d) => p.
1031
1033
  specifiers.find(
1032
- (m) => n.isImportSpecifier(m) && n.isIdentifier(m.imported) && m.imported.name === d
1033
- ), "hasImportSpecifier"), a = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1034
- (m) => n.isImportNamespaceSpecifier(m) && n.isIdentifier(m.local) && m.local.name === d
1034
+ (u) => n.isImportSpecifier(u) && n.isIdentifier(u.imported) && u.imported.name === d
1035
+ ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1036
+ (u) => n.isImportNamespaceSpecifier(u) && n.isIdentifier(u.local) && u.local.name === d
1035
1037
  ), "hasNamespaceImportSpecifier");
1036
1038
  e === null ? t || this._ast.program.body.unshift(n.importDeclaration([], n.stringLiteral(r))) : typeof e == "string" ? t ? (/* @__PURE__ */ f(
1037
1039
  (p, d) => p.specifiers.find(
1038
- (m) => n.isImportDefaultSpecifier(m) && n.isIdentifier(m.local) && m.local.name === d
1040
+ (u) => n.isImportDefaultSpecifier(u) && n.isIdentifier(u.local) && u.local.name === d
1039
1041
  ), "hasDefaultImportSpecifier"))(t, e) || t.specifiers.push(
1040
1042
  n.importDefaultSpecifier(n.identifier(e))
1041
1043
  ) : this._ast.program.body.unshift(
@@ -1044,13 +1046,13 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
1044
1046
  n.stringLiteral(r)
1045
1047
  )
1046
1048
  ) : Array.isArray(e) ? t ? e.forEach((p) => {
1047
- o(t, p) || t.specifiers.push(i(p));
1049
+ a(t, p) || t.specifiers.push(i(p));
1048
1050
  }) : this._ast.program.body.unshift(
1049
1051
  n.importDeclaration(
1050
1052
  e.map(i),
1051
1053
  n.stringLiteral(r)
1052
1054
  )
1053
- ) : e.namespace && (t ? a(t, e.namespace) || t.specifiers.push(
1055
+ ) : e.namespace && (t ? o(t, e.namespace) || t.specifiers.push(
1054
1056
  n.importNamespaceSpecifier(n.identifier(e.namespace))
1055
1057
  ) : this._ast.program.body.unshift(
1056
1058
  n.importDeclaration(
@@ -1063,28 +1065,29 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
1063
1065
  let r = xe(s);
1064
1066
  return new Z(r, s, e);
1065
1067
  }, "loadConfig"), ot = /* @__PURE__ */ f((s) => at(s).code, "formatConfig"), at = /* @__PURE__ */ f((s, e = {}) => st.print(s._ast, e), "pri\
1066
- ntConfig"), $t = /* @__PURE__ */ f(async (s) => {
1068
+ ntConfig"), Rt = /* @__PURE__ */ f(async (s) => {
1067
1069
  let e = (await rt(s, "utf-8")).toString();
1068
1070
  return nt(e, s).parse();
1069
- }, "readConfig"), Rt = /* @__PURE__ */ f(async (s, e) => {
1071
+ }, "readConfig"), Lt = /* @__PURE__ */ f(async (s, e) => {
1070
1072
  let r = e || s.fileName;
1071
1073
  if (!r)
1072
1074
  throw new Error("Please specify a fileName for writeConfig");
1073
1075
  await it(r, ot(s));
1074
- }, "writeConfig"), Lt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((r) => n.isImportDeclaration(r) && r.source.value.includes("@sto\
1076
+ }, "writeConfig"), Mt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((r) => n.isImportDeclaration(r) && r.source.value.includes("@sto\
1075
1077
  rybook") && r.specifiers.some((t) => n.isImportSpecifier(t) && n.isIdentifier(t.imported) && t.imported.name === "definePreview")), "isCsfFa\
1076
1078
  ctoryPreview");
1077
1079
 
1078
1080
  // src/csf-tools/getStorySortParameter.ts
1079
- var je = U(V(), 1);
1081
+ var je = U(k(), 1);
1080
1082
  import { babelParse as lt, generate as Ee, types as h, traverse as ct } from "storybook/internal/babel";
1081
- var pt = console, ee = /* @__PURE__ */ f((s, e) => {
1083
+ import { logger as pt } from "storybook/internal/node-logger";
1084
+ var ee = /* @__PURE__ */ f((s, e) => {
1082
1085
  let r;
1083
1086
  return s.properties.forEach((t) => {
1084
1087
  h.isIdentifier(t.key) && t.key.name === e && (r = t.value);
1085
1088
  }), r;
1086
1089
  }, "getValue"), te = /* @__PURE__ */ f((s) => {
1087
- let e = L(s);
1090
+ let e = R(s);
1088
1091
  if (h.isArrayExpression(e))
1089
1092
  return e.elements.map((r) => te(r));
1090
1093
  if (h.isObjectExpression(e))
@@ -1092,9 +1095,9 @@ var pt = console, ee = /* @__PURE__ */ f((s, e) => {
1092
1095
  if (h.isLiteral(e))
1093
1096
  return e.value;
1094
1097
  if (h.isIdentifier(e))
1095
- return F(e.name, !0);
1098
+ return w(e.name, !0);
1096
1099
  throw new Error(`Unknown node type ${e.type}`);
1097
- }, "parseValue"), F = /* @__PURE__ */ f((s, e) => {
1100
+ }, "parseValue"), w = /* @__PURE__ */ f((s, e) => {
1098
1101
  let r = je.dedent`
1099
1102
  Unexpected '${s}'. Parameter 'options.storySort' should be defined inline e.g.:
1100
1103
 
@@ -1108,27 +1111,27 @@ var pt = console, ee = /* @__PURE__ */ f((s, e) => {
1108
1111
  `;
1109
1112
  if (e)
1110
1113
  throw new Error(r);
1111
- pt.info(r);
1112
- }, "unsupported"), L = /* @__PURE__ */ f((s) => h.isTSAsExpression(s) || h.isTSSatisfiesExpression(s) ? s.expression : s, "stripTSModifiers"),
1114
+ pt.log(r);
1115
+ }, "unsupported"), R = /* @__PURE__ */ f((s) => h.isTSAsExpression(s) || h.isTSSatisfiesExpression(s) ? s.expression : s, "stripTSModifiers"),
1113
1116
  Se = /* @__PURE__ */ f((s) => {
1114
- let e = L(s);
1117
+ let e = R(s);
1115
1118
  if (h.isObjectExpression(e)) {
1116
1119
  let r = ee(e, "options");
1117
1120
  if (r) {
1118
1121
  if (h.isObjectExpression(r))
1119
1122
  return ee(r, "storySort");
1120
- F("options", !0);
1123
+ w("options", !0);
1121
1124
  }
1122
1125
  }
1123
1126
  }, "parseParameters"), _e = /* @__PURE__ */ f((s, e) => {
1124
- let r = L(s);
1127
+ let r = R(s);
1125
1128
  if (h.isObjectExpression(r)) {
1126
1129
  let t = ee(r, "parameters");
1127
1130
  if (h.isIdentifier(t) && (t = P(t.name, e)), t)
1128
1131
  return Se(t);
1129
1132
  } else
1130
- F("default", !0);
1131
- }, "parseDefault"), Wt = /* @__PURE__ */ f((s) => {
1133
+ w("default", !0);
1134
+ }, "parseDefault"), zt = /* @__PURE__ */ f((s) => {
1132
1135
  if (!s.includes("storySort"))
1133
1136
  return;
1134
1137
  let e, r = lt(s);
@@ -1137,22 +1140,22 @@ Se = /* @__PURE__ */ f((s) => {
1137
1140
  enter({ node: t }) {
1138
1141
  h.isVariableDeclaration(t.declaration) ? t.declaration.declarations.forEach((i) => {
1139
1142
  if (h.isVariableDeclarator(i) && h.isIdentifier(i.id)) {
1140
- let { name: o } = i.id;
1141
- if (o === "parameters" && i.init) {
1142
- let a = L(i.init);
1143
- e = Se(a);
1143
+ let { name: a } = i.id;
1144
+ if (a === "parameters" && i.init) {
1145
+ let o = R(i.init);
1146
+ e = Se(o);
1144
1147
  }
1145
1148
  }
1146
1149
  }) : t.specifiers.forEach((i) => {
1147
- h.isIdentifier(i.exported) && i.exported.name === "parameters" && F("parameters", !1);
1150
+ h.isIdentifier(i.exported) && i.exported.name === "parameters" && w("parameters", !1);
1148
1151
  });
1149
1152
  }
1150
1153
  },
1151
1154
  ExportDefaultDeclaration: {
1152
1155
  enter({ node: t }) {
1153
1156
  let i = t.declaration;
1154
- h.isIdentifier(i) && (i = P(i.name, r.program)), i = L(i), h.isCallExpression(i) && h.isObjectExpression(i.arguments?.[0]) ? e = _e(
1155
- i.arguments[0], r.program) : h.isObjectExpression(i) ? e = _e(i, r.program) : F("default", !1);
1157
+ h.isIdentifier(i) && (i = P(i.name, r.program)), i = R(i), h.isCallExpression(i) && h.isObjectExpression(i.arguments?.[0]) ? e = _e(
1158
+ i.arguments[0], r.program) : h.isObjectExpression(i) ? e = _e(i, r.program) : w("default", !1);
1156
1159
  }
1157
1160
  }
1158
1161
  }), !!e) {
@@ -1161,30 +1164,30 @@ Se = /* @__PURE__ */ f((s) => {
1161
1164
  return (0, eval)(t);
1162
1165
  }
1163
1166
  if (h.isFunctionExpression(e)) {
1164
- let { code: t } = Ee(e, {}), i = e.id?.name, o = `(a, b) => {
1167
+ let { code: t } = Ee(e, {}), i = e.id?.name, a = `(a, b) => {
1165
1168
  ${t};
1166
1169
  return ${i}(a, b)
1167
1170
  }`;
1168
- return (0, eval)(o);
1171
+ return (0, eval)(a);
1169
1172
  }
1170
- return h.isLiteral(e) || h.isArrayExpression(e) || h.isObjectExpression(e) ? te(e) : F("storySort", !0);
1173
+ return h.isLiteral(e) || h.isArrayExpression(e) || h.isObjectExpression(e) ? te(e) : w("storySort", !0);
1171
1174
  }
1172
1175
  }, "getStorySortParameter");
1173
1176
 
1174
1177
  // src/csf-tools/enrichCsf.ts
1175
1178
  import { generate as ft, types as g } from "storybook/internal/babel";
1176
1179
  var dt = /* @__PURE__ */ f((s, e, r, t) => {
1177
- let i = e.getStoryExport(r), o = g.isCallExpression(i) && g.isMemberExpression(i.callee) && g.isIdentifier(i.callee.object) && i.callee.object.
1178
- name === "meta", a = !t?.disableSource && mt(i), l = !t?.disableDescription && Oe(e._storyStatements[r]), p = [], d = o ? g.memberExpression(
1179
- g.identifier(r), g.identifier("input")) : g.identifier(r), m = g.memberExpression(d, g.identifier("parameters"));
1180
- p.push(g.spreadElement(m));
1180
+ let i = e.getStoryExport(r), a = g.isCallExpression(i) && g.isMemberExpression(i.callee) && g.isIdentifier(i.callee.object) && i.callee.object.
1181
+ name === "meta", o = !t?.disableSource && ut(i), l = !t?.disableDescription && Oe(e._storyStatements[r]), p = [], d = a ? g.memberExpression(
1182
+ g.identifier(r), g.identifier("input")) : g.identifier(r), u = g.memberExpression(d, g.identifier("parameters"));
1183
+ p.push(g.spreadElement(u));
1181
1184
  let x = g.optionalMemberExpression(
1182
- m,
1185
+ u,
1183
1186
  g.identifier("docs"),
1184
1187
  !1,
1185
1188
  !0
1186
1189
  ), b = [];
1187
- if (a) {
1190
+ if (o) {
1188
1191
  let y = g.optionalMemberExpression(
1189
1192
  x,
1190
1193
  g.identifier("source"),
@@ -1195,7 +1198,7 @@ var dt = /* @__PURE__ */ f((s, e, r, t) => {
1195
1198
  g.objectProperty(
1196
1199
  g.identifier("source"),
1197
1200
  g.objectExpression([
1198
- g.objectProperty(g.identifier("originalSource"), g.stringLiteral(a)),
1201
+ g.objectProperty(g.identifier("originalSource"), g.stringLiteral(o)),
1199
1202
  g.spreadElement(y)
1200
1203
  ])
1201
1204
  )
@@ -1226,7 +1229,7 @@ var dt = /* @__PURE__ */ f((s, e, r, t) => {
1226
1229
  )
1227
1230
  );
1228
1231
  let y = g.expressionStatement(
1229
- g.assignmentExpression("=", m, g.objectExpression(p))
1232
+ g.assignmentExpression("=", u, g.objectExpression(p))
1230
1233
  );
1231
1234
  s._ast.program.body.push(y);
1232
1235
  }
@@ -1237,11 +1240,11 @@ var dt = /* @__PURE__ */ f((s, e, r, t) => {
1237
1240
  ) || s.properties.unshift(r);
1238
1241
  return;
1239
1242
  }
1240
- let [t, ...i] = e, o = s.properties.find(
1243
+ let [t, ...i] = e, a = s.properties.find(
1241
1244
  (l) => g.isObjectProperty(l) && g.isIdentifier(l.key) && l.key.name === t && g.isObjectExpression(l.value)
1242
- ), a;
1243
- o ? a = o.value : (a = g.objectExpression([]), s.properties.push(g.objectProperty(g.identifier(t), a))), Pe(a, i, r);
1244
- }, "addComponentDescription"), ut = /* @__PURE__ */ f((s, e, r) => {
1245
+ ), o;
1246
+ a ? o = a.value : (o = g.objectExpression([]), s.properties.push(g.objectProperty(g.identifier(t), o))), Pe(o, i, r);
1247
+ }, "addComponentDescription"), mt = /* @__PURE__ */ f((s, e, r) => {
1245
1248
  let t = !r?.disableDescription && Oe(e._metaStatement);
1246
1249
  if (t) {
1247
1250
  let i = s._metaNode;
@@ -1251,11 +1254,11 @@ var dt = /* @__PURE__ */ f((s, e, r, t) => {
1251
1254
  g.objectProperty(g.identifier("component"), g.stringLiteral(t))
1252
1255
  );
1253
1256
  }
1254
- }, "enrichCsfMeta"), Kt = /* @__PURE__ */ f((s, e, r) => {
1255
- ut(s, e, r), Object.keys(s._storyExports).forEach((t) => {
1257
+ }, "enrichCsfMeta"), Qt = /* @__PURE__ */ f((s, e, r) => {
1258
+ mt(s, e, r), Object.keys(s._storyExports).forEach((t) => {
1256
1259
  dt(s, e, t, r);
1257
1260
  });
1258
- }, "enrichCsf"), mt = /* @__PURE__ */ f((s) => {
1261
+ }, "enrichCsf"), ut = /* @__PURE__ */ f((s) => {
1259
1262
  let e = g.isVariableDeclarator(s) ? s.init : s, { code: r } = ft(e, {});
1260
1263
  return r;
1261
1264
  }, "extractSource"), Oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((r) => r.type === "CommentLine" || !r.value.startsWith(
@@ -1265,34 +1268,33 @@ var dt = /* @__PURE__ */ f((s, e, r, t) => {
1265
1268
  `) : "", "extractDescription");
1266
1269
 
1267
1270
  // src/csf-tools/index.ts
1268
- import { babelParse as cr } from "storybook/internal/babel";
1271
+ import { babelParse as dr } from "storybook/internal/babel";
1269
1272
 
1270
1273
  // src/csf-tools/vitest-plugin/transformer.ts
1271
- var re = U(V(), 1);
1272
- import { types as u } from "storybook/internal/babel";
1274
+ var re = U(k(), 1);
1275
+ import { types as m } from "storybook/internal/babel";
1273
1276
  import { getStoryTitle as gt } from "storybook/internal/common";
1274
1277
  import { combineTags as xt } from "storybook/internal/csf";
1275
- var ve = console, yt = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((r) => s?.includes(r)) || e.exclude.some((r) => s?.
1276
- includes(r))), "isValidTest");
1278
+ import { logger as ve } from "storybook/internal/node-logger";
1279
+ var yt = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((r) => s?.includes(r)) || e.exclude.some((r) => s?.includes(r))),
1280
+ "isValidTest");
1277
1281
  async function bt({
1278
1282
  code: s,
1279
1283
  fileName: e,
1280
1284
  configDir: r,
1281
1285
  stories: t,
1282
1286
  tagsFilter: i,
1283
- previewLevelTags: o = []
1287
+ previewLevelTags: a = []
1284
1288
  }) {
1285
- if (!/\.stor(y|ies)\./.test(e))
1286
- return s;
1287
- let l = Q(s, {
1289
+ let o = Q(s, {
1288
1290
  fileName: e,
1289
1291
  transformInlineMeta: !0,
1290
- makeTitle: /* @__PURE__ */ f((_) => {
1292
+ makeTitle: /* @__PURE__ */ f((E) => {
1291
1293
  let S = gt({
1292
1294
  storyFilePath: e,
1293
1295
  configDir: r,
1294
1296
  stories: t,
1295
- userTitle: _
1297
+ userTitle: E
1296
1298
  }) || "unknown";
1297
1299
  return S === "unknown" && ve.warn(
1298
1300
  re.dedent`
@@ -1301,100 +1303,100 @@ async function bt({
1301
1303
  `
1302
1304
  ), S;
1303
1305
  }, "makeTitle")
1304
- }).parse(), p = l._ast, d = l._metaVariableName, m = l._metaNode, x = m.properties.find(
1305
- (_) => u.isObjectProperty(_) && u.isIdentifier(_.key) && _.key.name === "title"
1306
- ), b = u.stringLiteral(l._meta?.title || "unknown");
1307
- if (x ? u.isObjectProperty(x) && (x.value = b) : m.properties.push(u.objectProperty(u.identifier("title"), b)), !m || !l._meta)
1306
+ }).parse(), l = o._ast, p = o._metaVariableName, d = o._metaNode, u = d.properties.find(
1307
+ (E) => m.isObjectProperty(E) && m.isIdentifier(E.key) && E.key.name === "title"
1308
+ ), x = m.stringLiteral(o._meta?.title || "unknown");
1309
+ if (u ? m.isObjectProperty(u) && (u.value = x) : d.properties.push(m.objectProperty(m.identifier("title"), x)), !d || !o._meta)
1308
1310
  throw new Error(
1309
1311
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
1310
1312
 
1311
1313
  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\
1312
1314
  le an issue with details about your use case.`
1313
1315
  );
1314
- let y = {};
1315
- Object.keys(l._stories).map((_) => {
1316
+ let b = {};
1317
+ Object.keys(o._stories).map((E) => {
1316
1318
  let S = xt(
1317
1319
  "test",
1318
1320
  "dev",
1319
- ...o,
1320
- ...l.meta?.tags || [],
1321
- ...l._stories[_].tags || []
1321
+ ...a,
1322
+ ...o.meta?.tags || [],
1323
+ ...o._stories[E].tags || []
1322
1324
  );
1323
- yt(S, i) && (y[_] = l._storyStatements[_]);
1325
+ yt(S, i) && (b[E] = o._storyStatements[E]);
1324
1326
  });
1325
- let E = l._file.path.scope.generateUidIdentifier("test"), D = l._file.path.scope.generateUidIdentifier("describe");
1326
- if (Object.keys(y).length === 0) {
1327
- let _ = u.expressionStatement(
1328
- u.callExpression(u.memberExpression(D, u.identifier("skip")), [
1329
- u.stringLiteral("No valid tests found")
1327
+ let y = o._file.path.scope.generateUidIdentifier("test"), _ = o._file.path.scope.generateUidIdentifier("describe");
1328
+ if (Object.keys(b).length === 0) {
1329
+ let E = m.expressionStatement(
1330
+ m.callExpression(m.memberExpression(_, m.identifier("skip")), [
1331
+ m.stringLiteral("No valid tests found")
1330
1332
  ])
1331
1333
  );
1332
- p.program.body.push(_);
1334
+ l.program.body.push(E);
1333
1335
  let S = [
1334
- u.importDeclaration(
1336
+ m.importDeclaration(
1335
1337
  [
1336
- u.importSpecifier(E, u.identifier("test")),
1337
- u.importSpecifier(D, u.identifier("describe"))
1338
+ m.importSpecifier(y, m.identifier("test")),
1339
+ m.importSpecifier(_, m.identifier("describe"))
1338
1340
  ],
1339
- u.stringLiteral("vitest")
1341
+ m.stringLiteral("vitest")
1340
1342
  )
1341
1343
  ];
1342
- p.program.body.unshift(...S);
1344
+ l.program.body.unshift(...S);
1343
1345
  } else {
1344
1346
  let ie = function() {
1345
- let j = l._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), I = u.memberExpression(
1346
- u.callExpression(u.memberExpression(_, u.identifier("getState")), []),
1347
- u.identifier("testPath")
1348
- ), C = u.memberExpression(
1349
- u.memberExpression(u.identifier("globalThis"), u.identifier("__vitest_worker__")),
1350
- u.identifier("filepath")
1351
- ), T = u.logicalExpression(
1347
+ let j = o._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), D = m.memberExpression(
1348
+ m.callExpression(m.memberExpression(E, m.identifier("getState")), []),
1349
+ m.identifier("testPath")
1350
+ ), F = m.memberExpression(
1351
+ m.memberExpression(m.identifier("globalThis"), m.identifier("__vitest_worker__")),
1352
+ m.identifier("filepath")
1353
+ ), C = m.logicalExpression(
1352
1354
  "??",
1353
1355
  // TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
1354
1356
  // https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
1355
- C,
1356
- I
1357
- ), M = u.callExpression(
1358
- u.memberExpression(
1359
- u.callExpression(u.identifier("convertToFilePath"), [
1360
- u.memberExpression(
1361
- u.memberExpression(u.identifier("import"), u.identifier("meta")),
1362
- u.identifier("url")
1357
+ F,
1358
+ D
1359
+ ), M = m.callExpression(
1360
+ m.memberExpression(
1361
+ m.callExpression(m.identifier("convertToFilePath"), [
1362
+ m.memberExpression(
1363
+ m.memberExpression(m.identifier("import"), m.identifier("meta")),
1364
+ m.identifier("url")
1363
1365
  )
1364
1366
  ]),
1365
- u.identifier("includes")
1367
+ m.identifier("includes")
1366
1368
  ),
1367
- [T]
1369
+ [C]
1368
1370
  );
1369
- return { isRunningFromThisFileDeclaration: u.variableDeclaration("const", [
1370
- u.variableDeclarator(j, M)
1371
+ return { isRunningFromThisFileDeclaration: m.variableDeclaration("const", [
1372
+ m.variableDeclarator(j, M)
1371
1373
  ]), isRunningFromThisFileId: j };
1372
1374
  };
1373
- var ht = ie;
1375
+ var L = ie;
1374
1376
  f(ie, "getTestGuardDeclaration");
1375
- let _ = l._file.path.scope.generateUidIdentifier("expect"), S = l._file.path.scope.generateUidIdentifier("testStory"), De = u.identifier(
1377
+ let E = o._file.path.scope.generateUidIdentifier("expect"), S = o._file.path.scope.generateUidIdentifier("testStory"), De = m.identifier(
1376
1378
  JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Ie, isRunningFromThisFileId: Ne } = ie();
1377
- p.program.body.push(Ie);
1379
+ l.program.body.push(Ie);
1378
1380
  let we = /* @__PURE__ */ f(({
1379
1381
  localName: j,
1380
- exportName: I,
1381
- testTitle: C,
1382
- node: T
1382
+ exportName: D,
1383
+ testTitle: F,
1384
+ node: C
1383
1385
  }) => {
1384
- let M = u.expressionStatement(
1385
- u.callExpression(E, [
1386
- u.stringLiteral(C),
1387
- u.callExpression(S, [
1388
- u.stringLiteral(I),
1389
- u.identifier(j),
1390
- u.identifier(d),
1386
+ let M = m.expressionStatement(
1387
+ m.callExpression(y, [
1388
+ m.stringLiteral(F),
1389
+ m.callExpression(S, [
1390
+ m.stringLiteral(D),
1391
+ m.identifier(j),
1392
+ m.identifier(p),
1391
1393
  De
1392
1394
  ])
1393
1395
  ])
1394
1396
  );
1395
- return M.loc = T.loc, M;
1396
- }, "getTestStatementForStory"), Fe = Object.entries(y).map(([j, I]) => {
1397
- if (I === null) {
1397
+ return M.loc = C.loc, M;
1398
+ }, "getTestStatementForStory"), Fe = Object.entries(b).map(([j, D]) => {
1399
+ if (D === null) {
1398
1400
  ve.warn(
1399
1401
  re.dedent`
1400
1402
  [Storybook]: Could not transform "${j}" story into test at "${e}".
@@ -1403,29 +1405,29 @@ le an issue with details about your use case.`
1403
1405
  );
1404
1406
  return;
1405
1407
  }
1406
- let C = l._stories[j].localName ?? j, T = l._stories[j].name ?? j;
1407
- return we({ testTitle: T, localName: C, exportName: j, node: I });
1408
- }).filter((j) => !!j), Ce = u.ifStatement(Ne, u.blockStatement(Fe));
1409
- p.program.body.push(Ce);
1408
+ let F = o._stories[j].localName ?? j, C = o._stories[j].name ?? j;
1409
+ return we({ testTitle: C, localName: F, exportName: j, node: D });
1410
+ }).filter((j) => !!j), Ce = m.ifStatement(Ne, m.blockStatement(Fe));
1411
+ l.program.body.push(Ce);
1410
1412
  let Te = [
1411
- u.importDeclaration(
1413
+ m.importDeclaration(
1412
1414
  [
1413
- u.importSpecifier(E, u.identifier("test")),
1414
- u.importSpecifier(_, u.identifier("expect"))
1415
+ m.importSpecifier(y, m.identifier("test")),
1416
+ m.importSpecifier(E, m.identifier("expect"))
1415
1417
  ],
1416
- u.stringLiteral("vitest")
1418
+ m.stringLiteral("vitest")
1417
1419
  ),
1418
- u.importDeclaration(
1420
+ m.importDeclaration(
1419
1421
  [
1420
- u.importSpecifier(S, u.identifier("testStory")),
1421
- u.importSpecifier(u.identifier("convertToFilePath"), u.identifier("convertToFilePath"))
1422
+ m.importSpecifier(S, m.identifier("testStory")),
1423
+ m.importSpecifier(m.identifier("convertToFilePath"), m.identifier("convertToFilePath"))
1422
1424
  ],
1423
- u.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1425
+ m.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1424
1426
  )
1425
1427
  ];
1426
- p.program.body.unshift(...Te);
1428
+ l.program.body.unshift(...Te);
1427
1429
  }
1428
- return ue(l, { sourceMaps: !0, sourceFileName: e }, s);
1430
+ return me(o, { sourceMaps: !0, sourceFileName: e }, s);
1429
1431
  }
1430
1432
  f(bt, "vitestTransform");
1431
1433
  export {
@@ -1435,26 +1437,26 @@ export {
1435
1437
  B as MixedFactoryError,
1436
1438
  K as MultipleMetaError,
1437
1439
  q as NoMetaError,
1438
- cr as babelParse,
1440
+ dr as babelParse,
1439
1441
  et as babelParseFile,
1440
- Kt as enrichCsf,
1441
- ut as enrichCsfMeta,
1442
+ Qt as enrichCsf,
1443
+ mt as enrichCsfMeta,
1442
1444
  dt as enrichCsfStory,
1443
1445
  Oe as extractDescription,
1444
- mt as extractSource,
1446
+ ut as extractSource,
1445
1447
  ot as formatConfig,
1446
- ue as formatCsf,
1447
- Wt as getStorySortParameter,
1448
- Lt as isCsfFactoryPreview,
1448
+ me as formatCsf,
1449
+ zt as getStorySortParameter,
1450
+ Mt as isCsfFactoryPreview,
1449
1451
  Qe as isModuleMock,
1450
1452
  Ke as isValidPreviewPath,
1451
1453
  nt as loadConfig,
1452
1454
  Q as loadCsf,
1453
1455
  at as printConfig,
1454
1456
  tt as printCsf,
1455
- $t as readConfig,
1457
+ Rt as readConfig,
1456
1458
  Ft as readCsf,
1457
1459
  bt as vitestTransform,
1458
- Rt as writeConfig,
1460
+ Lt as writeConfig,
1459
1461
  Ct as writeCsf
1460
1462
  };