@storybook/web-components 11.0.0-alpha.6 → 11.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/{chunk-BNL7LBNI.js → chunk-CAPEJO4V.js} +2 -2
- package/dist/_browser-chunks/{chunk-TXUT6K6E.js → chunk-IPGO7UEM.js} +9 -6
- package/dist/_node-chunks/chunk-MMJPCIXK.js +45 -0
- package/dist/_node-chunks/{chunk-X7F7EONQ.js → chunk-P75AOQLO.js} +500 -106
- package/dist/docgen/docgen-worker.js +8 -8
- package/dist/docgen/index.d.ts +13 -15
- package/dist/docgen/index.js +8 -11
- package/dist/entry-preview-argtypes.js +7 -5
- package/dist/entry-preview.js +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +2 -2
- package/dist/preset.js +63 -15
- package/package.json +7 -4
- package/template/stories_lit-vite-default-ts/demo-wc-counter/DemoWcCounter.js +176 -0
- package/template/stories_lit-vite-default-ts/demo-wc-counter/index.js +3 -0
- package/template/stories_lit-vite-default-ts/demo-wc-counter.stories.js +217 -0
- package/dist/_node-chunks/chunk-GDY64HEP.js +0 -87
|
@@ -137,7 +137,7 @@ var { Node: Node2 } = global, render = (args, context) => {
|
|
|
137
137
|
}
|
|
138
138
|
return fragment.append(element), fragment;
|
|
139
139
|
};
|
|
140
|
-
function renderToCanvas({ storyFn,
|
|
140
|
+
function renderToCanvas({ storyFn, title, name, showMain, showError, forceRemount }, canvasElement) {
|
|
141
141
|
let element = storyFn();
|
|
142
142
|
if (showMain(), isTemplateResult(element)) {
|
|
143
143
|
(forceRemount || !canvasElement.querySelector('[id="root-inner"]')) && (canvasElement.innerHTML = '<div id="root-inner"></div>');
|
|
@@ -151,7 +151,7 @@ function renderToCanvas({ storyFn, kind, name, showMain, showError, forceRemount
|
|
|
151
151
|
canvasElement.innerHTML = "", canvasElement.appendChild(element), simulateDOMContentLoaded();
|
|
152
152
|
} else
|
|
153
153
|
showError({
|
|
154
|
-
title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${
|
|
154
|
+
title: `Expecting an HTML snippet or DOM node from the story: "${name}" of "${title}".`,
|
|
155
155
|
description: dedent`
|
|
156
156
|
Did you forget to return the HTML snippet from the story?
|
|
157
157
|
Use "() => <your snippet or node>" or when defining the story.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
entry_preview_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CAPEJO4V.js";
|
|
4
4
|
import {
|
|
5
5
|
entry_preview_docs_exports
|
|
6
6
|
} from "./chunk-EGBR6PF2.js";
|
|
@@ -15,6 +15,8 @@ globalWindow.STORYBOOK_ENV = "web-components";
|
|
|
15
15
|
|
|
16
16
|
// src/framework-api.ts
|
|
17
17
|
import { global as global2 } from "@storybook/global";
|
|
18
|
+
import { deprecate } from "storybook/internal/client-logger";
|
|
19
|
+
var RUNTIME_MANIFEST_DEPRECATION = "The runtime Custom Elements Manifest is deprecated and will be removed in Storybook 12. Set framework.options.customElementsManifest in .storybook/main and enable features.docgenServer instead.";
|
|
18
20
|
function isValidComponent(tagName) {
|
|
19
21
|
if (!tagName)
|
|
20
22
|
return !1;
|
|
@@ -27,17 +29,18 @@ function isValidMetaData(customElements) {
|
|
|
27
29
|
return !1;
|
|
28
30
|
if (customElements.tags && Array.isArray(customElements.tags) || customElements.modules && Array.isArray(customElements.modules))
|
|
29
31
|
return !0;
|
|
30
|
-
throw new Error(
|
|
31
|
-
|
|
32
|
+
throw new Error(
|
|
33
|
+
"You need to set up valid Custom Elements metadata with a manifest generated by @custom-elements-manifest/analyzer. Configure it with framework.options.customElementsManifest in .storybook/main."
|
|
34
|
+
);
|
|
32
35
|
}
|
|
33
36
|
function setCustomElements(customElements) {
|
|
34
|
-
global2.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
|
|
37
|
+
deprecate(`setCustomElements() is deprecated: ${RUNTIME_MANIFEST_DEPRECATION}`), global2.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
|
|
35
38
|
}
|
|
36
39
|
function setCustomElementsManifest(customElements) {
|
|
37
|
-
global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
|
|
40
|
+
deprecate(`setCustomElementsManifest() is deprecated: ${RUNTIME_MANIFEST_DEPRECATION}`), global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
|
|
38
41
|
}
|
|
39
42
|
function getCustomElements() {
|
|
40
|
-
return global2.
|
|
43
|
+
return global2.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ || global2.__STORYBOOK_CUSTOM_ELEMENTS__;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
// src/portable-stories.ts
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_seyt09815b from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_seyt09815b from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_seyt09815b from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_seyt09815b.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_seyt09815b.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_seyt09815b.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// src/docgen/component-docgen/resolve-component/resolve-component.ts
|
|
14
|
+
import { loadCsf, unwrapExpression } from "storybook/internal/csf-tools";
|
|
15
|
+
import { recast, types as t } from "storybook/internal/babel";
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
function parseStoryFile(storyFilePath, title) {
|
|
18
|
+
try {
|
|
19
|
+
let source = readFileSync(storyFilePath, "utf8");
|
|
20
|
+
return loadCsf(source, { makeTitle: () => title }).parse();
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
var expressionFor = (node) => recast.print(node).code;
|
|
26
|
+
function tagFromNode(node) {
|
|
27
|
+
let expression = expressionFor(node), unwrapped = unwrapExpression(node);
|
|
28
|
+
if (t.isStringLiteral(unwrapped) && unwrapped.value !== "")
|
|
29
|
+
return { tag: unwrapped.value };
|
|
30
|
+
if (t.isTemplateLiteral(unwrapped) && unwrapped.expressions.length === 0) {
|
|
31
|
+
let tag = unwrapped.quasis[0]?.value.cooked;
|
|
32
|
+
if (tag)
|
|
33
|
+
return { tag };
|
|
34
|
+
}
|
|
35
|
+
return { reason: "component-not-a-tag", expression };
|
|
36
|
+
}
|
|
37
|
+
function resolveStoryComponent(csf) {
|
|
38
|
+
let component = csf._metaAnnotations.component;
|
|
39
|
+
return component ? tagFromNode(component) : { reason: "no-meta-component" };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
parseStoryFile,
|
|
44
|
+
resolveStoryComponent
|
|
45
|
+
};
|