@storybook/angular 9.1.0-alpha.5 → 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.
Files changed (266) hide show
  1. package/build-schema.json +199 -0
  2. package/builders.json +14 -0
  3. package/dist/builders/build-storybook/index.js +31 -80
  4. package/dist/builders/start-storybook/index.js +31 -101
  5. package/dist/chunk-CUDJAP6K.mjs +3 -0
  6. package/dist/chunk-KMSSK3DZ.mjs +6 -0
  7. package/dist/chunk-LXSTVAFF.mjs +40 -0
  8. package/dist/client/config.d.ts +20 -6
  9. package/dist/client/config.js +49 -20
  10. package/dist/client/config.mjs +10 -13
  11. package/dist/client/docs/config.d.ts +6 -3
  12. package/dist/client/docs/config.js +18 -14
  13. package/dist/client/docs/config.mjs +6 -10
  14. package/dist/client/index.d.ts +144 -6
  15. package/dist/client/index.js +47 -30
  16. package/dist/client/index.mjs +3 -9
  17. package/dist/client/preview-prod.d.ts +2 -1
  18. package/dist/client/preview-prod.js +5 -4
  19. package/dist/client/preview-prod.mjs +1 -0
  20. package/dist/index.d.ts +59 -2
  21. package/dist/index.js +47 -29
  22. package/dist/index.mjs +3 -13
  23. package/dist/preset.js +8 -38
  24. package/dist/server/framework-preset-angular-cli.js +20 -83
  25. package/dist/server/framework-preset-angular-ivy.js +6 -59
  26. package/dist/{client/types.d.ts → types-3b0b7107.d.ts} +9 -9
  27. package/package.json +59 -12
  28. package/start-schema.json +234 -0
  29. package/dist/builders/build-storybook/index.d.ts +0 -25
  30. package/dist/builders/build-storybook/index.mjs +0 -78
  31. package/dist/builders/build-storybook/index.spec.d.ts +0 -1
  32. package/dist/builders/build-storybook/index.spec.js +0 -222
  33. package/dist/builders/build-storybook/index.spec.mjs +0 -187
  34. package/dist/builders/build-storybook/schema.json +0 -199
  35. package/dist/builders/builders.json +0 -14
  36. package/dist/builders/start-storybook/index.d.ts +0 -21
  37. package/dist/builders/start-storybook/index.mjs +0 -99
  38. package/dist/builders/start-storybook/index.spec.d.ts +0 -1
  39. package/dist/builders/start-storybook/index.spec.js +0 -188
  40. package/dist/builders/start-storybook/index.spec.mjs +0 -186
  41. package/dist/builders/start-storybook/schema.json +0 -234
  42. package/dist/builders/utils/error-handler.d.ts +0 -2
  43. package/dist/builders/utils/error-handler.js +0 -38
  44. package/dist/builders/utils/error-handler.mjs +0 -33
  45. package/dist/builders/utils/run-compodoc.d.ts +0 -6
  46. package/dist/builders/utils/run-compodoc.js +0 -35
  47. package/dist/builders/utils/run-compodoc.mjs +0 -31
  48. package/dist/builders/utils/run-compodoc.spec.d.ts +0 -1
  49. package/dist/builders/utils/run-compodoc.spec.js +0 -76
  50. package/dist/builders/utils/run-compodoc.spec.mjs +0 -74
  51. package/dist/builders/utils/standalone-options.d.ts +0 -18
  52. package/dist/builders/utils/standalone-options.js +0 -2
  53. package/dist/builders/utils/standalone-options.mjs +0 -1
  54. package/dist/client/angular-beta/AbstractRenderer.d.ts +0 -75
  55. package/dist/client/angular-beta/AbstractRenderer.js +0 -201
  56. package/dist/client/angular-beta/AbstractRenderer.mjs +0 -164
  57. package/dist/client/angular-beta/CanvasRenderer.d.ts +0 -12
  58. package/dist/client/angular-beta/CanvasRenderer.js +0 -13
  59. package/dist/client/angular-beta/CanvasRenderer.mjs +0 -9
  60. package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +0 -24
  61. package/dist/client/angular-beta/ComputesTemplateFromComponent.js +0 -160
  62. package/dist/client/angular-beta/ComputesTemplateFromComponent.mjs +0 -154
  63. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +0 -1
  64. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +0 -730
  65. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.mjs +0 -728
  66. package/dist/client/angular-beta/DocsRenderer.d.ts +0 -13
  67. package/dist/client/angular-beta/DocsRenderer.js +0 -39
  68. package/dist/client/angular-beta/DocsRenderer.mjs +0 -35
  69. package/dist/client/angular-beta/RendererFactory.d.ts +0 -11
  70. package/dist/client/angular-beta/RendererFactory.js +0 -56
  71. package/dist/client/angular-beta/RendererFactory.mjs +0 -50
  72. package/dist/client/angular-beta/RendererFactory.test.d.ts +0 -1
  73. package/dist/client/angular-beta/RendererFactory.test.js +0 -235
  74. package/dist/client/angular-beta/RendererFactory.test.mjs +0 -233
  75. package/dist/client/angular-beta/StorybookModule.d.ts +0 -8
  76. package/dist/client/angular-beta/StorybookModule.js +0 -27
  77. package/dist/client/angular-beta/StorybookModule.mjs +0 -23
  78. package/dist/client/angular-beta/StorybookModule.test.d.ts +0 -1
  79. package/dist/client/angular-beta/StorybookModule.test.js +0 -321
  80. package/dist/client/angular-beta/StorybookModule.test.mjs +0 -319
  81. package/dist/client/angular-beta/StorybookProvider.d.ts +0 -5
  82. package/dist/client/angular-beta/StorybookProvider.js +0 -26
  83. package/dist/client/angular-beta/StorybookProvider.mjs +0 -22
  84. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +0 -13
  85. package/dist/client/angular-beta/StorybookWrapperComponent.js +0 -127
  86. package/dist/client/angular-beta/StorybookWrapperComponent.mjs +0 -123
  87. package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +0 -29
  88. package/dist/client/angular-beta/__testfixtures__/input.component.js +0 -76
  89. package/dist/client/angular-beta/__testfixtures__/input.component.mjs +0 -73
  90. package/dist/client/angular-beta/__testfixtures__/test.module.d.ts +0 -2
  91. package/dist/client/angular-beta/__testfixtures__/test.module.js +0 -20
  92. package/dist/client/angular-beta/__testfixtures__/test.module.mjs +0 -17
  93. package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +0 -12
  94. package/dist/client/angular-beta/utils/BootstrapQueue.js +0 -86
  95. package/dist/client/angular-beta/utils/BootstrapQueue.mjs +0 -49
  96. package/dist/client/angular-beta/utils/BootstrapQueue.test.d.ts +0 -1
  97. package/dist/client/angular-beta/utils/BootstrapQueue.test.js +0 -164
  98. package/dist/client/angular-beta/utils/BootstrapQueue.test.mjs +0 -162
  99. package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +0 -22
  100. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +0 -93
  101. package/dist/client/angular-beta/utils/NgComponentAnalyzer.mjs +0 -84
  102. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +0 -1
  103. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +0 -388
  104. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.mjs +0 -386
  105. package/dist/client/angular-beta/utils/NgModulesAnalyzer.d.ts +0 -6
  106. package/dist/client/angular-beta/utils/NgModulesAnalyzer.js +0 -41
  107. package/dist/client/angular-beta/utils/NgModulesAnalyzer.mjs +0 -37
  108. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +0 -1
  109. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +0 -24
  110. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.mjs +0 -22
  111. package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +0 -30
  112. package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -196
  113. package/dist/client/angular-beta/utils/PropertyExtractor.mjs +0 -158
  114. package/dist/client/angular-beta/utils/PropertyExtractor.test.d.ts +0 -1
  115. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +0 -177
  116. package/dist/client/angular-beta/utils/PropertyExtractor.test.mjs +0 -175
  117. package/dist/client/angular-beta/utils/StoryUID.d.ts +0 -22
  118. package/dist/client/angular-beta/utils/StoryUID.js +0 -43
  119. package/dist/client/angular-beta/utils/StoryUID.mjs +0 -38
  120. package/dist/client/argsToTemplate.d.ts +0 -56
  121. package/dist/client/argsToTemplate.js +0 -58
  122. package/dist/client/argsToTemplate.mjs +0 -55
  123. package/dist/client/argsToTemplate.test.d.ts +0 -1
  124. package/dist/client/argsToTemplate.test.js +0 -102
  125. package/dist/client/argsToTemplate.test.mjs +0 -100
  126. package/dist/client/compodoc-types.d.ts +0 -102
  127. package/dist/client/compodoc-types.js +0 -2
  128. package/dist/client/compodoc-types.mjs +0 -1
  129. package/dist/client/compodoc.d.ts +0 -12
  130. package/dist/client/compodoc.js +0 -261
  131. package/dist/client/compodoc.mjs +0 -248
  132. package/dist/client/compodoc.test.d.ts +0 -1
  133. package/dist/client/compodoc.test.js +0 -132
  134. package/dist/client/compodoc.test.mjs +0 -130
  135. package/dist/client/decorateStory.d.ts +0 -4
  136. package/dist/client/decorateStory.js +0 -48
  137. package/dist/client/decorateStory.mjs +0 -45
  138. package/dist/client/decorateStory.test.d.ts +0 -1
  139. package/dist/client/decorateStory.test.js +0 -306
  140. package/dist/client/decorateStory.test.mjs +0 -301
  141. package/dist/client/decorators.d.ts +0 -13
  142. package/dist/client/decorators.js +0 -69
  143. package/dist/client/decorators.mjs +0 -63
  144. package/dist/client/decorators.test.d.ts +0 -1
  145. package/dist/client/decorators.test.js +0 -159
  146. package/dist/client/decorators.test.mjs +0 -157
  147. package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +0 -110
  148. package/dist/client/docs/__testfixtures__/doc-button/input.js +0 -204
  149. package/dist/client/docs/__testfixtures__/doc-button/input.mjs +0 -201
  150. package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +0 -7
  151. package/dist/client/docs/angular-properties.test.d.ts +0 -1
  152. package/dist/client/docs/angular-properties.test.js +0 -36
  153. package/dist/client/docs/angular-properties.test.mjs +0 -34
  154. package/dist/client/docs/sourceDecorator.d.ts +0 -10
  155. package/dist/client/docs/sourceDecorator.js +0 -53
  156. package/dist/client/docs/sourceDecorator.mjs +0 -48
  157. package/dist/client/globals.d.ts +0 -1
  158. package/dist/client/globals.js +0 -33
  159. package/dist/client/globals.mjs +0 -31
  160. package/dist/client/portable-stories.d.ts +0 -23
  161. package/dist/client/portable-stories.js +0 -62
  162. package/dist/client/portable-stories.mjs +0 -26
  163. package/dist/client/public-types.d.ts +0 -54
  164. package/dist/client/public-types.js +0 -2
  165. package/dist/client/public-types.mjs +0 -1
  166. package/dist/client/render.d.ts +0 -7
  167. package/dist/client/render.js +0 -19
  168. package/dist/client/render.mjs +0 -14
  169. package/dist/client/types.js +0 -2
  170. package/dist/client/types.mjs +0 -1
  171. package/dist/node/index.d.ts +0 -2
  172. package/dist/node/index.js +0 -6
  173. package/dist/node/index.mjs +0 -3
  174. package/dist/preset.d.ts +0 -5
  175. package/dist/preset.mjs +0 -34
  176. package/dist/renderer.d.ts +0 -6
  177. package/dist/renderer.js +0 -15
  178. package/dist/renderer.mjs +0 -6
  179. package/dist/server/__mocks-ng-workspace__/empty-projects-entry/angular.json +0 -4
  180. package/dist/server/__mocks-ng-workspace__/minimal-config/angular.json +0 -18
  181. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.d.ts +0 -1
  182. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.js +0 -5
  183. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.mjs +0 -2
  184. package/dist/server/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +0 -9
  185. package/dist/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +0 -13
  186. package/dist/server/__mocks-ng-workspace__/some-config/angular.json +0 -19
  187. package/dist/server/__mocks-ng-workspace__/some-config/src/main.d.ts +0 -1
  188. package/dist/server/__mocks-ng-workspace__/some-config/src/main.js +0 -5
  189. package/dist/server/__mocks-ng-workspace__/some-config/src/main.mjs +0 -2
  190. package/dist/server/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +0 -9
  191. package/dist/server/__mocks-ng-workspace__/some-config/tsconfig.json +0 -13
  192. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +0 -64
  193. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +0 -1
  194. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +0 -5
  195. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.mjs +0 -2
  196. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +0 -9
  197. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +0 -13
  198. package/dist/server/__mocks-ng-workspace__/with-lib/angular.json +0 -28
  199. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +0 -1
  200. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +0 -5
  201. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.mjs +0 -2
  202. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +0 -20
  203. package/dist/server/__mocks-ng-workspace__/with-lib/tsconfig.json +0 -13
  204. package/dist/server/__mocks-ng-workspace__/with-nx/angular.json +0 -18
  205. package/dist/server/__mocks-ng-workspace__/with-nx/nx.json +0 -3
  206. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.d.ts +0 -1
  207. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.js +0 -5
  208. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.mjs +0 -2
  209. package/dist/server/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +0 -8
  210. package/dist/server/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -14
  211. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/nx.json +0 -3
  212. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +0 -1
  213. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.js +0 -5
  214. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.mjs +0 -2
  215. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +0 -8
  216. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -14
  217. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/workspace.json +0 -18
  218. package/dist/server/__mocks-ng-workspace__/with-options-styles/angular.json +0 -18
  219. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +0 -1
  220. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.js +0 -5
  221. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.mjs +0 -2
  222. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +0 -9
  223. package/dist/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -13
  224. package/dist/server/__mocks-ng-workspace__/without-architect-build/angular.json +0 -5
  225. package/dist/server/__mocks-ng-workspace__/without-architect-build-options/angular.json +0 -11
  226. package/dist/server/__mocks-ng-workspace__/without-compatible-projects/angular.json +0 -7
  227. package/dist/server/__mocks-ng-workspace__/without-projects-entry/angular.json +0 -3
  228. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +0 -1
  229. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +0 -5
  230. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.mjs +0 -2
  231. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +0 -20
  232. package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -13
  233. package/dist/server/__mocks-ng-workspace__/without-tsConfig/angular.json +0 -16
  234. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +0 -1
  235. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.js +0 -5
  236. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.mjs +0 -2
  237. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +0 -9
  238. package/dist/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -13
  239. package/dist/server/__tests__/angular.json +0 -96
  240. package/dist/server/angular-cli-webpack.d.ts +0 -1
  241. package/dist/server/angular-cli-webpack.js +0 -80
  242. package/dist/server/angular-cli-webpack.mjs +0 -80
  243. package/dist/server/framework-preset-angular-cli.d.ts +0 -3
  244. package/dist/server/framework-preset-angular-cli.mjs +0 -81
  245. package/dist/server/framework-preset-angular-ivy.d.ts +0 -10
  246. package/dist/server/framework-preset-angular-ivy.mjs +0 -56
  247. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +0 -12
  248. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +0 -55
  249. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.mjs +0 -52
  250. package/dist/server/preset-options.d.ts +0 -9
  251. package/dist/server/preset-options.js +0 -2
  252. package/dist/server/preset-options.mjs +0 -1
  253. package/dist/server/utils/filter-out-styling-rules.d.ts +0 -2
  254. package/dist/server/utils/filter-out-styling-rules.js +0 -17
  255. package/dist/server/utils/filter-out-styling-rules.mjs +0 -13
  256. package/dist/server/utils/module-is-available.d.ts +0 -1
  257. package/dist/server/utils/module-is-available.js +0 -13
  258. package/dist/server/utils/module-is-available.mjs +0 -9
  259. package/dist/test-setup.d.ts +0 -1
  260. package/dist/test-setup.js +0 -6
  261. package/dist/test-setup.mjs +0 -4
  262. package/dist/types.d.ts +0 -27
  263. package/dist/types.js +0 -2
  264. package/dist/types.mjs +0 -1
  265. package/scripts/postbuild.js +0 -17
  266. package/template/cli/.eslintrc.json +0 -5
