@storybook/web-components 11.0.0-alpha.6 → 11.0.0-alpha.8
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-TXUT6K6E.js → chunk-4CVRUPXU.js} +9 -6
- package/dist/_browser-chunks/{chunk-BNL7LBNI.js → chunk-XOX44XZE.js} +18 -11
- package/dist/_node-chunks/{chunk-X7F7EONQ.js → chunk-7DGX2RHV.js} +527 -117
- package/dist/_node-chunks/chunk-A2ZEEPU6.js +76 -0
- 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 +131 -559
- 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
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_f6rwsm0jxpo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_f6rwsm0jxpo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_f6rwsm0jxpo from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_f6rwsm0jxpo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_f6rwsm0jxpo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_f6rwsm0jxpo.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 {
|
|
15
|
+
isStringLiteral,
|
|
16
|
+
loadCsf,
|
|
17
|
+
oneLineTextOf,
|
|
18
|
+
resolveBindingMembers,
|
|
19
|
+
resolveObjectMembers,
|
|
20
|
+
unwrapExpression
|
|
21
|
+
} from "storybook/internal/csf-tools";
|
|
22
|
+
import { readFileSync } from "node:fs";
|
|
23
|
+
function parseStoryFile(storyFilePath, title) {
|
|
24
|
+
try {
|
|
25
|
+
let source = readFileSync(storyFilePath, "utf8");
|
|
26
|
+
return loadCsf(source, { makeTitle: () => title, fileName: storyFilePath }).parse();
|
|
27
|
+
} catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function tagFromNode(csf, node) {
|
|
32
|
+
let unwrapped = unwrapExpression(node);
|
|
33
|
+
if (isStringLiteral(unwrapped) && unwrapped.value !== "")
|
|
34
|
+
return { tag: unwrapped.value };
|
|
35
|
+
if (unwrapped.type === "TemplateLiteral" && unwrapped.expressions.length === 0) {
|
|
36
|
+
let tag = unwrapped.quasis[0]?.value.cooked;
|
|
37
|
+
if (tag)
|
|
38
|
+
return { tag };
|
|
39
|
+
}
|
|
40
|
+
return { reason: "component-not-a-tag", expression: csf.editor.source(node) };
|
|
41
|
+
}
|
|
42
|
+
function resolveStoryComponent(csf) {
|
|
43
|
+
if (!csf._metaNode)
|
|
44
|
+
return { reason: "no-meta-component" };
|
|
45
|
+
let ctx = { editor: csf.editor, filePath: csf._options.fileName ?? "" }, members = resolveObjectMembers(csf._metaNode, ctx);
|
|
46
|
+
return componentIn(csf, members, csf._metaNode, ctx, /* @__PURE__ */ new Set()) ?? { reason: "no-meta-component" };
|
|
47
|
+
}
|
|
48
|
+
function componentIn(csf, members, object, ctx, visited) {
|
|
49
|
+
let component = members.properties.component;
|
|
50
|
+
if (component && !members.shadowed.includes("component"))
|
|
51
|
+
return tagFromNode(csf, component);
|
|
52
|
+
let unreadable = object.properties.filter((property) => property.type === "SpreadElement").filter((spread) => members.unresolved.includes(oneLineTextOf(spread))).reverse();
|
|
53
|
+
for (let spread of unreadable) {
|
|
54
|
+
let found = spreadComponent(csf, spread, ctx, visited);
|
|
55
|
+
if (found || component)
|
|
56
|
+
return found ?? { reason: "unresolvable-meta-spread", spread: oneLineTextOf(spread) };
|
|
57
|
+
}
|
|
58
|
+
return component && tagFromNode(csf, component);
|
|
59
|
+
}
|
|
60
|
+
function spreadComponent(csf, spread, ctx, visited) {
|
|
61
|
+
let local = localObject(unwrapExpression(spread.argument), ctx);
|
|
62
|
+
return !local || visited.has(local.object) ? { reason: "unresolvable-meta-spread", spread: oneLineTextOf(spread) } : componentIn(csf, local.members, local.object, ctx, new Set(visited).add(local.object));
|
|
63
|
+
}
|
|
64
|
+
function localObject(argument, ctx) {
|
|
65
|
+
if (argument.type === "ObjectExpression")
|
|
66
|
+
return { object: argument, members: resolveObjectMembers(argument, ctx) };
|
|
67
|
+
if (argument.type !== "Identifier")
|
|
68
|
+
return;
|
|
69
|
+
let declarator = ctx.editor.scopes.program.bindings.get(argument.name)?.node, init = declarator?.type === "VariableDeclarator" && declarator.init ? unwrapExpression(declarator.init) : void 0, members = resolveBindingMembers(ctx, argument.name);
|
|
70
|
+
return init?.type === "ObjectExpression" && members ? { object: init, members } : void 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
parseStoryFile,
|
|
75
|
+
resolveStoryComponent
|
|
76
|
+
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_f6rwsm0jxpo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_f6rwsm0jxpo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_f6rwsm0jxpo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_f6rwsm0jxpo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_f6rwsm0jxpo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_f6rwsm0jxpo.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
createDocgenProvider
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
15
|
-
import "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-7DGX2RHV.js";
|
|
15
|
+
import "../_node-chunks/chunk-A2ZEEPU6.js";
|
|
16
16
|
export {
|
|
17
17
|
createDocgenProvider
|
|
18
18
|
};
|
package/dist/docgen/index.d.ts
CHANGED
|
@@ -11,18 +11,20 @@ interface CemTag {
|
|
|
11
11
|
manifestPath: string;
|
|
12
12
|
warning?: string;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region code/renderers/web-components/.dts-emit/code/renderers/web-components/src/docgen/component-docgen/tag-resolver.d.ts
|
|
16
|
+
interface TagLookup {
|
|
17
|
+
storyFilePath: string;
|
|
18
|
+
}
|
|
19
|
+
interface TagResolver {
|
|
20
|
+
find(tag: string, lookup: TagLookup): Promise<CemTag | DocgenError>;
|
|
20
21
|
}
|
|
21
22
|
//#endregion
|
|
22
23
|
//#region code/renderers/web-components/.dts-emit/code/renderers/web-components/src/docgen/component-docgen/build-docgen.d.ts
|
|
23
24
|
interface WebComponentsDocgenOptions {
|
|
24
25
|
manifestPaths: string[];
|
|
25
|
-
|
|
26
|
+
/** Also searched for element registrations when generating from sources. */
|
|
27
|
+
previewFilePath?: string;
|
|
26
28
|
}
|
|
27
29
|
type WebComponentsDocgenPayload = DocgenPayload & {
|
|
28
30
|
/** Set while the manifest is served from its last valid version after a failed reload. */warning?: string;
|
|
@@ -32,18 +34,14 @@ type WebComponentsDocgenPayload = DocgenPayload & {
|
|
|
32
34
|
};
|
|
33
35
|
};
|
|
34
36
|
interface BuildDocgenContext {
|
|
35
|
-
|
|
36
|
-
typeProperty: string;
|
|
37
|
+
resolver: TagResolver;
|
|
37
38
|
}
|
|
38
|
-
declare function buildDocgenPayload(input: DocgenProviderInput, context: BuildDocgenContext): WebComponentsDocgenPayload | undefined
|
|
39
|
+
declare function buildDocgenPayload(input: DocgenProviderInput, context: BuildDocgenContext): Promise<WebComponentsDocgenPayload | undefined>;
|
|
39
40
|
//#endregion
|
|
40
41
|
//#region code/renderers/web-components/.dts-emit/code/renderers/web-components/src/docgen/docgen-worker.d.ts
|
|
41
42
|
declare const createDocgenProvider: ({
|
|
42
43
|
manifestPaths,
|
|
43
|
-
|
|
44
|
+
previewFilePath
|
|
44
45
|
}: WebComponentsDocgenOptions) => DocgenMiddleware;
|
|
45
46
|
//#endregion
|
|
46
|
-
|
|
47
|
-
declare const DEFAULT_TYPE_PROPERTY = "parsedType";
|
|
48
|
-
//#endregion
|
|
49
|
-
export { DEFAULT_TYPE_PROPERTY, type WebComponentsDocgenOptions, type WebComponentsDocgenPayload, buildDocgenPayload, createDocgenProvider };
|
|
47
|
+
export { type WebComponentsDocgenOptions, type WebComponentsDocgenPayload, buildDocgenPayload, createDocgenProvider };
|
package/dist/docgen/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_f6rwsm0jxpo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_f6rwsm0jxpo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_f6rwsm0jxpo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_f6rwsm0jxpo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_f6rwsm0jxpo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_f6rwsm0jxpo.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -12,12 +12,9 @@ var require = CJS_COMPAT_NODE_MODULE_3ov4ld79bt3.createRequire(import.meta.url);
|
|
|
12
12
|
import {
|
|
13
13
|
buildDocgenPayload,
|
|
14
14
|
createDocgenProvider
|
|
15
|
-
} from "../_node-chunks/chunk-
|
|
16
|
-
import
|
|
17
|
-
DEFAULT_TYPE_PROPERTY
|
|
18
|
-
} from "../_node-chunks/chunk-GDY64HEP.js";
|
|
15
|
+
} from "../_node-chunks/chunk-7DGX2RHV.js";
|
|
16
|
+
import "../_node-chunks/chunk-A2ZEEPU6.js";
|
|
19
17
|
export {
|
|
20
|
-
DEFAULT_TYPE_PROPERTY,
|
|
21
18
|
buildDocgenPayload,
|
|
22
19
|
createDocgenProvider
|
|
23
20
|
};
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
getCustomElements,
|
|
3
3
|
isValidComponent,
|
|
4
4
|
isValidMetaData
|
|
5
|
-
} from "./_browser-chunks/chunk-
|
|
6
|
-
import "./_browser-chunks/chunk-
|
|
5
|
+
} from "./_browser-chunks/chunk-4CVRUPXU.js";
|
|
6
|
+
import "./_browser-chunks/chunk-XOX44XZE.js";
|
|
7
7
|
import "./_browser-chunks/chunk-EGBR6PF2.js";
|
|
8
8
|
import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
|
11
11
|
import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
12
12
|
|
|
13
13
|
// src/docs/custom-elements.ts
|
|
14
|
-
import { logger } from "storybook/internal/client-logger";
|
|
14
|
+
import { deprecate, logger } from "storybook/internal/client-logger";
|
|
15
15
|
|
|
16
16
|
// ../../../node_modules/es-toolkit/dist/string/capitalize.mjs
|
|
17
17
|
function capitalize(str) {
|
|
@@ -111,7 +111,9 @@ var getMetaDataExperimental = (tagName, customElements) => {
|
|
|
111
111
|
declaration.tagName === tagName && (metadata = declaration);
|
|
112
112
|
});
|
|
113
113
|
}), metadata || logger.warn(`Component not found in custom-elements.json: ${tagName}`), metadata;
|
|
114
|
-
}, getMetaData = (tagName, manifest) => manifest?.version === "experimental" ?
|
|
114
|
+
}, getMetaData = (tagName, manifest) => manifest?.version === "experimental" ? (deprecate(
|
|
115
|
+
"The web-component-analyzer Custom Elements Manifest shape is deprecated and will be removed in Storybook 12. Generate a Custom Elements Manifest with @custom-elements-manifest/analyzer instead."
|
|
116
|
+
), getMetaDataExperimental(tagName, manifest)) : getMetaDataV1(tagName, manifest), extractArgTypesFromElements = (tagName, customElements) => {
|
|
115
117
|
let metaData = getMetaData(tagName, customElements);
|
|
116
118
|
return metaData && mapArgTypes(metaData);
|
|
117
119
|
}, extractArgTypes = (tagName) => {
|
|
@@ -123,7 +125,7 @@ var getMetaDataExperimental = (tagName, customElements) => {
|
|
|
123
125
|
};
|
|
124
126
|
|
|
125
127
|
// src/entry-preview-argtypes.ts
|
|
126
|
-
var parameters = {
|
|
128
|
+
var useServiceArgTypes = "FEATURES" in globalThis && globalThis.FEATURES?.docgenServer, parameters = useServiceArgTypes ? {} : {
|
|
127
129
|
docs: {
|
|
128
130
|
extractArgTypes,
|
|
129
131
|
extractComponentDescription
|
package/dist/entry-preview.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -8,14 +8,11 @@ type WebComponentsFrameworkOptions = {
|
|
|
8
8
|
* Paths to Custom Elements Manifest files, relative to the Storybook config directory.
|
|
9
9
|
*
|
|
10
10
|
* When omitted, Storybook reads `customElements` from the nearest `package.json`.
|
|
11
|
-
*
|
|
11
|
+
* Tags no manifest declares are generated from the project's sources.
|
|
12
12
|
*
|
|
13
|
-
* Please note that the runtime `setCustomElementsManifest` path is deprecated and will be removed in
|
|
13
|
+
* Please note that the runtime `setCustomElementsManifest` path is deprecated and will be removed in Storybook 12.
|
|
14
14
|
*/
|
|
15
15
|
customElementsManifest?: string | string[];
|
|
16
|
-
docgen?: {
|
|
17
|
-
/** Manifest key that holds analyzer-resolved type text; defaults to `parsedType`. */typeProperty?: string;
|
|
18
|
-
};
|
|
19
16
|
};
|
|
20
17
|
type StoryFnHtmlReturnType = string | Node | DocumentFragment | TemplateResult | SVGTemplateResult;
|
|
21
18
|
interface WebComponentsRenderer extends WebRenderer {
|
|
@@ -49,11 +46,15 @@ type StoryContext<TArgs = StrictArgs$1> = StoryContext$1<WebComponentsRenderer,
|
|
|
49
46
|
type Preview = ProjectAnnotations<WebComponentsRenderer>;
|
|
50
47
|
//#endregion
|
|
51
48
|
//#region code/renderers/web-components/.dts-emit/code/renderers/web-components/src/framework-api.d.ts
|
|
49
|
+
/** @deprecated Use framework.options.customElementsManifest with features.docgenServer instead. This runtime manifest helper will be removed in Storybook 12. */
|
|
52
50
|
declare function isValidComponent(tagName: string): boolean;
|
|
51
|
+
/** @deprecated Use framework.options.customElementsManifest with features.docgenServer instead. This runtime manifest helper will be removed in Storybook 12. */
|
|
53
52
|
declare function isValidMetaData(customElements: any): boolean;
|
|
54
|
-
/** @
|
|
53
|
+
/** @deprecated Use framework.options.customElementsManifest with features.docgenServer instead. This runtime manifest setter will be removed in Storybook 12. */
|
|
55
54
|
declare function setCustomElements(customElements: any): void;
|
|
55
|
+
/** @deprecated Use framework.options.customElementsManifest with features.docgenServer instead. This runtime manifest setter will be removed in Storybook 12. */
|
|
56
56
|
declare function setCustomElementsManifest(customElements: any): void;
|
|
57
|
+
/** @deprecated Use framework.options.customElementsManifest with features.docgenServer instead. This runtime manifest getter will be removed in Storybook 12. */
|
|
57
58
|
declare function getCustomElements(): any;
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region code/renderers/web-components/.dts-emit/code/renderers/web-components/src/portable-stories.d.ts
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
setCustomElements,
|
|
7
7
|
setCustomElementsManifest,
|
|
8
8
|
setProjectAnnotations
|
|
9
|
-
} from "./_browser-chunks/chunk-
|
|
10
|
-
import "./_browser-chunks/chunk-
|
|
9
|
+
} from "./_browser-chunks/chunk-4CVRUPXU.js";
|
|
10
|
+
import "./_browser-chunks/chunk-XOX44XZE.js";
|
|
11
11
|
import "./_browser-chunks/chunk-EGBR6PF2.js";
|
|
12
12
|
import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
13
13
|
export {
|