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.
Files changed (71) hide show
  1. package/assets/server/base-preview-head.html +21 -0
  2. package/assets/server/template.ejs +4 -4
  3. package/dist/actions/preview.cjs +1 -1
  4. package/dist/actions/preview.d.ts +501 -0
  5. package/dist/actions/preview.js +1 -1
  6. package/dist/backgrounds/index.d.ts +501 -0
  7. package/dist/backgrounds/preview.d.ts +501 -0
  8. package/dist/bin/index.cjs +61 -61
  9. package/dist/bin/index.js +59 -59
  10. package/dist/builder-manager/index.cjs +27 -27
  11. package/dist/builder-manager/index.js +46 -46
  12. package/dist/cli/bin/index.cjs +1032 -1032
  13. package/dist/cli/bin/index.js +1032 -1032
  14. package/dist/cli/index.cjs +33709 -28783
  15. package/dist/cli/index.js +33641 -28711
  16. package/dist/common/index.cjs +2802 -2789
  17. package/dist/common/index.d.ts +2 -1
  18. package/dist/common/index.js +3250 -3237
  19. package/dist/components/index.cjs +711 -711
  20. package/dist/components/index.d.ts +2 -1
  21. package/dist/components/index.js +15 -15
  22. package/dist/controls/preview.d.ts +501 -0
  23. package/dist/core-events/index.cjs +55 -52
  24. package/dist/core-events/index.d.ts +3 -1
  25. package/dist/core-events/index.js +52 -49
  26. package/dist/core-server/index.cjs +12 -12
  27. package/dist/core-server/index.d.ts +512 -11
  28. package/dist/core-server/index.js +12 -12
  29. package/dist/core-server/presets/common-manager.js +4566 -5766
  30. package/dist/core-server/presets/common-override-preset.cjs +10 -12
  31. package/dist/core-server/presets/common-override-preset.js +3 -5
  32. package/dist/core-server/presets/common-preset.cjs +112 -116
  33. package/dist/core-server/presets/common-preset.js +10 -14
  34. package/dist/csf/index.d.ts +1 -1
  35. package/dist/csf-tools/index.cjs +116 -111
  36. package/dist/csf-tools/index.js +33 -28
  37. package/dist/highlight/preview.d.ts +501 -0
  38. package/dist/instrumenter/index.js +1849 -3547
  39. package/dist/manager/globals-module-info.cjs +3 -0
  40. package/dist/manager/globals-module-info.js +3 -0
  41. package/dist/manager/globals-runtime.js +21082 -22647
  42. package/dist/manager/runtime.js +2468 -2449
  43. package/dist/manager-api/index.cjs +2302 -8594
  44. package/dist/manager-api/index.d.ts +501 -0
  45. package/dist/manager-api/index.js +2602 -2631
  46. package/dist/measure/index.d.ts +501 -0
  47. package/dist/measure/preview.d.ts +501 -0
  48. package/dist/outline/index.d.ts +501 -0
  49. package/dist/outline/preview.d.ts +501 -0
  50. package/dist/preview/runtime.js +38420 -40024
  51. package/dist/preview-api/index.cjs +1546 -1459
  52. package/dist/preview-api/index.d.ts +8 -5
  53. package/dist/preview-api/index.js +1267 -1181
  54. package/dist/router/index.cjs +5700 -2327
  55. package/dist/router/index.d.ts +622 -243
  56. package/dist/router/index.js +1297 -870
  57. package/dist/test/index.cjs +1810 -1811
  58. package/dist/test/index.d.ts +53 -5
  59. package/dist/test/index.js +1907 -1908
  60. package/dist/test/preview.cjs +51 -15860
  61. package/dist/test/preview.d.ts +520 -13
  62. package/dist/test/preview.js +44 -14431
  63. package/dist/theming/index.cjs +17 -0
  64. package/dist/theming/index.js +17 -0
  65. package/dist/types/index.d.ts +516 -82
  66. package/dist/viewport/index.d.ts +502 -3
  67. package/dist/viewport/preview.d.ts +501 -0
  68. package/package.json +2 -18
  69. package/dist/test/spy.cjs +0 -258
  70. package/dist/test/spy.d.ts +0 -62
  71. package/dist/test/spy.js +0 -240
@@ -69,7 +69,7 @@ var V = Le((k) => {
69
69
  });
70
70
 
71
71
  // src/csf-tools/CsfFile.ts
72
- var P = U(V(), 1);
72
+ var O = U(V(), 1);
73
73
  import { readFile as Ue, writeFile as qe } from "node:fs/promises";
