storybook 10.0.0-beta.5 → 10.0.0-beta.7

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 (88) hide show
  1. package/assets/server/openBrowser.applescript +94 -0
  2. package/dist/_browser-chunks/{WithTooltip-ERFLZL6W.js → WithTooltip-SK46ZJ2J.js} +1 -1
  3. package/dist/_browser-chunks/{chunk-EOILZP2R.js → chunk-BOOOPFZF.js} +7 -2
  4. package/dist/_browser-chunks/{chunk-YQV3EGQ5.js → chunk-OQ6NCFPL.js} +38 -15
  5. package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
  6. package/dist/_node-chunks/{builder-manager-ZTS4EIKQ.js → builder-manager-VFP7HSCF.js} +21 -151
  7. package/dist/_node-chunks/camelcase-ZLZNQMDD.js +18 -0
  8. package/dist/_node-chunks/{chunk-VQN4WAIA.js → chunk-2GCKJYK6.js} +7 -7
  9. package/dist/_node-chunks/{chunk-H52PBBSK.js → chunk-3NIQHNDU.js} +7 -7
  10. package/dist/_node-chunks/{chunk-3VVGIILJ.js → chunk-3QZ7KLON.js} +8 -8
  11. package/dist/_node-chunks/{chunk-VWSUFVUF.js → chunk-3XXQRL3A.js} +7 -7
  12. package/dist/_node-chunks/{chunk-OC3TVLYU.js → chunk-46BWYN3K.js} +7 -7
  13. package/dist/_node-chunks/{chunk-VX5P3IYA.js → chunk-4DIDWIST.js} +7 -7
  14. package/dist/_node-chunks/{chunk-TBWOUVTA.js → chunk-5YUTWYNI.js} +709 -935
  15. package/dist/_node-chunks/{chunk-4VDRH7SM.js → chunk-A2DKPKBY.js} +7 -7
  16. package/dist/_node-chunks/{chunk-KU3JBNPY.js → chunk-BC23FKU4.js} +8 -8
  17. package/dist/_node-chunks/{chunk-KZB7ELL6.js → chunk-BID2X7MU.js} +7 -7
  18. package/dist/_node-chunks/{chunk-PIKDGR3O.js → chunk-C4EOB63P.js} +7 -7
  19. package/dist/_node-chunks/{chunk-TVKUJ3SE.js → chunk-DH7BCQMG.js} +8 -8
  20. package/dist/_node-chunks/{chunk-J3DQMIO4.js → chunk-FCNWWJV7.js} +7 -7
  21. package/dist/_node-chunks/{chunk-EIHJ5J3O.js → chunk-GBZZSL2K.js} +264 -109
  22. package/dist/_node-chunks/{chunk-F7YW5W6B.js → chunk-GCWAGPDV.js} +12 -12
  23. package/dist/_node-chunks/{chunk-K4YETNYJ.js → chunk-I7SRMFT5.js} +7 -7
  24. package/dist/_node-chunks/{chunk-TKN5TEZV.js → chunk-IEFSRAX2.js} +13 -13
  25. package/dist/_node-chunks/{chunk-AK5PHLUA.js → chunk-IGWCAXA2.js} +7 -7
  26. package/dist/_node-chunks/chunk-IYOHZPPC.js +18 -0
  27. package/dist/_node-chunks/{chunk-F3WE3456.js → chunk-KVOP6ASA.js} +7 -7
  28. package/dist/_node-chunks/{chunk-DZJNLBBL.js → chunk-MHVF6Y35.js} +7 -7
  29. package/dist/_node-chunks/{chunk-UTCFHTQH.js → chunk-MRCMZPA2.js} +7 -7
  30. package/dist/_node-chunks/chunk-RNHUADRS.js +62 -0
  31. package/dist/_node-chunks/{chunk-4KRR46V2.js → chunk-RP3VMQPF.js} +15 -15
  32. package/dist/_node-chunks/{chunk-P7YMEOXF.js → chunk-TFIGR2HH.js} +7 -7
  33. package/dist/_node-chunks/{chunk-SW3VZAH7.js → chunk-TXDIOSHI.js} +9 -9
  34. package/dist/_node-chunks/{chunk-WCSHG2QT.js → chunk-U6MJQ7C6.js} +7 -7
  35. package/dist/_node-chunks/{chunk-ACUNHBEO.js → chunk-XXVKM2ZR.js} +26 -23
  36. package/dist/_node-chunks/{chunk-QHIU5I7C.js → chunk-YWU65VY4.js} +6 -6
  37. package/dist/_node-chunks/{chunk-P3TWEOO5.js → chunk-Z3PLI7S2.js} +7 -7
  38. package/dist/_node-chunks/{chunk-2VMDKLSW.js → chunk-ZM2HT2RW.js} +6 -6
  39. package/dist/_node-chunks/{chunk-D7SDB4XE.js → chunk-ZPNXCXIT.js} +8 -8
  40. package/dist/_node-chunks/{dist-OGRBL76N.js → dist-PG4I7ZDU.js} +9 -9
  41. package/dist/_node-chunks/{globby-65LOULA6.js → globby-HXB6X43W.js} +17 -13
  42. package/dist/_node-chunks/{lib-TF7JCT3A.js → lib-4JJTZC7T.js} +7 -7
  43. package/dist/_node-chunks/{mdx-N42X6CFJ-6ZJEUZMZ.js → mdx-N42X6CFJ-3JBJ7PQF.js} +8 -8
  44. package/dist/_node-chunks/{p-limit-PF7JSPDT.js → p-limit-WBBNX4KI.js} +7 -7
  45. package/dist/_node-chunks/{plugin-A6XAWMXN.js → plugin-SEQ2OPRK.js} +10 -10
  46. package/dist/_node-chunks/{plugin-LGHGAC6J.js → plugin-SG6I7RFC.js} +10 -10
  47. package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-HDSEOU3Z.js → webpack-inject-mocker-runtime-plugin-5O25VYCQ.js} +10 -10
  48. package/dist/_node-chunks/{webpack-mock-plugin-ZJJVMJUS.js → webpack-mock-plugin-35I32SAF.js} +9 -9
  49. package/dist/babel/index.js +11 -11
  50. package/dist/bin/core.js +11 -11
  51. package/dist/bin/dispatcher.js +11 -11
  52. package/dist/bin/loader.js +8 -8
  53. package/dist/cli/index.js +27 -22
  54. package/dist/common/index.js +21 -21
  55. package/dist/components/index.js +8 -4
  56. package/dist/core-events/index.d.ts +18 -2
  57. package/dist/core-events/index.js +7 -1
  58. package/dist/core-server/index.js +1157 -1024
  59. package/dist/core-server/presets/common-manager.js +84 -39
  60. package/dist/core-server/presets/common-override-preset.js +9 -9
  61. package/dist/core-server/presets/common-preset.js +691 -29
  62. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -9
  63. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -10
  64. package/dist/csf/index.d.ts +9 -4
  65. package/dist/csf/index.js +37 -8
  66. package/dist/csf-tools/index.d.ts +13 -6
  67. package/dist/csf-tools/index.js +9 -9
  68. package/dist/manager/globals-runtime.js +1318 -1001
  69. package/dist/manager/globals.d.ts +0 -4
  70. package/dist/manager/globals.js +1 -6
  71. package/dist/manager/runtime.js +2198 -721
  72. package/dist/manager-api/index.d.ts +12 -5
  73. package/dist/manager-api/index.js +347 -76
  74. package/dist/node-logger/index.js +14 -14
  75. package/dist/preview/runtime.js +103 -63
  76. package/dist/preview-api/index.d.ts +70 -71
  77. package/dist/preview-api/index.js +1 -1
  78. package/dist/server-errors.js +10 -10
  79. package/dist/telemetry/index.d.ts +1 -1
  80. package/dist/telemetry/index.js +24 -24
  81. package/dist/types/index.d.ts +28 -7
  82. package/dist/viewport/index.d.ts +36 -4
  83. package/dist/viewport/index.js +1 -1
  84. package/package.json +5 -4
  85. package/dist/_node-chunks/camelcase-K3BM7RII.js +0 -18
  86. package/dist/_node-chunks/chunk-7LG5CLCT.js +0 -18
  87. package/dist/_node-chunks/chunk-DWJ7TV2O.js +0 -62
  88. package/dist/_node-chunks/default-browser-id-4RZZMHJE.js +0 -1719
