Skip to content

Commit

Permalink
Merge pull request #23032 from storybookjs/norbert/merge-channels
Browse files Browse the repository at this point in the history
Maintenance: Deprecate channel packages, merge into a single browserChannel, update builders
  • Loading branch information
ndelangen authored Jun 13, 2023
2 parents 9297487 + 50047f5 commit 4bbd7e8
Show file tree
Hide file tree
Showing 34 changed files with 425 additions and 311 deletions.
1 change: 1 addition & 0 deletions code/addons/storyshots-core/src/frameworks/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function configure<TRenderer extends Renderer>(
} = getConfigPathParts(configPath);

global.FEATURES = features;
global.CONFIG_TYPE = 'DEVELOPMENT';
global.STORIES = stories.map((specifier) => ({
...specifier,
importPathMatcher: specifier.importPathMatcher.source,
Expand Down
1 change: 1 addition & 0 deletions code/addons/storyshots-core/src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare module '@storybook/babel-plugin-require-context-hook/register';
declare var STORYBOOK_ENV: any;
declare var STORIES: any;

declare var CONFIG_TYPE: 'DEVELOPMENT' | 'PRODUCTION';
declare var FEATURES:
| {
storyStoreV7?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions code/builders/builder-vite/src/codegen-set-addon-channel.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export async function generateAddonSetupCode() {
return `
import { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
import { createBrowserChannel } from '@storybook/channels';
import { addons } from '@storybook/preview-api';
const channel = createPostMessageChannel({ page: 'preview' });
const channel = createBrowserChannel({ page: 'preview' });
addons.setChannel(channel);
window.__STORYBOOK_ADDONS_CHANNEL__ = channel;
Expand Down
1 change: 1 addition & 0 deletions code/builders/builder-vite/src/optimizeDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const INCLUDE_CANDIDATES = [
'@storybook/addon-docs > acorn-jsx',
'@storybook/addon-docs',
'@storybook/addon-essentials/docs/mdx-react-shim',
'@storybook/channels',
'@storybook/channel-postmessage',
'@storybook/channel-websocket',
'@storybook/client-api',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { global } from '@storybook/global';

import { ClientApi, PreviewWeb, addons, composeConfigs } from '@storybook/preview-api';
import { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
import { createBrowserChannel } from '@storybook/channels';

import { importFn } from './{{storiesFilename}}';

const getProjectAnnotations = () =>
composeConfigs([{{#each previewAnnotations}}require('{{this}}'),{{/each}}]);

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

if (global.CONFIG_TYPE === 'DEVELOPMENT'){
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"node": "./dist/index.js",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"types": "./dist/entry.d.ts",
"node": "./dist/entry.js",
"require": "./dist/entry.js",
"import": "./dist/entry.mjs"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"main": "dist/entry.js",
"module": "dist/entry.mjs",
"types": "dist/entry.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand All @@ -43,14 +43,8 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/channel-websocket": "7.1.0-alpha.32",
"@storybook/channels": "7.1.0-alpha.32",
"@storybook/client-logger": "7.1.0-alpha.32",
"@storybook/core-events": "7.1.0-alpha.32",
"@storybook/global": "^5.0.0",
"qs": "^6.10.0",
"telejson": "^7.0.3",
"tiny-invariant": "^1.3.1"
"@storybook/client-logger": "7.1.0-alpha.32"
},
"devDependencies": {
"typescript": "~4.9.3"
Expand All @@ -60,8 +54,9 @@
},
"bundler": {
"entries": [
"./src/index.ts"
]
"./src/entry.ts"
],
"shim": "@storybook/channels/dist/postmessage/index"
},
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
}
File renamed without changes.
7 changes: 7 additions & 0 deletions code/deprecated/channel-postmessage/src/entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { deprecate } from '@storybook/client-logger';

deprecate(
'importing from @storybook/channel-postmessage is deprecated and will be removed in 8.0, please import createPostmessageChannel from @storybook/channels'
);

export * from '@storybook/channels/dist/postmessage/index';
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"node": "./dist/index.js",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"types": "./dist/entry.d.ts",
"node": "./dist/entry.js",
"require": "./dist/entry.js",
"import": "./dist/entry.mjs"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"main": "dist/entry.js",
"module": "dist/entry.mjs",
"types": "dist/entry.d.ts",
"files": [
"dist/**/*",
"README.md",
Expand All @@ -40,14 +40,11 @@
],
"scripts": {
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "../../../scripts/prepare/bundle.ts"
"prep": "../../../scripts/prepare/facade.ts"
},
"dependencies": {
"@storybook/channels": "7.1.0-alpha.32",
"@storybook/client-logger": "7.1.0-alpha.32",
"@storybook/global": "^5.0.0",
"telejson": "^7.0.3",
"tiny-invariant": "^1.3.1"
"@storybook/client-logger": "7.1.0-alpha.32"
},
"devDependencies": {
"typescript": "~4.9.3"
Expand All @@ -57,8 +54,9 @@
},
"bundler": {
"entries": [
"./src/index.ts"
]
"./src/entry.ts"
],
"shim": "@storybook/channels/dist/websocket/index"
},
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
}
File renamed without changes.
7 changes: 7 additions & 0 deletions code/deprecated/channel-websocket/src/entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { deprecate } from '@storybook/client-logger';

deprecate(
'importing from @storybook/channel-websocket is deprecated and will be removed in 8.0, please import createWebsocketChannel from @storybook/channels'
);

export * from '@storybook/channels/dist/websocket/index';
File renamed without changes.
2 changes: 0 additions & 2 deletions code/lib/channel-websocket/src/typings.d.ts

This file was deleted.

38 changes: 37 additions & 1 deletion code/lib/channels/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,36 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./dist/postmessage/index": {
"types": "./dist/postmessage/index.d.ts",
"node": "./dist/postmessage/index.js",
"require": "./dist/postmessage/index.js",
"import": "./dist/postmessage/index.mjs"
},
"./dist/websocket/index": {
"types": "./dist/websocket/index.d.ts",
"node": "./dist/websocket/index.js",
"require": "./dist/websocket/index.js",
"import": "./dist/websocket/index.mjs"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
"dist/index.d.ts"
],
"dist/postmessage/index": [
"dist/postmessage/index.d.ts"
],
"dist/websocket/index": [
"dist/websocket/index.d.ts"
]
}
},
"files": [
"dist/**/*",
"README.md",
Expand All @@ -42,6 +67,15 @@
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@storybook/channels": "7.1.0-alpha.32",
"@storybook/client-logger": "7.1.0-alpha.32",
"@storybook/core-events": "7.1.0-alpha.32",
"@storybook/global": "^5.0.0",
"qs": "^6.10.0",
"telejson": "^7.0.3",
"tiny-invariant": "^1.3.1"
},
"devDependencies": {
"typescript": "~4.9.3"
},
Expand All @@ -50,7 +84,9 @@
},
"bundler": {
"entries": [
"./src/index.ts"
"./src/index.ts",
"./src/postmessage/index.ts",
"./src/websocket/index.ts"
]
},
"gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae16"
Expand Down
Loading

0 comments on commit 4bbd7e8

Please sign in to comment.