@ng-prism/core 22.6.0 → 22.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/README.md +11 -9
  2. package/dist/app/canvas/canvas-bg.styles.d.ts +1 -1
  3. package/dist/app/canvas/canvas-bg.styles.d.ts.map +1 -1
  4. package/dist/app/canvas/canvas-bg.styles.js +1 -1
  5. package/dist/app/canvas/canvas-overlay-tokens.d.ts +12 -0
  6. package/dist/app/canvas/canvas-overlay-tokens.d.ts.map +1 -0
  7. package/dist/app/canvas/canvas-overlay-tokens.js +52 -0
  8. package/dist/app/canvas/prism-canvas-bg-pill.component.js +2 -2
  9. package/dist/app/canvas/prism-canvas-pin-row.component.js +2 -2
  10. package/dist/app/canvas/prism-canvas-rulers.component.d.ts +2 -0
  11. package/dist/app/canvas/prism-canvas-rulers.component.d.ts.map +1 -1
  12. package/dist/app/canvas/prism-canvas-rulers.component.js +17 -12
  13. package/dist/app/canvas/prism-canvas-toolbar.component.d.ts +3 -2
  14. package/dist/app/canvas/prism-canvas-toolbar.component.d.ts.map +1 -1
  15. package/dist/app/canvas/prism-canvas-toolbar.component.js +89 -97
  16. package/dist/app/canvas/prism-template-popover.component.d.ts.map +1 -1
  17. package/dist/app/canvas/prism-template-popover.component.js +16 -7
  18. package/dist/app/component-head/head-metrics.d.ts +35 -19
  19. package/dist/app/component-head/head-metrics.d.ts.map +1 -1
  20. package/dist/app/component-head/head-metrics.js +57 -27
  21. package/dist/app/component-head/pipe-facts.d.ts +9 -0
  22. package/dist/app/component-head/pipe-facts.d.ts.map +1 -0
  23. package/dist/app/component-head/pipe-facts.js +15 -0
  24. package/dist/app/component-head/prism-component-head.component.d.ts +19 -22
  25. package/dist/app/component-head/prism-component-head.component.d.ts.map +1 -1
  26. package/dist/app/component-head/prism-component-head.component.js +80 -96
  27. package/dist/app/component-head/prism-head-gauge.component.d.ts +8 -12
  28. package/dist/app/component-head/prism-head-gauge.component.d.ts.map +1 -1
  29. package/dist/app/component-head/prism-head-gauge.component.js +51 -67
  30. package/dist/app/component-head/prism-head-info.component.d.ts +13 -2
  31. package/dist/app/component-head/prism-head-info.component.d.ts.map +1 -1
  32. package/dist/app/component-head/prism-head-info.component.js +57 -16
  33. package/dist/app/component-head/prism-stat.component.d.ts +4 -5
  34. package/dist/app/component-head/prism-stat.component.d.ts.map +1 -1
  35. package/dist/app/component-head/prism-stat.component.js +16 -12
  36. package/dist/app/component-head/service-facts.d.ts +8 -0
  37. package/dist/app/component-head/service-facts.d.ts.map +1 -0
  38. package/dist/app/component-head/service-facts.js +11 -0
  39. package/dist/app/controls/boolean-control.component.js +2 -2
  40. package/dist/app/controls/json-control.component.js +2 -2
  41. package/dist/app/controls/union-control.component.js +4 -3
  42. package/dist/app/header/header-brand.d.ts +25 -0
  43. package/dist/app/header/header-brand.d.ts.map +1 -0
  44. package/dist/app/header/header-brand.js +10 -0
  45. package/dist/app/header/prism-header.component.d.ts +2 -2
  46. package/dist/app/header/prism-header.component.d.ts.map +1 -1
  47. package/dist/app/header/prism-header.component.js +73 -57
  48. package/dist/app/icons/icon-registry.d.ts.map +1 -1
  49. package/dist/app/icons/icon-registry.js +4 -1
  50. package/dist/app/index.d.ts +12 -0
  51. package/dist/app/index.d.ts.map +1 -1
  52. package/dist/app/index.js +12 -1
  53. package/dist/app/layout-menu/prism-layout-menu.component.d.ts +3 -0
  54. package/dist/app/layout-menu/prism-layout-menu.component.d.ts.map +1 -1
  55. package/dist/app/layout-menu/prism-layout-menu.component.js +72 -58
  56. package/dist/app/overview/open-in-playground.d.ts +8 -0
  57. package/dist/app/overview/open-in-playground.d.ts.map +1 -1
  58. package/dist/app/overview/open-in-playground.js +13 -0
  59. package/dist/app/overview/overview-matrix.d.ts +10 -4
  60. package/dist/app/overview/overview-matrix.d.ts.map +1 -1
  61. package/dist/app/overview/overview-matrix.js +3 -3
  62. package/dist/app/overview/prism-overview-cell.component.d.ts +6 -2
  63. package/dist/app/overview/prism-overview-cell.component.d.ts.map +1 -1
  64. package/dist/app/overview/prism-overview-cell.component.js +35 -24
  65. package/dist/app/overview/prism-overview-matrix.component.js +46 -55
  66. package/dist/app/page-renderer/prism-page-renderer.component.js +2 -2
  67. package/dist/app/panels/a11y/a11y-header-badge.component.d.ts +1 -4
  68. package/dist/app/panels/a11y/a11y-header-badge.component.d.ts.map +1 -1
  69. package/dist/app/panels/a11y/a11y-header-badge.component.js +8 -19
  70. package/dist/app/panels/a11y/a11y-keyboard-overlay.component.js +2 -2
  71. package/dist/app/panels/a11y/a11y-overlay-host.component.d.ts +1 -0
  72. package/dist/app/panels/a11y/a11y-overlay-host.component.d.ts.map +1 -1
  73. package/dist/app/panels/a11y/a11y-overlay-host.component.js +4 -3
  74. package/dist/app/panels/a11y/a11y-panel.component.d.ts +4 -1
  75. package/dist/app/panels/a11y/a11y-panel.component.d.ts.map +1 -1
  76. package/dist/app/panels/a11y/a11y-panel.component.js +32 -54
  77. package/dist/app/panels/a11y/a11y-score.component.d.ts +8 -3
  78. package/dist/app/panels/a11y/a11y-score.component.d.ts.map +1 -1
  79. package/dist/app/panels/a11y/a11y-score.component.js +19 -35
  80. package/dist/app/panels/a11y/a11y-sr-overlay.component.js +2 -2
  81. package/dist/app/panels/a11y/a11y-sr.component.js +2 -2
  82. package/dist/app/panels/a11y/a11y-summary.d.ts.map +1 -1
  83. package/dist/app/panels/a11y/a11y-summary.js +8 -1
  84. package/dist/app/panels/a11y/a11y-tree.component.js +2 -2
  85. package/dist/app/panels/a11y/a11y-violations.component.d.ts +23 -2
  86. package/dist/app/panels/a11y/a11y-violations.component.d.ts.map +1 -1
  87. package/dist/app/panels/a11y/a11y-violations.component.js +104 -89
  88. package/dist/app/panels/a11y/severity.d.ts +9 -0
  89. package/dist/app/panels/a11y/severity.d.ts.map +1 -0
  90. package/dist/app/panels/a11y/severity.js +12 -0
  91. package/dist/app/panels/controls/non-editable-input-types.d.ts +9 -1
  92. package/dist/app/panels/controls/non-editable-input-types.d.ts.map +1 -1
  93. package/dist/app/panels/controls/non-editable-input-types.js +18 -0
  94. package/dist/app/panels/controls/prism-controls-panel.component.d.ts +2 -1
  95. package/dist/app/panels/controls/prism-controls-panel.component.d.ts.map +1 -1
  96. package/dist/app/panels/controls/prism-controls-panel.component.js +77 -59
  97. package/dist/app/panels/events/prism-events-panel.component.d.ts +2 -0
  98. package/dist/app/panels/events/prism-events-panel.component.d.ts.map +1 -1
  99. package/dist/app/panels/events/prism-events-panel.component.js +20 -7
  100. package/dist/app/panels/events/prism-json-node.utils.d.ts +6 -0
  101. package/dist/app/panels/events/prism-json-node.utils.d.ts.map +1 -1
  102. package/dist/app/panels/events/prism-json-node.utils.js +8 -0
  103. package/dist/app/panels/panel-host/addon-panels.d.ts +11 -0
  104. package/dist/app/panels/panel-host/addon-panels.d.ts.map +1 -0
  105. package/dist/app/panels/panel-host/addon-panels.js +12 -0
  106. package/dist/app/panels/panel-host/panel-badge.d.ts +22 -0
  107. package/dist/app/panels/panel-host/panel-badge.d.ts.map +1 -1
  108. package/dist/app/panels/panel-host/panel-badge.js +56 -11
  109. package/dist/app/panels/panel-host/prism-panel-host.component.d.ts +4 -1
  110. package/dist/app/panels/panel-host/prism-panel-host.component.d.ts.map +1 -1
  111. package/dist/app/panels/panel-host/prism-panel-host.component.js +36 -70
  112. package/dist/app/renderer/composition.d.ts +20 -0
  113. package/dist/app/renderer/composition.d.ts.map +1 -0
  114. package/dist/app/renderer/composition.js +26 -0
  115. package/dist/app/renderer/input-bindings.d.ts +13 -1
  116. package/dist/app/renderer/input-bindings.d.ts.map +1 -1
  117. package/dist/app/renderer/input-bindings.js +22 -1
  118. package/dist/app/renderer/prism-renderer.component.d.ts +8 -1
  119. package/dist/app/renderer/prism-renderer.component.d.ts.map +1 -1
  120. package/dist/app/renderer/prism-renderer.component.js +40 -28
  121. package/dist/app/renderer/snippet-generator.d.ts +14 -2
  122. package/dist/app/renderer/snippet-generator.d.ts.map +1 -1
  123. package/dist/app/renderer/snippet-generator.js +137 -82
  124. package/dist/app/services/navigation-item.d.ts +10 -0
  125. package/dist/app/services/navigation-item.d.ts.map +1 -0
  126. package/dist/app/services/navigation-item.js +20 -0
  127. package/dist/app/services/navigation-item.types.d.ts +8 -0
  128. package/dist/app/services/navigation-item.types.d.ts.map +1 -1
  129. package/dist/app/services/prism-layout.service.d.ts +12 -0
  130. package/dist/app/services/prism-layout.service.d.ts.map +1 -1
  131. package/dist/app/services/prism-layout.service.js +17 -7
  132. package/dist/app/services/prism-manifest.service.d.ts +4 -0
  133. package/dist/app/services/prism-manifest.service.d.ts.map +1 -1
  134. package/dist/app/services/prism-manifest.service.js +4 -0
  135. package/dist/app/services/prism-navigation.service.d.ts +12 -0
  136. package/dist/app/services/prism-navigation.service.d.ts.map +1 -1
  137. package/dist/app/services/prism-navigation.service.js +85 -19
  138. package/dist/app/services/prism-panel.service.d.ts +7 -3
  139. package/dist/app/services/prism-panel.service.d.ts.map +1 -1
  140. package/dist/app/services/prism-panel.service.js +13 -4
  141. package/dist/app/services/prism-renderer.service.d.ts +6 -0
  142. package/dist/app/services/prism-renderer.service.d.ts.map +1 -1
  143. package/dist/app/services/prism-renderer.service.js +40 -6
  144. package/dist/app/services/prism-search.service.d.ts +4 -0
  145. package/dist/app/services/prism-search.service.d.ts.map +1 -1
  146. package/dist/app/services/prism-search.service.js +29 -6
  147. package/dist/app/services/prism-theme.service.d.ts +11 -3
  148. package/dist/app/services/prism-theme.service.d.ts.map +1 -1
  149. package/dist/app/services/prism-theme.service.js +27 -19
  150. package/dist/app/services/prism-url-state.service.d.ts.map +1 -1
  151. package/dist/app/services/prism-url-state.service.js +42 -4
  152. package/dist/app/shared/badge.types.d.ts +7 -0
  153. package/dist/app/shared/badge.types.d.ts.map +1 -0
  154. package/dist/app/shared/badge.types.js +9 -0
  155. package/dist/app/shared/brand-mark.d.ts +35 -0
  156. package/dist/app/shared/brand-mark.d.ts.map +1 -0
  157. package/dist/app/shared/brand-mark.js +52 -0
  158. package/dist/app/shared/metric-bar.d.ts +6 -0
  159. package/dist/app/shared/metric-bar.d.ts.map +1 -0
  160. package/dist/app/shared/metric-bar.js +7 -0
  161. package/dist/app/shared/prism-badge.component.d.ts +21 -0
  162. package/dist/app/shared/prism-badge.component.d.ts.map +1 -0
  163. package/dist/app/shared/prism-badge.component.js +68 -0
  164. package/dist/app/shared/prism-button.component.d.ts +12 -0
  165. package/dist/app/shared/prism-button.component.d.ts.map +1 -0
  166. package/dist/app/shared/prism-button.component.js +28 -0
  167. package/dist/app/shared/prism-icon-button.component.d.ts +17 -0
  168. package/dist/app/shared/prism-icon-button.component.d.ts.map +1 -0
  169. package/dist/app/shared/prism-icon-button.component.js +37 -0
  170. package/dist/app/shared/prism-list-row.component.d.ts +17 -0
  171. package/dist/app/shared/prism-list-row.component.d.ts.map +1 -0
  172. package/dist/app/shared/prism-list-row.component.js +57 -0
  173. package/dist/app/shared/prism-logo.component.d.ts +24 -0
  174. package/dist/app/shared/prism-logo.component.d.ts.map +1 -0
  175. package/dist/app/shared/prism-logo.component.js +77 -0
  176. package/dist/app/shared/prism-metric-badge.component.d.ts +9 -4
  177. package/dist/app/shared/prism-metric-badge.component.d.ts.map +1 -1
  178. package/dist/app/shared/prism-metric-badge.component.js +33 -12
  179. package/dist/app/shared/prism-metric-card.component.d.ts +30 -0
  180. package/dist/app/shared/prism-metric-card.component.d.ts.map +1 -0
  181. package/dist/app/shared/prism-metric-card.component.js +111 -0
  182. package/dist/app/shared/prism-panel-toolbar.component.d.ts +13 -0
  183. package/dist/app/shared/prism-panel-toolbar.component.d.ts.map +1 -0
  184. package/dist/app/shared/prism-panel-toolbar.component.js +28 -0
  185. package/dist/app/shared/prism-segmented.component.d.ts +25 -0
  186. package/dist/app/shared/prism-segmented.component.d.ts.map +1 -0
  187. package/dist/app/shared/prism-segmented.component.js +77 -0
  188. package/dist/app/shared/prism-tabs.component.d.ts +44 -0
  189. package/dist/app/shared/prism-tabs.component.d.ts.map +1 -0
  190. package/dist/app/shared/prism-tabs.component.js +134 -0
  191. package/dist/app/shared/roving-focus.d.ts +13 -0
  192. package/dist/app/shared/roving-focus.d.ts.map +1 -0
  193. package/dist/app/shared/roving-focus.js +34 -0
  194. package/dist/app/shell/prism-shell.component.d.ts +13 -0
  195. package/dist/app/shell/prism-shell.component.d.ts.map +1 -1
  196. package/dist/app/shell/prism-shell.component.js +57 -28
  197. package/dist/app/shell/should-select-first.d.ts +17 -0
  198. package/dist/app/shell/should-select-first.d.ts.map +1 -0
  199. package/dist/app/shell/should-select-first.js +13 -0
  200. package/dist/app/sidebar/navigation-decorations.d.ts +23 -1
  201. package/dist/app/sidebar/navigation-decorations.d.ts.map +1 -1
  202. package/dist/app/sidebar/navigation-decorations.js +33 -2
  203. package/dist/app/sidebar/prism-sidebar.component.d.ts +5 -15
  204. package/dist/app/sidebar/prism-sidebar.component.d.ts.map +1 -1
  205. package/dist/app/sidebar/prism-sidebar.component.js +89 -77
  206. package/dist/app/theme/deprecated-tokens.d.ts +15 -0
  207. package/dist/app/theme/deprecated-tokens.d.ts.map +1 -0
  208. package/dist/app/theme/deprecated-tokens.js +22 -0
  209. package/dist/app/theme/favicon.d.ts +3 -0
  210. package/dist/app/theme/favicon.d.ts.map +1 -0
  211. package/dist/app/theme/favicon.js +3 -0
  212. package/dist/app/theme/prism-default-theme.d.ts.map +1 -1
  213. package/dist/app/theme/prism-default-theme.js +116 -61
  214. package/dist/app/theme/resolve-theme-tokens.d.ts +29 -0
  215. package/dist/app/theme/resolve-theme-tokens.d.ts.map +1 -0
  216. package/dist/app/theme/resolve-theme-tokens.js +43 -0
  217. package/dist/app/variant-ribbon/prism-variant-ribbon.component.d.ts +4 -7
  218. package/dist/app/variant-ribbon/prism-variant-ribbon.component.d.ts.map +1 -1
  219. package/dist/app/variant-ribbon/prism-variant-ribbon.component.js +31 -69
  220. package/dist/app/view-tab-bar/next-view-id.d.ts +7 -1
  221. package/dist/app/view-tab-bar/next-view-id.d.ts.map +1 -1
  222. package/dist/app/view-tab-bar/next-view-id.js +9 -1
  223. package/dist/app/view-tab-bar/panel-inputs.d.ts +28 -0
  224. package/dist/app/view-tab-bar/panel-inputs.d.ts.map +1 -0
  225. package/dist/app/view-tab-bar/panel-inputs.js +41 -0
  226. package/dist/app/view-tab-bar/prism-view-panel-host.component.d.ts +2 -3
  227. package/dist/app/view-tab-bar/prism-view-panel-host.component.d.ts.map +1 -1
  228. package/dist/app/view-tab-bar/prism-view-panel-host.component.js +9 -9
  229. package/dist/app/view-tab-bar/prism-view-tab-bar.component.d.ts +6 -0
  230. package/dist/app/view-tab-bar/prism-view-tab-bar.component.d.ts.map +1 -1
  231. package/dist/app/view-tab-bar/prism-view-tab-bar.component.js +22 -29
  232. package/dist/builder/config-loader/deprecated-options.d.ts +4 -2
  233. package/dist/builder/config-loader/deprecated-options.d.ts.map +1 -1
  234. package/dist/builder/config-loader/deprecated-options.js +13 -2
  235. package/dist/builder/manifest/composition-wrapper.generator.d.ts +14 -0
  236. package/dist/builder/manifest/composition-wrapper.generator.d.ts.map +1 -0
  237. package/dist/builder/manifest/composition-wrapper.generator.js +66 -0
  238. package/dist/builder/manifest/host-parser.d.ts +2 -0
  239. package/dist/builder/manifest/host-parser.d.ts.map +1 -1
  240. package/dist/builder/manifest/host-parser.js +9 -4
  241. package/dist/builder/manifest/manifest-imports.d.ts +34 -0
  242. package/dist/builder/manifest/manifest-imports.d.ts.map +1 -0
  243. package/dist/builder/manifest/manifest-imports.js +91 -0
  244. package/dist/builder/manifest/runtime-manifest.generator.d.ts +13 -0
  245. package/dist/builder/manifest/runtime-manifest.generator.d.ts.map +1 -1
  246. package/dist/builder/manifest/runtime-manifest.generator.js +135 -64
  247. package/dist/builder/manifest/selector-element.d.ts +16 -0
  248. package/dist/builder/manifest/selector-element.d.ts.map +1 -0
  249. package/dist/builder/manifest/selector-element.js +46 -0
  250. package/dist/builder/manifest/template-literal.d.ts +3 -0
  251. package/dist/builder/manifest/template-literal.d.ts.map +1 -0
  252. package/dist/builder/manifest/template-literal.js +4 -0
  253. package/dist/builder/plugin-runner/plugin-runner.d.ts.map +1 -1
  254. package/dist/builder/plugin-runner/plugin-runner.js +29 -26
  255. package/dist/builder/scanner/api/angular-decorators.d.ts +84 -0
  256. package/dist/builder/scanner/api/angular-decorators.d.ts.map +1 -0
  257. package/dist/builder/scanner/api/angular-decorators.js +157 -0
  258. package/dist/builder/scanner/api/component-api.extractor.d.ts +13 -0
  259. package/dist/builder/scanner/api/component-api.extractor.d.ts.map +1 -0
  260. package/dist/builder/scanner/api/component-api.extractor.js +104 -0
  261. package/dist/builder/scanner/api/doc-tags.d.ts +13 -0
  262. package/dist/builder/scanner/api/doc-tags.d.ts.map +1 -0
  263. package/dist/builder/scanner/api/doc-tags.js +101 -0
  264. package/dist/builder/scanner/api/export-index.d.ts +18 -0
  265. package/dist/builder/scanner/api/export-index.d.ts.map +1 -0
  266. package/dist/builder/scanner/api/export-index.js +22 -0
  267. package/dist/builder/scanner/api/member.extractor.d.ts +90 -0
  268. package/dist/builder/scanner/api/member.extractor.d.ts.map +1 -0
  269. package/dist/builder/scanner/api/member.extractor.js +270 -0
  270. package/dist/builder/scanner/api/pipe-api.extractor.d.ts +12 -0
  271. package/dist/builder/scanner/api/pipe-api.extractor.d.ts.map +1 -0
  272. package/dist/builder/scanner/api/pipe-api.extractor.js +52 -0
  273. package/dist/builder/scanner/api/service-api.extractor.d.ts +14 -0
  274. package/dist/builder/scanner/api/service-api.extractor.d.ts.map +1 -0
  275. package/dist/builder/scanner/api/service-api.extractor.js +119 -0
  276. package/dist/builder/scanner/api/setup.reader.d.ts +26 -0
  277. package/dist/builder/scanner/api/setup.reader.d.ts.map +1 -0
  278. package/dist/builder/scanner/api/setup.reader.js +89 -0
  279. package/dist/builder/scanner/api/type-collector.d.ts +24 -0
  280. package/dist/builder/scanner/api/type-collector.d.ts.map +1 -0
  281. package/dist/builder/scanner/api/type-collector.js +211 -0
  282. package/dist/builder/scanner/ast-utils.d.ts +8 -0
  283. package/dist/builder/scanner/ast-utils.d.ts.map +1 -1
  284. package/dist/builder/scanner/ast-utils.js +37 -1
  285. package/dist/builder/scanner/class-hierarchy.d.ts +5 -3
  286. package/dist/builder/scanner/class-hierarchy.d.ts.map +1 -1
  287. package/dist/builder/scanner/class-hierarchy.js +12 -6
  288. package/dist/builder/scanner/component.scanner.d.ts +60 -6
  289. package/dist/builder/scanner/component.scanner.d.ts.map +1 -1
  290. package/dist/builder/scanner/component.scanner.js +209 -57
  291. package/dist/builder/scanner/composition/compose-template.d.ts +36 -0
  292. package/dist/builder/scanner/composition/compose-template.d.ts.map +1 -0
  293. package/dist/builder/scanner/composition/compose-template.js +187 -0
  294. package/dist/builder/scanner/composition/declarables.d.ts +54 -0
  295. package/dist/builder/scanner/composition/declarables.d.ts.map +1 -0
  296. package/dist/builder/scanner/composition/declarables.js +182 -0
  297. package/dist/builder/scanner/composition/match-declarables.d.ts +43 -0
  298. package/dist/builder/scanner/composition/match-declarables.d.ts.map +1 -0
  299. package/dist/builder/scanner/composition/match-declarables.js +131 -0
  300. package/dist/builder/scanner/composition/read-composition.d.ts +77 -0
  301. package/dist/builder/scanner/composition/read-composition.d.ts.map +1 -0
  302. package/dist/builder/scanner/composition/read-composition.js +302 -0
  303. package/dist/builder/scanner/composition/template-elements.d.ts +12 -0
  304. package/dist/builder/scanner/composition/template-elements.d.ts.map +1 -0
  305. package/dist/builder/scanner/composition/template-elements.js +41 -0
  306. package/dist/builder/scanner/index.d.ts +4 -0
  307. package/dist/builder/scanner/index.d.ts.map +1 -1
  308. package/dist/builder/scanner/index.js +2 -0
  309. package/dist/builder/scanner/input.extractor.d.ts +31 -2
  310. package/dist/builder/scanner/input.extractor.d.ts.map +1 -1
  311. package/dist/builder/scanner/input.extractor.js +52 -15
  312. package/dist/builder/scanner/pipe.scanner.d.ts +29 -0
  313. package/dist/builder/scanner/pipe.scanner.d.ts.map +1 -0
  314. package/dist/builder/scanner/pipe.scanner.js +65 -0
  315. package/dist/builder/scanner/scanner.d.ts +25 -1
  316. package/dist/builder/scanner/scanner.d.ts.map +1 -1
  317. package/dist/builder/scanner/scanner.js +60 -26
  318. package/dist/builder/scanner/service/angular-decorators.d.ts +80 -0
  319. package/dist/builder/scanner/service/angular-decorators.d.ts.map +1 -0
  320. package/dist/builder/scanner/service/angular-decorators.js +154 -0
  321. package/dist/builder/scanner/service/doc-tags.d.ts +13 -0
  322. package/dist/builder/scanner/service/doc-tags.d.ts.map +1 -0
  323. package/dist/builder/scanner/service/doc-tags.js +97 -0
  324. package/dist/builder/scanner/service/export-index.d.ts +18 -0
  325. package/dist/builder/scanner/service/export-index.d.ts.map +1 -0
  326. package/dist/builder/scanner/service/export-index.js +22 -0
  327. package/dist/builder/scanner/service/member.extractor.d.ts +65 -0
  328. package/dist/builder/scanner/service/member.extractor.d.ts.map +1 -0
  329. package/dist/builder/scanner/service/member.extractor.js +216 -0
  330. package/dist/builder/scanner/service/pipe-api.extractor.d.ts +12 -0
  331. package/dist/builder/scanner/service/pipe-api.extractor.d.ts.map +1 -0
  332. package/dist/builder/scanner/service/pipe-api.extractor.js +72 -0
  333. package/dist/builder/scanner/service/service-api.extractor.d.ts +14 -0
  334. package/dist/builder/scanner/service/service-api.extractor.d.ts.map +1 -0
  335. package/dist/builder/scanner/service/service-api.extractor.js +119 -0
  336. package/dist/builder/scanner/service/setup.reader.d.ts +26 -0
  337. package/dist/builder/scanner/service/setup.reader.d.ts.map +1 -0
  338. package/dist/builder/scanner/service/setup.reader.js +89 -0
  339. package/dist/builder/scanner/service/type-collector.d.ts +23 -0
  340. package/dist/builder/scanner/service/type-collector.d.ts.map +1 -0
  341. package/dist/builder/scanner/service/type-collector.js +210 -0
  342. package/dist/builder/scanner/service.scanner.d.ts +26 -0
  343. package/dist/builder/scanner/service.scanner.d.ts.map +1 -0
  344. package/dist/builder/scanner/service.scanner.js +61 -0
  345. package/dist/builder/scanner/showcase-diagnostics.d.ts +60 -1
  346. package/dist/builder/scanner/showcase-diagnostics.d.ts.map +1 -1
  347. package/dist/builder/scanner/showcase-diagnostics.js +114 -1
  348. package/dist/builder/shared/prism-pipeline.d.ts +6 -0
  349. package/dist/builder/shared/prism-pipeline.d.ts.map +1 -1
  350. package/dist/builder/shared/prism-pipeline.js +43 -5
  351. package/dist/decorator/index.d.ts +1 -1
  352. package/dist/decorator/index.d.ts.map +1 -1
  353. package/dist/decorator/showcase.types.d.ts +79 -9
  354. package/dist/decorator/showcase.types.d.ts.map +1 -1
  355. package/dist/plugin/index.d.ts +6 -1
  356. package/dist/plugin/index.d.ts.map +1 -1
  357. package/dist/plugin/index.js +4 -0
  358. package/dist/plugin/pipe.types.d.ts +36 -0
  359. package/dist/plugin/pipe.types.d.ts.map +1 -0
  360. package/dist/plugin/pipe.types.js +1 -0
  361. package/dist/plugin/plugin.types.d.ts +140 -3
  362. package/dist/plugin/plugin.types.d.ts.map +1 -1
  363. package/dist/plugin/service.types.d.ts +124 -0
  364. package/dist/plugin/service.types.d.ts.map +1 -0
  365. package/dist/plugin/service.types.js +1 -0
  366. package/dist/plugin/status.d.ts +27 -0
  367. package/dist/plugin/status.d.ts.map +1 -0
  368. package/dist/plugin/status.js +26 -0
  369. package/dist/shared/composition.d.ts +30 -0
  370. package/dist/shared/composition.d.ts.map +1 -0
  371. package/dist/shared/composition.js +29 -0
  372. package/dist/shared/pseudo-state.type.d.ts +2 -1
  373. package/dist/shared/pseudo-state.type.d.ts.map +1 -1
  374. package/dist/shared/void-elements.d.ts +3 -0
  375. package/dist/shared/void-elements.d.ts.map +1 -0
  376. package/dist/shared/void-elements.js +2 -0
  377. package/package.json +1 -1
