index.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { b as ChannelTransport, d as ChannelHandler, C as Channel } from '../main-c55d8855.js';
  2. type OnError = (message: Event) => void;
  3. interface WebsocketTransportArgs {
  4. url: string;
  5. onError: OnError;
  6. }
  7. interface CreateChannelArgs {
  8. url?: string;
  9. async?: boolean;
  10. onError?: OnError;
  11. }
  12. declare class WebsocketTransport implements ChannelTransport {
  13. private buffer;
  14. private handler?;
  15. private socket;
  16. private isReady;
  17. constructor({ url, onError }: WebsocketTransportArgs);
  18. setHandler(handler: ChannelHandler): void;
  19. send(event: any): void;
  20. private sendLater;
  21. private sendNow;
  22. private flush;
  23. }
  24. /**
  25. * @deprecated This function is deprecated. Use the `createBrowserChannel` factory function from `@storybook/channels` instead. This API will be removed in 8.0.
  26. * @param {CreateChannelArgs} options - The options for creating the channel.
  27. * @param {string} [options.url] - The URL of the WebSocket server to connect to.
  28. * @param {boolean} [options.async=false] - Whether the channel should be asynchronous.
  29. * @param {OnError} [options.onError] - A function to handle errors that occur during the channel's lifetime.
  30. * @returns {Channel} - The newly created channel.
  31. */
  32. declare function createChannel({ url, async, onError, }: CreateChannelArgs): Channel;
  33. export { WebsocketTransport, createChannel, createChannel as default };