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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ up
14
+ } from "./chunk-RC6UIUJ4.js";
15
+
16
+ // ../../../node_modules/empathic/package.mjs
17
+ function up2(options) {
18
+ return up("package.json", options);
19
+ }
20
+
21
+ // src/builders/utils/error-handler.ts
22
+ import { logger, instance as npmLog } from "storybook/internal/node-logger";
23
+ import { dedent } from "ts-dedent";
24
+ var printErrorDetails = (error) => {
25
+ 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));
26
+ }, errorSummary = (error) => error.close ? dedent`
27
+ FATAL broken build!, will close the process,
28
+ Fix the error below and restart storybook.
29
+ ` : dedent`
30
+ Broken build, fix the error above.
31
+ You may need to refresh the browser.
32
+ `;
33
+
34
+ export {
35
+ up2 as up,
36
+ printErrorDetails,
37
+ errorSummary
38
+ };
@@ -0,0 +1,195 @@
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ findTsconfigUp
14
+ } from "./chunk-RC6UIUJ4.js";
15
+
16
+ // src/compodoc-config.ts
17
+ import { resolve } from "node:path";
18
+ var DEFAULT_COMPODOC_ARGS = ["-e", "json", "-d", "."], DOCUMENTATION_JSON = "documentation.json", readCompodocOutputDir = (compodocArgs) => {
19
+ for (let index = compodocArgs.length - 1; index >= 0; index--) {
20
+ let arg = compodocArgs[index];
21
+ if (arg.startsWith("--output="))
22
+ return arg.slice(9) || void 0;
23
+ if (arg === "-d" || arg === "--output") {
24
+ let value = compodocArgs[index + 1];
25
+ if (typeof value == "string" && !value.startsWith("-"))
26
+ return value;
27
+ }
28
+ }
29
+ }, resolveCompodocConfig = async (options, extra = {}) => {
30
+ 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
31
+ // it the docgen reader falls back to cwd and looks in a different directory than the writer.
32
+ (options?.configDir ? resolve(options.configDir, "..") : void 0) ?? process.cwd(), compodocArgs = frameworkOptions.compodocArgs ?? DEFAULT_COMPODOC_ARGS;
33
+ return {
34
+ /** `framework.options.compodoc`: `false` means the user opted out of Compodoc entirely. */
35
+ enabled: frameworkOptions.compodoc !== !1,
36
+ compodocArgs,
37
+ tsconfig: frameworkOptions.tsconfig ?? options?.tsConfig ?? options?.angularBuilderOptions?.tsConfig ?? // The same walk the builders use, so Compodoc is pointed at the tsconfig the Angular build
38
+ // would have picked rather than a different guess.
39
+ (options?.configDir ? findTsconfigUp(options.configDir) : void 0) ?? resolve(workspaceRoot, "tsconfig.json"),
40
+ /** Directory Compodoc runs in, and the base its relative `file` paths are written against. */
41
+ workspaceRoot,
42
+ /** Absolute directory Compodoc writes {@link DOCUMENTATION_JSON} into. */
43
+ outputDir: resolve(workspaceRoot, readCompodocOutputDir(compodocArgs) ?? ".")
44
+ };
45
+ };
46
+
47
+ // src/compodoc/ensure-documentation.ts
48
+ import { withFileLock } from "storybook/internal/common";
49
+ import { logger as logger2 } from "storybook/internal/node-logger";
50
+ import { randomUUID } from "node:crypto";
51
+ import { readFileSync as readFileSync2, writeFileSync } from "node:fs";
52
+ import { join as join2 } from "node:path";
53
+
54
+ // src/compodoc/generate-documentation.ts
55
+ import { executeNodeCommand } from "storybook/internal/common";
56
+ import { logger } from "storybook/internal/node-logger";
57
+ import {
58
+ existsSync,
59
+ mkdirSync,
60
+ mkdtempSync,
61
+ readFileSync,
62
+ readdirSync,
63
+ renameSync,
64
+ rmSync,
65
+ statSync
66
+ } from "node:fs";
67
+ import { createRequire } from "node:module";
68
+ import { dirname, isAbsolute, join, relative, resolve as resolve2 } from "node:path";
69
+ import { pathToFileURL } from "node:url";
70
+ var COMPODOC_TIMEOUT_MS = 600 * 1e3, OUTPUT_TAIL_BYTES = 4e3, SCRATCH_PREFIX = ".compodoc-", resolveCompodocCli = (workspaceRoot) => {
71
+ let searchFrom = [pathToFileURL(join(resolve2(workspaceRoot), "noop.js")).href, import.meta.url];
72
+ for (let from of searchFrom)
73
+ try {
74
+ let packageJsonPath = createRequire(from).resolve("@compodoc/compodoc/package.json"), { bin } = JSON.parse(readFileSync(packageJsonPath, "utf8")), entry = typeof bin == "string" ? bin : bin?.compodoc;
75
+ if (entry)
76
+ return join(dirname(packageJsonPath), entry);
77
+ } catch {
78
+ }
79
+ }, hasTsconfigArg = (args) => args.includes("-p"), toChildRelativePath = (path, cwd) => isAbsolute(path) ? relative(cwd, path) : path, runCli = async (cli, args, cwd, timeoutMs) => {
80
+ let result = await executeNodeCommand({
81
+ scriptPath: cli,
82
+ args,
83
+ options: {
84
+ cwd,
85
+ // Interleaved into one stream, so the failure message reads in the order Compodoc printed it.
86
+ all: !0,
87
+ encoding: "utf8",
88
+ // Failures come back as a result rather than a throw, so a timeout and a non-zero exit are
89
+ // told apart by inspecting one object.
90
+ reject: !1,
91
+ timeout: timeoutMs,
92
+ // Compodoc does not shut down promptly on SIGTERM, and a hung scan would otherwise keep the
93
+ // docgen worker waiting for it.
94
+ killSignal: "SIGKILL"
95
+ }
96
+ });
97
+ if (!result.failed)
98
+ return;
99
+ let output = String(result.all ?? "").trim().slice(-OUTPUT_TAIL_BYTES);
100
+ throw new Error(
101
+ result.timedOut ? `Compodoc did not finish within ${timeoutMs}ms.
102
+ ${output}` : `Compodoc exited with code ${result.exitCode}.
103
+ ${output}`
104
+ );
105
+ }, removeAbandonedScratchDirs = (outputDir, olderThanMs) => {
106
+ let cutoff = Date.now() - olderThanMs;
107
+ for (let entry of readdirSync(outputDir, { withFileTypes: !0 })) {
108
+ if (!entry.isDirectory() || !entry.name.startsWith(SCRATCH_PREFIX))
109
+ continue;
110
+ let path = join(outputDir, entry.name);
111
+ try {
112
+ statSync(path).mtimeMs < cutoff && rmSync(path, { recursive: !0, force: !0 });
113
+ } catch {
114
+ }
115
+ }
116
+ }, generateDocumentation = async ({
117
+ compodocArgs,
118
+ tsconfig,
119
+ workspaceRoot,
120
+ outputDir,
121
+ timeoutMs = COMPODOC_TIMEOUT_MS
122
+ }) => {
123
+ let cli = resolveCompodocCli(workspaceRoot);
124
+ if (!cli)
125
+ throw new Error(
126
+ "@compodoc/compodoc could not be resolved. Install it as a devDependency, or set framework.options.compodoc to false to turn Angular docgen off."
127
+ );
128
+ mkdirSync(outputDir, { recursive: !0 }), removeAbandonedScratchDirs(outputDir, timeoutMs);
129
+ let scratchDir = mkdtempSync(join(outputDir, SCRATCH_PREFIX)), startedAt = Date.now();
130
+ logger.info("[storybook-angular-vite] Generating Angular documentation with Compodoc...");
131
+ try {
132
+ await runCli(
133
+ cli,
134
+ [
135
+ ...hasTsconfigArg(compodocArgs) ? [] : ["-p", toChildRelativePath(tsconfig, workspaceRoot)],
136
+ ...compodocArgs,
137
+ // Last occurrence wins on Compodoc's command line, so this overrides any `-d`/`--output` the
138
+ // user configured. Their directory is where the finished file lands, not where it is built.
139
+ "-d",
140
+ scratchDir
141
+ ],
142
+ workspaceRoot,
143
+ timeoutMs
144
+ );
145
+ let produced = join(scratchDir, DOCUMENTATION_JSON);
146
+ if (!existsSync(produced))
147
+ throw new Error(
148
+ `Compodoc finished without writing ${DOCUMENTATION_JSON}. Check that its arguments still export JSON: ${compodocArgs.join(" ")}`
149
+ );
150
+ renameSync(produced, join(outputDir, DOCUMENTATION_JSON)), logger.debug(
151
+ `[storybook-angular-vite] generated ${DOCUMENTATION_JSON} in ${Date.now() - startedAt}ms`
152
+ );
153
+ } finally {
154
+ rmSync(scratchDir, { recursive: !0, force: !0 });
155
+ }
156
+ };
157
+
158
+ // src/compodoc/ensure-documentation.ts
159
+ 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) => {
160
+ try {
161
+ return readFileSync2(markerPath, "utf8").trim();
162
+ } catch {
163
+ return;
164
+ }
165
+ }, ensureCompodocDocumentation = async ({
166
+ compodocArgs,
167
+ tsconfig,
168
+ workspaceRoot,
169
+ outputDir,
170
+ waitBudgetMs
171
+ }) => {
172
+ let markerPath = join2(outputDir, COMPODOC_RUN_MARKER), runId = currentRunId();
173
+ if (markerRunId(markerPath) !== runId)
174
+ try {
175
+ await withFileLock(
176
+ join2(outputDir, COMPODOC_LOCK),
177
+ async () => {
178
+ markerRunId(markerPath) !== runId && (await generateDocumentation({ compodocArgs, tsconfig, workspaceRoot, outputDir }), writeFileSync(markerPath, runId));
179
+ },
180
+ { waitBudgetMs }
181
+ ) === "busy" && logger2.debug(
182
+ `[storybook-angular-vite] another process is still generating ${DOCUMENTATION_JSON}; continuing with what is on disk`
183
+ );
184
+ } catch (error) {
185
+ logger2.warn(
186
+ `[storybook-angular-vite] Compodoc generation failed: ${error instanceof Error ? error.message : String(error)}`
187
+ );
188
+ }
189
+ };
190
+
191
+ export {
192
+ DOCUMENTATION_JSON,
193
+ resolveCompodocConfig,
194
+ ensureCompodocDocumentation
195
+ };
@@ -0,0 +1,50 @@
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+
13
+ // src/find-tsconfig.ts
14
+ import { getProjectRoot } from "storybook/internal/common";
15
+
16
+ // ../../../node_modules/empathic/find.mjs
17
+ import { join as join2 } from "node:path";
18
+ import { existsSync, statSync } from "node:fs";
19
+
20
+ // ../../../node_modules/empathic/walk.mjs
21
+ import { dirname } from "node:path";
22
+
23
+ // ../../../node_modules/empathic/resolve.mjs
24
+ import { isAbsolute, join, resolve } from "node:path";
25
+ function absolute(input, root) {
26
+ return isAbsolute(input) ? input : resolve(root || ".", input);
27
+ }
28
+
29
+ // ../../../node_modules/empathic/walk.mjs
30
+ function up(base, options) {
31
+ let { last, cwd } = options || {}, tmp = absolute(base, cwd), root = absolute(last || "/", cwd), prev, arr = [];
32
+ for (; prev !== root && (arr.push(tmp), tmp = dirname(prev = tmp), tmp !== prev); )
33
+ ;
34
+ return arr;
35
+ }
36
+
37
+ // ../../../node_modules/empathic/find.mjs
38
+ function up2(name, options) {
39
+ let dir, tmp, start = options && options.cwd || "";
40
+ for (dir of up(start, options))
41
+ if (tmp = join2(dir, name), existsSync(tmp)) return tmp;
42
+ }
43
+
44
+ // src/find-tsconfig.ts
45
+ var findTsconfigUp = (configDir) => up2("tsconfig.json", { cwd: configDir, last: getProjectRoot() });
46
+
47
+ export {
48
+ up2 as up,
49
+ findTsconfigUp
50
+ };
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -12,13 +12,15 @@ var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
12
12
  import {
13
13
  errorSummary,
14
14
  printErrorDetails,
15
- up,
16
- up2
17
- } from "../../_node-chunks/chunk-JWIN6AI4.js";
15
+ up
16
+ } from "../../_node-chunks/chunk-35U7AODH.js";
17
+ import {
18
+ findTsconfigUp
19
+ } from "../../_node-chunks/chunk-RC6UIUJ4.js";
18
20
 
