@storybook/angular-vite 10.6.0-alpha.4 → 10.6.0-alpha.6

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.
@@ -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_b4rv4nwvmm5 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.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_b4rv4nwvmm5 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_b4rv4nwvmm5 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5 from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_b4rv4nwvmm5.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_b4rv4nwvmm5.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_b4rv4nwvmm5.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
- };