@storybook/angular 9.2.0-alpha.2 → 10.0.0-beta.0

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.
Files changed (37) hide show
  1. package/README.md +3 -1
  2. package/dist/_browser-chunks/chunk-CV6HSYTZ.js +92 -0
  3. package/dist/_browser-chunks/chunk-DAHG2CDK.js +3 -0
  4. package/dist/_browser-chunks/chunk-L4GU2V72.js +939 -0
  5. package/dist/_node-chunks/chunk-76OGQITJ.js +330 -0
  6. package/dist/_node-chunks/chunk-JXWXEIYP.js +17 -0
  7. package/dist/_node-chunks/chunk-YXFPXXZP.js +135 -0
  8. package/dist/builders/build-storybook/index.js +137 -28
  9. package/dist/builders/start-storybook/index.js +161 -28
  10. package/dist/client/config.js +304 -46
  11. package/dist/client/docs/config.js +54 -15
  12. package/dist/client/index.js +16 -47
  13. package/dist/client/preview-prod.js +3 -5
  14. package/dist/index.d.ts +177 -6
  15. package/dist/index.js +16 -47
  16. package/dist/node/index.d.ts +56 -0
  17. package/dist/node/index.js +23 -0
  18. package/dist/preset.js +54 -7
  19. package/dist/server/framework-preset-angular-cli.js +309 -16
  20. package/dist/server/framework-preset-angular-ivy.js +57 -5
  21. package/package.json +24 -70
  22. package/preset.js +1 -1
  23. package/dist/chunk-CUDJAP6K.mjs +0 -3
  24. package/dist/chunk-KMSSK3DZ.mjs +0 -6
  25. package/dist/chunk-LXSTVAFF.mjs +0 -40
  26. package/dist/client/config.d.ts +0 -20
  27. package/dist/client/config.mjs +0 -11
  28. package/dist/client/docs/config.d.ts +0 -6
  29. package/dist/client/docs/config.mjs +0 -7
  30. package/dist/client/index.d.ts +0 -144
  31. package/dist/client/index.mjs +0 -3
  32. package/dist/client/preview-prod.d.ts +0 -2
  33. package/dist/client/preview-prod.mjs +0 -3
  34. package/dist/index.mjs +0 -3
  35. package/dist/types-3b0b7107.d.ts +0 -42
  36. package/renderer.d.ts +0 -1
  37. package/renderer.js +0 -1
