@storybook/angular 7.1.0-alpha.9 → 7.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.
Files changed (38) hide show
  1. package/dist/builders/build-storybook/index.d.ts +13 -2
  2. package/dist/builders/build-storybook/index.js +5 -4
  3. package/dist/builders/build-storybook/index.spec.js +39 -41
  4. package/dist/builders/start-storybook/index.d.ts +10 -3
  5. package/dist/builders/start-storybook/index.js +12 -6
  6. package/dist/builders/start-storybook/index.spec.js +35 -34
  7. package/dist/builders/start-storybook/schema.json +9 -0
  8. package/dist/builders/utils/run-compodoc.js +1 -1
  9. package/dist/builders/utils/run-compodoc.spec.js +14 -29
  10. package/dist/client/angular-beta/AbstractRenderer.d.ts +3 -6
  11. package/dist/client/angular-beta/AbstractRenderer.js +3 -5
  12. package/dist/client/angular-beta/RendererFactory.d.ts +1 -1
  13. package/dist/client/angular-beta/RendererFactory.js +5 -5
  14. package/dist/client/angular-beta/RendererFactory.test.js +23 -156
  15. package/dist/client/angular-beta/StorybookModule.d.ts +1 -1
  16. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +6 -3
  17. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +1 -5
  18. package/dist/client/angular-beta/utils/PropertyExtractor.js +1 -1
  19. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +1 -0
  20. package/dist/client/docs/angular-properties.test.js +17 -11
  21. package/dist/client/docs/compodoc.test.js +11 -11
  22. package/dist/client/docs/sourceDecorator.js +2 -2
  23. package/dist/client/public-api.js +2 -2
  24. package/dist/client/render.d.ts +1 -1
  25. package/dist/client/render.js +2 -3
  26. package/dist/server/angular-cli-webpack.js +24 -1
  27. package/dist/server/framework-preset-angular-ivy.js +12 -11
  28. package/jest.config.js +8 -8
  29. package/package.json +48 -50
  30. package/src/server/angular-cli-webpack.d.ts +7 -0
  31. package/src/server/angular-cli-webpack.js +127 -0
  32. package/src/server/plugins/storybook-normalize-angular-entry-plugin.js +54 -0
  33. package/src/typings.d.ts +21 -0
  34. package/template/cli/header.component.ts +1 -1
  35. package/template/cli/page.component.ts +1 -1
  36. package/template/components/form.component.ts +1 -1
  37. package/dist/server/framework-preset-angular-cli.test.d.ts +0 -1
  38. package/dist/server/framework-preset-angular-cli.test.js +0 -698
package/jest.config.js CHANGED
@@ -2,22 +2,22 @@ const path = require('path');
2
2
 
3
3
  module.exports = {
4
4
  displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
5
- preset: 'jest-preset-angular',
5
+ preset: 'jest-preset-angular/presets/defaults-esm',
6
6
  setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
7
7
  transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid)'],
8
8
  snapshotFormat: {
9
9
  escapeString: true,
10
10
  printBasicPrototype: true,
11
11
  },
12
- globals: {
13
- 'ts-jest': {
14
- tsconfig: '<rootDir>/tsconfig.spec.json',
15
- stringifyContentPathRegex: '\\.(html|svg)$',
16
- },
17
- },
18
12
  coverageDirectory: './coverage/testapp',
19
13
  transform: {
20
- '^.+\\.(ts|mjs|js|html)$': 'jest-preset-angular',
14
+ '^.+\\.(ts|mjs|js|html)$': [
15
+ 'jest-preset-angular',
16
+ {
17
+ tsconfig: '<rootDir>/tsconfig.spec.json',
18
+ stringifyContentPathRegex: '\\.(html|svg)$',
19
+ },
20
+ ],
21
21
  },
