From c80f4079f948de36d64bb4c71bb75dc61cee38a5 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 27 Oct 2022 20:16:21 +0200 Subject: [PATCH 1/2] remove dead code --- .../src/{preview => }/executeLoadable.ts | 0 code/lib/core-client/src/globals/polyfills.ts | 1 - code/lib/core-client/src/index.ts | 6 ++- code/lib/core-client/src/manager/index.ts | 13 ----- code/lib/core-client/src/manager/provider.ts | 48 ------------------- code/lib/core-client/src/preview/index.ts | 5 -- .../src/{preview => }/start.test.ts | 0 .../core-client/src/{preview => }/start.ts | 0 8 files changed, 5 insertions(+), 68 deletions(-) rename code/lib/core-client/src/{preview => }/executeLoadable.ts (100%) delete mode 100644 code/lib/core-client/src/globals/polyfills.ts delete mode 100644 code/lib/core-client/src/manager/index.ts delete mode 100644 code/lib/core-client/src/manager/provider.ts delete mode 100644 code/lib/core-client/src/preview/index.ts rename code/lib/core-client/src/{preview => }/start.test.ts (100%) rename code/lib/core-client/src/{preview => }/start.ts (100%) diff --git a/code/lib/core-client/src/preview/executeLoadable.ts b/code/lib/core-client/src/executeLoadable.ts similarity index 100% rename from code/lib/core-client/src/preview/executeLoadable.ts rename to code/lib/core-client/src/executeLoadable.ts diff --git a/code/lib/core-client/src/globals/polyfills.ts b/code/lib/core-client/src/globals/polyfills.ts deleted file mode 100644 index b535f6a2cc34..000000000000 --- a/code/lib/core-client/src/globals/polyfills.ts +++ /dev/null @@ -1 +0,0 @@ -import 'regenerator-runtime/runtime'; diff --git a/code/lib/core-client/src/index.ts b/code/lib/core-client/src/index.ts index 45799160cd5b..23c8d04e27e1 100644 --- a/code/lib/core-client/src/index.ts +++ b/code/lib/core-client/src/index.ts @@ -1 +1,5 @@ -export * from './preview'; +import { ClientApi } from '@storybook/client-api'; +import { StoryStore } from '@storybook/store'; +import { start } from './start'; + +export { start, ClientApi, StoryStore }; diff --git a/code/lib/core-client/src/manager/index.ts b/code/lib/core-client/src/manager/index.ts deleted file mode 100644 index 00435366d2f1..000000000000 --- a/code/lib/core-client/src/manager/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -import global from 'global'; -import { renderStorybookUI } from '@storybook/manager'; - -import Provider from './provider'; - -const { document } = global; - -// We need to wait a promise "tick" to allow all subsequent addons etc to execute -// (alternatively, we could ensure this entry point is always loaded last) -Promise.resolve().then(() => { - const rootEl = document.getElementById('root'); - renderStorybookUI(rootEl, new Provider()); -}); diff --git a/code/lib/core-client/src/manager/provider.ts b/code/lib/core-client/src/manager/provider.ts deleted file mode 100644 index 9603a62d1d3a..000000000000 --- a/code/lib/core-client/src/manager/provider.ts +++ /dev/null @@ -1,48 +0,0 @@ -import global from 'global'; -import { Provider } from '@storybook/manager'; -import { Channel } from '@storybook/channels'; -import type { Addon_Types, Addon_Config } from '@storybook/types'; -import { addons, AddonStore } from '@storybook/addons'; -import * as postMessage from '@storybook/channel-postmessage'; -import * as webSocket from '@storybook/channel-websocket'; -import { CHANNEL_CREATED } from '@storybook/core-events'; - -const { FEATURES, SERVER_CHANNEL_URL } = global; - -export default class ReactProvider extends Provider { - private addons: AddonStore; - - private channel: Channel; - - private serverChannel?: Channel; - - constructor() { - super(); - - const channel = postMessage.createChannel({ page: 'manager' }); - - addons.setChannel(channel); - channel.emit(CHANNEL_CREATED); - - this.addons = addons; - this.channel = channel; - - if (FEATURES?.storyStoreV7 && SERVER_CHANNEL_URL) { - const serverChannel = webSocket.createChannel({ url: SERVER_CHANNEL_URL }); - this.serverChannel = serverChannel; - addons.setServerChannel(this.serverChannel); - } - } - - getElements(type: Addon_Types) { - return this.addons.getElements(type); - } - - getConfig(): Addon_Config { - return this.addons.getConfig(); - } - - handleAPI(api: unknown) { - this.addons.loadAddons(api); - } -} diff --git a/code/lib/core-client/src/preview/index.ts b/code/lib/core-client/src/preview/index.ts deleted file mode 100644 index 23c8d04e27e1..000000000000 --- a/code/lib/core-client/src/preview/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { ClientApi } from '@storybook/client-api'; -import { StoryStore } from '@storybook/store'; -import { start } from './start'; - -export { start, ClientApi, StoryStore }; diff --git a/code/lib/core-client/src/preview/start.test.ts b/code/lib/core-client/src/start.test.ts similarity index 100% rename from code/lib/core-client/src/preview/start.test.ts rename to code/lib/core-client/src/start.test.ts diff --git a/code/lib/core-client/src/preview/start.ts b/code/lib/core-client/src/start.ts similarity index 100% rename from code/lib/core-client/src/preview/start.ts rename to code/lib/core-client/src/start.ts From ae8f7e9be345649b1dc1d2459acafc8fc1b771cc Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 27 Oct 2022 20:17:27 +0200 Subject: [PATCH 2/2] remove unused dependencies --- code/lib/core-client/package.json | 2 -- code/yarn.lock | 2 -- 2 files changed, 4 deletions(-) diff --git a/code/lib/core-client/package.json b/code/lib/core-client/package.json index 0911f105f4de..0e3a2b5eeefd 100644 --- a/code/lib/core-client/package.json +++ b/code/lib/core-client/package.json @@ -43,12 +43,10 @@ "@storybook/client-logger": "7.0.0-alpha.44", "@storybook/core-events": "7.0.0-alpha.44", "@storybook/csf": "next", - "@storybook/manager": "7.0.0-alpha.44", "@storybook/preview-web": "7.0.0-alpha.44", "@storybook/store": "7.0.0-alpha.44", "@storybook/types": "7.0.0-alpha.44", "global": "^4.4.0", - "regenerator-runtime": "^0.13.7", "util-deprecate": "^1.0.2" }, "devDependencies": { diff --git a/code/yarn.lock b/code/yarn.lock index 103292c6a2ca..1d3431a3ef32 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6464,12 +6464,10 @@ __metadata: "@storybook/client-logger": 7.0.0-alpha.44 "@storybook/core-events": 7.0.0-alpha.44 "@storybook/csf": next - "@storybook/manager": 7.0.0-alpha.44 "@storybook/preview-web": 7.0.0-alpha.44 "@storybook/store": 7.0.0-alpha.44 "@storybook/types": 7.0.0-alpha.44 global: ^4.4.0 - regenerator-runtime: ^0.13.7 typescript: ~4.6.3 util-deprecate: ^1.0.2 peerDependenciesMeta: