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

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/preset.js CHANGED
@@ -1,19 +1,20 @@
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";
1
+ import CJS_COMPAT_NODE_URL_8ni5g5ueuqs from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_8ni5g5ueuqs from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_8ni5g5ueuqs from "node:module";
4
4
 
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);
5
+ var __filename = CJS_COMPAT_NODE_URL_8ni5g5ueuqs.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_8ni5g5ueuqs.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_8ni5g5ueuqs.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
- ensureCompodocDocumentation,
14
- resolveCompodocConfig
15
- } from "./_node-chunks/chunk-77BJXJPD.js";
16
- import "./_node-chunks/chunk-RC6UIUJ4.js";
13
+ findTsconfigUp
14
+ } from "./_node-chunks/chunk-QNPJ2GGJ.js";
15
+ import {
16
+ parseStoryFile
17
+ } from "./_node-chunks/chunk-GWJVWZ3H.js";
17
18
 
18
19
  // src/preset.ts
19
20
  import { findConfigFile } from "storybook/internal/common";
@@ -24,36 +25,227 @@ import {
24
25
  getAutomockCode,
25
26
  getRealPath
26
27
  } from "storybook/internal/mocking-utils";
27
- import { readFileSync } from "node:fs";
28
- import { resolve } from "node:path";
28
+ import { logger as logger5 } from "storybook/internal/node-logger";
29
+ import { readFileSync as readFileSync3 } from "node:fs";
30
+ import { basename, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve4 } from "node:path";
29
31
  import { fileURLToPath as fileURLToPath2 } from "node:url";
30
32
 
33
+ // src/compodoc-config.ts
34
+ import { resolve } from "node:path";
35
+ var DEFAULT_COMPODOC_ARGS = ["-e", "json", "-d", "."], DOCUMENTATION_JSON = "documentation.json", readCompodocOutputDir = (compodocArgs) => {
36
+ for (let index = compodocArgs.length - 1; index >= 0; index--) {
37
+ let arg = compodocArgs[index];
38
+ if (arg.startsWith("--output="))
39
+ return arg.slice(9) || void 0;
40
+ if (arg === "-d" || arg === "--output") {
41
+ let value = compodocArgs[index + 1];
42
+ if (typeof value == "string" && !value.startsWith("-"))
43
+ return value;
44
+ }
45
+ }
46
+ }, resolveCompodocConfig = async (options, extra = {}) => {
47
+ let framework = await options?.presets?.apply("framework"), frameworkOptions = typeof framework == "string" ? {} : framework?.options ?? {}, workspaceRoot = options?.angularBuilderContext?.workspaceRoot ?? extra.viteRoot ?? // Mirrors what builder-vite does with Vite's root, which only `viteFinal` can pass along. Without
48
+ // it the docgen reader falls back to cwd and looks in a different directory than the writer.
49
+ (options?.configDir ? resolve(options.configDir, "..") : void 0) ?? process.cwd(), compodocArgs = frameworkOptions.compodocArgs ?? DEFAULT_COMPODOC_ARGS;
50
+ return {
51
+ /** `framework.options.compodoc`: `false` means the user opted out of Compodoc entirely. */
52
+ enabled: frameworkOptions.compodoc !== !1,
53
+ compodocArgs,
54
+ tsconfig: frameworkOptions.tsconfig ?? options?.tsConfig ?? options?.angularBuilderOptions?.tsConfig ?? // The same walk the builders use, so Compodoc is pointed at the tsconfig the Angular build
55
+ // would have picked rather than a different guess.
56
+ (options?.configDir ? findTsconfigUp(options.configDir) : void 0) ?? resolve(workspaceRoot, "tsconfig.json"),
57
+ /** Directory Compodoc runs in, and the base its relative `file` paths are written against. */
58
+ workspaceRoot,
59
+ /** Absolute directory Compodoc writes {@link DOCUMENTATION_JSON} into. */
60
+ outputDir: resolve(workspaceRoot, readCompodocOutputDir(compodocArgs) ?? ".")
61
+ };
62
+ };
63
+
64
+ // src/props-table.ts
65
+ import { deprecate, logger } from "storybook/internal/node-logger";
66
+ var MODES = ["all", "api", "inputs"], configuredMode = (frameworkOptions) => {
67
+ let configured = frameworkOptions?.propsTable;
68
+ return MODES.includes(configured) ? configured : void 0;
69
+ }, resolvePropsTable = (frameworkOptions, features2) => {
70
+ let deprecatedFlag = features2?.angularFilterNonInputControls, inherited = deprecatedFlag === void 0 ? void 0 : deprecatedFlag ? "inputs" : "all";
71
+ return configuredMode(frameworkOptions) ?? inherited ?? "api";
72
+ }, warnAboutPropsTable = (frameworkOptions, features2) => {
73
+ let raw = frameworkOptions?.propsTable, configured = configuredMode(frameworkOptions);
74
+ if (raw !== void 0 && configured === void 0 && logger.warn(
75
+ `Ignoring the unknown \`propsTable\` value ${JSON.stringify(raw)}; expected 'all', 'api' or 'inputs'.`
76
+ ), features2?.angularFilterNonInputControls !== void 0) {
77
+ let mode = resolvePropsTable(frameworkOptions, features2);
78
+ deprecate(
79
+ "The `angularFilterNonInputControls` feature is deprecated and will be removed in Storybook 11. " + (configured !== void 0 ? `The \`propsTable: '${mode}'\` framework option takes precedence over it, so the feature has no effect and can be removed.` : `Replace it with the \`propsTable: '${mode}'\` option on your \`@storybook/angular-vite\` framework.`)
80
+ );
81
+ }
82
+ configured === "api" && features2?.experimentalDocgenServer !== !0 && logger.warn(
83
+ "`propsTable: 'api'` needs the `experimentalDocgenServer` feature, which is off, so the props table keeps showing every member. Enable it with `features: { experimentalDocgenServer: true }`, or set `propsTable: 'all'` to say you want every member."
84
+ );
85
+ };
86
+
87
+ // src/compodoc/ensure-documentation.ts
88
+ import { withFileLock } from "storybook/internal/common";
89
+ import { logger as logger3 } from "storybook/internal/node-logger";
90
+ import { randomUUID } from "node:crypto";
91
+ import { readFileSync as readFileSync2, writeFileSync } from "node:fs";
92
+ import { join as join2 } from "node:path";
93
+
94
+ // src/compodoc/generate-documentation.ts
95
+ import { executeNodeCommand } from "storybook/internal/common";
96
+ import { logger as logger2 } from "storybook/internal/node-logger";
97
+ import {
98
+ existsSync,
99
+ mkdirSync,
100
+ mkdtempSync,
101
+ readFileSync,
102
+ readdirSync,
103
+ renameSync,
104
+ rmSync,
105
+ statSync
106
+ } from "node:fs";
107
+ import { createRequire } from "node:module";
108
+ import { dirname, isAbsolute, join, relative, resolve as resolve2 } from "node:path";
109
+ import { pathToFileURL } from "node:url";
110
+ var COMPODOC_TIMEOUT_MS = 600 * 1e3, OUTPUT_TAIL_BYTES = 4e3, SCRATCH_PREFIX = ".compodoc-", resolveCompodocCli = (workspaceRoot) => {
111
+ let searchFrom = [pathToFileURL(join(resolve2(workspaceRoot), "noop.js")).href, import.meta.url];
112
+ for (let from of searchFrom)
113
+ try {
114
+ let packageJsonPath = createRequire(from).resolve("@compodoc/compodoc/package.json"), { bin } = JSON.parse(readFileSync(packageJsonPath, "utf8")), entry = typeof bin == "string" ? bin : bin?.compodoc;
115
+ if (entry)
116
+ return join(dirname(packageJsonPath), entry);
117
+ } catch {
118
+ }
119
+ }, hasTsconfigArg = (args) => args.includes("-p"), toChildRelativePath = (path, cwd) => isAbsolute(path) ? relative(cwd, path) : path, runCli = async (cli, args, cwd, timeoutMs) => {
120
+ let result = await executeNodeCommand({
121
+ scriptPath: cli,
122
+ args,
123
+ options: {
124
+ cwd,
125
+ // Interleaved into one stream, so the failure message reads in the order Compodoc printed it.
126
+ all: !0,
127
+ encoding: "utf8",
128
+ // Failures come back as a result rather than a throw, so a timeout and a non-zero exit are
129
+ // told apart by inspecting one object.
130
+ reject: !1,
131
+ timeout: timeoutMs,
132
+ // Compodoc does not shut down promptly on SIGTERM, and a hung scan would otherwise keep the
133
+ // docgen worker waiting for it.
134
+ killSignal: "SIGKILL"
135
+ }
136
+ });
137
+ if (!result.failed)
138
+ return;
139
+ let output = String(result.all ?? "").trim().slice(-OUTPUT_TAIL_BYTES);
140
+ throw new Error(
141
+ result.timedOut ? `Compodoc did not finish within ${timeoutMs}ms.
142
+ ${output}` : `Compodoc exited with code ${result.exitCode}.
143
+ ${output}`
144
+ );
145
+ }, removeAbandonedScratchDirs = (outputDir, olderThanMs) => {
146
+ let cutoff = Date.now() - olderThanMs;
147
+ for (let entry of readdirSync(outputDir, { withFileTypes: !0 })) {
148
+ if (!entry.isDirectory() || !entry.name.startsWith(SCRATCH_PREFIX))
149
+ continue;
150
+ let path = join(outputDir, entry.name);
151
+ try {
152
+ statSync(path).mtimeMs < cutoff && rmSync(path, { recursive: !0, force: !0 });
153
+ } catch {
154
+ }
155
+ }
156
+ }, generateDocumentation = async ({
157
+ compodocArgs,
158
+ tsconfig,
159
+ workspaceRoot,
160
+ outputDir,
161
+ timeoutMs = COMPODOC_TIMEOUT_MS
162
+ }) => {
163
+ let cli = resolveCompodocCli(workspaceRoot);
164
+ if (!cli)
165
+ throw new Error(
166
+ "@compodoc/compodoc could not be resolved. Install it as a devDependency, or set framework.options.compodoc to false to turn Angular docgen off."
167
+ );
168
+ mkdirSync(outputDir, { recursive: !0 }), removeAbandonedScratchDirs(outputDir, timeoutMs);
169
+ let scratchDir = mkdtempSync(join(outputDir, SCRATCH_PREFIX)), startedAt = Date.now();
170
+ logger2.info("[storybook-angular-vite] Generating Angular documentation with Compodoc...");
171
+ try {
172
+ await runCli(
173
+ cli,
174
+ [
175
+ ...hasTsconfigArg(compodocArgs) ? [] : ["-p", toChildRelativePath(tsconfig, workspaceRoot)],
176
+ ...compodocArgs,
177
+ // Last occurrence wins on Compodoc's command line, so this overrides any `-d`/`--output` the
178
+ // user configured. Their directory is where the finished file lands, not where it is built.
179
+ "-d",
180
+ scratchDir
181
+ ],
182
+ workspaceRoot,
183
+ timeoutMs
184
+ );
185
+ let produced = join(scratchDir, DOCUMENTATION_JSON);
186
+ if (!existsSync(produced))
187
+ throw new Error(
188
+ `Compodoc finished without writing ${DOCUMENTATION_JSON}. Check that its arguments still export JSON: ${compodocArgs.join(" ")}`
189
+ );
190
+ renameSync(produced, join(outputDir, DOCUMENTATION_JSON)), logger2.debug(
191
+ `[storybook-angular-vite] generated ${DOCUMENTATION_JSON} in ${Date.now() - startedAt}ms`
192
+ );
193
+ } finally {
194
+ rmSync(scratchDir, { recursive: !0, force: !0 });
195
+ }
196
+ };
197
+
198
+ // src/compodoc/ensure-documentation.ts
199
+ var COMPODOC_LOCK = ".compodoc.lock", COMPODOC_RUN_MARKER = ".compodoc.run", RUN_ID_ENV = "STORYBOOK_COMPODOC_RUN_ID", currentRunId = () => process.env[RUN_ID_ENV] ??= randomUUID(), markerRunId = (markerPath) => {
200
+ try {
201
+ return readFileSync2(markerPath, "utf8").trim();
202
+ } catch {
203
+ return;
204
+ }
205
+ }, ensureCompodocDocumentation = async ({
206
+ compodocArgs,
207
+ tsconfig,
208
+ workspaceRoot,
209
+ outputDir,
210
+ waitBudgetMs
211
+ }) => {
212
+ let markerPath = join2(outputDir, COMPODOC_RUN_MARKER), runId = currentRunId();
213
+ if (markerRunId(markerPath) !== runId)
214
+ try {
215
+ await withFileLock(
216
+ join2(outputDir, COMPODOC_LOCK),
217
+ async () => {
218
+ markerRunId(markerPath) !== runId && (await generateDocumentation({ compodocArgs, tsconfig, workspaceRoot, outputDir }), writeFileSync(markerPath, runId));
219
+ },
220
+ { waitBudgetMs }
221
+ ) === "busy" && logger3.debug(
222
+ `[storybook-angular-vite] another process is still generating ${DOCUMENTATION_JSON}; continuing with what is on disk`
223
+ );
224
+ } catch (error) {
225
+ logger3.warn(
226
+ `[storybook-angular-vite] Compodoc generation failed: ${error instanceof Error ? error.message : String(error)}`
227
+ );
228
+ }
229
+ };
230
+
31
231
  // src/docgen/preset.ts
