@storybook/angular 8.2.0-alpha.8 → 8.2.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 (39) hide show
  1. package/.eslintrc.js +8 -0
  2. package/dist/builders/build-storybook/index.d.ts +1 -1
  3. package/dist/builders/build-storybook/index.js +7 -7
  4. package/dist/builders/build-storybook/index.spec.js +2 -2
  5. package/dist/builders/start-storybook/index.d.ts +1 -1
  6. package/dist/builders/start-storybook/index.js +7 -7
  7. package/dist/builders/start-storybook/index.spec.js +2 -2
  8. package/dist/builders/utils/error-handler.js +1 -1
  9. package/dist/builders/utils/run-compodoc.js +2 -2
  10. package/dist/builders/utils/run-compodoc.spec.js +1 -1
  11. package/dist/builders/utils/standalone-options.d.ts +1 -1
  12. package/dist/client/angular-beta/AbstractRenderer.d.ts +0 -1
  13. package/dist/client/angular-beta/AbstractRenderer.js +3 -13
  14. package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +1 -1
  15. package/dist/client/angular-beta/DocsRenderer.js +2 -2
  16. package/dist/client/angular-beta/utils/PropertyExtractor.js +5 -8
  17. package/dist/client/decorateStory.d.ts +1 -1
  18. package/dist/client/decorateStory.js +1 -1
  19. package/dist/client/decorators.d.ts +1 -1
  20. package/dist/client/decorators.test.js +5 -0
  21. package/dist/client/docs/compodoc.d.ts +3 -3
  22. package/dist/client/docs/compodoc.js +1 -1
  23. package/dist/client/docs/config.d.ts +1 -1
  24. package/dist/client/docs/config.js +1 -1
  25. package/dist/client/docs/sourceDecorator.d.ts +1 -1
  26. package/dist/client/docs/sourceDecorator.js +10 -4
  27. package/dist/client/public-types.d.ts +2 -2
  28. package/dist/client/render.d.ts +1 -1
  29. package/dist/client/types.d.ts +1 -1
  30. package/dist/preset.d.ts +1 -1
  31. package/dist/server/angular-cli-webpack.js +1 -2
  32. package/dist/server/framework-preset-angular-cli.js +2 -2
  33. package/dist/server/framework-preset-angular-docs.d.ts +1 -1
  34. package/dist/server/framework-preset-angular-docs.js +1 -1
  35. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +3 -17
  36. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +30 -24
  37. package/dist/server/preset-options.d.ts +1 -1
  38. package/dist/types.d.ts +1 -1
  39. package/package.json +5 -13
package/.eslintrc.js CHANGED
@@ -5,4 +5,12 @@ module.exports = {
5
5
  { prefer: 'no-type-imports', disallowTypeAnnotations: false },
6
6
  ],
7
7
  },
8
+ overrides: [
9
+ {
10
+ files: ['template/**/*.*'],
11
+ rules: {
12
+ 'import/no-extraneous-dependencies': 'off',
13
+ },
14
+ },
15
+ ],
8
16
  };
@@ -1,7 +1,7 @@
1
1
  import { BuilderOutput } from '@angular-devkit/architect';
2
2
  import { JsonObject } from '@angular-devkit/core';
3
3
  import { StylePreprocessorOptions } from '@angular-devkit/build-angular';
4
- import { CLIOptions } from '@storybook/types';
4
+ import { CLIOptions } from 'storybook/internal/types';
5
5
  import { AssetPattern, SourceMapUnion, StyleElement } from '@angular-devkit/build-angular/src/builders/browser/schema';
