@microsoft/api-extractor 7.56.3 → 7.57.1

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 (299) hide show
  1. package/CHANGELOG.json +58 -0
  2. package/CHANGELOG.md +15 -1
  3. package/bin/api-extractor +1 -1
  4. package/dist/tsdoc-metadata.json +1 -1
  5. package/lib-esm/aedoc/PackageDocComment.js +56 -0
  6. package/lib-esm/aedoc/PackageDocComment.js.map +1 -0
  7. package/lib-esm/analyzer/AstDeclaration.js +214 -0
  8. package/lib-esm/analyzer/AstDeclaration.js.map +1 -0
  9. package/lib-esm/analyzer/AstEntity.js +35 -0
  10. package/lib-esm/analyzer/AstEntity.js.map +1 -0
  11. package/lib-esm/analyzer/AstImport.js +76 -0
  12. package/lib-esm/analyzer/AstImport.js.map +1 -0
  13. package/lib-esm/analyzer/AstModule.js +22 -0
  14. package/lib-esm/analyzer/AstModule.js.map +1 -0
  15. package/lib-esm/analyzer/AstNamespaceExport.js +38 -0
  16. package/lib-esm/analyzer/AstNamespaceExport.js.map +1 -0
  17. package/lib-esm/analyzer/AstNamespaceImport.js +57 -0
  18. package/lib-esm/analyzer/AstNamespaceImport.js.map +1 -0
  19. package/lib-esm/analyzer/AstReferenceResolver.js +202 -0
  20. package/lib-esm/analyzer/AstReferenceResolver.js.map +1 -0
  21. package/lib-esm/analyzer/AstSymbol.js +104 -0
  22. package/lib-esm/analyzer/AstSymbol.js.map +1 -0
  23. package/lib-esm/analyzer/AstSymbolTable.js +524 -0
  24. package/lib-esm/analyzer/AstSymbolTable.js.map +1 -0
  25. package/lib-esm/analyzer/ExportAnalyzer.js +725 -0
  26. package/lib-esm/analyzer/ExportAnalyzer.js.map +1 -0
  27. package/lib-esm/analyzer/PackageMetadataManager.js +235 -0
  28. package/lib-esm/analyzer/PackageMetadataManager.js.map +1 -0
  29. package/lib-esm/analyzer/SourceFileLocationFormatter.js +44 -0
  30. package/lib-esm/analyzer/SourceFileLocationFormatter.js.map +1 -0
  31. package/lib-esm/analyzer/Span.js +545 -0
  32. package/lib-esm/analyzer/Span.js.map +1 -0
  33. package/lib-esm/analyzer/SyntaxHelpers.js +72 -0
  34. package/lib-esm/analyzer/SyntaxHelpers.js.map +1 -0
  35. package/lib-esm/analyzer/TypeScriptHelpers.js +242 -0
  36. package/lib-esm/analyzer/TypeScriptHelpers.js.map +1 -0
  37. package/lib-esm/analyzer/TypeScriptInternals.js +114 -0
  38. package/lib-esm/analyzer/TypeScriptInternals.js.map +1 -0
  39. package/lib-esm/api/CompilerState.js +149 -0
  40. package/lib-esm/api/CompilerState.js.map +1 -0
  41. package/lib-esm/api/ConsoleMessageId.js +82 -0
  42. package/lib-esm/api/ConsoleMessageId.js.map +1 -0
  43. package/lib-esm/api/Extractor.js +290 -0
  44. package/lib-esm/api/Extractor.js.map +1 -0
  45. package/lib-esm/api/ExtractorConfig.js +801 -0
  46. package/lib-esm/api/ExtractorConfig.js.map +1 -0
  47. package/lib-esm/api/ExtractorLogLevel.js +46 -0
  48. package/lib-esm/api/ExtractorLogLevel.js.map +1 -0
  49. package/lib-esm/api/ExtractorMessage.js +140 -0
  50. package/lib-esm/api/ExtractorMessage.js.map +1 -0
  51. package/lib-esm/api/ExtractorMessageId.js +128 -0
  52. package/lib-esm/api/ExtractorMessageId.js.map +1 -0
  53. package/lib-esm/api/IConfigFile.js +4 -0
  54. package/lib-esm/api/IConfigFile.js.map +1 -0
  55. package/lib-esm/cli/ApiExtractorCommandLine.js +51 -0
  56. package/lib-esm/cli/ApiExtractorCommandLine.js.map +1 -0
  57. package/lib-esm/cli/InitAction.js +35 -0
  58. package/lib-esm/cli/InitAction.js.map +1 -0
  59. package/lib-esm/cli/RunAction.js +123 -0
  60. package/lib-esm/cli/RunAction.js.map +1 -0
  61. package/lib-esm/collector/ApiItemMetadata.js +55 -0
  62. package/lib-esm/collector/ApiItemMetadata.js.map +1 -0
  63. package/lib-esm/collector/Collector.js +794 -0
  64. package/lib-esm/collector/Collector.js.map +1 -0
  65. package/lib-esm/collector/CollectorEntity.js +219 -0
  66. package/lib-esm/collector/CollectorEntity.js.map +1 -0
  67. package/lib-esm/collector/DeclarationMetadata.js +24 -0
  68. package/lib-esm/collector/DeclarationMetadata.js.map +1 -0
  69. package/lib-esm/collector/MessageRouter.js +476 -0
  70. package/lib-esm/collector/MessageRouter.js.map +1 -0
  71. package/lib-esm/collector/SourceMapper.js +171 -0
  72. package/lib-esm/collector/SourceMapper.js.map +1 -0
  73. package/lib-esm/collector/SymbolMetadata.js +12 -0
  74. package/lib-esm/collector/SymbolMetadata.js.map +1 -0
  75. package/lib-esm/collector/VisitorState.js +23 -0
  76. package/lib-esm/collector/VisitorState.js.map +1 -0
  77. package/lib-esm/collector/WorkingPackage.js +30 -0
  78. package/lib-esm/collector/WorkingPackage.js.map +1 -0
  79. package/lib-esm/enhancers/DocCommentEnhancer.js +213 -0
  80. package/lib-esm/enhancers/DocCommentEnhancer.js.map +1 -0
  81. package/lib-esm/enhancers/ValidationEnhancer.js +217 -0
  82. package/lib-esm/enhancers/ValidationEnhancer.js.map +1 -0
  83. package/lib-esm/generators/ApiModelGenerator.js +852 -0
  84. package/lib-esm/generators/ApiModelGenerator.js.map +1 -0
  85. package/lib-esm/generators/ApiReportGenerator.js +518 -0
  86. package/lib-esm/generators/ApiReportGenerator.js.map +1 -0
  87. package/lib-esm/generators/DeclarationReferenceGenerator.js +292 -0
  88. package/lib-esm/generators/DeclarationReferenceGenerator.js.map +1 -0
  89. package/lib-esm/generators/DtsEmitHelpers.js +227 -0
  90. package/lib-esm/generators/DtsEmitHelpers.js.map +1 -0
  91. package/lib-esm/generators/DtsRollupGenerator.js +391 -0
  92. package/lib-esm/generators/DtsRollupGenerator.js.map +1 -0
  93. package/lib-esm/generators/ExcerptBuilder.js +259 -0
  94. package/lib-esm/generators/ExcerptBuilder.js.map +1 -0
  95. package/lib-esm/generators/IndentedWriter.js +238 -0
  96. package/lib-esm/generators/IndentedWriter.js.map +1 -0
  97. package/lib-esm/index.js +17 -0
  98. package/lib-esm/index.js.map +1 -0
  99. package/lib-esm/schemas/api-extractor-defaults.json +94 -0
  100. package/lib-esm/schemas/api-extractor-template.json +454 -0
  101. package/lib-esm/schemas/api-extractor.schema.json +257 -0
  102. package/lib-esm/start.js +14 -0
  103. package/lib-esm/start.js.map +1 -0
  104. package/package.json +37 -9
  105. /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js +0 -0
  106. /package/{lib → lib-commonjs}/aedoc/PackageDocComment.js.map +0 -0
  107. /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js +0 -0
  108. /package/{lib → lib-commonjs}/analyzer/AstDeclaration.js.map +0 -0
  109. /package/{lib → lib-commonjs}/analyzer/AstEntity.js +0 -0
  110. /package/{lib → lib-commonjs}/analyzer/AstEntity.js.map +0 -0
  111. /package/{lib → lib-commonjs}/analyzer/AstImport.js +0 -0
  112. /package/{lib → lib-commonjs}/analyzer/AstImport.js.map +0 -0
  113. /package/{lib → lib-commonjs}/analyzer/AstModule.js +0 -0
  114. /package/{lib → lib-commonjs}/analyzer/AstModule.js.map +0 -0
  115. /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js +0 -0
  116. /package/{lib → lib-commonjs}/analyzer/AstNamespaceExport.js.map +0 -0
  117. /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js +0 -0
  118. /package/{lib → lib-commonjs}/analyzer/AstNamespaceImport.js.map +0 -0
  119. /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js +0 -0
  120. /package/{lib → lib-commonjs}/analyzer/AstReferenceResolver.js.map +0 -0
  121. /package/{lib → lib-commonjs}/analyzer/AstSymbol.js +0 -0
  122. /package/{lib → lib-commonjs}/analyzer/AstSymbol.js.map +0 -0
  123. /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js +0 -0
  124. /package/{lib → lib-commonjs}/analyzer/AstSymbolTable.js.map +0 -0
  125. /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js +0 -0
  126. /package/{lib → lib-commonjs}/analyzer/ExportAnalyzer.js.map +0 -0
  127. /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js +0 -0
  128. /package/{lib → lib-commonjs}/analyzer/PackageMetadataManager.js.map +0 -0
  129. /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js +0 -0
  130. /package/{lib → lib-commonjs}/analyzer/SourceFileLocationFormatter.js.map +0 -0
  131. /package/{lib → lib-commonjs}/analyzer/Span.js +0 -0
  132. /package/{lib → lib-commonjs}/analyzer/Span.js.map +0 -0
  133. /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js +0 -0
  134. /package/{lib → lib-commonjs}/analyzer/SyntaxHelpers.js.map +0 -0
  135. /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js +0 -0
  136. /package/{lib → lib-commonjs}/analyzer/TypeScriptHelpers.js.map +0 -0
  137. /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js +0 -0
  138. /package/{lib → lib-commonjs}/analyzer/TypeScriptInternals.js.map +0 -0
  139. /package/{lib → lib-commonjs}/api/CompilerState.js +0 -0
  140. /package/{lib → lib-commonjs}/api/CompilerState.js.map +0 -0
  141. /package/{lib → lib-commonjs}/api/ConsoleMessageId.js +0 -0
  142. /package/{lib → lib-commonjs}/api/ConsoleMessageId.js.map +0 -0
  143. /package/{lib → lib-commonjs}/api/Extractor.js +0 -0
  144. /package/{lib → lib-commonjs}/api/Extractor.js.map +0 -0
  145. /package/{lib → lib-commonjs}/api/ExtractorConfig.js +0 -0
  146. /package/{lib → lib-commonjs}/api/ExtractorConfig.js.map +0 -0
  147. /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js +0 -0
  148. /package/{lib → lib-commonjs}/api/ExtractorLogLevel.js.map +0 -0
  149. /package/{lib → lib-commonjs}/api/ExtractorMessage.js +0 -0
  150. /package/{lib → lib-commonjs}/api/ExtractorMessage.js.map +0 -0
  151. /package/{lib → lib-commonjs}/api/ExtractorMessageId.js +0 -0
  152. /package/{lib → lib-commonjs}/api/ExtractorMessageId.js.map +0 -0
  153. /package/{lib → lib-commonjs}/api/IConfigFile.js +0 -0
  154. /package/{lib → lib-commonjs}/api/IConfigFile.js.map +0 -0
  155. /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js +0 -0
  156. /package/{lib → lib-commonjs}/cli/ApiExtractorCommandLine.js.map +0 -0
  157. /package/{lib → lib-commonjs}/cli/InitAction.js +0 -0
  158. /package/{lib → lib-commonjs}/cli/InitAction.js.map +0 -0
  159. /package/{lib → lib-commonjs}/cli/RunAction.js +0 -0
  160. /package/{lib → lib-commonjs}/cli/RunAction.js.map +0 -0
  161. /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js +0 -0
  162. /package/{lib → lib-commonjs}/collector/ApiItemMetadata.js.map +0 -0
  163. /package/{lib → lib-commonjs}/collector/Collector.js +0 -0
  164. /package/{lib → lib-commonjs}/collector/Collector.js.map +0 -0
  165. /package/{lib → lib-commonjs}/collector/CollectorEntity.js +0 -0
  166. /package/{lib → lib-commonjs}/collector/CollectorEntity.js.map +0 -0
  167. /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js +0 -0
  168. /package/{lib → lib-commonjs}/collector/DeclarationMetadata.js.map +0 -0
  169. /package/{lib → lib-commonjs}/collector/MessageRouter.js +0 -0
  170. /package/{lib → lib-commonjs}/collector/MessageRouter.js.map +0 -0
  171. /package/{lib → lib-commonjs}/collector/SourceMapper.js +0 -0
  172. /package/{lib → lib-commonjs}/collector/SourceMapper.js.map +0 -0
  173. /package/{lib → lib-commonjs}/collector/SymbolMetadata.js +0 -0
  174. /package/{lib → lib-commonjs}/collector/SymbolMetadata.js.map +0 -0
  175. /package/{lib → lib-commonjs}/collector/VisitorState.js +0 -0
  176. /package/{lib → lib-commonjs}/collector/VisitorState.js.map +0 -0
  177. /package/{lib → lib-commonjs}/collector/WorkingPackage.js +0 -0
  178. /package/{lib → lib-commonjs}/collector/WorkingPackage.js.map +0 -0
  179. /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js +0 -0
  180. /package/{lib → lib-commonjs}/enhancers/DocCommentEnhancer.js.map +0 -0
  181. /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js +0 -0
  182. /package/{lib → lib-commonjs}/enhancers/ValidationEnhancer.js.map +0 -0
  183. /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js +0 -0
  184. /package/{lib → lib-commonjs}/generators/ApiModelGenerator.js.map +0 -0
  185. /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js +0 -0
  186. /package/{lib → lib-commonjs}/generators/ApiReportGenerator.js.map +0 -0
  187. /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js +0 -0
  188. /package/{lib → lib-commonjs}/generators/DeclarationReferenceGenerator.js.map +0 -0
  189. /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js +0 -0
  190. /package/{lib → lib-commonjs}/generators/DtsEmitHelpers.js.map +0 -0
  191. /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js +0 -0
  192. /package/{lib → lib-commonjs}/generators/DtsRollupGenerator.js.map +0 -0
  193. /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js +0 -0
  194. /package/{lib → lib-commonjs}/generators/ExcerptBuilder.js.map +0 -0
  195. /package/{lib → lib-commonjs}/generators/IndentedWriter.js +0 -0
  196. /package/{lib → lib-commonjs}/generators/IndentedWriter.js.map +0 -0
  197. /package/{lib → lib-commonjs}/index.js +0 -0
  198. /package/{lib → lib-commonjs}/index.js.map +0 -0
  199. /package/{lib → lib-commonjs}/schemas/api-extractor-defaults.json +0 -0
  200. /package/{lib → lib-commonjs}/schemas/api-extractor-template.json +0 -0
  201. /package/{lib → lib-commonjs}/schemas/api-extractor.schema.json +0 -0
  202. /package/{lib → lib-commonjs}/start.js +0 -0
  203. /package/{lib → lib-commonjs}/start.js.map +0 -0
  204. /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts +0 -0
  205. /package/{lib → lib-dts}/aedoc/PackageDocComment.d.ts.map +0 -0
  206. /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts +0 -0
  207. /package/{lib → lib-dts}/analyzer/AstDeclaration.d.ts.map +0 -0
  208. /package/{lib → lib-dts}/analyzer/AstEntity.d.ts +0 -0
  209. /package/{lib → lib-dts}/analyzer/AstEntity.d.ts.map +0 -0
  210. /package/{lib → lib-dts}/analyzer/AstImport.d.ts +0 -0
  211. /package/{lib → lib-dts}/analyzer/AstImport.d.ts.map +0 -0
  212. /package/{lib → lib-dts}/analyzer/AstModule.d.ts +0 -0
  213. /package/{lib → lib-dts}/analyzer/AstModule.d.ts.map +0 -0
  214. /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts +0 -0
  215. /package/{lib → lib-dts}/analyzer/AstNamespaceExport.d.ts.map +0 -0
  216. /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts +0 -0
  217. /package/{lib → lib-dts}/analyzer/AstNamespaceImport.d.ts.map +0 -0
  218. /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts +0 -0
  219. /package/{lib → lib-dts}/analyzer/AstReferenceResolver.d.ts.map +0 -0
  220. /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts +0 -0
  221. /package/{lib → lib-dts}/analyzer/AstSymbol.d.ts.map +0 -0
  222. /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts +0 -0
  223. /package/{lib → lib-dts}/analyzer/AstSymbolTable.d.ts.map +0 -0
  224. /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts +0 -0
  225. /package/{lib → lib-dts}/analyzer/ExportAnalyzer.d.ts.map +0 -0
  226. /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts +0 -0
  227. /package/{lib → lib-dts}/analyzer/PackageMetadataManager.d.ts.map +0 -0
  228. /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts +0 -0
  229. /package/{lib → lib-dts}/analyzer/SourceFileLocationFormatter.d.ts.map +0 -0
  230. /package/{lib → lib-dts}/analyzer/Span.d.ts +0 -0
  231. /package/{lib → lib-dts}/analyzer/Span.d.ts.map +0 -0
  232. /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts +0 -0
  233. /package/{lib → lib-dts}/analyzer/SyntaxHelpers.d.ts.map +0 -0
  234. /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts +0 -0
  235. /package/{lib → lib-dts}/analyzer/TypeScriptHelpers.d.ts.map +0 -0
  236. /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts +0 -0
  237. /package/{lib → lib-dts}/analyzer/TypeScriptInternals.d.ts.map +0 -0
  238. /package/{lib → lib-dts}/api/CompilerState.d.ts +0 -0
  239. /package/{lib → lib-dts}/api/CompilerState.d.ts.map +0 -0
  240. /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts +0 -0
  241. /package/{lib → lib-dts}/api/ConsoleMessageId.d.ts.map +0 -0
  242. /package/{lib → lib-dts}/api/Extractor.d.ts +0 -0
  243. /package/{lib → lib-dts}/api/Extractor.d.ts.map +0 -0
  244. /package/{lib → lib-dts}/api/ExtractorConfig.d.ts +0 -0
  245. /package/{lib → lib-dts}/api/ExtractorConfig.d.ts.map +0 -0
  246. /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts +0 -0
  247. /package/{lib → lib-dts}/api/ExtractorLogLevel.d.ts.map +0 -0
  248. /package/{lib → lib-dts}/api/ExtractorMessage.d.ts +0 -0
  249. /package/{lib → lib-dts}/api/ExtractorMessage.d.ts.map +0 -0
  250. /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts +0 -0
  251. /package/{lib → lib-dts}/api/ExtractorMessageId.d.ts.map +0 -0
  252. /package/{lib → lib-dts}/api/IConfigFile.d.ts +0 -0
  253. /package/{lib → lib-dts}/api/IConfigFile.d.ts.map +0 -0
  254. /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts +0 -0
  255. /package/{lib → lib-dts}/cli/ApiExtractorCommandLine.d.ts.map +0 -0
  256. /package/{lib → lib-dts}/cli/InitAction.d.ts +0 -0
  257. /package/{lib → lib-dts}/cli/InitAction.d.ts.map +0 -0
  258. /package/{lib → lib-dts}/cli/RunAction.d.ts +0 -0
  259. /package/{lib → lib-dts}/cli/RunAction.d.ts.map +0 -0
  260. /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts +0 -0
  261. /package/{lib → lib-dts}/collector/ApiItemMetadata.d.ts.map +0 -0
  262. /package/{lib → lib-dts}/collector/Collector.d.ts +0 -0
  263. /package/{lib → lib-dts}/collector/Collector.d.ts.map +0 -0
  264. /package/{lib → lib-dts}/collector/CollectorEntity.d.ts +0 -0
  265. /package/{lib → lib-dts}/collector/CollectorEntity.d.ts.map +0 -0
  266. /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts +0 -0
  267. /package/{lib → lib-dts}/collector/DeclarationMetadata.d.ts.map +0 -0
  268. /package/{lib → lib-dts}/collector/MessageRouter.d.ts +0 -0
  269. /package/{lib → lib-dts}/collector/MessageRouter.d.ts.map +0 -0
  270. /package/{lib → lib-dts}/collector/SourceMapper.d.ts +0 -0
  271. /package/{lib → lib-dts}/collector/SourceMapper.d.ts.map +0 -0
  272. /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts +0 -0
  273. /package/{lib → lib-dts}/collector/SymbolMetadata.d.ts.map +0 -0
  274. /package/{lib → lib-dts}/collector/VisitorState.d.ts +0 -0
  275. /package/{lib → lib-dts}/collector/VisitorState.d.ts.map +0 -0
  276. /package/{lib → lib-dts}/collector/WorkingPackage.d.ts +0 -0
  277. /package/{lib → lib-dts}/collector/WorkingPackage.d.ts.map +0 -0
  278. /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts +0 -0
  279. /package/{lib → lib-dts}/enhancers/DocCommentEnhancer.d.ts.map +0 -0
  280. /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts +0 -0
  281. /package/{lib → lib-dts}/enhancers/ValidationEnhancer.d.ts.map +0 -0
  282. /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts +0 -0
  283. /package/{lib → lib-dts}/generators/ApiModelGenerator.d.ts.map +0 -0
  284. /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts +0 -0
  285. /package/{lib → lib-dts}/generators/ApiReportGenerator.d.ts.map +0 -0
  286. /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts +0 -0
  287. /package/{lib → lib-dts}/generators/DeclarationReferenceGenerator.d.ts.map +0 -0
  288. /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts +0 -0
  289. /package/{lib → lib-dts}/generators/DtsEmitHelpers.d.ts.map +0 -0
  290. /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts +0 -0
  291. /package/{lib → lib-dts}/generators/DtsRollupGenerator.d.ts.map +0 -0
  292. /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts +0 -0
  293. /package/{lib → lib-dts}/generators/ExcerptBuilder.d.ts.map +0 -0
  294. /package/{lib → lib-dts}/generators/IndentedWriter.d.ts +0 -0
  295. /package/{lib → lib-dts}/generators/IndentedWriter.d.ts.map +0 -0
  296. /package/{lib → lib-dts}/index.d.ts +0 -0
  297. /package/{lib → lib-dts}/index.d.ts.map +0 -0
  298. /package/{lib → lib-dts}/start.d.ts +0 -0
  299. /package/{lib → lib-dts}/start.d.ts.map +0 -0