@@ -0,0 +1,330 @@
1
+ import CJS_COMPAT_NODE_URL_bs5nei9dti8 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_bs5nei9dti8 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_bs5nei9dti8 from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_bs5nei9dti8.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_bs5nei9dti8.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_bs5nei9dti8.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ __name
14
+ } from "./chunk-JXWXEIYP.js";
15
+
16
+ // ../../node_modules/find-up/index.js
17
+ import path2 from "node:path";
18
+
19
+ // ../../node_modules/locate-path/index.js
20
+ import process from "node:process";
21
+ import path from "node:path";
22
+ import fs, { promises as fsPromises } from "node:fs";
23
+ import { fileURLToPath } from "node:url";
24
+
25
+ // ../../node_modules/yocto-queue/index.js
26
+ var Node = class {
27
+ static {
28
+ __name(this, "Node");
29
+ }
30
+ value;
31
+ next;
32
+ constructor(value) {
33
+ this.value = value;
34
+ }
35
+ };
36
+ var Queue = class {
37
+ static {
38
+ __name(this, "Queue");
39
+ }
40
+ #head;
41
+ #tail;
42
+ #size;
43
+ constructor() {
44
+ this.clear();
45
+ }
46
+ enqueue(value) {
47
+ const node = new Node(value);
48
+ if (this.#head) {
49
+ this.#tail.next = node;
50
+ this.#tail = node;
51
+ } else {
52
+ this.#head = node;
53
+ this.#tail = node;
54
+ }
55
+ this.#size++;
56
+ }
57
+ dequeue() {
58
+ const current = this.#head;
59
+ if (!current) {
60
+ return;
61
+ }
62
+ this.#head = this.#head.next;
63
+ this.#size--;
64
+ return current.value;
65
+ }
66
+ peek() {
67
+ if (!this.#head) {
68
+ return;
69
+ }
70
+ return this.#head.value;
71
+ }
72
+ clear() {
73
+ this.#head = void 0;
74
+ this.#tail = void 0;
75
+ this.#size = 0;
76
+ }
77
+ get size() {
78
+ return this.#size;
79
+ }
80
+ *[Symbol.iterator]() {
81
+ let current = this.#head;
82
+ while (current) {
83
+ yield current.value;
84
+ current = current.next;
85
+ }
86
+ }
87
+ *drain() {
88
+ while (this.#head) {
89
+ yield this.dequeue();
90
+ }
91
+ }
92
+ };
93
+
94
+ // ../../node_modules/locate-path/node_modules/p-limit/index.js
95
+ function pLimit(concurrency) {
96
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
97
+ throw new TypeError("Expected `concurrency` to be a number from 1 and up");
98
+ }
99
+ const queue = new Queue();
100
+ let activeCount = 0;
101
+ const next = /* @__PURE__ */ __name(() => {
102
+ activeCount--;
103
+ if (queue.size > 0) {
104
+ queue.dequeue()();
105
+ }
106
+ }, "next");
107
+ const run = /* @__PURE__ */ __name(async (fn, resolve, args) => {
108
+ activeCount++;
109
+ const result = (async () => fn(...args))();
110
+ resolve(result);
111
+ try {
112
+ await result;
113
+ } catch {
114
+ }
115
+ next();
116
+ }, "run");
117
+ const enqueue = /* @__PURE__ */ __name((fn, resolve, args) => {
118
+ queue.enqueue(run.bind(void 0, fn, resolve, args));
119
+ (async () => {
120
+ await Promise.resolve();
121
+ if (activeCount < concurrency && queue.size > 0) {
122
+ queue.dequeue()();
123
+ }
124
+ })();
125
+ }, "enqueue");
126
+ const generator = /* @__PURE__ */ __name((fn, ...args) => new Promise((resolve) => {
127
+ enqueue(fn, resolve, args);
128
+ }), "generator");
129
+ Object.defineProperties(generator, {
130
+ activeCount: {
131
+ get: /* @__PURE__ */ __name(() => activeCount, "get")
132
+ },
133
+ pendingCount: {
134
+ get: /* @__PURE__ */ __name(() => queue.size, "get")
135
+ },
136
+ clearQueue: {
137
+ value: /* @__PURE__ */ __name(() => {
138
+ queue.clear();
139
+ }, "value")
140
+ }
141
+ });
142
+ return generator;
143
+ }
144
+ __name(pLimit, "pLimit");
145
+
146
+ // ../../node_modules/locate-path/node_modules/p-locate/index.js
147
+ var EndError = class extends Error {
148
+ static {
149
+ __name(this, "EndError");
150
+ }
151
+ constructor(value) {
152
+ super();
153
+ this.value = value;
154
+ }
155
+ };
156
+ var testElement = /* @__PURE__ */ __name(async (element, tester) => tester(await element), "testElement");
157
+ var finder = /* @__PURE__ */ __name(async (element) => {
158
+ const values = await Promise.all(element);
159
+ if (values[1] === true) {
160
+ throw new EndError(values[0]);
161
+ }
162
+ return false;
163
+ }, "finder");
164
+ async function pLocate(iterable, tester, {
165
+ concurrency = Number.POSITIVE_INFINITY,
166
+ preserveOrder = true
167
+ } = {}) {
168
+ const limit = pLimit(concurrency);
169
+ const items = [...iterable].map((element) => [element, limit(testElement, element, tester)]);
170
+ const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
171
+ try {
172
+ await Promise.all(items.map((element) => checkLimit(finder, element)));
173
+ } catch (error) {
174
+ if (error instanceof EndError) {
175
+ return error.value;
176
+ }
177
+ throw error;
178
+ }
179
+ }
180
+ __name(pLocate, "pLocate");
181
+
182
+ // ../../node_modules/locate-path/index.js
183
+ var typeMappings = {
184
+ directory: "isDirectory",
185
+ file: "isFile"
186
+ };
187
+ function checkType(type) {
188
+ if (Object.hasOwnProperty.call(typeMappings, type)) {
189
+ return;
190
+ }
191
+ throw new Error(`Invalid type specified: ${type}`);
192
+ }
193
+ __name(checkType, "checkType");
194
+ var matchType = /* @__PURE__ */ __name((type, stat) => stat[typeMappings[type]](), "matchType");
195
+ var toPath = /* @__PURE__ */ __name((urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath, "toPath");
196
+ async function locatePath(paths, {
197
+ cwd = process.cwd(),
198
+ type = "file",
199
+ allowSymlinks = true,
200
+ concurrency,
201
+ preserveOrder
202
+ } = {}) {
203
+ checkType(type);
204
+ cwd = toPath(cwd);
205
+ const statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;
206
+ return pLocate(paths, async (path_) => {
207
+ try {
208
+ const stat = await statFunction(path.resolve(cwd, path_));
209
+ return matchType(type, stat);
210
+ } catch {
211
+ return false;
212
+ }
213
+ }, { concurrency, preserveOrder });
214
+ }
215
+ __name(locatePath, "locatePath");
216
+ function locatePathSync(paths, {
217
+ cwd = process.cwd(),
218
+ type = "file",
219
+ allowSymlinks = true
220
+ } = {}) {
221
+ checkType(type);
222
+ cwd = toPath(cwd);
223
+ const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
224
+ for (const path_ of paths) {
225
+ try {
226
+ const stat = statFunction(path.resolve(cwd, path_), {
227
+ throwIfNoEntry: false
228
+ });
229
+ if (!stat) {
230
+ continue;
231
+ }
232
+ if (matchType(type, stat)) {
233
+ return path_;
234
+ }
235
+ } catch {
236
+ }
237
+ }
238
+ }
239
+ __name(locatePathSync, "locatePathSync");
240
+
241
+ // ../../node_modules/find-up/node_modules/unicorn-magic/node.js
242
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
243
+ function toPath2(urlOrPath) {
244
+ return urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
245
+ }
246
+ __name(toPath2, "toPath");
247
+
248
+ // ../../node_modules/find-up/index.js
249
+ var findUpStop = Symbol("findUpStop");
250
+ async function findUpMultiple(name, options = {}) {
251
+ let directory = path2.resolve(toPath2(options.cwd) ?? "");
252
+ const { root } = path2.parse(directory);
253
+ const stopAt = path2.resolve(directory, toPath2(options.stopAt ?? root));
254
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
255
+ const paths = [name].flat();
256
+ const runMatcher = /* @__PURE__ */ __name(async (locateOptions) => {
257
+ if (typeof name !== "function") {
258
+ return locatePath(paths, locateOptions);
259
+ }
260
+ const foundPath = await name(locateOptions.cwd);
261
+ if (typeof foundPath === "string") {
262
+ return locatePath([foundPath], locateOptions);
263
+ }
264
+ return foundPath;
265
+ }, "runMatcher");
266
+ const matches = [];
267
+ while (true) {
268
+ const foundPath = await runMatcher({ ...options, cwd: directory });
269
+ if (foundPath === findUpStop) {
270
+ break;
271
+ }
272
+ if (foundPath) {
273
+ matches.push(path2.resolve(directory, foundPath));
274
+ }
275
+ if (directory === stopAt || matches.length >= limit) {
276
+ break;
277
+ }
278
+ directory = path2.dirname(directory);
279
+ }
280
+ return matches;
281
+ }
282
+ __name(findUpMultiple, "findUpMultiple");
283
+ function findUpMultipleSync(name, options = {}) {
284
+ let directory = path2.resolve(toPath2(options.cwd) ?? "");
285
+ const { root } = path2.parse(directory);
286
+ const stopAt = path2.resolve(directory, toPath2(options.stopAt) ?? root);
287
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
288
+ const paths = [name].flat();
289
+ const runMatcher = /* @__PURE__ */ __name((locateOptions) => {
290
+ if (typeof name !== "function") {
291
+ return locatePathSync(paths, locateOptions);
292
+ }
293
+ const foundPath = name(locateOptions.cwd);
294
+ if (typeof foundPath === "string") {
295
+ return locatePathSync([foundPath], locateOptions);
296
+ }
297
+ return foundPath;
298
+ }, "runMatcher");
299
+ const matches = [];
300
+ while (true) {
301
+ const foundPath = runMatcher({ ...options, cwd: directory });
302
+ if (foundPath === findUpStop) {
303
+ break;
304
+ }
305
+ if (foundPath) {
306
+ matches.push(path2.resolve(directory, foundPath));
307
+ }
308
+ if (directory === stopAt || matches.length >= limit) {
309
+ break;
310
+ }
311
+ directory = path2.dirname(directory);
312
+ }
313
+ return matches;
314
+ }
315
+ __name(findUpMultipleSync, "findUpMultipleSync");
316
+ async function findUp(name, options = {}) {
317
+ const matches = await findUpMultiple(name, { ...options, limit: 1 });
318
+ return matches[0];
319
+ }
320
+ __name(findUp, "findUp");
321
+ function findUpSync(name, options = {}) {
322
+ const matches = findUpMultipleSync(name, { ...options, limit: 1 });
323
+ return matches[0];
324
+ }
325
+ __name(findUpSync, "findUpSync");
326
+
327
+ export {
328
+ findUp,
329
+ findUpSync
330
+ };
@@ -0,0 +1,17 @@
1
+ import CJS_COMPAT_NODE_URL_bs5nei9dti8 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_bs5nei9dti8 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_bs5nei9dti8 from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_bs5nei9dti8.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_bs5nei9dti8.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_bs5nei9dti8.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ var __defProp = Object.defineProperty;
13
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
14
+
15
+ export {
16
+ __name
17
+ };
@@ -0,0 +1,135 @@
1
+ import CJS_COMPAT_NODE_URL_bs5nei9dti8 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_bs5nei9dti8 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_bs5nei9dti8 from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_bs5nei9dti8.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_bs5nei9dti8.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_bs5nei9dti8.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ __name
14
+ } from "./chunk-JXWXEIYP.js";
15
+
16
+ // ../../node_modules/walk-up-path/dist/mjs/index.js
17
+ import { dirname, resolve } from "path";
18
+ var walkUp = /* @__PURE__ */ __name(function* (path) {
19
+ for (path = resolve(path); path; ) {
20
+ yield path;
21
+ const pp = dirname(path);
22
+ if (pp === path) {
23
+ break;
24
+ } else {
25
+ path = pp;
26
+ }
27
+ }
28
+ }, "walkUp");
29
+
30
+ // ../../node_modules/fd-package-json/dist/esm/main.js
31
+ import { resolve as resolve2 } from "node:path";
32
+ import { statSync, readFileSync } from "node:fs";
33
+ function fileExistsSync(path) {
34
+ try {
35
+ const stats = statSync(path);
36
+ return stats.isFile();
37
+ } catch (_err) {
38
+ return false;
39
+ }
40
+ }
41
+ __name(fileExistsSync, "fileExistsSync");
42
+ function findPackagePathSync(cwd) {
43
+ for (const path of walkUp(cwd)) {
44
+ const packagePath = resolve2(path, "package.json");
45
+ const hasPackageJson = fileExistsSync(packagePath);
46
+ if (hasPackageJson) {
47
+ return packagePath;
48
+ }
49
+ }
50
+ return null;
51
+ }
52
+ __name(findPackagePathSync, "findPackagePathSync");
53
+ function findPackageSync(cwd) {
54
+ const packagePath = findPackagePathSync(cwd);
55
+ if (!packagePath) {
56
+ return null;
57
+ }
58
+ try {
59
+ const source = readFileSync(packagePath, { encoding: "utf8" });
60
+ return JSON.parse(source);
61
+ } catch (_err) {
62
+ return null;
63
+ }
64
+ }
65
+ __name(findPackageSync, "findPackageSync");
66
+
67
+ // src/builders/utils/error-handler.ts
68
+ import { logger, instance as npmLog } from "storybook/internal/node-logger";
69
+ import { dedent } from "ts-dedent";
70
+ var printErrorDetails = /* @__PURE__ */ __name((error) => {
71
+ npmLog.heading = "";
72
+ if (error instanceof Error) {
73
+ if (error.error) {
74
+ logger.error(error.error);
75
+ } else if (error.stats && error.stats.compilation.errors) {
76
+ error.stats.compilation.errors.forEach((e) => logger.plain(e));
77
+ } else {
78
+ logger.error(error);
79
+ }
80
+ } else if (error.compilation?.errors) {
81
+ error.compilation.errors.forEach((e) => logger.plain(e));
82
+ }
83
+ logger.line();
84
+ }, "printErrorDetails");
85
+ var errorSummary = /* @__PURE__ */ __name((error) => {
86
+ return error.close ? dedent`
87
+ FATAL broken build!, will close the process,
88
+ Fix the error below and restart storybook.
89
+ ` : dedent`
90
+ Broken build, fix the error above.
91
+ You may need to refresh the browser.
92
+ `;
93
+ }, "errorSummary");
94
+
95
+ // src/builders/utils/run-compodoc.ts
96
+ import { isAbsolute, relative } from "node:path";
97
+ import { JsPackageManagerFactory } from "storybook/internal/common";
98
+ import { Observable } from "rxjs";
99
+ var hasTsConfigArg = /* @__PURE__ */ __name((args) => args.indexOf("-p") !== -1, "hasTsConfigArg");
100
+ var hasOutputArg = /* @__PURE__ */ __name((args) => args.indexOf("-d") !== -1 || args.indexOf("--output") !== -1, "hasOutputArg");
101
+ var toRelativePath = /* @__PURE__ */ __name((pathToTsConfig) => {
102
+ return isAbsolute(pathToTsConfig) ? relative(".", pathToTsConfig) : pathToTsConfig;
103
+ }, "toRelativePath");
104
+ var runCompodoc = /* @__PURE__ */ __name(({ compodocArgs, tsconfig }, context) => {
105
+ return new Observable((observer) => {
106
+ const tsConfigPath = toRelativePath(tsconfig);
107
+ const finalCompodocArgs = [
108
+ ...hasTsConfigArg(compodocArgs) ? [] : ["-p", tsConfigPath],
109
+ ...hasOutputArg(compodocArgs) ? [] : ["-d", `${context.workspaceRoot || "."}`],
110
+ ...compodocArgs
111
+ ];
112
+ const packageManager = JsPackageManagerFactory.getPackageManager();
113
+ try {
114
+ const stdout = packageManager.runPackageCommandSync(
115
+ "compodoc",
116
+ finalCompodocArgs,
117
+ context.workspaceRoot,
118
+ "inherit"
119
+ );
120
+ context.logger.info(stdout);
121
+ observer.next();
122
+ observer.complete();
123
+ } catch (e) {
124
+ context.logger.error(e);
125
+ observer.error();
126
+ }
127
+ });
128
+ }, "runCompodoc");
129
+
130
+ export {
131
+ findPackageSync,
132
+ printErrorDetails,
133
+ errorSummary,
134
+ runCompodoc
135
+ };
@@ -1,31 +1,140 @@
1
- 'use strict';
1
+ import CJS_COMPAT_NODE_URL_bs5nei9dti8 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_bs5nei9dti8 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_bs5nei9dti8 from "node:module";
2
4
 
