storybook 9.0.0-alpha.16 → 9.0.0-alpha.18
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/bin/index.cjs +48 -49
- package/dist/bin/index.js +55 -56
- package/dist/cli/bin/index.cjs +1 -1
- package/dist/cli/bin/index.js +1 -1
- package/dist/common/index.cjs +44 -45
- package/dist/common/index.d.ts +1 -2
- package/dist/common/index.js +44 -45
- package/dist/core-server/index.cjs +2 -2
- package/dist/core-server/index.js +2 -2
- package/dist/core-server/presets/common-manager.js +5730 -3497
- package/dist/csf-tools/index.cjs +18 -18
- package/dist/csf-tools/index.js +18 -18
- package/dist/instrumenter/index.cjs +1525 -1889
- package/dist/instrumenter/index.js +1252 -1608
- package/dist/manager/globals-runtime.js +55042 -62107
- package/dist/manager-api/index.cjs +1 -1
- package/dist/manager-api/index.js +1 -1
- package/dist/preview/runtime.js +42527 -44033
- package/dist/test/index.cjs +6 -6
- package/dist/test/index.js +6 -6
- package/package.json +1 -1
package/dist/csf-tools/index.cjs
CHANGED
|
@@ -78,7 +78,7 @@ Qe(dt, {
|
|
|
78
78
|
babelParseFile: () => ye,
|
|
79
79
|
enrichCsf: () => pt,
|
|
80
80
|
enrichCsfMeta: () => we,
|
|
81
|
-
enrichCsfStory: () =>
|
|
81
|
+
enrichCsfStory: () => ve,
|
|
82
82
|
extractDescription: () => oe,
|
|
83
83
|
extractSource: () => Fe,
|
|
84
84
|
formatConfig: () => Se,
|
|
@@ -395,7 +395,7 @@ var D = /* @__PURE__ */ f((s, e) => {
|
|
|
395
395
|
);
|
|
396
396
|
else if (b.key.name === "parameters" && c.types.isObjectExpression(b.value)) {
|
|
397
397
|
let h = b.value.properties.find(
|
|
398
|
-
(
|
|
398
|
+
(v) => c.types.isObjectProperty(v) && c.types.isIdentifier(v.key) && v.key.name === "__id"
|
|
399
399
|
);
|
|
400
400
|
h && (E.__id = h.value.value);
|
|
401
401
|
}
|
|
@@ -1180,7 +1180,7 @@ TSModifiers"), De = /* @__PURE__ */ f((s) => {
|
|
|
1180
1180
|
|
|
1181
1181
|
// src/csf-tools/enrichCsf.ts
|
|
1182
1182
|
var u = require("storybook/internal/babel");
|
|
1183
|
-
var
|
|
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
1185
|
i.callee.object.name === "meta", l = !r?.disableSource && Fe(i), a = !r?.disableDescription && oe(e._storyStatements[t]), p = [], d = o ? u.types.
|
|
1186
1186
|
memberExpression(u.types.identifier(t), u.types.identifier("input")) : u.types.identifier(t), g = u.types.memberExpression(d, u.types.identifier(
|
|
@@ -1238,7 +1238,7 @@ var Ne = /* @__PURE__ */ f((s, e, t, r) => {
|
|
|
1238
1238
|
);
|
|
1239
1239
|
s._ast.program.body.push(b);
|
|
1240
1240
|
}
|
|
1241
|
-
}, "enrichCsfStory"),
|
|
1241
|
+
}, "enrichCsfStory"), Ne = /* @__PURE__ */ f((s, e, t) => {
|
|
1242
1242
|
if (!e.length) {
|
|
1243
1243
|
s.properties.find(
|
|
1244
1244
|
(p) => u.types.isObjectProperty(p) && u.types.isIdentifier(p.key) && p.key.name === "component"
|
|
@@ -1248,12 +1248,12 @@ var Ne = /* @__PURE__ */ f((s, e, t, r) => {
|
|
|
1248
1248
|
let [r, ...i] = e, o = s.properties.find(
|
|
1249
1249
|
(a) => u.types.isObjectProperty(a) && u.types.isIdentifier(a.key) && a.key.name === r && u.types.isObjectExpression(a.value)
|
|
1250
1250
|
), l;
|
|
1251
|
-
o ? l = o.value : (l = u.types.objectExpression([]), s.properties.push(u.types.objectProperty(u.types.identifier(r), l))),
|
|
1251
|
+
o ? l = o.value : (l = u.types.objectExpression([]), s.properties.push(u.types.objectProperty(u.types.identifier(r), l))), Ne(l, i, t);
|
|
1252
1252
|
}, "addComponentDescription"), we = /* @__PURE__ */ f((s, e, t) => {
|
|
1253
1253
|
let r = !t?.disableDescription && oe(e._metaStatement);
|
|
1254
1254
|
if (r) {
|
|
1255
1255
|
let i = s._metaNode;
|
|
1256
|
-
i && u.types.isObjectExpression(i) &&
|
|
1256
|
+
i && u.types.isObjectExpression(i) && Ne(
|
|
1257
1257
|
i,
|
|
1258
1258
|
["parameters", "docs", "description"],
|
|
1259
1259
|
u.types.objectProperty(u.types.identifier("component"), u.types.stringLiteral(r))
|
|
@@ -1261,7 +1261,7 @@ var Ne = /* @__PURE__ */ f((s, e, t, r) => {
|
|
|
1261
1261
|
}
|
|
1262
1262
|
}, "enrichCsfMeta"), pt = /* @__PURE__ */ f((s, e, t) => {
|
|
1263
1263
|
we(s, e, t), Object.keys(s._storyExports).forEach((r) => {
|
|
1264
|
-
|
|
1264
|
+
ve(s, e, r, t);
|
|
1265
1265
|
});
|
|
1266
1266
|
}, "enrichCsf"), Fe = /* @__PURE__ */ f((s) => {
|
|
1267
1267
|
let e = u.types.isVariableDeclarator(s) ? s.init : s, { code: t } = (0, u.generate)(e, {});
|
|
@@ -1328,10 +1328,10 @@ le an issue with details about your use case.`
|
|
|
1328
1328
|
);
|
|
1329
1329
|
ft(S, i) && (b[_] = a._storyStatements[_]);
|
|
1330
1330
|
});
|
|
1331
|
-
let h = a._file.path.scope.generateUidIdentifier("test"),
|
|
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
1333
|
let _ = m.types.expressionStatement(
|
|
1334
|
-
m.types.callExpression(m.types.memberExpression(
|
|
1334
|
+
m.types.callExpression(m.types.memberExpression(v, m.types.identifier("skip")), [
|
|
1335
1335
|
m.types.stringLiteral("No valid tests found")
|
|
1336
1336
|
])
|
|
1337
1337
|
);
|
|
@@ -1340,7 +1340,7 @@ le an issue with details about your use case.`
|
|
|
1340
1340
|
m.types.importDeclaration(
|
|
1341
1341
|
[
|
|
1342
1342
|
m.types.importSpecifier(h, m.types.identifier("test")),
|
|
1343
|
-
m.types.importSpecifier(
|
|
1343
|
+
m.types.importSpecifier(v, m.types.identifier("describe"))
|
|
1344
1344
|
],
|
|
1345
1345
|
m.types.stringLiteral("vitest")
|
|
1346
1346
|
)
|
|
@@ -1348,7 +1348,7 @@ le an issue with details about your use case.`
|
|
|
1348
1348
|
p.program.body.unshift(...S);
|
|
1349
1349
|
} else {
|
|
1350
1350
|
let le = function() {
|
|
1351
|
-
let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"),
|
|
1351
|
+
let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), N = m.types.memberExpression(
|
|
1352
1352
|
m.types.callExpression(m.types.memberExpression(_, m.types.identifier("getState")), []),
|
|
1353
1353
|
m.types.identifier("testPath")
|
|
1354
1354
|
), k = m.types.memberExpression(
|
|
@@ -1359,7 +1359,7 @@ le an issue with details about your use case.`
|
|
|
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
1363
|
), G = m.types.callExpression(
|
|
1364
1364
|
m.types.memberExpression(
|
|
1365
1365
|
m.types.memberExpression(
|
|
@@ -1381,7 +1381,7 @@ le an issue with details about your use case.`
|
|
|
1381
1381
|
p.program.body.push(Re);
|
|
1382
1382
|
let Me = /* @__PURE__ */ f(({
|
|
1383
1383
|
localName: j,
|
|
1384
|
-
exportName:
|
|
1384
|
+
exportName: N,
|
|
1385
1385
|
testTitle: k,
|
|
1386
1386
|
node: V
|
|
1387
1387
|
}) => {
|
|
@@ -1389,7 +1389,7 @@ le an issue with details about your use case.`
|
|
|
1389
1389
|
m.types.callExpression(h, [
|
|
1390
1390
|
m.types.stringLiteral(k),
|
|
1391
1391
|
m.types.callExpression(S, [
|
|
1392
|
-
m.types.stringLiteral(
|
|
1392
|
+
m.types.stringLiteral(N),
|
|
1393
1393
|
m.types.identifier(j),
|
|
1394
1394
|
m.types.identifier(d),
|
|
1395
1395
|
$e
|
|
@@ -1397,8 +1397,8 @@ le an issue with details about your use case.`
|
|
|
1397
1397
|
])
|
|
1398
1398
|
);
|
|
1399
1399
|
return G.loc = V.loc, G;
|
|
1400
|
-
}, "getTestStatementForStory"), Ue = Object.entries(b).map(([j,
|
|
1401
|
-
if (
|
|
1400
|
+
}, "getTestStatementForStory"), Ue = Object.entries(b).map(([j, N]) => {
|
|
1401
|
+
if (N === null) {
|
|
1402
1402
|
Ce.warn(
|
|
1403
1403
|
ae.dedent`
|
|
1404
1404
|
[Storybook]: Could not transform "${j}" story into test at "${e}".
|
|
@@ -1408,7 +1408,7 @@ le an issue with details about your use case.`
|
|
|
1408
1408
|
return;
|
|
1409
1409
|
}
|
|
1410
1410
|
let k = a._stories[j].localName ?? j, V = a._stories[j].name ?? j;
|
|
1411
|
-
return Me({ testTitle: V, localName: k, exportName: j, node:
|
|
1411
|
+
return Me({ testTitle: V, localName: k, exportName: j, node: N });
|
|
1412
1412
|
}).filter((j) => !!j), qe = m.types.ifStatement(Le, m.types.blockStatement(Ue));
|
|
1413
1413
|
p.program.body.push(qe);
|
|
1414
1414
|
let Be = [
|
|
@@ -1421,7 +1421,7 @@ le an issue with details about your use case.`
|
|
|
1421
1421
|
),
|
|
1422
1422
|
m.types.importDeclaration(
|
|
1423
1423
|
[m.types.importSpecifier(S, m.types.identifier("testStory"))],
|
|
1424
|
-
m.types.stringLiteral("@storybook/addon-
|
|
1424
|
+
m.types.stringLiteral("@storybook/addon-vitest/internal/test-utils")
|
|
1425
1425
|
)
|
|
1426
1426
|
];
|
|
1427
1427
|
p.program.body.unshift(...Be);
|
package/dist/csf-tools/index.js
CHANGED
|
@@ -592,7 +592,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
592
592
|
return e.body.find((r) => (n.isVariableDeclaration(r) ? t = r.declarations : n.isExportNamedDeclaration(r) && n.isVariableDeclaration(r.declaration) &&
|
|
593
593
|
(t = r.declaration.declarations), t && t.find((o) => n.isVariableDeclarator(o) && n.isIdentifier(o.id) && o.id.name === s ? (i = o, !0) : !1))),
|
|
594
594
|
i;
|
|
595
|
-
}, "_findVarDeclarator"),
|
|
595
|
+
}, "_findVarDeclarator"), N = /* @__PURE__ */ f((s, e) => z(s, e)?.init, "_findVarInitialization"), R = /* @__PURE__ */ f((s, e) => {
|
|
596
596
|
if (s.length === 0)
|
|
597
597
|
return e;
|
|
598
598
|
let [i, ...t] = s, r = R(t, e);
|
|
@@ -622,7 +622,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
622
622
|
let t = w(i);
|
|
623
623
|
if (t) {
|
|
624
624
|
let r = i.value;
|
|
625
|
-
n.isIdentifier(r) && (r =
|
|
625
|
+
n.isIdentifier(r) && (r = N(r.name, this._ast.program)), this._exports[t] = r;
|
|
626
626
|
}
|
|
627
627
|
});
|
|
628
628
|
}
|
|
@@ -632,7 +632,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
632
632
|
ExportDefaultDeclaration: {
|
|
633
633
|
enter({ node: i, parent: t }) {
|
|
634
634
|
e.hasDefaultExport = !0;
|
|
635
|
-
let r = n.isIdentifier(i.declaration) && n.isProgram(t) ?
|
|
635
|
+
let r = n.isIdentifier(i.declaration) && n.isProgram(t) ? N(i.declaration.name, t) : i.declaration;
|
|
636
636
|
r = G(r), n.isCallExpression(r) && n.isObjectExpression(r.arguments[0]) && (r = r.arguments[0]), n.isObjectExpression(r) ? e._parseExportsObject(
|
|
637
637
|
r) : H.warn(
|
|
638
638
|
Y({
|
|
@@ -649,7 +649,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
649
649
|
i.declaration.declarations.forEach((r) => {
|
|
650
650
|
if (n.isVariableDeclarator(r) && n.isIdentifier(r.id)) {
|
|
651
651
|
let { name: o } = r.id, l = r.init;
|
|
652
|
-
n.isIdentifier(l) && (l =
|
|
652
|
+
n.isIdentifier(l) && (l = N(l.name, t)), e._exports[o] = l, e._exportDecls[o] = r;
|
|
653
653
|
}
|
|
654
654
|
});
|
|
655
655
|
else if (n.isFunctionDeclaration(i.declaration)) {
|
|
@@ -679,11 +679,11 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
679
679
|
if (n.isMemberExpression(r) && n.isIdentifier(r.object) && r.object.name === "module" && n.isIdentifier(r.property) && r.property.
|
|
680
680
|
name === "exports") {
|
|
681
681
|
let l = o;
|
|
682
|
-
n.isIdentifier(o) && (l =
|
|
682
|
+
n.isIdentifier(o) && (l = N(o.name, t)), l = G(l), n.isObjectExpression(l) ? (e._exportsObject = l, l.properties.forEach((a) => {
|
|
683
683
|
let p = w(a);
|
|
684
684
|
if (p) {
|
|
685
685
|
let d = a.value;
|
|
686
|
-
n.isIdentifier(d) && (d =
|
|
686
|
+
n.isIdentifier(d) && (d = N(
|
|
687
687
|
d.name,
|
|
688
688
|
t
|
|
689
689
|
)), e._exports[p] = d;
|
|
@@ -849,7 +849,7 @@ null, "propKey"), G = /* @__PURE__ */ f((s) => n.isTSAsExpression(s) || n.isTSSa
|
|
|
849
849
|
}
|
|
850
850
|
if (n.isExportDefaultDeclaration(o)) {
|
|
851
851
|
let l = o.declaration;
|
|
852
|
-
if (n.isIdentifier(l) && (l =
|
|
852
|
+
if (n.isIdentifier(l) && (l = N(l.name, this._ast.program)), l = G(l), n.isObjectExpression(l)) {
|
|
853
853
|
let a = l.properties;
|
|
854
854
|
i(a, e[0]), r = !0;
|
|
855
855
|
}
|
|
@@ -1335,7 +1335,7 @@ le an issue with details about your use case.`
|
|
|
1335
1335
|
p.program.body.unshift(...S);
|
|
1336
1336
|
} else {
|
|
1337
1337
|
let ie = function() {
|
|
1338
|
-
let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"),
|
|
1338
|
+
let j = a._file.path.scope.generateUidIdentifier("isRunningFromThisFile"), v = m.memberExpression(
|
|
1339
1339
|
m.callExpression(m.memberExpression(_, m.identifier("getState")), []),
|
|
1340
1340
|
m.identifier("testPath")
|
|
1341
1341
|
), C = m.memberExpression(
|
|
@@ -1346,7 +1346,7 @@ le an issue with details about your use case.`
|
|
|
1346
1346
|
// TODO: switch order of testPathProperty and filePathProperty when the bug is fixed
|
|
1347
1347
|
// https://github.com/vitest-dev/vitest/issues/6367 (or probably just use testPathProperty)
|
|
1348
1348
|
C,
|
|
1349
|
-
|
|
1349
|
+
v
|
|
1350
1350
|
), M = m.callExpression(
|
|
1351
1351
|
m.memberExpression(
|
|
1352
1352
|
m.memberExpression(
|
|
@@ -1364,11 +1364,11 @@ le an issue with details about your use case.`
|
|
|
1364
1364
|
var Et = ie;
|
|
1365
1365
|
f(ie, "getTestGuardDeclaration");
|
|
1366
1366
|
let _ = a._file.path.scope.generateUidIdentifier("expect"), S = a._file.path.scope.generateUidIdentifier("testStory"), De = m.identifier(
|
|
1367
|
-
JSON.stringify(r.skip)), { isRunningFromThisFileDeclaration:
|
|
1368
|
-
p.program.body.push(
|
|
1367
|
+
JSON.stringify(r.skip)), { isRunningFromThisFileDeclaration: ve, isRunningFromThisFileId: Ne } = ie();
|
|
1368
|
+
p.program.body.push(ve);
|
|
1369
1369
|
let we = /* @__PURE__ */ f(({
|
|
1370
1370
|
localName: j,
|
|
1371
|
-
exportName:
|
|
1371
|
+
exportName: v,
|
|
1372
1372
|
testTitle: C,
|
|
1373
1373
|
node: T
|
|
1374
1374
|
}) => {
|
|
@@ -1376,7 +1376,7 @@ le an issue with details about your use case.`
|
|
|
1376
1376
|
m.callExpression(h, [
|
|
1377
1377
|
m.stringLiteral(C),
|
|
1378
1378
|
m.callExpression(S, [
|
|
1379
|
-
m.stringLiteral(
|
|
1379
|
+
m.stringLiteral(v),
|
|
1380
1380
|
m.identifier(j),
|
|
1381
1381
|
m.identifier(d),
|
|
1382
1382
|
De
|
|
@@ -1384,8 +1384,8 @@ le an issue with details about your use case.`
|
|
|
1384
1384
|
])
|
|
1385
1385
|
);
|
|
1386
1386
|
return M.loc = T.loc, M;
|
|
1387
|
-
}, "getTestStatementForStory"), Fe = Object.entries(y).map(([j,
|
|
1388
|
-
if (
|
|
1387
|
+
}, "getTestStatementForStory"), Fe = Object.entries(y).map(([j, v]) => {
|
|
1388
|
+
if (v === null) {
|
|
1389
1389
|
Ie.warn(
|
|
1390
1390
|
re.dedent`
|
|
1391
1391
|
[Storybook]: Could not transform "${j}" story into test at "${e}".
|
|
@@ -1395,8 +1395,8 @@ le an issue with details about your use case.`
|
|
|
1395
1395
|
return;
|
|
1396
1396
|
}
|
|
1397
1397
|
let C = a._stories[j].localName ?? j, T = a._stories[j].name ?? j;
|
|
1398
|
-
return we({ testTitle: T, localName: C, exportName: j, node:
|
|
1399
|
-
}).filter((j) => !!j), Ce = m.ifStatement(
|
|
1398
|
+
return we({ testTitle: T, localName: C, exportName: j, node: v });
|
|
1399
|
+
}).filter((j) => !!j), Ce = m.ifStatement(Ne, m.blockStatement(Fe));
|
|
1400
1400
|
p.program.body.push(Ce);
|
|
1401
1401
|
let Te = [
|
|
1402
1402
|
m.importDeclaration(
|
|
@@ -1408,7 +1408,7 @@ le an issue with details about your use case.`
|
|
|
1408
1408
|
),
|
|
1409
1409
|
m.importDeclaration(
|
|
1410
1410
|
[m.importSpecifier(S, m.identifier("testStory"))],
|
|
1411
|
-
m.stringLiteral("@storybook/addon-
|
|
1411
|
+
m.stringLiteral("@storybook/addon-vitest/internal/test-utils")
|
|
1412
1412
|
)
|
|
1413
1413
|
];
|
|
1414
1414
|
p.program.body.unshift(...Te);
|