@storybook/angular-vite 10.6.0-alpha.3 → 10.6.0-alpha.5

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/index.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  componentWrapperDecorator,
6
6
  moduleMetadata,
7
7
  setProjectAnnotations
8
- } from "./_browser-chunks/chunk-KBKLVYEJ.js";
9
- import "./_browser-chunks/chunk-P4DOL4U2.js";
8
+ } from "./_browser-chunks/chunk-GVH2OCSY.js";
9
+ import "./_browser-chunks/chunk-XXAOQLNU.js";
10
10
  import "./_browser-chunks/chunk-THKACJYB.js";
11
11
  import "./_browser-chunks/chunk-6DVGZIOB.js";
12
12
  export {
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,6 +1,14 @@
1
1
  import { Plugin } from "vite";
2
2
 
3
3
  //#region code/frameworks/angular-vite/.dts-emit/code/frameworks/angular-vite/src/node/vitest.d.ts
4
+ /**
5
+ * Collect every ancestor directory of `startDir` (inclusive) that contains a `node_modules` folder,
6
+ * normalized to Vite's forward-slash convention. All are kept rather than stopping at the first
7
+ * because Storybook's cache creates a `node_modules/.cache` in the project directory, which would
8
+ * otherwise shadow the real workspace root (e.g. an Angular workspace, where dependencies live at
9
+ * the root above `projects/<lib>/`).
10
+ */
11
+ declare const findNodeModulesRoots: (startDir: string) => string[];
4
12
  /**
5
13
  * Angular build options that influence how stories compile under Vitest.
6
14
  * Known keys give autocomplete; the index signature is NOT speculative — it
@@ -35,4 +43,4 @@ interface AngularVitestOptions {
35
43
  */
36
44
  declare function storybookAngularVitest(options?: AngularVitestOptions): Plugin;
37
45
  //#endregion
38
- export { AngularVitestOptions, storybookAngularVitest };
46
+ export { AngularVitestOptions, findNodeModulesRoots, storybookAngularVitest };
@@ -1,18 +1,31 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.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
 
13
13
  // src/node/vitest.ts
14
+ import { existsSync } from "node:fs";
15
+ import { dirname, join, resolve } from "node:path";
14
16
  import { logger } from "storybook/internal/node-logger";
15
- var ENV_KEY = "STORYBOOK_ANGULAR_BUILDER_OPTIONS_JSON", COMPILER_SETUP = "@angular/compiler";
17
+ import { normalizePath } from "vite";
18
+ var ENV_KEY = "STORYBOOK_ANGULAR_BUILDER_OPTIONS_JSON", findNodeModulesRoots = (startDir) => {
19
+ let roots = [], dir = resolve(startDir);
20
+ for (; ; ) {
21
+ existsSync(join(dir, "node_modules")) && roots.push(normalizePath(dir));
22
+ let parent = dirname(dir);
23
+ if (parent === dir)
24
+ break;
25
+ dir = parent;
26
+ }
27
+ return roots;
28
+ }, COMPILER_SETUP = "@angular/compiler";
16
29
  function storybookAngularVitest(options = {}) {
17
30
  let serialized;
18
31
  try {
@@ -29,9 +42,24 @@ function storybookAngularVitest(options = {}) {
29
42
  name: "storybook:angular-vitest-options",
30
43
  // Vitest augments Vite's `UserConfig` with `test`; assert the shape here rather than import
31
44
  // Vitest's types, which would pull its whole type graph into the framework's d.ts build.
32
- config: () => ({ test: { setupFiles: [COMPILER_SETUP] } })
45
+ config: () => ({ test: { setupFiles: [COMPILER_SETUP] } }),
46
+ // In an Angular workspace library the Vite dev-server root is `projects/<lib>/`, but
47
+ // `node_modules` (with `@angular/compiler`) lives at the workspace root. Vite only treats
48
+ // `pnpm-workspace.yaml`, `lerna.json`, or a `workspaces` field as workspace-root markers, so a
49
+ // plain Angular workspace resolves the root to the library folder — and the `@angular/compiler`
50
+ // setup file above falls outside `server.fs.allow`, failing to load in the browser with
51
+ // "Failed to fetch dynamically imported module". Allow every ancestor that contains
52
+ // `node_modules`. `configureServer` is required: Vitest builds the browser server's allow-list
53
+ // itself, so entries added via the `config` hook or static config never reach it.
54
+ configureServer(server) {
55
+ let fs = server.config.server.fs;
56
+ fs.allow ??= [];
57
+ for (let nodeModulesRoot of findNodeModulesRoots(server.config.root))
58
+ fs.allow.includes(nodeModulesRoot) || fs.allow.push(nodeModulesRoot);
59
+ }
33
60
  };
34
61
  }
35
62
  export {
63
+ findNodeModulesRoots,
36
64
  storybookAngularVitest
37
65
  };
package/dist/preset.js CHANGED
@@ -1,14 +1,19 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
+ import {
13
+ ensureCompodocDocumentation,
14
+ resolveCompodocConfig
15
+ } from "./_node-chunks/chunk-77BJXJPD.js";
16
+ import "./_node-chunks/chunk-RC6UIUJ4.js";
12
17
 
13
18
  // src/preset.ts
14
19
  import { findConfigFile } from "storybook/internal/common";
@@ -21,18 +26,58 @@ import {
21
26
  } from "storybook/internal/mocking-utils";
22
27
  import { readFileSync } from "node:fs";
23
28
  import { resolve } from "node:path";
29
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
30
+
31
+ // src/docgen/preset.ts
24
32
  import { fileURLToPath } from "node:url";
33
+ var experimental_docgenProvider = async (existing = [], options) => {
34
+ let features = await options?.presets?.apply("features", {});
35
+ if (!features?.experimentalDocgenServer)
36
+ return existing;
37
+ let compodocConfig = await resolveCompodocConfig(options);
38
+ if (!compodocConfig.enabled)
39
+ return existing;
40
+ let descriptor = {
41
+ moduleSpecifier: fileURLToPath(
42
+ import.meta.resolve("@storybook/angular-vite/internal/docgen-worker")
43
+ ),
44
+ // Structured-cloned onto the worker thread: plain JSON only, no closures or class instances.
45
+ options: {
46
+ outputDir: compodocConfig.outputDir,
47
+ compodocArgs: compodocConfig.compodocArgs,
48
+ workspaceRoot: compodocConfig.workspaceRoot,
49
+ angularFilterNonInputControls: features?.angularFilterNonInputControls,
50
+ tsconfig: compodocConfig.tsconfig
51
+ }
52
+ };
53
+ return [...existing, descriptor];
54
+ }, experimental_manifests = async (existingManifests = {}, options) => {
55
+ let features = await options?.presets?.apply("features", {});
56
+ if (!features?.experimentalDocgenServer || !features?.componentsManifest)
57
+ return existingManifests;
58
+ let existingComponents = existingManifests.components;
59
+ return {
60
+ ...existingManifests,
61
+ components: {
62
+ v: existingComponents?.v ?? 0,
63
+ components: existingComponents?.components ?? {},
64
+ meta: { docgen: "compodoc", durationMs: 0 }
65
+ }
66
+ };
67
+ };
68
+
69
+ // src/preset.ts
25
70
  var addons = [], previewAnnotations = async (entries = [], options) => {
26
- let config = fileURLToPath(import.meta.resolve("@storybook/angular-vite/client/config")), annotations = [...entries, config];
71
+ let config = fileURLToPath2(import.meta.resolve("@storybook/angular-vite/client/config")), annotations = [...entries, config];
27
72
  if (options.enableProdMode) {
28
- let previewProdPath = fileURLToPath(
73
+ let previewProdPath = fileURLToPath2(
29
74
  import.meta.resolve("@storybook/angular-vite/client/preview-prod")
30
75
  );
31
76
  annotations.unshift(previewProdPath);
32
77
  }
33
78
  let docsConfig = await options.presets.apply("docs", {}, options);
34
79
  if (Object.keys(docsConfig).length > 0) {
35
- let docsConfigPath = fileURLToPath(
80
+ let docsConfigPath = fileURLToPath2(
36
81
  import.meta.resolve("@storybook/angular-vite/client/docs/config")
37
82
  );
38
83
  annotations.push(docsConfigPath);
@@ -60,18 +105,13 @@ var viteFinal = async (config, options) => {
60
105
  } catch {
61
106
  }
62
107
  config.plugins = (config.plugins ?? []).flat().filter((plugin) => !plugin.name.includes("analogjs")).map((plugin) => plugin?.name === "plugin-csf" && plugin.enforce === "pre" ? { ...plugin, enforce: void 0 } : plugin);
63
- let { mergeConfig, normalizePath } = await import("vite"), { default: angular } = await import("@analogjs/vite-plugin-angular"), framework = await options.presets.apply("framework");
64
- if (framework.options?.compodoc !== !1) {
65
- let { existsSync } = await import("node:fs"), path = await import("node:path"), workspaceRoot = options?.angularBuilderContext?.workspaceRoot ?? config?.root ?? process.cwd(), documentationJsonPath = path.resolve(workspaceRoot, "documentation.json");
66
- if (!existsSync(documentationJsonPath)) {
67
- let { runCompodoc } = await import("./_node-chunks/run-compodoc-3TI5YJGV.js"), tsconfig = framework.options?.tsconfig ?? options?.tsConfig ?? options?.angularBuilderOptions?.tsConfig ?? path.resolve(workspaceRoot, "tsconfig.json"), compodocArgs = framework.options?.compodocArgs ?? ["-e", "json", "-d", "."];
68
- try {
69
- await runCompodoc({ compodocArgs, tsconfig, workspaceRoot });
70
- } catch (err) {
71
- console.warn("[storybook-angular-vite] compodoc generation failed:", err);
72
- }
73
- }
74
- }
108
+ let { mergeConfig, normalizePath } = await import("vite"), { default: angular } = await import("@analogjs/vite-plugin-angular"), framework = await options.presets.apply("framework"), compodocConfig = await resolveCompodocConfig(options, { viteRoot: config?.root });
109
+ compodocConfig.enabled && await ensureCompodocDocumentation({
110
+ compodocArgs: compodocConfig.compodocArgs,
111
+ tsconfig: compodocConfig.tsconfig,
112
+ workspaceRoot: compodocConfig.workspaceRoot,
113
+ outputDir: compodocConfig.outputDir
114
+ });
75
115
  let zoneless = resolveZoneless(options?.angularBuilderOptions), angularPlugins = angular({
76
116
  jit: typeof framework.options?.jit < "u" ? framework.options?.jit : !0,
77
117
  liveReload: typeof framework.options?.liveReload < "u" ? framework.options?.liveReload : !1,
@@ -249,6 +289,8 @@ export {
249
289
  addons,
250
290
  angularOptionsPlugin,
251
291
  core,
292
+ experimental_docgenProvider,
293
+ experimental_manifests,
252
294
  previewAnnotations,
253
295
  typescript,
254
296
  viteFinal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/angular-vite",
3
- "version": "10.6.0-alpha.3",
3
+ "version": "10.6.0-alpha.5",
4
4
  "description": "Storybook for Angular: Develop, document, and test UI components in isolation",
5
5
  "keywords": [
6
6
  "storybook",
@@ -36,6 +36,7 @@
36
36
  "./client/config": "./dist/client/config.js",
37
37
  "./client/docs/config": "./dist/client/docs/config.js",
38
38
  "./client/preview-prod": "./dist/client/preview-prod.js",
39
+ "./internal/docgen-worker": "./dist/docgen/docgen-worker.js",
39
40
  "./node": {
40
41
  "types": "./dist/node/index.d.ts",
41
42
  "code": "./src/node/index.ts",
@@ -62,7 +63,7 @@
62
63
  "!src/**/*"
63
64
  ],
64
65
  "dependencies": {
65
- "@storybook/builder-vite": "10.6.0-alpha.3",
66
+ "@storybook/builder-vite": "10.6.0-alpha.5",
66
67
  "@storybook/global": "^5.0.0",
67
68
  "telejson": "8.0.0",
68
69
  "ts-dedent": "^2.0.0",
@@ -81,8 +82,11 @@
81
82
  "@angular/forms": "^21.2.14",
82
83
  "@angular/platform-browser": "^21.2.14",
83
84
  "@angular/platform-browser-dynamic": "^21.2.14",
85
+ "@babel/types": "^7.28.5",
86
+ "@storybook/angular-compodoc": "10.6.0-alpha.5",
84
87
  "@types/node": "^22.19.1",
85
88
  "empathic": "^2.0.0",
89
+ "memfs": "^4.11.1",
86
90
  "rimraf": "^6.0.1",
87
91
  "typescript": "^6.0.3",
88
92
  "zone.js": "^0.16.2"
@@ -100,7 +104,7 @@
100
104
  "@angular/core": ">=21.0.0 < 23.0.0",
101
105
  "@angular/platform-browser": ">=21.0.0 < 23.0.0",
102
106
  "rxjs": "^7.4.0",
103
- "storybook": "^10.6.0-alpha.3",
107
+ "storybook": "^10.6.0-alpha.5",
104
108
  "typescript": ">= 5.9.x",
105
109
  "vite": ">=8.0.0",
106
110
  "zone.js": ">=0.16.0"
@@ -1,250 +0,0 @@
1
- import {
2
- __export,
3
- computesTemplateFromComponent,
4
- getComponentInputsOutputs,
5
- render,
6
- renderToCanvas
7
- } from "./chunk-6DVGZIOB.js";
8
-
9
- // src/client/config.ts
10
- var config_exports = {};
11
- __export(config_exports, {
12
- applyDecorators: () => decorateStory,
13
- argTypesEnhancers: () => argTypesEnhancers,
14
- parameters: () => parameters,
15
- render: () => render,
16
- renderToCanvas: () => renderToCanvas
17
- });
18
-
19
- // src/client/globals.ts
20
- import { global } from "@storybook/global";
21
- global.STORYBOOK_ENV = "angular";
22
-
23
- // src/client/decorateStory.ts
24
- import { sanitizeStoryContextUpdate } from "storybook/preview-api";
25
- function decorateStory(mainStoryFn, decorators) {
26
- return [cleanArgsDecorator, ...decorators].reduce(
27
- (previousStoryFn, decorator) => (context) => decorator((update) => previousStoryFn({
28
- ...context,
29
- ...sanitizeStoryContextUpdate(update)
30
- }), context),
31
- (context) => prepareMain(mainStoryFn(context), context)
32
- );
33
- }
34
- var prepareMain = (story, context) => {
35
- let { template } = story, { component } = context, userDefinedTemplate = !hasNoTemplate(template);
36
- return !userDefinedTemplate && component && (template = computesTemplateFromComponent(component, story.props, "")), {
37
- ...story,
38
- ...template ? { template, userDefinedTemplate } : {}
39
- };
40
- };
41
- function hasNoTemplate(template) {
42
- return template == null;
43
- }
44
- var cleanArgsDecorator = (storyFn, context) => {
45
- if (!context.argTypes || !context.args || Object.keys(context.argTypes).length === 0)
46
- return storyFn();
47
- let componentIO = context.component ? getComponentInputsOutputs(context.component) : { inputs: [], outputs: [] }, componentBindings = /* @__PURE__ */ new Set([
48
- ...componentIO.inputs.map((i) => i.templateName),
49
- ...componentIO.outputs.map((o) => o.templateName)
50
- ]), argsToClean = context.args;
51
- return context.args = Object.entries(argsToClean).reduce((obj, [key, arg]) => {
52
- let argType = context.argTypes[key];
53
- return argType?.action || argType?.control || componentBindings.has(key) ? { ...obj, [key]: arg } : obj;
54
- }, {}), storyFn();
55
- };
56
-
57
- // src/client/config.ts
58
- import { enhanceArgTypes } from "storybook/internal/docs-tools";
59
-
60
- // src/client/compodoc.ts
61
- import { logger } from "storybook/internal/client-logger";
62
- import { global as global2 } from "@storybook/global";
63
- var { FEATURES } = global2, isMethod = (methodOrProp) => methodOrProp.args !== void 0;
64
- var getCompodocJson = () => global2.__STORYBOOK_COMPODOC_JSON__, checkValidComponentOrDirective = (component) => {
65
- if (!component.name)
66
- throw new Error(`Invalid component ${JSON.stringify(component)}`);
67
- }, checkValidCompodocJson = (compodocJson) => {
68
- if (!compodocJson || !compodocJson.components)
69
- throw new Error("Invalid compodoc JSON");
70
- }, hasDecorator = (item, decoratorName) => item.decorators && item.decorators.find((x) => x.name === decoratorName), mapPropertyToSection = (item) => hasDecorator(item, "ViewChild") ? "view child" : hasDecorator(item, "ViewChildren") ? "view children" : hasDecorator(item, "ContentChild") ? "content child" : hasDecorator(item, "ContentChildren") ? "content children" : "properties", mapItemToSection = (key, item) => {
71
- switch (key) {
72
- case "methods":
73
- case "methodsClass":
74
- return "methods";
75
- case "inputsClass":
76
- return "inputs";
77
- case "outputsClass":
78
- return "outputs";
79
- case "properties":
80
- case "propertiesClass":
81
- if (isMethod(item))
82
- throw new Error("Cannot be of type Method if key === 'propertiesClass'");
83
- return mapPropertyToSection(item);
84
- default:
85
- throw new Error(`Unknown key: ${key}`);
86
- }
87
- }, findComponentByName = (name, compodocJson) => compodocJson.components.find((c) => c.name === name) || compodocJson.directives.find((c) => c.name === name) || compodocJson.pipes.find((c) => c.name === name) || compodocJson.injectables.find((c) => c.name === name) || compodocJson.classes.find((c) => c.name === name), getComponentData = (component) => {
88
- if (!component)
89
- return null;
90
- checkValidComponentOrDirective(component);
91
- let compodocJson = getCompodocJson();
92
- if (!compodocJson)
93
- return null;
94
- checkValidCompodocJson(compodocJson);
95
- let { name } = component, metadata = findComponentByName(name, compodocJson);
96
- return metadata || logger.warn(`Component not found in compodoc JSON: '${name}'`), metadata;
97
- }, displaySignature = (item) => `(${item.args.map(
98
- (arg) => `${arg.name}${arg.optional ? "?" : ""}: ${arg.type}`
99
- ).join(", ")}) => ${item.returnType}`, extractTypeFromValue = (defaultValue) => {
100
- let valueType = typeof defaultValue;
101
- return defaultValue || valueType === "number" || valueType === "boolean" || valueType === "string" ? valueType : null;
102
- }, extractEnumValues = (compodocType) => {
103
- let enumType = getCompodocJson()?.miscellaneous?.enumerations?.find((x) => x.name === compodocType);
104
- if (enumType?.childs.every((x) => x.value))
105
- return enumType.childs.map((x) => x.value);
106
- if (typeof compodocType != "string" || compodocType.indexOf("|") === -1)
107
- return null;
108
- try {
109
- return compodocType.split("|").map((value) => JSON.parse(value));
110
- } catch {
111
- return null;
112
- }
113
- }, extractType = (property, defaultValue) => {
114
- let compodocType = property.type || extractTypeFromValue(defaultValue);
115
- switch (compodocType) {
116
- case "string":
117
- case "boolean":
118
- case "number":
119
- return { name: compodocType };
120
- case void 0:
121
- case null:
122
- return { name: "other", value: "void" };
123
- default: {
124
- let resolvedType = resolveTypealias(compodocType), enumValues = extractEnumValues(resolvedType);
125
- return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
126
- }
127
- }
128
- }, castDefaultValue = (property, defaultValue) => {
129
- let compodocType = property.type;
130
- if (["boolean", "number", "string", "EventEmitter"].includes(compodocType))
131
- switch (compodocType) {
132
- case "boolean":
133
- return defaultValue === "true";
134
- case "number":
135
- return Number(defaultValue);
136
- case "EventEmitter":
137
- return;
138
- default:
139
- return defaultValue;
140
- }
141
- else
142
- switch (defaultValue) {
143
- case "true":
144
- return !0;
145
- case "false":
146
- return !1;
147
- case "null":
148
- return null;
149
- case "undefined":
150
- return;
151
- default:
152
- return defaultValue;
153
- }
154
- }, extractDefaultValueFromComments = (property, value) => {
155
- let commentValue = value;
156
- return property.jsdoctags.forEach((tag) => {
157
- ["default", "defaultvalue"].includes(tag.tagName.escapedText) && (commentValue = new global2.DOMParser().parseFromString(tag.comment, "text/html").body.textContent);
158
- }), commentValue;
159
- }, extractDefaultValue = (property) => {
160
- try {
161
- let value = property.defaultValue?.replace(/^'(.*)'$/, "$1");
162
- return value = castDefaultValue(property, value), value == null && property.jsdoctags?.length > 0 && (value = extractDefaultValueFromComments(property, value)), value;
163
- } catch {
164
- logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
165
- return;
166
- }
167
- }, resolveTypealias = (compodocType) => {
168
- let typeAlias = getCompodocJson()?.miscellaneous?.typealiases?.find((x) => x.name === compodocType);
169
- return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
170
- }, extractArgTypesFromData = (componentData) => {
171
- let sectionToItems = {}, componentClasses = FEATURES.angularFilterNonInputControls ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"], compodocClasses = ["component", "directive"].includes(componentData.type) ? componentClasses : ["properties", "methods"], inputClassNames = new Set(
172
- (componentData.inputsClass || []).map((item) => item.name)
173
- ), modelProperties = (componentData.outputsClass || []).filter((item) => inputClassNames.has(item.name)), modelPropertyNames = new Set(modelProperties.map((item) => item.name));
174
- compodocClasses.forEach((key) => {
175
- (componentData[key] || []).forEach((item) => {
176
- let section = mapItemToSection(key, item);
177
- if (key === "outputsClass" && !isMethod(item) && modelPropertyNames.has(item.name))
178
- return;
179
- let defaultValue = isMethod(item) ? void 0 : extractDefaultValue(item), type = isMethod(item) || section !== "inputs" && section !== "properties" ? { name: "other", value: "void" } : extractType(item, defaultValue), action = section === "outputs" ? { action: item.name } : {}, argType = {
180
- name: item.name,
181
- description: item.rawdescription || item.description,
182
- type,
183
- ...action,
184
- table: {
185
- category: section,
186
- type: {
187
- summary: isMethod(item) ? displaySignature(item) : item.type,
188
- required: isMethod(item) ? !1 : !item.optional
189
- },
190
- defaultValue: { summary: defaultValue }
191
- }
192
- };
193
- sectionToItems[section] || (sectionToItems[section] = []), sectionToItems[section].push(argType);
194
- });
195
- }), modelProperties.forEach((item) => {
196
- let changeName = `${item.name}Change`, argType = {
197
- name: changeName,
198
- description: item.rawdescription || item.description,
199
- type: { name: "other", value: "void" },
200
- action: changeName,
201
- table: {
202
- category: "outputs",
203
- type: {
204
- summary: `(e: ${item.type}) => void`,
205
- required: !item.optional
206
- }
207
- }
208
- };
209
- sectionToItems.outputs || (sectionToItems.outputs = []), sectionToItems.outputs.push(argType);
210
- });
211
- let SECTIONS = [
212
- "properties",
213
- "inputs",
214
- "outputs",
215
- "methods",
216
- "view child",
217
- "view children",
218
- "content child",
219
- "content children"
220
- ], argTypes = {};
221
- return SECTIONS.forEach((section) => {
222
- let items = sectionToItems[section];
223
- items && items.forEach((argType) => {
224
- argTypes[argType.name] = argType;
225
- });
226
- }), argTypes;
227
- }, extractArgTypes = (component) => {
228
- let componentData = getComponentData(component);
229
- return componentData && extractArgTypesFromData(componentData);
230
- }, extractComponentDescription = (component) => {
231
- let componentData = getComponentData(component);
232
- return componentData && (componentData.rawdescription || componentData.description);
233
- };
234
-
235
- // src/client/config.ts
236
- var parameters = {
237
- renderer: "angular",
238
- docs: {
239
- story: { inline: !0 },
240
- extractArgTypes,
241
- extractComponentDescription
242
- }
243
- }, argTypesEnhancers = [enhanceArgTypes];
244
-
245
- export {
246
- decorateStory,
247
- parameters,
248
- argTypesEnhancers,
249
- config_exports
250
- };
@@ -1,64 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
-
13
- // ../../../node_modules/empathic/find.mjs
14
- import { join as join2 } from "node:path";
15
- import { existsSync, statSync } from "node:fs";
16
-
17
- // ../../../node_modules/empathic/walk.mjs
18
- import { dirname } from "node:path";
19
-
20
- // ../../../node_modules/empathic/resolve.mjs
21
- import { isAbsolute, join, resolve } from "node:path";
22
- function absolute(input, root) {
23
- return isAbsolute(input) ? input : resolve(root || ".", input);
24
- }
25
-
26
- // ../../../node_modules/empathic/walk.mjs
27
- function up(base, options) {
28
- let { last, cwd } = options || {}, tmp = absolute(base, cwd), root = absolute(last || "/", cwd), prev, arr = [];
29
- for (; prev !== root && (arr.push(tmp), tmp = dirname(prev = tmp), tmp !== prev); )
30
- ;
31
- return arr;
32
- }
33
-
34
- // ../../../node_modules/empathic/find.mjs
35
- function up2(name, options) {
36
- let dir, tmp, start = options && options.cwd || "";
37
- for (dir of up(start, options))
38
- if (tmp = join2(dir, name), existsSync(tmp)) return tmp;
39
- }
40
-
41
- // ../../../node_modules/empathic/package.mjs
42
- function up3(options) {
43
- return up2("package.json", options);
44
- }
45
-
46
- // src/builders/utils/error-handler.ts
47
- import { logger, instance as npmLog } from "storybook/internal/node-logger";
48
- import { dedent } from "ts-dedent";
49
- var printErrorDetails = (error) => {
50
- npmLog.heading = "", error instanceof Error ? error.error ? logger.error(error.error) : error.stats && error.stats.compilation.errors ? error.stats.compilation.errors.forEach((e) => logger.log(e)) : logger.error(error) : error.compilation?.errors && error.compilation.errors.forEach((e) => logger.log(e));
51
- }, errorSummary = (error) => error.close ? dedent`
52
- FATAL broken build!, will close the process,
53
- Fix the error below and restart storybook.
54
- ` : dedent`
55
- Broken build, fix the error above.
56
- You may need to refresh the browser.
57
- `;
58
-
59
- export {
60
- up2 as up,
61
- up3 as up2,
62
- printErrorDetails,
63
- errorSummary
64
- };
@@ -1,39 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
-
13
- // src/builders/utils/run-compodoc.ts
14
- import { isAbsolute, relative } from "node:path";
15
- import { JsPackageManagerFactory } from "storybook/internal/common";
16
- import { prompt } from "storybook/internal/node-logger";
17
- var hasTsConfigArg = (args) => args.indexOf("-p") !== -1, hasOutputArg = (args) => args.indexOf("-d") !== -1 || args.indexOf("--output") !== -1, toRelativePath = (pathToTsConfig) => isAbsolute(pathToTsConfig) ? relative(".", pathToTsConfig) : pathToTsConfig, runCompodoc = async (opts) => {
18
- let { compodocArgs, tsconfig, workspaceRoot } = opts, tsConfigPath = toRelativePath(tsconfig), finalCompodocArgs = [
19
- "compodoc",
20
- ...hasTsConfigArg(compodocArgs) ? [] : ["-p", tsConfigPath],
21
- ...hasOutputArg(compodocArgs) ? [] : ["-d", `${workspaceRoot || "."}`],
22
- ...compodocArgs
23
- ], packageManager = JsPackageManagerFactory.getPackageManager();
24
- await prompt.executeTaskWithSpinner(
25
- () => packageManager.runPackageCommand({
26
- args: finalCompodocArgs,
27
- cwd: workspaceRoot
28
- }),
29
- {
30
- id: "compodoc",
31
- intro: "Generating documentation with Compodoc",
32
- success: "Compodoc finished successfully",
33
- error: "Compodoc failed"
34
- }
35
- );
36
- };
37
- export {
38
- runCompodoc
39
- };