@storybook/web-components 11.0.0-alpha.7 → 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-IPGO7UEM.js → chunk-4CVRUPXU.js} +1 -1
- package/dist/_browser-chunks/{chunk-CAPEJO4V.js → chunk-XOX44XZE.js} +16 -9
- package/dist/_node-chunks/{chunk-P75AOQLO.js → chunk-7DGX2RHV.js} +34 -18
- package/dist/_node-chunks/chunk-A2ZEEPU6.js +76 -0
- package/dist/docgen/docgen-worker.js +8 -8
- package/dist/docgen/index.js +8 -8
- package/dist/entry-preview-argtypes.js +2 -2
- package/dist/entry-preview.js +1 -1
- package/dist/index.js +2 -2
- package/dist/preset.js +129 -605
- package/package.json +2 -2
- package/dist/_node-chunks/chunk-MMJPCIXK.js +0 -45
package/dist/preset.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,7 +12,7 @@ var require = CJS_COMPAT_NODE_MODULE_seyt09815b.createRequire(import.meta.url);
|
|
|
12
12
|
import {
|
|
13
13
|
parseStoryFile,
|
|
14
14
|
resolveStoryComponent
|
|
15
|
-
} from "./_node-chunks/chunk-
|
|
15
|
+
} from "./_node-chunks/chunk-A2ZEEPU6.js";
|
|
16
16
|
|
|
17
17
|
// src/preset.ts
|
|
18
18
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -68,7 +68,6 @@ import { createWorkerGatedStoryDocsProvider, getService } from "storybook/intern
|
|
|
68
68
|
import { logger } from "storybook/internal/node-logger";
|
|
69
69
|
|
|
70
70
|
// src/docgen/story-docs/build-story-docs.ts
|
|
71
|
-
import { types as t7 } from "storybook/internal/babel";
|
|
72
71
|
import { getComponentIdFromEntry, getStoryImportPathFromEntry } from "storybook/internal/common";
|
|
73
72
|
import { storyNameFromExport } from "storybook/internal/csf";
|
|
74
73
|
import {
|
|
@@ -77,38 +76,41 @@ import {
|
|
|
77
76
|
createStoryReferenceResolver,
|
|
78
77
|
extractStoryJSDocInfo,
|
|
79
78
|
noSnippetWarning,
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
resolveEffectiveRender,
|
|
80
|
+
oneLineTextOf as oneLineTextOf5,
|
|
81
|
+
unwrapExpression as unwrapExpression4,
|
|
82
82
|
unresolvedWarning
|
|
83
83
|
} from "storybook/internal/csf-tools";
|
|
84
84
|
import { resolve as resolve2 } from "node:path";
|
|
85
85
|
|
|
86
86
|
// src/docgen/story-docs/arg-values.ts
|
|
87
|
-
import {
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
import {
|
|
88
|
+
staticKey,
|
|
89
|
+
oneLineTextOf,
|
|
90
|
+
templateParts,
|
|
91
|
+
unwrapExpression
|
|
92
|
+
} from "storybook/internal/csf-tools";
|
|
93
|
+
var FAILED = /* @__PURE__ */ Symbol("failed"), isFunctionNode = (node) => node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration", primitiveLiteralValue = (node) => node.type !== "Literal" ? FAILED : ["string", "number", "boolean"].includes(typeof node.value) ? node.value : node.value === null && !("regex" in node) && !("bigint" in node) ? null : FAILED;
|
|
90
94
|
function evaluateArgValue(node) {
|
|
91
95
|
let value = evaluate(node);
|
|
92
96
|
if (value === FAILED) {
|
|
93
97
|
let unwrapped = unwrapExpression(node);
|
|
94
|
-
return
|
|
98
|
+
return isFunctionNode(unwrapped) ? { kind: "function" } : { kind: "unresolved", source: oneLineTextOf(node) };
|
|
95
99
|
}
|
|
96
100
|
return value === void 0 ? { kind: "unset" } : { kind: "value", value };
|
|
97
101
|
}
|
|
98
102
|
var evaluate = (node) => {
|
|
99
|
-
let unwrapped = unwrapExpression(node);
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
if (
|
|
103
|
-
if (t.isIdentifier(unwrapped, { name: "undefined" }) || t.isUnaryExpression(unwrapped) && unwrapped.operator === "void") return;
|
|
104
|
-
if (t.isUnaryExpression(unwrapped) && (unwrapped.operator === "-" || unwrapped.operator === "+") && t.isNumericLiteral(unwrapped.argument))
|
|
103
|
+
let unwrapped = unwrapExpression(node), literal = primitiveLiteralValue(unwrapped);
|
|
104
|
+
if (literal !== FAILED) return literal;
|
|
105
|
+
if (unwrapped.type === "Identifier" && unwrapped.name === "undefined" || unwrapped.type === "UnaryExpression" && unwrapped.operator === "void") return;
|
|
106
|
+
if (unwrapped.type === "UnaryExpression" && (unwrapped.operator === "-" || unwrapped.operator === "+") && unwrapped.argument.type === "Literal" && typeof unwrapped.argument.value == "number")
|
|
105
107
|
return unwrapped.operator === "-" ? -unwrapped.argument.value : unwrapped.argument.value;
|
|
106
108
|
let parts = templateParts(unwrapped);
|
|
107
|
-
return parts && parts.expressions.length === 0 ? parts.quasis[0] ?? FAILED :
|
|
109
|
+
return parts && parts.expressions.length === 0 ? parts.quasis[0] ?? FAILED : isFunctionNode(unwrapped) ? FAILED : unwrapped.type === "ArrayExpression" ? evaluateArray(unwrapped) : unwrapped.type === "ObjectExpression" ? evaluateObject(unwrapped) : FAILED;
|
|
108
110
|
}, evaluateArray = (node) => {
|
|
109
111
|
let values = [];
|
|
110
112
|
for (let element of node.elements) {
|
|
111
|
-
if (element === null ||
|
|
113
|
+
if (element === null || element.type === "SpreadElement")
|
|
112
114
|
return FAILED;
|
|
113
115
|
let value = evaluate(element);
|
|
114
116
|
if (value === FAILED)
|
|
@@ -119,10 +121,10 @@ var evaluate = (node) => {
|
|
|
119
121
|
}, evaluateObject = (node) => {
|
|
120
122
|
let values = {};
|
|
121
123
|
for (let property of node.properties) {
|
|
122
|
-
if (
|
|
124
|
+
if (property.type !== "Property" || property.method || property.kind !== "init" || property.computed)
|
|
123
125
|
return FAILED;
|
|
124
|
-
let key =
|
|
125
|
-
if (key ===
|
|
126
|
+
let key = staticKey(property), value = evaluate(property.value);
|
|
127
|
+
if (key === void 0 || value === FAILED)
|
|
126
128
|
return FAILED;
|
|
127
129
|
values[key] = value;
|
|
128
130
|
}
|
|
@@ -162,15 +164,15 @@ function classifyArg(key, isFunction, argTypes, declaration) {
|
|
|
162
164
|
case "attributes":
|
|
163
165
|
return attributeBinding(
|
|
164
166
|
name,
|
|
165
|
-
attributeViaField(
|
|
166
|
-
attributeDefault(
|
|
167
|
+
attributeViaField(name, declaration),
|
|
168
|
+
attributeDefault(name, declaration)
|
|
167
169
|
);
|
|
168
170
|
case "properties": {
|
|
169
171
|
let attribute = pairedAttribute(name, declaration);
|
|
170
172
|
return attribute ? attributeBinding(
|
|
171
173
|
attribute,
|
|
172
174
|
!0,
|
|
173
|
-
fieldDefault(name, declaration) ?? attributeDefault(
|
|
175
|
+
fieldDefault(name, declaration) ?? attributeDefault(attribute, declaration)
|
|
174
176
|
) : { kind: "property", name };
|
|
175
177
|
}
|
|
176
178
|
case "events":
|
|
@@ -201,8 +203,8 @@ var fieldDefault = (fieldName, declaration) => fieldDeclaration(fieldName, decla
|
|
|
201
203
|
...defaultValue === void 0 ? {} : { defaultValue }
|
|
202
204
|
}), fieldDeclaration = (fieldName, declaration) => declaration.members?.find(
|
|
203
205
|
(member) => member.kind === "field" && member.name === fieldName
|
|
204
|
-
), attributeDeclaration = (attributeName, declaration) => declaration.attributes?.find((attribute) => attribute.name === attributeName), attributeViaField = (
|
|
205
|
-
let attribute = attributeDeclaration(attributeName, declaration), fieldName = attribute?.fieldName
|
|
206
|
+
), attributeDeclaration = (attributeName, declaration) => declaration.attributes?.find((attribute) => attribute.name === attributeName), attributeViaField = (attributeName, declaration) => pairedAttribute(attributeName, declaration) === attributeName, attributeDefault = (attributeName, declaration) => {
|
|
207
|
+
let attribute = attributeDeclaration(attributeName, declaration), fieldName = attribute?.fieldName ?? (attributeViaField(attributeName, declaration) ? attributeName : void 0);
|
|
206
208
|
return (fieldName ? fieldDefault(fieldName, declaration) : void 0) ?? attribute?.default;
|
|
207
209
|
}, eventForArg = (key, declaration) => {
|
|
208
210
|
let matches = declaration.events?.filter(
|
|
@@ -609,82 +611,82 @@ var printCssProperties = (properties) => {
|
|
|
609
611
|
];
|
|
610
612
|
}, hasSlotAttribute = (node) => node.attributes.some((attribute) => attribute.name === "slot"), escapeScriptString = (value) => value.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/</g, "\\x3C"), sanitizeScriptHandler = (value) => value.replace(/<!--/g, "<\\!--").replace(/<script/gi, "<\\script").replace(/<\/script/gi, "<\\/script");
|
|
611
613
|
|
|
612
|
-
// src/docgen/story-docs/template-print.ts
|
|
613
|
-
import { sourceOf as sourceOf4 } from "storybook/internal/csf-tools";
|
|
614
|
-
|
|
615
614
|
// src/docgen/story-docs/template-holes.ts
|
|
616
|
-
import {
|
|
617
|
-
|
|
615
|
+
import {
|
|
616
|
+
oneLineTextOf as oneLineTextOf3,
|
|
617
|
+
reindent,
|
|
618
|
+
textOf,
|
|
619
|
+
unwrapExpression as unwrapExpression3,
|
|
620
|
+
walk
|
|
621
|
+
} from "storybook/internal/csf-tools";
|
|
618
622
|
|
|
619
623
|
// src/docgen/story-docs/template-scope.ts
|
|
620
|
-
import { types as t2 } from "storybook/internal/babel";
|
|
621
624
|
import {
|
|
622
625
|
collectImportBindings,
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
+
isStringLiteral,
|
|
627
|
+
staticKey as staticKey2,
|
|
628
|
+
returnedExpression,
|
|
629
|
+
oneLineTextOf as oneLineTextOf2,
|
|
626
630
|
unwrapExpression as unwrapExpression2
|
|
627
631
|
} from "storybook/internal/csf-tools";
|
|
628
632
|
var TEMPLATE_TAG_SOURCES = ["lit", "lit-html", "lit-element"];
|
|
629
633
|
function resolveHtmlTemplate(renderFunction, csf) {
|
|
630
|
-
let bindings = collectImportBindings(csf.
|
|
634
|
+
let bindings = collectImportBindings(csf.program), returned = returnedTemplateExpression(renderFunction, bindings);
|
|
631
635
|
return returned ? templateFromExpression(unwrapExpression2(returned.node), bindings, returned.scope) : void 0;
|
|
632
636
|
}
|
|
633
637
|
function templateFromExpression(expression, bindings, scope) {
|
|
634
|
-
if (
|
|
638
|
+
if (isStringLiteral(expression))
|
|
635
639
|
return {
|
|
636
640
|
bindings,
|
|
637
641
|
expressions: [],
|
|
638
642
|
lit: !1,
|
|
639
643
|
quasis: [expression.value],
|
|
640
644
|
scope,
|
|
641
|
-
source:
|
|
645
|
+
source: oneLineTextOf2(expression)
|
|
642
646
|
};
|
|
643
|
-
if (
|
|
644
|
-
return templateFromLiteral(expression, bindings, !1, scope,
|
|
645
|
-
if (!(
|
|
646
|
-
return isImported(expression.tag.name, "html", TEMPLATE_TAG_SOURCES, bindings) || isImported(expression.tag.name, "default", TEMPLATE_TAG_SOURCES, bindings) ? templateFromLiteral(expression.quasi, bindings, !0, scope,
|
|
647
|
+
if (expression.type === "TemplateLiteral")
|
|
648
|
+
return templateFromLiteral(expression, bindings, !1, scope, oneLineTextOf2(expression));
|
|
649
|
+
if (!(expression.type !== "TaggedTemplateExpression" || expression.tag.type !== "Identifier"))
|
|
650
|
+
return isImported(expression.tag.name, "html", TEMPLATE_TAG_SOURCES, bindings) || isImported(expression.tag.name, "default", TEMPLATE_TAG_SOURCES, bindings) ? templateFromLiteral(expression.quasi, bindings, !0, scope, oneLineTextOf2(expression)) : void 0;
|
|
647
651
|
}
|
|
648
652
|
function aliasValueForIdentifier(expression, scope) {
|
|
649
653
|
return scope.aliases.get(expression.name);
|
|
650
654
|
}
|
|
651
655
|
function argReferenceForExpression(expression, scope) {
|
|
652
656
|
let unwrapped = unwrapExpression2(expression);
|
|
653
|
-
if (
|
|
657
|
+
if (unwrapped.type === "Identifier") {
|
|
654
658
|
let alias = aliasValueForIdentifier(unwrapped, scope);
|
|
655
659
|
return alias?.kind === "arg" ? { name: alias.name, path: alias.path } : parameterArgReference(unwrapped, scope);
|
|
656
660
|
}
|
|
657
|
-
if (
|
|
661
|
+
if (unwrapped.type !== "MemberExpression")
|
|
658
662
|
return;
|
|
659
663
|
let property = memberPropertyName(unwrapped);
|
|
660
664
|
if (property === void 0)
|
|
661
665
|
return;
|
|
662
|
-
if (scope.args &&
|
|
666
|
+
if (scope.args && unwrapped.object.type === "Identifier" && unwrapped.object.name === scope.args)
|
|
663
667
|
return { name: property, path: [] };
|
|
664
|
-
if (!t2.isExpression(unwrapped.object))
|
|
665
|
-
return;
|
|
666
668
|
let object = argReferenceForExpression(unwrapped.object, scope);
|
|
667
669
|
return object ? { name: object.name, path: [...object.path, property] } : void 0;
|
|
668
670
|
}
|
|
669
671
|
var returnedTemplateExpression = (renderFunction, bindings) => {
|
|
670
|
-
let baseScope = scopeForRenderFunction(renderFunction), strict =
|
|
672
|
+
let baseScope = scopeForRenderFunction(renderFunction), strict = returnedExpression(renderFunction);
|
|
671
673
|
if (strict)
|
|
672
|
-
return { node: strict
|
|
673
|
-
if (
|
|
674
|
+
return { node: strict, scope: baseScope };
|
|
675
|
+
if (renderFunction.body?.type !== "BlockStatement")
|
|
674
676
|
return;
|
|
675
|
-
let statements = renderFunction.
|
|
676
|
-
if (
|
|
677
|
+
let statements = renderFunction.body.body, returned = statements.at(-1);
|
|
678
|
+
if (returned?.type !== "ReturnStatement" || !returned.argument)
|
|
677
679
|
return;
|
|
678
680
|
let scope = copyScope(baseScope);
|
|
679
681
|
for (let statement of statements.slice(0, -1))
|
|
680
|
-
if (
|
|
682
|
+
if (statement.type !== "VariableDeclaration" || statement.kind !== "const" && statement.kind !== "let" || !addVariableAliases(statement, scope, bindings))
|
|
681
683
|
return;
|
|
682
684
|
return { node: returned.argument, scope };
|
|
683
685
|
}, scopeForRenderFunction = (renderFunction) => {
|
|
684
|
-
let [first] = renderFunction.
|
|
685
|
-
if (
|
|
686
|
+
let [first] = renderFunction.params, scope = { aliases: /* @__PURE__ */ new Map(), destructured: /* @__PURE__ */ new Map() };
|
|
687
|
+
if (first?.type === "Identifier")
|
|
686
688
|
return scope.args = first.name, scope;
|
|
687
|
-
if (
|
|
689
|
+
if (first?.type !== "ObjectPattern")
|
|
688
690
|
return scope;
|
|
689
691
|
let destructured = destructuredAliases(first, { name: "", path: [] });
|
|
690
692
|
if (!destructured)
|
|
@@ -694,16 +696,16 @@ var returnedTemplateExpression = (renderFunction, bindings) => {
|
|
|
694
696
|
return scope;
|
|
695
697
|
}, addVariableAliases = (declaration, scope, bindings) => {
|
|
696
698
|
for (let declarator of declaration.declarations) {
|
|
697
|
-
if (!
|
|
699
|
+
if (!declarator.init)
|
|
698
700
|
return !1;
|
|
699
|
-
if (
|
|
701
|
+
if (declarator.id.type === "Identifier") {
|
|
700
702
|
let alias = aliasForExpression(declarator.init, scope, bindings);
|
|
701
703
|
if (!alias)
|
|
702
704
|
return !1;
|
|
703
705
|
scope.aliases.set(declarator.id.name, alias);
|
|
704
706
|
continue;
|
|
705
707
|
}
|
|
706
|
-
if (
|
|
708
|
+
if (declarator.id.type === "ObjectPattern") {
|
|
707
709
|
let source = destructureSourceForExpression(declarator.init, scope);
|
|
708
710
|
if (!source)
|
|
709
711
|
return !1;
|
|
@@ -718,28 +720,28 @@ var returnedTemplateExpression = (renderFunction, bindings) => {
|
|
|
718
720
|
return !0;
|
|
719
721
|
}, destructureSourceForExpression = (expression, scope) => {
|
|
720
722
|
let unwrapped = unwrapExpression2(expression);
|
|
721
|
-
return scope.args &&
|
|
723
|
+
return scope.args && unwrapped.type === "Identifier" && unwrapped.name === scope.args ? { name: "", path: [] } : argReferenceForExpression(expression, scope);
|
|
722
724
|
}, aliasForExpression = (expression, scope, bindings) => {
|
|
723
|
-
let unwrapped = unwrapExpression2(expression), arg =
|
|
725
|
+
let unwrapped = unwrapExpression2(expression), arg = argReferenceForExpression(unwrapped, scope);
|
|
724
726
|
if (arg)
|
|
725
|
-
return { kind: "arg", source:
|
|
727
|
+
return { kind: "arg", source: oneLineTextOf2(expression), ...arg };
|
|
726
728
|
if (isStaticLiteral(unwrapped))
|
|
727
729
|
return { kind: "value", value: literalValue(unwrapped) };
|
|
728
730
|
let template = templateFromExpression(unwrapped, bindings, copyScope(scope));
|
|
729
731
|
if (template)
|
|
730
|
-
return { kind: "template", source:
|
|
732
|
+
return { kind: "template", source: oneLineTextOf2(expression), template };
|
|
731
733
|
}, destructuredAliases = (pattern, source) => {
|
|
732
734
|
let aliases = /* @__PURE__ */ new Map();
|
|
733
735
|
for (let property of pattern.properties) {
|
|
734
|
-
if (
|
|
736
|
+
if (property.type !== "Property" || property.computed)
|
|
735
737
|
return;
|
|
736
|
-
let key =
|
|
738
|
+
let key = staticKey2(property);
|
|
737
739
|
if (!key)
|
|
738
740
|
return;
|
|
739
741
|
let root = source.name === "" ? { name: key, path: [] } : { name: source.name, path: [...source.path, key] };
|
|
740
|
-
if (
|
|
742
|
+
if (property.value.type === "Identifier")
|
|
741
743
|
aliases.set(property.value.name, { kind: "arg", ...root });
|
|
742
|
-
else if (
|
|
744
|
+
else if (property.value.type === "ObjectPattern") {
|
|
743
745
|
let nested = destructuredAliases(property.value, root);
|
|
744
746
|
if (!nested)
|
|
745
747
|
return;
|
|
@@ -751,11 +753,9 @@ var returnedTemplateExpression = (renderFunction, bindings) => {
|
|
|
751
753
|
}, parameterArgReference = (expression, scope) => {
|
|
752
754
|
let arg = scope.destructured.get(expression.name);
|
|
753
755
|
return arg ? { name: arg, path: [] } : void 0;
|
|
754
|
-
}, memberPropertyName = (expression) => !expression.computed &&
|
|
756
|
+
}, memberPropertyName = (expression) => !expression.computed && expression.property.type === "Identifier" ? expression.property.name : expression.computed && isStringLiteral(expression.property) ? expression.property.value : void 0, templateFromLiteral = (literal, bindings, lit, scope, source) => ({
|
|
755
757
|
bindings,
|
|
756
|
-
expressions: literal.expressions
|
|
757
|
-
(expression) => t2.isExpression(expression)
|
|
758
|
-
),
|
|
758
|
+
expressions: literal.expressions,
|
|
759
759
|
lit,
|
|
760
760
|
quasis: literal.quasis.map((quasi) => quasi.value.raw),
|
|
761
761
|
scope,
|
|
@@ -767,36 +767,47 @@ var returnedTemplateExpression = (renderFunction, bindings) => {
|
|
|
767
767
|
}), isImported = (local, importName, sources, bindings) => {
|
|
768
768
|
let binding = bindings.get(local);
|
|
769
769
|
return !!binding && sources.includes(binding.importId) && binding.importName === importName;
|
|
770
|
-
}, isStaticLiteral = (expression) =>
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
770
|
+
}, isStaticLiteral = (expression) => {
|
|
771
|
+
let value = primitiveLiteralValue(expression);
|
|
772
|
+
return value !== FAILED && value !== null || expression.type === "TemplateLiteral" && expression.expressions.length === 0;
|
|
773
|
+
}, literalValue = (expression) => {
|
|
774
|
+
if (expression.type === "TemplateLiteral")
|
|
774
775
|
return expression.quasis[0]?.value.cooked ?? expression.quasis[0]?.value.raw ?? "";
|
|
776
|
+
let value = primitiveLiteralValue(expression);
|
|
777
|
+
return value === FAILED ? void 0 : value;
|
|
775
778
|
};
|
|
776
779
|
|
|
777
780
|
// src/docgen/story-docs/template-holes.ts
|
|
778
|
-
var
|
|
779
|
-
let
|
|
781
|
+
var handlerText = (node) => {
|
|
782
|
+
let code = textOf(node), closingIndent = /^[ \t]*/.exec(code.slice(code.lastIndexOf(`
|
|
783
|
+
`) + 1))[0];
|
|
784
|
+
return reindent(code, closingIndent, " ");
|
|
785
|
+
}, TEMPLATE_TAG_SOURCES2 = ["lit", "lit-html", "lit-element"], IF_DEFINED_SOURCES = ["lit/directives/if-defined.js", "lit-html/directives/if-defined.js"], resolveHoleValue = (expression, context) => {
|
|
786
|
+
let expressionNode = unwrapExpression3(expression), alias = expressionNode.type === "Identifier" ? aliasValueForIdentifier(expressionNode, context.scope) : void 0;
|
|
780
787
|
if (alias)
|
|
781
|
-
return resolveAlias(alias, context,
|
|
788
|
+
return resolveAlias(alias, context, oneLineTextOf3(expression));
|
|
782
789
|
let arg = argReferenceForExpression(expression, context.scope);
|
|
783
790
|
if (arg)
|
|
784
|
-
return resolveArgReference(arg, context.storyArgs[arg.name],
|
|
791
|
+
return resolveArgReference(arg, context.storyArgs[arg.name], oneLineTextOf3(expression));
|
|
785
792
|
let unwrapped = expressionNode;
|
|
786
793
|
if (isNothingExpression(unwrapped, context.bindings))
|
|
787
794
|
return { kind: "nothing" };
|
|
788
795
|
if (isStaticLiteral2(unwrapped))
|
|
789
796
|
return { kind: "value", value: literalValue2(unwrapped) };
|
|
790
|
-
if (
|
|
791
|
-
return {
|
|
797
|
+
if (isFunctionNode(unwrapped))
|
|
798
|
+
return {
|
|
799
|
+
handler: handlerText(expression),
|
|
800
|
+
kind: "function",
|
|
801
|
+
source: oneLineTextOf3(expression)
|
|
802
|
+
};
|
|
792
803
|
let nested = templateFromExpression(unwrapped, context.bindings, context.scope);
|
|
793
804
|
if (nested)
|
|
794
|
-
return { kind: "template", source:
|
|
805
|
+
return { kind: "template", source: oneLineTextOf3(expression), template: nested };
|
|
795
806
|
if (isIfDefinedCall(unwrapped, context.bindings)) {
|
|
796
807
|
let value = resolveHoleValue(unwrapped.arguments[0], context);
|
|
797
808
|
return value.kind === "value" && value.value !== null && value.value !== void 0 ? value : { kind: "nothing", ...value.arg ? { arg: value.arg } : {} };
|
|
798
809
|
}
|
|
799
|
-
if (
|
|
810
|
+
if (unwrapped.type === "ConditionalExpression") {
|
|
800
811
|
let test = resolveConditionalTest(unwrapped.test, context);
|
|
801
812
|
if (test.kind === "unresolved")
|
|
802
813
|
return test;
|
|
@@ -806,24 +817,14 @@ var TEMPLATE_TAG_SOURCES2 = ["lit", "lit-html", "lit-element"], IF_DEFINED_SOURC
|
|
|
806
817
|
);
|
|
807
818
|
return test.arg && !branch.arg ? { ...branch, arg: test.arg } : branch;
|
|
808
819
|
}
|
|
809
|
-
return { kind: "unresolved", source:
|
|
820
|
+
return { kind: "unresolved", source: oneLineTextOf3(expression) };
|
|
810
821
|
}, collectReferencedArgs = (expression, scope) => {
|
|
811
|
-
let referenced = /* @__PURE__ */ new Set()
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
for (let key of t3.VISITOR_KEYS[node.type] ?? []) {
|
|
818
|
-
if (skipsReferenceChild(node, key))
|
|
819
|
-
continue;
|
|
820
|
-
let child = node[key];
|
|
821
|
-
Array.isArray(child) ? child.forEach((entry) => {
|
|
822
|
-
t3.isNode(entry) && visit(entry);
|
|
823
|
-
}) : t3.isNode(child) && visit(child);
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
|
-
return visit(expression), referenced;
|
|
822
|
+
let referenced = /* @__PURE__ */ new Set();
|
|
823
|
+
return walk(expression, (node, parent) => {
|
|
824
|
+
if (isStaticName(node, parent))
|
|
825
|
+
return !1;
|
|
826
|
+
referencedArgsForExpression(node, scope).forEach((arg) => referenced.add(arg));
|
|
827
|
+
}), referenced;
|
|
827
828
|
}, isTruthyAttributeValue = (value) => value.kind === "value" ? !!value.value : value.kind === "template" || value.kind === "function", attributeValue = (value, context, referenced) => {
|
|
828
829
|
if (value.kind === "empty" || value.kind === "function" || value.kind === "nothing")
|
|
829
830
|
return { kind: "value", value: void 0 };
|
|
@@ -839,7 +840,7 @@ var TEMPLATE_TAG_SOURCES2 = ["lit", "lit-html", "lit-element"], IF_DEFINED_SOURC
|
|
|
839
840
|
let value = evaluateArgValue(node);
|
|
840
841
|
switch (value.kind) {
|
|
841
842
|
case "function":
|
|
842
|
-
return { handler:
|
|
843
|
+
return { handler: handlerText(node), kind: "function", arg, source: oneLineTextOf3(node) };
|
|
843
844
|
case "unset":
|
|
844
845
|
return { kind: "value", arg, value: void 0 };
|
|
845
846
|
case "unresolved":
|
|
@@ -875,7 +876,7 @@ var TEMPLATE_TAG_SOURCES2 = ["lit", "lit-html", "lit-element"], IF_DEFINED_SOURC
|
|
|
875
876
|
}
|
|
876
877
|
return current2 === void 0 ? missingPathSource ? { arg: reference.name, kind: "unresolved", source: missingPathSource } : { arg: reference.name, kind: "empty" } : { arg: reference.name, kind: "value", value: current2 };
|
|
877
878
|
}, referencedArgsForExpression = (expression, scope) => {
|
|
878
|
-
let alias =
|
|
879
|
+
let alias = expression.type === "Identifier" ? aliasValueForIdentifier(expression, scope) : void 0;
|
|
879
880
|
if (alias)
|
|
880
881
|
return referencedArgsForAlias(alias);
|
|
881
882
|
let arg = argReferenceForExpression(expression, scope);
|
|
@@ -897,24 +898,22 @@ var TEMPLATE_TAG_SOURCES2 = ["lit", "lit-html", "lit-element"], IF_DEFINED_SOURC
|
|
|
897
898
|
default:
|
|
898
899
|
return alias;
|
|
899
900
|
}
|
|
900
|
-
},
|
|
901
|
-
if (
|
|
902
|
-
return null;
|
|
903
|
-
if (t3.isStringLiteral(expression) || t3.isNumericLiteral(expression) || t3.isBooleanLiteral(expression))
|
|
904
|
-
return expression.value;
|
|
905
|
-
if (!t3.isIdentifier(expression, { name: "undefined" }) && !(t3.isUnaryExpression(expression) && expression.operator === "void") && t3.isTemplateLiteral(expression))
|
|
901
|
+
}, isStaticName = (node, parent) => parent?.type === "MemberExpression" && parent.property === node && !parent.computed || parent?.type === "Property" && parent.key === node && parent.value !== node && !parent.computed, isNothingExpression = (expression, bindings) => expression.type === "Identifier" && isImported2(expression.name, "nothing", TEMPLATE_TAG_SOURCES2, bindings), isStaticLiteral2 = (expression) => primitiveLiteralValue(expression) !== FAILED || expression.type === "Identifier" && expression.name === "undefined" || expression.type === "UnaryExpression" && expression.operator === "void" || expression.type === "TemplateLiteral" && expression.expressions.length === 0, literalValue2 = (expression) => {
|
|
902
|
+
if (expression.type === "TemplateLiteral")
|
|
906
903
|
return expression.quasis[0]?.value.cooked ?? expression.quasis[0]?.value.raw ?? "";
|
|
907
|
-
|
|
904
|
+
let value = primitiveLiteralValue(expression);
|
|
905
|
+
return value === FAILED ? void 0 : value;
|
|
906
|
+
}, isIfDefinedCall = (expression, bindings) => expression.type === "CallExpression" && expression.arguments.length === 1 && expression.arguments[0].type !== "SpreadElement" && expression.callee.type === "Identifier" && isImported2(expression.callee.name, "ifDefined", IF_DEFINED_SOURCES, bindings), resolveConditionalTest = (expression, context) => {
|
|
908
907
|
let arg = argReferenceForExpression(expression, context.scope);
|
|
909
908
|
if (arg) {
|
|
910
|
-
let value = resolveArgReference(arg, context.storyArgs[arg.name],
|
|
909
|
+
let value = resolveArgReference(arg, context.storyArgs[arg.name], oneLineTextOf3(expression));
|
|
911
910
|
return value.kind === "value" || value.kind === "empty" ? { arg: arg.name, kind: "value", truthy: value.kind === "value" && !!value.value } : {
|
|
912
911
|
kind: "unresolved",
|
|
913
|
-
source: value.kind === "unresolved" ? value.source :
|
|
912
|
+
source: value.kind === "unresolved" ? value.source : oneLineTextOf3(expression)
|
|
914
913
|
};
|
|
915
914
|
}
|
|
916
915
|
let unwrapped = unwrapExpression3(expression);
|
|
917
|
-
return isNothingExpression(unwrapped, context.bindings) ? { kind: "value", truthy: !1 } : isStaticLiteral2(unwrapped) ? { kind: "value", truthy: !!literalValue2(unwrapped) } : { kind: "unresolved", source:
|
|
916
|
+
return isNothingExpression(unwrapped, context.bindings) ? { kind: "value", truthy: !1 } : isStaticLiteral2(unwrapped) ? { kind: "value", truthy: !!literalValue2(unwrapped) } : { kind: "unresolved", source: oneLineTextOf3(expression) };
|
|
918
917
|
}, templateAttributeText = (template, context, referenced) => {
|
|
919
918
|
let scopedContext = { ...context, bindings: template.bindings, scope: template.scope }, text = "";
|
|
920
919
|
for (let index = 0; index < template.expressions.length; index += 1) {
|
|
@@ -935,6 +934,7 @@ var TEMPLATE_TAG_SOURCES2 = ["lit", "lit-html", "lit-element"], IF_DEFINED_SOURC
|
|
|
935
934
|
};
|
|
936
935
|
|
|
937
936
|
// src/docgen/story-docs/template-print.ts
|
|
937
|
+
import { oneLineTextOf as oneLineTextOf4 } from "storybook/internal/csf-tools";
|
|
938
938
|
function printHtmlTemplate(template, storyArgs, declaration) {
|
|
939
939
|
return printTemplate(template, {
|
|
940
940
|
bindings: template.bindings,
|
|
@@ -1055,7 +1055,7 @@ ${script}` : snippet,
|
|
|
1055
1055
|
continue;
|
|
1056
1056
|
let value = resolveMarkerValue(expression, state);
|
|
1057
1057
|
if (value.kind === "function") {
|
|
1058
|
-
state.unresolved.add(
|
|
1058
|
+
state.unresolved.add(oneLineTextOf4(expression));
|
|
1059
1059
|
return;
|
|
1060
1060
|
}
|
|
1061
1061
|
if (value.kind === "nothing")
|
|
@@ -1121,15 +1121,15 @@ ${script}` : snippet,
|
|
|
1121
1121
|
let next = text;
|
|
1122
1122
|
for (let marker of markersIn(text, state)) {
|
|
1123
1123
|
let expression = state.markers.get(marker);
|
|
1124
|
-
expression && state.unresolved.add(
|
|
1124
|
+
expression && state.unresolved.add(oneLineTextOf4(expression)), next = next.replace(marker, "");
|
|
1125
1125
|
}
|
|
1126
1126
|
return next;
|
|
1127
1127
|
}, unresolvedMarkers = (text, state) => {
|
|
1128
1128
|
for (let marker of markersIn(text, state)) {
|
|
1129
1129
|
let expression = state.markers.get(marker);
|
|
1130
|
-
expression && state.unresolved.add(
|
|
1130
|
+
expression && state.unresolved.add(oneLineTextOf4(expression));
|
|
1131
1131
|
}
|
|
1132
|
-
}, containsMarker = (text, state) => markersIn(text, state).length > 0, markersIn = (text, state) => [...state.markers.keys()].filter((marker) => text.includes(marker)), markerSources = (markers, state) => markers.map((marker) => state.markers.get(marker)).filter((expression) => expression !== void 0).map(
|
|
1132
|
+
}, containsMarker = (text, state) => markersIn(text, state).length > 0, markersIn = (text, state) => [...state.markers.keys()].filter((marker) => text.includes(marker)), markerSources = (markers, state) => markers.map((marker) => state.markers.get(marker)).filter((expression) => expression !== void 0).map(oneLineTextOf4).join(", "), attributeFromPrinted = (attribute) => {
|
|
1133
1133
|
if (!attribute)
|
|
1134
1134
|
return;
|
|
1135
1135
|
let [node] = parseHtml(`<x ${attribute}></x>`);
|
|
@@ -1143,482 +1143,6 @@ ${script}` : snippet,
|
|
|
1143
1143
|
attributes[index] = next;
|
|
1144
1144
|
};
|
|
1145
1145
|
|
|
1146
|
-
// ../../core/src/csf-tools/story-shape/utils.ts
|
|
1147
|
-
import { types as t4 } from "storybook/internal/babel";
|
|
1148
|
-
var unwrapExpression4 = (node) => t4.isTSAsExpression(node) || t4.isTSSatisfiesExpression(node) || t4.isTSNonNullExpression(node) || t4.isTSTypeAssertion(node) || t4.isParenthesizedExpression(node) ? unwrapExpression4(node.expression) : node, isCanonicalCsf2BindCall = (node) => t4.isCallExpression(node) && t4.isMemberExpression(node.callee) && !node.callee.computed && t4.isIdentifier(node.callee.object) && t4.isIdentifier(node.callee.property, { name: "bind" }) && (node.arguments.length === 0 || node.arguments.length === 1 && t4.isObjectExpression(node.arguments[0]) && node.arguments[0].properties.length === 0), withoutTypeCalls = (object) => t4.isCallExpression(object) && object.arguments.length === 0 && t4.isMemberExpression(object.callee) && !object.callee.computed && t4.isIdentifier(object.callee.property, { name: "type" }) ? withoutTypeCalls(object.callee.object) : object, isCsfFactoryCall = (node) => t4.isCallExpression(node) && t4.isMemberExpression(node.callee) && !node.callee.computed && t4.isIdentifier(withoutTypeCalls(node.callee.object)) && t4.isIdentifier(node.callee.property) && (node.callee.property.name === "story" || node.callee.property.name === "extend"), csfFactoryReceiver = (node) => withoutTypeCalls(node.callee.object);
|
|
1149
|
-
var keyOf3 = (p) => t4.isStringLiteral(p.key) ? p.key.value : !p.computed && t4.isIdentifier(p.key) ? p.key.name : null;
|
|
1150
|
-
function resolveIdentifierInit(storyPath, identifier) {
|
|
1151
|
-
let programPath = storyPath.findParent((p) => p.isProgram());
|
|
1152
|
-
if (!programPath)
|
|
1153
|
-
return null;
|
|
1154
|
-
for (let stmt of programPath.get("body")) {
|
|
1155
|
-
if (stmt.isFunctionDeclaration() && stmt.node.id?.name === identifier.node.name)
|
|
1156
|
-
return stmt;
|
|
1157
|
-
if (stmt.isExportNamedDeclaration()) {
|
|
1158
|
-
let decl = stmt.get("declaration");
|
|
1159
|
-
if (decl.isFunctionDeclaration() && decl.node.id?.name === identifier.node.name)
|
|
1160
|
-
return decl;
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
let match = programPath.get("body").flatMap((stmt) => {
|
|
1164
|
-
if (stmt.isVariableDeclaration())
|
|
1165
|
-
return stmt.get("declarations");
|
|
1166
|
-
if (stmt.isExportNamedDeclaration()) {
|
|
1167
|
-
let decl = stmt.get("declaration");
|
|
1168
|
-
if (decl && decl.isVariableDeclaration())
|
|
1169
|
-
return decl.get("declarations");
|
|
1170
|
-
}
|
|
1171
|
-
return [];
|
|
1172
|
-
}).find((d) => {
|
|
1173
|
-
let id = d.get("id");
|
|
1174
|
-
return id.isIdentifier() && id.node.name === identifier.node.name;
|
|
1175
|
-
});
|
|
1176
|
-
if (!match)
|
|
1177
|
-
return null;
|
|
1178
|
-
let init = match.get("init");
|
|
1179
|
-
return init && init.isExpression() ? init : null;
|
|
1180
|
-
}
|
|
1181
|
-
function pathForNode(program, target) {
|
|
1182
|
-
if (!target)
|
|
1183
|
-
return;
|
|
1184
|
-
let found;
|
|
1185
|
-
return program.traverse({
|
|
1186
|
-
enter(p) {
|
|
1187
|
-
p.node && p.node === target && (found = p, p.stop());
|
|
1188
|
-
}
|
|
1189
|
-
}), found;
|
|
1190
|
-
}
|
|
1191
|
-
function metaObjectPath(csf) {
|
|
1192
|
-
let metaPath = pathForNode(csf._file.path, csf._metaNode);
|
|
1193
|
-
return metaPath?.isObjectExpression() ? metaPath : void 0;
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
// ../../core/src/csf-tools/story-shape/normalize-story.ts
|
|
1197
|
-
function normalizeStoryDeclaration(storyDeclaration) {
|
|
1198
|
-
let storyPath = declarationExpression(storyDeclaration), resolvedStoryPath = resolveLocalStory(storyDeclaration, storyPath), normalizedPath = bindInitializer(storyDeclaration, resolvedStoryPath) ?? factoryArgumentExpression(resolvedStoryPath), unwrappedPath = unwrapTypeExpression(normalizedPath);
|
|
1199
|
-
return classifyStoryPath(unwrappedPath);
|
|
1200
|
-
}
|
|
1201
|
-
function resolveLocalStory(declaration, expression) {
|
|
1202
|
-
let visited = /* @__PURE__ */ new Set(), current2 = unwrapTypeExpression(expression);
|
|
1203
|
-
for (; current2.isIdentifier(); ) {
|
|
1204
|
-
let name = current2.node.name;
|
|
1205
|
-
if (visited.has(name) || !current2.scope.getBinding(name)?.constant)
|
|
1206
|
-
break;
|
|
1207
|
-
visited.add(name);
|
|
1208
|
-
let resolved = resolveIdentifierInit(declaration, current2);
|
|
1209
|
-
if (!resolved)
|
|
1210
|
-
break;
|
|
1211
|
-
current2 = unwrapTypeExpression(resolved);
|
|
1212
|
-
}
|
|
1213
|
-
return current2;
|
|
1214
|
-
}
|
|
1215
|
-
function declarationExpression(storyDeclaration) {
|
|
1216
|
-
if (storyDeclaration.isFunctionDeclaration())
|
|
1217
|
-
return storyDeclaration;
|
|
1218
|
-
if (storyDeclaration.isVariableDeclarator()) {
|
|
1219
|
-
let init = storyDeclaration.get("init");
|
|
1220
|
-
if (!init.isExpression())
|
|
1221
|
-
throw storyDeclaration.buildCodeFrameError("Expected story initializer to be an expression");
|
|
1222
|
-
return init;
|
|
1223
|
-
}
|
|
1224
|
-
throw storyDeclaration.buildCodeFrameError(
|
|
1225
|
-
"Expected story to be a function or variable declaration"
|
|
1226
|
-
);
|
|
1227
|
-
}
|
|
1228
|
-
function bindInitializer(storyDeclaration, storyPath) {
|
|
1229
|
-
if (!storyPath.isCallExpression() || !isCanonicalCsf2BindCall(storyPath.node))
|
|
1230
|
-
return null;
|
|
1231
|
-
let callee = storyPath.get("callee");
|
|
1232
|
-
if (!callee.isMemberExpression())
|
|
1233
|
-
return null;
|
|
1234
|
-
let obj = callee.get("object");
|
|
1235
|
-
return obj.isIdentifier() ? resolveIdentifierInit(storyDeclaration, obj) : null;
|
|
1236
|
-
}
|
|
1237
|
-
function factoryArgumentExpression(storyPath) {
|
|
1238
|
-
if (!storyPath.isCallExpression() || !isCsfFactoryCall(storyPath.node))
|
|
1239
|
-
return storyPath;
|
|
1240
|
-
let args = storyPath.get("arguments");
|
|
1241
|
-
if (args.length === 0)
|
|
1242
|
-
return storyPath;
|
|
1243
|
-
if (args.length !== 1 || !args[0].isExpression())
|
|
1244
|
-
throw storyPath.buildCodeFrameError("Could not evaluate story expression");
|
|
1245
|
-
return args[0];
|
|
1246
|
-
}
|
|
1247
|
-
function unwrapTypeExpression(storyPath) {
|
|
1248
|
-
return storyPath.isTSSatisfiesExpression() || storyPath.isTSAsExpression() ? storyPath.get("expression") : storyPath;
|
|
1249
|
-
}
|
|
1250
|
-
function classifyStoryPath(storyPath) {
|
|
1251
|
-
if (storyPath.isObjectExpression())
|
|
1252
|
-
return { type: "config", path: storyPath };
|
|
1253
|
-
if (storyPath.isArrowFunctionExpression() || storyPath.isFunctionExpression() || storyPath.isFunctionDeclaration())
|
|
1254
|
-
return { type: "fn", path: storyPath };
|
|
1255
|
-
if (storyPath.isCallExpression() && isCsfFactoryCall(storyPath.node) && storyPath.node.arguments.length === 0)
|
|
1256
|
-
return { type: "emptyConfig", path: storyPath };
|
|
1257
|
-
throw storyPath.buildCodeFrameError(
|
|
1258
|
-
"Expected story to be csf factory, function or an object expression"
|
|
1259
|
-
);
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1262
|
-
// ../../core/src/csf-tools/story-shape/resolve-members.ts
|
|
1263
|
-
import { generate, types as t6 } from "storybook/internal/babel";
|
|
1264
|
-
|
|
1265
|
-
// ../../core/src/csf-tools/story-shape/imports.ts
|
|
1266
|
-
import { types as t5 } from "storybook/internal/babel";
|
|
1267
|
-
var isTypeSpecifier = (s) => t5.isImportSpecifier(s) && s.importKind === "type", importedName = (im) => t5.isIdentifier(im) ? im.name : im.value;
|
|
1268
|
-
|
|
1269
|
-
// ../../core/src/csf-tools/story-shape/resolve-members.ts
|
|
1270
|
-
var sourceOf5 = (node) => generate(node, { concise: !0, comments: !1 }).code, complete = (properties = {}) => ({
|
|
1271
|
-
properties,
|
|
1272
|
-
shadowed: [],
|
|
1273
|
-
unresolved: []
|
|
1274
|
-
}), resolveObjectMembers = (object, ctx) => membersOf(object, ctx, /* @__PURE__ */ new Set());
|
|
1275
|
-
var membersOf = (object, ctx, visited) => {
|
|
1276
|
-
let properties = {}, unresolved = [], shadowed = /* @__PURE__ */ new Set(), shadowKnownMembers = (source) => {
|
|
1277
|
-
unresolved.push(source);
|
|
1278
|
-
for (let key of Object.keys(properties))
|
|
1279
|
-
shadowed.add(key);
|
|
1280
|
-
};
|
|
1281
|
-
for (let property of object.properties) {
|
|
1282
|
-
if (t6.isSpreadElement(property)) {
|
|
1283
|
-
let spread = spreadMembers(ctx, property, visited);
|
|
1284
|
-
if (spread === void 0 || spread.unresolved.length > 0) {
|
|
1285
|
-
shadowKnownMembers(sourceOf5(property));
|
|
1286
|
-
continue;
|
|
1287
|
-
}
|
|
1288
|
-
for (let [key2, value] of Object.entries(spread.properties))
|
|
1289
|
-
properties[key2] = value, shadowed.delete(key2);
|
|
1290
|
-
continue;
|
|
1291
|
-
}
|
|
1292
|
-
let key = keyOf3(property);
|
|
1293
|
-
if (key === null) {
|
|
1294
|
-
shadowKnownMembers(sourceOf5(property));
|
|
1295
|
-
continue;
|
|
1296
|
-
}
|
|
1297
|
-
if (t6.isObjectMethod(property) && (property.kind !== "method" || property.generator)) {
|
|
1298
|
-
delete properties[key], shadowed.delete(key), unresolved.push(sourceOf5(property));
|
|
1299
|
-
continue;
|
|
1300
|
-
}
|
|
1301
|
-
properties[key] = t6.isObjectMethod(property) ? property : property.value, shadowed.delete(key);
|
|
1302
|
-
}
|
|
1303
|
-
return { properties, shadowed: [...shadowed], unresolved };
|
|
1304
|
-
}, spreadMembers = (ctx, spread, visited) => {
|
|
1305
|
-
let argument = unwrapExpression4(spread.argument);
|
|
1306
|
-
return t6.isObjectExpression(argument) ? membersOf(argument, ctx, visited) : resolveReference(ctx, argument, spread.start ?? void 0, visited);
|
|
1307
|
-
}, memberChain = (node) => {
|
|
1308
|
-
let path = [], current2 = unwrapExpression4(node);
|
|
1309
|
-
for (; t6.isMemberExpression(current2); ) {
|
|
1310
|
-
let key = t6.isIdentifier(current2.property) && !current2.computed ? current2.property.name : t6.isStringLiteral(current2.property) ? current2.property.value : void 0;
|
|
1311
|
-
if (key === void 0)
|
|
1312
|
-
return;
|
|
1313
|
-
path.unshift(key), current2 = unwrapExpression4(current2.object);
|
|
1314
|
-
}
|
|
1315
|
-
return t6.isIdentifier(current2) ? { root: current2.name, path } : void 0;
|
|
1316
|
-
}, resolveReference = (ctx, expression, position, visited) => {
|
|
1317
|
-
let chain = memberChain(expression);
|
|
1318
|
-
if (!chain)
|
|
1319
|
-
return;
|
|
1320
|
-
let key = `ref:${ctx.filePath}#${chain.root}.${chain.path.join(".")}`;
|
|
1321
|
-
if (!visited.has(key)) {
|
|
1322
|
-
visited.add(key);
|
|
1323
|
-
try {
|
|
1324
|
-
return unguardedResolveReference(ctx, chain, position, visited);
|
|
1325
|
-
} finally {
|
|
1326
|
-
visited.delete(key);
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
}, unguardedResolveReference = (ctx, chain, position, visited) => {
|
|
1330
|
-
let located = locate(ctx, chain, position, visited);
|
|
1331
|
-
if (!located)
|
|
1332
|
-
return;
|
|
1333
|
-
let members = located.members, scope = located.ctx;
|
|
1334
|
-
for (let [index, key] of located.path.entries()) {
|
|
1335
|
-
if (members.unresolved.length > 0)
|
|
1336
|
-
return;
|
|
1337
|
-
let value = members.properties[key];
|
|
1338
|
-
if (value === void 0)
|
|
1339
|
-
return index === located.path.length - 1 ? complete() : void 0;
|
|
1340
|
-
let unwrapped = unwrapExpression4(value);
|
|
1341
|
-
if (!t6.isObjectExpression(unwrapped))
|
|
1342
|
-
return;
|
|
1343
|
-
members = membersOf(unwrapped, scope, visited);
|
|
1344
|
-
}
|
|
1345
|
-
return located.external ? externalized(members, scope) : members;
|
|
1346
|
-
}, locate = (ctx, chain, position, visited) => {
|
|
1347
|
-
let binding = bindingMembers(ctx, chain.root, position, visited);
|
|
1348
|
-
if (!binding)
|
|
1349
|
-
return;
|
|
1350
|
-
if (binding.kind === "namespace") {
|
|
1351
|
-
let [exportName, ...path] = chain.path;
|
|
1352
|
-
if (exportName === void 0)
|
|
1353
|
-
return;
|
|
1354
|
-
let exported = bindingMembers(binding.ctx, exportName, void 0, visited);
|
|
1355
|
-
if (exported === void 0 || exported.kind === "namespace")
|
|
1356
|
-
return;
|
|
1357
|
-
let located2 = withAccessor(exported, path);
|
|
1358
|
-
return located2 === void 0 ? void 0 : { ...located2, external: !0 };
|
|
1359
|
-
}
|
|
1360
|
-
let located = withAccessor(binding, chain.path);
|
|
1361
|
-
return located === void 0 ? void 0 : { ...located, external: binding.external };
|
|
1362
|
-
}, withAccessor = (binding, path) => binding.accessor === void 0 ? { members: binding.members, ctx: binding.ctx, path } : path[0] === binding.accessor ? { members: binding.members, ctx: binding.ctx, path: path.slice(1) } : void 0, externalized = (members, ctx) => {
|
|
1363
|
-
if (!ctx.externalize)
|
|
1364
|
-
return members;
|
|
1365
|
-
let properties = {};
|
|
1366
|
-
for (let [key, node] of Object.entries(members.properties)) {
|
|
1367
|
-
let value = ctx.externalize(node);
|
|
1368
|
-
if (value === void 0)
|
|
1369
|
-
return;
|
|
1370
|
-
properties[key] = value;
|
|
1371
|
-
}
|
|
1372
|
-
return {
|
|
1373
|
-
properties,
|
|
1374
|
-
shadowed: members.shadowed,
|
|
1375
|
-
unresolved: members.unresolved
|
|
1376
|
-
};
|
|
1377
|
-
}, bindingMembers = (ctx, name, position, visited) => {
|
|
1378
|
-
let key = `${ctx.filePath}#${name}`;
|
|
1379
|
-
if (!visited.has(key)) {
|
|
1380
|
-
visited.add(key);
|
|
1381
|
-
try {
|
|
1382
|
-
return unguardedBindingMembers(ctx, name, position, visited);
|
|
1383
|
-
} finally {
|
|
1384
|
-
visited.delete(key);
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1387
|
-
}, unguardedBindingMembers = (ctx, name, position, visited) => {
|
|
1388
|
-
let binding = ctx.program.scope.getBinding(name);
|
|
1389
|
-
if (!binding)
|
|
1390
|
-
return;
|
|
1391
|
-
if (binding.kind === "module")
|
|
1392
|
-
return importedBinding(ctx, binding.path, visited);
|
|
1393
|
-
if (!binding.constant)
|
|
1394
|
-
return;
|
|
1395
|
-
let rootName = localAliasRoot(ctx, name), rootBinding = ctx.program.scope.getBinding(rootName), declared = declaredBindingMembers(
|
|
1396
|
-
ctx,
|
|
1397
|
-
rootBinding?.path.node ?? binding.path.node,
|
|
1398
|
-
position,
|
|
1399
|
-
visited
|
|
1400
|
-
);
|
|
1401
|
-
if (declared === void 0)
|
|
1402
|
-
return;
|
|
1403
|
-
let assigned = assignedMembers(ctx, localAliases(ctx, rootName), position);
|
|
1404
|
-
return {
|
|
1405
|
-
kind: "members",
|
|
1406
|
-
ctx,
|
|
1407
|
-
external: !1,
|
|
1408
|
-
...declared.accessor ? { accessor: declared.accessor } : {},
|
|
1409
|
-
members: {
|
|
1410
|
-
properties: { ...declared.members.properties, ...assigned.properties },
|
|
1411
|
-
shadowed: declared.members.shadowed.filter((key) => !(key in assigned.properties)),
|
|
1412
|
-
unresolved: [...declared.members.unresolved, ...assigned.unresolved]
|
|
1413
|
-
}
|
|
1414
|
-
};
|
|
1415
|
-
}, declaredBindingMembers = (ctx, node, position, visited) => {
|
|
1416
|
-
if (t6.isFunctionDeclaration(node))
|
|
1417
|
-
return { members: complete() };
|
|
1418
|
-
if (t6.isVariableDeclarator(node) && !(position !== void 0 && (node.start ?? Number.POSITIVE_INFINITY) > position))
|
|
1419
|
-
return node.init ? declaredMembers(ctx, node.init, position, visited) : { members: complete() };
|
|
1420
|
-
}, declaredMembers = (ctx, init, position, visited) => {
|
|
1421
|
-
let unwrapped = unwrapExpression4(init);
|
|
1422
|
-
if (t6.isObjectExpression(unwrapped))
|
|
1423
|
-
return { members: membersOf(unwrapped, ctx, visited) };
|
|
1424
|
-
let factory = factoryCall(unwrapped);
|
|
1425
|
-
if (factory === void 0 && (t6.isFunction(unwrapped) || isCanonicalCsf2BindCall(unwrapped)))
|
|
1426
|
-
return { members: complete() };
|
|
1427
|
-
if (t6.isIdentifier(unwrapped)) {
|
|
1428
|
-
let referenced = bindingMembers(ctx, unwrapped.name, position, visited);
|
|
1429
|
-
if (referenced?.kind === "members") {
|
|
1430
|
-
let members = referenced.external ? ctx.externalize && externalized(referenced.members, referenced.ctx) : referenced.members;
|
|
1431
|
-
if (members)
|
|
1432
|
-
return { members, ...referenced.accessor ? { accessor: referenced.accessor } : {} };
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
if (factory === void 0)
|
|
1436
|
-
return {
|
|
1437
|
-
members: { properties: {}, shadowed: [], unresolved: [sourceOf5(unwrapped)] }
|
|
1438
|
-
};
|
|
1439
|
-
let config = factory.config ? membersOf(factory.config, ctx, visited) : complete();
|
|
1440
|
-
if (factory.method === "story")
|
|
1441
|
-
return { members: config, accessor: "input" };
|
|
1442
|
-
let parent = bindingMembers(ctx, factory.parent, position, visited);
|
|
1443
|
-
return parent === void 0 || parent.kind === "namespace" || parent.accessor !== "input" || parent.external ? void 0 : {
|
|
1444
|
-
members: {
|
|
1445
|
-
properties: mergedAnnotations(parent.members, config).properties,
|
|
1446
|
-
shadowed: [
|
|
1447
|
-
...parent.members.shadowed.filter((key) => !(key in config.properties)),
|
|
1448
|
-
...config.shadowed
|
|
1449
|
-
],
|
|
1450
|
-
unresolved: [...parent.members.unresolved, ...config.unresolved]
|
|
1451
|
-
},
|
|
1452
|
-
accessor: "input"
|
|
1453
|
-
};
|
|
1454
|
-
}, MERGED_ANNOTATIONS = ["args", "argTypes", "parameters", "globals"], localAliasRoot = (ctx, name) => {
|
|
1455
|
-
let visited = /* @__PURE__ */ new Set(), current2 = name;
|
|
1456
|
-
for (; !visited.has(current2); ) {
|
|
1457
|
-
visited.add(current2);
|
|
1458
|
-
let binding = ctx.program.scope.getBinding(current2), node = binding?.path.node;
|
|
1459
|
-
if (!binding?.constant || !t6.isVariableDeclarator(node) || !node.init)
|
|
1460
|
-
break;
|
|
1461
|
-
let init = unwrapExpression4(node.init);
|
|
1462
|
-
if (!t6.isIdentifier(init))
|
|
1463
|
-
break;
|
|
1464
|
-
let target = ctx.program.scope.getBinding(init.name);
|
|
1465
|
-
if (!target?.constant || target.kind === "module")
|
|
1466
|
-
break;
|
|
1467
|
-
current2 = init.name;
|
|
1468
|
-
}
|
|
1469
|
-
return current2;
|
|
1470
|
-
}, localAliases = (ctx, root) => {
|
|
1471
|
-
let aliases = /* @__PURE__ */ new Map([[root, Number.NEGATIVE_INFINITY]]);
|
|
1472
|
-
for (let [name, binding] of Object.entries(ctx.program.scope.bindings))
|
|
1473
|
-
name !== root && binding.constant && localAliasRoot(ctx, name) === root && aliases.set(name, binding.path.node.start ?? Number.POSITIVE_INFINITY);
|
|
1474
|
-
return aliases;
|
|
1475
|
-
}, mergedAnnotations = (parent, child) => {
|
|
1476
|
-
let properties = { ...parent.properties, ...child.properties };
|
|
1477
|
-
for (let key of MERGED_ANNOTATIONS) {
|
|
1478
|
-
let from = parent.properties[key], over = child.properties[key];
|
|
1479
|
-
from === void 0 || over === void 0 || !t6.isExpression(from) || !t6.isExpression(over) || (properties[key] = t6.objectExpression([t6.spreadElement(from), t6.spreadElement(over)]));
|
|
1480
|
-
}
|
|
1481
|
-
return { properties };
|
|
1482
|
-
}, factoryCall = (node) => {
|
|
1483
|
-
if (!isCsfFactoryCall(node))
|
|
1484
|
-
return;
|
|
1485
|
-
let method = node.callee.property.name;
|
|
1486
|
-
if (method !== "story" && method !== "extend")
|
|
1487
|
-
return;
|
|
1488
|
-
let [argument] = node.arguments, config = argument && unwrapExpression4(argument);
|
|
1489
|
-
if (!(argument !== void 0 && (config === void 0 || !t6.isObjectExpression(config))))
|
|
1490
|
-
return {
|
|
1491
|
-
method,
|
|
1492
|
-
parent: csfFactoryReceiver(node).name,
|
|
1493
|
-
...config && t6.isObjectExpression(config) ? { config } : {}
|
|
1494
|
-
};
|
|
1495
|
-
}, assignedMembers = (ctx, aliases, position) => {
|
|
1496
|
-
let properties = {}, unresolved = [];
|
|
1497
|
-
for (let statement of ctx.program.node.body) {
|
|
1498
|
-
if (!t6.isExpressionStatement(statement) || !t6.isAssignmentExpression(statement.expression))
|
|
1499
|
-
continue;
|
|
1500
|
-
let assignment = statement.expression, target = assignment.left, depth = 0, outermost;
|
|
1501
|
-
for (; t6.isMemberExpression(target); )
|
|
1502
|
-
depth += 1, outermost = t6.isIdentifier(target.property) && !target.computed ? target.property.name : t6.isStringLiteral(target.property) ? target.property.value : void 0, target = target.object;
|
|
1503
|
-
if (!(depth === 0 || !t6.isIdentifier(target) || !aliases.has(target.name)) && !((assignment.start ?? 0) < aliases.get(target.name)) && !(position !== void 0 && (assignment.start ?? 0) > position)) {
|
|
1504
|
-
if (depth > 1 || outermost === void 0 || assignment.operator !== "=") {
|
|
1505
|
-
unresolved.push(sourceOf5(assignment));
|
|
1506
|
-
continue;
|
|
1507
|
-
}
|
|
1508
|
-
properties[outermost] = assignment.right;
|
|
1509
|
-
}
|
|
1510
|
-
}
|
|
1511
|
-
return { properties, unresolved };
|
|
1512
|
-
}, importedBinding = (ctx, specifierPath, visited) => {
|
|
1513
|
-
let specifier = specifierPath.node, declaration = specifierPath.parent;
|
|
1514
|
-
if (!t6.isImportDeclaration(declaration) || declaration.importKind === "type" || !(t6.isImportSpecifier(specifier) || t6.isImportDefaultSpecifier(specifier) || t6.isImportNamespaceSpecifier(specifier)) || isTypeSpecifier(specifier))
|
|
1515
|
-
return;
|
|
1516
|
-
let target = resolveTargetModule(ctx, declaration.source.value);
|
|
1517
|
-
if (!target)
|
|
1518
|
-
return;
|
|
1519
|
-
if (t6.isImportNamespaceSpecifier(specifier))
|
|
1520
|
-
return { kind: "namespace", ctx: target };
|
|
1521
|
-
let exportName = t6.isImportDefaultSpecifier(specifier) ? "default" : importedName(specifier.imported);
|
|
1522
|
-
return exportedBinding(target, exportName, visited);
|
|
1523
|
-
}, resolveTargetModule = (ctx, specifier) => {
|
|
1524
|
-
let target = ctx.resolveModule?.(ctx.filePath, specifier);
|
|
1525
|
-
return target ? { ...ctx, ...target } : void 0;
|
|
1526
|
-
}, exportedBinding = (ctx, exportName, visited) => {
|
|
1527
|
-
let asExternal = (bound) => bound === void 0 || bound.kind === "namespace" ? bound : { ...bound, external: !0 };
|
|
1528
|
-
for (let statement of ctx.program.node.body) {
|
|
1529
|
-
if (t6.isExportDefaultDeclaration(statement) && exportName === "default") {
|
|
1530
|
-
let declaration = unwrapExpression4(statement.declaration);
|
|
1531
|
-
return t6.isIdentifier(declaration) ? asExternal(bindingMembers(ctx, declaration.name, void 0, visited)) : t6.isObjectExpression(declaration) ? {
|
|
1532
|
-
kind: "members",
|
|
1533
|
-
ctx,
|
|
1534
|
-
external: !0,
|
|
1535
|
-
members: membersOf(declaration, ctx, visited)
|
|
1536
|
-
} : void 0;
|
|
1537
|
-
}
|
|
1538
|
-
if (!t6.isExportNamedDeclaration(statement) || statement.exportKind === "type")
|
|
1539
|
-
continue;
|
|
1540
|
-
let specifier = statement.specifiers.find(
|
|
1541
|
-
(candidate) => t6.isExportSpecifier(candidate) && candidate.exportKind !== "type" && importedName(candidate.exported) === exportName
|
|
1542
|
-
);
|
|
1543
|
-
if (!specifier)
|
|
1544
|
-
continue;
|
|
1545
|
-
if (!statement.source)
|
|
1546
|
-
return asExternal(bindingMembers(ctx, specifier.local.name, void 0, visited));
|
|
1547
|
-
let target = resolveTargetModule(ctx, statement.source.value);
|
|
1548
|
-
return target ? exportedBinding(target, specifier.local.name, visited) : void 0;
|
|
1549
|
-
}
|
|
1550
|
-
return exportName === "default" ? void 0 : asExternal(bindingMembers(ctx, exportName, void 0, visited));
|
|
1551
|
-
};
|
|
1552
|
-
|
|
1553
|
-
// ../../core/src/csf-tools/story-shape/render.ts
|
|
1554
|
-
var isRenderFunction = (path) => path.isArrowFunctionExpression() || path.isFunctionExpression() || path.isFunctionDeclaration();
|
|
1555
|
-
function resolveEffectiveRender(csf, exportName, references) {
|
|
1556
|
-
let declaration = csf._storyDeclarationPath[exportName], normalized = normalizeStoryDeclarationForRender(declaration);
|
|
1557
|
-
if (normalized.type === "fn")
|
|
1558
|
-
return { kind: "resolved", path: normalized.path };
|
|
1559
|
-
let storyRender = readRender(
|
|
1560
|
-
normalized.type === "config" ? normalized.path : void 0,
|
|
1561
|
-
declaration,
|
|
1562
|
-
references
|
|
1563
|
-
);
|
|
1564
|
-
if (storyRender.kind === "invalid")
|
|
1565
|
-
return { kind: "unresolved" };
|
|
1566
|
-
if (storyRender.kind !== "missing")
|
|
1567
|
-
return storyRender;
|
|
1568
|
-
let metaRender = readRender(metaObjectPath(csf), declaration, references);
|
|
1569
|
-
return metaRender.kind === "invalid" ? { kind: "unresolved" } : metaRender;
|
|
1570
|
-
}
|
|
1571
|
-
var normalizeStoryDeclarationForRender = normalizeStoryDeclaration, readRender = (config, storyDeclaration, references) => {
|
|
1572
|
-
let properties = config?.get("properties") ?? [], renderIndex = -1;
|
|
1573
|
-
for (let index = properties.length - 1; index >= 0; index -= 1) {
|
|
1574
|
-
let property = properties[index];
|
|
1575
|
-
if ((property.isObjectProperty() || property.isObjectMethod()) && keyOf3(property.node) === "render") {
|
|
1576
|
-
renderIndex = index;
|
|
1577
|
-
break;
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
let throughSpreads = () => config && references ? renderFromMembers(
|
|
1581
|
-
resolveObjectMembers(config.node, references),
|
|
1582
|
-
references,
|
|
1583
|
-
storyDeclaration
|
|
1584
|
-
) : { kind: "unresolved" };
|
|
1585
|
-
if (renderIndex === -1)
|
|
1586
|
-
return properties.some((property) => property.isSpreadElement()) ? throughSpreads() : { kind: "missing" };
|
|
1587
|
-
let resolved = readRenderProperty(properties[renderIndex], storyDeclaration);
|
|
1588
|
-
if (properties.some((property, index) => index > renderIndex && property.isSpreadElement())) {
|
|
1589
|
-
let read = throughSpreads();
|
|
1590
|
-
return read.kind !== "unresolved" ? read : resolved.kind === "resolved" ? { kind: "unresolved", shadowedRender: resolved.path } : { kind: "unresolved" };
|
|
1591
|
-
}
|
|
1592
|
-
return resolved;
|
|
1593
|
-
};
|
|
1594
|
-
function renderFromMembers(members, references, storyDeclaration) {
|
|
1595
|
-
if (members.unresolved.length > 0)
|
|
1596
|
-
return { kind: "unresolved" };
|
|
1597
|
-
let node = members.properties.render;
|
|
1598
|
-
if (node === void 0)
|
|
1599
|
-
return { kind: "missing" };
|
|
1600
|
-
let path = pathForNode(references.program, node);
|
|
1601
|
-
if (!path)
|
|
1602
|
-
return { kind: "unresolved" };
|
|
1603
|
-
if (path.isObjectMethod())
|
|
1604
|
-
return path.node.kind === "method" && !path.node.generator ? { kind: "resolved", path } : { kind: "unresolved" };
|
|
1605
|
-
if (path.isIdentifier()) {
|
|
1606
|
-
let resolved = resolveIdentifierInit(storyDeclaration, path);
|
|
1607
|
-
return resolved && isRenderFunction(resolved) ? { kind: "resolved", path: resolved } : { kind: "unresolved" };
|
|
1608
|
-
}
|
|
1609
|
-
return isRenderFunction(path) ? { kind: "resolved", path } : { kind: "unresolved" };
|
|
1610
|
-
}
|
|
1611
|
-
function readRenderProperty(renderProperty, storyDeclaration) {
|
|
1612
|
-
if (renderProperty.isObjectMethod())
|
|
1613
|
-
return renderProperty.node.kind === "method" && !renderProperty.node.generator ? { kind: "resolved", path: renderProperty } : { kind: "unresolved" };
|
|
1614
|
-
let renderPath = renderProperty.get("value");
|
|
1615
|
-
if (renderPath.isIdentifier()) {
|
|
1616
|
-
let resolved = resolveIdentifierInit(storyDeclaration, renderPath);
|
|
1617
|
-
return resolved && isRenderFunction(resolved) ? { kind: "resolved", path: resolved } : { kind: "unresolved" };
|
|
1618
|
-
}
|
|
1619
|
-
return isRenderFunction(renderPath) ? { kind: "resolved", path: renderPath } : { kind: "invalid", path: renderPath };
|
|
1620
|
-
}
|
|
1621
|
-
|
|
1622
1146
|
// src/docgen/story-docs/build-story-docs.ts
|
|
1623
1147
|
var NO_COMPONENT_WARNING = "No static snippet: `meta.component` is not set.", openStoryReferences = createStoryReferenceResolver();
|
|
1624
1148
|
async function buildStoryDocsPayload(input, context) {
|
|
@@ -1673,7 +1197,10 @@ var buildPayload = (input, storyImportPath, csf, snippetFor, name) => {
|
|
|
1673
1197
|
filePath: storyFilePath,
|
|
1674
1198
|
resolveModule: openStoryReferences().resolveModule
|
|
1675
1199
|
}), baseStoryDoc = (csf, exportName, story, result) => {
|
|
1676
|
-
let { description, summary } = extractStoryJSDocInfo(
|
|
1200
|
+
let { description, summary } = extractStoryJSDocInfo(
|
|
1201
|
+
csf._storyStatements[exportName],
|
|
1202
|
+
csf.editor
|
|
1203
|
+
);
|
|
1677
1204
|
return {
|
|
1678
1205
|
id: story.id,
|
|
1679
1206
|
name: story.name ?? storyNameFromExport(exportName),
|
|
@@ -1712,7 +1239,7 @@ var buildPayload = (input, storyImportPath, csf, snippetFor, name) => {
|
|
|
1712
1239
|
}, renderedArgsSnippet = (exportName, resolved, deps) => {
|
|
1713
1240
|
let warnings = [], render = resolveEffectiveRender(deps.csf, exportName, deps.resolveStoryArgs.ctx);
|
|
1714
1241
|
if (render.kind === "resolved") {
|
|
1715
|
-
let template = resolveHtmlTemplate(render.
|
|
1242
|
+
let template = resolveHtmlTemplate(render.node, deps.csf);
|
|
1716
1243
|
if (template) {
|
|
1717
1244
|
let printed = printHtmlTemplate(template, resolved.args, deps.declaration), unresolved = [...resolved.unresolved, ...printed.unresolved];
|
|
1718
1245
|
warnings.push(unresolvedWarning(unresolved)), warnings.push(incompleteList(printed.properties, "properties without an attribute")), warnings.push(
|
|
@@ -1724,7 +1251,7 @@ var buildPayload = (input, storyImportPath, csf, snippetFor, name) => {
|
|
|
1724
1251
|
...joinWarnings(hasSnippet ? warnings : [...warnings, noSnippetWarning(unresolved)])
|
|
1725
1252
|
};
|
|
1726
1253
|
}
|
|
1727
|
-
warnings.push(unresolvedWarning([
|
|
1254
|
+
warnings.push(unresolvedWarning([oneLineTextOf5(render.node)]));
|
|
1728
1255
|
} else render.kind === "unresolved" && warnings.push(unresolvedWarning(unresolvedRenderSource(render, resolved)));
|
|
1729
1256
|
let args = argsSnippet(
|
|
1730
1257
|
resolved.args,
|
|
@@ -1741,8 +1268,8 @@ var buildPayload = (input, storyImportPath, csf, snippetFor, name) => {
|
|
|
1741
1268
|
let bound = new Set(referenced), unbound = Object.entries(args).filter(([name, node]) => !bound.has(name) && evaluateArgValue(node).kind !== "unset").map(([name]) => name);
|
|
1742
1269
|
return incompleteList(unbound, "args not bound by the render template");
|
|
1743
1270
|
}, unresolvedRenderSource = (render, resolved) => {
|
|
1744
|
-
let node = resolved.storyMembers.properties.render ?? resolved.metaMembers.properties.render ?? render.shadowedRender
|
|
1745
|
-
return node ? [
|
|
1271
|
+
let node = resolved.storyMembers.properties.render ?? resolved.metaMembers.properties.render ?? render.shadowedRender;
|
|
1272
|
+
return node ? [oneLineTextOf5(node)] : [];
|
|
1746
1273
|
}, argsSnippet = (args, declaration, argTypes, tag, unresolvedArgs) => {
|
|
1747
1274
|
let snippet = {
|
|
1748
1275
|
tag,
|
|
@@ -1836,10 +1363,7 @@ var buildPayload = (input, storyImportPath, csf, snippetFor, name) => {
|
|
|
1836
1363
|
return;
|
|
1837
1364
|
}
|
|
1838
1365
|
items[index] = next;
|
|
1839
|
-
}, falseDefaultAttributes = (snippet) => snippet.attributes.filter(({ value, defaultValue }) => value === !1 && defaultValue === "true").map(({ source, name }) => source ?? name), hasSnippetContent = (snippet) => snippet.attributes.length > 0 || snippet.cssProperties.length > 0 || snippet.listeners.length > 0 || snippet.slots.length > 0 || snippet.styleRules.length > 0, listenerHandler2 = (node) => {
|
|
1840
|
-
let unwrapped = t7.isExpression(node) ? unwrapExpression5(node) : node;
|
|
1841
|
-
return t7.isFunction(unwrapped) ? sourceOf6(node) : "() => {}";
|
|
1842
|
-
}, incompleteList = (names, suffix) => names.length === 0 ? void 0 : `Incomplete snippet: ${suffix}: ${names.map((name) => `\`${name}\``).join(", ")}.`, joinWarnings = (parts) => {
|
|
1366
|
+
}, falseDefaultAttributes = (snippet) => snippet.attributes.filter(({ value, defaultValue }) => value === !1 && defaultValue === "true").map(({ source, name }) => source ?? name), hasSnippetContent = (snippet) => snippet.attributes.length > 0 || snippet.cssProperties.length > 0 || snippet.listeners.length > 0 || snippet.slots.length > 0 || snippet.styleRules.length > 0, listenerHandler2 = (node) => isFunctionNode(unwrapExpression4(node)) ? handlerText(node) : "() => {}", incompleteList = (names, suffix) => names.length === 0 ? void 0 : `Incomplete snippet: ${suffix}: ${names.map((name) => `\`${name}\``).join(", ")}.`, joinWarnings = (parts) => {
|
|
1843
1367
|
let warning = [...new Set(parts.filter((part) => part !== void 0))].join(`
|
|
1844
1368
|
`);
|
|
1845
1369
|
return warning === "" ? {} : { warning };
|