@@ -0,0 +1,852 @@
1
+ // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
2
+ // See LICENSE in the project root for license information.
3
+ /* eslint-disable no-bitwise */
4
+ import * as path from 'node:path';
5
+ import * as ts from 'typescript';
6
+ import { ApiModel, ApiClass, ApiPackage, ApiEntryPoint, ApiMethod, ApiNamespace, ApiInterface, ApiPropertySignature, ReleaseTag, ApiProperty, ApiMethodSignature, ApiEnum, ApiEnumMember, ApiConstructor, ApiConstructSignature, ApiFunction, ApiIndexSignature, ApiVariable, ApiTypeAlias, ApiCallSignature, EnumMemberOrder } from '@microsoft/api-extractor-model';
7
+ import { Path } from '@rushstack/node-core-library';
8
+ import { ExcerptBuilder } from './ExcerptBuilder';
9
+ import { AstSymbol } from '../analyzer/AstSymbol';
10
+ import { DeclarationReferenceGenerator } from './DeclarationReferenceGenerator';
11
+ import { AstNamespaceImport } from '../analyzer/AstNamespaceImport';
12
+ import { TypeScriptInternals } from '../analyzer/TypeScriptInternals';
13
+ import { DtsEmitHelpers } from './DtsEmitHelpers';
14
+ export class ApiModelGenerator {
15
+ constructor(collector, extractorConfig) {
16
+ this._collector = collector;
17
+ this._apiModel = new ApiModel();
18
+ this._referenceGenerator = new DeclarationReferenceGenerator(collector);
19
+ const apiModelGenerationOptions = extractorConfig.docModelGenerationOptions;
20
+ if (apiModelGenerationOptions) {
21
+ this._releaseTagsToTrim = apiModelGenerationOptions.releaseTagsToTrim;
22
+ this.docModelEnabled = true;
23
+ }
24
+ else {
25
+ this.docModelEnabled = false;
26
+ }
27
+ }
28
+ get apiModel() {
29
+ return this._apiModel;
30
+ }
31
+ buildApiPackage() {
32
+ const packageDocComment = this._collector.workingPackage.tsdocComment;
33
+ const apiPackage = new ApiPackage({
34
+ name: this._collector.workingPackage.name,
35
+ docComment: packageDocComment,
36
+ tsdocConfiguration: this._collector.extractorConfig.tsdocConfiguration,
37
+ projectFolderUrl: this._collector.extractorConfig.projectFolderUrl
38
+ });
39
+ this._apiModel.addMember(apiPackage);
40
+ const apiEntryPoint = new ApiEntryPoint({ name: '' });
41
+ apiPackage.addMember(apiEntryPoint);
42
+ for (const entity of this._collector.entities) {
43
+ // Only process entities that are exported from the entry point. Entities that are exported from
44
+ // `AstNamespaceImport` entities will be processed by `_processAstNamespaceImport`. However, if
45
+ // we are including forgotten exports, then process everything.
46
+ if (entity.exportedFromEntryPoint || this._collector.extractorConfig.docModelIncludeForgottenExports) {
47
+ this._processAstEntity(entity.astEntity, {
48
+ name: entity.nameForEmit,
49
+ isExported: entity.exportedFromEntryPoint,
50
+ parentApiItem: apiEntryPoint
51
+ });
52
+ }
53
+ }
54
+ return apiPackage;
55
+ }
56
+ _processAstEntity(astEntity, context) {
57
+ if (astEntity instanceof AstSymbol) {
58
+ // Skip ancillary declarations; we will process them with the main declaration
59
+ for (const astDeclaration of this._collector.getNonAncillaryDeclarations(astEntity)) {
60
+ this._processDeclaration(astDeclaration, context);
61
+ }
62
+ return;
63
+ }
64
+ if (astEntity instanceof AstNamespaceImport) {
65
+ // Note that a single API item can belong to two different AstNamespaceImport namespaces. For example:
66
+ //
67
+ // // file.ts defines "thing()"
68
+ // import * as example1 from "./file";
69
+ // import * as example2 from "./file";
70
+ //
71
+ // // ...so here we end up with example1.thing() and example2.thing()
72
+ // export { example1, example2 }
73
+ //
74
+ // The current logic does not try to associate "thing()" with a specific parent. Instead
75
+ // the API documentation will show duplicated entries for example1.thing() and example2.thing().
76
+ //
77
+ // This could be improved in the future, but it requires a stable mechanism for choosing an associated parent.
78
+ // For thoughts about this: https://github.com/microsoft/rushstack/issues/1308
79
+ this._processAstNamespaceImport(astEntity, context);
80
+ return;
81
+ }
82
+ // TODO: Figure out how to represent reexported AstImport objects. Basically we need to introduce a new
83
+ // ApiItem subclass for "export alias", similar to a type alias, but representing declarations of the
84
+ // form "export { X } from 'external-package'". We can also use this to solve GitHub issue #950.
85
+ }
86
+ _processAstNamespaceImport(astNamespaceImport, context) {
87
+ const astModule = astNamespaceImport.astModule;
88
+ const { name, isExported, parentApiItem } = context;
89
+ const containerKey = ApiNamespace.getContainerKey(name);
90
+ const fileUrlPath = this._getFileUrlPath(astNamespaceImport.declaration);
91
+ let apiNamespace = parentApiItem.tryGetMemberByKey(containerKey);
92
+ if (apiNamespace === undefined) {
93
+ apiNamespace = new ApiNamespace({
94
+ name,
95
+ docComment: undefined,
96
+ releaseTag: ReleaseTag.None,
97
+ excerptTokens: [],
98
+ isExported,
99
+ fileUrlPath
100
+ });
101
+ parentApiItem.addMember(apiNamespace);
102
+ }
103
+ astModule.astModuleExportInfo.exportedLocalEntities.forEach((exportedEntity, exportedName) => {
104
+ this._processAstEntity(exportedEntity, {
105
+ name: exportedName,
106
+ isExported: true,
107
+ parentApiItem: apiNamespace
108
+ });
109
+ });
110
+ }
111
+ _processDeclaration(astDeclaration, context) {
112
+ var _a;
113
+ if ((astDeclaration.modifierFlags & ts.ModifierFlags.Private) !== 0) {
114
+ return; // trim out private declarations
115
+ }
116
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
117
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
118
+ if ((_a = this._releaseTagsToTrim) === null || _a === void 0 ? void 0 : _a.has(releaseTag)) {
119
+ return;
120
+ }
121
+ switch (astDeclaration.declaration.kind) {
122
+ case ts.SyntaxKind.CallSignature:
123
+ this._processApiCallSignature(astDeclaration, context);
124
+ break;
125
+ case ts.SyntaxKind.Constructor:
126
+ this._processApiConstructor(astDeclaration, context);
127
+ break;
128
+ case ts.SyntaxKind.ConstructSignature:
129
+ this._processApiConstructSignature(astDeclaration, context);
130
+ break;
131
+ case ts.SyntaxKind.ClassDeclaration:
132
+ this._processApiClass(astDeclaration, context);
133
+ break;
134
+ case ts.SyntaxKind.EnumDeclaration:
135
+ this._processApiEnum(astDeclaration, context);
136
+ break;
137
+ case ts.SyntaxKind.EnumMember:
138
+ this._processApiEnumMember(astDeclaration, context);
139
+ break;
140
+ case ts.SyntaxKind.FunctionDeclaration:
141
+ this._processApiFunction(astDeclaration, context);
142
+ break;
143
+ case ts.SyntaxKind.GetAccessor:
144
+ this._processApiProperty(astDeclaration, context);
145
+ break;
146
+ case ts.SyntaxKind.SetAccessor:
147
+ this._processApiProperty(astDeclaration, context);
148
+ break;
149
+ case ts.SyntaxKind.IndexSignature:
150
+ this._processApiIndexSignature(astDeclaration, context);
151
+ break;
152
+ case ts.SyntaxKind.InterfaceDeclaration:
153
+ this._processApiInterface(astDeclaration, context);
154
+ break;
155
+ case ts.SyntaxKind.MethodDeclaration:
156
+ this._processApiMethod(astDeclaration, context);
157
+ break;
158
+ case ts.SyntaxKind.MethodSignature:
159
+ this._processApiMethodSignature(astDeclaration, context);
160
+ break;
161
+ case ts.SyntaxKind.ModuleDeclaration:
162
+ this._processApiNamespace(astDeclaration, context);
163
+ break;
164
+ case ts.SyntaxKind.PropertyDeclaration:
165
+ this._processApiProperty(astDeclaration, context);
166
+ break;
167
+ case ts.SyntaxKind.PropertySignature:
168
+ this._processApiPropertySignature(astDeclaration, context);
169
+ break;
170
+ case ts.SyntaxKind.TypeAliasDeclaration:
171
+ this._processApiTypeAlias(astDeclaration, context);
172
+ break;
173
+ case ts.SyntaxKind.VariableDeclaration:
174
+ // check for arrow functions in variable declaration
175
+ const functionDeclaration = this._tryFindFunctionDeclaration(astDeclaration);
176
+ if (functionDeclaration) {
177
+ this._processApiFunction(astDeclaration, context, functionDeclaration);
178
+ }
179
+ else {
180
+ this._processApiVariable(astDeclaration, context);
181
+ }
182
+ break;
183
+ default:
184
+ // ignore unknown types
185
+ }
186
+ }
187
+ _tryFindFunctionDeclaration(astDeclaration) {
188
+ const children = astDeclaration.declaration.getChildren(astDeclaration.declaration.getSourceFile());
189
+ return children.find(ts.isFunctionTypeNode);
190
+ }
191
+ _processChildDeclarations(astDeclaration, context) {
192
+ for (const childDeclaration of astDeclaration.children) {
193
+ this._processDeclaration(childDeclaration, {
194
+ ...context,
195
+ name: childDeclaration.astSymbol.localName
196
+ });
197
+ }
198
+ }
199
+ _processApiCallSignature(astDeclaration, context) {
200
+ const { parentApiItem } = context;
201
+ const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
202
+ const containerKey = ApiCallSignature.getContainerKey(overloadIndex);
203
+ let apiCallSignature = parentApiItem.tryGetMemberByKey(containerKey);
204
+ if (apiCallSignature === undefined) {
205
+ const callSignature = astDeclaration.declaration;
206
+ const nodeTransforms = [];
207
+ const returnTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
208
+ if (callSignature.type) {
209
+ nodeTransforms.push({ node: callSignature.type, captureTokenRange: returnTypeTokenRange });
210
+ }
211
+ const typeParameters = this._captureTypeParameters(nodeTransforms, callSignature.typeParameters);
212
+ const parameters = this._captureParameters(nodeTransforms, callSignature.parameters);
213
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
214
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
215
+ const docComment = apiItemMetadata.tsdocComment;
216
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
217
+ const fileUrlPath = this._getFileUrlPath(callSignature);
218
+ apiCallSignature = new ApiCallSignature({
219
+ docComment,
220
+ releaseTag,
221
+ typeParameters,
222
+ parameters,
223
+ overloadIndex,
224
+ excerptTokens,
225
+ returnTypeTokenRange,
226
+ fileUrlPath
227
+ });
228
+ parentApiItem.addMember(apiCallSignature);
229
+ }
230
+ }
231
+ _processApiConstructor(astDeclaration, context) {
232
+ const { parentApiItem } = context;
233
+ const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
234
+ const containerKey = ApiConstructor.getContainerKey(overloadIndex);
235
+ let apiConstructor = parentApiItem.tryGetMemberByKey(containerKey);
236
+ if (apiConstructor === undefined) {
237
+ const constructorDeclaration = astDeclaration.declaration;
238
+ const nodeTransforms = [];
239
+ const parameters = this._captureParameters(nodeTransforms, constructorDeclaration.parameters);
240
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
241
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
242
+ const docComment = apiItemMetadata.tsdocComment;
243
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
244
+ const isProtected = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
245
+ const fileUrlPath = this._getFileUrlPath(constructorDeclaration);
246
+ apiConstructor = new ApiConstructor({
247
+ docComment,
248
+ releaseTag,
249
+ isProtected,
250
+ parameters,
251
+ overloadIndex,
252
+ excerptTokens,
253
+ fileUrlPath
254
+ });
255
+ parentApiItem.addMember(apiConstructor);
256
+ }
257
+ }
258
+ _processApiClass(astDeclaration, context) {
259
+ const { name, isExported, parentApiItem } = context;
260
+ const containerKey = ApiClass.getContainerKey(name);
261
+ let apiClass = parentApiItem.tryGetMemberByKey(containerKey);
262
+ if (apiClass === undefined) {
263
+ const classDeclaration = astDeclaration.declaration;
264
+ const nodeTransforms = [];
265
+ const typeParameters = this._captureTypeParameters(nodeTransforms, classDeclaration.typeParameters);
266
+ let extendsTokenRange = undefined;
267
+ const implementsTokenRanges = [];
268
+ for (const heritageClause of classDeclaration.heritageClauses || []) {
269
+ if (heritageClause.token === ts.SyntaxKind.ExtendsKeyword) {
270
+ extendsTokenRange = ExcerptBuilder.createEmptyTokenRange();
271
+ if (heritageClause.types.length > 0) {
272
+ nodeTransforms.push({ node: heritageClause.types[0], captureTokenRange: extendsTokenRange });
273
+ }
274
+ }
275
+ else if (heritageClause.token === ts.SyntaxKind.ImplementsKeyword) {
276
+ for (const heritageType of heritageClause.types) {
277
+ const implementsTokenRange = ExcerptBuilder.createEmptyTokenRange();
278
+ implementsTokenRanges.push(implementsTokenRange);
279
+ nodeTransforms.push({ node: heritageType, captureTokenRange: implementsTokenRange });
280
+ }
281
+ }
282
+ }
283
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
284
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
285
+ const docComment = apiItemMetadata.tsdocComment;
286
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
287
+ const isAbstract = (ts.getCombinedModifierFlags(classDeclaration) & ts.ModifierFlags.Abstract) !== 0;
288
+ const fileUrlPath = this._getFileUrlPath(classDeclaration);
289
+ apiClass = new ApiClass({
290
+ name,
291
+ isAbstract,
292
+ docComment,
293
+ releaseTag,
294
+ excerptTokens,
295
+ typeParameters,
296
+ extendsTokenRange,
297
+ implementsTokenRanges,
298
+ isExported,
299
+ fileUrlPath
300
+ });
301
+ parentApiItem.addMember(apiClass);
302
+ }
303
+ this._processChildDeclarations(astDeclaration, {
304
+ ...context,
305
+ parentApiItem: apiClass
306
+ });
307
+ }
308
+ _processApiConstructSignature(astDeclaration, context) {
309
+ const { parentApiItem } = context;
310
+ const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
311
+ const containerKey = ApiConstructSignature.getContainerKey(overloadIndex);
312
+ let apiConstructSignature = parentApiItem.tryGetMemberByKey(containerKey);
313
+ if (apiConstructSignature === undefined) {
314
+ const constructSignature = astDeclaration.declaration;
315
+ const nodeTransforms = [];
316
+ const returnTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
317
+ if (constructSignature.type) {
318
+ nodeTransforms.push({ node: constructSignature.type, captureTokenRange: returnTypeTokenRange });
319
+ }
320
+ const typeParameters = this._captureTypeParameters(nodeTransforms, constructSignature.typeParameters);
321
+ const parameters = this._captureParameters(nodeTransforms, constructSignature.parameters);
322
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
323
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
324
+ const docComment = apiItemMetadata.tsdocComment;
325
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
326
+ const fileUrlPath = this._getFileUrlPath(constructSignature);
327
+ apiConstructSignature = new ApiConstructSignature({
328
+ docComment,
329
+ releaseTag,
330
+ typeParameters,
331
+ parameters,
332
+ overloadIndex,
333
+ excerptTokens,
334
+ returnTypeTokenRange,
335
+ fileUrlPath
336
+ });
337
+ parentApiItem.addMember(apiConstructSignature);
338
+ }
339
+ }
340
+ _processApiEnum(astDeclaration, context) {
341
+ const { name, isExported, parentApiItem } = context;
342
+ const containerKey = ApiEnum.getContainerKey(name);
343
+ let apiEnum = parentApiItem.tryGetMemberByKey(containerKey);
344
+ if (apiEnum === undefined) {
345
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, []);
346
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
347
+ const docComment = apiItemMetadata.tsdocComment;
348
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
349
+ const preserveMemberOrder = this._collector.extractorConfig.enumMemberOrder === EnumMemberOrder.Preserve;
350
+ const fileUrlPath = this._getFileUrlPath(astDeclaration.declaration);
351
+ apiEnum = new ApiEnum({
352
+ name,
353
+ docComment,
354
+ releaseTag,
355
+ excerptTokens,
356
+ preserveMemberOrder,
357
+ isExported,
358
+ fileUrlPath
359
+ });
360
+ parentApiItem.addMember(apiEnum);
361
+ }
362
+ this._processChildDeclarations(astDeclaration, {
363
+ ...context,
364
+ parentApiItem: apiEnum
365
+ });
366
+ }
367
+ _processApiEnumMember(astDeclaration, context) {
368
+ const { name, parentApiItem } = context;
369
+ const containerKey = ApiEnumMember.getContainerKey(name);
370
+ let apiEnumMember = parentApiItem.tryGetMemberByKey(containerKey);
371
+ if (apiEnumMember === undefined) {
372
+ const enumMember = astDeclaration.declaration;
373
+ const nodeTransforms = [];
374
+ let initializerTokenRange = undefined;
375
+ if (enumMember.initializer) {
376
+ initializerTokenRange = ExcerptBuilder.createEmptyTokenRange();
377
+ nodeTransforms.push({ node: enumMember.initializer, captureTokenRange: initializerTokenRange });
378
+ }
379
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
380
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
381
+ const docComment = apiItemMetadata.tsdocComment;
382
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
383
+ const fileUrlPath = this._getFileUrlPath(enumMember);
384
+ apiEnumMember = new ApiEnumMember({
385
+ name,
386
+ docComment,
387
+ releaseTag,
388
+ excerptTokens,
389
+ initializerTokenRange,
390
+ fileUrlPath
391
+ });
392
+ parentApiItem.addMember(apiEnumMember);
393
+ }
394
+ }
395
+ _processApiFunction(astDeclaration, context, altFunctionDeclaration) {
396
+ const { name, isExported, parentApiItem } = context;
397
+ const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
398
+ const containerKey = ApiFunction.getContainerKey(name, overloadIndex);
399
+ let apiFunction = parentApiItem.tryGetMemberByKey(containerKey);
400
+ if (apiFunction === undefined) {
401
+ const functionDeclaration = altFunctionDeclaration !== null && altFunctionDeclaration !== void 0 ? altFunctionDeclaration : astDeclaration.declaration;
402
+ const nodeTransforms = [];
403
+ const returnTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
404
+ if (functionDeclaration.type) {
405
+ nodeTransforms.push({ node: functionDeclaration.type, captureTokenRange: returnTypeTokenRange });
406
+ }
407
+ const typeParameters = this._captureTypeParameters(nodeTransforms, functionDeclaration.typeParameters);
408
+ const parameters = this._captureParameters(nodeTransforms, functionDeclaration.parameters);
409
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
410
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
411
+ const docComment = apiItemMetadata.tsdocComment;
412
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
413
+ const fileUrlPath = this._getFileUrlPath(functionDeclaration);
414
+ apiFunction = new ApiFunction({
415
+ name,
416
+ docComment,
417
+ releaseTag,
418
+ typeParameters,
419
+ parameters,
420
+ overloadIndex,
421
+ excerptTokens,
422
+ returnTypeTokenRange,
423
+ isExported,
424
+ fileUrlPath
425
+ });
426
+ parentApiItem.addMember(apiFunction);
427
+ }
428
+ }
429
+ _processApiIndexSignature(astDeclaration, context) {
430
+ const { parentApiItem } = context;
431
+ const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
432
+ const containerKey = ApiIndexSignature.getContainerKey(overloadIndex);
433
+ let apiIndexSignature = parentApiItem.tryGetMemberByKey(containerKey);
434
+ if (apiIndexSignature === undefined) {
435
+ const indexSignature = astDeclaration.declaration;
436
+ const nodeTransforms = [];
437
+ const returnTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
438
+ nodeTransforms.push({ node: indexSignature.type, captureTokenRange: returnTypeTokenRange });
439
+ const parameters = this._captureParameters(nodeTransforms, indexSignature.parameters);
440
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
441
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
442
+ const docComment = apiItemMetadata.tsdocComment;
443
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
444
+ const isReadonly = this._isReadonly(astDeclaration);
445
+ const fileUrlPath = this._getFileUrlPath(indexSignature);
446
+ apiIndexSignature = new ApiIndexSignature({
447
+ docComment,
448
+ releaseTag,
449
+ parameters,
450
+ overloadIndex,
451
+ excerptTokens,
452
+ returnTypeTokenRange,
453
+ isReadonly,
454
+ fileUrlPath
455
+ });
456
+ parentApiItem.addMember(apiIndexSignature);
457
+ }
458
+ }
459
+ _processApiInterface(astDeclaration, context) {
460
+ const { name, isExported, parentApiItem } = context;
461
+ const containerKey = ApiInterface.getContainerKey(name);
462
+ let apiInterface = parentApiItem.tryGetMemberByKey(containerKey);
463
+ if (apiInterface === undefined) {
464
+ const interfaceDeclaration = astDeclaration.declaration;
465
+ const nodeTransforms = [];
466
+ const typeParameters = this._captureTypeParameters(nodeTransforms, interfaceDeclaration.typeParameters);
467
+ const extendsTokenRanges = [];
468
+ for (const heritageClause of interfaceDeclaration.heritageClauses || []) {
469
+ if (heritageClause.token === ts.SyntaxKind.ExtendsKeyword) {
470
+ for (const heritageType of heritageClause.types) {
471
+ const extendsTokenRange = ExcerptBuilder.createEmptyTokenRange();
472
+ extendsTokenRanges.push(extendsTokenRange);
473
+ nodeTransforms.push({ node: heritageType, captureTokenRange: extendsTokenRange });
474
+ }
475
+ }
476
+ }
477
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
478
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
479
+ const docComment = apiItemMetadata.tsdocComment;
480
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
481
+ const fileUrlPath = this._getFileUrlPath(interfaceDeclaration);
482
+ apiInterface = new ApiInterface({
483
+ name,
484
+ docComment,
485
+ releaseTag,
486
+ excerptTokens,
487
+ typeParameters,
488
+ extendsTokenRanges,
489
+ isExported,
490
+ fileUrlPath
491
+ });
492
+ parentApiItem.addMember(apiInterface);
493
+ }
494
+ this._processChildDeclarations(astDeclaration, {
495
+ ...context,
496
+ parentApiItem: apiInterface
497
+ });
498
+ }
499
+ _processApiMethod(astDeclaration, context) {
500
+ const { name, parentApiItem } = context;
501
+ const isStatic = (astDeclaration.modifierFlags & ts.ModifierFlags.Static) !== 0;
502
+ const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
503
+ const containerKey = ApiMethod.getContainerKey(name, isStatic, overloadIndex);
504
+ let apiMethod = parentApiItem.tryGetMemberByKey(containerKey);
505
+ if (apiMethod === undefined) {
506
+ const methodDeclaration = astDeclaration.declaration;
507
+ const nodeTransforms = [];
508
+ const returnTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
509
+ if (methodDeclaration.type) {
510
+ nodeTransforms.push({ node: methodDeclaration.type, captureTokenRange: returnTypeTokenRange });
511
+ }
512
+ const typeParameters = this._captureTypeParameters(nodeTransforms, methodDeclaration.typeParameters);
513
+ const parameters = this._captureParameters(nodeTransforms, methodDeclaration.parameters);
514
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
515
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
516
+ const docComment = apiItemMetadata.tsdocComment;
517
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
518
+ if (releaseTag === ReleaseTag.Internal || releaseTag === ReleaseTag.Alpha) {
519
+ return; // trim out items marked as "@internal" or "@alpha"
520
+ }
521
+ const isOptional = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
522
+ const isProtected = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
523
+ const isAbstract = (astDeclaration.modifierFlags & ts.ModifierFlags.Abstract) !== 0;
524
+ const fileUrlPath = this._getFileUrlPath(methodDeclaration);
525
+ apiMethod = new ApiMethod({
526
+ name,
527
+ isAbstract,
528
+ docComment,
529
+ releaseTag,
530
+ isProtected,
531
+ isStatic,
532
+ isOptional,
533
+ typeParameters,
534
+ parameters,
535
+ overloadIndex,
536
+ excerptTokens,
537
+ returnTypeTokenRange,
538
+ fileUrlPath
539
+ });
540
+ parentApiItem.addMember(apiMethod);
541
+ }
542
+ }
543
+ _processApiMethodSignature(astDeclaration, context) {
544
+ const { name, parentApiItem } = context;
545
+ const overloadIndex = this._collector.getOverloadIndex(astDeclaration);
546
+ const containerKey = ApiMethodSignature.getContainerKey(name, overloadIndex);
547
+ let apiMethodSignature = parentApiItem.tryGetMemberByKey(containerKey);
548
+ if (apiMethodSignature === undefined) {
549
+ const methodSignature = astDeclaration.declaration;
550
+ const nodeTransforms = [];
551
+ const returnTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
552
+ if (methodSignature.type) {
553
+ nodeTransforms.push({ node: methodSignature.type, captureTokenRange: returnTypeTokenRange });
554
+ }
555
+ const typeParameters = this._captureTypeParameters(nodeTransforms, methodSignature.typeParameters);
556
+ const parameters = this._captureParameters(nodeTransforms, methodSignature.parameters);
557
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
558
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
559
+ const docComment = apiItemMetadata.tsdocComment;
560
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
561
+ const isOptional = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
562
+ const fileUrlPath = this._getFileUrlPath(methodSignature);
563
+ apiMethodSignature = new ApiMethodSignature({
564
+ name,
565
+ docComment,
566
+ releaseTag,
567
+ isOptional,
568
+ typeParameters,
569
+ parameters,
570
+ overloadIndex,
571
+ excerptTokens,
572
+ returnTypeTokenRange,
573
+ fileUrlPath
574
+ });
575
+ parentApiItem.addMember(apiMethodSignature);
576
+ }
577
+ }
578
+ _processApiNamespace(astDeclaration, context) {
579
+ const { name, isExported, parentApiItem } = context;
580
+ const containerKey = ApiNamespace.getContainerKey(name);
581
+ let apiNamespace = parentApiItem.tryGetMemberByKey(containerKey);
582
+ if (apiNamespace === undefined) {
583
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, []);
584
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
585
+ const docComment = apiItemMetadata.tsdocComment;
586
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
587
+ const fileUrlPath = this._getFileUrlPath(astDeclaration.declaration);
588
+ apiNamespace = new ApiNamespace({
589
+ name,
590
+ docComment,
591
+ releaseTag,
592
+ excerptTokens,
593
+ isExported,
594
+ fileUrlPath
595
+ });
596
+ parentApiItem.addMember(apiNamespace);
597
+ }
598
+ this._processChildDeclarations(astDeclaration, {
599
+ ...context,
600
+ parentApiItem: apiNamespace
601
+ });
602
+ }
603
+ _processApiProperty(astDeclaration, context) {
604
+ const { name, parentApiItem } = context;
605
+ const isStatic = (astDeclaration.modifierFlags & ts.ModifierFlags.Static) !== 0;
606
+ const containerKey = ApiProperty.getContainerKey(name, isStatic);
607
+ let apiProperty = parentApiItem.tryGetMemberByKey(containerKey);
608
+ if (apiProperty === undefined) {
609
+ const declaration = astDeclaration.declaration;
610
+ const nodeTransforms = [];
611
+ const propertyTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
612
+ let propertyTypeNode;
613
+ if (ts.isPropertyDeclaration(declaration) || ts.isGetAccessorDeclaration(declaration)) {
614
+ propertyTypeNode = declaration.type;
615
+ }
616
+ if (ts.isSetAccessorDeclaration(declaration)) {
617
+ // Note that TypeScript always reports an error if a setter does not have exactly one parameter.
618
+ propertyTypeNode = declaration.parameters[0].type;
619
+ }
620
+ if (propertyTypeNode) {
621
+ nodeTransforms.push({ node: propertyTypeNode, captureTokenRange: propertyTypeTokenRange });
622
+ }
623
+ let initializerTokenRange = undefined;
624
+ if (ts.isPropertyDeclaration(declaration) && declaration.initializer) {
625
+ initializerTokenRange = ExcerptBuilder.createEmptyTokenRange();
626
+ nodeTransforms.push({ node: declaration.initializer, captureTokenRange: initializerTokenRange });
627
+ }
628
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
629
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
630
+ const docComment = apiItemMetadata.tsdocComment;
631
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
632
+ const isOptional = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
633
+ const isProtected = (astDeclaration.modifierFlags & ts.ModifierFlags.Protected) !== 0;
634
+ const isAbstract = (astDeclaration.modifierFlags & ts.ModifierFlags.Abstract) !== 0;
635
+ const isReadonly = this._isReadonly(astDeclaration);
636
+ const fileUrlPath = this._getFileUrlPath(declaration);
637
+ apiProperty = new ApiProperty({
638
+ name,
639
+ docComment,
640
+ releaseTag,
641
+ isAbstract,
642
+ isProtected,
643
+ isStatic,
644
+ isOptional,
645
+ isReadonly,
646
+ excerptTokens,
647
+ propertyTypeTokenRange,
648
+ initializerTokenRange,
649
+ fileUrlPath
650
+ });
651
+ parentApiItem.addMember(apiProperty);
652
+ }
653
+ else {
654
+ // If the property was already declared before (via a merged interface declaration),
655
+ // we assume its signature is identical, because the language requires that.
656
+ }
657
+ }
658
+ _processApiPropertySignature(astDeclaration, context) {
659
+ const { name, parentApiItem } = context;
660
+ const containerKey = ApiPropertySignature.getContainerKey(name);
661
+ let apiPropertySignature = parentApiItem.tryGetMemberByKey(containerKey);
662
+ if (apiPropertySignature === undefined) {
663
+ const propertySignature = astDeclaration.declaration;
664
+ const nodeTransforms = [];
665
+ const propertyTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
666
+ if (propertySignature.type) {
667
+ nodeTransforms.push({ node: propertySignature.type, captureTokenRange: propertyTypeTokenRange });
668
+ }
669
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
670
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
671
+ const docComment = apiItemMetadata.tsdocComment;
672
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
673
+ const isOptional = (astDeclaration.astSymbol.followedSymbol.flags & ts.SymbolFlags.Optional) !== 0;
674
+ const isReadonly = this._isReadonly(astDeclaration);
675
+ const fileUrlPath = this._getFileUrlPath(propertySignature);
676
+ apiPropertySignature = new ApiPropertySignature({
677
+ name,
678
+ docComment,
679
+ releaseTag,
680
+ isOptional,
681
+ excerptTokens,
682
+ propertyTypeTokenRange,
683
+ isReadonly,
684
+ fileUrlPath
685
+ });
686
+ parentApiItem.addMember(apiPropertySignature);
687
+ }
688
+ else {
689
+ // If the property was already declared before (via a merged interface declaration),
690
+ // we assume its signature is identical, because the language requires that.
691
+ }
692
+ }
693
+ _processApiTypeAlias(astDeclaration, context) {
694
+ const { name, isExported, parentApiItem } = context;
695
+ const containerKey = ApiTypeAlias.getContainerKey(name);
696
+ let apiTypeAlias = parentApiItem.tryGetMemberByKey(containerKey);
697
+ if (apiTypeAlias === undefined) {
698
+ const typeAliasDeclaration = astDeclaration.declaration;
699
+ const nodeTransforms = [];
700
+ const typeParameters = this._captureTypeParameters(nodeTransforms, typeAliasDeclaration.typeParameters);
701
+ const typeTokenRange = ExcerptBuilder.createEmptyTokenRange();
702
+ nodeTransforms.push({ node: typeAliasDeclaration.type, captureTokenRange: typeTokenRange });
703
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
704
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
705
+ const docComment = apiItemMetadata.tsdocComment;
706
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
707
+ const fileUrlPath = this._getFileUrlPath(typeAliasDeclaration);
708
+ apiTypeAlias = new ApiTypeAlias({
709
+ name,
710
+ docComment,
711
+ typeParameters,
712
+ releaseTag,
713
+ excerptTokens,
714
+ typeTokenRange,
715
+ isExported,
716
+ fileUrlPath
717
+ });
718
+ parentApiItem.addMember(apiTypeAlias);
719
+ }
720
+ }
721
+ _processApiVariable(astDeclaration, context) {
722
+ const { name, isExported, parentApiItem } = context;
723
+ const containerKey = ApiVariable.getContainerKey(name);
724
+ let apiVariable = parentApiItem.tryGetMemberByKey(containerKey);
725
+ if (apiVariable === undefined) {
726
+ const variableDeclaration = astDeclaration.declaration;
727
+ const nodeTransforms = [];
728
+ const variableTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
729
+ if (variableDeclaration.type) {
730
+ nodeTransforms.push({ node: variableDeclaration.type, captureTokenRange: variableTypeTokenRange });
731
+ }
732
+ let initializerTokenRange = undefined;
733
+ if (variableDeclaration.initializer) {
734
+ initializerTokenRange = ExcerptBuilder.createEmptyTokenRange();
735
+ nodeTransforms.push({
736
+ node: variableDeclaration.initializer,
737
+ captureTokenRange: initializerTokenRange
738
+ });
739
+ }
740
+ const excerptTokens = this._buildExcerptTokens(astDeclaration, nodeTransforms);
741
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
742
+ const docComment = apiItemMetadata.tsdocComment;
743
+ const releaseTag = apiItemMetadata.effectiveReleaseTag;
744
+ const isReadonly = this._isReadonly(astDeclaration);
745
+ const fileUrlPath = this._getFileUrlPath(variableDeclaration);
746
+ apiVariable = new ApiVariable({
747
+ name,
748
+ docComment,
749
+ releaseTag,
750
+ excerptTokens,
751
+ variableTypeTokenRange,
752
+ initializerTokenRange,
753
+ isReadonly,
754
+ isExported,
755
+ fileUrlPath
756
+ });
757
+ parentApiItem.addMember(apiVariable);
758
+ }
759
+ }
760
+ /**
761
+ * @param nodeTransforms - A list of child nodes whose token ranges we want to capture
762
+ */
763
+ _buildExcerptTokens(astDeclaration, nodeTransforms) {
764
+ const excerptTokens = [];
765
+ // Build the main declaration
766
+ ExcerptBuilder.addDeclaration(excerptTokens, astDeclaration, nodeTransforms, this._referenceGenerator);
767
+ const declarationMetadata = this._collector.fetchDeclarationMetadata(astDeclaration);
768
+ // Add any ancillary declarations
769
+ for (const ancillaryDeclaration of declarationMetadata.ancillaryDeclarations) {
770
+ ExcerptBuilder.addBlankLine(excerptTokens);
771
+ ExcerptBuilder.addDeclaration(excerptTokens, ancillaryDeclaration, nodeTransforms, this._referenceGenerator);
772
+ }
773
+ return excerptTokens;
774
+ }
775
+ _captureTypeParameters(nodeTransforms, typeParameterNodes) {
776
+ const typeParameters = [];
777
+ if (typeParameterNodes) {
778
+ for (const typeParameter of typeParameterNodes) {
779
+ const constraintTokenRange = ExcerptBuilder.createEmptyTokenRange();
780
+ if (typeParameter.constraint) {
781
+ nodeTransforms.push({ node: typeParameter.constraint, captureTokenRange: constraintTokenRange });
782
+ }
783
+ const defaultTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
784
+ if (typeParameter.default) {
785
+ nodeTransforms.push({ node: typeParameter.default, captureTokenRange: defaultTypeTokenRange });
786
+ }
787
+ typeParameters.push({
788
+ typeParameterName: typeParameter.name.getText().trim(),
789
+ constraintTokenRange,
790
+ defaultTypeTokenRange
791
+ });
792
+ }
793
+ }
794
+ return typeParameters;
795
+ }
796
+ _captureParameters(nodeTransforms, parameterNodes) {
797
+ const parameters = [];
798
+ DtsEmitHelpers.forEachParameterToNormalize(parameterNodes, (parameter, syntheticName) => {
799
+ const parameterTypeTokenRange = ExcerptBuilder.createEmptyTokenRange();
800
+ if (parameter.type) {
801
+ nodeTransforms.push({ node: parameter.type, captureTokenRange: parameterTypeTokenRange });
802
+ }
803
+ parameters.push({
804
+ parameterName: syntheticName !== null && syntheticName !== void 0 ? syntheticName : parameter.name.getText().trim(),
805
+ parameterTypeTokenRange,
806
+ isOptional: this._collector.typeChecker.isOptionalParameter(parameter)
807
+ });
808
+ if (syntheticName !== undefined) {
809
+ // Replace the subexpression like "{ y, z }" with the synthesized parameter name
810
+ nodeTransforms.push({ node: parameter.name, replacementText: syntheticName });
811
+ }
812
+ });
813
+ return parameters;
814
+ }
815
+ _isReadonly(astDeclaration) {
816
+ var _a;
817
+ switch (astDeclaration.declaration.kind) {
818
+ case ts.SyntaxKind.GetAccessor:
819
+ case ts.SyntaxKind.IndexSignature:
820
+ case ts.SyntaxKind.PropertyDeclaration:
821
+ case ts.SyntaxKind.PropertySignature:
822
+ case ts.SyntaxKind.SetAccessor:
823
+ case ts.SyntaxKind.VariableDeclaration: {
824
+ const apiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
825
+ const docComment = apiItemMetadata.tsdocComment;
826
+ const declarationMetadata = this._collector.fetchDeclarationMetadata(astDeclaration);
827
+ const hasReadonlyModifier = (astDeclaration.modifierFlags & ts.ModifierFlags.Readonly) !== 0;
828
+ const hasReadonlyDocTag = !!((_a = docComment === null || docComment === void 0 ? void 0 : docComment.modifierTagSet) === null || _a === void 0 ? void 0 : _a.hasTagName('@readonly'));
829
+ const isGetterWithNoSetter = ts.isGetAccessorDeclaration(astDeclaration.declaration) &&
830
+ declarationMetadata.ancillaryDeclarations.length === 0;
831
+ const isVarConst = ts.isVariableDeclaration(astDeclaration.declaration) &&
832
+ TypeScriptInternals.isVarConst(astDeclaration.declaration);
833
+ return hasReadonlyModifier || hasReadonlyDocTag || isGetterWithNoSetter || isVarConst;
834
+ }
835
+ default: {
836
+ // Readonly-ness does not make sense for any other declaration kind.
837
+ return false;
838
+ }
839
+ }
840
+ }
841
+ _getFileUrlPath(declaration) {
842
+ const sourceFile = declaration.getSourceFile();
843
+ const sourceLocation = this._collector.sourceMapper.getSourceLocation({
844
+ sourceFile,
845
+ pos: declaration.pos
846
+ });
847
+ let result = path.relative(this._collector.extractorConfig.projectFolder, sourceLocation.sourceFilePath);
848
+ result = Path.convertToSlashes(result);
849
+ return result;
850
+ }
851
+ }
852
+ //# sourceMappingURL=ApiModelGenerator.js.map