@storybook/angular-vite 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-Y5SREGLY.js → chunk-2AD3AFBS.js} +3 -3
- package/dist/_browser-chunks/{chunk-S752VTMD.js → chunk-7TI2NQDW.js} +1 -1
- package/dist/_browser-chunks/{chunk-IFJFIE3P.js → chunk-SPIIFZLB.js} +1 -1
- package/dist/_browser-chunks/{chunk-6VSOLSRX.js → chunk-V7SLOYXF.js} +13 -11
- package/dist/_node-chunks/chunk-P3P4Y7DE.js +6 -0
- package/dist/builders/build-storybook/index.js +4 -1
- package/dist/builders/start-storybook/index.js +4 -1
- package/dist/client/config.js +2 -2
- package/dist/client/docs/config.js +2 -2
- package/dist/client/index.js +4 -4
- package/dist/docgen/docgen-worker.js +79 -90
- package/dist/index.js +4 -4
- package/dist/node/vitest.js +8 -4
- package/dist/preset.js +39 -30
- package/package.json +6 -6
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SPIIFZLB.js";
|
|
4
4
|
import {
|
|
5
5
|
config_exports as config_exports2
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7TI2NQDW.js";
|
|
7
7
|
import {
|
|
8
8
|
computesTemplateFromComponent,
|
|
9
9
|
formatPropInTemplate,
|
|
10
10
|
isComponent,
|
|
11
11
|
render_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-V7SLOYXF.js";
|
|
13
13
|
|
|
14
14
|
// src/client/portable-stories.ts
|
|
15
15
|
import {
|
|
@@ -22,6 +22,11 @@ import { BehaviorSubject } from "rxjs";
|
|
|
22
22
|
import { stringify } from "telejson";
|
|
23
23
|
|
|
24
24
|
// src/template-grammar.ts
|
|
25
|
+
import {
|
|
26
|
+
SNIPPET_INDENT,
|
|
27
|
+
SNIPPET_PRINT_WIDTH,
|
|
28
|
+
printOpeningTag
|
|
29
|
+
} from "storybook/internal/docs-tools/snippets";
|
|
25
30
|
var formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? propertyName : `this['${propertyName}']`, stringifyCircular = (obj) => {
|
|
26
31
|
let seen = /* @__PURE__ */ new Set();
|
|
27
32
|
return JSON.stringify(obj, (key, value) => {
|
|
@@ -60,26 +65,23 @@ var formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? p
|
|
|
60
65
|
"source",
|
|
61
66
|
"track",
|
|
62
67
|
"wbr"
|
|
63
|
-
]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/,
|
|
68
|
+
]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/, asWritten = (code) => code, buildTemplate = (selector, { inputs, outputs, innerTemplate = "", selfClosing = !1 }, unmarked = asWritten) => {
|
|
64
69
|
let bindings = [
|
|
65
70
|
...inputs.map(({ name, expression, attribute }) => attribute ?? inputBinding(name, expression)),
|
|
66
71
|
...outputs.map((name) => `(${name})="${formatPropInTemplate(name)}($event)"`)
|
|
67
72
|
], firstSelector = selector.split(",")[0];
|
|
68
73
|
return (LEADING_CLASS.test(firstSelector) || LEADING_ATTRIBUTE.test(firstSelector) ? `div${firstSelector}` : firstSelector).replace(ID, ' id="$1"').replace(CLASS_RUN, (classes) => ` class="${classes.split(".").join(" ").trim()}"`).replace(ATTRIBUTE, " $1").replace(ELEMENT_AND_ATTRIBUTES, (_, element, attributes) => {
|
|
69
|
-
let closesItself = VOID_ELEMENTS.has(element) || selfClosing && element.includes("-") && innerTemplate === "",
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (closesItself)
|
|
76
|
-
return selfClosing ? `${brokenTag}
|
|
77
|
-
/>` : `${brokenTag} />`;
|
|
74
|
+
let closesItself = VOID_ELEMENTS.has(element) || selfClosing && element.includes("-") && innerTemplate === "", closing = closesItself ? "" : `${innerTemplate}</${element}>`, { text, broken } = printOpeningTag(
|
|
75
|
+
{ open: `<${element}${attributes}`, attributes: bindings, close: closesItself ? "/>" : ">" },
|
|
76
|
+
{ after: closing, measure: unmarked }
|
|
77
|
+
);
|
|
78
|
+
if (!broken || closesItself)
|
|
79
|
+
return `${text}${closing}`;
|
|
78
80
|
let content = innerTemplate === "" ? `
|
|
79
81
|
` : `
|
|
80
82
|
${innerTemplate}
|
|
81
83
|
`;
|
|
82
|
-
return `${
|
|
84
|
+
return `${text}${content}</${element}>`;
|
|
83
85
|
});
|
|
84
86
|
}, buildComponentOutletTemplate = (componentName, { selfClosing = !1 } = {}) => selfClosing ? `<ng-container *ngComponentOutlet="${componentName}" />` : `<ng-container *ngComponentOutlet="${componentName}"></ng-container>`;
|
|
85
87
|
|
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
resolveTsconfig
|
|
11
11
|
} from "../../_node-chunks/chunk-DSX4K57A.js";
|
|
12
|
+
import {
|
|
13
|
+
BUILDER_OPTIONS_ENV
|
|
14
|
+
} from "../../_node-chunks/chunk-P3P4Y7DE.js";
|
|
12
15
|
|
|
13
16
|
// src/builders/build-storybook/index.ts
|
|
14
17
|
import { readFileSync } from "node:fs";
|
|
@@ -68,7 +71,7 @@ var commandBuilder = async (options, context) => {
|
|
|
68
71
|
tsConfig,
|
|
69
72
|
statsJson: normalizeStatsJson(statsJson)
|
|
70
73
|
};
|
|
71
|
-
if (process.env
|
|
74
|
+
if (process.env[BUILDER_OPTIONS_ENV] = JSON.stringify({
|
|
72
75
|
...standaloneOptions.angularBuilderOptions,
|
|
73
76
|
// Style and load paths in the target options are workspace-root-relative; the addon-vitest
|
|
74
77
|
// child runs with a different Vite root, so it needs the workspace root to resolve them.
|
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
resolveTsconfig
|
|
11
11
|
} from "../../_node-chunks/chunk-DSX4K57A.js";
|
|
12
|
+
import {
|
|
13
|
+
BUILDER_OPTIONS_ENV
|
|
14
|
+
} from "../../_node-chunks/chunk-P3P4Y7DE.js";
|
|
12
15
|
|
|
13
16
|
// src/builders/start-storybook/index.ts
|
|
14
17
|
import { readFileSync } from "node:fs";
|
|
@@ -93,7 +96,7 @@ var commandBuilder = (options, context) => new Observable((observer) => {
|
|
|
93
96
|
statsJson: normalizeStatsJson(statsJson),
|
|
94
97
|
loglevel
|
|
95
98
|
};
|
|
96
|
-
process.env
|
|
99
|
+
process.env[BUILDER_OPTIONS_ENV] = JSON.stringify({
|
|
97
100
|
...standaloneOptions.angularBuilderOptions,
|
|
98
101
|
// Style and load paths in the target options are workspace-root-relative; the addon-vitest
|
|
99
102
|
// child runs with a different Vite root, so it needs the workspace root to resolve them.
|
package/dist/client/config.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
argTypesEnhancers,
|
|
3
3
|
decorateStory,
|
|
4
4
|
parameters
|
|
5
|
-
} from "../_browser-chunks/chunk-
|
|
5
|
+
} from "../_browser-chunks/chunk-SPIIFZLB.js";
|
|
6
6
|
import {
|
|
7
7
|
render,
|
|
8
8
|
renderToCanvas
|
|
9
|
-
} from "../_browser-chunks/chunk-
|
|
9
|
+
} from "../_browser-chunks/chunk-V7SLOYXF.js";
|
|
10
10
|
import "../_browser-chunks/chunk-T4WQC6BZ.js";
|
|
11
11
|
export {
|
|
12
12
|
decorateStory as applyDecorators,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decorators,
|
|
3
3
|
parameters
|
|
4
|
-
} from "../../_browser-chunks/chunk-
|
|
4
|
+
} from "../../_browser-chunks/chunk-7TI2NQDW.js";
|
|
5
5
|
import "../../_browser-chunks/chunk-YS33I6LM.js";
|
|
6
|
-
import "../../_browser-chunks/chunk-
|
|
6
|
+
import "../../_browser-chunks/chunk-V7SLOYXF.js";
|
|
7
7
|
import "../../_browser-chunks/chunk-T4WQC6BZ.js";
|
|
8
8
|
export {
|
|
9
9
|
decorators,
|
package/dist/client/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
componentWrapperDecorator,
|
|
6
6
|
moduleMetadata,
|
|
7
7
|
setProjectAnnotations
|
|
8
|
-
} from "../_browser-chunks/chunk-
|
|
9
|
-
import "../_browser-chunks/chunk-
|
|
10
|
-
import "../_browser-chunks/chunk-
|
|
8
|
+
} from "../_browser-chunks/chunk-2AD3AFBS.js";
|
|
9
|
+
import "../_browser-chunks/chunk-SPIIFZLB.js";
|
|
10
|
+
import "../_browser-chunks/chunk-7TI2NQDW.js";
|
|
11
11
|
import "../_browser-chunks/chunk-YS33I6LM.js";
|
|
12
|
-
import "../_browser-chunks/chunk-
|
|
12
|
+
import "../_browser-chunks/chunk-V7SLOYXF.js";
|
|
13
13
|
import "../_browser-chunks/chunk-T4WQC6BZ.js";
|
|
14
14
|
export {
|
|
15
15
|
__definePreview,
|
|
@@ -25,9 +25,6 @@ import { statSync as statSync2 } from "node:fs";
|
|
|
25
25
|
import { logger } from "storybook/internal/node-logger";
|
|
26
26
|
import { slash } from "storybook/internal/common";
|
|
27
27
|
import { isInNodeModules as isInNodeModules2 } from "storybook/internal/common";
|
|
28
|
-
import {
|
|
29
|
-
extractComponentJsDocInfo
|
|
30
|
-
} from "storybook/internal/component-meta";
|
|
31
28
|
import { logger as logger5 } from "storybook/internal/node-logger";
|
|
32
29
|
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
33
30
|
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
@@ -2273,11 +2270,7 @@ function analyzeSourceFile(ts, sourceFile, checker, context = analyzerContext(ts
|
|
|
2273
2270
|
);
|
|
2274
2271
|
continue;
|
|
2275
2272
|
}
|
|
2276
|
-
let name = statement.name.text, file = sourceFile.fileName, members = collectClassMembers(ctx, statement, kind), common = {
|
|
2277
|
-
file,
|
|
2278
|
-
...getJsDocDescription(ts, statement),
|
|
2279
|
-
...getJsDocTagsField(ts, statement)
|
|
2280
|
-
};
|
|
2273
|
+
let name = statement.name.text, file = sourceFile.fileName, members = collectClassMembers(ctx, statement, kind), common = { file };
|
|
2281
2274
|
if (kind === "component" || kind === "directive") {
|
|
2282
2275
|
let { selector, standalone } = componentMetadata(ctx, statement, kind), record = {
|
|
2283
2276
|
name,
|
|
@@ -2378,16 +2371,7 @@ var KNOWN_DECORATORS = {
|
|
|
2378
2371
|
function extractComponent(typescript, checker, sourceFile, names, debug) {
|
|
2379
2372
|
let context = analyzerContext(typescript, sourceFile, checker), fileMeta = analyzeSourceFile(typescript, sourceFile, checker, context), entry = pickEntry(typescript, fileMeta, sourceFile, names);
|
|
2380
2373
|
if (entry)
|
|
2381
|
-
return debug(`${describe(entry)} from ${sourceFile.fileName}`), {
|
|
2382
|
-
entry,
|
|
2383
|
-
json: fileMeta,
|
|
2384
|
-
context,
|
|
2385
|
-
...jsDocInfoField(
|
|
2386
|
-
typescript,
|
|
2387
|
-
checker,
|
|
2388
|
-
findClassDeclaration(typescript, sourceFile, entry.name)
|
|
2389
|
-
)
|
|
2390
|
-
};
|
|
2374
|
+
return debug(`${describe(entry)} from ${sourceFile.fileName}`), { entry, json: fileMeta, context };
|
|
2391
2375
|
let viaExports = extractViaModuleExports(
|
|
2392
2376
|
typescript,
|
|
2393
2377
|
checker,
|
|
@@ -2443,12 +2427,7 @@ var importClosure = (typescript, checker, entry) => {
|
|
|
2443
2427
|
continue;
|
|
2444
2428
|
let declarationFile = declaration.getSourceFile(), targetContext = declarationFile === sourceFile ? context : analyzerContext(typescript, declarationFile, checker), targetMeta = declarationFile === sourceFile ? fileMeta : analyzeSourceFile(typescript, declarationFile, checker, targetContext), entry = findRecord(targetMeta, declaration.name.text);
|
|
2445
2429
|
if (entry)
|
|
2446
|
-
return {
|
|
2447
|
-
entry,
|
|
2448
|
-
json: targetMeta,
|
|
2449
|
-
context: targetContext,
|
|
2450
|
-
...jsDocInfoField(typescript, checker, declaration)
|
|
2451
|
-
};
|
|
2430
|
+
return { entry, json: targetMeta, context: targetContext };
|
|
2452
2431
|
}
|
|
2453
2432
|
}, allRecords = (fileMeta) => [
|
|
2454
2433
|
...fileMeta.components,
|
|
@@ -2460,15 +2439,6 @@ var importClosure = (typescript, checker, entry) => {
|
|
|
2460
2439
|
let counts = "inputsClass" in entry ? `${entry.inputsClass?.length ?? 0} input(s), ${entry.outputsClass?.length ?? 0} output(s), ${"propertiesClass" in entry ? entry.propertiesClass?.length ?? 0 : 0} propertie(s)` : `${entry.properties.length} propertie(s), ${entry.methods.length} method(s)`;
|
|
2461
2440
|
return `extracted ${entry.type} ${entry.name} with ${counts}`;
|
|
2462
2441
|
}, findRecord = (fileMeta, name) => name ? allRecords(fileMeta).find((record) => record.name === name) : void 0;
|
|
2463
|
-
function findClassDeclaration(typescript, sourceFile, name) {
|
|
2464
|
-
return sourceFile.statements.find(
|
|
2465
|
-
(statement) => typescript.isClassDeclaration(statement) && statement.name?.text === name
|
|
2466
|
-
);
|
|
2467
|
-
}
|
|
2468
|
-
function jsDocInfoField(typescript, checker, declaration) {
|
|
2469
|
-
let symbol = declaration?.name && checker.getSymbolAtLocation(declaration.name);
|
|
2470
|
-
return symbol ? { jsDocInfo: extractComponentJsDocInfo(typescript, checker, symbol) } : {};
|
|
2471
|
-
}
|
|
2472
2442
|
function findDefaultExportedClassName(typescript, sourceFile) {
|
|
2473
2443
|
for (let statement of sourceFile.statements) {
|
|
2474
2444
|
if (typescript.isClassDeclaration(statement) && statement.name && statement.modifiers?.some(
|
|
@@ -2746,7 +2716,8 @@ import { logger as logger6 } from "storybook/internal/node-logger";
|
|
|
2746
2716
|
import {
|
|
2747
2717
|
componentPathFromStory,
|
|
2748
2718
|
getComponentIdFromEntry,
|
|
2749
|
-
getStoryImportPathFromEntry
|
|
2719
|
+
getStoryImportPathFromEntry,
|
|
2720
|
+
readDeclarationDocs
|
|
2750
2721
|
} from "storybook/internal/common";
|
|
2751
2722
|
import { resolve } from "node:path";
|
|
2752
2723
|
|
|
@@ -2813,17 +2784,7 @@ function buildApiDescription(argTypes, componentName) {
|
|
|
2813
2784
|
}
|
|
2814
2785
|
|
|
2815
2786
|
// src/docgen/build-docgen.ts
|
|
2816
|
-
var inputsOf = (entry) => "inputsClass" in entry ? entry.inputsClass ?? [] : [], outputsOf = (entry) => "outputsClass" in entry ? entry.outputsClass ?? [] : [], describedBy = (text) => text?.trim() || void 0,
|
|
2817
|
-
let tags = {};
|
|
2818
|
-
for (let tag of entry.jsdoctags ?? []) {
|
|
2819
|
-
let name = tag.tagName?.escapedText;
|
|
2820
|
-
if (!name)
|
|
2821
|
-
continue;
|
|
2822
|
-
let value = tag.comment === void 0 ? "" : String(tag.comment).trim();
|
|
2823
|
-
(tags[name] ??= []).push(value);
|
|
2824
|
-
}
|
|
2825
|
-
return tags;
|
|
2826
|
-
}, metaToSnippetMeta = (meta) => {
|
|
2787
|
+
var inputsOf = (entry) => "inputsClass" in entry ? entry.inputsClass ?? [] : [], outputsOf = (entry) => "outputsClass" in entry ? entry.outputsClass ?? [] : [], describedBy = (text) => text?.trim() || void 0, metaToSnippetMeta = (meta) => {
|
|
2827
2788
|
let { entry } = meta, inputs = inputsOf(entry).map((input) => input.name), inputNames = new Set(inputs), outputs = [];
|
|
2828
2789
|
for (let output of outputsOf(entry)) {
|
|
2829
2790
|
let bindingName2 = inputNames.has(output.name) ? `${output.name}Change` : output.name;
|
|
@@ -2842,16 +2803,16 @@ var inputsOf = (entry) => "inputsClass" in entry ? entry.inputsClass ?? [] : [],
|
|
|
2842
2803
|
};
|
|
2843
2804
|
}, notFound = (message) => ({
|
|
2844
2805
|
error: { name: "AngularComponentMetaNotFound", message }
|
|
2845
|
-
}), unresolvedError = (resolution, reference,
|
|
2806
|
+
}), unresolvedError = (resolution, reference, storyImportPath) => {
|
|
2846
2807
|
switch (resolution.reason) {
|
|
2847
2808
|
case "unreadable-component-expression":
|
|
2848
2809
|
return notFound(
|
|
2849
2810
|
`The story file sets \`${reference}: ${resolution.expression}\`, which does not resolve to a class.
|
|
2850
|
-
Storybook follows an imported name, a namespace-import property access, or a chain of property accesses and spreads through modules it can resolve. Assign the component to a name in ${
|
|
2811
|
+
Storybook follows an imported name, a namespace-import property access, or a chain of property accesses and spreads through modules it can resolve. Assign the component to a name in ${storyImportPath}.`
|
|
2851
2812
|
);
|
|
2852
2813
|
case "no-component-import":
|
|
2853
2814
|
return notFound(
|
|
2854
|
-
`Resolving \`meta.${reference}\` from ${
|
|
2815
|
+
`Resolving \`meta.${reference}\` from ${storyImportPath} reached a binding that is a type-only or namespace import, which carries no class to document.
|
|
2855
2816
|
Import the component as a value in whichever module declares that binding.`
|
|
2856
2817
|
);
|
|
2857
2818
|
case "missing-export":
|
|
@@ -2860,18 +2821,28 @@ Import the component as a value in whichever module declares that binding.`
|
|
|
2860
2821
|
Check the name against the module's exports, and any barrel that re-exports it.`
|
|
2861
2822
|
);
|
|
2862
2823
|
case "no-meta-component":
|
|
2863
|
-
return notFound(`The story file ${
|
|
2824
|
+
return notFound(`The story file ${storyImportPath} sets no \`meta.${reference}\`.`);
|
|
2864
2825
|
default: {
|
|
2865
2826
|
let unhandled = resolution;
|
|
2866
2827
|
throw new Error(`Unhandled resolution ${JSON.stringify(unhandled)}`);
|
|
2867
2828
|
}
|
|
2868
2829
|
}
|
|
2869
|
-
},
|
|
2830
|
+
}, displayNameOf = (component) => component.exportName === "default" ? component.localName : component.exportName, readClassDocs = (component) => {
|
|
2831
|
+
let docs = readDeclarationDocs(component);
|
|
2832
|
+
return {
|
|
2833
|
+
// The declaration has the class name even when the story file imported it as a default export.
|
|
2834
|
+
name: docs?.name ?? displayNameOf(component),
|
|
2835
|
+
description: describedBy(docs?.description) ?? describedBy(docs?.tags.description?.[0]),
|
|
2836
|
+
summary: docs?.tags.summary?.[0],
|
|
2837
|
+
jsDocTags: docs?.tags ?? {}
|
|
2838
|
+
};
|
|
2839
|
+
}, extractClassDocgen = (component, displayName, reference, story, { manager, options, logger: logger8 }) => {
|
|
2840
|
+
let pathLikeStory = (file) => componentPathFromStory(story.importPath, story.filePath, file);
|
|
2870
2841
|
if (!component.path)
|
|
2871
2842
|
return notFound(
|
|
2872
2843
|
// The import can be written in another module the reference reaches, such as a barrel, so the
|
|
2873
2844
|
// message names the module that writes it.
|
|
2874
|
-
`Storybook could not resolve the import "${component.importId}" of "${displayName}" in ${component.importer
|
|
2845
|
+
`Storybook could not resolve the import "${component.importId}" of "${displayName}" in ${component.importer ? pathLikeStory(component.importer) : story.importPath}, reached while resolving \`meta.${reference}\` from ${story.importPath}.
|
|
2875
2846
|
Check the import specifier there, and any tsconfig path aliases it relies on.`
|
|
2876
2847
|
);
|
|
2877
2848
|
let meta;
|
|
@@ -2884,13 +2855,13 @@ Check the import specifier there, and any tsconfig path aliases it relies on.`
|
|
|
2884
2855
|
return {
|
|
2885
2856
|
error: {
|
|
2886
2857
|
name: "AngularComponentMetaExtractionFailed",
|
|
2887
|
-
message: `The analyzer threw while extracting "${component.exportName}" from ${component.path}: ${err instanceof Error ? err.message : String(err)}`
|
|
2858
|
+
message: `The analyzer threw while extracting "${component.exportName}" from ${pathLikeStory(component.path)}: ${err instanceof Error ? err.message : String(err)}`
|
|
2888
2859
|
}
|
|
2889
2860
|
};
|
|
2890
2861
|
}
|
|
2891
2862
|
if (!meta)
|
|
2892
2863
|
return notFound(
|
|
2893
|
-
`No metadata was extracted for the "${component.exportName}" export of ${component.path}.
|
|
2864
|
+
`No metadata was extracted for the "${component.exportName}" export of ${pathLikeStory(component.path)}.
|
|
2894
2865
|
Check that the file exports the component class and is covered by a tsconfig.json in or above its directory.`
|
|
2895
2866
|
);
|
|
2896
2867
|
let argTypes = extractArgTypesFromData(meta.entry, {
|
|
@@ -2905,79 +2876,94 @@ Check that the file exports the component class and is covered by a tsconfig.jso
|
|
|
2905
2876
|
propsTable: "api",
|
|
2906
2877
|
logger: logger8,
|
|
2907
2878
|
context: meta.context
|
|
2908
|
-
})
|
|
2879
|
+
});
|
|
2909
2880
|
return {
|
|
2910
|
-
// The analyzer knows the class name even when the story file imported it as a default export.
|
|
2911
|
-
name: meta.entry.name,
|
|
2912
|
-
description,
|
|
2913
|
-
summary: jsDocTags.summary?.[0],
|
|
2914
|
-
jsDocTags,
|
|
2915
2881
|
argTypes,
|
|
2916
2882
|
apiDescription: buildApiDescription(apiArgTypes, meta.entry.name),
|
|
2917
2883
|
angularComponentMeta: metaToSnippetMeta(meta)
|
|
2918
2884
|
};
|
|
2919
|
-
},
|
|
2885
|
+
}, nameOfUnresolved = (resolution, title) => resolution.reason === "unreadable-component-expression" ? resolution.expression : title.split("/").at(-1) ?? title, buildSubcomponentDocgen = ({ name, resolution }, story, context) => {
|
|
2920
2886
|
let reference = `subcomponents.${name}`;
|
|
2921
2887
|
if ("reason" in resolution) {
|
|
2922
|
-
let { error } = unresolvedError(resolution, reference,
|
|
2923
|
-
return { name, path:
|
|
2888
|
+
let { error } = unresolvedError(resolution, reference, story.importPath);
|
|
2889
|
+
return { name, path: story.importPath, jsDocTags: {}, error };
|
|
2924
2890
|
}
|
|
2925
|
-
let docgen = extractClassDocgen(
|
|
2891
|
+
let docs = readClassDocs(resolution.component), docgen = extractClassDocgen(
|
|
2926
2892
|
resolution.component,
|
|
2927
2893
|
displayNameOf(resolution.component),
|
|
2928
2894
|
reference,
|
|
2929
|
-
|
|
2895
|
+
story,
|
|
2930
2896
|
context
|
|
2931
2897
|
);
|
|
2932
2898
|
if ("error" in docgen)
|
|
2933
|
-
return { name, path:
|
|
2934
|
-
let { angularComponentMeta: _, ...
|
|
2899
|
+
return { ...docs, name, path: story.importPath, error: docgen.error };
|
|
2900
|
+
let { angularComponentMeta: _, ...props } = docgen, { path: path2 } = resolution.component;
|
|
2935
2901
|
return {
|
|
2936
|
-
...
|
|
2937
|
-
|
|
2902
|
+
...docs,
|
|
2903
|
+
...props,
|
|
2904
|
+
path: path2 ? componentPathFromStory(story.importPath, story.filePath, path2) : story.importPath,
|
|
2938
2905
|
renderer: "angular"
|
|
2939
2906
|
};
|
|
2940
|
-
},
|
|
2907
|
+
}, describeStoryComponent = (input, context) => {
|
|
2941
2908
|
let storyImportPath = getStoryImportPathFromEntry(input.entry);
|
|
2942
2909
|
if (!storyImportPath)
|
|
2943
2910
|
return;
|
|
2944
2911
|
let storyFilePath = (context.resolvePath ?? ((importPath) => resolve(process.cwd(), importPath)))(storyImportPath), { component: resolved, subcomponents } = resolveStoryComponents(
|
|
2945
2912
|
storyFilePath,
|
|
2946
2913
|
input.entry.title
|
|
2947
|
-
), id = getComponentIdFromEntry(input.entry);
|
|
2914
|
+
), id = getComponentIdFromEntry(input.entry), story = { importPath: storyImportPath, filePath: storyFilePath };
|
|
2948
2915
|
if ("reason" in resolved) {
|
|
2949
2916
|
if (resolved.reason === "no-meta-component") {
|
|
2950
|
-
context.logger
|
|
2917
|
+
context.logger?.debug(
|
|
2951
2918
|
`No Angular component resolved from ${storyFilePath}: ${resolved.reason}.`
|
|
2952
2919
|
);
|
|
2953
2920
|
return;
|
|
2954
2921
|
}
|
|
2955
|
-
let { error } = unresolvedError(resolved, "component", storyFilePath);
|
|
2956
2922
|
return {
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2923
|
+
docs: {
|
|
2924
|
+
id,
|
|
2925
|
+
name: nameOfUnresolved(resolved, input.entry.title),
|
|
2926
|
+
path: storyImportPath,
|
|
2927
|
+
jsDocTags: {}
|
|
2928
|
+
},
|
|
2929
|
+
story,
|
|
2930
|
+
...unresolvedError(resolved, "component", storyImportPath)
|
|
2962
2931
|
};
|
|
2963
2932
|
}
|
|
2964
|
-
|
|
2965
|
-
resolved.component,
|
|
2966
|
-
|
|
2933
|
+
return {
|
|
2934
|
+
docs: { id, path: storyImportPath, ...readClassDocs(resolved.component) },
|
|
2935
|
+
story,
|
|
2936
|
+
component: resolved.component,
|
|
2937
|
+
subcomponents
|
|
2938
|
+
};
|
|
2939
|
+
}, buildBasicDocgen = (input, context = {}) => {
|
|
2940
|
+
let described = describeStoryComponent(input, context);
|
|
2941
|
+
if (described)
|
|
2942
|
+
return "error" in described ? { ...described.docs, error: described.error } : described.docs;
|
|
2943
|
+
}, buildDocgenPayload = (input, context) => {
|
|
2944
|
+
let described = describeStoryComponent(input, context);
|
|
2945
|
+
if (!described)
|
|
2946
|
+
return;
|
|
2947
|
+
let { docs, story } = described;
|
|
2948
|
+
if ("error" in described)
|
|
2949
|
+
return { ...docs, error: described.error };
|
|
2950
|
+
let { component, subcomponents } = described, docgen = extractClassDocgen(
|
|
2951
|
+
component,
|
|
2952
|
+
displayNameOf(component),
|
|
2967
2953
|
"component",
|
|
2968
|
-
|
|
2954
|
+
story,
|
|
2969
2955
|
context
|
|
2970
2956
|
);
|
|
2971
2957
|
if ("error" in docgen)
|
|
2972
|
-
return { ...
|
|
2958
|
+
return { ...docs, error: docgen.error };
|
|
2973
2959
|
let subcomponentEntries = Object.fromEntries(
|
|
2974
2960
|
subcomponents.map((subcomponent) => [
|
|
2975
2961
|
subcomponent.name,
|
|
2976
|
-
buildSubcomponentDocgen(subcomponent,
|
|
2962
|
+
buildSubcomponentDocgen(subcomponent, story, context)
|
|
2977
2963
|
])
|
|
2978
2964
|
);
|
|
2979
2965
|
return {
|
|
2980
|
-
...
|
|
2966
|
+
...docs,
|
|
2981
2967
|
...docgen,
|
|
2982
2968
|
renderer: "angular",
|
|
2983
2969
|
...subcomponents.length > 0 ? { subcomponents: subcomponentEntries } : {}
|
|
@@ -3001,16 +2987,19 @@ var workerLogger = {
|
|
|
3001
2987
|
return;
|
|
3002
2988
|
}
|
|
3003
2989
|
}, createDocgenProvider = (options) => {
|
|
3004
|
-
let managerPromise
|
|
2990
|
+
let managerPromise, extractFull = async (input) => {
|
|
2991
|
+
let manager = await (managerPromise ??= createManager(options.typeScriptSpecifier));
|
|
2992
|
+
if (!manager)
|
|
2993
|
+
return;
|
|
2994
|
+
let ours = buildDocgenPayload(input, { manager, options, logger: workerLogger });
|
|
2995
|
+
return manager.recycleIfHeapPressured(), ours;
|
|
2996
|
+
};
|
|
3005
2997
|
return (nextDocgen) => async (input) => {
|
|
3006
2998
|
let storyImportPath = getStoryImportPathFromEntry2(input.entry);
|
|
3007
2999
|
if (!storyImportPath || !STORY_FILE_TEST_REGEXP.test(storyImportPath))
|
|
3008
3000
|
return nextDocgen(input);
|
|
3009
|
-
let
|
|
3010
|
-
|
|
3011
|
-
return nextDocgen(input);
|
|
3012
|
-
let ours = buildDocgenPayload(input, { manager, options, logger: workerLogger });
|
|
3013
|
-
return manager.recycleIfHeapPressured(), ours ? ours.error ? await nextDocgen(input) ?? ours : { ...await nextDocgen(input), ...ours } : nextDocgen(input);
|
|
3001
|
+
let ours = input.detail === "basic" ? buildBasicDocgen(input, { logger: workerLogger }) : await extractFull(input);
|
|
3002
|
+
return ours ? ours.error ? await nextDocgen(input) ?? ours : { ...await nextDocgen(input), ...ours } : nextDocgen(input);
|
|
3014
3003
|
};
|
|
3015
3004
|
};
|
|
3016
3005
|
export {
|
package/dist/index.js
CHANGED
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
componentWrapperDecorator,
|
|
6
6
|
moduleMetadata,
|
|
7
7
|
setProjectAnnotations
|
|
8
|
-
} from "./_browser-chunks/chunk-
|
|
9
|
-
import "./_browser-chunks/chunk-
|
|
10
|
-
import "./_browser-chunks/chunk-
|
|
8
|
+
} from "./_browser-chunks/chunk-2AD3AFBS.js";
|
|
9
|
+
import "./_browser-chunks/chunk-SPIIFZLB.js";
|
|
10
|
+
import "./_browser-chunks/chunk-7TI2NQDW.js";
|
|
11
11
|
import "./_browser-chunks/chunk-YS33I6LM.js";
|
|
12
|
-
import "./_browser-chunks/chunk-
|
|
12
|
+
import "./_browser-chunks/chunk-V7SLOYXF.js";
|
|
13
13
|
import "./_browser-chunks/chunk-T4WQC6BZ.js";
|
|
14
14
|
export {
|
|
15
15
|
__definePreview,
|
package/dist/node/vitest.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUILDER_OPTIONS_ENV
|
|
3
|
+
} from "../_node-chunks/chunk-P3P4Y7DE.js";
|
|
4
|
+
|
|
1
5
|
// src/node/vitest.ts
|
|
2
6
|
import { existsSync } from "node:fs";
|
|
3
7
|
import { dirname, join, resolve } from "node:path";
|
|
4
8
|
import { logger } from "storybook/internal/node-logger";
|
|
5
9
|
import { normalizePath } from "vite";
|
|
6
|
-
var
|
|
10
|
+
var findNodeModulesRoots = (startDir) => {
|
|
7
11
|
let roots = [], dir = resolve(startDir);
|
|
8
12
|
for (; ; ) {
|
|
9
13
|
existsSync(join(dir, "node_modules")) && roots.push(normalizePath(dir));
|
|
@@ -23,10 +27,10 @@ function storybookAngularVitest(options = {}) {
|
|
|
23
27
|
`[storybook-angular-vite] storybookAngularVitest received non-serializable options: ${err.message}`
|
|
24
28
|
);
|
|
25
29
|
}
|
|
26
|
-
let existing = process.env[
|
|
30
|
+
let existing = process.env[BUILDER_OPTIONS_ENV];
|
|
27
31
|
return existing !== void 0 ? existing !== serialized && logger.warn(
|
|
28
|
-
|
|
29
|
-
) : process.env[
|
|
32
|
+
`[storybook-angular-vite] ${BUILDER_OPTIONS_ENV} is already set (likely by the Storybook CLI or the Vitest addon panel). Keeping the existing value; the options passed to storybookAngularVitest() are ignored in this run.`
|
|
33
|
+
) : process.env[BUILDER_OPTIONS_ENV] = serialized, {
|
|
30
34
|
name: "storybook:angular-vitest-options",
|
|
31
35
|
// Vitest augments Vite's `UserConfig` with `test`; assert the shape here rather than import
|
|
32
36
|
// Vitest's types, which would pull its whole type graph into the framework's d.ts build.
|
package/dist/preset.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
findTsconfigUp
|
|
3
3
|
} from "./_node-chunks/chunk-DSX4K57A.js";
|
|
4
|
+
import {
|
|
5
|
+
BUILDER_OPTIONS_ENV
|
|
6
|
+
} from "./_node-chunks/chunk-P3P4Y7DE.js";
|
|
4
7
|
import {
|
|
5
8
|
parseStoryFile
|
|
6
9
|
} from "./_node-chunks/chunk-MIQVDAHU.js";
|
|
@@ -439,6 +442,11 @@ import {
|
|
|
439
442
|
} from "storybook/internal/csf-tools";
|
|
440
443
|
|
|
441
444
|
// src/template-grammar.ts
|
|
445
|
+
import {
|
|
446
|
+
SNIPPET_INDENT,
|
|
447
|
+
SNIPPET_PRINT_WIDTH,
|
|
448
|
+
printOpeningTag
|
|
449
|
+
} from "storybook/internal/docs-tools/snippets";
|
|
442
450
|
var formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? propertyName : `this['${propertyName}']`;
|
|
443
451
|
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
444
452
|
"area",
|
|
@@ -457,28 +465,25 @@ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
457
465
|
"source",
|
|
458
466
|
"track",
|
|
459
467
|
"wbr"
|
|
460
|
-
]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/,
|
|
468
|
+
]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/, asWritten = (code) => code, buildTemplate = (selector, { inputs, outputs, innerTemplate = "", selfClosing = !1 }, unmarked = asWritten) => {
|
|
461
469
|
let bindings = [
|
|
462
470
|
...inputs.map(({ name, expression, attribute }) => attribute ?? inputBinding(name, expression)),
|
|
463
471
|
...outputs.map((name) => `(${name})="${formatPropInTemplate(name)}($event)"`)
|
|
464
472
|
], firstSelector = selector.split(",")[0];
|
|
465
473
|
return (LEADING_CLASS.test(firstSelector) || LEADING_ATTRIBUTE.test(firstSelector) ? `div${firstSelector}` : firstSelector).replace(ID, ' id="$1"').replace(CLASS_RUN, (classes) => ` class="${classes.split(".").join(" ").trim()}"`).replace(ATTRIBUTE, " $1").replace(ELEMENT_AND_ATTRIBUTES, (_, element, attributes) => {
|
|
466
|
-
let closesItself = VOID_ELEMENTS.has(element) || selfClosing && element.includes("-") && innerTemplate === "",
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
if (closesItself)
|
|
473
|
-
return selfClosing ? `${brokenTag}
|
|
474
|
-
/>` : `${brokenTag} />`;
|
|
474
|
+
let closesItself = VOID_ELEMENTS.has(element) || selfClosing && element.includes("-") && innerTemplate === "", closing = closesItself ? "" : `${innerTemplate}</${element}>`, { text, broken } = printOpeningTag(
|
|
475
|
+
{ open: `<${element}${attributes}`, attributes: bindings, close: closesItself ? "/>" : ">" },
|
|
476
|
+
{ after: closing, measure: unmarked }
|
|
477
|
+
);
|
|
478
|
+
if (!broken || closesItself)
|
|
479
|
+
return `${text}${closing}`;
|
|
475
480
|
let content = innerTemplate === "" ? `
|
|
476
481
|
` : `
|
|
477
482
|
${innerTemplate}
|
|
478
483
|
`;
|
|
479
|
-
return `${
|
|
484
|
+
return `${text}${content}</${element}>`;
|
|
480
485
|
});
|
|
481
|
-
}, buildComponentOutletTemplate = (componentName, { selfClosing = !1 } = {}) => selfClosing ? `<ng-container *ngComponentOutlet="${componentName}" />` : `<ng-container *ngComponentOutlet="${componentName}"></ng-container>`,
|
|
486
|
+
}, buildComponentOutletTemplate = (componentName, { selfClosing = !1 } = {}) => selfClosing ? `<ng-container *ngComponentOutlet="${componentName}" />` : `<ng-container *ngComponentOutlet="${componentName}"></ng-container>`, MARKUP_TAG = /<(\/?)([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g, parseMarkup = (markup) => {
|
|
482
487
|
let root = {
|
|
483
488
|
tag: "",
|
|
484
489
|
rawOpen: "",
|
|
@@ -512,25 +517,30 @@ ${innerTemplate}
|
|
|
512
517
|
}
|
|
513
518
|
let trailing = markup.slice(lastIndex).trim();
|
|
514
519
|
return trailing && stack.at(-1).children.push(trailing), stack.length === 1 ? root.children : void 0;
|
|
515
|
-
}, MARKUP_ATTRIBUTE = /[^\s=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|\S+))?[\uE000-\uF8FF]*/g, openTagLines = (node, pad,
|
|
516
|
-
let
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
520
|
+
}, MARKUP_ATTRIBUTE = /[^\s=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|\S+))?[\uE000-\uF8FF]*/g, openTagLines = (node, pad, after, unmarked) => {
|
|
521
|
+
let { text, broken } = printOpeningTag(
|
|
522
|
+
{
|
|
523
|
+
open: `<${node.tag}`,
|
|
524
|
+
attributes: node.attrText.match(MARKUP_ATTRIBUTE) ?? [],
|
|
525
|
+
close: node.closed ? "/>" : ">"
|
|
526
|
+
},
|
|
527
|
+
{ indent: pad, after, measure: unmarked }
|
|
528
|
+
);
|
|
529
|
+
return broken ? `${pad}${text}`.split(`
|
|
530
|
+
`) : [`${pad}${node.rawOpen}`];
|
|
526
531
|
}, printMarkup = (markup, node, depth, unmarked) => {
|
|
527
|
-
let pad =
|
|
532
|
+
let pad = SNIPPET_INDENT.repeat(depth);
|
|
528
533
|
if (typeof node == "string")
|
|
529
534
|
return [`${pad}${node}`];
|
|
530
535
|
let hasElementChild = node.children.some((child) => typeof child != "string"), verbatim = markup.slice(node.start, node.end);
|
|
531
|
-
if (!hasElementChild && pad.length + unmarked(verbatim).length <=
|
|
536
|
+
if (!hasElementChild && pad.length + unmarked(verbatim).length <= SNIPPET_PRINT_WIDTH)
|
|
532
537
|
return [`${pad}${verbatim}`];
|
|
533
|
-
let openLines = openTagLines(
|
|
538
|
+
let openLines = openTagLines(
|
|
539
|
+
node,
|
|
540
|
+
pad,
|
|
541
|
+
hasElementChild ? "" : verbatim.slice(node.rawOpen.length),
|
|
542
|
+
unmarked
|
|
543
|
+
);
|
|
534
544
|
return node.closed ? openLines : [
|
|
535
545
|
...openLines,
|
|
536
546
|
...node.children.flatMap((child) => printMarkup(markup, child, depth + 1, unmarked)),
|
|
@@ -1190,11 +1200,10 @@ function resolveZoneless(angularBuilderOptions) {
|
|
|
1190
1200
|
return angularBuilderOptions?.zoneless ?? !0;
|
|
1191
1201
|
}
|
|
1192
1202
|
var viteFinal = async (config, options) => {
|
|
1193
|
-
|
|
1203
|
+
let bridgedBuilderOptions = process.env[BUILDER_OPTIONS_ENV];
|
|
1204
|
+
if (!options.angularBuilderOptions && bridgedBuilderOptions)
|
|
1194
1205
|
try {
|
|
1195
|
-
options.angularBuilderOptions = JSON.parse(
|
|
1196
|
-
process.env.STORYBOOK_ANGULAR_BUILDER_OPTIONS_JSON
|
|
1197
|
-
);
|
|
1206
|
+
options.angularBuilderOptions = JSON.parse(bridgedBuilderOptions);
|
|
1198
1207
|
} catch {
|
|
1199
1208
|
}
|
|
1200
1209
|
config.plugins = (config.plugins ?? []).flat().filter((plugin) => !plugin?.name?.includes("analogjs"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular-vite",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.4",
|
|
4
4
|
"description": "Storybook for Angular: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"!src/**/*"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@storybook/builder-vite": "11.0.0-rc.
|
|
68
|
+
"@storybook/builder-vite": "11.0.0-rc.4",
|
|
69
69
|
"telejson": "8.0.0",
|
|
70
70
|
"ts-dedent": "^2.2.0",
|
|
71
71
|
"vite": ">=8.0.0"
|
|
@@ -82,9 +82,9 @@
|
|
|
82
82
|
"@angular/forms": "^21.2.14",
|
|
83
83
|
"@angular/platform-browser": "^21.2.14",
|
|
84
84
|
"@angular/platform-browser-dynamic": "^21.2.14",
|
|
85
|
-
"@storybook/angular-cm": "11.0.0-rc.
|
|
86
|
-
"@storybook/angular-compodoc": "11.0.0-rc.
|
|
87
|
-
"@storybook/component-meta-typescript": "11.0.0-rc.
|
|
85
|
+
"@storybook/angular-cm": "11.0.0-rc.4",
|
|
86
|
+
"@storybook/angular-compodoc": "11.0.0-rc.4",
|
|
87
|
+
"@storybook/component-meta-typescript": "11.0.0-rc.4",
|
|
88
88
|
"@types/node": "^22.19.1",
|
|
89
89
|
"empathic": "^2.0.0",
|
|
90
90
|
"memfs": "^4.11.1",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"rxjs": "^7.4.0",
|
|
108
108
|
"sass": "^1.0.0",
|
|
109
109
|
"sass-embedded": "^1.0.0",
|
|
110
|
-
"storybook": "^11.0.0-rc.
|
|
110
|
+
"storybook": "^11.0.0-rc.4",
|
|
111
111
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0",
|
|
112
112
|
"vite": ">=8.0.0",
|
|
113
113
|
"zone.js": ">=0.14.0"
|