@stories-js/core
Version:
Stories web components to build stories
50 lines (46 loc) • 1.33 kB
JavaScript
/*!
* (C) StoriesJS https://storiesjs.org - GPL-2.0 License
*/
import { r as registerInstance, h } from './index-49238f69.js';
import { s as state } from './index-f706f0f6.js';
const addonsCss = "";
const Addons = class {
constructor(hostRef) {
registerInstance(this, hostRef);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async registerAddon(addon) {
const addons = state.addons;
if (addons[addon.id]) {
throw new Error(`Please remove duplicate addon ${addon.id}`);
}
addons[addon.id] = addon;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async unregisterAddon(addon) {
const addons = state.addons;
if (!addons[addon.id]) {
throw new Error(`Cannot unregister addon ${addon.id}`);
}
delete addons[addon.id];
}
async findAddon(id) {
const addons = state.addons;
if (!addons[id]) {
throw new Error(`Cannot find addon by id ${id}`);
}
return addons[id];
}
async storyContextChanged(story, context) {
// Update all addons
Object.values(state.addons).forEach(addon => {
addon.storyContextChanged(story, context);
});
}
render() {
return (h("slot", null));
}
};
Addons.style = addonsCss;
export { Addons as stories_addons };
//# sourceMappingURL=stories-addons.entry.js.map