Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- [Deprecated docs parameters](#deprecated-docs-parameters)
- [Description Doc block properties](#description-doc-block-properties)
- [Manager API expandAll and collapseAll methods](#manager-api-expandall-and-collapseall-methods)
- [`createChannel` from `@storybook/postmessage` and `@storybook/channel-websocket`](#createchannel-from-storybookpostmessage-and--storybookchannel-websocket)
- [From version 7.5.0 to 7.6.0](#from-version-750-to-760)
- [CommonJS with Vite is deprecated](#commonjs-with-vite-is-deprecated)
- [Using implicit actions during rendering is deprecated](#using-implicit-actions-during-rendering-is-deprecated)
Expand Down Expand Up @@ -877,6 +878,12 @@ api.collapseAll() // becomes api.emit(STORIES_COLLAPSE_ALL)
api.expandAll() // becomes api.emit(STORIES_EXPAND_ALL)
```

#### `createChannel` from `@storybook/postmessage` and `@storybook/channel-websocket`

The `createChannel` APIs from both `@storybook/channel-websocket` and `@storybook/postmessage` are now removed. Please use `createBrowserChannel` instead, from the `@storybook/channels` package.

Additionally, the `PostmsgTransport` type is now removed in favor of `PostMessageTransport`.

## From version 7.5.0 to 7.6.0

#### CommonJS with Vite is deprecated
Expand Down
4 changes: 2 additions & 2 deletions code/lib/channels/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export * from './main';

export default Channel;

export { createChannel as createPostMessageChannel, PostMessageTransport } from './postmessage';
export { createChannel as createWebSocketChannel, WebsocketTransport } from './websocket';
export { PostMessageTransport } from './postmessage';
export { WebsocketTransport } from './websocket';

type Options = Config & {
extraTransports?: ChannelTransport[];
Expand Down
23 changes: 0 additions & 23 deletions code/lib/channels/src/postmessage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { logger, pretty } from '@storybook/client-logger';
import { isJSON, parse, stringify } from 'telejson';
import qs from 'qs';
import invariant from 'tiny-invariant';
import { Channel } from '../main';
import type {
ChannelTransport,
BufferedEvent,
Expand Down Expand Up @@ -243,25 +242,3 @@ export class PostMessageTransport implements ChannelTransport {
}
}
}

/**
* @deprecated This export is deprecated. Use `PostMessageTransport` instead. This API will be removed in 8.0.
*/
export const PostmsgTransport = PostMessageTransport;

/**
* @deprecated This function is deprecated. Use the `createBrowserChannel` factory function from `@storybook/channels` instead. This API will be removed in 8.0.
* @param {Config} config - The configuration object.
* @returns {Channel} The channel instance.
*/
export function createChannel({ page }: Config): Channel {
const transport = new PostmsgTransport({ page });
return new Channel({ transport });
}

/**
* @deprecated This function is deprecated. Use the `createBrowserChannel` factory function from `@storybook/channels` instead. This API will be removed in 8.0.
* @param {Config} config - The configuration object.
* @returns {Channel} The channel instance.
*/
export default createChannel;
36 changes: 1 addition & 35 deletions code/lib/channels/src/websocket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
/// <reference path="../typings.d.ts" />

import { global } from '@storybook/global';
import { logger } from '@storybook/client-logger';
import { isJSON, parse, stringify } from 'telejson';
import invariant from 'tiny-invariant';
import { Channel } from '../main';

import type { ChannelTransport, ChannelHandler } from '../types';

const { WebSocket } = global;
Expand All @@ -17,12 +16,6 @@ interface WebsocketTransportArgs {
onError: OnError;
}

interface CreateChannelArgs {
url?: string;
async?: boolean;
onError?: OnError;
}

export class WebsocketTransport implements ChannelTransport {
private buffer: string[] = [];

Expand Down Expand Up @@ -77,30 +70,3 @@ export class WebsocketTransport implements ChannelTransport {
buffer.forEach((event) => this.send(event));
}
}

/**
* @deprecated This function is deprecated. Use the `createBrowserChannel` factory function from `@storybook/channels` instead. This API will be removed in 8.0.
* @param {CreateChannelArgs} options - The options for creating the channel.
* @param {string} [options.url] - The URL of the WebSocket server to connect to.
* @param {boolean} [options.async=false] - Whether the channel should be asynchronous.
* @param {OnError} [options.onError] - A function to handle errors that occur during the channel's lifetime.
* @returns {Channel} - The newly created channel.
*/
export function createChannel({
url,
async = false,
onError = (err) => logger.warn(err),
}: CreateChannelArgs) {
let channelUrl = url;
if (!channelUrl) {
const protocol = window.location.protocol === 'http:' ? 'ws' : 'wss';
const { hostname, port } = window.location;
channelUrl = `${protocol}://${hostname}:${port}/storybook-server-channel`;
}

const transport = new WebsocketTransport({ url: channelUrl, onError });
return new Channel({ transport, async });
}

// backwards compat with builder-vite
export default createChannel;
2 changes: 0 additions & 2 deletions code/ui/manager/src/globals/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ export default {
'PostMessageTransport',
'WebsocketTransport',
'createBrowserChannel',
'createPostMessageChannel',
'createWebSocketChannel',
],
'@storybook/core-events': [
'CHANNEL_CREATED',
Expand Down