@stories-js/core
Version:
Stories web components to build stories
54 lines (48 loc) • 1.44 kB
JavaScript
/*!
* (C) StoriesJS https://storiesjs.org - GPL-2.0 License
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
const index = require('./index-c25eada5.js');
const index$1 = require('./index-ad63dbd0.js');
const addonsCss = "";
const Addons = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async registerAddon(addon) {
const addons = index$1.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 = index$1.state.addons;
if (!addons[addon.id]) {
throw new Error(`Cannot unregister addon ${addon.id}`);
}
delete addons[addon.id];
}
async findAddon(id) {
const addons = index$1.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(index$1.state.addons).forEach(addon => {
addon.storyContextChanged(story, context);
});
}
render() {
return (index.h("slot", null));
}
};
Addons.style = addonsCss;
exports.stories_addons = Addons;
//# sourceMappingURL=stories-addons.cjs.entry.js.map