@storybook/angular 7.0.0-alpha.1 → 7.0.0-alpha.4
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.
- package/dist/types/builders/build-storybook/index.js +4 -6
- package/dist/types/builders/start-storybook/index.js +4 -6
- package/dist/types/builders/utils/standalone-options.d.ts +12 -0
- package/dist/types/builders/utils/standalone-options.js +2 -0
- package/dist/types/client/docs/config.d.ts +0 -1
- package/dist/types/client/docs/config.js +0 -2
- package/dist/types/client/preview/angular-beta/StorybookModule.js +8 -2
- package/dist/types/client/preview/angular-beta/utils/NgComponentAnalyzer.d.ts +1 -0
- package/dist/types/client/preview/angular-beta/utils/NgComponentAnalyzer.js +11 -1
- package/dist/types/preset.d.ts +2 -1
- package/dist/types/preset.js +13 -2
- package/dist/types/server/framework-preset-angular-cli.js +1 -1
- package/package.json +13 -14
- package/dist/types/client/docs/prepareForInline.d.ts +0 -7
- package/dist/types/client/docs/prepareForInline.js +0 -37
- package/standalone.d.ts +0 -21
- package/standalone.js +0 -7
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const architect_1 = require("@angular-devkit/architect");
|
|
7
4
|
const rxjs_1 = require("rxjs");
|
|
8
5
|
const operators_1 = require("rxjs/operators");
|
|
9
6
|
const find_up_1 = require("find-up");
|
|
10
|
-
|
|
11
|
-
const
|
|
7
|
+
const read_pkg_up_1 = require("read-pkg-up");
|
|
8
|
+
const core_server_1 = require("@storybook/core-server");
|
|
12
9
|
const run_compodoc_1 = require("../utils/run-compodoc");
|
|
13
10
|
const build_standalone_errors_handler_1 = require("../utils/build-standalone-errors-handler");
|
|
14
11
|
exports.default = (0, architect_1.createBuilder)(commandBuilder);
|
|
@@ -21,6 +18,7 @@ function commandBuilder(options, context) {
|
|
|
21
18
|
}), (0, operators_1.map)(({ tsConfig }) => {
|
|
22
19
|
const { browserTarget, stylePreprocessorOptions, styles, configDir, docs, loglevel, outputDir, quiet, webpackStatsJson, } = options;
|
|
23
20
|
const standaloneOptions = {
|
|
21
|
+
packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
|
|
24
22
|
configDir,
|
|
25
23
|
docs,
|
|
26
24
|
loglevel,
|
|
@@ -54,5 +52,5 @@ async function setup(options, context) {
|
|
|
54
52
|
};
|
|
55
53
|
}
|
|
56
54
|
function runInstance(options) {
|
|
57
|
-
return (0, rxjs_1.from)((0,
|
|
55
|
+
return (0, rxjs_1.from)((0, core_server_1.buildStaticStandalone)(options)).pipe((0, operators_1.catchError)((error) => (0, rxjs_1.throwError)((0, build_standalone_errors_handler_1.buildStandaloneErrorHandler)(error))));
|
|
58
56
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
const architect_1 = require("@angular-devkit/architect");
|
|
7
4
|
const rxjs_1 = require("rxjs");
|
|
8
5
|
const operators_1 = require("rxjs/operators");
|
|
9
6
|
const find_up_1 = require("find-up");
|
|
10
|
-
|
|
11
|
-
const
|
|
7
|
+
const read_pkg_up_1 = require("read-pkg-up");
|
|
8
|
+
const core_server_1 = require("@storybook/core-server");
|
|
12
9
|
const run_compodoc_1 = require("../utils/run-compodoc");
|
|
13
10
|
const build_standalone_errors_handler_1 = require("../utils/build-standalone-errors-handler");
|
|
14
11
|
exports.default = (0, architect_1.createBuilder)(commandBuilder);
|
|
@@ -21,6 +18,7 @@ function commandBuilder(options, context) {
|
|
|
21
18
|
}), (0, operators_1.map)(({ tsConfig }) => {
|
|
22
19
|
const { browserTarget, stylePreprocessorOptions, styles, ci, configDir, docs, host, https, port, quiet, smokeTest, sslCa, sslCert, sslKey, } = options;
|
|
23
20
|
const standaloneOptions = {
|
|
21
|
+
packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
|
|
24
22
|
ci,
|
|
25
23
|
configDir,
|
|
26
24
|
docs,
|
|
@@ -61,6 +59,6 @@ async function setup(options, context) {
|
|
|
61
59
|
function runInstance(options) {
|
|
62
60
|
return new rxjs_1.Observable((observer) => {
|
|
63
61
|
// This Observable intentionally never complete, leaving the process running ;)
|
|
64
|
-
(0,
|
|
62
|
+
(0, core_server_1.buildDevStandalone)(options).then(() => observer.next(), (error) => observer.error((0, build_standalone_errors_handler_1.buildStandaloneErrorHandler)(error)));
|
|
65
63
|
});
|
|
66
64
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuilderContext } from '@angular-devkit/architect';
|
|
2
|
+
import type { LoadOptions, CLIOptions, BuilderOptions } from '@storybook/core-common';
|
|
3
|
+
export declare type StandaloneOptions = Partial<CLIOptions & LoadOptions & BuilderOptions & {
|
|
4
|
+
mode?: 'static' | 'dev';
|
|
5
|
+
angularBrowserTarget?: string | null;
|
|
6
|
+
angularBuilderOptions?: Record<string, any> & {
|
|
7
|
+
styles?: any[];
|
|
8
|
+
stylePreprocessorOptions?: any;
|
|
9
|
+
};
|
|
10
|
+
angularBuilderContext?: BuilderContext | null;
|
|
11
|
+
tsConfig?: string;
|
|
12
|
+
}>;
|
|
@@ -2,7 +2,6 @@ import { SourceType } from '@storybook/docs-tools';
|
|
|
2
2
|
export declare const parameters: {
|
|
3
3
|
docs: {
|
|
4
4
|
inlineStories: boolean;
|
|
5
|
-
prepareForInline: (storyFn: import("@storybook/csf").PartialStoryFn<import("..").AngularFramework, import("@storybook/csf").Args>, { id, parameters, component }: import("..").StoryContext) => import("react").DetailedReactHTMLElement<import("react").HTMLAttributes<undefined>, undefined>;
|
|
6
5
|
extractArgTypes: (component: import("./types").Directive) => import("lib/api/dist/types").ArgTypes;
|
|
7
6
|
extractComponentDescription: (component: import("./types").Directive) => string;
|
|
8
7
|
source: {
|
|
@@ -4,12 +4,10 @@ exports.argTypesEnhancers = exports.decorators = exports.parameters = void 0;
|
|
|
4
4
|
const docs_tools_1 = require("@storybook/docs-tools");
|
|
5
5
|
const compodoc_1 = require("./compodoc");
|
|
6
6
|
const sourceDecorator_1 = require("./sourceDecorator");
|
|
7
|
-
const prepareForInline_1 = require("./prepareForInline");
|
|
8
7
|
exports.parameters = {
|
|
9
8
|
docs: {
|
|
10
9
|
// probably set this to true by default once it's battle-tested
|
|
11
10
|
inlineStories: false,
|
|
12
|
-
prepareForInline: prepareForInline_1.prepareForInline,
|
|
13
11
|
extractArgTypes: compodoc_1.extractArgTypes,
|
|
14
12
|
extractComponentDescription: compodoc_1.extractComponentDescription,
|
|
15
13
|
source: {
|
|
@@ -44,16 +44,22 @@ const getStorybookModuleMetadata = ({ storyFnAngular, component: annotatedCompon
|
|
|
44
44
|
* Create a component that wraps generated template and gives it props
|
|
45
45
|
*/
|
|
46
46
|
const ComponentToInject = (0, StorybookWrapperComponent_1.createStorybookWrapperComponent)(targetSelector, template, component, styles, props);
|
|
47
|
+
const isStandalone = (0, NgComponentAnalyzer_1.isStandaloneComponent)(component);
|
|
47
48
|
// Look recursively (deep) if the component is not already declared by an import module
|
|
48
49
|
const requiresComponentDeclaration = (0, NgComponentAnalyzer_1.isDeclarable)(component) &&
|
|
49
|
-
!(0, NgModulesAnalyzer_1.isComponentAlreadyDeclaredInModules)(component, moduleMetadata.declarations, moduleMetadata.imports)
|
|
50
|
+
!(0, NgModulesAnalyzer_1.isComponentAlreadyDeclaredInModules)(component, moduleMetadata.declarations, moduleMetadata.imports) &&
|
|
51
|
+
!isStandalone;
|
|
50
52
|
return {
|
|
51
53
|
declarations: [
|
|
52
54
|
...(requiresComponentDeclaration ? [component] : []),
|
|
53
55
|
ComponentToInject,
|
|
54
56
|
...(moduleMetadata.declarations ?? []),
|
|
55
57
|
],
|
|
56
|
-
imports: [
|
|
58
|
+
imports: [
|
|
59
|
+
platform_browser_1.BrowserModule,
|
|
60
|
+
...(isStandalone ? [component] : []),
|
|
61
|
+
...(moduleMetadata.imports ?? []),
|
|
62
|
+
],
|
|
57
63
|
providers: [(0, StorybookProvider_1.storyPropsProvider)(storyProps$), ...(moduleMetadata.providers ?? [])],
|
|
58
64
|
entryComponents: [...(moduleMetadata.entryComponents ?? [])],
|
|
59
65
|
schemas: [...(moduleMetadata.schemas ?? [])],
|
|
@@ -15,6 +15,7 @@ export declare type ComponentInputsOutputs = {
|
|
|
15
15
|
export declare const getComponentInputsOutputs: (component: any) => ComponentInputsOutputs;
|
|
16
16
|
export declare const isDeclarable: (component: any) => boolean;
|
|
17
17
|
export declare const isComponent: (component: any) => component is Type<unknown>;
|
|
18
|
+
export declare const isStandaloneComponent: (component: any) => component is Type<unknown>;
|
|
18
19
|
/**
|
|
19
20
|
* Returns all component decorator properties
|
|
20
21
|
* is used to get all `@Input` and `@Output` Decorator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
|
|
3
|
+
exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isStandaloneComponent = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
|
|
4
4
|
const core_1 = require("@angular/core");
|
|
5
5
|
const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
|
|
6
6
|
/**
|
|
@@ -69,6 +69,16 @@ const isComponent = (component) => {
|
|
|
69
69
|
return (decorators || []).some((d) => d instanceof core_1.Component);
|
|
70
70
|
};
|
|
71
71
|
exports.isComponent = isComponent;
|
|
72
|
+
const isStandaloneComponent = (component) => {
|
|
73
|
+
if (!component) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const decorators = reflectionCapabilities.annotations(component);
|
|
77
|
+
// TODO: `standalone` is only available in Angular v14. Remove cast to `any` once
|
|
78
|
+
// Angular deps are updated to v14.x.x.
|
|
79
|
+
return (decorators || []).some((d) => d instanceof core_1.Component && d.standalone);
|
|
80
|
+
};
|
|
81
|
+
exports.isStandaloneComponent = isStandaloneComponent;
|
|
72
82
|
/**
|
|
73
83
|
* Returns all component decorator properties
|
|
74
84
|
* is used to get all `@Input` and `@Output` Decorator
|
package/dist/types/preset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StorybookConfig } from './types';
|
|
2
2
|
export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
|
|
3
3
|
export declare const addons: StorybookConfig['addons'];
|
|
4
4
|
export declare const core: (config: StorybookConfig['core']) => Promise<{
|
|
@@ -10,3 +10,4 @@ export declare const core: (config: StorybookConfig['core']) => Promise<{
|
|
|
10
10
|
enableCrashReports?: boolean;
|
|
11
11
|
crossOriginIsolated?: boolean;
|
|
12
12
|
}>;
|
|
13
|
+
export declare const typescript: (config: StorybookConfig['typescript']) => Promise<StorybookConfig['typescript']>;
|
package/dist/types/preset.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.core = exports.addons = exports.previewAnnotations = void 0;
|
|
6
|
+
exports.typescript = exports.core = exports.addons = exports.previewAnnotations = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const previewAnnotations = (entries = []) => [
|
|
5
9
|
...entries,
|
|
6
10
|
require.resolve('./client/preview/config'),
|
|
@@ -15,7 +19,14 @@ exports.addons = [
|
|
|
15
19
|
const core = async (config) => {
|
|
16
20
|
return {
|
|
17
21
|
...config,
|
|
18
|
-
builder: require.resolve('@storybook/builder-webpack5'),
|
|
22
|
+
builder: path_1.default.dirname(require.resolve(path_1.default.join('@storybook/builder-webpack5', 'package.json'))),
|
|
19
23
|
};
|
|
20
24
|
};
|
|
21
25
|
exports.core = core;
|
|
26
|
+
const typescript = async (config) => {
|
|
27
|
+
return {
|
|
28
|
+
...config,
|
|
29
|
+
skipBabel: true,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.typescript = typescript;
|
|
@@ -163,7 +163,7 @@ async function getLegacyDefaultBuildOptions(options) {
|
|
|
163
163
|
project: (0, angular_read_workspace_1.getDefaultProjectName)(workspaceConfig),
|
|
164
164
|
target: 'build',
|
|
165
165
|
};
|
|
166
|
-
const { target
|
|
166
|
+
const { target } = (0, angular_read_workspace_1.findAngularProjectTarget)(workspaceConfig, browserTarget.project, browserTarget.target);
|
|
167
167
|
node_logger_1.logger.info(`=> Using angular project "${browserTarget.project}:${browserTarget.target}" for configuring Storybook`);
|
|
168
168
|
return { ...target.options };
|
|
169
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.4",
|
|
4
4
|
"description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"prepare": "node ../../scripts/prepare.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
37
|
-
"@storybook/api": "7.0.0-alpha.
|
|
38
|
-
"@storybook/builder-webpack5": "7.0.0-alpha.
|
|
39
|
-
"@storybook/client-logger": "7.0.0-alpha.
|
|
40
|
-
"@storybook/core-client": "7.0.0-alpha.
|
|
41
|
-
"@storybook/core-common": "7.0.0-alpha.
|
|
42
|
-
"@storybook/core-events": "7.0.0-alpha.
|
|
43
|
-
"@storybook/core-server": "7.0.0-alpha.
|
|
36
|
+
"@storybook/addons": "7.0.0-alpha.4",
|
|
37
|
+
"@storybook/api": "7.0.0-alpha.4",
|
|
38
|
+
"@storybook/builder-webpack5": "7.0.0-alpha.4",
|
|
39
|
+
"@storybook/client-logger": "7.0.0-alpha.4",
|
|
40
|
+
"@storybook/core-client": "7.0.0-alpha.4",
|
|
41
|
+
"@storybook/core-common": "7.0.0-alpha.4",
|
|
42
|
+
"@storybook/core-events": "7.0.0-alpha.4",
|
|
43
|
+
"@storybook/core-server": "7.0.0-alpha.4",
|
|
44
44
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
45
|
-
"@storybook/docs-tools": "7.0.0-alpha.
|
|
46
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
|
45
|
+
"@storybook/docs-tools": "7.0.0-alpha.4",
|
|
46
|
+
"@storybook/node-logger": "7.0.0-alpha.4",
|
|
47
47
|
"@storybook/semver": "^7.3.2",
|
|
48
|
-
"@storybook/store": "7.0.0-alpha.
|
|
48
|
+
"@storybook/store": "7.0.0-alpha.4",
|
|
49
49
|
"@types/node": "^14.14.20 || ^16.0.0",
|
|
50
50
|
"@types/react": "^16.14.23",
|
|
51
51
|
"@types/react-dom": "^16.9.14",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"react": "^16.14.0",
|
|
63
63
|
"react-dom": "^16.14.0",
|
|
64
64
|
"read-pkg-up": "^7.0.1",
|
|
65
|
-
"regenerator-runtime": "^0.13.7",
|
|
66
65
|
"sass-loader": "^12.6.0",
|
|
67
66
|
"telejson": "^6.0.8",
|
|
68
67
|
"ts-dedent": "^2.0.0",
|
|
@@ -128,5 +127,5 @@
|
|
|
128
127
|
"access": "public"
|
|
129
128
|
},
|
|
130
129
|
"builders": "dist/types/builders/builders.json",
|
|
131
|
-
"gitHead": "
|
|
130
|
+
"gitHead": "006ed54452dd7c37a8cbe91a84f5312182f7ca00"
|
|
132
131
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PartialStoryFn } from '@storybook/csf';
|
|
3
|
-
import { AngularFramework, StoryContext } from '..';
|
|
4
|
-
/**
|
|
5
|
-
* Uses the angular renderer to generate a story. Uses p-limit to run synchronously
|
|
6
|
-
*/
|
|
7
|
-
export declare const prepareForInline: (storyFn: PartialStoryFn<AngularFramework>, { id, parameters, component }: StoryContext) => React.DetailedReactHTMLElement<React.HTMLAttributes<undefined>, undefined>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.prepareForInline = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const p_limit_1 = __importDefault(require("p-limit"));
|
|
9
|
-
const nanoid_1 = require("nanoid");
|
|
10
|
-
const renderer_1 = require("../../renderer");
|
|
11
|
-
const limit = (0, p_limit_1.default)(1);
|
|
12
|
-
/**
|
|
13
|
-
* Uses the angular renderer to generate a story. Uses p-limit to run synchronously
|
|
14
|
-
*/
|
|
15
|
-
const prepareForInline = (storyFn, { id, parameters, component }) => {
|
|
16
|
-
const el = react_1.default.useRef();
|
|
17
|
-
react_1.default.useEffect(() => {
|
|
18
|
-
(async () => {
|
|
19
|
-
limit(async () => {
|
|
20
|
-
const renderer = await renderer_1.rendererFactory.getRendererInstance(`${id}-${(0, nanoid_1.nanoid)(10)}`.toLowerCase(), el.current);
|
|
21
|
-
if (renderer) {
|
|
22
|
-
await renderer.render({
|
|
23
|
-
forced: false,
|
|
24
|
-
component,
|
|
25
|
-
parameters,
|
|
26
|
-
storyFnAngular: storyFn(),
|
|
27
|
-
targetDOMNode: el.current,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
})();
|
|
32
|
-
});
|
|
33
|
-
return react_1.default.createElement('div', {
|
|
34
|
-
ref: el,
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
exports.prepareForInline = prepareForInline;
|
package/standalone.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { CLIOptions, LoadOptions, BuilderOptions } from '@storybook/core-common';
|
|
2
|
-
import type { BuilderContext } from '@angular-devkit/architect';
|
|
3
|
-
|
|
4
|
-
export type StandaloneOptions = Partial<
|
|
5
|
-
CLIOptions &
|
|
6
|
-
LoadOptions &
|
|
7
|
-
BuilderOptions & {
|
|
8
|
-
mode?: 'static' | 'dev';
|
|
9
|
-
angularBrowserTarget?: string | null;
|
|
10
|
-
angularBuilderOptions?: Record<string, any> & {
|
|
11
|
-
styles?: any[];
|
|
12
|
-
stylePreprocessorOptions?: any;
|
|
13
|
-
};
|
|
14
|
-
angularBuilderContext?: BuilderContext | null;
|
|
15
|
-
tsConfig?: string;
|
|
16
|
-
}
|
|
17
|
-
>;
|
|
18
|
-
|
|
19
|
-
declare module '@storybook/angular/standalone' {
|
|
20
|
-
export default function buildStandalone(options: StandaloneOptions): Promise<unknown>;
|
|
21
|
-
}
|