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
@@ -1,142 +1,143 @@
1
1
  "use strict";
2
- var We = Object.create;
3
- var A = Object.defineProperty;
4
- var Ge = Object.getOwnPropertyDescriptor;
5
- var ze = Object.getOwnPropertyNames;
6
- var Xe = Object.getPrototypeOf, Ke = Object.prototype.hasOwnProperty;
7
- var f = (s, e) => A(s, "name", { value: e, configurable: !0 });
8
- var Je = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports), Qe = (s, e) => {
2
+ var Ge = Object.create;
3
+ var V = Object.defineProperty;
4
+ var ze = Object.getOwnPropertyDescriptor;
5
+ var Xe = Object.getOwnPropertyNames;
6
+ var Ke = Object.getPrototypeOf, Je = Object.prototype.hasOwnProperty;
7
+ var f = (s, e) => V(s, "name", { value: e, configurable: !0 });
8
+ var Qe = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports), He = (s, e) => {
9
9
  for (var r in e)
10
- A(s, r, { get: e[r], enumerable: !0 });
11
- }, ce = (s, e, r, t) => {
10
+ V(s, r, { get: e[r], enumerable: !0 });
11
+ }, fe = (s, e, r, t) => {
12
12
  if (e && typeof e == "object" || typeof e == "function")
13
- for (let i of ze(e))
14
- !Ke.call(s, i) && i !== r && A(s, i, { get: () => e[i], enumerable: !(t = Ge(e, i)) || t.enumerable });
13
+ for (let i of Xe(e))
14
+ !Je.call(s, i) && i !== r && V(s, i, { get: () => e[i], enumerable: !(t = ze(e, i)) || t.enumerable });
15
15
  return s;
16
16
  };
17
- var z = (s, e, r) => (r = s != null ? We(Xe(s)) : {}, ce(
17
+ var z = (s, e, r) => (r = s != null ? Ge(Ke(s)) : {}, fe(
18
18
  // If the importer is in node compatibility mode or this is not an ESM
19
19
  // file that has been converted to a CommonJS file using a Babel-
20
20
  // compatible transform (i.e. "__esModule" has not been set), then set
21
21
  // "default" to the CommonJS "module.exports" for node compatibility.
22
- e || !s || !s.__esModule ? A(r, "default", { value: s, enumerable: !0 }) : r,
22
+ e || !s || !s.__esModule ? V(r, "default", { value: s, enumerable: !0 }) : r,
23
23
  s
24
- )), He = (s) => ce(A({}, "__esModule", { value: !0 }), s);
24
+ )), Ye = (s) => fe(V({}, "__esModule", { value: !0 }), s);
25
25
 
26
26
  // ../node_modules/ts-dedent/dist/index.js
