@storybook/web-components
Version:
Storybook Web Components renderer: Develop, document, and test UI components in isolation
69 lines (62 loc) • 2.14 kB
JavaScript
import {
entry_preview_exports
} from "./chunk-UN5GYDGC.js";
// src/index.ts
import { global as global3 } from "@storybook/global";
// src/globals.ts
import { global } from "@storybook/global";
var { window: globalWindow } = global;
globalWindow.STORYBOOK_ENV = "web-components";
// src/framework-api.ts
import { global as global2 } from "@storybook/global";
function isValidComponent(tagName) {
if (!tagName)
return !1;
if (typeof tagName == "string")
return !0;
throw new Error('Provided component needs to be a string. e.g. component: "my-element"');
}
function isValidMetaData(customElements) {
if (!customElements)
return !1;
if (customElements.tags && Array.isArray(customElements.tags) || customElements.modules && Array.isArray(customElements.modules))
return !0;
throw new Error(`You need to setup valid meta data in your config.js via setCustomElements().
See the readme of addon-docs for web components for more details.`);
}
function setCustomElements(customElements) {
global2.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
}
function setCustomElementsManifest(customElements) {
global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
}
function getCustomElements() {
return global2.__STORYBOOK_CUSTOM_ELEMENTS__ || global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__;
}
// src/portable-stories.ts
import {
setProjectAnnotations as originalSetProjectAnnotations,
setDefaultProjectAnnotations
} from "storybook/preview-api";
function setProjectAnnotations(projectAnnotations) {
return setDefaultProjectAnnotations(entry_preview_exports), originalSetProjectAnnotations(
projectAnnotations
);
}
// src/index.ts
var { window, EventSource } = global3;
typeof module < "u" && module?.hot?.decline && (module.hot.decline(), new EventSource("__webpack_hmr").addEventListener("message", function(event) {
try {
let { action } = JSON.parse(event.data);
action === "built" && window.location.reload();
} catch {
}
}));
export {
isValidComponent,
isValidMetaData,
setCustomElements,
setCustomElementsManifest,
getCustomElements,
setProjectAnnotations
};