@storybook/angular-vite 11.0.0-alpha.7 → 11.0.0-alpha.9
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-RX6XLQUB.js → chunk-GCT6OYDT.js} +1 -1
- package/dist/_browser-chunks/{chunk-BFQMI74D.js → chunk-IEOSIOYC.js} +1 -1
- package/dist/_browser-chunks/{chunk-WUACJKA6.js → chunk-RMTRNQGG.js} +1 -1
- package/dist/_browser-chunks/{chunk-7BGWKSXV.js → chunk-VFDWJHES.js} +3 -3
- package/dist/_node-chunks/{chunk-SYNVOJIG.js → chunk-3NOOT4P4.js} +7 -7
- package/dist/_node-chunks/{chunk-JCPXXM2Q.js → chunk-HHXKBK6J.js} +6 -6
- package/dist/_node-chunks/{chunk-3TMNUOKB.js → chunk-IIBIIU2W.js} +7 -7
- package/dist/_node-chunks/{story-docs-template-analysis-DSYAHFCQ.js → story-docs-template-analysis-R5ORZ5HO.js} +6 -6
- package/dist/builders/build-storybook/index.js +8 -8
- package/dist/builders/start-storybook/index.js +8 -8
- 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 +162 -52
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/node/index.js +6 -6
- package/dist/node/vitest.js +6 -6
- package/dist/preset.js +147 -120
- package/package.json +5 -6
|
@@ -334,7 +334,7 @@ _PropertyExtractor.analyzeRestricted = (ngModule) => {
|
|
|
334
334
|
Please remove "BrowserModule" from moduleMetadata.imports to remove this warning.
|
|
335
335
|
`
|
|
336
336
|
), [!0];
|
|
337
|
-
let ngModuleName = ngModule?.name;
|
|
337
|
+
let ngModuleName = ngModule?.name?.replace(/^_+/, "").replace(/\$\d+$/, "");
|
|
338
338
|
return ngModuleName === "BrowserAnimationsModule" || ngModuleName === "NoopAnimationsModule" ? (console.warn(
|
|
339
339
|
dedent`
|
|
340
340
|
Storybook Warning:
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GCT6OYDT.js";
|
|
4
4
|
import {
|
|
5
5
|
config_exports as config_exports2
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RMTRNQGG.js";
|
|
7
7
|
import {
|
|
8
8
|
computesTemplateFromComponent,
|
|
9
9
|
formatPropInTemplate,
|
|
10
10
|
isComponent,
|
|
11
11
|
render_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-IEOSIOYC.js";
|
|
13
13
|
|
|
14
14
|
// src/client/portable-stories.ts
|
|
15
15
|
import {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
up
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HHXKBK6J.js";
|
|
15
15
|
|
|
16
16
|
// ../../../node_modules/empathic/package.mjs
|
|
17
17
|
function up2(options) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -26,7 +26,7 @@ var resolveMetaComponent = createMetaComponentResolver(), storyImportResolver =
|
|
|
26
26
|
function parseStoryFile(storyFilePath, title) {
|
|
27
27
|
try {
|
|
28
28
|
let source = readFileSync(storyFilePath, "utf8");
|
|
29
|
-
return loadCsf(source, { makeTitle: () => title }).parse();
|
|
29
|
+
return loadCsf(source, { makeTitle: () => title, fileName: storyFilePath }).parse();
|
|
30
30
|
} catch {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
printErrorDetails,
|
|
17
17
|
requireBuilderTarget,
|
|
18
18
|
up
|
|
19
|
-
} from "../../_node-chunks/chunk-
|
|
19
|
+
} from "../../_node-chunks/chunk-3NOOT4P4.js";
|
|
20
20
|
import {
|
|
21
21
|
resolveTsconfig
|
|
22
|
-
} from "../../_node-chunks/chunk-
|
|
22
|
+
} from "../../_node-chunks/chunk-HHXKBK6J.js";
|
|
23
23
|
|
|
24
24
|
// src/builders/build-storybook/index.ts
|
|
25
25
|
import { readFileSync } from "node:fs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -16,10 +16,10 @@ import {
|
|
|
16
16
|
printErrorDetails,
|
|
17
17
|
requireBuilderTarget,
|
|
18
18
|
up
|
|
19
|
-
} from "../../_node-chunks/chunk-
|
|
19
|
+
} from "../../_node-chunks/chunk-3NOOT4P4.js";
|
|
20
20
|
import {
|
|
21
21
|
resolveTsconfig
|
|
22
|
-
} from "../../_node-chunks/chunk-
|
|
22
|
+
} from "../../_node-chunks/chunk-HHXKBK6J.js";
|
|
23
23
|
|
|
24
24
|
// src/builders/start-storybook/index.ts
|
|
25
25
|
import { readFileSync } from "node:fs";
|
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-GCT6OYDT.js";
|
|
6
6
|
import {
|
|
7
7
|
render,
|
|
8
8
|
renderToCanvas
|
|
9
|
-
} from "../_browser-chunks/chunk-
|
|
9
|
+
} from "../_browser-chunks/chunk-IEOSIOYC.js";
|
|
10
10
|
export {
|
|
11
11
|
decorateStory as applyDecorators,
|
|
12
12
|
argTypesEnhancers,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decorators,
|
|
3
3
|
parameters
|
|
4
|
-
} from "../../_browser-chunks/chunk-
|
|
5
|
-
import "../../_browser-chunks/chunk-
|
|
4
|
+
} from "../../_browser-chunks/chunk-RMTRNQGG.js";
|
|
5
|
+
import "../../_browser-chunks/chunk-IEOSIOYC.js";
|
|
6
6
|
export {
|
|
7
7
|
decorators,
|
|
8
8
|
parameters
|
package/dist/client/index.js
CHANGED
|
@@ -5,10 +5,10 @@ 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-
|
|
11
|
-
import "../_browser-chunks/chunk-
|
|
8
|
+
} from "../_browser-chunks/chunk-VFDWJHES.js";
|
|
9
|
+
import "../_browser-chunks/chunk-GCT6OYDT.js";
|
|
10
|
+
import "../_browser-chunks/chunk-RMTRNQGG.js";
|
|
11
|
+
import "../_browser-chunks/chunk-IEOSIOYC.js";
|
|
12
12
|
export {
|
|
13
13
|
__definePreview,
|
|
14
14
|
applicationConfig,
|
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
resolveStoryComponent
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
14
|
+
} from "../_node-chunks/chunk-IIBIIU2W.js";
|
|
15
15
|
|
|
16
16
|
// src/docgen/docgen-worker.ts
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
getStoryImportPathFromEntry as getStoryImportPathFromEntry2,
|
|
19
|
+
loadTypeScriptCompilerApi,
|
|
20
|
+
STORY_FILE_TEST_REGEXP
|
|
21
|
+
} from "storybook/internal/common";
|
|
18
22
|
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
19
23
|
|
|
20
24
|
// ../../lib/angular-cm/dist/index.js
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
25
|
+
import CJS_COMPAT_NODE_URL_dx4x88ucjc8 from "node:url";
|
|
26
|
+
import CJS_COMPAT_NODE_PATH_dx4x88ucjc8 from "node:path";
|
|
27
|
+
import CJS_COMPAT_NODE_MODULE_dx4x88ucjc8 from "node:module";
|
|
24
28
|
import { isInNodeModules } from "storybook/internal/common";
|
|
25
29
|
import {
|
|
26
30
|
ComponentMetaManager,
|
|
@@ -36,7 +40,7 @@ import { logger as logger3 } from "storybook/internal/node-logger";
|
|
|
36
40
|
import * as path from "node:path";
|
|
37
41
|
import { logger as logger2 } from "storybook/internal/node-logger";
|
|
38
42
|
import { logger } from "storybook/internal/node-logger";
|
|
39
|
-
var __filename =
|
|
43
|
+
var __filename = CJS_COMPAT_NODE_URL_dx4x88ucjc8.fileURLToPath(import.meta.url), __dirname = CJS_COMPAT_NODE_PATH_dx4x88ucjc8.dirname(__filename), require2 = CJS_COMPAT_NODE_MODULE_dx4x88ucjc8.createRequire(import.meta.url), resolvedSymbol = (ctx, node) => {
|
|
40
44
|
let symbol = ctx.checker.getSymbolAtLocation(node);
|
|
41
45
|
return symbol && symbol.flags & ctx.ts.SymbolFlags.Alias ? ctx.checker.getAliasedSymbol(symbol) : symbol;
|
|
42
46
|
}, resolvedNameSymbol = (ctx, name) => {
|
|
@@ -386,13 +390,10 @@ ${detailLines(lines).join(`
|
|
|
386
390
|
}), argTypes;
|
|
387
391
|
}, isAngularCoreOrUnresolved = (ctx, node) => {
|
|
388
392
|
let symbol = resolvedSymbol(ctx, node);
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
(declaration) => declaration.getSourceFile().fileName.includes("@angular/core")
|
|
394
|
-
) : !0;
|
|
395
|
-
}, importedName = (ctx, target) => {
|
|
393
|
+
return !symbol?.declarations?.length || isDeclaredInAngularCore(symbol);
|
|
394
|
+
}, isDeclaredInAngularCore = (symbol) => symbol.declarations?.some(
|
|
395
|
+
(declaration) => declaration.getSourceFile().fileName.includes("/@angular/core/")
|
|
396
|
+
) ?? !1, importedName = (ctx, target) => {
|
|
396
397
|
let symbol = resolvedSymbol(ctx, target);
|
|
397
398
|
return symbol?.declarations?.length ? symbol.name : ctx.ts.isIdentifier(target) ? ctx.checker.getSymbolAtLocation(target)?.declarations?.find(ctx.ts.isImportSpecifier)?.propertyName?.text ?? target.text : target.name.text;
|
|
398
399
|
}, getDecorators = (ctx, node) => {
|
|
@@ -469,7 +470,57 @@ ${detailLines(lines).join(`
|
|
|
469
470
|
}
|
|
470
471
|
}
|
|
471
472
|
return entries;
|
|
472
|
-
},
|
|
473
|
+
}, PRE_STANDALONE_ARGUMENT_COUNT = 7, readComponentDeclaration = (ctx, classNode) => {
|
|
474
|
+
if (!classNode.getSourceFile().isDeclarationFile)
|
|
475
|
+
return;
|
|
476
|
+
let type = staticCmpType(ctx, classNode), typeArguments = type?.typeArguments;
|
|
477
|
+
if (!type || !typeArguments || typeArguments.length < PRE_STANDALONE_ARGUMENT_COUNT || !isAngularComponentDeclaration(ctx, type.typeName) || !referencesClass(ctx, typeArguments[0], classNode))
|
|
478
|
+
return;
|
|
479
|
+
let standaloneArgument = typeArguments[PRE_STANDALONE_ARGUMENT_COUNT];
|
|
480
|
+
return {
|
|
481
|
+
selector: stringLiteral(ctx, typeArguments[1]),
|
|
482
|
+
standalone: standaloneArgument ? booleanArgument(ctx, standaloneArgument) : !1,
|
|
483
|
+
inputsOutputs: [
|
|
484
|
+
...ioMapEntries(ctx, typeArguments[3], "inputs"),
|
|
485
|
+
...ioMapEntries(ctx, typeArguments[4], "outputs")
|
|
486
|
+
]
|
|
487
|
+
};
|
|
488
|
+
}, staticCmpType = ({ ts }, classNode) => {
|
|
489
|
+
for (let member of classNode.members)
|
|
490
|
+
if (ts.isPropertyDeclaration(member) && ts.isIdentifier(member.name) && member.name.text === "\u0275cmp" && ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword) && member.type && ts.isTypeReferenceNode(member.type))
|
|
491
|
+
return member.type;
|
|
492
|
+
}, entityIdentifier = ({ ts }, name) => ts.isQualifiedName(name) ? name.right : name, isAngularComponentDeclaration = (ctx, typeName) => {
|
|
493
|
+
let symbol = resolvedSymbol(ctx, entityIdentifier(ctx, typeName));
|
|
494
|
+
return symbol?.name === "\u0275\u0275ComponentDeclaration" && isDeclaredInAngularCore(symbol);
|
|
495
|
+
}, referencesClass = (ctx, argument, classNode) => {
|
|
496
|
+
if (!ctx.ts.isTypeReferenceNode(argument) || !classNode.name)
|
|
497
|
+
return !1;
|
|
498
|
+
let classSymbol = ctx.checker.getSymbolAtLocation(classNode.name);
|
|
499
|
+
return classSymbol !== void 0 && resolvedSymbol(ctx, entityIdentifier(ctx, argument.typeName)) === classSymbol;
|
|
500
|
+
}, booleanArgument = ({ ts }, argument) => {
|
|
501
|
+
if (ts.isLiteralTypeNode(argument))
|
|
502
|
+
return argument.literal.kind === ts.SyntaxKind.TrueKeyword ? !0 : argument.literal.kind === ts.SyntaxKind.FalseKeyword ? !1 : void 0;
|
|
503
|
+
}, ioMapEntries = (ctx, map, bucket) => {
|
|
504
|
+
let { ts } = ctx;
|
|
505
|
+
if (!ts.isTypeLiteralNode(map))
|
|
506
|
+
return [];
|
|
507
|
+
let entries = [];
|
|
508
|
+
for (let member of map.members) {
|
|
509
|
+
let name = member.name && propertyNameText(ctx, member.name), value = ts.isPropertySignature(member) ? member.type : void 0;
|
|
510
|
+
if (!name || !value)
|
|
511
|
+
continue;
|
|
512
|
+
let alias = ts.isTypeLiteralNode(value) ? stringLiteral(ctx, objectTypeMember(ctx, value, "alias")) : stringLiteral(ctx, value), required = ts.isTypeLiteralNode(value) ? booleanLiteral(ctx, objectTypeMember(ctx, value, "required")) : void 0;
|
|
513
|
+
entries.push({
|
|
514
|
+
bucket,
|
|
515
|
+
name,
|
|
516
|
+
...alias === void 0 || alias === name ? {} : { alias },
|
|
517
|
+
...required === void 0 ? {} : { required }
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
return entries;
|
|
521
|
+
}, propertyNameText = ({ ts }, name) => ts.isIdentifier(name) || ts.isStringLiteral(name) ? name.text : void 0, objectTypeMember = (ctx, object, key) => object.members.find(
|
|
522
|
+
(member) => ctx.ts.isPropertySignature(member) && propertyNameText(ctx, member.name) === key
|
|
523
|
+
)?.type, stringLiteral = ({ ts }, node) => node && ts.isLiteralTypeNode(node) && ts.isStringLiteral(node.literal) ? node.literal.text : void 0, booleanLiteral = (ctx, node) => node ? booleanArgument(ctx, node) : void 0, unwrapInitializer = (ts, expression) => {
|
|
473
524
|
let unwrapped = expression;
|
|
474
525
|
for (; ts.isParenthesizedExpression(unwrapped) || ts.isAsExpression(unwrapped) || ts.isSatisfiesExpression(unwrapped) || ts.isTypeAssertionExpression(unwrapped) || ts.isNonNullExpression(unwrapped); )
|
|
475
526
|
unwrapped = unwrapped.expression;
|
|
@@ -567,6 +618,28 @@ ${detailLines(lines).join(`
|
|
|
567
618
|
...getJsDocDescription(ts, member),
|
|
568
619
|
...getJsDocTagsField(ts, member)
|
|
569
620
|
};
|
|
621
|
+
}, DECLARED_SIGNAL_KINDS = /* @__PURE__ */ new Map([
|
|
622
|
+
["InputSignal", "input"],
|
|
623
|
+
["InputSignalWithTransform", "input"],
|
|
624
|
+
["ModelSignal", "model"],
|
|
625
|
+
["OutputEmitterRef", "output"]
|
|
626
|
+
]), declaredSignalKind = (ctx, member) => {
|
|
627
|
+
let { ts } = ctx;
|
|
628
|
+
if (!member.getSourceFile().isDeclarationFile || ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword))
|
|
629
|
+
return;
|
|
630
|
+
let type = ctx.checker.getTypeAtLocation(member), symbol = type.aliasSymbol ?? type.getSymbol();
|
|
631
|
+
return symbol && isDeclaredInAngularCore(symbol) ? DECLARED_SIGNAL_KINDS.get(symbol.name) : void 0;
|
|
632
|
+
}, buildDeclaredSignalEntry = (ctx, member) => {
|
|
633
|
+
let { ts } = ctx, type = signalValueTypeFromChecker(ctx, member);
|
|
634
|
+
return {
|
|
635
|
+
name: memberName(ts, member.name),
|
|
636
|
+
...type === void 0 ? {} : { type },
|
|
637
|
+
optional: !1,
|
|
638
|
+
required: !1,
|
|
639
|
+
line: ts.getLineAndCharacterOfPosition(member.getSourceFile(), member.getStart()).line + 1,
|
|
640
|
+
...getJsDocDescription(ts, member),
|
|
641
|
+
...getJsDocTagsField(ts, member)
|
|
642
|
+
};
|
|
570
643
|
}, signalValueTypeFromChecker = (ctx, member) => signalValueTypeFromType(ctx, ctx.checker.getTypeAtLocation(member), member), signalValueTypeFromType = (ctx, type, node) => {
|
|
571
644
|
let { checker, ts } = ctx, symbolName = type.aliasSymbol?.name ?? type.getSymbol()?.name;
|
|
572
645
|
if (!symbolName || !SIGNAL_TYPE_NAMES.has(symbolName) || !(type.flags & ts.TypeFlags.Object && type.objectFlags & ts.ObjectFlags.Reference))
|
|
@@ -614,26 +687,50 @@ function visitClassMembers(ctx, classNode, kind) {
|
|
|
614
687
|
}
|
|
615
688
|
function applyMetadataInputsOutputs(ctx, classNode, members) {
|
|
616
689
|
for (let decoratorName of ["Component", "Directive"])
|
|
617
|
-
for (let entry of readMetadataInputsOutputs(ctx, classNode, decoratorName))
|
|
618
|
-
|
|
619
|
-
|
|
690
|
+
for (let entry of readMetadataInputsOutputs(ctx, classNode, decoratorName))
|
|
691
|
+
reclassify(
|
|
692
|
+
members,
|
|
693
|
+
entry,
|
|
694
|
+
entry.required === void 0 ? {} : { required: entry.required, optional: !entry.required }
|
|
620
695
|
);
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
entry.bucket === "inputs" ? members.inputs.push({
|
|
628
|
-
...renamed,
|
|
629
|
-
value: {
|
|
630
|
-
...renamed.value,
|
|
631
|
-
...entry.required !== void 0 ? { required: entry.required, optional: !entry.required } : {}
|
|
632
|
-
}
|
|
633
|
-
}) : members.outputs.push(renamed);
|
|
634
|
-
}
|
|
696
|
+
for (let entry of readComponentDeclaration(ctx, classNode)?.inputsOutputs ?? [])
|
|
697
|
+
reclassify(members, entry, {
|
|
698
|
+
// `@Input()` and `@Input({ required: false })` compile to the same entry, so only `true` tells.
|
|
699
|
+
...entry.required ? { required: !0, optional: !1 } : {},
|
|
700
|
+
...acceptedInputType(ctx, classNode, entry)
|
|
701
|
+
});
|
|
635
702
|
}
|
|
636
|
-
var
|
|
703
|
+
var reclassify = (members, entry, inputFields) => {
|
|
704
|
+
let bucket = entry.bucket === "inputs" ? members.inputs : members.outputs, isField = (member) => member.declName === entry.name && !member.isStatic, bind = (member) => ({
|
|
705
|
+
...member,
|
|
706
|
+
value: {
|
|
707
|
+
...member.value,
|
|
708
|
+
name: entry.alias ?? entry.name,
|
|
709
|
+
...entry.bucket === "inputs" ? inputFields : {}
|
|
710
|
+
}
|
|
711
|
+
}), index = members.properties.findIndex(isField);
|
|
712
|
+
if (index >= 0) {
|
|
713
|
+
let [property] = members.properties.splice(index, 1);
|
|
714
|
+
bucket.push(bind(property));
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
let signal = bucket.find((member) => isField(member) && member.typeSource?.kind === "signal");
|
|
718
|
+
if (!signal || signal.typeSource?.kind === "signal" && signal.typeSource.signalKind === "model" && entry.bucket === "outputs")
|
|
719
|
+
return;
|
|
720
|
+
let bound = bind(signal);
|
|
721
|
+
for (let list of [members.inputs, members.outputs]) {
|
|
722
|
+
let at = list.indexOf(signal);
|
|
723
|
+
at >= 0 && (list[at] = bound);
|
|
724
|
+
}
|
|
725
|
+
}, acceptedInputType = (ctx, classNode, entry) => {
|
|
726
|
+
let { ts } = ctx;
|
|
727
|
+
if (entry.bucket !== "inputs")
|
|
728
|
+
return {};
|
|
729
|
+
let accepted = classNode.members.find(
|
|
730
|
+
(member) => ts.isPropertyDeclaration(member) && isStatic(ctx, member) && memberName(ts, member.name) === `ngAcceptInputType_${entry.name}`
|
|
731
|
+
), type = accepted && ctx.checker.getTypeAtLocation(accepted);
|
|
732
|
+
return type && !(type.flags & (ts.TypeFlags.Unknown | ts.TypeFlags.Any)) ? { type: ctx.types.renderValueType(type, accepted) } : {};
|
|
733
|
+
}, entryFor = (ctx, member, value, typeSource) => ({
|
|
637
734
|
declName: memberName(ctx.ts, member.name),
|
|
638
735
|
isStatic: isStatic(ctx, member),
|
|
639
736
|
declaration: member,
|
|
@@ -651,18 +748,18 @@ var entryFor = (ctx, member, value, typeSource) => ({
|
|
|
651
748
|
members.outputs.push(entryFor(ctx, member, buildDecoratorOutput(ctx, member, outputDecorator)));
|
|
652
749
|
return;
|
|
653
750
|
}
|
|
654
|
-
let signal = parseSignalCall(ctx, member);
|
|
655
|
-
if (
|
|
751
|
+
let signal = parseSignalCall(ctx, member), signalKind = signal?.kind ?? declaredSignalKind(ctx, member);
|
|
752
|
+
if (signalKind) {
|
|
656
753
|
let entry = entryFor(
|
|
657
754
|
ctx,
|
|
658
755
|
member,
|
|
659
756
|
{
|
|
660
|
-
...buildSignalEntry(ctx, member, signal),
|
|
757
|
+
...signal ? buildSignalEntry(ctx, member, signal) : buildDeclaredSignalEntry(ctx, member),
|
|
661
758
|
...memberApiFields(ctx, member)
|
|
662
759
|
},
|
|
663
|
-
{ kind: "signal", signalKind
|
|
760
|
+
{ kind: "signal", signalKind }
|
|
664
761
|
);
|
|
665
|
-
|
|
762
|
+
signalKind !== "output" && members.inputs.push(entry), signalKind !== "input" && members.outputs.push(entry);
|
|
666
763
|
return;
|
|
667
764
|
}
|
|
668
765
|
members.properties.push(entryFor(ctx, member, buildPlainProperty(ctx, member, decorators)));
|
|
@@ -859,7 +956,7 @@ function walkBases(ctx, classNode, members, kind, visited, substitutions) {
|
|
|
859
956
|
inheritedSubstitutions,
|
|
860
957
|
baseType
|
|
861
958
|
);
|
|
862
|
-
|
|
959
|
+
mergeBucket(ctx, members, baseMembers, "inputs"), mergeBucket(ctx, members, baseMembers, "outputs"), mergeInto(members.properties, baseMembers.properties, members), mergeInto(members.methods, baseMembers.methods, members);
|
|
863
960
|
}
|
|
864
961
|
}
|
|
865
962
|
var extendsClauseFor = (ctx, classNode, declaration) => {
|
|
@@ -1270,17 +1367,19 @@ function analyzeSourceFile(ts, sourceFile, checker, context = analyzerContext(ts
|
|
|
1270
1367
|
logger2.debug(`[angular-cm] ${statement.name.text} left out of docgen: an @NgModule`);
|
|
1271
1368
|
continue;
|
|
1272
1369
|
}
|
|
1370
|
+
if (kind === "class" && sourceFile.isDeclarationFile) {
|
|
1371
|
+
logger2.debug(
|
|
1372
|
+
`[angular-cm] ${statement.name.text} left out of docgen: a declaration-file class with no compiled \u0275cmp`
|
|
1373
|
+
);
|
|
1374
|
+
continue;
|
|
1375
|
+
}
|
|
1273
1376
|
let name = statement.name.text, file = sourceFile.fileName, members = collectClassMembers(ctx, statement, kind), common = {
|
|
1274
1377
|
file,
|
|
1275
1378
|
...getJsDocDescription(ts, statement),
|
|
1276
1379
|
...getJsDocTagsField(ts, statement)
|
|
1277
1380
|
};
|
|
1278
1381
|
if (kind === "component" || kind === "directive") {
|
|
1279
|
-
let
|
|
1280
|
-
ctx,
|
|
1281
|
-
statement,
|
|
1282
|
-
kind === "component" ? "Component" : "Directive"
|
|
1283
|
-
), selector = metadata && decoratorSelector(ctx, metadata), standalone = metadata && decoratorStandalone(ctx, metadata), record = {
|
|
1382
|
+
let { selector, standalone } = componentMetadata(ctx, statement, kind), record = {
|
|
1284
1383
|
name,
|
|
1285
1384
|
type: kind,
|
|
1286
1385
|
...selector === void 0 ? {} : { selector },
|
|
@@ -1338,7 +1437,16 @@ var KNOWN_DECORATORS = {
|
|
|
1338
1437
|
if (kind)
|
|
1339
1438
|
return kind;
|
|
1340
1439
|
}
|
|
1341
|
-
return "class";
|
|
1440
|
+
return readComponentDeclaration(ctx, node) ? "component" : "class";
|
|
1441
|
+
}, componentMetadata = (ctx, node, kind) => {
|
|
1442
|
+
let declared = readComponentDeclaration(ctx, node);
|
|
1443
|
+
if (declared)
|
|
1444
|
+
return declared;
|
|
1445
|
+
let metadata = decoratorObjectArg(ctx, node, kind === "component" ? "Component" : "Directive");
|
|
1446
|
+
return {
|
|
1447
|
+
selector: metadata && decoratorSelector(ctx, metadata),
|
|
1448
|
+
standalone: metadata && decoratorStandalone(ctx, metadata)
|
|
1449
|
+
};
|
|
1342
1450
|
}, decoratorSelector = (ctx, metadata) => {
|
|
1343
1451
|
let selector = objectProperty(ctx, metadata, "selector"), value = selector && resolveInitializer(ctx, selector);
|
|
1344
1452
|
return value && ctx.ts.isStringLiteralLike(value) ? value.text : void 0;
|
|
@@ -1466,7 +1574,7 @@ var KNOWN_DECORATORS = {
|
|
|
1466
1574
|
let declaration = (exported.flags & SymbolFlags.Alias ? checker.getAliasedSymbol(exported) : exported).declarations?.find(
|
|
1467
1575
|
(candidate) => isClassDeclaration(candidate)
|
|
1468
1576
|
);
|
|
1469
|
-
if (!declaration?.name
|
|
1577
|
+
if (!declaration?.name)
|
|
1470
1578
|
continue;
|
|
1471
1579
|
let declarationFile = declaration.getSourceFile(), targetContext = declarationFile === sourceFile ? context : analyzerContext(this.typescript, declarationFile, checker), targetMeta = declarationFile === sourceFile ? fileMeta : analyzeSourceFile(this.typescript, declarationFile, checker, targetContext), entry = findRecord(targetMeta, declaration.name.text);
|
|
1472
1580
|
if (entry)
|
|
@@ -1770,7 +1878,9 @@ var workerLogger = {
|
|
|
1770
1878
|
debug: (message) => logger4.debug(`[storybook-angular-vite] ${message}`)
|
|
1771
1879
|
}, createManager = async () => {
|
|
1772
1880
|
try {
|
|
1773
|
-
let
|
|
1881
|
+
let manager = new AngularComponentMetaManager(
|
|
1882
|
+
await loadTypeScriptCompilerApi(() => import("typescript"))
|
|
1883
|
+
);
|
|
1774
1884
|
return manager.startWatching(), manager;
|
|
1775
1885
|
} catch (error) {
|
|
1776
1886
|
logger4.warn(
|
package/dist/index.d.ts
CHANGED
|
@@ -46,19 +46,19 @@ type Parameters = Parameters$2 & {
|
|
|
46
46
|
/**
|
|
47
47
|
* Metadata to configure the stories for a component.
|
|
48
48
|
*
|
|
49
|
-
* @see [
|
|
49
|
+
* @see [Meta](https://storybook.js.org/docs/writing-stories/csf#meta)
|
|
50
50
|
*/
|
|
51
51
|
type Meta<TArgs = Args$1> = ComponentAnnotations<AngularRenderer, TransformComponentType<TArgs>>;
|
|
52
52
|
/**
|
|
53
53
|
* Story function that represents a CSFv2 component example.
|
|
54
54
|
*
|
|
55
|
-
* @see [
|
|
55
|
+
* @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
|
|
56
56
|
*/
|
|
57
57
|
type StoryFn<TArgs = Args$1> = AnnotatedStoryFn<AngularRenderer, TransformComponentType<TArgs>>;
|
|
58
58
|
/**
|
|
59
59
|
* Story object that represents a CSFv3 component example.
|
|
60
60
|
*
|
|
61
|
-
* @see [
|
|
61
|
+
* @see [Stories](https://storybook.js.org/docs/writing-stories/csf#stories)
|
|
62
62
|
*/
|
|
63
63
|
type StoryObj<TArgs = Args$1> = StoryAnnotations<AngularRenderer, TransformComponentType<TArgs>>;
|
|
64
64
|
type Decorator<TArgs = StrictArgs$1> = DecoratorFunction<AngularRenderer, TArgs>;
|
package/dist/index.js
CHANGED
|
@@ -5,10 +5,10 @@ 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-
|
|
11
|
-
import "./_browser-chunks/chunk-
|
|
8
|
+
} from "./_browser-chunks/chunk-VFDWJHES.js";
|
|
9
|
+
import "./_browser-chunks/chunk-GCT6OYDT.js";
|
|
10
|
+
import "./_browser-chunks/chunk-RMTRNQGG.js";
|
|
11
|
+
import "./_browser-chunks/chunk-IEOSIOYC.js";
|
|
12
12
|
export {
|
|
13
13
|
__definePreview,
|
|
14
14
|
applicationConfig,
|
package/dist/node/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/dist/node/vitest.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/dist/preset.js
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_rfopit31jsf from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_rfopit31jsf from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_rfopit31jsf from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_rfopit31jsf.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_rfopit31jsf.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_rfopit31jsf.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
findTsconfigUp
|
|
14
|
-
} from "./_node-chunks/chunk-
|
|
14
|
+
} from "./_node-chunks/chunk-HHXKBK6J.js";
|
|
15
15
|
import {
|
|
16
16
|
parseStoryFile
|
|
17
|
-
} from "./_node-chunks/chunk-
|
|
17
|
+
} from "./_node-chunks/chunk-IIBIIU2W.js";
|
|
18
18
|
|
|
19
19
|
// src/preset.ts
|
|
20
|
-
import { findConfigFile } from "storybook/internal/common";
|
|
20
|
+
import { findConfigFile, isTypeScriptReadyForDocgen } from "storybook/internal/common";
|
|
21
21
|
import {
|
|
22
|
-
babelParser,
|
|
23
22
|
extractMockCalls,
|
|
24
23
|
findMockRedirect,
|
|
25
24
|
getAutomockCode,
|
|
@@ -269,7 +268,6 @@ import { createWorkerGatedStoryDocsProvider, getService } from "storybook/intern
|
|
|
269
268
|
import { logger as logger4 } from "storybook/internal/node-logger";
|
|
270
269
|
|
|
271
270
|
// src/docgen/story-docs-build.ts
|
|
272
|
-
import { types as t4 } from "storybook/internal/babel";
|
|
273
271
|
import { getComponentIdFromEntry, getStoryImportPathFromEntry } from "storybook/internal/common";
|
|
274
272
|
import { storyNameFromExport } from "storybook/internal/csf/csf-utils";
|
|
275
273
|
import {
|
|
@@ -288,8 +286,14 @@ import {
|
|
|
288
286
|
import { resolve as resolve3 } from "node:path";
|
|
289
287
|
|
|
290
288
|
// src/docgen/story-docs-args.ts
|
|
291
|
-
import {
|
|
292
|
-
|
|
289
|
+
import {
|
|
290
|
+
detachedTextOf,
|
|
291
|
+
parseExpression,
|
|
292
|
+
staticKey,
|
|
293
|
+
parseModule,
|
|
294
|
+
reindent,
|
|
295
|
+
unwrapExpression
|
|
296
|
+
} from "storybook/internal/csf-tools";
|
|
293
297
|
|
|
294
298
|
// src/template-grammar.ts
|
|
295
299
|
var isValidIdentifier = (name) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name), formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? propertyName : `this['${propertyName}']`;
|
|
@@ -398,30 +402,45 @@ ${innerTemplate}
|
|
|
398
402
|
// src/docgen/story-docs-args.ts
|
|
399
403
|
var EVAL_FAILED = /* @__PURE__ */ Symbol("story-docs-eval-failed"), createArgExternalizer = (enums) => (node) => {
|
|
400
404
|
let value = evaluateNode(node, enums);
|
|
401
|
-
return value === EVAL_FAILED ? void 0 :
|
|
402
|
-
}, evaluateArgExpression = (node, enums) => {
|
|
403
|
-
let literal = evaluateArgLiteral(node, enums);
|
|
404
|
-
return escapeAttributeExpression(literal ?? printArgSource(unwrapExpression(node)));
|
|
405
|
+
return value === EVAL_FAILED ? void 0 : parseExpression(printExpressionValue(value, /* @__PURE__ */ new Set()));
|
|
405
406
|
}, evaluateArgLiteral = (node, enums) => {
|
|
406
407
|
let value = evaluateNode(unwrapExpression(node), enums);
|
|
407
408
|
return value === EVAL_FAILED ? void 0 : printExpressionValue(value, /* @__PURE__ */ new Set());
|
|
408
|
-
}, argFieldValue = (node) =>
|
|
409
|
+
}, argFieldValue = (node) => expandTabs(detachedTextOf(unwrapExpression(node))), evaluateArgExpression = (node, enums) => {
|
|
410
|
+
let literal = evaluateArgLiteral(node, enums);
|
|
411
|
+
return escapeAttributeExpression(
|
|
412
|
+
literal ?? expandTabs(withoutComments(detachedTextOf(unwrapExpression(node))))
|
|
413
|
+
);
|
|
414
|
+
}, expandTabs = (code) => {
|
|
415
|
+
let result = code, deepest = Math.max(0, ...result.split(`
|
|
416
|
+
`).map((line) => /^\t*/.exec(line)[0].length));
|
|
417
|
+
for (let depth = deepest; depth > 0; depth--)
|
|
418
|
+
result = reindent(result, " ".repeat(depth), " ".repeat(depth));
|
|
419
|
+
return result;
|
|
420
|
+
}, withoutComments = (code) => {
|
|
421
|
+
let { code: wrapped, comments } = parseModule(`(${code}
|
|
422
|
+
)`), result = "", cursor = 0;
|
|
423
|
+
for (let comment of comments)
|
|
424
|
+
result += wrapped.slice(cursor, comment.start), cursor = comment.end + /^[ \t]*/.exec(wrapped.slice(comment.end))[0].length, wrapped[cursor] === `
|
|
425
|
+
` ? result = result.replace(/[ \t]+$/, "") : /[\w$]$/.test(result) && /[\w$]/.test(wrapped[cursor]) && (result += " ");
|
|
426
|
+
return result += wrapped.slice(cursor), result.slice(1, -2);
|
|
427
|
+
}, quoteExpressionString = (value) => `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r")}'`, printExpressionValue = (value, seen) => typeof value == "string" ? quoteExpressionString(value) : typeof value != "object" || value === null ? `${value}` : seen.has(value) ? quoteExpressionString("[Circular]") : (seen.add(value), Array.isArray(value) ? `[${value.map((element) => printExpressionValue(element ?? null, seen)).join(", ")}]` : `{${Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).map(
|
|
409
428
|
([key, entryValue]) => `${isValidIdentifier(key) ? key : quoteExpressionString(key)}: ${printExpressionValue(entryValue, seen)}`
|
|
410
429
|
).join(", ")}}`), escapeAttributeExpression = (expression) => expression.replace(/&(?=#|\w+;)/g, "&").replace(/"/g, """), evaluateNode = (node, enums) => {
|
|
411
430
|
let unwrapped = unwrapExpression(node);
|
|
412
|
-
if (
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
if (!(
|
|
417
|
-
if (
|
|
431
|
+
if (unwrapped.type === "Literal") {
|
|
432
|
+
let { value } = unwrapped;
|
|
433
|
+
return typeof value == "string" || typeof value == "number" || typeof value == "boolean" ? value : "regex" in unwrapped || "bigint" in unwrapped ? EVAL_FAILED : null;
|
|
434
|
+
}
|
|
435
|
+
if (!(unwrapped.type === "Identifier" && unwrapped.name === "undefined") && !(unwrapped.type === "UnaryExpression" && unwrapped.operator === "void")) {
|
|
436
|
+
if (unwrapped.type === "UnaryExpression" && unwrapped.operator === "-" && unwrapped.argument.type === "Literal" && typeof unwrapped.argument.value == "number")
|
|
418
437
|
return -unwrapped.argument.value;
|
|
419
|
-
if (
|
|
438
|
+
if (unwrapped.type === "TemplateLiteral" && unwrapped.expressions.length === 0)
|
|
420
439
|
return unwrapped.quasis[0]?.value.cooked ?? EVAL_FAILED;
|
|
421
|
-
if (
|
|
440
|
+
if (unwrapped.type === "ArrayExpression") {
|
|
422
441
|
let values = [];
|
|
423
442
|
for (let element of unwrapped.elements) {
|
|
424
|
-
if (element === null ||
|
|
443
|
+
if (element === null || element.type === "SpreadElement")
|
|
425
444
|
return EVAL_FAILED;
|
|
426
445
|
let value = evaluateNode(element, enums);
|
|
427
446
|
if (value === EVAL_FAILED)
|
|
@@ -430,13 +449,13 @@ var EVAL_FAILED = /* @__PURE__ */ Symbol("story-docs-eval-failed"), createArgExt
|
|
|
430
449
|
}
|
|
431
450
|
return values;
|
|
432
451
|
}
|
|
433
|
-
if (
|
|
452
|
+
if (unwrapped.type === "ObjectExpression") {
|
|
434
453
|
let value = {};
|
|
435
454
|
for (let property of unwrapped.properties) {
|
|
436
|
-
if (
|
|
455
|
+
if (property.type !== "Property" || property.method || property.kind !== "init")
|
|
437
456
|
return EVAL_FAILED;
|
|
438
|
-
let key =
|
|
439
|
-
if (key ===
|
|
457
|
+
let key = staticKey(property);
|
|
458
|
+
if (key === void 0)
|
|
440
459
|
return EVAL_FAILED;
|
|
441
460
|
let propertyValue = evaluateNode(property.value, enums);
|
|
442
461
|
if (propertyValue === EVAL_FAILED)
|
|
@@ -445,7 +464,7 @@ var EVAL_FAILED = /* @__PURE__ */ Symbol("story-docs-eval-failed"), createArgExt
|
|
|
445
464
|
}
|
|
446
465
|
return value;
|
|
447
466
|
}
|
|
448
|
-
if (
|
|
467
|
+
if (unwrapped.type === "MemberExpression" && !unwrapped.computed && unwrapped.object.type === "Identifier" && unwrapped.property.type === "Identifier") {
|
|
449
468
|
let objectName = unwrapped.object.name, propertyName = unwrapped.property.name;
|
|
450
469
|
return enums.find((enumeration) => enumeration.name === objectName)?.members.find((candidate) => candidate.name === propertyName)?.value ?? EVAL_FAILED;
|
|
451
470
|
}
|
|
@@ -454,11 +473,12 @@ var EVAL_FAILED = /* @__PURE__ */ Symbol("story-docs-eval-failed"), createArgExt
|
|
|
454
473
|
};
|
|
455
474
|
|
|
456
475
|
// src/docgen/story-docs-markup.ts
|
|
457
|
-
import { types as t2 } from "storybook/internal/babel";
|
|
458
476
|
import {
|
|
477
|
+
importedName,
|
|
459
478
|
isCanonicalCsf2BindCall,
|
|
460
|
-
|
|
461
|
-
|
|
479
|
+
isStringLiteral,
|
|
480
|
+
oneLineTextOf,
|
|
481
|
+
staticKey as staticKey2,
|
|
462
482
|
templateParts,
|
|
463
483
|
unwrapExpression as unwrapExpression2
|
|
464
484
|
} from "storybook/internal/csf-tools";
|
|
@@ -484,7 +504,7 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
484
504
|
if (csf2) {
|
|
485
505
|
let templateProperty = resolvedProperty(csf2.returned, "template");
|
|
486
506
|
if (templateProperty.kind === "unresolvable")
|
|
487
|
-
return { kind: "unresolvable", source:
|
|
507
|
+
return { kind: "unresolvable", source: oneLineTextOf(csf2.returned) };
|
|
488
508
|
let fromCsf2 = templateFrom(
|
|
489
509
|
templateProperty.kind === "value" ? templateProperty.node : void 0,
|
|
490
510
|
shape,
|
|
@@ -498,7 +518,10 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
498
518
|
}, shapeTemplate = (members, shape, bindings) => {
|
|
499
519
|
let template = resolvedMember(members, "template");
|
|
500
520
|
if (template.kind === "unresolvable")
|
|
501
|
-
return {
|
|
521
|
+
return {
|
|
522
|
+
kind: "unresolvable",
|
|
523
|
+
...template.node ? { source: oneLineTextOf(template.node) } : {}
|
|
524
|
+
};
|
|
502
525
|
if (template.kind === "value") {
|
|
503
526
|
let own = templateFrom(declaredValue(shape, template.node), shape, bindings, NO_SCOPE);
|
|
504
527
|
if (own)
|
|
@@ -508,28 +531,28 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
508
531
|
if (render.kind === "missing")
|
|
509
532
|
return;
|
|
510
533
|
if (render.kind === "unresolvable")
|
|
511
|
-
return { kind: "unresolvable", ...render.node ? { source:
|
|
534
|
+
return { kind: "unresolvable", ...render.node ? { source: oneLineTextOf(render.node) } : {} };
|
|
512
535
|
let fn = declaredValue(shape, render.node), returned = returnedObject(fn);
|
|
513
536
|
if (!returned)
|
|
514
|
-
return { kind: "unresolvable", source: `render: ${
|
|
537
|
+
return { kind: "unresolvable", source: `render: ${oneLineTextOf(render.node)}` };
|
|
515
538
|
let templateProperty = resolvedProperty(returned, "template");
|
|
516
|
-
return templateProperty.kind === "unresolvable" ? { kind: "unresolvable", source: `render: ${
|
|
539
|
+
return templateProperty.kind === "unresolvable" ? { kind: "unresolvable", source: `render: ${oneLineTextOf(render.node)}` } : templateFrom(
|
|
517
540
|
templateProperty.kind === "value" ? templateProperty.node : void 0,
|
|
518
541
|
shape,
|
|
519
542
|
bindings,
|
|
520
543
|
functionScope(fn)
|
|
521
544
|
);
|
|
522
545
|
}, templateFrom = (node, shape, bindings, scope) => {
|
|
523
|
-
if (node === void 0 ||
|
|
546
|
+
if (node === void 0 || isNullLiteral(node) || node.type === "Identifier" && node.name === "undefined")
|
|
524
547
|
return;
|
|
525
|
-
if (
|
|
548
|
+
if (isStringLiteral(node))
|
|
526
549
|
return literalTemplate(node.value, /* @__PURE__ */ new Set(), []);
|
|
527
550
|
let parts = templateParts(node);
|
|
528
551
|
if (parts) {
|
|
529
552
|
let representedArgs = /* @__PURE__ */ new Set(), expansions = [], markup = interpolate(parts, shape, bindings, scope, representedArgs, expansions);
|
|
530
|
-
return markup === void 0 ? { kind: "unresolvable", source:
|
|
553
|
+
return markup === void 0 ? { kind: "unresolvable", source: oneLineTextOf(node) } : literalTemplate(markup, representedArgs, expansions);
|
|
531
554
|
}
|
|
532
|
-
return { kind: "unresolvable", source:
|
|
555
|
+
return { kind: "unresolvable", source: oneLineTextOf(node) };
|
|
533
556
|
}, literalTemplate = (markup, representedArgs, expansions) => ({
|
|
534
557
|
kind: "literal",
|
|
535
558
|
markup,
|
|
@@ -556,8 +579,8 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
556
579
|
}
|
|
557
580
|
return markup;
|
|
558
581
|
}, substituteExpression = (expression, shape, bindings, scope, representedArgs, marker, expansions) => {
|
|
559
|
-
if (
|
|
560
|
-
let argument = expression.arguments[0], excluded =
|
|
582
|
+
if (expression.type === "CallExpression" && isImportedArgsToTemplate(expression, shape)) {
|
|
583
|
+
let argument = expression.arguments[0], excluded = argument?.type === "Identifier" ? scope.argsExpansions.get(argument.name) : void 0;
|
|
561
584
|
if (!bindings || excluded === void 0)
|
|
562
585
|
return;
|
|
563
586
|
let filter = bindingFilterOf(expression.arguments[1]);
|
|
@@ -566,7 +589,7 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
566
589
|
let withRest = { ...filter, exclude: [...filter.exclude ?? [], ...excluded] }, allowed = filter.include ? { ...withRest, include: filter.include.filter((name) => !excluded.includes(name)) } : withRest;
|
|
567
590
|
return expansions.push({ marker, ...bindingAttributes(bindings, allowed, representedArgs) }), marker;
|
|
568
591
|
}
|
|
569
|
-
if (
|
|
592
|
+
if (expression.type !== "Identifier")
|
|
570
593
|
return;
|
|
571
594
|
let argName = scope.argBindings.get(expression.name);
|
|
572
595
|
if (argName !== void 0) {
|
|
@@ -578,18 +601,15 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
578
601
|
let declared = declaredValue(shape, expression);
|
|
579
602
|
return declared === expression ? void 0 : literalText(declared);
|
|
580
603
|
}, ARGS_TO_TEMPLATE_MODULES = /* @__PURE__ */ new Set(["@storybook/angular", "@storybook/angular-vite"]), isImportedArgsToTemplate = (call, shape) => {
|
|
581
|
-
if (
|
|
604
|
+
if (call.callee.type !== "Identifier")
|
|
582
605
|
return !1;
|
|
583
|
-
let binding = shape.csf.
|
|
584
|
-
|
|
585
|
-
return !1;
|
|
586
|
-
let specifier = binding?.path.node, declaration = binding?.path.findParent((path) => t2.isImportDeclaration(path.node))?.node;
|
|
587
|
-
return !t2.isImportSpecifier(specifier) || !t2.isImportDeclaration(declaration) ? !1 : (t2.isIdentifier(specifier.imported) ? specifier.imported.name : specifier.imported.value) === "argsToTemplate" && ARGS_TO_TEMPLATE_MODULES.has(declaration.source.value);
|
|
606
|
+
let binding = shape.csf.editor.scopes.bindingOf(call.callee), specifier = binding?.node, declaration = binding?.declaration;
|
|
607
|
+
return specifier?.type !== "ImportSpecifier" || declaration?.type !== "ImportDeclaration" ? !1 : importedName(specifier.imported) === "argsToTemplate" && ARGS_TO_TEMPLATE_MODULES.has(declaration.source.value);
|
|
588
608
|
}, bindingFilterOf = (options) => {
|
|
589
609
|
if (options === void 0)
|
|
590
610
|
return {};
|
|
591
611
|
let unwrapped = unwrapExpression2(options);
|
|
592
|
-
if (
|
|
612
|
+
if (unwrapped.type !== "ObjectExpression" || unwrapped.properties.some((property) => property.type === "SpreadElement"))
|
|
593
613
|
return;
|
|
594
614
|
let filter = {};
|
|
595
615
|
for (let key of ["include", "exclude"]) {
|
|
@@ -604,38 +624,42 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
604
624
|
}
|
|
605
625
|
}
|
|
606
626
|
return filter;
|
|
607
|
-
}, stringArray = (node) =>
|
|
627
|
+
}, stringArray = (node) => node?.type === "ArrayExpression" && node.elements.every(isStringLiteral) ? node.elements.map((element) => element.value) : void 0, literalText = (node) => {
|
|
608
628
|
let unwrapped = node && unwrapExpression2(node);
|
|
609
|
-
|
|
610
|
-
|
|
629
|
+
if (unwrapped?.type !== "Literal")
|
|
630
|
+
return;
|
|
631
|
+
let { value } = unwrapped;
|
|
632
|
+
return typeof value == "string" ? value : typeof value == "number" || typeof value == "boolean" ? String(value) : void 0;
|
|
633
|
+
}, isNullLiteral = (node) => node.type === "Literal" && node.value === null && !("regex" in node) && !("bigint" in node), resolvedMember = (members, key) => {
|
|
611
634
|
let node = members.properties[key];
|
|
612
635
|
return node !== void 0 ? members.shadowed.includes(key) ? { kind: "unresolvable", node } : { kind: "value", node } : members.unresolved.length > 0 ? { kind: "unresolvable" } : { kind: "missing" };
|
|
613
636
|
}, resolvedProperty = (object, key) => {
|
|
614
637
|
let found, opaqueAfter;
|
|
615
638
|
return object.properties.forEach((property) => {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
found = property, opaqueAfter = void 0;
|
|
639
|
+
if (property.type === "SpreadElement") {
|
|
640
|
+
opaqueAfter = property;
|
|
619
641
|
return;
|
|
620
642
|
}
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
},
|
|
624
|
-
|
|
625
|
-
let
|
|
626
|
-
if (!
|
|
643
|
+
let name = staticKey2(property);
|
|
644
|
+
name === key ? (found = property, opaqueAfter = void 0) : name === void 0 && (opaqueAfter = property);
|
|
645
|
+
}), found ? opaqueAfter ? { kind: "unresolvable", node: opaqueAfter } : found.method || found.kind !== "init" ? isPlainMethod(found) ? { kind: "value", node: found } : { kind: "unresolvable", node: found } : { kind: "value", node: found.value } : opaqueAfter ? { kind: "unresolvable", node: opaqueAfter } : { kind: "missing" };
|
|
646
|
+
}, isPlainMethod = (node) => node?.type === "Property" && node.method && node.kind === "init" && node.value.type === "FunctionExpression" && !node.value.generator, functionOf = (node) => isPlainMethod(node) ? node.value : node?.type === "ArrowFunctionExpression" || node?.type === "FunctionExpression" || node?.type === "FunctionDeclaration" ? node : void 0, returnedObject = (node) => {
|
|
647
|
+
let fn = functionOf(node);
|
|
648
|
+
if (!fn?.body)
|
|
627
649
|
return;
|
|
628
|
-
if (
|
|
650
|
+
if (fn.body.type !== "BlockStatement") {
|
|
629
651
|
let unwrapped2 = unwrapExpression2(fn.body);
|
|
630
|
-
return
|
|
652
|
+
return unwrapped2.type === "ObjectExpression" ? unwrapped2 : void 0;
|
|
631
653
|
}
|
|
632
654
|
let statements = fn.body.body, last = statements.at(-1);
|
|
633
|
-
if (
|
|
655
|
+
if (last?.type !== "ReturnStatement" || !last.argument || !statements.slice(0, -1).every(
|
|
656
|
+
(statement) => statement.type === "VariableDeclaration" || statement.type === "ExpressionStatement"
|
|
657
|
+
))
|
|
634
658
|
return;
|
|
635
659
|
let unwrapped = unwrapExpression2(last.argument);
|
|
636
|
-
return
|
|
660
|
+
return unwrapped.type === "ObjectExpression" ? unwrapped : void 0;
|
|
637
661
|
}, csf2Shape = (shape) => {
|
|
638
|
-
let declared = shape.csf._storyExports[shape.exportName], candidates =
|
|
662
|
+
let declared = shape.csf._storyExports[shape.exportName], candidates = declared?.type === "VariableDeclarator" ? [declared.init] : (
|
|
639
663
|
// `export { S }` records no declarator; the statement is the initializer it resolved to.
|
|
640
664
|
[declared, shape.csf._storyStatements[shape.exportName]]
|
|
641
665
|
);
|
|
@@ -646,88 +670,91 @@ var returnedObject = (fn) => {
|
|
|
646
670
|
if (fn && returned)
|
|
647
671
|
return { fn, returned };
|
|
648
672
|
}
|
|
649
|
-
}, functionScope = (
|
|
650
|
-
|
|
673
|
+
}, functionScope = (node) => {
|
|
674
|
+
let fn = functionOf(node?.type === "Property" ? node.value : node);
|
|
675
|
+
if (!fn)
|
|
651
676
|
return NO_SCOPE;
|
|
652
|
-
let [firstParam] = fn.params, argsPattern =
|
|
677
|
+
let [firstParam] = fn.params, argsPattern = firstParam?.type === "AssignmentPattern" ? firstParam.left : firstParam, parameterNames = /* @__PURE__ */ new Set();
|
|
653
678
|
fn.params.forEach((param) => collectPatternNames(param, parameterNames));
|
|
654
679
|
let argBindings = /* @__PURE__ */ new Map();
|
|
655
|
-
if (
|
|
680
|
+
if (argsPattern?.type === "ObjectPattern")
|
|
656
681
|
for (let property of argsPattern.properties) {
|
|
657
|
-
if (
|
|
682
|
+
if (property.type !== "Property" || property.computed)
|
|
658
683
|
continue;
|
|
659
|
-
let argName =
|
|
660
|
-
argName !== void 0 &&
|
|
684
|
+
let argName = staticKey2(property), local = property.value.type === "AssignmentPattern" ? property.value.left : property.value;
|
|
685
|
+
argName !== void 0 && local.type === "Identifier" && argBindings.set(local.name, argName);
|
|
661
686
|
}
|
|
662
687
|
let bodyDeclared = /* @__PURE__ */ new Set();
|
|
663
|
-
if (
|
|
688
|
+
if (fn.body?.type === "BlockStatement") {
|
|
664
689
|
for (let statement of fn.body.body)
|
|
665
|
-
if (
|
|
690
|
+
if (statement.type === "VariableDeclaration")
|
|
666
691
|
for (let declarator of statement.declarations)
|
|
667
692
|
collectPatternNames(declarator.id, bodyDeclared);
|
|
668
693
|
}
|
|
669
694
|
let argsExpansions = /* @__PURE__ */ new Map();
|
|
670
|
-
if (
|
|
695
|
+
if (argsPattern?.type === "Identifier")
|
|
671
696
|
argsExpansions.set(argsPattern.name, []);
|
|
672
|
-
else if (
|
|
697
|
+
else if (argsPattern?.type === "ObjectPattern") {
|
|
673
698
|
let destructured = [], rest, knownKeys = !0;
|
|
674
699
|
for (let property of argsPattern.properties)
|
|
675
|
-
if (
|
|
700
|
+
if (property.type === "RestElement" && property.argument.type === "Identifier")
|
|
676
701
|
rest = property.argument.name;
|
|
677
|
-
else if (
|
|
678
|
-
let key = property.computed ? void 0 :
|
|
702
|
+
else if (property.type === "Property") {
|
|
703
|
+
let key = property.computed ? void 0 : staticKey2(property);
|
|
679
704
|
key !== void 0 ? destructured.push(key) : knownKeys = !1;
|
|
680
705
|
}
|
|
681
706
|
rest !== void 0 && knownKeys && argsExpansions.set(rest, destructured);
|
|
682
707
|
}
|
|
683
708
|
return { argBindings, parameterNames, bodyDeclared, argsExpansions };
|
|
684
709
|
}, collectPatternNames = (pattern, into) => {
|
|
685
|
-
if (
|
|
710
|
+
if (pattern.type === "Identifier")
|
|
686
711
|
into.add(pattern.name);
|
|
687
|
-
else if (
|
|
712
|
+
else if (pattern.type === "ObjectPattern")
|
|
688
713
|
for (let property of pattern.properties)
|
|
689
|
-
collectPatternNames(
|
|
690
|
-
|
|
714
|
+
collectPatternNames(
|
|
715
|
+
property.type === "RestElement" ? property.argument : property.value,
|
|
716
|
+
into
|
|
717
|
+
);
|
|
718
|
+
else pattern.type === "ArrayPattern" ? pattern.elements.forEach((element) => element && collectPatternNames(element, into)) : pattern.type === "AssignmentPattern" ? collectPatternNames(pattern.left, into) : pattern.type === "RestElement" && collectPatternNames(pattern.argument, into);
|
|
691
719
|
}, declaredValue = (shape, node) => {
|
|
692
|
-
if (
|
|
720
|
+
if (node?.type !== "Identifier")
|
|
693
721
|
return node;
|
|
694
|
-
let binding = shape.csf.
|
|
722
|
+
let binding = shape.csf.editor.scopes.program.bindings.get(node.name);
|
|
695
723
|
if (!binding?.constant)
|
|
696
724
|
return node;
|
|
697
|
-
let declaration = binding.
|
|
698
|
-
return
|
|
725
|
+
let declaration = binding.node;
|
|
726
|
+
return declaration.type === "VariableDeclarator" ? declaration.init ?? node : declaration.type === "FunctionDeclaration" ? declaration : node;
|
|
699
727
|
};
|
|
700
728
|
|
|
701
729
|
// src/docgen/story-docs-ng-modules.ts
|
|
702
|
-
import { types as t3 } from "storybook/internal/babel";
|
|
703
730
|
import {
|
|
704
731
|
buildImportStatements,
|
|
705
|
-
|
|
732
|
+
staticKey as staticKey3,
|
|
706
733
|
resolveComponentImport,
|
|
707
734
|
unwrapExpression as unwrapExpression3
|
|
708
735
|
} from "storybook/internal/csf-tools";
|
|
709
736
|
var ngModulesFromDecorators = (decorators, componentName) => {
|
|
710
737
|
let result = { names: [], declaresComponent: !1 }, list = decorators === void 0 ? void 0 : unwrapExpression3(decorators);
|
|
711
|
-
if (
|
|
738
|
+
if (list?.type !== "ArrayExpression")
|
|
712
739
|
return result;
|
|
713
740
|
for (let element of list.elements) {
|
|
714
|
-
if (!element ||
|
|
741
|
+
if (!element || element.type === "SpreadElement")
|
|
715
742
|
continue;
|
|
716
743
|
let call = unwrapExpression3(element);
|
|
717
|
-
if (
|
|
744
|
+
if (call.type !== "CallExpression" || call.callee.type !== "Identifier" || call.callee.name !== "moduleMetadata")
|
|
718
745
|
continue;
|
|
719
|
-
let [metadataArg] = call.arguments, metadata = metadataArg &&
|
|
720
|
-
if (
|
|
746
|
+
let [metadataArg] = call.arguments, metadata = metadataArg && metadataArg.type !== "SpreadElement" ? unwrapExpression3(metadataArg) : void 0;
|
|
747
|
+
if (metadata?.type === "ObjectExpression")
|
|
721
748
|
for (let property of metadata.properties) {
|
|
722
|
-
if (
|
|
749
|
+
if (property.type !== "Property" || property.method || property.kind !== "init")
|
|
723
750
|
continue;
|
|
724
|
-
let key =
|
|
725
|
-
if (!(key !== "imports" && key !== "declarations" ||
|
|
751
|
+
let key = staticKey3(property), value = unwrapExpression3(property.value);
|
|
752
|
+
if (!(key !== "imports" && key !== "declarations" || value.type !== "ArrayExpression"))
|
|
726
753
|
for (let item of value.elements) {
|
|
727
|
-
if (!item ||
|
|
754
|
+
if (!item || item.type === "SpreadElement")
|
|
728
755
|
continue;
|
|
729
756
|
let entry = unwrapExpression3(item);
|
|
730
|
-
|
|
757
|
+
entry.type === "Identifier" && (key === "imports" ? entry.name !== componentName && !result.names.includes(entry.name) && result.names.push(entry.name) : entry.name === componentName && (result.declaresComponent = !0));
|
|
731
758
|
}
|
|
732
759
|
}
|
|
733
760
|
}
|
|
@@ -826,7 +853,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
826
853
|
let target = resolveImport(fromFile, specifier);
|
|
827
854
|
return target === void 0 ? void 0 : parseReferenceModule(target);
|
|
828
855
|
} : openStoryReferences().resolveModule
|
|
829
|
-
}, componentName = componentNameOf(componentNode), importBindings = collectImportBindings(csf.
|
|
856
|
+
}, componentName = componentNameOf(componentNode), importBindings = collectImportBindings(csf.program), deps = {
|
|
830
857
|
csf,
|
|
831
858
|
resolveStoryArgs: createStoryArgsResolver(csf, references),
|
|
832
859
|
snippetMeta: docgenPayload?.angularComponentMeta,
|
|
@@ -853,12 +880,15 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
853
880
|
return buildImportStatements2({ refs: [{ ...ref, importOverride }] }).join(`
|
|
854
881
|
`) || void 0;
|
|
855
882
|
}, componentNameOf = (node) => {
|
|
856
|
-
let identifier = node
|
|
857
|
-
return identifier
|
|
883
|
+
let identifier = node?.type === "TSInstantiationExpression" ? node.expression : node;
|
|
884
|
+
return identifier?.type === "Identifier" ? identifier.name : void 0;
|
|
858
885
|
}, openStoryReferences = createStoryReferenceResolver(), buildStoryDoc = async (exportName, story, deps) => {
|
|
859
886
|
let { csf } = deps, name = story.name ?? storyNameFromExport(exportName);
|
|
860
887
|
try {
|
|
861
|
-
let { description, summary } = extractStoryJSDocInfo(
|
|
888
|
+
let { description, summary } = extractStoryJSDocInfo(
|
|
889
|
+
csf._storyStatements[exportName],
|
|
890
|
+
csf.editor
|
|
891
|
+
), rendered = await renderedSnippet(storyShape(exportName, deps), deps);
|
|
862
892
|
return {
|
|
863
893
|
id: story.id,
|
|
864
894
|
name,
|
|
@@ -890,7 +920,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
890
920
|
}, storyShape = (exportName, deps) => {
|
|
891
921
|
let resolved = deps.resolveStoryArgs.resolve(exportName), enums = deps.snippetMeta?.enums ?? [], unresolved = [...resolved.unresolved];
|
|
892
922
|
for (let value of Object.values(resolved.args))
|
|
893
|
-
evaluateArgLiteral(value, enums) === void 0 && !isSelfContained(value) && unresolved.push(
|
|
923
|
+
evaluateArgLiteral(value, enums) === void 0 && !isSelfContained(value) && unresolved.push(oneLineTextOf(value));
|
|
894
924
|
return {
|
|
895
925
|
csf: deps.csf,
|
|
896
926
|
exportName,
|
|
@@ -911,7 +941,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
911
941
|
fields: fields2
|
|
912
942
|
});
|
|
913
943
|
if (userMarkup?.kind === "literal") {
|
|
914
|
-
let { analyzeStoryTemplate } = await import("./_node-chunks/story-docs-template-analysis-
|
|
944
|
+
let { analyzeStoryTemplate } = await import("./_node-chunks/story-docs-template-analysis-R5ORZ5HO.js"), analysis = analyzeStoryTemplate(userMarkup.markup, userMarkup.expansions), referencedNames = new Set(analysis.kind === "resolved" ? analysis.referencedNames : []), boundOutputs = analysis.kind === "resolved" ? snippetMeta.outputs.filter((name) => analysis.boundOutputs.includes(name)) : [], hostArgs = referencedArgFields(
|
|
915
945
|
referencedNames,
|
|
916
946
|
userMarkup.representedArgs,
|
|
917
947
|
shape,
|
|
@@ -957,7 +987,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
957
987
|
continue;
|
|
958
988
|
let value = evaluateArgLiteral(node, enums);
|
|
959
989
|
if (value === void 0) {
|
|
960
|
-
unresolved.push(
|
|
990
|
+
unresolved.push(oneLineTextOf(node));
|
|
961
991
|
continue;
|
|
962
992
|
}
|
|
963
993
|
fields.push({ name, value });
|
|
@@ -995,10 +1025,10 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
995
1025
|
return { inputs, outputs };
|
|
996
1026
|
}, isFunctionValue = (node) => {
|
|
997
1027
|
let unwrapped = unwrapExpression4(node);
|
|
998
|
-
return
|
|
1028
|
+
return unwrapped.type === "ArrowFunctionExpression" || unwrapped.type === "FunctionExpression" || unwrapped.type === "FunctionDeclaration";
|
|
999
1029
|
}, isUndefinedValue = (node) => {
|
|
1000
1030
|
let unwrapped = unwrapExpression4(node);
|
|
1001
|
-
return
|
|
1031
|
+
return unwrapped.type === "Identifier" && unwrapped.name === "undefined" || unwrapped.type === "UnaryExpression" && unwrapped.operator === "void";
|
|
1002
1032
|
};
|
|
1003
1033
|
|
|
1004
1034
|
// src/docgen/story-docs-preset.ts
|
|
@@ -1018,7 +1048,7 @@ var warnedMissingDocgenService = !1, getDocgenPayload = async (componentId) => {
|
|
|
1018
1048
|
});
|
|
1019
1049
|
|
|
1020
1050
|
// src/preset.ts
|
|
1021
|
-
var isDocgenProviderEnabled =
|
|
1051
|
+
var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen((specifier) => import.meta.resolve(specifier), options), addons = [], features = async (existing) => ({
|
|
1022
1052
|
...existing,
|
|
1023
1053
|
componentsManifest: !0
|
|
1024
1054
|
}), previewAnnotations = async (entries = [], options) => {
|
|
@@ -1312,13 +1342,10 @@ function angularViteRedirectReapplyPlugin(options) {
|
|
|
1312
1342
|
try {
|
|
1313
1343
|
let calls = extractMockCalls(
|
|
1314
1344
|
{ previewConfigPath, configDir: options.configDir },
|
|
1315
|
-
babelParser,
|
|
1316
1345
|
viteConfig.root ?? process.cwd(),
|
|
1317
1346
|
findMockRedirect
|
|
1318
1347
|
);
|
|
1319
|
-
redirects = calls.filter(
|
|
1320
|
-
(call) => !!call.redirectPath
|
|
1321
|
-
).map((call) => ({
|
|
1348
|
+
redirects = calls.filter((call) => !!call.redirectPath).map((call) => ({
|
|
1322
1349
|
absolutePath: call.absolutePath,
|
|
1323
1350
|
redirectPath: call.redirectPath
|
|
1324
1351
|
})), automocks = calls.filter((call) => !call.redirectPath && !!call.absolutePath).map((call) => ({ absolutePath: call.absolutePath, spy: !!call.spy }));
|
|
@@ -1341,7 +1368,7 @@ function angularViteRedirectReapplyPlugin(options) {
|
|
|
1341
1368
|
if (code.includes("__vitest_current_es_module__"))
|
|
1342
1369
|
return null;
|
|
1343
1370
|
try {
|
|
1344
|
-
let automocked = getAutomockCode(code, a.spy,
|
|
1371
|
+
let automocked = getAutomockCode(code, a.spy, id);
|
|
1345
1372
|
return {
|
|
1346
1373
|
code: automocked.toString(),
|
|
1347
1374
|
map: automocked.generateMap()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular-vite",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.9",
|
|
4
4
|
"description": "Storybook for Angular: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"!src/**/*"
|
|
64
64
|
],
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@storybook/builder-vite": "11.0.0-alpha.
|
|
66
|
+
"@storybook/builder-vite": "11.0.0-alpha.9",
|
|
67
67
|
"@storybook/global": "^5.0.0",
|
|
68
68
|
"telejson": "8.0.0",
|
|
69
69
|
"ts-dedent": "^2.2.0",
|
|
@@ -81,9 +81,8 @@
|
|
|
81
81
|
"@angular/forms": "^21.2.14",
|
|
82
82
|
"@angular/platform-browser": "^21.2.14",
|
|
83
83
|
"@angular/platform-browser-dynamic": "^21.2.14",
|
|
84
|
-
"@
|
|
85
|
-
"@storybook/angular-
|
|
86
|
-
"@storybook/angular-compodoc": "11.0.0-alpha.7",
|
|
84
|
+
"@storybook/angular-cm": "11.0.0-alpha.9",
|
|
85
|
+
"@storybook/angular-compodoc": "11.0.0-alpha.9",
|
|
87
86
|
"@types/node": "^22.19.1",
|
|
88
87
|
"empathic": "^2.0.0",
|
|
89
88
|
"memfs": "^4.11.1",
|
|
@@ -106,7 +105,7 @@
|
|
|
106
105
|
"rxjs": "^7.4.0",
|
|
107
106
|
"sass": "^1.0.0",
|
|
108
107
|
"sass-embedded": "^1.0.0",
|
|
109
|
-
"storybook": "^11.0.0-alpha.
|
|
108
|
+
"storybook": "^11.0.0-alpha.9",
|
|
110
109
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0",
|
|
111
110
|
"vite": ">=8.0.0",
|
|
112
111
|
"zone.js": ">=0.14.0"
|