@storybook/angular 9.1.0-alpha.6 → 9.1.0-alpha.7
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/build-schema.json +199 -0
- package/builders.json +14 -0
- package/dist/builders/build-storybook/index.js +31 -83
- package/dist/builders/start-storybook/index.js +31 -104
- package/dist/chunk-CUDJAP6K.mjs +3 -0
- package/dist/chunk-KMSSK3DZ.mjs +6 -0
- package/dist/chunk-LXSTVAFF.mjs +40 -0
- package/dist/client/config.d.ts +20 -6
- package/dist/client/config.js +49 -20
- package/dist/client/config.mjs +10 -13
- package/dist/client/docs/config.d.ts +6 -3
- package/dist/client/docs/config.js +18 -14
- package/dist/client/docs/config.mjs +6 -10
- package/dist/client/index.d.ts +144 -6
- package/dist/client/index.js +47 -30
- package/dist/client/index.mjs +3 -9
- package/dist/client/preview-prod.d.ts +2 -1
- package/dist/client/preview-prod.js +5 -4
- package/dist/client/preview-prod.mjs +1 -0
- package/dist/index.d.ts +59 -2
- package/dist/index.js +47 -29
- package/dist/index.mjs +3 -13
- package/dist/preset.js +8 -38
- package/dist/server/framework-preset-angular-cli.js +20 -84
- package/dist/server/framework-preset-angular-ivy.js +6 -59
- package/dist/{client/types.d.ts → types-3b0b7107.d.ts} +9 -9
- package/package.json +59 -12
- package/start-schema.json +234 -0
- package/dist/builders/build-storybook/index.d.ts +0 -25
- package/dist/builders/build-storybook/index.mjs +0 -81
- package/dist/builders/build-storybook/index.spec.d.ts +0 -1
- package/dist/builders/build-storybook/index.spec.js +0 -222
- package/dist/builders/build-storybook/index.spec.mjs +0 -187
- package/dist/builders/build-storybook/schema.json +0 -199
- package/dist/builders/builders.json +0 -14
- package/dist/builders/start-storybook/index.d.ts +0 -21
- package/dist/builders/start-storybook/index.mjs +0 -102
- package/dist/builders/start-storybook/index.spec.d.ts +0 -1
- package/dist/builders/start-storybook/index.spec.js +0 -188
- package/dist/builders/start-storybook/index.spec.mjs +0 -186
- package/dist/builders/start-storybook/schema.json +0 -234
- package/dist/builders/utils/error-handler.d.ts +0 -2
- package/dist/builders/utils/error-handler.js +0 -38
- package/dist/builders/utils/error-handler.mjs +0 -33
- package/dist/builders/utils/run-compodoc.d.ts +0 -6
- package/dist/builders/utils/run-compodoc.js +0 -35
- package/dist/builders/utils/run-compodoc.mjs +0 -31
- package/dist/builders/utils/run-compodoc.spec.d.ts +0 -1
- package/dist/builders/utils/run-compodoc.spec.js +0 -76
- package/dist/builders/utils/run-compodoc.spec.mjs +0 -74
- package/dist/builders/utils/standalone-options.d.ts +0 -18
- package/dist/builders/utils/standalone-options.js +0 -2
- package/dist/builders/utils/standalone-options.mjs +0 -1
- package/dist/client/angular-beta/AbstractRenderer.d.ts +0 -75
- package/dist/client/angular-beta/AbstractRenderer.js +0 -201
- package/dist/client/angular-beta/AbstractRenderer.mjs +0 -164
- package/dist/client/angular-beta/CanvasRenderer.d.ts +0 -12
- package/dist/client/angular-beta/CanvasRenderer.js +0 -13
- package/dist/client/angular-beta/CanvasRenderer.mjs +0 -9
- package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +0 -24
- package/dist/client/angular-beta/ComputesTemplateFromComponent.js +0 -160
- package/dist/client/angular-beta/ComputesTemplateFromComponent.mjs +0 -154
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +0 -1
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +0 -730
- package/dist/client/angular-beta/ComputesTemplateFromComponent.test.mjs +0 -728
- package/dist/client/angular-beta/DocsRenderer.d.ts +0 -13
- package/dist/client/angular-beta/DocsRenderer.js +0 -39
- package/dist/client/angular-beta/DocsRenderer.mjs +0 -35
- package/dist/client/angular-beta/RendererFactory.d.ts +0 -11
- package/dist/client/angular-beta/RendererFactory.js +0 -56
- package/dist/client/angular-beta/RendererFactory.mjs +0 -50
- package/dist/client/angular-beta/RendererFactory.test.d.ts +0 -1
- package/dist/client/angular-beta/RendererFactory.test.js +0 -235
- package/dist/client/angular-beta/RendererFactory.test.mjs +0 -233
- package/dist/client/angular-beta/StorybookModule.d.ts +0 -8
- package/dist/client/angular-beta/StorybookModule.js +0 -27
- package/dist/client/angular-beta/StorybookModule.mjs +0 -23
- package/dist/client/angular-beta/StorybookModule.test.d.ts +0 -1
- package/dist/client/angular-beta/StorybookModule.test.js +0 -321
- package/dist/client/angular-beta/StorybookModule.test.mjs +0 -319
- package/dist/client/angular-beta/StorybookProvider.d.ts +0 -5
- package/dist/client/angular-beta/StorybookProvider.js +0 -26
- package/dist/client/angular-beta/StorybookProvider.mjs +0 -22
- package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +0 -13
- package/dist/client/angular-beta/StorybookWrapperComponent.js +0 -127
- package/dist/client/angular-beta/StorybookWrapperComponent.mjs +0 -123
- package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +0 -29
- package/dist/client/angular-beta/__testfixtures__/input.component.js +0 -76
- package/dist/client/angular-beta/__testfixtures__/input.component.mjs +0 -73
- package/dist/client/angular-beta/__testfixtures__/test.module.d.ts +0 -2
- package/dist/client/angular-beta/__testfixtures__/test.module.js +0 -20
- package/dist/client/angular-beta/__testfixtures__/test.module.mjs +0 -17
- package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +0 -12
- package/dist/client/angular-beta/utils/BootstrapQueue.js +0 -86
- package/dist/client/angular-beta/utils/BootstrapQueue.mjs +0 -49
- package/dist/client/angular-beta/utils/BootstrapQueue.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/BootstrapQueue.test.js +0 -164
- package/dist/client/angular-beta/utils/BootstrapQueue.test.mjs +0 -162
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +0 -22
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +0 -93
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.mjs +0 -84
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +0 -388
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.mjs +0 -386
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.d.ts +0 -6
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.js +0 -41
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.mjs +0 -37
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +0 -24
- package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.mjs +0 -22
- package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +0 -30
- package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -196
- package/dist/client/angular-beta/utils/PropertyExtractor.mjs +0 -158
- package/dist/client/angular-beta/utils/PropertyExtractor.test.d.ts +0 -1
- package/dist/client/angular-beta/utils/PropertyExtractor.test.js +0 -177
- package/dist/client/angular-beta/utils/PropertyExtractor.test.mjs +0 -175
- package/dist/client/angular-beta/utils/StoryUID.d.ts +0 -22
- package/dist/client/angular-beta/utils/StoryUID.js +0 -43
- package/dist/client/angular-beta/utils/StoryUID.mjs +0 -38
- package/dist/client/argsToTemplate.d.ts +0 -56
- package/dist/client/argsToTemplate.js +0 -58
- package/dist/client/argsToTemplate.mjs +0 -55
- package/dist/client/argsToTemplate.test.d.ts +0 -1
- package/dist/client/argsToTemplate.test.js +0 -102
- package/dist/client/argsToTemplate.test.mjs +0 -100
- package/dist/client/compodoc-types.d.ts +0 -102
- package/dist/client/compodoc-types.js +0 -2
- package/dist/client/compodoc-types.mjs +0 -1
- package/dist/client/compodoc.d.ts +0 -12
- package/dist/client/compodoc.js +0 -261
- package/dist/client/compodoc.mjs +0 -248
- package/dist/client/compodoc.test.d.ts +0 -1
- package/dist/client/compodoc.test.js +0 -132
- package/dist/client/compodoc.test.mjs +0 -130
- package/dist/client/decorateStory.d.ts +0 -4
- package/dist/client/decorateStory.js +0 -48
- package/dist/client/decorateStory.mjs +0 -45
- package/dist/client/decorateStory.test.d.ts +0 -1
- package/dist/client/decorateStory.test.js +0 -306
- package/dist/client/decorateStory.test.mjs +0 -301
- package/dist/client/decorators.d.ts +0 -13
- package/dist/client/decorators.js +0 -69
- package/dist/client/decorators.mjs +0 -63
- package/dist/client/decorators.test.d.ts +0 -1
- package/dist/client/decorators.test.js +0 -159
- package/dist/client/decorators.test.mjs +0 -157
- package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +0 -110
- package/dist/client/docs/__testfixtures__/doc-button/input.js +0 -204
- package/dist/client/docs/__testfixtures__/doc-button/input.mjs +0 -201
- package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +0 -7
- package/dist/client/docs/angular-properties.test.d.ts +0 -1
- package/dist/client/docs/angular-properties.test.js +0 -36
- package/dist/client/docs/angular-properties.test.mjs +0 -34
- package/dist/client/docs/sourceDecorator.d.ts +0 -10
- package/dist/client/docs/sourceDecorator.js +0 -53
- package/dist/client/docs/sourceDecorator.mjs +0 -48
- package/dist/client/globals.d.ts +0 -1
- package/dist/client/globals.js +0 -33
- package/dist/client/globals.mjs +0 -31
- package/dist/client/portable-stories.d.ts +0 -23
- package/dist/client/portable-stories.js +0 -62
- package/dist/client/portable-stories.mjs +0 -26
- package/dist/client/public-types.d.ts +0 -54
- package/dist/client/public-types.js +0 -2
- package/dist/client/public-types.mjs +0 -1
- package/dist/client/render.d.ts +0 -7
- package/dist/client/render.js +0 -19
- package/dist/client/render.mjs +0 -14
- package/dist/client/types.js +0 -2
- package/dist/client/types.mjs +0 -1
- package/dist/node/index.d.ts +0 -2
- package/dist/node/index.js +0 -6
- package/dist/node/index.mjs +0 -3
- package/dist/preset.d.ts +0 -5
- package/dist/preset.mjs +0 -34
- package/dist/renderer.d.ts +0 -6
- package/dist/renderer.js +0 -15
- package/dist/renderer.mjs +0 -6
- package/dist/server/__mocks-ng-workspace__/empty-projects-entry/angular.json +0 -4
- package/dist/server/__mocks-ng-workspace__/minimal-config/angular.json +0 -18
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/some-config/angular.json +0 -19
- package/dist/server/__mocks-ng-workspace__/some-config/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/some-config/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/some-config/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/some-config/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +0 -64
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/with-lib/angular.json +0 -28
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +0 -20
- package/dist/server/__mocks-ng-workspace__/with-lib/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/with-nx/angular.json +0 -18
- package/dist/server/__mocks-ng-workspace__/with-nx/nx.json +0 -3
- package/dist/server/__mocks-ng-workspace__/with-nx/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-nx/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-nx/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +0 -8
- package/dist/server/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -14
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/nx.json +0 -3
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +0 -8
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -14
- package/dist/server/__mocks-ng-workspace__/with-nx-workspace/workspace.json +0 -18
- package/dist/server/__mocks-ng-workspace__/with-options-styles/angular.json +0 -18
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/without-architect-build/angular.json +0 -5
- package/dist/server/__mocks-ng-workspace__/without-architect-build-options/angular.json +0 -11
- package/dist/server/__mocks-ng-workspace__/without-compatible-projects/angular.json +0 -7
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/angular.json +0 -3
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +0 -20
- package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -13
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/angular.json +0 -16
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +0 -1
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.js +0 -5
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.mjs +0 -2
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +0 -9
- package/dist/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -13
- package/dist/server/__tests__/angular.json +0 -96
- package/dist/server/angular-cli-webpack.d.ts +0 -1
- package/dist/server/angular-cli-webpack.js +0 -80
- package/dist/server/angular-cli-webpack.mjs +0 -80
- package/dist/server/framework-preset-angular-cli.d.ts +0 -3
- package/dist/server/framework-preset-angular-cli.mjs +0 -82
- package/dist/server/framework-preset-angular-ivy.d.ts +0 -10
- package/dist/server/framework-preset-angular-ivy.mjs +0 -56
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +0 -12
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +0 -55
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.mjs +0 -52
- package/dist/server/preset-options.d.ts +0 -9
- package/dist/server/preset-options.js +0 -2
- package/dist/server/preset-options.mjs +0 -1
- package/dist/server/utils/filter-out-styling-rules.d.ts +0 -2
- package/dist/server/utils/filter-out-styling-rules.js +0 -17
- package/dist/server/utils/filter-out-styling-rules.mjs +0 -13
- package/dist/server/utils/module-is-available.d.ts +0 -1
- package/dist/server/utils/module-is-available.js +0 -13
- package/dist/server/utils/module-is-available.mjs +0 -9
- package/dist/test-setup.d.ts +0 -1
- package/dist/test-setup.js +0 -6
- package/dist/test-setup.mjs +0 -4
- package/dist/types.d.ts +0 -27
- package/dist/types.js +0 -2
- package/dist/types.mjs +0 -1
- package/scripts/postbuild.js +0 -17
- package/template/cli/.eslintrc.json +0 -5
|
@@ -1,196 +0,0 @@
|
|
|
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 () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var _a;
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.PropertyExtractor = exports.uniqueArray = exports.REMOVED_MODULES = exports.reflectionCapabilities = void 0;
|
|
38
|
-
const common_1 = require("@angular/common");
|
|
39
|
-
const core_1 = require("@angular/core");
|
|
40
|
-
const platform_browser_1 = require("@angular/platform-browser");
|
|
41
|
-
const ts_dedent_1 = require("ts-dedent");
|
|
42
|
-
const NgModulesAnalyzer_1 = require("./NgModulesAnalyzer");
|
|
43
|
-
exports.reflectionCapabilities = new core_1.ɵReflectionCapabilities();
|
|
44
|
-
exports.REMOVED_MODULES = new core_1.InjectionToken('REMOVED_MODULES');
|
|
45
|
-
const uniqueArray = (arr) => {
|
|
46
|
-
return arr
|
|
47
|
-
.flat(Number.MAX_VALUE)
|
|
48
|
-
.filter(Boolean)
|
|
49
|
-
.filter((value, index, self) => self.indexOf(value) === index);
|
|
50
|
-
};
|
|
51
|
-
exports.uniqueArray = uniqueArray;
|
|
52
|
-
class PropertyExtractor {
|
|
53
|
-
constructor(metadata, component) {
|
|
54
|
-
this.metadata = metadata;
|
|
55
|
-
this.component = component;
|
|
56
|
-
this.declarations = [];
|
|
57
|
-
/**
|
|
58
|
-
* Analyze NgModule Metadata
|
|
59
|
-
*
|
|
60
|
-
* - Removes Restricted Imports
|
|
61
|
-
* - Extracts providers from ModuleWithProviders
|
|
62
|
-
* - Returns a new NgModuleMetadata object
|
|
63
|
-
*/
|
|
64
|
-
this.analyzeMetadata = async (metadata) => {
|
|
65
|
-
const declarations = [...(metadata?.declarations || [])];
|
|
66
|
-
const providers = [...(metadata?.providers || [])];
|
|
67
|
-
const applicationProviders = [];
|
|
68
|
-
const imports = await Promise.all([...(metadata?.imports || [])].map(async (imported) => {
|
|
69
|
-
const [isRestricted, restrictedProviders] = await _a.analyzeRestricted(imported);
|
|
70
|
-
if (isRestricted) {
|
|
71
|
-
applicationProviders.unshift(restrictedProviders || []);
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
return imported;
|
|
75
|
-
})).then((results) => results.filter(Boolean));
|
|
76
|
-
return { ...metadata, imports, providers, applicationProviders, declarations };
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
// With the new way of mounting standalone components to the DOM via bootstrapApplication API,
|
|
80
|
-
// we should now pass ModuleWithProviders to the providers array of the bootstrapApplication function.
|
|
81
|
-
static warnImportsModuleWithProviders(propertyExtractor) {
|
|
82
|
-
const hasModuleWithProvidersImport = propertyExtractor.imports.some((importedModule) => 'ngModule' in importedModule);
|
|
83
|
-
if (hasModuleWithProvidersImport) {
|
|
84
|
-
console.warn((0, ts_dedent_1.dedent)(`
|
|
85
|
-
Storybook Warning:
|
|
86
|
-
moduleMetadata property 'imports' contains one or more ModuleWithProviders, likely the result of a 'Module.forRoot()'-style call.
|
|
87
|
-
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.
|
|
88
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' to pass your ModuleWithProviders to the 'providers' property in combination with the importProvidersFrom helper function from '@angular/core' to extract all the necessary providers.
|
|
89
|
-
Visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information
|
|
90
|
-
`));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
async init() {
|
|
94
|
-
const analyzed = await this.analyzeMetadata(this.metadata);
|
|
95
|
-
this.imports = (0, exports.uniqueArray)([common_1.CommonModule, analyzed.imports]);
|
|
96
|
-
this.providers = (0, exports.uniqueArray)(analyzed.providers);
|
|
97
|
-
this.applicationProviders = (0, exports.uniqueArray)(analyzed.applicationProviders);
|
|
98
|
-
this.declarations = (0, exports.uniqueArray)(analyzed.declarations);
|
|
99
|
-
if (this.component) {
|
|
100
|
-
const { isDeclarable, isStandalone } = _a.analyzeDecorators(this.component);
|
|
101
|
-
const isDeclared = (0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(this.component, analyzed.declarations, this.imports);
|
|
102
|
-
if (isStandalone) {
|
|
103
|
-
this.imports.push(this.component);
|
|
104
|
-
}
|
|
105
|
-
else if (isDeclarable && !isDeclared) {
|
|
106
|
-
this.declarations.push(this.component);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.PropertyExtractor = PropertyExtractor;
|
|
112
|
-
_a = PropertyExtractor;
|
|
113
|
-
PropertyExtractor.analyzeRestricted = async (ngModule) => {
|
|
114
|
-
if (ngModule === platform_browser_1.BrowserModule) {
|
|
115
|
-
console.warn((0, ts_dedent_1.dedent) `
|
|
116
|
-
Storybook Warning:
|
|
117
|
-
You have imported the "BrowserModule", which is not necessary anymore.
|
|
118
|
-
In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM.
|
|
119
|
-
Note that the BrowserModule providers are automatically included when starting an application with bootstrapApplication()
|
|
120
|
-
Please remove the "BrowserModule" from the list of imports in your moduleMetadata definition to remove this warning.
|
|
121
|
-
`);
|
|
122
|
-
return [true];
|
|
123
|
-
}
|
|
124
|
-
try {
|
|
125
|
-
const animations = await Promise.resolve().then(() => __importStar(require('@angular/platform-browser/animations')));
|
|
126
|
-
if (ngModule === animations.BrowserAnimationsModule) {
|
|
127
|
-
console.warn((0, ts_dedent_1.dedent) `
|
|
128
|
-
Storybook Warning:
|
|
129
|
-
You have added the "BrowserAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
|
|
130
|
-
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.
|
|
131
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideAnimations" function to the list of "providers".
|
|
132
|
-
If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up animations. For this case, please add "importProvidersFrom(BrowserAnimationsModule)" to the list of providers of your applicationConfig definition.
|
|
133
|
-
Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
|
|
134
|
-
`);
|
|
135
|
-
return [true, animations.provideAnimations()];
|
|
136
|
-
}
|
|
137
|
-
if (ngModule === animations.NoopAnimationsModule) {
|
|
138
|
-
console.warn((0, ts_dedent_1.dedent) `
|
|
139
|
-
Storybook Warning:
|
|
140
|
-
You have added the "NoopAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
|
|
141
|
-
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.
|
|
142
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideNoopAnimations" function to the list of "providers".
|
|
143
|
-
If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up noop animations and to extract all necessary providers from NoopAnimationsModule. For this case, please add "importProvidersFrom(NoopAnimationsModule)" to the list of providers of your applicationConfig definition.
|
|
144
|
-
Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
|
|
145
|
-
`);
|
|
146
|
-
return [true, animations.provideNoopAnimations()];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (e) {
|
|
150
|
-
return [false];
|
|
151
|
-
}
|
|
152
|
-
return [false];
|
|
153
|
-
};
|
|
154
|
-
PropertyExtractor.analyzeDecorators = (component) => {
|
|
155
|
-
const decorators = exports.reflectionCapabilities.annotations(component);
|
|
156
|
-
const isComponent = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Component'));
|
|
157
|
-
const isDirective = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Directive'));
|
|
158
|
-
const isPipe = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Pipe'));
|
|
159
|
-
const isDeclarable = isComponent || isDirective || isPipe;
|
|
160
|
-
// Check if the hierarchically lowest Component or Directive decorator (the only relevant for importing dependencies) is standalone.
|
|
161
|
-
let isStandalone = (isComponent || isDirective) &&
|
|
162
|
-
[...decorators]
|
|
163
|
-
.reverse() // reflectionCapabilities returns decorators in a hierarchically top-down order
|
|
164
|
-
.find((d) => _a.isDecoratorInstanceOf(d, 'Component') || _a.isDecoratorInstanceOf(d, 'Directive'))?.standalone;
|
|
165
|
-
//Starting in Angular 19 the default (in case it's undefined) value for standalone is true
|
|
166
|
-
if (isStandalone === undefined) {
|
|
167
|
-
isStandalone = !!(core_1.VERSION.major && Number(core_1.VERSION.major) >= 19);
|
|
168
|
-
}
|
|
169
|
-
return { isDeclarable, isStandalone };
|
|
170
|
-
};
|
|
171
|
-
PropertyExtractor.isDecoratorInstanceOf = (decorator, name) => {
|
|
172
|
-
let factory;
|
|
173
|
-
switch (name) {
|
|
174
|
-
case 'Component':
|
|
175
|
-
factory = core_1.Component;
|
|
176
|
-
break;
|
|
177
|
-
case 'Directive':
|
|
178
|
-
factory = core_1.Directive;
|
|
179
|
-
break;
|
|
180
|
-
case 'Pipe':
|
|
181
|
-
factory = core_1.Pipe;
|
|
182
|
-
break;
|
|
183
|
-
case 'Injectable':
|
|
184
|
-
factory = core_1.Injectable;
|
|
185
|
-
break;
|
|
186
|
-
case 'Input':
|
|
187
|
-
factory = core_1.Input;
|
|
188
|
-
break;
|
|
189
|
-
case 'Output':
|
|
190
|
-
factory = core_1.Output;
|
|
191
|
-
break;
|
|
192
|
-
default:
|
|
193
|
-
throw new Error(`Unknown decorator type: ${name}`);
|
|
194
|
-
}
|
|
195
|
-
return decorator instanceof factory || decorator.ngMetadataName === name;
|
|
196
|
-
};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { Component, Directive, Injectable, InjectionToken, Input, Output, Pipe, ɵReflectionCapabilities as ReflectionCapabilities, VERSION, } from '@angular/core';
|
|
4
|
-
import { BrowserModule } from '@angular/platform-browser';
|
|
5
|
-
import { dedent } from 'ts-dedent';
|
|
6
|
-
import { isComponentAlreadyDeclared } from './NgModulesAnalyzer';
|
|
7
|
-
export const reflectionCapabilities = new ReflectionCapabilities();
|
|
8
|
-
export const REMOVED_MODULES = new InjectionToken('REMOVED_MODULES');
|
|
9
|
-
export const uniqueArray = (arr) => {
|
|
10
|
-
return arr
|
|
11
|
-
.flat(Number.MAX_VALUE)
|
|
12
|
-
.filter(Boolean)
|
|
13
|
-
.filter((value, index, self) => self.indexOf(value) === index);
|
|
14
|
-
};
|
|
15
|
-
export class PropertyExtractor {
|
|
16
|
-
constructor(metadata, component) {
|
|
17
|
-
this.metadata = metadata;
|
|
18
|
-
this.component = component;
|
|
19
|
-
this.declarations = [];
|
|
20
|
-
/**
|
|
21
|
-
* Analyze NgModule Metadata
|
|
22
|
-
*
|
|
23
|
-
* - Removes Restricted Imports
|
|
24
|
-
* - Extracts providers from ModuleWithProviders
|
|
25
|
-
* - Returns a new NgModuleMetadata object
|
|
26
|
-
*/
|
|
27
|
-
this.analyzeMetadata = async (metadata) => {
|
|
28
|
-
const declarations = [...(metadata?.declarations || [])];
|
|
29
|
-
const providers = [...(metadata?.providers || [])];
|
|
30
|
-
const applicationProviders = [];
|
|
31
|
-
const imports = await Promise.all([...(metadata?.imports || [])].map(async (imported) => {
|
|
32
|
-
const [isRestricted, restrictedProviders] = await _a.analyzeRestricted(imported);
|
|
33
|
-
if (isRestricted) {
|
|
34
|
-
applicationProviders.unshift(restrictedProviders || []);
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return imported;
|
|
38
|
-
})).then((results) => results.filter(Boolean));
|
|
39
|
-
return { ...metadata, imports, providers, applicationProviders, declarations };
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
// With the new way of mounting standalone components to the DOM via bootstrapApplication API,
|
|
43
|
-
// we should now pass ModuleWithProviders to the providers array of the bootstrapApplication function.
|
|
44
|
-
static warnImportsModuleWithProviders(propertyExtractor) {
|
|
45
|
-
const hasModuleWithProvidersImport = propertyExtractor.imports.some((importedModule) => 'ngModule' in importedModule);
|
|
46
|
-
if (hasModuleWithProvidersImport) {
|
|
47
|
-
console.warn(dedent(`
|
|
48
|
-
Storybook Warning:
|
|
49
|
-
moduleMetadata property 'imports' contains one or more ModuleWithProviders, likely the result of a 'Module.forRoot()'-style call.
|
|
50
|
-
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.
|
|
51
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' to pass your ModuleWithProviders to the 'providers' property in combination with the importProvidersFrom helper function from '@angular/core' to extract all the necessary providers.
|
|
52
|
-
Visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information
|
|
53
|
-
`));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
async init() {
|
|
57
|
-
const analyzed = await this.analyzeMetadata(this.metadata);
|
|
58
|
-
this.imports = uniqueArray([CommonModule, analyzed.imports]);
|
|
59
|
-
this.providers = uniqueArray(analyzed.providers);
|
|
60
|
-
this.applicationProviders = uniqueArray(analyzed.applicationProviders);
|
|
61
|
-
this.declarations = uniqueArray(analyzed.declarations);
|
|
62
|
-
if (this.component) {
|
|
63
|
-
const { isDeclarable, isStandalone } = _a.analyzeDecorators(this.component);
|
|
64
|
-
const isDeclared = isComponentAlreadyDeclared(this.component, analyzed.declarations, this.imports);
|
|
65
|
-
if (isStandalone) {
|
|
66
|
-
this.imports.push(this.component);
|
|
67
|
-
}
|
|
68
|
-
else if (isDeclarable && !isDeclared) {
|
|
69
|
-
this.declarations.push(this.component);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
_a = PropertyExtractor;
|
|
75
|
-
PropertyExtractor.analyzeRestricted = async (ngModule) => {
|
|
76
|
-
if (ngModule === BrowserModule) {
|
|
77
|
-
console.warn(dedent `
|
|
78
|
-
Storybook Warning:
|
|
79
|
-
You have imported the "BrowserModule", which is not necessary anymore.
|
|
80
|
-
In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM.
|
|
81
|
-
Note that the BrowserModule providers are automatically included when starting an application with bootstrapApplication()
|
|
82
|
-
Please remove the "BrowserModule" from the list of imports in your moduleMetadata definition to remove this warning.
|
|
83
|
-
`);
|
|
84
|
-
return [true];
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
const animations = await import('@angular/platform-browser/animations');
|
|
88
|
-
if (ngModule === animations.BrowserAnimationsModule) {
|
|
89
|
-
console.warn(dedent `
|
|
90
|
-
Storybook Warning:
|
|
91
|
-
You have added the "BrowserAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
|
|
92
|
-
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.
|
|
93
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideAnimations" function to the list of "providers".
|
|
94
|
-
If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up animations. For this case, please add "importProvidersFrom(BrowserAnimationsModule)" to the list of providers of your applicationConfig definition.
|
|
95
|
-
Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
|
|
96
|
-
`);
|
|
97
|
-
return [true, animations.provideAnimations()];
|
|
98
|
-
}
|
|
99
|
-
if (ngModule === animations.NoopAnimationsModule) {
|
|
100
|
-
console.warn(dedent `
|
|
101
|
-
Storybook Warning:
|
|
102
|
-
You have added the "NoopAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
|
|
103
|
-
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.
|
|
104
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideNoopAnimations" function to the list of "providers".
|
|
105
|
-
If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up noop animations and to extract all necessary providers from NoopAnimationsModule. For this case, please add "importProvidersFrom(NoopAnimationsModule)" to the list of providers of your applicationConfig definition.
|
|
106
|
-
Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
|
|
107
|
-
`);
|
|
108
|
-
return [true, animations.provideNoopAnimations()];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
catch (e) {
|
|
112
|
-
return [false];
|
|
113
|
-
}
|
|
114
|
-
return [false];
|
|
115
|
-
};
|
|
116
|
-
PropertyExtractor.analyzeDecorators = (component) => {
|
|
117
|
-
const decorators = reflectionCapabilities.annotations(component);
|
|
118
|
-
const isComponent = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Component'));
|
|
119
|
-
const isDirective = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Directive'));
|
|
120
|
-
const isPipe = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Pipe'));
|
|
121
|
-
const isDeclarable = isComponent || isDirective || isPipe;
|
|
122
|
-
// Check if the hierarchically lowest Component or Directive decorator (the only relevant for importing dependencies) is standalone.
|
|
123
|
-
let isStandalone = (isComponent || isDirective) &&
|
|
124
|
-
[...decorators]
|
|
125
|
-
.reverse() // reflectionCapabilities returns decorators in a hierarchically top-down order
|
|
126
|
-
.find((d) => _a.isDecoratorInstanceOf(d, 'Component') || _a.isDecoratorInstanceOf(d, 'Directive'))?.standalone;
|
|
127
|
-
//Starting in Angular 19 the default (in case it's undefined) value for standalone is true
|
|
128
|
-
if (isStandalone === undefined) {
|
|
129
|
-
isStandalone = !!(VERSION.major && Number(VERSION.major) >= 19);
|
|
130
|
-
}
|
|
131
|
-
return { isDeclarable, isStandalone };
|
|
132
|
-
};
|
|
133
|
-
PropertyExtractor.isDecoratorInstanceOf = (decorator, name) => {
|
|
134
|
-
let factory;
|
|
135
|
-
switch (name) {
|
|
136
|
-
case 'Component':
|
|
137
|
-
factory = Component;
|
|
138
|
-
break;
|
|
139
|
-
case 'Directive':
|
|
140
|
-
factory = Directive;
|
|
141
|
-
break;
|
|
142
|
-
case 'Pipe':
|
|
143
|
-
factory = Pipe;
|
|
144
|
-
break;
|
|
145
|
-
case 'Injectable':
|
|
146
|
-
factory = Injectable;
|
|
147
|
-
break;
|
|
148
|
-
case 'Input':
|
|
149
|
-
factory = Input;
|
|
150
|
-
break;
|
|
151
|
-
case 'Output':
|
|
152
|
-
factory = Output;
|
|
153
|
-
break;
|
|
154
|
-
default:
|
|
155
|
-
throw new Error(`Unknown decorator type: ${name}`);
|
|
156
|
-
}
|
|
157
|
-
return decorator instanceof factory || decorator.ngMetadataName === name;
|
|
158
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const common_1 = require("@angular/common");
|
|
4
|
-
const core_1 = require("@angular/core");
|
|
5
|
-
const platform_browser_1 = require("@angular/platform-browser");
|
|
6
|
-
const animations_1 = require("@angular/platform-browser/animations");
|
|
7
|
-
const vitest_1 = require("vitest");
|
|
8
|
-
const test_module_1 = require("../__testfixtures__/test.module");
|
|
9
|
-
const PropertyExtractor_1 = require("./PropertyExtractor");
|
|
10
|
-
const TEST_TOKEN = new core_1.InjectionToken('testToken');
|
|
11
|
-
const TestTokenProvider = { provide: TEST_TOKEN, useValue: 123 };
|
|
12
|
-
const TestService = (0, core_1.Injectable)()(class {
|
|
13
|
-
});
|
|
14
|
-
const TestComponent1 = (0, core_1.Component)({ standalone: false })(class {
|
|
15
|
-
});
|
|
16
|
-
const TestComponent2 = (0, core_1.Component)({ standalone: false })(class {
|
|
17
|
-
});
|
|
18
|
-
const StandaloneTestComponent = (0, core_1.Component)({})(class {
|
|
19
|
-
});
|
|
20
|
-
const StandaloneTestDirective = (0, core_1.Directive)({})(class {
|
|
21
|
-
});
|
|
22
|
-
const MixedTestComponent1 = (0, core_1.Component)({})(class extends StandaloneTestComponent {
|
|
23
|
-
});
|
|
24
|
-
const MixedTestComponent2 = (0, core_1.Component)({ standalone: false })(class extends MixedTestComponent1 {
|
|
25
|
-
});
|
|
26
|
-
const MixedTestComponent3 = (0, core_1.Component)({})(class extends MixedTestComponent2 {
|
|
27
|
-
});
|
|
28
|
-
const TestModuleWithDeclarations = (0, core_1.NgModule)({ declarations: [TestComponent1] })(class {
|
|
29
|
-
});
|
|
30
|
-
const TestModuleWithImportsAndProviders = (0, core_1.NgModule)({
|
|
31
|
-
imports: [TestModuleWithDeclarations],
|
|
32
|
-
providers: [TestTokenProvider],
|
|
33
|
-
})(class {
|
|
34
|
-
});
|
|
35
|
-
const analyzeMetadata = async (metadata, component) => {
|
|
36
|
-
const propertyExtractor = new PropertyExtractor_1.PropertyExtractor(metadata, component);
|
|
37
|
-
await propertyExtractor.init();
|
|
38
|
-
return propertyExtractor;
|
|
39
|
-
};
|
|
40
|
-
const extractImports = async (metadata, component) => {
|
|
41
|
-
const propertyExtractor = new PropertyExtractor_1.PropertyExtractor(metadata, component);
|
|
42
|
-
await propertyExtractor.init();
|
|
43
|
-
return propertyExtractor.imports;
|
|
44
|
-
};
|
|
45
|
-
const extractDeclarations = async (metadata, component) => {
|
|
46
|
-
const propertyExtractor = new PropertyExtractor_1.PropertyExtractor(metadata, component);
|
|
47
|
-
await propertyExtractor.init();
|
|
48
|
-
return propertyExtractor.declarations;
|
|
49
|
-
};
|
|
50
|
-
const extractProviders = async (metadata, component) => {
|
|
51
|
-
const propertyExtractor = new PropertyExtractor_1.PropertyExtractor(metadata, component);
|
|
52
|
-
await propertyExtractor.init();
|
|
53
|
-
return propertyExtractor.providers;
|
|
54
|
-
};
|
|
55
|
-
const extractApplicationProviders = async (metadata, component) => {
|
|
56
|
-
const propertyExtractor = new PropertyExtractor_1.PropertyExtractor(metadata, component);
|
|
57
|
-
await propertyExtractor.init();
|
|
58
|
-
return propertyExtractor.applicationProviders;
|
|
59
|
-
};
|
|
60
|
-
(0, vitest_1.describe)('PropertyExtractor', () => {
|
|
61
|
-
vitest_1.vi.spyOn(console, 'warn').mockImplementation(() => { });
|
|
62
|
-
(0, vitest_1.describe)('analyzeMetadata', () => {
|
|
63
|
-
(0, vitest_1.it)('should remove BrowserModule', async () => {
|
|
64
|
-
const metadata = {
|
|
65
|
-
imports: [platform_browser_1.BrowserModule],
|
|
66
|
-
};
|
|
67
|
-
const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
|
|
68
|
-
(0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
|
|
69
|
-
(0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
|
|
70
|
-
(0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
|
|
71
|
-
});
|
|
72
|
-
(0, vitest_1.it)('should remove BrowserAnimationsModule and use its providers instead', async () => {
|
|
73
|
-
const metadata = {
|
|
74
|
-
imports: [animations_1.BrowserAnimationsModule],
|
|
75
|
-
};
|
|
76
|
-
const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
|
|
77
|
-
(0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
|
|
78
|
-
(0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
|
|
79
|
-
(0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideAnimations)());
|
|
80
|
-
});
|
|
81
|
-
(0, vitest_1.it)('should remove NoopAnimationsModule and use its providers instead', async () => {
|
|
82
|
-
const metadata = {
|
|
83
|
-
imports: [animations_1.NoopAnimationsModule],
|
|
84
|
-
};
|
|
85
|
-
const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
|
|
86
|
-
(0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
|
|
87
|
-
(0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
|
|
88
|
-
(0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideNoopAnimations)());
|
|
89
|
-
});
|
|
90
|
-
(0, vitest_1.it)('should remove Browser/Animations modules recursively', async () => {
|
|
91
|
-
const metadata = {
|
|
92
|
-
imports: [animations_1.BrowserAnimationsModule, platform_browser_1.BrowserModule],
|
|
93
|
-
};
|
|
94
|
-
const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
|
|
95
|
-
(0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule]);
|
|
96
|
-
(0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
|
|
97
|
-
(0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual((0, animations_1.provideAnimations)());
|
|
98
|
-
});
|
|
99
|
-
(0, vitest_1.it)('should not destructure Angular official module', async () => {
|
|
100
|
-
const metadata = {
|
|
101
|
-
imports: [test_module_1.WithOfficialModule],
|
|
102
|
-
};
|
|
103
|
-
const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
|
|
104
|
-
(0, vitest_1.expect)(imports.flat(Number.MAX_VALUE)).toEqual([common_1.CommonModule, test_module_1.WithOfficialModule]);
|
|
105
|
-
(0, vitest_1.expect)(providers.flat(Number.MAX_VALUE)).toEqual([]);
|
|
106
|
-
(0, vitest_1.expect)(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
(0, vitest_1.describe)('extractImports', () => {
|
|
110
|
-
(0, vitest_1.it)('should return Angular official modules', async () => {
|
|
111
|
-
const imports = await extractImports({ imports: [TestModuleWithImportsAndProviders] });
|
|
112
|
-
(0, vitest_1.expect)(imports).toEqual([common_1.CommonModule, TestModuleWithImportsAndProviders]);
|
|
113
|
-
});
|
|
114
|
-
(0, vitest_1.it)('should return standalone components', async () => {
|
|
115
|
-
const imports = await extractImports({
|
|
116
|
-
imports: [TestModuleWithImportsAndProviders],
|
|
117
|
-
}, StandaloneTestComponent);
|
|
118
|
-
(0, vitest_1.expect)(imports).toEqual([
|
|
119
|
-
common_1.CommonModule,
|
|
120
|
-
TestModuleWithImportsAndProviders,
|
|
121
|
-
StandaloneTestComponent,
|
|
122
|
-
]);
|
|
123
|
-
});
|
|
124
|
-
(0, vitest_1.it)('should return standalone directives', async () => {
|
|
125
|
-
const imports = await extractImports({
|
|
126
|
-
imports: [TestModuleWithImportsAndProviders],
|
|
127
|
-
}, StandaloneTestDirective);
|
|
128
|
-
(0, vitest_1.expect)(imports).toEqual([
|
|
129
|
-
common_1.CommonModule,
|
|
130
|
-
TestModuleWithImportsAndProviders,
|
|
131
|
-
StandaloneTestDirective,
|
|
132
|
-
]);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
(0, vitest_1.describe)('extractDeclarations', () => {
|
|
136
|
-
(0, vitest_1.it)('should return an array of declarations that contains `storyComponent`', async () => {
|
|
137
|
-
const declarations = await extractDeclarations({ declarations: [TestComponent1] }, TestComponent2);
|
|
138
|
-
(0, vitest_1.expect)(declarations).toEqual([TestComponent1, TestComponent2]);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
(0, vitest_1.describe)('analyzeDecorators', () => {
|
|
142
|
-
(0, vitest_1.it)('isStandalone should be false', () => {
|
|
143
|
-
const { isStandalone } = PropertyExtractor_1.PropertyExtractor.analyzeDecorators(TestComponent1);
|
|
144
|
-
(0, vitest_1.expect)(isStandalone).toBe(false);
|
|
145
|
-
});
|
|
146
|
-
(0, vitest_1.it)('isStandalone should be true', () => {
|
|
147
|
-
const { isStandalone } = PropertyExtractor_1.PropertyExtractor.analyzeDecorators(StandaloneTestComponent);
|
|
148
|
-
(0, vitest_1.expect)(isStandalone).toBe(true);
|
|
149
|
-
});
|
|
150
|
-
(0, vitest_1.it)('isStandalone should be true', () => {
|
|
151
|
-
const { isStandalone } = PropertyExtractor_1.PropertyExtractor.analyzeDecorators(MixedTestComponent1);
|
|
152
|
-
(0, vitest_1.expect)(isStandalone).toBe(true);
|
|
153
|
-
});
|
|
154
|
-
(0, vitest_1.it)('isStandalone should be false', () => {
|
|
155
|
-
const { isStandalone } = PropertyExtractor_1.PropertyExtractor.analyzeDecorators(MixedTestComponent2);
|
|
156
|
-
(0, vitest_1.expect)(isStandalone).toBe(false);
|
|
157
|
-
});
|
|
158
|
-
(0, vitest_1.it)('isStandalone should be true', () => {
|
|
159
|
-
const { isStandalone } = PropertyExtractor_1.PropertyExtractor.analyzeDecorators(MixedTestComponent3);
|
|
160
|
-
(0, vitest_1.expect)(isStandalone).toBe(true);
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
(0, vitest_1.describe)('extractProviders', () => {
|
|
164
|
-
(0, vitest_1.it)('should return an array of providers', async () => {
|
|
165
|
-
const providers = await extractProviders({
|
|
166
|
-
providers: [TestService],
|
|
167
|
-
});
|
|
168
|
-
(0, vitest_1.expect)(providers).toEqual([TestService]);
|
|
169
|
-
});
|
|
170
|
-
(0, vitest_1.it)('should return an array of singletons extracted', async () => {
|
|
171
|
-
const singeltons = await extractApplicationProviders({
|
|
172
|
-
imports: [animations_1.BrowserAnimationsModule],
|
|
173
|
-
});
|
|
174
|
-
(0, vitest_1.expect)(singeltons).toEqual((0, animations_1.provideAnimations)());
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|