@@ -1,386 +0,0 @@
1
- // @vitest-environment happy-dom
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- import { Component, ComponentFactoryResolver, Directive, EventEmitter, HostBinding, Injectable, Input, Output, Pipe, input, output, } from '@angular/core';
12
- import { TestBed } from '@angular/core/testing';
13
- import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
14
- import { describe, expect, it } from 'vitest';
15
- import { getComponentInputsOutputs, isComponent, isDeclarable, getComponentDecoratorMetadata, isStandaloneComponent, } from './NgComponentAnalyzer';
16
- describe('getComponentInputsOutputs', () => {
17
- it('should return empty if no I/O found', () => {
18
- let FooComponent = class FooComponent {
19
- };
20
- FooComponent = __decorate([
21
- Component({
22
- standalone: false,
23
- })
24
- ], FooComponent);
25
- expect(getComponentInputsOutputs(FooComponent)).toEqual({
26
- inputs: [],
27
- outputs: [],
28
- });
29
- class BarComponent {
30
- }
31
- expect(getComponentInputsOutputs(BarComponent)).toEqual({
32
- inputs: [],
33
- outputs: [],
34
- });
35
- });
36
- it('should return I/O', () => {
37
- let FooComponent = class FooComponent {
38
- constructor() {
39
- this.signalInput = input();
40
- this.signalInputAliased = input('signalInputAliased', {
41
- alias: 'signalInputAliasedAlias',
42
- });
43
- this.output = new EventEmitter();
44
- this.outputWithBindingPropertyName = new EventEmitter();
45
- this.signalOutput = output();
46
- }
47
- };
48
- __decorate([
49
- Input(),
50
- __metadata("design:type", String)
51
- ], FooComponent.prototype, "input", void 0);
52
- __decorate([
53
- Input('inputPropertyName'),
54
- __metadata("design:type", String)
55
- ], FooComponent.prototype, "inputWithBindingPropertyName", void 0);
56
- __decorate([
57
- Output(),
58
- __metadata("design:type", Object)
59
- ], FooComponent.prototype, "output", void 0);
60
- __decorate([
61
- Output('outputPropertyName'),
62
- __metadata("design:type", Object)
63
- ], FooComponent.prototype, "outputWithBindingPropertyName", void 0);
64
- FooComponent = __decorate([
65
- Component({
66
- template: '',
67
- inputs: ['inputInComponentMetadata'],
68
- outputs: ['outputInComponentMetadata'],
69
- standalone: false,
70
- })
71
- ], FooComponent);
72
- const fooComponentFactory = resolveComponentFactory(FooComponent);
73
- const { inputs, outputs } = getComponentInputsOutputs(FooComponent);
74
- expect({ inputs, outputs }).toEqual({
75
- inputs: [
76
- { propName: 'inputInComponentMetadata', templateName: 'inputInComponentMetadata' },
77
- { propName: 'input', templateName: 'input' },
78
- { propName: 'inputWithBindingPropertyName', templateName: 'inputPropertyName' },
79
- ],
80
- outputs: [
81
- { propName: 'outputInComponentMetadata', templateName: 'outputInComponentMetadata' },
82
- { propName: 'output', templateName: 'output' },
83
- { propName: 'outputWithBindingPropertyName', templateName: 'outputPropertyName' },
84
- ],
85
- });
86
- expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs.map(({ isSignal, ...rest }) => rest)));
87
- expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
88
- });
89
- it("should return I/O when some of component metadata has the same name as one of component's properties", () => {
90
- let FooComponent = class FooComponent {
91
- constructor() {
92
- this.output = new EventEmitter();
93
- this.outputWithBindingPropertyName = new EventEmitter();
94
- }
95
- };
96
- __decorate([
97
- Input(),
98
- __metadata("design:type", String)
99
- ], FooComponent.prototype, "input", void 0);
100
- __decorate([
101
- Input('inputPropertyName'),
102
- __metadata("design:type", String)
103
- ], FooComponent.prototype, "inputWithBindingPropertyName", void 0);
104
- __decorate([
105
- Output(),
106
- __metadata("design:type", Object)
107
- ], FooComponent.prototype, "output", void 0);
108
- __decorate([
109
- Output('outputPropertyName'),
110
- __metadata("design:type", Object)
111
- ], FooComponent.prototype, "outputWithBindingPropertyName", void 0);
112
- FooComponent = __decorate([
113
- Component({
114
- template: '',
115
- inputs: ['input', 'inputWithBindingPropertyName'],
116
- outputs: ['outputWithBindingPropertyName'],
117
- standalone: false,
118
- })
119
- ], FooComponent);
120
- const fooComponentFactory = resolveComponentFactory(FooComponent);
121
- const { inputs, outputs } = getComponentInputsOutputs(FooComponent);
122
- expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs.map(({ isSignal, ...rest }) => rest)));
123
- expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
124
- });
125
- it('should return I/O in the presence of multiple decorators', () => {
126
- let FooComponent = class FooComponent {
127
- };
128
- __decorate([
129
- Input(),
130
- HostBinding('class.preceeding-first'),
131
- __metadata("design:type", String)
132
- ], FooComponent.prototype, "inputPreceedingHostBinding", void 0);
133
- __decorate([
134
- HostBinding('class.following-binding'),
135
- Input(),
136
- __metadata("design:type", String)
137
- ], FooComponent.prototype, "inputFollowingHostBinding", void 0);
138
- FooComponent = __decorate([
139
- Component({
140
- template: '',
141
- standalone: false,
142
- })
143
- ], FooComponent);
144
- const fooComponentFactory = resolveComponentFactory(FooComponent);
145
- const { inputs, outputs } = getComponentInputsOutputs(FooComponent);
146
- expect({ inputs, outputs }).toEqual({
147
- inputs: [
148
- { propName: 'inputPreceedingHostBinding', templateName: 'inputPreceedingHostBinding' },
149
- { propName: 'inputFollowingHostBinding', templateName: 'inputFollowingHostBinding' },
150
- ],
151
- outputs: [],
152
- });
153
- expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs.map(({ isSignal, ...rest }) => rest)));
154
- expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
155
- });
156
- it('should return I/O with extending classes', () => {
157
- let BarComponent = class BarComponent {
158
- };
159
- __decorate([
160
- Input(),
161
- __metadata("design:type", String)
162
- ], BarComponent.prototype, "a", void 0);
163
- __decorate([
164
- Input(),
165
- __metadata("design:type", String)
166
- ], BarComponent.prototype, "b", void 0);
167
- BarComponent = __decorate([
168
- Component({
169
- template: '',
170
- standalone: false,
171
- })
172
- ], BarComponent);
173
- let FooComponent = class FooComponent extends BarComponent {
174
- };
175
- __decorate([
176
- Input(),
177
- __metadata("design:type", String)
178
- ], FooComponent.prototype, "b", void 0);
179
- __decorate([
180
- Input(),
181
- __metadata("design:type", String)
182
- ], FooComponent.prototype, "c", void 0);
183
- FooComponent = __decorate([
184
- Component({
185
- template: '',
186
- standalone: false,
187
- })
188
- ], FooComponent);
189
- const fooComponentFactory = resolveComponentFactory(FooComponent);
190
- const { inputs, outputs } = getComponentInputsOutputs(FooComponent);
191
- expect({ inputs, outputs }).toEqual({
192
- inputs: [
193
- { propName: 'a', templateName: 'a' },
194
- { propName: 'b', templateName: 'b' },
195
- { propName: 'c', templateName: 'c' },
196
- ],
197
- outputs: [],
198
- });
199
- expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs.map(({ isSignal, ...rest }) => rest)));
200
- expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
201
- });
202
- });
203
- describe('isDeclarable', () => {
204
- it('should return true with a Component', () => {
205
- let FooComponent = class FooComponent {
206
- };
207
- FooComponent = __decorate([
208
- Component({})
209
- ], FooComponent);
210
- expect(isDeclarable(FooComponent)).toEqual(true);
211
- });
212
- it('should return true with a Directive', () => {
213
- let FooDirective = class FooDirective {
214
- };
215
- FooDirective = __decorate([
216
- Directive({})
217
- ], FooDirective);
218
- expect(isDeclarable(FooDirective)).toEqual(true);
219
- });
220
- it('should return true with a Pipe', () => {
221
- let FooPipe = class FooPipe {
222
- };
223
- FooPipe = __decorate([
224
- Pipe({ name: 'pipe' })
225
- ], FooPipe);
226
- expect(isDeclarable(FooPipe)).toEqual(true);
227
- });
228
- it('should return false with simple class', () => {
229
- class FooPipe {
230
- }
231
- expect(isDeclarable(FooPipe)).toEqual(false);
232
- });
233
- it('should return false with Injectable', () => {
234
- let FooInjectable = class FooInjectable {
235
- };
236
- FooInjectable = __decorate([
237
- Injectable()
238
- ], FooInjectable);
239
- expect(isDeclarable(FooInjectable)).toEqual(false);
240
- });
241
- });
242
- describe('isComponent', () => {
243
- it('should return true with a Component', () => {
244
- let FooComponent = class FooComponent {
245
- };
246
- FooComponent = __decorate([
247
- Component({})
248
- ], FooComponent);
249
- expect(isComponent(FooComponent)).toEqual(true);
250
- });
251
- it('should return false with simple class', () => {
252
- class FooPipe {
253
- }
254
- expect(isComponent(FooPipe)).toEqual(false);
255
- });
256
- it('should return false with Directive', () => {
257
- let FooDirective = class FooDirective {
258
- };
259
- FooDirective = __decorate([
260
- Directive()
261
- ], FooDirective);
262
- expect(isComponent(FooDirective)).toEqual(false);
263
- });
264
- });
265
- describe('isStandaloneComponent', () => {
266
- it('should return true with a Component with "standalone: true"', () => {
267
- let FooComponent = class FooComponent {
268
- };
269
- FooComponent = __decorate([
270
- Component({ standalone: true })
271
- ], FooComponent);
272
- expect(isStandaloneComponent(FooComponent)).toEqual(true);
273
- });
274
- it('should return false with a Component with "standalone: false"', () => {
275
- let FooComponent = class FooComponent {
276
- };
277
- FooComponent = __decorate([
278
- Component({ standalone: false })
279
- ], FooComponent);
280
- expect(isStandaloneComponent(FooComponent)).toEqual(false);
281
- });
282
- it('should return false with a Component without the "standalone" property', () => {
283
- let FooComponent = class FooComponent {
284
- };
285
- FooComponent = __decorate([
286
- Component({})
287
- ], FooComponent);
288
- expect(isStandaloneComponent(FooComponent)).toEqual(false);
289
- });
290
- it('should return false with simple class', () => {
291
- class FooPipe {
292
- }
293
- expect(isStandaloneComponent(FooPipe)).toEqual(false);
294
- });
295
- it('should return true with a Directive with "standalone: true"', () => {
296
- let FooDirective = class FooDirective {
297
- };
298
- FooDirective = __decorate([
299
- Directive({ standalone: true })
300
- ], FooDirective);
301
- expect(isStandaloneComponent(FooDirective)).toEqual(true);
302
- });
303
- it('should return false with a Directive with "standalone: false"', () => {
304
- let FooDirective = class FooDirective {
305
- };
306
- FooDirective = __decorate([
307
- Directive({ standalone: false })
308
- ], FooDirective);
309
- expect(isStandaloneComponent(FooDirective)).toEqual(false);
310
- });
311
- it('should return false with Directive without the "standalone" property', () => {
312
- let FooDirective = class FooDirective {
313
- };
314
- FooDirective = __decorate([
315
- Directive()
316
- ], FooDirective);
317
- expect(isStandaloneComponent(FooDirective)).toEqual(false);
318
- });
319
- it('should return true with a Pipe with "standalone: true"', () => {
320
- let FooPipe = class FooPipe {
321
- };
322
- FooPipe = __decorate([
323
- Pipe({ name: 'FooPipe', standalone: true })
324
- ], FooPipe);
325
- expect(isStandaloneComponent(FooPipe)).toEqual(true);
326
- });
327
- it('should return false with a Pipe with "standalone: false"', () => {
328
- let FooPipe = class FooPipe {
329
- };
330
- FooPipe = __decorate([
331
- Pipe({ name: 'FooPipe', standalone: false })
332
- ], FooPipe);
333
- expect(isStandaloneComponent(FooPipe)).toEqual(false);
334
- });
335
- it('should return false with Pipe without the "standalone" property', () => {
336
- let FooPipe = class FooPipe {
337
- };
338
- FooPipe = __decorate([
339
- Pipe({
340
- name: 'fooPipe',
341
- })
342
- ], FooPipe);
343
- expect(isStandaloneComponent(FooPipe)).toEqual(false);
344
- });
345
- });
346
- describe('getComponentDecoratorMetadata', () => {
347
- it('should return Component with a Component', () => {
348
- let FooComponent = class FooComponent {
349
- };
350
- FooComponent = __decorate([
351
- Component({ selector: 'foo' })
352
- ], FooComponent);
353
- expect(getComponentDecoratorMetadata(FooComponent)).toBeInstanceOf(Component);
354
- expect(getComponentDecoratorMetadata(FooComponent)).toEqual({
355
- changeDetection: 1,
356
- selector: 'foo',
357
- });
358
- });
359
- it('should return Component with extending classes', () => {
360
- let BarComponent = class BarComponent {
361
- };
362
- BarComponent = __decorate([
363
- Component({ selector: 'bar' })
364
- ], BarComponent);
365
- let FooComponent = class FooComponent extends BarComponent {
366
- };
367
- FooComponent = __decorate([
368
- Component({ selector: 'foo' })
369
- ], FooComponent);
370
- expect(getComponentDecoratorMetadata(FooComponent)).toBeInstanceOf(Component);
371
- expect(getComponentDecoratorMetadata(FooComponent)).toEqual({
372
- changeDetection: 1,
373
- selector: 'foo',
374
- });
375
- });
376
- });
377
- function sortByPropName(array) {
378
- return array.sort((a, b) => a.propName.localeCompare(b.propName));
379
- }
380
- function resolveComponentFactory(component) {
381
- TestBed.configureTestingModule({
382
- declarations: [component],
383
- }).overrideModule(BrowserDynamicTestingModule, {});
384
- const componentFactoryResolver = TestBed.inject(ComponentFactoryResolver);
385
- return componentFactoryResolver.resolveComponentFactory(component);
386
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Avoid component redeclaration
3
- *
4
- * Checks recursively if the component has already been declared in all import Module
5
- */
6
- export declare const isComponentAlreadyDeclared: (componentToFind: any, moduleDeclarations: any[], moduleImports: any[]) => boolean;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isComponentAlreadyDeclared = void 0;
4
- const core_1 = require("@angular/core");
5
- const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
6
- /**
7
- * Avoid component redeclaration
8
- *
9
- * Checks recursively if the component has already been declared in all import Module
10
- */
11
- const isComponentAlreadyDeclared = (componentToFind, moduleDeclarations, moduleImports) => {
12
- if (moduleDeclarations &&
13
- moduleDeclarations.flat().some((declaration) => declaration === componentToFind)) {
14
- // Found component in declarations array
15
- return true;
16
- }
17
- if (!moduleImports) {
18
- return false;
19
- }
20
- return moduleImports.flat().some((importItem) => {
21
- const extractedNgModuleMetadata = extractNgModuleMetadata(importItem);
22
- if (!extractedNgModuleMetadata) {
23
- // Not an NgModule
24
- return false;
25
- }
26
- return (0, exports.isComponentAlreadyDeclared)(componentToFind, extractedNgModuleMetadata.declarations, extractedNgModuleMetadata.imports);
27
- });
28
- };
29
- exports.isComponentAlreadyDeclared = isComponentAlreadyDeclared;
30
- const extractNgModuleMetadata = (importItem) => {
31
- const target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
32
- const decorators = reflectionCapabilities.annotations(target);
33
- if (!decorators || decorators.length === 0) {
34
- return null;
35
- }
36
- const ngModuleDecorator = decorators.find((decorator) => decorator instanceof core_1.NgModule);
37
- if (!ngModuleDecorator) {
38
- return null;
39
- }
40
- return ngModuleDecorator;
41
- };
@@ -1,37 +0,0 @@
1
- import { NgModule, ɵReflectionCapabilities as ReflectionCapabilities } from '@angular/core';
2
- const reflectionCapabilities = new ReflectionCapabilities();
3
- /**
4
- * Avoid component redeclaration
5
- *
6
- * Checks recursively if the component has already been declared in all import Module
7
- */
8
- export const isComponentAlreadyDeclared = (componentToFind, moduleDeclarations, moduleImports) => {
9
- if (moduleDeclarations &&
10
- moduleDeclarations.flat().some((declaration) => declaration === componentToFind)) {
11
- // Found component in declarations array
12
- return true;
13
- }
14
- if (!moduleImports) {
15
- return false;
16
- }
17
- return moduleImports.flat().some((importItem) => {
18
- const extractedNgModuleMetadata = extractNgModuleMetadata(importItem);
19
- if (!extractedNgModuleMetadata) {
20
- // Not an NgModule
21
- return false;
22
- }
23
- return isComponentAlreadyDeclared(componentToFind, extractedNgModuleMetadata.declarations, extractedNgModuleMetadata.imports);
24
- });
25
- };
26
- const extractNgModuleMetadata = (importItem) => {
27
- const target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
28
- const decorators = reflectionCapabilities.annotations(target);
29
- if (!decorators || decorators.length === 0) {
30
- return null;
31
- }
32
- const ngModuleDecorator = decorators.find((decorator) => decorator instanceof NgModule);
33
- if (!ngModuleDecorator) {
34
- return null;
35
- }
36
- return ngModuleDecorator;
37
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@angular/core");
4
- const vitest_1 = require("vitest");
5
- const NgModulesAnalyzer_1 = require("./NgModulesAnalyzer");
6
- const FooComponent = (0, core_1.Component)({})(class {
7
- });
8
- const BarComponent = (0, core_1.Component)({})(class {
9
- });
10
- const BetaModule = (0, core_1.NgModule)({ declarations: [FooComponent] })(class {
11
- });
12
- const AlphaModule = (0, core_1.NgModule)({ imports: [BetaModule] })(class {
13
- });
14
- (0, vitest_1.describe)('isComponentAlreadyDeclaredInModules', () => {
15
- (0, vitest_1.it)('should return true when the component is already declared in one of modules', () => {
16
- (0, vitest_1.expect)((0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(FooComponent, [], [AlphaModule])).toEqual(true);
17
- });
18
- (0, vitest_1.it)('should return true if the component is in moduleDeclarations', () => {
19
- (0, vitest_1.expect)((0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(BarComponent, [BarComponent], [AlphaModule])).toEqual(true);
20
- });
21
- (0, vitest_1.it)('should return false if the component is not declared', () => {
22
- (0, vitest_1.expect)((0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(BarComponent, [], [AlphaModule])).toEqual(false);
23
- });
24
- });
@@ -1,22 +0,0 @@
1
- import { Component, NgModule } from '@angular/core';
2
- import { describe, expect, it } from 'vitest';
3
- import { isComponentAlreadyDeclared } from './NgModulesAnalyzer';
4
- const FooComponent = Component({})(class {
5
- });
6
- const BarComponent = Component({})(class {
7
- });
8
- const BetaModule = NgModule({ declarations: [FooComponent] })(class {
9
- });
10
- const AlphaModule = NgModule({ imports: [BetaModule] })(class {
11
- });
12
- describe('isComponentAlreadyDeclaredInModules', () => {
13
- it('should return true when the component is already declared in one of modules', () => {
14
- expect(isComponentAlreadyDeclared(FooComponent, [], [AlphaModule])).toEqual(true);
15
- });
16
- it('should return true if the component is in moduleDeclarations', () => {
17
- expect(isComponentAlreadyDeclared(BarComponent, [BarComponent], [AlphaModule])).toEqual(true);
18
- });
19
- it('should return false if the component is not declared', () => {
20
- expect(isComponentAlreadyDeclared(BarComponent, [], [AlphaModule])).toEqual(false);
21
- });
22
- });
@@ -1,30 +0,0 @@
1
- import { InjectionToken, NgModule, Provider, ɵReflectionCapabilities as ReflectionCapabilities, importProvidersFrom } from '@angular/core';
2
- import { NgModuleMetadata } from '../../types';
3
- export declare const reflectionCapabilities: ReflectionCapabilities;
4
- export declare const REMOVED_MODULES: InjectionToken<unknown>;
5
- export declare const uniqueArray: (arr: any[]) => any[];
6
- export declare class PropertyExtractor implements NgModuleMetadata {
7
- private metadata;
8
- private component?;
9
- declarations?: any[];
10
- imports?: any[];
11
- providers?: Provider[];
12
- applicationProviders?: Array<Provider | ReturnType<typeof importProvidersFrom>>;
13
- constructor(metadata: NgModuleMetadata, component?: any | undefined);
14
- static warnImportsModuleWithProviders(propertyExtractor: PropertyExtractor): void;
15
- init(): Promise<void>;
16
- /**
17
- * Analyze NgModule Metadata
18
- *
19
- * - Removes Restricted Imports
20
- * - Extracts providers from ModuleWithProviders
21
- * - Returns a new NgModuleMetadata object
22
- */
23
- private analyzeMetadata;
24
- static analyzeRestricted: (ngModule: NgModule) => Promise<[boolean] | [boolean, Provider]>;
25
- static analyzeDecorators: (component: any) => {
26
- isDeclarable: boolean;
27
- isStandalone: any;
28
- };
29
- static isDecoratorInstanceOf: (decorator: any, name: string) => boolean;
30
- }