Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._asyncStorage = params.asyncStorage;
}
const onDeviceUI = params.onDeviceUI !== false;
const { initialSelection, shouldPersistSelection } = params;
try {
channel = addons.getChannel();
} catch (e) {
// getChannel throws if the channel is not defined,
// which is fine in this case (we will define it below)
}
if (!channel || params.resetStorybook) {
if (onDeviceUI && params.disableWebsockets) {
channel = new Channel({ async: true });
this._setInitialStory(initialSelection, shouldPersistSelection);
} else {
const host = getHost(params.host || 'localhost');
const port = `:${params.port || 7007}`;
const query = params.query || '';
const { secured } = params;
const websocketType = secured ? 'wss' : 'ws';
const httpType = secured ? 'https' : 'http';
const url = `${websocketType}://${host}${port}/${query}`;
webUrl = `${httpType}://${host}${port}`;
channel = createChannel({
url,
async: onDeviceUI,
onError: () => {
export default function createChannel({ page }: Config): Channel {
const transport = new PostmsgTransport({ page });
return new Channel({ transport });
}
export function mockChannel() {
const transport = {
setHandler: () => {},
send: () => {},
};
return new Channel({ transport });
}