diff --git a/MIGRATION.md b/MIGRATION.md
index d113f70da386..08676d51127a 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -14,6 +14,7 @@
- [Toolbar `globalTypes` entries: index signature and `defaultValue` removed](#toolbar-globaltypes-entries-index-signature-and-defaultvalue-removed)
- [Docs Code panel enabled by default](#docs-code-panel-enabled-by-default)
- [`argTypes` removed from loaders, `beforeEach`, `play` and `afterEach`](#argtypes-removed-from-loaders-beforeeach-play-and-aftereach)
+ - [Deprecated CSF and manager type aliases removed](#deprecated-csf-and-manager-type-aliases-removed)
- [`docgenServer` is stable and enabled by default](#docgenserver-is-stable-and-enabled-by-default)
- [Builder docgen is deprecated](#builder-docgen-is-deprecated)
- [Node.js 22.12 or higher](#nodejs-2212-or-higher)
@@ -947,6 +948,28 @@ export const Primary: Story = {
Decorators and `render` functions keep receiving `argTypes`, because renderers rely on them while rendering. Their context type is the new `StoryContextForRender`; the `StoryContext` type no longer declares `argTypes`. Custom decorator or render helpers that annotate their context parameter as `StoryContext` and read `argTypes` should switch to `StoryContextForRender`.
+### Deprecated CSF and manager type aliases removed
+
+The following deprecated type aliases and fields are removed. If your code imports any of them from `storybook` (via `storybook/internal/csf`, `storybook/internal/types`, or `storybook/manager-api`), switch to the supported replacement:
+
+| Deprecated | Replacement |
+| ------------------------ | ----------------------- |
+| `StoryKind` | `ComponentTitle` |
+| `StoryIdentifier.kind` | `StoryIdentifier.title` |
+| `StoryIdentifier.story` | `StoryIdentifier.name` |
+| `AnyFramework` | `Renderer` |
+| `StoryContextForLoaders` | `StoryContext` |
+| `PlayFunctionContext` | `StoryContext` |
+| `StoriesHash` | `IndexHash` |
+
+The deprecated `kind` and `story` fields are also gone from `Addon_AddStoryArgs`, `Addon_StoryApi`, and the legacy `setStories` payload type `SetStoriesStory` (the whole interface is removed). The `RenderContext` passed to `renderToCanvas` no longer contains `kind` or `story`; third-party renderers read `title` and `name` instead.
+
+`@storybook/addon-links`' deprecated `LinkTo` `kind` and `story` props are removed; use `title` and `name`. The `data-sb-kind` and `data-sb-story` HTML attributes are unchanged. The provider `StoryMapper` option is removed.
+
+Story context objects passed to loaders and play functions no longer carry the deprecated `kind` and `story` keys; read `title` and `name` instead. The same applies to the context passed to decorators and `render` functions: custom helpers that read `context.kind` or `context.story` must switch to `context.title` and `context.name`. The `extract()` output — the serialized stories that external tools such as the Chromatic CLI read — still includes the deprecated `kind` and `story` fields for compatibility, so tools reading the serialized output keep working.
+
+The manager resolves `SELECT_STORY` payloads from `storyId` or `title`/`name`, and still accepts the deprecated `kind`/`story` payload that composed Storybooks built with Storybook 10.x or earlier send, so cross-story links inside those refs keep navigating. A payload without any of those keys is ignored with a warning. Composed refs must publish a story index (`stories.json`); the v2 format is no longer accepted and the legacy `setStories` event is no longer read.
+
### `docgenServer` is stable and enabled by default
The `experimentalDocgenServer` feature is now `docgenServer`, and Storybook no longer reads the old name.
diff --git a/code/addons/a11y/src/components/VisionSimulator.stories.tsx b/code/addons/a11y/src/components/VisionSimulator.stories.tsx
index ec3972219667..59388551cb3c 100644
--- a/code/addons/a11y/src/components/VisionSimulator.stories.tsx
+++ b/code/addons/a11y/src/components/VisionSimulator.stories.tsx
@@ -1,4 +1,4 @@
-import type { PlayFunction, PlayFunctionContext } from 'storybook/internal/types';
+import type { PlayFunction } from 'storybook/internal/types';
import { ManagerContext } from 'storybook/manager-api';
import { expect, fn, screen } from 'storybook/test';
diff --git a/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx b/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx
index ba6e53203f60..12a4bb0cde0f 100644
--- a/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx
+++ b/code/addons/docs/src/blocks/blocks/ArgTypes.stories.tsx
@@ -1,5 +1,5 @@
/** Custom docs page: {@link ./ArgTypes.mdx} (attached via ``). */
-import type { PlayFunctionContext } from 'storybook/internal/csf';
+import type { StoryContext } from 'storybook/internal/csf';
import type { Meta, StoryObj } from '@storybook/react-vite';
@@ -133,7 +133,7 @@ const DOCGEN_TIMEOUT = { timeout: 5000 };
const findSubcomponentTabs = async (
canvas: Parameters>[0]['canvas'],
- step: PlayFunctionContext['step']
+ step: StoryContext['step']
) => {
let subcomponentATab: HTMLElement | null = null;
let subcomponentBTab: HTMLElement | null = null;
diff --git a/code/addons/docs/src/blocks/blocks/Controls.stories.tsx b/code/addons/docs/src/blocks/blocks/Controls.stories.tsx
index 6f469887fa84..9dcecaa027db 100644
--- a/code/addons/docs/src/blocks/blocks/Controls.stories.tsx
+++ b/code/addons/docs/src/blocks/blocks/Controls.stories.tsx
@@ -1,7 +1,7 @@
/** Custom docs page: {@link ./Controls.mdx} (attached via ``). */
import React from 'react';
-import type { PlayFunctionContext } from 'storybook/internal/csf';
+import type { StoryContext } from 'storybook/internal/csf';
import type { Meta, StoryObj } from '@storybook/react-vite';
@@ -103,7 +103,7 @@ const DOCGEN_TIMEOUT = { timeout: 5000 };
const findSubcomponentTabs = async (
canvas: ReturnType,
- step: PlayFunctionContext['step']
+ step: StoryContext['step']
) => {
let subcomponentATab: HTMLElement | null = null;
let subcomponentBTab: HTMLElement | null = null;
diff --git a/code/addons/docs/src/blocks/components/Story.stories.tsx b/code/addons/docs/src/blocks/components/Story.stories.tsx
index d6e15cc702fa..a4b5d8430585 100644
--- a/code/addons/docs/src/blocks/components/Story.stories.tsx
+++ b/code/addons/docs/src/blocks/components/Story.stories.tsx
@@ -6,7 +6,7 @@ import {
STORY_ARGS_UPDATED,
UPDATE_STORY_ARGS,
} from 'storybook/internal/core-events';
-import type { PlayFunctionContext } from 'storybook/internal/csf';
+import type { StoryContext } from 'storybook/internal/csf';
import type { ModuleExport, WebRenderer } from 'storybook/internal/types';
import type { Meta, ReactRenderer, StoryObj } from '@storybook/react-vite';
@@ -97,7 +97,7 @@ export const ForceInitialArgs = {
chromatic: { disableSnapshot: true },
},
// test that it ignores updated args by emitting an arg update and assert that it isn't reflected in the DOM
- play: async ({ args, canvasElement, loaded }: PlayFunctionContext) => {
+ play: async ({ args, canvasElement, loaded }: StoryContext) => {
const docsContext = loaded.docsContext as DocsContextProps;
const resolved = docsContext.resolveOf(args.storyExport, ['story']);
diff --git a/code/addons/links/README.md b/code/addons/links/README.md
index 0192e4d55e5c..75b5711d01ca 100644
--- a/code/addons/links/README.md
+++ b/code/addons/links/README.md
@@ -70,9 +70,9 @@ export const index = () => (
);
-export const first = () => Go back;
-export const second = () => Go back;
-export const third = () => Go back;
+export const first = () => Go back;
+export const second = () => Go back;
+export const third = () => Go back;
```
## hrefTo function
@@ -141,18 +141,17 @@ export default {
title: 'Link',
};
-export const first = () => Go to Second;
-export const second = () => Go to First;
+export const first = () => Go to Second;
+export const second = () => Go to First;
```
-It accepts all the props the `a` element does, plus `story` and `kind`. It the `kind` prop is omitted, the current kind will be preserved.
+It accepts all the props the `a` element does, plus `title` and `name`. If the `title` prop is omitted, the current component's title will be used.
```mdx
Go to Second
diff --git a/code/addons/links/src/react/components/link.tsx b/code/addons/links/src/react/components/link.tsx
index 9e3930c3b30c..e86aec6a16c1 100644
--- a/code/addons/links/src/react/components/link.tsx
+++ b/code/addons/links/src/react/components/link.tsx
@@ -1,7 +1,7 @@
import type { MouseEvent, ReactNode } from 'react';
import React, { PureComponent } from 'react';
-import type { ComponentTitle, StoryKind, StoryName } from 'storybook/internal/types';
+import type { ComponentTitle, StoryName } from 'storybook/internal/types';
import { hrefTo, navigate } from '../../utils.ts';
@@ -22,9 +22,7 @@ const cancelled = (e: MouseEvent, cb = (_e: any) => {}) => {
};
interface Props {
- kind?: StoryKind;
title?: ComponentTitle;
- story?: StoryName;
name?: StoryName;
children: ReactNode;
}
@@ -47,20 +45,15 @@ export default class LinkTo extends PureComponent {
}
componentDidUpdate(prevProps: Props) {
- const { kind, title, story, name } = this.props;
-
- if (
- prevProps.kind !== kind ||
- prevProps.story !== story ||
- prevProps.title !== title ||
- prevProps.name !== name
- ) {
+ const { title, name } = this.props;
+
+ if (prevProps.title !== title || prevProps.name !== name) {
this.updateHref();
}
}
updateHref = async () => {
- const { kind, title = kind, story, name = story } = this.props;
+ const { title, name } = this.props;
if (title && name) {
const href = await hrefTo(title, name);
this.setState({ href });
@@ -68,14 +61,14 @@ export default class LinkTo extends PureComponent {
};
handleClick = () => {
- const { kind, title = kind, story, name = story } = this.props;
+ const { title, name } = this.props;
if (title && name) {
navigate({ title, name });
}
};
render() {
- const { kind, title = kind, story, name = story, children, ...rest } = this.props;
+ const { title, name, children, ...rest } = this.props;
const { href } = this.state;
return (
diff --git a/code/addons/links/src/utils.test.ts b/code/addons/links/src/utils.test.ts
index d946e007a31b..e0227e54deaa 100644
--- a/code/addons/links/src/utils.test.ts
+++ b/code/addons/links/src/utils.test.ts
@@ -32,8 +32,8 @@ describe('preview', () => {
handler();
expect(channel.emit).toHaveBeenCalledWith(SELECT_STORY, {
- kind: 'title',
- story: 'name',
+ title: 'title',
+ name: 'name',
});
});
@@ -42,7 +42,7 @@ describe('preview', () => {
handler();
expect(channel.emit).toHaveBeenCalledWith(SELECT_STORY, {
- kind: 'title',
+ title: 'title',
});
});
@@ -53,7 +53,7 @@ describe('preview', () => {
handler();
expect(channel.emit).toHaveBeenCalledWith(SELECT_STORY, {
- story: 'name',
+ name: 'name',
});
});
@@ -76,8 +76,8 @@ describe('preview', () => {
expect(channel.emit.mock.calls).toContainEqual([
SELECT_STORY,
{
- kind: 'titlename',
- story: 'nametitle',
+ title: 'titlename',
+ name: 'nametitle',
},
]);
});
diff --git a/code/addons/links/src/utils.ts b/code/addons/links/src/utils.ts
index aa8b2eadb602..6b455b535c69 100644
--- a/code/addons/links/src/utils.ts
+++ b/code/addons/links/src/utils.ts
@@ -1,6 +1,6 @@
import { SELECT_STORY, STORY_CHANGED } from 'storybook/internal/core-events';
import { toId } from 'storybook/internal/csf';
-import type { ComponentTitle, StoryId, StoryKind, StoryName } from 'storybook/internal/types';
+import type { ComponentTitle, SelectStoryPayload, StoryName } from 'storybook/internal/types';
import { global } from '@storybook/global';
@@ -10,16 +10,6 @@ import { PARAM_KEY } from './constants.ts';
const { document, HTMLElement } = global;
-interface ParamsId {
- storyId: StoryId;
-}
-interface ParamsCombo {
- kind?: StoryKind;
- title?: ComponentTitle;
- story?: StoryName;
- name?: StoryName;
-}
-
function parseQuery(queryString: string) {
const query: Record = {};
const pairs = (queryString[0] === '?' ? queryString.substring(1) : queryString)
@@ -33,7 +23,7 @@ function parseQuery(queryString: string) {
return query;
}
-export const navigate = (params: ParamsId | ParamsCombo) =>
+export const navigate = (params: SelectStoryPayload) =>
addons.getChannel().emit(SELECT_STORY, params);
const generateStoryUrl = (title: ComponentTitle | undefined, name: StoryName): string => {
@@ -78,11 +68,11 @@ export const linkTo =
if (title?.match(/--/) && !name) {
navigate({ storyId: title });
} else if (name && title) {
- navigate({ kind: title, story: name });
+ navigate({ title, name });
} else if (title) {
- navigate({ kind: title });
+ navigate({ title });
} else if (name) {
- navigate({ story: name });
+ navigate({ name });
}
};
@@ -92,10 +82,10 @@ const linksListener = (e: Event) => {
return;
}
const element = target as HTMLElement;
- const { sbKind: kind, sbStory: story } = element.dataset;
- if (kind || story) {
+ const { sbKind, sbStory } = element.dataset;
+ if (sbKind || sbStory) {
e.preventDefault();
- navigate({ kind, story });
+ navigate({ title: sbKind, name: sbStory });
}
};
diff --git a/code/core/src/csf/story.ts b/code/core/src/csf/story.ts
index 4b768c264909..92632b02d7a3 100644
--- a/code/core/src/csf/story.ts
+++ b/code/core/src/csf/story.ts
@@ -13,21 +13,14 @@ export type ComponentId = string;
export type ComponentTitle = string;
export type StoryName = string;
-/** @deprecated */
-export type StoryKind = ComponentTitle;
-
export type Tag = string;
export interface StoryIdentifier {
componentId: ComponentId;
title: ComponentTitle;
- /** @deprecated */
- kind: ComponentTitle;
id: StoryId;
name: StoryName;
- /** @deprecated */
- story: StoryName;
tags: Tag[];
}
@@ -217,9 +210,6 @@ export interface Renderer extends AddonTypes {
csf4: boolean;
}
-/** @deprecated - Use `Renderer` */
-export type AnyFramework = Renderer;
-
export interface StoryContextForEnhancers<
TRenderer extends Renderer = Renderer,
TArgs = Args,
@@ -251,7 +241,7 @@ export interface StoryContextUpdate {
export type ViewMode = 'story' | 'docs';
export type LoaderFunction = (
- context: StoryContextForLoaders
+ context: StoryContext
) => Promise | void> | Record | void;
type Awaitable = T | PromiseLike;
@@ -306,18 +296,6 @@ export interface StoryContextForRender<
argTypes: StrictArgTypes;
}
-/** @deprecated Use {@link StoryContext} instead. */
-export interface StoryContextForLoaders<
- TRenderer extends Renderer = Renderer,
- TArgs = Args,
-> extends StoryContext {}
-
-/** @deprecated Use {@link StoryContext} instead. */
-export interface PlayFunctionContext<
- TRenderer extends Renderer = Renderer,
- TArgs = Args,
-> extends StoryContext {}
-
export type StepLabel = string;
export type StepFunction = (
@@ -326,7 +304,7 @@ export type StepFunction =
) => Promise | void;
export type PlayFunction = (
- context: PlayFunctionContext
+ context: StoryContext
) => Promise | void;
export type TestFunction = (
diff --git a/code/core/src/manager-api/lib/stories.test.ts b/code/core/src/manager-api/lib/stories.test.ts
index a4a2916f368b..047b29a6bf86 100644
--- a/code/core/src/manager-api/lib/stories.test.ts
+++ b/code/core/src/manager-api/lib/stories.test.ts
@@ -3,7 +3,6 @@ import { describe, expect, it } from 'vitest';
import {
type API_PreparedStoryIndex,
type StatusesByStoryIdAndTypeId,
- type StoryIndexV2,
type StoryIndexV3,
} from 'storybook/internal/types';
@@ -11,18 +10,10 @@ import type { State } from '../root.tsx';
import { mockEntries } from '../tests/mockStoriesEntries.ts';
import {
transformStoryIndexToStoriesHash,
- transformStoryIndexV2toV3,
transformStoryIndexV3toV4,
transformStoryIndexV4toV5,
} from './stories.ts';
-const baseV2: StoryIndexV2['stories'][0] = {
- id: '1',
- story: '',
- kind: '',
- parameters: {},
-};
-
const baseV3: StoryIndexV3['stories'][0] = {
id: '1',
title: '',
@@ -33,54 +24,6 @@ const baseV3: StoryIndexV3['stories'][0] = {
importPath: '',
};
-describe('transformStoryIndexV2toV3', () => {
- it('transforms a StoryIndexV2 to a StoryIndexV3 correctly', () => {
- const indexV2: StoryIndexV2 = {
- v: 2,
- stories: {
- '1': {
- ...baseV2,
- id: '1',
- kind: 'story',
- story: 'Story 1',
- },
- '2': {
- ...baseV2,
- id: '2',
- kind: 'blog',
- story: 'Blog 1',
- },
- },
- };
-
- expect(transformStoryIndexV2toV3(indexV2)).toMatchInlineSnapshot(`
- {
- "stories": {
- "1": {
- "id": "1",
- "importPath": "",
- "kind": "story",
- "name": "Story 1",
- "parameters": {},
- "story": "Story 1",
- "title": "story",
- },
- "2": {
- "id": "2",
- "importPath": "",
- "kind": "blog",
- "name": "Blog 1",
- "parameters": {},
- "story": "Blog 1",
- "title": "blog",
- },
- },
- "v": 3,
- }
- `);
- });
-});
-
describe('transformStoryIndexV3toV4', () => {
it('transforms a StoryIndexV3 to an API_PreparedStoryIndex correctly', () => {
const indexV3: StoryIndexV3 = {
diff --git a/code/core/src/manager-api/lib/stories.ts b/code/core/src/manager-api/lib/stories.ts
index 0c3cca7d2406..7c1f461786f2 100644
--- a/code/core/src/manager-api/lib/stories.ts
+++ b/code/core/src/manager-api/lib/stories.ts
@@ -13,103 +13,22 @@ import type {
DocsOptions,
IndexEntry,
Parameters,
- SetStoriesPayload,
- SetStoriesStoryData,
StatusesByStoryIdAndTypeId,
StoryId,
- StoryIndexV2,
StoryIndexV3,
} from 'storybook/internal/types';
import { countBy } from 'es-toolkit/array';
-import { mapValues } from 'es-toolkit/object';
import memoize from 'memoizerific';
import { dedent } from 'ts-dedent';
import { Tag } from '../../shared/constants/tags.ts';
-import { type API, type State, combineParameters } from '../root.tsx';
+import { type API, type State } from '../root.tsx';
import intersect from './intersect.ts';
import merge from './merge.ts';
const TITLE_PATH_SEPARATOR = /\s*\/\s*/;
-export const denormalizeStoryParameters = ({
- globalParameters,
- kindParameters,
- stories,
-}: SetStoriesPayload): SetStoriesStoryData => {
- return mapValues(stories, (storyData) => ({
- ...storyData,
- parameters: combineParameters(
- globalParameters,
- kindParameters[storyData.kind],
- storyData.parameters as unknown as Parameters
- ),
- })) as SetStoriesStoryData;
-};
-
-export const transformSetStoriesStoryDataToPreparedStoryIndex = (
- stories: SetStoriesStoryData
-): API_PreparedStoryIndex => {
- const entries: API_PreparedStoryIndex['entries'] = Object.entries(stories).reduce(
- (acc, [id, story]) => {
- if (!story) {
- return acc;
- }
-
- const { docsOnly, fileName, ...parameters } = story.parameters;
- const base = {
- title: story.kind,
- id,
- name: story.name,
- importPath: fileName,
- };
- if (docsOnly) {
- acc[id] = {
- type: 'docs',
- tags: ['stories-mdx'],
- storiesImports: [],
- ...base,
- };
- } else {
- const { argTypes, args, initialArgs } = story;
- acc[id] = {
- type: 'story',
- subtype: 'story',
- ...base,
- parameters,
- argTypes,
- args,
- initialArgs,
- };
- }
- return acc;
- },
- {} as API_PreparedStoryIndex['entries']
- );
-
- return { v: 5, entries };
-};
-
-export const transformStoryIndexV2toV3 = (index: StoryIndexV2): StoryIndexV3 => {
- return {
- v: 3,
- stories: Object.values(index.stories).reduce(
- (acc, entry) => {
- acc[entry.id] = {
- ...entry,
- title: entry.kind,
- name: entry.name || entry.story,
- importPath: entry.parameters.fileName || '',
- };
-
- return acc;
- },
- {} as StoryIndexV3['stories']
- ),
- };
-};
-
export const transformStoryIndexV3toV4 = (index: StoryIndexV3): API_PreparedStoryIndex => {
const countByTitle = countBy(Object.values(index.stories), (item) => item.title);
return {
@@ -175,15 +94,19 @@ type ToStoriesHashOptions = {
};
export const transformStoryIndexToStoriesHash = (
- input: API_PreparedStoryIndex | StoryIndexV2 | StoryIndexV3,
+ input: API_PreparedStoryIndex | StoryIndexV3,
{ provider, docsOptions, filters, allStatuses, statusFilterKey }: ToStoriesHashOptions
): API_IndexHash => {
if (!input.v) {
throw new Error('Composition: Missing stories.json version');
}
+ if (input.v < 3) {
+ throw new Error(
+ `Unsupported story index version: v${input.v}. Storybook 11 requires index version 3 or later.`
+ );
+ }
let index = input;
- index = index.v === 2 ? transformStoryIndexV2toV3(index as any) : index;
index = index.v === 3 ? transformStoryIndexV3toV4(index as any) : index;
index = index.v === 4 ? transformStoryIndexV4toV5(index as any) : index;
index = index as API_PreparedStoryIndex;
diff --git a/code/core/src/manager-api/modules/refs.ts b/code/core/src/manager-api/modules/refs.ts
index 320af6b39210..8552af579e6d 100644
--- a/code/core/src/manager-api/modules/refs.ts
+++ b/code/core/src/manager-api/modules/refs.ts
@@ -5,8 +5,6 @@ import type {
API_RefStoryRuntimeData,
API_Refs,
API_SetRefData,
- API_StoryMapper,
- SetStoriesStoryData,
StoryIndex,
} from 'storybook/internal/types';
@@ -14,10 +12,7 @@ import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
-import {
- transformSetStoriesStoryDataToPreparedStoryIndex,
- transformStoryIndexToStoriesHash,
-} from '../lib/stories.ts';
+import { transformStoryIndexToStoriesHash } from '../lib/stories.ts';
import type { ModuleFn } from '../lib/types.tsx';
const { location, fetch } = global;
@@ -94,10 +89,6 @@ export const getSourceType = (source: string, refId?: string) => {
return [null, null];
};
-export const defaultStoryMapper: API_StoryMapper = (b: any, a: any) => {
- return { ...a, kind: a.kind.replace('|', '/') };
-};
-
const addRefIds = (input: API_IndexHash, ref: API_ComposedRef): API_IndexHash => {
return Object.entries(input).reduce((acc, [id, item]) => {
return { ...acc, [id]: { ...item!, refId: ref.id } };
@@ -201,20 +192,6 @@ const getRedirectedRefUrl = (refUrl: string, indexResponseUrl: string | undefine
return served.origin + served.pathname.slice(0, -'/index.json'.length);
};
-const map = (
- input: SetStoriesStoryData,
- ref: API_ComposedRef,
- options: { storyMapper?: API_StoryMapper }
-): SetStoriesStoryData => {
- const { storyMapper } = options;
- if (storyMapper) {
- return Object.entries(input).reduce((acc, [id, item]) => {
- return { ...acc, [id]: storyMapper(ref, item) };
- }, {} as SetStoriesStoryData);
- }
- return input;
-};
-
export const init: ModuleFn = (
{ store, provider, singleStory, docsOptions = {} },
{ runCheck = true } = {}
@@ -345,7 +322,7 @@ export const init: ModuleFn = (
return refs;
},
- setRef: async (id, { storyIndex, setStoriesData, ...rest }, ready = false) => {
+ setRef: async (id, { storyIndex, ...rest }, ready = false) => {
if (singleStory) {
return;
}
@@ -353,24 +330,17 @@ export const init: ModuleFn = (
let index: API_IndexHash | undefined;
let filteredIndex: API_IndexHash | undefined;
const { filters } = store.getState();
- const { storyMapper = defaultStoryMapper } = provider.getConfig();
const ref = api.getRefs()[id];
- if (storyIndex || setStoriesData) {
- internal_index = setStoriesData
- ? transformSetStoriesStoryDataToPreparedStoryIndex(
- map(setStoriesData, ref, { storyMapper })
- )
- : storyIndex;
+ if (storyIndex) {
+ internal_index = storyIndex;
- // @ts-expect-error (could be undefined)
filteredIndex = transformStoryIndexToStoriesHash(storyIndex, {
provider,
docsOptions,
filters,
allStatuses: {},
});
- // @ts-expect-error (could be undefined)
index = transformStoryIndexToStoriesHash(storyIndex, {
provider,
docsOptions,
diff --git a/code/core/src/manager-api/modules/stories.ts b/code/core/src/manager-api/modules/stories.ts
index 4c60f9052f28..9521105d13b8 100644
--- a/code/core/src/manager-api/modules/stories.ts
+++ b/code/core/src/manager-api/modules/stories.ts
@@ -10,7 +10,6 @@ import {
SET_CURRENT_STORY,
SET_FILTER,
SET_INDEX,
- SET_STORIES,
SIDEBAR_FILTER_CHANGED,
STORY_ARGS_UPDATED,
STORY_CHANGED,
@@ -38,11 +37,10 @@ import type {
Args,
ComponentTitle,
DocsPreparedPayload,
- SetStoriesPayload,
+ SelectStoryPayload,
StatusValue,
StoryId,
StoryIndex,
- StoryKind,
StoryName,
StoryPreparedPayload,
Tag,
@@ -58,7 +56,6 @@ import { countStatusesByValue } from '../../shared/status-store/index.ts';
import { getEventMetadata } from '../lib/events.ts';
import {
addPreparedStories,
- denormalizeStoryParameters,
getComponentLookupList,
getStoriesLookupList,
transformStoryIndexToStoriesHash,
@@ -76,6 +73,34 @@ import {
serializeTagsParam,
} from './tags.ts';
+/** Sent by composed Storybooks built with 10.x or earlier (their addon-links). */
+type LegacySelectStoryPayload = {
+ /** @deprecated Use `title`. */
+ kind?: ComponentTitle;
+ /** @deprecated Use `name`. */
+ story?: StoryName;
+ viewMode?: API_ViewMode;
+ scrollTo?: string;
+};
+
+/**
+ * Accepts the deprecated `kind`/`story` keys so cross-story links inside composed
+ * Storybooks built with 10.x or earlier keep navigating; everything downstream is modern-only.
+ */
+type SelectStoryEvent = SelectStoryPayload | LegacySelectStoryPayload;
+
+const normalizeSelectStoryPayload = (payload: SelectStoryEvent): SelectStoryPayload => {
+ if ('storyId' in payload) {
+ return payload;
+ }
+ const { viewMode, scrollTo } = payload;
+ const title =
+ ('title' in payload && payload.title) || ('kind' in payload ? payload.kind : undefined);
+ const name =
+ ('name' in payload && payload.name) || ('story' in payload ? payload.story : undefined);
+ return { title, name, viewMode, scrollTo };
+};
+
const { fetch } = global;
const STORY_INDEX_PATH = './index.json';
@@ -770,12 +795,6 @@ export const init: ModuleFn = ({
const storyIndex = (await result.json()) as StoryIndex;
- // We can only do this if the stories.json is a proper storyIndex
- if (storyIndex.v < 3) {
- logger.warn(`Skipping story index with version v${storyIndex.v}, awaiting SET_STORIES.`);
- return;
- }
-
await api.setIndex(storyIndex);
} catch (err: any) {
await store.setState({ indexError: err });
@@ -1246,48 +1265,21 @@ export const init: ModuleFn = ({
}
});
- // For composition back-compatibilty
- provider.channel?.on(SET_STORIES, function handler(this: any, data: SetStoriesPayload) {
+ provider.channel?.on(SELECT_STORY, function handler(this: any, rawPayload: SelectStoryEvent) {
const { ref } = getEventMetadata(this, fullAPI)!;
- const setStoriesData = data.v ? denormalizeStoryParameters(data) : data.stories;
-
- if (!ref) {
- throw new Error('Cannot call SET_STORIES for local frame');
+ const payload = normalizeSelectStoryPayload(rawPayload);
+
+ if ('storyId' in payload) {
+ const { storyId, viewMode, scrollTo } = payload;
+ fullAPI.selectStory(storyId, undefined, { viewMode, scrollTo, ref: ref?.id });
+ } else if (payload.title || payload.name) {
+ const { title, name, viewMode, scrollTo } = payload;
+ fullAPI.selectStory(title, name, { viewMode, scrollTo, ref: ref?.id });
} else {
- fullAPI.setRef(ref.id, { ...ref, setStoriesData }, true);
+ logger.warn('Received a SELECT_STORY event without storyId, title or name; ignoring it.');
}
});
- provider.channel?.on(
- SELECT_STORY,
- function handler(
- this: any,
- {
- kind,
- title = kind,
- story,
- name = story,
- storyId,
- ...rest
- }: {
- kind?: StoryKind;
- title?: ComponentTitle;
- story?: StoryName;
- name?: StoryName;
- storyId: string;
- viewMode: API_ViewMode;
- }
- ) {
- const { ref } = getEventMetadata(this, fullAPI)!;
-
- if (!ref) {
- fullAPI.selectStory(storyId || title, name, rest);
- } else {
- fullAPI.selectStory(storyId || title, name, { ...rest, ref: ref.id });
- }
- }
- );
-
provider.channel?.on(
STORY_ARGS_UPDATED,
function handleStoryArgsUpdated(
diff --git a/code/core/src/manager-api/root.tsx b/code/core/src/manager-api/root.tsx
index 9e3bcabe5091..d1ab695e1412 100644
--- a/code/core/src/manager-api/root.tsx
+++ b/code/core/src/manager-api/root.tsx
@@ -334,8 +334,6 @@ export function useStorybookApi(): API {
}
export type {
- /** @deprecated Now IndexHash */
- API_IndexHash as StoriesHash,
API_IndexHash as IndexHash,
API_RootEntry as RootEntry,
API_GroupEntry as GroupEntry,
diff --git a/code/core/src/manager-api/tests/stories.test.ts b/code/core/src/manager-api/tests/stories.test.ts
index 9e8b7b73ab2b..b71dfcf04f37 100644
--- a/code/core/src/manager-api/tests/stories.test.ts
+++ b/code/core/src/manager-api/tests/stories.test.ts
@@ -6,10 +6,10 @@ import {
CURRENT_STORY_WAS_SET,
DOCS_PREPARED,
RESET_STORY_ARGS,
+ SELECT_STORY,
SET_CONFIG,
SET_FILTER,
SET_INDEX,
- SET_STORIES,
STORY_ARGS_UPDATED,
STORY_INDEX_INVALIDATED,
STORY_MISSING,
@@ -1401,71 +1401,78 @@ describe('stories API', () => {
});
});
});
- describe('v2 SET_STORIES event', () => {
- it('normalizes parameters and calls setRef for external stories', () => {
+ describe('SELECT_STORY event', () => {
+ const setup = () => {
const fullAPI = {
findRef: vi.fn(),
setRef: vi.fn(),
+ selectStory: vi.fn(),
};
const moduleArgs = createMockModuleArgs({ fullAPI });
initStories(moduleArgs as unknown as ModuleArgs);
- const { provider, store } = moduleArgs;
+ return { provider: moduleArgs.provider, fullAPI };
+ };
- getEventMetadata.mockReturnValueOnce({
- sourceType: 'external',
- ref: { id: 'ref' },
- } as any);
- const setStoriesPayload = {
- v: 2,
- globalParameters: { global: 'global' },
- kindParameters: { a: { kind: 'kind' } },
- stories: { 'a--1': { kind: 'a', parameters: { story: 'story' } } },
- };
- provider.channel.emit(SET_STORIES, setStoriesPayload);
- expect(store.getState().index).toBeUndefined();
- expect(fullAPI.setRef).toHaveBeenCalledWith(
- 'ref',
- {
- id: 'ref',
- setStoriesData: {
- 'a--1': { kind: 'a', parameters: { global: 'global', kind: 'kind', story: 'story' } },
- },
- },
- true
- );
+ it('resolves the story from title and name', () => {
+ const { provider, fullAPI } = setup();
+
+ getEventMetadata.mockReturnValueOnce({ sourceType: 'local' } as any);
+ provider.channel.emit(SELECT_STORY, {
+ title: 'a',
+ name: '1',
+ viewMode: 'story',
+ });
+
+ expect(fullAPI.selectStory).toHaveBeenCalledWith('a', '1', { viewMode: 'story' });
});
- });
- describe('legacy (v1) SET_STORIES event', () => {
- it('calls setRef with stories', () => {
- const fullAPI = {
- findRef: vi.fn(),
- setRef: vi.fn(),
- };
- const moduleArgs = createMockModuleArgs({ fullAPI });
- initStories(moduleArgs as unknown as ModuleArgs);
- const { provider, store } = moduleArgs;
+
+ it('resolves the story from storyId when provided', () => {
+ const { provider, fullAPI } = setup();
+
+ getEventMetadata.mockReturnValueOnce({ sourceType: 'local' } as any);
+ provider.channel.emit(SELECT_STORY, {
+ storyId: 'a--1',
+ viewMode: 'story',
+ });
+
+ expect(fullAPI.selectStory).toHaveBeenCalledWith('a--1', undefined, { viewMode: 'story' });
+ });
+
+ it('resolves the story from the legacy kind/story payload sent by older composed Storybooks', () => {
+ const { provider, fullAPI } = setup();
getEventMetadata.mockReturnValueOnce({
sourceType: 'external',
ref: { id: 'ref' },
} as any);
- const setStoriesPayload = {
- stories: { 'a--1': {} },
- };
- provider.channel.emit(SET_STORIES, setStoriesPayload);
- expect(store.getState().index).toBeUndefined();
- expect(fullAPI.setRef).toHaveBeenCalledWith(
- 'ref',
- {
- id: 'ref',
- setStoriesData: {
- 'a--1': {},
- },
- },
- true
+ provider.channel.emit(SELECT_STORY, {
+ kind: 'a',
+ story: '1',
+ viewMode: 'story',
+ });
+
+ expect(fullAPI.selectStory).toHaveBeenCalledWith('a', '1', {
+ viewMode: 'story',
+ ref: 'ref',
+ });
+ });
+
+ it('warns and does not navigate on a payload without storyId, title or name', () => {
+ const { provider, fullAPI } = setup();
+ const warnSpy = vi.spyOn(logger, 'warn').mockImplementation(() => {});
+
+ getEventMetadata.mockReturnValueOnce({ sourceType: 'local' } as any);
+ provider.channel.emit(SELECT_STORY, {});
+
+ expect(fullAPI.selectStory).not.toHaveBeenCalled();
+ expect(warnSpy).toHaveBeenCalledWith(
+ expect.stringContaining('without storyId, title or name')
);
+
+ warnSpy.mockRestore();
});
});
+
describe('SET_CONFIG', () => {
it('ignores sidebar.filters when config arrives after the index', async () => {
const moduleArgs = createMockModuleArgs({
diff --git a/code/core/src/manager/components/sidebar/SearchResults.stories.tsx b/code/core/src/manager/components/sidebar/SearchResults.stories.tsx
index 55f532b9e360..116c18ad7e97 100644
--- a/code/core/src/manager/components/sidebar/SearchResults.stories.tsx
+++ b/code/core/src/manager/components/sidebar/SearchResults.stories.tsx
@@ -1,6 +1,6 @@
import React from 'react';
-import type { StoriesHash } from 'storybook/manager-api';
+import type { IndexHash } from 'storybook/manager-api';
import { expect } from 'storybook/test';
import { searchItem } from '../../utils/tree.ts';
@@ -25,7 +25,7 @@ export default {
],
};
-const combinedDataset = (refs: Record): CombinedDataset => {
+const combinedDataset = (refs: Record): CombinedDataset => {
const hash = Object.entries(refs).reduce(
(acc, [refId, index]) =>
Object.assign(acc, {
diff --git a/code/core/src/manager/components/sidebar/types.ts b/code/core/src/manager/components/sidebar/types.ts
index 6fc08d2796d1..04558ecc19a0 100644
--- a/code/core/src/manager/components/sidebar/types.ts
+++ b/code/core/src/manager/components/sidebar/types.ts
@@ -1,13 +1,13 @@
import type { StatusValue, StatusesByStoryIdAndTypeId } from 'storybook/internal/types';
import type { ControllerStateAndHelpers } from 'downshift';
-import type { State, StoriesHash } from 'storybook/manager-api';
+import type { State, IndexHash } from 'storybook/manager-api';
export type Refs = State['refs'];
export type RefType = Refs[keyof Refs] & {
allStatuses?: StatusesByStoryIdAndTypeId;
};
-export type Item = StoriesHash[keyof StoriesHash];
+export type Item = IndexHash[keyof IndexHash];
/**
* Final argument passed to `renderLabel` and `renderAriaLabel`. The tree always reports `sidebar`,
diff --git a/code/core/src/manager/components/sidebar/useExpanded.test.tsx b/code/core/src/manager/components/sidebar/useExpanded.test.tsx
index e80fe7a23ae7..df6e5ed35b49 100644
--- a/code/core/src/manager/components/sidebar/useExpanded.test.tsx
+++ b/code/core/src/manager/components/sidebar/useExpanded.test.tsx
@@ -4,7 +4,7 @@ import React from 'react';
import { act, renderHook } from '@testing-library/react';
import { describe, expect, it, vi } from 'vitest';
-import type { StoriesHash } from 'storybook/manager-api';
+import type { IndexHash } from 'storybook/manager-api';
import { ManagerContext } from 'storybook/manager-api';
import { useExpanded } from './useExpanded.ts';
@@ -22,7 +22,7 @@ const wrapper = ({ children }: { children: React.ReactNode }) => (
{children}
);
-const root = (id: string, startCollapsed = false): StoriesHash[string] =>
+const root = (id: string, startCollapsed = false): IndexHash[string] =>
({
type: 'root',
id,
@@ -34,7 +34,7 @@ const root = (id: string, startCollapsed = false): StoriesHash[string] =>
describe('useExpanded', () => {
it('expands a default root when it first appears, without reopening collapsed ones', () => {
- const initial: StoriesHash = { a: root('a') };
+ const initial: IndexHash = { a: root('a') };
const { result, rerender } = renderHook(
({ data }) => useExpanded({ data, selectedStoryId: null }),
{ wrapper, initialProps: { data: initial } }
@@ -53,7 +53,7 @@ describe('useExpanded', () => {
});
it('keeps a startCollapsed root collapsed when it appears after mount', () => {
- const initial: StoriesHash = { a: root('a') };
+ const initial: IndexHash = { a: root('a') };
const { result, rerender } = renderHook(
({ data }) => useExpanded({ data, selectedStoryId: null }),
{ wrapper, initialProps: { data: initial } }
diff --git a/code/core/src/manager/components/sidebar/useExpanded.ts b/code/core/src/manager/components/sidebar/useExpanded.ts
index 425edabd91d5..bc66a28fac39 100644
--- a/code/core/src/manager/components/sidebar/useExpanded.ts
+++ b/code/core/src/manager/components/sidebar/useExpanded.ts
@@ -3,7 +3,7 @@ import { useCallback, useEffect, useMemo, useReducer, useRef } from 'react';
import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from 'storybook/internal/core-events';
-import type { StoriesHash } from 'storybook/manager-api';
+import type { IndexHash } from 'storybook/manager-api';
import { useStorybookApi } from 'storybook/manager-api';
import { getAncestorIds } from '../../utils/tree.ts';
@@ -17,7 +17,7 @@ export interface ExpandAction {
}
export interface ExpandedProps {
- data: StoriesHash;
+ data: IndexHash;
selectedStoryId: string | null;
}
@@ -26,7 +26,7 @@ const initializeExpanded = ({
initialExpanded,
selectedStoryId,
}: {
- data: StoriesHash;
+ data: IndexHash;
initialExpanded: ExpandedState;
selectedStoryId: string | null;
}) => {
@@ -60,7 +60,7 @@ export const useExpanded = ({
const [expanded, setExpanded] = useReducer<
Reducer,
{
- data: StoriesHash;
+ data: IndexHash;
initialExpanded: ExpandedState;
selectedStoryId: string | null;
}
diff --git a/code/core/src/manager/container/Preview.tsx b/code/core/src/manager/container/Preview.tsx
index a4641ae57eac..ee319fb72223 100644
--- a/code/core/src/manager/container/Preview.tsx
+++ b/code/core/src/manager/container/Preview.tsx
@@ -5,7 +5,7 @@ import type { Addon_BaseType, Addon_Collection, Addon_WrapperType } from 'storyb
import { Addon_TypesEnum } from 'storybook/internal/types';
import memoizerific from 'memoizerific';
-import type { State, StoriesHash } from 'storybook/manager-api';
+import type { IndexHash, State } from 'storybook/manager-api';
import { Consumer } from 'storybook/manager-api';
import { Preview } from '../components/preview/Preview.tsx';
@@ -48,7 +48,7 @@ const memoizedWrapper = memoizerific(1)((_, previewElements: Addon_Collection) =
...Object.values(previewElements),
]);
-export type Item = StoriesHash[keyof StoriesHash];
+export type Item = IndexHash[keyof IndexHash];
const splitTitleAddExtraSpace = (input: string) =>
input.split('/').join(' / ').replace(/\s\s/, ' ');
diff --git a/code/core/src/manager/container/Sidebar.tsx b/code/core/src/manager/container/Sidebar.tsx
index 3f0b100770f2..2a47c38b3d45 100755
--- a/code/core/src/manager/container/Sidebar.tsx
+++ b/code/core/src/manager/container/Sidebar.tsx
@@ -1,13 +1,13 @@
import React from 'react';
-import type { Combo, StoriesHash } from 'storybook/manager-api';
+import type { Combo, IndexHash } from 'storybook/manager-api';
import { Consumer, experimental_useStatusStore } from 'storybook/manager-api';
import type { SidebarProps as SidebarComponentProps } from '../components/sidebar/Sidebar.tsx';
import { Sidebar as SidebarComponent } from '../components/sidebar/Sidebar.tsx';
import { useMenu } from './Menu.tsx';
-export type Item = StoriesHash[keyof StoriesHash];
+export type Item = IndexHash[keyof IndexHash];
interface SidebarProps {
onMenuClick?: SidebarComponentProps['onMenuClick'];
diff --git a/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts b/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts
index 6024e258e20a..ff0d28383ec6 100644
--- a/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts
+++ b/code/core/src/preview-api/modules/preview-web/render/StoryRender.ts
@@ -272,10 +272,8 @@ export class StoryRender implements Render = {
componentId,
title,
- kind: title,
id,
name,
- story: name,
tags,
...this.callbacks,
showError: (error) => {
diff --git a/code/core/src/preview-api/modules/store/StoryStore.test.ts b/code/core/src/preview-api/modules/store/StoryStore.test.ts
index f4507af894c6..565d0bf721b1 100644
--- a/code/core/src/preview-api/modules/store/StoryStore.test.ts
+++ b/code/core/src/preview-api/modules/store/StoryStore.test.ts
@@ -743,6 +743,46 @@ describe('StoryStore', () => {
`);
});
+ it('sets story to the parent story name for test entries and keeps the deprecated kind field', async () => {
+ const testExports = {
+ default: { title: 'Component One' },
+ a: { args: { foo: 'a' } },
+ 'a--test': { args: { foo: 'a' } },
+ };
+ const testImportFn = vi.fn(async (path) =>
+ path === './src/ComponentOne.stories.js' ? testExports : componentTwoExports
+ );
+ const testIndex: StoryIndex = {
+ v: 5,
+ entries: {
+ 'component-one--a': {
+ type: 'story',
+ subtype: 'story',
+ id: 'component-one--a',
+ title: 'Component One',
+ name: 'A',
+ importPath: './src/ComponentOne.stories.js',
+ },
+ 'component-one--a-test': {
+ type: 'story',
+ subtype: 'test',
+ id: 'component-one--a-test',
+ title: 'Component One',
+ name: 'A Test',
+ parent: 'component-one--a',
+ parentName: 'A',
+ importPath: './src/ComponentOne.stories.js',
+ },
+ },
+ };
+ const store = new StoryStore(testIndex, testImportFn, projectAnnotations);
+ await store.cacheAllCSFFiles();
+
+ const extracted = store.extract();
+ expect(extracted['component-one--a-test'].story).toBe('A');
+ expect(extracted['component-one--a-test'].kind).toBe('Component One');
+ });
+
it('does not include (legacy) docs only stories by default', async () => {
const docsOnlyImportFn = vi.fn(async (path) => {
return path === './src/ComponentOne.stories.js'
diff --git a/code/core/src/preview-api/modules/store/StoryStore.ts b/code/core/src/preview-api/modules/store/StoryStore.ts
index 3f5aeeb08475..aed7c40fff49 100644
--- a/code/core/src/preview-api/modules/store/StoryStore.ts
+++ b/code/core/src/preview-api/modules/store/StoryStore.ts
@@ -4,6 +4,7 @@ import {
MissingStoryFromCsfFileError,
} from 'storybook/internal/preview-errors';
import type {
+ ComponentTitle,
CSFFile,
IndexEntry,
ModuleExports,
@@ -17,6 +18,7 @@ import type {
StoryContextForEnhancers,
StoryId,
StoryIndex,
+ StoryName,
} from 'storybook/internal/types';
import { omitBy, pick } from 'es-toolkit/object';
@@ -57,6 +59,18 @@ function composeProjectAnnotations(
const CSF_CACHE_SIZE = 1000;
const STORY_CACHE_SIZE = 10000;
+/**
+ * The serialized story an external tool (such as the Chromatic CLI) reads via `extract()`.
+ * Keeps the deprecated `kind`/`story` fields for those extractors; everything else uses `title`/`name`.
+ */
+export type ExtractedStory =
+ StoryContextForEnhancers & {
+ /** @deprecated Use `title`. Kept for external extractors such as the Chromatic CLI. */
+ kind: ComponentTitle;
+ /** @deprecated Use `name`. Kept for external extractors such as the Chromatic CLI. */
+ story: StoryName;
+ };
+
export class StoryStore {
public storyIndex: StoryIndexStore;
@@ -292,7 +306,7 @@ export class StoryStore {
extract(
options: { includeDocsOnly?: boolean } = { includeDocsOnly: false }
- ): Record> {
+ ): Record> {
const { cachedCSFFiles } = this;
console.log('extract: extracting stories', cachedCSFFiles);
@@ -316,9 +330,6 @@ export class StoryStore {
acc[storyId] = Object.entries(story).reduce(
(storyAcc, [key, value]) => {
- if (key === 'story' && entry.subtype === 'test') {
- return { ...storyAcc, story: entry.parentName };
- }
if (key === 'moduleExport') {
return storyAcc;
}
@@ -338,6 +349,8 @@ export class StoryStore {
...story.storyGlobals,
},
storyId: entry.parent ? entry.parent : storyId,
+ kind: story.title,
+ story: entry.subtype === 'test' ? entry.parentName : story.name,
}
);
return acc;
diff --git a/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts b/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts
index 1e93b7795a07..61281191e281 100644
--- a/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts
+++ b/code/core/src/preview-api/modules/store/csf/prepareStory.test.ts
@@ -855,7 +855,6 @@ describe('prepareMeta', () => {
// omitting the properties from preparedStory that are not in preparedMeta
const {
name: storyName,
- story,
applyLoaders,
applyBeforeEach,
applyAfterEach,
diff --git a/code/core/src/preview-api/modules/store/csf/prepareStory.ts b/code/core/src/preview-api/modules/store/csf/prepareStory.ts
index 0ebc1ba660bd..4d231fd25145 100644
--- a/code/core/src/preview-api/modules/store/csf/prepareStory.ts
+++ b/code/core/src/preview-api/modules/store/csf/prepareStory.ts
@@ -153,7 +153,6 @@ export function prepareStory(
moduleExport,
id,
name,
- story: name,
originalStoryFn: render!,
undecoratedStoryFn,
unboundStoryFn,
@@ -251,11 +250,9 @@ function preparePartialAnnotations(
} = {
componentId: componentAnnotations.id,
title: componentAnnotations.title,
- kind: componentAnnotations.title, // Back compat
id: storyAnnotations?.id || componentAnnotations.id,
// if there's no story name, we create a fake one since enhancers expect a name
name: storyAnnotations?.name || '__meta',
- story: storyAnnotations?.name || '__meta', // Back compat
component: componentAnnotations.component,
subcomponents: componentAnnotations.subcomponents,
tags,
@@ -293,7 +290,7 @@ function preparePartialAnnotations(
initialArgsBeforeEnhancers
);
- const { name, story, ...withoutStoryIdentifiers } = contextForEnhancers;
+ const { name, ...withoutStoryIdentifiers } = contextForEnhancers;
return withoutStoryIdentifiers;
}
diff --git a/code/core/src/preview-api/modules/store/decorators.test.ts b/code/core/src/preview-api/modules/store/decorators.test.ts
index 850673451637..0edfa647d922 100644
--- a/code/core/src/preview-api/modules/store/decorators.test.ts
+++ b/code/core/src/preview-api/modules/store/decorators.test.ts
@@ -7,7 +7,6 @@ import { defaultDecorateStory } from './decorators.ts';
function makeContext(input: Record = {}): StoryContextForRender {
return {
id: 'id',
- kind: 'kind',
name: 'name',
viewMode: 'story',
parameters: {},
@@ -122,17 +121,15 @@ describe('client-api.decorators', () => {
const contexts: StoryContextForRender[] = [];
const decorators = [
// @ts-expect-error (not defined)
- (s, c) =>
- contexts.push(c) &&
- s({ parameters: { c: 'd' }, id: 'notId', kind: 'notKind', name: 'notName' }),
+ (s, c) => contexts.push(c) && s({ parameters: { c: 'd' }, id: 'notId', name: 'notName' }),
];
const decorated = defaultDecorateStory((c) => contexts.push(c), decorators);
expect(contexts).toEqual([]);
decorated(makeContext({ parameters: { a: 'b' } }));
expect(contexts).toEqual([
- expect.objectContaining({ parameters: { a: 'b' }, id: 'id', kind: 'kind', name: 'name' }),
- expect.objectContaining({ parameters: { a: 'b' }, id: 'id', kind: 'kind', name: 'name' }),
+ expect.objectContaining({ parameters: { a: 'b' }, id: 'id', name: 'name' }),
+ expect.objectContaining({ parameters: { a: 'b' }, id: 'id', name: 'name' }),
]);
});
});
diff --git a/code/core/src/preview-api/modules/store/decorators.ts b/code/core/src/preview-api/modules/store/decorators.ts
index 0953fbfd14fc..07af1702cc7b 100644
--- a/code/core/src/preview-api/modules/store/decorators.ts
+++ b/code/core/src/preview-api/modules/store/decorators.ts
@@ -30,10 +30,8 @@ export function decorateStory(
export function sanitizeStoryContextUpdate({
componentId,
title,
- kind,
id,
name,
- story,
parameters,
initialArgs,
argTypes,
diff --git a/code/core/src/types/modules/addons.ts b/code/core/src/types/modules/addons.ts
index ef3605e5f9ac..e95331e02b7e 100644
--- a/code/core/src/types/modules/addons.ts
+++ b/code/core/src/types/modules/addons.ts
@@ -17,7 +17,6 @@ import type {
StoryContextForRender as StoryContextForFramework,
StoryFn as StoryFnForFramework,
StoryId,
- StoryKind,
StoryName,
} from './csf.ts';
import type { IndexEntry } from './indexer.ts';
@@ -121,7 +120,6 @@ export type Addon_MakeDecoratorResult = (...args: any) => any;
export interface Addon_AddStoryArgs {
id: StoryId;
- kind: StoryKind;
name: StoryName;
storyFn: Addon_StoryFn;
parameters: Parameters;
@@ -140,7 +138,6 @@ export type Addon_ClientApiReturnFn = (
) => Addon_StoryApi;
export interface Addon_StoryApi {
- kind: StoryKind;
add: (
storyName: StoryName,
storyFn: Addon_StoryFn,
diff --git a/code/core/src/types/modules/api.ts b/code/core/src/types/modules/api.ts
index d913fc536a00..ce766bf56cfb 100644
--- a/code/core/src/types/modules/api.ts
+++ b/code/core/src/types/modules/api.ts
@@ -12,7 +12,6 @@ import type {
API_PreparedIndexEntry,
API_RefStoryRuntimeData,
} from './api-stories.ts';
-import type { SetStoriesStory, SetStoriesStoryData } from './channelApi.ts';
import type { DocsOptions } from './core-common.ts';
import type { StoryIndex } from './indexer.ts';
@@ -50,7 +49,6 @@ export interface API_Provider {
sidebar?: API_SidebarOptions;
theme?: ThemeVars;
selectedPanel?: string;
- StoryMapper?: API_StoryMapper;
[k: string]: any;
};
[key: string]: any;
@@ -161,13 +159,10 @@ type API_Versions = Record;
export type API_SetRefData = Partial<
API_ComposedRef & {
- setStoriesData: SetStoriesStoryData;
storyIndex: StoryIndex;
}
>;
-export type API_StoryMapper = (ref: API_ComposedRef, story: SetStoriesStory) => SetStoriesStory;
-
export interface API_LoadedRefData {
index?: API_IndexHash;
filteredIndex?: API_IndexHash;
diff --git a/code/core/src/types/modules/channelApi.ts b/code/core/src/types/modules/channelApi.ts
index 6935f7145475..4227a79fdadb 100644
--- a/code/core/src/types/modules/channelApi.ts
+++ b/code/core/src/types/modules/channelApi.ts
@@ -2,54 +2,18 @@ import type { API_ViewMode } from './api.ts';
import type {
ArgTypes,
Args,
- ComponentId,
+ ComponentTitle,
GlobalTypes,
Globals,
Parameters,
StoryId,
- StoryKind,
+ StoryName,
} from './csf.ts';
-// The data received on the (legacy) `setStories` event
-export interface SetStoriesStory {
- id: StoryId;
- name: string;
- refId?: string;
- componentId?: ComponentId;
- kind: StoryKind;
- parameters: {
- fileName: string;
- options: {
- [optionName: string]: any;
- };
- docsOnly?: boolean;
- viewMode?: API_ViewMode;
- [parameterName: string]: any;
- };
- argTypes?: ArgTypes;
- args?: Args;
- initialArgs?: Args;
-}
-
-export interface SetStoriesStoryData {
- [id: string]: SetStoriesStory;
-}
-
-export type SetStoriesPayload =
- | {
- v: 2;
- error?: Error;
- globals: Args;
- globalParameters: Parameters;
- stories: SetStoriesStoryData;
- kindParameters: {
- [kind: string]: Parameters;
- };
- }
- | ({
- v?: number;
- stories: SetStoriesStoryData;
- } & Record);
+export type SelectStoryPayload =
+ | { storyId: StoryId; viewMode?: API_ViewMode; scrollTo?: string }
+ // `title` is optional so a bare `name` can target the current component's story.
+ | { title?: ComponentTitle; name?: StoryName; viewMode?: API_ViewMode; scrollTo?: string };
export interface SetGlobalsPayload {
// userGlobals
diff --git a/code/core/src/types/modules/csf.ts b/code/core/src/types/modules/csf.ts
index 72c5419f7c38..1a05ac191431 100644
--- a/code/core/src/types/modules/csf.ts
+++ b/code/core/src/types/modules/csf.ts
@@ -34,7 +34,6 @@ export type {
Parameters,
PartialStoryFn,
PlayFunction,
- PlayFunctionContext,
Renderer,
SBArrayType,
SBEnumType,
@@ -52,13 +51,11 @@ export type {
StoryAnnotationsOrFn,
StoryContext,
StoryContextForEnhancers,
- StoryContextForLoaders,
StoryContextForRender,
StoryContextUpdate,
StoryFn,
StoryId,
StoryIdentifier,
- StoryKind,
StoryName,
StrictArgs,
StrictArgTypes,
diff --git a/code/core/src/types/modules/indexer.ts b/code/core/src/types/modules/indexer.ts
index 6150fa6c2ae4..548eca5bdb26 100644
--- a/code/core/src/types/modules/indexer.ts
+++ b/code/core/src/types/modules/indexer.ts
@@ -166,16 +166,6 @@ export interface V3CompatIndexEntry extends Omit & {
- name?: StoryName;
- }
- >;
-}
-
export interface StoryIndexV3 {
v: number;
stories: Record;
diff --git a/code/core/template/stories/argMapping.stories.ts b/code/core/template/stories/argMapping.stories.ts
index ea77d3edfddc..4732c421e843 100644
--- a/code/core/template/stories/argMapping.stories.ts
+++ b/code/core/template/stories/argMapping.stories.ts
@@ -1,4 +1,4 @@
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -43,7 +43,7 @@ export const Single = {
},
},
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toMatchObject({
mappingArg: { name: 'ArrowRight' },
});
@@ -64,7 +64,7 @@ export const Multiple = {
},
},
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toMatchObject({
mappingArg: [{ name: 'ArrowRight' }, { name: 'ArrowLeft' }],
});
diff --git a/code/core/template/stories/argTypes.stories.ts b/code/core/template/stories/argTypes.stories.ts
index d285779480f8..1b85a6d8057e 100644
--- a/code/core/template/stories/argTypes.stories.ts
+++ b/code/core/template/stories/argTypes.stories.ts
@@ -1,8 +1,4 @@
-import type {
- PartialStoryFn,
- PlayFunctionContext,
- StoryContextForRender,
-} from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext, StoryContextForRender } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -27,7 +23,7 @@ export const Inheritance = {
storyArg: { type: 'number' },
composedArg: { options: ['a', 'b'] },
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
// NOTE: these stories don't test project-level argTypes inheritance as it is too problematic
// to have an argType floating around that will apply too *all* other stories in our sandboxes.
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toMatchObject({
@@ -47,7 +43,7 @@ export const ArgTypeInference = {
d: { a: 'b' },
e: ['a', 'b'],
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const argTypes = JSON.parse(within(canvasElement).getByTestId('pre').innerText);
// `prepareStory` skips `inferArgTypes` when `docgenServer` is on; the manager
// runs that second pass in `mergeServiceArgTypes`, so the preview canvas never sees types
@@ -72,7 +68,7 @@ export const ArgTypeInference = {
};
export const HiddenFromPlay = {
- play: async (context: PlayFunctionContext) => {
+ play: async (context: StoryContext) => {
expect('argTypes' in context).toBe(false);
expect(() => context.argTypes).toThrow(/no longer part of the story context/);
},
diff --git a/code/core/template/stories/args.stories.ts b/code/core/template/stories/args.stories.ts
index e1760c784a3b..b4d6b5815f4a 100644
--- a/code/core/template/stories/args.stories.ts
+++ b/code/core/template/stories/args.stories.ts
@@ -3,7 +3,7 @@ import {
STORY_ARGS_UPDATED,
UPDATE_STORY_ARGS,
} from 'storybook/internal/core-events';
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -46,7 +46,7 @@ export const Inheritance = {
a: 'story',
},
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
// NOTE: these stories don't test project-level args inheritance as it is too problematic
// to have an arg floating around that will apply too *all* other stories in our sandboxes.
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toEqual({
@@ -68,7 +68,7 @@ export const Targets = {
a: { target: 'elsewhere' },
},
parameters: { argNames: ['a', 'b'] },
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
// Check that `a` doesn't end up set
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toEqual({
b: 'b',
@@ -82,7 +82,7 @@ export const Events = {
test: 'initial',
},
parameters: { argNames: ['test'] },
- play: async ({ canvasElement, id }: PlayFunctionContext) => {
+ play: async ({ canvasElement, id }: StoryContext) => {
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
await channel.emit(RESET_STORY_ARGS, { storyId: id });
await new Promise((resolve) => channel.once(STORY_ARGS_UPDATED, resolve));
diff --git a/code/core/template/stories/autotitle.stories.ts b/code/core/template/stories/autotitle.stories.ts
index 5fa47cbe32ab..11068b43037d 100644
--- a/code/core/template/stories/autotitle.stories.ts
+++ b/code/core/template/stories/autotitle.stories.ts
@@ -1,4 +1,4 @@
-import type { PlayFunctionContext } from 'storybook/internal/types';
+import type { StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -10,7 +10,7 @@ export default {
};
export const Default = {
- play: async ({ title }: PlayFunctionContext) => {
+ play: async ({ title }: StoryContext) => {
await expect(title).toBe('core/autotitle');
},
};
diff --git a/code/core/template/stories/component-play.stories.ts b/code/core/template/stories/component-play.stories.ts
index 729cbf882ed1..ccb7443e119a 100644
--- a/code/core/template/stories/component-play.stories.ts
+++ b/code/core/template/stories/component-play.stories.ts
@@ -1,4 +1,4 @@
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -6,7 +6,7 @@ import { expect, within } from 'storybook/test';
export default {
component: globalThis.__TEMPLATE_COMPONENTS__.Pre,
- play: async ({ canvasElement, name }: PlayFunctionContext) => {
+ play: async ({ canvasElement, name }: StoryContext) => {
await expect(
JSON.parse(within(canvasElement as HTMLPreElement).getByTestId('pre').innerText)
).toEqual({
diff --git a/code/core/template/stories/decorators.stories.ts b/code/core/template/stories/decorators.stories.ts
index ea220afdf2c8..cbe39e07fd77 100644
--- a/code/core/template/stories/decorators.stories.ts
+++ b/code/core/template/stories/decorators.stories.ts
@@ -6,7 +6,6 @@ import {
import type {
ArgsStoryFn,
PartialStoryFn,
- PlayFunctionContext,
StoryContext,
StoryContextForRender,
} from 'storybook/internal/types';
@@ -33,7 +32,7 @@ export const Inheritance = {
args: {
text: 'starting',
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const canvas = within(canvasElement);
await expect(canvas.getByTestId('pre').innerText).toEqual('story component project starting');
},
@@ -58,7 +57,7 @@ export const Hooks = {
text: 'text',
condition: true,
},
- play: async ({ id, args }: PlayFunctionContext) => {
+ play: async ({ id, args }: StoryContext) => {
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
await channel.emit(RESET_STORY_ARGS, { storyId: id });
await new Promise((resolve) => channel.once(STORY_ARGS_UPDATED, resolve));
diff --git a/code/core/template/stories/globals.stories.ts b/code/core/template/stories/globals.stories.ts
index 15bbf6acd55e..b620735ec8f2 100644
--- a/code/core/template/stories/globals.stories.ts
+++ b/code/core/template/stories/globals.stories.ts
@@ -1,4 +1,4 @@
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -18,7 +18,7 @@ export const Inheritance = {
(storyFn: PartialStoryFn, context: StoryContext) =>
storyFn({ args: { object: context.globals } }),
],
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toMatchObject({
foo: 'fooValue',
bar: 'barValue',
@@ -34,7 +34,7 @@ export const Events = {
(storyFn: PartialStoryFn, context: StoryContext) =>
storyFn({ args: { text: context.globals.foo } }),
],
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
await channel.emit('updateGlobals', { globals: { foo: 'fooValue' } });
await within(canvasElement).findByText('fooValue');
@@ -60,7 +60,7 @@ export const Overrides1 = {
foo: 'fooOverridden1',
baz: 'bazOverridden1',
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toMatchObject({
foo: 'fooOverridden1',
bar: 'barValue',
@@ -79,7 +79,7 @@ export const Overrides2 = {
foo: 'fooOverridden2',
baz: 'bazOverridden2',
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
await expect(JSON.parse(within(canvasElement).getByTestId('pre').innerText)).toMatchObject({
foo: 'fooOverridden2',
bar: 'barValue',
diff --git a/code/core/template/stories/indexer.stories.ts b/code/core/template/stories/indexer.stories.ts
index 1b03c38bd029..d22e7161228f 100644
--- a/code/core/template/stories/indexer.stories.ts
+++ b/code/core/template/stories/indexer.stories.ts
@@ -1,4 +1,4 @@
-import type { PlayFunctionContext } from 'storybook/internal/types';
+import type { StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -11,7 +11,7 @@ export default {
};
export const Default = {
- play: async ({ id }: PlayFunctionContext) => {
+ play: async ({ id }: StoryContext) => {
await expect(id).toBe('indexer-custom-meta-id--default');
},
};
@@ -20,7 +20,7 @@ export const CustomParametersId = {
parameters: {
__id: 'custom-id',
},
- play: async ({ id }: PlayFunctionContext) => {
+ play: async ({ id }: StoryContext) => {
await expect(id).toBe('custom-id');
},
};
diff --git a/code/core/template/stories/names.stories.ts b/code/core/template/stories/names.stories.ts
index f87b1f8aafa3..b028c9b3c94b 100644
--- a/code/core/template/stories/names.stories.ts
+++ b/code/core/template/stories/names.stories.ts
@@ -1,4 +1,4 @@
-import type { PlayFunctionContext } from 'storybook/internal/types';
+import type { StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -13,13 +13,13 @@ export default {
// Repro for https://github.com/storybookjs/storybook/issues/11571
export const PrefixAndName = {
- play: async ({ name }: PlayFunctionContext) => {
+ play: async ({ name }: StoryContext) => {
await expect(name).toBe('Prefix And Name');
},
};
export const Prefix = {
- play: async ({ name }: PlayFunctionContext) => {
+ play: async ({ name }: StoryContext) => {
await expect(name).toBe('Prefix');
},
};
diff --git a/code/core/template/stories/parameters.stories.ts b/code/core/template/stories/parameters.stories.ts
index 7c8c1e00c29b..6583195346a1 100644
--- a/code/core/template/stories/parameters.stories.ts
+++ b/code/core/template/stories/parameters.stories.ts
@@ -1,4 +1,4 @@
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -32,7 +32,7 @@ export const Inheritance = {
a: 'story',
},
},
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const canvas = within(canvasElement);
await expect(JSON.parse(canvas.getByTestId('pre').innerText)).toEqual({
projectParameter: 'projectParameter',
diff --git a/code/core/template/stories/rendering.stories.ts b/code/core/template/stories/rendering.stories.ts
index 8d98901d6396..ca3a55ab5fa6 100644
--- a/code/core/template/stories/rendering.stories.ts
+++ b/code/core/template/stories/rendering.stories.ts
@@ -4,7 +4,7 @@ import {
STORY_ARGS_UPDATED,
UPDATE_STORY_ARGS,
} from 'storybook/internal/core-events';
-import type { PlayFunctionContext } from 'storybook/internal/types';
+import type { StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -27,7 +27,7 @@ export const ForceRemount = {
* FORCE_REMOUNT event
*/
parameters: { chromatic: { disableSnapshot: true } },
- play: async ({ canvasElement, id }: PlayFunctionContext) => {
+ play: async ({ canvasElement, id }: StoryContext) => {
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
const button = await within(canvasElement).findByRole('button');
@@ -76,7 +76,7 @@ export const SlowLoader = {
};
export const ChangeArgs = {
- play: async ({ canvasElement, id }: PlayFunctionContext) => {
+ play: async ({ canvasElement, id }: StoryContext) => {
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
await channel.emit(RESET_STORY_ARGS, { storyId: id });
diff --git a/code/core/template/stories/shortcuts.stories.ts b/code/core/template/stories/shortcuts.stories.ts
index 2db1beaf58d1..54a6ce0ecb58 100644
--- a/code/core/template/stories/shortcuts.stories.ts
+++ b/code/core/template/stories/shortcuts.stories.ts
@@ -1,5 +1,5 @@
import { PREVIEW_KEYDOWN } from 'storybook/internal/core-events';
-import type { PlayFunctionContext } from 'storybook/internal/csf';
+import type { StoryContext } from 'storybook/internal/csf';
import { global as globalThis } from '@storybook/global';
@@ -15,7 +15,7 @@ export default {
};
export const KeydownDuringPlay = {
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
const previewKeydown = fn();
diff --git a/code/core/template/stories/tags-add.stories.ts b/code/core/template/stories/tags-add.stories.ts
index 8f330a5eca0e..cbca939ffbde 100644
--- a/code/core/template/stories/tags-add.stories.ts
+++ b/code/core/template/stories/tags-add.stories.ts
@@ -1,4 +1,4 @@
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -19,7 +19,7 @@ export default {
export const Inheritance = {
tags: ['story-one', '!vitest'],
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const canvas = within(canvasElement);
await expect(JSON.parse(canvas.getByTestId('pre').innerText)).toEqual({
tags: ['story-one'],
diff --git a/code/core/template/stories/tags-config.stories.ts b/code/core/template/stories/tags-config.stories.ts
index 73241353cb7f..38bc5c368f77 100644
--- a/code/core/template/stories/tags-config.stories.ts
+++ b/code/core/template/stories/tags-config.stories.ts
@@ -1,4 +1,4 @@
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -19,7 +19,7 @@ export default {
export const Inheritance = {
tags: ['story-one', '!vitest'],
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const canvas = within(canvasElement);
await expect(JSON.parse(canvas.getByTestId('pre').innerText)).toEqual({
tags: ['dev', 'test', 'component-one', 'component-two', 'autodocs', 'story-one'],
diff --git a/code/core/template/stories/tags-remove.stories.ts b/code/core/template/stories/tags-remove.stories.ts
index 10b95a2932d7..3ad0b001d719 100644
--- a/code/core/template/stories/tags-remove.stories.ts
+++ b/code/core/template/stories/tags-remove.stories.ts
@@ -1,4 +1,4 @@
-import type { PartialStoryFn, PlayFunctionContext, StoryContext } from 'storybook/internal/types';
+import type { PartialStoryFn, StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -19,7 +19,7 @@ export default {
export const Inheritance = {
tags: ['story-one', '!vitest'],
- play: async ({ canvasElement }: PlayFunctionContext) => {
+ play: async ({ canvasElement }: StoryContext) => {
const canvas = within(canvasElement);
await expect(JSON.parse(canvas.getByTestId('pre').innerText)).toEqual({
tags: ['dev', 'test', 'component-one', 'autodocs', 'story-one'],
diff --git a/code/core/template/stories/title.stories.ts b/code/core/template/stories/title.stories.ts
index d8c432447616..609ceb64ee1b 100644
--- a/code/core/template/stories/title.stories.ts
+++ b/code/core/template/stories/title.stories.ts
@@ -1,4 +1,4 @@
-import type { PlayFunctionContext } from 'storybook/internal/types';
+import type { StoryContext } from 'storybook/internal/types';
import { global as globalThis } from '@storybook/global';
@@ -11,7 +11,7 @@ export default {
};
export const Default = {
- play: async ({ title }: PlayFunctionContext) => {
+ play: async ({ title }: StoryContext) => {
await expect(title).toBe('core/manual title');
},
};
diff --git a/code/frameworks/angular-vite/src/client/decorateStory.test.ts b/code/frameworks/angular-vite/src/client/decorateStory.test.ts
index cce2901baeaa..e271843d6ba7 100644
--- a/code/frameworks/angular-vite/src/client/decorateStory.test.ts
+++ b/code/frameworks/angular-vite/src/client/decorateStory.test.ts
@@ -337,7 +337,6 @@ describe('decorateStory', () => {
function makeContext(input: Record): StoryContextForRender {
return {
id: 'id',
- kind: 'kind',
name: 'name',
viewMode: 'story',
parameters: {},
diff --git a/code/frameworks/angular/src/client/decorateStory.test.ts b/code/frameworks/angular/src/client/decorateStory.test.ts
index 016c23a7f250..3b3eb6b0b3cb 100644
--- a/code/frameworks/angular/src/client/decorateStory.test.ts
+++ b/code/frameworks/angular/src/client/decorateStory.test.ts
@@ -332,7 +332,6 @@ describe.skip('decorateStory', () => {
function makeContext(input: Record): StoryContextForRender {
return {
id: 'id',
- kind: 'kind',
name: 'name',
viewMode: 'story',
parameters: {},
diff --git a/code/frameworks/ember/src/client/preview/render.ts b/code/frameworks/ember/src/client/preview/render.ts
index 46068ae0a131..f26f8fb8f88b 100644
--- a/code/frameworks/ember/src/client/preview/render.ts
+++ b/code/frameworks/ember/src/client/preview/render.ts
@@ -69,14 +69,14 @@ function render(options: OptionsArgs, el: EmberRenderer['canvasElement']) {
}
export function renderToCanvas(
- { storyFn, kind, name, showMain, showError }: RenderContext,
+ { storyFn, title, name, showMain, showError }: RenderContext,
canvasElement: EmberRenderer['canvasElement']
) {
const element = storyFn();
if (!element) {
showError({
- title: `Expecting a Ember element from the story: "${name}" of "${kind}".`,
+ title: `Expecting a Ember element from the story: "${name}" of "${title}".`,
description: dedent`
Did you forget to return the Ember element from the story?
Use "() => hbs('{{component}}')" or "() => { return {
diff --git a/code/renderers/html/src/render.ts b/code/renderers/html/src/render.ts
index 987ff763c055..6e2c6a281ddd 100644
--- a/code/renderers/html/src/render.ts
+++ b/code/renderers/html/src/render.ts
@@ -42,7 +42,7 @@ export const render: ArgsStoryFn = (args, context) => {
};
export function renderToCanvas(
- { storyFn, kind, name, showMain, showError, forceRemount }: RenderContext,
+ { storyFn, title, name, showMain, showError, forceRemount }: RenderContext,
canvasElement: HtmlRenderer['canvasElement']
) {
const element = storyFn();
@@ -60,7 +60,7 @@ export function renderToCanvas(
simulateDOMContentLoaded();
} else {
showError({
- title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${kind}".`,
+ title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${title}".`,
description: dedent`
Did you forget to return the HTML snippet from the story?
Use "() => " or when defining the story.
diff --git a/code/renderers/react/src/__test__/RenderToCanvas.stories.tsx b/code/renderers/react/src/__test__/RenderToCanvas.stories.tsx
index a343a430129c..c4bbaf982beb 100644
--- a/code/renderers/react/src/__test__/RenderToCanvas.stories.tsx
+++ b/code/renderers/react/src/__test__/RenderToCanvas.stories.tsx
@@ -39,10 +39,8 @@ export const AwaitsDocsLayoutEffects: Story = {
{
componentId: context.componentId,
title: context.title,
- kind: context.kind,
id: context.id,
name: context.name,
- story: context.story,
tags: context.tags,
showMain: () => {},
showError: () => {},
diff --git a/code/renderers/web-components/src/render.ts b/code/renderers/web-components/src/render.ts
index c2d771c88788..f2bd87c0f28a 100644
--- a/code/renderers/web-components/src/render.ts
+++ b/code/renderers/web-components/src/render.ts
@@ -41,7 +41,7 @@ export const render: ArgsStoryFn = (args, context) => {
};
export function renderToCanvas(
- { storyFn, kind, name, showMain, showError, forceRemount }: RenderContext,
+ { storyFn, title, name, showMain, showError, forceRemount }: RenderContext,
canvasElement: WebComponentsRenderer['canvasElement']
): void {
const element = storyFn();
@@ -72,7 +72,7 @@ export function renderToCanvas(
simulateDOMContentLoaded();
} else {
showError({
- title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${kind}".`,
+ title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${title}".`,
description: dedent`
Did you forget to return the HTML snippet from the story?
Use "() => " or when defining the story.