@storybook/angular 9.0.0-alpha.9 → 9.0.0-beta.1

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.
@@ -177,7 +177,7 @@ class AbstractRenderer {
177
177
  const previousStoryRenderInfo = this.previousStoryRenderInfo.get(targetDOMNode);
178
178
  const currentStoryRender = {
179
179
  storyFnAngular,
180
- moduleMetadataSnapshot: (0, telejson_1.stringify)(moduleMetadata, { allowFunction: false }),
180
+ moduleMetadataSnapshot: (0, telejson_1.stringify)(moduleMetadata, { maxDepth: 50 }),
181
181
  };
182
182
  this.previousStoryRenderInfo.set(targetDOMNode, currentStoryRender);
183
183
  if (
@@ -50,11 +50,9 @@ const uniqueArray = (arr) => {
50
50
  };
51
51
  exports.uniqueArray = uniqueArray;
52
52
  class PropertyExtractor {
53
- /* eslint-enable @typescript-eslint/lines-between-class-members */
54
53
  constructor(metadata, component) {
55
54
  this.metadata = metadata;
56
55
  this.component = component;
57
- /* eslint-disable @typescript-eslint/lines-between-class-members */
58
56
  this.declarations = [];
59
57
  /**
60
58
  * Analyze NgModule Metadata
@@ -12,7 +12,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.InputComponent = exports.ButtonAccent = exports.exportedConstant = void 0;
15
- /* eslint-disable no-underscore-dangle */
16
15
  const core_1 = require("@angular/core");
17
16
  exports.exportedConstant = 'An exported constant';
18
17
  var ButtonAccent;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractComponentDescription = exports.extractArgTypes = exports.extractArgTypesFromData = exports.extractType = exports.findComponentByName = exports.checkValidCompodocJson = exports.checkValidComponentOrDirective = exports.getCompodocJson = exports.setCompodocJson = exports.isMethod = void 0;
4
- /* eslint-disable no-underscore-dangle */
5
4
  const client_logger_1 = require("storybook/internal/client-logger");
6
5
  const global_1 = require("@storybook/global");
7
6
  const isMethod = (methodOrProp) => {
@@ -23,39 +23,31 @@ exports.skipSourceRender = skipSourceRender;
23
23
  */
24
24
  const sourceDecorator = (storyFn, context) => {
25
25
  const story = storyFn();
26
- if ((0, exports.skipSourceRender)(context)) {
27
- return story;
28
- }
29
- const channel = preview_api_1.addons.getChannel();
30
- const { props, userDefinedTemplate } = story;
31
- const { component, argTypes, parameters } = context;
32
- const template = parameters.docs?.source?.excludeDecorators
33
- ? context.originalStoryFn(context.args, context).template
34
- : story.template;
35
- let toEmit;
26
+ const source = (0, preview_api_1.useRef)(undefined);
36
27
  (0, preview_api_1.useEffect)(() => {
37
- if (toEmit) {
38
- const { id, unmappedArgs } = context;
39
- const format = parameters?.docs?.source?.format ?? true;
40
- channel.emit(docs_tools_1.SNIPPET_RENDERED, {
41
- id,
42
- args: unmappedArgs,
43
- source: toEmit,
44
- format: format === true ? 'angular' : format,
45
- });
28
+ if ((0, exports.skipSourceRender)(context)) {
29
+ return;
46
30
  }
47
- });
48
- if (component && !userDefinedTemplate) {
49
- const source = (0, renderer_1.computesTemplateSourceFromComponent)(component, props, argTypes);
50
- // We might have a story with a Directive or Service defined as the component
51
- // In these cases there might exist a template, even if we aren't able to create source from component
52
- if (source || template) {
53
- toEmit = source || template;
31
+ const { props, userDefinedTemplate } = story;
32
+ const { component, argTypes, parameters } = context;
33
+ const template = parameters.docs?.source?.excludeDecorators
34
+ ? context.originalStoryFn(context.args, context).template
35
+ : story.template;
36
+ if (component && !userDefinedTemplate) {
37
+ const sourceFromComponent = (0, renderer_1.computesTemplateSourceFromComponent)(component, props, argTypes);
38
+ // We might have a story with a Directive or Service defined as the component
39
+ // In these cases there might exist a template, even if we aren't able to create source from component
40
+ const newSource = sourceFromComponent || template;
41
+ if (newSource && newSource !== source.current) {
42
+ (0, preview_api_1.emitTransformCode)(newSource, context);
43
+ source.current = newSource;
44
+ }
54
45
  }
55
- }
56
- else if (template) {
57
- toEmit = template;
58
- }
46
+ else if (template && template !== source.current) {
47
+ (0, preview_api_1.emitTransformCode)(template, context);
48
+ source.current = template;
49
+ }
50
+ });
59
51
  return story;
60
52
  };
61
53
  exports.sourceDecorator = sourceDecorator;
@@ -26,9 +26,7 @@ export type Decorator<TArgs = StrictArgs> = DecoratorFunction<AngularRenderer, T
26
26
  export type Loader<TArgs = StrictArgs> = LoaderFunction<AngularRenderer, TArgs>;
27
27
  export type StoryContext<TArgs = StrictArgs> = GenericStoryContext<AngularRenderer, TArgs>;
28
28
  export type Preview = ProjectAnnotations<AngularRenderer>;
29
- /**
30
- * Utility type that transforms InputSignal and EventEmitter types
31
- */
29
+ /** Utility type that transforms InputSignal and EventEmitter types */
32
30
  type TransformComponentType<T> = TransformInputSignalType<TransformOutputSignalType<TransformEventType<T>>>;
33
31
  // @ts-ignore
34
32
  type AngularInputSignal<T> = AngularCore.InputSignal<T>;
@@ -4,28 +4,7 @@ const { generateI18nBrowserWebpackConfigFromContext, } = require('@angular-devki
4
4
  const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
5
5
  const { filterOutStylingRules } = require('./utils/filter-out-styling-rules');
6
6
  const { default: StorybookNormalizeAngularEntryPlugin, } = require('./plugins/storybook-normalize-angular-entry-plugin');
7
- const getAngularWebpackUtils = () => {
8
- try {
9
- // Angular < 16.1.0
10
- const { getCommonConfig, getStylesConfig, getDevServerConfig, getTypeScriptConfig, } = require('@angular-devkit/build-angular/src/webpack/configs');
11
- return {
12
- getCommonConfig,
13
- getStylesConfig,
14
- getDevServerConfig,
15
- getTypeScriptConfig,
16
- };
17
- }
18
- catch (e) {
19
- // Angular > 16.1.0
20
- const { getCommonConfig, getStylesConfig, getDevServerConfig, getTypeScriptConfig, } = require('@angular-devkit/build-angular/src/tools/webpack/configs');
21
- return {
22
- getCommonConfig,
23
- getStylesConfig,
24
- getDevServerConfig,
25
- getTypeScriptConfig,
26
- };
27
- }
28
- };
7
+ const { getCommonConfig, getStylesConfig, getDevServerConfig, getTypeScriptConfig, } = require('@angular-devkit/build-angular/src/tools/webpack/configs');
29
8
  /**
30
9
  * Extract webpack config from angular-cli 13.x.x ⚠️ This file is in JavaScript to not use
31
10
  * TypeScript. Because current storybook TypeScript version is not compatible with Angular CLI.
@@ -36,7 +15,6 @@ const getAngularWebpackUtils = () => {
36
15
  */
37
16
  exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }) => {
38
17
  /** Get angular-cli Webpack config */
39
- const { getCommonConfig, getStylesConfig, getDevServerConfig, getTypeScriptConfig } = getAngularWebpackUtils();
40
18
  const { config: cliConfig } = await generateI18nBrowserWebpackConfigFromContext({
41
19
  // Default options
42
20
  index: 'noop-index',
@@ -60,6 +38,9 @@ exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }
60
38
  getStylesConfig(wco),
61
39
  getTypeScriptConfig ? getTypeScriptConfig(wco) : getDevServerConfig(wco),
62
40
  ]);
41
+ if (!builderOptions.experimentalZoneless && !cliConfig.entry.polyfills?.includes('zone.js')) {
42
+ cliConfig.entry.polyfills.push('zone.js');
43
+ }
63
44
  /** Merge baseConfig Webpack with angular-cli Webpack */
64
45
  const entry = [
65
46
  ...(cliConfig.entry.polyfills ?? []),
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.webpack = exports.runNgcc = void 0;
4
- const node_fs_1 = require("node:fs");
5
4
  const node_path_1 = require("node:path");
6
5
  /**
7
6
  * Source :
@@ -45,31 +44,17 @@ const runNgcc = async () => {
45
44
  };
46
45
  exports.runNgcc = runNgcc;
47
46
  const webpack = async (webpackConfig, options) => {
48
- const packageJsonPath = require.resolve('@angular/core/package.json');
49
- const packageJson = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf8'));
50
- const VERSION = packageJson.version;
51
47
  const framework = await options.presets.apply('framework');
52
48
  const angularOptions = (typeof framework === 'object' ? framework.options : {});
53
- const angularMajorVersion = VERSION.split('.')[0];
54
- const isAngular16OrNewer = parseInt(angularMajorVersion, 10) >= 16;
55
49
  // Default to true, if undefined
56
50
  if (angularOptions.enableIvy === false) {
57
51
  return webpackConfig;
58
52
  }
59
- let extraMainFields = [];
60
- if (angularOptions.enableNgcc !== false && !isAngular16OrNewer) {
61
- // TODO: Drop if Angular 14 and 15 are not supported anymore
62
- (0, exports.runNgcc)();
63
- extraMainFields = ['es2015_ivy_ngcc', 'module_ivy_ngcc', 'main_ivy_ngcc'];
64
- }
65
- if (!isAngular16OrNewer) {
66
- extraMainFields.push('es2015');
67
- }
68
53
  return {
69
54
  ...webpackConfig,
70
55
  resolve: {
71
56
  ...webpackConfig.resolve,
72
- mainFields: [...extraMainFields, 'browser', 'module', 'main'],
57
+ mainFields: ['browser', 'module', 'main'],
73
58
  },
74
59
  };
75
60
  };
package/dist/types.d.ts CHANGED
@@ -23,6 +23,5 @@ type StorybookConfigFramework = {
23
23
  export type StorybookConfig = Omit<StorybookConfigBase, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
24
24
  export interface AngularOptions {
25
25
  enableIvy?: boolean;
26
- enableNgcc?: boolean;
27
26
  }
28
27
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/angular",
3
- "version": "9.0.0-alpha.9",
3
+ "version": "9.0.0-beta.1",
4
4
  "description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
5
5
  "keywords": [
6
6
  "storybook",
@@ -52,8 +52,8 @@
52
52
  "prep": "rimraf dist && jiti ../../../scripts/prepare/tsc.ts"
53
53
  },
54
54
  "dependencies": {
55
- "@storybook/builder-webpack5": "9.0.0-alpha.9",
56
- "@storybook/core-webpack": "9.0.0-alpha.9",
55
+ "@storybook/builder-webpack5": "9.0.0-beta.1",
56
+ "@storybook/core-webpack": "9.0.0-beta.1",
57
57
  "@storybook/global": "^5.0.0",
58
58
  "@types/react": "^18.0.37",
59
59
  "@types/react-dom": "^18.0.11",
@@ -62,7 +62,7 @@
62
62
  "fd-package-json": "^1.2.0",
63
63
  "find-up": "^5.0.0",
64
64
  "semver": "^7.3.7",
65
- "telejson": "^7.2.0",
65
+ "telejson": "8.0.0",
66
66
  "ts-dedent": "^2.0.0",
67
67
  "tsconfig-paths-webpack-plugin": "^4.0.1",
68
68
  "util-deprecate": "^1.0.2",
@@ -93,22 +93,22 @@
93
93
  "zone.js": "^0.15.0"
94
94
  },
95
95
  "peerDependencies": {
96
- "@angular-devkit/architect": ">=0.1500.0 < 0.2000.0",
97
- "@angular-devkit/build-angular": ">=15.0.0 < 20.0.0",
98
- "@angular-devkit/core": ">=15.0.0 < 20.0.0",
99
- "@angular/animations": ">=15.0.0 < 20.0.0",
100
- "@angular/cli": ">=15.0.0 < 20.0.0",
101
- "@angular/common": ">=15.0.0 < 20.0.0",
102
- "@angular/compiler": ">=15.0.0 < 20.0.0",
103
- "@angular/compiler-cli": ">=15.0.0 < 20.0.0",
104
- "@angular/core": ">=15.0.0 < 20.0.0",
105
- "@angular/forms": ">=15.0.0 < 20.0.0",
106
- "@angular/platform-browser": ">=15.0.0 < 20.0.0",
107
- "@angular/platform-browser-dynamic": ">=15.0.0 < 20.0.0",
108
- "rxjs": "^6.0.0 || ^7.4.0",
109
- "storybook": "^9.0.0-alpha.9",
96
+ "@angular-devkit/architect": ">=0.1800.0 < 0.2000.0",
97
+ "@angular-devkit/build-angular": ">=18.0.0 < 20.0.0",
98
+ "@angular-devkit/core": ">=18.0.0 < 20.0.0",
99
+ "@angular/animations": ">=18.0.0 < 20.0.0",
100
+ "@angular/cli": ">=18.0.0 < 20.0.0",
101
+ "@angular/common": ">=18.0.0 < 20.0.0",
102
+ "@angular/compiler": ">=18.0.0 < 20.0.0",
103
+ "@angular/compiler-cli": ">=18.0.0 < 20.0.0",
104
+ "@angular/core": ">=18.0.0 < 20.0.0",
105
+ "@angular/forms": ">=18.0.0 < 20.0.0",
106
+ "@angular/platform-browser": ">=18.0.0 < 20.0.0",
107
+ "@angular/platform-browser-dynamic": ">=18.0.0 < 20.0.0",
108
+ "rxjs": "^6.5.3 || ^7.4.0",
109
+ "storybook": "^9.0.0-beta.1",
110
110
  "typescript": "^4.9.0 || ^5.0.0",
111
- "zone.js": ">= 0.11.1 < 1.0.0"
111
+ "zone.js": ">=0.14.0"
112
112
  },
113
113
  "peerDependenciesMeta": {
114
114
  "@angular/animations": {
@@ -122,7 +122,7 @@
122
122
  }
123
123
  },
124
124
  "engines": {
125
- "node": ">=18.0.0"
125
+ "node": ">=20.0.0"
126
126
  },
127
127
  "publishConfig": {
128
128
  "access": "public"