Skip to content

Commit

Permalink
Merge pull request #16475 from storybookjs/tom/ch-661-addon-a11y-init…
Browse files Browse the repository at this point in the history
…ializing-forever

Core: Ensure we don't reset `WebPreview` if calling `start()` in v7 mode
  • Loading branch information
shilman authored Oct 26, 2021
2 parents 52ef064 + 894fd20 commit 7e6bf86
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/core-client/src/preview/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Path } from '@storybook/store';
import { Loadable } from './types';
import { executeLoadableForChanges } from './executeLoadable';

const { window: globalWindow } = global;
const { window: globalWindow, FEATURES } = global;

const configureDeprecationWarning = deprecate(
() => {},
Expand All @@ -20,6 +20,10 @@ Please use the \`stories\` field of \`main.js\` to load stories.
Read more at https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-configure`
);

const removedApi = (name: string) => () => {
throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`);
};

export function start<TFramework extends AnyFramework>(
renderToDOM: WebProjectAnnotations<TFramework>['renderToDOM'],
{
Expand All @@ -30,6 +34,24 @@ export function start<TFramework extends AnyFramework>(
render?: ArgsStoryFn<TFramework>;
} = {}
) {
if (FEATURES?.storyStoreV7) {
return {
forceReRender: removedApi('forceReRender'),
getStorybook: removedApi('getStorybook'),
configure: removedApi('configure'),
clientApi: {
addDecorator: removedApi('clientApi.addDecorator'),
addParameters: removedApi('clientApi.addParameters'),
clearDecorators: removedApi('clientApi.clearDecorators'),
addLoader: removedApi('clientApi.addLoader'),
setAddon: removedApi('clientApi.setAddon'),
getStorybook: removedApi('clientApi.getStorybook'),
storiesOf: removedApi('clientApi.storiesOf'),
raw: removedApi('raw'),
},
};
}

const channel = createChannel({ page: 'preview' });
addons.setChannel(channel);

Expand Down

0 comments on commit 7e6bf86

Please sign in to comment.