22
22
  snapshotSerializers: [
23
23
  'jest-preset-angular/build/serializers/no-ng-attributes',
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@storybook/angular",
3
- "version": "7.1.0-alpha.9",
3
+ "version": "7.1.0-beta.0",
4
4
  "description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
5
5
  "keywords": [
6
6
  "storybook",
7
7
  "angular"
8
8
  ],
9
- "homepage": "https://github.com/storybookjs/storybook/tree/main/frameworks/angular",
9
+ "homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/angular",
10
10
  "bugs": {
11
11
  "url": "https://github.com/storybookjs/storybook/issues"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "https://github.com/storybookjs/storybook.git",
16
- "directory": "frameworks/angular"
16
+ "directory": "code/frameworks/angular"
17
17
  },
18
18
  "funding": {
19
19
  "type": "opencollective",
@@ -36,21 +36,20 @@
36
36
  "prep": "../../../scripts/prepare/tsc.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@storybook/builder-webpack5": "7.1.0-alpha.9",
40
- "@storybook/cli": "7.1.0-alpha.9",
41
- "@storybook/client-logger": "7.1.0-alpha.9",
42
- "@storybook/core-client": "7.1.0-alpha.9",
43
- "@storybook/core-common": "7.1.0-alpha.9",
44
- "@storybook/core-events": "7.1.0-alpha.9",
45
- "@storybook/core-server": "7.1.0-alpha.9",
46
- "@storybook/core-webpack": "7.1.0-alpha.9",
47
- "@storybook/docs-tools": "7.1.0-alpha.9",
39
+ "@storybook/builder-webpack5": "7.1.0-beta.0",
40
+ "@storybook/cli": "7.1.0-beta.0",
41
+ "@storybook/client-logger": "7.1.0-beta.0",
42
+ "@storybook/core-common": "7.1.0-beta.0",
43
+ "@storybook/core-events": "7.1.0-beta.0",
44
+ "@storybook/core-server": "7.1.0-beta.0",
45
+ "@storybook/core-webpack": "7.1.0-beta.0",
46
+ "@storybook/docs-tools": "7.1.0-beta.0",
48
47
  "@storybook/global": "^5.0.0",
49
- "@storybook/manager-api": "7.1.0-alpha.9",
50
- "@storybook/node-logger": "7.1.0-alpha.9",
51
- "@storybook/preview-api": "7.1.0-alpha.9",
52
- "@storybook/telemetry": "7.1.0-alpha.9",
53
- "@storybook/types": "7.1.0-alpha.9",
48
+ "@storybook/manager-api": "7.1.0-beta.0",
49
+ "@storybook/node-logger": "7.1.0-beta.0",
50
+ "@storybook/preview-api": "7.1.0-beta.0",
51
+ "@storybook/telemetry": "7.1.0-beta.0",
52
+ "@storybook/types": "7.1.0-beta.0",
54
53
  "@types/node": "^16.0.0",
55
54
  "@types/react": "^16.14.34",
56
55
  "@types/react-dom": "^16.9.14",
@@ -61,52 +60,51 @@
61
60
  "semver": "^7.3.7",
62
61
  "telejson": "^7.0.3",
63
62
  "ts-dedent": "^2.0.0",
64
- "tsconfig-paths-webpack-plugin": "^3.5.2",
63
+ "tsconfig-paths-webpack-plugin": "^4.0.1",
65
64
  "util-deprecate": "^1.0.2",
66
65
  "webpack": "5"
67
66
  },
68
67
  "devDependencies": {
69
- "@angular-devkit/architect": "^0.1500.4",
70
- "@angular-devkit/build-angular": "^15.1.1",
71
- "@angular-devkit/core": "^15.1.1",
72
- "@angular/animations": "^15.1.1",
73
- "@angular/cli": "^15.1.1",
74
- "@angular/common": "^15.1.1",
75
- "@angular/compiler": "^15.1.1",
76
- "@angular/compiler-cli": "^15.1.1",
77
- "@angular/core": "^15.1.1",
78
- "@angular/forms": "^15.1.1",
79
- "@angular/platform-browser": "^15.1.1",
80
- "@angular/platform-browser-dynamic": "^15.1.1",
81
- "@types/rimraf": "^3.0.2",
68
+ "@angular-devkit/architect": "^0.1600.0-rc.4",
69
+ "@angular-devkit/build-angular": "^16.0.0-rc.4",
70
+ "@angular-devkit/core": "^16.0.0-rc.4",
71
+ "@angular/animations": "^16.0.0-rc.4",
72
+ "@angular/cli": "^16.0.0-rc.4",
73
+ "@angular/common": "^16.0.0-rc.4",
74
+ "@angular/compiler": "^16.0.0-rc.4",
75
+ "@angular/compiler-cli": "^16.0.0-rc.4",
76
+ "@angular/core": "^16.0.0-rc.4",
77
+ "@angular/forms": "^16.0.0-rc.4",
78
+ "@angular/platform-browser": "^16.0.0-rc.4",
79
+ "@angular/platform-browser-dynamic": "^16.0.0-rc.4",
80
+ "@types/cross-spawn": "^6.0.2",
82
81
  "@types/tmp": "^0.2.3",
83
82
  "cross-spawn": "^7.0.3",
84
83
  "jest": "^29.3.1",
85
- "jest-preset-angular": "^12.2.3",
86
- "jest-specific-snapshot": "^7.0.0",
87
- "rimraf": "^3.0.2",
84
+ "jest-preset-angular": "^13.0.1",
85
+ "jest-specific-snapshot": "^8.0.0",
88
86
  "tmp": "^0.2.1",
89
- "typescript": "~4.9.3",
87
+ "typescript": "^5.0.4",
90
88
  "webpack": "5",
91
- "zone.js": "^0.12.0"
89
+ "zone.js": "^0.13.0"
92
90
  },
93
91
  "peerDependencies": {
94
- "@angular-devkit/architect": ">=0.1400.0 < 0.1600.0",
95
- "@angular-devkit/build-angular": ">=14.1.0 < 16.0.0",
96
- "@angular-devkit/core": ">=14.1.0 < 16.0.0",
97
- "@angular/cli": ">=14.1.0 < 16.0.0",
98
- "@angular/common": ">=14.1.0 < 16.0.0",
99
- "@angular/compiler": ">=14.1.0 < 16.0.0",
100
- "@angular/compiler-cli": ">=14.1.0 < 16.0.0",
101
- "@angular/core": ">=14.1.0 < 16.0.0",
102
- "@angular/forms": ">=14.1.0 < 16.0.0",
103
- "@angular/platform-browser": ">=14.1.0 < 16.0.0",
104
- "@angular/platform-browser-dynamic": ">=14.1.0 < 16.0.0",
92
+ "@angular-devkit/architect": ">=0.1400.0 < 0.1700.0",
93
+ "@angular-devkit/build-angular": ">=14.1.0 < 17.0.0",
94
+ "@angular-devkit/core": ">=14.1.0 < 17.0.0",
95
+ "@angular/cli": ">=14.1.0 < 17.0.0",
96
+ "@angular/common": ">=14.1.0 < 17.0.0",
97
+ "@angular/compiler": ">=14.1.0 < 17.0.0",
98
+ "@angular/compiler-cli": ">=14.1.0 < 17.0.0",
99
+ "@angular/core": ">=14.1.0 < 17.0.0",
100
+ "@angular/forms": ">=14.1.0 < 17.0.0",
101
+ "@angular/platform-browser": ">=14.1.0 < 17.0.0",
102
+ "@angular/platform-browser-dynamic": ">=14.1.0 < 17.0.0",
105
103
  "@babel/core": "*",
106
104
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
107
105
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
108
106
  "rxjs": "^6.0.0 || ^7.4.0",
109
- "typescript": "^4.0.0",
107
+ "typescript": "^4.0.0 || ^5.0.0",
110
108
  "zone.js": "^0.8.29 || >= 0.9.0 < 1.0.0"
111
109
  },
112
110
  "peerDependenciesMeta": {
@@ -124,5 +122,5 @@
124
122
  "bundler": {
125
123
  "tsConfig": "tsconfig.build.json"
126
124
  },
127
- "gitHead": "ec112401efaae6d3d4996c790a30301177570da9"
128
- }
125
+ "gitHead": "e6a7fd8a655c69780bc20b9749c2699e44beae17"
126
+ }
@@ -0,0 +1,7 @@
1
+ import { JsonObject } from '@angular-devkit/core';
2
+ import { BuilderContext } from '@angular-devkit/architect';
3
+
4
+ export declare function getWebpackConfig(
5
+ baseConfig: any,
6
+ options: { builderOptions: JsonObject; builderContext: BuilderContext }
7
+ ): any;
@@ -0,0 +1,127 @@
1
+ /* eslint-disable global-require */
2
+ // Private angular devkit stuff
3
+ const {
4
+ generateI18nBrowserWebpackConfigFromContext,
5
+ } = require('@angular-devkit/build-angular/src/utils/webpack-browser-config');
6
+ const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
7
+ const { filterOutStylingRules } = require('./utils/filter-out-styling-rules');
8
+ const {
9
+ default: StorybookNormalizeAngularEntryPlugin,
10
+ } = require('./plugins/storybook-normalize-angular-entry-plugin');
11
+
12
+ const getAngularWebpackUtils = () => {
13
+ try {
14
+ // Angular < 16.1.0
15
+ const {
16
+ getCommonConfig,
17
+ getStylesConfig,
18
+ getDevServerConfig,
19
+ getTypeScriptConfig,
20
+ } = require('@angular-devkit/build-angular/src/webpack/configs');
21
+
22
+ return {
23
+ getCommonConfig,
24
+ getStylesConfig,
25
+ getDevServerConfig,
26
+ getTypeScriptConfig,
27
+ };
28
+ } catch (e) {
29
+ // Angular > 16.1.0
30
+ const {
31
+ getCommonConfig,
32
+ getStylesConfig,
33
+ getDevServerConfig,
34
+ getTypeScriptConfig,
35
+ } = require('@angular-devkit/build-angular/src/tools/webpack/configs');
36
+
37
+ return {
38
+ getCommonConfig,
39
+ getStylesConfig,
40
+ getDevServerConfig,
41
+ getTypeScriptConfig,
42
+ };
43
+ }
44
+ };
45
+
46
+ /**
47
+ * Extract webpack config from angular-cli 13.x.x
48
+ * ⚠️ This file is in JavaScript to not use TypeScript. Because current storybook TypeScript version is not compatible with Angular CLI.
49
+ * FIXME: Try another way with TypeScript on future storybook version (7 maybe 🤞)
50
+ *
51
+ * @param {*} baseConfig Previous webpack config from storybook
52
+ * @param {*} options { builderOptions, builderContext }
53
+ */
54
+ exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }) => {
55
+ /**
56
+ * Get angular-cli Webpack config
57
+ */
58
+ const { getCommonConfig, getStylesConfig, getDevServerConfig, getTypeScriptConfig } =
59
+ getAngularWebpackUtils();
60
+ const { config: cliConfig } = await generateI18nBrowserWebpackConfigFromContext(
61
+ {
62
+ // Default options
63
+ index: 'noop-index',
64
+ main: 'noop-main',
65
+ outputPath: 'noop-out',
66
+
67
+ // Options provided by user
68
+ ...builderOptions,
69
+
70
+ // Fixed options
71
+ optimization: false,
72
+ namedChunks: false,
73
+ progress: false,
74
+ buildOptimizer: false,
75
+ aot: false,
76
+ },
77
+ builderContext,
78
+ (wco) => [
79
+ getCommonConfig(wco),
80
+ getStylesConfig(wco),
81
+ getTypeScriptConfig ? getTypeScriptConfig(wco) : getDevServerConfig(wco),
82
+ ]
83
+ );
84
+
85
+ /**
86
+ * Merge baseConfig Webpack with angular-cli Webpack
87
+ */
88
+ const entry = [
89
+ ...baseConfig.entry,
90
+ ...(cliConfig.entry.styles ?? []),
91
+ ...(cliConfig.entry.polyfills ?? []),
92
+ ];
93
+
94
+ // Don't use storybooks styling rules because we have to use rules created by @angular-devkit/build-angular
95
+ // because @angular-devkit/build-angular created rules have include/exclude for global style files.
96
+ const rulesExcludingStyles = filterOutStylingRules(baseConfig);
97
+ const module = {
98
+ ...baseConfig.module,
99
+ rules: [...cliConfig.module.rules, ...rulesExcludingStyles],
100
+ };
101
+
102
+ const plugins = [
103
+ ...(cliConfig.plugins ?? []),
104
+ ...baseConfig.plugins,
105
+ new StorybookNormalizeAngularEntryPlugin(),
106
+ ];
107
+
108
+ const resolve = {
109
+ ...baseConfig.resolve,
110
+ modules: Array.from(new Set([...baseConfig.resolve.modules, ...cliConfig.resolve.modules])),
111
+ plugins: [
112
+ new TsconfigPathsPlugin({
113
+ configFile: builderOptions.tsConfig,
114
+ mainFields: ['browser', 'module', 'main'],
115
+ }),
116
+ ],
117
+ };
118
+
119
+ return {
120
+ ...baseConfig,
121
+ entry,
122
+ module,
123
+ plugins,
124
+ resolve,
125
+ resolveLoader: cliConfig.resolveLoader,
126
+ };
127
+ };
@@ -0,0 +1,54 @@
1
+ const PLUGIN_NAME = 'storybook-normalize-angular-entry-plugin';
2
+
3
+ /**
4
+ * Angular's webpack plugin @angular-devkit/build-angular/src/webpack/plugins/styles-webpack-plugin.js
5
+ * transforms the original webpackOptions.entry point array into a structure like this:
6
+ *
7
+ * ```js
8
+ * {
9
+ * main: {
10
+ * import: [...]
11
+ * },
12
+ *
13
+ * styles: {
14
+ * import: [...]
15
+ * },
16
+ * }
17
+ * ```
18
+ *
19
+ * Storybook throws an __webpack_require__.nmd is not a function error, when another runtime bundle (styles~runtime.iframe.bundle.js) is loaded.
20
+ * To prevent this error, we have to normalize the entry point to only generate one runtime bundle (main~runtime.iframe.bundle.js).
21
+ */
22
+ export default class StorybookNormalizeAngularEntryPlugin {
23
+ constructor(options) {
24
+ this.options = options;
25
+ }
26
+
27
+ apply(compiler) {
28
+ compiler.hooks.environment.tap(PLUGIN_NAME, () => {
29
+ const webpackOptions = compiler.options;
30
+ const entry =
31
+ typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
32
+
33
+ webpackOptions.entry = async () => {
34
+ const entryResult = await entry;
35
+
36
+ if (entryResult.main && entryResult.styles) {
37
+ return {
38
+ main: {
39
+ import: Array.from(
40
+ new Set([...entryResult.main.import, ...entryResult.styles.import])
41
+ ),
42
+ },
43
+ };
44
+ }
45
+
46
+ return entry;
47
+ };
48
+ });
49
+
50
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
51
+ this.compilation = compilation;
52
+ });
53
+ }
54
+ }
@@ -0,0 +1,21 @@
1
+ /* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
2
+
3
+ // will be provided by the webpack define plugin
4
+ declare var NODE_ENV: string | undefined;
5
+
6
+ declare var __STORYBOOK_ADDONS_CHANNEL__: any;
7
+ declare var __STORYBOOK_ADDONS_PREVIEW: any;
8
+ declare var __STORYBOOK_COMPODOC_JSON__: any;
9
+ declare var __STORYBOOK_CLIENT_API__: any;
10
+ declare var __STORYBOOK_PREVIEW__: any;
11
+ declare var __STORYBOOK_STORY_STORE__: any;
12
+ declare var CHANNEL_OPTIONS: any;
13
+ declare var DOCS_OPTIONS: any;
14
+
15
+ declare var FEATURES: import('@storybook/types').StorybookConfig['features'];
16
+
17
+ declare var IS_STORYBOOK: any;
18
+ declare var LOGLEVEL: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | undefined;
19
+ declare var STORIES: any;
20
+ declare var STORYBOOK_ENV: 'angular';
21
+ declare var STORYBOOK_HOOKS_CONTEXT: any;
@@ -4,7 +4,7 @@ import type { User } from './User';
4
4
  @Component({
5
5
  selector: 'storybook-header',
6
6
  template: `<header>
7
- <div class="wrapper">
7
+ <div class="storybook-header">
8
8
  <div>
9
9
  <svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
10
10
  <g fill="none" fillRule="evenodd">
@@ -10,7 +10,7 @@ import type { User } from './User';
10
10
  (onLogin)="doLogin()"
11
11
  (onCreateAccount)="doCreateAccount()"
12
12
  ></storybook-header>
13
- <section>
13
+ <section class="storybook-page">
14
14
  <h2>Pages in Storybook</h2>
15
15
  <p>
16
16
  We recommend building UIs with a
@@ -6,7 +6,7 @@ import { Component, Output, EventEmitter } from '@angular/core';
6
6
  <form id="interaction-test-form" (submit)="handleSubmit($event)">
7
7
  <label>
8
8
  Enter Value
9
- <input type="text" data-testid="value" [value]="value" required />
9
+ <input type="text" data-testid="value" [(ngModel)]="value" required />
10
10
  </label>
11
11
  <button type="submit">Submit</button>
12
12
  <p *ngIf="complete">Completed!!</p>
@@ -1 +0,0 @@
1
- export {};