@@ -1,21 +1,21 @@
1
- import CJS_COMPAT_NODE_URL_0oz6lpav6bgq from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0oz6lpav6bgq from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0oz6lpav6bgq from "node:module";
1
+ import CJS_COMPAT_NODE_URL_srln17sp2zh from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_srln17sp2zh from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_srln17sp2zh from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0oz6lpav6bgq.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0oz6lpav6bgq.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0oz6lpav6bgq.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_srln17sp2zh.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_srln17sp2zh.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_srln17sp2zh.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
13
  rewriteSbMockImportCalls
14
- } from "../../../../_node-chunks/chunk-3VVGIILJ.js";
15
- import "../../../../_node-chunks/chunk-4VDRH7SM.js";
14
+ } from "../../../../_node-chunks/chunk-3QZ7KLON.js";
15
+ import "../../../../_node-chunks/chunk-A2DKPKBY.js";
16
16
  import {
17
17
  __name
18
- } from "../../../../_node-chunks/chunk-2VMDKLSW.js";
18
+ } from "../../../../_node-chunks/chunk-ZM2HT2RW.js";
19
19
 
20
20
  // src/core-server/presets/webpack/loaders/storybook-mock-transform-loader.ts
21
21
  import { logger } from "storybook/internal/node-logger";
@@ -1,24 +1,24 @@
1
- import CJS_COMPAT_NODE_URL_0oz6lpav6bgq from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0oz6lpav6bgq from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0oz6lpav6bgq from "node:module";
1
+ import CJS_COMPAT_NODE_URL_srln17sp2zh from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_srln17sp2zh from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_srln17sp2zh from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0oz6lpav6bgq.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0oz6lpav6bgq.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0oz6lpav6bgq.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_srln17sp2zh.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_srln17sp2zh.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_srln17sp2zh.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
13
  getAutomockCode