74
74
  import {
75
75
  BabelFileClass as Be,
@@ -83,7 +83,7 @@ import { isExportStory as ne, storyNameFromExport as oe, toId as ze } from "stor
83
83
 
84
84
  // src/csf-tools/findVarInitialization.ts
85
85
  import { types as A } from "storybook/internal/babel";
86
- var O = /* @__PURE__ */ f((s, e) => {
86
+ var P = /* @__PURE__ */ f((s, e) => {
87
87
  let i = null, t = null;
88
88
  return e.body.find((r) => (A.isVariableDeclaration(r) ? t = r.declarations : A.isExportNamedDeclaration(r) && A.isVariableDeclaration(r.declaration) &&
89
89
  (t = r.declaration.declarations), t && t.find((o) => A.isVariableDeclarator(o) && A.isIdentifier(o.id) && o.id.name === s ? (i = o.init, !0) :
@@ -129,7 +129,7 @@ var I = /* @__PURE__ */ f((s, e) => {
129
129
  let { callee: r, arguments: o } = s;
130
130
  if (c.isProgram(e) && c.isMemberExpression(r) && c.isIdentifier(r.object) && c.isIdentifier(r.property) && r.property.name === "bind" &&
131
131
  (o.length === 0 || o.length === 1 && c.isObjectExpression(o[0]) && o[0].properties.length === 0)) {
132
- let l = r.object.name, a = O(l, e);
132
+ let l = r.object.name, a = P(l, e);
133
133
  a && (i._templates[l] = a, t = a);
134
134
  }
135
135
  }
@@ -167,7 +167,7 @@ var I = /* @__PURE__ */ f((s, e) => {
167
167
  }
168
168
  constructor(e, i, t) {
169
169
  let r = "".trim();
170
- super(P.dedent`
170
+ super(O.dedent`
171
171
  CSF: ${e} ${I(i, t)}
172
172
 
173
173
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -179,7 +179,7 @@ var I = /* @__PURE__ */ f((s, e) => {
179
179
  }
180
180
  constructor(e, i, t) {
181
181
  let r = `${e} ${I(i, t)}`.trim();
182
- super(P.dedent`
182
+ super(O.dedent`
183
183
  CSF: ${e} ${I(i, t)}
184
184
 
185
185
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -191,7 +191,7 @@ var I = /* @__PURE__ */ f((s, e) => {
191
191
  }
192
192
  constructor(e, i, t) {
193
193
  let r = `${e} ${I(i, t)}`.trim();
194
- super(P.dedent`
194
+ super(O.dedent`
195
195
  CSF: ${e} ${I(i, t)}
196
196
 
197
197
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -203,7 +203,7 @@ var I = /* @__PURE__ */ f((s, e) => {
203
203
  }
204
204
  constructor(e, i, t) {
205
205
  let r = "".trim();
206
- super(P.dedent`
206
+ super(O.dedent`
207
207
  CSF: ${e} ${I(i, t)}
208
208
 
209
209
  More info: https://storybook.js.org/docs/writing-stories#default-export
@@ -224,12 +224,12 @@ var I = /* @__PURE__ */ f((s, e) => {
224
224
  f(this, "CsfFile");
225
225
  }
226
226
  _parseTitle(e) {
227
- let i = c.isIdentifier(e) ? O(e.name, this._ast.program) : e;
227
+ let i = c.isIdentifier(e) ? P(e.name, this._ast.program) : e;
228
228
  if (c.isStringLiteral(i))
229
229
  return i.value;
230
230
  if (c.isTSSatisfiesExpression(i) && c.isStringLiteral(i.expression))
231
231
  return i.expression.value;
232
- throw new Error(P.dedent`
232
+ throw new Error(O.dedent`
233
233
  CSF: unexpected dynamic title ${I(i, this._options.fileName)}
234
234
 
235
235
  More info: https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#string-literal-titles
@@ -261,7 +261,7 @@ var I = /* @__PURE__ */ f((s, e) => {
261
261
  t.component = l;
262
262
  } else if (r.key.name === "tags") {
263
263
  let o = r.value;
264
- c.isIdentifier(o) && (o = O(o.name, this._ast.program)), t.tags = le(o);
264
+ c.isIdentifier(o) && (o = P(o.name, this._ast.program)), t.tags = le(o);
265
265
  } else if (r.key.name === "id")
266
266
  if (c.isStringLiteral(r.value))
267
267
  t.id = r.value.value;
@@ -391,7 +391,7 @@ var I = /* @__PURE__ */ f((s, e) => {
391
391
  }
392
392
  }) : r.specifiers.length > 0 && r.specifiers.forEach((a) => {
393
393
  if (c.isExportSpecifier(a) && c.isIdentifier(a.exported)) {
394
- let { name: p } = a.exported, { name: d } = a.local, g = c.isProgram(o) ? O(a.local.name, o) : a.local;
394
+ let { name: p } = a.exported, { name: d } = a.local, g = c.isProgram(o) ? P(a.local.name, o) : a.local;
395
395
  if (p === "default") {
396
396
  let x;
397
397
  c.isObjectExpression(g) ? x = g : (
@@ -431,7 +431,7 @@ var I = /* @__PURE__ */ f((s, e) => {
431
431
  enter(t) {
432
432
  let { node: r } = t, { callee: o } = r;
433
433
  if (c.isIdentifier(o) && o.name === "storiesOf")
434
- throw new Error(P.dedent`
434
+ throw new Error(O.dedent`
435
435
  Unexpected \`storiesOf\` usage: ${I(r, e._options.fileName)}.
436
436
 
437
437
  SB8 does not support \`storiesOf\`.
@@ -474,7 +474,7 @@ var I = /* @__PURE__ */ f((s, e) => {
474
474
  r === "__page" && (i.length === 1 || Array.isArray(p) && p.length === 1) && (a.docsOnly = !0), t[r] = { ...o, id: l, parameters: a };
475
475
  let d = e._storyAnnotations[r], { tags: g, play: x } = d;
476
476
  if (g) {
477
- let h = c.isIdentifier(g) ? O(g.name, this._ast.program) : g;
477
+ let h = c.isIdentifier(g) ? P(g.name, this._ast.program) : g;
478
478
  t[r].tags = le(h);
479
479
  }
480
480
  x && (t[r].tags = [...t[r].tags || [], "play-fn"]);
@@ -512,7 +512,7 @@ var I = /* @__PURE__ */ f((s, e) => {
512
512
  let { fileName: e } = this._options;
513
513
  if (!e)
514
514
  throw new Error(
515
- P.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
515
+ O.dedent`Cannot automatically create index inputs with CsfFile.indexInputs because the CsfFile instance was created without a the fileName option.
516
516
  Either add the fileName option when creating the CsfFile instance, or create the index inputs manually.`
517
517
  );
518
518
  return Object.entries(this._stories).map(([i, t]) => {
@@ -1117,7 +1117,7 @@ Se = /* @__PURE__ */ f((s) => {
1117
1117
  let i = L(s);
1118
1118
  if (E.isObjectExpression(i)) {
1119
1119
  let t = ee(i, "parameters");
1120
- if (E.isIdentifier(t) && (t = O(t.name, e)), t)
1120
+ if (E.isIdentifier(t) && (t = P(t.name, e)), t)
1121
1121
  return Se(t);
1122
1122
  } else
1123
1123
  F("default", !0);
@@ -1144,7 +1144,7 @@ Se = /* @__PURE__ */ f((s) => {
1144
1144
  ExportDefaultDeclaration: {
1145
1145
  enter({ node: t }) {
1146
1146
  let r = t.declaration;
1147
- E.isIdentifier(r) && (r = O(r.name, i.program)), r = L(r), E.isCallExpression(r) && E.isObjectExpression(r.arguments?.[0]) ? e = _e(
1147
+ E.isIdentifier(r) && (r = P(r.name, i.program)), r = L(r), E.isCallExpression(r) && E.isObjectExpression(r.arguments?.[0]) ? e = _e(
1148
1148
  r.arguments[0], i.program) : E.isObjectExpression(r) ? e = _e(r, i.program) : F("default", !1);
1149
1149
  }
1150
1150
  }
@@ -1168,7 +1168,7 @@ Se = /* @__PURE__ */ f((s) => {
1168
1168
  import { generate as ft, types as u } from "storybook/internal/babel";
1169
1169
  var dt = /* @__PURE__ */ f((s, e, i, t) => {
1170
1170
  let r = e.getStoryExport(i), o = u.isCallExpression(r) && u.isMemberExpression(r.callee) && u.isIdentifier(r.callee.object) && r.callee.object.
1171
- name === "meta", l = !t?.disableSource && ut(r), a = !t?.disableDescription && Pe(e._storyStatements[i]), p = [], d = o ? u.memberExpression(
1171
+ name === "meta", l = !t?.disableSource && ut(r), a = !t?.disableDescription && Oe(e._storyStatements[i]), p = [], d = o ? u.memberExpression(
1172
1172
  u.identifier(i), u.identifier("input")) : u.identifier(i), g = u.memberExpression(d, u.identifier("parameters"));
1173
1173
  p.push(u.spreadElement(g));
1174
1174
  let x = u.optionalMemberExpression(
@@ -1223,7 +1223,7 @@ var dt = /* @__PURE__ */ f((s, e, i, t) => {
1223
1223
  );
1224
1224
  s._ast.program.body.push(y);
1225
1225
  }
1226
- }, "enrichCsfStory"), Oe = /* @__PURE__ */ f((s, e, i) => {
1226
+ }, "enrichCsfStory"), Pe = /* @__PURE__ */ f((s, e, i) => {
1227
1227
  if (!e.length) {
1228
1228
  s.properties.find(
1229
1229
  (p) => u.isObjectProperty(p) && u.isIdentifier(p.key) && p.key.name === "component"
@@ -1233,12 +1233,12 @@ var dt = /* @__PURE__ */ f((s, e, i, t) => {
1233
1233
  let [t, ...r] = e, o = s.properties.find(
1234
1234
  (a) => u.isObjectProperty(a) && u.isIdentifier(a.key) && a.key.name === t && u.isObjectExpression(a.value)
1235
1235
  ), l;
1236
- o ? l = o.value : (l = u.objectExpression([]), s.properties.push(u.objectProperty(u.identifier(t), l))), Oe(l, r, i);
1236
+ o ? l = o.value : (l = u.objectExpression([]), s.properties.push(u.objectProperty(u.identifier(t), l))), Pe(l, r, i);
1237
1237
  }, "addComponentDescription"), mt = /* @__PURE__ */ f((s, e, i) => {
1238
- let t = !i?.disableDescription && Pe(e._metaStatement);
1238
+ let t = !i?.disableDescription && Oe(e._metaStatement);
1239
1239
  if (t) {
1240
1240
  let r = s._metaNode;
1241
- r && u.isObjectExpression(r) && Oe(
1241
+ r && u.isObjectExpression(r) && Pe(
1242
1242
  r,
1243
1243
  ["parameters", "docs", "description"],
1244
1244
  u.objectProperty(u.identifier("component"), u.stringLiteral(t))
@@ -1251,7 +1251,7 @@ var dt = /* @__PURE__ */ f((s, e, i, t) => {
1251
1251
  }, "enrichCsf"), ut = /* @__PURE__ */ f((s) => {
1252
1252
  let e = u.isVariableDeclarator(s) ? s.init : s, { code: i } = ft(e, {});
1253
1253
  return i;
1254
- }, "extractSource"), Pe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((i) => i.type === "CommentLine" || !i.value.startsWith(
1254
+ }, "extractSource"), Oe = /* @__PURE__ */ f((s) => s?.leadingComments ? s.leadingComments.map((i) => i.type === "CommentLine" || !i.value.startsWith(
1255
1255
  "*") ? null : i.value.split(`
1256
1256
  `).map((t) => t.replace(/^(\s+)?(\*+)?(\s)?/, "")).join(`
1257
1257
  `).trim()).filter(Boolean).join(`
@@ -1349,10 +1349,12 @@ le an issue with details about your use case.`
1349
1349
  v
1350
1350
  ), M = m.callExpression(
1351
1351
  m.memberExpression(
1352
- m.memberExpression(
1353
- m.memberExpression(m.identifier("import"), m.identifier("meta")),
1354
- m.identifier("url")
1355
- ),
1352
+ m.callExpression(m.identifier("convertToFilePath"), [
1353
+ m.memberExpression(
1354
+ m.memberExpression(m.identifier("import"), m.identifier("meta")),
1355
+ m.identifier("url")
1356
+ )
1357
+ ]),
1356
1358
  m.identifier("includes")
1357
1359
  ),
1358
1360
  [T]
@@ -1407,7 +1409,10 @@ le an issue with details about your use case.`
1407
1409
  m.stringLiteral("vitest")
1408
1410
  ),
1409
1411
  m.importDeclaration(
1410
- [m.importSpecifier(S, m.identifier("testStory"))],
1412
+ [
1413
+ m.importSpecifier(S, m.identifier("testStory")),
1414
+ m.importSpecifier(m.identifier("convertToFilePath"), m.identifier("convertToFilePath"))
1415
+ ],
1411
1416
  m.stringLiteral("@storybook/addon-vitest/internal/test-utils")
1412
1417
  )
1413
1418
  ];
@@ -1428,7 +1433,7 @@ export {
1428
1433
  Kt as enrichCsf,
1429
1434
  mt as enrichCsfMeta,
1430
1435
  dt as enrichCsfStory,
1431
- Pe as extractDescription,
1436
+ Oe as extractDescription,
1432
1437
  ut as extractSource,
1433
1438
  ot as formatConfig,
1434
1439
  me as formatCsf,