@storybook/angular 10.1.0-alpha.10 → 10.1.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,9 @@
1
1
  import {
2
- __name,
3
2
  computesTemplateFromComponent,
4
3
  formatPropInTemplate,
5
4
  isComponent,
6
5
  render_exports
7
- } from "./chunk-L4GU2V72.js";
6
+ } from "./chunk-6CHBWP5J.js";
8
7
 
9
8
  // src/client/portable-stories.ts
10
9
  import {
@@ -12,19 +11,15 @@ import {
12
11
  setDefaultProjectAnnotations
13
12
  } from "storybook/preview-api";
14
13
  function setProjectAnnotations(projectAnnotations) {
15
- setDefaultProjectAnnotations(render_exports);
16
- return originalSetProjectAnnotations(
14
+ return setDefaultProjectAnnotations(render_exports), originalSetProjectAnnotations(
17
15
  projectAnnotations
18
16
  );
19
17
  }
20
- __name(setProjectAnnotations, "setProjectAnnotations");
21
18
 
22
19
  // src/client/decorators.ts
23
- var moduleMetadata = /* @__PURE__ */ __name((metadata) => (storyFn) => {
24
- const story = storyFn();
25
- const storyMetadata = story.moduleMetadata || {};
26
- metadata = metadata || {};
27
- return {
20
+ var moduleMetadata = (metadata) => (storyFn) => {
21
+ let story = storyFn(), storyMetadata = story.moduleMetadata || {};
22
+ return metadata = metadata || {}, {
28
23
  ...story,
29
24
  moduleMetadata: {
30
25
  declarations: [...metadata.declarations || [], ...storyMetadata.declarations || []],
@@ -37,11 +32,10 @@ var moduleMetadata = /* @__PURE__ */ __name((metadata) => (storyFn) => {
37
32
  providers: [...metadata.providers || [], ...storyMetadata.providers || []]
38
33
  }
39
34
  };
40
- }, "moduleMetadata");
35
+ };
41
36
  function applicationConfig(config) {
42
37
  return (storyFn) => {
43
- const story = storyFn();
44
- const storyConfig = story.applicationConfig;
38
+ let story = storyFn(), storyConfig = story.applicationConfig;
45
39
  return {
46
40
  ...story,
47
41
  applicationConfig: storyConfig || config ? {
@@ -52,11 +46,8 @@ function applicationConfig(config) {
52
46
  };
53
47
  };
54
48
  }
55
- __name(applicationConfig, "applicationConfig");
56
- var componentWrapperDecorator = /* @__PURE__ */ __name((element, props) => (storyFn, storyContext) => {
57
- const story = storyFn();
58
- const currentProps = typeof props === "function" ? props(storyContext) : props;
59
- const template = isComponent(element) ? computesTemplateFromComponent(element, currentProps ?? {}, story.template) : element(story.template);
49
+ var componentWrapperDecorator = (element, props) => (storyFn, storyContext) => {
50
+ let story = storyFn(), currentProps = typeof props == "function" ? props(storyContext) : props, template = isComponent(element) ? computesTemplateFromComponent(element, currentProps ?? {}, story.template) : element(story.template);
60
51
  return {
61
52
  ...story,
62
53
  template,
@@ -67,21 +58,15 @@ var componentWrapperDecorator = /* @__PURE__ */ __name((element, props) => (stor
67
58
  }
68
59
  } : {}
69
60
  };
70
- }, "componentWrapperDecorator");
61
+ };
71
62
 
72
63
  // src/client/argsToTemplate.ts
73
64
  function argsToTemplate(args, options = {}) {
74
- const includeSet = options.include ? new Set(options.include) : null;
75
- const excludeSet = options.exclude ? new Set(options.exclude) : null;
76
- return Object.entries(args).filter(([key]) => args[key] !== void 0).filter(([key]) => {
77
- if (includeSet) return includeSet.has(key);
78
- if (excludeSet) return !excludeSet.has(key);
79
- return true;
80
- }).map(
81
- ([key, value]) => typeof value === "function" ? `(${key})="${formatPropInTemplate(key)}($event)"` : `[${key}]="${formatPropInTemplate(key)}"`
65
+ let includeSet = options.include ? new Set(options.include) : null, excludeSet = options.exclude ? new Set(options.exclude) : null;
66
+ return Object.entries(args).filter(([key]) => args[key] !== void 0).filter(([key]) => includeSet ? includeSet.has(key) : excludeSet ? !excludeSet.has(key) : !0).map(
67
+ ([key, value]) => typeof value == "function" ? `(${key})="${formatPropInTemplate(key)}($event)"` : `[${key}]="${formatPropInTemplate(key)}"`
82
68
  ).join(" ");
83
69
  }
84
- __name(argsToTemplate, "argsToTemplate");
85
70
 
86
71
  export {
87
72
  setProjectAnnotations,
@@ -0,0 +1,62 @@
1
+ import CJS_COMPAT_NODE_URL_qv1b0zi7im from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_qv1b0zi7im from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_qv1b0zi7im from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_qv1b0zi7im.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_qv1b0zi7im.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_qv1b0zi7im.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-CI264AI2.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.plain(e)) : logger.error(error) : error.compilation?.errors && error.compilation.errors.forEach((e) => logger.plain(e)), logger.line();
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
+ // src/builders/utils/run-compodoc.ts
35
+ import { isAbsolute, relative } from "node:path";
36
+ import { JsPackageManagerFactory } from "storybook/internal/common";
37
+ import { Observable } from "rxjs";
38
+ var hasTsConfigArg = (args) => args.indexOf("-p") !== -1, hasOutputArg = (args) => args.indexOf("-d") !== -1 || args.indexOf("--output") !== -1, toRelativePath = (pathToTsConfig) => isAbsolute(pathToTsConfig) ? relative(".", pathToTsConfig) : pathToTsConfig, runCompodoc = ({ compodocArgs, tsconfig }, context) => new Observable((observer) => {
39
+ let tsConfigPath = toRelativePath(tsconfig), finalCompodocArgs = [
40
+ ...hasTsConfigArg(compodocArgs) ? [] : ["-p", tsConfigPath],
41
+ ...hasOutputArg(compodocArgs) ? [] : ["-d", `${context.workspaceRoot || "."}`],
42
+ ...compodocArgs
43
+ ], packageManager = JsPackageManagerFactory.getPackageManager();
44
+ try {
45
+ let stdout = packageManager.runPackageCommandSync(
46
+ "compodoc",
47
+ finalCompodocArgs,
48
+ context.workspaceRoot,
49
+ "inherit"
50
+ );
51
+ context.logger.info(stdout), observer.next(), observer.complete();
52
+ } catch (e) {
53
+ context.logger.error(e), observer.error();
54
+ }
55
+ });
56
+
57
+ export {
58
+ up2 as up,
59
+ printErrorDetails,
60
+ errorSummary,
61
+ runCompodoc
62
+ };
@@ -0,0 +1,43 @@
1
+ import CJS_COMPAT_NODE_URL_qv1b0zi7im from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_qv1b0zi7im from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_qv1b0zi7im from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_qv1b0zi7im.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_qv1b0zi7im.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_qv1b0zi7im.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+
13
+ // ../../node_modules/empathic/find.mjs
14
+ import { join as join2 } from "node:path";
15
+ import { existsSync, statSync } from "node:fs";
16
+
17
+ // ../../node_modules/empathic/walk.mjs
18
+ import { dirname } from "node:path";
19
+
20
+ // ../../node_modules/empathic/resolve.mjs
21
+ import { isAbsolute, join, resolve } from "node:path";
22
+ function absolute(input, root) {
23
+ return isAbsolute(input) ? input : resolve(root || ".", input);
24
+ }
25
+
26
+ // ../../node_modules/empathic/walk.mjs
27
+ function up(base, options) {
28
+ let { last, cwd } = options || {}, tmp = absolute(base, cwd), root = absolute(last || "/", cwd), prev, arr = [];
29
+ for (; prev !== root && (arr.push(tmp), tmp = dirname(prev = tmp), tmp !== prev); )
30
+ ;
31
+ return arr;
32
+ }
33
+
34
+ // ../../node_modules/empathic/find.mjs
35
+ function up2(name, options) {
36
+ let dir, tmp, start = options && options.cwd || "";
37
+ for (dir of up(start, options))
38
+ if (tmp = join2(dir, name), existsSync(tmp)) return tmp;
39
+ }
40
+
41
+ export {
42
+ up2 as up
43
+ };
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_2x62fuu3g38 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_2x62fuu3g38 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_2x62fuu3g38 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_qv1b0zi7im from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_qv1b0zi7im from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_qv1b0zi7im from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_2x62fuu3g38.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_2x62fuu3g38.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_2x62fuu3g38.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_qv1b0zi7im.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_qv1b0zi7im.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_qv1b0zi7im.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -14,13 +14,10 @@ import {
14
14
  printErrorDetails,
15
15
  runCompodoc,
16
16
  up as up2
17
- } from "../../_node-chunks/chunk-QC5VOLQ4.js";
17
+ } from "../../_node-chunks/chunk-6VHHYZRT.js";
18
18
  import {
19
19
  up
20
- } from "../../_node-chunks/chunk-4RJNAYZ2.js";
21
- import {
22
- __name
23
- } from "../../_node-chunks/chunk-CE4PZTEJ.js";
20
+ } from "../../_node-chunks/chunk-CI264AI2.js";
24
21
 
25
22
  // src/builders/build-storybook/index.ts
26
23
  import { readFileSync } from "node:fs";
@@ -32,99 +29,83 @@ import { from, of, throwError } from "rxjs";
32
29
  import { catchError, map, mapTo, switchMap } from "rxjs/operators";
33
30
  import { VERSION } from "@angular/core";
34
31
  addToGlobalContext("cliVersion", versions.storybook);
35
- var commandBuilder = /* @__PURE__ */ __name((options, context) => {
36
- const builder = from(setup(options, context)).pipe(
37
- switchMap(({ tsConfig }) => {
38
- const docTSConfig = up("tsconfig.doc.json", {
39
- cwd: options.configDir,
40
- last: getProjectRoot()
41
- });
42
- const runCompodoc$ = options.compodoc ? runCompodoc(
43
- { compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig },
44
- context
45
- ).pipe(mapTo({ tsConfig })) : of({});
46
- return runCompodoc$.pipe(mapTo({ tsConfig }));
47
- }),
48
- map(({ tsConfig }) => {
49
- getEnvConfig(options, {
50
- staticDir: "SBCONFIG_STATIC_DIR",
51
- outputDir: "SBCONFIG_OUTPUT_DIR",
52
- configDir: "SBCONFIG_CONFIG_DIR"
53
- });
54
- const {
55
- browserTarget,
56
- stylePreprocessorOptions,
57
- styles,
58
- configDir,
59
- docs,
60
- loglevel,
61
- test,
62
- outputDir,
63
- quiet,
64
- enableProdMode = true,
65
- webpackStatsJson,
66
- statsJson,
67
- debugWebpack,
68
- disableTelemetry,
69
- assets,
70
- previewUrl,
71
- sourceMap = false,
72
- preserveSymlinks = false,
73
- experimentalZoneless = !!(VERSION.major && Number(VERSION.major) >= 21)
74
- } = options;
75
- const packageJsonPath = up2({ cwd: __dirname });
76
- const packageJson = packageJsonPath != null ? JSON.parse(readFileSync(packageJsonPath, "utf8")) : null;
77
- const standaloneOptions = {
78
- packageJson,
79
- configDir,
80
- ...docs ? { docs } : {},
81
- loglevel,
82
- outputDir,
83
- test,
84
- quiet,
85
- enableProdMode,
86
- disableTelemetry,
87
- angularBrowserTarget: browserTarget,
88
- angularBuilderContext: context,
89
- angularBuilderOptions: {
90
- ...stylePreprocessorOptions ? { stylePreprocessorOptions } : {},
91
- ...styles ? { styles } : {},
92
- ...assets ? { assets } : {},
93
- sourceMap,
94
- preserveSymlinks,
95
- experimentalZoneless
96
- },
97
- tsConfig,
98
- webpackStatsJson,
99
- statsJson,
100
- debugWebpack,
101
- previewUrl
102
- };
103
- return standaloneOptions;
104
- }),
105
- switchMap((standaloneOptions) => runInstance({ ...standaloneOptions, mode: "static" })),
106
- map(() => {
107
- return { success: true };
108
- })
109
- );
110
- return builder;
111
- }, "commandBuilder");
112
- var build_storybook_default = createBuilder(commandBuilder);
32
+ var commandBuilder = (options, context) => from(setup(options, context)).pipe(
33
+ switchMap(({ tsConfig }) => {
34
+ let docTSConfig = up("tsconfig.doc.json", {
35
+ cwd: options.configDir,
36
+ last: getProjectRoot()
37
+ });
38
+ return (options.compodoc ? runCompodoc(
39
+ { compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig },
40
+ context
41
+ ).pipe(mapTo({ tsConfig })) : of({})).pipe(mapTo({ tsConfig }));
42
+ }),
43
+ map(({ tsConfig }) => {
44
+ getEnvConfig(options, {
45
+ staticDir: "SBCONFIG_STATIC_DIR",
46
+ outputDir: "SBCONFIG_OUTPUT_DIR",
47
+ configDir: "SBCONFIG_CONFIG_DIR"
48
+ });
49
+ let {
50
+ browserTarget,
51
+ stylePreprocessorOptions,
52
+ styles,
53
+ configDir,
54
+ docs,
55
+ loglevel,
56
+ test,
57
+ outputDir,
58
+ quiet,
59
+ enableProdMode = !0,
60
+ webpackStatsJson,
61
+ statsJson,
62
+ debugWebpack,
63
+ disableTelemetry,
64
+ assets,
65
+ previewUrl,
66
+ sourceMap = !1,
67
+ preserveSymlinks = !1,
68
+ experimentalZoneless = !!(VERSION.major && Number(VERSION.major) >= 21)
69
+ } = options, packageJsonPath = up2({ cwd: __dirname });
70
+ return {
71
+ packageJson: packageJsonPath != null ? JSON.parse(readFileSync(packageJsonPath, "utf8")) : null,
72
+ configDir,
73
+ ...docs ? { docs } : {},
74
+ loglevel,
75
+ outputDir,
76
+ test,
77
+ quiet,
78
+ enableProdMode,
79
+ disableTelemetry,
80
+ angularBrowserTarget: browserTarget,
81
+ angularBuilderContext: context,
82
+ angularBuilderOptions: {
83
+ ...stylePreprocessorOptions ? { stylePreprocessorOptions } : {},
84
+ ...styles ? { styles } : {},
85
+ ...assets ? { assets } : {},
86
+ sourceMap,
87
+ preserveSymlinks,
88
+ experimentalZoneless
89
+ },
90
+ tsConfig,
91
+ webpackStatsJson,
92
+ statsJson,
93
+ debugWebpack,
94
+ previewUrl
95
+ };
96
+ }),
97
+ switchMap((standaloneOptions) => runInstance({ ...standaloneOptions, mode: "static" })),
98
+ map(() => ({ success: !0 }))
99
+ ), build_storybook_default = createBuilder(commandBuilder);
113
100
  async function setup(options, context) {
114
- let browserOptions;
115
- let browserTarget;
116
- if (options.browserTarget) {
117
- browserTarget = targetFromTargetString(options.browserTarget);
118
- browserOptions = await context.validateOptions(
119
- await context.getTargetOptions(browserTarget),
120
- await context.getBuilderNameForTarget(browserTarget)
121
- );
122
- }
123
- return {
101
+ let browserOptions, browserTarget;
102
+ return options.browserTarget && (browserTarget = targetFromTargetString(options.browserTarget), browserOptions = await context.validateOptions(
103
+ await context.getTargetOptions(browserTarget),
104
+ await context.getBuilderNameForTarget(browserTarget)
105
+ )), {
124
106
  tsConfig: options.tsConfig ?? up("tsconfig.json", { cwd: options.configDir, last: getProjectRoot() }) ?? browserOptions.tsConfig
125
107
  };
126
108
  }
127
- __name(setup, "setup");
128
109
  function runInstance(options) {
129
110
  return from(
130
111
  withTelemetry(
@@ -138,7 +119,6 @@ function runInstance(options) {
138
119
  )
139
120
  ).pipe(catchError((error) => throwError(errorSummary(error))));
140
121
  }
141
- __name(runInstance, "runInstance");
142
122
  export {
143
123
  build_storybook_default as default
144
124
  };