14
- } from "../../../../_node-chunks/chunk-K4YETNYJ.js";
14
+ } from "../../../../_node-chunks/chunk-I7SRMFT5.js";
15
15
  import {
16
16
  babelParser
17
- } from "../../../../_node-chunks/chunk-3VVGIILJ.js";
18
- import "../../../../_node-chunks/chunk-4VDRH7SM.js";
17
+ } from "../../../../_node-chunks/chunk-3QZ7KLON.js";
18
+ import "../../../../_node-chunks/chunk-A2DKPKBY.js";
19
19
  import {
20
20
  __name
21
- } from "../../../../_node-chunks/chunk-2VMDKLSW.js";
21
+ } from "../../../../_node-chunks/chunk-ZM2HT2RW.js";
22
22
 
23
23
  // src/core-server/presets/webpack/loaders/webpack-automock-loader.ts
24
24
  function webpackAutomockLoader(source) {
@@ -1,4 +1,4 @@
1
- import { StorybookTypes, Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, NormalizedProjectAnnotations, Args as Args$1, ComponentAnnotations as ComponentAnnotations$1, StoryAnnotations as StoryAnnotations$1, ComposedStoryFn } from 'storybook/internal/types';
1
+ import { StorybookTypes, Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, NormalizedProjectAnnotations, Args as Args$1, ComponentAnnotations as ComponentAnnotations$1, StoryAnnotations as StoryAnnotations$1, ComposedStoryFn, TestFunction as TestFunction$1 } from 'storybook/internal/types';
2
2
  import { AddonTypes as AddonTypes$1, StoryContext as StoryContext$1 } from 'storybook/internal/csf';
3
3
 
4
4
  declare global {
@@ -758,6 +758,7 @@ interface PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Arg
758
758
  type StepLabel = string;
759
759
  type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>) => Promise<void> | void;
760
760
  type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void> | void;
761
+ type TestFunction<TRenderer extends Renderer = Renderer, TArgs = TRenderer['args']> = (context: StoryContext<TRenderer, TArgs>) => Promise<void> | void;
761
762
  type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
762
763
  type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
763
764
  type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
@@ -992,12 +993,14 @@ interface Story<TRenderer extends Renderer$1, TInput extends StoryAnnotations$1<
992
993
  name: string;
993
994
  };
