@storybook/angular 0.0.0-pr-23609-sha-f47ef339

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 (280) hide show
  1. package/.eslintrc.js +8 -0
  2. package/README.md +322 -0
  3. package/dist/builders/build-storybook/index.js +72 -0
  4. package/dist/builders/build-storybook/index.spec.d.ts +1 -0
  5. package/dist/builders/build-storybook/index.spec.js +216 -0
  6. package/dist/builders/build-storybook/schema.json +167 -0
  7. package/dist/builders/builders.json +14 -0
  8. package/dist/builders/start-storybook/index.js +93 -0
  9. package/dist/builders/start-storybook/index.spec.d.ts +1 -0
  10. package/dist/builders/start-storybook/index.spec.js +215 -0
  11. package/dist/builders/start-storybook/schema.json +198 -0
  12. package/dist/builders/utils/error-handler.d.ts +2 -0
  13. package/dist/builders/utils/error-handler.js +38 -0
  14. package/dist/builders/utils/run-compodoc.d.ts +6 -0
  15. package/dist/builders/utils/run-compodoc.js +58 -0
  16. package/dist/builders/utils/run-compodoc.spec.d.ts +1 -0
  17. package/dist/builders/utils/run-compodoc.spec.js +86 -0
  18. package/dist/builders/utils/standalone-options.d.ts +15 -0
  19. package/dist/builders/utils/standalone-options.js +2 -0
  20. package/dist/client/angular-beta/AbstractRenderer.d.ts +53 -0
  21. package/dist/client/angular-beta/AbstractRenderer.js +180 -0
  22. package/dist/client/angular-beta/CanvasRenderer.d.ts +13 -0
  23. package/dist/client/angular-beta/CanvasRenderer.js +16 -0
  24. package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +17 -0
  25. package/dist/client/angular-beta/ComputesTemplateFromComponent.js +132 -0
  26. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +1 -0
  27. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +403 -0
  28. package/dist/client/angular-beta/DocsRenderer.d.ts +13 -0
  29. package/dist/client/angular-beta/DocsRenderer.js +40 -0
  30. package/dist/client/angular-beta/RendererFactory.d.ts +11 -0
  31. package/dist/client/angular-beta/RendererFactory.js +56 -0
  32. package/dist/client/angular-beta/RendererFactory.test.d.ts +1 -0
  33. package/dist/client/angular-beta/RendererFactory.test.js +164 -0
  34. package/dist/client/angular-beta/StorybookModule.d.ts +8 -0
  35. package/dist/client/angular-beta/StorybookModule.js +29 -0
  36. package/dist/client/angular-beta/StorybookModule.test.d.ts +1 -0
  37. package/dist/client/angular-beta/StorybookModule.test.js +311 -0
  38. package/dist/client/angular-beta/StorybookProvider.d.ts +5 -0
  39. package/dist/client/angular-beta/StorybookProvider.js +26 -0
  40. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +16 -0
  41. package/dist/client/angular-beta/StorybookWrapperComponent.js +140 -0
  42. package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +26 -0
  43. package/dist/client/angular-beta/__testfixtures__/input.component.js +67 -0
  44. package/dist/client/angular-beta/__testfixtures__/test.module.d.ts +2 -0
  45. package/dist/client/angular-beta/__testfixtures__/test.module.js +20 -0
  46. package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +29 -0
  47. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +100 -0
  48. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +1 -0
  49. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +374 -0
  50. package/dist/client/angular-beta/utils/NgModulesAnalyzer.d.ts +6 -0
  51. package/dist/client/angular-beta/utils/NgModulesAnalyzer.js +41 -0
  52. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +1 -0
  53. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +23 -0
  54. package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +32 -0
  55. package/dist/client/angular-beta/utils/PropertyExtractor.js +162 -0
  56. package/dist/client/angular-beta/utils/PropertyExtractor.test.d.ts +1 -0
  57. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +142 -0
  58. package/dist/client/config.d.ts +6 -0
  59. package/dist/client/config.js +10 -0
  60. package/dist/client/decorateStory.d.ts +4 -0
  61. package/dist/client/decorateStory.js +49 -0
  62. package/dist/client/decorateStory.test.d.ts +1 -0
  63. package/dist/client/decorateStory.test.js +304 -0
  64. package/dist/client/decorators.d.ts +14 -0
  65. package/dist/client/decorators.js +70 -0
  66. package/dist/client/decorators.test.d.ts +1 -0
  67. package/dist/client/decorators.test.js +146 -0
  68. package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +111 -0
  69. package/dist/client/docs/__testfixtures__/doc-button/input.js +207 -0
  70. package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +7 -0
  71. package/dist/client/docs/angular-properties.test.d.ts +1 -0
  72. package/dist/client/docs/angular-properties.test.js +62 -0
  73. package/dist/client/docs/compodoc.d.ts +12 -0
  74. package/dist/client/docs/compodoc.js +258 -0
  75. package/dist/client/docs/compodoc.test.d.ts +1 -0
  76. package/dist/client/docs/compodoc.test.js +131 -0
  77. package/dist/client/docs/config.d.ts +4 -0
  78. package/dist/client/docs/config.js +19 -0
  79. package/dist/client/docs/index.d.ts +1 -0
  80. package/dist/client/docs/index.js +17 -0
  81. package/dist/client/docs/sourceDecorator.d.ts +9 -0
  82. package/dist/client/docs/sourceDecorator.js +51 -0
  83. package/dist/client/docs/types.d.ts +102 -0
  84. package/dist/client/docs/types.js +2 -0
  85. package/dist/client/globals.d.ts +23 -0
  86. package/dist/client/globals.js +40 -0
  87. package/dist/client/index.d.ts +5 -0
  88. package/dist/client/index.js +30 -0
  89. package/dist/client/preview-prod.d.ts +1 -0
  90. package/dist/client/preview-prod.js +4 -0
  91. package/dist/client/public-api.d.ts +15 -0
  92. package/dist/client/public-api.js +36 -0
  93. package/dist/client/public-types.d.ts +37 -0
  94. package/dist/client/public-types.js +2 -0
  95. package/dist/client/render.d.ts +7 -0
  96. package/dist/client/render.js +19 -0
  97. package/dist/client/types.d.ts +46 -0
  98. package/dist/client/types.js +2 -0
  99. package/dist/index.d.ts +2 -0
  100. package/dist/index.js +29 -0
  101. package/dist/index.mjs +13 -0
  102. package/dist/preset.d.ts +6 -0
  103. package/dist/preset.js +36 -0
  104. package/dist/preset.mjs +30 -0
  105. package/dist/renderer.d.ts +6 -0
  106. package/dist/renderer.js +15 -0
  107. package/dist/renderer.mjs +6 -0
  108. package/dist/server/__mocks-ng-workspace__/empty-projects-entry/angular.json +4 -0
  109. package/dist/server/__mocks-ng-workspace__/minimal-config/angular.json +18 -0
  110. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.d.ts +1 -0
  111. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.js +5 -0
  112. package/dist/server/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +9 -0
  113. package/dist/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +13 -0
  114. package/dist/server/__mocks-ng-workspace__/some-config/angular.json +19 -0
  115. package/dist/server/__mocks-ng-workspace__/some-config/src/main.d.ts +1 -0
  116. package/dist/server/__mocks-ng-workspace__/some-config/src/main.js +5 -0
  117. package/dist/server/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +9 -0
  118. package/dist/server/__mocks-ng-workspace__/some-config/tsconfig.json +13 -0
  119. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +64 -0
  120. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +1 -0
  121. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +5 -0
  122. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +9 -0
  123. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +13 -0
  124. package/dist/server/__mocks-ng-workspace__/with-lib/angular.json +28 -0
  125. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +1 -0
  126. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +5 -0
  127. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +20 -0
  128. package/dist/server/__mocks-ng-workspace__/with-lib/tsconfig.json +13 -0
  129. package/dist/server/__mocks-ng-workspace__/with-nx/angular.json +18 -0
  130. package/dist/server/__mocks-ng-workspace__/with-nx/nx.json +3 -0
  131. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.d.ts +1 -0
  132. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.js +5 -0
  133. package/dist/server/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +8 -0
  134. package/dist/server/__mocks-ng-workspace__/with-nx/tsconfig.json +14 -0
  135. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/nx.json +3 -0
  136. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +1 -0
  137. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.js +5 -0
  138. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +8 -0
  139. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +14 -0
  140. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/workspace.json +18 -0
  141. package/dist/server/__mocks-ng-workspace__/with-options-styles/angular.json +18 -0
  142. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +1 -0
  143. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.js +5 -0
  144. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +9 -0
  145. package/dist/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +13 -0
  146. package/dist/server/__mocks-ng-workspace__/without-architect-build/angular.json +5 -0
  147. package/dist/server/__mocks-ng-workspace__/without-architect-build-options/angular.json +11 -0
  148. package/dist/server/__mocks-ng-workspace__/without-compatible-projects/angular.json +7 -0
  149. package/dist/server/__mocks-ng-workspace__/without-projects-entry/angular.json +3 -0
  150. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +1 -0
  151. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +5 -0
  152. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +20 -0
  153. package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +13 -0
  154. package/dist/server/__mocks-ng-workspace__/without-tsConfig/angular.json +16 -0
  155. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +1 -0
  156. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.js +5 -0
  157. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +9 -0
  158. package/dist/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +13 -0
  159. package/dist/server/__tests__/angular.json +96 -0
  160. package/dist/server/angular-cli-webpack.d.ts +1 -0
  161. package/dist/server/angular-cli-webpack.js +99 -0
  162. package/dist/server/framework-preset-angular-cli.d.ts +4 -0
  163. package/dist/server/framework-preset-angular-cli.js +85 -0
  164. package/dist/server/framework-preset-angular-docs.d.ts +2 -0
  165. package/dist/server/framework-preset-angular-docs.js +10 -0
  166. package/dist/server/framework-preset-angular-ivy.d.ts +10 -0
  167. package/dist/server/framework-preset-angular-ivy.js +103 -0
  168. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +25 -0
  169. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +48 -0
  170. package/dist/server/preset-options.d.ts +13 -0
  171. package/dist/server/preset-options.js +2 -0
  172. package/dist/server/utils/filter-out-styling-rules.d.ts +2 -0
  173. package/dist/server/utils/filter-out-styling-rules.js +17 -0
  174. package/dist/server/utils/module-is-available.d.ts +1 -0
  175. package/dist/server/utils/module-is-available.js +13 -0
  176. package/dist/types.d.ts +29 -0
  177. package/dist/types.js +2 -0
  178. package/dist/types.mjs +1 -0
  179. package/jest.config.js +31 -0
  180. package/package.json +126 -0
  181. package/preset.js +1 -0
  182. package/renderer.d.ts +1 -0
  183. package/renderer.js +1 -0
  184. package/src/server/angular-cli-webpack.d.ts +7 -0
  185. package/src/server/angular-cli-webpack.js +127 -0
  186. package/src/server/plugins/storybook-normalize-angular-entry-plugin.js +54 -0
  187. package/src/typings.d.ts +21 -0
  188. package/template/cli/.eslintrc.json +5 -0
  189. package/template/cli/Button.stories.ts +51 -0
  190. package/template/cli/Header.stories.ts +37 -0
  191. package/template/cli/Page.stories.ts +46 -0
  192. package/template/cli/User.ts +2 -0
  193. package/template/cli/button.component.ts +55 -0
  194. package/template/cli/header.component.ts +75 -0
  195. package/template/cli/page.component.ts +77 -0
  196. package/template/components/button.component.ts +54 -0
  197. package/template/components/button.css +30 -0
  198. package/template/components/form.component.ts +37 -0
  199. package/template/components/html.component.ts +22 -0
  200. package/template/components/index.js +8 -0
  201. package/template/components/pre.component.ts +29 -0
  202. package/template/stories/angular-mdx.stories.mdx +25 -0
  203. package/template/stories/argTypes/doc-button/doc-button.component.html +7 -0
  204. package/template/stories/argTypes/doc-button/doc-button.component.scss +3 -0
  205. package/template/stories/argTypes/doc-button/doc-button.component.ts +232 -0
  206. package/template/stories/argTypes/doc-button/doc-button.stories.ts +24 -0
  207. package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +24 -0
  208. package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +14 -0
  209. package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +27 -0
  210. package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +17 -0
  211. package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +18 -0
  212. package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +17 -0
  213. package/template/stories/basics/README.stories.mdx +7 -0
  214. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +27 -0
  215. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +57 -0
  216. package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +19 -0
  217. package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +8 -0
  218. package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +8 -0
  219. package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +19 -0
  220. package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +8 -0
  221. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +8 -0
  222. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +37 -0
  223. package/template/stories/basics/component-with-enums/enums.component.html +8 -0
  224. package/template/stories/basics/component-with-enums/enums.component.stories.ts +24 -0
  225. package/template/stories/basics/component-with-enums/enums.component.ts +53 -0
  226. package/template/stories/basics/component-with-inheritance/base-button.component.ts +10 -0
  227. package/template/stories/basics/component-with-inheritance/base-button.stories.ts +12 -0
  228. package/template/stories/basics/component-with-inheritance/icon-button.component.ts +11 -0
  229. package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +13 -0
  230. package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +58 -0
  231. package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +29 -0
  232. package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +40 -0
  233. package/template/stories/basics/component-with-on-push/on-push-box.component.ts +21 -0
  234. package/template/stories/basics/component-with-on-push/on-push.stories.ts +21 -0
  235. package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +31 -0
  236. package/template/stories/basics/component-with-pipe/custom.pipe.ts +10 -0
  237. package/template/stories/basics/component-with-pipe/with-pipe.component.ts +10 -0
  238. package/template/stories/basics/component-with-provider/di.component.html +7 -0
  239. package/template/stories/basics/component-with-provider/di.component.stories.ts +26 -0
  240. package/template/stories/basics/component-with-provider/di.component.ts +28 -0
  241. package/template/stories/basics/component-with-style/styled.component.css +3 -0
  242. package/template/stories/basics/component-with-style/styled.component.html +5 -0
  243. package/template/stories/basics/component-with-style/styled.component.scss +5 -0
  244. package/template/stories/basics/component-with-style/styled.component.stories.ts +10 -0
  245. package/template/stories/basics/component-with-style/styled.component.ts +8 -0
  246. package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +73 -0
  247. package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +71 -0
  248. package/template/stories/basics/component-without-selector/without-selector.component.ts +30 -0
  249. package/template/stories/basics/component-without-selector/without-selector.stories.ts +30 -0
  250. package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +3 -0
  251. package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +29 -0
  252. package/template/stories/basics/ng-module/angular-src/chip.component.ts +60 -0
  253. package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +49 -0
  254. package/template/stories/basics/ng-module/angular-src/chips.module.ts +31 -0
  255. package/template/stories/basics/ng-module/import-module-chip.stories.ts +23 -0
  256. package/template/stories/basics/ng-module/import-module-for-root.stories.ts +50 -0
  257. package/template/stories/basics/ng-module/import-module.stories.ts +35 -0
  258. package/template/stories/button.component.ts +26 -0
  259. package/template/stories/core/README.stories.mdx +7 -0
  260. package/template/stories/core/applicationConfig/with-browser-animations.stories.ts +40 -0
  261. package/template/stories/core/applicationConfig/with-noop-browser-animations.stories.ts +35 -0
  262. package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +20 -0
  263. package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +99 -0
  264. package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +18 -0
  265. package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +20 -0
  266. package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +10 -0
  267. package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +14 -0
  268. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.css +13 -0
  269. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.html +7 -0
  270. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.ts +39 -0
  271. package/template/stories/core/moduleMetadata/angular-src/service.component.ts +24 -0
  272. package/template/stories/core/moduleMetadata/angular-src/token.component.ts +31 -0
  273. package/template/stories/core/moduleMetadata/in-export-default.stories.ts +38 -0
  274. package/template/stories/core/moduleMetadata/in-stories.stories.ts +46 -0
  275. package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +35 -0
  276. package/template/stories/core/parameters/bootstrap-options.stories.ts +18 -0
  277. package/template/stories/core/styles/story-styles.stories.ts +50 -0
  278. package/template/stories/others/app-initializer-use-factory/app-initializer-use-factory.stories.ts +34 -0
  279. package/template/stories/others/issues/12009-unknown-component.stories.ts +14 -0
  280. package/template/stories/others/ngx-translate/README.stories.mdx +65 -0
