storybook 9.1.13 → 9.1.15
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.
- package/dist/babel/index.cjs +22495 -21246
- package/dist/babel/index.d.ts +672 -336
- package/dist/babel/index.js +22534 -21285
- package/dist/bin/index.cjs +42 -43
- package/dist/bin/index.js +42 -43
- package/dist/cli/bin/index.cjs +1 -1
- package/dist/cli/bin/index.js +1 -1
- package/dist/cli/index.cjs +27120 -25868
- package/dist/cli/index.js +27267 -26015
- package/dist/common/index.cjs +57 -58
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +103 -104
- package/dist/components/index.cjs +4464 -4353
- package/dist/components/index.js +3290 -3181
- package/dist/core-events/index.cjs +105 -103
- package/dist/core-events/index.d.ts +3 -1
- package/dist/core-events/index.js +85 -83
- package/dist/core-server/index.cjs +7389 -7318
- package/dist/core-server/index.js +7598 -7529
- package/dist/core-server/presets/common-preset.cjs +20111 -19862
- package/dist/core-server/presets/common-preset.js +20183 -19934
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.cjs +306 -518
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +302 -525
- package/dist/csf-tools/index.cjs +150 -144
- package/dist/csf-tools/index.js +401 -395
- package/dist/manager/globals-module-info.cjs +2 -0
- package/dist/manager/globals-module-info.js +2 -0
- package/dist/manager/globals-runtime.js +16492 -16380
- package/dist/manager/runtime.js +525 -522
- package/dist/manager-api/index.cjs +1 -1
- package/dist/manager-api/index.js +1 -1
- package/dist/node-logger/index.cjs +71 -71
- package/dist/node-logger/index.js +71 -71
- package/dist/preview/runtime.js +7462 -7458
- package/dist/preview-api/index.cjs +2 -0
- package/dist/preview-api/index.js +233 -230
- package/dist/telemetry/index.cjs +5 -4
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +5 -4
- package/dist/test/index.cjs +267 -267
- package/dist/test/index.js +240 -240
- package/package.json +1 -1
package/dist/csf-tools/index.js
CHANGED
|
@@ -8,44 +8,44 @@ var ke = Object.create;
|
|
|
8
8
|
var X = Object.defineProperty;
|
|
9
9
|
var Ve = Object.getOwnPropertyDescriptor;
|
|
10
10
|
var Ae = Object.getOwnPropertyNames;
|
|
11
|
-
var $e = Object.getPrototypeOf,
|
|
11
|
+
var $e = Object.getPrototypeOf, Me = Object.prototype.hasOwnProperty;
|
|
12
12
|
var f = (s, e) => X(s, "name", { value: e, configurable: !0 });
|
|
13
|
-
var
|
|
14
|
-
var
|
|
13
|
+
var Re = (s, e) => () => (e || s((e = { exports: {} }).exports, e), e.exports);
|
|
14
|
+
var Le = (s, e, i, t) => {
|
|
15
15
|
if (e && typeof e == "object" || typeof e == "function")
|
|
16
|
-
for (let
|
|
17
|
-
!
|
|
16
|
+
for (let r of Ae(e))
|
|
17
|
+
!Me.call(s, r) && r !== i && X(s, r, { get: () => e[r], enumerable: !(t = Ve(e, r)) || t.enumerable });
|
|
18
18
|
return s;
|
|
19
19
|
};
|
|
20
|
-
var
|
|
20
|
+
var L = (s, e, i) => (i = s != null ? ke($e(s)) : {}, Le(
|
|
21
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
23
23
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
24
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
e || !s || !s.__esModule ? X(
|
|
25
|
+
e || !s || !s.__esModule ? X(i, "default", { value: s, enumerable: !0 }) : i,
|
|
26
26
|
s
|
|
27
27
|
));
|
|
28
28
|
|
|
29
29
|
// ../node_modules/ts-dedent/dist/index.js
|
|
30
|
-
var k =
|
|
30
|
+
var k = Re((T) => {
|
|
31
31
|
"use strict";
|
|
32
32
|
Object.defineProperty(T, "__esModule", { value: !0 });
|
|
33
33
|
T.dedent = void 0;
|
|
34
34
|
function se(s) {
|
|
35
|
-
for (var e = [],
|
|
36
|
-
e[
|
|
35
|
+
for (var e = [], i = 1; i < arguments.length; i++)
|
|
36
|
+
e[i - 1] = arguments[i];
|
|
37
37
|
var t = Array.from(typeof s == "string" ? [s] : s);
|
|
38
38
|
t[t.length - 1] = t[t.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
39
|
-
var
|
|
39
|
+
var r = t.reduce(function(c, p) {
|
|
40
40
|
var d = p.match(/\n([\t ]+|(?!\s).)/g);
|
|
41
41
|
return d ? c.concat(d.map(function(u) {
|
|
42
42
|
var g, b;
|
|
43
43
|
return (b = (g = u.match(/[\t ]/g)) === null || g === void 0 ? void 0 : g.length) !== null && b !== void 0 ? b : 0;
|
|
44
44
|
})) : c;
|
|
45
45
|
}, []);
|
|
46
|
-
if (
|
|
46
|
+
if (r.length) {
|
|
47
47
|
var a = new RegExp(`
|
|
48
|
-
[ ]{` + Math.min.apply(Math,
|
|
48
|
+
[ ]{` + Math.min.apply(Math, r) + "}", "g");
|
|
49
49
|
t = t.map(function(c) {
|
|
50
50
|
return c.replace(a, `
|
|
51
51
|
`);
|
|
@@ -69,7 +69,7 @@ var k = Le((T) => {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
// src/csf-tools/CsfFile.ts
|
|
72
|
-
var P =
|
|
72
|
+
var P = L(k(), 1);
|
|
73
73
|
import { readFile as Ue, writeFile as qe } from "node:fs/promises";
|
|
74
74
|
import {
|
|
75
75
|
BabelFileClass as Be,
|
|
@@ -85,10 +85,10 @@ import { logger as ae } from "storybook/internal/node-logger";
|
|
|
85
85
|
// src/csf-tools/findVarInitialization.ts
|
|
86
86
|
import { types as V } from "storybook/internal/babel";
|
|
87
87
|
var O = /* @__PURE__ */ f((s, e) => {
|
|
88
|
-
let
|
|
89
|
-
return e.body.find((
|
|
90
|
-
(t =
|
|
91
|
-
!1))),
|
|
88
|
+
let i = null, t = null;
|
|
89
|
+
return e.body.find((r) => (V.isVariableDeclaration(r) ? t = r.declarations : V.isExportNamedDeclaration(r) && V.isVariableDeclaration(r.declaration) &&
|
|
90
|
+
(t = r.declaration.declarations), t && t.find((a) => V.isVariableDeclarator(a) && V.isIdentifier(a.id) && a.id.name === s ? (i = a.init, !0) :
|
|
91
|
+
!1))), i;
|
|
92
92
|
}, "findVarInitialization");
|
|
93
93
|
|
|
94
94
|
// src/csf-tools/CsfFile.ts
|
|
@@ -118,20 +118,20 @@ function le(s) {
|
|
|
118
118
|
}
|
|
119
119
|
f(le, "parseTags");
|
|
120
120
|
var v = /* @__PURE__ */ f((s, e) => {
|
|
121
|
-
let
|
|
121
|
+
let i = "";
|
|
122
122
|
if (s.loc) {
|
|
123
|
-
let { line: t, column:
|
|
124
|
-
|
|
123
|
+
let { line: t, column: r } = s.loc?.start || {};
|
|
124
|
+
i = `(line ${t}, col ${r})`;
|
|
125
125
|
}
|
|
126
|
-
return `${e || ""} ${
|
|
127
|
-
}, "formatLocation"), Qe = /* @__PURE__ */ f((s) => Ze.test(s), "isModuleMock"), ce = /* @__PURE__ */ f((s, e,
|
|
126
|
+
return `${e || ""} ${i}`.trim();
|
|
127
|
+
}, "formatLocation"), Qe = /* @__PURE__ */ f((s) => Ze.test(s), "isModuleMock"), ce = /* @__PURE__ */ f((s, e, i) => {
|
|
128
128
|
let t = s;
|
|
129
129
|
if (l.isCallExpression(s)) {
|
|
130
|
-
let { callee:
|
|
131
|
-
if (l.isProgram(e) && l.isMemberExpression(
|
|
130
|
+
let { callee: r, arguments: a } = s;
|
|
131
|
+
if (l.isProgram(e) && l.isMemberExpression(r) && l.isIdentifier(r.object) && l.isIdentifier(r.property) && r.property.name === "bind" &&
|
|
132
132
|
(a.length === 0 || a.length === 1 && l.isObjectExpression(a[0]) && a[0].properties.length === 0)) {
|
|
133
|
-
let o =
|
|
134
|
-
c && (
|
|
133
|
+
let o = r.object.name, c = O(o, e);
|
|
134
|
+
c && (i._templates[o] = c, t = c);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
return l.isArrowFunctionExpression(t) || l.isFunctionDeclaration(t) ? t.params.length > 0 : !1;
|
|
@@ -144,32 +144,32 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
144
144
|
});
|
|
145
145
|
throw new Error(`Expected array of string literals: ${s}`);
|
|
146
146
|
}, "parseExportsOrder"), pe = /* @__PURE__ */ f((s, e) => e.reduce(
|
|
147
|
-
(
|
|
148
|
-
let
|
|
149
|
-
return
|
|
147
|
+
(i, t) => {
|
|
148
|
+
let r = s[t];
|
|
149
|
+
return r && (i[t] = r), i;
|
|
150
150
|
},
|
|
151
151
|
{}
|
|
152
152
|
), "sortExports"), Ye = /* @__PURE__ */ f((s) => {
|
|
153
|
-
if (l.isArrowFunctionExpression(s) || l.isFunctionDeclaration(s)) {
|
|
153
|
+
if (l.isArrowFunctionExpression(s) || l.isFunctionDeclaration(s) || l.isObjectMethod(s)) {
|
|
154
154
|
let e = s.params;
|
|
155
155
|
if (e.length >= 1) {
|
|
156
|
-
let [
|
|
157
|
-
if (l.isObjectPattern(
|
|
158
|
-
return !!
|
|
156
|
+
let [i] = e;
|
|
157
|
+
if (l.isObjectPattern(i))
|
|
158
|
+
return !!i.properties.find((t) => {
|
|
159
159
|
if (l.isObjectProperty(t) && l.isIdentifier(t.key))
|
|
160
160
|
return t.key.name === "mount";
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
return !1;
|
|
165
|
-
}, "hasMount"), Ze = /^[.\/#].*\.mock($|\.[^.]*$)/i,
|
|
165
|
+
}, "hasMount"), Ze = /^[.\/#].*\.mock($|\.[^.]*$)/i, U = class extends Error {
|
|
166
166
|
static {
|
|
167
167
|
f(this, "NoMetaError");
|
|
168
168
|
}
|
|
169
|
-
constructor(e,
|
|
170
|
-
let
|
|
169
|
+
constructor(e, i, t) {
|
|
170
|
+
let r = e.trim();
|
|
171
171
|
super(P.dedent`
|
|
172
|
-
CSF: ${
|
|
172
|
+
CSF: ${r} ${v(i, t)}
|
|
173
173
|
|
|
174
174
|
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
|
|
175
175
|
`), this.name = this.constructor.name;
|
|
@@ -178,40 +178,40 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
178
178
|
static {
|
|
179
179
|
f(this, "MultipleMetaError");
|
|
180
180
|
}
|
|
181
|
-
constructor(e,
|
|
182
|
-
let
|
|
181
|
+
constructor(e, i, t) {
|
|
182
|
+
let r = `${e} ${v(i, t)}`.trim();
|
|
183
183
|
super(P.dedent`
|
|
184
|
-
CSF: ${e} ${v(
|
|
184
|
+
CSF: ${e} ${v(i, t)}
|
|
185
185
|
|
|
186
186
|
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
|
|
187
187
|
`), this.name = this.constructor.name;
|
|
188
188
|
}
|
|
189
|
-
},
|
|
189
|
+
}, q = class extends Error {
|
|
190
190
|
static {
|
|
191
191
|
f(this, "MixedFactoryError");
|
|
192
192
|
}
|
|
193
|
-
constructor(e,
|
|
194
|
-
let
|
|
193
|
+
constructor(e, i, t) {
|
|
194
|
+
let r = `${e} ${v(i, t)}`.trim();
|
|
195
195
|
super(P.dedent`
|
|
196
|
-
CSF: ${e} ${v(
|
|
196
|
+
CSF: ${e} ${v(i, t)}
|
|
197
197
|
|
|
198
198
|
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
|
|
199
199
|
`), this.name = this.constructor.name;
|
|
200
200
|
}
|
|
201
|
-
},
|
|
201
|
+
}, B = class extends Error {
|
|
202
202
|
static {
|
|
203
203
|
f(this, "BadMetaError");
|
|
204
204
|
}
|
|
205
|
-
constructor(e,
|
|
206
|
-
let
|
|
205
|
+
constructor(e, i, t) {
|
|
206
|
+
let r = "".trim();
|
|
207
207
|
super(P.dedent`
|
|
208
|
-
CSF: ${e} ${v(
|
|
208
|
+
CSF: ${e} ${v(i, t)}
|
|
209
209
|
|
|
210
210
|
More info: https://storybook.js.org/docs/writing-stories?ref=error#default-export
|
|
211
211
|
`), this.name = this.constructor.name;
|
|
212
212
|
}
|
|
213
213
|
}, J = class {
|
|
214
|
-
constructor(e,
|
|
214
|
+
constructor(e, i, t) {
|
|
215
215
|
this._stories = {};
|
|
216
216
|
this._metaAnnotations = {};
|
|
217
217
|
this._storyExports = {};
|
|
@@ -219,81 +219,82 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
219
219
|
this._storyStatements = {};
|
|
220
220
|
this._storyAnnotations = {};
|
|
221
221
|
this._templates = {};
|
|
222
|
-
this._ast = e, this._file = t, this._options =
|
|
222
|
+
this._ast = e, this._file = t, this._options = i, this.imports = [];
|
|
223
223
|
}
|
|
224
224
|
static {
|
|
225
225
|
f(this, "CsfFile");
|
|
226
226
|
}
|
|
227
227
|
_parseTitle(e) {
|
|
228
|
-
let
|
|
229
|
-
if (l.isStringLiteral(
|
|
230
|
-
return
|
|
231
|
-
if (l.isTSSatisfiesExpression(
|
|
232
|
-
return
|
|
228
|
+
let i = l.isIdentifier(e) ? O(e.name, this._ast.program) : e;
|
|
229
|
+
if (l.isStringLiteral(i))
|
|
230
|
+
return i.value;
|
|
231
|
+
if (l.isTSSatisfiesExpression(i) && l.isStringLiteral(i.expression))
|
|
232
|
+
return i.expression.value;
|
|
233
233
|
throw new Error(P.dedent`
|
|
234
|
-
CSF: unexpected dynamic title ${v(
|
|
234
|
+
CSF: unexpected dynamic title ${v(i, this._options.fileName)}
|
|
235
235
|
|
|
236
236
|
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
|
|
237
237
|
`);
|
|
238
238
|
}
|
|
239
|
-
_parseMeta(e,
|
|
239
|
+
_parseMeta(e, i) {
|
|
240
240
|
if (this._metaNode)
|
|
241
241
|
throw new K("multiple meta objects", e, this._options.fileName);
|
|
242
242
|
this._metaNode = e;
|
|
243
243
|
let t = {};
|
|
244
|
-
e.properties.forEach((
|
|
245
|
-
if (l.isIdentifier(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
244
|
+
e.properties.forEach((r) => {
|
|
245
|
+
if (l.isIdentifier(r.key)) {
|
|
246
|
+
let a = l.isObjectMethod(r) ? r : r.value;
|
|
247
|
+
if (this._metaAnnotations[r.key.name] = a, r.key.name === "title")
|
|
248
|
+
t.title = this._parseTitle(r.value);
|
|
249
|
+
else if (["includeStories", "excludeStories"].includes(r.key.name))
|
|
250
|
+
t[r.key.name] = Je(r.value);
|
|
251
|
+
else if (r.key.name === "component") {
|
|
252
|
+
let o = r.value;
|
|
253
|
+
if (l.isIdentifier(o)) {
|
|
254
|
+
let p = o.name, d = i.body.find(
|
|
255
|
+
(u) => l.isImportDeclaration(u) && u.specifiers.find((g) => g.local.name === p)
|
|
255
256
|
);
|
|
256
|
-
if (
|
|
257
|
-
let { source:
|
|
258
|
-
l.isStringLiteral(
|
|
257
|
+
if (d) {
|
|
258
|
+
let { source: u } = d;
|
|
259
|
+
l.isStringLiteral(u) && (this._rawComponentPath = u.value);
|
|
259
260
|
}
|
|
260
261
|
}
|
|
261
|
-
let { code:
|
|
262
|
-
t.component =
|
|
263
|
-
} else if (
|
|
264
|
-
let
|
|
265
|
-
l.isIdentifier(
|
|
266
|
-
} else if (
|
|
267
|
-
if (l.isStringLiteral(
|
|
268
|
-
t.id =
|
|
262
|
+
let { code: c } = de.print(r.value, {});
|
|
263
|
+
t.component = c;
|
|
264
|
+
} else if (r.key.name === "tags") {
|
|
265
|
+
let o = r.value;
|
|
266
|
+
l.isIdentifier(o) && (o = O(o.name, this._ast.program)), t.tags = le(o);
|
|
267
|
+
} else if (r.key.name === "id")
|
|
268
|
+
if (l.isStringLiteral(r.value))
|
|
269
|
+
t.id = r.value.value;
|
|
269
270
|
else
|
|
270
|
-
throw new Error(`Unexpected component id: ${
|
|
271
|
+
throw new Error(`Unexpected component id: ${r.value}`);
|
|
271
272
|
}
|
|
272
273
|
}), this._meta = t;
|
|
273
274
|
}
|
|
274
275
|
getStoryExport(e) {
|
|
275
|
-
let
|
|
276
|
-
if (
|
|
277
|
-
let { callee: t, arguments:
|
|
278
|
-
if (l.isMemberExpression(t) && l.isIdentifier(t.object) && l.isIdentifier(t.property) && t.property.name === "bind" && (
|
|
279
|
-
|
|
276
|
+
let i = this._storyExports[e];
|
|
277
|
+
if (i = l.isVariableDeclarator(i) ? i.init : i, l.isCallExpression(i)) {
|
|
278
|
+
let { callee: t, arguments: r } = i;
|
|
279
|
+
if (l.isMemberExpression(t) && l.isIdentifier(t.object) && l.isIdentifier(t.property) && t.property.name === "bind" && (r.length === 0 ||
|
|
280
|
+
r.length === 1 && l.isObjectExpression(r[0]) && r[0].properties.length === 0)) {
|
|
280
281
|
let { name: a } = t.object;
|
|
281
|
-
|
|
282
|
+
i = this._templates[a];
|
|
282
283
|
}
|
|
283
284
|
}
|
|
284
|
-
return
|
|
285
|
+
return i;
|
|
285
286
|
}
|
|
286
287
|
parse() {
|
|
287
288
|
let e = this;
|
|
288
289
|
if (Ge(this._ast, {
|
|
289
290
|
ExportDefaultDeclaration: {
|
|
290
291
|
enter(t) {
|
|
291
|
-
let { node:
|
|
292
|
-
if (e._options.transformInlineMeta && !o && l.isExpression(
|
|
292
|
+
let { node: r, parent: a } = t, o = l.isIdentifier(r.declaration) && l.isProgram(a);
|
|
293
|
+
if (e._options.transformInlineMeta && !o && l.isExpression(r.declaration)) {
|
|
293
294
|
let d = t.scope.generateUidIdentifier("meta");
|
|
294
295
|
e._metaVariableName = d.name;
|
|
295
296
|
let u = [
|
|
296
|
-
l.variableDeclaration("const", [l.variableDeclarator(d,
|
|
297
|
+
l.variableDeclaration("const", [l.variableDeclarator(d, r.declaration)]),
|
|
297
298
|
l.exportDefaultDeclaration(d)
|
|
298
299
|
];
|
|
299
300
|
u.forEach((g) => g.loc = t.node.loc), t.replaceWithMultiple(u);
|
|
@@ -301,7 +302,7 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
301
302
|
}
|
|
302
303
|
let c, p;
|
|
303
304
|
if (o) {
|
|
304
|
-
let d =
|
|
305
|
+
let d = r.declaration.name;
|
|
305
306
|
e._metaVariableName = d;
|
|
306
307
|
let u = /* @__PURE__ */ f((g) => l.isIdentifier(g.id) && g.id.name === d, "isVariableDeclarator");
|
|
307
308
|
e._metaStatement = e._ast.program.body.find(
|
|
@@ -310,14 +311,14 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
310
311
|
u
|
|
311
312
|
)?.init;
|
|
312
313
|
} else
|
|
313
|
-
e._metaStatement =
|
|
314
|
+
e._metaStatement = r, p = r.declaration;
|
|
314
315
|
if (l.isObjectExpression(p) ? c = p : /* export default { ... } as Meta<...> */ /* export default { ... } satisfies Meta<...> */ (l.
|
|
315
316
|
isTSAsExpression(p) || l.isTSSatisfiesExpression(p)) && l.isObjectExpression(p.expression) ? c = p.expression : (
|
|
316
317
|
// export default { ... } satisfies Meta as Meta<...>
|
|
317
318
|
l.isTSAsExpression(p) && l.isTSSatisfiesExpression(p.expression) && l.isObjectExpression(p.expression.expression) && (c = p.expression.
|
|
318
319
|
expression)
|
|
319
320
|
), c && l.isProgram(a) && e._parseMeta(c, a), e._metaStatement && !e._metaNode)
|
|
320
|
-
throw new
|
|
321
|
+
throw new U(
|
|
321
322
|
"default export must be an object",
|
|
322
323
|
e._metaStatement,
|
|
323
324
|
e._options.fileName
|
|
@@ -327,16 +328,16 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
327
328
|
},
|
|
328
329
|
ExportNamedDeclaration: {
|
|
329
330
|
enter(t) {
|
|
330
|
-
let { node:
|
|
331
|
-
l.isVariableDeclaration(
|
|
332
|
-
|
|
331
|
+
let { node: r, parent: a } = t, o;
|
|
332
|
+
l.isVariableDeclaration(r.declaration) ? o = r.declaration.declarations.filter((c) => l.isVariableDeclarator(c)) : l.isFunctionDeclaration(
|
|
333
|
+
r.declaration) && (o = [r.declaration]), o ? o.forEach((c) => {
|
|
333
334
|
if (l.isIdentifier(c.id)) {
|
|
334
335
|
let p = !1, { name: d } = c.id;
|
|
335
336
|
if (d === "__namedExportsOrder" && l.isVariableDeclarator(c)) {
|
|
336
337
|
e._namedExportsOrder = He(c.init);
|
|
337
338
|
return;
|
|
338
339
|
}
|
|
339
|
-
e._storyExports[d] = c, e._storyPaths[d] = t, e._storyStatements[d] =
|
|
340
|
+
e._storyExports[d] = c, e._storyPaths[d] = t, e._storyStatements[d] = r;
|
|
340
341
|
let u = oe(d);
|
|
341
342
|
e._storyAnnotations[d] ? ae.warn(
|
|
342
343
|
`Unexpected annotations for "${d}" before story declaration`
|
|
@@ -346,17 +347,17 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
346
347
|
expression : l.isTSAsExpression(c.init) || l.isTSSatisfiesExpression(c.init) ? g = c.init.expression : g = c.init : g = c, l.isCallExpression(
|
|
347
348
|
g) && l.isMemberExpression(g.callee) && l.isIdentifier(g.callee.property) && (g.callee.property.name === "story" || g.callee.property.
|
|
348
349
|
name === "extend") && (p = !0, g = g.arguments[0]), e._metaIsFactory && !p)
|
|
349
|
-
throw new
|
|
350
|
+
throw new q(
|
|
350
351
|
"expected factory story",
|
|
351
352
|
g,
|
|
352
353
|
e._options.fileName
|
|
353
354
|
);
|
|
354
355
|
if (!e._metaIsFactory && p)
|
|
355
|
-
throw e._metaNode ? new
|
|
356
|
+
throw e._metaNode ? new q(
|
|
356
357
|
"expected non-factory story",
|
|
357
358
|
g,
|
|
358
359
|
e._options.fileName
|
|
359
|
-
) : new
|
|
360
|
+
) : new B(
|
|
360
361
|
"meta() factory must be imported from .storybook/preview configuration",
|
|
361
362
|
g,
|
|
362
363
|
e._options.fileName
|
|
@@ -364,25 +365,30 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
364
365
|
let b = {};
|
|
365
366
|
l.isObjectExpression(g) ? (b.__isArgsStory = !0, g.properties.forEach((y) => {
|
|
366
367
|
if (l.isIdentifier(y.key)) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
368
|
+
let j = y.key.name;
|
|
369
|
+
if (l.isObjectMethod(y))
|
|
370
|
+
e._storyAnnotations[d][j] = y;
|
|
371
|
+
else {
|
|
372
|
+
if (y.key.name === "render")
|
|
373
|
+
b.__isArgsStory = ce(
|
|
374
|
+
y.value,
|
|
375
|
+
a,
|
|
376
|
+
e
|
|
377
|
+
);
|
|
378
|
+
else if (y.key.name === "name" && l.isStringLiteral(y.value))
|
|
379
|
+
u = y.value.value;
|
|
380
|
+
else if (y.key.name === "storyName" && l.isStringLiteral(y.value))
|
|
381
|
+
ae.warn(
|
|
382
|
+
`Unexpected usage of "storyName" in "${d}". Please use "name" instead.`
|
|
383
|
+
);
|
|
384
|
+
else if (y.key.name === "parameters" && l.isObjectExpression(y.value)) {
|
|
385
|
+
let z = y.value.properties.find(
|
|
386
|
+
(h) => l.isObjectProperty(h) && l.isIdentifier(h.key) && h.key.name === "__id"
|
|
387
|
+
);
|
|
388
|
+
z && (b.__id = z.value.value);
|
|
389
|
+
}
|
|
390
|
+
e._storyAnnotations[d][y.key.name] = y.value;
|
|
384
391
|
}
|
|
385
|
-
e._storyAnnotations[d][y.key.name] = y.value;
|
|
386
392
|
}
|
|
387
393
|
})) : b.__isArgsStory = ce(g, a, e), e._stories[d] = {
|
|
388
394
|
id: "FIXME",
|
|
@@ -393,7 +399,7 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
393
399
|
}
|
|
394
400
|
};
|
|
395
401
|
}
|
|
396
|
-
}) :
|
|
402
|
+
}) : r.specifiers.length > 0 && r.specifiers.forEach((c) => {
|
|
397
403
|
if (l.isExportSpecifier(c) && l.isIdentifier(c.exported)) {
|
|
398
404
|
let { name: p } = c.exported, { name: d } = c.local, u = l.isProgram(a) ? O(d, a) : c.local;
|
|
399
405
|
if (p === "default") {
|
|
@@ -421,9 +427,9 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
421
427
|
}
|
|
422
428
|
},
|
|
423
429
|
ExpressionStatement: {
|
|
424
|
-
enter({ node: t, parent:
|
|
430
|
+
enter({ node: t, parent: r }) {
|
|
425
431
|
let { expression: a } = t;
|
|
426
|
-
if (l.isProgram(
|
|
432
|
+
if (l.isProgram(r) && l.isAssignmentExpression(a) && l.isMemberExpression(a.left) && l.isIdentifier(a.left.object) && l.isIdentifier(
|
|
427
433
|
a.left.property)) {
|
|
428
434
|
let o = a.left.object.name, c = a.left.property.name, p = a.right;
|
|
429
435
|
if (e._storyAnnotations[o] && (c === "story" && l.isObjectExpression(p) ? p.properties.forEach((d) => {
|
|
@@ -439,22 +445,22 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
439
445
|
},
|
|
440
446
|
CallExpression: {
|
|
441
447
|
enter(t) {
|
|
442
|
-
let { node:
|
|
448
|
+
let { node: r } = t, { callee: a } = r;
|
|
443
449
|
if (l.isIdentifier(a) && a.name === "storiesOf")
|
|
444
450
|
throw new Error(P.dedent`
|
|
445
|
-
Unexpected \`storiesOf\` usage: ${v(
|
|
451
|
+
Unexpected \`storiesOf\` usage: ${v(r, e._options.fileName)}.
|
|
446
452
|
|
|
447
453
|
SB8 does not support \`storiesOf\`.
|
|
448
454
|
`);
|
|
449
|
-
if (l.isMemberExpression(a) && l.isIdentifier(a.property) && a.property.name === "meta" && l.isIdentifier(a.object) &&
|
|
455
|
+
if (l.isMemberExpression(a) && l.isIdentifier(a.property) && a.property.name === "meta" && l.isIdentifier(a.object) && r.arguments.
|
|
450
456
|
length > 0) {
|
|
451
457
|
let c = t.scope.getBinding(a.object.name)?.path?.parentPath?.node;
|
|
452
458
|
if (l.isImportDeclaration(c))
|
|
453
459
|
if (Ke(c.source.value)) {
|
|
454
|
-
let p =
|
|
460
|
+
let p = r.arguments[0];
|
|
455
461
|
e._metaVariableName = a.property.name, e._metaIsFactory = !0, e._parseMeta(p, e._ast.program);
|
|
456
462
|
} else
|
|
457
|
-
throw new
|
|
463
|
+
throw new B(
|
|
458
464
|
"meta() factory must be imported from .storybook/preview configuration",
|
|
459
465
|
c,
|
|
460
466
|
e._options.fileName
|
|
@@ -464,37 +470,37 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
464
470
|
},
|
|
465
471
|
ImportDeclaration: {
|
|
466
472
|
enter({ node: t }) {
|
|
467
|
-
let { source:
|
|
468
|
-
if (l.isStringLiteral(
|
|
469
|
-
e.imports.push(
|
|
473
|
+
let { source: r } = t;
|
|
474
|
+
if (l.isStringLiteral(r))
|
|
475
|
+
e.imports.push(r.value);
|
|
470
476
|
else
|
|
471
477
|
throw new Error("CSF: unexpected import source");
|
|
472
478
|
}
|
|
473
479
|
}
|
|
474
480
|
}), !e._meta)
|
|
475
|
-
throw new
|
|
476
|
-
let
|
|
481
|
+
throw new U("missing default export", e._ast, e._options.fileName);
|
|
482
|
+
let i = Object.entries(e._stories);
|
|
477
483
|
if (e._meta.title = this._options.makeTitle(e._meta?.title), e._metaAnnotations.play && (e._meta.tags = [...e._meta.tags || [], "play-fn"]),
|
|
478
|
-
e._stories =
|
|
479
|
-
(t, [
|
|
480
|
-
if (!ne(
|
|
484
|
+
e._stories = i.reduce(
|
|
485
|
+
(t, [r, a]) => {
|
|
486
|
+
if (!ne(r, e._meta))
|
|
481
487
|
return t;
|
|
482
|
-
let o = a.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, oe(
|
|
488
|
+
let o = a.parameters?.__id ?? ze(e._meta?.id || e._meta?.title, oe(r)), c = { ...a.parameters, __id: o }, { includeStories: p } = e.
|
|
483
489
|
_meta || {};
|
|
484
|
-
|
|
485
|
-
let d = e._storyAnnotations[
|
|
490
|
+
r === "__page" && (i.length === 1 || Array.isArray(p) && p.length === 1) && (c.docsOnly = !0), t[r] = { ...a, id: o, parameters: c };
|
|
491
|
+
let d = e._storyAnnotations[r], { tags: u, play: g } = d;
|
|
486
492
|
if (u) {
|
|
487
|
-
let
|
|
488
|
-
t[
|
|
493
|
+
let j = l.isIdentifier(u) ? O(u.name, this._ast.program) : u;
|
|
494
|
+
t[r].tags = le(j);
|
|
489
495
|
}
|
|
490
|
-
g && (t[
|
|
491
|
-
let b = t[
|
|
492
|
-
["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((
|
|
493
|
-
b[
|
|
496
|
+
g && (t[r].tags = [...t[r].tags || [], "play-fn"]);
|
|
497
|
+
let b = t[r].__stats;
|
|
498
|
+
["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((j) => {
|
|
499
|
+
b[j] = !!d[j] || !!e._metaAnnotations[j];
|
|
494
500
|
});
|
|
495
|
-
let y = e.getStoryExport(
|
|
501
|
+
let y = e.getStoryExport(r);
|
|
496
502
|
return b.storyFn = !!(l.isArrowFunctionExpression(y) || l.isFunctionDeclaration(y)), b.mount = Ye(d.play ?? e._metaAnnotations.play),
|
|
497
|
-
b.moduleMock = !!e.imports.find((
|
|
503
|
+
b.moduleMock = !!e.imports.find((j) => Qe(j)), t;
|
|
498
504
|
},
|
|
499
505
|
{}
|
|
500
506
|
), Object.keys(e._storyExports).forEach((t) => {
|
|
@@ -502,11 +508,11 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
502
508
|
}), e._namedExportsOrder) {
|
|
503
509
|
let t = Object.keys(e._storyExports);
|
|
504
510
|
e._storyExports = pe(e._storyExports, e._namedExportsOrder), e._stories = pe(e._stories, e._namedExportsOrder);
|
|
505
|
-
let
|
|
506
|
-
if (t.length !==
|
|
511
|
+
let r = Object.keys(e._storyExports);
|
|
512
|
+
if (t.length !== r.length)
|
|
507
513
|
throw new Error(
|
|
508
514
|
`Missing exports after sort: ${t.filter(
|
|
509
|
-
(a) => !
|
|
515
|
+
(a) => !r.includes(a)
|
|
510
516
|
)}`
|
|
511
517
|
);
|
|
512
518
|
}
|
|
@@ -525,17 +531,17 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
525
531
|
P.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
|
|
526
532
|
Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
|
|
527
533
|
);
|
|
528
|
-
return Object.entries(this._stories).map(([
|
|
529
|
-
let
|
|
534
|
+
return Object.entries(this._stories).map(([i, t]) => {
|
|
535
|
+
let r = [...this._meta?.tags ?? [], ...t.tags ?? []];
|
|
530
536
|
return {
|
|
531
537
|
type: "story",
|
|
532
538
|
importPath: e,
|
|
533
539
|
rawComponentPath: this._rawComponentPath,
|
|
534
|
-
exportName:
|
|
540
|
+
exportName: i,
|
|
535
541
|
name: t.name,
|
|
536
542
|
title: this.meta?.title,
|
|
537
543
|
metaId: this.meta?.id,
|
|
538
|
-
tags:
|
|
544
|
+
tags: r,
|
|
539
545
|
__id: t.id,
|
|
540
546
|
__stats: t.__stats
|
|
541
547
|
};
|
|
@@ -544,16 +550,16 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
544
550
|
}, et = /* @__PURE__ */ f(({
|
|
545
551
|
code: s,
|
|
546
552
|
filename: e = "",
|
|
547
|
-
ast:
|
|
548
|
-
}) => new Be({ filename: e }, { code: s, ast:
|
|
549
|
-
let
|
|
550
|
-
return new J(
|
|
551
|
-
}, "loadCsf"), me = /* @__PURE__ */ f((s, e = { sourceMaps: !1 },
|
|
552
|
-
let t = We(s._ast, e,
|
|
553
|
+
ast: i
|
|
554
|
+
}) => new Be({ filename: e }, { code: s, ast: i ?? fe(s) }), "babelParseFile"), Q = /* @__PURE__ */ f((s, e) => {
|
|
555
|
+
let i = fe(s), t = et({ code: s, filename: e.fileName, ast: i });
|
|
556
|
+
return new J(i, e, t);
|
|
557
|
+
}, "loadCsf"), me = /* @__PURE__ */ f((s, e = { sourceMaps: !1 }, i) => {
|
|
558
|
+
let t = We(s._ast, e, i);
|
|
553
559
|
return e.sourceMaps ? t : t.code;
|
|
554
560
|
}, "formatCsf"), tt = /* @__PURE__ */ f((s, e = {}) => de.print(s._ast, e), "printCsf"), Ft = /* @__PURE__ */ f(async (s, e) => {
|
|
555
|
-
let
|
|
556
|
-
return Q(
|
|
561
|
+
let i = (await Ue(s, "utf-8")).toString();
|
|
562
|
+
return Q(i, { ...e, fileName: s });
|
|
557
563
|
}, "readCsf"), Ct = /* @__PURE__ */ f(async (s, e) => {
|
|
558
564
|
if (!(e || s._options.fileName))
|
|
559
565
|
throw new Error("Please specify a fileName for writeCsf");
|
|
@@ -561,7 +567,7 @@ var v = /* @__PURE__ */ f((s, e) => {
|
|
|
561
567
|
}, "writeCsf");
|
|
562
568
|
|
|
563
569
|
// src/csf-tools/ConfigFile.ts
|
|
564
|
-
var ye =
|
|
570
|
+
var ye = L(k(), 1);
|
|
565
571
|
import { readFile as rt, writeFile as it } from "node:fs/promises";
|
|
566
572
|
import {
|
|
567
573
|
babelParse as xe,
|
|
@@ -574,18 +580,18 @@ import { logger as H } from "storybook/internal/node-logger";
|
|
|
574
580
|
var Y = /* @__PURE__ */ f(({
|
|
575
581
|
expectedType: s,
|
|
576
582
|
foundType: e,
|
|
577
|
-
node:
|
|
583
|
+
node: i
|
|
578
584
|
}) => ye.dedent`
|
|
579
|
-
CSF Parsing error: Expected '${s}' but found '${e}' instead in '${
|
|
585
|
+
CSF Parsing error: Expected '${s}' but found '${e}' instead in '${i?.type}'.
|
|
580
586
|
`, "getCsfParsingErrorMessage"), N = /* @__PURE__ */ f((s) => n.isIdentifier(s.key) ? s.key.name : n.isStringLiteral(s.key) ? s.key.value :
|
|
581
|
-
null, "propKey"),
|
|
587
|
+
null, "propKey"), W = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSatisfiesExpression(s) ? W(s.expression) : s, "unwrap"), be = /* @__PURE__ */ f(
|
|
582
588
|
(s, e) => {
|
|
583
589
|
if (s.length === 0)
|
|
584
590
|
return e;
|
|
585
591
|
if (n.isObjectExpression(e)) {
|
|
586
|
-
let [
|
|
587
|
-
if (
|
|
588
|
-
return be(t,
|
|
592
|
+
let [i, ...t] = s, r = e.properties.find((a) => N(a) === i);
|
|
593
|
+
if (r)
|
|
594
|
+
return be(t, r.value);
|
|
589
595
|
}
|
|
590
596
|
}, "_getPath"), Ee = /* @__PURE__ */ f((s, e) => {
|
|
591
597
|
if (s.length === 0) {
|
|
@@ -594,46 +600,46 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
594
600
|
throw new Error("Expected object expression");
|
|
595
601
|
}
|
|
596
602
|
if (n.isObjectExpression(e)) {
|
|
597
|
-
let [
|
|
598
|
-
if (
|
|
599
|
-
return t.length === 0 ? e.properties : Ee(t,
|
|
603
|
+
let [i, ...t] = s, r = e.properties.find((a) => N(a) === i);
|
|
604
|
+
if (r)
|
|
605
|
+
return t.length === 0 ? e.properties : Ee(t, r.value);
|
|
600
606
|
}
|
|
601
|
-
}, "_getPathProperties"),
|
|
602
|
-
let
|
|
603
|
-
return e.body.find((
|
|
604
|
-
(t =
|
|
605
|
-
|
|
606
|
-
}, "_findVarDeclarator"), I = /* @__PURE__ */ f((s, e) =>
|
|
607
|
+
}, "_getPathProperties"), G = /* @__PURE__ */ f((s, e) => {
|
|
608
|
+
let i = null, t = null;
|
|
609
|
+
return e.body.find((r) => (n.isVariableDeclaration(r) ? t = r.declarations : n.isExportNamedDeclaration(r) && n.isVariableDeclaration(r.declaration) &&
|
|
610
|
+
(t = r.declaration.declarations), t && t.find((a) => n.isVariableDeclarator(a) && n.isIdentifier(a.id) && a.id.name === s ? (i = a, !0) : !1))),
|
|
611
|
+
i;
|
|
612
|
+
}, "_findVarDeclarator"), I = /* @__PURE__ */ f((s, e) => G(s, e)?.init, "_findVarInitialization"), $ = /* @__PURE__ */ f((s, e) => {
|
|
607
613
|
if (s.length === 0)
|
|
608
614
|
return e;
|
|
609
|
-
let [
|
|
610
|
-
return n.objectExpression([n.objectProperty(n.identifier(
|
|
611
|
-
}, "_makeObjectExpression"), A = /* @__PURE__ */ f((s, e,
|
|
612
|
-
let [t, ...
|
|
615
|
+
let [i, ...t] = s, r = $(t, e);
|
|
616
|
+
return n.objectExpression([n.objectProperty(n.identifier(i), r)]);
|
|
617
|
+
}, "_makeObjectExpression"), A = /* @__PURE__ */ f((s, e, i) => {
|
|
618
|
+
let [t, ...r] = s, a = i.properties.find(
|
|
613
619
|
(o) => N(o) === t
|
|
614
620
|
);
|
|
615
|
-
a ? n.isObjectExpression(a.value) &&
|
|
616
|
-
n.objectProperty(n.identifier(t), $(
|
|
621
|
+
a ? n.isObjectExpression(a.value) && r.length > 0 ? A(r, e, a.value) : a.value = $(r, e) : i.properties.push(
|
|
622
|
+
n.objectProperty(n.identifier(t), $(r, e))
|
|
617
623
|
);
|
|
618
624
|
}, "_updateExportNode"), Z = class {
|
|
619
|
-
constructor(e,
|
|
625
|
+
constructor(e, i, t) {
|
|
620
626
|
this._exports = {};
|
|
621
627
|
// FIXME: this is a hack. this is only used in the case where the user is
|
|
622
628
|
// modifying a named export that's a scalar. The _exports map is not suitable
|
|
623
629
|
// for that. But rather than refactor the whole thing, we just use this as a stopgap.
|
|
624
630
|
this._exportDecls = {};
|
|
625
631
|
this.hasDefaultExport = !1;
|
|
626
|
-
this._ast = e, this._code =
|
|
632
|
+
this._ast = e, this._code = i, this.fileName = t;
|
|
627
633
|
}
|
|
628
634
|
static {
|
|
629
635
|
f(this, "ConfigFile");
|
|
630
636
|
}
|
|
631
637
|
_parseExportsObject(e) {
|
|
632
|
-
this._exportsObject = e, e.properties.forEach((
|
|
633
|
-
let t = N(
|
|
638
|
+
this._exportsObject = e, e.properties.forEach((i) => {
|
|
639
|
+
let t = N(i);
|
|
634
640
|
if (t) {
|
|
635
|
-
let
|
|
636
|
-
n.isIdentifier(
|
|
641
|
+
let r = i.value;
|
|
642
|
+
n.isIdentifier(r) && (r = I(r.name, this._ast.program)), this._exports[t] = r;
|
|
637
643
|
}
|
|
638
644
|
});
|
|
639
645
|
}
|
|
@@ -641,56 +647,56 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
641
647
|
let e = this;
|
|
642
648
|
return ge(this._ast, {
|
|
643
649
|
ExportDefaultDeclaration: {
|
|
644
|
-
enter({ node:
|
|
650
|
+
enter({ node: i, parent: t }) {
|
|
645
651
|
e.hasDefaultExport = !0;
|
|
646
|
-
let
|
|
647
|
-
|
|
648
|
-
|
|
652
|
+
let r = n.isIdentifier(i.declaration) && n.isProgram(t) ? I(i.declaration.name, t) : i.declaration;
|
|
653
|
+
r = W(r), n.isCallExpression(r) && n.isObjectExpression(r.arguments[0]) && (r = r.arguments[0]), n.isObjectExpression(r) ? e._parseExportsObject(
|
|
654
|
+
r) : H.warn(
|
|
649
655
|
Y({
|
|
650
656
|
expectedType: "ObjectExpression",
|
|
651
|
-
foundType:
|
|
652
|
-
node:
|
|
657
|
+
foundType: r?.type,
|
|
658
|
+
node: r || i.declaration
|
|
653
659
|
})
|
|
654
660
|
);
|
|
655
661
|
}
|
|
656
662
|
},
|
|
657
663
|
ExportNamedDeclaration: {
|
|
658
|
-
enter({ node:
|
|
659
|
-
if (n.isVariableDeclaration(
|
|
660
|
-
|
|
661
|
-
if (n.isVariableDeclarator(
|
|
662
|
-
let { name: a } =
|
|
663
|
-
n.isIdentifier(o) && (o = I(o.name, t)), e._exports[a] = o, e._exportDecls[a] =
|
|
664
|
+
enter({ node: i, parent: t }) {
|
|
665
|
+
if (n.isVariableDeclaration(i.declaration))
|
|
666
|
+
i.declaration.declarations.forEach((r) => {
|
|
667
|
+
if (n.isVariableDeclarator(r) && n.isIdentifier(r.id)) {
|
|
668
|
+
let { name: a } = r.id, o = r.init;
|
|
669
|
+
n.isIdentifier(o) && (o = I(o.name, t)), e._exports[a] = o, e._exportDecls[a] = r;
|
|
664
670
|
}
|
|
665
671
|
});
|
|
666
|
-
else if (n.isFunctionDeclaration(
|
|
667
|
-
let
|
|
668
|
-
if (n.isIdentifier(
|
|
669
|
-
let { name: a } =
|
|
670
|
-
e._exportDecls[a] =
|
|
672
|
+
else if (n.isFunctionDeclaration(i.declaration)) {
|
|
673
|
+
let r = i.declaration;
|
|
674
|
+
if (n.isIdentifier(r.id)) {
|
|
675
|
+
let { name: a } = r.id;
|
|
676
|
+
e._exportDecls[a] = r;
|
|
671
677
|
}
|
|
672
|
-
} else
|
|
673
|
-
if (n.isExportSpecifier(
|
|
674
|
-
let { name: a } =
|
|
678
|
+
} else i.specifiers ? i.specifiers.forEach((r) => {
|
|
679
|
+
if (n.isExportSpecifier(r) && n.isIdentifier(r.local) && n.isIdentifier(r.exported)) {
|
|
680
|
+
let { name: a } = r.local, { name: o } = r.exported, c = G(a, t);
|
|
675
681
|
c && (e._exports[o] = c.init, e._exportDecls[o] = c);
|
|
676
682
|
}
|
|
677
683
|
}) : H.warn(
|
|
678
684
|
Y({
|
|
679
685
|
expectedType: "VariableDeclaration",
|
|
680
|
-
foundType:
|
|
681
|
-
node:
|
|
686
|
+
foundType: i.declaration?.type,
|
|
687
|
+
node: i.declaration
|
|
682
688
|
})
|
|
683
689
|
);
|
|
684
690
|
}
|
|
685
691
|
},
|
|
686
692
|
ExpressionStatement: {
|
|
687
|
-
enter({ node:
|
|
688
|
-
if (n.isAssignmentExpression(
|
|
689
|
-
let { left:
|
|
690
|
-
if (n.isMemberExpression(
|
|
693
|
+
enter({ node: i, parent: t }) {
|
|
694
|
+
if (n.isAssignmentExpression(i.expression) && i.expression.operator === "=") {
|
|
695
|
+
let { left: r, right: a } = i.expression;
|
|
696
|
+
if (n.isMemberExpression(r) && n.isIdentifier(r.object) && r.object.name === "module" && n.isIdentifier(r.property) && r.property.
|
|
691
697
|
name === "exports") {
|
|
692
698
|
let o = a;
|
|
693
|
-
n.isIdentifier(a) && (o = I(a.name, t)), o =
|
|
699
|
+
n.isIdentifier(a) && (o = I(a.name, t)), o = W(o), n.isObjectExpression(o) ? (e._exportsObject = o, o.properties.forEach((c) => {
|
|
694
700
|
let p = N(c);
|
|
695
701
|
if (p) {
|
|
696
702
|
let d = c.value;
|
|
@@ -711,27 +717,27 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
711
717
|
}
|
|
712
718
|
},
|
|
713
719
|
CallExpression: {
|
|
714
|
-
enter: /* @__PURE__ */ f(({ node:
|
|
715
|
-
n.isIdentifier(
|
|
716
|
-
e._parseExportsObject(
|
|
720
|
+
enter: /* @__PURE__ */ f(({ node: i }) => {
|
|
721
|
+
n.isIdentifier(i.callee) && i.callee.name === "definePreview" && i.arguments.length === 1 && n.isObjectExpression(i.arguments[0]) &&
|
|
722
|
+
e._parseExportsObject(i.arguments[0]);
|
|
717
723
|
}, "enter")
|
|
718
724
|
}
|
|
719
725
|
}), e;
|
|
720
726
|
}
|
|
721
727
|
getFieldNode(e) {
|
|
722
|
-
let [
|
|
723
|
-
if (
|
|
724
|
-
return be(t,
|
|
728
|
+
let [i, ...t] = e, r = this._exports[i];
|
|
729
|
+
if (r)
|
|
730
|
+
return be(t, r);
|
|
725
731
|
}
|
|
726
732
|
getFieldProperties(e) {
|
|
727
|
-
let [
|
|
728
|
-
if (
|
|
729
|
-
return Ee(t,
|
|
733
|
+
let [i, ...t] = e, r = this._exports[i];
|
|
734
|
+
if (r)
|
|
735
|
+
return Ee(t, r);
|
|
730
736
|
}
|
|
731
737
|
getFieldValue(e) {
|
|
732
|
-
let
|
|
733
|
-
if (
|
|
734
|
-
let { code: t } = ue(
|
|
738
|
+
let i = this.getFieldNode(e);
|
|
739
|
+
if (i) {
|
|
740
|
+
let { code: t } = ue(i, {});
|
|
735
741
|
return (0, eval)(`(() => (${t}))()`);
|
|
736
742
|
}
|
|
737
743
|
}
|
|
@@ -741,32 +747,32 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
741
747
|
} catch {
|
|
742
748
|
}
|
|
743
749
|
}
|
|
744
|
-
setFieldNode(e,
|
|
745
|
-
let [t, ...
|
|
750
|
+
setFieldNode(e, i) {
|
|
751
|
+
let [t, ...r] = e, a = this._exports[t];
|
|
746
752
|
if (this._exportsObject) {
|
|
747
753
|
let p = this._exportsObject.properties.find((d) => N(d) === t);
|
|
748
754
|
if (p && n.isIdentifier(p.value)) {
|
|
749
|
-
let d =
|
|
755
|
+
let d = G(p.value.name, this._ast.program);
|
|
750
756
|
if (d && n.isObjectExpression(d.init)) {
|
|
751
|
-
A(
|
|
757
|
+
A(r, i, d.init);
|
|
752
758
|
return;
|
|
753
759
|
}
|
|
754
760
|
}
|
|
755
|
-
A(e,
|
|
761
|
+
A(e, i, this._exportsObject), this._exports[e[0]] = i;
|
|
756
762
|
return;
|
|
757
763
|
}
|
|
758
|
-
if (a && n.isObjectExpression(a) &&
|
|
759
|
-
A(
|
|
764
|
+
if (a && n.isObjectExpression(a) && r.length > 0) {
|
|
765
|
+
A(r, i, a);
|
|
760
766
|
return;
|
|
761
767
|
}
|
|
762
|
-
let o =
|
|
768
|
+
let o = G(t, this._ast.program);
|
|
763
769
|
if (o && n.isObjectExpression(o.init)) {
|
|
764
|
-
A(
|
|
770
|
+
A(r, i, o.init);
|
|
765
771
|
return;
|
|
766
772
|
}
|
|
767
|
-
if (a &&
|
|
773
|
+
if (a && r.length === 0 && this._exportDecls[e[0]]) {
|
|
768
774
|
let c = this._exportDecls[e[0]];
|
|
769
|
-
n.isVariableDeclarator(c) && (c.init = $([],
|
|
775
|
+
n.isVariableDeclarator(c) && (c.init = $([], i));
|
|
770
776
|
} else {
|
|
771
777
|
if (this.hasDefaultExport)
|
|
772
778
|
throw new Error(
|
|
@@ -775,7 +781,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
775
781
|
)}" field as the default export is not an object in this file.`
|
|
776
782
|
);
|
|
777
783
|
{
|
|
778
|
-
let c = $(
|
|
784
|
+
let c = $(r, i), p = n.exportNamedDeclaration(
|
|
779
785
|
n.variableDeclaration("const", [n.variableDeclarator(n.identifier(t), c)])
|
|
780
786
|
);
|
|
781
787
|
this._exports[t] = c, this._ast.program.body.push(p);
|
|
@@ -794,9 +800,9 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
794
800
|
* @returns The name of a node in a given path, supporting the following formats:
|
|
795
801
|
*/
|
|
796
802
|
getNameFromPath(e) {
|
|
797
|
-
let
|
|
798
|
-
if (
|
|
799
|
-
return this._getPresetValue(
|
|
803
|
+
let i = this.getFieldNode(e);
|
|
804
|
+
if (i)
|
|
805
|
+
return this._getPresetValue(i, "name");
|
|
800
806
|
}
|
|
801
807
|
/**
|
|
802
808
|
* Returns an array of names of a node in a given path, supporting the following formats:
|
|
@@ -812,19 +818,19 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
812
818
|
* ```
|
|
813
819
|
*/
|
|
814
820
|
getNamesFromPath(e) {
|
|
815
|
-
let
|
|
816
|
-
if (!
|
|
821
|
+
let i = this.getFieldNode(e);
|
|
822
|
+
if (!i)
|
|
817
823
|
return;
|
|
818
824
|
let t = [];
|
|
819
|
-
return n.isArrayExpression(
|
|
820
|
-
t.push(this._getPresetValue(
|
|
825
|
+
return n.isArrayExpression(i) && i.elements.forEach((r) => {
|
|
826
|
+
t.push(this._getPresetValue(r, "name"));
|
|
821
827
|
}), t;
|
|
822
828
|
}
|
|
823
829
|
_getPnpWrappedValue(e) {
|
|
824
830
|
if (n.isCallExpression(e)) {
|
|
825
|
-
let
|
|
826
|
-
if (n.isStringLiteral(
|
|
827
|
-
return
|
|
831
|
+
let i = e.arguments[0];
|
|
832
|
+
if (n.isStringLiteral(i))
|
|
833
|
+
return i.value;
|
|
828
834
|
}
|
|
829
835
|
}
|
|
830
836
|
/**
|
|
@@ -833,63 +839,63 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
833
839
|
* 1. `{ node: 'value' }`
|
|
834
840
|
* 2. `{ node: { fallbackProperty: 'value' } }`
|
|
835
841
|
*/
|
|
836
|
-
_getPresetValue(e,
|
|
842
|
+
_getPresetValue(e, i) {
|
|
837
843
|
let t;
|
|
838
|
-
if (n.isStringLiteral(e) ? t = e.value : n.isObjectExpression(e) ? e.properties.forEach((
|
|
839
|
-
n.isObjectProperty(
|
|
840
|
-
|
|
844
|
+
if (n.isStringLiteral(e) ? t = e.value : n.isObjectExpression(e) ? e.properties.forEach((r) => {
|
|
845
|
+
n.isObjectProperty(r) && n.isIdentifier(r.key) && r.key.name === i && (n.isStringLiteral(r.value) ? t = r.value.value : t = this._getPnpWrappedValue(
|
|
846
|
+
r.value)), n.isObjectProperty(r) && n.isStringLiteral(r.key) && r.key.value === "name" && n.isStringLiteral(r.value) && (t = r.value.value);
|
|
841
847
|
}) : n.isCallExpression(e) && (t = this._getPnpWrappedValue(e)), !t)
|
|
842
848
|
throw new Error(
|
|
843
|
-
`The given node must be a string literal or an object expression with a "${
|
|
849
|
+
`The given node must be a string literal or an object expression with a "${i}" property that is a string literal.`
|
|
844
850
|
);
|
|
845
851
|
return t;
|
|
846
852
|
}
|
|
847
853
|
removeField(e) {
|
|
848
|
-
let
|
|
849
|
-
let o =
|
|
854
|
+
let i = /* @__PURE__ */ f((r, a) => {
|
|
855
|
+
let o = r.findIndex(
|
|
850
856
|
(c) => n.isIdentifier(c.key) && c.key.name === a || n.isStringLiteral(c.key) && c.key.value === a
|
|
851
857
|
);
|
|
852
|
-
o >= 0 &&
|
|
858
|
+
o >= 0 && r.splice(o, 1);
|
|
853
859
|
}, "removeProperty");
|
|
854
860
|
if (e.length === 1) {
|
|
855
|
-
let
|
|
861
|
+
let r = !1;
|
|
856
862
|
if (this._ast.program.body.forEach((a) => {
|
|
857
863
|
if (n.isExportNamedDeclaration(a) && n.isVariableDeclaration(a.declaration)) {
|
|
858
864
|
let o = a.declaration.declarations[0];
|
|
859
|
-
n.isIdentifier(o.id) && o.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(a), 1),
|
|
865
|
+
n.isIdentifier(o.id) && o.id.name === e[0] && (this._ast.program.body.splice(this._ast.program.body.indexOf(a), 1), r = !0);
|
|
860
866
|
}
|
|
861
867
|
if (n.isExportDefaultDeclaration(a)) {
|
|
862
868
|
let o = a.declaration;
|
|
863
|
-
if (n.isIdentifier(o) && (o = I(o.name, this._ast.program)), o =
|
|
869
|
+
if (n.isIdentifier(o) && (o = I(o.name, this._ast.program)), o = W(o), n.isObjectExpression(o)) {
|
|
864
870
|
let c = o.properties;
|
|
865
|
-
|
|
871
|
+
i(c, e[0]), r = !0;
|
|
866
872
|
}
|
|
867
873
|
}
|
|
868
874
|
if (n.isExpressionStatement(a) && n.isAssignmentExpression(a.expression) && n.isMemberExpression(a.expression.left) && n.isIdentifier(
|
|
869
875
|
a.expression.left.object) && a.expression.left.object.name === "module" && n.isIdentifier(a.expression.left.property) && a.expression.
|
|
870
876
|
left.property.name === "exports" && n.isObjectExpression(a.expression.right)) {
|
|
871
877
|
let o = a.expression.right.properties;
|
|
872
|
-
|
|
878
|
+
i(o, e[0]), r = !0;
|
|
873
879
|
}
|
|
874
|
-
}),
|
|
880
|
+
}), r)
|
|
875
881
|
return;
|
|
876
882
|
}
|
|
877
883
|
let t = this.getFieldProperties(e);
|
|
878
884
|
if (t) {
|
|
879
|
-
let
|
|
880
|
-
|
|
885
|
+
let r = e.at(-1);
|
|
886
|
+
i(t, r);
|
|
881
887
|
}
|
|
882
888
|
}
|
|
883
|
-
appendValueToArray(e,
|
|
884
|
-
let t = this.valueToNode(
|
|
889
|
+
appendValueToArray(e, i) {
|
|
890
|
+
let t = this.valueToNode(i);
|
|
885
891
|
t && this.appendNodeToArray(e, t);
|
|
886
892
|
}
|
|
887
|
-
appendNodeToArray(e,
|
|
893
|
+
appendNodeToArray(e, i) {
|
|
888
894
|
let t = this.getFieldNode(e);
|
|
889
895
|
if (!t)
|
|
890
|
-
this.setFieldNode(e, n.arrayExpression([
|
|
896
|
+
this.setFieldNode(e, n.arrayExpression([i]));
|
|
891
897
|
else if (n.isArrayExpression(t))
|
|
892
|
-
t.elements.push(
|
|
898
|
+
t.elements.push(i);
|
|
893
899
|
else
|
|
894
900
|
throw new Error(`Expected array at '${e.join(".")}', got '${t.type}'`);
|
|
895
901
|
}
|
|
@@ -897,23 +903,23 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
897
903
|
* Specialized helper to remove addons or other array entries that can either be strings or
|
|
898
904
|
* objects with a name property.
|
|
899
905
|
*/
|
|
900
|
-
removeEntryFromArray(e,
|
|
906
|
+
removeEntryFromArray(e, i) {
|
|
901
907
|
let t = this.getFieldNode(e);
|
|
902
908
|
if (t)
|
|
903
909
|
if (n.isArrayExpression(t)) {
|
|
904
|
-
let
|
|
905
|
-
|
|
906
|
-
if (
|
|
907
|
-
t.elements.splice(
|
|
910
|
+
let r = t.elements.findIndex((a) => n.isStringLiteral(a) ? a.value === i : n.isObjectExpression(a) ? this._getPresetValue(a, "name") ===
|
|
911
|
+
i : this._getPnpWrappedValue(a) === i);
|
|
912
|
+
if (r >= 0)
|
|
913
|
+
t.elements.splice(r, 1);
|
|
908
914
|
else
|
|
909
|
-
throw new Error(`Could not find '${
|
|
915
|
+
throw new Error(`Could not find '${i}' in array at '${e.join(".")}'`);
|
|
910
916
|
} else
|
|
911
917
|
throw new Error(`Expected array at '${e.join(".")}', got '${t.type}'`);
|
|
912
918
|
}
|
|
913
919
|
_inferQuotes() {
|
|
914
920
|
if (!this._quotes) {
|
|
915
921
|
let e = (this._ast.tokens || []).slice(0, 500).reduce(
|
|
916
|
-
(
|
|
922
|
+
(i, t) => (t.type.label === "string" && (i[this._code[t.start]] += 1), i),
|
|
917
923
|
{ "'": 0, '"': 0 }
|
|
918
924
|
);
|
|
919
925
|
this._quotes = e["'"] > e['"'] ? "single" : "double";
|
|
@@ -921,9 +927,9 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
921
927
|
return this._quotes;
|
|
922
928
|
}
|
|
923
929
|
valueToNode(e) {
|
|
924
|
-
let
|
|
925
|
-
if (
|
|
926
|
-
let { code:
|
|
930
|
+
let i = this._inferQuotes(), t;
|
|
931
|
+
if (i === "single") {
|
|
932
|
+
let { code: r } = ue(n.valueToNode(e), { jsescOption: { quotes: i } }), a = xe(`const __x = ${r}`);
|
|
927
933
|
ge(a, {
|
|
928
934
|
VariableDeclaration: {
|
|
929
935
|
enter({ node: o }) {
|
|
@@ -936,10 +942,10 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
936
942
|
t = n.valueToNode(e);
|
|
937
943
|
return t;
|
|
938
944
|
}
|
|
939
|
-
setFieldValue(e,
|
|
940
|
-
let t = this.valueToNode(
|
|
945
|
+
setFieldValue(e, i) {
|
|
946
|
+
let t = this.valueToNode(i);
|
|
941
947
|
if (!t)
|
|
942
|
-
throw new Error(`Unexpected value ${JSON.stringify(
|
|
948
|
+
throw new Error(`Unexpected value ${JSON.stringify(i)}`);
|
|
943
949
|
this.setFieldNode(e, t);
|
|
944
950
|
}
|
|
945
951
|
getBodyDeclarations() {
|
|
@@ -965,14 +971,14 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
965
971
|
* import will be set. Otherwise, an array of named imports will be set
|
|
966
972
|
* @param fromImport - The module to import from
|
|
967
973
|
*/
|
|
968
|
-
setRequireImport(e,
|
|
974
|
+
setRequireImport(e, i) {
|
|
969
975
|
let t = this._ast.program.body.find((o) => {
|
|
970
976
|
let c = n.isVariableDeclaration(o) && o.declarations.length === 1 && n.isVariableDeclarator(o.declarations[0]) && n.isCallExpression(o.
|
|
971
977
|
declarations[0].init) && n.isIdentifier(o.declarations[0].init.callee) && o.declarations[0].init.callee.name === "require" && n.isStringLiteral(
|
|
972
|
-
o.declarations[0].init.arguments[0]) && (o.declarations[0].init.arguments[0].value ===
|
|
973
|
-
|
|
974
|
-
return c && (
|
|
975
|
-
}),
|
|
978
|
+
o.declarations[0].init.arguments[0]) && (o.declarations[0].init.arguments[0].value === i || o.declarations[0].init.arguments[0].value ===
|
|
979
|
+
i.split("node:")[1]);
|
|
980
|
+
return c && (i = o.declarations[0].init.arguments[0].value), c;
|
|
981
|
+
}), r = /* @__PURE__ */ f((o) => n.isObjectPattern(t?.declarations[0].id) && t?.declarations[0].id.properties.find(
|
|
976
982
|
(c) => n.isObjectProperty(c) && n.isIdentifier(c.key) && c.key.name === o
|
|
977
983
|
), "hasRequireSpecifier"), a = /* @__PURE__ */ f((o, c) => o.declarations.length === 1 && n.isVariableDeclarator(o.declarations[0]) && n.
|
|
978
984
|
isIdentifier(o.declarations[0].id) && o.declarations[0].id.name === c, "hasDefaultRequireSpecifier");
|
|
@@ -982,14 +988,14 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
982
988
|
n.variableDeclaration("const", [
|
|
983
989
|
n.variableDeclarator(
|
|
984
990
|
n.identifier(e),
|
|
985
|
-
n.callExpression(n.identifier("require"), [n.stringLiteral(
|
|
991
|
+
n.callExpression(n.identifier("require"), [n.stringLiteral(i)])
|
|
986
992
|
)
|
|
987
993
|
])
|
|
988
994
|
);
|
|
989
995
|
}, "addDefaultRequireSpecifier");
|
|
990
996
|
t && a(t, e) || o();
|
|
991
997
|
} else t ? e.forEach((o) => {
|
|
992
|
-
|
|
998
|
+
r(o) || t.declarations[0].id.properties.push(
|
|
993
999
|
n.objectProperty(n.identifier(o), n.identifier(o), void 0, !0)
|
|
994
1000
|
);
|
|
995
1001
|
}) : this._ast.program.body.unshift(
|
|
@@ -1000,7 +1006,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
1000
1006
|
(o) => n.objectProperty(n.identifier(o), n.identifier(o), void 0, !0)
|
|
1001
1007
|
)
|
|
1002
1008
|
),
|
|
1003
|
-
n.callExpression(n.identifier("require"), [n.stringLiteral(
|
|
1009
|
+
n.callExpression(n.identifier("require"), [n.stringLiteral(i)])
|
|
1004
1010
|
)
|
|
1005
1011
|
])
|
|
1006
1012
|
);
|
|
@@ -1030,17 +1036,17 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
1030
1036
|
* import will be set. Otherwise, an array of named imports will be set
|
|
1031
1037
|
* @param fromImport - The module to import from
|
|
1032
1038
|
*/
|
|
1033
|
-
setImport(e,
|
|
1039
|
+
setImport(e, i) {
|
|
1034
1040
|
let t = this._ast.program.body.find((p) => {
|
|
1035
|
-
let d = n.isImportDeclaration(p) && (p.source.value ===
|
|
1036
|
-
return d && (
|
|
1037
|
-
}),
|
|
1041
|
+
let d = n.isImportDeclaration(p) && (p.source.value === i || p.source.value === i.split("node:")[1]);
|
|
1042
|
+
return d && (i = p.source.value), d;
|
|
1043
|
+
}), r = /* @__PURE__ */ f((p) => n.importSpecifier(n.identifier(p), n.identifier(p)), "getNewImportSpecifier"), a = /* @__PURE__ */ f((p, d) => p.
|
|
1038
1044
|
specifiers.find(
|
|
1039
1045
|
(u) => n.isImportSpecifier(u) && n.isIdentifier(u.imported) && u.imported.name === d
|
|
1040
1046
|
), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, d) => p.specifiers.find(
|
|
1041
1047
|
(u) => n.isImportNamespaceSpecifier(u) && n.isIdentifier(u.local) && u.local.name === d
|
|
1042
1048
|
), "hasNamespaceImportSpecifier");
|
|
1043
|
-
e === null ? t || this._ast.program.body.unshift(n.importDeclaration([], n.stringLiteral(
|
|
1049
|
+
e === null ? t || this._ast.program.body.unshift(n.importDeclaration([], n.stringLiteral(i))) : typeof e == "string" ? t ? (/* @__PURE__ */ f(
|
|
1044
1050
|
(p, d) => p.specifiers.find(
|
|
1045
1051
|
(u) => n.isImportDefaultSpecifier(u) && n.isIdentifier(u.local) && u.local.name === d
|
|
1046
1052
|
), "hasDefaultImportSpecifier"))(t, e) || t.specifiers.push(
|
|
@@ -1048,62 +1054,62 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
1048
1054
|
) : this._ast.program.body.unshift(
|
|
1049
1055
|
n.importDeclaration(
|
|
1050
1056
|
[n.importDefaultSpecifier(n.identifier(e))],
|
|
1051
|
-
n.stringLiteral(
|
|
1057
|
+
n.stringLiteral(i)
|
|
1052
1058
|
)
|
|
1053
1059
|
) : Array.isArray(e) ? t ? e.forEach((p) => {
|
|
1054
|
-
a(t, p) || t.specifiers.push(
|
|
1060
|
+
a(t, p) || t.specifiers.push(r(p));
|
|
1055
1061
|
}) : this._ast.program.body.unshift(
|
|
1056
1062
|
n.importDeclaration(
|
|
1057
|
-
e.map(
|
|
1058
|
-
n.stringLiteral(
|
|
1063
|
+
e.map(r),
|
|
1064
|
+
n.stringLiteral(i)
|
|
1059
1065
|
)
|
|
1060
1066
|
) : e.namespace && (t ? o(t, e.namespace) || t.specifiers.push(
|
|
1061
1067
|
n.importNamespaceSpecifier(n.identifier(e.namespace))
|
|
1062
1068
|
) : this._ast.program.body.unshift(
|
|
1063
1069
|
n.importDeclaration(
|
|
1064
1070
|
[n.importNamespaceSpecifier(n.identifier(e.namespace))],
|
|
1065
|
-
n.stringLiteral(
|
|
1071
|
+
n.stringLiteral(i)
|
|
1066
1072
|
)
|
|
1067
1073
|
));
|
|
1068
1074
|
}
|
|
1069
1075
|
}, nt = /* @__PURE__ */ f((s, e) => {
|
|
1070
|
-
let
|
|
1071
|
-
return new Z(
|
|
1076
|
+
let i = xe(s);
|
|
1077
|
+
return new Z(i, s, e);
|
|
1072
1078
|
}, "loadConfig"), ot = /* @__PURE__ */ f((s) => at(s).code, "formatConfig"), at = /* @__PURE__ */ f((s, e = {}) => st.print(s._ast, e), "pri\
|
|
1073
|
-
ntConfig"),
|
|
1079
|
+
ntConfig"), Mt = /* @__PURE__ */ f(async (s) => {
|
|
1074
1080
|
let e = (await rt(s, "utf-8")).toString();
|
|
1075
1081
|
return nt(e, s).parse();
|
|
1076
|
-
}, "readConfig"),
|
|
1077
|
-
let
|
|
1078
|
-
if (!
|
|
1082
|
+
}, "readConfig"), Rt = /* @__PURE__ */ f(async (s, e) => {
|
|
1083
|
+
let i = e || s.fileName;
|
|
1084
|
+
if (!i)
|
|
1079
1085
|
throw new Error("Please specify a fileName for writeConfig");
|
|
1080
|
-
await it(
|
|
1081
|
-
}, "writeConfig"),
|
|
1082
|
-
rybook") &&
|
|
1086
|
+
await it(i, ot(s));
|
|
1087
|
+
}, "writeConfig"), Lt = /* @__PURE__ */ f((s) => !!s._ast.program.body.find((i) => n.isImportDeclaration(i) && i.source.value.includes("@sto\
|
|
1088
|
+
rybook") && i.specifiers.some((t) => n.isImportSpecifier(t) && n.isIdentifier(t.imported) && t.imported.name === "definePreview")), "isCsfFa\
|
|
1083
1089
|
ctoryPreview");
|
|
1084
1090
|
|
|
1085
1091
|
// src/csf-tools/getStorySortParameter.ts
|
|
1086
|
-
var je =
|
|
1092
|
+
var je = L(k(), 1);
|
|
1087
1093
|
import { babelParse as lt, generate as he, types as E, traverse as ct } from "storybook/internal/babel";
|
|
1088
1094
|
import { logger as pt } from "storybook/internal/node-logger";
|
|
1089
1095
|
var ee = /* @__PURE__ */ f((s, e) => {
|
|
1090
|
-
let
|
|
1096
|
+
let i;
|
|
1091
1097
|
return s.properties.forEach((t) => {
|
|
1092
|
-
E.isIdentifier(t.key) && t.key.name === e && (
|
|
1093
|
-
}),
|
|
1098
|
+
E.isIdentifier(t.key) && t.key.name === e && (i = t.value);
|
|
1099
|
+
}), i;
|
|
1094
1100
|
}, "getValue"), te = /* @__PURE__ */ f((s) => {
|
|
1095
|
-
let e =
|
|
1101
|
+
let e = M(s);
|
|
1096
1102
|
if (E.isArrayExpression(e))
|
|
1097
|
-
return e.elements.map((
|
|
1103
|
+
return e.elements.map((i) => te(i));
|
|
1098
1104
|
if (E.isObjectExpression(e))
|
|
1099
|
-
return e.properties.reduce((
|
|
1105
|
+
return e.properties.reduce((i, t) => (E.isIdentifier(t.key) && (i[t.key.name] = te(t.value)), i), {});
|
|
1100
1106
|
if (E.isLiteral(e))
|
|
1101
1107
|
return e.value;
|
|
1102
1108
|
if (E.isIdentifier(e))
|
|
1103
1109
|
return w(e.name, !0);
|
|
1104
1110
|
throw new Error(`Unknown node type ${e.type}`);
|
|
1105
1111
|
}, "parseValue"), w = /* @__PURE__ */ f((s, e) => {
|
|
1106
|
-
let
|
|
1112
|
+
let i = je.dedent`
|
|
1107
1113
|
Unexpected '${s}'. Parameter 'options.storySort' should be defined inline e.g.:
|
|
1108
1114
|
|
|
1109
1115
|
export default {
|
|
@@ -1115,23 +1121,23 @@ var ee = /* @__PURE__ */ f((s, e) => {
|
|
|
1115
1121
|
};
|
|
1116
1122
|
`;
|
|
1117
1123
|
if (e)
|
|
1118
|
-
throw new Error(
|
|
1119
|
-
pt.log(
|
|
1120
|
-
}, "unsupported"),
|
|
1124
|
+
throw new Error(i);
|
|
1125
|
+
pt.log(i);
|
|
1126
|
+
}, "unsupported"), M = /* @__PURE__ */ f((s) => E.isTSAsExpression(s) || E.isTSSatisfiesExpression(s) ? s.expression : s, "stripTSModifiers"),
|
|
1121
1127
|
Se = /* @__PURE__ */ f((s) => {
|
|
1122
|
-
let e =
|
|
1128
|
+
let e = M(s);
|
|
1123
1129
|
if (E.isObjectExpression(e)) {
|
|
1124
|
-
let
|
|
1125
|
-
if (
|
|
1126
|
-
if (E.isObjectExpression(
|
|
1127
|
-
return ee(
|
|
1130
|
+
let i = ee(e, "options");
|
|
1131
|
+
if (i) {
|
|
1132
|
+
if (E.isObjectExpression(i))
|
|
1133
|
+
return ee(i, "storySort");
|
|
1128
1134
|
w("options", !0);
|
|
1129
1135
|
}
|
|
1130
1136
|
}
|
|
1131
1137
|
}, "parseParameters"), _e = /* @__PURE__ */ f((s, e) => {
|
|
1132
|
-
let
|
|
1133
|
-
if (E.isObjectExpression(
|
|
1134
|
-
let t = ee(
|
|
1138
|
+
let i = M(s);
|
|
1139
|
+
if (E.isObjectExpression(i)) {
|
|
1140
|
+
let t = ee(i, "parameters");
|
|
1135
1141
|
if (E.isIdentifier(t) && (t = O(t.name, e)), t)
|
|
1136
1142
|
return Se(t);
|
|
1137
1143
|
} else
|
|
@@ -1139,28 +1145,28 @@ Se = /* @__PURE__ */ f((s) => {
|
|
|
1139
1145
|
}, "parseDefault"), zt = /* @__PURE__ */ f((s) => {
|
|
1140
1146
|
if (!s.includes("storySort"))
|
|
1141
1147
|
return;
|
|
1142
|
-
let e,
|
|
1143
|
-
if (ct(
|
|
1148
|
+
let e, i = lt(s);
|
|
1149
|
+
if (ct(i, {
|
|
1144
1150
|
ExportNamedDeclaration: {
|
|
1145
1151
|
enter({ node: t }) {
|
|
1146
|
-
E.isVariableDeclaration(t.declaration) ? t.declaration.declarations.forEach((
|
|
1147
|
-
if (E.isVariableDeclarator(
|
|
1148
|
-
let { name: a } =
|
|
1149
|
-
if (a === "parameters" &&
|
|
1150
|
-
let o =
|
|
1152
|
+
E.isVariableDeclaration(t.declaration) ? t.declaration.declarations.forEach((r) => {
|
|
1153
|
+
if (E.isVariableDeclarator(r) && E.isIdentifier(r.id)) {
|
|
1154
|
+
let { name: a } = r.id;
|
|
1155
|
+
if (a === "parameters" && r.init) {
|
|
1156
|
+
let o = M(r.init);
|
|
1151
1157
|
e = Se(o);
|
|
1152
1158
|
}
|
|
1153
1159
|
}
|
|
1154
|
-
}) : t.specifiers.forEach((
|
|
1155
|
-
E.isIdentifier(
|
|
1160
|
+
}) : t.specifiers.forEach((r) => {
|
|
1161
|
+
E.isIdentifier(r.exported) && r.exported.name === "parameters" && w("parameters", !1);
|
|
1156
1162
|
});
|
|
1157
1163
|
}
|
|
1158
1164
|
},
|
|
1159
1165
|
ExportDefaultDeclaration: {
|
|
1160
1166
|
enter({ node: t }) {
|
|
1161
|
-
let
|
|
1162
|
-
E.isIdentifier(
|
|
1163
|
-
|
|
1167
|
+
let r = t.declaration;
|
|
1168
|
+
E.isIdentifier(r) && (r = O(r.name, i.program)), r = M(r), E.isCallExpression(r) && E.isObjectExpression(r.arguments?.[0]) ? e = _e(
|
|
1169
|
+
r.arguments[0], i.program) : E.isObjectExpression(r) ? e = _e(r, i.program) : w("default", !1);
|
|
1164
1170
|
}
|
|
1165
1171
|
}
|
|
1166
1172
|
}), !!e) {
|
|
@@ -1169,9 +1175,9 @@ Se = /* @__PURE__ */ f((s) => {
|
|
|
1169
1175
|
return (0, eval)(t);
|
|
1170
1176
|
}
|
|
1171
1177
|
if (E.isFunctionExpression(e)) {
|
|
1172
|
-
let { code: t } = he(e, {}),
|
|
1178
|
+
let { code: t } = he(e, {}), r = e.id?.name, a = `(a, b) => {
|
|
1173
1179
|
${t};
|
|
1174
|
-
return ${
|
|
1180
|
+
return ${r}(a, b)
|
|
1175
1181
|
}`;
|
|
1176
1182
|
return (0, eval)(a);
|
|
1177
1183
|
}
|
|
@@ -1181,10 +1187,10 @@ Se = /* @__PURE__ */ f((s) => {
|
|
|
1181
1187
|
|
|
1182
1188
|
// src/csf-tools/enrichCsf.ts
|
|
1183
1189
|
import { generate as ft, types as x } from "storybook/internal/babel";
|
|
1184
|
-
var dt = /* @__PURE__ */ f((s, e,
|
|
1185
|
-
let
|
|
1186
|
-
name === "meta", o = !t?.disableSource && ut(
|
|
1187
|
-
x.identifier(
|
|
1190
|
+
var dt = /* @__PURE__ */ f((s, e, i, t) => {
|
|
1191
|
+
let r = e.getStoryExport(i), a = x.isCallExpression(r) && x.isMemberExpression(r.callee) && x.isIdentifier(r.callee.object) && r.callee.object.
|
|
1192
|
+
name === "meta", o = !t?.disableSource && ut(r), c = !t?.disableDescription && Pe(e._storyStatements[i]), p = [], d = a ? x.memberExpression(
|
|
1193
|
+
x.identifier(i), x.identifier("input")) : x.identifier(i), u = x.memberExpression(d, x.identifier("parameters"));
|
|
1188
1194
|
p.push(x.spreadElement(u));
|
|
1189
1195
|
let g = x.optionalMemberExpression(
|
|
1190
1196
|
u,
|
|
@@ -1238,36 +1244,36 @@ var dt = /* @__PURE__ */ f((s, e, r, t) => {
|
|
|
1238
1244
|
);
|
|
1239
1245
|
s._ast.program.body.push(y);
|
|
1240
1246
|
}
|
|
1241
|
-
}, "enrichCsfStory"), Oe = /* @__PURE__ */ f((s, e,
|
|
1247
|
+
}, "enrichCsfStory"), Oe = /* @__PURE__ */ f((s, e, i) => {
|
|
1242
1248
|
if (!e.length) {
|
|
1243
1249
|
s.properties.find(
|
|
1244
1250
|
(p) => x.isObjectProperty(p) && x.isIdentifier(p.key) && p.key.name === "component"
|
|
1245
|
-
) || s.properties.unshift(
|
|
1251
|
+
) || s.properties.unshift(i);
|
|
1246
1252
|
return;
|
|
1247
1253
|
}
|
|
1248
|
-
let [t, ...
|
|
1254
|
+
let [t, ...r] = e, a = s.properties.find(
|
|
1249
1255
|
(c) => x.isObjectProperty(c) && x.isIdentifier(c.key) && c.key.name === t && x.isObjectExpression(c.value)
|
|
1250
1256
|
), o;
|
|
1251
|
-
a ? o = a.value : (o = x.objectExpression([]), s.properties.push(x.objectProperty(x.identifier(t), o))), Oe(o,
|
|
1252
|
-
}, "addComponentDescription"), mt = /* @__PURE__ */ f((s, e,
|
|
1253
|
-
let t = !
|
|
1257
|
+
a ? o = a.value : (o = x.objectExpression([]), s.properties.push(x.objectProperty(x.identifier(t), o))), Oe(o, r, i);
|
|
1258
|
+
}, "addComponentDescription"), mt = /* @__PURE__ */ f((s, e, i) => {
|
|
1259
|
+
let t = !i?.disableDescription && Pe(e._metaStatement);
|
|
1254
1260
|
if (t) {
|
|
1255
|
-
let
|
|
1256
|
-
|
|
1257
|
-
|
|
1261
|
+
let r = s._metaNode;
|
|
1262
|
+
r && x.isObjectExpression(r) && Oe(
|
|
1263
|
+
r,
|
|
1258
1264
|
["parameters", "docs", "description"],
|
|
1259
1265
|
x.objectProperty(x.identifier("component"), x.stringLiteral(t))
|
|
1260
1266
|
);
|
|
1261
1267
|
}
|
|
1262
|
-
}, "enrichCsfMeta"), Qt = /* @__PURE__ */ f((s, e,
|
|
1263
|
-
mt(s, e,
|
|
1264
|
-
dt(s, e, t,
|
|
1268
|
+
}, "enrichCsfMeta"), Qt = /* @__PURE__ */ f((s, e, i) => {
|
|
1269
|
+
mt(s, e, i), Object.keys(s._storyExports).forEach((t) => {
|
|
1270
|
+
dt(s, e, t, i);
|
|
1265
1271
|
});
|
|
1266
1272
|
}, "enrichCsf"), ut = /* @__PURE__ */ f((s) => {
|
|
1267
|
-
let e = x.isVariableDeclarator(s) ? s.init : s, { code:
|
|
1268
|
-
return
|
|
1269
|
-
}, "extractSource"), Pe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((
|
|
1270
|
-
"*") ? null :
|
|
1273
|
+
let e = x.isVariableDeclarator(s) ? s.init : s, { code: i } = ft(e, {});
|
|
1274
|
+
return i;
|
|
1275
|
+
}, "extractSource"), Pe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((i) => i.type === "CommentLine" || !i.value.startsWith(
|
|
1276
|
+
"*") ? null : i.value.split(`
|
|
1271
1277
|
`).map((t) => t.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
|
|
1272
1278
|
`).trim()).filter(Boolean).join(`
|
|
1273
1279
|
`) : "", "extractDescription");
|
|
@@ -1276,19 +1282,19 @@ var dt = /* @__PURE__ */ f((s, e, r, t) => {
|
|
|
1276
1282
|
import { babelParse as dr } from "storybook/internal/babel";
|
|
1277
1283
|
|
|
1278
1284
|
// src/csf-tools/vitest-plugin/transformer.ts
|
|
1279
|
-
var re =
|
|
1285
|
+
var re = L(k(), 1);
|
|
1280
1286
|
import { types as m } from "storybook/internal/babel";
|
|
1281
1287
|
import { getStoryTitle as gt } from "storybook/internal/common";
|
|
1282
1288
|
import { combineTags as xt } from "storybook/internal/csf";
|
|
1283
1289
|
import { logger as ve } from "storybook/internal/node-logger";
|
|
1284
|
-
var yt = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((
|
|
1290
|
+
var yt = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((i) => s?.includes(i)) || e.exclude.some((i) => s?.includes(i))),
|
|
1285
1291
|
"isValidTest");
|
|
1286
1292
|
async function bt({
|
|
1287
1293
|
code: s,
|
|
1288
1294
|
fileName: e,
|
|
1289
|
-
configDir:
|
|
1295
|
+
configDir: i,
|
|
1290
1296
|
stories: t,
|
|
1291
|
-
tagsFilter:
|
|
1297
|
+
tagsFilter: r,
|
|
1292
1298
|
previewLevelTags: a = []
|
|
1293
1299
|
}) {
|
|
1294
1300
|
let o = Q(s, {
|
|
@@ -1297,14 +1303,14 @@ async function bt({
|
|
|
1297
1303
|
makeTitle: /* @__PURE__ */ f((h) => {
|
|
1298
1304
|
let S = gt({
|
|
1299
1305
|
storyFilePath: e,
|
|
1300
|
-
configDir:
|
|
1306
|
+
configDir: i,
|
|
1301
1307
|
stories: t,
|
|
1302
1308
|
userTitle: h
|
|
1303
1309
|
}) || "unknown";
|
|
1304
1310
|
return S === "unknown" && ve.warn(
|
|
1305
1311
|
re.dedent`
|
|
1306
1312
|
[Storybook]: Could not calculate story title for "${e}".
|
|
1307
|
-
Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${
|
|
1313
|
+
Please make sure that this file matches the globs included in the "stories" field in your Storybook configuration at "${i}".
|
|
1308
1314
|
`
|
|
1309
1315
|
), S;
|
|
1310
1316
|
}, "makeTitle")
|
|
@@ -1327,12 +1333,12 @@ le an issue with details about your use case.`
|
|
|
1327
1333
|
...o.meta?.tags || [],
|
|
1328
1334
|
...o._stories[h].tags || []
|
|
1329
1335
|
);
|
|
1330
|
-
yt(S,
|
|
1336
|
+
yt(S, r) && (b[h] = o._storyStatements[h]);
|
|
1331
1337
|
});
|
|
1332
|
-
let y = o._file.path.scope.generateUidIdentifier("test"),
|
|
1338
|
+
let y = o._file.path.scope.generateUidIdentifier("test"), j = o._file.path.scope.generateUidIdentifier("describe");
|
|
1333
1339
|
if (Object.keys(b).length === 0) {
|
|
1334
1340
|
let h = m.expressionStatement(
|
|
1335
|
-
m.callExpression(m.memberExpression(
|
|
1341
|
+
m.callExpression(m.memberExpression(j, m.identifier("skip")), [
|
|
1336
1342
|
m.stringLiteral("No valid tests found")
|
|
1337
1343
|
])
|
|
1338
1344
|
);
|
|
@@ -1341,7 +1347,7 @@ le an issue with details about your use case.`
|
|
|
1341
1347
|
m.importDeclaration(
|
|
1342
1348
|
[
|
|
1343
1349
|
m.importSpecifier(y, m.identifier("test")),
|
|
1344
|
-
m.importSpecifier(
|
|
1350
|
+
m.importSpecifier(j, m.identifier("describe"))
|
|
1345
1351
|
],
|
|
1346
1352
|
m.stringLiteral("vitest")
|
|
1347
1353
|
)
|
|
@@ -1349,7 +1355,7 @@ le an issue with details about your use case.`
|
|
|
1349
1355
|
c.program.body.unshift(...S);
|
|
1350
1356
|
} else {
|
|
1351
1357
|
let ie = function() {
|
|
1352
|
-
let
|
|
1358
|
+
let _ = o._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), D = m.memberExpression(
|
|
1353
1359
|
m.callExpression(m.memberExpression(h, m.identifier("getState")), []),
|
|
1354
1360
|
m.identifier("testPath")
|
|
1355
1361
|
), F = m.memberExpression(
|
|
@@ -1361,7 +1367,7 @@ le an issue with details about your use case.`
|
|
|
1361
1367
|
// https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
|
|
1362
1368
|
F,
|
|
1363
1369
|
D
|
|
1364
|
-
),
|
|
1370
|
+
), R = m.callExpression(
|
|
1365
1371
|
m.memberExpression(
|
|
1366
1372
|
m.callExpression(m.identifier("convertToFilePath"), [
|
|
1367
1373
|
m.memberExpression(
|
|
@@ -1374,45 +1380,45 @@ le an issue with details about your use case.`
|
|
|
1374
1380
|
[C]
|
|
1375
1381
|
);
|
|
1376
1382
|
return { isRunningFromThisFileDeclaration: m.variableDeclaration("const", [
|
|
1377
|
-
m.variableDeclarator(
|
|
1378
|
-
]), isRunningFromThisFileId:
|
|
1383
|
+
m.variableDeclarator(_, R)
|
|
1384
|
+
]), isRunningFromThisFileId: _ };
|
|
1379
1385
|
};
|
|
1380
|
-
var
|
|
1386
|
+
var z = ie;
|
|
1381
1387
|
f(ie, "getTestGuardDeclaration");
|
|
1382
1388
|
let h = o._file.path.scope.generateUidIdentifier("expect"), S = o._file.path.scope.generateUidIdentifier("testStory"), De = m.identifier(
|
|
1383
|
-
JSON.stringify(
|
|
1389
|
+
JSON.stringify(r.skip)), { isRunningFromThisFileDeclaration: Ie, isRunningFromThisFileId: Ne } = ie();
|
|
1384
1390
|
c.program.body.push(Ie);
|
|
1385
1391
|
let we = /* @__PURE__ */ f(({
|
|
1386
|
-
localName:
|
|
1392
|
+
localName: _,
|
|
1387
1393
|
exportName: D,
|
|
1388
1394
|
testTitle: F,
|
|
1389
1395
|
node: C
|
|
1390
1396
|
}) => {
|
|
1391
|
-
let
|
|
1397
|
+
let R = m.expressionStatement(
|
|
1392
1398
|
m.callExpression(y, [
|
|
1393
1399
|
m.stringLiteral(F),
|
|
1394
1400
|
m.callExpression(S, [
|
|
1395
1401
|
m.stringLiteral(D),
|
|
1396
|
-
m.identifier(
|
|
1402
|
+
m.identifier(_),
|
|
1397
1403
|
m.identifier(p),
|
|
1398
1404
|
De
|
|
1399
1405
|
])
|
|
1400
1406
|
])
|
|
1401
1407
|
);
|
|
1402
|
-
return
|
|
1403
|
-
}, "getTestStatementForStory"), Fe = Object.entries(b).map(([
|
|
1408
|
+
return R.loc = C.loc, R;
|
|
1409
|
+
}, "getTestStatementForStory"), Fe = Object.entries(b).map(([_, D]) => {
|
|
1404
1410
|
if (D === null) {
|
|
1405
1411
|
ve.warn(
|
|
1406
1412
|
re.dedent`
|
|
1407
|
-
[Storybook]: Could not transform "${
|
|
1413
|
+
[Storybook]: Could not transform "${_}" story into test at "${e}".
|
|
1408
1414
|
Please make sure to define stories in the same file and not re-export stories coming from other files".
|
|
1409
1415
|
`
|
|
1410
1416
|
);
|
|
1411
1417
|
return;
|
|
1412
1418
|
}
|
|
1413
|
-
let F = o._stories[
|
|
1414
|
-
return we({ testTitle: C, localName: F, exportName:
|
|
1415
|
-
}).filter((
|
|
1419
|
+
let F = o._stories[_].localName ?? _, C = o._stories[_].name ?? _;
|
|
1420
|
+
return we({ testTitle: C, localName: F, exportName: _, node: D });
|
|
1421
|
+
}).filter((_) => !!_), Ce = m.ifStatement(Ne, m.blockStatement(Fe));
|
|
1416
1422
|
c.program.body.push(Ce);
|
|
1417
1423
|
let Te = [
|
|
1418
1424
|
m.importDeclaration(
|
|
@@ -1436,12 +1442,12 @@ le an issue with details about your use case.`
|
|
|
1436
1442
|
}
|
|
1437
1443
|
f(bt, "vitestTransform");
|
|
1438
1444
|
export {
|
|
1439
|
-
|
|
1445
|
+
B as BadMetaError,
|
|
1440
1446
|
Z as ConfigFile,
|
|
1441
1447
|
J as CsfFile,
|
|
1442
|
-
|
|
1448
|
+
q as MixedFactoryError,
|
|
1443
1449
|
K as MultipleMetaError,
|
|
1444
|
-
|
|
1450
|
+
U as NoMetaError,
|
|
1445
1451
|
dr as babelParse,
|
|
1446
1452
|
et as babelParseFile,
|
|
1447
1453
|
Qt as enrichCsf,
|
|
@@ -1452,16 +1458,16 @@ export {
|
|
|
1452
1458
|
ot as formatConfig,
|
|
1453
1459
|
me as formatCsf,
|
|
1454
1460
|
zt as getStorySortParameter,
|
|
1455
|
-
|
|
1461
|
+
Lt as isCsfFactoryPreview,
|
|
1456
1462
|
Qe as isModuleMock,
|
|
1457
1463
|
Ke as isValidPreviewPath,
|
|
1458
1464
|
nt as loadConfig,
|
|
1459
1465
|
Q as loadCsf,
|
|
1460
1466
|
at as printConfig,
|
|
1461
1467
|
tt as printCsf,
|
|
1462
|
-
|
|
1468
|
+
Mt as readConfig,
|
|
1463
1469
|
Ft as readCsf,
|
|
1464
1470
|
bt as vitestTransform,
|
|
1465
|
-
|
|
1471
|
+
Rt as writeConfig,
|
|
1466
1472
|
Ct as writeCsf
|
|
1467
1473
|
};
|