3
- var common = require('storybook/internal/common');
4
- var coreServer = require('storybook/internal/core-server');
5
- var telemetry = require('storybook/internal/telemetry');
6
- var architect = require('@angular-devkit/architect');
7
- var path2 = require('path');
8
- require('fs/promises');
9
- var fs = require('fs');
10
- var process = require('process');
11
- var url = require('url');
12
- var rxjs = require('rxjs');
13
- var operators = require('rxjs/operators');
14
- var nodeLogger = require('storybook/internal/node-logger');
15
- var tsDedent = require('ts-dedent');
5
+ var __filename = CJS_COMPAT_NODE_URL_bs5nei9dti8.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_bs5nei9dti8.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_bs5nei9dti8.createRequire(import.meta.url);
16
8
 
17
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+ import {
13
+ errorSummary,
14
+ findPackageSync,
15
+ printErrorDetails,
16
+ runCompodoc
17
+ } from "../../_node-chunks/chunk-YXFPXXZP.js";
18
+ import {
19
+ findUpSync
20
+ } from "../../_node-chunks/chunk-76OGQITJ.js";
21
+ import {
22
+ __name
23
+ } from "../../_node-chunks/chunk-JXWXEIYP.js";
18
24
 
19
- var path2__default = /*#__PURE__*/_interopDefault(path2);
20
- var fs__default = /*#__PURE__*/_interopDefault(fs);
21
- var process__default = /*#__PURE__*/_interopDefault(process);
22
-
23
- var walkUp=function*(path3){for(path3=path2.resolve(path3);path3;){yield path3;let pp=path2.dirname(path3);if(pp===path3)break;path3=pp;}};function fileExistsSync(path3){try{return fs.statSync(path3).isFile()}catch{return !1}}function findPackagePathSync(cwd){for(let path3 of walkUp(cwd)){let packagePath=path2.resolve(path3,"package.json");if(fileExistsSync(packagePath))return packagePath}return null}function findPackageSync(cwd){let packagePath=findPackagePathSync(cwd);if(!packagePath)return null;try{let source=fs.readFileSync(packagePath,{encoding:"utf8"});return JSON.parse(source)}catch{return null}}var typeMappings={directory:"isDirectory",file:"isFile"};function checkType(type){if(!Object.hasOwnProperty.call(typeMappings,type))throw new Error(`Invalid type specified: ${type}`)}var matchType=(type,stat2)=>stat2[typeMappings[type]](),toPath=urlOrPath=>urlOrPath instanceof URL?url.fileURLToPath(urlOrPath):urlOrPath;function locatePathSync(paths,{cwd=process__default.default.cwd(),type="file",allowSymlinks=!0}={}){checkType(type),cwd=toPath(cwd);let statFunction=allowSymlinks?fs__default.default.statSync:fs__default.default.lstatSync;for(let path_ of paths)try{let stat2=statFunction(path2__default.default.resolve(cwd,path_),{throwIfNoEntry:!1});if(!stat2)continue;if(matchType(type,stat2))return path_}catch{}}function toPath2(urlOrPath){return urlOrPath instanceof URL?url.fileURLToPath(urlOrPath):urlOrPath}var findUpStop=Symbol("findUpStop");function findUpMultipleSync(name,options={}){let directory=path2__default.default.resolve(toPath2(options.cwd)??""),{root}=path2__default.default.parse(directory),stopAt=path2__default.default.resolve(directory,toPath2(options.stopAt)??root),limit=options.limit??Number.POSITIVE_INFINITY,paths=[name].flat(),runMatcher=locateOptions=>{if(typeof name!="function")return locatePathSync(paths,locateOptions);let foundPath=name(locateOptions.cwd);return typeof foundPath=="string"?locatePathSync([foundPath],locateOptions):foundPath},matches=[];for(;;){let foundPath=runMatcher({...options,cwd:directory});if(foundPath===findUpStop||(foundPath&&matches.push(path2__default.default.resolve(directory,foundPath)),directory===stopAt||matches.length>=limit))break;directory=path2__default.default.dirname(directory);}return matches}function findUpSync(name,options={}){return findUpMultipleSync(name,{...options,limit:1})[0]}var printErrorDetails=error=>{nodeLogger.instance.heading="",error instanceof Error?error.error?nodeLogger.logger.error(error.error):error.stats&&error.stats.compilation.errors?error.stats.compilation.errors.forEach(e=>nodeLogger.logger.plain(e)):nodeLogger.logger.error(error):error.compilation?.errors&&error.compilation.errors.forEach(e=>nodeLogger.logger.plain(e)),nodeLogger.logger.line();},errorSummary=error=>error.close?tsDedent.dedent`
24
- FATAL broken build!, will close the process,
25
- Fix the error below and restart storybook.
26
- `:tsDedent.dedent`
27
- Broken build, fix the error above.
28
- You may need to refresh the browser.
29
- `;var hasTsConfigArg=args=>args.indexOf("-p")!==-1,hasOutputArg=args=>args.indexOf("-d")!==-1||args.indexOf("--output")!==-1,toRelativePath=pathToTsConfig=>path2.isAbsolute(pathToTsConfig)?path2.relative(".",pathToTsConfig):pathToTsConfig,runCompodoc=({compodocArgs,tsconfig},context)=>new rxjs.Observable(observer=>{let tsConfigPath=toRelativePath(tsconfig),finalCompodocArgs=[...hasTsConfigArg(compodocArgs)?[]:["-p",tsConfigPath],...hasOutputArg(compodocArgs)?[]:["-d",`${context.workspaceRoot||"."}`],...compodocArgs],packageManager=common.JsPackageManagerFactory.getPackageManager();try{let stdout=packageManager.runPackageCommandSync("compodoc",finalCompodocArgs,context.workspaceRoot,"inherit");context.logger.info(stdout),observer.next(),observer.complete();}catch(e){context.logger.error(e),observer.error();}});telemetry.addToGlobalContext("cliVersion",common.versions.storybook);var commandBuilder=(options,context)=>rxjs.from(setup(options,context)).pipe(operators.switchMap(({tsConfig})=>{let docTSConfig=findUpSync("tsconfig.doc.json",{cwd:options.configDir,stopAt:common.getProjectRoot()});return (options.compodoc?runCompodoc({compodocArgs:options.compodocArgs,tsconfig:docTSConfig??tsConfig},context).pipe(operators.mapTo({tsConfig})):rxjs.of({})).pipe(operators.mapTo({tsConfig}))}),operators.map(({tsConfig})=>{common.getEnvConfig(options,{staticDir:"SBCONFIG_STATIC_DIR",outputDir:"SBCONFIG_OUTPUT_DIR",configDir:"SBCONFIG_CONFIG_DIR"});let{browserTarget,stylePreprocessorOptions,styles,configDir,docs,loglevel,test,outputDir,quiet,enableProdMode=!0,webpackStatsJson,statsJson,debugWebpack,disableTelemetry,assets,previewUrl,sourceMap=!1,preserveSymlinks=!1,experimentalZoneless=!1}=options;return {packageJson:findPackageSync(__dirname),configDir,...docs?{docs}:{},loglevel,outputDir,test,quiet,enableProdMode,disableTelemetry,angularBrowserTarget:browserTarget,angularBuilderContext:context,angularBuilderOptions:{...stylePreprocessorOptions?{stylePreprocessorOptions}:{},...styles?{styles}:{},...assets?{assets}:{},sourceMap,preserveSymlinks,experimentalZoneless},tsConfig,webpackStatsJson,statsJson,debugWebpack,previewUrl}}),operators.switchMap(standaloneOptions=>runInstance({...standaloneOptions,mode:"static"})),operators.map(()=>({success:!0}))),build_storybook_default=architect.createBuilder(commandBuilder);async function setup(options,context){let browserOptions,browserTarget;return options.browserTarget&&(browserTarget=architect.targetFromTargetString(options.browserTarget),browserOptions=await context.validateOptions(await context.getTargetOptions(browserTarget),await context.getBuilderNameForTarget(browserTarget))),{tsConfig:options.tsConfig??findUpSync("tsconfig.json",{cwd:options.configDir,stopAt:common.getProjectRoot()})??browserOptions.tsConfig}}function runInstance(options){return rxjs.from(coreServer.withTelemetry("build",{cliOptions:options,presetOptions:{...options,corePresets:[],overridePresets:[]},printError:printErrorDetails},()=>coreServer.buildStaticStandalone(options))).pipe(operators.catchError(error=>rxjs.throwError(errorSummary(error))))}
30
-
31
- module.exports = build_storybook_default;
25
+ // src/builders/build-storybook/index.ts
26
+ import { getEnvConfig, getProjectRoot, versions } from "storybook/internal/common";
27
+ import { buildStaticStandalone, withTelemetry } from "storybook/internal/core-server";
28
+ import { addToGlobalContext } from "storybook/internal/telemetry";
29
+ import { createBuilder, targetFromTargetString } from "@angular-devkit/architect";
30
+ import { from, of, throwError } from "rxjs";
31
+ import { catchError, map, mapTo, switchMap } from "rxjs/operators";
32
+ addToGlobalContext("cliVersion", versions.storybook);
33
+ var commandBuilder = /* @__PURE__ */ __name((options, context) => {
34
+ const builder = from(setup(options, context)).pipe(
35
+ switchMap(({ tsConfig }) => {
36
+ const docTSConfig = findUpSync("tsconfig.doc.json", {
37
+ cwd: options.configDir,
38
+ stopAt: getProjectRoot()
39
+ });
40
+ const runCompodoc$ = options.compodoc ? runCompodoc(
41
+ { compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig },
42
+ context
43
+ ).pipe(mapTo({ tsConfig })) : of({});
44
+ return runCompodoc$.pipe(mapTo({ tsConfig }));
45
+ }),
46
+ map(({ tsConfig }) => {
47
+ getEnvConfig(options, {
48
+ staticDir: "SBCONFIG_STATIC_DIR",
49
+ outputDir: "SBCONFIG_OUTPUT_DIR",
50
+ configDir: "SBCONFIG_CONFIG_DIR"
51
+ });
52
+ const {
53
+ browserTarget,
54
+ stylePreprocessorOptions,
55
+ styles,
56
+ configDir,
57
+ docs,
58
+ loglevel,
59
+ test,
60
+ outputDir,
61
+ quiet,
62
+ enableProdMode = true,
63
+ webpackStatsJson,
64
+ statsJson,
65
+ debugWebpack,
66
+ disableTelemetry,
67
+ assets,
68
+ previewUrl,
69
+ sourceMap = false,
70
+ preserveSymlinks = false,
71
+ experimentalZoneless = false
72
+ } = options;
73
+ const standaloneOptions = {
74
+ packageJson: findPackageSync(__dirname),
75
+ configDir,
76
+ ...docs ? { docs } : {},
77
+ loglevel,
78
+ outputDir,
79
+ test,
80
+ quiet,
81
+ enableProdMode,
82
+ disableTelemetry,
83
+ angularBrowserTarget: browserTarget,
84
+ angularBuilderContext: context,
85
+ angularBuilderOptions: {
86
+ ...stylePreprocessorOptions ? { stylePreprocessorOptions } : {},
87
+ ...styles ? { styles } : {},
88
+ ...assets ? { assets } : {},
89
+ sourceMap,
90
+ preserveSymlinks,
91
+ experimentalZoneless
92
+ },
93
+ tsConfig,
94
+ webpackStatsJson,
95
+ statsJson,
96
+ debugWebpack,
97
+ previewUrl
98
+ };
99
+ return standaloneOptions;
100
+ }),
101
+ switchMap((standaloneOptions) => runInstance({ ...standaloneOptions, mode: "static" })),
102
+ map(() => {
103
+ return { success: true };
104
+ })
105
+ );
106
+ return builder;
107
+ }, "commandBuilder");
108
+ var build_storybook_default = createBuilder(commandBuilder);
109
+ async function setup(options, context) {
110
+ let browserOptions;
111
+ let browserTarget;
112
+ if (options.browserTarget) {
113
+ browserTarget = targetFromTargetString(options.browserTarget);
114
+ browserOptions = await context.validateOptions(
115
+ await context.getTargetOptions(browserTarget),
116
+ await context.getBuilderNameForTarget(browserTarget)
117
+ );
118
+ }
119
+ return {
120
+ tsConfig: options.tsConfig ?? findUpSync("tsconfig.json", { cwd: options.configDir, stopAt: getProjectRoot() }) ?? browserOptions.tsConfig
121
+ };
122
+ }
123
+ __name(setup, "setup");
124
+ function runInstance(options) {
125
+ return from(
126
+ withTelemetry(
127
+ "build",
128
+ {
129
+ cliOptions: options,
130
+ presetOptions: { ...options, corePresets: [], overridePresets: [] },
131
+ printError: printErrorDetails
132
+ },
133
+ () => buildStaticStandalone(options)
134
+ )
135
+ ).pipe(catchError((error) => throwError(errorSummary(error))));
136
+ }
137
+ __name(runInstance, "runInstance");
138
+ export {
139
+ build_storybook_default as default
140
+ };