994
995
  meta: Meta<TRenderer>;
995
- __compose: () => ComposedStoryFn<TRenderer>;
996
996
  play: TInput['play'];
997
- run: (context?: Partial<StoryContext$1<TRenderer, Partial<TRenderer['args']>>>) => Promise<void>;
997
+ run: (context?: Partial<StoryContext$1<TRenderer, Partial<TRenderer['args']>>>, testName?: string) => Promise<void>;
998
998
  extend<TInput extends StoryAnnotations$1<TRenderer, TRenderer['args']>>(input: TInput): Story<TRenderer, TInput>;
999
+ test(name: string, fn: TestFunction$1<TRenderer>): void;
1000
+ test(name: string, annotations: StoryAnnotations$1<TRenderer, TRenderer['args']>, fn: TestFunction$1<TRenderer>): void;
999
1001
  }
1000
1002
  declare function isStory<TRenderer extends Renderer$1>(input: unknown): input is Story<TRenderer>;
1003
+ declare function getStoryChildren<TRenderer extends Renderer$1>(story: Story<TRenderer>): Story<TRenderer>[];
1001
1004
 
1002
1005
  /**
1003
1006
  * Remove punctuation and illegal characters from a story ID.
@@ -1007,6 +1010,8 @@ declare function isStory<TRenderer extends Renderer$1>(input: unknown): input is
1007
1010
  declare const sanitize: (string: string) => string;
1008
1011
  /** Generate a storybook ID from a component/kind and story name. */
1009
1012
  declare const toId: (kind: string, name?: string) => string;
1013
+ /** Generate a storybook test ID from a story ID and test name. */
1014
+ declare const toTestId: (parentId: string, testName: string) => string;
1010
1015
  /** Transform a CSF named export into a readable story name */
1011
1016
  declare const storyNameFromExport: (key: string) => string;
1012
1017
  type StoryDescriptor = string[] | RegExp;
@@ -1028,4 +1033,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
1028
1033
  /** Combine a set of project / meta / story tags, removing duplicates and handling negations. */
1029
1034
  declare const combineTags: (...tags: string[]) => string[];
1030
1035
 