@@ -0,0 +1,65 @@
1
+ import ts from 'typescript';
2
+ import type { ApiMethod, ApiProperty, ApiTypeRef } from '../../../plugin/service.types.js';
3
+ /** What a type is the type of: a property, a parameter of a method, or what a method returns. */
4
+ export type TypeSite = {
5
+ kind: 'property';
6
+ name: string;
7
+ } | {
8
+ kind: 'parameter';
9
+ name: string;
10
+ method: string;
11
+ } | {
12
+ kind: 'return';
13
+ method: string;
14
+ };
15
+ /**
16
+ * Turns the type of a member, parameter or return value into an {@link ApiTypeRef}.
17
+ * `reachedFrom` says where it was met, e.g. `parameter of show()`, and `site`
18
+ * the same in parts, for a resolver that documents the types it finds on the
19
+ * way and follows their members.
20
+ */
21
+ export interface TypeRefResolver {
22
+ ref(typeNode: ts.TypeNode | undefined, type: ts.Type, reachedFrom: string, site?: TypeSite): ApiTypeRef;
23
+ }
24
+ /** A type as written, or as the checker prints it when there is nothing written. Whitespace is collapsed, so a multi-line literal type stays on one line. */
25
+ export declare function readTypeText(checker: ts.TypeChecker, typeNode: ts.TypeNode | undefined, type: ts.Type): string;
26
+ /** Gives the text of a type and nothing else: no links, no documented types. */
27
+ export declare function textOnlyResolver(checker: ts.TypeChecker): TypeRefResolver;
28
+ /**
29
+ * The public instance members of a class and of its base classes, nearest
30
+ * class first and in source order. A class that declares a name hides it in
31
+ * the classes above, whatever it declares: an `@internal` override removes
32
+ * the member, a redeclaration replaces the inherited one. A static member
33
+ * hides nothing, as it is not an instance member.
34
+ *
35
+ * Left out: `private`, `protected` and `#` members, names with a `_` prefix,
36
+ * lifecycle hooks, the constructor, statics and what is tagged `@internal`.
37
+ * The constructor's parameter properties (`constructor(readonly id: string)`)
38
+ * are properties, in the constructor's place, described by its `@param`.
39
+ * Methods are listed with or without JSDoc. A redeclaration without JSDoc of
40
+ * its own keeps its signature, but takes description, tags and `@param` texts
41
+ * from the nearest base class member of that name that has them.
42
+ */
43
+ export declare function extractMembers(classDecl: ts.ClassDeclaration, checker: ts.TypeChecker, types: TypeRefResolver): {
44
+ properties: ApiProperty[];
45
+ methods: ApiMethod[];
46
+ };
47
+ /**
48
+ * The members of an interface or an object literal type, the inherited ones
49
+ * included, own members first. What is tagged `@internal` is left out; there
50
+ * is nothing private to leave out.
51
+ */
52
+ export declare function extractObjectTypeMembers(type: ts.Type, checker: ts.TypeChecker, types: TypeRefResolver): {
53
+ properties: ApiProperty[];
54
+ methods: ApiMethod[];
55
+ };
56
+ /**
57
+ * The signature of a method, or of a function such as a setup function, with
58
+ * the doc block read from `docs`: the declaration itself, the statement of a
59
+ * `const` arrow function, or a declaration it inherits the docs of.
60
+ */
61
+ export declare function extractMethod(name: string, declaration: ts.SignatureDeclaration, docs: ts.Node, checker: ts.TypeChecker, types: TypeRefResolver): ApiMethod;
62
+ /** The first parameter that is not `this`. */
63
+ export declare function firstParameter(declaration: ts.SignatureDeclaration): ts.ParameterDeclaration | undefined;
64
+ export declare function collapseWhitespace(text: string): string;
65
+ //# sourceMappingURL=member.extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"member.extractor.d.ts","sourceRoot":"","sources":["../../../../src/builder/scanner/service/member.extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAY,WAAW,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAIrG,iGAAiG;AACjG,MAAM,MAAM,QAAQ,GAAG;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErJ;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC5B,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC3G;AAkBD,6JAA6J;AAC7J,wBAAgB,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAE9G;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,eAAe,CAIzE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,GAAG;IAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,SAAS,EAAE,CAAA;CAAE,CAyBnK;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,GAAG;IAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAAC,OAAO,EAAE,SAAS,EAAE,CAAA;CAAE,CAuB5J;AAiFD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAC,oBAAoB,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,KAAK,EAAE,eAAe,GAAG,SAAS,CAe3J;AAoBD,8CAA8C;AAC9C,wBAAgB,cAAc,CAAC,WAAW,EAAE,EAAE,CAAC,oBAAoB,GAAG,EAAE,CAAC,oBAAoB,GAAG,SAAS,CAExG;AAkBD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD"}
@@ -0,0 +1,216 @@
1
+ import ts from 'typescript';
2
+ import { getClassHierarchy } from '../class-hierarchy.js';
3
+ import { isDocumented, isInternal, readDescription, readDocTags, readParamDescriptions } from './doc-tags.js';
4
+ /** The lifecycle hooks Angular calls on a service; they are not part of what a user calls. */
5
+ const LIFECYCLE_HOOKS = new Set([
6
+ 'ngOnInit',
7
+ 'ngOnDestroy',
8
+ 'ngOnChanges',
9
+ 'ngDoCheck',
10
+ 'ngAfterContentInit',
11
+ 'ngAfterContentChecked',
12
+ 'ngAfterViewInit',
13
+ 'ngAfterViewChecked'
14
+ ]);
15
+ /** A type as written, or as the checker prints it when there is nothing written. Whitespace is collapsed, so a multi-line literal type stays on one line. */
16
+ export function readTypeText(checker, typeNode, type) {
17
+ return typeNode ? collapseWhitespace(typeNode.getText()) : checker.typeToString(type, undefined, ts.TypeFormatFlags.NoTruncation);
18
+ }
19
+ /** Gives the text of a type and nothing else: no links, no documented types. */
20
+ export function textOnlyResolver(checker) {
21
+ return {
22
+ ref: (typeNode, type) => ({ text: readTypeText(checker, typeNode, type) })
23
+ };
24
+ }
25
+ /**
26
+ * The public instance members of a class and of its base classes, nearest
27
+ * class first and in source order. A class that declares a name hides it in
28
+ * the classes above, whatever it declares: an `@internal` override removes
29
+ * the member, a redeclaration replaces the inherited one. A static member
30
+ * hides nothing, as it is not an instance member.
31
+ *
32
+ * Left out: `private`, `protected` and `#` members, names with a `_` prefix,
33
+ * lifecycle hooks, the constructor, statics and what is tagged `@internal`.
34
+ * The constructor's parameter properties (`constructor(readonly id: string)`)
35
+ * are properties, in the constructor's place, described by its `@param`.
36
+ * Methods are listed with or without JSDoc. A redeclaration without JSDoc of
37
+ * its own keeps its signature, but takes description, tags and `@param` texts
38
+ * from the nearest base class member of that name that has them.
39
+ */
40
+ export function extractMembers(classDecl, checker, types) {
41
+ const properties = [];
42
+ const methods = [];
43
+ const declared = new Set();
44
+ const levels = getClassHierarchy(classDecl, checker).classes.map(({ classDecl: current }) => groupByName(current));
45
+ levels.forEach((groups, level) => {
46
+ for (const [name, group] of groups) {
47
+ if (declared.has(name))
48
+ continue;
49
+ // The doc block sits on one of them: the first overload, or the getter or the setter.
50
+ const declaration = group.find(hasOwnDocs) ?? group[0];
51
+ if (!isPublicApi(name, group, declaration))
52
+ continue;
53
+ const docs = hasOwnDocs(declaration) ? declaration : (findInheritedDocs(levels.slice(level + 1), name) ?? declaration);
54
+ if (ts.isMethodDeclaration(declaration))
55
+ methods.push(extractMethod(name, declaration, docs, checker, types));
56
+ else
57
+ properties.push(extractProperty(name, group, declaration, docs, checker, types));
58
+ }
59
+ for (const name of groups.keys())
60
+ declared.add(name);
61
+ });
62
+ return { properties, methods };
63
+ }
64
+ /**
65
+ * The members of an interface or an object literal type, the inherited ones
66
+ * included, own members first. What is tagged `@internal` is left out; there
67
+ * is nothing private to leave out.
68
+ */
69
+ export function extractObjectTypeMembers(type, checker, types) {
70
+ const properties = [];
71
+ const methods = [];
72
+ for (const symbol of checker.getPropertiesOfType(type)) {
73
+ const group = (symbol.declarations ?? []).filter((d) => ts.isMethodSignature(d) ||
74
+ ts.isMethodDeclaration(d) ||
75
+ ts.isPropertySignature(d) ||
76
+ ts.isPropertyDeclaration(d) ||
77
+ ts.isGetAccessor(d) ||
78
+ ts.isSetAccessor(d));
79
+ const declaration = group.find(isDocumented) ?? group[0];
80
+ if (!declaration || isInternal(declaration))
81
+ continue;
82
+ if (ts.isMethodSignature(declaration) || ts.isMethodDeclaration(declaration))
83
+ methods.push(extractMethod(symbol.name, declaration, declaration, checker, types));
84
+ else
85
+ properties.push(extractProperty(symbol.name, group, declaration, declaration, checker, types));
86
+ }
87
+ return { properties, methods };
88
+ }
89
+ /**
90
+ * The named instance members of a class by name, in source order: a getter and
91
+ * its setter, or the overloads of a method, share one entry. The parameter
92
+ * properties of the constructor come in where the constructor stands.
93
+ */
94
+ function groupByName(classDecl) {
95
+ const groups = new Map();
96
+ const add = (name, member) => groups.set(name, [...(groups.get(name) ?? []), member]);
97
+ for (const member of classDecl.members) {
98
+ if (ts.isConstructorDeclaration(member)) {
99
+ for (const param of member.parameters) {
100
+ if (ts.isParameterPropertyDeclaration(param, member))
101
+ add(param.name.text, param);
102
+ }
103
+ continue;
104
+ }
105
+ if (!(ts.isPropertyDeclaration(member) || ts.isMethodDeclaration(member) || ts.isGetAccessorDeclaration(member) || ts.isSetAccessorDeclaration(member)))
106
+ continue;
107
+ if (hasModifier(member, ts.SyntaxKind.StaticKeyword))
108
+ continue;
109
+ const name = getMemberName(member);
110
+ if (name !== undefined)
111
+ add(name, member);
112
+ }
113
+ return groups;
114
+ }
115
+ /**
116
+ * Whether a member is documented where it is declared: by a doc block of its
117
+ * own, or, for a parameter property, by the constructor's `@param` for it.
118
+ */
119
+ function hasOwnDocs(member) {
120
+ return isDocumented(member) || (ts.isParameter(member) && readParamDescriptions(member.parent).has(member.name.text));
121
+ }
122
+ function isPublicApi(name, group, declaration) {
123
+ if (name.startsWith('_') || LIFECYCLE_HOOKS.has(name))
124
+ return false;
125
+ if (group.some((member) => hasModifier(member, ts.SyntaxKind.PrivateKeyword) || hasModifier(member, ts.SyntaxKind.ProtectedKeyword)))
126
+ return false;
127
+ // Only its own block: a member is internal where it is declared, as for `stripInternal`.
128
+ return !isInternal(declaration);
129
+ }
130
+ /** The documented declaration of a name in the nearest of the given base classes that has one. */
131
+ function findInheritedDocs(levels, name) {
132
+ for (const groups of levels) {
133
+ const documented = groups.get(name)?.find(hasOwnDocs);
134
+ if (documented)
135
+ return documented;
136
+ }
137
+ return undefined;
138
+ }
139
+ /** `docs` is the node the doc block is read from: the declaration itself, or a declaration it inherits the docs of. */
140
+ function extractProperty(name, group, declaration, docs, checker, types) {
141
+ const getter = group.find(ts.isGetAccessorDeclaration);
142
+ const setter = group.find(ts.isSetAccessorDeclaration);
143
+ const isField = ts.isPropertyDeclaration(declaration) || ts.isPropertySignature(declaration) || ts.isParameter(declaration);
144
+ // A property reads its type from the getter, and from the setter's parameter when there is none.
145
+ const typeNode = isField ? declaration.type : (getter?.type ?? setter?.parameters[0]?.type);
146
+ const property = {
147
+ name,
148
+ type: types.ref(typeNode, checker.getTypeAtLocation(declaration), `type of ${name}`, { kind: 'property', name }),
149
+ readonly: isField ? hasModifier(declaration, ts.SyntaxKind.ReadonlyKeyword) : !!getter && !setter,
150
+ tags: readDocTags(docs)
151
+ };
152
+ if (isField && declaration.questionToken)
153
+ property.optional = true;
154
+ // A parameter property has its text in the constructor's `@param`, unless it carries a block of its own.
155
+ const description = readDescription(docs) ?? (ts.isParameter(docs) && ts.isIdentifier(docs.name) ? readParamDescriptions(docs.parent).get(docs.name.text) : undefined);
156
+ if (description)
157
+ property.description = description;
158
+ return property;
159
+ }
160
+ /**
161
+ * The signature of a method, or of a function such as a setup function, with
162
+ * the doc block read from `docs`: the declaration itself, the statement of a
163
+ * `const` arrow function, or a declaration it inherits the docs of.
164
+ */
165
+ export function extractMethod(name, declaration, docs, checker, types) {
166
+ const signature = checker.getSignatureFromDeclaration(declaration);
167
+ const returnType = signature ? checker.getReturnTypeOfSignature(signature) : checker.getTypeAtLocation(declaration);
168
+ const descriptions = readParamDescriptions(docs);
169
+ const result = {
170
+ name,
171
+ params: declaration.parameters.filter((param) => !isThisParameter(param)).map((param) => extractParam(name, param, descriptions, checker, types)),
172
+ returnType: types.ref(declaration.type, returnType, `returned by ${name}()`, { kind: 'return', method: name }),
173
+ tags: readDocTags(docs)
174
+ };
175
+ const description = readDescription(docs);
176
+ if (description)
177
+ result.description = description;
178
+ return result;
179
+ }
180
+ function extractParam(methodName, param, descriptions, checker, types) {
181
+ const name = ts.isIdentifier(param.name) ? param.name.text : collapseWhitespace(param.name.getText());
182
+ const result = {
183
+ name,
184
+ type: types.ref(param.type, checker.getTypeAtLocation(param), `parameter of ${methodName}()`, { kind: 'parameter', name, method: methodName }),
185
+ optional: !!(param.questionToken || param.initializer)
186
+ };
187
+ if (param.dotDotDotToken)
188
+ result.rest = true;
189
+ if (param.initializer)
190
+ result.defaultValue = collapseWhitespace(param.initializer.getText());
191
+ const description = descriptions.get(name);
192
+ if (description)
193
+ result.description = description;
194
+ return result;
195
+ }
196
+ /** The first parameter that is not `this`. */
197
+ export function firstParameter(declaration) {
198
+ return declaration.parameters.find((param) => !isThisParameter(param));
199
+ }
200
+ function isThisParameter(param) {
201
+ return ts.isIdentifier(param.name) && param.name.text === 'this';
202
+ }
203
+ /** `#private` and computed names have none: neither is part of the API a user reads. */
204
+ function getMemberName(member) {
205
+ if (!member.name)
206
+ return undefined;
207
+ if (ts.isIdentifier(member.name) || ts.isStringLiteral(member.name))
208
+ return member.name.text;
209
+ return undefined;
210
+ }
211
+ function hasModifier(node, kind) {
212
+ return ts.canHaveModifiers(node) && !!ts.getModifiers(node)?.some((modifier) => modifier.kind === kind);
213
+ }
214
+ export function collapseWhitespace(text) {
215
+ return text.replace(/\s+/g, ' ').trim();
216
+ }
@@ -0,0 +1,12 @@
1
+ import ts from 'typescript';
2
+ import type { PipeApi } from '../../../plugin/pipe.types.js';
3
+ import type { ExportIndex } from './export-index.js';
4
+ import type { SetupRef } from './setup.reader.js';
5
+ /**
6
+ * What the API page of a pipe shows: the description and tags of the class,
7
+ * the signatures of `transform()`, its setup functions and tokens with their
8
+ * config tables, and every documented type all of them reach. A template only
9
+ * calls `transform()`: no other member is read, and none adds a type.
10
+ */
11
+ export declare function extractPipeApi(classDecl: ts.ClassDeclaration, setupRefs: SetupRef[], checker: ts.TypeChecker, exportIndex: ExportIndex): PipeApi;
12
+ //# sourceMappingURL=pipe-api.extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe-api.extractor.d.ts","sourceRoot":"","sources":["../../../../src/builder/scanner/service/pipe-api.extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAI7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,OAAO,CAWhJ"}
@@ -0,0 +1,72 @@
1
+ import ts from 'typescript';
2
+ import { getClassChain } from '../class-hierarchy.js';
3
+ import { isDocumented, readDescription, readDocTags } from './doc-tags.js';
4
+ import { extractMethod } from './member.extractor.js';
5
+ import { describeSetupEntries } from './service-api.extractor.js';
6
+ import { createTypeCollector } from './type-collector.js';
7
+ /**
8
+ * What the API page of a pipe shows: the description and tags of the class,
9
+ * the signatures of `transform()`, its setup functions and tokens with their
10
+ * config tables, and every documented type all of them reach. A template only
11
+ * calls `transform()`: no other member is read, and none adds a type.
12
+ */
13
+ export function extractPipeApi(classDecl, setupRefs, checker, exportIndex) {
14
+ const collector = createTypeCollector(checker, exportIndex);
15
+ const transform = extractTransform(classDecl, checker, collector);
16
+ const setup = describeSetupEntries(setupRefs, checker, collector);
17
+ const api = { tags: readDocTags(classDecl), transform, setup, types: collector.drain() };
18
+ // The class's own block only: unlike a member, a pipe does not take the description of its base class.
19
+ const description = readDescription(classDecl);
20
+ if (description)
21
+ api.description = description;
22
+ return api;
23
+ }
24
+ /**
25
+ * The signatures of `transform()` in the nearest class that declares it,
26
+ * which may be a base class that only exists as a declaration, such as
27
+ * `DatePipe` in the .d.ts of `@angular/common`: its overload signatures, or
28
+ * the one declaration when there are none. The implementation of overloads is
29
+ * not one a template can call. In a .d.ts every declaration is a signature.
30
+ *
31
+ * A signature without a doc block of its own takes the one of the
32
+ * implementation, then of the first documented signature of the same class,
33
+ * then of the first documented `transform()` of the nearest base class that has one.
34
+ * The implementation and a base class document the method as a whole, so all
35
+ * of their block is taken. Another signature's block is about that signature:
36
+ * its description and `@param` texts are taken, its tags are not, since an
37
+ * overload marked `@deprecated` does not deprecate the one that replaces it.
38
+ */
39
+ function extractTransform(classDecl, checker, types) {
40
+ const levels = getClassChain(classDecl, checker).map(getTransformDeclarations);
41
+ const level = levels.findIndex((declarations) => declarations.length > 0);
42
+ if (level < 0)
43
+ return [];
44
+ const declarations = levels[level];
45
+ const signatures = declarations.filter((declaration) => !declaration.body);
46
+ const implementation = declarations.find((declaration) => declaration.body && isDocumented(declaration));
47
+ const sibling = signatures.find(isDocumented);
48
+ const fallback = implementation ?? sibling ?? findInheritedDocs(levels.slice(level + 1));
49
+ return (signatures.length > 0 ? signatures : declarations).map((signature) => {
50
+ const docs = isDocumented(signature) ? signature : (fallback ?? signature);
51
+ const method = extractMethod('transform', signature, docs, checker, types);
52
+ if (docs !== signature && docs === sibling)
53
+ method.tags = {};
54
+ return method;
55
+ });
56
+ }
57
+ /** The instance declarations of `transform()` in a class, in source order: the overload signatures and the implementation. */
58
+ function getTransformDeclarations(classDecl) {
59
+ return classDecl.members.filter((member) => ts.isMethodDeclaration(member) &&
60
+ (ts.isIdentifier(member.name) || ts.isStringLiteral(member.name)) &&
61
+ member.name.text === 'transform' &&
62
+ !ts.getModifiers(member)?.some((modifier) => modifier.kind === ts.SyntaxKind.StaticKeyword));
63
+ }
64
+ /** The first documented `transform()` declaration in the nearest of the given base classes that has one. */
65
+ function findInheritedDocs(levels) {
66
+ for (const declarations of levels) {
67
+ const documented = declarations.find(isDocumented);
68
+ if (documented)
69
+ return documented;
70
+ }
71
+ return undefined;
72
+ }
@@ -0,0 +1,14 @@
1
+ import ts from 'typescript';
2
+ import type { ApiSetupEntry, ServiceApi } from '../../../plugin/service.types.js';
3
+ import type { ExportIndex } from './export-index.js';
4
+ import { type SetupRef } from './setup.reader.js';
5
+ import { type TypeCollector } from './type-collector.js';
6
+ /**
7
+ * What the API page of a service shows: the description and tags of the
8
+ * class, its public members, its setup functions and tokens with their config
9
+ * tables, and every documented type all of them reach.
10
+ */
11
+ export declare function extractServiceApi(classDecl: ts.ClassDeclaration, setupRefs: SetupRef[], checker: ts.TypeChecker, exportIndex: ExportIndex): ServiceApi;
12
+ /** The setup functions and tokens of a service or a pipe, with their config tables; the types they reach go to `collector`. */
13
+ export declare function describeSetupEntries(setupRefs: SetupRef[], checker: ts.TypeChecker, collector: TypeCollector): ApiSetupEntry[];
14
+ //# sourceMappingURL=service-api.extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-api.extractor.d.ts","sourceRoot":"","sources":["../../../../src/builder/scanner/service/service-api.extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,KAAK,EAAe,aAAa,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAK9E;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,WAAW,GAAG,UAAU,CAUtJ;AAED,+HAA+H;AAC/H,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,aAAa,GAAG,aAAa,EAAE,CAE9H"}
@@ -0,0 +1,119 @@
1
+ import ts from 'typescript';
2
+ import { readDescription, readDocTags } from './doc-tags.js';
3
+ import { extractMembers, extractMethod, extractObjectTypeMembers, firstParameter } from './member.extractor.js';
4
+ import { skipParentheses } from './setup.reader.js';
5
+ import { createTypeCollector } from './type-collector.js';
6
+ /** The wrappers a config table looks through. */
7
+ const CONFIG_WRAPPERS = new Set(['Partial', 'Required', 'Readonly']);
8
+ /**
9
+ * What the API page of a service shows: the description and tags of the
10
+ * class, its public members, its setup functions and tokens with their config
11
+ * tables, and every documented type all of them reach.
12
+ */
13
+ export function extractServiceApi(classDecl, setupRefs, checker, exportIndex) {
14
+ const collector = createTypeCollector(checker, exportIndex);
15
+ const { properties, methods } = extractMembers(classDecl, checker, collector);
16
+ const setup = describeSetupEntries(setupRefs, checker, collector);
17
+ const api = { tags: readDocTags(classDecl), properties, methods, setup, types: collector.drain() };
18
+ const description = readDescription(classDecl);
19
+ if (description)
20
+ api.description = description;
21
+ return api;
22
+ }
23
+ /** The setup functions and tokens of a service or a pipe, with their config tables; the types they reach go to `collector`. */
24
+ export function describeSetupEntries(setupRefs, checker, collector) {
25
+ return setupRefs.map((ref) => (ref.kind === 'function' ? describeSetupFunction(ref, checker, collector) : describeSetupToken(ref, checker, collector)));
26
+ }
27
+ /** A setup function: its signature and docs, and the options of its first parameter when that is an object. */
28
+ function describeSetupFunction({ name, declaration, importPath }, checker, collector) {
29
+ const fn = ts.isFunctionDeclaration(declaration) ? declaration : skipParentheses(declaration.initializer);
30
+ const { params, returnType, description, tags } = extractMethod(name, fn, docNodeOf(declaration), checker, collector);
31
+ const entry = { name, kind: 'function', importPath, tags, params, returnType };
32
+ const param = firstParameter(fn);
33
+ const config = param && readConfig(param.type, checker.getTypeAtLocation(param), checker, collector.within(params[0].name));
34
+ if (description)
35
+ entry.description = description;
36
+ if (config)
37
+ entry.config = config;
38
+ return entry;
39
+ }
40
+ /** A token: `InjectionToken<T>` as written, and the options of `T` when that is an object. */
41
+ function describeSetupToken({ name, declaration, importPath }, checker, collector) {
42
+ // A token is always a `const`: the setup reader takes no other declaration for one.
43
+ const variable = declaration;
44
+ const typeNode = variable.type;
45
+ const type = checker.getTypeAtLocation(variable.name);
46
+ const docs = docNodeOf(variable);
47
+ const entry = {
48
+ name,
49
+ kind: 'token',
50
+ importPath,
51
+ tags: readDocTags(docs),
52
+ tokenType: collector.ref(typeNode, type, `type of ${name}`, { kind: 'property', name })
53
+ };
54
+ const argumentNode = typeNode && ts.isTypeReferenceNode(typeNode) ? typeNode.typeArguments?.[0] : undefined;
55
+ const argument = argumentNode ? checker.getTypeFromTypeNode(argumentNode) : isTypeReference(type) ? checker.getTypeArguments(type)[0] : undefined;
56
+ const config = argument && readConfig(argumentNode, argument, checker, collector.within(name));
57
+ const description = readDescription(docs);
58
+ if (description)
59
+ entry.description = description;
60
+ if (config)
61
+ entry.config = config;
62
+ return entry;
63
+ }
64
+ /** The doc block of a `const` sits on its statement, not on the declaration. */
65
+ function docNodeOf(declaration) {
66
+ return ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) ? declaration.parent.parent : declaration;
67
+ }
68
+ /**
69
+ * The options of a config object: the properties of an interface, an object
70
+ * literal type or an object type alias, looked for through `Partial`,
71
+ * `Required` and `Readonly`, which change what the options say. `undefined`
72
+ * for anything else, a class or an array or a primitive.
73
+ */
74
+ function readConfig(typeNode, type, checker, types) {
75
+ const wrappers = [];
76
+ let node = typeNode;
77
+ // The type as annotated: the parameter's own type has `undefined` in it when the parameter is optional.
78
+ let current = node ? checker.getTypeFromTypeNode(node) : checker.getNonNullableType(type);
79
+ // Through the annotation where there is one, through the alias the checker keeps otherwise.
80
+ for (;;) {
81
+ if (node && ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && CONFIG_WRAPPERS.has(node.typeName.text) && node.typeArguments?.length === 1) {
82
+ wrappers.push(node.typeName.text);
83
+ node = node.typeArguments[0];
84
+ current = checker.getTypeFromTypeNode(node);
85
+ }
86
+ else if (!node && current.aliasSymbol && CONFIG_WRAPPERS.has(current.aliasSymbol.name) && current.aliasTypeArguments?.length === 1) {
87
+ wrappers.push(current.aliasSymbol.name);
88
+ current = current.aliasTypeArguments[0];
89
+ }
90
+ else {
91
+ break;
92
+ }
93
+ }
94
+ if (!isConfigObject(current, checker))
95
+ return undefined;
96
+ const { properties } = extractObjectTypeMembers(current, checker, types);
97
+ // The innermost wrapper first: `Partial<Required<T>>` leaves every option optional.
98
+ for (const wrapper of wrappers.reverse())
99
+ properties.forEach((option) => applyWrapper(wrapper, option));
100
+ return properties.length > 0 ? properties : undefined;
101
+ }
102
+ function applyWrapper(wrapper, option) {
103
+ if (wrapper === 'Partial')
104
+ option.optional = true;
105
+ else if (wrapper === 'Required')
106
+ delete option.optional;
107
+ else
108
+ option.readonly = true;
109
+ }
110
+ function isConfigObject(type, checker) {
111
+ if (type.isIntersection())
112
+ return type.types.every((part) => isConfigObject(part, checker));
113
+ if (!(type.flags & ts.TypeFlags.Object) || type.objectFlags & ts.ObjectFlags.Class)
114
+ return false;
115
+ return !checker.isArrayType(type) && !checker.isTupleType(type) && type.getCallSignatures().length === 0;
116
+ }
117
+ function isTypeReference(type) {
118
+ return !!(type.flags & ts.TypeFlags.Object) && !!(type.objectFlags & ts.ObjectFlags.Reference);
119
+ }
@@ -0,0 +1,26 @@
1
+ import ts from 'typescript';
2
+ import type { ExportIndex } from './export-index.js';
3
+ /** One entry of a service's `setup`: what the styleguide shows to configure the service, and where to import it from. */
4
+ export interface SetupRef {
5
+ name: string;
6
+ kind: 'function' | 'token';
7
+ declaration: ts.FunctionDeclaration | ts.VariableDeclaration;
8
+ importPath: string;
9
+ }
10
+ /** Only the literal: a `setup` that arrives through a spread or a constant is not found, and dropped without a word. */
11
+ export declare function findSetupProperty(showcaseArg: ts.Expression): ts.ObjectLiteralElementLike | undefined;
12
+ /**
13
+ * Read the functions and tokens a service names in `setup: () => [provideToast, TOAST_LABELS]`.
14
+ *
15
+ * `setup` is an arrow function, not an array, so that the imports it refers to
16
+ * are only touched when it runs: a showcase file that imports from a module
17
+ * which imports the service back would otherwise hit the temporal dead zone.
18
+ * The scanner never runs it. It reads the array literal in the source and
19
+ * traces each element to its declaration, and to the entry point that exports it.
20
+ *
21
+ * What cannot be read is reported and dropped: a `setup` of another shape as a
22
+ * whole, any other entry on its own.
23
+ */
24
+ export declare function readSetupRefs(showcaseArg: ts.Expression, className: string, checker: ts.TypeChecker, exportIndex: ExportIndex, report: (message: string) => void): SetupRef[];
25
+ export declare function skipParentheses(expression: ts.Expression): ts.Expression;
26
+ //# sourceMappingURL=setup.reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.reader.d.ts","sourceRoot":"","sources":["../../../../src/builder/scanner/service/setup.reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,yHAAyH;AACzH,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;IAC3B,WAAW,EAAE,EAAE,CAAC,mBAAmB,GAAG,EAAE,CAAC,mBAAmB,CAAC;IAC7D,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,wHAAwH;AACxH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,wBAAwB,GAAG,SAAS,CAIrG;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CACzB,WAAW,EAAE,EAAE,CAAC,UAAU,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAClC,QAAQ,EAAE,CAkCZ;AAaD,wBAAgB,eAAe,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,UAAU,CAKxE"}
@@ -0,0 +1,89 @@
1
+ import ts from 'typescript';
2
+ import { describeInvalidSetup, describeSetupEntryNotExported, describeSetupEntryNotSupported } from '../showcase-diagnostics.js';
3
+ /** Only the literal: a `setup` that arrives through a spread or a constant is not found, and dropped without a word. */
4
+ export function findSetupProperty(showcaseArg) {
5
+ if (!ts.isObjectLiteralExpression(showcaseArg))
6
+ return undefined;
7
+ return showcaseArg.properties.find((p) => p.name !== undefined && (ts.isIdentifier(p.name) || ts.isStringLiteral(p.name)) && p.name.text === 'setup');
8
+ }
9
+ /**
10
+ * Read the functions and tokens a service names in `setup: () => [provideToast, TOAST_LABELS]`.
11
+ *
12
+ * `setup` is an arrow function, not an array, so that the imports it refers to
13
+ * are only touched when it runs: a showcase file that imports from a module
14
+ * which imports the service back would otherwise hit the temporal dead zone.
15
+ * The scanner never runs it. It reads the array literal in the source and
16
+ * traces each element to its declaration, and to the entry point that exports it.
17
+ *
18
+ * What cannot be read is reported and dropped: a `setup` of another shape as a
19
+ * whole, any other entry on its own.
20
+ */
21
+ export function readSetupRefs(showcaseArg, className, checker, exportIndex, report) {
22
+ const property = findSetupProperty(showcaseArg);
23
+ if (!property)
24
+ return [];
25
+ const array = ts.isPropertyAssignment(property) ? readSetupArray(property.initializer) : undefined;
26
+ if (!array) {
27
+ report(describeInvalidSetup(className, ts.isPropertyAssignment(property) ? property.initializer : property));
28
+ return [];
29
+ }
30
+ const refs = [];
31
+ array.elements.forEach((element, index) => {
32
+ const symbol = resolveEntry(element, checker);
33
+ const target = symbol && classifyEntry(symbol, checker);
34
+ if (!symbol || !target) {
35
+ report(describeSetupEntryNotSupported(className, index, element));
36
+ return;
37
+ }
38
+ const importPath = exportIndex.get(symbol);
39
+ if (importPath === undefined) {
40
+ report(describeSetupEntryNotExported(className, index, element));
41
+ return;
42
+ }
43
+ refs.push({ name: symbol.name, ...target, importPath });
44
+ });
45
+ return refs;
46
+ }
47
+ /** The array literal an arrow function returns, as an expression body or as the only statement of a block. */
48
+ function readSetupArray(initializer) {
49
+ if (!ts.isArrowFunction(initializer))
50
+ return undefined;
51
+ const { body } = initializer;
52
+ const returned = ts.isBlock(body) ? (body.statements.length === 1 && ts.isReturnStatement(body.statements[0]) ? body.statements[0].expression : undefined) : body;
53
+ const value = returned && skipParentheses(returned);
54
+ return value && ts.isArrayLiteralExpression(value) ? value : undefined;
55
+ }
56
+ export function skipParentheses(expression) {
57
+ let current = expression;
58
+ while (ts.isParenthesizedExpression(current))
59
+ current = current.expression;
60
+ return current;
61
+ }
62
+ /**
63
+ * The declaration symbol an entry refers to, with an import followed to its
64
+ * source: the symbol the export index holds. Only a name or a property access
65
+ * (`toasts.provideToast`) can refer to one; a call or a spread cannot.
66
+ */
67
+ function resolveEntry(element, checker) {
68
+ if (!ts.isIdentifier(element) && !ts.isPropertyAccessExpression(element))
69
+ return undefined;
70
+ const symbol = checker.getSymbolAtLocation(element);
71
+ if (!symbol)
72
+ return undefined;
73
+ // A declaration that is exported from its own file is a local symbol there, and the export symbol is the one that is indexed.
74
+ return checker.getExportSymbolOfSymbol(symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol);
75
+ }
76
+ function classifyEntry(symbol, checker) {
77
+ for (const declaration of symbol.declarations ?? []) {
78
+ if (ts.isFunctionDeclaration(declaration))
79
+ return { kind: 'function', declaration };
80
+ if (!ts.isVariableDeclaration(declaration) || !(ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const))
81
+ continue;
82
+ const initializer = declaration.initializer && skipParentheses(declaration.initializer);
83
+ if (initializer && (ts.isArrowFunction(initializer) || ts.isFunctionExpression(initializer)))
84
+ return { kind: 'function', declaration };
85
+ if (checker.getTypeAtLocation(declaration.name).getSymbol()?.name === 'InjectionToken')
86
+ return { kind: 'token', declaration };
87
+ }
88
+ return undefined;
89
+ }