storybook 9.0.0-beta.9 → 9.0.0-rc.0
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/assets/server/base-preview-head.html +21 -0
- package/assets/server/template.ejs +4 -4
- package/dist/actions/preview.cjs +1 -1
- package/dist/actions/preview.d.ts +501 -0
- package/dist/actions/preview.js +1 -1
- package/dist/backgrounds/index.d.ts +501 -0
- package/dist/backgrounds/preview.d.ts +501 -0
- package/dist/bin/index.cjs +61 -61
- package/dist/bin/index.js +59 -59
- package/dist/builder-manager/index.cjs +27 -27
- package/dist/builder-manager/index.js +46 -46
- package/dist/cli/bin/index.cjs +1032 -1032
- package/dist/cli/bin/index.js +1032 -1032
- package/dist/cli/index.cjs +33709 -28783
- package/dist/cli/index.js +33641 -28711
- package/dist/common/index.cjs +2802 -2789
- package/dist/common/index.d.ts +2 -1
- package/dist/common/index.js +3250 -3237
- package/dist/components/index.cjs +711 -711
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +15 -15
- package/dist/controls/preview.d.ts +501 -0
- package/dist/core-events/index.cjs +55 -52
- package/dist/core-events/index.d.ts +3 -1
- package/dist/core-events/index.js +52 -49
- package/dist/core-server/index.cjs +12 -12
- package/dist/core-server/index.d.ts +512 -11
- package/dist/core-server/index.js +12 -12
- package/dist/core-server/presets/common-manager.js +4566 -5766
- package/dist/core-server/presets/common-override-preset.cjs +10 -12
- package/dist/core-server/presets/common-override-preset.js +3 -5
- package/dist/core-server/presets/common-preset.cjs +112 -116
- package/dist/core-server/presets/common-preset.js +10 -14
- package/dist/csf/index.d.ts +1 -1
- package/dist/csf-tools/index.cjs +116 -111
- package/dist/csf-tools/index.js +33 -28
- package/dist/highlight/preview.d.ts +501 -0
- package/dist/instrumenter/index.js +1849 -3547
- package/dist/manager/globals-module-info.cjs +3 -0
- package/dist/manager/globals-module-info.js +3 -0
- package/dist/manager/globals-runtime.js +21082 -22647
- package/dist/manager/runtime.js +2468 -2449
- package/dist/manager-api/index.cjs +2302 -8594
- package/dist/manager-api/index.d.ts +501 -0
- package/dist/manager-api/index.js +2602 -2631
- package/dist/measure/index.d.ts +501 -0
- package/dist/measure/preview.d.ts +501 -0
- package/dist/outline/index.d.ts +501 -0
- package/dist/outline/preview.d.ts +501 -0
- package/dist/preview/runtime.js +38420 -40024
- package/dist/preview-api/index.cjs +1546 -1459
- package/dist/preview-api/index.d.ts +8 -5
- package/dist/preview-api/index.js +1267 -1181
- package/dist/router/index.cjs +5700 -2327
- package/dist/router/index.d.ts +622 -243
- package/dist/router/index.js +1297 -870
- package/dist/test/index.cjs +1810 -1811
- package/dist/test/index.d.ts +53 -5
- package/dist/test/index.js +1907 -1908
- package/dist/test/preview.cjs +51 -15860
- package/dist/test/preview.d.ts +520 -13
- package/dist/test/preview.js +44 -14431
- package/dist/theming/index.cjs +17 -0
- package/dist/theming/index.js +17 -0
- package/dist/types/index.d.ts +516 -82
- package/dist/viewport/index.d.ts +502 -3
- package/dist/viewport/preview.d.ts +501 -0
- package/package.json +2 -18
- package/dist/test/spy.cjs +0 -258
- package/dist/test/spy.d.ts +0 -62
- package/dist/test/spy.js +0 -240
|
@@ -10170,20 +10170,17 @@ don")), { ...t, removeAddon: r };
|
|
|
10170
10170
|
}, JD = /* @__PURE__ */ n((t) => [PP].concat(t || []), "experimental_indexers"), eI = /* @__PURE__ */ n(async (t, e) => {
|
|
10171
10171
|
let r = await e.presets.apply("framework");
|
|
10172
10172
|
return typeof r == "string" ? {} : typeof r > "u" ? null : r.options;
|
|
10173
|
-
}, "frameworkOptions"), tI = /* @__PURE__ */ n((t,
|
|
10174
|
-
...t,
|
|
10175
|
-
docsMode: e
|
|
10176
|
-
} : t, "docs"), rI = /* @__PURE__ */ n(async (t, e) => {
|
|
10173
|
+
}, "frameworkOptions"), tI = /* @__PURE__ */ n(async (t, e) => {
|
|
10177
10174
|
let r = ir(e.configDir, "manager-head.html");
|
|
10178
10175
|
if (zo(r)) {
|
|
10179
10176
|
let i = fP(r, { encoding: "utf8" }), s = e.presets.apply("env");
|
|
10180
10177
|
return wP(await i, await s);
|
|
10181
10178
|
}
|
|
10182
10179
|
return "";
|
|
10183
|
-
}, "managerHead"),
|
|
10180
|
+
}, "managerHead"), rI = /* @__PURE__ */ n(async (t, e) => {
|
|
10184
10181
|
let r = await e.presets.apply("core");
|
|
10185
10182
|
return dm(t, e, r), dh(t, e, r), sh(t, e, r), Sa(t, e, r), t;
|
|
10186
|
-
}, "experimental_serverChannel"),
|
|
10183
|
+
}, "experimental_serverChannel"), iI = /* @__PURE__ */ n(async (t) => {
|
|
10187
10184
|
try {
|
|
10188
10185
|
return {
|
|
10189
10186
|
...t,
|
|
@@ -10193,12 +10190,12 @@ don")), { ...t, removeAddon: r };
|
|
|
10193
10190
|
} catch {
|
|
10194
10191
|
return t;
|
|
10195
10192
|
}
|
|
10196
|
-
}, "resolvedReact"),
|
|
10193
|
+
}, "resolvedReact"), sI = /* @__PURE__ */ n(async (t) => ({
|
|
10197
10194
|
...t,
|
|
10198
10195
|
"dev-only": { excludeFromDocsStories: !0 },
|
|
10199
10196
|
"docs-only": { excludeFromSidebar: !0 },
|
|
10200
10197
|
"test-only": { excludeFromSidebar: !0, excludeFromDocsStories: !0 }
|
|
10201
|
-
}), "tags"),
|
|
10198
|
+
}), "tags"), nI = /* @__PURE__ */ n(async (t) => [
|
|
10202
10199
|
ir(
|
|
10203
10200
|
hi(k.resolve("storybook/internal/package.json")),
|
|
10204
10201
|
"dist/core-server/presets/common-manager.js"
|
|
@@ -10209,22 +10206,21 @@ export {
|
|
|
10209
10206
|
WD as babel,
|
|
10210
10207
|
QD as core,
|
|
10211
10208
|
PP as csfIndexer,
|
|
10212
|
-
tI as docs,
|
|
10213
10209
|
YD as env,
|
|
10214
10210
|
JD as experimental_indexers,
|
|
10215
10211
|
XD as experimental_serverAPI,
|
|
10216
|
-
|
|
10212
|
+
rI as experimental_serverChannel,
|
|
10217
10213
|
BD as favicon,
|
|
10218
10214
|
ZD as features,
|
|
10219
10215
|
eI as frameworkOptions,
|
|
10220
10216
|
GD as logLevel,
|
|
10221
|
-
|
|
10222
|
-
|
|
10217
|
+
nI as managerEntries,
|
|
10218
|
+
tI as managerHead,
|
|
10223
10219
|
zD as previewBody,
|
|
10224
10220
|
UD as previewHead,
|
|
10225
|
-
|
|
10221
|
+
iI as resolvedReact,
|
|
10226
10222
|
HD as staticDirs,
|
|
10227
|
-
|
|
10223
|
+
sI as tags,
|
|
10228
10224
|
VD as title,
|
|
10229
10225
|
KD as typescript
|
|
10230
10226
|
};
|
package/dist/csf/index.d.ts
CHANGED
|
@@ -561,7 +561,7 @@ interface BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> {
|
|
|
561
561
|
* `afterEach` can be added to preview, the default export and to a specific story. They are run
|
|
562
562
|
* (and awaited) reverse order: preview, default export, story
|
|
563
563
|
*/
|
|
564
|
-
|
|
564
|
+
afterEach?: AfterEach<TRenderer, TArgs>[] | AfterEach<TRenderer, TArgs>;
|
|
565
565
|
/**
|
|
566
566
|
* Define a custom render function for the story(ies). If not passed, a default render function by
|
|
567
567
|
* the renderer will be used.
|
package/dist/csf-tools/index.cjs
CHANGED
|
@@ -34,8 +34,8 @@ var R = Je(($) => {
|
|
|
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
36
|
var i = r.reduce(function(a, p) {
|
|
37
|
-
var
|
|
38
|
-
return
|
|
37
|
+
var m = p.match(/\n([\t ]+|(?!\s).)/g);
|
|
38
|
+
return m ? a.concat(m.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
41
|
})) : a;
|
|
@@ -51,7 +51,7 @@ var R = Je(($) => {
|
|
|
51
51
|
r[0] = r[0].replace(/^\r?\n/, "");
|
|
52
52
|
var l = r[0];
|
|
53
53
|
return e.forEach(function(a, p) {
|
|
54
|
-
var
|
|
54
|
+
var m = l.match(/(?:^|\n)( *)$/), g = m ? m[1] : "", x = a;
|
|
55
55
|
typeof a == "string" && a.includes(`
|
|
56
56
|
`) && (x = String(a).split(`
|
|
57
57
|
`).map(function(E, b) {
|
|
@@ -89,7 +89,7 @@ Qe(dt, {
|
|
|
89
89
|
isValidPreviewPath: () => ge,
|
|
90
90
|
loadConfig: () => je,
|
|
91
91
|
loadCsf: () => Q,
|
|
92
|
-
printConfig: () =>
|
|
92
|
+
printConfig: () => Pe,
|
|
93
93
|
printCsf: () => be,
|
|
94
94
|
readConfig: () => nt,
|
|
95
95
|
readCsf: () => it,
|
|
@@ -100,11 +100,11 @@ Qe(dt, {
|
|
|
100
100
|
module.exports = He(dt);
|
|
101
101
|
|
|
102
102
|
// src/csf-tools/CsfFile.ts
|
|
103
|
-
var J = require("node:fs/promises"), c = require("storybook/internal/babel"), I = require("storybook/internal/csf"),
|
|
103
|
+
var J = require("node:fs/promises"), c = require("storybook/internal/babel"), I = require("storybook/internal/csf"), O = z(R(), 1);
|
|
104
104
|
|
|
105
105
|
// src/csf-tools/findVarInitialization.ts
|
|
106
106
|
var w = require("storybook/internal/babel");
|
|
107
|
-
var
|
|
107
|
+
var P = /* @__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.
|
|
@@ -150,7 +150,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
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 l = i.object.name, a =
|
|
153
|
+
let l = i.object.name, a = P(l, e);
|
|
154
154
|
a && (t._templates[l] = a, r = a);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -188,7 +188,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
188
188
|
}
|
|
189
189
|
constructor(e, t, r) {
|
|
190
190
|
let i = "".trim();
|
|
191
|
-
super(
|
|
191
|
+
super(O.dedent`
|
|
192
192
|
CSF: ${e} ${D(t, r)}
|
|
193
193
|
|
|
194
194
|
More info: https://storybook.js.org/docs/writing-stories#default-export
|
|
@@ -200,7 +200,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
200
200
|
}
|
|
201
201
|
constructor(e, t, r) {
|
|
202
202
|
let i = `${e} ${D(t, r)}`.trim();
|
|
203
|
-
super(
|
|
203
|
+
super(O.dedent`
|
|
204
204
|
CSF: ${e} ${D(t, r)}
|
|
205
205
|
|
|
206
206
|
More info: https://storybook.js.org/docs/writing-stories#default-export
|
|
@@ -212,7 +212,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
212
212
|
}
|
|
213
213
|
constructor(e, t, r) {
|
|
214
214
|
let i = `${e} ${D(t, r)}`.trim();
|
|
215
|
-
super(
|
|
215
|
+
super(O.dedent`
|
|
216
216
|
CSF: ${e} ${D(t, r)}
|
|
217
217
|
|
|
218
218
|
More info: https://storybook.js.org/docs/writing-stories#default-export
|
|
@@ -224,7 +224,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
224
224
|
}
|
|
225
225
|
constructor(e, t, r) {
|
|
226
226
|
let i = "".trim();
|
|
227
|
-
super(
|
|
227
|
+
super(O.dedent`
|
|
228
228
|
CSF: ${e} ${D(t, r)}
|
|
229
229
|
|
|
230
230
|
More info: https://storybook.js.org/docs/writing-stories#default-export
|
|
@@ -245,12 +245,12 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
245
245
|
f(this, "CsfFile");
|
|
246
246
|
}
|
|
247
247
|
_parseTitle(e) {
|
|
248
|
-
let t = c.types.isIdentifier(e) ?
|
|
248
|
+
let t = c.types.isIdentifier(e) ? P(e.name, this._ast.program) : e;
|
|
249
249
|
if (c.types.isStringLiteral(t))
|
|
250
250
|
return t.value;
|
|
251
251
|
if (c.types.isTSSatisfiesExpression(t) && c.types.isStringLiteral(t.expression))
|
|
252
252
|
return t.expression.value;
|
|
253
|
-
throw new Error(
|
|
253
|
+
throw new Error(O.dedent`
|
|
254
254
|
CSF: unexpected dynamic title ${D(t, this._options.fileName)}
|
|
255
255
|
|
|
256
256
|
More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
|
|
@@ -271,18 +271,18 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
271
271
|
let o = i.value;
|
|
272
272
|
if (c.types.isIdentifier(o)) {
|
|
273
273
|
let a = o.name, p = t.body.find(
|
|
274
|
-
(
|
|
274
|
+
(m) => c.types.isImportDeclaration(m) && m.specifiers.find((g) => g.local.name === a)
|
|
275
275
|
);
|
|
276
276
|
if (p) {
|
|
277
|
-
let { source:
|
|
278
|
-
c.types.isStringLiteral(
|
|
277
|
+
let { source: m } = p;
|
|
278
|
+
c.types.isStringLiteral(m) && (this._rawComponentPath = m.value);
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
let { code: l } = c.recast.print(i.value, {});
|
|
282
282
|
r.component = l;
|
|
283
283
|
} else if (i.key.name === "tags") {
|
|
284
284
|
let o = i.value;
|
|
285
|
-
c.types.isIdentifier(o) && (o =
|
|
285
|
+
c.types.isIdentifier(o) && (o = P(o.name, this._ast.program)), r.tags = de(o);
|
|
286
286
|
} else if (i.key.name === "id")
|
|
287
287
|
if (c.types.isStringLiteral(i.value))
|
|
288
288
|
r.id = i.value.value;
|
|
@@ -310,20 +310,20 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
310
310
|
enter(r) {
|
|
311
311
|
let { node: i, parent: o } = r, l = c.types.isIdentifier(i.declaration) && c.types.isProgram(o);
|
|
312
312
|
if (e._options.transformInlineMeta && !l && c.types.isExpression(i.declaration)) {
|
|
313
|
-
let
|
|
314
|
-
e._metaVariableName =
|
|
313
|
+
let m = r.scope.generateUidIdentifier("meta");
|
|
314
|
+
e._metaVariableName = m.name;
|
|
315
315
|
let g = [
|
|
316
|
-
c.types.variableDeclaration("const", [c.types.variableDeclarator(
|
|
317
|
-
c.types.exportDefaultDeclaration(
|
|
316
|
+
c.types.variableDeclaration("const", [c.types.variableDeclarator(m, i.declaration)]),
|
|
317
|
+
c.types.exportDefaultDeclaration(m)
|
|
318
318
|
];
|
|
319
319
|
g.forEach((x) => x.loc = r.node.loc), r.replaceWithMultiple(g);
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
322
|
let a, p;
|
|
323
323
|
if (l) {
|
|
324
|
-
let
|
|
325
|
-
e._metaVariableName =
|
|
326
|
-
let g = /* @__PURE__ */ f((x) => c.types.isIdentifier(x.id) && x.id.name ===
|
|
324
|
+
let m = i.declaration.name;
|
|
325
|
+
e._metaVariableName = m;
|
|
326
|
+
let g = /* @__PURE__ */ f((x) => c.types.isIdentifier(x.id) && x.id.name === m, "isVariableDeclarator");
|
|
327
327
|
e._metaStatement = e._ast.program.body.find(
|
|
328
328
|
(x) => c.types.isVariableDeclaration(x) && x.declarations.find(g)
|
|
329
329
|
), p = (e?._metaStatement?.declarations || []).find(
|
|
@@ -349,16 +349,16 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
349
349
|
c.types.isVariableDeclaration(i.declaration) ? l = i.declaration.declarations.filter((a) => c.types.isVariableDeclarator(a)) : c.types.
|
|
350
350
|
isFunctionDeclaration(i.declaration) && (l = [i.declaration]), l ? l.forEach((a) => {
|
|
351
351
|
if (c.types.isIdentifier(a.id)) {
|
|
352
|
-
let p = !1, { name:
|
|
353
|
-
if (
|
|
352
|
+
let p = !1, { name: m } = a.id;
|
|
353
|
+
if (m === "__namedExportsOrder" && c.types.isVariableDeclarator(a)) {
|
|
354
354
|
e._namedExportsOrder = et(a.init);
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
|
-
e._storyExports[
|
|
358
|
-
let g = (0, I.storyNameFromExport)(
|
|
359
|
-
e._storyAnnotations[
|
|
360
|
-
`Unexpected annotations for "${
|
|
361
|
-
) : e._storyAnnotations[
|
|
357
|
+
e._storyExports[m] = a, e._storyPaths[m] = r, e._storyStatements[m] = i;
|
|
358
|
+
let g = (0, I.storyNameFromExport)(m);
|
|
359
|
+
e._storyAnnotations[m] ? fe.warn(
|
|
360
|
+
`Unexpected annotations for "${m}" before story declaration`
|
|
361
|
+
) : e._storyAnnotations[m] = {};
|
|
362
362
|
let x;
|
|
363
363
|
if (c.types.isVariableDeclarator(a) ? x = c.types.isTSAsExpression(a.init) || c.types.isTSSatisfiesExpression(a.init) ? a.init.
|
|
364
364
|
expression : a.init : x = a, c.types.isCallExpression(x) && c.types.isMemberExpression(x.callee) && c.types.isIdentifier(x.callee.
|
|
@@ -391,7 +391,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
391
391
|
g = b.value.value;
|
|
392
392
|
else if (b.key.name === "storyName" && c.types.isStringLiteral(b.value))
|
|
393
393
|
fe.warn(
|
|
394
|
-
`Unexpected usage of "storyName" in "${
|
|
394
|
+
`Unexpected usage of "storyName" in "${m}". Please use "name" instead.`
|
|
395
395
|
);
|
|
396
396
|
else if (b.key.name === "parameters" && c.types.isObjectExpression(b.value)) {
|
|
397
397
|
let h = b.value.properties.find(
|
|
@@ -399,9 +399,9 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
399
399
|
);
|
|
400
400
|
h && (E.__id = h.value.value);
|
|
401
401
|
}
|
|
402
|
-
e._storyAnnotations[
|
|
402
|
+
e._storyAnnotations[m][b.key.name] = b.value;
|
|
403
403
|
}
|
|
404
|
-
})) : E.__isArgsStory = me(x, o, e), e._stories[
|
|
404
|
+
})) : E.__isArgsStory = me(x, o, e), e._stories[m] = {
|
|
405
405
|
id: "FIXME",
|
|
406
406
|
name: g,
|
|
407
407
|
parameters: E,
|
|
@@ -412,7 +412,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
412
412
|
}
|
|
413
413
|
}) : i.specifiers.length > 0 && i.specifiers.forEach((a) => {
|
|
414
414
|
if (c.types.isExportSpecifier(a) && c.types.isIdentifier(a.exported)) {
|
|
415
|
-
let { name: p } = a.exported, { name:
|
|
415
|
+
let { name: p } = a.exported, { name: m } = a.local, g = c.types.isProgram(o) ? P(a.local.name, o) : a.local;
|
|
416
416
|
if (p === "default") {
|
|
417
417
|
let x;
|
|
418
418
|
c.types.isObjectExpression(g) ? x = g : (
|
|
@@ -423,7 +423,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
423
423
|
e._storyAnnotations[p] = {}, e._storyStatements[p] = g, e._storyPaths[p] = r, e._stories[p] = {
|
|
424
424
|
id: "FIXME",
|
|
425
425
|
name: p,
|
|
426
|
-
localName:
|
|
426
|
+
localName: m,
|
|
427
427
|
parameters: {},
|
|
428
428
|
__stats: {}
|
|
429
429
|
};
|
|
@@ -437,13 +437,13 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
437
437
|
if (c.types.isProgram(i) && c.types.isAssignmentExpression(o) && c.types.isMemberExpression(o.left) && c.types.isIdentifier(o.left.
|
|
438
438
|
object) && c.types.isIdentifier(o.left.property)) {
|
|
439
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((
|
|
441
|
-
c.types.isIdentifier(
|
|
440
|
+
if (e._storyAnnotations[l] && (a === "story" && c.types.isObjectExpression(p) ? p.properties.forEach((m) => {
|
|
441
|
+
c.types.isIdentifier(m.key) && (e._storyAnnotations[l][m.key.name] = m.value);
|
|
442
442
|
}) : e._storyAnnotations[l][a] = p), a === "storyName" && c.types.isStringLiteral(p)) {
|
|
443
|
-
let
|
|
443
|
+
let m = p.value, g = e._stories[l];
|
|
444
444
|
if (!g)
|
|
445
445
|
return;
|
|
446
|
-
g.name =
|
|
446
|
+
g.name = m;
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
}
|
|
@@ -452,7 +452,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
452
452
|
enter(r) {
|
|
453
453
|
let { node: i } = r, { callee: o } = i;
|
|
454
454
|
if (c.types.isIdentifier(o) && o.name === "storiesOf")
|
|
455
|
-
throw new Error(
|
|
455
|
+
throw new Error(O.dedent`
|
|
456
456
|
Unexpected \`storiesOf\` usage: ${D(i, e._options.fileName)}.
|
|
457
457
|
|
|
458
458
|
SB8 does not support \`storiesOf\`.
|
|
@@ -493,18 +493,18 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
493
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
494
|
{ includeStories: p } = e._meta || {};
|
|
495
495
|
i === "__page" && (t.length === 1 || Array.isArray(p) && p.length === 1) && (a.docsOnly = !0), r[i] = { ...o, id: l, parameters: a };
|
|
496
|
-
let
|
|
496
|
+
let m = e._storyAnnotations[i], { tags: g, play: x } = m;
|
|
497
497
|
if (g) {
|
|
498
|
-
let h = c.types.isIdentifier(g) ?
|
|
498
|
+
let h = c.types.isIdentifier(g) ? P(g.name, this._ast.program) : g;
|
|
499
499
|
r[i].tags = de(h);
|
|
500
500
|
}
|
|
501
501
|
x && (r[i].tags = [...r[i].tags || [], "play-fn"]);
|
|
502
502
|
let E = r[i].__stats;
|
|
503
503
|
["play", "render", "loaders", "beforeEach", "globals", "tags"].forEach((h) => {
|
|
504
|
-
E[h] = !!
|
|
504
|
+
E[h] = !!m[h] || !!e._metaAnnotations[h];
|
|
505
505
|
});
|
|
506
506
|
let b = e.getStoryExport(i);
|
|
507
|
-
return E.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), E.mount = tt(
|
|
507
|
+
return E.storyFn = !!(c.types.isArrowFunctionExpression(b) || c.types.isFunctionDeclaration(b)), E.mount = tt(m.play ?? e._metaAnnotations.
|
|
508
508
|
play), E.moduleMock = !!e.imports.find((h) => xe(h)), r;
|
|
509
509
|
},
|
|
510
510
|
{}
|
|
@@ -533,7 +533,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
533
533
|
let { fileName: e } = this._options;
|
|
534
534
|
if (!e)
|
|
535
535
|
throw new Error(
|
|
536
|
-
|
|
536
|
+
O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
|
|
537
537
|
Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
|
|
538
538
|
);
|
|
539
539
|
return Object.entries(this._stories).map(([t, r]) => {
|
|
@@ -696,11 +696,11 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
|
|
|
696
696
|
(a) => {
|
|
697
697
|
let p = C(a);
|
|
698
698
|
if (p) {
|
|
699
|
-
let
|
|
700
|
-
n.types.isIdentifier(
|
|
701
|
-
|
|
699
|
+
let m = a.value;
|
|
700
|
+
n.types.isIdentifier(m) && (m = F(
|
|
701
|
+
m.name,
|
|
702
702
|
r
|
|
703
|
-
)), e._exports[p] =
|
|
703
|
+
)), e._exports[p] = m;
|
|
704
704
|
}
|
|
705
705
|
})) : re.warn(
|
|
706
706
|
ie({
|
|
@@ -747,11 +747,11 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
|
|
|
747
747
|
setFieldNode(e, t) {
|
|
748
748
|
let [r, ...i] = e, o = this._exports[r];
|
|
749
749
|
if (this._exportsObject) {
|
|
750
|
-
let p = this._exportsObject.properties.find((
|
|
750
|
+
let p = this._exportsObject.properties.find((m) => C(m) === r);
|
|
751
751
|
if (p && n.types.isIdentifier(p.value)) {
|
|
752
|
-
let
|
|
753
|
-
if (
|
|
754
|
-
q(i, t,
|
|
752
|
+
let m = Y(p.value.name, this._ast.program);
|
|
753
|
+
if (m && n.types.isObjectExpression(m.init)) {
|
|
754
|
+
q(i, t, m.init);
|
|
755
755
|
return;
|
|
756
756
|
}
|
|
757
757
|
}
|
|
@@ -1034,12 +1034,12 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
|
|
|
1034
1034
|
*/
|
|
1035
1035
|
setImport(e, t) {
|
|
1036
1036
|
let r = /* @__PURE__ */ f((p) => n.types.importSpecifier(n.types.identifier(p), n.types.identifier(p)), "getNewImportSpecifier"), i = /* @__PURE__ */ f(
|
|
1037
|
-
(p,
|
|
1038
|
-
(g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name ===
|
|
1039
|
-
), "hasImportSpecifier"), o = /* @__PURE__ */ f((p,
|
|
1040
|
-
(g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name ===
|
|
1041
|
-
), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p,
|
|
1042
|
-
(g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name ===
|
|
1037
|
+
(p, m) => p.specifiers.find(
|
|
1038
|
+
(g) => n.types.isImportSpecifier(g) && n.types.isIdentifier(g.imported) && g.imported.name === m
|
|
1039
|
+
), "hasImportSpecifier"), o = /* @__PURE__ */ f((p, m) => p.specifiers.find(
|
|
1040
|
+
(g) => n.types.isImportNamespaceSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
|
|
1041
|
+
), "hasNamespaceImportSpecifier"), l = /* @__PURE__ */ f((p, m) => p.specifiers.find(
|
|
1042
|
+
(g) => n.types.isImportDefaultSpecifier(g) && n.types.isIdentifier(g.local) && g.local.name === m
|
|
1043
1043
|
), "hasDefaultImportSpecifier"), a = this._ast.program.body.find(
|
|
1044
1044
|
(p) => n.types.isImportDeclaration(p) && p.source.value === t
|
|
1045
1045
|
);
|
|
@@ -1070,7 +1070,7 @@ s, "unwrap"), he = /* @__PURE__ */ f((s, e) => {
|
|
|
1070
1070
|
}, je = /* @__PURE__ */ f((s, e) => {
|
|
1071
1071
|
let t = (0, n.babelParse)(s);
|
|
1072
1072
|
return new Z(t, s, e);
|
|
1073
|
-
}, "loadConfig"), Se = /* @__PURE__ */ f((s) =>
|
|
1073
|
+
}, "loadConfig"), Se = /* @__PURE__ */ f((s) => Pe(s).code, "formatConfig"), Pe = /* @__PURE__ */ f((s, e = {}) => n.recast.print(s._ast, e),
|
|
1074
1074
|
"printConfig"), nt = /* @__PURE__ */ f(async (s) => {
|
|
1075
1075
|
let e = (await (0, ee.readFile)(s, "utf-8")).toString();
|
|
1076
1076
|
return je(e, s).parse();
|
|
@@ -1127,11 +1127,11 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
|
|
|
1127
1127
|
T("options", !0);
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
|
-
}, "parseParameters"),
|
|
1130
|
+
}, "parseParameters"), Oe = /* @__PURE__ */ f((s, e) => {
|
|
1131
1131
|
let t = W(s);
|
|
1132
1132
|
if (y.types.isObjectExpression(t)) {
|
|
1133
1133
|
let r = se(t, "parameters");
|
|
1134
|
-
if (y.types.isIdentifier(r) && (r =
|
|
1134
|
+
if (y.types.isIdentifier(r) && (r = P(r.name, e)), r)
|
|
1135
1135
|
return De(r);
|
|
1136
1136
|
} else
|
|
1137
1137
|
T("default", !0);
|
|
@@ -1158,8 +1158,8 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
|
|
|
1158
1158
|
ExportDefaultDeclaration: {
|
|
1159
1159
|
enter({ node: r }) {
|
|
1160
1160
|
let i = r.declaration;
|
|
1161
|
-
y.types.isIdentifier(i) && (i =
|
|
1162
|
-
e =
|
|
1161
|
+
y.types.isIdentifier(i) && (i = P(i.name, t.program)), i = W(i), y.types.isCallExpression(i) && y.types.isObjectExpression(i.arguments?.[0]) ?
|
|
1162
|
+
e = Oe(i.arguments[0], t.program) : y.types.isObjectExpression(i) ? e = Oe(i, t.program) : T("default", !1);
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
1165
|
}), !!e) {
|
|
@@ -1182,8 +1182,8 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
|
|
|
1182
1182
|
var u = require("storybook/internal/babel");
|
|
1183
1183
|
var ve = /* @__PURE__ */ f((s, e, t, r) => {
|
|
1184
1184
|
let i = e.getStoryExport(t), o = u.types.isCallExpression(i) && u.types.isMemberExpression(i.callee) && u.types.isIdentifier(i.callee.object) &&
|
|
1185
|
-
i.callee.object.name === "meta", l = !r?.disableSource && Fe(i), a = !r?.disableDescription && oe(e._storyStatements[t]), p = [],
|
|
1186
|
-
memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(
|
|
1185
|
+
i.callee.object.name === "meta", l = !r?.disableSource && Fe(i), a = !r?.disableDescription && oe(e._storyStatements[t]), p = [], m = o ? u.types.
|
|
1186
|
+
memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(m, u.types.identifier(
|
|
1187
1187
|
"parameters"));
|
|
1188
1188
|
p.push(u.types.spreadElement(g));
|
|
1189
1189
|
let x = u.types.optionalMemberExpression(
|
|
@@ -1276,7 +1276,7 @@ var ve = /* @__PURE__ */ f((s, e, t, r) => {
|
|
|
1276
1276
|
var Ae = require("storybook/internal/babel");
|
|
1277
1277
|
|
|
1278
1278
|
// src/csf-tools/vitest-plugin/transformer.ts
|
|
1279
|
-
var
|
|
1279
|
+
var d = require("storybook/internal/babel"), Te = require("storybook/internal/common"), ke = require("storybook/internal/csf"), ae = z(R(), 1);
|
|
1280
1280
|
var Ce = console, ft = /* @__PURE__ */ f((s, e) => !(e.include.length && !e.include.some((t) => s?.includes(t)) || e.exclude.some((t) => s?.
|
|
1281
1281
|
includes(t))), "isValidTest");
|
|
1282
1282
|
async function Ve({
|
|
@@ -1306,10 +1306,10 @@ async function Ve({
|
|
|
1306
1306
|
`
|
|
1307
1307
|
), S;
|
|
1308
1308
|
}, "makeTitle")
|
|
1309
|
-
}).parse(), p = a._ast,
|
|
1310
|
-
(_) =>
|
|
1311
|
-
), E =
|
|
1312
|
-
if (x ?
|
|
1309
|
+
}).parse(), p = a._ast, m = a._metaVariableName, g = a._metaNode, x = g.properties.find(
|
|
1310
|
+
(_) => d.types.isObjectProperty(_) && d.types.isIdentifier(_.key) && _.key.name === "title"
|
|
1311
|
+
), E = d.types.stringLiteral(a._meta?.title || "unknown");
|
|
1312
|
+
if (x ? d.types.isObjectProperty(x) && (x.value = E) : g.properties.push(d.types.objectProperty(d.types.identifier("title"), E)), !g || !a.
|
|
1313
1313
|
_meta)
|
|
1314
1314
|
throw new Error(
|
|
1315
1315
|
`The Storybook vitest plugin could not detect the meta (default export) object in the story file.
|
|
@@ -1330,53 +1330,55 @@ le an issue with details about your use case.`
|
|
|
1330
1330
|
});
|
|
1331
1331
|
let h = a._file.path.scope.generateUidIdentifier("test"), v = a._file.path.scope.generateUidIdentifier("describe");
|
|
1332
1332
|
if (Object.keys(b).length === 0) {
|
|
1333
|
-
let _ =
|
|
1334
|
-
|
|
1335
|
-
|
|
1333
|
+
let _ = d.types.expressionStatement(
|
|
1334
|
+
d.types.callExpression(d.types.memberExpression(v, d.types.identifier("skip")), [
|
|
1335
|
+
d.types.stringLiteral("No valid tests found")
|
|
1336
1336
|
])
|
|
1337
1337
|
);
|
|
1338
1338
|
p.program.body.push(_);
|
|
1339
1339
|
let S = [
|
|
1340
|
-
|
|
1340
|
+
d.types.importDeclaration(
|
|
1341
1341
|
[
|
|
1342
|
-
|
|
1343
|
-
|
|
1342
|
+
d.types.importSpecifier(h, d.types.identifier("test")),
|
|
1343
|
+
d.types.importSpecifier(v, d.types.identifier("describe"))
|
|
1344
1344
|
],
|
|
1345
|
-
|
|
1345
|
+
d.types.stringLiteral("vitest")
|
|
1346
1346
|
)
|
|
1347
1347
|
];
|
|
1348
1348
|
p.program.body.unshift(...S);
|
|
1349
1349
|
} else {
|
|
1350
1350
|
let le = function() {
|
|
1351
|
-
let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N =
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
), k =
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
), V =
|
|
1351
|
+
let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = d.types.memberExpression(
|
|
1352
|
+
d.types.callExpression(d.types.memberExpression(_, d.types.identifier("getState")), []),
|
|
1353
|
+
d.types.identifier("testPath")
|
|
1354
|
+
), k = d.types.memberExpression(
|
|
1355
|
+
d.types.memberExpression(d.types.identifier("globalThis"), d.types.identifier("__vitest_worker__")),
|
|
1356
|
+
d.types.identifier("filepath")
|
|
1357
|
+
), V = d.types.logicalExpression(
|
|
1358
1358
|
"??",
|
|
1359
1359
|
// TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
|
|
1360
1360
|
// https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
|
|
1361
1361
|
k,
|
|
1362
1362
|
N
|
|
1363
|
-
), G =
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1363
|
+
), G = d.types.callExpression(
|
|
1364
|
+
d.types.memberExpression(
|
|
1365
|
+
d.types.callExpression(d.types.identifier("convertToFilePath"), [
|
|
1366
|
+
d.types.memberExpression(
|
|
1367
|
+
d.types.memberExpression(d.types.identifier("import"), d.types.identifier("meta")),
|
|
1368
|
+
d.types.identifier("url")
|
|
1369
|
+
)
|
|
1370
|
+
]),
|
|
1371
|
+
d.types.identifier("includes")
|
|
1370
1372
|
),
|
|
1371
1373
|
[V]
|
|
1372
1374
|
);
|
|
1373
|
-
return { isRunningFromThisFileDeclaration:
|
|
1374
|
-
|
|
1375
|
+
return { isRunningFromThisFileDeclaration: d.types.variableDeclaration("const", [
|
|
1376
|
+
d.types.variableDeclarator(j, G)
|
|
1375
1377
|
]), isRunningFromThisFileId: j };
|
|
1376
1378
|
};
|
|
1377
1379
|
var mt = le;
|
|
1378
1380
|
f(le, "getTestGuardDeclaration");
|
|
1379
|
-
let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), $e =
|
|
1381
|
+
let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), $e = d.types.identifier(
|
|
1380
1382
|
JSON.stringify(i.skip)), { isRunningFromThisFileDeclaration: Re, isRunningFromThisFileId: Le } = le();
|
|
1381
1383
|
p.program.body.push(Re);
|
|
1382
1384
|
let Me = /* @__PURE__ */ f(({
|
|
@@ -1385,13 +1387,13 @@ le an issue with details about your use case.`
|
|
|
1385
1387
|
testTitle: k,
|
|
1386
1388
|
node: V
|
|
1387
1389
|
}) => {
|
|
1388
|
-
let G =
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1390
|
+
let G = d.types.expressionStatement(
|
|
1391
|
+
d.types.callExpression(h, [
|
|
1392
|
+
d.types.stringLiteral(k),
|
|
1393
|
+
d.types.callExpression(S, [
|
|
1394
|
+
d.types.stringLiteral(N),
|
|
1395
|
+
d.types.identifier(j),
|
|
1396
|
+
d.types.identifier(m),
|
|
1395
1397
|
$e
|
|
1396
1398
|
])
|
|
1397
1399
|
])
|
|
@@ -1409,19 +1411,22 @@ le an issue with details about your use case.`
|
|
|
1409
1411
|
}
|
|
1410
1412
|
let k = a._stories[j].localName ?? j, V = a._stories[j].name ?? j;
|
|
1411
1413
|
return Me({ testTitle: V, localName: k, exportName: j, node: N });
|
|
1412
|
-
}).filter((j) => !!j), qe =
|
|
1414
|
+
}).filter((j) => !!j), qe = d.types.ifStatement(Le, d.types.blockStatement(Ue));
|
|
1413
1415
|
p.program.body.push(qe);
|
|
1414
1416
|
let Be = [
|
|
1415
|
-
|
|
1417
|
+
d.types.importDeclaration(
|
|
1416
1418
|
[
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
+
d.types.importSpecifier(h, d.types.identifier("test")),
|
|
1420
|
+
d.types.importSpecifier(_, d.types.identifier("expect"))
|
|
1419
1421
|
],
|
|
1420
|
-
|
|
1422
|
+
d.types.stringLiteral("vitest")
|
|
1421
1423
|
),
|
|
1422
|
-
|
|
1423
|
-
[
|
|
1424
|
-
|
|
1424
|
+
d.types.importDeclaration(
|
|
1425
|
+
[
|
|
1426
|
+
d.types.importSpecifier(S, d.types.identifier("testStory")),
|
|
1427
|
+
d.types.importSpecifier(d.types.identifier("convertToFilePath"), d.types.identifier("convertToFilePath"))
|
|
1428
|
+
],
|
|
1429
|
+
d.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
|
|
1425
1430
|
)
|
|
1426
1431
|
];
|
|
1427
1432
|
p.program.body.unshift(...Be);
|