@@ -0,0 +1,198 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "title": "Start Storybook",
4
+ "description": "Serve up storybook in development mode.",
5
+ "type": "object",
6
+ "properties": {
7
+ "browserTarget": {
8
+ "type": "string",
9
+ "description": "Build target to be served in project-name:builder:config format. Should generally target on the builder: '@angular-devkit/build-angular:browser'. Useful for Storybook to use options (styles, assets, ...).",
10
+ "pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$",
11
+ "default": null
12
+ },
13
+ "tsConfig": {
14
+ "type": "string",
15
+ "description": "The full path for the TypeScript configuration file, relative to the current workspace."
16
+ },
17
+ "port": {
18
+ "type": "number",
19
+ "description": "Port to listen on.",
20
+ "default": 9009
21
+ },
22
+ "host": {
23
+ "type": "string",
24
+ "description": "Host to listen on.",
25
+ "default": "localhost"
26
+ },
27
+ "configDir": {
28
+ "type": "string",
29
+ "description": "Directory where to load Storybook configurations from.",
30
+ "default": ".storybook"
31
+ },
32
+ "https": {
33
+ "type": "boolean",
34
+ "description": "Serve Storybook over HTTPS. Note: You must provide your own certificate information.",
35
+ "default": false
36
+ },
37
+ "sslCa": {
38
+ "type": "string",
39
+ "description": "Provide an SSL certificate authority. (Optional with --https, required if using a self-signed certificate)."
40
+ },
41
+ "sslCert": {
42
+ "type": "string",
43
+ "description": "Provide an SSL certificate. (Required with --https)."
44
+ },
45
+ "sslKey": {
46
+ "type": "string",
47
+ "description": "SSL key to use for serving HTTPS."
48
+ },
49
+ "smokeTest": {
50
+ "type": "boolean",
51
+ "description": "Exit after successful start.",
52
+ "default": false
53
+ },
54
+ "ci": {
55
+ "type": "boolean",
56
+ "description": "CI mode (skip interactive prompts, don't open browser).",
57
+ "default": false
58
+ },
59
+ "open": {
60
+ "type": "boolean",
61
+ "description": "Whether to open Storybook automatically in the browser.",
62
+ "default": true
63
+ },
64
+ "quiet": {
65
+ "type": "boolean",
66
+ "description": "Suppress verbose build output.",
67
+ "default": false
68
+ },
69
+ "enableProdMode": {
70
+ "type": "boolean",
71
+ "description": "Disable Angular's development mode, which turns off assertions and other checks within the framework.",
72
+ "default": false
73
+ },
74
+ "docs": {
75
+ "type": "boolean",
76
+ "description": "Starts Storybook in documentation mode. Learn more about it : https://storybook.js.org/docs/react/writing-docs/build-documentation#preview-storybooks-documentation.",
77
+ "default": false
78
+ },
79
+ "compodoc": {
80
+ "type": "boolean",
81
+ "description": "Execute compodoc before.",
82
+ "default": true
83
+ },
84
+ "compodocArgs": {
85
+ "type": "array",
86
+ "description": "Compodoc options : https://compodoc.app/guides/options.html. Options `-p` with tsconfig path and `-d` with workspace root is always given.",
87
+ "default": ["-e", "json"],
88
+ "items": {
89
+ "type": "string"
90
+ }
91
+ },
92
+ "styles": {
93
+ "type": "array",
94
+ "description": "Global styles to be included in the build.",
95
+ "items": {
96
+ "$ref": "#/definitions/styleElement"
97
+ },
98
+ "default": ""
99
+ },
100
+ "stylePreprocessorOptions": {
101
+ "description": "Options to pass to style preprocessors.",
102
+ "type": "object",
103
+ "properties": {
104
+ "includePaths": {
105
+ "description": "Paths to include. Paths will be resolved to workspace root.",
106
+ "type": "array",
107
+ "items": {
108
+ "type": "string"
109
+ }
110
+ }
111
+ },
112
+ "additionalProperties": false,
113
+ "default": ""
114
+ },
115
+ "assets": {
116
+ "type": "array",
117
+ "description": "List of static application assets.",
118
+ "default": [],
119
+ "items": {
120
+ "$ref": "#/definitions/assetPattern"
121
+ }
122
+ },
123
+ "initialPath": {
124
+ "type": "string",
125
+ "description": "URL path to be appended when visiting Storybook for the first time"
126
+ }
127
+ },
128
+ "additionalProperties": false,
129
+ "definitions": {
130
+ "assetPattern": {
131
+ "oneOf": [
132
+ {
133
+ "type": "object",
134
+ "properties": {
135
+ "followSymlinks": {
136
+ "type": "boolean",
137
+ "default": false,
138
+ "description": "Allow glob patterns to follow symlink directories. This allows subdirectories of the symlink to be searched."
139
+ },
140
+ "glob": {
141
+ "type": "string",
142
+ "description": "The pattern to match."
143
+ },
144
+ "input": {
145
+ "type": "string",
146
+ "description": "The input directory path in which to apply 'glob'. Defaults to the project root."
147
+ },
148
+ "ignore": {
149
+ "description": "An array of globs to ignore.",
150
+ "type": "array",
151
+ "items": {
152
+ "type": "string"
153
+ }
154
+ },
155
+ "output": {
156
+ "type": "string",
157
+ "description": "Absolute path within the output."
158
+ }
159
+ },
160
+ "additionalProperties": false,
161
+ "required": ["glob", "input", "output"]
162
+ },
163
+ {
164
+ "type": "string"
165
+ }
166
+ ]
167
+ },
168
+ "styleElement": {
169
+ "oneOf": [
170
+ {
171
+ "type": "object",
172
+ "properties": {
173
+ "input": {
174
+ "type": "string",
175
+ "description": "The file to include."
176
+ },
177
+ "bundleName": {
178
+ "type": "string",
179
+ "pattern": "^[\\w\\-.]*$",
180
+ "description": "The bundle name for this extra entry point."
181
+ },
182
+ "inject": {
183
+ "type": "boolean",
184
+ "description": "If the bundle will be referenced in the HTML file.",
185
+ "default": true
186
+ }
187
+ },
188
+ "additionalProperties": false,
189
+ "required": ["input"]
190
+ },
191
+ {
192
+ "type": "string",
193
+ "description": "The file to include."
194
+ }
195
+ ]
196
+ }
197
+ }
198
+ }
@@ -0,0 +1,2 @@
1
+ export declare const printErrorDetails: (error: any) => void;
2
+ export declare const errorSummary: (error: any) => string;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.errorSummary = exports.printErrorDetails = void 0;
4
+ const node_logger_1 = require("@storybook/node-logger");
5
+ const ts_dedent_1 = require("ts-dedent");
6
+ const printErrorDetails = (error) => {
7
+ // Duplicate code for Standalone error handling
8
+ // Source: https://github.com/storybookjs/storybook/blob/39c7ba09ad84fbd466f9c25d5b92791a5450b9f6/lib/core-server/src/build-dev.ts#L136
9
+ node_logger_1.instance.heading = '';
10
+ if (error instanceof Error) {
11
+ if (error.error) {
12
+ node_logger_1.logger.error(error.error);
13
+ }
14
+ else if (error.stats && error.stats.compilation.errors) {
15
+ error.stats.compilation.errors.forEach((e) => node_logger_1.logger.plain(e));
16
+ }
17
+ else {
18
+ node_logger_1.logger.error(error);
19
+ }
20
+ }
21
+ else if (error.compilation?.errors) {
22
+ error.compilation.errors.forEach((e) => node_logger_1.logger.plain(e));
23
+ }
24
+ node_logger_1.logger.line();
25
+ };
26
+ exports.printErrorDetails = printErrorDetails;
27
+ const errorSummary = (error) => {
28
+ return error.close
29
+ ? (0, ts_dedent_1.dedent) `
30
+ FATAL broken build!, will close the process,
31
+ Fix the error below and restart storybook.
32
+ `
33
+ : (0, ts_dedent_1.dedent) `
34
+ Broken build, fix the error above.
35
+ You may need to refresh the browser.
36
+ `;
37
+ };
38
+ exports.errorSummary = errorSummary;
@@ -0,0 +1,6 @@
1
+ import { BuilderContext } from '@angular-devkit/architect';
2
+ import { Observable } from 'rxjs';
3
+ export declare const runCompodoc: ({ compodocArgs, tsconfig }: {
4
+ compodocArgs: string[];
5
+ tsconfig: string;
6
+ }, context: BuilderContext) => Observable<void>;
@@ -0,0 +1,58 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.runCompodoc = void 0;
27
+ const rxjs_1 = require("rxjs");
28
+ const path = __importStar(require("path"));
29
+ const cli_1 = require("@storybook/cli");
30
+ const hasTsConfigArg = (args) => args.indexOf('-p') !== -1;
31
+ const hasOutputArg = (args) => args.indexOf('-d') !== -1 || args.indexOf('--output') !== -1;
32
+ // path.relative is necessary to workaround a compodoc issue with
33
+ // absolute paths on windows machines
34
+ const toRelativePath = (pathToTsConfig) => {
35
+ return path.isAbsolute(pathToTsConfig) ? path.relative('.', pathToTsConfig) : pathToTsConfig;
36
+ };
37
+ const runCompodoc = ({ compodocArgs, tsconfig }, context) => {
38
+ return new rxjs_1.Observable((observer) => {
39
+ const tsConfigPath = toRelativePath(tsconfig);
40
+ const finalCompodocArgs = [
41
+ ...(hasTsConfigArg(compodocArgs) ? [] : ['-p', tsConfigPath]),
42
+ ...(hasOutputArg(compodocArgs) ? [] : ['-d', `${context.workspaceRoot || '.'}`]),
43
+ ...compodocArgs,
44
+ ];
45
+ const packageManager = cli_1.JsPackageManagerFactory.getPackageManager();
46
+ try {
47
+ const stdout = packageManager.runPackageCommandSync('compodoc', finalCompodocArgs, context.workspaceRoot, 'inherit');
48
+ context.logger.info(stdout);
49
+ observer.next();
50
+ observer.complete();
51
+ }
52
+ catch (e) {
53
+ context.logger.error(e);
54
+ observer.error();
55
+ }
56
+ });
57
+ };
58
+ exports.runCompodoc = runCompodoc;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const operators_1 = require("rxjs/operators");
4
+ const { runCompodoc } = require('./run-compodoc');
5
+ const mockRunScript = jest.fn();
6
+ jest.mock('@storybook/cli', () => ({
7
+ JsPackageManagerFactory: {
8
+ getPackageManager: () => ({
9
+ runPackageCommandSync: mockRunScript,
10
+ }),
11
+ },
12
+ }));
13
+ const builderContextLoggerMock = {
14
+ createChild: jest.fn(),
15
+ log: jest.fn(),
16
+ debug: jest.fn(),
17
+ info: jest.fn(),
18
+ warn: jest.fn(),
19
+ error: jest.fn(),
20
+ fatal: jest.fn(),
21
+ };
22
+ describe('runCompodoc', () => {
23
+ afterEach(() => {
24
+ mockRunScript.mockClear();
25
+ });
26
+ it('should run compodoc with tsconfig from context', async () => {
27
+ runCompodoc({
28
+ compodocArgs: [],
29
+ tsconfig: 'path/to/tsconfig.json',
30
+ }, {
31
+ workspaceRoot: 'path/to/project',
32
+ logger: builderContextLoggerMock,
33
+ })
34
+ .pipe((0, operators_1.take)(1))
35
+ .subscribe();
36
+ expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
37
+ });
38
+ it('should run compodoc with tsconfig from compodocArgs', async () => {
39
+ runCompodoc({
40
+ compodocArgs: ['-p', 'path/to/tsconfig.stories.json'],
41
+ tsconfig: 'path/to/tsconfig.json',
42
+ }, {
43
+ workspaceRoot: 'path/to/project',
44
+ logger: builderContextLoggerMock,
45
+ })
46
+ .pipe((0, operators_1.take)(1))
47
+ .subscribe();
48
+ expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-d', 'path/to/project', '-p', 'path/to/tsconfig.stories.json'], 'path/to/project', 'inherit');
49
+ });
50
+ it('should run compodoc with default output folder.', async () => {
51
+ runCompodoc({
52
+ compodocArgs: [],
53
+ tsconfig: 'path/to/tsconfig.json',
54
+ }, {
55
+ workspaceRoot: 'path/to/project',
56
+ logger: builderContextLoggerMock,
57
+ })
58
+ .pipe((0, operators_1.take)(1))
59
+ .subscribe();
60
+ expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], 'path/to/project', 'inherit');
61
+ });
62
+ it('should run with custom output folder specified with --output compodocArgs', async () => {
63
+ runCompodoc({
64
+ compodocArgs: ['--output', 'path/to/customFolder'],
65
+ tsconfig: 'path/to/tsconfig.json',
66
+ }, {
67
+ workspaceRoot: 'path/to/project',
68
+ logger: builderContextLoggerMock,
69
+ })
70
+ .pipe((0, operators_1.take)(1))
71
+ .subscribe();
72
+ expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '--output', 'path/to/customFolder'], 'path/to/project', 'inherit');
73
+ });
74
+ it('should run with custom output folder specified with -d compodocArgs', async () => {
75
+ runCompodoc({
76
+ compodocArgs: ['-d', 'path/to/customFolder'],
77
+ tsconfig: 'path/to/tsconfig.json',
78
+ }, {
79
+ workspaceRoot: 'path/to/project',
80
+ logger: builderContextLoggerMock,
81
+ })
82
+ .pipe((0, operators_1.take)(1))
83
+ .subscribe();
84
+ expect(mockRunScript).toHaveBeenCalledWith('compodoc', ['-p', 'path/to/tsconfig.json', '-d', 'path/to/customFolder'], 'path/to/project', 'inherit');
85
+ });
86
+ });
@@ -0,0 +1,15 @@
1
+ import { BuilderContext } from '@angular-devkit/architect';
2
+ import { AssetPattern, StyleElement, StylePreprocessorOptions } from '@angular-devkit/build-angular/src/builders/browser/schema';
3
+ import { LoadOptions, CLIOptions, BuilderOptions } from '@storybook/types';
4
+ export type StandaloneOptions = CLIOptions & LoadOptions & BuilderOptions & {
5
+ mode?: 'static' | 'dev';
6
+ enableProdMode: boolean;
7
+ angularBrowserTarget?: string | null;
8
+ angularBuilderOptions?: Record<string, any> & {
9
+ styles?: StyleElement[];
10
+ stylePreprocessorOptions?: StylePreprocessorOptions;
11
+ assets?: AssetPattern[];
12
+ };
13
+ angularBuilderContext?: BuilderContext | null;
14
+ tsConfig?: string;
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,53 @@
1
+ import { Subject } from 'rxjs';
2
+ import { ICollection, StoryFnAngularReturnType } from '../types';
3
+ type StoryRenderInfo = {
4
+ storyFnAngular: StoryFnAngularReturnType;
5
+ moduleMetadataSnapshot: string;
6
+ };
7
+ export declare abstract class AbstractRenderer {
8
+ /**
9
+ * Wait and destroy the platform
10
+ */
11
+ static resetApplications(domNode?: HTMLElement): void;
12
+ /**
13
+ * Reset compiled components because we often want to compile the same component with
14
+ * more than one NgModule.
15
+ */
16
+ protected static resetCompiledComponents: () => Promise<void>;
17
+ protected previousStoryRenderInfo: Map<HTMLElement, StoryRenderInfo>;
18
+ protected storyProps$: Subject<ICollection | undefined>;
19
+ constructor();
20
+ protected abstract beforeFullRender(domNode?: HTMLElement): Promise<void>;
21
+ protected abstract afterFullRender(): Promise<void>;
22
+ /**
23
+ * Bootstrap main angular module with main component or send only new `props` with storyProps$
24
+ *
25
+ * @param storyFnAngular {StoryFnAngularReturnType}
26
+ * @param forced {boolean} If :
27
+ * - true render will only use the StoryFn `props' in storyProps observable that will update sotry's component/template properties. Improves performance without reloading the whole module&component if props changes
28
+ * - false fully recharges or initializes angular module & component
29
+ * @param component {Component}
30
+ */
31
+ render({ storyFnAngular, forced, component, targetDOMNode, }: {
32
+ storyFnAngular: StoryFnAngularReturnType;
33
+ forced: boolean;
34
+ component?: any;
35
+ targetDOMNode: HTMLElement;
36
+ }): Promise<void>;
37
+ /**
38
+ * Only ASCII alphanumerics can be used as HTML tag name.
39
+ * https://html.spec.whatwg.org/#elements-2
40
+ *
41
+ * Therefore, stories break when non-ASCII alphanumerics are included in target selector.
42
+ * https://github.com/storybookjs/storybook/issues/15147
43
+ *
44
+ * This method returns storyId when it doesn't contain any non-ASCII alphanumerics.
45
+ * Otherwise, it generates a valid HTML tag name from storyId by removing non-ASCII alphanumerics from storyId, prefixing "sb-", and suffixing "-component"
46
+ * @protected
47
+ * @memberof AbstractRenderer
48
+ */
49
+ protected generateTargetSelectorFromStoryId(id: string): string;
50
+ protected initAngularRootElement(targetDOMNode: HTMLElement, targetSelector: string): void;
51
+ private fullRendererRequired;
52
+ }
53
+ export {};
@@ -0,0 +1,180 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.AbstractRenderer = void 0;
28
+ const core_1 = require("@angular/core");
29
+ const platform_browser_1 = require("@angular/platform-browser");
30
+ const rxjs_1 = require("rxjs");
31
+ const telejson_1 = require("telejson");
32
+ const StorybookModule_1 = require("./StorybookModule");
33
+ const StorybookProvider_1 = require("./StorybookProvider");
34
+ const StorybookWrapperComponent_1 = require("./StorybookWrapperComponent");
35
+ const PropertyExtractor_1 = require("./utils/PropertyExtractor");
36
+ const applicationRefs = new Map();
37
+ class AbstractRenderer {
38
+ /**
39
+ * Wait and destroy the platform
40
+ */
41
+ static resetApplications(domNode) {
42
+ StorybookWrapperComponent_1.componentNgModules.clear();
43
+ applicationRefs.forEach((appRef, appDOMNode) => {
44
+ if (!appRef.destroyed && (!domNode || appDOMNode === domNode)) {
45
+ appRef.destroy();
46
+ }
47
+ });
48
+ }
49
+ constructor() {
50
+ this.previousStoryRenderInfo = new Map();
51
+ if (typeof NODE_ENV === 'string' && NODE_ENV !== 'development') {
52
+ try {
53
+ // platform should be set after enableProdMode()
54
+ (0, core_1.enableProdMode)();
55
+ }
56
+ catch (e) {
57
+ // eslint-disable-next-line no-console
58
+ console.debug(e);
59
+ }
60
+ }
61
+ }
62
+ /**
63
+ * Bootstrap main angular module with main component or send only new `props` with storyProps$
64
+ *
65
+ * @param storyFnAngular {StoryFnAngularReturnType}
66
+ * @param forced {boolean} If :
67
+ * - true render will only use the StoryFn `props' in storyProps observable that will update sotry's component/template properties. Improves performance without reloading the whole module&component if props changes
68
+ * - false fully recharges or initializes angular module & component
69
+ * @param component {Component}
70
+ */
71
+ async render({ storyFnAngular, forced, component, targetDOMNode, }) {
72
+ const targetSelector = this.generateTargetSelectorFromStoryId(targetDOMNode.id);
73
+ const newStoryProps$ = new rxjs_1.BehaviorSubject(storyFnAngular.props);
74
+ if (!this.fullRendererRequired({
75
+ targetDOMNode,
76
+ storyFnAngular,
77
+ moduleMetadata: {
78
+ ...storyFnAngular.moduleMetadata,
79
+ },
80
+ forced,
81
+ })) {
82
+ this.storyProps$.next(storyFnAngular.props);
83
+ return;
84
+ }
85
+ await this.beforeFullRender(targetDOMNode);
86
+ // Complete last BehaviorSubject and set a new one for the current module
87
+ if (this.storyProps$) {
88
+ this.storyProps$.complete();
89
+ }
90
+ this.storyProps$ = newStoryProps$;
91
+ this.initAngularRootElement(targetDOMNode, targetSelector);
92
+ const analyzedMetadata = new PropertyExtractor_1.PropertyExtractor(storyFnAngular.moduleMetadata, component);
93
+ const application = (0, StorybookModule_1.getApplication)({
94
+ storyFnAngular,
95
+ component,
96
+ targetSelector,
97
+ analyzedMetadata,
98
+ });
99
+ const applicationRef = await (0, platform_browser_1.bootstrapApplication)(application, {
100
+ ...storyFnAngular.applicationConfig,
101
+ providers: [
102
+ (0, StorybookProvider_1.storyPropsProvider)(newStoryProps$),
103
+ ...analyzedMetadata.applicationProviders,
104
+ ...(storyFnAngular.applicationConfig?.providers ?? []),
105
+ ],
106
+ });
107
+ applicationRefs.set(targetDOMNode, applicationRef);
108
+ await this.afterFullRender();
109
+ }
110
+ /**
111
+ * Only ASCII alphanumerics can be used as HTML tag name.
112
+ * https://html.spec.whatwg.org/#elements-2
113
+ *
114
+ * Therefore, stories break when non-ASCII alphanumerics are included in target selector.
115
+ * https://github.com/storybookjs/storybook/issues/15147
116
+ *
117
+ * This method returns storyId when it doesn't contain any non-ASCII alphanumerics.
118
+ * Otherwise, it generates a valid HTML tag name from storyId by removing non-ASCII alphanumerics from storyId, prefixing "sb-", and suffixing "-component"
119
+ * @protected
120
+ * @memberof AbstractRenderer
121
+ */
122
+ generateTargetSelectorFromStoryId(id) {
123
+ const invalidHtmlTag = /[^A-Za-z0-9-]/g;
124
+ const storyIdIsInvalidHtmlTagName = invalidHtmlTag.test(id);
125
+ return storyIdIsInvalidHtmlTagName ? `sb-${id.replace(invalidHtmlTag, '')}-component` : id;
126
+ }
127
+ initAngularRootElement(targetDOMNode, targetSelector) {
128
+ // Adds DOM element that angular will use as bootstrap component
129
+ // eslint-disable-next-line no-param-reassign
130
+ targetDOMNode.innerHTML = '';
131
+ targetDOMNode.appendChild(document.createElement(targetSelector));
132
+ }
133
+ fullRendererRequired({ targetDOMNode, storyFnAngular, moduleMetadata, forced, }) {
134
+ const previousStoryRenderInfo = this.previousStoryRenderInfo.get(targetDOMNode);
135
+ const currentStoryRender = {
136
+ storyFnAngular,
137
+ moduleMetadataSnapshot: (0, telejson_1.stringify)(moduleMetadata),
138
+ };
139
+ this.previousStoryRenderInfo.set(targetDOMNode, currentStoryRender);
140
+ if (
141
+ // check `forceRender` of story RenderContext
142
+ !forced ||
143
+ // if it's the first rendering and storyProps$ is not init
144
+ !this.storyProps$) {
145
+ return true;
146
+ }
147
+ // force the rendering if the template has changed
148
+ const hasChangedTemplate = !!storyFnAngular?.template &&
149
+ previousStoryRenderInfo?.storyFnAngular?.template !== storyFnAngular.template;
150
+ if (hasChangedTemplate) {
151
+ return true;
152
+ }
153
+ // force the rendering if the metadata structure has changed
154
+ const hasChangedModuleMetadata = currentStoryRender.moduleMetadataSnapshot !== previousStoryRenderInfo?.moduleMetadataSnapshot;
155
+ return hasChangedModuleMetadata;
156
+ }
157
+ }
158
+ _a = AbstractRenderer;
159
+ /**
160
+ * Reset compiled components because we often want to compile the same component with
161
+ * more than one NgModule.
162
+ */
163
+ AbstractRenderer.resetCompiledComponents = async () => {
164
+ try {
165
+ // Clear global Angular component cache in order to be able to re-render the same component across multiple stories
166
+ //
167
+ // References:
168
+ // https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/webpack/plugins/hmr/hmr-accept.ts#L50
169
+ // https://github.com/angular/angular/blob/2ebe2bcb2fe19bf672316b05f15241fd7fd40803/packages/core/src/render3/jit/module.ts#L377-L384
170
+ const { ɵresetCompiledComponents } = await Promise.resolve().then(() => __importStar(require('@angular/core')));
171
+ ɵresetCompiledComponents();
172
+ }
173
+ catch (e) {
174
+ /**
175
+ * noop catch
176
+ * This means angular removed or modified ɵresetCompiledComponents
177
+ */
178
+ }
179
+ };
180
+ exports.AbstractRenderer = AbstractRenderer;
@@ -0,0 +1,13 @@
1
+ import { AbstractRenderer } from './AbstractRenderer';
2
+ import { StoryFnAngularReturnType, Parameters } from '../types';
3
+ export declare class CanvasRenderer extends AbstractRenderer {
4
+ render(options: {
5
+ storyFnAngular: StoryFnAngularReturnType;
6
+ forced: boolean;
7
+ parameters: Parameters;
8
+ component: any;
9
+ targetDOMNode: HTMLElement;
10
+ }): Promise<void>;
11
+ beforeFullRender(): Promise<void>;
12
+ afterFullRender(): Promise<void>;
13
+ }