From c3044911f260792219428c6b8410755f38f7c3a1 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Tue, 26 Oct 2021 16:17:17 +1100 Subject: [PATCH 1/5] Ensure we don't reset `WebPreview` if calling `start()` in v7 mode --- lib/core-client/src/preview/start.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/core-client/src/preview/start.ts b/lib/core-client/src/preview/start.ts index 74d19aeb475..e2af280ddf0 100644 --- a/lib/core-client/src/preview/start.ts +++ b/lib/core-client/src/preview/start.ts @@ -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( () => {}, @@ -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( renderToDOM: WebProjectAnnotations['renderToDOM'], { @@ -30,6 +34,22 @@ export function start( render?: ArgsStoryFn; } = {} ) { + if (FEATURES.storyStoreV7) { + return { + forceReRender: removedApi('forceReRender'), + getStorybook: removedApi('getStorybook'), + raw: removedApi('raw'), + configure: removedApi('configure'), + clientApi: { + addDecorator: removedApi('clientApi.addDecorator'), + addParameters: removedApi('clientApi.addParameters'), + clearDecorators: removedApi('clientApi.clearDecorators'), + setAddon: removedApi('clientApi.setAddon'), + getStorybook: removedApi('clientApi.getStorybook'), + }, + }; + } + const channel = createChannel({ page: 'preview' }); addons.setChannel(channel); From 0de76c6e76c566ea4b5bc6e3bc2fe822f31b9aa0 Mon Sep 17 00:00:00 2001 From: Tom Coleman Date: Tue, 26 Oct 2021 16:30:05 +1100 Subject: [PATCH 2/5] Missed one! --- lib/core-client/src/preview/start.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/core-client/src/preview/start.ts b/lib/core-client/src/preview/start.ts index e2af280ddf0..0fb95a85570 100644 --- a/lib/core-client/src/preview/start.ts +++ b/lib/core-client/src/preview/start.ts @@ -46,6 +46,7 @@ export function start( clearDecorators: removedApi('clientApi.clearDecorators'), setAddon: removedApi('clientApi.setAddon'), getStorybook: removedApi('clientApi.getStorybook'), + storiesOf: removedApi('clientApi.storiesOf'), }, }; } From ac753e340f7cf22c49f5287ee740f784a17116d7 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Tue, 26 Oct 2021 23:57:13 +0800 Subject: [PATCH 3/5] Add missing API --- lib/core-client/src/preview/start.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/core-client/src/preview/start.ts b/lib/core-client/src/preview/start.ts index 0fb95a85570..faa90a3eb6a 100644 --- a/lib/core-client/src/preview/start.ts +++ b/lib/core-client/src/preview/start.ts @@ -44,6 +44,7 @@ export function start( 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'), From 8d6b0901aa4ba0ab8aca4437dab0431e71fa84f3 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Wed, 27 Oct 2021 00:04:14 +0800 Subject: [PATCH 4/5] Fix clientAPi.raw API signature --- lib/core-client/src/preview/start.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core-client/src/preview/start.ts b/lib/core-client/src/preview/start.ts index faa90a3eb6a..beed4dde158 100644 --- a/lib/core-client/src/preview/start.ts +++ b/lib/core-client/src/preview/start.ts @@ -38,7 +38,6 @@ export function start( return { forceReRender: removedApi('forceReRender'), getStorybook: removedApi('getStorybook'), - raw: removedApi('raw'), configure: removedApi('configure'), clientApi: { addDecorator: removedApi('clientApi.addDecorator'), @@ -48,6 +47,7 @@ export function start( setAddon: removedApi('clientApi.setAddon'), getStorybook: removedApi('clientApi.getStorybook'), storiesOf: removedApi('clientApi.storiesOf'), + raw: removedApi('raw'), }, }; } From 894fd20a9007adc1b3397286762d2744a29d7897 Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Wed, 27 Oct 2021 00:15:11 +0800 Subject: [PATCH 5/5] Fix undefined FEATURES --- lib/core-client/src/preview/start.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core-client/src/preview/start.ts b/lib/core-client/src/preview/start.ts index beed4dde158..22b5fba95b8 100644 --- a/lib/core-client/src/preview/start.ts +++ b/lib/core-client/src/preview/start.ts @@ -34,7 +34,7 @@ export function start( render?: ArgsStoryFn; } = {} ) { - if (FEATURES.storyStoreV7) { + if (FEATURES?.storyStoreV7) { return { forceReRender: removedApi('forceReRender'), getStorybook: removedApi('getStorybook'),