27
- var R = Je(($) => {
27
+ var $ = Qe((A) => {
28
28
  "use strict";
29
- Object.defineProperty($, "__esModule", { value: !0 });
30
- $.dedent = void 0;
31
- function pe(s) {
29
+ Object.defineProperty(A, "__esModule", { value: !0 });
30
+ A.dedent = void 0;
31
+ function de(s) {
32
32
  for (var e = [], r = 1; r < arguments.length; r++)
33
33
  e[r - 1] = arguments[r];
34
34
  var t = Array.from(typeof s == "string" ? [s] : s);
35
35
  t[t.length - 1] = t[t.length - 1].replace(/\r?\n([\t ]*)$/, "");
36
- var i = t.reduce(function(l, p) {
36
+ var i = t.reduce(function(c, p) {
37
37
  var d = p.match(/\n([\t ]+|(?!\s).)/g);
38
- return d ? l.concat(d.map(function(g) {
38
+ return d ? c.concat(d.map(function(g) {
39
39
  var x, h;
40
40
  return (h = (x = g.match(/[\t ]/g)) === null || x === void 0 ? void 0 : x.length) !== null && h !== void 0 ? h : 0;
41
- })) : l;
41
+ })) : c;
42
42
  }, []);
43
43
  if (i.length) {
44
- var o = new RegExp(`
44
+ var a = new RegExp(`
45
45
  [ ]{` + Math.min.apply(Math, i) + "}", "g");
46
- t = t.map(function(l) {
47
- return l.replace(o, `
46
+ t = t.map(function(c) {
47
+ return c.replace(a, `
48
48
  `);
49
49
  });
50
50
  }
51
51
  t[0] = t[0].replace(/^\r?\n/, "");
52
- var a = t[0];
53
- return e.forEach(function(l, p) {
54
- var d = a.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = l;
55
- typeof l == "string" && l.includes(`
56
- `) && (x = String(l).split(`
52
+ var o = t[0];
53
+ return e.forEach(function(c, p) {
54
+ var d = o.match(/(?:^|\n)( *)$/), g = d ? d[1] : "", x = c;
55
+ typeof c == "string" && c.includes(`
56
+ `) && (x = String(c).split(`
57
57
  `).map(function(h, b) {
58
58
  return b === 0 ? h : "" + g + h;
59
59
  }).join(`
60
- `)), a += x + t[p + 1];
61
- }), a;
60
+ `)), o += x + t[p + 1];
61
+ }), o;
62
62
  }
63
- f(pe, "dedent");
64
- $.dedent = pe;
65
- $.default = pe;
63
+ f(de, "dedent");
64
+ A.dedent = de;
65
+ A.default = de;
66
66
  });
67
67
 
68
68
  // src/csf-tools/index.ts
69
69
  var dt = {};
70
- Qe(dt, {
71
- BadMetaError: () => U,
72
- ConfigFile: () => Z,
70
+ He(dt, {
71
+ BadMetaError: () => M,
72
+ ConfigFile: () => ee,
73
73
  CsfFile: () => K,
74
- MixedFactoryError: () => M,
74
+ MixedFactoryError: () => L,
75
75
  MultipleMetaError: () => X,
76
- NoMetaError: () => L,
77
- babelParse: () => Ae.babelParse,
78
- babelParseFile: () => ye,
76
+ NoMetaError: () => R,
77
+ babelParse: () => $e.babelParse,
78
+ babelParseFile: () => be,
79
79
  enrichCsf: () => pt,
80
- enrichCsfMeta: () => we,
81
- enrichCsfStory: () => Ie,
82
- extractDescription: () => oe,
83
- extractSource: () => Fe,
84
- formatConfig: () => Se,
85
- formatCsf: () => te,
80
+ enrichCsfMeta: () => Ce,
81
+ enrichCsfStory: () => we,
82
+ extractDescription: () => ae,
83
+ extractSource: () => Te,
84
+ formatConfig: () => Pe,
85
+ formatCsf: () => ie,
86
86
  getStorySortParameter: () => ct,
87
- isCsfFactoryPreview: () => at,
88
- isModuleMock: () => xe,
89
- isValidPreviewPath: () => ge,
90
- loadConfig: () => je,
87
+ isCsfFactoryPreview: () => lt,
88
+ isModuleMock: () => ye,
89
+ isValidPreviewPath: () => xe,
90
+ loadConfig: () => Se,
91
91
  loadCsf: () => Q,
92
- printConfig: () => Pe,
93
- printCsf: () => be,
94
- readConfig: () => nt,
95
- readCsf: () => it,
96
- vitestTransform: () => Ve,
97
- writeConfig: () => ot,
98
- writeCsf: () => st
92
+ printConfig: () => Oe,
93
+ printCsf: () => he,
94
+ readConfig: () => ot,
95
+ readCsf: () => st,
96
+ vitestTransform: () => Ae,
97
+ writeConfig: () => at,
98
+ writeCsf: () => nt
99
99
  });
100
- module.exports = He(dt);
100
+ module.exports = Ye(dt);
101
101
 
102
102
  // src/csf-tools/CsfFile.ts
103
- var J = require("node:fs/promises"), c = require("storybook/internal/babel"), v = require("storybook/internal/csf"), O = z(R(), 1);
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
105
 
105
106
  // src/csf-tools/findVarInitialization.ts
106
- var w = require("storybook/internal/babel");
107
+ var N = require("storybook/internal/babel");
107
108
  var P = /* @__PURE__ */ f((s, e) => {
108
109
  let r = null, t = null;
109
- return e.body.find((i) => (w.types.isVariableDeclaration(i) ? t = i.declarations : w.types.isExportNamedDeclaration(i) && w.types.isVariableDeclaration(
110
- i.declaration) && (t = i.declaration.declarations), t && t.find((o) => w.types.isVariableDeclarator(o) && w.types.isIdentifier(o.id) && o.
111
- id.name === s ? (r = o.init, !0) : !1))), r;
110
+ return e.body.find((i) => (N.types.isVariableDeclaration(i) ? t = i.declarations : N.types.isExportNamedDeclaration(i) && N.types.isVariableDeclaration(
111
+ i.declaration) && (t = i.declaration.declarations), t && t.find((a) => N.types.isVariableDeclarator(a) && N.types.isIdentifier(a.id) && a.
112
+ id.name === s ? (r = a.init, !0) : !1))), r;
112
113
  }, "findVarInitialization");
113
114
 
114
115
  // src/csf-tools/CsfFile.ts
115
- var fe = console, Ye = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, ge = /* @__PURE__ */ f((s) => Ye.test(s), "isValidPreviewPath");
116
- function Ze(s) {
117
- if (c.types.isArrayExpression(s))
116
+ var Ze = /\/preview(.(js|jsx|mjs|ts|tsx))?$/, xe = /* @__PURE__ */ f((s) => Ze.test(s), "isValidPreviewPath");
117
+ function et(s) {
118
+ if (l.types.isArrayExpression(s))
118
119
  return s.elements.map((e) => {
119
- if (c.types.isStringLiteral(e))
120
+ if (l.types.isStringLiteral(e))
120
121
  return e.value;
121
122
  throw new Error(`Expected string literal: ${e}`);
122
123
  });
123
- if (c.types.isStringLiteral(s))
124
+ if (l.types.isStringLiteral(s))
124
125
  return new RegExp(s.value);
125
- if (c.types.isRegExpLiteral(s))
126
+ if (l.types.isRegExpLiteral(s))
126
127
  return new RegExp(s.pattern, s.flags);
127
128
  throw new Error(`Unknown include/exclude: ${s}`);
128
129
  }
129
- f(Ze, "parseIncludeExclude");
130
- function de(s) {
131
- if (!c.types.isArrayExpression(s))
130
+ f(et, "parseIncludeExclude");
131
+ function me(s) {
132
+ if (!l.types.isArrayExpression(s))
132
133
  throw new Error("CSF: Expected tags array");
133
134
  return s.elements.map((e) => {
134
- if (c.types.isStringLiteral(e))
135
+ if (l.types.isStringLiteral(e))
135
136
  return e.value;
136
137
  throw new Error("CSF: Expected tag to be string literal");
137
138
  });
138
139
  }
139
- f(de, "parseTags");
140
+ f(me, "parseTags");
140
141
  var D = /* @__PURE__ */ f((s, e) => {
141
142
  let r = "";
142
143
  if (s.loc) {
@@ -144,52 +145,52 @@ var D = /* @__PURE__ */ f((s, e) => {
144
145
  r = `(line ${t}, col ${i})`;
145
146
  }
146
147
  return `${e || ""} ${r}`.trim();
147
- }, "formatLocation"), xe = /* @__PURE__ */ f((s) => rt.test(s), "isModuleMock"), ue = /* @__PURE__ */ f((s, e, r) => {
148
+ }, "formatLocation"), ye = /* @__PURE__ */ f((s) => it.test(s), "isModuleMock"), ue = /* @__PURE__ */ f((s, e, r) => {
148
149
  let t = s;
149
- if (c.types.isCallExpression(s)) {
150
- let { callee: i, arguments: o } = s;
151
- if (c.types.isProgram(e) && c.types.isMemberExpression(i) && c.types.isIdentifier(i.object) && c.types.isIdentifier(i.property) && i.property.
152
- name === "bind" && (o.length === 0 || o.length === 1 && c.types.isObjectExpression(o[0]) && o[0].properties.length === 0)) {
153
- let a = i.object.name, l = P(a, e);
154
- l && (r._templates[a] = l, t = l);
150
+ if (l.types.isCallExpression(s)) {
151
+ let { callee: i, arguments: a } = s;
152
+ if (l.types.isProgram(e) && l.types.isMemberExpression(i) && l.types.isIdentifier(i.object) && l.types.isIdentifier(i.property) && i.property.
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);
155
+ c && (r._templates[o] = c, t = c);
155
156
  }
156
157
  }
157
- return c.types.isArrowFunctionExpression(t) || c.types.isFunctionDeclaration(t) ? t.params.length > 0 : !1;
158
- }, "isArgsStory"), et = /* @__PURE__ */ f((s) => {
159
- if (c.types.isArrayExpression(s))
158
+ return l.types.isArrowFunctionExpression(t) || l.types.isFunctionDeclaration(t) ? t.params.length > 0 : !1;
159
+ }, "isArgsStory"), tt = /* @__PURE__ */ f((s) => {
160
+ if (l.types.isArrayExpression(s))
160
161
  return s.elements.map((e) => {
161
- if (c.types.isStringLiteral(e))
162
+ if (l.types.isStringLiteral(e))
162
163
  return e.value;
163
164
  throw new Error(`Expected string literal named export: ${e}`);
164
165
  });
165
166
  throw new Error(`Expected array of string literals: ${s}`);
166
- }, "parseExportsOrder"), me = /* @__PURE__ */ f((s, e) => e.reduce(
167
+ }, "parseExportsOrder"), ge = /* @__PURE__ */ f((s, e) => e.reduce(
167
168
  (r, t) => {
168
169
  let i = s[t];
169
170
  return i && (r[t] = i), r;
170
171
  },
171
172
  {}
172
- ), "sortExports"), tt = /* @__PURE__ */ f((s) => {
173
- if (c.types.isArrowFunctionExpression(s) || c.types.isFunctionDeclaration(s)) {
173
+ ), "sortExports"), rt = /* @__PURE__ */ f((s) => {
174
+ if (l.types.isArrowFunctionExpression(s) || l.types.isFunctionDeclaration(s)) {
174
175
  let e = s.params;
175
176
  if (e.length >= 1) {
176
177
  let [r] = e;
177
- if (c.types.isObjectPattern(r))
178
+ if (l.types.isObjectPattern(r))
178
179
  return !!r.properties.find((t) => {
179
- if (c.types.isObjectProperty(t) && c.types.isIdentifier(t.key))
180
+ if (l.types.isObjectProperty(t) && l.types.isIdentifier(t.key))
180
181
  return t.key.name === "mount";
181
182
  });
182
183
  }
183
184
  }
184
185
  return !1;
185
- }, "hasMount"), rt = /^[.\/#].*\.mock($|\.[^.]*$)/i, L = class extends Error {
186
+ }, "hasMount"), it = /^[.\/#].*\.mock($|\.[^.]*$)/i, R = class extends Error {
186
187
  static {
187
188
  f(this, "NoMetaError");
188
189
  }
189
190
  constructor(e, r, t) {
190
- let i = "".trim();
191
+ let i = e.trim();
191
192
  super(O.dedent`
192
- CSF: ${e} ${D(r, t)}
193
+ CSF: ${i} ${D(r, t)}
193
194
 
194
195
  More info: https://storybook.js.org/docs/writing-stories#default-export
195
196
  `), this.name = this.constructor.name;
@@ -206,7 +207,7 @@ var D = /* @__PURE__ */ f((s, e) => {
206
207
  More info: https://storybook.js.org/docs/writing-stories#default-export
207
208
  `), this.name = this.constructor.name;
208
209
  }
209
- }, M = class extends Error {
210
+ }, L = class extends Error {
210
211
  static {
211
212
  f(this, "MixedFactoryError");
212
213
  }
@@ -218,7 +219,7 @@ var D = /* @__PURE__ */ f((s, e) => {
218
219
  More info: https://storybook.js.org/docs/writing-stories#default-export
219
220
  `), this.name = this.constructor.name;
220
221
  }
221
- }, U = class extends Error {
222
+ }, M = class extends Error {
222
223
  static {
223
224
  f(this, "BadMetaError");
224
225
  }
@@ -245,10 +246,10 @@ var D = /* @__PURE__ */ f((s, e) => {
245
246
  f(this, "CsfFile");
246
247
  }
247
248
  _parseTitle(e) {
248
- let r = c.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
249
- if (c.types.isStringLiteral(r))
249
+ let r = l.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
250
+ if (l.types.isStringLiteral(r))
250
251
  return r.value;
251
- if (c.types.isTSSatisfiesExpression(r) && c.types.isStringLiteral(r.expression))
252
+ if (l.types.isTSSatisfiesExpression(r) && l.types.isStringLiteral(r.expression))
252
253
  return r.expression.value;
253
254
  throw new Error(O.dedent`
254
255
  CSF: unexpected dynamic title ${D(r, this._options.fileName)}
@@ -262,29 +263,29 @@ var D = /* @__PURE__ */ f((s, e) => {
262
263
  this._metaNode = e;
263
264
  let t = {};
264
265
  e.properties.forEach((i) => {
265
- if (c.types.isIdentifier(i.key)) {
266
+ if (l.types.isIdentifier(i.key)) {
266
267
  if (this._metaAnnotations[i.key.name] = i.value, i.key.name === "title")
267
268
  t.title = this._parseTitle(i.value);
268
269
  else if (["includeStories", "excludeStories"].includes(i.key.name))
269
- t[i.key.name] = Ze(i.value);
270
+ t[i.key.name] = et(i.value);
270
271
  else if (i.key.name === "component") {
271
- let o = i.value;
272
- if (c.types.isIdentifier(o)) {
273
- let l = o.name, p = r.body.find(
274
- (d) => c.types.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === l)
272
+ let a = i.value;
273
+ if (l.types.isIdentifier(a)) {
274
+ let c = a.name, p = r.body.find(
275
+ (d) => l.types.isImportDeclaration(d) && d.specifiers.find((g) => g.local.name === c)
275
276
  );
276
277
  if (p) {
277
278
  let { source: d } = p;
278
- c.types.isStringLiteral(d) && (this._rawComponentPath = d.value);
279
+ l.types.isStringLiteral(d) && (this._rawComponentPath = d.value);
279
280
  }
280
281
  }
281
- let { code: a } = c.recast.print(i.value, {});
282
- t.component = a;
282
+ let { code: o } = l.recast.print(i.value, {});
283
+ t.component = o;
283
284
  } else if (i.key.name === "tags") {
284
- let o = i.value;
285
- c.types.isIdentifier(o) && (o = P(o.name, this._ast.program)), t.tags = de(o);
285
+ let a = i.value;
286
+ l.types.isIdentifier(a) && (a = P(a.name, this._ast.program)), t.tags = me(a);
286
287
  } else if (i.key.name === "id")
287
- if (c.types.isStringLiteral(i.value))
288
+ if (l.types.isStringLiteral(i.value))
288
289
  t.id = i.value.value;
289
290
  else
290
291
  throw new Error(`Unexpected component id: ${i.value}`);
@@ -293,49 +294,49 @@ var D = /* @__PURE__ */ f((s, e) => {
293
294
  }
294
295
  getStoryExport(e) {
295
296
  let r = this._storyExports[e];
296
- if (r = c.types.isVariableDeclarator(r) ? r.init : r, c.types.isCallExpression(r)) {
297
+ if (r = l.types.isVariableDeclarator(r) ? r.init : r, l.types.isCallExpression(r)) {
297
298
  let { callee: t, arguments: i } = r;
298
- if (c.types.isMemberExpression(t) && c.types.isIdentifier(t.object) && c.types.isIdentifier(t.property) && t.property.name === "bind" &&
299
- (i.length === 0 || i.length === 1 && c.types.isObjectExpression(i[0]) && i[0].properties.length === 0)) {
300
- let { name: o } = t.object;
301
- r = this._templates[o];
299
+ if (l.types.isMemberExpression(t) && l.types.isIdentifier(t.object) && l.types.isIdentifier(t.property) && t.property.name === "bind" &&
300
+ (i.length === 0 || i.length === 1 && l.types.isObjectExpression(i[0]) && i[0].properties.length === 0)) {
301
+ let { name: a } = t.object;
302
+ r = this._templates[a];
302
303
  }
303
304
  }
304
305
  return r;
305
306
  }
306
307
  parse() {
307
308
  let e = this;
308
- if ((0, c.traverse)(this._ast, {
309
+ if ((0, l.traverse)(this._ast, {
309
310
  ExportDefaultDeclaration: {
310
311
  enter(t) {
311
- let { node: i, parent: o } = t, a = c.types.isIdentifier(i.declaration) && c.types.isProgram(o);
312
- if (e._options.transformInlineMeta && !a && c.types.isExpression(i.declaration)) {
312
+ let { node: i, parent: a } = t, o = l.types.isIdentifier(i.declaration) && l.types.isProgram(a);
313
+ if (e._options.transformInlineMeta && !o && l.types.isExpression(i.declaration)) {
313
314
  let d = t.scope.generateUidIdentifier("meta");
314
315
  e._metaVariableName = d.name;
315
316
  let g = [
316
- c.types.variableDeclaration("const", [c.types.variableDeclarator(d, i.declaration)]),
317
- c.types.exportDefaultDeclaration(d)
317
+ l.types.variableDeclaration("const", [l.types.variableDeclarator(d, i.declaration)]),
318
+ l.types.exportDefaultDeclaration(d)
318
319
  ];
319
320
  g.forEach((x) => x.loc = t.node.loc), t.replaceWithMultiple(g);
320
321
  return;
321
322
  }
322
- let l, p;
323
- if (a) {
323
+ let c, p;
324
+ if (o) {
324
325
  let d = i.declaration.name;
325
326
  e._metaVariableName = d;
326
- let g = /* @__PURE__ */ f((x) => c.types.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
327
+ let g = /* @__PURE__ */ f((x) => l.types.isIdentifier(x.id) && x.id.name === d, "isVariableDeclarator");
327
328
  e._metaStatement = e._ast.program.body.find(
328
- (x) => c.types.isVariableDeclaration(x) && x.declarations.find(g)
329
+ (x) => l.types.isVariableDeclaration(x) && x.declarations.find(g)
329
330
  ), p = (e?._metaStatement?.declarations || []).find(
330
331
  g
331
332
  )?.init;
332
333
  } else
333
334
  e._metaStatement = i, p = i.declaration;
334
- if (c.types.isObjectExpression(p) ? l = p : (
335
+ if (l.types.isObjectExpression(p) ? c = p : (
335
336
  // export default { ... } as Meta<...>
336
- (c.types.isTSAsExpression(p) || c.types.isTSSatisfiesExpression(p)) && c.types.isObjectExpression(p.expression) && (l = p.expression)
337
- ), l && c.types.isProgram(o) && e._parseMeta(l, o), e._metaStatement && !e._metaNode)
338
- throw new L(
337
+ (l.types.isTSAsExpression(p) || l.types.isTSSatisfiesExpression(p)) && l.types.isObjectExpression(p.expression) && (c = p.expression)
338
+ ), c && l.types.isProgram(a) && e._parseMeta(c, a), e._metaStatement && !e._metaNode)
339
+ throw new R(
339
340
  "default export must be an object",
340
341
  e._metaStatement,
341
342
  e._options.fileName
@@ -345,63 +346,64 @@ var D = /* @__PURE__ */ f((s, e) => {
345
346
  },
346
347
  ExportNamedDeclaration: {
347
348
  enter(t) {
348
- let { node: i, parent: o } = t, a;
349
- c.types.isVariableDeclaration(i.declaration) ? a = i.declaration.declarations.filter((l) => c.types.isVariableDeclarator(l)) : c.types.
350
- isFunctionDeclaration(i.declaration) && (a = [i.declaration]), a ? a.forEach((l) => {
351
- if (c.types.isIdentifier(l.id)) {
352
- let p = !1, { name: d } = l.id;
353
- if (d === "__namedExportsOrder" && c.types.isVariableDeclarator(l)) {
354
- e._namedExportsOrder = et(l.init);
349
+ let { node: i, parent: a } = t, o;
350
+ l.types.isVariableDeclaration(i.declaration) ? o = i.declaration.declarations.filter((c) => l.types.isVariableDeclarator(c)) : l.types.
351
+ isFunctionDeclaration(i.declaration) && (o = [i.declaration]), o ? o.forEach((c) => {
352
+ if (l.types.isIdentifier(c.id)) {
353
+ let p = !1, { name: d } = c.id;
354
+ if (d === "__namedExportsOrder" && l.types.isVariableDeclarator(c)) {
355
+ e._namedExportsOrder = tt(c.init);
355
356
  return;
356
357
  }
357
- e._storyExports[d] = l, e._storyPaths[d] = t, e._storyStatements[d] = i;
358
+ e._storyExports[d] = c, e._storyPaths[d] = t, e._storyStatements[d] = i;
358
359
  let g = (0, v.storyNameFromExport)(d);
359
- e._storyAnnotations[d] ? fe.warn(
360
+ e._storyAnnotations[d] ? re.logger.warn(
360
361
  `Unexpected annotations for "${d}" before story declaration`
361
362
  ) : e._storyAnnotations[d] = {};
362
363
  let x;
363
- if (c.types.isVariableDeclarator(l) ? x = c.types.isTSAsExpression(l.init) || c.types.isTSSatisfiesExpression(l.init) ? l.init.
364
- expression : l.init : x = l, c.types.isCallExpression(x) && c.types.isMemberExpression(x.callee) && c.types.isIdentifier(x.callee.
365
- property) && x.callee.property.name === "story" && (p = !0, x = x.arguments[0]), e._metaIsFactory && !p)
366
- throw new M(
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 &&
367
+ !p)
368
+ throw new L(
367
369
  "expected factory story",
368
370
  x,
369
371
  e._options.fileName
370
372
  );
371
373
  if (!e._metaIsFactory && p)
372
- throw e._metaNode ? new M(
374
+ throw e._metaNode ? new L(
373
375
  "expected non-factory story",
374
376
  x,
375
377
  e._options.fileName
376
- ) : new U(
378
+ ) : new M(
377
379
  "meta() factory must be imported from .storybook/preview configuration",
378
380
  x,
379
381
  e._options.fileName
380
382
  );
381
383
  let h = {};
382
- c.types.isObjectExpression(x) ? (h.__isArgsStory = !0, x.properties.forEach((b) => {
383
- if (c.types.isIdentifier(b.key)) {
384
+ l.types.isObjectExpression(x) ? (h.__isArgsStory = !0, x.properties.forEach((b) => {
385
+ if (l.types.isIdentifier(b.key)) {
384
386
  if (b.key.name === "render")
385
387
  h.__isArgsStory = ue(
386
388
  b.value,
387
- o,
389
+ a,
388
390
  e
389
391
  );
390
- else if (b.key.name === "name" && c.types.isStringLiteral(b.value))
392
+ else if (b.key.name === "name" && l.types.isStringLiteral(b.value))
391
393
  g = b.value.value;
392
- else if (b.key.name === "storyName" && c.types.isStringLiteral(b.value))
393
- fe.warn(
394
+ else if (b.key.name === "storyName" && l.types.isStringLiteral(b.value))
395
+ re.logger.warn(
394
396
  `Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
395
397
  );
396
- else if (b.key.name === "parameters" && c.types.isObjectExpression(b.value)) {
397
- let E = b.value.properties.find(
398
- (I) => c.types.isObjectProperty(I) && c.types.isIdentifier(I.key) && I.key.name === "__id"
398
+ else if (b.key.name === "parameters" && l.types.isObjectExpression(b.value)) {
399
+ let _ = b.value.properties.find(
400
+ (W) => l.types.isObjectProperty(W) && l.types.isIdentifier(W.key) && W.key.name === "__id"
399
401
  );
400
- E && (h.__id = E.value.value);
402
+ _ && (h.__id = _.value.value);
401
403
  }
402
404
  e._storyAnnotations[d][b.key.name] = b.value;
403
405
  }
404
- })) : h.__isArgsStory = ue(x, o, e), e._stories[d] = {
406
+ })) : h.__isArgsStory = ue(x, a, e), e._stories[d] = {
405
407
  id: "FIXME",
406
408
  name: g,
407
409
  parameters: h,
@@ -410,19 +412,19 @@ var D = /* @__PURE__ */ f((s, e) => {
410
412
  }
411
413
  };
412
414
  }
413
- }) : i.specifiers.length > 0 && i.specifiers.forEach((l) => {
414
- if (c.types.isExportSpecifier(l) && c.types.isIdentifier(l.exported)) {
415
- let { name: p } = l.exported, { name: d } = l.local, g = c.types.isProgram(o) ? P(d, o) : l.local;
415
+ }) : i.specifiers.length > 0 && i.specifiers.forEach((c) => {
416
+ 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;
416
418
  if (p === "default") {
417
419
  let x;
418
- c.types.isObjectExpression(g) ? x = g : (
420
+ l.types.isObjectExpression(g) ? x = g : (
419
421
  // export default { ... } as Meta<...>
420
- c.types.isTSAsExpression(g) && c.types.isObjectExpression(g.expression) && (x = g.expression)
421
- ), x && c.types.isProgram(o) && e._parseMeta(x, o);
422
+ l.types.isTSAsExpression(g) && l.types.isObjectExpression(g.expression) && (x = g.expression)
423
+ ), x && l.types.isProgram(a) && e._parseMeta(x, a);
422
424
  } else {
423
425
  let x = {}, h = g;
424
- c.types.isObjectExpression(h) && h.properties.forEach((b) => {
425
- c.types.isIdentifier(b.key) && (x[b.key.name] = b.value);
426
+ l.types.isObjectExpression(h) && h.properties.forEach((b) => {
427
+ l.types.isIdentifier(b.key) && (x[b.key.name] = b.value);
426
428
  }), e._storyAnnotations[p] = x, e._storyStatements[p] = g, e._storyPaths[p] = t, e._stories[p] = {
427
429
  id: "FIXME",
428
430
  name: p,
@@ -437,14 +439,14 @@ var D = /* @__PURE__ */ f((s, e) => {
437
439
  },
438
440
  ExpressionStatement: {
439
441
  enter({ node: t, parent: i }) {
440
- let { expression: o } = t;
441
- if (c.types.isProgram(i) && c.types.isAssignmentExpression(o) && c.types.isMemberExpression(o.left) && c.types.isIdentifier(o.left.
442
- object) && c.types.isIdentifier(o.left.property)) {
443
- let a = o.left.object.name, l = o.left.property.name, p = o.right;
444
- if (e._storyAnnotations[a] && (l === "story" && c.types.isObjectExpression(p) ? p.properties.forEach((d) => {
445
- c.types.isIdentifier(d.key) && (e._storyAnnotations[a][d.key.name] = d.value);
446
- }) : e._storyAnnotations[a][l] = p), l === "storyName" && c.types.isStringLiteral(p)) {
447
- let d = p.value, g = e._stories[a];
442
+ let { expression: a } = t;
443
+ if (l.types.isProgram(i) && l.types.isAssignmentExpression(a) && l.types.isMemberExpression(a.left) && l.types.isIdentifier(a.left.
444
+ object) && l.types.isIdentifier(a.left.property)) {
445
+ let o = a.left.object.name, c = a.left.property.name, p = a.right;
446
+ if (e._storyAnnotations[o] && (c === "story" && l.types.isObjectExpression(p) ? p.properties.forEach((d) => {
447
+ l.types.isIdentifier(d.key) && (e._storyAnnotations[o][d.key.name] = d.value);
448
+ }) : e._storyAnnotations[o][c] = p), c === "storyName" && l.types.isStringLiteral(p)) {
449
+ let d = p.value, g = e._stories[o];
448
450
  if (!g)
449
451
  return;
450
452
  g.name = d;
@@ -454,24 +456,24 @@ var D = /* @__PURE__ */ f((s, e) => {
454
456
  },
455
457
  CallExpression: {
456
458
  enter(t) {
457
- let { node: i } = t, { callee: o } = i;
458
- if (c.types.isIdentifier(o) && o.name === "storiesOf")
459
+ let { node: i } = t, { callee: a } = i;
460
+ if (l.types.isIdentifier(a) && a.name === "storiesOf")
459
461
  throw new Error(O.dedent`
460
462
  Unexpected \`storiesOf\` usage: ${D(i, e._options.fileName)}.
461
463
 
462
464
  SB8 does not support \`storiesOf\`.
463
465
  `);
464
- if (c.types.isMemberExpression(o) && c.types.isIdentifier(o.property) && o.property.name === "meta" && c.types.isIdentifier(o.object) &&
466
+ if (l.types.isMemberExpression(a) && l.types.isIdentifier(a.property) && a.property.name === "meta" && l.types.isIdentifier(a.object) &&
465
467
  i.arguments.length > 0) {
466
- let l = t.scope.getBinding(o.object.name)?.path?.parentPath?.node;
467
- if (c.types.isImportDeclaration(l))
468
- if (ge(l.source.value)) {
468
+ let c = t.scope.getBinding(a.object.name)?.path?.parentPath?.node;
469
+ if (l.types.isImportDeclaration(c))
470
+ if (xe(c.source.value)) {
469
471
  let p = i.arguments[0];
470
- e._metaVariableName = o.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
472
+ e._metaVariableName = a.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
471
473
  } else
472
- throw new U(
474
+ throw new M(
473
475
  "meta() factory must be imported from .storybook/preview configuration",
474
- l,
476
+ c,
475
477
  e._options.fileName
476
478
  );
477
479
  }
@@ -480,48 +482,48 @@ var D = /* @__PURE__ */ f((s, e) => {
480
482
  ImportDeclaration: {
481
483
  enter({ node: t }) {
482
484
  let { source: i } = t;
483
- if (c.types.isStringLiteral(i))
485
+ if (l.types.isStringLiteral(i))
484
486
  e.imports.push(i.value);
485
487
  else
486
488
  throw new Error("CSF: unexpected import source");
487
489
  }
488
490
  }
489
491
  }), !e._meta)
490
- throw new L("missing default export", e._ast, e._options.fileName);
492
+ throw new R("missing default export", e._ast, e._options.fileName);
491
493
  let r = Object.entries(e._stories);
492
494
  if (e._meta.title = this._options.makeTitle(e._meta?.title), e._metaAnnotations.play && (e._meta.tags = [...e._meta.tags || [], "play-fn"]),
493
495
  e._stories = r.reduce(
494
- (t, [i, o]) => {
496
+ (t, [i, a]) => {
495
497
  if (!(0, v.isExportStory)(i, e._meta))
496
498
  return t;
497
- let a = o.parameters?.__id ?? (0, v.toId)(e._meta?.id || e._meta?.title, (0, v.storyNameFromExport)(i)), l = { ...o.parameters, __id: a },
499
+ let o = a.parameters?.__id ?? (0, v.toId)(e._meta?.id || e._meta?.title, (0, v.storyNameFromExport)(i)), c = { ...a.parameters, __id: o },
498
500
  { includeStories: p } = e._meta || {};
499
- i === "__page" && (r.length === 1 || Array.isArray(p) && p.length === 1) && (l.docsOnly = !0), t[i] = { ...o, id: a, parameters: l };
501
+ i === "__page" && (r.length === 1 || Array.isArray(p) && p.length === 1) && (c.docsOnly = !0), t[i] = { ...a, id: o, parameters: c };
500
502
  let d = e._storyAnnotations[i], { tags: g, play: x } = d;
501
503
  if (g) {
502
- let E = c.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
503
- t[i].tags = de(E);
504
+ let _ = l.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
505
+ t[i].tags = me(_);
504
506
  }
505
507
  x && (t[i].tags = [...t[i].tags || [], "play-fn"]);
506
508
  let h = t[i].__stats;
507
- ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((E) => {
508
- h[E] = !!d[E] || !!e._metaAnnotations[E];
509
+ ["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((_) => {
510
+ h[_] = !!d[_] || !!e._metaAnnotations[_];
509
511
  });
510
512
  let b = e.getStoryExport(i);
511
- return h.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), h.mount = tt(d.play ?? e._metaAnnotations.
512
- play), h.moduleMock = !!e.imports.find((E) => xe(E)), t;
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;
513
515
  },
514
516
  {}
515
517
  ), Object.keys(e._storyExports).forEach((t) => {
516
518
  (0, v.isExportStory)(t, e._meta) || (delete e._storyExports[t], delete e._storyAnnotations[t], delete e._storyStatements[t]);
517
519
  }), e._namedExportsOrder) {
518
520
  let t = Object.keys(e._storyExports);
519
- e._storyExports = me(e._storyExports, e._namedExportsOrder), e._stories = me(e._stories, e._namedExportsOrder);
521
+ e._storyExports = ge(e._storyExports, e._namedExportsOrder), e._stories = ge(e._stories, e._namedExportsOrder);
520
522
  let i = Object.keys(e._storyExports);
521
523
  if (t.length !== i.length)
522
524
  throw new Error(
523
525
  `Missing exports after sort: ${t.filter(
524
- (o) => !i.includes(o)
526
+ (a) => !i.includes(a)
525
527
  )}`
526
528
  );
527
529
  }
@@ -556,72 +558,72 @@ var D = /* @__PURE__ */ f((s, e) => {
556
558
  };
557
559
  });
558
560
  }
559
- }, ye = /* @__PURE__ */ f(({
561
+ }, be = /* @__PURE__ */ f(({
560
562
  code: s,
561
563
  filename: e = "",
562
564
  ast: r
563
- }) => new c.BabelFileClass({ filename: e }, { code: s, ast: r ?? (0, c.babelParse)(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
564
- let r = (0, c.babelParse)(s), t = ye({ code: s, filename: e.fileName, ast: r });
565
+ }) => new l.BabelFileClass({ filename: e }, { code: s, ast: r ?? (0, l.babelParse)(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
566
+ let r = (0, l.babelParse)(s), t = be({ code: s, filename: e.fileName, ast: r });
565
567
  return new K(r, e, t);
566
- }, "loadCsf"), te = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, r) => {
567
- let t = (0, c.generate)(s._ast, e, r);
568
+ }, "loadCsf"), ie = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, r) => {
569
+ let t = (0, l.generate)(s._ast, e, r);
568
570
  return e.sourceMaps ? t : t.code;
569
- }, "formatCsf"), be = /* @__PURE__ */ f((s, e = {}) => c.recast.print(s._ast, e), "printCsf"), it = /* @__PURE__ */ f(async (s, e) => {
571
+ }, "formatCsf"), he = /* @__PURE__ */ f((s, e = {}) => l.recast.print(s._ast, e), "printCsf"), st = /* @__PURE__ */ f(async (s, e) => {
570
572
  let r = (await (0, J.readFile)(s, "utf-8")).toString();
571
573
  return Q(r, { ...e, fileName: s });
572
- }, "readCsf"), st = /* @__PURE__ */ f(async (s, e) => {
574
+ }, "readCsf"), nt = /* @__PURE__ */ f(async (s, e) => {
573
575
  if (!(e || s._options.fileName))
574
576
  throw new Error("Please specify a fileName for writeCsf");
575
- await (0, J.writeFile)(e, be(s).code);
577
+ await (0, J.writeFile)(e, he(s).code);
576
578
  }, "writeCsf");
577
579
 
578
580
  // src/csf-tools/ConfigFile.ts
579
- var ee = require("node:fs/promises"), n = require("storybook/internal/babel"), he = z(R(), 1);
580
- var re = console, ie = /* @__PURE__ */ f(({
581
+ var te = require("node:fs/promises"), n = require("storybook/internal/babel"), H = require("storybook/internal/node-logger"), Ee = z($(), 1);
582
+ var se = /* @__PURE__ */ f(({
581
583
  expectedType: s,
582
584
  foundType: e,
583
585
  node: r
584
- }) => he.dedent`
586
+ }) => Ee.dedent`
585
587
  CSF Parsing error: Expected '${s}' but found '${e}' instead in '${r?.type}'.
586
- `, "getCsfParsingErrorMessage"), C = /* @__PURE__ */ f((s) => n.types.isIdentifier(s.key) ? s.key.name : n.types.isStringLiteral(s.key) ?
587
- s.key.value : null, "propKey"), H = /* @__PURE__ */ f((s) => n.types.isTSAsExpression(s) || n.types.isTSSatisfiesExpression(s) ? H(s.expression) :
588
- s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
588
+ `, "getCsfParsingErrorMessage"), F = /* @__PURE__ */ f((s) => n.types.isIdentifier(s.key) ? s.key.name : n.types.isStringLiteral(s.key) ?
589
+ s.key.value : null, "propKey"), Y = /* @__PURE__ */ f((s) => n.types.isTSAsExpression(s) || n.types.isTSSatisfiesExpression(s) ? Y(s.expression) :
590
+ s, "unwrap"), _e = /* @__PURE__ */ f((s, e) => {
589
591
  if (s.length === 0)
590
592
  return e;
591
593
  if (n.types.isObjectExpression(e)) {
592
- let [r, ...t] = s, i = e.properties.find((o) => C(o) === r);
594
+ let [r, ...t] = s, i = e.properties.find((a) => F(a) === r);
593
595
  if (i)
594
- return Ee(t, i.value);
596
+ return _e(t, i.value);
595
597
  }
596
- }, "_getPath"), _e = /* @__PURE__ */ f((s, e) => {
598
+ }, "_getPath"), je = /* @__PURE__ */ f((s, e) => {
597
599
  if (s.length === 0) {
598
600
  if (n.types.isObjectExpression(e))
599
601
  return e.properties;
600
602
  throw new Error("Expected object expression");
601
603
  }
602
604
  if (n.types.isObjectExpression(e)) {
603
- let [r, ...t] = s, i = e.properties.find((o) => C(o) === r);
605
+ let [r, ...t] = s, i = e.properties.find((a) => F(a) === r);
604
606
  if (i)
605
- return t.length === 0 ? e.properties : _e(t, i.value);
607
+ return t.length === 0 ? e.properties : je(t, i.value);
606
608
  }
607
- }, "_getPathProperties"), Y = /* @__PURE__ */ f((s, e) => {
609
+ }, "_getPathProperties"), Z = /* @__PURE__ */ f((s, e) => {
608
610
  let r = null, t = null;
609
611
  return e.body.find((i) => (n.types.isVariableDeclaration(i) ? t = i.declarations : n.types.isExportNamedDeclaration(i) && n.types.isVariableDeclaration(
610
- i.declaration) && (t = i.declaration.declarations), t && t.find((o) => n.types.isVariableDeclarator(o) && n.types.isIdentifier(o.id) && o.
611
- id.name === s ? (r = o, !0) : !1))), r;
612
- }, "_findVarDeclarator"), F = /* @__PURE__ */ f((s, e) => Y(s, e)?.init, "_findVarInitialization"), B = /* @__PURE__ */ f((s, e) => {
612
+ i.declaration) && (t = i.declaration.declarations), t && t.find((a) => n.types.isVariableDeclarator(a) && n.types.isIdentifier(a.id) && a.
613
+ id.name === s ? (r = a, !0) : !1))), r;
614
+ }, "_findVarDeclarator"), w = /* @__PURE__ */ f((s, e) => Z(s, e)?.init, "_findVarInitialization"), q = /* @__PURE__ */ f((s, e) => {
613
615
  if (s.length === 0)
614
616
  return e;
615
- let [r, ...t] = s, i = B(t, e);
617
+ let [r, ...t] = s, i = q(t, e);
616
618
  return n.types.objectExpression([n.types.objectProperty(n.types.identifier(r), i)]);
617
- }, "_makeObjectExpression"), q = /* @__PURE__ */ f((s, e, r) => {
618
- let [t, ...i] = s, o = r.properties.find(
619
- (a) => C(a) === t
619
+ }, "_makeObjectExpression"), U = /* @__PURE__ */ f((s, e, r) => {
620
+ let [t, ...i] = s, a = r.properties.find(
621
+ (o) => F(o) === t
620
622
  );
621
- o ? n.types.isObjectExpression(o.value) && i.length > 0 ? q(i, e, o.value) : o.value = B(i, e) : r.properties.push(
622
- n.types.objectProperty(n.types.identifier(t), B(i, e))
623
+ a ? n.types.isObjectExpression(a.value) && i.length > 0 ? U(i, e, a.value) : a.value = q(i, e) : r.properties.push(
624
+ n.types.objectProperty(n.types.identifier(t), q(i, e))
623
625
  );
624
- }, "_updateExportNode"), Z = class {
626
+ }, "_updateExportNode"), ee = class {
625
627
  constructor(e, r, t) {
626
628
  this._exports = {};
627
629
  // FIXME: this is a hack. this is only used in the case where the user is
@@ -636,10 +638,10 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
636
638
  }
637
639
  _parseExportsObject(e) {
638
640
  this._exportsObject = e, e.properties.forEach((r) => {
639
- let t = C(r);
641
+ let t = F(r);
640
642
  if (t) {
641
643
  let i = r.value;
642
- n.types.isIdentifier(i) && (i = F(i.name, this._ast.program)), this._exports[t] = i;
644
+ n.types.isIdentifier(i) && (i = w(i.name, this._ast.program)), this._exports[t] = i;
643
645
  }
644
646
  });
645
647
  }
@@ -649,10 +651,10 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
649
651
  ExportDefaultDeclaration: {
650
652
  enter({ node: r, parent: t }) {
651
653
  e.hasDefaultExport = !0;
652
- let i = n.types.isIdentifier(r.declaration) && n.types.isProgram(t) ? F(r.declaration.name, t) : r.declaration;
653
- i = H(i), n.types.isCallExpression(i) && n.types.isObjectExpression(i.arguments[0]) && (i = i.arguments[0]), n.types.isObjectExpression(
654
- i) ? e._parseExportsObject(i) : re.warn(
655
- ie({
654
+ let i = n.types.isIdentifier(r.declaration) && n.types.isProgram(t) ? w(r.declaration.name, t) : r.declaration;
655
+ i = Y(i), n.types.isCallExpression(i) && n.types.isObjectExpression(i.arguments[0]) && (i = i.arguments[0]), n.types.isObjectExpression(
656
+ i) ? e._parseExportsObject(i) : H.logger.warn(
657
+ se({
656
658
  expectedType: "ObjectExpression",
657
659
  foundType: i?.type,
658
660
  node: i || r.declaration
@@ -665,23 +667,23 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
665
667
  if (n.types.isVariableDeclaration(r.declaration))
666
668
  r.declaration.declarations.forEach((i) => {
667
669
  if (n.types.isVariableDeclarator(i) && n.types.isIdentifier(i.id)) {
668
- let { name: o } = i.id, a = i.init;
669
- n.types.isIdentifier(a) && (a = F(a.name, t)), e._exports[o] = a, e._exportDecls[o] = i;
670
+ let { name: a } = i.id, o = i.init;
671
+ n.types.isIdentifier(o) && (o = w(o.name, t)), e._exports[a] = o, e._exportDecls[a] = i;
670
672
  }
671
673
  });
672
674
  else if (n.types.isFunctionDeclaration(r.declaration)) {
673
675
  let i = r.declaration;
674
676
  if (n.types.isIdentifier(i.id)) {
675
- let { name: o } = i.id;
676
- e._exportDecls[o] = i;
677
+ let { name: a } = i.id;
678
+ e._exportDecls[a] = i;
677
679
  }
678
680
  } else r.specifiers ? r.specifiers.forEach((i) => {
679
681
  if (n.types.isExportSpecifier(i) && n.types.isIdentifier(i.local) && n.types.isIdentifier(i.exported)) {
680
- let { name: o } = i.local, { name: a } = i.exported, l = Y(o, t);
681
- l && (e._exports[a] = l.init, e._exportDecls[a] = l);
682
+ let { name: a } = i.local, { name: o } = i.exported, c = Z(a, t);
683
+ c && (e._exports[o] = c.init, e._exportDecls[o] = c);
682
684
  }
683
- }) : re.warn(
684
- ie({
685
+ }) : H.logger.warn(
686
+ se({
685
687
  expectedType: "VariableDeclaration",
686
688
  foundType: r.declaration?.type,
687
689
  node: r.declaration
@@ -692,25 +694,25 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
692
694
  ExpressionStatement: {
693
695
  enter({ node: r, parent: t }) {
694
696
  if (n.types.isAssignmentExpression(r.expression) && r.expression.operator === "=") {
695
- let { left: i, right: o } = r.expression;
697
+ let { left: i, right: a } = r.expression;
696
698
  if (n.types.isMemberExpression(i) && n.types.isIdentifier(i.object) && i.object.name === "module" && n.types.isIdentifier(i.property) &&
697
699
  i.property.name === "exports") {
698
- let a = o;
699
- n.types.isIdentifier(o) && (a = F(o.name, t)), a = H(a), n.types.isObjectExpression(a) ? (e._exportsObject = a, a.properties.forEach(
700
- (l) => {
701
- let p = C(l);
700
+ let o = a;
701
+ n.types.isIdentifier(a) && (o = w(a.name, t)), o = Y(o), n.types.isObjectExpression(o) ? (e._exportsObject = o, o.properties.forEach(
702
+ (c) => {
703
+ let p = F(c);
702
704
  if (p) {
703
- let d = l.value;
704
- n.types.isIdentifier(d) && (d = F(
705
+ let d = c.value;
706
+ n.types.isIdentifier(d) && (d = w(
705
707
  d.name,
706
708
  t
707
709
  )), e._exports[p] = d;
708
710
  }
709
- })) : re.warn(
710
- ie({
711
+ })) : H.logger.warn(
712
+ se({
711
713
  expectedType: "ObjectExpression",
712
- foundType: a?.type,
713
- node: a
714
+ foundType: o?.type,
715
+ node: o
714
716
  })
715
717
  );
716
718
  }
@@ -728,12 +730,12 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
728
730
  getFieldNode(e) {
729
731
  let [r, ...t] = e, i = this._exports[r];
730
732
  if (i)
731
- return Ee(t, i);
733
+ return _e(t, i);
732
734
  }
733
735
  getFieldProperties(e) {
734
736
  let [r, ...t] = e, i = this._exports[r];
735
737
  if (i)
736
- return _e(t, i);
738
+ return je(t, i);
737
739
  }
738
740
  getFieldValue(e) {
739
741
  let r = this.getFieldNode(e);
@@ -749,31 +751,31 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
749
751
  }
750
752
  }
751
753
  setFieldNode(e, r) {
752
- let [t, ...i] = e, o = this._exports[t];
754
+ let [t, ...i] = e, a = this._exports[t];
753
755
  if (this._exportsObject) {
754
- let p = this._exportsObject.properties.find((d) => C(d) === t);
756
+ let p = this._exportsObject.properties.find((d) => F(d) === t);
755
757
  if (p && n.types.isIdentifier(p.value)) {
756
- let d = Y(p.value.name, this._ast.program);
758
+ let d = Z(p.value.name, this._ast.program);
757
759
  if (d && n.types.isObjectExpression(d.init)) {
758
- q(i, r, d.init);
760
+ U(i, r, d.init);
759
761
  return;
760
762
  }
761
763
  }
762
- q(e, r, this._exportsObject), this._exports[e[0]] = r;
764
+ U(e, r, this._exportsObject), this._exports[e[0]] = r;
763
765
  return;
764
766
  }
765
- if (o && n.types.isObjectExpression(o) && i.length > 0) {
766
- q(i, r, o);
767
+ if (a && n.types.isObjectExpression(a) && i.length > 0) {
768
+ U(i, r, a);
767
769
  return;
768
770
  }
769
- let a = Y(t, this._ast.program);
770
- if (a && n.types.isObjectExpression(a.init)) {
771
- q(i, r, a.init);
771
+ let o = Z(t, this._ast.program);
772
+ if (o && n.types.isObjectExpression(o.init)) {
773
+ U(i, r, o.init);
772
774
  return;
773
775
  }
774
- if (o && i.length === 0 && this._exportDecls[e[0]]) {
775
- let l = this._exportDecls[e[0]];
776
- n.types.isVariableDeclarator(l) && (l.init = B([], r));
776
+ if (a && i.length === 0 && this._exportDecls[e[0]]) {
777
+ let c = this._exportDecls[e[0]];
778
+ n.types.isVariableDeclarator(c) && (c.init = q([], r));
777
779
  } else {
778
780
  if (this.hasDefaultExport)
779
781
  throw new Error(
@@ -782,10 +784,10 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
782
784
  )}" field as the default export is not an object in this file.`
783
785
  );
784
786
  {
785
- let l = B(i, r), p = n.types.exportNamedDeclaration(
786
- n.types.variableDeclaration("const", [n.types.variableDeclarator(n.types.identifier(t), l)])
787
+ let c = q(i, r), p = n.types.exportNamedDeclaration(
788
+ n.types.variableDeclaration("const", [n.types.variableDeclarator(n.types.identifier(t), c)])
787
789
  );
788
- this._exports[t] = l, this._ast.program.body.push(p);
790
+ this._exports[t] = c, this._ast.program.body.push(p);
789
791
  }
790
792
  }
791
793
  }
@@ -853,31 +855,31 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
853
855
  return t;
854
856
  }
855
857
  removeField(e) {
856
- let r = /* @__PURE__ */ f((i, o) => {
857
- let a = i.findIndex(
858
- (l) => n.types.isIdentifier(l.key) && l.key.name === o || n.types.isStringLiteral(l.key) && l.key.value === o
858
+ let r = /* @__PURE__ */ f((i, a) => {
859
+ let o = i.findIndex(
860
+ (c) => n.types.isIdentifier(c.key) && c.key.name === a || n.types.isStringLiteral(c.key) && c.key.value === a
859
861
  );
860
- a >= 0 && i.splice(a, 1);
862
+ o >= 0 && i.splice(o, 1);
861
863
  }, "removeProperty");
862
864
  if (e.length === 1) {
863
865
  let i = !1;
864
- if (this._ast.program.body.forEach((o) => {
865
- if (n.types.isExportNamedDeclaration(o) && n.types.isVariableDeclaration(o.declaration)) {
866
- let a = o.declaration.declarations[0];
867
- n.types.isIdentifier(a.id) && a.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(o), 1), i = !0);
866
+ if (this._ast.program.body.forEach((a) => {
867
+ if (n.types.isExportNamedDeclaration(a) && n.types.isVariableDeclaration(a.declaration)) {
868
+ let o = a.declaration.declarations[0];
869
+ n.types.isIdentifier(o.id) && o.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(a), 1), i = !0);
868
870
  }
869
- if (n.types.isExportDefaultDeclaration(o)) {
870
- let a = o.declaration;
871
- if (n.types.isIdentifier(a) && (a = F(a.name, this._ast.program)), a = H(a), n.types.isObjectExpression(a)) {
872
- let l = a.properties;
873
- r(l, e[0]), i = !0;
871
+ if (n.types.isExportDefaultDeclaration(a)) {
872
+ let o = a.declaration;
873
+ if (n.types.isIdentifier(o) && (o = w(o.name, this._ast.program)), o = Y(o), n.types.isObjectExpression(o)) {
874
+ let c = o.properties;
875
+ r(c, e[0]), i = !0;
874
876
  }
875
877
  }
876
- if (n.types.isExpressionStatement(o) && n.types.isAssignmentExpression(o.expression) && n.types.isMemberExpression(o.expression.left) &&
877
- n.types.isIdentifier(o.expression.left.object) && o.expression.left.object.name === "module" && n.types.isIdentifier(o.expression.left.
878
- property) && o.expression.left.property.name === "exports" && n.types.isObjectExpression(o.expression.right)) {
879
- let a = o.expression.right.properties;
880
- r(a, e[0]), i = !0;
878
+ if (n.types.isExpressionStatement(a) && n.types.isAssignmentExpression(a.expression) && n.types.isMemberExpression(a.expression.left) &&
879
+ n.types.isIdentifier(a.expression.left.object) && a.expression.left.object.name === "module" && n.types.isIdentifier(a.expression.left.
880
+ property) && a.expression.left.property.name === "exports" && n.types.isObjectExpression(a.expression.right)) {
881
+ let o = a.expression.right.properties;
882
+ r(o, e[0]), i = !0;
881
883
  }
882
884
  }), i)
883
885
  return;
@@ -909,8 +911,8 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
909
911
  let t = this.getFieldNode(e);
910
912
  if (t)
911
913
  if (n.types.isArrayExpression(t)) {
912
- let i = t.elements.findIndex((o) => n.types.isStringLiteral(o) ? o.value === r : n.types.isObjectExpression(o) ? this._getPresetValue(
913
- o, "name") === r : this._getPnpWrappedValue(o) === r);
914
+ let i = t.elements.findIndex((a) => n.types.isStringLiteral(a) ? a.value === r : n.types.isObjectExpression(a) ? this._getPresetValue(
915
+ a, "name") === r : this._getPnpWrappedValue(a) === r);
914
916
  if (i >= 0)
915
917
  t.elements.splice(i, 1);
916
918
  else
@@ -931,12 +933,12 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
931
933
  valueToNode(e) {
932
934
  let r = this._inferQuotes(), t;
933
935
  if (r === "single") {
934
- let { code: i } = (0, n.generate)(n.types.valueToNode(e), { jsescOption: { quotes: r } }), o = (0, n.babelParse)(`const __x = ${i}`);
935
- (0, n.traverse)(o, {
936
+ let { code: i } = (0, n.generate)(n.types.valueToNode(e), { jsescOption: { quotes: r } }), a = (0, n.babelParse)(`const __x = ${i}`);
937
+ (0, n.traverse)(a, {
936
938
  VariableDeclaration: {
937
- enter({ node: a }) {
938
- a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) && n.types.isIdentifier(a.declarations[0].id) && a.
939
- declarations[0].id.name === "__x" && (t = a.declarations[0].init);
939
+ enter({ node: o }) {
940
+ o.declarations.length === 1 && n.types.isVariableDeclarator(o.declarations[0]) && n.types.isIdentifier(o.declarations[0].id) && o.
941
+ declarations[0].id.name === "__x" && (t = o.declarations[0].init);
940
942
  }
941
943
  }
942
944
  });
@@ -974,18 +976,18 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
974
976
  * @param fromImport - The module to import from
975
977
  */
976
978
  setRequireImport(e, r) {
977
- let t = this._ast.program.body.find((a) => {
978
- let l = n.types.isVariableDeclaration(a) && a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) && n.types.
979
- isCallExpression(a.declarations[0].init) && n.types.isIdentifier(a.declarations[0].init.callee) && a.declarations[0].init.callee.name ===
980
- "require" && n.types.isStringLiteral(a.declarations[0].init.arguments[0]) && (a.declarations[0].init.arguments[0].value === r || a.declarations[0].
979
+ let t = this._ast.program.body.find((o) => {
980
+ let c = n.types.isVariableDeclaration(o) && o.declarations.length === 1 && n.types.isVariableDeclarator(o.declarations[0]) && n.types.
981
+ isCallExpression(o.declarations[0].init) && n.types.isIdentifier(o.declarations[0].init.callee) && o.declarations[0].init.callee.name ===
982
+ "require" && n.types.isStringLiteral(o.declarations[0].init.arguments[0]) && (o.declarations[0].init.arguments[0].value === r || o.declarations[0].
981
983
  init.arguments[0].value === r.split("node:")[1]);
982
- return l && (r = a.declarations[0].init.arguments[0].value), l;
983
- }), i = /* @__PURE__ */ f((a) => n.types.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
984
- (l) => n.types.isObjectProperty(l) && n.types.isIdentifier(l.key) && l.key.name === a
985
- ), "hasRequireSpecifier"), o = /* @__PURE__ */ f((a, l) => a.declarations.length === 1 && n.types.isVariableDeclarator(a.declarations[0]) &&
986
- n.types.isIdentifier(a.declarations[0].id) && a.declarations[0].id.name === l, "hasDefaultRequireSpecifier");
984
+ return c && (r = o.declarations[0].init.arguments[0].value), c;
985
+ }), i = /* @__PURE__ */ f((o) => n.types.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
986
+ (c) => n.types.isObjectProperty(c) && n.types.isIdentifier(c.key) && c.key.name === o
987
+ ), "hasRequireSpecifier"), a = /* @__PURE__ */ f((o, c) => o.declarations.length === 1 && n.types.isVariableDeclarator(o.declarations[0]) &&
988
+ n.types.isIdentifier(o.declarations[0].id) && o.declarations[0].id.name === c, "hasDefaultRequireSpecifier");
987
989
  if (typeof e == "string") {
988
- let a = /* @__PURE__ */ f(() => {
990
+ let o = /* @__PURE__ */ f(() => {
989
991
  this._ast.program.body.unshift(
990
992
  n.types.variableDeclaration("const", [
991
993
  n.types.variableDeclarator(
@@ -995,17 +997,17 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
995
997
  ])
996
998
  );
997
999
  }, "addDefaultRequireSpecifier");
998
- t && o(t, e) || a();
999
- } else t ? e.forEach((a) => {
1000
- i(a) || t.declarations[0].id.properties.push(
1001
- n.types.objectProperty(n.types.identifier(a), n.types.identifier(a), void 0, !0)
1000
+ t && a(t, e) || o();
1001
+ } else t ? e.forEach((o) => {
1002
+ i(o) || t.declarations[0].id.properties.push(
1003
+ n.types.objectProperty(n.types.identifier(o), n.types.identifier(o), void 0, !0)
1002
1004
  );
1003
1005
  }) : this._ast.program.body.unshift(
1004
1006
  n.types.variableDeclaration("const", [
1005
1007
  n.types.variableDeclarator(
1006
1008
  n.types.objectPattern(
1007
1009
  e.map(
1008
- (a) => n.types.objectProperty(n.types.identifier(a), n.types.identifier(a), void 0, !0)
1010
+ (o) => n.types.objectProperty(n.types.identifier(o), n.types.identifier(o), void 0, !0)
1009
1011
  )
1010
1012
  ),
1011
1013
  n.types.callExpression(n.types.identifier("require"), [n.types.stringLiteral(r)])
@@ -1042,10 +1044,10 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
1042
1044
  let t = this._ast.program.body.find((p) => {
1043
1045
  let d = n.types.isImportDeclaration(p) && (p.source.value === r || p.source.value === r.split("node:")[1]);
1044
1046
  return d && (r = p.source.value), d;
1045
- }), i = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), o = /* @__PURE__ */ f(
1047
+ }), i = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), a = /* @__PURE__ */ f(
1046
1048
  (p, d) => p.specifiers.find(
1047
1049
  (g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === d
1048
- ), "hasImportSpecifier"), a = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1050
+ ), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
1049
1051
  (g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === d
1050
1052
  ), "hasNamespaceImportSpecifier");
1051
1053
  e === null ? t || this._ast.program.body.unshift(n.types.importDeclaration([], n.types.stringLiteral(r))) : typeof e == "string" ? t ? (/* @__PURE__ */ f(
@@ -1059,13 +1061,13 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
1059
1061
  n.types.stringLiteral(r)
1060
1062
  )
1061
1063
  ) : Array.isArray(e) ? t ? e.forEach((p) => {
1062
- o(t, p) || t.specifiers.push(i(p));
1064
+ a(t, p) || t.specifiers.push(i(p));
1063
1065
  }) : this._ast.program.body.unshift(
1064
1066
  n.types.importDeclaration(
1065
1067
  e.map(i),
1066
1068
  n.types.stringLiteral(r)
1067
1069
  )
1068
- ) : e.namespace && (t ? a(t, e.namespace) || t.specifiers.push(
1070
+ ) : e.namespace && (t ? o(t, e.namespace) || t.specifiers.push(
1069
1071
  n.types.importNamespaceSpecifier(n.types.identifier(e.namespace))
1070
1072
  ) : this._ast.program.body.unshift(
1071
1073
  n.types.importDeclaration(
@@ -1074,42 +1076,42 @@ s, "unwrap"), Ee = /* @__PURE__ */ f((s, e) => {
1074
1076
  )
1075
1077
  ));
1076
1078
  }
1077
- }, je = /* @__PURE__ */ f((s, e) => {
1079
+ }, Se = /* @__PURE__ */ f((s, e) => {
1078
1080
  let r = (0, n.babelParse)(s);
1079
- return new Z(r, s, e);
1080
- }, "loadConfig"), Se = /* @__PURE__ */ f((s) => Pe(s).code, "formatConfig"), Pe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
1081
- "printConfig"), nt = /* @__PURE__ */ f(async (s) => {
1082
- let e = (await (0, ee.readFile)(s, "utf-8")).toString();
1083
- return je(e, s).parse();
1084
- }, "readConfig"), ot = /* @__PURE__ */ f(async (s, e) => {
1081
+ 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),
1083
+ "printConfig"), ot = /* @__PURE__ */ f(async (s) => {
1084
+ let e = (await (0, te.readFile)(s, "utf-8")).toString();
1085
+ return Se(e, s).parse();
1086
+ }, "readConfig"), at = /* @__PURE__ */ f(async (s, e) => {
1085
1087
  let r = e || s.fileName;
1086
1088
  if (!r)
1087
1089
  throw new Error("Please specify a fileName for writeConfig");
1088
- await (0, ee.writeFile)(r, Se(s));
1089
- }, "writeConfig"), at = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((r) => n.types.isImportDeclaration(r) && r.source.value.includes(
1090
+ await (0, te.writeFile)(r, Pe(s));
1091
+ }, "writeConfig"), lt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((r) => n.types.isImportDeclaration(r) && r.source.value.includes(
1090
1092
  "@storybook") && r.specifiers.some((t) => n.types.isImportSpecifier(t) && n.types.isIdentifier(t.imported) && t.imported.name === "definePre\
1091
1093
  view")), "isCsfFactoryPreview");
1092
1094
 
1093
1095
  // src/csf-tools/getStorySortParameter.ts
1094
- var y = require("storybook/internal/babel"), ve = z(R(), 1);
1095
- var lt = console, se = /* @__PURE__ */ f((s, e) => {
1096
+ var y = require("storybook/internal/babel"), De = require("storybook/internal/node-logger"), Ie = z($(), 1);
1097
+ var ne = /* @__PURE__ */ f((s, e) => {
1096
1098
  let r;
1097
1099
  return s.properties.forEach((t) => {
1098
1100
  y.types.isIdentifier(t.key) && t.key.name === e && (r = t.value);
1099
1101
  }), r;
1100
- }, "getValue"), ne = /* @__PURE__ */ f((s) => {
1101
- let e = W(s);
1102
+ }, "getValue"), oe = /* @__PURE__ */ f((s) => {
1103
+ let e = B(s);
1102
1104
  if (y.types.isArrayExpression(e))
1103
- return e.elements.map((r) => ne(r));
1105
+ return e.elements.map((r) => oe(r));
1104
1106
  if (y.types.isObjectExpression(e))
1105
- return e.properties.reduce((r, t) => (y.types.isIdentifier(t.key) && (r[t.key.name] = ne(t.value)), r), {});
1107
+ return e.properties.reduce((r, t) => (y.types.isIdentifier(t.key) && (r[t.key.name] = oe(t.value)), r), {});
1106
1108
  if (y.types.isLiteral(e))
1107
1109
  return e.value;
1108
1110
  if (y.types.isIdentifier(e))
1109
- return T(e.name, !0);
1111
+ return C(e.name, !0);
1110
1112
  throw new Error(`Unknown node type ${e.type}`);
1111
- }, "parseValue"), T = /* @__PURE__ */ f((s, e) => {
1112
- let r = ve.dedent`
1113
+ }, "parseValue"), C = /* @__PURE__ */ f((s, e) => {
1114
+ let r = Ie.dedent`
1113
1115
  Unexpected '${s}'. Parameter 'options.storySort' should be defined inline e.g.:
1114
1116
 
1115
1117
  export default {
@@ -1122,26 +1124,26 @@ var lt = console, se = /* @__PURE__ */ f((s, e) => {
1122
1124
  `;
1123
1125
  if (e)
1124
1126
  throw new Error(r);
1125
- lt.info(r);
1126
- }, "unsupported"), W = /* @__PURE__ */ f((s) => y.types.isTSAsExpression(s) || y.types.isTSSatisfiesExpression(s) ? s.expression : s, "strip\
1127
- TSModifiers"), De = /* @__PURE__ */ f((s) => {
1128
- let e = W(s);
1127
+ De.logger.log(r);
1128
+ }, "unsupported"), B = /* @__PURE__ */ f((s) => y.types.isTSAsExpression(s) || y.types.isTSSatisfiesExpression(s) ? s.expression : s, "strip\
1129
+ TSModifiers"), Ne = /* @__PURE__ */ f((s) => {
1130
+ let e = B(s);
1129
1131
  if (y.types.isObjectExpression(e)) {
1130
- let r = se(e, "options");
1132
+ let r = ne(e, "options");
1131
1133
  if (r) {
1132
1134
  if (y.types.isObjectExpression(r))
1133
- return se(r, "storySort");
1134
- T("options", !0);
1135
+ return ne(r, "storySort");
1136
+ C("options", !0);
1135
1137
  }
1136
1138
  }
1137
- }, "parseParameters"), Oe = /* @__PURE__ */ f((s, e) => {
1138
- let r = W(s);
1139
+ }, "parseParameters"), ve = /* @__PURE__ */ f((s, e) => {
1140
+ let r = B(s);
1139
1141
  if (y.types.isObjectExpression(r)) {
1140
- let t = se(r, "parameters");
1142
+ let t = ne(r, "parameters");
1141
1143
  if (y.types.isIdentifier(t) && (t = P(t.name, e)), t)
1142
- return De(t);
1144
+ return Ne(t);
1143
1145
  } else
1144
- T("default", !0);
1146
+ C("default", !0);
1145
1147
  }, "parseDefault"), ct = /* @__PURE__ */ f((s) => {
1146
1148
  if (!s.includes("storySort"))
1147
1149
  return;
@@ -1151,22 +1153,22 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
1151
1153
  enter({ node: t }) {
1152
1154
  y.types.isVariableDeclaration(t.declaration) ? t.declaration.declarations.forEach((i) => {
1153
1155
  if (y.types.isVariableDeclarator(i) && y.types.isIdentifier(i.id)) {
1154
- let { name: o } = i.id;
1155
- if (o === "parameters" && i.init) {
1156
- let a = W(i.init);
1157
- e = De(a);
1156
+ let { name: a } = i.id;
1157
+ if (a === "parameters" && i.init) {
1158
+ let o = B(i.init);
1159
+ e = Ne(o);
1158
1160
  }
1159
1161
  }
1160
1162
  }) : t.specifiers.forEach((i) => {
1161
- y.types.isIdentifier(i.exported) && i.exported.name === "parameters" && T("parameters", !1);
1163
+ y.types.isIdentifier(i.exported) && i.exported.name === "parameters" && C("parameters", !1);
1162
1164
  });
1163
1165
  }
1164
1166
  },
1165
1167
  ExportDefaultDeclaration: {
1166
1168
  enter({ node: t }) {
1167
1169
  let i = t.declaration;
1168
- y.types.isIdentifier(i) && (i = P(i.name, r.program)), i = W(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1169
- e = Oe(i.arguments[0], r.program) : y.types.isObjectExpression(i) ? e = Oe(i, r.program) : T("default", !1);
1170
+ y.types.isIdentifier(i) && (i = P(i.name, r.program)), i = B(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
1171
+ e = ve(i.arguments[0], r.program) : y.types.isObjectExpression(i) ? e = ve(i, r.program) : C("default", !1);
1170
1172
  }
1171
1173
  }
1172
1174
  }), !!e) {
@@ -1175,148 +1177,147 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
1175
1177
  return (0, eval)(t);
1176
1178
  }
1177
1179
  if (y.types.isFunctionExpression(e)) {
1178
- let { code: t } = (0, y.generate)(e, {}), i = e.id?.name, o = `(a, b) => {
1180
+ let { code: t } = (0, y.generate)(e, {}), i = e.id?.name, a = `(a, b) => {
1179
1181
  ${t};
1180
1182
  return ${i}(a, b)
1181
1183
  }`;
1182
- return (0, eval)(o);
1184
+ return (0, eval)(a);
1183
1185
  }
1184
- return y.types.isLiteral(e) || y.types.isArrayExpression(e) || y.types.isObjectExpression(e) ? ne(e) : T("storySort", !0);
1186
+ return y.types.isLiteral(e) || y.types.isArrayExpression(e) || y.types.isObjectExpression(e) ? oe(e) : C("storySort", !0);
1185
1187
  }
1186
1188
  }, "getStorySortParameter");
1187
1189
 
1188
1190
  // src/csf-tools/enrichCsf.ts
1189
- var m = require("storybook/internal/babel");
1190
- var Ie = /* @__PURE__ */ f((s, e, r, t) => {
1191
- let i = e.getStoryExport(r), o = m.types.isCallExpression(i) && m.types.isMemberExpression(i.callee) && m.types.isIdentifier(i.callee.object) &&
1192
- i.callee.object.name === "meta", a = !t?.disableSource && Fe(i), l = !t?.disableDescription && oe(e._storyStatements[r]), p = [], d = o ? m.types.
1193
- memberExpression(m.types.identifier(r), m.types.identifier("input")) : m.types.identifier(r), g = m.types.memberExpression(d, m.types.identifier(
1191
+ var u = require("storybook/internal/babel");
1192
+ 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(
1194
1196
  "parameters"));
1195
- p.push(m.types.spreadElement(g));
1196
- let x = m.types.optionalMemberExpression(
1197
+ p.push(u.types.spreadElement(g));
1198
+ let x = u.types.optionalMemberExpression(
1197
1199
  g,
1198
- m.types.identifier("docs"),
1200
+ u.types.identifier("docs"),
1199
1201
  !1,
1200
1202
  !0
1201
1203
  ), h = [];
1202
- if (a) {
1203
- let b = m.types.optionalMemberExpression(
1204
+ if (o) {
1205
+ let b = u.types.optionalMemberExpression(
1204
1206
  x,
1205
- m.types.identifier("source"),
1207
+ u.types.identifier("source"),
1206
1208
  !1,
1207
1209
  !0
1208
1210
  );
1209
1211
  h.push(
1210
- m.types.objectProperty(
1211
- m.types.identifier("source"),
1212
- m.types.objectExpression([
1213
- m.types.objectProperty(m.types.identifier("originalSource"), m.types.stringLiteral(a)),
1214
- m.types.spreadElement(b)
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)
1215
1217
  ])
1216
1218
  )
1217
1219
  );
1218
1220
  }
1219
- if (l) {
1220
- let b = m.types.optionalMemberExpression(
1221
+ if (c) {
1222
+ let b = u.types.optionalMemberExpression(
1221
1223
  x,
1222
- m.types.identifier("description"),
1224
+ u.types.identifier("description"),
1223
1225
  !1,
1224
1226
  !0
1225
1227
  );
1226
1228
  h.push(
1227
- m.types.objectProperty(
1228
- m.types.identifier("description"),
1229
- m.types.objectExpression([
1230
- m.types.objectProperty(m.types.identifier("story"), m.types.stringLiteral(l)),
1231
- m.types.spreadElement(b)
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)
1232
1234
  ])
1233
1235
  )
1234
1236
  );
1235
1237
  }
1236
1238
  if (h.length > 0) {
1237
1239
  p.push(
1238
- m.types.objectProperty(
1239
- m.types.identifier("docs"),
1240
- m.types.objectExpression([m.types.spreadElement(x), ...h])
1240
+ u.types.objectProperty(
1241
+ u.types.identifier("docs"),
1242
+ u.types.objectExpression([u.types.spreadElement(x), ...h])
1241
1243
  )
1242
1244
  );
1243
- let b = m.types.expressionStatement(
1244
- m.types.assignmentExpression("=", g, m.types.objectExpression(p))
1245
+ let b = u.types.expressionStatement(
1246
+ u.types.assignmentExpression("=", g, u.types.objectExpression(p))
1245
1247
  );
1246
1248
  s._ast.program.body.push(b);
1247
1249
  }
1248
- }, "enrichCsfStory"), Ne = /* @__PURE__ */ f((s, e, r) => {
1250
+ }, "enrichCsfStory"), Fe = /* @__PURE__ */ f((s, e, r) => {
1249
1251
  if (!e.length) {
1250
1252
  s.properties.find(
1251
- (p) => m.types.isObjectProperty(p) && m.types.isIdentifier(p.key) && p.key.name === "component"
1253
+ (p) => u.types.isObjectProperty(p) && u.types.isIdentifier(p.key) && p.key.name === "component"
1252
1254
  ) || s.properties.unshift(r);
1253
1255
  return;
1254
1256
  }
1255
- let [t, ...i] = e, o = s.properties.find(
1256
- (l) => m.types.isObjectProperty(l) && m.types.isIdentifier(l.key) && l.key.name === t && m.types.isObjectExpression(l.value)
1257
- ), a;
1258
- o ? a = o.value : (a = m.types.objectExpression([]), s.properties.push(m.types.objectProperty(m.types.identifier(t), a))), Ne(a, i, r);
1259
- }, "addComponentDescription"), we = /* @__PURE__ */ f((s, e, r) => {
1260
- let t = !r?.disableDescription && oe(e._metaStatement);
1257
+ 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)
1259
+ ), 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);
1261
+ }, "addComponentDescription"), Ce = /* @__PURE__ */ f((s, e, r) => {
1262
+ let t = !r?.disableDescription && ae(e._metaStatement);
1261
1263
  if (t) {
1262
1264
  let i = s._metaNode;
1263
- i && m.types.isObjectExpression(i) && Ne(
1265
+ i && u.types.isObjectExpression(i) && Fe(
1264
1266
  i,
1265
1267
  ["parameters", "docs", "description"],
1266
- m.types.objectProperty(m.types.identifier("component"), m.types.stringLiteral(t))
1268
+ u.types.objectProperty(u.types.identifier("component"), u.types.stringLiteral(t))
1267
1269
  );
1268
1270
  }
1269
1271
  }, "enrichCsfMeta"), pt = /* @__PURE__ */ f((s, e, r) => {
1270
- we(s, e, r), Object.keys(s._storyExports).forEach((t) => {
1271
- Ie(s, e, t, r);
1272
+ Ce(s, e, r), Object.keys(s._storyExports).forEach((t) => {
1273
+ we(s, e, t, r);
1272
1274
  });
1273
- }, "enrichCsf"), Fe = /* @__PURE__ */ f((s) => {
1274
- let e = m.types.isVariableDeclarator(s) ? s.init : s, { code: r } = (0, m.generate)(e, {});
1275
+ }, "enrichCsf"), Te = /* @__PURE__ */ f((s) => {
1276
+ let e = u.types.isVariableDeclarator(s) ? s.init : s, { code: r } = (0, u.generate)(e, {});
1275
1277
  return r;
1276
- }, "extractSource"), oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((r) => r.type === "CommentLine" || !r.value.startsWith(
1278
+ }, "extractSource"), ae = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((r) => r.type === "CommentLine" || !r.value.startsWith(
1277
1279
  "*") ? null : r.value.split(`
1278
1280
  `).map((t) => t.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
1279
1281
  `).trim()).filter(Boolean).join(`
1280
1282
  `) : "", "extractDescription");
1281
1283
 
1282
1284
  // src/csf-tools/index.ts
1283
- var Ae = require("storybook/internal/babel");
1285
+ var $e = require("storybook/internal/babel");
1284
1286
 
1285
1287
  // src/csf-tools/vitest-plugin/transformer.ts
1286
- var u = require("storybook/internal/babel"), Te = require("storybook/internal/common"), ke = require("storybook/internal/csf"), ae = z(R(), 1);
1287
- var Ce = console, ft = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((r) => s?.includes(r)) || e.exclude.some((r) => s?.
1288
- includes(r))), "isValidTest");
1289
- async function Ve({
1288
+ var m = require("storybook/internal/babel"), ke = require("storybook/internal/common"), Ve = require("storybook/internal/csf"), le = require("storybook/internal/node-logger"),
1289
+ ce = z($(), 1);
1290
+ var ft = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((r) => s?.includes(r)) || e.exclude.some((r) => s?.includes(r))),
1291
+ "isValidTest");
1292
+ async function Ae({
1290
1293
  code: s,
1291
1294
  fileName: e,
1292
1295
  configDir: r,
1293
1296
  stories: t,
1294
1297
  tagsFilter: i,
1295
- previewLevelTags: o = []
1298
+ previewLevelTags: a = []
1296
1299
  }) {
1297
- if (!/\.stor(y|ies)\./.test(e))
1298
- return s;
1299
- let l = Q(s, {
1300
+ let o = Q(s, {
1300
1301
  fileName: e,
1301
1302
  transformInlineMeta: !0,
1302
- makeTitle: /* @__PURE__ */ f((_) => {
1303
- let S = (0, Te.getStoryTitle)({
1303
+ makeTitle: /* @__PURE__ */ f((E) => {
1304
+ let S = (0, ke.getStoryTitle)({
1304
1305
  storyFilePath: e,
1305
1306
  configDir: r,
1306
1307
  stories: t,
1307
- userTitle: _
1308
+ userTitle: E
1308
1309
  }) || "unknown";
1309
- return S === "unknown" && Ce.warn(
1310
- ae.dedent`
1310
+ return S === "unknown" && le.logger.warn(
1311
+ ce.dedent`
1311
1312
  [Storybook]: Could not calculate story title for "${e}".
1312
1313
  Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${r}".
1313
1314
  `
1314
1315
  ), S;
1315
1316
  }, "makeTitle")
1316
- }).parse(), p = l._ast, d = l._metaVariableName, g = l._metaNode, x = g.properties.find(
1317
- (_) => u.types.isObjectProperty(_) && u.types.isIdentifier(_.key) && _.key.name === "title"
1318
- ), h = u.types.stringLiteral(l._meta?.title || "unknown");
1319
- if (x ? u.types.isObjectProperty(x) && (x.value = h) : g.properties.push(u.types.objectProperty(u.types.identifier("title"), h)), !g || !l.
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"
1319
+ ), 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.
1320
1321
  _meta)
1321
1322
  throw new Error(
1322
1323
  `The Storybook vitest plugin could not detect the meta (default export) object in the story file.
@@ -1324,120 +1325,120 @@ async function Ve({
1324
1325
  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\
1325
1326
  le an issue with details about your use case.`
1326
1327
  );
1327
- let b = {};
1328
- Object.keys(l._stories).map((_) => {
1329
- let S = (0, ke.combineTags)(
1328
+ let h = {};
1329
+ Object.keys(o._stories).map((E) => {
1330
+ let S = (0, Ve.combineTags)(
1330
1331
  "test",
1331
1332
  "dev",
1332
- ...o,
1333
- ...l.meta?.tags || [],
1334
- ...l._stories[_].tags || []
1333
+ ...a,
1334
+ ...o.meta?.tags || [],
1335
+ ...o._stories[E].tags || []
1335
1336
  );
1336
- ft(S, i) && (b[_] = l._storyStatements[_]);
1337
+ ft(S, i) && (h[E] = o._storyStatements[E]);
1337
1338
  });
1338
- let E = l._file.path.scope.generateUidIdentifier("test"), I = l._file.path.scope.generateUidIdentifier("describe");
1339
- if (Object.keys(b).length === 0) {
1340
- let _ = u.types.expressionStatement(
1341
- u.types.callExpression(u.types.memberExpression(I, u.types.identifier("skip")), [
1342
- u.types.stringLiteral("No valid tests found")
1339
+ 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(
1342
+ m.types.callExpression(m.types.memberExpression(_, m.types.identifier("skip")), [
1343
+ m.types.stringLiteral("No valid tests found")
1343
1344
  ])
1344
1345
  );
1345
- p.program.body.push(_);
1346
+ c.program.body.push(E);
1346
1347
  let S = [
1347
- u.types.importDeclaration(
1348
+ m.types.importDeclaration(
1348
1349
  [
1349
- u.types.importSpecifier(E, u.types.identifier("test")),
1350
- u.types.importSpecifier(I, u.types.identifier("describe"))
1350
+ m.types.importSpecifier(b, m.types.identifier("test")),
1351
+ m.types.importSpecifier(_, m.types.identifier("describe"))
1351
1352
  ],
1352
- u.types.stringLiteral("vitest")
1353
+ m.types.stringLiteral("vitest")
1353
1354
  )
1354
1355
  ];
1355
- p.program.body.unshift(...S);
1356
+ c.program.body.unshift(...S);
1356
1357
  } else {
1357
- let le = function() {
1358
- let j = l._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = u.types.memberExpression(
1359
- u.types.callExpression(u.types.memberExpression(_, u.types.identifier("getState")), []),
1360
- u.types.identifier("testPath")
1361
- ), k = u.types.memberExpression(
1362
- u.types.memberExpression(u.types.identifier("globalThis"), u.types.identifier("__vitest_worker__")),
1363
- u.types.identifier("filepath")
1364
- ), V = u.types.logicalExpression(
1358
+ let pe = function() {
1359
+ let j = o._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), I = m.types.memberExpression(
1360
+ m.types.callExpression(m.types.memberExpression(E, m.types.identifier("getState")), []),
1361
+ m.types.identifier("testPath")
1362
+ ), T = m.types.memberExpression(
1363
+ m.types.memberExpression(m.types.identifier("globalThis"), m.types.identifier("__vitest_worker__")),
1364
+ m.types.identifier("filepath")
1365
+ ), k = m.types.logicalExpression(
1365
1366
  "??",
1366
1367
  // TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
1367
1368
  // https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
1368
- k,
1369
- N
1370
- ), G = u.types.callExpression(
1371
- u.types.memberExpression(
1372
- u.types.callExpression(u.types.identifier("convertToFilePath"), [
1373
- u.types.memberExpression(
1374
- u.types.memberExpression(u.types.identifier("import"), u.types.identifier("meta")),
1375
- u.types.identifier("url")
1369
+ T,
1370
+ I
1371
+ ), G = m.types.callExpression(
1372
+ m.types.memberExpression(
1373
+ m.types.callExpression(m.types.identifier("convertToFilePath"), [
1374
+ m.types.memberExpression(
1375
+ m.types.memberExpression(m.types.identifier("import"), m.types.identifier("meta")),
1376
+ m.types.identifier("url")
1376
1377
  )
1377
1378
  ]),
1378
- u.types.identifier("includes")
1379
+ m.types.identifier("includes")
1379
1380
  ),
1380
- [V]
1381
+ [k]
1381
1382
  );
1382
- return { isRunningFromThisFileDeclaration: u.types.variableDeclaration("const", [
1383
- u.types.variableDeclarator(j, G)
1383
+ return { isRunningFromThisFileDeclaration: m.types.variableDeclaration("const", [
1384
+ m.types.variableDeclarator(j, G)
1384
1385
  ]), isRunningFromThisFileId: j };
1385
1386
  };
1386
- var ut = le;
1387
- f(le, "getTestGuardDeclaration");
1388
- let _ = l._file.path.scope.generateUidIdentifier("expect"), S = l._file.path.scope.generateUidIdentifier("testStory"), $e = u.types.identifier(
1389
- JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Re, isRunningFromThisFileId: Le } = le();
1390
- p.program.body.push(Re);
1391
- let Me = /* @__PURE__ */ f(({
1387
+ var W = pe;
1388
+ f(pe, "getTestGuardDeclaration");
1389
+ let E = o._file.path.scope.generateUidIdentifier("expect"), S = o._file.path.scope.generateUidIdentifier("testStory"), Re = m.types.identifier(
1390
+ JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Le, isRunningFromThisFileId: Me } = pe();
1391
+ c.program.body.push(Le);
1392
+ let Ue = /* @__PURE__ */ f(({
1392
1393
  localName: j,
1393
- exportName: N,
1394
- testTitle: k,
1395
- node: V
1394
+ exportName: I,
1395
+ testTitle: T,
1396
+ node: k
1396
1397
  }) => {
1397
- let G = u.types.expressionStatement(
1398
- u.types.callExpression(E, [
1399
- u.types.stringLiteral(k),
1400
- u.types.callExpression(S, [
1401
- u.types.stringLiteral(N),
1402
- u.types.identifier(j),
1403
- u.types.identifier(d),
1404
- $e
1398
+ let G = m.types.expressionStatement(
1399
+ m.types.callExpression(b, [
1400
+ m.types.stringLiteral(T),
1401
+ m.types.callExpression(S, [
1402
+ m.types.stringLiteral(I),
1403
+ m.types.identifier(j),
1404
+ m.types.identifier(p),
1405
+ Re
1405
1406
  ])
1406
1407
  ])
1407
1408
  );
1408
- return G.loc = V.loc, G;
1409
- }, "getTestStatementForStory"), Ue = Object.entries(b).map(([j, N]) => {
1410
- if (N === null) {
1411
- Ce.warn(
1412
- ae.dedent`
1409
+ return G.loc = k.loc, G;
1410
+ }, "getTestStatementForStory"), qe = Object.entries(h).map(([j, I]) => {
1411
+ if (I === null) {
1412
+ le.logger.warn(
1413
+ ce.dedent`
1413
1414
  [Storybook]: Could not transform "${j}" story into test at "${e}".
1414
1415
  Please make sure to define stories in the same file and not re-export stories coming from other files".
1415
1416
  `
1416
1417
  );
1417
1418
  return;
1418
1419
  }
1419
- let k = l._stories[j].localName ?? j, V = l._stories[j].name ?? j;
1420
- return Me({ testTitle: V, localName: k, exportName: j, node: N });
1421
- }).filter((j) => !!j), qe = u.types.ifStatement(Le, u.types.blockStatement(Ue));
1422
- p.program.body.push(qe);
1423
- let Be = [
1424
- u.types.importDeclaration(
1420
+ let T = o._stories[j].localName ?? j, k = o._stories[j].name ?? j;
1421
+ return Ue({ testTitle: k, localName: T, exportName: j, node: I });
1422
+ }).filter((j) => !!j), Be = m.types.ifStatement(Me, m.types.blockStatement(qe));
1423
+ c.program.body.push(Be);
1424
+ let We = [
1425
+ m.types.importDeclaration(
1425
1426
  [
1426
- u.types.importSpecifier(E, u.types.identifier("test")),
1427
- u.types.importSpecifier(_, u.types.identifier("expect"))
1427
+ m.types.importSpecifier(b, m.types.identifier("test")),
1428
+ m.types.importSpecifier(E, m.types.identifier("expect"))
1428
1429
  ],
1429
- u.types.stringLiteral("vitest")
1430
+ m.types.stringLiteral("vitest")
1430
1431
  ),
1431
- u.types.importDeclaration(
1432
+ m.types.importDeclaration(
1432
1433
  [
1433
- u.types.importSpecifier(S, u.types.identifier("testStory")),
1434
- u.types.importSpecifier(u.types.identifier("convertToFilePath"), u.types.identifier("convertToFilePath"))
1434
+ m.types.importSpecifier(S, m.types.identifier("testStory")),
1435
+ m.types.importSpecifier(m.types.identifier("convertToFilePath"), m.types.identifier("convertToFilePath"))
1435
1436
  ],
1436
- u.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1437
+ m.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1437
1438
  )
1438
1439
  ];
1439
- p.program.body.unshift(...Be);
1440
+ c.program.body.unshift(...We);
1440
1441
  }
1441
- return te(l, { sourceMaps: !0, sourceFileName: e }, s);
1442
+ return ie(o, { sourceMaps: !0, sourceFileName: e }, s);
1442
1443
  }
1443
- f(Ve, "vitestTransform");
1444
+ f(Ae, "vitestTransform");