@storybook/angular 8.0.0-alpha.9 → 8.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 (35) hide show
  1. package/dist/builders/build-storybook/index.d.ts +2 -2
  2. package/dist/builders/build-storybook/index.js +5 -4
  3. package/dist/builders/build-storybook/index.spec.js +8 -10
  4. package/dist/builders/start-storybook/index.js +3 -4
  5. package/dist/builders/start-storybook/index.spec.js +2 -4
  6. package/dist/builders/utils/run-compodoc.js +2 -2
  7. package/dist/builders/utils/run-compodoc.spec.js +1 -1
  8. package/dist/client/angular-beta/AbstractRenderer.d.ts +0 -6
  9. package/dist/client/angular-beta/AbstractRenderer.js +11 -59
  10. package/dist/client/angular-beta/CanvasRenderer.d.ts +0 -1
  11. package/dist/client/angular-beta/CanvasRenderer.js +0 -3
  12. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +65 -66
  13. package/dist/client/angular-beta/DocsRenderer.d.ts +0 -1
  14. package/dist/client/angular-beta/DocsRenderer.js +0 -3
  15. package/dist/client/angular-beta/RendererFactory.test.js +33 -2
  16. package/dist/client/angular-beta/StorybookModule.test.js +36 -35
  17. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +0 -1
  18. package/dist/client/angular-beta/StorybookWrapperComponent.js +11 -22
  19. package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +14 -0
  20. package/dist/client/angular-beta/utils/BootstrapQueue.js +81 -0
  21. package/dist/client/angular-beta/utils/BootstrapQueue.test.d.ts +1 -0
  22. package/dist/client/angular-beta/utils/BootstrapQueue.test.js +162 -0
  23. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +66 -65
  24. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +8 -7
  25. package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -1
  26. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +0 -2
  27. package/dist/client/argsToTemplate.test.js +20 -19
  28. package/dist/client/decorateStory.test.js +28 -27
  29. package/dist/client/docs/__testfixtures__/doc-button/input.js +2 -3
  30. package/dist/client/docs/angular-properties.test.js +4 -26
  31. package/dist/client/public-types.d.ts +0 -10
  32. package/dist/preset.d.ts +2 -3
  33. package/dist/server/angular-cli-webpack.js +0 -1
  34. package/dist/server/framework-preset-angular-ivy.js +0 -1
  35. package/package.json +12 -13
@@ -13,18 +13,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const core_1 = require("@angular/core");
16
+ const vitest_1 = require("vitest");
16
17
  const decorators_1 = require("./decorators");
17
18
  const decorateStory_1 = __importDefault(require("./decorateStory"));
