@storybook/angular 8.0.0-alpha.8 → 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.
- package/dist/builders/build-storybook/index.d.ts +2 -2
- package/dist/builders/build-storybook/index.js +5 -4
- package/dist/builders/build-storybook/index.spec.js +8 -10
- package/dist/builders/start-storybook/index.js +3 -4
- package/dist/builders/start-storybook/index.spec.js +2 -4
- package/dist/builders/utils/run-compodoc.js +2 -2
- package/dist/builders/utils/run-compodoc.spec.js +1 -1
- package/dist/client/angular-beta/AbstractRenderer.d.ts +0 -6
- package/dist/client/angular-beta/AbstractRenderer.js +11 -59
- package/dist/client/angular-beta/CanvasRenderer.d.ts +0 -1
- package/dist/client/angular-beta/CanvasRenderer.js +0 -3
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +65 -66
- package/dist/client/angular-beta/DocsRenderer.d.ts +0 -1
- package/dist/client/angular-beta/DocsRenderer.js +0 -3
- package/dist/client/angular-beta/RendererFactory.test.js +33 -2
- package/dist/client/angular-beta/StorybookModule.test.js +36 -35
- package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +0 -1
- package/dist/client/angular-beta/StorybookWrapperComponent.js +11 -22
- package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +14 -0
- package/dist/client/angular-beta/utils/BootstrapQueue.js +81 -0
- package/dist/client/angular-beta/utils/BootstrapQueue.test.d.ts +1 -0
- package/dist/client/angular-beta/utils/BootstrapQueue.test.js +162 -0
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +66 -65
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +8 -7
- package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -1
- package/dist/client/angular-beta/utils/PropertyExtractor.test.js +0 -2
- package/dist/client/argsToTemplate.test.js +20 -19
- package/dist/client/decorateStory.test.js +28 -27
- package/dist/client/docs/__testfixtures__/doc-button/input.js +2 -3
- package/dist/client/docs/angular-properties.test.js +4 -26
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +0 -3
- package/dist/client/public-types.d.ts +1 -11
- package/dist/preset.d.ts +2 -3
- package/dist/preset.js +0 -1
- package/dist/preset.mjs +0 -1
- package/dist/server/angular-cli-webpack.js +0 -1
- package/dist/server/framework-preset-angular-ivy.js +0 -1
- package/package.json +12 -14
- package/dist/client/public-api.d.ts +0 -1
- package/dist/client/public-api.js +0 -17
|
@@ -15,7 +15,7 @@ export type StorybookBuilderOptions = JsonObject & {
|
|
|
15
15
|
stylePreprocessorOptions?: StylePreprocessorOptions;
|
|
16
16
|
assets?: AssetPattern[];
|
|
17
17
|
sourceMap?: SourceMapUnion;
|
|
18
|
-
} & Pick<CLIOptions, 'outputDir' | 'configDir' | 'loglevel' | 'quiet' | 'webpackStatsJson' | 'disableTelemetry' | 'debugWebpack' | 'previewUrl'>;
|
|
18
|
+
} & Pick<CLIOptions, 'outputDir' | 'configDir' | 'loglevel' | 'quiet' | 'test' | 'webpackStatsJson' | 'disableTelemetry' | 'debugWebpack' | 'previewUrl'>;
|
|
19
19
|
export type StorybookBuilderOutput = JsonObject & BuilderOutput & {
|
|
20
20
|
[key: string]: any;
|
|
21
21
|
};
|
|
@@ -31,5 +31,5 @@ declare const _default: import("@angular-devkit/architect/src/internal").Builder
|
|
|
31
31
|
stylePreprocessorOptions?: StylePreprocessorOptions | undefined;
|
|
32
32
|
assets?: AssetPattern[] | undefined;
|
|
33
33
|
sourceMap?: SourceMapUnion | undefined;
|
|
34
|
-
} & Pick<CLIOptions, "webpackStatsJson" | "outputDir" | "configDir" | "loglevel" | "quiet" | "disableTelemetry" | "debugWebpack" | "previewUrl">>;
|
|
34
|
+
} & Pick<CLIOptions, "webpackStatsJson" | "outputDir" | "configDir" | "loglevel" | "quiet" | "test" | "disableTelemetry" | "debugWebpack" | "previewUrl">>;
|
|
35
35
|
export default _default;
|
|
@@ -5,12 +5,12 @@ const rxjs_1 = require("rxjs");
|
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const find_up_1 = require("find-up");
|
|
7
7
|
const read_pkg_up_1 = require("read-pkg-up");
|
|
8
|
-
const
|
|
8
|
+
const core_common_1 = require("@storybook/core-common");
|
|
9
9
|
const telemetry_1 = require("@storybook/telemetry");
|
|
10
10
|
const core_server_1 = require("@storybook/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',
|
|
13
|
+
(0, telemetry_1.addToGlobalContext)('cliVersion', core_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 runCompodoc$ = options.compodoc
|
|
@@ -18,18 +18,19 @@ const commandBuilder = (options, context) => {
|
|
|
18
18
|
: (0, rxjs_1.of)({});
|
|
19
19
|
return runCompodoc$.pipe((0, operators_1.mapTo)({ tsConfig }));
|
|
20
20
|
}), (0, operators_1.map)(({ tsConfig }) => {
|
|
21
|
-
(0,
|
|
21
|
+
(0, core_common_1.getEnvConfig)(options, {
|
|
22
22
|
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
23
23
|
outputDir: 'SBCONFIG_OUTPUT_DIR',
|
|
24
24
|
configDir: 'SBCONFIG_CONFIG_DIR',
|
|
25
25
|
});
|
|
26
|
-
const { browserTarget, stylePreprocessorOptions, styles, configDir, docs, loglevel, outputDir, quiet, enableProdMode = true, webpackStatsJson, debugWebpack, disableTelemetry, assets, previewUrl, sourceMap = false, } = options;
|
|
26
|
+
const { browserTarget, stylePreprocessorOptions, styles, configDir, docs, loglevel, test, outputDir, quiet, enableProdMode = true, webpackStatsJson, debugWebpack, disableTelemetry, assets, previewUrl, sourceMap = false, } = options;
|
|
27
27
|
const standaloneOptions = {
|
|
28
28
|
packageJson: (0, read_pkg_up_1.sync)({ cwd: __dirname }).packageJson,
|
|
29
29
|
configDir,
|
|
30
30
|
...(docs ? { docs } : {}),
|
|
31
31
|
loglevel,
|
|
32
32
|
outputDir,
|
|
33
|
+
test,
|
|
33
34
|
quiet,
|
|
34
35
|
enableProdMode,
|
|
35
36
|
disableTelemetry,
|
|
@@ -40,7 +40,7 @@ const buildMock = {
|
|
|
40
40
|
withTelemetry: (name, options, fn) => fn(),
|
|
41
41
|
};
|
|
42
42
|
vitest_1.vi.doMock('@storybook/core-server', () => buildMock);
|
|
43
|
-
vitest_1.vi.doMock('@storybook/
|
|
43
|
+
vitest_1.vi.doMock('@storybook/core-common', () => ({
|
|
44
44
|
JsPackageManagerFactory: {
|
|
45
45
|
getPackageManager: () => ({
|
|
46
46
|
runPackageCommand: mockRunScript,
|
|
@@ -54,7 +54,6 @@ vitest_1.vi.doMock('@storybook/cli', () => ({
|
|
|
54
54
|
vitest_1.vi.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
|
|
55
55
|
const mockRunScript = vitest_1.vi.fn();
|
|
56
56
|
// Randomly fails on CI. TODO: investigate why
|
|
57
|
-
// eslint-disable-next-line jest/no-disabled-tests
|
|
58
57
|
vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
59
58
|
let architect;
|
|
60
59
|
let architectHost;
|
|
@@ -83,10 +82,10 @@ vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
|
83
82
|
(0, vitest_1.beforeEach)(() => {
|
|
84
83
|
buildStaticStandaloneMock.mockImplementation((_options) => Promise.resolve(_options));
|
|
85
84
|
});
|
|
86
|
-
afterEach(() => {
|
|
85
|
+
(0, vitest_1.afterEach)(() => {
|
|
87
86
|
vitest_1.vi.clearAllMocks();
|
|
88
87
|
});
|
|
89
|
-
it('should start storybook with angularBrowserTarget', async () => {
|
|
88
|
+
(0, vitest_1.it)('should start storybook with angularBrowserTarget', async () => {
|
|
90
89
|
const run = await architect.scheduleBuilder('@storybook/angular:build-storybook', {
|
|
91
90
|
browserTarget: 'angular-cli:build-2',
|
|
92
91
|
compodoc: false,
|
|
@@ -109,7 +108,7 @@ vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
|
109
108
|
webpackStatsJson: false,
|
|
110
109
|
}));
|
|
111
110
|
});
|
|
112
|
-
it('should start storybook with tsConfig', async () => {
|
|
111
|
+
(0, vitest_1.it)('should start storybook with tsConfig', async () => {
|
|
113
112
|
const run = await architect.scheduleBuilder('@storybook/angular:build-storybook', {
|
|
114
113
|
tsConfig: 'path/to/tsConfig.json',
|
|
115
114
|
compodoc: false,
|
|
@@ -132,7 +131,7 @@ vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
|
132
131
|
webpackStatsJson: false,
|
|
133
132
|
}));
|
|
134
133
|
});
|
|
135
|
-
it('should build storybook with webpack stats.json', async () => {
|
|
134
|
+
(0, vitest_1.it)('should build storybook with webpack stats.json', async () => {
|
|
136
135
|
const run = await architect.scheduleBuilder('@storybook/angular:build-storybook', {
|
|
137
136
|
tsConfig: 'path/to/tsConfig.json',
|
|
138
137
|
compodoc: false,
|
|
@@ -155,7 +154,7 @@ vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
|
155
154
|
webpackStatsJson: true,
|
|
156
155
|
}));
|
|
157
156
|
});
|
|
158
|
-
it('should throw error', async () => {
|
|
157
|
+
(0, vitest_1.it)('should throw error', async () => {
|
|
159
158
|
buildStaticStandaloneMock.mockRejectedValue(true);
|
|
160
159
|
const run = await architect.scheduleBuilder('@storybook/angular:build-storybook', {
|
|
161
160
|
browserTarget: 'angular-cli:build-2',
|
|
@@ -166,11 +165,10 @@ vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
|
166
165
|
(0, vitest_1.expect)(false).toEqual('Throw expected');
|
|
167
166
|
}
|
|
168
167
|
catch (error) {
|
|
169
|
-
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
|
|
170
168
|
(0, vitest_1.expect)(error).toEqual('Broken build, fix the error above.\nYou may need to refresh the browser.');
|
|
171
169
|
}
|
|
172
170
|
});
|
|
173
|
-
it('should run compodoc', async () => {
|
|
171
|
+
(0, vitest_1.it)('should run compodoc', async () => {
|
|
174
172
|
const run = await architect.scheduleBuilder('@storybook/angular:build-storybook', {
|
|
175
173
|
browserTarget: 'angular-cli:build-2',
|
|
176
174
|
});
|
|
@@ -191,7 +189,7 @@ vitest_1.describe.skip('Build Storybook Builder', () => {
|
|
|
191
189
|
webpackStatsJson: false,
|
|
192
190
|
}));
|
|
193
191
|
});
|
|
194
|
-
it('should start storybook with styles options', async () => {
|
|
192
|
+
(0, vitest_1.it)('should start storybook with styles options', async () => {
|
|
195
193
|
const run = await architect.scheduleBuilder('@storybook/angular:build-storybook', {
|
|
196
194
|
tsConfig: 'path/to/tsConfig.json',
|
|
197
195
|
compodoc: false,
|
|
@@ -5,12 +5,12 @@ const rxjs_1 = require("rxjs");
|
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const find_up_1 = require("find-up");
|
|
7
7
|
const read_pkg_up_1 = require("read-pkg-up");
|
|
8
|
-
const
|
|
8
|
+
const core_common_1 = require("@storybook/core-common");
|
|
9
9
|
const telemetry_1 = require("@storybook/telemetry");
|
|
10
10
|
const core_server_1 = require("@storybook/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',
|
|
13
|
+
(0, telemetry_1.addToGlobalContext)('cliVersion', core_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 runCompodoc$ = options.compodoc
|
|
@@ -21,14 +21,13 @@ const commandBuilder = (options, context) => {
|
|
|
21
21
|
: (0, rxjs_1.of)({});
|
|
22
22
|
return runCompodoc$.pipe((0, operators_1.mapTo)({ tsConfig }));
|
|
23
23
|
}), (0, operators_1.map)(({ tsConfig }) => {
|
|
24
|
-
(0,
|
|
24
|
+
(0, core_common_1.getEnvConfig)(options, {
|
|
25
25
|
port: 'SBCONFIG_PORT',
|
|
26
26
|
host: 'SBCONFIG_HOSTNAME',
|
|
27
27
|
staticDir: 'SBCONFIG_STATIC_DIR',
|
|
28
28
|
configDir: 'SBCONFIG_CONFIG_DIR',
|
|
29
29
|
ci: 'CI',
|
|
30
30
|
});
|
|
31
|
-
// eslint-disable-next-line no-param-reassign
|
|
32
31
|
options.port = parseInt(`${options.port}`, 10);
|
|
33
32
|
const { browserTarget, stylePreprocessorOptions, styles, ci, configDir, docs, host, https, port, quiet, enableProdMode = false, smokeTest, sslCa, sslCert, sslKey, disableTelemetry, assets, initialPath, open, debugWebpack, loglevel, webpackStatsJson, previewUrl, sourceMap = false, } = options;
|
|
34
33
|
const standaloneOptions = {
|
|
@@ -42,7 +42,7 @@ const buildMock = {
|
|
|
42
42
|
vitest_1.vi.doMock('@storybook/core-server', () => buildMock);
|
|
43
43
|
vitest_1.vi.doMock('find-up', () => ({ sync: () => './storybook/tsconfig.ts' }));
|
|
44
44
|
const mockRunScript = vitest_1.vi.fn();
|
|
45
|
-
vitest_1.vi.mock('@storybook/
|
|
45
|
+
vitest_1.vi.mock('@storybook/core-common', () => ({
|
|
46
46
|
getEnvConfig: (options) => options,
|
|
47
47
|
versions: {
|
|
48
48
|
storybook: 'x.x.x',
|
|
@@ -54,7 +54,6 @@ vitest_1.vi.mock('@storybook/cli', () => ({
|
|
|
54
54
|
},
|
|
55
55
|
}));
|
|
56
56
|
// Randomly fails on CI. TODO: investigate why
|
|
57
|
-
// eslint-disable-next-line jest/no-disabled-tests
|
|
58
57
|
vitest_1.describe.skip('Start Storybook Builder', () => {
|
|
59
58
|
let architect;
|
|
60
59
|
let architectHost;
|
|
@@ -83,7 +82,7 @@ vitest_1.describe.skip('Start Storybook Builder', () => {
|
|
|
83
82
|
(0, vitest_1.beforeEach)(() => {
|
|
84
83
|
buildDevStandaloneMock.mockImplementation((_options) => Promise.resolve(_options));
|
|
85
84
|
});
|
|
86
|
-
afterEach(() => {
|
|
85
|
+
(0, vitest_1.afterEach)(() => {
|
|
87
86
|
vitest_1.vi.clearAllMocks();
|
|
88
87
|
});
|
|
89
88
|
(0, vitest_1.it)('should start storybook with angularBrowserTarget', async () => {
|
|
@@ -154,7 +153,6 @@ vitest_1.describe.skip('Start Storybook Builder', () => {
|
|
|
154
153
|
(0, vitest_1.expect)(false).toEqual('Throw expected');
|
|
155
154
|
}
|
|
156
155
|
catch (error) {
|
|
157
|
-
// eslint-disable-next-line jest/no-try-expect, jest/no-conditional-expect
|
|
158
156
|
(0, vitest_1.expect)(error).toEqual('Broken build, fix the error above.\nYou may need to refresh the browser.');
|
|
159
157
|
}
|
|
160
158
|
});
|
|
@@ -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
|
|
29
|
+
const core_common_1 = require("@storybook/core-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 =
|
|
45
|
+
const packageManager = core_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/
|
|
8
|
+
vitest_1.vi.mock('@storybook/core-common', () => ({
|
|
9
9
|
JsPackageManagerFactory: {
|
|
10
10
|
getPackageManager: () => ({
|
|
11
11
|
runPackageCommandSync: mockRunScript,
|
|
@@ -16,16 +16,10 @@ export declare abstract class AbstractRenderer {
|
|
|
16
16
|
* Wait and destroy the platform
|
|
17
17
|
*/
|
|
18
18
|
static resetApplications(domNode?: HTMLElement): void;
|
|
19
|
-
/**
|
|
20
|
-
* Reset compiled components because we often want to compile the same component with
|
|
21
|
-
* more than one NgModule.
|
|
22
|
-
*/
|
|
23
|
-
protected static resetCompiledComponents: () => Promise<void>;
|
|
24
19
|
protected previousStoryRenderInfo: Map<HTMLElement, StoryRenderInfo>;
|
|
25
20
|
protected storyProps$: Subject<ICollection | undefined>;
|
|
26
21
|
constructor();
|
|
27
22
|
protected abstract beforeFullRender(domNode?: HTMLElement): Promise<void>;
|
|
28
|
-
protected abstract afterFullRender(): Promise<void>;
|
|
29
23
|
/**
|
|
30
24
|
* Bootstrap main angular module with main component or send only new `props` with storyProps$
|
|
31
25
|
*
|
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var _a;
|
|
26
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
3
|
exports.AbstractRenderer = exports.STORY_UID_ATTRIBUTE = void 0;
|
|
28
4
|
const core_1 = require("@angular/core");
|
|
@@ -31,8 +7,8 @@ const rxjs_1 = require("rxjs");
|
|
|
31
7
|
const telejson_1 = require("telejson");
|
|
32
8
|
const StorybookModule_1 = require("./StorybookModule");
|
|
33
9
|
const StorybookProvider_1 = require("./StorybookProvider");
|
|
34
|
-
const StorybookWrapperComponent_1 = require("./StorybookWrapperComponent");
|
|
35
10
|
const PropertyExtractor_1 = require("./utils/PropertyExtractor");
|
|
11
|
+
const BootstrapQueue_1 = require("./utils/BootstrapQueue");
|
|
36
12
|
const applicationRefs = new Map();
|
|
37
13
|
/**
|
|
38
14
|
* Attribute name for the story UID that may be written to the targetDOMNode.
|
|
@@ -46,7 +22,6 @@ class AbstractRenderer {
|
|
|
46
22
|
* Wait and destroy the platform
|
|
47
23
|
*/
|
|
48
24
|
static resetApplications(domNode) {
|
|
49
|
-
StorybookWrapperComponent_1.componentNgModules.clear();
|
|
50
25
|
applicationRefs.forEach((appRef, appDOMNode) => {
|
|
51
26
|
if (!appRef.destroyed && (!domNode || appDOMNode === domNode)) {
|
|
52
27
|
appRef.destroy();
|
|
@@ -61,7 +36,6 @@ class AbstractRenderer {
|
|
|
61
36
|
(0, core_1.enableProdMode)();
|
|
62
37
|
}
|
|
63
38
|
catch (e) {
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
39
|
console.debug(e);
|
|
66
40
|
}
|
|
67
41
|
}
|
|
@@ -109,16 +83,17 @@ class AbstractRenderer {
|
|
|
109
83
|
targetSelector: componentSelector,
|
|
110
84
|
analyzedMetadata,
|
|
111
85
|
});
|
|
112
|
-
const applicationRef = await (0,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
86
|
+
const applicationRef = await (0, BootstrapQueue_1.queueBootstrapping)(() => {
|
|
87
|
+
return (0, platform_browser_1.bootstrapApplication)(application, {
|
|
88
|
+
...storyFnAngular.applicationConfig,
|
|
89
|
+
providers: [
|
|
90
|
+
(0, StorybookProvider_1.storyPropsProvider)(newStoryProps$),
|
|
91
|
+
...analyzedMetadata.applicationProviders,
|
|
92
|
+
...(storyFnAngular.applicationConfig?.providers ?? []),
|
|
93
|
+
],
|
|
94
|
+
});
|
|
119
95
|
});
|
|
120
96
|
applicationRefs.set(targetDOMNode, applicationRef);
|
|
121
|
-
await this.afterFullRender();
|
|
122
97
|
}
|
|
123
98
|
/**
|
|
124
99
|
* Only ASCII alphanumerics can be used as HTML tag name.
|
|
@@ -141,7 +116,6 @@ class AbstractRenderer {
|
|
|
141
116
|
* Adds DOM element that angular will use as bootstrap component.
|
|
142
117
|
*/
|
|
143
118
|
initAngularRootElement(targetDOMNode, targetSelector) {
|
|
144
|
-
// eslint-disable-next-line no-param-reassign
|
|
145
119
|
targetDOMNode.innerHTML = '';
|
|
146
120
|
targetDOMNode.appendChild(document.createElement(targetSelector));
|
|
147
121
|
}
|
|
@@ -149,7 +123,7 @@ class AbstractRenderer {
|
|
|
149
123
|
const previousStoryRenderInfo = this.previousStoryRenderInfo.get(targetDOMNode);
|
|
150
124
|
const currentStoryRender = {
|
|
151
125
|
storyFnAngular,
|
|
152
|
-
moduleMetadataSnapshot: (0, telejson_1.stringify)(moduleMetadata),
|
|
126
|
+
moduleMetadataSnapshot: (0, telejson_1.stringify)(moduleMetadata, { allowFunction: false }),
|
|
153
127
|
};
|
|
154
128
|
this.previousStoryRenderInfo.set(targetDOMNode, currentStoryRender);
|
|
155
129
|
if (
|
|
@@ -171,25 +145,3 @@ class AbstractRenderer {
|
|
|
171
145
|
}
|
|
172
146
|
}
|
|
173
147
|
exports.AbstractRenderer = AbstractRenderer;
|
|
174
|
-
_a = AbstractRenderer;
|
|
175
|
-
/**
|
|
176
|
-
* Reset compiled components because we often want to compile the same component with
|
|
177
|
-
* more than one NgModule.
|
|
178
|
-
*/
|
|
179
|
-
AbstractRenderer.resetCompiledComponents = async () => {
|
|
180
|
-
try {
|
|
181
|
-
// Clear global Angular component cache in order to be able to re-render the same component across multiple stories
|
|
182
|
-
//
|
|
183
|
-
// References:
|
|
184
|
-
// https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts#L50
|
|
185
|
-
// https://github.com/angular/angular/blob/2ebe2bcb2fe19bf672316b05f15241fd7fd40803/packages/core/src/render3/jit/module.ts#L377-L384
|
|
186
|
-
const { ɵresetCompiledComponents } = await Promise.resolve().then(() => __importStar(require('@angular/core')));
|
|
187
|
-
ɵresetCompiledComponents();
|
|
188
|
-
}
|
|
189
|
-
catch (e) {
|
|
190
|
-
/**
|
|
191
|
-
* noop catch
|
|
192
|
-
* This means angular removed or modified ɵresetCompiledComponents
|
|
193
|
-
*/
|
|
194
|
-
}
|
|
195
|
-
};
|
|
@@ -9,8 +9,5 @@ class CanvasRenderer extends AbstractRenderer_1.AbstractRenderer {
|
|
|
9
9
|
async beforeFullRender() {
|
|
10
10
|
CanvasRenderer.resetApplications();
|
|
11
11
|
}
|
|
12
|
-
async afterFullRender() {
|
|
13
|
-
await AbstractRenderer_1.AbstractRenderer.resetCompiledComponents();
|
|
14
|
-
}
|
|
15
12
|
}
|
|
16
13
|
exports.CanvasRenderer = CanvasRenderer;
|