@storybook/angular 10.1.0-alpha.8 → 10.1.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.
@@ -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,43 @@
1
+ import CJS_COMPAT_NODE_URL_ysqodpy6j9j from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_ysqodpy6j9j from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_ysqodpy6j9j from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_ysqodpy6j9j.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_ysqodpy6j9j.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_ysqodpy6j9j.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
+ };
@@ -0,0 +1,62 @@
1
+ import CJS_COMPAT_NODE_URL_ysqodpy6j9j from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_ysqodpy6j9j from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_ysqodpy6j9j from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_ysqodpy6j9j.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_ysqodpy6j9j.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_ysqodpy6j9j.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-YMPHFUN2.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
+ // 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
+ "compodoc",
41
+ ...hasTsConfigArg(compodocArgs) ? [] : ["-p", tsConfigPath],
42
+ ...hasOutputArg(compodocArgs) ? [] : ["-d", `${context.workspaceRoot || "."}`],
43
+ ...compodocArgs
44
+ ], packageManager = JsPackageManagerFactory.getPackageManager();
45
+ try {
46
+ packageManager.runPackageCommand({
47
+ args: finalCompodocArgs,
48
+ cwd: context.workspaceRoot
49
+ }).then((result) => {
50
+ context.logger.info(result.stdout), observer.next(), observer.complete();
51
+ });
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
+ };
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_49fwnnwgxdq from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_49fwnnwgxdq from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_49fwnnwgxdq from "node:module";
1
+ import CJS_COMPAT_NODE_URL_ysqodpy6j9j from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_ysqodpy6j9j from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_ysqodpy6j9j from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_49fwnnwgxdq.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_49fwnnwgxdq.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_49fwnnwgxdq.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_ysqodpy6j9j.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_ysqodpy6j9j.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_ysqodpy6j9j.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -14,117 +14,99 @@ import {
14
14
  printErrorDetails,
15
15
  runCompodoc,
16
16
  up as up2
17
- } from "../../_node-chunks/chunk-CKMZCINS.js";
17
+ } from "../../_node-chunks/chunk-Z5FLT7AH.js";
18
18
  import {
19
19
  up
20
- } from "../../_node-chunks/chunk-C7I5GKOQ.js";
21
- import {
22
- __name
23
- } from "../../_node-chunks/chunk-5KBZJOS2.js";
20
+ } from "../../_node-chunks/chunk-YMPHFUN2.js";
24
21
 
25
22
  // src/builders/build-storybook/index.ts
26
23
  import { readFileSync } from "node:fs";
27
24
  import { getEnvConfig, getProjectRoot, versions } from "storybook/internal/common";
28
25
  import { buildStaticStandalone, withTelemetry } from "storybook/internal/core-server";
29
26
  import { addToGlobalContext } from "storybook/internal/telemetry";
27
+ import { logger } from "storybook/internal/node-logger";
30
28
  import { createBuilder, targetFromTargetString } from "@angular-devkit/architect";
31
29
  import { from, of, throwError } from "rxjs";
32
30
  import { catchError, map, mapTo, switchMap } from "rxjs/operators";
33
31
  import { VERSION } from "@angular/core";
34
32
  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);
33
+ var commandBuilder = (options, context) => from(setup(options, context)).pipe(
34
+ switchMap(({ tsConfig }) => {
35
+ let docTSConfig = up("tsconfig.doc.json", {
36
+ cwd: options.configDir,
37
+ last: getProjectRoot()
38
+ });
39
+ return (options.compodoc ? runCompodoc(
40
+ { compodocArgs: options.compodocArgs, tsconfig: docTSConfig ?? tsConfig },
41
+ context
42
+ ).pipe(mapTo({ tsConfig })) : of({})).pipe(mapTo({ tsConfig }));
43
+ }),
44
+ map(({ tsConfig }) => {
45
+ getEnvConfig(options, {
46
+ staticDir: "SBCONFIG_STATIC_DIR",
47
+ outputDir: "SBCONFIG_OUTPUT_DIR",
48
+ configDir: "SBCONFIG_CONFIG_DIR"
49
+ });
50
+ let {
51
+ browserTarget,
52
+ stylePreprocessorOptions,
53
+ styles,
54
+ configDir,
55
+ docs,
56
+ loglevel,
57
+ test,
58
+ outputDir,
59
+ quiet,
60
+ enableProdMode = !0,
61
+ webpackStatsJson,
62
+ statsJson,
63
+ debugWebpack,
64
+ disableTelemetry,
65
+ assets,
66
+ previewUrl,
67
+ sourceMap = !1,
68
+ preserveSymlinks = !1,
69
+ experimentalZoneless = !!(VERSION.major && Number(VERSION.major) >= 21)
70
+ } = options, packageJsonPath = up2({ cwd: __dirname });
71
+ return {
72
+ packageJson: packageJsonPath != null ? JSON.parse(readFileSync(packageJsonPath, "utf8")) : null,
73
+ configDir,
74
+ ...docs ? { docs } : {},
75
+ loglevel,
76
+ outputDir,
77
+ test,
78
+ quiet,
79
+ enableProdMode,
80
+ disableTelemetry,
81
+ angularBrowserTarget: browserTarget,
82
+ angularBuilderContext: context,
83
+ angularBuilderOptions: {
84
+ ...stylePreprocessorOptions ? { stylePreprocessorOptions } : {},
85
+ ...styles ? { styles } : {},
86
+ ...assets ? { assets } : {},
87
+ sourceMap,
88
+ preserveSymlinks,
89
+ experimentalZoneless
90
+ },
91
+ tsConfig,
92
+ webpackStatsJson,
93
+ statsJson,
94
+ debugWebpack,
95
+ previewUrl
96
+ };
97
+ }),
98
+ switchMap((standaloneOptions) => runInstance({ ...standaloneOptions, mode: "static" })),
99
+ map(() => ({ success: !0 }))
100
+ ), build_storybook_default = createBuilder(commandBuilder);
113
101
  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 {
102
+ let browserOptions, browserTarget;
103
+ return options.browserTarget && (browserTarget = targetFromTargetString(options.browserTarget), browserOptions = await context.validateOptions(
104
+ await context.getTargetOptions(browserTarget),
105
+ await context.getBuilderNameForTarget(browserTarget)
106
+ )), {
124
107
  tsConfig: options.tsConfig ?? up("tsconfig.json", { cwd: options.configDir, last: getProjectRoot() }) ?? browserOptions.tsConfig
125
108
  };
126
109
  }
127
- __name(setup, "setup");
128
110
  function runInstance(options) {
129
111
  return from(
130
112
  withTelemetry(
@@ -134,11 +116,14 @@ function runInstance(options) {
134
116
  presetOptions: { ...options, corePresets: [], overridePresets: [] },
135
117
  printError: printErrorDetails
136
118
  },
137
- () => buildStaticStandalone(options)
119
+ async () => {
120
+ logger.intro("Building storybook");
121
+ let result = await buildStaticStandalone(options);
122
+ return logger.outro("Storybook build completed successfully"), result;
123
+ }
138
124
  )
139
125
  ).pipe(catchError((error) => throwError(errorSummary(error))));
140
126
  }
141
- __name(runInstance, "runInstance");
142
127
  export {
143
128
  build_storybook_default as default
144
129
  };