@microsoft/api-extractor 7.19.3 → 7.20.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 (58) hide show
  1. package/README.md +51 -51
  2. package/dist/tsdoc-metadata.json +1 -1
  3. package/extends/tsdoc-base.json +72 -72
  4. package/lib/aedoc/PackageDocComment.js.map +1 -1
  5. package/lib/analyzer/AstDeclaration.js.map +1 -1
  6. package/lib/analyzer/AstEntity.js.map +1 -1
  7. package/lib/analyzer/AstImport.js.map +1 -1
  8. package/lib/analyzer/AstModule.js.map +1 -1
  9. package/lib/analyzer/AstNamespaceImport.js.map +1 -1
  10. package/lib/analyzer/AstReferenceResolver.js.map +1 -1
  11. package/lib/analyzer/AstSymbol.js.map +1 -1
  12. package/lib/analyzer/AstSymbolTable.js.map +1 -1
  13. package/lib/analyzer/ExportAnalyzer.js.map +1 -1
  14. package/lib/analyzer/PackageMetadataManager.js.map +1 -1
  15. package/lib/analyzer/SourceFileLocationFormatter.js.map +1 -1
  16. package/lib/analyzer/Span.js.map +1 -1
  17. package/lib/analyzer/SyntaxHelpers.js.map +1 -1
  18. package/lib/analyzer/TypeScriptHelpers.js.map +1 -1
  19. package/lib/analyzer/TypeScriptInternals.js.map +1 -1
  20. package/lib/api/CompilerState.js.map +1 -1
  21. package/lib/api/ConsoleMessageId.js.map +1 -1
  22. package/lib/api/Extractor.js.map +1 -1
  23. package/lib/api/ExtractorConfig.js.map +1 -1
  24. package/lib/api/ExtractorLogLevel.js.map +1 -1
  25. package/lib/api/ExtractorMessage.js.map +1 -1
  26. package/lib/api/ExtractorMessageId.js.map +1 -1
  27. package/lib/api/IConfigFile.js.map +1 -1
  28. package/lib/cli/ApiExtractorCommandLine.js.map +1 -1
  29. package/lib/cli/InitAction.js.map +1 -1
  30. package/lib/cli/RunAction.js.map +1 -1
  31. package/lib/collector/ApiItemMetadata.js.map +1 -1
  32. package/lib/collector/Collector.js.map +1 -1
  33. package/lib/collector/CollectorEntity.js.map +1 -1
  34. package/lib/collector/DeclarationMetadata.js.map +1 -1
  35. package/lib/collector/MessageRouter.js.map +1 -1
  36. package/lib/collector/SourceMapper.js.map +1 -1
  37. package/lib/collector/SymbolMetadata.js.map +1 -1
  38. package/lib/collector/VisitorState.js.map +1 -1
  39. package/lib/collector/WorkingPackage.js.map +1 -1
  40. package/lib/enhancers/DocCommentEnhancer.js.map +1 -1
  41. package/lib/enhancers/ValidationEnhancer.js.map +1 -1
  42. package/lib/generators/ApiModelGenerator.d.ts.map +1 -1
  43. package/lib/generators/ApiModelGenerator.js +2 -1
  44. package/lib/generators/ApiModelGenerator.js.map +1 -1
  45. package/lib/generators/ApiReportGenerator.js.map +1 -1
  46. package/lib/generators/DeclarationReferenceGenerator.js.map +1 -1
  47. package/lib/generators/DtsEmitHelpers.js.map +1 -1
  48. package/lib/generators/DtsRollupGenerator.js.map +1 -1
  49. package/lib/generators/ExcerptBuilder.js.map +1 -1
  50. package/lib/generators/IndentedWriter.js.map +1 -1
  51. package/lib/index.js.map +1 -1
  52. package/lib/schemas/api-extractor-defaults.json +84 -84
  53. package/lib/schemas/api-extractor-template.json +364 -364
  54. package/lib/schemas/api-extractor.schema.json +205 -205
  55. package/lib/start.js.map +1 -1
  56. package/package.json +63 -60
  57. package/CHANGELOG.json +0 -5656
  58. package/CHANGELOG.md +0 -2290