19
21
  // src/builders/build-storybook/index.ts
20
22
  import { readFileSync } from "node:fs";
21
- import { getEnvConfig, getProjectRoot, versions } from "storybook/internal/common";
23
+ import { getEnvConfig, versions } from "storybook/internal/common";
22
24
  import { buildStaticStandalone, withTelemetry } from "storybook/internal/core-server";
23
25
  import { addToGlobalContext } from "storybook/internal/telemetry";
24
26
  import { logger, logTracker } from "storybook/internal/node-logger";
@@ -51,7 +53,7 @@ var commandBuilder = async (options, context) => {
51
53
  sourceMap = !1,
52
54
  preserveSymlinks = !1,
53
55
  zoneless = !0
54
- } = options, packageJsonPath = up2({ cwd: __dirname }), standaloneOptions = {
56
+ } = options, packageJsonPath = up({ cwd: __dirname }), standaloneOptions = {
55
57
  packageJson: packageJsonPath != null ? JSON.parse(readFileSync(packageJsonPath, "utf8")) : null,
56
58
  configDir,
57
59
  ...docs ? { docs } : {},
@@ -89,7 +91,7 @@ async function setup(options, context) {
89
91
  await context.getTargetOptions(browserTarget),
90
92
  await context.getBuilderNameForTarget(browserTarget)
91
93
  )), {
92
- tsConfig: options.tsConfig ?? up("tsconfig.json", { cwd: options.configDir, last: getProjectRoot() }) ?? browserOptions.tsConfig
94
+ tsConfig: options.tsConfig ?? findTsconfigUp(options.configDir) ?? browserOptions.tsConfig
93
95
  };