1031
- export { type AddonTypes, type AfterEach, type AnnotatedStoryFn, type AnyFramework, type ArgTypes, type ArgTypesEnhancer, type Args, type ArgsEnhancer, type ArgsFromMeta, type ArgsStoryFn, type BaseAnnotations, type BeforeAll, type BeforeEach, type Canvas, type CleanupCallback, type ComponentAnnotations, type ComponentId, type ComponentTitle, type Conditional, type CoreTypes, type DecoratorApplicator, type DecoratorFunction, type GlobalTypes, type Globals, type IncludeExcludeOptions, type InferTypes, type InputType, type LegacyAnnotatedStoryFn, type LegacyStoryAnnotationsOrFn, type LegacyStoryFn, type LoaderFunction, type Meta, type Parameters, type PartialStoryFn, type PlayFunction, type PlayFunctionContext, type Preview, type PreviewAddon, type ProjectAnnotations, type Renderer, type SBArrayType, type SBEnumType, type SBIntersectionType, type SBObjectType, type SBOtherType, type SBScalarType, type SBType, type SBUnionType, type SeparatorOptions, type StepFunction, type StepLabel, type StepRunner, type Story, type StoryAnnotations, type StoryAnnotationsOrFn, type StoryContext, type StoryContextForEnhancers, type StoryContextForLoaders, type StoryContextUpdate, type StoryFn, type StoryId, type StoryIdentifier, type StoryKind, type StoryName, type StrictArgTypes, type StrictArgs, type StrictGlobalTypes, type StrictInputType, type StrictParameters, type Tag, type ViewMode, combineTags, definePreview, definePreviewAddon, getCoreAnnotations, includeConditionalArg, isExportStory, isMeta, isPreview, isStory, parseKind, sanitize, storyNameFromExport, toId };
1036
+ export { type AddonTypes, type AfterEach, type AnnotatedStoryFn, type AnyFramework, type ArgTypes, type ArgTypesEnhancer, type Args, type ArgsEnhancer, type ArgsFromMeta, type ArgsStoryFn, type BaseAnnotations, type BeforeAll, type BeforeEach, type Canvas, type CleanupCallback, type ComponentAnnotations, type ComponentId, type ComponentTitle, type Conditional, type CoreTypes, type DecoratorApplicator, type DecoratorFunction, type GlobalTypes, type Globals, type IncludeExcludeOptions, type InferTypes, type InputType, type LegacyAnnotatedStoryFn, type LegacyStoryAnnotationsOrFn, type LegacyStoryFn, type LoaderFunction, type Meta, type Parameters, type PartialStoryFn, type PlayFunction, type PlayFunctionContext, type Preview, type PreviewAddon, type ProjectAnnotations, type Renderer, type SBArrayType, type SBEnumType, type SBIntersectionType, type SBObjectType, type SBOtherType, type SBScalarType, type SBType, type SBUnionType, type SeparatorOptions, type StepFunction, type StepLabel, type StepRunner, type Story, type StoryAnnotations, type StoryAnnotationsOrFn, type StoryContext, type StoryContextForEnhancers, type StoryContextForLoaders, type StoryContextUpdate, type StoryFn, type StoryId, type StoryIdentifier, type StoryKind, type StoryName, type StrictArgTypes, type StrictArgs, type StrictGlobalTypes, type StrictInputType, type StrictParameters, type Tag, type TestFunction, type ViewMode, combineTags, definePreview, definePreviewAddon, getCoreAnnotations, getStoryChildren, includeConditionalArg, isExportStory, isMeta, isPreview, isStory, parseKind, sanitize, storyNameFromExport, toId, toTestId };
package/dist/csf/index.js CHANGED
@@ -7,9 +7,10 @@ import {
7
7
  import {
8
8
  composeConfigs,
9
9
  composeStory,
10
+ mountDestructured,
10
11
  normalizeArrays,
11
12
  normalizeProjectAnnotations
12
- } from "../_browser-chunks/chunk-YQV3EGQ5.js";
13
+ } from "../_browser-chunks/chunk-OQ6NCFPL.js";
13
14
  import "../_browser-chunks/chunk-LYCSRYYR.js";
14
15
  import "../_browser-chunks/chunk-Y3M7TW6K.js";
