@storybook/vue3 11.0.0-rc.2 → 11.0.0-rc.4
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-ZXXNCHU7.js → chunk-FTNLYRVC.js} +2 -2
- package/dist/_node-chunks/{chunk-HCZJLA2R.js → chunk-FEPCDEC2.js} +89 -46
- package/dist/_node-chunks/{chunk-P5M6CRJS.js → chunk-IXYCOERX.js} +87 -44
- package/dist/_node-chunks/{chunk-7WHIMGTJ.js → chunk-YPMEPZAF.js} +113 -29
- package/dist/_node-chunks/{component-meta-FWIOHTOX.js → component-meta-H4SIVDTW.js} +5 -3
- package/dist/{chunk-Dka2iJUy.d.ts → chunk-CmSWgGT0.d.ts} +4 -4
- package/dist/docgen/docgen-worker.js +4 -2
- package/dist/docgen/index.d.ts +1 -1
- package/dist/docgen/index.js +3 -3
- package/dist/docs/register-print-hole.js +1 -1
- package/dist/entry-preview-docs.js +1 -1
- package/dist/index.js +1 -1
- package/dist/preset.d.ts +1 -1
- package/dist/preset.js +2 -2
- package/package.json +2 -2
|
@@ -67,11 +67,11 @@ var printHole = (hole, value) => {
|
|
|
67
67
|
case "attr":
|
|
68
68
|
return value === void 0 ? "" : attribute(hole.name ?? arg, arg, value);
|
|
69
69
|
case "props":
|
|
70
|
-
return Object.entries(value).filter(([name]) => !hole.except.includes(name)).sort(([a], [b]) => attributeOrder(a, b)).map(([name, item]) => attribute(name, name, item)).join(
|
|
70
|
+
return Object.entries(value).filter(([name]) => !hole.except.includes(name)).sort(([a], [b]) => attributeOrder(a, b)).map(([name, item]) => attribute(name, name, item)).join(hole.separator);
|
|
71
71
|
case "slots": {
|
|
72
72
|
let set = hole.slots.filter((name) => Object.hasOwn(value, name)).sort(slotOrder);
|
|
73
73
|
if (set.length === 0)
|
|
74
|
-
return hole.tag ?
|
|
74
|
+
return hole.tag ? hole.closing : "";
|
|
75
75
|
let children = set.map((name) => wrapSlotContent(name, slot(name, value[name]))).map((child) => indent(child, hole.indent)).join(`
|
|
76
76
|
`);
|
|
77
77
|
return hole.tag ? `>
|
|
@@ -292,7 +292,7 @@ function partitionArgsByRole(args) {
|
|
|
292
292
|
slots: args.filter((arg) => arg.role === "slot").sort((a, b) => slotOrder(a.name, b.name))
|
|
293
293
|
};
|
|
294
294
|
}
|
|
295
|
-
function createRenderContext(
|
|
295
|
+
function createRenderContext(marks) {
|
|
296
296
|
return {
|
|
297
297
|
imports: {},
|
|
298
298
|
// `ref` is reserved up front so no hoisted arg can shadow the Vue import a v-model may need.
|
|
@@ -301,7 +301,8 @@ function createRenderContext(mark) {
|
|
|
301
301
|
hoistedArgs: /* @__PURE__ */ new Map(),
|
|
302
302
|
componentImports: /* @__PURE__ */ new Set(),
|
|
303
303
|
statements: [],
|
|
304
|
-
mark
|
|
304
|
+
mark: marks?.mark,
|
|
305
|
+
measure: marks?.unmark ?? ((code) => code)
|
|
305
306
|
};
|
|
306
307
|
}
|
|
307
308
|
var marked = (ctx, hole, text, space) => ctx.mark ? ctx.mark(hole, text, space) : text, attributeHole = (name, arg) => ({
|
|
@@ -447,30 +448,23 @@ function importStatementForBinding(localName, binding) {
|
|
|
447
448
|
}
|
|
448
449
|
function normalizeTemplateBlock(source) {
|
|
449
450
|
let lines = source.split(`
|
|
450
|
-
`), start
|
|
451
|
-
|
|
452
|
-
let line = lines[lineIndex], contentIndex = line.search(/\S/);
|
|
453
|
-
if (contentIndex === -1) {
|
|
454
|
-
lines[lineIndex] = "";
|
|
455
|
-
continue;
|
|
456
|
-
}
|
|
457
|
-
if (start ??= lineIndex, end = lineIndex + 1, commonPrefix === void 0) {
|
|
458
|
-
commonPrefix = line.slice(0, contentIndex);
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
let index = 0;
|
|
462
|
-
for (; index < commonPrefix.length && index < contentIndex && commonPrefix[index] === line[index]; )
|
|
463
|
-
index += 1;
|
|
464
|
-
commonPrefix = commonPrefix.slice(0, index);
|
|
465
|
-
}
|
|
466
|
-
if (start === void 0)
|
|
451
|
+
`).map((line) => /\S/.test(line) ? line : ""), start = lines.findIndex((line) => line !== "");
|
|
452
|
+
if (start === -1)
|
|
467
453
|
return "";
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
lines[lineIndex] = lines[lineIndex].slice(commonPrefix.length);
|
|
471
|
-
return lines.slice(start, end).join(`
|
|
454
|
+
let end = lines.findLastIndex((line) => line !== "") + 1, indent2 = templateIndent(source);
|
|
455
|
+
return lines.slice(start, end).map((line) => line.slice(indent2.length)).join(`
|
|
472
456
|
`);
|
|
473
457
|
}
|
|
458
|
+
function templateIndent(source) {
|
|
459
|
+
let indents = source.split(`
|
|
460
|
+
`).filter((line) => /\S/.test(line)).map((line) => /^\s*/.exec(line)[0]);
|
|
461
|
+
return indents.reduce((common, indent2) => {
|
|
462
|
+
let length = 0;
|
|
463
|
+
for (; length < common.length && common[length] === indent2[length]; )
|
|
464
|
+
length += 1;
|
|
465
|
+
return common.slice(0, length);
|
|
466
|
+
}, indents[0] ?? "");
|
|
467
|
+
}
|
|
474
468
|
|
|
475
469
|
// src/docgen/story-docs/print-h/print-h.ts
|
|
476
470
|
var H_FUNCTION = "h", ARGS_NAME = "args", ARGS_BINDING = `v-bind="${ARGS_NAME}"`, NO_DOCGEN = { props: /* @__PURE__ */ new Set(), events: /* @__PURE__ */ new Set(), slots: /* @__PURE__ */ new Set() }, VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
@@ -769,6 +763,7 @@ import {
|
|
|
769
763
|
unwrapExpression as unwrapExpression7,
|
|
770
764
|
walk as walk4
|
|
771
765
|
} from "storybook/internal/csf-tools";
|
|
766
|
+
import { SNIPPET_INDENT, layOutWrittenTag } from "storybook/internal/docs-tools";
|
|
772
767
|
|
|
773
768
|
// src/docgen/story-docs/transform-template/forward-setup.ts
|
|
774
769
|
import {
|
|
@@ -1032,7 +1027,8 @@ function transformTemplate(input) {
|
|
|
1032
1027
|
slots: input.slots ?? /* @__PURE__ */ new Set(),
|
|
1033
1028
|
argsStory: input.argsStory ?? !1,
|
|
1034
1029
|
importBindings: input.importBindings ?? /* @__PURE__ */ new Map(),
|
|
1035
|
-
template
|
|
1030
|
+
template,
|
|
1031
|
+
indent: templateIndent(template)
|
|
1036
1032
|
};
|
|
1037
1033
|
if (!(input.setup && !seedForwardedSetup(input.setup, state)) && collectTemplateScopeBindings(ast.children, state.ctx) && ast.children.every((child) => transformNode(child, state)) && !(input.setup && !appendSetupStatements(input.setup, state)))
|
|
1038
1034
|
return {
|
|
@@ -1117,6 +1113,7 @@ function transformElement(node, state) {
|
|
|
1117
1113
|
}, attributesByName = attributePropsByName(node), plan = planArgsBindingExpansion(node, attributesByName, state);
|
|
1118
1114
|
if (!plan)
|
|
1119
1115
|
return !1;
|
|
1116
|
+
let propEdits = state.edits.length;
|
|
1120
1117
|
for (let prop of node.props) {
|
|
1121
1118
|
if (plan.removed.has(prop)) {
|
|
1122
1119
|
state.edits.push(replacementFor(prop, "", state.template));
|
|
@@ -1137,20 +1134,25 @@ function transformElement(node, state) {
|
|
|
1137
1134
|
if (prop.type === NodeTypes.DIRECTIVE && !transformDirective(prop, attributesByName, element, state))
|
|
1138
1135
|
return !1;
|
|
1139
1136
|
}
|
|
1140
|
-
let
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1137
|
+
let closeStart = layOutStartTag(
|
|
1138
|
+
node,
|
|
1139
|
+
plan.directive,
|
|
1140
|
+
element,
|
|
1141
|
+
state.edits.splice(propEdits),
|
|
1142
|
+
state
|
|
1143
|
+
), slotsHole = (text, tag) => {
|
|
1144
|
+
let place = { kind: "slots", slots: element.unsetSlots, indent: "", spread: !0 };
|
|
1145
|
+
return marked(state.ctx, tag ? { ...place, tag, closing: text } : place, text);
|
|
1146
|
+
};
|
|
1145
1147
|
if (element.slotChildren.length > 0) {
|
|
1146
1148
|
if (hasNonWhitespaceChildren(node))
|
|
1147
1149
|
return !1;
|
|
1148
|
-
let after = element.unsetSlots.length > 0 ? slotsHole("") : "", edit = slotChildrenEdit(node, element.slotChildren, after, state.template);
|
|
1150
|
+
let after = element.unsetSlots.length > 0 ? slotsHole("") : "", edit = slotChildrenEdit(node, element.slotChildren, after, state.template, closeStart);
|
|
1149
1151
|
if (!edit)
|
|
1150
1152
|
return !1;
|
|
1151
1153
|
state.edits.push(edit);
|
|
1152
1154
|
} else if (node.isSelfClosing && element.unsetSlots.length > 0) {
|
|
1153
|
-
let end = node.loc.end.offset, start = blankRunStart(state.template, end - 2);
|
|
1155
|
+
let end = node.loc.end.offset, start = closeStart ?? blankRunStart(state.template, end - 2);
|
|
1154
1156
|
state.edits.push({ start, end, text: slotsHole(state.template.slice(start, end), node.tag) });
|
|
1155
1157
|
}
|
|
1156
1158
|
return node.children.every((child) => transformNode(child, state));
|
|
@@ -1180,7 +1182,7 @@ function planArgsBindingExpansion(node, attributesByName, state) {
|
|
|
1180
1182
|
}
|
|
1181
1183
|
return { directive, surviving, removed };
|
|
1182
1184
|
}
|
|
1183
|
-
function expandArgsBinding({ directive, surviving
|
|
1185
|
+
function expandArgsBinding({ directive, surviving }, attributesByName, element, state) {
|
|
1184
1186
|
let rendered = renderArgsBindingExpansion(surviving, state.ctx, {
|
|
1185
1187
|
roleAware: element.storyTag,
|
|
1186
1188
|
renderSlotArg: (slot) => renderSlotArgContent(slot, state.ctx, state.importBindings, state.componentImports)
|
|
@@ -1196,13 +1198,13 @@ function expandArgsBinding({ directive, surviving, removed }, attributesByName,
|
|
|
1196
1198
|
),
|
|
1197
1199
|
...surviving.map((arg) => arg.name),
|
|
1198
1200
|
...state.slots
|
|
1199
|
-
],
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
"",
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
return state.edits.push({ ...edit, text: edit.text + added }), !0;
|
|
1201
|
+
], except = [...new Set(printed)];
|
|
1202
|
+
element.expansion = {
|
|
1203
|
+
attributes: rendered.attributes,
|
|
1204
|
+
added: (separator) => marked(state.ctx, { kind: "props", except, separator, spread: !0 }, "", separator)
|
|
1205
|
+
};
|
|
1206
|
+
let edit = replacementFor(directive, rendered.attributes.join(" "), state.template);
|
|
1207
|
+
return state.edits.push({ ...edit, text: edit.text + element.expansion.added(" ") }), !0;
|
|
1206
1208
|
}
|
|
1207
1209
|
function boundProp(prop, directive, attributesByName, element, state) {
|
|
1208
1210
|
let binding = prop.type === NodeTypes.DIRECTIVE ? prop : void 0, name = binding ? binding.name === "bind" && !setsOwnKey(binding) ? staticDirectiveArg(binding) : void 0 : prop.name, exp = binding?.exp?.type === NodeTypes.SIMPLE_EXPRESSION ? binding.exp : void 0, read = exp && state.argsByName.get(exactArgsMemberName(exp.content.trim()) ?? ""), later = attributesByName.get(name ?? "")?.some(
|
|
@@ -1440,6 +1442,42 @@ function replacementFor(prop, text, template) {
|
|
|
1440
1442
|
` && template[lineEnd] === `
|
|
1441
1443
|
` ? { start: lineStart - 1, end: lineEnd, text } : { start: lineStart, end, text };
|
|
1442
1444
|
}
|
|
1445
|
+
function layOutStartTag(node, directive, element, propEdits, state) {
|
|
1446
|
+
let { template } = state, tagEnd = openTagEndOffset(node, template), keep = () => {
|
|
1447
|
+
state.edits.push(...propEdits);
|
|
1448
|
+
};
|
|
1449
|
+
if (!element.expansion || tagEnd === void 0)
|
|
1450
|
+
return keep();
|
|
1451
|
+
let attributes = [];
|
|
1452
|
+
for (let prop of node.props) {
|
|
1453
|
+
let start = prop.loc.start.offset, end = prop.loc.end.offset;
|
|
1454
|
+
if (prop === directive) {
|
|
1455
|
+
attributes.push(...element.expansion.attributes, element.expansion.added);
|
|
1456
|
+
continue;
|
|
1457
|
+
}
|
|
1458
|
+
let inside = propEdits.filter((edit) => edit.start >= start && edit.end <= end), around = propEdits.filter(
|
|
1459
|
+
(edit) => edit.start < end && edit.end > start && !inside.includes(edit)
|
|
1460
|
+
);
|
|
1461
|
+
if (around.some((edit) => edit.text !== ""))
|
|
1462
|
+
return keep();
|
|
1463
|
+
let text2 = around.length > 0 ? "" : applyEdits(
|
|
1464
|
+
template.slice(start, end),
|
|
1465
|
+
inside.map((edit) => ({ ...edit, start: edit.start - start, end: edit.end - start }))
|
|
1466
|
+
);
|
|
1467
|
+
text2 !== "" && attributes.push(text2);
|
|
1468
|
+
}
|
|
1469
|
+
let close = node.isSelfClosing ? "/>" : ">", tag = {
|
|
1470
|
+
start: node.loc.start.offset,
|
|
1471
|
+
nameEnd: node.loc.start.offset + 1 + node.tag.length,
|
|
1472
|
+
closeStart: tagEnd - close.length,
|
|
1473
|
+
close
|
|
1474
|
+
}, text = layOutWrittenTag(template, tag, attributes, {
|
|
1475
|
+
measure: state.ctx.measure,
|
|
1476
|
+
// The snippet's `<template>` holds the markup dedented, one level in.
|
|
1477
|
+
before: (written) => SNIPPET_INDENT + written.slice(state.indent.length)
|
|
1478
|
+
});
|
|
1479
|
+
return text === void 0 ? keep() : (state.edits.push({ start: tag.nameEnd, end: tag.closeStart, text }), tag.closeStart);
|
|
1480
|
+
}
|
|
1443
1481
|
function blankRunStart(template, index) {
|
|
1444
1482
|
let cursor = index;
|
|
1445
1483
|
for (; cursor > 0 && BLANK_REGEXP.test(template[cursor - 1]); )
|
|
@@ -1452,14 +1490,14 @@ function blankRunEnd(template, index) {
|
|
|
1452
1490
|
cursor += 1;
|
|
1453
1491
|
return cursor;
|
|
1454
1492
|
}
|
|
1455
|
-
function slotChildrenEdit(node, children, after, template) {
|
|
1493
|
+
function slotChildrenEdit(node, children, after, template, closeStart) {
|
|
1456
1494
|
let baseIndent = " ".repeat(Math.max(node.loc.start.column - 1, 0)), joined = `
|
|
1457
1495
|
${children.map((child) => indentBy(child, `${baseIndent} `)).join(`
|
|
1458
1496
|
`)}${after}
|
|
1459
1497
|
${baseIndent}`;
|
|
1460
1498
|
if (node.isSelfClosing) {
|
|
1461
|
-
let start = node.loc.end.offset - 2;
|
|
1462
|
-
for (; start > 0 && template[start - 1] === " "; )
|
|
1499
|
+
let start = closeStart ?? node.loc.end.offset - 2;
|
|
1500
|
+
for (; closeStart === void 0 && start > 0 && template[start - 1] === " "; )
|
|
1463
1501
|
start -= 1;
|
|
1464
1502
|
return { start, end: node.loc.end.offset, text: `>${joined}</${node.tag}>` };
|
|
1465
1503
|
}
|
|
@@ -1670,10 +1708,10 @@ function enrichStoryDoc(csf, storyExport, storyDoc, options) {
|
|
|
1670
1708
|
let resolved = resolveStaticStoryArgs(storyExport, docgenArgInfo, options), { classified } = resolved, { args, unresolved: classifyUnresolved } = classified, unresolved = [...classifyUnresolved, ...resolved.unresolved];
|
|
1671
1709
|
if (args.length === 0 && unresolved.length > 0)
|
|
1672
1710
|
return withWarning(noSnippetWarning(unresolved));
|
|
1673
|
-
let print = (
|
|
1711
|
+
let print = (marks2) => renderStaticStorySnippet(renderer, classified, componentName, docgenArgInfo, options, marks2), rendered = print();
|
|
1674
1712
|
if (!rendered)
|
|
1675
1713
|
return withWarning(UNRENDERED_WARNINGS[renderer.kind]);
|
|
1676
|
-
let marks = createHoleMarks([rendered.snippet]), printed = print(marks
|
|
1714
|
+
let marks = createHoleMarks([rendered.snippet]), printed = print(marks)?.snippet, holes = printed === void 0 ? void 0 : marks.toTemplate(printed);
|
|
1677
1715
|
return {
|
|
1678
1716
|
...storyDoc,
|
|
1679
1717
|
snippet: rendered.snippet,
|
|
@@ -1693,6 +1731,11 @@ function laidOut(template) {
|
|
|
1693
1731
|
else if (segment.kind === "slots") {
|
|
1694
1732
|
let line = /[^\n]*$/.exec(stripHoles(result))[0];
|
|
1695
1733
|
result.push({ ...segment, indent: /^\s*/.exec(line)[0] + (segment.tag ? " " : "") });
|
|
1734
|
+
} else if (segment.kind === "props" && segment.separator.startsWith(`
|
|
1735
|
+
`)) {
|
|
1736
|
+
let line = /[^\n]*$/.exec(stripHoles(result))[0], separator = `
|
|
1737
|
+
${/^\s*/.exec(line)[0]}`;
|
|
1738
|
+
result.push({ ...segment, separator, space: separator });
|
|
1696
1739
|
} else if (typeof previous == "string" && /\n[ \t]+$/.test(previous) && segment.text === "" && segment.space === void 0 && (next === void 0 || typeof next == "string" && next.startsWith(`
|
|
1697
1740
|
`))) {
|
|
1698
1741
|
let space = /[ \t]+$/.exec(previous)[0];
|
|
@@ -1740,8 +1783,8 @@ function resolveStaticStoryArgs(storyExport, docgenArgInfo, options) {
|
|
|
1740
1783
|
unresolved: resolved.unresolved
|
|
1741
1784
|
};
|
|
1742
1785
|
}
|
|
1743
|
-
function renderStaticStorySnippet(renderer, classified, componentName, docgenArgInfo, options,
|
|
1744
|
-
let componentImportStatement = options.snippet?.componentImportStatement, { args } = classified, ctx = createRenderContext(
|
|
1786
|
+
function renderStaticStorySnippet(renderer, classified, componentName, docgenArgInfo, options, marks) {
|
|
1787
|
+
let componentImportStatement = options.snippet?.componentImportStatement, { args } = classified, ctx = createRenderContext(marks), slots = docgenArgInfo.slots;
|
|
1745
1788
|
if (renderer.kind === "sfc")
|
|
1746
1789
|
return componentImportStatement ? transformTemplate({
|
|
1747
1790
|
args,
|
|
@@ -2,8 +2,9 @@ import {
|
|
|
2
2
|
indent
|
|
3
3
|
} from "./chunk-B2AO4N3K.js";
|
|
4
4
|
import {
|
|
5
|
-
collectComponentMetaSources
|
|
6
|
-
|
|
5
|
+
collectComponentMetaSources,
|
|
6
|
+
relative
|
|
7
|
+
} from "./chunk-YPMEPZAF.js";
|
|
7
8
|
|
|
8
9
|
// src/docgen/component-docgen/arg-types/extractArgTypes.ts
|
|
9
10
|
import { convert, extractComponentProps, hasDocgen } from "storybook/internal/docs-tools";
|
|
@@ -319,7 +320,7 @@ function createNamedTypeDetailResolver({
|
|
|
319
320
|
|
|
320
321
|
// src/docgen/component-docgen/build-docgen.ts
|
|
321
322
|
import { readFile } from "node:fs/promises";
|
|
322
|
-
import { join } from "node:path";
|
|
323
|
+
import { join, parse } from "node:path";
|
|
323
324
|
import {
|
|
324
325
|
extractComponentDescription,
|
|
325
326
|
extractDescription,
|
|
@@ -333,6 +334,31 @@ import {
|
|
|
333
334
|
getStoryImportPathFromEntry
|
|
334
335
|
} from "storybook/internal/common";
|
|
335
336
|
|
|
337
|
+
// src/docgen/component-docgen/component-docs.ts
|
|
338
|
+
import { readFileSync } from "node:fs";
|
|
339
|
+
import { readDeclarationDocs } from "storybook/internal/common";
|
|
340
|
+
import {
|
|
341
|
+
SourceEditor,
|
|
342
|
+
parseReferenceModule
|
|
343
|
+
} from "storybook/internal/csf-tools";
|
|
344
|
+
import { parse as parseSfc } from "@vue/language-core";
|
|
345
|
+
function readSfcModule(filePath) {
|
|
346
|
+
try {
|
|
347
|
+
let script = parseSfc(readFileSync(filePath, "utf8")).descriptor.script?.content ?? "", editor = new SourceEditor(script, filePath);
|
|
348
|
+
return {
|
|
349
|
+
filePath,
|
|
350
|
+
editor: editor.program.body.some(({ type }) => type === "ExportDefaultDeclaration") ? editor : new SourceEditor(`${script}
|
|
351
|
+
export default {};`, filePath)
|
|
352
|
+
};
|
|
353
|
+
} catch {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
var readComponentDocs = (component) => readDeclarationDocs(
|
|
358
|
+
component,
|
|
359
|
+
(filePath) => (filePath.endsWith(".vue") ? readSfcModule : parseReferenceModule)(filePath)
|
|
360
|
+
);
|
|
361
|
+
|
|
336
362
|
// src/docgen/component-docgen/resolve-component/follow-re-export.ts
|
|
337
363
|
function followReExport(checker, filePath, exportName) {
|
|
338
364
|
let program = checker.getProgram(), sourceFile = program?.getSourceFile(filePath);
|
|
@@ -405,7 +431,7 @@ function getUsableComponentName(component) {
|
|
|
405
431
|
if (!(!name || NON_COMPONENT_NAMES.has(name.split(".")[0]) || !META_COMPONENT_NAME.test(name)))
|
|
406
432
|
return name;
|
|
407
433
|
}
|
|
408
|
-
async function extractVueComponentDocgen(context, resolvedComponent,
|
|
434
|
+
async function extractVueComponentDocgen(context, resolvedComponent, errorContext = "") {
|
|
409
435
|
let checker = context.getChecker(resolvedComponent.path), declaredExport = followReExport(
|
|
410
436
|
checker,
|
|
411
437
|
resolvedComponent.path,
|
|
@@ -413,23 +439,15 @@ async function extractVueComponentDocgen(context, resolvedComponent, { metaJsDoc
|
|
|
413
439
|
) ?? {
|
|
414
440
|
path: resolvedComponent.path,
|
|
415
441
|
exportName: resolvedComponent.exportName
|
|
416
|
-
}, componentMeta = (await collectComponentMetaSources(
|
|
417
|
-
checker,
|
|
418
|
-
declaredExport.path,
|
|
419
|
-
context.typescript
|
|
420
|
-
)).find((meta) => meta.exportName === declaredExport.exportName);
|
|
442
|
+
}, componentMeta = (await collectComponentMetaSources(checker, declaredExport.path)).find((meta) => meta.exportName === declaredExport.exportName);
|
|
421
443
|
if (!componentMeta)
|
|
422
444
|
return {
|
|
423
445
|
error: {
|
|
424
446
|
name: "No docgen found",
|
|
425
|
-
message: `vue-component-meta extracted no component metadata for the "${declaredExport.exportName}" export of ${declaredExport.path}${errorContext}.`
|
|
447
|
+
message: `vue-component-meta extracted no component metadata for the "${declaredExport.exportName}" export of ${relative(process.cwd(), declaredExport.path)}${errorContext}.`
|
|
426
448
|
}
|
|
427
449
|
};
|
|
428
|
-
let
|
|
429
|
-
metaJsDoc,
|
|
430
|
-
componentMeta.description,
|
|
431
|
-
componentMeta.jsDocTags
|
|
432
|
-
), resolveNamedTypeDetail = createNamedTypeDetailResolver({
|
|
450
|
+
let resolveNamedTypeDetail = createNamedTypeDetailResolver({
|
|
433
451
|
checker,
|
|
434
452
|
typescript: context.typescript,
|
|
435
453
|
componentPath: declaredExport.path
|
|
@@ -437,18 +455,15 @@ async function extractVueComponentDocgen(context, resolvedComponent, { metaJsDoc
|
|
|
437
455
|
return {
|
|
438
456
|
path: declaredExport.path,
|
|
439
457
|
componentMeta,
|
|
440
|
-
description,
|
|
441
|
-
summary,
|
|
442
|
-
jsDocTags,
|
|
443
458
|
argTypes: extractArgTypes({ __docgenInfo: componentMeta }, resolveNamedTypeDetail) ?? void 0,
|
|
444
459
|
apiDescription: buildApiDescription(componentMeta)
|
|
445
460
|
};
|
|
446
461
|
}
|
|
447
462
|
async function buildSubcomponentDocgen(csf, storyPath, storyFilePath, declared, context) {
|
|
448
|
-
let failure = (error) => ({
|
|
463
|
+
let failure = (error, docs = { jsDocTags: {} }) => ({
|
|
449
464
|
name: declared.componentName,
|
|
450
465
|
path: storyFilePath,
|
|
451
|
-
|
|
466
|
+
...docs,
|
|
452
467
|
error
|
|
453
468
|
});
|
|
454
469
|
try {
|
|
@@ -457,16 +472,20 @@ async function buildSubcomponentDocgen(csf, storyPath, storyFilePath, declared,
|
|
|
457
472
|
return failure(
|
|
458
473
|
unresolvedComponentError(resolved.reason, `meta.subcomponents.${declared.name}`)
|
|
459
474
|
);
|
|
460
|
-
let
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
475
|
+
let componentDocs = readComponentDocs(resolved.component), docs = extractComponentDescription(
|
|
476
|
+
void 0,
|
|
477
|
+
componentDocs?.description,
|
|
478
|
+
componentDocs?.tags
|
|
479
|
+
), extracted = await extractVueComponentDocgen(
|
|
480
|
+
context,
|
|
481
|
+
resolved.component,
|
|
482
|
+
` (subcomponent "${declared.name}")`
|
|
483
|
+
);
|
|
484
|
+
return "error" in extracted ? failure(extracted.error, docs) : {
|
|
464
485
|
name: declared.componentName,
|
|
465
486
|
// Written like the story's index path, as in the other renderers, not as a machine path.
|
|
466
487
|
path: componentPathFromStory(storyFilePath, storyPath, extracted.path),
|
|
467
|
-
|
|
468
|
-
summary: extracted.summary,
|
|
469
|
-
jsDocTags: extracted.jsDocTags,
|
|
488
|
+
...docs,
|
|
470
489
|
argTypes: extracted.argTypes,
|
|
471
490
|
apiDescription: extracted.apiDescription,
|
|
472
491
|
renderer: "vue3"
|
|
@@ -478,7 +497,7 @@ async function buildSubcomponentDocgen(csf, storyPath, storyFilePath, declared,
|
|
|
478
497
|
});
|
|
479
498
|
}
|
|
480
499
|
}
|
|
481
|
-
async function
|
|
500
|
+
async function describeStoryComponent(input, context = {}) {
|
|
482
501
|
let storyFilePath = getStoryImportPathFromEntry(input.entry);
|
|
483
502
|
if (!storyFilePath)
|
|
484
503
|
return;
|
|
@@ -490,12 +509,7 @@ async function buildDocgenPayload(input, context) {
|
|
|
490
509
|
return;
|
|
491
510
|
throw error;
|
|
492
511
|
}
|
|
493
|
-
let fallbackName = componentNameFromTitle(input.entry.title),
|
|
494
|
-
id: getComponentIdFromEntry(input.entry),
|
|
495
|
-
name,
|
|
496
|
-
path: storyFilePath,
|
|
497
|
-
jsDocTags: {}
|
|
498
|
-
}), csf;
|
|
512
|
+
let fallbackName = componentNameFromTitle(input.entry.title), id = getComponentIdFromEntry(input.entry), csf;
|
|
499
513
|
try {
|
|
500
514
|
csf = loadCsf(storyFile, {
|
|
501
515
|
makeTitle: () => input.entry.title,
|
|
@@ -503,7 +517,7 @@ async function buildDocgenPayload(input, context) {
|
|
|
503
517
|
}).parse();
|
|
504
518
|
} catch (error) {
|
|
505
519
|
return {
|
|
506
|
-
|
|
520
|
+
docs: { id, name: fallbackName, path: storyFilePath, jsDocTags: {} },
|
|
507
521
|
error: {
|
|
508
522
|
name: "Story file could not be parsed",
|
|
509
523
|
message: `${error instanceof Error ? error.message : String(error)}
|
|
@@ -513,14 +527,19 @@ ${storyFile}`
|
|
|
513
527
|
}
|
|
514
528
|
};
|
|
515
529
|
}
|
|
516
|
-
let authoredComponentName = getUsableComponentName(csf._meta?.component),
|
|
530
|
+
let authoredComponentName = getUsableComponentName(csf._meta?.component), metaJsDoc = extractDescription(csf._metaStatement, csf.editor) || void 0, resolved = resolveMetaComponent(csf, storyPath);
|
|
517
531
|
if ("reason" in resolved) {
|
|
518
532
|
let error = unresolvedComponentError(
|
|
519
533
|
resolved.reason,
|
|
520
534
|
resolved.reason === "no-meta-component" ? "your story file" : "meta.component"
|
|
521
535
|
);
|
|
522
536
|
return {
|
|
523
|
-
|
|
537
|
+
docs: {
|
|
538
|
+
id,
|
|
539
|
+
name: authoredComponentName ?? fallbackName,
|
|
540
|
+
path: storyFilePath,
|
|
541
|
+
...extractComponentDescription(metaJsDoc, void 0)
|
|
542
|
+
},
|
|
524
543
|
error: {
|
|
525
544
|
name: error.name,
|
|
526
545
|
message: (csf._metaStatement ? storyShapeError(error.message, csf._metaStatement, csf.editor).message : error.message) + `
|
|
@@ -530,8 +549,34 @@ ${storyFile}`
|
|
|
530
549
|
}
|
|
531
550
|
};
|
|
532
551
|
}
|
|
533
|
-
let { component } = resolved,
|
|
534
|
-
|
|
552
|
+
let { component } = resolved, componentDocs = readComponentDocs(component), exportedName = component.exportName === "default" ? parse(component.path).name : component.exportName;
|
|
553
|
+
return {
|
|
554
|
+
docs: {
|
|
555
|
+
id,
|
|
556
|
+
name: (authoredComponentName ?? exportedName) || fallbackName,
|
|
557
|
+
path: storyFilePath,
|
|
558
|
+
...extractComponentDescription(metaJsDoc, componentDocs?.description, componentDocs?.tags)
|
|
559
|
+
},
|
|
560
|
+
csf,
|
|
561
|
+
storyPath,
|
|
562
|
+
storyFilePath,
|
|
563
|
+
component
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
async function buildBasicDocgen(input, context = {}) {
|
|
567
|
+
let described = await describeStoryComponent(input, context);
|
|
568
|
+
if (described)
|
|
569
|
+
return "error" in described ? { ...described.docs, error: described.error } : described.docs;
|
|
570
|
+
}
|
|
571
|
+
async function buildDocgenPayload(input, context) {
|
|
572
|
+
let described = await describeStoryComponent(input, context);
|
|
573
|
+
if (!described)
|
|
574
|
+
return;
|
|
575
|
+
let { docs } = described;
|
|
576
|
+
if ("error" in described)
|
|
577
|
+
return { ...docs, error: described.error };
|
|
578
|
+
let { csf, storyPath, storyFilePath, component } = described, [primaryDocgen, subcomponentEntries] = await Promise.all([
|
|
579
|
+
extractVueComponentDocgen(context, component),
|
|
535
580
|
Promise.all(
|
|
536
581
|
extractDeclaredSubcomponents(csf).map(
|
|
537
582
|
async (declaredSubcomponent) => [
|
|
@@ -547,11 +592,8 @@ ${storyFile}`
|
|
|
547
592
|
)
|
|
548
593
|
).then((entries) => Object.fromEntries(entries))
|
|
549
594
|
]);
|
|
550
|
-
return "error" in primaryDocgen ? { ...
|
|
551
|
-
...
|
|
552
|
-
description: primaryDocgen.description,
|
|
553
|
-
summary: primaryDocgen.summary,
|
|
554
|
-
jsDocTags: primaryDocgen.jsDocTags,
|
|
595
|
+
return "error" in primaryDocgen ? { ...docs, error: primaryDocgen.error } : {
|
|
596
|
+
...docs,
|
|
555
597
|
vueComponentMeta: primaryDocgen.componentMeta,
|
|
556
598
|
argTypes: primaryDocgen.argTypes,
|
|
557
599
|
apiDescription: primaryDocgen.apiDescription,
|
|
@@ -564,5 +606,6 @@ export {
|
|
|
564
606
|
extractArgTypes,
|
|
565
607
|
buildApiDescription,
|
|
566
608
|
createNamedTypeDetailResolver,
|
|
609
|
+
buildBasicDocgen,
|
|
567
610
|
buildDocgenPayload
|
|
568
611
|
};
|
|
@@ -1,11 +1,74 @@
|
|
|
1
1
|
// src/docgen/component-docgen/component-meta/component-meta.ts
|
|
2
2
|
import { readFile, stat } from "node:fs/promises";
|
|
3
|
-
import { join, parse } from "node:path";
|
|
3
|
+
import { isAbsolute as isAbsolute2, join as join2, parse as parse2, resolve as resolve2 } from "node:path";
|
|
4
4
|
import { getProjectRoot } from "storybook/internal/common";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
|
|
6
|
+
// ../../../node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
7
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
8
|
+
function normalizeWindowsPath(input = "") {
|
|
9
|
+
return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
10
|
+
}
|
|
11
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
12
|
+
var _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
13
|
+
function cwd() {
|
|
14
|
+
return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
|
|
15
|
+
}
|
|
16
|
+
var resolve = function(...arguments_) {
|
|
17
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
18
|
+
let resolvedPath = "", resolvedAbsolute = !1;
|
|
19
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
20
|
+
let path = index >= 0 ? arguments_[index] : cwd();
|
|
21
|
+
!path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path));
|
|
22
|
+
}
|
|
23
|
+
return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
|
|
24
|
+
};
|
|
25
|
+
function normalizeString(path, allowAboveRoot) {
|
|
26
|
+
let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
|
|
27
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
28
|
+
if (index < path.length)
|
|
29
|
+
char = path[index];
|
|
30
|
+
else {
|
|
31
|
+
if (char === "/")
|
|
32
|
+
break;
|
|
33
|
+
char = "/";
|
|
34
|
+
}
|
|
35
|
+
if (char === "/") {
|
|
36
|
+
if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
|
|
37
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
38
|
+
if (res.length > 2) {
|
|
39
|
+
let lastSlashIndex = res.lastIndexOf("/");
|
|
40
|
+
lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
|
|
41
|
+
continue;
|
|
42
|
+
} else if (res.length > 0) {
|
|
43
|
+
res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
|
|
48
|
+
} else
|
|
49
|
+
res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
|
|
50
|
+
lastSlash = index, dots = 0;
|
|
51
|
+
} else char === "." && dots !== -1 ? ++dots : dots = -1;
|
|
52
|
+
}
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
var isAbsolute = function(p) {
|
|
56
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
57
|
+
};
|
|
58
|
+
var relative = function(from, to) {
|
|
59
|
+
let _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/"), _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
60
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0])
|
|
61
|
+
return _to.join("/");
|
|
62
|
+
let _fromCopy = [..._from];
|
|
63
|
+
for (let segment of _fromCopy) {
|
|
64
|
+
if (_to[0] !== segment)
|
|
65
|
+
break;
|
|
66
|
+
_from.shift(), _to.shift();
|
|
67
|
+
}
|
|
68
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/docgen/component-docgen/component-meta/component-meta.ts
|
|
9
72
|
import {
|
|
10
73
|
TypeMeta,
|
|
11
74
|
createChecker,
|
|
@@ -22,10 +85,10 @@ var CHECKER_OPTIONS = {
|
|
|
22
85
|
schema: !0
|
|
23
86
|
};
|
|
24
87
|
async function createVueComponentMetaChecker(tsconfigPath = "tsconfig.json") {
|
|
25
|
-
let projectRoot = getProjectRoot(), projectTsConfigPath =
|
|
88
|
+
let projectRoot = getProjectRoot(), projectTsConfigPath = join2(projectRoot, tsconfigPath), defaultChecker = createCheckerByJson(projectRoot, { include: ["**/*"] }, CHECKER_OPTIONS);
|
|
26
89
|
return await fileExists(projectTsConfigPath) ? (await getTsConfigReferences(projectTsConfigPath)).length > 0 ? defaultChecker : createChecker(projectTsConfigPath, CHECKER_OPTIONS) : defaultChecker;
|
|
27
90
|
}
|
|
28
|
-
async function collectComponentMetaSources(checker, id
|
|
91
|
+
async function collectComponentMetaSources(checker, id) {
|
|
29
92
|
let entries = [];
|
|
30
93
|
for (let name of checker.getExportNames(id)) {
|
|
31
94
|
let meta;
|
|
@@ -33,22 +96,19 @@ async function collectComponentMetaSources(checker, id, typescript) {
|
|
|
33
96
|
meta = checker.getComponentMeta(id, name);
|
|
34
97
|
} catch {
|
|
35
98
|
}
|
|
36
|
-
meta && entries.push({
|
|
37
|
-
name,
|
|
38
|
-
meta,
|
|
39
|
-
jsDocInfo: typescript ? extractVueComponentJsDocInfo(typescript, checker, id, name) : void 0
|
|
40
|
-
});
|
|
99
|
+
meta && entries.push({ name, meta });
|
|
41
100
|
}
|
|
42
101
|
if (entries.length === 0)
|
|
43
102
|
return [];
|
|
44
103
|
let typeParams = await extractVueSfcTypeParams(id), fixedComponentsMeta = await applyVueDocgenApiTempFixes(
|
|
45
104
|
id,
|
|
46
105
|
entries.map((entry) => entry.meta),
|
|
47
|
-
entries.map((entry) => entry.name)
|
|
106
|
+
entries.map((entry) => entry.name),
|
|
107
|
+
getVueDocgenApiOptions(checker)
|
|
48
108
|
);
|
|
49
109
|
entries = entries.map((entry, index) => ({ ...entry, meta: fixedComponentsMeta[index] }));
|
|
50
110
|
let metaSources = [];
|
|
51
|
-
return entries.forEach(({ name, meta
|
|
111
|
+
return entries.forEach(({ name, meta }) => {
|
|
52
112
|
if (!meta.props.length && !meta.events.length && !meta.slots.length && !meta.exposed.length || meta.type === TypeMeta.Unknown)
|
|
53
113
|
return;
|
|
54
114
|
["props", "events", "slots", "exposed"].forEach((key) => {
|
|
@@ -67,14 +127,14 @@ async function collectComponentMetaSources(checker, id, typescript) {
|
|
|
67
127
|
exportName: name,
|
|
68
128
|
displayName: name === "default" ? getFilenameWithoutExtension(id) : name,
|
|
69
129
|
typeParams,
|
|
70
|
-
|
|
130
|
+
// Not spread: the `description` of the meta is a getter that reads the docblock.
|
|
131
|
+
name: meta.name,
|
|
132
|
+
type: meta.type,
|
|
71
133
|
props: meta.props.filter(isDocumented),
|
|
72
134
|
events: meta.events.filter(isDocumented),
|
|
73
135
|
slots: meta.slots.filter(isDocumented),
|
|
74
|
-
description: jsDocInfo?.description,
|
|
75
|
-
jsDocTags: jsDocInfo?.jsDocTags,
|
|
76
136
|
exposed: exposed.filter(isDocumented),
|
|
77
|
-
sourceFiles: id
|
|
137
|
+
sourceFiles: relative(process.cwd(), id)
|
|
78
138
|
})
|
|
79
139
|
);
|
|
80
140
|
}), metaSources;
|
|
@@ -95,16 +155,8 @@ async function extractVueSfcTypeParams(id) {
|
|
|
95
155
|
return;
|
|
96
156
|
}
|
|
97
157
|
}
|
|
98
|
-
function extractVueComponentJsDocInfo(typescript, checker, id, exportName) {
|
|
99
|
-
let program = checker.getProgram(), sourceFile = program?.getSourceFile(id.replace(/\\/g, "/"));
|
|
100
|
-
if (!program || !sourceFile)
|
|
101
|
-
return;
|
|
102
|
-
let typeChecker = program.getTypeChecker(), symbol = resolveExportedSymbol(typescript, typeChecker, sourceFile, exportName);
|
|
103
|
-
if (symbol)
|
|
104
|
-
return extractComponentJsDocInfo(typescript, typeChecker, symbol);
|
|
105
|
-
}
|
|
106
158
|
function getFilenameWithoutExtension(filename) {
|
|
107
|
-
return
|
|
159
|
+
return parse2(filename).name;
|
|
108
160
|
}
|
|
109
161
|
function lowercaseFirstLetter(string) {
|
|
110
162
|
return string.charAt(0).toLowerCase() + string.slice(1);
|
|
@@ -116,12 +168,34 @@ async function fileExists(fullPath) {
|
|
|
116
168
|
return !1;
|
|
117
169
|
}
|
|
118
170
|
}
|
|
119
|
-
|
|
171
|
+
function getVueDocgenApiOptions(checker) {
|
|
172
|
+
try {
|
|
173
|
+
let alias = getVueDocgenApiAliases(checker.getProgram()?.getCompilerOptions());
|
|
174
|
+
return alias ? { alias } : void 0;
|
|
175
|
+
} catch {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function getVueDocgenApiAliases(compilerOptions) {
|
|
180
|
+
let paths = compilerOptions?.paths, basePath = compilerOptions?.baseUrl ?? compilerOptions?.pathsBasePath;
|
|
181
|
+
if (!paths || !basePath)
|
|
182
|
+
return;
|
|
183
|
+
let aliases = {};
|
|
184
|
+
for (let [pattern, targets] of Object.entries(paths)) {
|
|
185
|
+
let target = targets[0];
|
|
186
|
+
if (!pattern.endsWith("/*") || !target?.endsWith("/*"))
|
|
187
|
+
continue;
|
|
188
|
+
let aliasKey = pattern.slice(0, -2), targetDir = target.slice(0, -2);
|
|
189
|
+
!aliasKey || aliasKey.includes("*") || targetDir.includes("*") || (aliases[aliasKey] = isAbsolute2(targetDir) ? targetDir : resolve2(basePath, targetDir));
|
|
190
|
+
}
|
|
191
|
+
return Object.keys(aliases).length > 0 ? aliases : void 0;
|
|
192
|
+
}
|
|
193
|
+
async function applyVueDocgenApiTempFixes(filename, componentsMeta, exportNames, docgenOptions) {
|
|
120
194
|
let source = await readVueDocgenApiFallbackSource(filename), hasEvents = componentsMeta.some((meta) => meta.events.length > 0), needsEventRestore = hasRuntimeEmitsDeclaration(source), needsSlots = hasTemplateSlotGap(filename, componentsMeta, source);
|
|
121
195
|
if (!hasEvents && !needsEventRestore && !needsSlots)
|
|
122
196
|
return componentsMeta;
|
|
123
197
|
try {
|
|
124
|
-
let parsedComponentDocs = await
|
|
198
|
+
let parsedComponentDocs = await parseMultiForFallback(filename, docgenOptions), parsedByExportName = new Map(parsedComponentDocs.map((doc) => [doc.exportName, doc]));
|
|
125
199
|
componentsMeta.forEach((meta, index) => {
|
|
126
200
|
let parsed = parsedByExportName.get(exportNames[index]);
|
|
127
201
|
parsed && ((hasEvents || needsEventRestore) && mergeEventDescriptions(meta, parsed.events), needsEventRestore && restoreMissingRuntimeEvents(meta, parsed.events), needsSlots && mergeTemplateSlots(meta, parsed.slots, source));
|
|
@@ -130,6 +204,14 @@ async function applyVueDocgenApiTempFixes(filename, componentsMeta, exportNames)
|
|
|
130
204
|
}
|
|
131
205
|
return componentsMeta;
|
|
132
206
|
}
|
|
207
|
+
var isParsableTypeSource = (fullFilePath) => !/[\\/]node_modules[\\/]/.test(fullFilePath) && !fullFilePath.endsWith(".vue");
|
|
208
|
+
async function parseMultiForFallback(filename, docgenOptions) {
|
|
209
|
+
try {
|
|
210
|
+
return await parseMulti(filename, docgenOptions);
|
|
211
|
+
} catch {
|
|
212
|
+
return parseMulti(filename, { ...docgenOptions, validExtends: isParsableTypeSource });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
133
215
|
async function readVueDocgenApiFallbackSource(filename) {
|
|
134
216
|
if (/\.(?:vue|tsx?|jsx?)$/.test(filename))
|
|
135
217
|
try {
|
|
@@ -229,8 +311,10 @@ function removeNestedSchemas(schema) {
|
|
|
229
311
|
}
|
|
230
312
|
|
|
231
313
|
export {
|
|
314
|
+
relative,
|
|
232
315
|
CHECKER_OPTIONS,
|
|
233
316
|
createVueComponentMetaChecker,
|
|
234
317
|
collectComponentMetaSources,
|
|
318
|
+
getVueDocgenApiAliases,
|
|
235
319
|
applyVueDocgenApiTempFixes
|
|
236
320
|
};
|
|
@@ -2,11 +2,13 @@ import {
|
|
|
2
2
|
CHECKER_OPTIONS,
|
|
3
3
|
applyVueDocgenApiTempFixes,
|
|
4
4
|
collectComponentMetaSources,
|
|
5
|
-
createVueComponentMetaChecker
|
|
6
|
-
|
|
5
|
+
createVueComponentMetaChecker,
|
|
6
|
+
getVueDocgenApiAliases
|
|
7
|
+
} from "./chunk-YPMEPZAF.js";
|
|
7
8
|
export {
|
|
8
9
|
CHECKER_OPTIONS,
|
|
9
10
|
applyVueDocgenApiTempFixes,
|
|
10
11
|
collectComponentMetaSources,
|
|
11
|
-
createVueComponentMetaChecker
|
|
12
|
+
createVueComponentMetaChecker,
|
|
13
|
+
getVueDocgenApiAliases
|
|
12
14
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ComponentMeta, ComponentMetaChecker, MetaCheckerOptions } from "vue-component-meta";
|
|
2
|
+
import { DocGenOptions } from "vue-docgen-api";
|
|
2
3
|
import ts from "typescript";
|
|
3
4
|
|
|
4
5
|
//#region code/renderers/vue3/.dts-emit/code/renderers/vue3/src/docgen/component-docgen/component-meta/component-meta.d.ts
|
|
@@ -10,8 +11,7 @@ type MetaSource = {
|
|
|
10
11
|
displayName: string; /** Component-level TypeScript type parameters declared by the SFC. */
|
|
11
12
|
typeParams?: string;
|
|
12
13
|
sourceFiles: string;
|
|
13
|
-
|
|
14
|
-
} & Serializable<ComponentMeta> & MetaCheckerOptions['schema'];
|
|
14
|
+
} & Serializable<Omit<ComponentMeta, 'description'>> & MetaCheckerOptions['schema'];
|
|
15
15
|
/** Checker options shared by every path so legacy and server extraction produce identical meta. */
|
|
16
16
|
declare const CHECKER_OPTIONS: MetaCheckerOptions;
|
|
17
17
|
/**
|
|
@@ -25,7 +25,7 @@ declare function createVueComponentMetaChecker(tsconfigPath?: string): Promise<C
|
|
|
25
25
|
* Exports whose meta is empty or of an unknown type are dropped, so a file with one non-component
|
|
26
26
|
* export cannot suppress the docgen of its siblings.
|
|
27
27
|
*/
|
|
28
|
-
declare function collectComponentMetaSources(checker: ComponentMetaChecker, id: string
|
|
28
|
+
declare function collectComponentMetaSources(checker: ComponentMetaChecker, id: string): Promise<MetaSource[]>;
|
|
29
29
|
/**
|
|
30
30
|
* Fills the gaps Volar cannot extract yet from a `vue-docgen-api` parse of the same file:
|
|
31
31
|
*
|
|
@@ -39,6 +39,6 @@ declare function collectComponentMetaSources(checker: ComponentMetaChecker, id:
|
|
|
39
39
|
* actually present in the extracted meta. Delete each merge once Volar covers it, and uninstall
|
|
40
40
|
* the vue-docgen-api dependency when both are gone.
|
|
41
41
|
*/
|
|
42
|
-
declare function applyVueDocgenApiTempFixes(filename: string, componentsMeta: ComponentMeta[], exportNames: string[]): Promise<ComponentMeta[]>;
|
|
42
|
+
declare function applyVueDocgenApiTempFixes(filename: string, componentsMeta: ComponentMeta[], exportNames: string[], docgenOptions?: DocGenOptions): Promise<ComponentMeta[]>;
|
|
43
43
|
//#endregion
|
|
44
44
|
export { createVueComponentMetaChecker as a, collectComponentMetaSources as i, MetaSource as n, applyVueDocgenApiTempFixes as r, CHECKER_OPTIONS as t };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
buildBasicDocgen,
|
|
2
3
|
buildDocgenPayload
|
|
3
|
-
} from "../_node-chunks/chunk-
|
|
4
|
+
} from "../_node-chunks/chunk-IXYCOERX.js";
|
|
4
5
|
import "../_node-chunks/chunk-B2AO4N3K.js";
|
|
5
6
|
import {
|
|
6
7
|
CHECKER_OPTIONS
|
|
7
|
-
} from "../_node-chunks/chunk-
|
|
8
|
+
} from "../_node-chunks/chunk-YPMEPZAF.js";
|
|
8
9
|
|
|
9
10
|
// src/docgen/docgen-worker.ts
|
|
10
11
|
import { createLazyDocgenMiddleware, loadTypeScriptCompilerApi } from "storybook/internal/common";
|
|
@@ -225,6 +226,7 @@ var createDocgenProvider = () => createLazyDocgenMiddleware({
|
|
|
225
226
|
return;
|
|
226
227
|
}
|
|
227
228
|
},
|
|
229
|
+
extractBasic: (input) => buildBasicDocgen(input),
|
|
228
230
|
extract: async (manager, input) => {
|
|
229
231
|
let ours = await buildDocgenPayload(input, {
|
|
230
232
|
getChecker: (componentPath) => manager.getCheckerForFile(componentPath),
|
package/dist/docgen/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l as StoryContext$1 } from "../chunk-DIk4dpkW.js";
|
|
2
|
-
import { i as collectComponentMetaSources, n as MetaSource, r as applyVueDocgenApiTempFixes, t as CHECKER_OPTIONS } from "../chunk-
|
|
2
|
+
import { i as collectComponentMetaSources, n as MetaSource, r as applyVueDocgenApiTempFixes, t as CHECKER_OPTIONS } from "../chunk-CmSWgGT0.js";
|
|
3
3
|
import { DocgenPayload, DocgenProviderInput, StoryDocsPayload, StoryDocsProviderInput, StrictArgTypes } from "storybook/internal/types";
|
|
4
4
|
import { ComponentMetaChecker } from "vue-component-meta";
|
|
5
5
|
import ts from "typescript";
|
package/dist/docgen/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildStoryDocsPayload
|
|
3
|
-
} from "../_node-chunks/chunk-
|
|
3
|
+
} from "../_node-chunks/chunk-FEPCDEC2.js";
|
|
4
4
|
import {
|
|
5
5
|
buildApiDescription,
|
|
6
6
|
buildDocgenPayload,
|
|
7
7
|
createNamedTypeDetailResolver,
|
|
8
8
|
extractArgTypes
|
|
9
|
-
} from "../_node-chunks/chunk-
|
|
9
|
+
} from "../_node-chunks/chunk-IXYCOERX.js";
|
|
10
10
|
import "../_node-chunks/chunk-B2AO4N3K.js";
|
|
11
11
|
import {
|
|
12
12
|
CHECKER_OPTIONS,
|
|
13
13
|
applyVueDocgenApiTempFixes,
|
|
14
14
|
collectComponentMetaSources
|
|
15
|
-
} from "../_node-chunks/chunk-
|
|
15
|
+
} from "../_node-chunks/chunk-YPMEPZAF.js";
|
|
16
16
|
|
|
17
17
|
// src/docgen/story-docs/source-decorator/sourceDecorator.ts
|
|
18
18
|
import { SourceType } from "storybook/internal/docs-tools";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import "../_browser-chunks/chunk-
|
|
1
|
+
import "../_browser-chunks/chunk-FTNLYRVC.js";
|
|
2
2
|
import "../_browser-chunks/chunk-4BE7D4DS.js";
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
entry_preview_docs_exports
|
|
8
8
|
} from "./_browser-chunks/chunk-SERTEPAZ.js";
|
|
9
|
-
import "./_browser-chunks/chunk-
|
|
9
|
+
import "./_browser-chunks/chunk-FTNLYRVC.js";
|
|
10
10
|
import "./_browser-chunks/chunk-4BE7D4DS.js";
|
|
11
11
|
|
|
12
12
|
// src/globals.ts
|
package/dist/preset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createVueComponentMetaChecker, i as collectComponentMetaSources } from "./chunk-
|
|
1
|
+
import { a as createVueComponentMetaChecker, i as collectComponentMetaSources } from "./chunk-CmSWgGT0.js";
|
|
2
2
|
import { DocgenProviderDescriptor, IndexEntry, Options, PresetProperty, PresetPropertyFn, StorybookConfigRaw } from "storybook/internal/types";
|
|
3
3
|
import { parse } from "vue-docgen-api";
|
|
4
4
|
import { ImportParser } from "storybook/internal/core-server";
|
package/dist/preset.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildStoryDocsPayload
|
|
3
|
-
} from "./_node-chunks/chunk-
|
|
3
|
+
} from "./_node-chunks/chunk-FEPCDEC2.js";
|
|
4
4
|
import "./_node-chunks/chunk-B2AO4N3K.js";
|
|
5
5
|
|
|
6
6
|
// src/preset.ts
|
|
@@ -38,7 +38,7 @@ var experimental_storyDocsProvider = createWorkerGatedStoryDocsProvider({
|
|
|
38
38
|
|
|
39
39
|
// src/docgen/engine.ts
|
|
40
40
|
var experimental_vueDocgenEngine = async () => ({
|
|
41
|
-
componentMeta: () => import("./_node-chunks/component-meta-
|
|
41
|
+
componentMeta: () => import("./_node-chunks/component-meta-H4SIVDTW.js"),
|
|
42
42
|
vueDocgenApi: () => import("./_node-chunks/vue-docgen-api-IRJAMTGH.js")
|
|
43
43
|
});
|
|
44
44
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/vue3",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.4",
|
|
4
4
|
"description": "Storybook Vue 3 renderer: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"vue-tsc": "latest"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"storybook": "^11.0.0-rc.
|
|
74
|
+
"storybook": "^11.0.0-rc.4",
|
|
75
75
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0",
|
|
76
76
|
"vue": "^3.0.0"
|
|
77
77
|
},
|