storybook 9.0.0-alpha.2 → 9.0.0-alpha.20

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