32
232
  import { fileURLToPath } from "node:url";
33
233
  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)
234
+ let features2 = await options?.presets?.apply("features", {});
235
+ if (!features2?.experimentalDocgenServer)
39
236
  return existing;
40
237
  let descriptor = {
41
238
  moduleSpecifier: fileURLToPath(
42
239
  import.meta.resolve("@storybook/angular-vite/internal/docgen-worker")
43
240
  ),
44
- // Structured-cloned onto the worker thread: plain JSON only, no closures or class instances.
45
241
  options: {
46
- outputDir: compodocConfig.outputDir,
47
- compodocArgs: compodocConfig.compodocArgs,
48
- workspaceRoot: compodocConfig.workspaceRoot,
49
- angularFilterNonInputControls: features?.angularFilterNonInputControls,
50
- tsconfig: compodocConfig.tsconfig
242
+ propsTable: resolvePropsTable(await options?.presets?.apply("frameworkOptions"), features2)
51
243
  }
52
244
  };
53
245
  return [...existing, descriptor];
54
246
  }, experimental_manifests = async (existingManifests = {}, options) => {
55
- let features = await options?.presets?.apply("features", {});
56
- if (!features?.experimentalDocgenServer || !features?.componentsManifest)
247
+ let features2 = await options?.presets?.apply("features", {});
248
+ if (!features2?.experimentalDocgenServer || !features2?.componentsManifest)
57
249
  return existingManifests;
58
250
  let existingComponents = existingManifests.components;
59
251
  return {
@@ -61,13 +253,791 @@ var experimental_docgenProvider = async (existing = [], options) => {
61
253
  components: {
62
254
  v: existingComponents?.v ?? 0,
63
255
  components: existingComponents?.components ?? {},
64
- meta: { docgen: "compodoc", durationMs: 0 }
256
+ meta: { docgen: "angular-component-meta", durationMs: 0 }
257
+ }
258
+ };
259
+ };
260
+
261
+ // src/docgen/story-docs-preset.ts
262
+ import { STORY_FILE_TEST_REGEXP, getStoryImportPathFromEntry as getStoryImportPathFromEntry2 } from "storybook/internal/common";
263
+ import { getService } from "storybook/internal/core-server";
264
+ import { logger as logger4 } from "storybook/internal/node-logger";
265
+
266
+ // src/docgen/story-docs-build.ts
267
+ import { types as t5 } from "storybook/internal/babel";
268
+ import { getComponentIdFromEntry, getStoryImportPathFromEntry } from "storybook/internal/common";
269
+ import { storyNameFromExport } from "storybook/internal/csf";
270
+ import {
271
+ buildImportStatements as buildImportStatements2,
272
+ collectImportBindings,
273
+ createStoryArgsResolver,
274
+ createStoryReferenceResolver,
275
+ extractStoryJSDocInfo,
276
+ isSelfContained,
277
+ parseReferenceModule,
278
+ resolveComponentImport as resolveComponentImport2,
279
+ unresolvedWarning,
280
+ unwrapExpression as unwrapExpression5
281
+ } from "storybook/internal/csf-tools";
282
+ import { resolve as resolve3 } from "node:path";
283
+
284
+ // src/docgen/story-docs-args.ts
285
+ import { babelPrint, types as t } from "storybook/internal/babel";
286
+ import { keyOf, unwrapExpression } from "storybook/internal/csf-tools";
287
+
288
+ // src/template-grammar.ts
289
+ var isValidIdentifier = (name) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name), formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? propertyName : `this['${propertyName}']`;
290
+ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
291
+ "area",
292
+ "base",
293
+ "br",
294
+ "col",
295
+ "command",
296
+ "embed",
297
+ "hr",
298
+ "img",
299
+ "input",
300
+ "keygen",
301
+ "link",
302
+ "meta",
303
+ "param",
304
+ "source",
305
+ "track",
306
+ "wbr"
307
+ ]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/, MAX_SINGLE_LINE = 80, buildTemplate = (selector, { inputs, outputs, innerTemplate = "", selfClosing = !1 }) => {
308
+ let bindings = [
309
+ ...inputs.map(({ name, expression }) => `[${name}]="${expression}"`),
310
+ ...outputs.map((name) => `(${name})="${formatPropInTemplate(name)}($event)"`)
311
+ ], firstSelector = selector.split(",")[0];
312
+ return (LEADING_CLASS.test(firstSelector) || LEADING_ATTRIBUTE.test(firstSelector) ? `div${firstSelector}` : firstSelector).replace(ID, ' id="$1"').replace(CLASS_RUN, (classes) => ` class="${classes.split(".").join(" ").trim()}"`).replace(ATTRIBUTE, " $1").replace(ELEMENT_AND_ATTRIBUTES, (_, element, attributes) => {
313
+ let closesItself = VOID_ELEMENTS.has(element) || selfClosing && element.includes("-") && innerTemplate === "", inlineTag = `<${element}${attributes}${bindings.map((binding) => ` ${binding}`).join("")}`, inline = closesItself ? `${inlineTag} />` : `${inlineTag}>${innerTemplate}</${element}>`;
314
+ if (inline.length <= MAX_SINGLE_LINE || bindings.length === 0)
315
+ return inline;
316
+ let brokenTag = `<${element}${attributes}
317
+ ${bindings.map((binding) => ` ${binding}`).join(`
318
+ `)}`;
319
+ if (closesItself)
320
+ return selfClosing ? `${brokenTag}
321
+ />` : `${brokenTag} />`;
322
+ let content = innerTemplate === "" ? `
323
+ ` : `
324
+ ${innerTemplate}
325
+ `;
326
+ return `${brokenTag}>${content}</${element}>`;
327
+ });
328
+ }, buildComponentOutletTemplate = (componentName, { selfClosing = !1 } = {}) => selfClosing ? `<ng-container *ngComponentOutlet="${componentName}" />` : `<ng-container *ngComponentOutlet="${componentName}"></ng-container>`, INDENT = " ", MARKUP_TAG = /<(\/?)([A-Za-z][\w-]*)((?:"[^"]*"|'[^']*'|[^>"'])*)>/g, parseMarkup = (markup) => {
329
+ let root = {
330
+ tag: "",
331
+ rawOpen: "",
332
+ attrText: "",
333
+ closed: !1,
334
+ start: 0,
335
+ end: 0,
336
+ children: []
337
+ }, stack = [root], lastIndex = 0;
338
+ for (let match of markup.matchAll(MARKUP_TAG)) {
339
+ let text = markup.slice(lastIndex, match.index).trim();
340
+ text && stack.at(-1).children.push(text), lastIndex = match.index + match[0].length;
341
+ let [rawOpen, closing, tag, rawAttrText] = match;
342
+ if (closing) {
343
+ let open = stack.pop();
344
+ if (!open || open.tag !== tag || stack.length === 0)
345
+ return;
346
+ open.end = lastIndex;
347
+ continue;
348
+ }
349
+ let selfClosing = rawAttrText.trimEnd().endsWith("/"), attrText = selfClosing ? rawAttrText.trimEnd().slice(0, -1) : rawAttrText, element = {
350
+ tag,
351
+ rawOpen,
352
+ attrText: attrText.trimEnd(),
353
+ closed: selfClosing || VOID_ELEMENTS.has(tag),
354
+ start: match.index,
355
+ end: lastIndex,
356
+ children: []
357
+ };
358
+ stack.at(-1).children.push(element), element.closed || stack.push(element);
359
+ }
360
+ let trailing = markup.slice(lastIndex).trim();
361
+ return trailing && stack.at(-1).children.push(trailing), stack.length === 1 ? root.children : void 0;
362
+ }, MARKUP_ATTRIBUTE = /[^\s=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|\S+))?/g, openTagLines = (node, pad, forceAttrBreak) => {
363
+ let inlineOpen = `${pad}${node.rawOpen}`, attrs = node.attrText.match(MARKUP_ATTRIBUTE) ?? [];
364
+ if (inlineOpen.length <= MAX_SINGLE_LINE && !forceAttrBreak || attrs.length === 0)
365
+ return [inlineOpen];
366
+ let bracket = node.closed ? " />" : ">";
367
+ return [
368
+ `${pad}<${node.tag}`,
369
+ ...attrs.map(
370
+ (attr, index) => `${pad}${INDENT}${attr}${index === attrs.length - 1 ? bracket : ""}`
371
+ )
372
+ ];
373
+ }, printMarkup = (markup, node, depth) => {
374
+ let pad = INDENT.repeat(depth);
375
+ if (typeof node == "string")
376
+ return [`${pad}${node}`];
377
+ let hasElementChild = node.children.some((child) => typeof child != "string"), verbatim = markup.slice(node.start, node.end);
378
+ if (!hasElementChild && pad.length + verbatim.length <= MAX_SINGLE_LINE)
379
+ return [`${pad}${verbatim}`];
380
+ let openLines = openTagLines(node, pad, !hasElementChild);
381
+ return node.closed ? openLines : [
382
+ ...openLines,
383
+ ...node.children.flatMap((child) => printMarkup(markup, child, depth + 1)),
384
+ `${pad}</${node.tag}>`
385
+ ];
386
+ }, formatTemplateMarkup = (markup) => {
387
+ let children = parseMarkup(markup);
388
+ return !children || children.length === 0 ? markup : children.flatMap((child) => printMarkup(markup, child, 0)).join(`
389
+ `);
390
+ };
391
+
392
+ // src/docgen/story-docs-args.ts
393
+ var EVAL_FAILED = /* @__PURE__ */ Symbol("story-docs-eval-failed"), createArgExternalizer = (enums) => (node) => {
394
+ let value = evaluateNode(node, enums);
395
+ return value === EVAL_FAILED ? void 0 : t.valueToNode(value);
396
+ }, evaluateArgExpression = (node, enums) => {
397
+ let literal = evaluateArgLiteral(node, enums);
398
+ return escapeAttributeExpression(literal ?? printArgSource(unwrapExpression(node)));
399
+ }, evaluateArgLiteral = (node, enums) => {
400
+ let value = evaluateNode(unwrapExpression(node), enums);
401
+ return value === EVAL_FAILED ? void 0 : printExpressionValue(value, /* @__PURE__ */ new Set());
402
+ }, printArgSource = (node) => babelPrint(t.cloneNode(node, !0)), 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(
403
+ ([key, entryValue]) => `${isValidIdentifier(key) ? key : quoteExpressionString(key)}: ${printExpressionValue(entryValue, seen)}`
404
+ ).join(", ")}}`), escapeAttributeExpression = (expression) => expression.replace(/&(?=#|\w+;)/g, "&amp;").replace(/"/g, "&quot;"), evaluateNode = (node, enums) => {
405
+ let unwrapped = unwrapExpression(node);
406
+ if (t.isStringLiteral(unwrapped) || t.isNumericLiteral(unwrapped) || t.isBooleanLiteral(unwrapped))
407
+ return unwrapped.value;
408
+ if (t.isNullLiteral(unwrapped))
409
+ return null;
410
+ if (!(t.isIdentifier(unwrapped) && unwrapped.name === "undefined") && !(t.isUnaryExpression(unwrapped) && unwrapped.operator === "void")) {
411
+ if (t.isUnaryExpression(unwrapped) && unwrapped.operator === "-" && t.isNumericLiteral(unwrapped.argument))
412
+ return -unwrapped.argument.value;
413
+ if (t.isTemplateLiteral(unwrapped) && unwrapped.expressions.length === 0)
414
+ return unwrapped.quasis[0]?.value.cooked ?? EVAL_FAILED;
415
+ if (t.isArrayExpression(unwrapped)) {
416
+ let values = [];
417
+ for (let element of unwrapped.elements) {
418
+ if (element === null || t.isSpreadElement(element))
419
+ return EVAL_FAILED;
420
+ let value = evaluateNode(element, enums);
421
+ if (value === EVAL_FAILED)
422
+ return EVAL_FAILED;
423
+ values.push(value);
424
+ }
425
+ return values;
426
+ }
427
+ if (t.isObjectExpression(unwrapped)) {
428
+ let value = {};
429
+ for (let property of unwrapped.properties) {
430
+ if (!t.isObjectProperty(property))
431
+ return EVAL_FAILED;
432
+ let key = keyOf(property);
433
+ if (key === null)
434
+ return EVAL_FAILED;
435
+ let propertyValue = evaluateNode(property.value, enums);
436
+ if (propertyValue === EVAL_FAILED)
437
+ return EVAL_FAILED;
438
+ value[key] = propertyValue;
439
+ }
440
+ return value;
441
+ }
442
+ if (t.isMemberExpression(unwrapped) && !unwrapped.computed && t.isIdentifier(unwrapped.object) && t.isIdentifier(unwrapped.property)) {
443
+ let objectName = unwrapped.object.name, propertyName = unwrapped.property.name;
444
+ return enums.find((enumeration) => enumeration.name === objectName)?.members.find((candidate) => candidate.name === propertyName)?.value ?? EVAL_FAILED;
445
+ }
446
+ return EVAL_FAILED;
447
+ }
448
+ };
449
+
450
+ // src/docgen/story-docs-markup.ts
451
+ import { types as t2 } from "storybook/internal/babel";
452
+ import {
453
+ isCanonicalCsf2BindCall,
454
+ isCsfFactoryCall,
455
+ sourceOf,
456
+ unwrapExpression as unwrapExpression2
457
+ } from "storybook/internal/csf-tools";
458
+ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
459
+ let allowed = (name) => filter.include ? filter.include.includes(name) : !filter.exclude?.includes(name), representedInputs = inputs.filter(({ name }) => allowed(name)), representedOutputs = outputs.filter(allowed);
460
+ return representedInputs.forEach(({ name }) => representedArgs.add(name)), representedOutputs.forEach((name) => representedArgs.add(name)), {
461
+ inputAttributes: representedInputs.map(({ name, expression }) => `[${name}]="${expression}"`),
462
+ outputAttributes: representedOutputs.map((name) => ({
463
+ name,
464
+ markup: `(${name})="${formatPropInTemplate(name)}($event)"`
465
+ }))
466
+ };
467
+ }, NO_SCOPE = {
468
+ argBindings: /* @__PURE__ */ new Map(),
469
+ parameterNames: /* @__PURE__ */ new Set(),
470
+ bodyDeclared: /* @__PURE__ */ new Set(),
471
+ argsExpansions: /* @__PURE__ */ new Map()
472
+ }, userTemplate = (shape, bindings) => {
473
+ let own = shapeTemplate(shape.members, shape, bindings);
474
+ if (own)
475
+ return own;
476
+ let csf2 = csf2Shape(shape);
477
+ if (csf2) {
478
+ let templateProperty = resolvedProperty(csf2.returned, "template");
479
+ if (templateProperty.kind === "unresolvable")
480
+ return { kind: "unresolvable", source: sourceOf(csf2.returned) };
481
+ let fromCsf2 = templateFrom(
482
+ templateProperty.kind === "value" ? templateProperty.node : void 0,
483
+ shape,
484
+ bindings,
485
+ functionScope(csf2.fn)
486
+ );
487
+ if (fromCsf2)
488
+ return fromCsf2;
489
+ }
490
+ return shapeTemplate(shape.metaMembers, shape, bindings);
491
+ }, shapeTemplate = (members, shape, bindings) => {
492
+ let template = resolvedMember(members, "template");
493
+ if (template.kind === "unresolvable")
494
+ return { kind: "unresolvable", ...template.node ? { source: sourceOf(template.node) } : {} };
495
+ if (template.kind === "value") {
496
+ let own = templateFrom(declaredValue(shape, template.node), shape, bindings, NO_SCOPE);
497
+ if (own)
498
+ return own;
499
+ }
500
+ let render = resolvedMember(members, "render");
501
+ if (render.kind === "missing")
502
+ return;
503
+ if (render.kind === "unresolvable")
504
+ return { kind: "unresolvable", ...render.node ? { source: sourceOf(render.node) } : {} };
505
+ let fn = declaredValue(shape, render.node), returned = returnedObject(fn);
506
+ if (!returned)
507
+ return { kind: "unresolvable", source: `render: ${sourceOf(render.node)}` };
508
+ let templateProperty = resolvedProperty(returned, "template");
509
+ return templateProperty.kind === "unresolvable" ? { kind: "unresolvable", source: `render: ${sourceOf(render.node)}` } : templateFrom(
510
+ templateProperty.kind === "value" ? templateProperty.node : void 0,
511
+ shape,
512
+ bindings,
513
+ functionScope(fn)
514
+ );
515
+ }, templateFrom = (node, shape, bindings, scope) => {
516
+ if (node === void 0 || t2.isNullLiteral(node) || t2.isIdentifier(node) && node.name === "undefined")
517
+ return;
518
+ if (t2.isStringLiteral(node))
519
+ return literalTemplate(node.value, /* @__PURE__ */ new Set(), []);
520
+ let parts = templateParts(node);
521
+ if (parts) {
522
+ let representedArgs = /* @__PURE__ */ new Set(), expansions = [], markup = interpolate(parts, shape, bindings, scope, representedArgs, expansions);
523
+ return markup === void 0 ? { kind: "unresolvable", source: sourceOf(node) } : literalTemplate(markup, representedArgs, expansions);
524
+ }
525
+ return { kind: "unresolvable", source: sourceOf(node) };
526
+ }, literalTemplate = (markup, representedArgs, expansions) => ({
527
+ kind: "literal",
528
+ markup,
529
+ representedArgs: [...representedArgs],
530
+ expansions
531
+ }), templateParts = (node) => {
532
+ if (t2.isTemplateLiteral(node))
533
+ return {
534
+ quasis: node.quasis.map((quasi) => quasi.value.cooked ?? ""),
535
+ expressions: node.expressions
536
+ };
537
+ if (!(!t2.isTaggedTemplateExpression(node) || !isStringRawTag(node.tag)))
538
+ return {
539
+ quasis: node.quasi.quasis.map((quasi) => quasi.value.raw),
540
+ expressions: node.quasi.expressions
541
+ };
542
+ }, isStringRawTag = (tag) => t2.isMemberExpression(tag) && !tag.computed && t2.isIdentifier(tag.object, { name: "String" }) && t2.isIdentifier(tag.property, { name: "raw" }), interpolate = ({ quasis, expressions }, shape, bindings, scope, representedArgs, expansions) => {
543
+ let markup = quasis[0] ?? "";
544
+ for (let [index, expression] of expressions.entries()) {
545
+ let marker = `data-storybook-args-to-template-${index}`;
546
+ for (; markup.includes(marker) || quasis.some((quasi) => quasi.includes(marker)); )
547
+ marker += "-x";
548
+ let substituted = substituteExpression(
549
+ expression,
550
+ shape,
551
+ bindings,
552
+ scope,
553
+ representedArgs,
554
+ marker,
555
+ expansions
556
+ );
557
+ if (substituted === void 0)
558
+ return;
559
+ markup += substituted + (quasis[index + 1] ?? "");
560
+ }
561
+ return markup;
562
+ }, substituteExpression = (expression, shape, bindings, scope, representedArgs, marker, expansions) => {
563
+ if (t2.isCallExpression(expression) && isImportedArgsToTemplate(expression, shape)) {
564
+ let argument = expression.arguments[0], excluded = t2.isIdentifier(argument) ? scope.argsExpansions.get(argument.name) : void 0;
565
+ if (!bindings || excluded === void 0)
566
+ return;
567
+ let filter = bindingFilterOf(expression.arguments[1]);
568
+ if (filter === void 0)
569
+ return;
570
+ let withRest = { ...filter, exclude: [...filter.exclude ?? [], ...excluded] }, allowed = filter.include ? { ...withRest, include: filter.include.filter((name) => !excluded.includes(name)) } : withRest;
571
+ return expansions.push({ marker, ...bindingAttributes(bindings, allowed, representedArgs) }), marker;
572
+ }
573
+ if (!t2.isIdentifier(expression))
574
+ return;
575
+ let argName = scope.argBindings.get(expression.name);
576
+ if (argName !== void 0) {
577
+ let text = shape.unresolvedArgs.length === 0 ? literalText(shape.args[argName]) : void 0;
578
+ return text !== void 0 && representedArgs.add(argName), text;
579
+ }
580
+ if (scope.parameterNames.has(expression.name) || scope.bodyDeclared.has(expression.name))
581
+ return;
582
+ let declared = declaredValue(shape, expression);
583
+ return declared === expression ? void 0 : literalText(declared);
584
+ }, ARGS_TO_TEMPLATE_MODULES = /* @__PURE__ */ new Set(["@storybook/angular", "@storybook/angular-vite"]), isImportedArgsToTemplate = (call, shape) => {
585
+ if (!t2.isIdentifier(call.callee))
586
+ return !1;
587
+ let binding = shape.csf._file.path.scope.getBinding(call.callee.name);
588
+ if (!binding?.referencePaths.some((path) => path.node === call.callee))
589
+ return !1;
590
+ let specifier = binding?.path.node, declaration = binding?.path.findParent((path) => t2.isImportDeclaration(path.node))?.node;
591
+ 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);
592
+ }, bindingFilterOf = (options) => {
593
+ if (options === void 0)
594
+ return {};
595
+ let unwrapped = unwrapExpression2(options);
596
+ if (!t2.isObjectExpression(unwrapped) || unwrapped.properties.some(t2.isSpreadElement))
597
+ return;
598
+ let filter = {};
599
+ for (let key of ["include", "exclude"]) {
600
+ let node = resolvedProperty(unwrapped, key);
601
+ if (node.kind === "unresolvable")
602
+ return;
603
+ if (node.kind === "value") {
604
+ let names = stringArray(node.node);
605
+ if (names === void 0)
606
+ return;
607
+ filter[key] = names;
608
+ }
609
+ }
610
+ return filter;
611
+ }, stringArray = (node) => t2.isArrayExpression(node) && node.elements.every((element) => t2.isStringLiteral(element)) ? node.elements.map((element) => element.value) : void 0, literalText = (node) => {
612
+ let unwrapped = node && unwrapExpression2(node);
613
+ return t2.isStringLiteral(unwrapped) ? unwrapped.value : t2.isNumericLiteral(unwrapped) || t2.isBooleanLiteral(unwrapped) ? String(unwrapped.value) : void 0;
614
+ }, resolvedMember = (members, key) => {
615
+ let node = members.properties[key];
616
+ return node !== void 0 ? members.shadowed.includes(key) ? { kind: "unresolvable", node } : { kind: "value", node } : members.unresolved.length > 0 ? { kind: "unresolvable" } : { kind: "missing" };
617
+ }, resolvedProperty = (object, key) => {
618
+ let found, opaqueAfter;
619
+ return object.properties.forEach((property) => {
620
+ let isMember = t2.isObjectProperty(property) || t2.isObjectMethod(property);
621
+ if (isMember && keyNameOf(property) === key) {
622
+ found = property, opaqueAfter = void 0;
623
+ return;
624
+ }
625
+ (t2.isSpreadElement(property) || isMember && keyNameOf(property) === void 0) && (opaqueAfter = property);
626
+ }), found ? opaqueAfter ? { kind: "unresolvable", node: opaqueAfter } : t2.isObjectMethod(found) ? found.kind === "method" && !found.generator ? { kind: "value", node: found } : { kind: "unresolvable", node: found } : { kind: "value", node: found.value } : opaqueAfter ? { kind: "unresolvable", node: opaqueAfter } : { kind: "missing" };
627
+ }, keyNameOf = (property) => t2.isIdentifier(property.key) && !property.computed ? property.key.name : t2.isStringLiteral(property.key) ? property.key.value : void 0;
628
+ var returnedObject = (fn) => {
629
+ let isPlainMethod = t2.isObjectMethod(fn) && fn.kind === "method" && !fn.generator;
630
+ if (!t2.isArrowFunctionExpression(fn) && !t2.isFunctionExpression(fn) && !t2.isFunctionDeclaration(fn) && !isPlainMethod)
631
+ return;
632
+ if (!t2.isBlockStatement(fn.body)) {
633
+ let unwrapped2 = unwrapExpression2(fn.body);
634
+ return t2.isObjectExpression(unwrapped2) ? unwrapped2 : void 0;
635
+ }
636
+ let statements = fn.body.body, last = statements.at(-1);
637
+ if (!t2.isReturnStatement(last) || !last.argument || !statements.slice(0, -1).every((statement) => t2.isVariableDeclaration(statement) || t2.isExpressionStatement(statement)))
638
+ return;
639
+ let unwrapped = unwrapExpression2(last.argument);
640
+ return t2.isObjectExpression(unwrapped) ? unwrapped : void 0;
641
+ }, csf2Shape = (shape) => {
642
+ let declared = shape.csf._storyExports[shape.exportName], candidates = t2.isVariableDeclarator(declared) ? [declared.init] : (
643
+ // `export { S }` records no declarator; the statement is the initializer it resolved to.
644
+ [declared, shape.csf._storyStatements[shape.exportName]]
645
+ );
646
+ for (let candidate of candidates) {
647
+ let fn = candidate ? unwrapExpression2(candidate) : void 0;
648
+ fn && isCanonicalCsf2BindCall(fn) && (fn = declaredValue(shape, fn.callee.object));
649
+ let returned = returnedObject(fn);
650
+ if (fn && returned)
651
+ return { fn, returned };
652
+ }
653
+ }, functionScope = (fn) => {
654
+ if (!t2.isArrowFunctionExpression(fn) && !t2.isFunctionExpression(fn) && !t2.isFunctionDeclaration(fn) && !t2.isObjectMethod(fn))
655
+ return NO_SCOPE;
656
+ let [firstParam] = fn.params, argsPattern = t2.isAssignmentPattern(firstParam) ? firstParam.left : firstParam, parameterNames = /* @__PURE__ */ new Set();
657
+ fn.params.forEach((param) => collectPatternNames(param, parameterNames));
658
+ let argBindings = /* @__PURE__ */ new Map();
659
+ if (t2.isObjectPattern(argsPattern))
660
+ for (let property of argsPattern.properties) {
661
+ if (!t2.isObjectProperty(property) || property.computed)
662
+ continue;
663
+ let argName = keyNameOf(property), local = t2.isAssignmentPattern(property.value) ? property.value.left : property.value;
664
+ argName !== void 0 && t2.isIdentifier(local) && argBindings.set(local.name, argName);
65
665
  }
666
+ let bodyDeclared = /* @__PURE__ */ new Set();
667
+ if (t2.isBlockStatement(fn.body)) {
668
+ for (let statement of fn.body.body)
669
+ if (t2.isVariableDeclaration(statement))
670
+ for (let declarator of statement.declarations)
671
+ collectPatternNames(declarator.id, bodyDeclared);
672
+ }
673
+ let argsExpansions = /* @__PURE__ */ new Map();
674
+ if (t2.isIdentifier(argsPattern))
675
+ argsExpansions.set(argsPattern.name, []);
676
+ else if (t2.isObjectPattern(argsPattern)) {
677
+ let destructured = [], rest, knownKeys = !0;
678
+ for (let property of argsPattern.properties)
679
+ if (t2.isRestElement(property) && t2.isIdentifier(property.argument))
680
+ rest = property.argument.name;
681
+ else if (t2.isObjectProperty(property)) {
682
+ let key = property.computed ? void 0 : keyNameOf(property);
683
+ key !== void 0 ? destructured.push(key) : knownKeys = !1;
684
+ }
685
+ rest !== void 0 && knownKeys && argsExpansions.set(rest, destructured);
686
+ }
687
+ return { argBindings, parameterNames, bodyDeclared, argsExpansions };
688
+ }, collectPatternNames = (pattern, into) => {
689
+ if (t2.isIdentifier(pattern))
690
+ into.add(pattern.name);
691
+ else if (t2.isObjectPattern(pattern))
692
+ for (let property of pattern.properties)
693
+ collectPatternNames(t2.isRestElement(property) ? property.argument : property.value, into);
694
+ else t2.isArrayPattern(pattern) ? pattern.elements.forEach((element) => element && collectPatternNames(element, into)) : t2.isAssignmentPattern(pattern) ? collectPatternNames(pattern.left, into) : t2.isRestElement(pattern) && collectPatternNames(pattern.argument, into);
695
+ }, declaredValue = (shape, node) => {
696
+ if (!t2.isIdentifier(node))
697
+ return node;
698
+ let binding = shape.csf._file.path.scope.getBinding(node.name);
699
+ if (!binding?.constant)
700
+ return node;
701
+ let declaration = binding.path.node;
702
+ return t2.isVariableDeclarator(declaration) ? declaration.init ?? node : t2.isFunctionDeclaration(declaration) ? declaration : node;
703
+ };
704
+
705
+ // src/docgen/story-docs-ng-modules.ts
706
+ import { types as t3 } from "storybook/internal/babel";
707
+ import {
708
+ buildImportStatements,
709
+ keyOf as keyOf2,
710
+ resolveComponentImport,
711
+ unwrapExpression as unwrapExpression3
712
+ } from "storybook/internal/csf-tools";
713
+ var ngModulesFromDecorators = (decorators, componentName) => {
714
+ let result = { names: [], declaresComponent: !1 }, list = decorators === void 0 ? void 0 : unwrapExpression3(decorators);
715
+ if (!list || !t3.isArrayExpression(list))
716
+ return result;
717
+ for (let element of list.elements) {
718
+ if (!element || t3.isSpreadElement(element))
719
+ continue;
720
+ let call = unwrapExpression3(element);
721
+ if (!t3.isCallExpression(call) || !t3.isIdentifier(call.callee, { name: "moduleMetadata" }))
722
+ continue;
723
+ let [metadataArg] = call.arguments, metadata = metadataArg && t3.isExpression(metadataArg) ? unwrapExpression3(metadataArg) : void 0;
724
+ if (!(!metadata || !t3.isObjectExpression(metadata)))
725
+ for (let property of metadata.properties) {
726
+ if (!t3.isObjectProperty(property) || !t3.isExpression(property.value))
727
+ continue;
728
+ let key = keyOf2(property), value = unwrapExpression3(property.value);
729
+ if (!(key !== "imports" && key !== "declarations" || !t3.isArrayExpression(value)))
730
+ for (let item of value.elements) {
731
+ if (!item || t3.isSpreadElement(item))
732
+ continue;
733
+ let entry = unwrapExpression3(item);
734
+ t3.isIdentifier(entry) && (key === "imports" ? entry.name !== componentName && !result.names.includes(entry.name) && result.names.push(entry.name) : entry.name === componentName && (result.declaresComponent = !0));
735
+ }
736
+ }
737
+ }
738
+ return result;
739
+ }, storyNgModules = (storyDecorators, { metaNgModules, componentName, importBindings }) => {
740
+ let story = ngModulesFromDecorators(storyDecorators, componentName);
741
+ if (metaNgModules.declaresComponent || story.declaresComponent)
742
+ return;
743
+ let refs = [.../* @__PURE__ */ new Set([...metaNgModules.names, ...story.names])].map((name) => resolveComponentImport(name, importBindings)).filter((ref) => ref.importId);
744
+ if (refs.length !== 0)
745
+ return {
746
+ names: refs.map((ref) => ref.componentName),
747
+ importStatements: buildImportStatements({ refs })
748
+ };
749
+ };
750
+
751
+ // src/docgen/story-docs-snippet.ts
752
+ var HOST_SELECTOR = "app-demo", HOST_CLASS = "DemoComponent", escapeTemplateLiteral = (template) => template.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
753
+ var memberName = (name) => isValidIdentifier(name) ? name : `['${name}']`, embedTemplate = (template) => template.includes(`
754
+ `) ? `
755
+ ${template.split(`
756
+ `).map((line) => line === "" ? line : ` ${line}`).join(`
757
+ `)}` : template, buildHostComponentSnippet = ({
758
+ template,
759
+ componentName,
760
+ componentImport,
761
+ viaComponentOutlet,
762
+ standalone,
763
+ ngModules,
764
+ outputs,
765
+ fields = []
766
+ }) => {
767
+ let importable = viaComponentOutlet || standalone, moduleNames = viaComponentOutlet ? [] : ngModules?.names ?? [], imports = [
768
+ ...viaComponentOutlet ? ["import { NgComponentOutlet } from '@angular/common';"] : [],
769
+ "import { Component } from '@angular/core';",
770
+ ...componentImport && importable ? [componentImport] : [],
771
+ ...moduleNames.length > 0 ? ngModules?.importStatements ?? [] : []
772
+ ], declared = viaComponentOutlet ? "NgComponentOutlet" : [...standalone ? [componentName] : [], ...moduleNames].join(", "), members = [
773
+ ...viaComponentOutlet ? [` protected readonly ${componentName} = ${componentName};`] : [],
774
+ ...fields.map(({ name, value }) => ` ${memberName(name)} = ${value};`),
775
+ ...outputs.map((name) => ` ${memberName(name)}(event: unknown) {}`)
776
+ ], body = members.length > 0 ? `{
777
+ ${members.join(`
778
+ `)}
779
+ }` : "{}", snippet = [
780
+ imports.join(`
781
+ `),
782
+ "",
783
+ "@Component({",
784
+ ` selector: '${HOST_SELECTOR}',`,
785
+ ` imports: [${declared}],`,
786
+ ` template: \`${embedTemplate(escapeTemplateLiteral(template))}\`,`,
787
+ "})",
788
+ `export class ${HOST_CLASS} ${body}`
789
+ ].join(`
790
+ `), warning = !importable && moduleNames.length === 0 ? `${componentName} is declared with \`standalone: false\`, so it cannot be listed in the host component's \`imports\`. Add the NgModule that declares and exports ${componentName} to \`imports\` to make this snippet compile.` : importable && componentImport === void 0 ? `${componentName} is declared in the story file, so the snippet references it without importing it.` : void 0;
791
+ return warning === void 0 ? { snippet } : { snippet, warning };
792
+ };
793
+
794
+ // src/docgen/story-docs-source.ts
795
+ import { types as t4 } from "storybook/internal/babel";
796
+ import {
797
+ resolveArgValue,
798
+ resolveObjectMembers,
799
+ sourceOf as sourceOf2,
800
+ unwrapExpression as unwrapExpression4
801
+ } from "storybook/internal/csf-tools";
802
+ var authoredSource = (shape, ctx) => {
803
+ for (let members of [shape.members, shape.metaMembers]) {
804
+ let code = memberAt(members, ["parameters", "docs", "source", "code"], ctx);
805
+ if (code.kind === "missing")
806
+ continue;
807
+ if (code.kind === "masked")
808
+ return { kind: "missing" };
809
+ if (code.kind === "unresolvable")
810
+ return code;
811
+ let resolved = resolveArgValue(code.node, ctx), value = unwrapExpression4(resolved.node);
812
+ if (t4.isIdentifier(value, { name: "undefined" }) || t4.isUnaryExpression(value, { operator: "void" }))
813
+ continue;
814
+ if (t4.isNullLiteral(value))
815
+ return { kind: "disabled" };
816
+ if (t4.isStringLiteral(value))
817
+ return { kind: "code", code: value.value };
818
+ let parts = templateParts(value);
819
+ return parts && parts.expressions.length === 0 ? { kind: "code", code: parts.quasis[0] ?? "" } : { kind: "unresolvable", source: sourceOf2(code.node) };
820
+ }
821
+ return { kind: "missing" };
822
+ }, memberAt = (members, path, ctx) => {
823
+ let result = memberOf(members, path[0]);
824
+ for (let [depth, key] of path.slice(1).entries()) {
825
+ if (result.kind !== "value")
826
+ return result;
827
+ let original = result.node, object = unwrapExpression4(resolveArgValue(original, ctx).node);
828
+ if (!t4.isObjectExpression(object))
829
+ return t4.isIdentifier(object, { name: "undefined" }) || t4.isUnaryExpression(object, { operator: "void" }) ? { kind: "missing" } : isOpaqueValue(object) ? { kind: "unresolvable", source: sourceOf2(original) } : depth === 0 ? { kind: "missing" } : { kind: "masked" };
830
+ result = memberOf(resolveObjectMembers(object, ctx), key);
831
+ }
832
+ return result;
833
+ }, memberOf = (members, key) => {
834
+ let node = members.properties[key];
835
+ return node !== void 0 && !members.shadowed.includes(key) ? { kind: "value", node } : members.unresolved.length > 0 ? { kind: "unresolvable", source: members.unresolved.at(-1) } : { kind: "missing" };
836
+ }, isOpaqueValue = (node) => !t4.isLiteral(node) && !t4.isArrayExpression(node) && !t4.isFunction(node);
837
+
838
+ // src/docgen/story-docs-build.ts
839
+ var buildStoryDocsPayload = async (input, context) => {
840
+ let storyImportPath = getStoryImportPathFromEntry(input.entry);
841
+ if (!storyImportPath)
842
+ return;
843
+ let storyFilePath = (context.resolvePath ?? ((importPath) => resolve3(process.cwd(), importPath)))(storyImportPath), csf = parseStoryFile(storyFilePath, input.entry.title);
844
+ if (!csf)
845
+ return;
846
+ let componentNode = csf._metaAnnotations.component, docgenPayload = componentNode ? await context.getDocgenPayload(getComponentIdFromEntry(input.entry)) : void 0, enums = docgenPayload?.angularComponentMeta?.enums ?? [], { resolveImport } = context, references = {
847
+ filePath: storyFilePath,
848
+ externalize: createArgExternalizer(enums),
849
+ resolveModule: resolveImport ? (fromFile, specifier) => {
850
+ let target = resolveImport(fromFile, specifier);
851
+ return target === void 0 ? void 0 : parseReferenceModule(target);
852
+ } : openStoryReferences().resolveModule
853
+ }, componentName = componentNameOf(componentNode), importBindings = collectImportBindings(csf._file.path), deps = {
854
+ csf,
855
+ resolveStoryArgs: createStoryArgsResolver(csf, references),
856
+ snippetMeta: docgenPayload?.angularComponentMeta,
857
+ componentName,
858
+ componentImport: componentName === void 0 ? void 0 : createImportStatement(componentName, importBindings, docgenPayload),
859
+ metaNgModules: ngModulesFromDecorators(csf._metaAnnotations.decorators, componentName),
860
+ importBindings
861
+ }, stories = Object.fromEntries(
862
+ await Promise.all(
863
+ Object.entries(csf._stories).map(
864
+ async ([exportName, story]) => [story.id, await buildStoryDoc(exportName, story, deps)]
865
+ )
866
+ )
867
+ ), titleName = input.entry.title.split("/").at(-1).replace(/\s+/g, "");
868
+ return {
869
+ id: getComponentIdFromEntry(input.entry),
870
+ // The docgen payload knows the class name even when the story file imported it under an alias.
871
+ name: docgenPayload?.name ?? componentName ?? titleName,
872
+ path: storyImportPath,
873
+ stories
66
874
  };
875
+ }, createImportStatement = (componentName, importBindings, docgenPayload) => {
876
+ let ref = resolveComponentImport2(componentName, importBindings), importOverride = docgenPayload?.jsDocTags?.import?.[0]?.trim();
877
+ return buildImportStatements2({ refs: [{ ...ref, importOverride }] }).join(`
878
+ `) || void 0;
879
+ }, componentNameOf = (node) => {
880
+ let identifier = node && t5.isTSInstantiationExpression(node) ? node.expression : node;
881
+ return identifier && t5.isIdentifier(identifier) ? identifier.name : void 0;
882
+ }, openStoryReferences = createStoryReferenceResolver(), buildStoryDoc = async (exportName, story, deps) => {
883
+ let { csf } = deps, name = story.name ?? storyNameFromExport(exportName);
884
+ try {
885
+ let { description, summary } = extractStoryJSDocInfo(csf._storyStatements[exportName]), rendered = await renderedSnippet(storyShape(exportName, deps), deps);
886
+ return {
887
+ id: story.id,
888
+ name,
889
+ ...rendered === void 0 ? {} : { snippet: rendered.snippet },
890
+ ...rendered?.warning === void 0 ? {} : { warning: rendered.warning },
891
+ ...description ? { description } : {},
892
+ ...summary === void 0 ? {} : { summary }
893
+ };
894
+ } catch (e) {
895
+ let err = e instanceof Error ? e : void 0;
896
+ return {
897
+ id: story.id,
898
+ name,
899
+ error: { name: err?.name ?? "Error", message: err?.message ?? String(e) }
900
+ };
901
+ }
902
+ }, renderedSnippet = async (shape, deps) => {
903
+ let authored = authoredSource(shape, deps.resolveStoryArgs.ctx);
904
+ if (authored.kind === "code")
905
+ return { snippet: authored.code };
906
+ if (authored.kind === "disabled")
907
+ return;
908
+ let derived = deps.snippetMeta ? await renderStorySnippet(deps.snippetMeta, shape, shape.members.properties.decorators, deps) : void 0;
909
+ return derived && authored.kind === "unresolvable" ? withWarnings(derived, unresolvedWarning([authored.source])) : derived;
910
+ }, storyShape = (exportName, deps) => {
911
+ let resolved = deps.resolveStoryArgs.resolve(exportName), enums = deps.snippetMeta?.enums ?? [], unresolved = [...resolved.unresolved];
912
+ for (let value of Object.values(resolved.args))
913
+ evaluateArgLiteral(value, enums) === void 0 && !isSelfContained(value) && unresolved.push(sourceOf(value));
914
+ return {
915
+ csf: deps.csf,
916
+ exportName,
917
+ members: resolved.storyMembers,
918
+ metaMembers: resolved.metaMembers,
919
+ args: resolved.args,
920
+ unresolvedArgs: unresolved
921
+ };
922
+ }, renderStorySnippet = async (snippetMeta, shape, storyDecorators, deps) => {
923
+ let { componentImport } = deps, localName = componentNameOf(shape.csf._metaAnnotations.component) ?? snippetMeta.name, ngModules = storyNgModules(storyDecorators, deps), expansion = argsExpansion(snippetMeta, shape), userMarkup = userTemplate(shape, shape.unresolvedArgs.length === 0 ? expansion : void 0), host = (template, viaComponentOutlet, outputs, fields) => buildHostComponentSnippet({
924
+ template,
925
+ componentName: localName,
926
+ componentImport,
927
+ viaComponentOutlet,
928
+ standalone: snippetMeta.standalone,
929
+ ngModules,
930
+ outputs,
931
+ fields
932
+ });
933
+ if (userMarkup?.kind === "literal") {
934
+ let { analyzeStoryTemplate } = await import("./_node-chunks/story-docs-template-analysis-6YH7XNRB.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(
935
+ referencedNames,
936
+ userMarkup.representedArgs,
937
+ shape,
938
+ boundOutputs,
939
+ snippetMeta.enums
940
+ );
941
+ return withWarnings(
942
+ host(formatTemplateMarkup(analysis.markup), !1, boundOutputs, hostArgs.fields),
943
+ unresolvedWarning([
944
+ ...shape.metaMembers.unresolved,
945
+ ...shape.members.unresolved,
946
+ ...hostArgs.unresolved
947
+ ]),
948
+ templateAnalysisWarning(analysis),
949
+ unknownTemplateReferencesWarning(referencedNames, shape, boundOutputs),
950
+ unboundArgsWarning(localName, snippetMeta, shape, [
951
+ ...userMarkup.representedArgs,
952
+ ...referencedNames
953
+ ])
954
+ );
955
+ }
956
+ let markupSources = userMarkup?.source === void 0 ? [] : [userMarkup.source];
957
+ return snippetMeta.selector ? withWarnings(
958
+ host(
959
+ buildTemplate(snippetMeta.selector, {
960
+ ...componentBindings(snippetMeta, shape),
961
+ selfClosing: !0
962
+ }),
963
+ !1,
964
+ snippetMeta.outputs
965
+ ),
966
+ unresolvedWarning([...markupSources, ...shape.unresolvedArgs]),
967
+ unboundArgsWarning(localName, snippetMeta, shape)
968
+ ) : withWarnings(
969
+ host(buildComponentOutletTemplate(localName, { selfClosing: !0 }), !0, []),
970
+ unresolvedWarning(markupSources)
971
+ );
972
+ }, referencedArgFields = (referencedNames, representedArgs, shape, boundOutputs, enums) => {
973
+ let taken = /* @__PURE__ */ new Set([...representedArgs, ...boundOutputs]), fields = [], unresolved = [];
974
+ for (let [name, node] of Object.entries(shape.args)) {
975
+ if (taken.has(name) || !referencedNames.has(name))
976
+ continue;
977
+ let value = evaluateArgLiteral(node, enums);
978
+ if (value === void 0) {
979
+ unresolved.push(sourceOf(node));
980
+ continue;
981
+ }
982
+ fields.push({ name, value });
983
+ }
984
+ return { fields, unresolved };
985
+ }, withWarnings = (rendered, ...parts) => {
986
+ let warning = [.../* @__PURE__ */ new Set([rendered.warning, ...parts])].filter((part) => part !== void 0).join(`
987
+ `);
988
+ return warning === "" ? rendered : { snippet: rendered.snippet, warning };
989
+ }, templateAnalysisWarning = (analysis) => analysis.kind === "resolved" ? void 0 : `Incomplete snippet: the story template could not be analyzed statically. ${analysis.errors.join(`
990
+ `)}`, unknownTemplateReferencesWarning = (referencedNames, shape, outputHandlers) => {
991
+ let provided = /* @__PURE__ */ new Set([...Object.keys(shape.args), ...outputHandlers]), names = [...referencedNames].filter((name) => !provided.has(name));
992
+ return names.length === 0 ? void 0 : `Incomplete snippet: ${names.map((name) => `\`${name}\``).join(", ")} could not be provided, since the story declares no such arg.`;
993
+ }, unboundArgsWarning = (componentName, snippetMeta, shape, representedArgs) => {
994
+ let represented = new Set(representedArgs), inputNames = new Set(snippetMeta.inputs), outputNames = new Set(snippetMeta.outputs), unbound = Object.entries(shape.args).filter(([name, node]) => represented.has(name) || isUndefinedValue(node) ? !1 : representedArgs === void 0 ? !inputNames.has(name) && !outputNames.has(name) : isFunctionValue(node) ? !outputNames.has(name) : !inputNames.has(name)).map(([name, node]) => ({ name, kind: isFunctionValue(node) ? "output" : "input" }));
995
+ if (unbound.length === 0)
996
+ return;
997
+ let reason = new Set(unbound.map(({ kind }) => kind)).size === 1 ? `declares no such ${unbound[0].kind}` : "declares no compatible input or output";
998
+ return `Incomplete snippet: ${unbound.map(({ name }) => `\`${name}\``).join(", ")} could not be bound, since ${componentName} ${reason}.`;
999
+ }, componentBindings = (snippetMeta, shape) => {
1000
+ let inputNames = new Set(snippetMeta.inputs);
1001
+ return { inputs: Object.entries(shape.args).filter(([argName]) => inputNames.has(argName)).map(([argName, node]) => ({
1002
+ name: argName,
1003
+ expression: evaluateArgExpression(node, snippetMeta.enums)
1004
+ })), outputs: snippetMeta.outputs };
1005
+ }, argsExpansion = (snippetMeta, shape) => {
1006
+ let inputNames = new Set(snippetMeta.inputs), outputNames = new Set(snippetMeta.outputs), inputs = [], outputs = [];
1007
+ for (let [name, node] of Object.entries(shape.args))
1008
+ isUndefinedValue(node) || (isFunctionValue(node) ? outputNames.has(name) && outputs.push(name) : inputNames.has(name) && inputs.push({ name, expression: evaluateArgExpression(node, snippetMeta.enums) }));
1009
+ return { inputs, outputs };
1010
+ }, isFunctionValue = (node) => {
1011
+ let unwrapped = unwrapExpression5(node);
1012
+ return t5.isFunction(unwrapped);
1013
+ }, isUndefinedValue = (node) => {
1014
+ let unwrapped = unwrapExpression5(node);
1015
+ return t5.isIdentifier(unwrapped) && unwrapped.name === "undefined" || t5.isUnaryExpression(unwrapped, { operator: "void" });
1016
+ };
1017
+
1018
+ // src/docgen/story-docs-preset.ts
1019
+ var warnedMissingDocgenService = !1, getDocgenPayload = async (componentId) => {
1020
+ try {
1021
+ return await getService("core/docgen", { internal: !0 }).queries.docgen.loaded({ id: componentId });
1022
+ } catch (error) {
1023
+ warnedMissingDocgenService || (warnedMissingDocgenService = !0, logger4.warn(
1024
+ `Angular story snippets are unavailable: querying core/docgen failed. ${error instanceof Error ? error.message : String(error)}`
1025
+ ));
1026
+ return;
1027
+ }
1028
+ }, experimental_storyDocsProvider = async (nextStoryDocs) => async (input) => {
1029
+ let storyImportPath = getStoryImportPathFromEntry2(input.entry);
1030
+ if (!storyImportPath || !STORY_FILE_TEST_REGEXP.test(storyImportPath))
1031
+ return nextStoryDocs(input);
1032
+ let ours = await buildStoryDocsPayload(input, { getDocgenPayload });
1033
+ return ours ? { ...await nextStoryDocs(input), ...ours } : nextStoryDocs(input);
67
1034
  };
68
1035
 
69
1036
  // src/preset.ts
70
- var addons = [], previewAnnotations = async (entries = [], options) => {
1037
+ var addons = [], features = async (existing) => ({
1038
+ ...existing,
1039
+ experimentalDocgenServer: !0
1040
+ }), previewAnnotations = async (entries = [], options) => {
71
1041
  let config = fileURLToPath2(import.meta.resolve("@storybook/angular-vite/client/config")), annotations = [...entries, config];
72
1042
  if (options.enableProdMode) {
73
1043
  let previewProdPath = fileURLToPath2(
@@ -104,14 +1074,21 @@ var viteFinal = async (config, options) => {
104
1074
  );
105
1075
  } catch {
106
1076
  }
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);
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({
1077
+ config.plugins = (config.plugins ?? []).flat().filter((plugin) => !plugin?.name?.includes("analogjs"));
1078
+ let { mergeConfig, normalizePath } = await import("vite"), { default: angular } = await import("@analogjs/vite-plugin-angular"), framework = await options.presets.apply("framework"), resolvedFeatures = await options.presets.apply(
1079
+ "features",
1080
+ {}
1081
+ ), docgenServer = !!resolvedFeatures?.experimentalDocgenServer, compodocConfig = await resolveCompodocConfig(options, { viteRoot: config?.root });
1082
+ compodocConfig.enabled && !docgenServer && await ensureCompodocDocumentation({
110
1083
  compodocArgs: compodocConfig.compodocArgs,
111
1084
  tsconfig: compodocConfig.tsconfig,
112
1085
  workspaceRoot: compodocConfig.workspaceRoot,
113
1086
  outputDir: compodocConfig.outputDir
114
1087
  });
1088
+ let propsTable = resolvePropsTable(framework.options, resolvedFeatures);
1089
+ warnAboutPropsTable(framework.options, resolvedFeatures), resolvedFeatures?.componentsManifest && !docgenServer && logger5.warn(
1090
+ "The `componentsManifest` feature needs the `experimentalDocgenServer` feature, which is off, so this Storybook publishes no components manifest and MCP clients get no component API from it. Turn the docgen server on with `features: { experimentalDocgenServer: true }` in your `main.ts`."
1091
+ );
115
1092
  let zoneless = resolveZoneless(options?.angularBuilderOptions), angularPlugins = angular({
116
1093
  jit: typeof framework.options?.jit < "u" ? framework.options?.jit : !0,
117
1094
  liveReload: typeof framework.options?.liveReload < "u" ? framework.options?.liveReload : !1,
@@ -119,6 +1096,15 @@ var viteFinal = async (config, options) => {
119
1096
  inlineStylesExtension: typeof framework.options?.inlineStylesExtension < "u" ? framework.options?.inlineStylesExtension : "css"
120
1097
  }), pluginsToInject = (Array.isArray(angularPlugins) ? angularPlugins : [angularPlugins]).filter(Boolean).map((plugin) => plugin?.name === "@analogjs/vite-plugin-angular" && !plugin.enforce ? { ...plugin, enforce: "pre" } : plugin);
121
1098
  return mergeConfig(config, {
1099
+ // `build` already falls back to `compilerOptions.paths` once normal resolution fails, so an
1100
+ // Angular workspace alias with no `node_modules` counterpart already resolves in `build`
1101
+ // today; `dev` only consults `paths` when this is on, so the same alias fails to serve.
1102
+ // Turning it on closes that gap, but for a specifier that resolves both ways - a tsconfig
1103
+ // path alongside a `node_modules` copy of the same package - it also flips precedence to the
1104
+ // tsconfig target in `build`, not just `dev`. See MIGRATION.md.
1105
+ resolve: {
1106
+ tsconfigPaths: config.resolve?.tsconfigPaths ?? !0
1107
+ },
122
1108
  // Add dependencies to pre-optimization
123
1109
  optimizeDeps: {
124
1110
  include: [
@@ -164,15 +1150,57 @@ var viteFinal = async (config, options) => {
164
1150
  ...pluginsToInject,
165
1151
  angularViteRedirectReapplyPlugin(options),
166
1152
  angularOptionsPlugin(options, { normalizePath, zoneless }),
167
- storybookOxcPlugin()
1153
+ storybookOxcPlugin(),
1154
+ ...docgenServer && options?.configDir ? [compodocJsonStubPlugin(options.configDir)] : []
168
1155
  ],
169
1156
  define: {
170
1157
  STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({
171
- zoneless: !!zoneless
1158
+ zoneless: !!zoneless,
1159
+ propsTable
172
1160
  })
173
1161
  }
174
1162
  });
1163
+ }, COMPODOC_JSON_STUB_ID = "\0storybook-angular-vite/empty-compodoc-json", EMPTY_COMPODOC_JSON = {
1164
+ classes: [],
1165
+ components: [],
1166
+ coverage: { count: 0, status: "low", files: [] },
1167
+ directives: [],
1168
+ guards: [],
1169
+ injectables: [],
1170
+ interceptors: [],
1171
+ interfaces: [],
1172
+ miscellaneous: {
1173
+ enumerations: [],
1174
+ functions: [],
1175
+ groupedEnumerations: {},
1176
+ groupedFunctions: {},
1177
+ groupedTypeAliases: {},
1178
+ groupedVariables: {},
1179
+ typealiases: [],
1180
+ variables: []
1181
+ },
1182
+ modules: [],
1183
+ pipes: [],
1184
+ routes: { name: "<root>", kind: "module", children: [] }
175
1185
  };
1186
+ function compodocJsonStubPlugin(configDir) {
1187
+ let importedFromStorybookConfig = (importer) => {
1188
+ if (!importer)
1189
+ return !1;
1190
+ let fromConfigDir = relative2(configDir, importer);
1191
+ return fromConfigDir !== "" && !fromConfigDir.startsWith("..") && !isAbsolute2(fromConfigDir);
1192
+ };
1193
+ return {
1194
+ name: "storybook-angular-vite-compodoc-json-stub",
1195
+ enforce: "pre",
1196
+ async resolveId(source, importer, resolveOptions) {
1197
+ return basename(source) !== DOCUMENTATION_JSON || !importedFromStorybookConfig(importer) || await this.resolve(source, importer, { ...resolveOptions, skipSelf: !0 }) ? null : COMPODOC_JSON_STUB_ID;
1198
+ },
1199
+ load(id) {
1200
+ return id === COMPODOC_JSON_STUB_ID ? `export default ${JSON.stringify(EMPTY_COMPODOC_JSON)};` : null;
1201
+ }
1202
+ };
1203
+ }
176
1204
  function angularOptionsPlugin(options, { normalizePath, zoneless }) {
177
1205
  let resolvedConfig, resolvedPreviewPath;
178
1206
  return {
@@ -180,30 +1208,31 @@ function angularOptionsPlugin(options, { normalizePath, zoneless }) {
180
1208
  config(userConfig) {
181
1209
  resolvedConfig = userConfig, resolvedPreviewPath = findConfigFile("preview", options.configDir) ?? void 0;
182
1210
  let stylePreprocessorOptions = options?.angularBuilderOptions?.stylePreprocessorOptions ?? {}, loadPaths = stylePreprocessorOptions.includePaths ?? stylePreprocessorOptions.loadPaths, sassOptions = stylePreprocessorOptions.sass;
183
- if (Array.isArray(loadPaths)) {
184
- let workspaceRoot = options.angularBuilderContext?.workspaceRoot ?? userConfig?.root ?? process.cwd();
185
- return {
186
- css: {
187
- preprocessorOptions: {
188
- scss: {
189
- ...sassOptions,
190
- loadPaths: loadPaths.map((loadPath) => `${resolve(workspaceRoot, loadPath)}`)
191
- }
1211
+ if (!Array.isArray(loadPaths) && !sassOptions)
1212
+ return;
1213
+ let workspaceRoot = options.angularBuilderContext?.workspaceRoot ?? userConfig?.root ?? process.cwd();
1214
+ return {
1215
+ css: {
1216
+ preprocessorOptions: {
1217
+ scss: {
1218
+ ...sassOptions,
1219
+ ...Array.isArray(loadPaths) ? { loadPaths: loadPaths.map((loadPath) => `${resolve4(workspaceRoot, loadPath)}`) } : {}
192
1220
  }
193
1221
  }
194
- };
195
- }
1222
+ }
1223
+ };
196
1224
  },
197
1225
  async transform(code, id) {
198
1226
  if (resolvedPreviewPath && normalizePath(id).endsWith(normalizePath(resolvedPreviewPath))) {
199
1227
  let imports = [], styles = options?.angularBuilderOptions?.styles;
200
1228
  Array.isArray(styles) && styles.forEach((style) => {
201
- imports.push(style);
1229
+ let stylePath = typeof style == "string" ? style : style !== null && typeof style == "object" && "input" in style && typeof style.input == "string" ? style.input : void 0;
1230
+ stylePath !== void 0 && imports.push(stylePath);
202
1231
  }), zoneless || imports.push("zone.js");
203
1232
  let projectRoot = resolvedConfig?.root ?? process.cwd();
204
1233
  return {
205
1234
  code: `