15
16
  import {
@@ -2434,9 +2435,6 @@ function defineMeta(input, preview) {
2434
2435
  _tag: "Meta",
2435
2436
  input,
2436
2437
  preview,
2437
- get composed() {
2438
- throw new Error("Not implemented");
2439
- },
2440
2438
  // @ts-expect-error hard
2441
2439
  story(story = {}) {
2442
2440
  return defineStory(typeof story === "function" ? { render: story } : story, this);
@@ -2461,11 +2459,14 @@ function defineStory(input, meta) {
2461
2459
  }
2462
2460
  return composed;
2463
2461
  }, "compose");
2462
+ const __children = [];
2464
2463
  return {
2465
2464
  _tag: "Story",
2466
2465
  input,
2467
2466
  meta,
2467
+ // @ts-expect-error this is a private property used only once in renderers/react/src/preview
2468
2468
  __compose: compose,
2469
+ __children,
2469
2470
  get composed() {
2470
2471
  const composed2 = compose();
2471
2472
  const { args, argTypes, parameters: parameters2, id, tags, globals, storyName: name } = composed2;
@@ -2475,16 +2476,34 @@ function defineStory(input, meta) {
2475
2476
  return input.play ?? meta.input?.play ?? (async () => {
2476
2477
  });
2477
2478
  },
2478
- get run() {
2479
- return compose().run ?? (async () => {
2479
+ async run(context) {
2480
+ await compose().run(context);
2481
+ },
2482
+ test(name, overridesOrTestFn, testFn) {
2483
+ const annotations = typeof overridesOrTestFn !== "function" ? overridesOrTestFn : {};
2484
+ const testFunction = typeof overridesOrTestFn !== "function" ? testFn : overridesOrTestFn;
2485
+ const play = mountDestructured(this.play) || mountDestructured(testFunction) ? async ({ context }) => {
2486
+ await this.play?.(context);
2487
+ await testFunction(context);
2488
+ } : async (context) => {
2489
+ await this.play?.(context);
2490
+ await testFunction(context);
2491
+ };
2492
+ const test = this.extend({
2493
+ ...annotations,
2494
+ name,
2495
+ tags: ["test-fn", "!autodocs", ...annotations.tags ?? []],
2496
+ play
2480
2497
  });
2498
+ __children.push(test);
2499
+ return test;
2481
2500
  },
2482
2501
  extend(input2) {
2483
2502
  return defineStory(
2484
2503
  {
2485
2504
  ...this.input,
2486
2505
  ...input2,
2487
- args: { ...this.input.args, ...input2.args },
2506
+ args: { ...this.input.args || {}, ...input2.args },
2488
2507
  argTypes: combineParameters(this.input.argTypes, input2.argTypes),
2489
2508
  afterEach: [
2490
2509
  ...normalizeArrays(this.input?.afterEach ?? []),
@@ -2512,6 +2531,13 @@ function defineStory(input, meta) {
2512
2531
  };
2513
2532
  }
2514
2533
  __name(defineStory, "defineStory");
2534
+ function getStoryChildren(story) {
2535
+ if ("__children" in story) {
2536
+ return story.__children;
2537
+ }
2538
+ return [];
2539
+ }
2540
+ __name(getStoryChildren, "getStoryChildren");
2515
2541
 
2516
2542
  // src/csf/index.ts
2517
2543
  var sanitize = /* @__PURE__ */ __name((string) => {
@@ -2525,6 +2551,7 @@ var sanitizeSafe = /* @__PURE__ */ __name((string, part) => {
2525
2551
  return sanitized;
2526
2552
  }, "sanitizeSafe");
2527
2553
  var toId = /* @__PURE__ */ __name((kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`, "toId");
2554
+ var toTestId = /* @__PURE__ */ __name((parentId, testName) => `${parentId}:${sanitizeSafe(testName, "test")}`, "toTestId");
2528
2555
  var storyNameFromExport = /* @__PURE__ */ __name((key) => toStartCaseStr(key), "storyNameFromExport");
2529
2556
  function matches(storyKey, arrayOrRegex) {
2530
2557
  if (Array.isArray(arrayOrRegex)) {
@@ -2564,6 +2591,7 @@ export {
2564
2591
  definePreview,
2565
2592
  definePreviewAddon9 as definePreviewAddon,
2566
2593
  getCoreAnnotations,
2594
+ getStoryChildren,
2567
2595
  includeConditionalArg,
2568
2596
  isExportStory,
2569
2597
  isMeta,
@@ -2572,5 +2600,6 @@ export {
2572
2600
  parseKind,
2573
2601
  sanitize,
2574
2602
  storyNameFromExport,
2575
- toId
2603
+ toId,
2604
+ toTestId
2576
2605
  };
@@ -49,6 +49,16 @@ interface StaticStory extends Pick<StoryAnnotations, 'name' | 'parameters' | 'ta
49
49
  localName?: string;
50
50
  __stats: IndexInputStats;
51
51
  }
52
+ interface StoryTest {
53
+ node: types.Node;
54
+ function: types.Node;
55
+ name: string;
56
+ id: string;
57
+ tags: string[];
58
+ parent: {
59
+ node: types.Node;
60
+ };
61
+ }
52
62
  declare class CsfFile {
53
63
  _ast: types.File;
54
64
  _file: BabelFile;
@@ -69,6 +79,7 @@ declare class CsfFile {
69
79
  _templates: Record<string, types.Expression>;
70
80
  _namedExportsOrder?: string[];
71
81
  imports: string[];
82
+ _tests: StoryTest[];
72
83
  constructor(ast: types.File, options: CsfOptions, file: BabelFile);
73
84
  _parseTitle(value: types.Node): string;
74
85
  _parseMeta(declaration: types.ObjectExpression, program: types.Program): void;
@@ -76,6 +87,7 @@ declare class CsfFile {
76
87
  parse(): CsfFile & IndexedCSFFile;
77
88
  get meta(): StaticMeta | undefined;
78
89
  get stories(): StaticStory[];
90
+ getStoryTests(story: string | types.Node): StoryTest[];
79
91
  get indexInputs(): IndexInput[];
80
92
  }
81
93
  /** Using new babel.File is more powerful and give access to API such as buildCodeFrameError */
@@ -263,11 +275,6 @@ type TagsFilter = {
263
275
  exclude: string[];
264
276
  skip: string[];
265
277
  };
266
- /**
267
- * TODO: the functionality in this file can be moved back to the vitest plugin itself It can use
268
- * `storybook/internal/babel` for all it's babel needs, without duplicating babel embedding in our
269
- * bundles.
270
- */
271
278
  declare function vitestTransform({ code, fileName, configDir, stories, tagsFilter, previewLevelTags, }: {
272
279
  code: string;
273
280
  fileName: string;
@@ -277,4 +284,4 @@ declare function vitestTransform({ code, fileName, configDir, stories, tagsFilte
277
284
  previewLevelTags: Tag[];
278
285
  }): Promise<ReturnType<typeof formatCsf>>;
279
286
 
280
- export { BadMetaError, ConfigFile, CsfFile, type CsfOptions, type EnrichCsfOptions, MixedFactoryError, MultipleMetaError, NoMetaError, type StaticMeta, type StaticStory, babelParseFile, enrichCsf, enrichCsfMeta, enrichCsfStory, extractDescription, extractSource, formatConfig, formatCsf, getStorySortParameter, isCsfFactoryPreview, isModuleMock, isValidPreviewPath, loadConfig, loadCsf, printConfig, printCsf, readConfig, readCsf, vitestTransform, writeConfig, writeCsf };
287
+ export { BadMetaError, ConfigFile, CsfFile, type CsfOptions, type EnrichCsfOptions, MixedFactoryError, MultipleMetaError, NoMetaError, type StaticMeta, type StaticStory, type StoryTest, babelParseFile, enrichCsf, enrichCsfMeta, enrichCsfStory, extractDescription, extractSource, formatConfig, formatCsf, getStorySortParameter, isCsfFactoryPreview, isModuleMock, isValidPreviewPath, loadConfig, loadCsf, printConfig, printCsf, readConfig, readCsf, vitestTransform, writeConfig, writeCsf };
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_0oz6lpav6bgq from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0oz6lpav6bgq from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0oz6lpav6bgq from "node:module";
1
+ import CJS_COMPAT_NODE_URL_srln17sp2zh from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_srln17sp2zh from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_srln17sp2zh from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0oz6lpav6bgq.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0oz6lpav6bgq.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0oz6lpav6bgq.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_srln17sp2zh.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_srln17sp2zh.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_srln17sp2zh.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -38,9 +38,9 @@ import {
38
38
  vitestTransform,
39
39
  writeConfig,
40
40
  writeCsf
41
- } from "../_node-chunks/chunk-EIHJ5J3O.js";
42
- import "../_node-chunks/chunk-P7YMEOXF.js";
43
- import "../_node-chunks/chunk-2VMDKLSW.js";
41
+ } from "../_node-chunks/chunk-GBZZSL2K.js";
42
+ import "../_node-chunks/chunk-TFIGR2HH.js";
43
+ import "../_node-chunks/chunk-ZM2HT2RW.js";
44
44
  export {
45
45
  BadMetaError,
46
46
  ConfigFile,