94
96
  }
95
97
  async function runInstance(options) {
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_te10sz511b from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_te10sz511b from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_te10sz511b from "node:module";
1
+ import CJS_COMPAT_NODE_URL_1pj9uj7yzpf from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_1pj9uj7yzpf from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_te10sz511b.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_te10sz511b.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_1pj9uj7yzpf.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_1pj9uj7yzpf.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_1pj9uj7yzpf.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -12,9 +12,11 @@ var require = CJS_COMPAT_NODE_MODULE_te10sz511b.createRequire(import.meta.url);
12
12
  import {
13
13
  errorSummary,
14
14
  printErrorDetails,
15
- up,
16
- up2
17
- } from "../../_node-chunks/chunk-JWIN6AI4.js";
15
+ up
16
+ } from "../../_node-chunks/chunk-35U7AODH.js";
17
+ import {
18
+ findTsconfigUp
19
+ } from "../../_node-chunks/chunk-RC6UIUJ4.js";
18
20
 
19
21
  // src/builders/start-storybook/index.ts
20
22
  import { readFileSync } from "node:fs";
@@ -64,7 +66,7 @@ var commandBuilder = (options, context) => new Observable((observer) => {
64
66
  sourceMap = !1,
65
67
  preserveSymlinks = !1,
66
68
  zoneless = !0
67
- } = options, packageJsonPath = up2({ cwd: __dirname }), standaloneOptions = {
69
+ } = options, packageJsonPath = up({ cwd: __dirname }), standaloneOptions = {
68
70
  packageJson: packageJsonPath != null ? JSON.parse(readFileSync(packageJsonPath, "utf8")) : null,
69
71
  ci,
70
72
  configDir,
@@ -119,7 +121,7 @@ async function setup(options, context) {
119
121
  await context.getTargetOptions(browserTarget),
120
122
  await context.getBuilderNameForTarget(browserTarget)
121
123
  )), {
122
- tsConfig: options.tsConfig ?? up("tsconfig.json", { cwd: options.configDir }) ?? browserOptions.tsConfig
124
+ tsConfig: options.tsConfig ?? findTsconfigUp(options.configDir) ?? browserOptions.tsConfig
123
125
  };
124
126
  }
125
127
  async function runInstance(options) {
@@ -2,7 +2,7 @@ import {
2
2
  argTypesEnhancers,
3
3
  decorateStory,
4
4
  parameters
5
- } from "../_browser-chunks/chunk-P4DOL4U2.js";
5
+ } from "../_browser-chunks/chunk-XXAOQLNU.js";
6
6
  import {
7
7
  render,
8
8
  renderToCanvas
@@ -5,8 +5,8 @@ import {
5
5
  componentWrapperDecorator,
6
6
  moduleMetadata,
7
7
  setProjectAnnotations
8
- } from "../_browser-chunks/chunk-KBKLVYEJ.js";
9
- import "../_browser-chunks/chunk-P4DOL4U2.js";
8
+ } from "../_browser-chunks/chunk-GVH2OCSY.js";
9
+ import "../_browser-chunks/chunk-XXAOQLNU.js";
10
10
  import "../_browser-chunks/chunk-THKACJYB.js";
11
11
  import "../_browser-chunks/chunk-6DVGZIOB.js";
12
12
  export {