206
- ${imports.map((extraImport) => extraImport.startsWith(".") || extraImport.startsWith("src") ? `import '${normalizePath(resolve(projectRoot, extraImport))}';` : `import '${extraImport}';`).join(`
1235
+ ${imports.map((extraImport) => extraImport.startsWith(".") || extraImport.startsWith("src") ? `import '${normalizePath(resolve4(projectRoot, extraImport))}';` : `import '${extraImport}';`).join(`
207
1236
  `)}
208
1237
  ${code}
209
1238
  `
@@ -248,7 +1277,7 @@ function angularViteRedirectReapplyPlugin(options) {
248
1277
  for (let r of redirects)
249
1278
  if (getRealPath(r.absolutePath, preserveSymlinks) === idNorm)
250
1279
  return this.addWatchFile(r.redirectPath), {
251
- code: readFileSync(r.redirectPath, "utf-8"),
1280
+ code: readFileSync3(r.redirectPath, "utf-8"),
252
1281
  map: { mappings: "" }
253
1282
  };
254
1283
  for (let a of automocks)
@@ -288,9 +1317,12 @@ var typescript = async (config) => ({
288
1317
  export {
289
1318
  addons,
290
1319
  angularOptionsPlugin,
1320
+ compodocJsonStubPlugin,
291
1321
  core,
292
1322
  experimental_docgenProvider,
293
1323
  experimental_manifests,
1324
+ experimental_storyDocsProvider,
1325
+ features,
294
1326
  previewAnnotations,
295
1327
  typescript,
296
1328
  viteFinal