@@ -1 +1 @@
1
- {"version":3,"file":"DtsEmitHelpers.js","sourceRoot":"","sources":["../../src/generators/DtsEmitHelpers.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,oEAA6D;AAE7D,qDAAiE;AACjE,+DAA4D;AAI5D,yFAAsF;AAEtF;;GAEG;AACH,MAAa,cAAc;IAClB,MAAM,CAAC,UAAU,CACtB,MAAsB,EACtB,eAAgC,EAChC,SAAoB;QAEpB,MAAM,YAAY,GAAW,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAA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,CAAC;gBAEpF,MAAM,WAAW,GAAW,GAAG,gBAAgB,CAAC,WAAW,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,cAAc,EAAE,CAAC;gBAE1H,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,WAAW,CAAC;aACxC;iBAAM;gBACL,4CAA4C;gBAC5C,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,gBAAgB,CAAC,WAAW,GAAG,iBAAiB,GAAG,cAAc,EAAE,CAAC;aACnG;SACF;IACH,CAAC;CACF;AA3JD,wCA2JC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport * as ts from 'typescript';\r\n\r\nimport { InternalError } from '@rushstack/node-core-library';\r\nimport { CollectorEntity } from '../collector/CollectorEntity';\r\nimport { AstImport, AstImportKind } from '../analyzer/AstImport';\r\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\r\nimport { Collector } from '../collector/Collector';\r\nimport { Span } from '../analyzer/Span';\r\nimport { IndentedWriter } from './IndentedWriter';\r\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\r\n\r\n/**\r\n * Some common code shared between DtsRollupGenerator and ApiReportGenerator.\r\n */\r\nexport class DtsEmitHelpers {\r\n public static emitImport(\r\n writer: IndentedWriter,\r\n collectorEntity: CollectorEntity,\r\n astImport: AstImport\r\n ): void {\r\n const importPrefix: string = astImport.isTypeOnlyEverywhere ? 'import type' : 'import';\r\n\r\n switch (astImport.importKind) {\r\n case AstImportKind.DefaultImport:\r\n if (collectorEntity.nameForEmit !== astImport.exportName) {\r\n writer.write(`${importPrefix} { default as ${collectorEntity.nameForEmit} }`);\r\n } else {\r\n writer.write(`${importPrefix} ${astImport.exportName}`);\r\n }\r\n writer.writeLine(` from '${astImport.modulePath}';`);\r\n break;\r\n case AstImportKind.NamedImport:\r\n if (collectorEntity.nameForEmit === astImport.exportName) {\r\n writer.write(`${importPrefix} { ${astImport.exportName} }`);\r\n } else {\r\n writer.write(`${importPrefix} { ${astImport.exportName} as ${collectorEntity.nameForEmit} }`);\r\n }\r\n writer.writeLine(` from '${astImport.modulePath}';`);\r\n break;\r\n case AstImportKind.StarImport:\r\n writer.writeLine(\r\n `${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`\r\n );\r\n break;\r\n case AstImportKind.EqualsImport:\r\n writer.writeLine(\r\n `${importPrefix} ${collectorEntity.nameForEmit} = require('${astImport.modulePath}');`\r\n );\r\n break;\r\n case AstImportKind.ImportType:\r\n if (!astImport.exportName) {\r\n writer.writeLine(\r\n `${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`\r\n );\r\n } else {\r\n const topExportName: string = astImport.exportName.split('.')[0];\r\n if (collectorEntity.nameForEmit === topExportName) {\r\n writer.write(`${importPrefix} { ${topExportName} }`);\r\n } else {\r\n writer.write(`${importPrefix} { ${topExportName} as ${collectorEntity.nameForEmit} }`);\r\n }\r\n writer.writeLine(` from '${astImport.modulePath}';`);\r\n }\r\n break;\r\n default:\r\n throw new InternalError('Unimplemented AstImportKind');\r\n }\r\n }\r\n\r\n public static emitNamedExport(\r\n writer: IndentedWriter,\r\n exportName: string,\r\n collectorEntity: CollectorEntity\r\n ): void {\r\n if (exportName === ts.InternalSymbolName.Default) {\r\n writer.writeLine(`export default ${collectorEntity.nameForEmit};`);\r\n } else if (collectorEntity.nameForEmit !== exportName) {\r\n writer.writeLine(`export { ${collectorEntity.nameForEmit} as ${exportName} }`);\r\n } else {\r\n writer.writeLine(`export { ${exportName} }`);\r\n }\r\n }\r\n\r\n public static emitStarExports(writer: IndentedWriter, collector: Collector): void {\r\n if (collector.starExportedExternalModulePaths.length > 0) {\r\n writer.writeLine();\r\n for (const starExportedExternalModulePath of collector.starExportedExternalModulePaths) {\r\n writer.writeLine(`export * from \"${starExportedExternalModulePath}\";`);\r\n }\r\n }\r\n }\r\n\r\n public static modifyImportTypeSpan(\r\n collector: Collector,\r\n span: Span,\r\n astDeclaration: AstDeclaration,\r\n modifyNestedSpan: (childSpan: Span, childAstDeclaration: AstDeclaration) => void\r\n ): void {\r\n const node: ts.ImportTypeNode = span.node as ts.ImportTypeNode;\r\n const referencedEntity: CollectorEntity | undefined = collector.tryGetEntityForNode(node);\r\n\r\n if (referencedEntity) {\r\n if (!referencedEntity.nameForEmit) {\r\n // This should never happen\r\n\r\n throw new InternalError('referencedEntry.nameForEmit is undefined');\r\n }\r\n\r\n let typeArgumentsText: string = '';\r\n\r\n if (node.typeArguments && node.typeArguments.length > 0) {\r\n // Type arguments have to be processed and written to the document\r\n const lessThanTokenPos: number = span.children.findIndex(\r\n (childSpan) => childSpan.node.kind === ts.SyntaxKind.LessThanToken\r\n );\r\n const greaterThanTokenPos: number = span.children.findIndex(\r\n (childSpan) => childSpan.node.kind === ts.SyntaxKind.GreaterThanToken\r\n );\r\n\r\n if (lessThanTokenPos < 0 || greaterThanTokenPos <= lessThanTokenPos) {\r\n throw new InternalError(\r\n `Invalid type arguments: ${node.getText()}\\n` +\r\n SourceFileLocationFormatter.formatDeclaration(node)\r\n );\r\n }\r\n\r\n const typeArgumentsSpans: Span[] = span.children.slice(lessThanTokenPos + 1, greaterThanTokenPos);\r\n\r\n // Apply modifications to Span elements of typeArguments\r\n typeArgumentsSpans.forEach((childSpan) => {\r\n const childAstDeclaration: AstDeclaration = AstDeclaration.isSupportedSyntaxKind(childSpan.kind)\r\n ? collector.astSymbolTable.getChildAstDeclarationByNode(childSpan.node, astDeclaration)\r\n : astDeclaration;\r\n\r\n modifyNestedSpan(childSpan, childAstDeclaration);\r\n });\r\n\r\n const typeArgumentsStrings: string[] = typeArgumentsSpans.map((childSpan) =>\r\n childSpan.getModifiedText()\r\n );\r\n typeArgumentsText = `<${typeArgumentsStrings.join(', ')}>`;\r\n }\r\n\r\n const separatorAfter: string = /(\\s*)$/.exec(span.getText())?.[1] ?? '';\r\n\r\n if (\r\n referencedEntity.astEntity instanceof AstImport &&\r\n referencedEntity.astEntity.importKind === AstImportKind.ImportType &&\r\n referencedEntity.astEntity.exportName\r\n ) {\r\n // For an ImportType with a namespace chain, only the top namespace is imported.\r\n // Must add the original nested qualifiers to the rolled up import.\r\n const qualifiersText: string = node.qualifier?.getText() ?? '';\r\n const nestedQualifiersStart: number = qualifiersText.indexOf('.');\r\n // Including the leading \".\"\r\n const nestedQualifiersText: string =\r\n nestedQualifiersStart >= 0 ? qualifiersText.substring(nestedQualifiersStart) : '';\r\n\r\n const replacement: string = `${referencedEntity.nameForEmit}${nestedQualifiersText}${typeArgumentsText}${separatorAfter}`;\r\n\r\n span.modification.skipAll();\r\n span.modification.prefix = replacement;\r\n } else {\r\n // Replace with internal symbol or AstImport\r\n span.modification.skipAll();\r\n span.modification.prefix = `${referencedEntity.nameForEmit}${typeArgumentsText}${separatorAfter}`;\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DtsEmitHelpers.js","sourceRoot":"","sources":["../../src/generators/DtsEmitHelpers.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,oEAA6D;AAE7D,qDAAiE;AACjE,+DAA4D;AAI5D,yFAAsF;AAEtF;;GAEG;AACH,MAAa,cAAc;IAClB,MAAM,CAAC,UAAU,CACtB,MAAsB,EACtB,eAAgC,EAChC,SAAoB;QAEpB,MAAM,YAAY,GAAW,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;QAEvF,QAAQ,SAAS,CAAC,UAAU,EAAE;YAC5B,KAAK,yBAAa,CAAC,aAAa;gBAC9B,IAAI,eAAe,CAAC,WAAW,KAAK,SAAS,CAAC,UAAU,EAAE;oBACxD,MAAM,CAAC,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AC,MAAM,GAAG,WAAW,CAAC;aACxC;iBAAM;gBACL,4CAA4C;gBAC5C,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG,gBAAgB,CAAC,WAAW,GAAG,iBAAiB,GAAG,cAAc,EAAE,CAAC;aACnG;SACF;IACH,CAAC;CACF;AA3JD,wCA2JC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\n\nimport { InternalError } from '@rushstack/node-core-library';\nimport { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstImport, AstImportKind } from '../analyzer/AstImport';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport { Collector } from '../collector/Collector';\nimport { Span } from '../analyzer/Span';\nimport { IndentedWriter } from './IndentedWriter';\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\n\n/**\n * Some common code shared between DtsRollupGenerator and ApiReportGenerator.\n */\nexport class DtsEmitHelpers {\n public static emitImport(\n writer: IndentedWriter,\n collectorEntity: CollectorEntity,\n astImport: AstImport\n ): void {\n const importPrefix: string = astImport.isTypeOnlyEverywhere ? 'import type' : 'import';\n\n switch (astImport.importKind) {\n case AstImportKind.DefaultImport:\n if (collectorEntity.nameForEmit !== astImport.exportName) {\n writer.write(`${importPrefix} { default as ${collectorEntity.nameForEmit} }`);\n } else {\n writer.write(`${importPrefix} ${astImport.exportName}`);\n }\n writer.writeLine(` from '${astImport.modulePath}';`);\n break;\n case AstImportKind.NamedImport:\n if (collectorEntity.nameForEmit === astImport.exportName) {\n writer.write(`${importPrefix} { ${astImport.exportName} }`);\n } else {\n writer.write(`${importPrefix} { ${astImport.exportName} as ${collectorEntity.nameForEmit} }`);\n }\n writer.writeLine(` from '${astImport.modulePath}';`);\n break;\n case AstImportKind.StarImport:\n writer.writeLine(\n `${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`\n );\n break;\n case AstImportKind.EqualsImport:\n writer.writeLine(\n `${importPrefix} ${collectorEntity.nameForEmit} = require('${astImport.modulePath}');`\n );\n break;\n case AstImportKind.ImportType:\n if (!astImport.exportName) {\n writer.writeLine(\n `${importPrefix} * as ${collectorEntity.nameForEmit} from '${astImport.modulePath}';`\n );\n } else {\n const topExportName: string = astImport.exportName.split('.')[0];\n if (collectorEntity.nameForEmit === topExportName) {\n writer.write(`${importPrefix} { ${topExportName} }`);\n } else {\n writer.write(`${importPrefix} { ${topExportName} as ${collectorEntity.nameForEmit} }`);\n }\n writer.writeLine(` from '${astImport.modulePath}';`);\n }\n break;\n default:\n throw new InternalError('Unimplemented AstImportKind');\n }\n }\n\n public static emitNamedExport(\n writer: IndentedWriter,\n exportName: string,\n collectorEntity: CollectorEntity\n ): void {\n if (exportName === ts.InternalSymbolName.Default) {\n writer.writeLine(`export default ${collectorEntity.nameForEmit};`);\n } else if (collectorEntity.nameForEmit !== exportName) {\n writer.writeLine(`export { ${collectorEntity.nameForEmit} as ${exportName} }`);\n } else {\n writer.writeLine(`export { ${exportName} }`);\n }\n }\n\n public static emitStarExports(writer: IndentedWriter, collector: Collector): void {\n if (collector.starExportedExternalModulePaths.length > 0) {\n writer.writeLine();\n for (const starExportedExternalModulePath of collector.starExportedExternalModulePaths) {\n writer.writeLine(`export * from \"${starExportedExternalModulePath}\";`);\n }\n }\n }\n\n public static modifyImportTypeSpan(\n collector: Collector,\n span: Span,\n astDeclaration: AstDeclaration,\n modifyNestedSpan: (childSpan: Span, childAstDeclaration: AstDeclaration) => void\n ): void {\n const node: ts.ImportTypeNode = span.node as ts.ImportTypeNode;\n const referencedEntity: CollectorEntity | undefined = collector.tryGetEntityForNode(node);\n\n if (referencedEntity) {\n if (!referencedEntity.nameForEmit) {\n // This should never happen\n\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n let typeArgumentsText: string = '';\n\n if (node.typeArguments && node.typeArguments.length > 0) {\n // Type arguments have to be processed and written to the document\n const lessThanTokenPos: number = span.children.findIndex(\n (childSpan) => childSpan.node.kind === ts.SyntaxKind.LessThanToken\n );\n const greaterThanTokenPos: number = span.children.findIndex(\n (childSpan) => childSpan.node.kind === ts.SyntaxKind.GreaterThanToken\n );\n\n if (lessThanTokenPos < 0 || greaterThanTokenPos <= lessThanTokenPos) {\n throw new InternalError(\n `Invalid type arguments: ${node.getText()}\\n` +\n SourceFileLocationFormatter.formatDeclaration(node)\n );\n }\n\n const typeArgumentsSpans: Span[] = span.children.slice(lessThanTokenPos + 1, greaterThanTokenPos);\n\n // Apply modifications to Span elements of typeArguments\n typeArgumentsSpans.forEach((childSpan) => {\n const childAstDeclaration: AstDeclaration = AstDeclaration.isSupportedSyntaxKind(childSpan.kind)\n ? collector.astSymbolTable.getChildAstDeclarationByNode(childSpan.node, astDeclaration)\n : astDeclaration;\n\n modifyNestedSpan(childSpan, childAstDeclaration);\n });\n\n const typeArgumentsStrings: string[] = typeArgumentsSpans.map((childSpan) =>\n childSpan.getModifiedText()\n );\n typeArgumentsText = `<${typeArgumentsStrings.join(', ')}>`;\n }\n\n const separatorAfter: string = /(\\s*)$/.exec(span.getText())?.[1] ?? '';\n\n if (\n referencedEntity.astEntity instanceof AstImport &&\n referencedEntity.astEntity.importKind === AstImportKind.ImportType &&\n referencedEntity.astEntity.exportName\n ) {\n // For an ImportType with a namespace chain, only the top namespace is imported.\n // Must add the original nested qualifiers to the rolled up import.\n const qualifiersText: string = node.qualifier?.getText() ?? '';\n const nestedQualifiersStart: number = qualifiersText.indexOf('.');\n // Including the leading \".\"\n const nestedQualifiersText: string =\n nestedQualifiersStart >= 0 ? qualifiersText.substring(nestedQualifiersStart) : '';\n\n const replacement: string = `${referencedEntity.nameForEmit}${nestedQualifiersText}${typeArgumentsText}${separatorAfter}`;\n\n span.modification.skipAll();\n span.modification.prefix = replacement;\n } else {\n // Replace with internal symbol or AstImport\n span.modification.skipAll();\n span.modification.prefix = `${referencedEntity.nameForEmit}${typeArgumentsText}${separatorAfter}`;\n }\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DtsRollupGenerator.js","sourceRoot":"","sources":["../../src/generators/DtsRollupGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;AAE3D,+BAA+B;AAE/B,+CAAiC;AACjC,oEAAsF;AACtF,wEAA4D;AAG5D,qEAAkE;AAClE,2CAAiF;AACjF,qDAAkD;AAElD,+DAA4D;AAE5D,qDAAkD;AAElD,qDAAkD;AAClD,qDAAkD;AAElD,uEAAoE;AAEpE,yFAAsF;AAGtF;;GAEG;AACH,IAAY,aAoBX;AApBD,WAAY,aAAa;IACvB;;;OAGG;IACH,uEAAe,CAAA;IAEf;;;;OAIG;IACH,+DAAW,CAAA;IAEX;;;;OAIG;IACH,mEAAa,CAAA;AACf,CAAC,EApBW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAoBxB;AAED,MAAa,kBAAkB;IAC7B;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAC5B,SAAoB,EACpB,WAAmB,EACnB,OAAsB,EACtB,WAAwB;QAExB,MAAM,MAAM,GAAmB,IAAI,+BAAc,EAAE,CAAC;QACpD,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAEhC,kBAAkB,CAAC,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAE3E,8BAAU,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE;YACnD,kBAAkB,EAAE,WAAW;YAC/B,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,2BAA2B,CACxC,SAAoB,EACpB,MAAsB,EACtB,OAAsB;QAEtB,gEAAgE;QAChE,IAAI,SAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE;YAC/C,MAAM,CAAC,iBAAiB,GAAG,KAAK,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AAO,UAAU,KAAK,gCAAU,CAAC,MAAM,IAAI,UAAU,KAAK,gCAAU,CAAC,IAAI,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;SACnE;IACH,CAAC;CACF;AAvZD,gDAuZC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/* eslint-disable no-bitwise */\r\n\r\nimport * as ts from 'typescript';\r\nimport { FileSystem, NewlineKind, InternalError } from '@rushstack/node-core-library';\r\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\r\n\r\nimport { Collector } from '../collector/Collector';\r\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\r\nimport { IndentDocCommentScope, Span, SpanModification } from '../analyzer/Span';\r\nimport { AstImport } from '../analyzer/AstImport';\r\nimport { CollectorEntity } from '../collector/CollectorEntity';\r\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\r\nimport { ApiItemMetadata } from '../collector/ApiItemMetadata';\r\nimport { AstSymbol } from '../analyzer/AstSymbol';\r\nimport { SymbolMetadata } from '../collector/SymbolMetadata';\r\nimport { IndentedWriter } from './IndentedWriter';\r\nimport { DtsEmitHelpers } from './DtsEmitHelpers';\r\nimport { DeclarationMetadata } from '../collector/DeclarationMetadata';\r\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\r\nimport { AstModuleExportInfo } from '../analyzer/AstModule';\r\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\r\nimport { AstEntity } from '../analyzer/AstEntity';\r\n\r\n/**\r\n * Used with DtsRollupGenerator.writeTypingsFile()\r\n */\r\nexport enum DtsRollupKind {\r\n /**\r\n * Generate a *.d.ts file for an internal release, or for the trimming=false mode.\r\n * This output file will contain all definitions that are reachable from the entry point.\r\n */\r\n InternalRelease,\r\n\r\n /**\r\n * Generate a *.d.ts file for a preview release.\r\n * This output file will contain all definitions that are reachable from the entry point,\r\n * except definitions marked as \\@alpha or \\@internal.\r\n */\r\n BetaRelease,\r\n\r\n /**\r\n * Generate a *.d.ts file for a public release.\r\n * This output file will contain all definitions that are reachable from the entry point,\r\n * except definitions marked as \\@beta, \\@alpha, or \\@internal.\r\n */\r\n PublicRelease\r\n}\r\n\r\nexport class DtsRollupGenerator {\r\n /**\r\n * Generates the typings file and writes it to disk.\r\n *\r\n * @param dtsFilename - The *.d.ts output filename\r\n */\r\n public static writeTypingsFile(\r\n collector: Collector,\r\n dtsFilename: string,\r\n dtsKind: DtsRollupKind,\r\n newlineKind: NewlineKind\r\n ): void {\r\n const writer: IndentedWriter = new IndentedWriter();\r\n writer.trimLeadingSpaces = true;\r\n\r\n DtsRollupGenerator._generateTypingsFileContent(collector, writer, dtsKind);\r\n\r\n FileSystem.writeFile(dtsFilename, writer.toString(), {\r\n convertLineEndings: newlineKind,\r\n ensureFolderExists: true\r\n });\r\n }\r\n\r\n private static _generateTypingsFileContent(\r\n collector: Collector,\r\n writer: IndentedWriter,\r\n dtsKind: DtsRollupKind\r\n ): void {\r\n // Emit the @packageDocumentation comment at the top of the file\r\n if (collector.workingPackage.tsdocParserContext) {\r\n writer.trimLeadingSpaces = false;\r\n writer.writeLine(collector.workingPackage.tsdocParserContext.sourceRange.toString());\r\n writer.trimLeadingSpaces = true;\r\n writer.ensureSkippedLine();\r\n }\r\n\r\n // Emit the triple slash directives\r\n for (const typeDirectiveReference of collector.dtsTypeReferenceDirectives) {\r\n // https://github.com/microsoft/TypeScript/blob/611ebc7aadd7a44a4c0447698bfda9222a78cb66/src/compiler/declarationEmitter.ts#L162\r\n writer.writeLine(`/// <reference types=\"${typeDirectiveReference}\" />`);\r\n }\r\n for (const libDirectiveReference of collector.dtsLibReferenceDirectives) {\r\n writer.writeLine(`/// <reference lib=\"${libDirectiveReference}\" />`);\r\n }\r\n writer.ensureSkippedLine();\r\n\r\n // Emit the imports\r\n for (const entity of collector.entities) {\r\n if (entity.astEntity instanceof AstImport) {\r\n const astImport: AstImport = entity.astEntity;\r\n\r\n // For example, if the imported API comes from an external package that supports AEDoc,\r\n // and it was marked as `@internal`, then don't emit it.\r\n const symbolMetadata: SymbolMetadata | undefined = collector.tryFetchMetadataForAstEntity(astImport);\r\n const maxEffectiveReleaseTag: ReleaseTag = symbolMetadata\r\n ? symbolMetadata.maxEffectiveReleaseTag\r\n : ReleaseTag.None;\r\n\r\n if (this._shouldIncludeReleaseTag(maxEffectiveReleaseTag, dtsKind)) {\r\n DtsEmitHelpers.emitImport(writer, entity, astImport);\r\n }\r\n }\r\n }\r\n writer.ensureSkippedLine();\r\n\r\n // Emit the regular declarations\r\n for (const entity of collector.entities) {\r\n const astEntity: AstEntity = entity.astEntity;\r\n const symbolMetadata: SymbolMetadata | undefined = collector.tryFetchMetadataForAstEntity(astEntity);\r\n const maxEffectiveReleaseTag: ReleaseTag = symbolMetadata\r\n ? symbolMetadata.maxEffectiveReleaseTag\r\n : ReleaseTag.None;\r\n\r\n if (!this._shouldIncludeReleaseTag(maxEffectiveReleaseTag, dtsKind)) {\r\n if (!collector.extractorConfig.omitTrimmingComments) {\r\n writer.ensureSkippedLine();\r\n writer.writeLine(`/* Excluded from this release type: ${entity.nameForEmit} */`);\r\n }\r\n continue;\r\n }\r\n\r\n if (astEntity instanceof AstSymbol) {\r\n // Emit all the declarations for this entry\r\n for (const astDeclaration of astEntity.astDeclarations || []) {\r\n const apiItemMetadata: ApiItemMetadata = collector.fetchApiItemMetadata(astDeclaration);\r\n\r\n if (!this._shouldIncludeReleaseTag(apiItemMetadata.effectiveReleaseTag, dtsKind)) {\r\n if (!collector.extractorConfig.omitTrimmingComments) {\r\n writer.ensureSkippedLine();\r\n writer.writeLine(`/* Excluded declaration from this release type: ${entity.nameForEmit} */`);\r\n }\r\n continue;\r\n } else {\r\n const span: Span = new Span(astDeclaration.declaration);\r\n DtsRollupGenerator._modifySpan(collector, span, entity, astDeclaration, dtsKind);\r\n writer.ensureSkippedLine();\r\n span.writeModifiedText(writer);\r\n writer.ensureNewLine();\r\n }\r\n }\r\n }\r\n\r\n if (astEntity instanceof AstNamespaceImport) {\r\n const astModuleExportInfo: AstModuleExportInfo = astEntity.fetchAstModuleExportInfo(collector);\r\n\r\n if (entity.nameForEmit === undefined) {\r\n // This should never happen\r\n throw new InternalError('referencedEntry.nameForEmit is undefined');\r\n }\r\n\r\n if (astModuleExportInfo.starExportedExternalModules.size > 0) {\r\n // We could support this, but we would need to find a way to safely represent it.\r\n throw new Error(\r\n `The ${entity.nameForEmit} namespace import includes a start export, which is not supported:\\n` +\r\n SourceFileLocationFormatter.formatDeclaration(astEntity.declaration)\r\n );\r\n }\r\n\r\n // Emit a synthetic declaration for the namespace. It will look like this:\r\n //\r\n // declare namespace example {\r\n // export {\r\n // f1,\r\n // f2\r\n // }\r\n // }\r\n //\r\n // Note that we do not try to relocate f1()/f2() to be inside the namespace because other type\r\n // signatures may reference them directly (without using the namespace qualifier).\r\n\r\n writer.ensureSkippedLine();\r\n if (entity.shouldInlineExport) {\r\n writer.write('export ');\r\n }\r\n writer.writeLine(`declare namespace ${entity.nameForEmit} {`);\r\n\r\n // all local exports of local imported module are just references to top-level declarations\r\n writer.increaseIndent();\r\n writer.writeLine('export {');\r\n writer.increaseIndent();\r\n\r\n const exportClauses: string[] = [];\r\n for (const [exportedName, exportedEntity] of astModuleExportInfo.exportedLocalEntities) {\r\n const collectorEntity: CollectorEntity | undefined =\r\n collector.tryGetCollectorEntity(exportedEntity);\r\n if (collectorEntity === undefined) {\r\n // This should never happen\r\n // top-level exports of local imported module should be added as collector entities before\r\n throw new InternalError(\r\n `Cannot find collector entity for ${entity.nameForEmit}.${exportedEntity.localName}`\r\n );\r\n }\r\n\r\n if (collectorEntity.nameForEmit === exportedName) {\r\n exportClauses.push(collectorEntity.nameForEmit);\r\n } else {\r\n exportClauses.push(`${collectorEntity.nameForEmit} as ${exportedName}`);\r\n }\r\n }\r\n writer.writeLine(exportClauses.join(',\\n'));\r\n\r\n writer.decreaseIndent();\r\n writer.writeLine('}'); // end of \"export { ... }\"\r\n writer.decreaseIndent();\r\n writer.writeLine('}'); // end of \"declare namespace { ... }\"\r\n }\r\n\r\n if (!entity.shouldInlineExport) {\r\n for (const exportName of entity.exportNames) {\r\n DtsEmitHelpers.emitNamedExport(writer, exportName, entity);\r\n }\r\n }\r\n\r\n writer.ensureSkippedLine();\r\n }\r\n\r\n DtsEmitHelpers.emitStarExports(writer, collector);\r\n\r\n // Emit \"export { }\" which is a special directive that prevents consumers from importing declarations\r\n // that don't have an explicit \"export\" modifier.\r\n writer.ensureSkippedLine();\r\n writer.writeLine('export { }');\r\n }\r\n\r\n /**\r\n * Before writing out a declaration, _modifySpan() applies various fixups to make it nice.\r\n */\r\n private static _modifySpan(\r\n collector: Collector,\r\n span: Span,\r\n entity: CollectorEntity,\r\n astDeclaration: AstDeclaration,\r\n dtsKind: DtsRollupKind\r\n ): void {\r\n const previousSpan: Span | undefined = span.previousSibling;\r\n\r\n let recurseChildren: boolean = true;\r\n switch (span.kind) {\r\n case ts.SyntaxKind.JSDocComment:\r\n // If the @packageDocumentation comment seems to be attached to one of the regular API items,\r\n // omit it. It gets explictly emitted at the top of the file.\r\n if (span.node.getText().match(/(?:\\s|\\*)@packageDocumentation(?:\\s|\\*)/gi)) {\r\n span.modification.skipAll();\r\n }\r\n\r\n // For now, we don't transform JSDoc comment nodes at all\r\n recurseChildren = false;\r\n break;\r\n\r\n case ts.SyntaxKind.ExportKeyword:\r\n case ts.SyntaxKind.DefaultKeyword:\r\n case ts.SyntaxKind.DeclareKeyword:\r\n // Delete any explicit \"export\" or \"declare\" keywords -- we will re-add them below\r\n span.modification.skipAll();\r\n break;\r\n\r\n case ts.SyntaxKind.InterfaceKeyword:\r\n case ts.SyntaxKind.ClassKeyword:\r\n case ts.SyntaxKind.EnumKeyword:\r\n case ts.SyntaxKind.NamespaceKeyword:\r\n case ts.SyntaxKind.ModuleKeyword:\r\n case ts.SyntaxKind.TypeKeyword:\r\n case ts.SyntaxKind.FunctionKeyword:\r\n // Replace the stuff we possibly deleted above\r\n let replacedModifiers: string = '';\r\n\r\n // Add a declare statement for root declarations (but not for nested declarations)\r\n if (!astDeclaration.parent) {\r\n replacedModifiers += 'declare ';\r\n }\r\n\r\n if (entity.shouldInlineExport) {\r\n replacedModifiers = 'export ' + replacedModifiers;\r\n }\r\n\r\n if (previousSpan && previousSpan.kind === ts.SyntaxKind.SyntaxList) {\r\n // If there is a previous span of type SyntaxList, then apply it before any other modifiers\r\n // (e.g. \"abstract\") that appear there.\r\n previousSpan.modification.prefix = replacedModifiers + previousSpan.modification.prefix;\r\n } else {\r\n // Otherwise just stick it in front of this span\r\n span.modification.prefix = replacedModifiers + span.modification.prefix;\r\n }\r\n break;\r\n\r\n case ts.SyntaxKind.VariableDeclaration:\r\n // Is this a top-level variable declaration?\r\n // (The logic below does not apply to variable declarations that are part of an explicit \"namespace\" block,\r\n // since the compiler prefers not to emit \"declare\" or \"export\" keywords for those declarations.)\r\n if (!span.parent) {\r\n // The VariableDeclaration node is part of a VariableDeclarationList, however\r\n // the Entry.followedSymbol points to the VariableDeclaration part because\r\n // multiple definitions might share the same VariableDeclarationList.\r\n //\r\n // Since we are emitting a separate declaration for each one, we need to look upwards\r\n // in the ts.Node tree and write a copy of the enclosing VariableDeclarationList\r\n // content (e.g. \"var\" from \"var x=1, y=2\").\r\n const list: ts.VariableDeclarationList | undefined = TypeScriptHelpers.matchAncestor(span.node, [\r\n ts.SyntaxKind.VariableDeclarationList,\r\n ts.SyntaxKind.VariableDeclaration\r\n ]);\r\n if (!list) {\r\n // This should not happen unless the compiler API changes somehow\r\n throw new InternalError('Unsupported variable declaration');\r\n }\r\n const listPrefix: string = list\r\n .getSourceFile()\r\n .text.substring(list.getStart(), list.declarations[0].getStart());\r\n span.modification.prefix = 'declare ' + listPrefix + span.modification.prefix;\r\n span.modification.suffix = ';';\r\n\r\n if (entity.shouldInlineExport) {\r\n span.modification.prefix = 'export ' + span.modification.prefix;\r\n }\r\n\r\n const declarationMetadata: DeclarationMetadata = collector.fetchDeclarationMetadata(astDeclaration);\r\n if (declarationMetadata.tsdocParserContext) {\r\n // Typically the comment for a variable declaration is attached to the outer variable statement\r\n // (which may possibly contain multiple variable declarations), so it's not part of the Span.\r\n // Instead we need to manually inject it.\r\n let originalComment: string = declarationMetadata.tsdocParserContext.sourceRange.toString();\r\n if (!/\\r?\\n\\s*$/.test(originalComment)) {\r\n originalComment += '\\n';\r\n }\r\n span.modification.indentDocComment = IndentDocCommentScope.PrefixOnly;\r\n span.modification.prefix = originalComment + span.modification.prefix;\r\n }\r\n }\r\n break;\r\n\r\n case ts.SyntaxKind.Identifier:\r\n {\r\n const referencedEntity: CollectorEntity | undefined = collector.tryGetEntityForNode(\r\n span.node as ts.Identifier\r\n );\r\n\r\n if (referencedEntity) {\r\n if (!referencedEntity.nameForEmit) {\r\n // This should never happen\r\n throw new InternalError('referencedEntry.nameForEmit is undefined');\r\n }\r\n\r\n span.modification.prefix = referencedEntity.nameForEmit;\r\n // For debugging:\r\n // span.modification.prefix += '/*R=FIX*/';\r\n } else {\r\n // For debugging:\r\n // span.modification.prefix += '/*R=KEEP*/';\r\n }\r\n }\r\n break;\r\n\r\n case ts.SyntaxKind.ImportType:\r\n DtsEmitHelpers.modifyImportTypeSpan(\r\n collector,\r\n span,\r\n astDeclaration,\r\n (childSpan, childAstDeclaration) => {\r\n DtsRollupGenerator._modifySpan(collector, childSpan, entity, childAstDeclaration, dtsKind);\r\n }\r\n );\r\n break;\r\n }\r\n\r\n if (recurseChildren) {\r\n for (const child of span.children) {\r\n let childAstDeclaration: AstDeclaration = astDeclaration;\r\n\r\n // Should we trim this node?\r\n let trimmed: boolean = false;\r\n if (AstDeclaration.isSupportedSyntaxKind(child.kind)) {\r\n childAstDeclaration = collector.astSymbolTable.getChildAstDeclarationByNode(\r\n child.node,\r\n astDeclaration\r\n );\r\n const releaseTag: ReleaseTag =\r\n collector.fetchApiItemMetadata(childAstDeclaration).effectiveReleaseTag;\r\n\r\n if (!this._shouldIncludeReleaseTag(releaseTag, dtsKind)) {\r\n let nodeToTrim: Span = child;\r\n\r\n // If we are trimming a variable statement, then we need to trim the outer VariableDeclarationList\r\n // as well.\r\n if (child.kind === ts.SyntaxKind.VariableDeclaration) {\r\n const variableStatement: Span | undefined = child.findFirstParent(\r\n ts.SyntaxKind.VariableStatement\r\n );\r\n if (variableStatement !== undefined) {\r\n nodeToTrim = variableStatement;\r\n }\r\n }\r\n\r\n const modification: SpanModification = nodeToTrim.modification;\r\n\r\n // Yes, trim it and stop here\r\n const name: string = childAstDeclaration.astSymbol.localName;\r\n modification.omitChildren = true;\r\n\r\n if (!collector.extractorConfig.omitTrimmingComments) {\r\n modification.prefix = `/* Excluded from this release type: ${name} */`;\r\n } else {\r\n modification.prefix = '';\r\n }\r\n modification.suffix = '';\r\n\r\n if (nodeToTrim.children.length > 0) {\r\n // If there are grandchildren, then keep the last grandchild's separator,\r\n // since it often has useful whitespace\r\n modification.suffix = nodeToTrim.children[nodeToTrim.children.length - 1].separator;\r\n }\r\n\r\n if (nodeToTrim.nextSibling) {\r\n // If the thing we are trimming is followed by a comma, then trim the comma also.\r\n // An example would be an enum member.\r\n if (nodeToTrim.nextSibling.kind === ts.SyntaxKind.CommaToken) {\r\n // Keep its separator since it often has useful whitespace\r\n modification.suffix += nodeToTrim.nextSibling.separator;\r\n nodeToTrim.nextSibling.modification.skipAll();\r\n }\r\n }\r\n\r\n trimmed = true;\r\n }\r\n }\r\n\r\n if (!trimmed) {\r\n DtsRollupGenerator._modifySpan(collector, child, entity, childAstDeclaration, dtsKind);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static _shouldIncludeReleaseTag(releaseTag: ReleaseTag, dtsKind: DtsRollupKind): boolean {\r\n switch (dtsKind) {\r\n case DtsRollupKind.InternalRelease:\r\n return true;\r\n case DtsRollupKind.BetaRelease:\r\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\r\n return (\r\n releaseTag === ReleaseTag.Beta || releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None\r\n );\r\n case DtsRollupKind.PublicRelease:\r\n return releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None;\r\n default:\r\n throw new Error(`${DtsRollupKind[dtsKind]} is not implemented`);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DtsRollupGenerator.js","sourceRoot":"","sources":["../../src/generators/DtsRollupGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;AAE3D,+BAA+B;AAE/B,+CAAiC;AACjC,oEAAsF;AACtF,wEAA4D;AAG5D,qEAAkE;AAClE,2CAAiF;AACjF,qDAAkD;AAElD,+DAA4D;AAE5D,qDAAkD;AAElD,qDAAkD;AAClD,qDAAkD;AAElD,uEAAoE;AAEpE,yFAAsF;AAGtF;;GAEG;AACH,IAAY,aAoBX;AApBD,WAAY,aAAa;IACvB;;;OAGG;IACH,uEAAe,CAAA;IAEf;;;;OAIG;IACH,+DAAW,CAAA;IAEX;;;;OAIG;IACH,mEAAa,CAAA;AACf,CAAC,EApBW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAoBxB;AAED,MAAa,kBAAkB;IAC7B;;;;OAIG;IACI,MAAM,CAAC,gBAAgB,CAC5B,SAAoB,EACpB,WAAmB,EACnB,OAAsB,EACtB,WAAwB;QAExB,MAAM,MAAM,GAAmB,IAAI,+BAAc,EAAE,CAAC;QACpD,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAEhC,kBAAkB,CAAC,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;QAE3E,8BAAU,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE;YACnD,kBAAkB,EAAE,WAAW;YAC/B,kBAAkB,EAAE,IAAI;SACzB,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,2BAA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AK,gCAAU,CAAC,IAAI,IAAI,UAAU,KAAK,gCAAU,CAAC,MAAM,IAAI,UAAU,KAAK,gCAAU,CAAC,IAAI,CACrG,CAAC;YACJ,KAAK,aAAa,CAAC,aAAa;gBAC9B,OAAO,UAAU,KAAK,gCAAU,CAAC,MAAM,IAAI,UAAU,KAAK,gCAAU,CAAC,IAAI,CAAC;YAC5E;gBACE,MAAM,IAAI,KAAK,CAAC,GAAG,aAAa,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;SACnE;IACH,CAAC;CACF;AAvZD,gDAuZC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable no-bitwise */\n\nimport * as ts from 'typescript';\nimport { FileSystem, NewlineKind, InternalError } from '@rushstack/node-core-library';\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\n\nimport { Collector } from '../collector/Collector';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { IndentDocCommentScope, Span, SpanModification } from '../analyzer/Span';\nimport { AstImport } from '../analyzer/AstImport';\nimport { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport { ApiItemMetadata } from '../collector/ApiItemMetadata';\nimport { AstSymbol } from '../analyzer/AstSymbol';\nimport { SymbolMetadata } from '../collector/SymbolMetadata';\nimport { IndentedWriter } from './IndentedWriter';\nimport { DtsEmitHelpers } from './DtsEmitHelpers';\nimport { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\nimport { AstModuleExportInfo } from '../analyzer/AstModule';\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\nimport { AstEntity } from '../analyzer/AstEntity';\n\n/**\n * Used with DtsRollupGenerator.writeTypingsFile()\n */\nexport enum DtsRollupKind {\n /**\n * Generate a *.d.ts file for an internal release, or for the trimming=false mode.\n * This output file will contain all definitions that are reachable from the entry point.\n */\n InternalRelease,\n\n /**\n * Generate a *.d.ts file for a preview release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@alpha or \\@internal.\n */\n BetaRelease,\n\n /**\n * Generate a *.d.ts file for a public release.\n * This output file will contain all definitions that are reachable from the entry point,\n * except definitions marked as \\@beta, \\@alpha, or \\@internal.\n */\n PublicRelease\n}\n\nexport class DtsRollupGenerator {\n /**\n * Generates the typings file and writes it to disk.\n *\n * @param dtsFilename - The *.d.ts output filename\n */\n public static writeTypingsFile(\n collector: Collector,\n dtsFilename: string,\n dtsKind: DtsRollupKind,\n newlineKind: NewlineKind\n ): void {\n const writer: IndentedWriter = new IndentedWriter();\n writer.trimLeadingSpaces = true;\n\n DtsRollupGenerator._generateTypingsFileContent(collector, writer, dtsKind);\n\n FileSystem.writeFile(dtsFilename, writer.toString(), {\n convertLineEndings: newlineKind,\n ensureFolderExists: true\n });\n }\n\n private static _generateTypingsFileContent(\n collector: Collector,\n writer: IndentedWriter,\n dtsKind: DtsRollupKind\n ): void {\n // Emit the @packageDocumentation comment at the top of the file\n if (collector.workingPackage.tsdocParserContext) {\n writer.trimLeadingSpaces = false;\n writer.writeLine(collector.workingPackage.tsdocParserContext.sourceRange.toString());\n writer.trimLeadingSpaces = true;\n writer.ensureSkippedLine();\n }\n\n // Emit the triple slash directives\n for (const typeDirectiveReference of collector.dtsTypeReferenceDirectives) {\n // https://github.com/microsoft/TypeScript/blob/611ebc7aadd7a44a4c0447698bfda9222a78cb66/src/compiler/declarationEmitter.ts#L162\n writer.writeLine(`/// <reference types=\"${typeDirectiveReference}\" />`);\n }\n for (const libDirectiveReference of collector.dtsLibReferenceDirectives) {\n writer.writeLine(`/// <reference lib=\"${libDirectiveReference}\" />`);\n }\n writer.ensureSkippedLine();\n\n // Emit the imports\n for (const entity of collector.entities) {\n if (entity.astEntity instanceof AstImport) {\n const astImport: AstImport = entity.astEntity;\n\n // For example, if the imported API comes from an external package that supports AEDoc,\n // and it was marked as `@internal`, then don't emit it.\n const symbolMetadata: SymbolMetadata | undefined = collector.tryFetchMetadataForAstEntity(astImport);\n const maxEffectiveReleaseTag: ReleaseTag = symbolMetadata\n ? symbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n\n if (this._shouldIncludeReleaseTag(maxEffectiveReleaseTag, dtsKind)) {\n DtsEmitHelpers.emitImport(writer, entity, astImport);\n }\n }\n }\n writer.ensureSkippedLine();\n\n // Emit the regular declarations\n for (const entity of collector.entities) {\n const astEntity: AstEntity = entity.astEntity;\n const symbolMetadata: SymbolMetadata | undefined = collector.tryFetchMetadataForAstEntity(astEntity);\n const maxEffectiveReleaseTag: ReleaseTag = symbolMetadata\n ? symbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n\n if (!this._shouldIncludeReleaseTag(maxEffectiveReleaseTag, dtsKind)) {\n if (!collector.extractorConfig.omitTrimmingComments) {\n writer.ensureSkippedLine();\n writer.writeLine(`/* Excluded from this release type: ${entity.nameForEmit} */`);\n }\n continue;\n }\n\n if (astEntity instanceof AstSymbol) {\n // Emit all the declarations for this entry\n for (const astDeclaration of astEntity.astDeclarations || []) {\n const apiItemMetadata: ApiItemMetadata = collector.fetchApiItemMetadata(astDeclaration);\n\n if (!this._shouldIncludeReleaseTag(apiItemMetadata.effectiveReleaseTag, dtsKind)) {\n if (!collector.extractorConfig.omitTrimmingComments) {\n writer.ensureSkippedLine();\n writer.writeLine(`/* Excluded declaration from this release type: ${entity.nameForEmit} */`);\n }\n continue;\n } else {\n const span: Span = new Span(astDeclaration.declaration);\n DtsRollupGenerator._modifySpan(collector, span, entity, astDeclaration, dtsKind);\n writer.ensureSkippedLine();\n span.writeModifiedText(writer);\n writer.ensureNewLine();\n }\n }\n }\n\n if (astEntity instanceof AstNamespaceImport) {\n const astModuleExportInfo: AstModuleExportInfo = astEntity.fetchAstModuleExportInfo(collector);\n\n if (entity.nameForEmit === undefined) {\n // This should never happen\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n if (astModuleExportInfo.starExportedExternalModules.size > 0) {\n // We could support this, but we would need to find a way to safely represent it.\n throw new Error(\n `The ${entity.nameForEmit} namespace import includes a start export, which is not supported:\\n` +\n SourceFileLocationFormatter.formatDeclaration(astEntity.declaration)\n );\n }\n\n // Emit a synthetic declaration for the namespace. It will look like this:\n //\n // declare namespace example {\n // export {\n // f1,\n // f2\n // }\n // }\n //\n // Note that we do not try to relocate f1()/f2() to be inside the namespace because other type\n // signatures may reference them directly (without using the namespace qualifier).\n\n writer.ensureSkippedLine();\n if (entity.shouldInlineExport) {\n writer.write('export ');\n }\n writer.writeLine(`declare namespace ${entity.nameForEmit} {`);\n\n // all local exports of local imported module are just references to top-level declarations\n writer.increaseIndent();\n writer.writeLine('export {');\n writer.increaseIndent();\n\n const exportClauses: string[] = [];\n for (const [exportedName, exportedEntity] of astModuleExportInfo.exportedLocalEntities) {\n const collectorEntity: CollectorEntity | undefined =\n collector.tryGetCollectorEntity(exportedEntity);\n if (collectorEntity === undefined) {\n // This should never happen\n // top-level exports of local imported module should be added as collector entities before\n throw new InternalError(\n `Cannot find collector entity for ${entity.nameForEmit}.${exportedEntity.localName}`\n );\n }\n\n if (collectorEntity.nameForEmit === exportedName) {\n exportClauses.push(collectorEntity.nameForEmit);\n } else {\n exportClauses.push(`${collectorEntity.nameForEmit} as ${exportedName}`);\n }\n }\n writer.writeLine(exportClauses.join(',\\n'));\n\n writer.decreaseIndent();\n writer.writeLine('}'); // end of \"export { ... }\"\n writer.decreaseIndent();\n writer.writeLine('}'); // end of \"declare namespace { ... }\"\n }\n\n if (!entity.shouldInlineExport) {\n for (const exportName of entity.exportNames) {\n DtsEmitHelpers.emitNamedExport(writer, exportName, entity);\n }\n }\n\n writer.ensureSkippedLine();\n }\n\n DtsEmitHelpers.emitStarExports(writer, collector);\n\n // Emit \"export { }\" which is a special directive that prevents consumers from importing declarations\n // that don't have an explicit \"export\" modifier.\n writer.ensureSkippedLine();\n writer.writeLine('export { }');\n }\n\n /**\n * Before writing out a declaration, _modifySpan() applies various fixups to make it nice.\n */\n private static _modifySpan(\n collector: Collector,\n span: Span,\n entity: CollectorEntity,\n astDeclaration: AstDeclaration,\n dtsKind: DtsRollupKind\n ): void {\n const previousSpan: Span | undefined = span.previousSibling;\n\n let recurseChildren: boolean = true;\n switch (span.kind) {\n case ts.SyntaxKind.JSDocComment:\n // If the @packageDocumentation comment seems to be attached to one of the regular API items,\n // omit it. It gets explictly emitted at the top of the file.\n if (span.node.getText().match(/(?:\\s|\\*)@packageDocumentation(?:\\s|\\*)/gi)) {\n span.modification.skipAll();\n }\n\n // For now, we don't transform JSDoc comment nodes at all\n recurseChildren = false;\n break;\n\n case ts.SyntaxKind.ExportKeyword:\n case ts.SyntaxKind.DefaultKeyword:\n case ts.SyntaxKind.DeclareKeyword:\n // Delete any explicit \"export\" or \"declare\" keywords -- we will re-add them below\n span.modification.skipAll();\n break;\n\n case ts.SyntaxKind.InterfaceKeyword:\n case ts.SyntaxKind.ClassKeyword:\n case ts.SyntaxKind.EnumKeyword:\n case ts.SyntaxKind.NamespaceKeyword:\n case ts.SyntaxKind.ModuleKeyword:\n case ts.SyntaxKind.TypeKeyword:\n case ts.SyntaxKind.FunctionKeyword:\n // Replace the stuff we possibly deleted above\n let replacedModifiers: string = '';\n\n // Add a declare statement for root declarations (but not for nested declarations)\n if (!astDeclaration.parent) {\n replacedModifiers += 'declare ';\n }\n\n if (entity.shouldInlineExport) {\n replacedModifiers = 'export ' + replacedModifiers;\n }\n\n if (previousSpan && previousSpan.kind === ts.SyntaxKind.SyntaxList) {\n // If there is a previous span of type SyntaxList, then apply it before any other modifiers\n // (e.g. \"abstract\") that appear there.\n previousSpan.modification.prefix = replacedModifiers + previousSpan.modification.prefix;\n } else {\n // Otherwise just stick it in front of this span\n span.modification.prefix = replacedModifiers + span.modification.prefix;\n }\n break;\n\n case ts.SyntaxKind.VariableDeclaration:\n // Is this a top-level variable declaration?\n // (The logic below does not apply to variable declarations that are part of an explicit \"namespace\" block,\n // since the compiler prefers not to emit \"declare\" or \"export\" keywords for those declarations.)\n if (!span.parent) {\n // The VariableDeclaration node is part of a VariableDeclarationList, however\n // the Entry.followedSymbol points to the VariableDeclaration part because\n // multiple definitions might share the same VariableDeclarationList.\n //\n // Since we are emitting a separate declaration for each one, we need to look upwards\n // in the ts.Node tree and write a copy of the enclosing VariableDeclarationList\n // content (e.g. \"var\" from \"var x=1, y=2\").\n const list: ts.VariableDeclarationList | undefined = TypeScriptHelpers.matchAncestor(span.node, [\n ts.SyntaxKind.VariableDeclarationList,\n ts.SyntaxKind.VariableDeclaration\n ]);\n if (!list) {\n // This should not happen unless the compiler API changes somehow\n throw new InternalError('Unsupported variable declaration');\n }\n const listPrefix: string = list\n .getSourceFile()\n .text.substring(list.getStart(), list.declarations[0].getStart());\n span.modification.prefix = 'declare ' + listPrefix + span.modification.prefix;\n span.modification.suffix = ';';\n\n if (entity.shouldInlineExport) {\n span.modification.prefix = 'export ' + span.modification.prefix;\n }\n\n const declarationMetadata: DeclarationMetadata = collector.fetchDeclarationMetadata(astDeclaration);\n if (declarationMetadata.tsdocParserContext) {\n // Typically the comment for a variable declaration is attached to the outer variable statement\n // (which may possibly contain multiple variable declarations), so it's not part of the Span.\n // Instead we need to manually inject it.\n let originalComment: string = declarationMetadata.tsdocParserContext.sourceRange.toString();\n if (!/\\r?\\n\\s*$/.test(originalComment)) {\n originalComment += '\\n';\n }\n span.modification.indentDocComment = IndentDocCommentScope.PrefixOnly;\n span.modification.prefix = originalComment + span.modification.prefix;\n }\n }\n break;\n\n case ts.SyntaxKind.Identifier:\n {\n const referencedEntity: CollectorEntity | undefined = collector.tryGetEntityForNode(\n span.node as ts.Identifier\n );\n\n if (referencedEntity) {\n if (!referencedEntity.nameForEmit) {\n // This should never happen\n throw new InternalError('referencedEntry.nameForEmit is undefined');\n }\n\n span.modification.prefix = referencedEntity.nameForEmit;\n // For debugging:\n // span.modification.prefix += '/*R=FIX*/';\n } else {\n // For debugging:\n // span.modification.prefix += '/*R=KEEP*/';\n }\n }\n break;\n\n case ts.SyntaxKind.ImportType:\n DtsEmitHelpers.modifyImportTypeSpan(\n collector,\n span,\n astDeclaration,\n (childSpan, childAstDeclaration) => {\n DtsRollupGenerator._modifySpan(collector, childSpan, entity, childAstDeclaration, dtsKind);\n }\n );\n break;\n }\n\n if (recurseChildren) {\n for (const child of span.children) {\n let childAstDeclaration: AstDeclaration = astDeclaration;\n\n // Should we trim this node?\n let trimmed: boolean = false;\n if (AstDeclaration.isSupportedSyntaxKind(child.kind)) {\n childAstDeclaration = collector.astSymbolTable.getChildAstDeclarationByNode(\n child.node,\n astDeclaration\n );\n const releaseTag: ReleaseTag =\n collector.fetchApiItemMetadata(childAstDeclaration).effectiveReleaseTag;\n\n if (!this._shouldIncludeReleaseTag(releaseTag, dtsKind)) {\n let nodeToTrim: Span = child;\n\n // If we are trimming a variable statement, then we need to trim the outer VariableDeclarationList\n // as well.\n if (child.kind === ts.SyntaxKind.VariableDeclaration) {\n const variableStatement: Span | undefined = child.findFirstParent(\n ts.SyntaxKind.VariableStatement\n );\n if (variableStatement !== undefined) {\n nodeToTrim = variableStatement;\n }\n }\n\n const modification: SpanModification = nodeToTrim.modification;\n\n // Yes, trim it and stop here\n const name: string = childAstDeclaration.astSymbol.localName;\n modification.omitChildren = true;\n\n if (!collector.extractorConfig.omitTrimmingComments) {\n modification.prefix = `/* Excluded from this release type: ${name} */`;\n } else {\n modification.prefix = '';\n }\n modification.suffix = '';\n\n if (nodeToTrim.children.length > 0) {\n // If there are grandchildren, then keep the last grandchild's separator,\n // since it often has useful whitespace\n modification.suffix = nodeToTrim.children[nodeToTrim.children.length - 1].separator;\n }\n\n if (nodeToTrim.nextSibling) {\n // If the thing we are trimming is followed by a comma, then trim the comma also.\n // An example would be an enum member.\n if (nodeToTrim.nextSibling.kind === ts.SyntaxKind.CommaToken) {\n // Keep its separator since it often has useful whitespace\n modification.suffix += nodeToTrim.nextSibling.separator;\n nodeToTrim.nextSibling.modification.skipAll();\n }\n }\n\n trimmed = true;\n }\n }\n\n if (!trimmed) {\n DtsRollupGenerator._modifySpan(collector, child, entity, childAstDeclaration, dtsKind);\n }\n }\n }\n }\n\n private static _shouldIncludeReleaseTag(releaseTag: ReleaseTag, dtsKind: DtsRollupKind): boolean {\n switch (dtsKind) {\n case DtsRollupKind.InternalRelease:\n return true;\n case DtsRollupKind.BetaRelease:\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n return (\n releaseTag === ReleaseTag.Beta || releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None\n );\n case DtsRollupKind.PublicRelease:\n return releaseTag === ReleaseTag.Public || releaseTag === ReleaseTag.None;\n default:\n throw new Error(`${DtsRollupKind[dtsKind]} is not implemented`);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExcerptBuilder.js","sourceRoot":"","sources":["../../src/generators/ExcerptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,wEAAqG;AAErG,2CAAwC;AAmDxC,MAAa,cAAc;IACzB;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,aAA8B;QACvD,IAAI,QAAQ,GAAW,MAAM,CAAC;QAC9B,kFAAkF;QAClF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,MAAM,YAAY,GAAW,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1E,IAAI,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;gBAC5B,QAAQ,GAAG,IAAI,CAAC;aACjB;SACF;QACD,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,sCAAgB,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAC1B,aAA8B,E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AAC,IAAa;QACzC,QAAQ,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;YACtC,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;YAC7B,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;YACpC,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC;YACnC,KAAK,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC;YACvC,KAAK,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;YACrC,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;YAC/B,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;YAC/B,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;YACxC,KAAK,EAAE,CAAC,UAAU,CAAC,oBAAoB,CAAC;YACxC,KAAK,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC;YACjC,KAAK,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAC9B,KAAK,EAAE,CAAC,UAAU,CAAC,cAAc;gBAC/B,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;CACF;AA7ND,wCA6NC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport * as ts from 'typescript';\r\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\r\nimport { ExcerptTokenKind, IExcerptToken, IExcerptTokenRange } from '@microsoft/api-extractor-model';\r\n\r\nimport { Span } from '../analyzer/Span';\r\nimport { DeclarationReferenceGenerator } from './DeclarationReferenceGenerator';\r\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\r\n\r\n/**\r\n * Used to provide ExcerptBuilder with a list of nodes whose token range we want to capture.\r\n */\r\nexport interface IExcerptBuilderNodeToCapture {\r\n /**\r\n * The node to capture\r\n */\r\n node: ts.Node | undefined;\r\n /**\r\n * The token range whose startIndex/endIndex will be overwritten with the indexes for the\r\n * tokens corresponding to IExcerptBuilderNodeToCapture.node\r\n */\r\n tokenRange: IExcerptTokenRange;\r\n}\r\n\r\n/**\r\n * Internal state for ExcerptBuilder\r\n */\r\ninterface IBuildSpanState {\r\n referenceGenerator: DeclarationReferenceGenerator;\r\n\r\n /**\r\n * The AST node that we will traverse to extract tokens\r\n */\r\n startingNode: ts.Node;\r\n\r\n /**\r\n * Normally, the excerpt will include all child nodes for `startingNode`; whereas if `childKindToStopBefore`\r\n * is specified, then the node traversal will stop before (i.e. excluding) the first immediate child\r\n * of `startingNode` with the specified syntax kind.\r\n *\r\n * @remarks\r\n * For example, suppose the signature is `interface X: Y { z: string }`. The token `{` has syntax kind\r\n * `ts.SyntaxKind.FirstPunctuation`, so we can specify that to truncate the excerpt to `interface X: Y`.\r\n */\r\n stopBeforeChildKind: ts.SyntaxKind | undefined;\r\n\r\n tokenRangesByNode: Map<ts.Node, IExcerptTokenRange>;\r\n\r\n /**\r\n * Normally adjacent tokens of the same kind get merged, to avoid creating lots of unnecessary extra tokens.\r\n * However when an captured excerpt needs to start/end at a specific character, we temporarily disable merging by\r\n * setting this flag. After the new token is added, this flag is cleared.\r\n */\r\n disableMergingForNextToken: boolean;\r\n}\r\n\r\nexport class ExcerptBuilder {\r\n /**\r\n * Appends a blank line to the `excerptTokens` list.\r\n * @param excerptTokens - The target token list to append to\r\n */\r\n public static addBlankLine(excerptTokens: IExcerptToken[]): void {\r\n let newlines: string = '\\n\\n';\r\n // If the existing text already ended with a newline, then only append one newline\r\n if (excerptTokens.length > 0) {\r\n const previousText: string = excerptTokens[excerptTokens.length - 1].text;\r\n if (/\\n$/.test(previousText)) {\r\n newlines = '\\n';\r\n }\r\n }\r\n excerptTokens.push({ kind: ExcerptTokenKind.Content, text: newlines });\r\n }\r\n\r\n /**\r\n * Appends the signature for the specified `AstDeclaration` to the `excerptTokens` list.\r\n * @param excerptTokens - The target token list to append to\r\n * @param nodesToCapture - A list of child nodes whose token ranges we want to capture\r\n */\r\n public static addDeclaration(\r\n excerptTokens: IExcerptToken[],\r\n astDeclaration: AstDeclaration,\r\n nodesToCapture: IExcerptBuilderNodeToCapture[],\r\n referenceGenerator: DeclarationReferenceGenerator\r\n ): void {\r\n let stopBeforeChildKind: ts.SyntaxKind | undefined = undefined;\r\n\r\n switch (astDeclaration.declaration.kind) {\r\n case ts.SyntaxKind.ClassDeclaration:\r\n case ts.SyntaxKind.EnumDeclaration:\r\n case ts.SyntaxKind.InterfaceDeclaration:\r\n // FirstPunctuation = \"{\"\r\n stopBeforeChildKind = ts.SyntaxKind.FirstPunctuation;\r\n break;\r\n case ts.SyntaxKind.ModuleDeclaration:\r\n // ModuleBlock = the \"{ ... }\" block\r\n stopBeforeChildKind = ts.SyntaxKind.ModuleBlock;\r\n break;\r\n }\r\n\r\n const span: Span = new Span(astDeclaration.declaration);\r\n\r\n const tokenRangesByNode: Map<ts.Node, IExcerptTokenRange> = new Map<ts.Node, IExcerptTokenRange>();\r\n for (const excerpt of nodesToCapture || []) {\r\n if (excerpt.node) {\r\n tokenRangesByNode.set(excerpt.node, excerpt.tokenRange);\r\n }\r\n }\r\n\r\n ExcerptBuilder._buildSpan(excerptTokens, span, {\r\n referenceGenerator: referenceGenerator,\r\n startingNode: span.node,\r\n stopBeforeChildKind,\r\n tokenRangesByNode,\r\n disableMergingForNextToken: false\r\n });\r\n }\r\n\r\n public static createEmptyTokenRange(): IExcerptTokenRange {\r\n return { startIndex: 0, endIndex: 0 };\r\n }\r\n\r\n private static _buildSpan(excerptTokens: IExcerptToken[], span: Span, state: IBuildSpanState): boolean {\r\n if (span.kind === ts.SyntaxKind.JSDocComment) {\r\n // Discard any comments\r\n return true;\r\n }\r\n\r\n // Can this node start a excerpt?\r\n const capturedTokenRange: IExcerptTokenRange | undefined = state.tokenRangesByNode.get(span.node);\r\n let excerptStartIndex: number = 0;\r\n\r\n if (capturedTokenRange) {\r\n // We will assign capturedTokenRange.startIndex to be the index of the next token to be appended\r\n excerptStartIndex = excerptTokens.length;\r\n state.disableMergingForNextToken = true;\r\n }\r\n\r\n if (span.prefix) {\r\n let canonicalReference: DeclarationReference | undefined = undefined;\r\n\r\n if (span.kind === ts.SyntaxKind.Identifier) {\r\n const name: ts.Identifier = span.node as ts.Identifier;\r\n if (!ExcerptBuilder._isDeclarationName(name)) {\r\n canonicalReference = state.referenceGenerator.getDeclarationReferenceForIdentifier(name);\r\n }\r\n }\r\n\r\n if (canonicalReference) {\r\n ExcerptBuilder._appendToken(\r\n excerptTokens,\r\n ExcerptTokenKind.Reference,\r\n span.prefix,\r\n state,\r\n canonicalReference\r\n );\r\n } else {\r\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.prefix, state);\r\n }\r\n }\r\n\r\n for (const child of span.children) {\r\n if (span.node === state.startingNode) {\r\n if (state.stopBeforeChildKind && child.kind === state.stopBeforeChildKind) {\r\n // We reached the a child whose kind is stopBeforeChildKind, so stop traversing\r\n return false;\r\n }\r\n }\r\n\r\n if (!this._buildSpan(excerptTokens, child, state)) {\r\n return false;\r\n }\r\n }\r\n\r\n if (span.suffix) {\r\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.suffix, state);\r\n }\r\n if (span.separator) {\r\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.separator, state);\r\n }\r\n\r\n // Are we building a excerpt? If so, set its range\r\n if (capturedTokenRange) {\r\n capturedTokenRange.startIndex = excerptStartIndex;\r\n\r\n // We will assign capturedTokenRange.startIndex to be the index after the last token that was appended so far\r\n capturedTokenRange.endIndex = excerptTokens.length;\r\n\r\n state.disableMergingForNextToken = true;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private static _appendToken(\r\n excerptTokens: IExcerptToken[],\r\n excerptTokenKind: ExcerptTokenKind,\r\n text: string,\r\n state: IBuildSpanState,\r\n canonicalReference?: DeclarationReference\r\n ): void {\r\n if (text.length === 0) {\r\n return;\r\n }\r\n\r\n if (excerptTokenKind !== ExcerptTokenKind.Content) {\r\n if (\r\n excerptTokenKind === ExcerptTokenKind.Reference &&\r\n excerptTokens.length > 1 &&\r\n !state.disableMergingForNextToken\r\n ) {\r\n // If the previous two tokens were a Reference and a '.', then concatenate\r\n // all three tokens as a qualified name Reference.\r\n const previousTokenM1: IExcerptToken = excerptTokens[excerptTokens.length - 1];\r\n const previousTokenM2: IExcerptToken = excerptTokens[excerptTokens.length - 2];\r\n if (\r\n previousTokenM1.kind === ExcerptTokenKind.Content &&\r\n previousTokenM1.text.trim() === '.' &&\r\n previousTokenM2.kind === ExcerptTokenKind.Reference\r\n ) {\r\n previousTokenM2.text += '.' + text;\r\n if (canonicalReference !== undefined) {\r\n previousTokenM2.canonicalReference = canonicalReference.toString();\r\n }\r\n excerptTokens.pop(); // remove previousTokenM1;\r\n return;\r\n }\r\n }\r\n } else {\r\n // If someone referenced this index, then we need to start a new token\r\n if (excerptTokens.length > 0 && !state.disableMergingForNextToken) {\r\n // Otherwise, can we merge with the previous token?\r\n const previousToken: IExcerptToken = excerptTokens[excerptTokens.length - 1];\r\n if (previousToken.kind === excerptTokenKind) {\r\n previousToken.text += text;\r\n return;\r\n }\r\n }\r\n }\r\n\r\n const excerptToken: IExcerptToken = { kind: excerptTokenKind, text: text };\r\n if (canonicalReference !== undefined) {\r\n excerptToken.canonicalReference = canonicalReference.toString();\r\n }\r\n excerptTokens.push(excerptToken);\r\n state.disableMergingForNextToken = false;\r\n }\r\n\r\n private static _isDeclarationName(name: ts.Identifier): boolean {\r\n return ExcerptBuilder._isDeclaration(name.parent) && name.parent.name === name;\r\n }\r\n\r\n private static _isDeclaration(node: ts.Node): node is ts.NamedDeclaration {\r\n switch (node.kind) {\r\n case ts.SyntaxKind.FunctionDeclaration:\r\n case ts.SyntaxKind.FunctionExpression:\r\n case ts.SyntaxKind.VariableDeclaration:\r\n case ts.SyntaxKind.Parameter:\r\n case ts.SyntaxKind.EnumDeclaration:\r\n case ts.SyntaxKind.ClassDeclaration:\r\n case ts.SyntaxKind.ClassExpression:\r\n case ts.SyntaxKind.ModuleDeclaration:\r\n case ts.SyntaxKind.MethodDeclaration:\r\n case ts.SyntaxKind.MethodSignature:\r\n case ts.SyntaxKind.PropertyDeclaration:\r\n case ts.SyntaxKind.PropertySignature:\r\n case ts.SyntaxKind.GetAccessor:\r\n case ts.SyntaxKind.SetAccessor:\r\n case ts.SyntaxKind.InterfaceDeclaration:\r\n case ts.SyntaxKind.TypeAliasDeclaration:\r\n case ts.SyntaxKind.TypeParameter:\r\n case ts.SyntaxKind.EnumMember:\r\n case ts.SyntaxKind.BindingElement:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ExcerptBuilder.js","sourceRoot":"","sources":["../../src/generators/ExcerptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,wEAAqG;AAErG,2CAAwC;AAmDxC,MAAa,cAAc;IACzB;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,aAA8B;QACvD,IAAI,QAAQ,GAAW,MAAM,CAAC;QAC9B,kFAAkF;QAClF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,MAAM,YAAY,GAAW,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1E,IAAI,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AU,CAAC,cAAc;gBAC/B,OAAO,IAAI,CAAC;YACd;gBACE,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;CACF;AA7ND,wCA6NC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as ts from 'typescript';\nimport { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport { ExcerptTokenKind, IExcerptToken, IExcerptTokenRange } from '@microsoft/api-extractor-model';\n\nimport { Span } from '../analyzer/Span';\nimport { DeclarationReferenceGenerator } from './DeclarationReferenceGenerator';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\n\n/**\n * Used to provide ExcerptBuilder with a list of nodes whose token range we want to capture.\n */\nexport interface IExcerptBuilderNodeToCapture {\n /**\n * The node to capture\n */\n node: ts.Node | undefined;\n /**\n * The token range whose startIndex/endIndex will be overwritten with the indexes for the\n * tokens corresponding to IExcerptBuilderNodeToCapture.node\n */\n tokenRange: IExcerptTokenRange;\n}\n\n/**\n * Internal state for ExcerptBuilder\n */\ninterface IBuildSpanState {\n referenceGenerator: DeclarationReferenceGenerator;\n\n /**\n * The AST node that we will traverse to extract tokens\n */\n startingNode: ts.Node;\n\n /**\n * Normally, the excerpt will include all child nodes for `startingNode`; whereas if `childKindToStopBefore`\n * is specified, then the node traversal will stop before (i.e. excluding) the first immediate child\n * of `startingNode` with the specified syntax kind.\n *\n * @remarks\n * For example, suppose the signature is `interface X: Y { z: string }`. The token `{` has syntax kind\n * `ts.SyntaxKind.FirstPunctuation`, so we can specify that to truncate the excerpt to `interface X: Y`.\n */\n stopBeforeChildKind: ts.SyntaxKind | undefined;\n\n tokenRangesByNode: Map<ts.Node, IExcerptTokenRange>;\n\n /**\n * Normally adjacent tokens of the same kind get merged, to avoid creating lots of unnecessary extra tokens.\n * However when an captured excerpt needs to start/end at a specific character, we temporarily disable merging by\n * setting this flag. After the new token is added, this flag is cleared.\n */\n disableMergingForNextToken: boolean;\n}\n\nexport class ExcerptBuilder {\n /**\n * Appends a blank line to the `excerptTokens` list.\n * @param excerptTokens - The target token list to append to\n */\n public static addBlankLine(excerptTokens: IExcerptToken[]): void {\n let newlines: string = '\\n\\n';\n // If the existing text already ended with a newline, then only append one newline\n if (excerptTokens.length > 0) {\n const previousText: string = excerptTokens[excerptTokens.length - 1].text;\n if (/\\n$/.test(previousText)) {\n newlines = '\\n';\n }\n }\n excerptTokens.push({ kind: ExcerptTokenKind.Content, text: newlines });\n }\n\n /**\n * Appends the signature for the specified `AstDeclaration` to the `excerptTokens` list.\n * @param excerptTokens - The target token list to append to\n * @param nodesToCapture - A list of child nodes whose token ranges we want to capture\n */\n public static addDeclaration(\n excerptTokens: IExcerptToken[],\n astDeclaration: AstDeclaration,\n nodesToCapture: IExcerptBuilderNodeToCapture[],\n referenceGenerator: DeclarationReferenceGenerator\n ): void {\n let stopBeforeChildKind: ts.SyntaxKind | undefined = undefined;\n\n switch (astDeclaration.declaration.kind) {\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.InterfaceDeclaration:\n // FirstPunctuation = \"{\"\n stopBeforeChildKind = ts.SyntaxKind.FirstPunctuation;\n break;\n case ts.SyntaxKind.ModuleDeclaration:\n // ModuleBlock = the \"{ ... }\" block\n stopBeforeChildKind = ts.SyntaxKind.ModuleBlock;\n break;\n }\n\n const span: Span = new Span(astDeclaration.declaration);\n\n const tokenRangesByNode: Map<ts.Node, IExcerptTokenRange> = new Map<ts.Node, IExcerptTokenRange>();\n for (const excerpt of nodesToCapture || []) {\n if (excerpt.node) {\n tokenRangesByNode.set(excerpt.node, excerpt.tokenRange);\n }\n }\n\n ExcerptBuilder._buildSpan(excerptTokens, span, {\n referenceGenerator: referenceGenerator,\n startingNode: span.node,\n stopBeforeChildKind,\n tokenRangesByNode,\n disableMergingForNextToken: false\n });\n }\n\n public static createEmptyTokenRange(): IExcerptTokenRange {\n return { startIndex: 0, endIndex: 0 };\n }\n\n private static _buildSpan(excerptTokens: IExcerptToken[], span: Span, state: IBuildSpanState): boolean {\n if (span.kind === ts.SyntaxKind.JSDocComment) {\n // Discard any comments\n return true;\n }\n\n // Can this node start a excerpt?\n const capturedTokenRange: IExcerptTokenRange | undefined = state.tokenRangesByNode.get(span.node);\n let excerptStartIndex: number = 0;\n\n if (capturedTokenRange) {\n // We will assign capturedTokenRange.startIndex to be the index of the next token to be appended\n excerptStartIndex = excerptTokens.length;\n state.disableMergingForNextToken = true;\n }\n\n if (span.prefix) {\n let canonicalReference: DeclarationReference | undefined = undefined;\n\n if (span.kind === ts.SyntaxKind.Identifier) {\n const name: ts.Identifier = span.node as ts.Identifier;\n if (!ExcerptBuilder._isDeclarationName(name)) {\n canonicalReference = state.referenceGenerator.getDeclarationReferenceForIdentifier(name);\n }\n }\n\n if (canonicalReference) {\n ExcerptBuilder._appendToken(\n excerptTokens,\n ExcerptTokenKind.Reference,\n span.prefix,\n state,\n canonicalReference\n );\n } else {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.prefix, state);\n }\n }\n\n for (const child of span.children) {\n if (span.node === state.startingNode) {\n if (state.stopBeforeChildKind && child.kind === state.stopBeforeChildKind) {\n // We reached the a child whose kind is stopBeforeChildKind, so stop traversing\n return false;\n }\n }\n\n if (!this._buildSpan(excerptTokens, child, state)) {\n return false;\n }\n }\n\n if (span.suffix) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.suffix, state);\n }\n if (span.separator) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.separator, state);\n }\n\n // Are we building a excerpt? If so, set its range\n if (capturedTokenRange) {\n capturedTokenRange.startIndex = excerptStartIndex;\n\n // We will assign capturedTokenRange.startIndex to be the index after the last token that was appended so far\n capturedTokenRange.endIndex = excerptTokens.length;\n\n state.disableMergingForNextToken = true;\n }\n\n return true;\n }\n\n private static _appendToken(\n excerptTokens: IExcerptToken[],\n excerptTokenKind: ExcerptTokenKind,\n text: string,\n state: IBuildSpanState,\n canonicalReference?: DeclarationReference\n ): void {\n if (text.length === 0) {\n return;\n }\n\n if (excerptTokenKind !== ExcerptTokenKind.Content) {\n if (\n excerptTokenKind === ExcerptTokenKind.Reference &&\n excerptTokens.length > 1 &&\n !state.disableMergingForNextToken\n ) {\n // If the previous two tokens were a Reference and a '.', then concatenate\n // all three tokens as a qualified name Reference.\n const previousTokenM1: IExcerptToken = excerptTokens[excerptTokens.length - 1];\n const previousTokenM2: IExcerptToken = excerptTokens[excerptTokens.length - 2];\n if (\n previousTokenM1.kind === ExcerptTokenKind.Content &&\n previousTokenM1.text.trim() === '.' &&\n previousTokenM2.kind === ExcerptTokenKind.Reference\n ) {\n previousTokenM2.text += '.' + text;\n if (canonicalReference !== undefined) {\n previousTokenM2.canonicalReference = canonicalReference.toString();\n }\n excerptTokens.pop(); // remove previousTokenM1;\n return;\n }\n }\n } else {\n // If someone referenced this index, then we need to start a new token\n if (excerptTokens.length > 0 && !state.disableMergingForNextToken) {\n // Otherwise, can we merge with the previous token?\n const previousToken: IExcerptToken = excerptTokens[excerptTokens.length - 1];\n if (previousToken.kind === excerptTokenKind) {\n previousToken.text += text;\n return;\n }\n }\n }\n\n const excerptToken: IExcerptToken = { kind: excerptTokenKind, text: text };\n if (canonicalReference !== undefined) {\n excerptToken.canonicalReference = canonicalReference.toString();\n }\n excerptTokens.push(excerptToken);\n state.disableMergingForNextToken = false;\n }\n\n private static _isDeclarationName(name: ts.Identifier): boolean {\n return ExcerptBuilder._isDeclaration(name.parent) && name.parent.name === name;\n }\n\n private static _isDeclaration(node: ts.Node): node is ts.NamedDeclaration {\n switch (node.kind) {\n case ts.SyntaxKind.FunctionDeclaration:\n case ts.SyntaxKind.FunctionExpression:\n case ts.SyntaxKind.VariableDeclaration:\n case ts.SyntaxKind.Parameter:\n case ts.SyntaxKind.EnumDeclaration:\n case ts.SyntaxKind.ClassDeclaration:\n case ts.SyntaxKind.ClassExpression:\n case ts.SyntaxKind.ModuleDeclaration:\n case ts.SyntaxKind.MethodDeclaration:\n case ts.SyntaxKind.MethodSignature:\n case ts.SyntaxKind.PropertyDeclaration:\n case ts.SyntaxKind.PropertySignature:\n case ts.SyntaxKind.GetAccessor:\n case ts.SyntaxKind.SetAccessor:\n case ts.SyntaxKind.InterfaceDeclaration:\n case ts.SyntaxKind.TypeAliasDeclaration:\n case ts.SyntaxKind.TypeParameter:\n case ts.SyntaxKind.EnumMember:\n case ts.SyntaxKind.BindingElement:\n return true;\n default:\n return false;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IndentedWriter.js","sourceRoot":"","sources":["../../src/generators/IndentedWriter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAA6E;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,cAAc;IAoDzB,YAAmB,OAAwB;QAnD3C;;;WAGG;QACI,wBAAmB,GAAW,MAAM,CAAC;QAE5C;;WAEG;QACI,qBAAgB,GAAY,KAAK,CAAC;QAEzC;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACI,sBAAiB,GAAY,KAAK,CAAC;QAexC,IAAI,CAAC,QAAQ,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,iCAAa,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAEhC,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,Q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O,iBAAiB;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;CACF;AAjPD,wCAiPC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { StringBuilder, IStringBuilder } from '@rushstack/node-core-library';\r\n\r\n/**\r\n * A utility for writing indented text.\r\n *\r\n * @remarks\r\n *\r\n * Note that the indentation is inserted at the last possible opportunity.\r\n * For example, this code...\r\n *\r\n * ```ts\r\n * writer.write('begin\\n');\r\n * writer.increaseIndent();\r\n * writer.write('one\\ntwo\\n');\r\n * writer.decreaseIndent();\r\n * writer.increaseIndent();\r\n * writer.decreaseIndent();\r\n * writer.write('end');\r\n * ```\r\n *\r\n * ...would produce this output:\r\n *\r\n * ```\r\n * begin\r\n * one\r\n * two\r\n * end\r\n * ```\r\n */\r\nexport class IndentedWriter {\r\n /**\r\n * The text characters used to create one level of indentation.\r\n * Two spaces by default.\r\n */\r\n public defaultIndentPrefix: string = ' ';\r\n\r\n /**\r\n * Whether to indent blank lines\r\n */\r\n public indentBlankLines: boolean = false;\r\n\r\n /**\r\n * Trims leading spaces from the input text before applying the indent.\r\n *\r\n * @remarks\r\n * Consider the following example:\r\n *\r\n * ```ts\r\n * indentedWriter.increaseIndent(' '); // four spaces\r\n * indentedWriter.write(' a\\n b c\\n');\r\n * indentedWriter.decreaseIndent();\r\n * ```\r\n *\r\n * Normally the output would be indented by 6 spaces: 4 from `increaseIndent()`, plus the 2 spaces\r\n * from `write()`:\r\n * ```\r\n * a\r\n * b c\r\n * ```\r\n *\r\n * Setting `trimLeadingSpaces=true` will trim the leading spaces, so that the lines are indented\r\n * by 4 spaces only:\r\n * ```\r\n * a\r\n * b c\r\n * ```\r\n */\r\n public trimLeadingSpaces: boolean = false;\r\n\r\n private readonly _builder: IStringBuilder;\r\n\r\n private _latestChunk: string | undefined;\r\n private _previousChunk: string | undefined;\r\n private _atStartOfLine: boolean;\r\n\r\n private readonly _indentStack: string[];\r\n private _indentText: string;\r\n\r\n private _previousLineIsBlank: boolean;\r\n private _currentLineIsBlank: boolean;\r\n\r\n public constructor(builder?: IStringBuilder) {\r\n this._builder = builder === undefined ? new StringBuilder() : builder;\r\n this._latestChunk = undefined;\r\n this._previousChunk = undefined;\r\n this._atStartOfLine = true;\r\n this._previousLineIsBlank = true;\r\n this._currentLineIsBlank = true;\r\n\r\n this._indentStack = [];\r\n this._indentText = '';\r\n }\r\n\r\n /**\r\n * Retrieves the output that was built so far.\r\n */\r\n public getText(): string {\r\n return this._builder.toString();\r\n }\r\n\r\n public toString(): string {\r\n return this.getText();\r\n }\r\n\r\n /**\r\n * Increases the indentation. Normally the indentation is two spaces,\r\n * however an arbitrary prefix can optional be specified. (For example,\r\n * the prefix could be \"// \" to indent and comment simultaneously.)\r\n * Each call to IndentedWriter.increaseIndent() must be followed by a\r\n * corresponding call to IndentedWriter.decreaseIndent().\r\n */\r\n public increaseIndent(indentPrefix?: string): void {\r\n this._indentStack.push(indentPrefix !== undefined ? indentPrefix : this.defaultIndentPrefix);\r\n this._updateIndentText();\r\n }\r\n\r\n /**\r\n * Decreases the indentation, reverting the effect of the corresponding call\r\n * to IndentedWriter.increaseIndent().\r\n */\r\n public decreaseIndent(): void {\r\n this._indentStack.pop();\r\n this._updateIndentText();\r\n }\r\n\r\n /**\r\n * A shorthand for ensuring that increaseIndent()/decreaseIndent() occur\r\n * in pairs.\r\n */\r\n public indentScope(scope: () => void, indentPrefix?: string): void {\r\n this.increaseIndent(indentPrefix);\r\n scope();\r\n this.decreaseIndent();\r\n }\r\n\r\n /**\r\n * Adds a newline if the file pointer is not already at the start of the line (or start of the stream).\r\n */\r\n public ensureNewLine(): void {\r\n const lastCharacter: string = this.peekLastCharacter();\r\n if (lastCharacter !== '\\n' && lastCharacter !== '') {\r\n this._writeNewLine();\r\n }\r\n }\r\n\r\n /**\r\n * Adds up to two newlines to ensure that there is a blank line above the current position.\r\n * The start of the stream is considered to be a blank line, so `ensureSkippedLine()` has no effect\r\n * unless some text has been written.\r\n */\r\n public ensureSkippedLine(): void {\r\n this.ensureNewLine();\r\n if (!this._previousLineIsBlank) {\r\n this._writeNewLine();\r\n }\r\n }\r\n\r\n /**\r\n * Returns the last character that was written, or an empty string if no characters have been written yet.\r\n */\r\n public peekLastCharacter(): string {\r\n if (this._latestChunk !== undefined) {\r\n return this._latestChunk.substr(-1, 1);\r\n }\r\n return '';\r\n }\r\n\r\n /**\r\n * Returns the second to last character that was written, or an empty string if less than one characters\r\n * have been written yet.\r\n */\r\n public peekSecondLastCharacter(): string {\r\n if (this._latestChunk !== undefined) {\r\n if (this._latestChunk.length > 1) {\r\n return this._latestChunk.substr(-2, 1);\r\n }\r\n if (this._previousChunk !== undefined) {\r\n return this._previousChunk.substr(-1, 1);\r\n }\r\n }\r\n return '';\r\n }\r\n\r\n /**\r\n * Writes some text to the internal string buffer, applying indentation according\r\n * to the current indentation level. If the string contains multiple newlines,\r\n * each line will be indented separately.\r\n */\r\n public write(message: string): void {\r\n if (message.length === 0) {\r\n return;\r\n }\r\n\r\n // If there are no newline characters, then append the string verbatim\r\n if (!/[\\r\\n]/.test(message)) {\r\n this._writeLinePart(message);\r\n return;\r\n }\r\n\r\n // Otherwise split the lines and write each one individually\r\n let first: boolean = true;\r\n for (const linePart of message.split('\\n')) {\r\n if (!first) {\r\n this._writeNewLine();\r\n } else {\r\n first = false;\r\n }\r\n if (linePart) {\r\n this._writeLinePart(linePart.replace(/[\\r]/g, ''));\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * A shorthand for writing an optional message, followed by a newline.\r\n * Indentation is applied following the semantics of IndentedWriter.write().\r\n */\r\n public writeLine(message: string = ''): void {\r\n if (message.length > 0) {\r\n this.write(message);\r\n }\r\n this._writeNewLine();\r\n }\r\n\r\n /**\r\n * Writes a string that does not contain any newline characters.\r\n */\r\n private _writeLinePart(message: string): void {\r\n let trimmedMessage: string = message;\r\n\r\n if (this.trimLeadingSpaces && this._atStartOfLine) {\r\n trimmedMessage = message.replace(/^ +/, '');\r\n }\r\n\r\n if (trimmedMessage.length > 0) {\r\n if (this._atStartOfLine && this._indentText.length > 0) {\r\n this._write(this._indentText);\r\n }\r\n this._write(trimmedMessage);\r\n if (this._currentLineIsBlank) {\r\n if (/\\S/.test(trimmedMessage)) {\r\n this._currentLineIsBlank = false;\r\n }\r\n }\r\n this._atStartOfLine = false;\r\n }\r\n }\r\n\r\n private _writeNewLine(): void {\r\n if (this.indentBlankLines) {\r\n if (this._atStartOfLine && this._indentText.length > 0) {\r\n this._write(this._indentText);\r\n }\r\n }\r\n\r\n this._previousLineIsBlank = this._currentLineIsBlank;\r\n this._write('\\n');\r\n this._currentLineIsBlank = true;\r\n this._atStartOfLine = true;\r\n }\r\n\r\n private _write(s: string): void {\r\n this._previousChunk = this._latestChunk;\r\n this._latestChunk = s;\r\n this._builder.append(s);\r\n }\r\n\r\n private _updateIndentText(): void {\r\n this._indentText = this._indentStack.join('');\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IndentedWriter.js","sourceRoot":"","sources":["../../src/generators/IndentedWriter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,oEAA6E;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,cAAc;IAoDzB,YAAmB,OAAwB;QAnD3C;;;WAGG;QACI,wBAAmB,GAAW,MAAM,CAAC;QAE5C;;WAEG;QACI,qBAAgB,GAAY,KAAK,CAAC;QAEzC;;;;;;;;;;;;;;;;;;;;;;;;;WAyBG;QACI,sBAAiB,GAAY,KAAK,CAAC;QAexC,IAAI,CAAC,QAAQ,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,iCAAa,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAC9B,IAAI,CAAC,cA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;QAClB,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,CAAC;IAEO,MAAM,CAAC,CAAS;QACtB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChD,CAAC;CACF;AAjPD,wCAiPC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { StringBuilder, IStringBuilder } from '@rushstack/node-core-library';\n\n/**\n * A utility for writing indented text.\n *\n * @remarks\n *\n * Note that the indentation is inserted at the last possible opportunity.\n * For example, this code...\n *\n * ```ts\n * writer.write('begin\\n');\n * writer.increaseIndent();\n * writer.write('one\\ntwo\\n');\n * writer.decreaseIndent();\n * writer.increaseIndent();\n * writer.decreaseIndent();\n * writer.write('end');\n * ```\n *\n * ...would produce this output:\n *\n * ```\n * begin\n * one\n * two\n * end\n * ```\n */\nexport class IndentedWriter {\n /**\n * The text characters used to create one level of indentation.\n * Two spaces by default.\n */\n public defaultIndentPrefix: string = ' ';\n\n /**\n * Whether to indent blank lines\n */\n public indentBlankLines: boolean = false;\n\n /**\n * Trims leading spaces from the input text before applying the indent.\n *\n * @remarks\n * Consider the following example:\n *\n * ```ts\n * indentedWriter.increaseIndent(' '); // four spaces\n * indentedWriter.write(' a\\n b c\\n');\n * indentedWriter.decreaseIndent();\n * ```\n *\n * Normally the output would be indented by 6 spaces: 4 from `increaseIndent()`, plus the 2 spaces\n * from `write()`:\n * ```\n * a\n * b c\n * ```\n *\n * Setting `trimLeadingSpaces=true` will trim the leading spaces, so that the lines are indented\n * by 4 spaces only:\n * ```\n * a\n * b c\n * ```\n */\n public trimLeadingSpaces: boolean = false;\n\n private readonly _builder: IStringBuilder;\n\n private _latestChunk: string | undefined;\n private _previousChunk: string | undefined;\n private _atStartOfLine: boolean;\n\n private readonly _indentStack: string[];\n private _indentText: string;\n\n private _previousLineIsBlank: boolean;\n private _currentLineIsBlank: boolean;\n\n public constructor(builder?: IStringBuilder) {\n this._builder = builder === undefined ? new StringBuilder() : builder;\n this._latestChunk = undefined;\n this._previousChunk = undefined;\n this._atStartOfLine = true;\n this._previousLineIsBlank = true;\n this._currentLineIsBlank = true;\n\n this._indentStack = [];\n this._indentText = '';\n }\n\n /**\n * Retrieves the output that was built so far.\n */\n public getText(): string {\n return this._builder.toString();\n }\n\n public toString(): string {\n return this.getText();\n }\n\n /**\n * Increases the indentation. Normally the indentation is two spaces,\n * however an arbitrary prefix can optional be specified. (For example,\n * the prefix could be \"// \" to indent and comment simultaneously.)\n * Each call to IndentedWriter.increaseIndent() must be followed by a\n * corresponding call to IndentedWriter.decreaseIndent().\n */\n public increaseIndent(indentPrefix?: string): void {\n this._indentStack.push(indentPrefix !== undefined ? indentPrefix : this.defaultIndentPrefix);\n this._updateIndentText();\n }\n\n /**\n * Decreases the indentation, reverting the effect of the corresponding call\n * to IndentedWriter.increaseIndent().\n */\n public decreaseIndent(): void {\n this._indentStack.pop();\n this._updateIndentText();\n }\n\n /**\n * A shorthand for ensuring that increaseIndent()/decreaseIndent() occur\n * in pairs.\n */\n public indentScope(scope: () => void, indentPrefix?: string): void {\n this.increaseIndent(indentPrefix);\n scope();\n this.decreaseIndent();\n }\n\n /**\n * Adds a newline if the file pointer is not already at the start of the line (or start of the stream).\n */\n public ensureNewLine(): void {\n const lastCharacter: string = this.peekLastCharacter();\n if (lastCharacter !== '\\n' && lastCharacter !== '') {\n this._writeNewLine();\n }\n }\n\n /**\n * Adds up to two newlines to ensure that there is a blank line above the current position.\n * The start of the stream is considered to be a blank line, so `ensureSkippedLine()` has no effect\n * unless some text has been written.\n */\n public ensureSkippedLine(): void {\n this.ensureNewLine();\n if (!this._previousLineIsBlank) {\n this._writeNewLine();\n }\n }\n\n /**\n * Returns the last character that was written, or an empty string if no characters have been written yet.\n */\n public peekLastCharacter(): string {\n if (this._latestChunk !== undefined) {\n return this._latestChunk.substr(-1, 1);\n }\n return '';\n }\n\n /**\n * Returns the second to last character that was written, or an empty string if less than one characters\n * have been written yet.\n */\n public peekSecondLastCharacter(): string {\n if (this._latestChunk !== undefined) {\n if (this._latestChunk.length > 1) {\n return this._latestChunk.substr(-2, 1);\n }\n if (this._previousChunk !== undefined) {\n return this._previousChunk.substr(-1, 1);\n }\n }\n return '';\n }\n\n /**\n * Writes some text to the internal string buffer, applying indentation according\n * to the current indentation level. If the string contains multiple newlines,\n * each line will be indented separately.\n */\n public write(message: string): void {\n if (message.length === 0) {\n return;\n }\n\n // If there are no newline characters, then append the string verbatim\n if (!/[\\r\\n]/.test(message)) {\n this._writeLinePart(message);\n return;\n }\n\n // Otherwise split the lines and write each one individually\n let first: boolean = true;\n for (const linePart of message.split('\\n')) {\n if (!first) {\n this._writeNewLine();\n } else {\n first = false;\n }\n if (linePart) {\n this._writeLinePart(linePart.replace(/[\\r]/g, ''));\n }\n }\n }\n\n /**\n * A shorthand for writing an optional message, followed by a newline.\n * Indentation is applied following the semantics of IndentedWriter.write().\n */\n public writeLine(message: string = ''): void {\n if (message.length > 0) {\n this.write(message);\n }\n this._writeNewLine();\n }\n\n /**\n * Writes a string that does not contain any newline characters.\n */\n private _writeLinePart(message: string): void {\n let trimmedMessage: string = message;\n\n if (this.trimLeadingSpaces && this._atStartOfLine) {\n trimmedMessage = message.replace(/^ +/, '');\n }\n\n if (trimmedMessage.length > 0) {\n if (this._atStartOfLine && this._indentText.length > 0) {\n this._write(this._indentText);\n }\n this._write(trimmedMessage);\n if (this._currentLineIsBlank) {\n if (/\\S/.test(trimmedMessage)) {\n this._currentLineIsBlank = false;\n }\n }\n this._atStartOfLine = false;\n }\n }\n\n private _writeNewLine(): void {\n if (this.indentBlankLines) {\n if (this._atStartOfLine && this._indentText.length > 0) {\n this._write(this._indentText);\n }\n }\n\n this._previousLineIsBlank = this._currentLineIsBlank;\n this._write('\\n');\n this._currentLineIsBlank = true;\n this._atStartOfLine = true;\n }\n\n private _write(s: string): void {\n this._previousChunk = this._latestChunk;\n this._latestChunk = s;\n this._builder.append(s);\n }\n\n private _updateIndentText(): void {\n this._indentText = this._indentStack.join('');\n }\n}\n"]}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAY3D,qDAAiF;AAAxE,8GAAA,aAAa,OAAA;AAEtB,6CAAsF;AAA7E,sGAAA,SAAS,OAAA;AAA2B,4GAAA,eAAe,OAAA;AAE5D,yDAI+B;AAD7B,kHAAA,eAAe,OAAA;AAKjB,2DAIgC;AAH9B,oHAAA,gBAAgB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * API Extractor helps with validation, documentation, and reviewing of the exported API for a TypeScript library.\r\n * The `@microsoft/api-extractor` package provides the command-line tool. It also exposes a developer API that you\r\n * can use to invoke API Extractor programmatically.\r\n *\r\n * @packageDocumentation\r\n */\r\n\r\nexport { ConsoleMessageId } from './api/ConsoleMessageId';\r\n\r\nexport { CompilerState, ICompilerStateCreateOptions } from './api/CompilerState';\r\n\r\nexport { Extractor, IExtractorInvokeOptions, ExtractorResult } from './api/Extractor';\r\n\r\nexport {\r\n IExtractorConfigPrepareOptions,\r\n IExtractorConfigLoadForFolderOptions,\r\n ExtractorConfig\r\n} from './api/ExtractorConfig';\r\n\r\nexport { ExtractorLogLevel } from './api/ExtractorLogLevel';\r\n\r\nexport {\r\n ExtractorMessage,\r\n IExtractorMessageProperties,\r\n ExtractorMessageCategory\r\n} from './api/ExtractorMessage';\r\n\r\nexport { ExtractorMessageId } from './api/ExtractorMessageId';\r\n\r\nexport {\r\n IConfigCompiler,\r\n IConfigApiReport,\r\n IConfigDocModel,\r\n IConfigDtsRollup,\r\n IConfigTsdocMetadata,\r\n IConfigMessageReportingRule,\r\n IConfigMessageReportingTable,\r\n IExtractorMessagesConfig,\r\n IConfigFile\r\n} from './api/IConfigFile';\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAY3D,qDAAiF;AAAxE,8GAAA,aAAa,OAAA;AAEtB,6CAAsF;AAA7E,sGAAA,SAAS,OAAA;AAA2B,4GAAA,eAAe,OAAA;AAE5D,yDAI+B;AAD7B,kHAAA,eAAe,OAAA;AAKjB,2DAIgC;AAH9B,oHAAA,gBAAgB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * API Extractor helps with validation, documentation, and reviewing of the exported API for a TypeScript library.\n * The `@microsoft/api-extractor` package provides the command-line tool. It also exposes a developer API that you\n * can use to invoke API Extractor programmatically.\n *\n * @packageDocumentation\n */\n\nexport { ConsoleMessageId } from './api/ConsoleMessageId';\n\nexport { CompilerState, ICompilerStateCreateOptions } from './api/CompilerState';\n\nexport { Extractor, IExtractorInvokeOptions, ExtractorResult } from './api/Extractor';\n\nexport {\n IExtractorConfigPrepareOptions,\n IExtractorConfigLoadForFolderOptions,\n ExtractorConfig\n} from './api/ExtractorConfig';\n\nexport { ExtractorLogLevel } from './api/ExtractorLogLevel';\n\nexport {\n ExtractorMessage,\n IExtractorMessageProperties,\n ExtractorMessageCategory\n} from './api/ExtractorMessage';\n\nexport { ExtractorMessageId } from './api/ExtractorMessageId';\n\nexport {\n IConfigCompiler,\n IConfigApiReport,\n IConfigDocModel,\n IConfigDtsRollup,\n IConfigTsdocMetadata,\n IConfigMessageReportingRule,\n IConfigMessageReportingTable,\n IExtractorMessagesConfig,\n IConfigFile\n} from './api/IConfigFile';\n"]}
@@ -1,84 +1,84 @@
1
- {
2
- "projectFolder": "<lookup>",
3
-
4
- // ("mainEntryPointFilePath" is required)
5
-
6
- "bundledPackages": [],
7
-
8
- "newlineKind": "crlf",
9
-
10
- "compiler": {
11
- "tsconfigFilePath": "<projectFolder>/tsconfig.json",
12
- "skipLibCheck": false
13
- },
14
-
15
- "apiReport": {
16
- // ("enabled" is required)
17
- "reportFileName": "<unscopedPackageName>.api.md",
18
- "reportFolder": "<projectFolder>/etc/",
19
- "reportTempFolder": "<projectFolder>/temp/"
20
- },
21
-
22
- "docModel": {
23
- // ("enabled" is required)
24
- "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
25
- },
26
-
27
- "dtsRollup": {
28
- // ("enabled" is required)
29
-
30
- "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
31
- "betaTrimmedFilePath": "",
32
- "publicTrimmedFilePath": "",
33
- "omitTrimmingComments": false
34
- },
35
-
36
- "tsdocMetadata": {
37
- "enabled": true,
38
- "tsdocMetadataFilePath": "<lookup>"
39
- },
40
-
41
- "messages": {
42
- "compilerMessageReporting": {
43
- "default": {
44
- "logLevel": "warning"
45
- }
46
- },
47
- "extractorMessageReporting": {
48
- "default": {
49
- "logLevel": "warning"
50
- },
51
- "ae-forgotten-export": {
52
- "logLevel": "warning",
53
- "addToApiReportFile": true
54
- },
55
- "ae-incompatible-release-tags": {
56
- "logLevel": "warning",
57
- "addToApiReportFile": true
58
- },
59
- "ae-internal-missing-underscore": {
60
- "logLevel": "warning",
61
- "addToApiReportFile": true
62
- },
63
- "ae-internal-mixed-release-tag": {
64
- "logLevel": "warning",
65
- "addToApiReportFile": true
66
- },
67
- "ae-unresolved-inheritdoc-reference": {
68
- "logLevel": "warning",
69
- "addToApiReportFile": true
70
- },
71
- "ae-unresolved-inheritdoc-base": {
72
- "logLevel": "warning",
73
- "addToApiReportFile": true
74
- }
75
- },
76
- "tsdocMessageReporting": {
77
- "default": {
78
- "logLevel": "warning"
79
- }
80
- }
81
- },
82
-
83
- "testMode": false
84
- }
1
+ {
2
+ "projectFolder": "<lookup>",
3
+
4
+ // ("mainEntryPointFilePath" is required)
5
+
6
+ "bundledPackages": [],
7
+
8
+ "newlineKind": "crlf",
9
+
10
+ "compiler": {
11
+ "tsconfigFilePath": "<projectFolder>/tsconfig.json",
12
+ "skipLibCheck": false
13
+ },
14
+
15
+ "apiReport": {
16
+ // ("enabled" is required)
17
+ "reportFileName": "<unscopedPackageName>.api.md",
18
+ "reportFolder": "<projectFolder>/etc/",
19
+ "reportTempFolder": "<projectFolder>/temp/"
20
+ },
21
+
22
+ "docModel": {
23
+ // ("enabled" is required)
24
+ "apiJsonFilePath": "<projectFolder>/temp/<unscopedPackageName>.api.json"
25
+ },
26
+
27
+ "dtsRollup": {
28
+ // ("enabled" is required)
29
+
30
+ "untrimmedFilePath": "<projectFolder>/dist/<unscopedPackageName>.d.ts",
31
+ "betaTrimmedFilePath": "",
32
+ "publicTrimmedFilePath": "",
33
+ "omitTrimmingComments": false
34
+ },
35
+
36
+ "tsdocMetadata": {
37
+ "enabled": true,
38
+ "tsdocMetadataFilePath": "<lookup>"
39
+ },
40
+
41
+ "messages": {
42
+ "compilerMessageReporting": {
43
+ "default": {
44
+ "logLevel": "warning"
45
+ }
46
+ },
47
+ "extractorMessageReporting": {
48
+ "default": {
49
+ "logLevel": "warning"
50
+ },
51
+ "ae-forgotten-export": {
52
+ "logLevel": "warning",
53
+ "addToApiReportFile": true
54
+ },
55
+ "ae-incompatible-release-tags": {
56
+ "logLevel": "warning",
57
+ "addToApiReportFile": true
58
+ },
59
+ "ae-internal-missing-underscore": {
60
+ "logLevel": "warning",
61
+ "addToApiReportFile": true
62
+ },
63
+ "ae-internal-mixed-release-tag": {
64
+ "logLevel": "warning",
65
+ "addToApiReportFile": true
66
+ },
67
+ "ae-unresolved-inheritdoc-reference": {
68
+ "logLevel": "warning",
69
+ "addToApiReportFile": true
70
+ },
71
+ "ae-unresolved-inheritdoc-base": {
72
+ "logLevel": "warning",
73
+ "addToApiReportFile": true
74
+ }
75
+ },
76
+ "tsdocMessageReporting": {
77
+ "default": {
78
+ "logLevel": "warning"
79
+ }
80
+ }
81
+ },
82
+
83
+ "testMode": false
84
+ }