@storybook/angular-vite 0.0.0-canary-test
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/README.md +5 -0
- package/build-schema.json +192 -0
- package/builders.json +14 -0
- package/dist/_browser-chunks/chunk-4WZEHS2U.js +47 -0
- package/dist/_browser-chunks/chunk-6U6AH4EH.js +723 -0
- package/dist/_browser-chunks/chunk-CIJX6X7B.js +246 -0
- package/dist/_browser-chunks/chunk-TARB3NLN.js +93 -0
- package/dist/_node-chunks/chunk-R2RNJVE7.js +90 -0
- package/dist/builders/build-storybook/index.js +123 -0
- package/dist/builders/start-storybook/index.js +155 -0
- package/dist/client/config.js +16 -0
- package/dist/client/docs/config.js +9 -0
- package/dist/client/index.js +19 -0
- package/dist/client/preview-prod.js +3 -0
- package/dist/index.d.ts +1343 -0
- package/dist/index.js +20 -0
- package/dist/node/index.d.ts +31 -0
- package/dist/node/index.js +19 -0
- package/dist/preset.js +235 -0
- package/package.json +116 -0
- package/preset.js +1 -0
- package/start-schema.json +227 -0
- package/template/cli/button.component.ts +50 -0
- package/template/cli/button.stories.ts +49 -0
- package/template/cli/header.component.ts +78 -0
- package/template/cli/header.stories.ts +33 -0
- package/template/cli/page.component.ts +84 -0
- package/template/cli/page.stories.ts +32 -0
- package/template/cli/user.ts +3 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export,
|
|
3
|
+
computesTemplateFromComponent,
|
|
4
|
+
render,
|
|
5
|
+
renderToCanvas
|
|
6
|
+
} from "./chunk-6U6AH4EH.js";
|
|
7
|
+
|
|
8
|
+
// src/client/config.ts
|
|
9
|
+
var config_exports = {};
|
|
10
|
+
__export(config_exports, {
|
|
11
|
+
applyDecorators: () => decorateStory,
|
|
12
|
+
argTypesEnhancers: () => argTypesEnhancers,
|
|
13
|
+
parameters: () => parameters,
|
|
14
|
+
render: () => render,
|
|
15
|
+
renderToCanvas: () => renderToCanvas
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/client/globals.ts
|
|
19
|
+
import { global } from "@storybook/global";
|
|
20
|
+
global.STORYBOOK_ENV = "angular";
|
|
21
|
+
|
|
22
|
+
// src/client/decorateStory.ts
|
|
23
|
+
import { sanitizeStoryContextUpdate } from "storybook/preview-api";
|
|
24
|
+
function decorateStory(mainStoryFn, decorators) {
|
|
25
|
+
return [cleanArgsDecorator, ...decorators].reduce(
|
|
26
|
+
(previousStoryFn, decorator) => (context) => decorator((update) => previousStoryFn({
|
|
27
|
+
...context,
|
|
28
|
+
...sanitizeStoryContextUpdate(update)
|
|
29
|
+
}), context),
|
|
30
|
+
(context) => prepareMain(mainStoryFn(context), context)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
var prepareMain = (story, context) => {
|
|
34
|
+
let { template } = story, { component } = context, userDefinedTemplate = !hasNoTemplate(template);
|
|
35
|
+
return !userDefinedTemplate && component && (template = computesTemplateFromComponent(component, story.props, "")), {
|
|
36
|
+
...story,
|
|
37
|
+
...template ? { template, userDefinedTemplate } : {}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
function hasNoTemplate(template) {
|
|
41
|
+
return template == null;
|
|
42
|
+
}
|
|
43
|
+
var cleanArgsDecorator = (storyFn, context) => {
|
|
44
|
+
if (!context.argTypes || !context.args || Object.keys(context.argTypes).length === 0)
|
|
45
|
+
return storyFn();
|
|
46
|
+
let argsToClean = context.args;
|
|
47
|
+
return context.args = Object.entries(argsToClean).reduce((obj, [key, arg]) => {
|
|
48
|
+
let argType = context.argTypes[key];
|
|
49
|
+
return argType?.action || argType?.control ? { ...obj, [key]: arg } : obj;
|
|
50
|
+
}, {}), storyFn();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/client/config.ts
|
|
54
|
+
import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
55
|
+
|
|
56
|
+
// src/client/compodoc.ts
|
|
57
|
+
import { logger } from "storybook/internal/client-logger";
|
|
58
|
+
import { global as global2 } from "@storybook/global";
|
|
59
|
+
var { FEATURES } = global2, isMethod = (methodOrProp) => methodOrProp.args !== void 0;
|
|
60
|
+
var getCompodocJson = () => global2.__STORYBOOK_COMPODOC_JSON__, checkValidComponentOrDirective = (component) => {
|
|
61
|
+
if (!component.name)
|
|
62
|
+
throw new Error(`Invalid component ${JSON.stringify(component)}`);
|
|
63
|
+
}, checkValidCompodocJson = (compodocJson) => {
|
|
64
|
+
if (!compodocJson || !compodocJson.components)
|
|
65
|
+
throw new Error("Invalid compodoc JSON");
|
|
66
|
+
}, 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) => {
|
|
67
|
+
switch (key) {
|
|
68
|
+
case "methods":
|
|
69
|
+
case "methodsClass":
|
|
70
|
+
return "methods";
|
|
71
|
+
case "inputsClass":
|
|
72
|
+
return "inputs";
|
|
73
|
+
case "outputsClass":
|
|
74
|
+
return "outputs";
|
|
75
|
+
case "properties":
|
|
76
|
+
case "propertiesClass":
|
|
77
|
+
if (isMethod(item))
|
|
78
|
+
throw new Error("Cannot be of type Method if key === 'propertiesClass'");
|
|
79
|
+
return mapPropertyToSection(item);
|
|
80
|
+
default:
|
|
81
|
+
throw new Error(`Unknown key: ${key}`);
|
|
82
|
+
}
|
|
83
|
+
}, 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) => {
|
|
84
|
+
if (!component)
|
|
85
|
+
return null;
|
|
86
|
+
checkValidComponentOrDirective(component);
|
|
87
|
+
let compodocJson = getCompodocJson();
|
|
88
|
+
if (!compodocJson)
|
|
89
|
+
return null;
|
|
90
|
+
checkValidCompodocJson(compodocJson);
|
|
91
|
+
let { name } = component, metadata = findComponentByName(name, compodocJson);
|
|
92
|
+
return metadata || logger.warn(`Component not found in compodoc JSON: '${name}'`), metadata;
|
|
93
|
+
}, displaySignature = (item) => `(${item.args.map(
|
|
94
|
+
(arg) => `${arg.name}${arg.optional ? "?" : ""}: ${arg.type}`
|
|
95
|
+
).join(", ")}) => ${item.returnType}`, extractTypeFromValue = (defaultValue) => {
|
|
96
|
+
let valueType = typeof defaultValue;
|
|
97
|
+
return defaultValue || valueType === "number" || valueType === "boolean" || valueType === "string" ? valueType : null;
|
|
98
|
+
}, extractEnumValues = (compodocType) => {
|
|
99
|
+
let enumType = getCompodocJson()?.miscellaneous?.enumerations?.find((x) => x.name === compodocType);
|
|
100
|
+
if (enumType?.childs.every((x) => x.value))
|
|
101
|
+
return enumType.childs.map((x) => x.value);
|
|
102
|
+
if (typeof compodocType != "string" || compodocType.indexOf("|") === -1)
|
|
103
|
+
return null;
|
|
104
|
+
try {
|
|
105
|
+
return compodocType.split("|").map((value) => JSON.parse(value));
|
|
106
|
+
} catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}, extractType = (property, defaultValue) => {
|
|
110
|
+
let compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
111
|
+
switch (compodocType) {
|
|
112
|
+
case "string":
|
|
113
|
+
case "boolean":
|
|
114
|
+
case "number":
|
|
115
|
+
return { name: compodocType };
|
|
116
|
+
case void 0:
|
|
117
|
+
case null:
|
|
118
|
+
return { name: "other", value: "void" };
|
|
119
|
+
default: {
|
|
120
|
+
let resolvedType = resolveTypealias(compodocType), enumValues = extractEnumValues(resolvedType);
|
|
121
|
+
return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, castDefaultValue = (property, defaultValue) => {
|
|
125
|
+
let compodocType = property.type;
|
|
126
|
+
if (["boolean", "number", "string", "EventEmitter"].includes(compodocType))
|
|
127
|
+
switch (compodocType) {
|
|
128
|
+
case "boolean":
|
|
129
|
+
return defaultValue === "true";
|
|
130
|
+
case "number":
|
|
131
|
+
return Number(defaultValue);
|
|
132
|
+
case "EventEmitter":
|
|
133
|
+
return;
|
|
134
|
+
default:
|
|
135
|
+
return defaultValue;
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
switch (defaultValue) {
|
|
139
|
+
case "true":
|
|
140
|
+
return !0;
|
|
141
|
+
case "false":
|
|
142
|
+
return !1;
|
|
143
|
+
case "null":
|
|
144
|
+
return null;
|
|
145
|
+
case "undefined":
|
|
146
|
+
return;
|
|
147
|
+
default:
|
|
148
|
+
return defaultValue;
|
|
149
|
+
}
|
|
150
|
+
}, extractDefaultValueFromComments = (property, value) => {
|
|
151
|
+
let commentValue = value;
|
|
152
|
+
return property.jsdoctags.forEach((tag) => {
|
|
153
|
+
["default", "defaultvalue"].includes(tag.tagName.escapedText) && (commentValue = new global2.DOMParser().parseFromString(tag.comment, "text/html").body.textContent);
|
|
154
|
+
}), commentValue;
|
|
155
|
+
}, extractDefaultValue = (property) => {
|
|
156
|
+
try {
|
|
157
|
+
let value = property.defaultValue?.replace(/^'(.*)'$/, "$1");
|
|
158
|
+
return value = castDefaultValue(property, value), value == null && property.jsdoctags?.length > 0 && (value = extractDefaultValueFromComments(property, value)), value;
|
|
159
|
+
} catch {
|
|
160
|
+
logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
}, resolveTypealias = (compodocType) => {
|
|
164
|
+
let typeAlias = getCompodocJson()?.miscellaneous?.typealiases?.find((x) => x.name === compodocType);
|
|
165
|
+
return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
|
|
166
|
+
}, extractArgTypesFromData = (componentData) => {
|
|
167
|
+
let sectionToItems = {}, componentClasses = FEATURES.angularFilterNonInputControls ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"], compodocClasses = ["component", "directive"].includes(componentData.type) ? componentClasses : ["properties", "methods"], inputClassNames = new Set(
|
|
168
|
+
(componentData.inputsClass || []).map((item) => item.name)
|
|
169
|
+
), modelProperties = (componentData.outputsClass || []).filter((item) => inputClassNames.has(item.name)), modelPropertyNames = new Set(modelProperties.map((item) => item.name));
|
|
170
|
+
compodocClasses.forEach((key) => {
|
|
171
|
+
(componentData[key] || []).forEach((item) => {
|
|
172
|
+
let section = mapItemToSection(key, item);
|
|
173
|
+
if (key === "outputsClass" && !isMethod(item) && modelPropertyNames.has(item.name))
|
|
174
|
+
return;
|
|
175
|
+
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 = {
|
|
176
|
+
name: item.name,
|
|
177
|
+
description: item.rawdescription || item.description,
|
|
178
|
+
type,
|
|
179
|
+
...action,
|
|
180
|
+
table: {
|
|
181
|
+
category: section,
|
|
182
|
+
type: {
|
|
183
|
+
summary: isMethod(item) ? displaySignature(item) : item.type,
|
|
184
|
+
required: isMethod(item) ? !1 : !item.optional
|
|
185
|
+
},
|
|
186
|
+
defaultValue: { summary: defaultValue }
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
sectionToItems[section] || (sectionToItems[section] = []), sectionToItems[section].push(argType);
|
|
190
|
+
});
|
|
191
|
+
}), modelProperties.forEach((item) => {
|
|
192
|
+
let changeName = `${item.name}Change`, argType = {
|
|
193
|
+
name: changeName,
|
|
194
|
+
description: item.rawdescription || item.description,
|
|
195
|
+
type: { name: "other", value: "void" },
|
|
196
|
+
action: changeName,
|
|
197
|
+
table: {
|
|
198
|
+
category: "outputs",
|
|
199
|
+
type: {
|
|
200
|
+
summary: `(e: ${item.type}) => void`,
|
|
201
|
+
required: !item.optional
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
sectionToItems.outputs || (sectionToItems.outputs = []), sectionToItems.outputs.push(argType);
|
|
206
|
+
});
|
|
207
|
+
let SECTIONS = [
|
|
208
|
+
"properties",
|
|
209
|
+
"inputs",
|
|
210
|
+
"outputs",
|
|
211
|
+
"methods",
|
|
212
|
+
"view child",
|
|
213
|
+
"view children",
|
|
214
|
+
"content child",
|
|
215
|
+
"content children"
|
|
216
|
+
], argTypes = {};
|
|
217
|
+
return SECTIONS.forEach((section) => {
|
|
218
|
+
let items = sectionToItems[section];
|
|
219
|
+
items && items.forEach((argType) => {
|
|
220
|
+
argTypes[argType.name] = argType;
|
|
221
|
+
});
|
|
222
|
+
}), argTypes;
|
|
223
|
+
}, extractArgTypes = (component) => {
|
|
224
|
+
let componentData = getComponentData(component);
|
|
225
|
+
return componentData && extractArgTypesFromData(componentData);
|
|
226
|
+
}, extractComponentDescription = (component) => {
|
|
227
|
+
let componentData = getComponentData(component);
|
|
228
|
+
return componentData && (componentData.rawdescription || componentData.description);
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/client/config.ts
|
|
232
|
+
var parameters = {
|
|
233
|
+
renderer: "angular",
|
|
234
|
+
docs: {
|
|
235
|
+
story: { inline: !0 },
|
|
236
|
+
extractArgTypes,
|
|
237
|
+
extractComponentDescription
|
|
238
|
+
}
|
|
239
|
+
}, argTypesEnhancers = [enhanceArgTypes];
|
|
240
|
+
|
|
241
|
+
export {
|
|
242
|
+
decorateStory,
|
|
243
|
+
parameters,
|
|
244
|
+
argTypesEnhancers,
|
|
245
|
+
config_exports
|
|
246
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
config_exports
|
|
3
|
+
} from "./chunk-CIJX6X7B.js";
|
|
4
|
+
import {
|
|
5
|
+
config_exports as config_exports2
|
|
6
|
+
} from "./chunk-4WZEHS2U.js";
|
|
7
|
+
import {
|
|
8
|
+
computesTemplateFromComponent,
|
|
9
|
+
formatPropInTemplate,
|
|
10
|
+
isComponent,
|
|
11
|
+
render_exports
|
|
12
|
+
} from "./chunk-6U6AH4EH.js";
|
|
13
|
+
|
|
14
|
+
// src/client/portable-stories.ts
|
|
15
|
+
import {
|
|
16
|
+
setProjectAnnotations as originalSetProjectAnnotations,
|
|
17
|
+
setDefaultProjectAnnotations
|
|
18
|
+
} from "storybook/preview-api";
|
|
19
|
+
function setProjectAnnotations(projectAnnotations) {
|
|
20
|
+
return setDefaultProjectAnnotations(render_exports), originalSetProjectAnnotations(
|
|
21
|
+
projectAnnotations
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// src/client/preview.ts
|
|
26
|
+
import { definePreview as definePreviewBase } from "storybook/internal/csf";
|
|
27
|
+
function __definePreview(input) {
|
|
28
|
+
return definePreviewBase({
|
|
29
|
+
...input,
|
|
30
|
+
addons: [config_exports, config_exports2, ...input.addons ?? []]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/client/decorators.ts
|
|
35
|
+
var moduleMetadata = (metadata) => (storyFn) => {
|
|
36
|
+
let story = storyFn(), storyMetadata = story.moduleMetadata || {};
|
|
37
|
+
return metadata = metadata || {}, {
|
|
38
|
+
...story,
|
|
39
|
+
moduleMetadata: {
|
|
40
|
+
declarations: [...metadata.declarations || [], ...storyMetadata.declarations || []],
|
|
41
|
+
entryComponents: [
|
|
42
|
+
...metadata.entryComponents || [],
|
|
43
|
+
...storyMetadata.entryComponents || []
|
|
44
|
+
],
|
|
45
|
+
imports: [...metadata.imports || [], ...storyMetadata.imports || []],
|
|
46
|
+
schemas: [...metadata.schemas || [], ...storyMetadata.schemas || []],
|
|
47
|
+
providers: [...metadata.providers || [], ...storyMetadata.providers || []]
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
function applicationConfig(config) {
|
|
52
|
+
return (storyFn) => {
|
|
53
|
+
let story = storyFn(), storyConfig = story.applicationConfig;
|
|
54
|
+
return {
|
|
55
|
+
...story,
|
|
56
|
+
applicationConfig: storyConfig || config ? {
|
|
57
|
+
...config,
|
|
58
|
+
...storyConfig,
|
|
59
|
+
providers: [...config?.providers || [], ...storyConfig?.providers || []]
|
|
60
|
+
} : void 0
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
var componentWrapperDecorator = (element, props) => (storyFn, storyContext) => {
|
|
65
|
+
let story = storyFn(), currentProps = typeof props == "function" ? props(storyContext) : props, template = isComponent(element) ? computesTemplateFromComponent(element, currentProps ?? {}, story.template) : element(story.template);
|
|
66
|
+
return {
|
|
67
|
+
...story,
|
|
68
|
+
template,
|
|
69
|
+
...currentProps || story.props ? {
|
|
70
|
+
props: {
|
|
71
|
+
...currentProps,
|
|
72
|
+
...story.props
|
|
73
|
+
}
|
|
74
|
+
} : {}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/client/argsToTemplate.ts
|
|
79
|
+
function argsToTemplate(args, options = {}) {
|
|
80
|
+
let includeSet = options.include ? new Set(options.include) : null, excludeSet = options.exclude ? new Set(options.exclude) : null;
|
|
81
|
+
return Object.entries(args).filter(([key]) => args[key] !== void 0).filter(([key]) => includeSet ? includeSet.has(key) : excludeSet ? !excludeSet.has(key) : !0).map(
|
|
82
|
+
([key, value]) => typeof value == "function" ? `(${key})="${formatPropInTemplate(key)}($event)"` : `[${key}]="${formatPropInTemplate(key)}"`
|
|
83
|
+
).join(" ");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
setProjectAnnotations,
|
|
88
|
+
__definePreview,
|
|
89
|
+
moduleMetadata,
|
|
90
|
+
applicationConfig,
|
|
91
|
+
componentWrapperDecorator,
|
|
92
|
+
argsToTemplate
|
|
93
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_w331jboqnti from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_w331jboqnti from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_w331jboqnti from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_w331jboqnti.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_w331jboqnti.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_w331jboqnti.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
|
+
// src/builders/utils/run-compodoc.ts
|
|
60
|
+
import { isAbsolute as isAbsolute2, relative } from "node:path";
|
|
61
|
+
import { JsPackageManagerFactory } from "storybook/internal/common";
|
|
62
|
+
import { prompt } from "storybook/internal/node-logger";
|
|
63
|
+
var hasTsConfigArg = (args) => args.indexOf("-p") !== -1, hasOutputArg = (args) => args.indexOf("-d") !== -1 || args.indexOf("--output") !== -1, toRelativePath = (pathToTsConfig) => isAbsolute2(pathToTsConfig) ? relative(".", pathToTsConfig) : pathToTsConfig, runCompodoc = async ({ compodocArgs, tsconfig }, context) => {
|
|
64
|
+
let tsConfigPath = toRelativePath(tsconfig), finalCompodocArgs = [
|
|
65
|
+
"compodoc",
|
|
66
|
+
...hasTsConfigArg(compodocArgs) ? [] : ["-p", tsConfigPath],
|
|
67
|
+
...hasOutputArg(compodocArgs) ? [] : ["-d", `${context.workspaceRoot || "."}`],
|
|
68
|
+
...compodocArgs
|
|
69
|
+
], packageManager = JsPackageManagerFactory.getPackageManager();
|
|
70
|
+
await prompt.executeTaskWithSpinner(
|
|
71
|
+
() => packageManager.runPackageCommand({
|
|
72
|
+
args: finalCompodocArgs,
|
|
73
|
+
cwd: context.workspaceRoot
|
|
74
|
+
}),
|
|
75
|
+
{
|
|
76
|
+
id: "compodoc",
|
|
77
|
+
intro: "Generating documentation with Compodoc",
|
|
78
|
+
success: "Compodoc finished successfully",
|
|
79
|
+
error: "Compodoc failed"
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
up2 as up,
|
|
86
|
+
up3 as up2,
|
|
87
|
+
printErrorDetails,
|
|
88
|
+
errorSummary,
|
|
89
|
+
runCompodoc
|
|
90
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_w331jboqnti from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_w331jboqnti from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_w331jboqnti from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_w331jboqnti.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_w331jboqnti.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_w331jboqnti.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
errorSummary,
|
|
14
|
+
printErrorDetails,
|
|
15
|
+
runCompodoc,
|
|
16
|
+
up,
|
|
17
|
+
up2
|
|
18
|
+
} from "../../_node-chunks/chunk-R2RNJVE7.js";
|
|
19
|
+
|
|
20
|
+
// src/builders/build-storybook/index.ts
|
|
21
|
+
import { readFileSync } from "node:fs";
|
|
22
|
+
import { getEnvConfig, getProjectRoot, versions } from "storybook/internal/common";
|
|
23
|
+
import { buildStaticStandalone, withTelemetry } from "storybook/internal/core-server";
|
|
24
|
+
import { addToGlobalContext } from "storybook/internal/telemetry";
|
|
25
|
+
import { logger, logTracker } from "storybook/internal/node-logger";
|
|
26
|
+
import { createBuilder, targetFromTargetString } from "@angular-devkit/architect";
|
|
27
|
+
import { Channel } from "storybook/internal/channels";
|
|
28
|
+
addToGlobalContext("cliVersion", versions.storybook);
|
|
29
|
+
var commandBuilder = async (options, context) => {
|
|
30
|
+
options.loglevel && logger.setLogLevel(options.loglevel), options.logfile && logTracker.enableLogWriting(), logger.intro("Building Storybook");
|
|
31
|
+
let { tsConfig } = await setup(options, context), docTSConfig = up("tsconfig.doc.json", {
|
|
32
|
+
cwd: options.configDir,
|
|
33
|
+
last: getProjectRoot()
|
|
34
|
+
});
|
|
35
|
+
options.compodoc && await runCompodoc(
|
|
36
|
+
{ compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig },
|
|
37
|
+
context
|
|
38
|
+
), getEnvConfig(options, {
|
|
39
|
+
staticDir: "SBCONFIG_STATIC_DIR",
|
|
40
|
+
outputDir: "SBCONFIG_OUTPUT_DIR",
|
|
41
|
+
configDir: "SBCONFIG_CONFIG_DIR"
|
|
42
|
+
});
|
|
43
|
+
let {
|
|
44
|
+
browserTarget,
|
|
45
|
+
stylePreprocessorOptions,
|
|
46
|
+
styles,
|
|
47
|
+
configDir,
|
|
48
|
+
docs,
|
|
49
|
+
loglevel,
|
|
50
|
+
test,
|
|
51
|
+
outputDir,
|
|
52
|
+
quiet,
|
|
53
|
+
enableProdMode = !0,
|
|
54
|
+
statsJson,
|
|
55
|
+
disableTelemetry,
|
|
56
|
+
assets,
|
|
57
|
+
previewUrl,
|
|
58
|
+
sourceMap = !1,
|
|
59
|
+
preserveSymlinks = !1,
|
|
60
|
+
zoneless = !0
|
|
61
|
+
} = options, packageJsonPath = up2({ cwd: __dirname }), standaloneOptions = {
|
|
62
|
+
packageJson: packageJsonPath != null ? JSON.parse(readFileSync(packageJsonPath, "utf8")) : null,
|
|
63
|
+
configDir,
|
|
64
|
+
...docs ? { docs } : {},
|
|
65
|
+
loglevel,
|
|
66
|
+
outputDir,
|
|
67
|
+
test,
|
|
68
|
+
quiet,
|
|
69
|
+
enableProdMode,
|
|
70
|
+
disableTelemetry,
|
|
71
|
+
angularBrowserTarget: browserTarget,
|
|
72
|
+
angularBuilderContext: context,
|
|
73
|
+
angularBuilderOptions: {
|
|
74
|
+
...stylePreprocessorOptions ? { stylePreprocessorOptions } : {},
|
|
75
|
+
...styles ? { styles } : {},
|
|
76
|
+
...assets ? { assets } : {},
|
|
77
|
+
sourceMap,
|
|
78
|
+
preserveSymlinks,
|
|
79
|
+
zoneless
|
|
80
|
+
},
|
|
81
|
+
tsConfig,
|
|
82
|
+
statsJson,
|
|
83
|
+
previewUrl
|
|
84
|
+
};
|
|
85
|
+
if (await runInstance({ ...standaloneOptions, mode: "static" }), logTracker.shouldWriteLogsToFile) {
|
|
86
|
+
let logFile = await logTracker.writeToFile(options.logfile);
|
|
87
|
+
logger.info(`Debug logs are written to: ${logFile}`);
|
|
88
|
+
}
|
|
89
|
+
return logger.outro("Storybook build completed successfully"), { success: !0 };
|
|
90
|
+
}, build_storybook_default = createBuilder(commandBuilder);
|
|
91
|
+
async function setup(options, context) {
|
|
92
|
+
let browserOptions, browserTarget;
|
|
93
|
+
return options.browserTarget && (browserTarget = targetFromTargetString(options.browserTarget), browserOptions = await context.validateOptions(
|
|
94
|
+
await context.getTargetOptions(browserTarget),
|
|
95
|
+
await context.getBuilderNameForTarget(browserTarget)
|
|
96
|
+
)), {
|
|
97
|
+
tsConfig: options.tsConfig ?? up("tsconfig.json", { cwd: options.configDir, last: getProjectRoot() }) ?? browserOptions.tsConfig
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async function runInstance(options) {
|
|
101
|
+
try {
|
|
102
|
+
await withTelemetry(
|
|
103
|
+
"build",
|
|
104
|
+
{
|
|
105
|
+
cliOptions: options,
|
|
106
|
+
presetOptions: {
|
|
107
|
+
...options,
|
|
108
|
+
corePresets: [],
|
|
109
|
+
overridePresets: [],
|
|
110
|
+
channel: new Channel({})
|
|
111
|
+
},
|
|
112
|
+
printError: printErrorDetails
|
|
113
|
+
},
|
|
114
|
+
async () => await buildStaticStandalone(options)
|
|
115
|
+
);
|
|
116
|
+
} catch (error) {
|
|
117
|
+
let summary = errorSummary(error);
|
|
118
|
+
throw new Error(summary);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
build_storybook_default as default
|
|
123
|
+
};
|