6
6
  export type StorybookBuilderOptions = JsonObject & {
7
7
  browserTarget?: string | null;
@@ -4,13 +4,13 @@ const architect_1 = require("@angular-devkit/architect");
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const find_up_1 = require("find-up");
7
- const read_pkg_up_1 = require("read-pkg-up");
8
- const core_common_1 = require("@storybook/core-common");
9
- const telemetry_1 = require("@storybook/telemetry");
10
- const core_server_1 = require("@storybook/core-server");
7
+ const fd_package_json_1 = require("fd-package-json");
8
+ const common_1 = require("storybook/internal/common");
9
+ const telemetry_1 = require("storybook/internal/telemetry");
10
+ const core_server_1 = require("storybook/internal/core-server");
11
11
  const run_compodoc_1 = require("../utils/run-compodoc");
12
12
  const error_handler_1 = require("../utils/error-handler");
13
- (0, telemetry_1.addToGlobalContext)('cliVersion', core_common_1.versions.storybook);
13
+ (0, telemetry_1.addToGlobalContext)('cliVersion', common_1.versions.storybook);
14
14
  const commandBuilder = (options, context) => {
15
15
  const builder = (0, rxjs_1.from)(setup(options, context)).pipe((0, operators_1.switchMap)(({ tsConfig }) => {
16
16
  const docTSConfig = (0, find_up_1.sync)('tsconfig.doc.json', { cwd: options.configDir });
@@ -19,14 +19,14 @@ const commandBuilder = (options, context) => {
19
19
  : (0, rxjs_1.of)({});
20
20
  return runCompodoc$.pipe((0, operators_1.mapTo)({ tsConfig }));
21
21
  }), (0, operators_1.map)(({ tsConfig }) => {
22
- (0, core_common_1.getEnvConfig)(options, {
22
+ (0, common_1.getEnvConfig)(options, {
23
23
  staticDir: 'SBCONFIG_STATIC_DIR',
24
24
  outputDir: 'SBCONFIG_OUTPUT_DIR',
25
25
  configDir: 'SBCONFIG_CONFIG_DIR',
26
26
  });
27
27
  const { browserTarget, stylePreprocessorOptions, styles, configDir, docs, loglevel, test, outputDir, quiet, enableProdMode = true, webpackStatsJson, statsJson, debugWebpack, disableTelemetry, assets, previewUrl, sourceMap = false, preserveSymlinks = false, } = options;
28
28
  const standaloneOptions = {
29
- packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
29
+ packageJson: (0, fd_package_json_1.findPackageSync)(__dirname),
30
30
  configDir,
31
31
  ...(docs ? { docs } : {}),
32
32
  loglevel,
@@ -36,8 +36,8 @@ const buildMock = {
36
36
  buildStaticStandalone: buildStaticStandaloneMock,
37
37
  withTelemetry: (name, options, fn) => fn(),
38
38
  };
39
- vitest_1.vi.doMock('@storybook/core-server', () => buildMock);
40
- vitest_1.vi.doMock('@storybook/core-common', () => ({
39
+ vitest_1.vi.doMock('storybook/internal/core-server', () => buildMock);
40
+ vitest_1.vi.doMock('storybook/internal/common', () => ({
41
41
  JsPackageManagerFactory: {
42
42
  getPackageManager: () => ({
43
43
  runPackageCommand: mockRunScript,
@@ -1,7 +1,7 @@
1
1
  import { BuilderOutput } from '@angular-devkit/architect';
2
2
  import { JsonObject } from '@angular-devkit/core';
3
3
  import { StylePreprocessorOptions } from '@angular-devkit/build-angular';
4
- import { CLIOptions } from '@storybook/types';
4
+ import { CLIOptions } from 'storybook/internal/types';
5
5
  import { AssetPattern, SourceMapUnion, StyleElement } from '@angular-devkit/build-angular/src/builders/browser/schema';
6
6
  export type StorybookBuilderOptions = JsonObject & {
7
7
  browserTarget?: string | null;
@@ -4,13 +4,13 @@ const architect_1 = require("@angular-devkit/architect");
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const find_up_1 = require("find-up");
7
- const read_pkg_up_1 = require("read-pkg-up");
8
- const core_common_1 = require("@storybook/core-common");
9
- const telemetry_1 = require("@storybook/telemetry");
10
- const core_server_1 = require("@storybook/core-server");
7
+ const fd_package_json_1 = require("fd-package-json");
8
+ const common_1 = require("storybook/internal/common");
9
+ const telemetry_1 = require("storybook/internal/telemetry");
10
+ const core_server_1 = require("storybook/internal/core-server");
11
11
  const run_compodoc_1 = require("../utils/run-compodoc");
12
12
  const error_handler_1 = require("../utils/error-handler");
13
- (0, telemetry_1.addToGlobalContext)('cliVersion', core_common_1.versions.storybook);
13
+ (0, telemetry_1.addToGlobalContext)('cliVersion', common_1.versions.storybook);
14
14
  const commandBuilder = (options, context) => {
15
15
  const builder = (0, rxjs_1.from)(setup(options, context)).pipe((0, operators_1.switchMap)(({ tsConfig }) => {
16
16
  const docTSConfig = (0, find_up_1.sync)('tsconfig.doc.json', { cwd: options.configDir });
@@ -22,7 +22,7 @@ const commandBuilder = (options, context) => {
22
22
  : (0, rxjs_1.of)({});
23
23
  return runCompodoc$.pipe((0, operators_1.mapTo)({ tsConfig }));
24
24
  }), (0, operators_1.map)(({ tsConfig }) => {
25
- (0, core_common_1.getEnvConfig)(options, {
25
+ (0, common_1.getEnvConfig)(options, {
26
26
  port: 'SBCONFIG_PORT',
27
27
  host: 'SBCONFIG_HOSTNAME',
28
28
  staticDir: 'SBCONFIG_STATIC_DIR',
@@ -32,7 +32,7 @@ const commandBuilder = (options, context) => {
32
32
  options.port = parseInt(`${options.port}`, 10);
33
33
  const { browserTarget, stylePreprocessorOptions, styles, ci, configDir, docs, host, https, port, quiet, enableProdMode = false, smokeTest, sslCa, sslCert, sslKey, disableTelemetry, assets, initialPath, open, debugWebpack, loglevel, webpackStatsJson, statsJson, previewUrl, sourceMap = false, preserveSymlinks = false, } = options;
34
34
  const standaloneOptions = {
35
- packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
35
+ packageJson: (0, fd_package_json_1.findPackageSync)(__dirname),
36
36
  ci,
37
37
  configDir,
38
38
  ...(docs ? { docs } : {}),
@@ -36,10 +36,10 @@ const buildMock = {
36
36
  buildStaticStandalone: buildStaticStandaloneMock,
37
37
  withTelemetry: (_, __, fn) => fn(),
38
38
  };
39
- vitest_1.vi.doMock('@storybook/core-server', () => buildMock);
39
+ vitest_1.vi.doMock('storybook/internal/core-server', () => buildMock);
40
40
  vitest_1.vi.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
41
41
  const mockRunScript = vitest_1.vi.fn();
42
- vitest_1.vi.mock('@storybook/core-common', () => ({
42
+ vitest_1.vi.mock('storybook/internal/common', () => ({
43
43
  getEnvConfig: (options) => options,
44
44
  versions: {
45
45
  storybook: 'x.x.x',
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.errorSummary = exports.printErrorDetails = void 0;
4
- const node_logger_1 = require("@storybook/node-logger");
4
+ const node_logger_1 = require("storybook/internal/node-logger");
5
5
  const ts_dedent_1 = require("ts-dedent");
6
6
  const printErrorDetails = (error) => {
7
7
  // Duplicate code for Standalone error handling
@@ -26,7 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.runCompodoc = void 0;
27
27
  const rxjs_1 = require("rxjs");
28
28
  const path = __importStar(require("path"));
29
- const core_common_1 = require("@storybook/core-common");
29
+ const common_1 = require("storybook/internal/common");
30
30
  const hasTsConfigArg = (args) => args.indexOf('-p') !== -1;
31
31
  const hasOutputArg = (args) => args.indexOf('-d') !== -1 || args.indexOf('--output') !== -1;
32
32
  // path.relative is necessary to workaround a compodoc issue with
@@ -42,7 +42,7 @@ const runCompodoc = ({ compodocArgs, tsconfig }, context) => {
42
42
  ...(hasOutputArg(compodocArgs) ? [] : ['-d', `${context.workspaceRoot || '.'}`]),
43
43
  ...compodocArgs,
44
44
  ];
45
- const packageManager = core_common_1.JsPackageManagerFactory.getPackageManager();
45
+ const packageManager = common_1.JsPackageManagerFactory.getPackageManager();
46
46
  try {
47
47
  const stdout = packageManager.runPackageCommandSync('compodoc', finalCompodocArgs, context.workspaceRoot, 'inherit');
48
48
  context.logger.info(stdout);
@@ -5,7 +5,7 @@ const vitest_1 = require("vitest");
5
5
  const operators_1 = require("rxjs/operators");
6
6
  const run_compodoc_1 = require("./run-compodoc");
7
7
  const mockRunScript = vitest_1.vi.fn();
8
- vitest_1.vi.mock('@storybook/core-common', () => ({
8
+ vitest_1.vi.mock('storybook/internal/common', () => ({
9
9
  JsPackageManagerFactory: {
10
10
  getPackageManager: () => ({
11
11
  runPackageCommandSync: mockRunScript,
@@ -1,6 +1,6 @@
1
1
  import { BuilderContext } from '@angular-devkit/architect';
2
2
  import { AssetPattern, SourceMapUnion, StyleElement, StylePreprocessorOptions } from '@angular-devkit/build-angular/src/builders/browser/schema';
3
- import { LoadOptions, CLIOptions, BuilderOptions } from '@storybook/types';
3
+ import { LoadOptions, CLIOptions, BuilderOptions } from 'storybook/internal/types';
4
4
  export type StandaloneOptions = CLIOptions & LoadOptions & BuilderOptions & {
5
5
  mode?: 'static' | 'dev';
6
6
  enableProdMode: boolean;
@@ -18,7 +18,6 @@ export declare abstract class AbstractRenderer {
18
18
  static resetApplications(domNode?: HTMLElement): void;
19
19
  protected previousStoryRenderInfo: Map<HTMLElement, StoryRenderInfo>;
20
20
  protected storyProps$: Subject<ICollection | undefined>;
21
- constructor();
22
21
  protected abstract beforeFullRender(domNode?: HTMLElement): Promise<void>;
23
22
  /**
24
23
  * Bootstrap main angular module with main component or send only new `props` with storyProps$
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractRenderer = exports.STORY_UID_ATTRIBUTE = void 0;
4
- const core_1 = require("@angular/core");
5
4
  const platform_browser_1 = require("@angular/platform-browser");
6
5
  const rxjs_1 = require("rxjs");
7
6
  const telejson_1 = require("telejson");
@@ -18,6 +17,9 @@ const applicationRefs = new Map();
18
17
  */
19
18
  exports.STORY_UID_ATTRIBUTE = 'data-sb-story-uid';
20
19
  class AbstractRenderer {
20
+ constructor() {
21
+ this.previousStoryRenderInfo = new Map();
22
+ }
21
23
  /**
22
24
  * Wait and destroy the platform
23
25
  */
@@ -28,18 +30,6 @@ class AbstractRenderer {
28
30
  }
29
31
  });
30
32
  }
31
- constructor() {
32
- this.previousStoryRenderInfo = new Map();
33
- if (typeof NODE_ENV === 'string' && NODE_ENV !== 'development') {
34
- try {
35
- // platform should be set after enableProdMode()
36
- (0, core_1.enableProdMode)();
37
- }
38
- catch (e) {
39
- console.debug(e);
40
- }
41
- }
42
- }
43
33
  /**
44
34
  * Bootstrap main angular module with main component or send only new `props` with storyProps$
45
35
  *
@@ -1,5 +1,5 @@
1
1
  import { Type } from '@angular/core';
2
- import { ArgTypes } from '@storybook/types';
2
+ import { ArgTypes } from 'storybook/internal/types';
3
3
  import { ICollection } from '../types';
4
4
  /**
5
5
  * Converts a component into a template with inputs/outputs present in initial props
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocsRenderer = void 0;
4
- const preview_api_1 = require("@storybook/preview-api");
5
- const core_events_1 = require("@storybook/core-events");
4
+ const preview_api_1 = require("storybook/internal/preview-api");
5
+ const core_events_1 = require("storybook/internal/core-events");
6
6
  const StoryUID_1 = require("./utils/StoryUID");
7
7
  const AbstractRenderer_1 = require("./AbstractRenderer");
8
8
  class DocsRenderer extends AbstractRenderer_1.AbstractRenderer {
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  var _a;
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
4
  exports.PropertyExtractor = exports.uniqueArray = exports.REMOVED_MODULES = exports.reflectionCapabilities = void 0;
@@ -9,7 +6,7 @@ const common_1 = require("@angular/common");
9
6
  const core_1 = require("@angular/core");
10
7
  const platform_browser_1 = require("@angular/platform-browser");
11
8
  const animations_1 = require("@angular/platform-browser/animations");
12
- const ts_dedent_1 = __importDefault(require("ts-dedent"));
9
+ const ts_dedent_1 = require("ts-dedent");
13
10
  const NgModulesAnalyzer_1 = require("./NgModulesAnalyzer");
14
11
  exports.reflectionCapabilities = new core_1.ɵReflectionCapabilities();
15
12
  exports.REMOVED_MODULES = new core_1.InjectionToken('REMOVED_MODULES');
@@ -60,7 +57,7 @@ class PropertyExtractor {
60
57
  static warnImportsModuleWithProviders(propertyExtractor) {
61
58
  const hasModuleWithProvidersImport = propertyExtractor.imports.some((importedModule) => 'ngModule' in importedModule);
62
59
  if (hasModuleWithProvidersImport) {
63
- console.warn((0, ts_dedent_1.default)(`
60
+ console.warn((0, ts_dedent_1.dedent)(`
64
61
  Storybook Warning:
65
62
  moduleMetadata property 'imports' contains one or more ModuleWithProviders, likely the result of a 'Module.forRoot()'-style call.
66
63
  In Storybook 7.0 we use Angular's new 'bootstrapApplication' API to mount the component to the DOM, which accepts a list of providers to set up application-wide providers.
@@ -91,7 +88,7 @@ exports.PropertyExtractor = PropertyExtractor;
91
88
  _a = PropertyExtractor;
92
89
  PropertyExtractor.analyzeRestricted = (ngModule) => {
93
90
  if (ngModule === platform_browser_1.BrowserModule) {
94
- console.warn((0, ts_dedent_1.default) `
91
+ console.warn((0, ts_dedent_1.dedent) `
95
92
  Storybook Warning:
96
93
  You have imported the "BrowserModule", which is not necessary anymore.
97
94
  In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM.
@@ -101,7 +98,7 @@ PropertyExtractor.analyzeRestricted = (ngModule) => {
101
98
  return [true];
102
99
  }
103
100
  if (ngModule === animations_1.BrowserAnimationsModule) {
104
- console.warn((0, ts_dedent_1.default) `
101
+ console.warn((0, ts_dedent_1.dedent) `
105
102
  Storybook Warning:
106
103
  You have added the "BrowserAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
107
104
  In Storybook 7.0 we use Angular's new 'bootstrapApplication' API to mount the component to the DOM, which accepts a list of providers to set up application-wide providers.
@@ -112,7 +109,7 @@ PropertyExtractor.analyzeRestricted = (ngModule) => {
112
109
  return [true, (0, animations_1.provideAnimations)()];
113
110
  }
114
111
  if (ngModule === animations_1.NoopAnimationsModule) {
115
- console.warn((0, ts_dedent_1.default) `
112
+ console.warn((0, ts_dedent_1.dedent) `
116
113
  Storybook Warning:
117
114
  You have added the "NoopAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
118
115
  In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM, which accepts a list of providers to set up application-wide providers.
@@ -1,4 +1,4 @@
1
- import { DecoratorFunction, LegacyStoryFn } from '@storybook/types';
1
+ import { DecoratorFunction, LegacyStoryFn } from 'storybook/internal/types';
2
2
  import { AngularRenderer } from './types';
3
3
  export default function decorateStory(mainStoryFn: LegacyStoryFn<AngularRenderer>, decorators: DecoratorFunction<AngularRenderer>[]): LegacyStoryFn<AngularRenderer>;
4
4
  export { decorateStory };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.decorateStory = void 0;
4
- const preview_api_1 = require("@storybook/preview-api");
4
+ const preview_api_1 = require("storybook/internal/preview-api");
5
5
  const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
6
6
  function decorateStory(mainStoryFn, decorators) {
7
7
  const returnDecorators = [cleanArgsDecorator, ...decorators].reduce((previousStoryFn, decorator) => (context) => {
@@ -1,6 +1,6 @@
1
1
  import { Type } from '@angular/core';
2
2
  import { ApplicationConfig } from '@angular/platform-browser';
3
- import { DecoratorFunction, StoryContext } from '@storybook/types';
3
+ import { DecoratorFunction, StoryContext } from 'storybook/internal/types';
4
4
  import { ICollection, NgModuleMetadata, AngularRenderer } from './types';
5
5
  export declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularRenderer, TArgs>;
6
6
  /**
@@ -28,7 +28,12 @@ const defaultContext = {
28
28
  viewMode: 'story',
29
29
  abortSignal: undefined,
30
30
  canvasElement: undefined,
31
+ step: undefined,
32
+ context: undefined,
33
+ canvas: undefined,
34
+ mount: undefined,
31
35
  };
36
+ defaultContext.context = defaultContext;
32
37
  class MockModule {
33
38
  }
34
39
  class MockModuleTwo {
@@ -1,4 +1,4 @@
1
- import { ArgTypes, SBType } from '@storybook/types';
1
+ import { ArgTypes, SBType } from 'storybook/internal/types';
2
2
  import { Class, CompodocJson, Component, Injectable, Method, Pipe, Property, Directive } from './types';
3
3
  export declare const isMethod: (methodOrProp: Method | Property) => methodOrProp is Method;
4
4
  export declare const setCompodocJson: (compodocJson: CompodocJson) => void;
@@ -7,6 +7,6 @@ export declare const checkValidComponentOrDirective: (component: Component | Dir
7
7
  export declare const checkValidCompodocJson: (compodocJson: CompodocJson) => void;
8
8
  export declare const findComponentByName: (name: string, compodocJson: CompodocJson) => Class | Injectable | Pipe | Directive | undefined;
9
9
  export declare const extractType: (property: Property, defaultValue: any) => SBType;
10
- export declare const extractArgTypesFromData: (componentData: Class | Directive | Injectable | Pipe) => ArgTypes<import("@storybook/types").Args>;
11
- export declare const extractArgTypes: (component: Component | Directive) => ArgTypes<import("@storybook/types").Args> | null | undefined;
10
+ export declare const extractArgTypesFromData: (componentData: Class | Directive | Injectable | Pipe) => ArgTypes<import("@storybook/csf").Args>;
11
+ export declare const extractArgTypes: (component: Component | Directive) => ArgTypes<import("@storybook/csf").Args> | null | undefined;
12
12
  export declare const extractComponentDescription: (component: Component | Directive) => string | null | undefined;
@@ -3,7 +3,7 @@ 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
4
  /* eslint-disable no-underscore-dangle */
5
5
  const global_1 = require("@storybook/global");
6
- const client_logger_1 = require("@storybook/client-logger");
6
+ const client_logger_1 = require("storybook/internal/client-logger");
7
7
  const isMethod = (methodOrProp) => {
8
8
  return methodOrProp.args !== undefined;
9
9
  };
@@ -1,4 +1,4 @@
1
- import { Parameters, DecoratorFunction, ArgTypesEnhancer } from '@storybook/types';
1
+ import { Parameters, DecoratorFunction, ArgTypesEnhancer } from 'storybook/internal/types';
2
2
  export declare const parameters: Parameters;
3
3
  export declare const decorators: DecoratorFunction[];
4
4
  export declare const argTypesEnhancers: ArgTypesEnhancer[];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.argTypesEnhancers = exports.decorators = exports.parameters = void 0;
4
- const docs_tools_1 = require("@storybook/docs-tools");
4
+ const docs_tools_1 = require("storybook/internal/docs-tools");
5
5
  const compodoc_1 = require("./compodoc");
6
6
  const sourceDecorator_1 = require("./sourceDecorator");
7
7
  exports.parameters = {
@@ -1,4 +1,4 @@
1
- import { PartialStoryFn } from '@storybook/types';
1
+ import { PartialStoryFn } from 'storybook/internal/types';
2
2
  import { StoryContext, AngularRenderer } from '../types';
3
3
  export declare const skipSourceRender: (context: StoryContext) => any;
4
4
  /**
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sourceDecorator = exports.skipSourceRender = void 0;
4
- const preview_api_1 = require("@storybook/preview-api");
5
- const docs_tools_1 = require("@storybook/docs-tools");
4
+ const preview_api_1 = require("storybook/internal/preview-api");
5
+ const docs_tools_1 = require("storybook/internal/docs-tools");
6
6
  const renderer_1 = require("../../renderer");
7
7
  const skipSourceRender = (context) => {
8
8
  const sourceParams = context?.parameters.docs?.source;
@@ -27,12 +27,18 @@ const sourceDecorator = (storyFn, context) => {
27
27
  }
28
28
  const channel = preview_api_1.addons.getChannel();
29
29
  const { props, template, userDefinedTemplate } = story;
30
- const { component, argTypes } = context;
30
+ const { component, argTypes, parameters } = context;
31
31
  let toEmit;
32
32
  (0, preview_api_1.useEffect)(() => {
33
33
  if (toEmit) {
34
34
  const { id, unmappedArgs } = context;
35
- channel.emit(docs_tools_1.SNIPPET_RENDERED, { id, args: unmappedArgs, source: toEmit, format: 'angular' });
35
+ const format = parameters?.docs?.source?.format ?? true;
36
+ channel.emit(docs_tools_1.SNIPPET_RENDERED, {
37
+ id,
38
+ args: unmappedArgs,
39
+ source: toEmit,
40
+ format: format === true ? 'angular' : format,
41
+ });
36
42
  }
37
43
  });
38
44
  if (component && !userDefinedTemplate) {
@@ -1,7 +1,7 @@
1
- import { AnnotatedStoryFn, Args, ComponentAnnotations, DecoratorFunction, LoaderFunction, StoryAnnotations, StoryContext as GenericStoryContext, StrictArgs, ProjectAnnotations } from '@storybook/types';
1
+ import { AnnotatedStoryFn, Args, ComponentAnnotations, DecoratorFunction, LoaderFunction, StoryAnnotations, StoryContext as GenericStoryContext, StrictArgs, ProjectAnnotations } from 'storybook/internal/types';
2
2
  import * as AngularCore from '@angular/core';
3
3
  import { AngularRenderer } from './types';
4
- export type { Args, ArgTypes, Parameters, StrictArgs } from '@storybook/types';
4
+ export type { Args, ArgTypes, Parameters, StrictArgs } from 'storybook/internal/types';
5
5
  export type { Parameters as AngularParameters } from './types';
6
6
  export type { AngularRenderer };
7
7
  /**
@@ -1,5 +1,5 @@
1
1
  import '@angular/compiler';
2
- import { RenderContext, ArgsStoryFn } from '@storybook/types';
2
+ import { RenderContext, ArgsStoryFn } from 'storybook/internal/types';
3
3
  import { AngularRenderer } from './types';
4
4
  import { RendererFactory } from './angular-beta/RendererFactory';
5
5
  export declare const rendererFactory: RendererFactory;
@@ -1,6 +1,6 @@
1
1
  import { Provider } from '@angular/core';
2
2
  import { ApplicationConfig } from '@angular/platform-browser';
3
- import { Parameters as DefaultParameters, StoryContext as DefaultStoryContext, WebRenderer } from '@storybook/types';
3
+ import { Parameters as DefaultParameters, StoryContext as DefaultStoryContext, WebRenderer } from 'storybook/internal/types';
4
4
  export interface NgModuleMetadata {
5
5
  /**
6
6
  * List of components, directives, and pipes that belong to your component.
package/dist/preset.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PresetProperty } from '@storybook/types';
1
+ import { PresetProperty } from 'storybook/internal/types';
2
2
  export declare const addons: PresetProperty<'addons'>;
3
3
  export declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
4
4
  export declare const core: PresetProperty<'core'>;
@@ -43,7 +43,6 @@ exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }
43
43
  // Default options
44
44
  index: 'noop-index',
45
45
  main: 'noop-main',
46
- outputPath: 'noop-out',
47
46
  // Options provided by user
48
47
  ...builderOptions,
49
48
  styles: builderOptions.styles
@@ -51,7 +50,7 @@ exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext }
51
50
  .filter((style) => typeof style === 'string' || style.inject !== false),
52
51
  outputPath: typeof builderOptions.outputPath === 'string'
53
52
  ? builderOptions.outputPath
54
- : builderOptions.outputPath?.base,
53
+ : builderOptions.outputPath?.base ?? 'noop-out',
55
54
  // Fixed options
56
55
  optimization: false,
57
56
  namedChunks: false,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.webpackFinal = void 0;
4
- const node_logger_1 = require("@storybook/node-logger");
5
- const server_errors_1 = require("@storybook/core-events/server-errors");
4
+ const node_logger_1 = require("storybook/internal/node-logger");
5
+ const server_errors_1 = require("storybook/internal/server-errors");
6
6
  const architect_1 = require("@angular-devkit/architect");
7
7
  const find_up_1 = require("find-up");
8
8
  const core_1 = require("@angular-devkit/core");
@@ -1,2 +1,2 @@
1
- import { PresetProperty } from '@storybook/types';
1
+ import { PresetProperty } from 'storybook/internal/types';
2
2
  export declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.previewAnnotations = void 0;
4
- const docs_tools_1 = require("@storybook/docs-tools");
4
+ const docs_tools_1 = require("storybook/internal/docs-tools");
5
5
  const previewAnnotations = (entry = [], options) => {
6
6
  if (!(0, docs_tools_1.hasDocsOrControls)(options))
7
7
  return entry;
@@ -1,21 +1,7 @@
1
1
  /**
2
- * Angular's webpack plugin @angular-devkit/build-angular/src/webpack/plugins/styles-webpack-plugin.js
3
- * transforms the original webpackOptions.entry point array into a structure like this:
4
- *
5
- * ```js
6
- * {
7
- * main: {
8
- * import: [...]
9
- * },
10
- *
11
- * styles: {
12
- * import: [...]
13
- * },
14
- * }
15
- * ```
16
- *
17
- * Storybook throws an __webpack_require__.nmd is not a function error, when another runtime bundle (styles~runtime.iframe.bundle.js) is loaded.
18
- * To prevent this error, we have to normalize the entry point to only generate one runtime bundle (main~runtime.iframe.bundle.js).
2
+ * This plugin is designed to modify the Webpack configuration for Storybook projects that use Angular,
3
+ * specifically to prevent multiple runtime bundle issues by merging 'main' and 'styles' entry points.
4
+ * It ensures that only one runtime bundle is generated to avoid '__webpack_require__.nmd is not a function' errors.
19
5
  */
20
6
  export default class StorybookNormalizeAngularEntryPlugin {
21
7
  constructor(options: any);
@@ -2,42 +2,48 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const PLUGIN_NAME = 'storybook-normalize-angular-entry-plugin';
4
4
  /**
5
- * Angular's webpack plugin @angular-devkit/build-angular/src/webpack/plugins/styles-webpack-plugin.js
6
- * transforms the original webpackOptions.entry point array into a structure like this:
7
- *
8
- * ```js
9
- * {
10
- * main: {
11
- * import: [...]
12
- * },
13
- *
14
- * styles: {
15
- * import: [...]
16
- * },
17
- * }
18
- * ```
19
- *
20
- * Storybook throws an __webpack_require__.nmd is not a function error, when another runtime bundle (styles~runtime.iframe.bundle.js) is loaded.
21
- * To prevent this error, we have to normalize the entry point to only generate one runtime bundle (main~runtime.iframe.bundle.js).
5
+ * This plugin is designed to modify the Webpack configuration for Storybook projects that use Angular,
6
+ * specifically to prevent multiple runtime bundle issues by merging 'main' and 'styles' entry points.
7
+ * It ensures that only one runtime bundle is generated to avoid '__webpack_require__.nmd is not a function' errors.
22
8
  */
23
9
  class StorybookNormalizeAngularEntryPlugin {
24
10
  constructor(options) {
25
- this.options = options;
11
+ this.options = options; // Store options if future configuration is needed
26
12
  }
27
13
  apply(compiler) {
28
14
  compiler.hooks.environment.tap(PLUGIN_NAME, () => {
29
- const webpackOptions = compiler.options;
30
- const entry = typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
31
- webpackOptions.entry = async () => {
32
- const entryResult = await entry;
33
- if (entryResult.main && entryResult.styles) {
15
+ // Store the original entry configuration
16
+ const originalEntry = compiler.options.entry;
17
+ // Overwrite the entry configuration to normalize it
18
+ compiler.options.entry = async () => {
19
+ let entryResult;
20
+ // Handle the case where the original entry is a function, which could be async
21
+ if (typeof originalEntry === 'function') {
22
+ try {
23
+ // Execute the function and await its result, in case it returns a promise
24
+ entryResult = await originalEntry();
25
+ }
26
+ catch (error) {
27
+ // Log the error and re-throw it to ensure it's visible and doesn't silently fail
28
+ console.error('Failed to execute the entry function:', error);
29
+ throw error;
30
+ }
31
+ }
32
+ else {
33
+ // If the original entry is not a function, use it as is
34
+ entryResult = originalEntry;
35
+ }
36
+ // Merge 'main' and 'styles' entries if both exist
37
+ if (entryResult && entryResult.main && entryResult.styles) {
38
+ // Combine and deduplicate imports from 'main' and 'styles'
34
39
  return {
35
40
  main: {
36
41
  import: Array.from(new Set([...entryResult.main.import, ...entryResult.styles.import])),
37
42
  },
38
43
  };
39
44
  }
40
- return entry;
45
+ // If not both 'main' and 'styles' are present, return the original or resolved entry result
46
+ return entryResult;
41
47
  };
42
48
  });
43
49
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
@@ -1,4 +1,4 @@
1
- import { Options as CoreOptions } from '@storybook/types';
1
+ import { Options as CoreOptions } from 'storybook/internal/types';
2
2
  import { BuilderContext } from '@angular-devkit/architect';
3
3
  import { StylePreprocessorOptions } from '@angular-devkit/build-angular';
4
4
  import { StyleElement } from '@angular-devkit/build-angular/src/builders/browser/schema';
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { StorybookConfig as StorybookConfigBase, TypescriptOptions as TypescriptOptionsReact } from '@storybook/core-webpack';
2
2
  import { StorybookConfigWebpack, BuilderOptions, TypescriptOptions as TypescriptOptionsBuilder } from '@storybook/builder-webpack5';
3
- import { CompatibleString } from '@storybook/types';
3
+ import { CompatibleString } from 'storybook/internal/types';
4
4
  type FrameworkName = CompatibleString<'@storybook/angular'>;
5
5
  type BuilderName = CompatibleString<'@storybook/builder-webpack5'>;
6
6
  export type FrameworkOptions = AngularOptions & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/angular",
3
- "version": "8.2.0-alpha.8",
3
+ "version": "8.2.0-beta.0",
4
4
  "description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
5
5
  "keywords": [
6
6
  "storybook",
@@ -37,25 +37,16 @@
37
37
  "prep": "rimraf dist && 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.2.0-alpha.8",
41
- "@storybook/client-logger": "8.2.0-alpha.8",
42
- "@storybook/core-common": "8.2.0-alpha.8",
43
- "@storybook/core-events": "8.2.0-alpha.8",
44
- "@storybook/core-server": "8.2.0-alpha.8",
45
- "@storybook/core-webpack": "8.2.0-alpha.8",
46
- "@storybook/docs-tools": "8.2.0-alpha.8",
40
+ "@storybook/builder-webpack5": "8.2.0-beta.0",
41
+ "@storybook/core-webpack": "8.2.0-beta.0",
47
42
  "@storybook/global": "^5.0.0",
48
- "@storybook/node-logger": "8.2.0-alpha.8",
49
- "@storybook/preview-api": "8.2.0-alpha.8",
50
- "@storybook/telemetry": "8.2.0-alpha.8",
51
- "@storybook/types": "8.2.0-alpha.8",
52
43
  "@types/node": "^18.0.0",
53
44
  "@types/react": "^18.0.37",
54
45
  "@types/react-dom": "^18.0.11",
55
46
  "@types/semver": "^7.3.4",
56
47
  "@types/webpack-env": "^1.18.0",
48
+ "fd-package-json": "^1.2.0",
57
49
  "find-up": "^5.0.0",
58
- "read-pkg-up": "^7.0.1",
59
50
  "semver": "^7.3.7",
60
51
  "telejson": "^7.2.0",
61
52
  "ts-dedent": "^2.0.0",
@@ -98,6 +89,7 @@
98
89
  "@angular/platform-browser": ">=15.0.0 < 19.0.0",
99
90
  "@angular/platform-browser-dynamic": ">=15.0.0 < 19.0.0",
100
91
  "rxjs": "^6.0.0 || ^7.4.0",
92
+ "storybook": "^8.2.0-beta.0",
101
93
  "typescript": "^4.0.0 || ^5.0.0",
102
94
  "zone.js": ">= 0.11.1 < 1.0.0"
103
95
  },