UNPKG

1.33 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.init = void 0;
7
8require("core-js/modules/es.array.concat.js");
9
10var _coreEvents = require("@storybook/core-events");
11
12var init = function init(_ref) {
13 var provider = _ref.provider;
14 var api = {
15 getChannel: function getChannel() {
16 return provider.channel;
17 },
18 on: function on(type, cb) {
19 provider.channel.addListener(type, cb);
20 return function () {
21 return provider.channel.removeListener(type, cb);
22 };
23 },
24 off: function off(type, cb) {
25 return provider.channel.removeListener(type, cb);
26 },
27 once: function once(type, cb) {
28 return provider.channel.once(type, cb);
29 },
30 emit: function emit(type) {
31 var _provider$channel;
32
33 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
34 args[_key - 1] = arguments[_key];
35 }
36
37 return (_provider$channel = provider.channel).emit.apply(_provider$channel, [type].concat(args));
38 },
39 collapseAll: function collapseAll() {
40 provider.channel.emit(_coreEvents.STORIES_COLLAPSE_ALL, {});
41 },
42 expandAll: function expandAll() {
43 api.emit(_coreEvents.STORIES_EXPAND_ALL);
44 }
45 };
46 return {
47 api: api
48 };
49};
50
51exports.init = init;
\No newline at end of file