18
- describe('decorateStory', () => {
19
- describe('angular behavior', () => {
20
- it('should use componentWrapperDecorator with args', () => {
19
+ (0, vitest_1.describe)('decorateStory', () => {
20
+ (0, vitest_1.describe)('angular behavior', () => {
21
+ (0, vitest_1.it)('should use componentWrapperDecorator with args', () => {
21
22
  const decorators = [
22
23
  (0, decorators_1.componentWrapperDecorator)(ParentComponent, ({ args }) => args),
23
24
  (0, decorators_1.componentWrapperDecorator)((story) => `<grandparent [grandparentInput]="grandparentInput">${story}</grandparent>`, ({ args }) => args),
24
25
  (0, decorators_1.componentWrapperDecorator)((story) => `<great-grandparent>${story}</great-grandparent>`),
25
26
  ];
26
27
  const decorated = (0, decorateStory_1.default)(() => ({ template: '</child>' }), decorators);
27
- expect(decorated(makeContext({
28
+ (0, vitest_1.expect)(decorated(makeContext({
28
29
  component: FooComponent,
29
30
  args: {
30
31
  parentInput: 'Parent input',
@@ -35,13 +36,13 @@ describe('decorateStory', () => {
35
36
  props: {
36
37
  parentInput: 'Parent input',
37
38
  grandparentInput: 'grandparent input',
38
- parentOutput: expect.any(Function),
39
+ parentOutput: vitest_1.expect.any(Function),
39
40
  },
40
41
  template: '<great-grandparent><grandparent [grandparentInput]="grandparentInput"><parent [parentInput]="parentInput" (parentOutput)="parentOutput($event)"></child></parent></grandparent></great-grandparent>',
41
42
  userDefinedTemplate: true,
42
43
  });
43
44
  });
44
- it('should use componentWrapperDecorator with input / output', () => {
45
+ (0, vitest_1.it)('should use componentWrapperDecorator with input / output', () => {
45
46
  const decorators = [
46
47
  (0, decorators_1.componentWrapperDecorator)(ParentComponent, {
47
48
  parentInput: 'Parent input',
@@ -54,12 +55,12 @@ describe('decorateStory', () => {
54
55
  (0, decorators_1.componentWrapperDecorator)((story) => `<great-grandparent>${story}</great-grandparent>`),
55
56
  ];
56
57
  const decorated = (0, decorateStory_1.default)(() => ({ template: '</child>', props: { sameInput: 'Story input' } }), decorators);
57
- expect(decorated(makeContext({
58
+ (0, vitest_1.expect)(decorated(makeContext({
58
59
  component: FooComponent,
59
60
  }))).toEqual({
60
61
  props: {
61
62
  parentInput: 'Parent input',
62
- parentOutput: expect.any(Function),
63
+ parentOutput: vitest_1.expect.any(Function),
63
64
  grandparentInput: 'Grandparent input',
64
65
  sameInput: 'Story input',
65
66
  },
@@ -67,19 +68,19 @@ describe('decorateStory', () => {
67
68
  userDefinedTemplate: true,
68
69
  });
69
70
  });
70
- it('should use componentWrapperDecorator', () => {
71
+ (0, vitest_1.it)('should use componentWrapperDecorator', () => {
71
72
  const decorators = [
72
73
  (0, decorators_1.componentWrapperDecorator)(ParentComponent),
73
74
  (0, decorators_1.componentWrapperDecorator)((story) => `<grandparent>${story}</grandparent>`),
74
75
  (0, decorators_1.componentWrapperDecorator)((story) => `<great-grandparent>${story}</great-grandparent>`),
75
76
  ];
76
77
  const decorated = (0, decorateStory_1.default)(() => ({ template: '</child>' }), decorators);
77
- expect(decorated(makeContext({ component: FooComponent }))).toEqual({
78
+ (0, vitest_1.expect)(decorated(makeContext({ component: FooComponent }))).toEqual({
78
79
  template: '<great-grandparent><grandparent><parent></child></parent></grandparent></great-grandparent>',
79
80
  userDefinedTemplate: true,
80
81
  });
81
82
  });
82
- it('should use template in preference to component parameters', () => {
83
+ (0, vitest_1.it)('should use template in preference to component parameters', () => {
83
84
  const decorators = [
84
85
  (s) => {
85
86
  const story = s();
@@ -104,12 +105,12 @@ describe('decorateStory', () => {
104
105
  },
105
106
  ];
106
107
  const decorated = (0, decorateStory_1.default)(() => ({ template: '</child>' }), decorators);
107
- expect(decorated(makeContext({ component: FooComponent }))).toEqual({
108
+ (0, vitest_1.expect)(decorated(makeContext({ component: FooComponent }))).toEqual({
108
109
  template: '<great-grandparent><grandparent><parent></child></parent></grandparent></great-grandparent>',
109
110
  userDefinedTemplate: true,
110
111
  });
111
112
  });
112
- it('should include story templates in decorators', () => {
113
+ (0, vitest_1.it)('should include story templates in decorators', () => {
113
114
  const decorators = [
114
115
  (s) => {
115
116
  const story = s();
@@ -134,12 +135,12 @@ describe('decorateStory', () => {
134
135
  },
135
136
  ];
136
137
  const decorated = (0, decorateStory_1.default)(() => ({ template: '</child>' }), decorators);
137
- expect(decorated(makeContext({}))).toEqual({
138
+ (0, vitest_1.expect)(decorated(makeContext({}))).toEqual({
138
139
  template: '<great-grandparent><grandparent><parent></child></parent></grandparent></great-grandparent>',
139
140
  userDefinedTemplate: true,
140
141
  });
141
142
  });
142
- it('should include story components in decorators', () => {
143
+ (0, vitest_1.it)('should include story components in decorators', () => {
143
144
  const decorators = [
144
145
  (s) => {
145
146
  const story = s();
@@ -164,25 +165,25 @@ describe('decorateStory', () => {
164
165
  },
165
166
  ];
166
167
  const decorated = (0, decorateStory_1.default)(() => ({}), decorators);
167
- expect(decorated(makeContext({ component: FooComponent }))).toEqual({
168
+ (0, vitest_1.expect)(decorated(makeContext({ component: FooComponent }))).toEqual({
168
169
  template: '<great-grandparent><grandparent><parent><foo></foo></parent></grandparent></great-grandparent>',
169
170
  userDefinedTemplate: false,
170
171
  });
171
172
  });
172
- it('should keep template with an empty value', () => {
173
+ (0, vitest_1.it)('should keep template with an empty value', () => {
173
174
  const decorators = [
174
175
  (0, decorators_1.componentWrapperDecorator)(ParentComponent),
175
176
  ];
176
177
  const decorated = (0, decorateStory_1.default)(() => ({ template: '' }), decorators);
177
- expect(decorated(makeContext({ component: FooComponent }))).toEqual({
178
+ (0, vitest_1.expect)(decorated(makeContext({ component: FooComponent }))).toEqual({
178
179
  template: '<parent></parent>',
179
180
  });
180
181
  });
181
- it('should only keeps args with a control or an action in argTypes', () => {
182
+ (0, vitest_1.it)('should only keeps args with a control or an action in argTypes', () => {
182
183
  const decorated = (0, decorateStory_1.default)((context) => ({
183
184
  template: `Args available in the story : ${Object.keys(context.args).join()}`,
184
185
  }), []);
185
- expect(decorated(makeContext({
186
+ (0, vitest_1.expect)(decorated(makeContext({
186
187
  component: FooComponent,
187
188
  argTypes: {
188
189
  withControl: { control: { type: 'object' }, name: 'withControl' },
@@ -200,8 +201,8 @@ describe('decorateStory', () => {
200
201
  });
201
202
  });
202
203
  });
203
- describe('default behavior', () => {
204
- it('calls decorators in out to in order', () => {
204
+ (0, vitest_1.describe)('default behavior', () => {
205
+ (0, vitest_1.it)('calls decorators in out to in order', () => {
205
206
  const decorators = [
206
207
  (s) => {
207
208
  const story = s();
@@ -217,9 +218,9 @@ describe('decorateStory', () => {
217
218
  },
218
219
  ];
219
220
  const decorated = (0, decorateStory_1.default)(() => ({ props: { a: [0] } }), decorators);
220
- expect(decorated(makeContext({}))).toEqual({ props: { a: [0, 1, 2, 3] } });
221
+ (0, vitest_1.expect)(decorated(makeContext({}))).toEqual({ props: { a: [0, 1, 2, 3] } });
221
222
  });
222
- it('passes context through to sub decorators', () => {
223
+ (0, vitest_1.it)('passes context through to sub decorators', () => {
223
224
  const decorators = [
224
225
  (s, c) => {
225
226
  const story = s({ ...c, k: 1 });
@@ -235,9 +236,9 @@ describe('decorateStory', () => {
235
236
  },
236
237
  ];
237
238
  const decorated = (0, decorateStory_1.default)((c) => ({ props: { a: [c.k] } }), decorators);
238
- expect(decorated(makeContext({ k: 0 }))).toEqual({ props: { a: [1, 2, 3, 0] } });
239
+ (0, vitest_1.expect)(decorated(makeContext({ k: 0 }))).toEqual({ props: { a: [1, 2, 3, 0] } });
239
240
  });
240
- it('DOES NOT merge parameter or pass through parameters key in context', () => {
241
+ (0, vitest_1.it)('DOES NOT merge parameter or pass through parameters key in context', () => {
241
242
  const decorators = [
242
243
  (s, c) => {
243
244
  const story = s({ ...c, k: 1, parameters: { p: 1 } });
@@ -262,7 +263,7 @@ describe('decorateStory', () => {
262
263
  },
263
264
  ];
264
265
  const decorated = (0, decorateStory_1.default)((c) => ({ props: { a: [c.k], p: [c.parameters.p] } }), decorators);
265
- expect(decorated(makeContext({ k: 0, parameters: { p: 0 } }))).toEqual({
266
+ (0, vitest_1.expect)(decorated(makeContext({ k: 0, parameters: { p: 0 } }))).toEqual({
266
267
  props: { a: [1, 2, 3, 0], p: [0, 0, 0, 0] },
267
268
  });
268
269
  });
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3
+ // @ts-nocheck
2
4
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
5
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
6
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -10,9 +12,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
12
  };
11
13
  Object.defineProperty(exports, "__esModule", { value: true });
12
14
  exports.InputComponent = exports.ButtonAccent = exports.exportedConstant = void 0;
13
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
- // @ts-nocheck
15
- /* eslint-disable no-console */
16
15
  /* eslint-disable no-underscore-dangle */
17
16
  const core_1 = require("@angular/core");
18
17
  exports.exportedConstant = 'An exported constant';
@@ -5,32 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const fs_1 = __importDefault(require("fs"));
8
- const tmp_1 = __importDefault(require("tmp"));
9
- const cross_spawn_1 = require("cross-spawn");
10
- // @ts-expect-error (Converted from ts-ignore)
11
- const { SNAPSHOT_OS } = global;
8
+ const vitest_1 = require("vitest");
12
9
  // File hierarchy: __testfixtures__ / some-test-case / input.*
13
10
  const inputRegExp = /^input\..*$/;
14
- const runCompodoc = (inputPath) => {
15
- const testDir = path_1.default.dirname(inputPath);
16
- const { name: tmpDir, removeCallback } = tmp_1.default.dirSync();
17
- // FIXME: for now, this requires a tsconfig.json for each test case. Tried generating
18
- // one dynamically in tmpDir, but compodoc doesn't handle absolute paths properly
19
- // (and screwed around with relative paths as well, but couldn't get it working)
20
- (0, cross_spawn_1.sync)('yarn', ['compodoc', '-p', `${testDir}/tsconfig.json`, '-e', 'json', '-d', tmpDir], {
21
- stdio: 'inherit',
22
- shell: true,
23
- });
24
- const output = fs_1.default.readFileSync(`${tmpDir}/documentation.json`, 'utf8');
25
- try {
26
- removeCallback();
27
- }
28
- catch (e) {
29
- //
30
- }
31
- return output;
32
- };
33
- describe('angular component properties', () => {
11
+ (0, vitest_1.describe)('angular component properties', () => {
34
12
  const fixturesDir = path_1.default.join(__dirname, '__testfixtures__');
35
13
  fs_1.default.readdirSync(fixturesDir, { withFileTypes: true }).forEach((testEntry) => {
36
14
  if (testEntry.isDirectory()) {
@@ -38,8 +16,8 @@ describe('angular component properties', () => {
38
16
  const testFile = fs_1.default.readdirSync(testDir).find((fileName) => inputRegExp.test(fileName));
39
17
  if (testFile) {
40
18
  // TODO: Remove this as soon as the real test is fixed
41
- it('true', () => {
42
- expect(true).toEqual(true);
19
+ (0, vitest_1.it)('true', () => {
20
+ (0, vitest_1.expect)(true).toEqual(true);
43
21
  });
44
22
  // TODO: Fix this test
45
23
  // it(`${testEntry.name}`, () => {
@@ -22,16 +22,6 @@ export type StoryFn<TArgs = Args> = AnnotatedStoryFn<AngularRenderer, TransformE
22
22
  * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
23
23
  */
24
24
  export type StoryObj<TArgs = Args> = StoryAnnotations<AngularRenderer, TransformEventType<TArgs>>;
25
- /**
26
- * @deprecated Use `StoryFn` instead.
27
- * Use `StoryObj` if you want to migrate to CSF3, which uses objects instead of functions to represent stories.
28
- * You can read more about the CSF3 format here: https://storybook.js.org/blog/component-story-format-3-0/
29
- *
30
- * Story function that represents a CSFv2 component example.
31
- *
32
- * @see [Named Story exports](https://storybook.js.org/docs/formats/component-story-format/#named-story-exports)
33
- */
34
- export type Story<TArgs = Args> = StoryFn<TArgs>;
35
25
  export type Decorator<TArgs = StrictArgs> = DecoratorFunction<AngularRenderer, TArgs>;
36
26
  export type Loader<TArgs = StrictArgs> = LoaderFunction<AngularRenderer, TArgs>;
37
27
  export type StoryContext<TArgs = StrictArgs> = GenericStoryContext<AngularRenderer, TArgs>;
package/dist/preset.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { PresetProperty } from '@storybook/types';
2
- import { StorybookConfig } from './types';
3
2
  export declare const addons: PresetProperty<'addons'>;
4
3
  export declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
5
- export declare const core: PresetProperty<'core', StorybookConfig>;
6
- export declare const typescript: PresetProperty<'typescript', StorybookConfig>;
4
+ export declare const core: PresetProperty<'core'>;
5
+ export declare const typescript: PresetProperty<'typescript'>;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable global-require */
3
2
  // Private angular devkit stuff
4
3
  const { generateI18nBrowserWebpackConfigFromContext, } = require('@angular-devkit/build-angular/src/utils/webpack-browser-config');
5
4
  const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
@@ -55,7 +55,6 @@ function loadEsmModule(modulePath) {
55
55
  const runNgcc = async () => {
56
56
  let ngcc;
57
57
  try {
58
- // eslint-disable-next-line global-require
59
58
  ngcc = require('@angular/compiler-cli/ngcc');
60
59
  }
61
60
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/angular",
3
- "version": "8.0.0-alpha.9",
3
+ "version": "8.0.0-beta.0",
4
4
  "description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
5
5
  "keywords": [
6
6
  "storybook",
@@ -37,19 +37,18 @@
37
37
  "prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/tsc.ts"
38
38
  },
39
39
  "dependencies": {
40
- "@storybook/builder-webpack5": "8.0.0-alpha.9",
41
- "@storybook/cli": "8.0.0-alpha.9",
42
- "@storybook/client-logger": "8.0.0-alpha.9",
43
- "@storybook/core-common": "8.0.0-alpha.9",
44
- "@storybook/core-events": "8.0.0-alpha.9",
45
- "@storybook/core-server": "8.0.0-alpha.9",
46
- "@storybook/core-webpack": "8.0.0-alpha.9",
47
- "@storybook/docs-tools": "8.0.0-alpha.9",
40
+ "@storybook/builder-webpack5": "8.0.0-beta.0",
41
+ "@storybook/client-logger": "8.0.0-beta.0",
42
+ "@storybook/core-common": "8.0.0-beta.0",
43
+ "@storybook/core-events": "8.0.0-beta.0",
44
+ "@storybook/core-server": "8.0.0-beta.0",
45
+ "@storybook/core-webpack": "8.0.0-beta.0",
46
+ "@storybook/docs-tools": "8.0.0-beta.0",
48
47
  "@storybook/global": "^5.0.0",
49
- "@storybook/node-logger": "8.0.0-alpha.9",
50
- "@storybook/preview-api": "8.0.0-alpha.9",
51
- "@storybook/telemetry": "8.0.0-alpha.9",
52
- "@storybook/types": "8.0.0-alpha.9",
48
+ "@storybook/node-logger": "8.0.0-beta.0",
49
+ "@storybook/preview-api": "8.0.0-beta.0",
50
+ "@storybook/telemetry": "8.0.0-beta.0",
51
+ "@storybook/types": "8.0.0-beta.0",
53
52
  "@types/node": "^18.0.0",
54
53
  "@types/react": "^18.0.37",
55
54
  "@types/react-dom": "^18.0.11",