@microsoft/api-extractor 7.51.1 → 7.52.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 (62) hide show
  1. package/CHANGELOG.json +12 -0
  2. package/CHANGELOG.md +8 -1
  3. package/dist/tsdoc-metadata.json +1 -1
  4. package/lib/aedoc/PackageDocComment.js +17 -7
  5. package/lib/aedoc/PackageDocComment.js.map +1 -1
  6. package/lib/analyzer/AstDeclaration.js +17 -7
  7. package/lib/analyzer/AstDeclaration.js.map +1 -1
  8. package/lib/analyzer/AstReferenceResolver.js +17 -7
  9. package/lib/analyzer/AstReferenceResolver.js.map +1 -1
  10. package/lib/analyzer/AstSymbolTable.js +17 -7
  11. package/lib/analyzer/AstSymbolTable.js.map +1 -1
  12. package/lib/analyzer/ExportAnalyzer.js +17 -7
  13. package/lib/analyzer/ExportAnalyzer.js.map +1 -1
  14. package/lib/analyzer/SourceFileLocationFormatter.js +17 -7
  15. package/lib/analyzer/SourceFileLocationFormatter.js.map +1 -1
  16. package/lib/analyzer/Span.js +17 -7
  17. package/lib/analyzer/Span.js.map +1 -1
  18. package/lib/analyzer/SyntaxHelpers.js +17 -7
  19. package/lib/analyzer/SyntaxHelpers.js.map +1 -1
  20. package/lib/analyzer/TypeScriptHelpers.js +17 -7
  21. package/lib/analyzer/TypeScriptHelpers.js.map +1 -1
  22. package/lib/analyzer/TypeScriptInternals.js +18 -8
  23. package/lib/analyzer/TypeScriptInternals.js.map +1 -1
  24. package/lib/api/CompilerState.js +17 -7
  25. package/lib/api/CompilerState.js.map +1 -1
  26. package/lib/api/Extractor.js +17 -7
  27. package/lib/api/Extractor.js.map +1 -1
  28. package/lib/api/ExtractorConfig.js +17 -7
  29. package/lib/api/ExtractorConfig.js.map +1 -1
  30. package/lib/cli/ApiExtractorCommandLine.js +17 -7
  31. package/lib/cli/ApiExtractorCommandLine.js.map +1 -1
  32. package/lib/cli/InitAction.js +17 -7
  33. package/lib/cli/InitAction.js.map +1 -1
  34. package/lib/cli/RunAction.js +17 -7
  35. package/lib/cli/RunAction.js.map +1 -1
  36. package/lib/collector/Collector.js +17 -7
  37. package/lib/collector/Collector.js.map +1 -1
  38. package/lib/collector/CollectorEntity.js +17 -7
  39. package/lib/collector/CollectorEntity.js.map +1 -1
  40. package/lib/collector/MessageRouter.js +17 -7
  41. package/lib/collector/MessageRouter.js.map +1 -1
  42. package/lib/collector/SourceMapper.js +17 -7
  43. package/lib/collector/SourceMapper.js.map +1 -1
  44. package/lib/enhancers/DocCommentEnhancer.js +17 -7
  45. package/lib/enhancers/DocCommentEnhancer.js.map +1 -1
  46. package/lib/enhancers/ValidationEnhancer.js +17 -7
  47. package/lib/enhancers/ValidationEnhancer.js.map +1 -1
  48. package/lib/generators/ApiModelGenerator.js +17 -7
  49. package/lib/generators/ApiModelGenerator.js.map +1 -1
  50. package/lib/generators/ApiReportGenerator.js +17 -7
  51. package/lib/generators/ApiReportGenerator.js.map +1 -1
  52. package/lib/generators/DeclarationReferenceGenerator.js +17 -7
  53. package/lib/generators/DeclarationReferenceGenerator.js.map +1 -1
  54. package/lib/generators/DtsEmitHelpers.js +17 -7
  55. package/lib/generators/DtsEmitHelpers.js.map +1 -1
  56. package/lib/generators/DtsRollupGenerator.js +17 -7
  57. package/lib/generators/DtsRollupGenerator.js.map +1 -1
  58. package/lib/generators/ExcerptBuilder.js +17 -7
  59. package/lib/generators/ExcerptBuilder.js.map +1 -1
  60. package/lib/start.js +17 -7
  61. package/lib/start.js.map +1 -1
  62. package/package.json +5 -5
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
38
  exports.DeclarationReferenceGenerator = void 0;
29
39
  /* eslint-disable no-bitwise */
@@ -1 +1 @@
1
- {"version":3,"file":"DeclarationReferenceGenerator.js","sourceRoot":"","sources":["../../src/generators/DeclarationReferenceGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+BAA+B;AAC/B,+CAAiC;AACjC,kGAMiE;AACjE,oEAAoF;AACpF,qEAAkE;AAClE,yEAAsE;AAGtE,uEAAoE;AAEpE,MAAa,6BAA6B;IAKxC,YAAmB,SAAoB;QACrC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,oCAAoC,CAAC,IAAmB;QAC7D,MAAM,MAAM,GAA0B,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5F,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,YAAY,GAAY,6BAA6B,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;YACzF,OAAO,CACL,IAAI,CAAC,gCAAgC,CACnC,MAAM,EACN,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,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C;YACN,OAAO,IAAI,2CAAoB,CAAC,mCAAY,CAAC,QAAQ,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,UAAyB;QAC/C,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,+BAA+B,CAAC,UAAU,CAAC,EAAE,CAAC;YACxE,MAAM,WAAW,GACf,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,yBAAyB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAEnF,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,EAAE,CAAC;gBACpC,OAAO,WAAW,CAAC,IAAI,CAAC;YAC1B,CAAC;YACD,OAAO,6BAA6B,CAAC,gBAAgB,CAAC;QACxD,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC;IAC7C,CAAC;IAEO,yBAAyB,CAAC,UAAqC;QACrE,IAAI,UAAU,IAAI,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;YAClD,MAAM,WAAW,GAAW,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YAE7D,IAAI,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBACzD,gGAAgG;gBAChG,+FAA+F;gBAC/F,uCAAuC;gBACvC,OAAO,IAAI,mCAAY,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,mCAAY,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,mCAAY,CAAC,QAAQ,CAAC;IAC/B,CAAC;;AAvWH,sEAwWC;AAvWwB,8CAAgB,GAAW,GAAG,CAAC","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 */\nimport * as ts from 'typescript';\nimport {\n DeclarationReference,\n ModuleSource,\n GlobalSource,\n Navigation,\n Meaning\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport { type INodePackageJson, InternalError } from '@rushstack/node-core-library';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { TypeScriptInternals } from '../analyzer/TypeScriptInternals';\nimport type { Collector } from '../collector/Collector';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\n\nexport class DeclarationReferenceGenerator {\n public static readonly unknownReference: string = '?';\n\n private _collector: Collector;\n\n public constructor(collector: Collector) {\n this._collector = collector;\n }\n\n /**\n * Gets the UID for a TypeScript Identifier that references a type.\n */\n public getDeclarationReferenceForIdentifier(node: ts.Identifier): DeclarationReference | undefined {\n const symbol: ts.Symbol | undefined = this._collector.typeChecker.getSymbolAtLocation(node);\n if (symbol !== undefined) {\n const isExpression: boolean = DeclarationReferenceGenerator._isInExpressionContext(node);\n return (\n this.getDeclarationReferenceForSymbol(\n symbol,\n isExpression ? ts.SymbolFlags.Value : ts.SymbolFlags.Type\n ) ||\n this.getDeclarationReferenceForSymbol(\n symbol,\n isExpression ? ts.SymbolFlags.Type : ts.SymbolFlags.Value\n ) ||\n this.getDeclarationReferenceForSymbol(symbol, ts.SymbolFlags.Namespace)\n );\n }\n }\n\n /**\n * Gets the DeclarationReference for a TypeScript Symbol for a given meaning.\n */\n public getDeclarationReferenceForSymbol(\n symbol: ts.Symbol,\n meaning: ts.SymbolFlags\n ): DeclarationReference | undefined {\n return this._symbolToDeclarationReference(symbol, meaning, /*includeModuleSymbols*/ false);\n }\n\n private static _isInExpressionContext(node: ts.Node): boolean {\n switch (node.parent.kind) {\n case ts.SyntaxKind.TypeQuery:\n case ts.SyntaxKind.ComputedPropertyName:\n return true;\n case ts.SyntaxKind.QualifiedName:\n return DeclarationReferenceGenerator._isInExpressionContext(node.parent);\n default:\n return false;\n }\n }\n\n private static _isExternalModuleSymbol(symbol: ts.Symbol): boolean {\n return (\n !!(symbol.flags & ts.SymbolFlags.ValueModule) &&\n symbol.valueDeclaration !== undefined &&\n ts.isSourceFile(symbol.valueDeclaration)\n );\n }\n\n private static _isSameSymbol(left: ts.Symbol | undefined, right: ts.Symbol): boolean {\n return (\n left === right ||\n !!(\n left &&\n left.valueDeclaration &&\n right.valueDeclaration &&\n left.valueDeclaration === right.valueDeclaration\n )\n );\n }\n\n private _getNavigationToSymbol(symbol: ts.Symbol): Navigation {\n const declaration: ts.Declaration | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n const parent: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(symbol);\n\n // If it's global or from an external library, then use either Members or Exports. It's not possible for\n // global symbols or external library symbols to be Locals.\n const isGlobal: boolean = !!sourceFile && !ts.isExternalModule(sourceFile);\n const isFromExternalLibrary: boolean =\n !!sourceFile && this._collector.program.isSourceFileFromExternalLibrary(sourceFile);\n if (isGlobal || isFromExternalLibrary) {\n if (\n parent &&\n parent.members &&\n DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)\n ) {\n return Navigation.Members;\n }\n\n return Navigation.Exports;\n }\n\n // Otherwise, this symbol is from the current package. If we've found an associated consumable\n // `CollectorEntity`, then use Exports. We use `consumable` here instead of `exported` because\n // if the symbol is exported from a non-consumable `AstNamespaceImport`, we don't want to use\n // Exports. We should use Locals instead.\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(symbol);\n if (entity?.consumable) {\n return Navigation.Exports;\n }\n\n // If its parent symbol is not a source file, then use either Exports or Members. If the parent symbol\n // is a source file, but it wasn't exported from the package entry point (in the check above), then the\n // symbol is a local, so fall through below.\n if (parent && !DeclarationReferenceGenerator._isExternalModuleSymbol(parent)) {\n if (\n parent.members &&\n DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)\n ) {\n return Navigation.Members;\n }\n\n return Navigation.Exports;\n }\n\n // Otherwise, we have a local symbol, so use a Locals navigation. These are either:\n //\n // 1. Symbols that are exported from a file module but not the package entry point.\n // 2. Symbols that are not exported from their parent module.\n return Navigation.Locals;\n }\n\n private static _getMeaningOfSymbol(symbol: ts.Symbol, meaning: ts.SymbolFlags): Meaning | undefined {\n if (symbol.flags & meaning & ts.SymbolFlags.Class) {\n return Meaning.Class;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Enum) {\n return Meaning.Enum;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Interface) {\n return Meaning.Interface;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.TypeAlias) {\n return Meaning.TypeAlias;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Function) {\n return Meaning.Function;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Variable) {\n return Meaning.Variable;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Module) {\n return Meaning.Namespace;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.ClassMember) {\n return Meaning.Member;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Constructor) {\n return Meaning.Constructor;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.EnumMember) {\n return Meaning.Member;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Signature) {\n if (symbol.escapedName === ts.InternalSymbolName.Call) {\n return Meaning.CallSignature;\n }\n if (symbol.escapedName === ts.InternalSymbolName.New) {\n return Meaning.ConstructSignature;\n }\n if (symbol.escapedName === ts.InternalSymbolName.Index) {\n return Meaning.IndexSignature;\n }\n }\n if (symbol.flags & meaning & ts.SymbolFlags.TypeParameter) {\n // This should have already been handled in `getDeclarationReferenceOfSymbol`.\n throw new InternalError('Not supported.');\n }\n return undefined;\n }\n\n private _symbolToDeclarationReference(\n symbol: ts.Symbol,\n meaning: ts.SymbolFlags,\n includeModuleSymbols: boolean\n ): DeclarationReference | undefined {\n const declaration: ts.Node | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n\n let followedSymbol: ts.Symbol = symbol;\n if (followedSymbol.flags & ts.SymbolFlags.ExportValue) {\n followedSymbol = this._collector.typeChecker.getExportSymbolOfSymbol(followedSymbol);\n }\n if (followedSymbol.flags & ts.SymbolFlags.Alias) {\n followedSymbol = this._collector.typeChecker.getAliasedSymbol(followedSymbol);\n\n // Without this logic, we end up following the symbol `ns` in `import * as ns from './file'` to\n // the actual file `file.ts`. We don't want to do this, so revert to the original symbol.\n if (followedSymbol.flags & ts.SymbolFlags.ValueModule) {\n followedSymbol = symbol;\n }\n }\n\n if (DeclarationReferenceGenerator._isExternalModuleSymbol(followedSymbol)) {\n if (!includeModuleSymbols) {\n return undefined;\n }\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n }\n\n // Do not generate a declaration reference for a type parameter.\n if (followedSymbol.flags & ts.SymbolFlags.TypeParameter) {\n return undefined;\n }\n\n let parentRef: DeclarationReference | undefined = this._getParentReference(followedSymbol);\n if (!parentRef) {\n return undefined;\n }\n\n let localName: string = followedSymbol.name;\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(followedSymbol);\n if (entity?.nameForEmit) {\n localName = entity.nameForEmit;\n }\n\n if (followedSymbol.escapedName === ts.InternalSymbolName.Constructor) {\n localName = 'constructor';\n } else {\n const wellKnownName: string | undefined = TypeScriptHelpers.tryDecodeWellKnownSymbolName(\n followedSymbol.escapedName\n );\n if (wellKnownName) {\n // TypeScript binds well-known ECMAScript symbols like 'Symbol.iterator' as '__@iterator'.\n // This converts a string like '__@iterator' into the property name '[Symbol.iterator]'.\n localName = wellKnownName;\n } else if (TypeScriptHelpers.isUniqueSymbolName(followedSymbol.escapedName)) {\n for (const decl of followedSymbol.declarations || []) {\n const declName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(decl);\n if (declName && ts.isComputedPropertyName(declName)) {\n const lateName: string | undefined = TypeScriptHelpers.tryGetLateBoundName(declName);\n if (lateName !== undefined) {\n localName = lateName;\n break;\n }\n }\n }\n }\n }\n\n const navigation: Navigation = this._getNavigationToSymbol(followedSymbol);\n\n // If the symbol is a global, ensure the source is global.\n if (sourceFile && !ts.isExternalModule(sourceFile) && parentRef.source !== GlobalSource.instance) {\n parentRef = new DeclarationReference(GlobalSource.instance);\n }\n\n return parentRef\n .addNavigationStep(navigation, localName)\n .withMeaning(DeclarationReferenceGenerator._getMeaningOfSymbol(followedSymbol, meaning));\n }\n\n private _getParentReference(symbol: ts.Symbol): DeclarationReference | undefined {\n const declaration: ts.Node | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n\n // Note that it's possible for a symbol to be exported from an entry point as well as one or more\n // namespaces. In that case, it's not clear what to choose as its parent. Today's logic is neither\n // perfect nor particularly stable to API items being renamed and shuffled around.\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(symbol);\n if (entity) {\n if (entity.exportedFromEntryPoint) {\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n }\n\n const firstExportingConsumableParent: CollectorEntity | undefined =\n entity.getFirstExportingConsumableParent();\n if (\n firstExportingConsumableParent &&\n firstExportingConsumableParent.astEntity instanceof AstNamespaceImport\n ) {\n const parentSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n firstExportingConsumableParent.astEntity.declaration,\n this._collector.typeChecker\n );\n if (parentSymbol) {\n return this._symbolToDeclarationReference(\n parentSymbol,\n parentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n }\n }\n\n // Next, try to find a parent symbol via the symbol tree.\n const parentSymbol: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(symbol);\n if (parentSymbol) {\n return this._symbolToDeclarationReference(\n parentSymbol,\n parentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n\n // If that doesn't work, try to find a parent symbol via the node tree. As far as we can tell,\n // this logic is only needed for local symbols within namespaces. For example:\n //\n // ```\n // export namespace n {\n // type SomeType = number;\n // export function someFunction(): SomeType { return 5; }\n // }\n // ```\n //\n // In the example above, `SomeType` doesn't have a parent symbol per the TS internal API above,\n // but its reference still needs to be qualified with the parent reference for `n`.\n const grandParent: ts.Node | undefined = declaration?.parent?.parent;\n if (grandParent && ts.isModuleDeclaration(grandParent)) {\n const grandParentSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n grandParent,\n this._collector.typeChecker\n );\n if (grandParentSymbol) {\n return this._symbolToDeclarationReference(\n grandParentSymbol,\n grandParentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n }\n\n // At this point, we have a local symbol in a module.\n if (sourceFile && ts.isExternalModule(sourceFile)) {\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n } else {\n return new DeclarationReference(GlobalSource.instance);\n }\n }\n\n private _getPackageName(sourceFile: ts.SourceFile): string {\n if (this._collector.program.isSourceFileFromExternalLibrary(sourceFile)) {\n const packageJson: INodePackageJson | undefined =\n this._collector.packageJsonLookup.tryLoadNodePackageJsonFor(sourceFile.fileName);\n\n if (packageJson && packageJson.name) {\n return packageJson.name;\n }\n return DeclarationReferenceGenerator.unknownReference;\n }\n return this._collector.workingPackage.name;\n }\n\n private _sourceFileToModuleSource(sourceFile: ts.SourceFile | undefined): GlobalSource | ModuleSource {\n if (sourceFile && ts.isExternalModule(sourceFile)) {\n const packageName: string = this._getPackageName(sourceFile);\n\n if (this._collector.bundledPackageNames.has(packageName)) {\n // The api-extractor.json config file has a \"bundledPackages\" setting, which causes imports from\n // certain NPM packages to be treated as part of the working project. In this case, we need to\n // substitute the working package name.\n return new ModuleSource(this._collector.workingPackage.name);\n } else {\n return new ModuleSource(packageName);\n }\n }\n return GlobalSource.instance;\n }\n}\n"]}
1
+ {"version":3,"file":"DeclarationReferenceGenerator.js","sourceRoot":"","sources":["../../src/generators/DeclarationReferenceGenerator.ts"],"names":[],"mappings":";AAAA,4F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CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;YAClD,MAAM,WAAW,GAAW,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;YAE7D,IAAI,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;gBACzD,gGAAgG;gBAChG,+FAA+F;gBAC/F,uCAAuC;gBACvC,OAAO,IAAI,mCAAY,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,mCAAY,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QACD,OAAO,mCAAY,CAAC,QAAQ,CAAC;IAC/B,CAAC;;AAvWH,sEAwWC;AAvWwB,8CAAgB,GAAW,GAAG,CAAC","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 */\nimport * as ts from 'typescript';\nimport {\n DeclarationReference,\n ModuleSource,\n GlobalSource,\n Navigation,\n Meaning\n} from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport { type INodePackageJson, InternalError } from '@rushstack/node-core-library';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { TypeScriptInternals } from '../analyzer/TypeScriptInternals';\nimport type { Collector } from '../collector/Collector';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\n\nexport class DeclarationReferenceGenerator {\n public static readonly unknownReference: string = '?';\n\n private _collector: Collector;\n\n public constructor(collector: Collector) {\n this._collector = collector;\n }\n\n /**\n * Gets the UID for a TypeScript Identifier that references a type.\n */\n public getDeclarationReferenceForIdentifier(node: ts.Identifier): DeclarationReference | undefined {\n const symbol: ts.Symbol | undefined = this._collector.typeChecker.getSymbolAtLocation(node);\n if (symbol !== undefined) {\n const isExpression: boolean = DeclarationReferenceGenerator._isInExpressionContext(node);\n return (\n this.getDeclarationReferenceForSymbol(\n symbol,\n isExpression ? ts.SymbolFlags.Value : ts.SymbolFlags.Type\n ) ||\n this.getDeclarationReferenceForSymbol(\n symbol,\n isExpression ? ts.SymbolFlags.Type : ts.SymbolFlags.Value\n ) ||\n this.getDeclarationReferenceForSymbol(symbol, ts.SymbolFlags.Namespace)\n );\n }\n }\n\n /**\n * Gets the DeclarationReference for a TypeScript Symbol for a given meaning.\n */\n public getDeclarationReferenceForSymbol(\n symbol: ts.Symbol,\n meaning: ts.SymbolFlags\n ): DeclarationReference | undefined {\n return this._symbolToDeclarationReference(symbol, meaning, /*includeModuleSymbols*/ false);\n }\n\n private static _isInExpressionContext(node: ts.Node): boolean {\n switch (node.parent.kind) {\n case ts.SyntaxKind.TypeQuery:\n case ts.SyntaxKind.ComputedPropertyName:\n return true;\n case ts.SyntaxKind.QualifiedName:\n return DeclarationReferenceGenerator._isInExpressionContext(node.parent);\n default:\n return false;\n }\n }\n\n private static _isExternalModuleSymbol(symbol: ts.Symbol): boolean {\n return (\n !!(symbol.flags & ts.SymbolFlags.ValueModule) &&\n symbol.valueDeclaration !== undefined &&\n ts.isSourceFile(symbol.valueDeclaration)\n );\n }\n\n private static _isSameSymbol(left: ts.Symbol | undefined, right: ts.Symbol): boolean {\n return (\n left === right ||\n !!(\n left &&\n left.valueDeclaration &&\n right.valueDeclaration &&\n left.valueDeclaration === right.valueDeclaration\n )\n );\n }\n\n private _getNavigationToSymbol(symbol: ts.Symbol): Navigation {\n const declaration: ts.Declaration | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n const parent: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(symbol);\n\n // If it's global or from an external library, then use either Members or Exports. It's not possible for\n // global symbols or external library symbols to be Locals.\n const isGlobal: boolean = !!sourceFile && !ts.isExternalModule(sourceFile);\n const isFromExternalLibrary: boolean =\n !!sourceFile && this._collector.program.isSourceFileFromExternalLibrary(sourceFile);\n if (isGlobal || isFromExternalLibrary) {\n if (\n parent &&\n parent.members &&\n DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)\n ) {\n return Navigation.Members;\n }\n\n return Navigation.Exports;\n }\n\n // Otherwise, this symbol is from the current package. If we've found an associated consumable\n // `CollectorEntity`, then use Exports. We use `consumable` here instead of `exported` because\n // if the symbol is exported from a non-consumable `AstNamespaceImport`, we don't want to use\n // Exports. We should use Locals instead.\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(symbol);\n if (entity?.consumable) {\n return Navigation.Exports;\n }\n\n // If its parent symbol is not a source file, then use either Exports or Members. If the parent symbol\n // is a source file, but it wasn't exported from the package entry point (in the check above), then the\n // symbol is a local, so fall through below.\n if (parent && !DeclarationReferenceGenerator._isExternalModuleSymbol(parent)) {\n if (\n parent.members &&\n DeclarationReferenceGenerator._isSameSymbol(parent.members.get(symbol.escapedName), symbol)\n ) {\n return Navigation.Members;\n }\n\n return Navigation.Exports;\n }\n\n // Otherwise, we have a local symbol, so use a Locals navigation. These are either:\n //\n // 1. Symbols that are exported from a file module but not the package entry point.\n // 2. Symbols that are not exported from their parent module.\n return Navigation.Locals;\n }\n\n private static _getMeaningOfSymbol(symbol: ts.Symbol, meaning: ts.SymbolFlags): Meaning | undefined {\n if (symbol.flags & meaning & ts.SymbolFlags.Class) {\n return Meaning.Class;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Enum) {\n return Meaning.Enum;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Interface) {\n return Meaning.Interface;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.TypeAlias) {\n return Meaning.TypeAlias;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Function) {\n return Meaning.Function;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Variable) {\n return Meaning.Variable;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Module) {\n return Meaning.Namespace;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.ClassMember) {\n return Meaning.Member;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Constructor) {\n return Meaning.Constructor;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.EnumMember) {\n return Meaning.Member;\n }\n if (symbol.flags & meaning & ts.SymbolFlags.Signature) {\n if (symbol.escapedName === ts.InternalSymbolName.Call) {\n return Meaning.CallSignature;\n }\n if (symbol.escapedName === ts.InternalSymbolName.New) {\n return Meaning.ConstructSignature;\n }\n if (symbol.escapedName === ts.InternalSymbolName.Index) {\n return Meaning.IndexSignature;\n }\n }\n if (symbol.flags & meaning & ts.SymbolFlags.TypeParameter) {\n // This should have already been handled in `getDeclarationReferenceOfSymbol`.\n throw new InternalError('Not supported.');\n }\n return undefined;\n }\n\n private _symbolToDeclarationReference(\n symbol: ts.Symbol,\n meaning: ts.SymbolFlags,\n includeModuleSymbols: boolean\n ): DeclarationReference | undefined {\n const declaration: ts.Node | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n\n let followedSymbol: ts.Symbol = symbol;\n if (followedSymbol.flags & ts.SymbolFlags.ExportValue) {\n followedSymbol = this._collector.typeChecker.getExportSymbolOfSymbol(followedSymbol);\n }\n if (followedSymbol.flags & ts.SymbolFlags.Alias) {\n followedSymbol = this._collector.typeChecker.getAliasedSymbol(followedSymbol);\n\n // Without this logic, we end up following the symbol `ns` in `import * as ns from './file'` to\n // the actual file `file.ts`. We don't want to do this, so revert to the original symbol.\n if (followedSymbol.flags & ts.SymbolFlags.ValueModule) {\n followedSymbol = symbol;\n }\n }\n\n if (DeclarationReferenceGenerator._isExternalModuleSymbol(followedSymbol)) {\n if (!includeModuleSymbols) {\n return undefined;\n }\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n }\n\n // Do not generate a declaration reference for a type parameter.\n if (followedSymbol.flags & ts.SymbolFlags.TypeParameter) {\n return undefined;\n }\n\n let parentRef: DeclarationReference | undefined = this._getParentReference(followedSymbol);\n if (!parentRef) {\n return undefined;\n }\n\n let localName: string = followedSymbol.name;\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(followedSymbol);\n if (entity?.nameForEmit) {\n localName = entity.nameForEmit;\n }\n\n if (followedSymbol.escapedName === ts.InternalSymbolName.Constructor) {\n localName = 'constructor';\n } else {\n const wellKnownName: string | undefined = TypeScriptHelpers.tryDecodeWellKnownSymbolName(\n followedSymbol.escapedName\n );\n if (wellKnownName) {\n // TypeScript binds well-known ECMAScript symbols like 'Symbol.iterator' as '__@iterator'.\n // This converts a string like '__@iterator' into the property name '[Symbol.iterator]'.\n localName = wellKnownName;\n } else if (TypeScriptHelpers.isUniqueSymbolName(followedSymbol.escapedName)) {\n for (const decl of followedSymbol.declarations || []) {\n const declName: ts.DeclarationName | undefined = ts.getNameOfDeclaration(decl);\n if (declName && ts.isComputedPropertyName(declName)) {\n const lateName: string | undefined = TypeScriptHelpers.tryGetLateBoundName(declName);\n if (lateName !== undefined) {\n localName = lateName;\n break;\n }\n }\n }\n }\n }\n\n const navigation: Navigation = this._getNavigationToSymbol(followedSymbol);\n\n // If the symbol is a global, ensure the source is global.\n if (sourceFile && !ts.isExternalModule(sourceFile) && parentRef.source !== GlobalSource.instance) {\n parentRef = new DeclarationReference(GlobalSource.instance);\n }\n\n return parentRef\n .addNavigationStep(navigation, localName)\n .withMeaning(DeclarationReferenceGenerator._getMeaningOfSymbol(followedSymbol, meaning));\n }\n\n private _getParentReference(symbol: ts.Symbol): DeclarationReference | undefined {\n const declaration: ts.Node | undefined = TypeScriptHelpers.tryGetADeclaration(symbol);\n const sourceFile: ts.SourceFile | undefined = declaration?.getSourceFile();\n\n // Note that it's possible for a symbol to be exported from an entry point as well as one or more\n // namespaces. In that case, it's not clear what to choose as its parent. Today's logic is neither\n // perfect nor particularly stable to API items being renamed and shuffled around.\n const entity: CollectorEntity | undefined = this._collector.tryGetEntityForSymbol(symbol);\n if (entity) {\n if (entity.exportedFromEntryPoint) {\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n }\n\n const firstExportingConsumableParent: CollectorEntity | undefined =\n entity.getFirstExportingConsumableParent();\n if (\n firstExportingConsumableParent &&\n firstExportingConsumableParent.astEntity instanceof AstNamespaceImport\n ) {\n const parentSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n firstExportingConsumableParent.astEntity.declaration,\n this._collector.typeChecker\n );\n if (parentSymbol) {\n return this._symbolToDeclarationReference(\n parentSymbol,\n parentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n }\n }\n\n // Next, try to find a parent symbol via the symbol tree.\n const parentSymbol: ts.Symbol | undefined = TypeScriptInternals.getSymbolParent(symbol);\n if (parentSymbol) {\n return this._symbolToDeclarationReference(\n parentSymbol,\n parentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n\n // If that doesn't work, try to find a parent symbol via the node tree. As far as we can tell,\n // this logic is only needed for local symbols within namespaces. For example:\n //\n // ```\n // export namespace n {\n // type SomeType = number;\n // export function someFunction(): SomeType { return 5; }\n // }\n // ```\n //\n // In the example above, `SomeType` doesn't have a parent symbol per the TS internal API above,\n // but its reference still needs to be qualified with the parent reference for `n`.\n const grandParent: ts.Node | undefined = declaration?.parent?.parent;\n if (grandParent && ts.isModuleDeclaration(grandParent)) {\n const grandParentSymbol: ts.Symbol | undefined = TypeScriptInternals.tryGetSymbolForDeclaration(\n grandParent,\n this._collector.typeChecker\n );\n if (grandParentSymbol) {\n return this._symbolToDeclarationReference(\n grandParentSymbol,\n grandParentSymbol.flags,\n /*includeModuleSymbols*/ true\n );\n }\n }\n\n // At this point, we have a local symbol in a module.\n if (sourceFile && ts.isExternalModule(sourceFile)) {\n return new DeclarationReference(this._sourceFileToModuleSource(sourceFile));\n } else {\n return new DeclarationReference(GlobalSource.instance);\n }\n }\n\n private _getPackageName(sourceFile: ts.SourceFile): string {\n if (this._collector.program.isSourceFileFromExternalLibrary(sourceFile)) {\n const packageJson: INodePackageJson | undefined =\n this._collector.packageJsonLookup.tryLoadNodePackageJsonFor(sourceFile.fileName);\n\n if (packageJson && packageJson.name) {\n return packageJson.name;\n }\n return DeclarationReferenceGenerator.unknownReference;\n }\n return this._collector.workingPackage.name;\n }\n\n private _sourceFileToModuleSource(sourceFile: ts.SourceFile | undefined): GlobalSource | ModuleSource {\n if (sourceFile && ts.isExternalModule(sourceFile)) {\n const packageName: string = this._getPackageName(sourceFile);\n\n if (this._collector.bundledPackageNames.has(packageName)) {\n // The api-extractor.json config file has a \"bundledPackages\" setting, which causes imports from\n // certain NPM packages to be treated as part of the working project. In this case, we need to\n // substitute the working package name.\n return new ModuleSource(this._collector.workingPackage.name);\n } else {\n return new ModuleSource(packageName);\n }\n }\n return GlobalSource.instance;\n }\n}\n"]}
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
38
  exports.DtsEmitHelpers = void 0;
29
39
  const ts = __importStar(require("typescript"));
@@ -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,CAAC,aAAa,CAAC,CAAC,CAAC,QAAQ,CAAC;QAEvF,QAAQ,SAAS,CAAC,UAAU,EAAE,CAAC;YAC7B,KAAK,yBAAa,CAAC,aAAa;gBAC9B,IAAI,eAAe,CAAC,WAAW,KAAK,SAAS,CAAC,UAAU,EAAE,CAAC;oBACzD,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,iBAAiB,eAAe,CAAC,WAAW,IAAI,CAAC,CAAC;gBAChF,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;gBAC1D,CAAC;gBACD,MAAM,CAAC,SAAS,CAAC,UAAU,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC;gBACrD,MAAM;YACR,KAAK,yBAAa,CAAC,WAAW;gBAC5B,IAAI,eAAe,CAAC,WAAW,KAAK,SAAS,CAAC,UAAU,EAAE,CAAC;oBACzD,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,MAAM,SAAS,CAAC,UAAU,IAAI,CAAC,CAAC;gBAC9D,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,MAAM,SAAS,CAAC,UAAU,OAAO,eAAe,CAA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CAAC,IAAI,CAAC,GAAG,CAAC;YAC7D,CAAC;YAED,MAAM,cAAc,GAAW,MAAA,MAAA,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,0CAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;YAExE,IACE,gBAAgB,CAAC,SAAS,YAAY,qBAAS;gBAC/C,gBAAgB,CAAC,SAAS,CAAC,UAAU,KAAK,yBAAa,CAAC,UAAU;gBAClE,gBAAgB,CAAC,SAAS,CAAC,UAAU,EACrC,CAAC;gBACD,gFAAgF;gBAChF,mEAAmE;gBACnE,MAAM,cAAc,GAAW,MAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,EAAE,mCAAI,EAAE,CAAC;gBAC/D,MAAM,qBAAqB,GAAW,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAClE,4BAA4B;gBAC5B,MAAM,oBAAoB,GACxB,qBAAqB,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,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;YACzC,CAAC;iBAAM,CAAC;gBACN,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;YACpG,CAAC;QACH,CAAC;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 type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstImport, AstImportKind } from '../analyzer/AstImport';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { Collector } from '../collector/Collector';\nimport type { Span } from '../analyzer/Span';\nimport type { 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
+ {"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,CA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AgF;gBAChF,mEAAmE;gBACnE,MAAM,cAAc,GAAW,MAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,OAAO,EAAE,mCAAI,EAAE,CAAC;gBAC/D,MAAM,qBAAqB,GAAW,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBAClE,4BAA4B;gBAC5B,MAAM,oBAAoB,GACxB,qBAAqB,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,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;YACzC,CAAC;iBAAM,CAAC;gBACN,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;YACpG,CAAC;QACH,CAAC;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 type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstImport, AstImportKind } from '../analyzer/AstImport';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { Collector } from '../collector/Collector';\nimport type { Span } from '../analyzer/Span';\nimport type { 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"]}
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
38
  exports.DtsRollupGenerator = exports.DtsRollupKind = void 0;
29
39
  /* eslint-disable no-bitwise */
@@ -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,oEAA2F;AAC3F,wEAA4D;AAG5D,qEAAkE;AAClE,2CAAsF;AACtF,qDAAkD;AAElD,+DAA4D;AAE5D,qDAAkD;AAElD,qDAAkD;AAClD,qDAAkD;AAElD,uEAAoE;AAEpE,yFAAsF;AAGtF;;GAEG;AACH,IAAY,aA2BX;AA3BD,WAAY,aAAa;IACvB;;;OAGG;IACH,uEAAe,CAAA;IAEf;;;;OAIG;IACH,iEAAY,CAAA;IAEZ;;;;OAIG;IACH,+DAAW,CAAA;IAEX;;;;OAIG;IACH,mEAAa,CAAA;AACf,CAAC,EA3BW,aAAa,6BAAb,aAAa,QA2BxB;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,MAA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AAC,CAAC;QACpE,CAAC;IACH,CAAC;CACF;AAtaD,gDAsaC","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, type NewlineKind, InternalError } from '@rushstack/node-core-library';\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\n\nimport type { Collector } from '../collector/Collector';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { IndentDocCommentScope, Span, type SpanModification } from '../analyzer/Span';\nimport { AstImport } from '../analyzer/AstImport';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { ApiItemMetadata } from '../collector/ApiItemMetadata';\nimport { AstSymbol } from '../analyzer/AstSymbol';\nimport type { SymbolMetadata } from '../collector/SymbolMetadata';\nimport { IndentedWriter } from './IndentedWriter';\nimport { DtsEmitHelpers } from './DtsEmitHelpers';\nimport type { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\nimport type { IAstModuleExportInfo } from '../analyzer/AstModule';\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\nimport type { 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 \\@internal.\n */\n AlphaRelease,\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 // Note: it isn't valid to trim imports based on their release tags.\n // E.g. class Foo (`@public`) extends interface Bar (`@beta`) from some external library.\n // API-Extractor cannot trim `import { Bar } from \"external-library\"` when generating its public rollup,\n // or the export of `Foo` would include a broken reference to `Bar`.\n const astImport: AstImport = entity.astEntity;\n DtsEmitHelpers.emitImport(writer, entity, astImport);\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: IAstModuleExportInfo = 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 the entity's declaration won't be included, then neither should the namespace export it\n // This fixes the issue encountered here: https://github.com/microsoft/rushstack/issues/2791\n const exportedSymbolMetadata: SymbolMetadata | undefined =\n collector.tryFetchMetadataForAstEntity(exportedEntity);\n const exportedMaxEffectiveReleaseTag: ReleaseTag = exportedSymbolMetadata\n ? exportedSymbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n if (!this._shouldIncludeReleaseTag(exportedMaxEffectiveReleaseTag, dtsKind)) {\n continue;\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.AlphaRelease:\n return (\n releaseTag === ReleaseTag.Alpha ||\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n releaseTag === ReleaseTag.None\n );\n case DtsRollupKind.BetaRelease:\n return (\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n 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
+ {"version":3,"file":"DtsRollupGenerator.js","sourceRoot":"","sources":["../../src/generators/DtsRollupGenerator.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+BAA+B;AAE/B,+CAAiC;AACjC,oEAA2F;AAC3F,wEAA4D;AAG5D,qEAAkE;AAClE,2CAAsF;AACtF,qDAAkD;AAElD,+DAA4D;AAE5D,qDAAkD;AAElD,qDAAkD;AAClD,qDAAkD;AAElD,uEAAoE;AAEpE,yFAAsF;AAGtF;;GAEG;AACH,IAAY,aA2BX;AA3BD,WAAY,aAAa;IACvB;;;OAGG;IACH,uEAAe,CAAA;IAEf;;;;OAIG;IACH,iEAAY,CAAA;IAEZ;;;;OAIG;IACH,+DAAW,CAAA;IAEX;;;;OAIG;IACH,mEAAa,CAAA;AACf,CAAC,EA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BAC/B,UAAU,KAAK,gCAAU,CAAC,IAAI;oBAC9B,UAAU,KAAK,gCAAU,CAAC,MAAM;oBAChC,uFAAuF;oBACvF,UAAU,KAAK,gCAAU,CAAC,IAAI,CAC/B,CAAC;YACJ,KAAK,aAAa,CAAC,WAAW;gBAC5B,OAAO,CACL,UAAU,KAAK,gCAAU,CAAC,IAAI;oBAC9B,UAAU,KAAK,gCAAU,CAAC,MAAM;oBAChC,uFAAuF;oBACvF,UAAU,KAAK,gCAAU,CAAC,IAAI,CAC/B,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;QACpE,CAAC;IACH,CAAC;CACF;AAtaD,gDAsaC","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, type NewlineKind, InternalError } from '@rushstack/node-core-library';\nimport { ReleaseTag } from '@microsoft/api-extractor-model';\n\nimport type { Collector } from '../collector/Collector';\nimport { TypeScriptHelpers } from '../analyzer/TypeScriptHelpers';\nimport { IndentDocCommentScope, Span, type SpanModification } from '../analyzer/Span';\nimport { AstImport } from '../analyzer/AstImport';\nimport type { CollectorEntity } from '../collector/CollectorEntity';\nimport { AstDeclaration } from '../analyzer/AstDeclaration';\nimport type { ApiItemMetadata } from '../collector/ApiItemMetadata';\nimport { AstSymbol } from '../analyzer/AstSymbol';\nimport type { SymbolMetadata } from '../collector/SymbolMetadata';\nimport { IndentedWriter } from './IndentedWriter';\nimport { DtsEmitHelpers } from './DtsEmitHelpers';\nimport type { DeclarationMetadata } from '../collector/DeclarationMetadata';\nimport { AstNamespaceImport } from '../analyzer/AstNamespaceImport';\nimport type { IAstModuleExportInfo } from '../analyzer/AstModule';\nimport { SourceFileLocationFormatter } from '../analyzer/SourceFileLocationFormatter';\nimport type { 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 \\@internal.\n */\n AlphaRelease,\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 // Note: it isn't valid to trim imports based on their release tags.\n // E.g. class Foo (`@public`) extends interface Bar (`@beta`) from some external library.\n // API-Extractor cannot trim `import { Bar } from \"external-library\"` when generating its public rollup,\n // or the export of `Foo` would include a broken reference to `Bar`.\n const astImport: AstImport = entity.astEntity;\n DtsEmitHelpers.emitImport(writer, entity, astImport);\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: IAstModuleExportInfo = 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 the entity's declaration won't be included, then neither should the namespace export it\n // This fixes the issue encountered here: https://github.com/microsoft/rushstack/issues/2791\n const exportedSymbolMetadata: SymbolMetadata | undefined =\n collector.tryFetchMetadataForAstEntity(exportedEntity);\n const exportedMaxEffectiveReleaseTag: ReleaseTag = exportedSymbolMetadata\n ? exportedSymbolMetadata.maxEffectiveReleaseTag\n : ReleaseTag.None;\n if (!this._shouldIncludeReleaseTag(exportedMaxEffectiveReleaseTag, dtsKind)) {\n continue;\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.AlphaRelease:\n return (\n releaseTag === ReleaseTag.Alpha ||\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n releaseTag === ReleaseTag.None\n );\n case DtsRollupKind.BetaRelease:\n return (\n releaseTag === ReleaseTag.Beta ||\n releaseTag === ReleaseTag.Public ||\n // NOTE: If the release tag is \"None\", then we don't have enough information to trim it\n 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"]}
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
17
17
  }) : function(o, v) {
18
18
  o["default"] = v;
19
19
  });
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
20
+ var __importStar = (this && this.__importStar) || (function () {
21
+ var ownKeys = function(o) {
22
+ ownKeys = Object.getOwnPropertyNames || function (o) {
23
+ var ar = [];
24
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
25
+ return ar;
26
+ };
27
+ return ownKeys(o);
28
+ };
29
+ return function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ })();
27
37
  Object.defineProperty(exports, "__esModule", { value: true });
28
38
  exports.ExcerptBuilder = void 0;
29
39
  const ts = __importStar(require("typescript"));
@@ -1 +1 @@
1
- {"version":3,"file":"ExcerptBuilder.js","sourceRoot":"","sources":["../../src/generators/ExcerptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;AAEjC,wEAIwC;AAExC,2CAAwC;AAkDxC,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,CAAC;YAC7B,MAAM,YAAY,GAAW,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1E,IAAI,KAAK,CAAC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K,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;QACjB,CAAC;IACH,CAAC;CACF;AAvRD,wCAuRC","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 type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport {\n ExcerptTokenKind,\n type IExcerptToken,\n type IExcerptTokenRange\n} from '@microsoft/api-extractor-model';\n\nimport { Span } from '../analyzer/Span';\nimport type { DeclarationReferenceGenerator } from './DeclarationReferenceGenerator';\nimport type { 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 * Tracks whether the last appended token was a separator. If so, and we're in the middle of\n * capturing a token range, then omit the separator from the range.\n */\n lastAppendedTokenIsSeparator: 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 lastAppendedTokenIsSeparator: false\n });\n ExcerptBuilder._condenseTokens(excerptTokens, [...tokenRangesByNode.values()]);\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 }\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 canonicalReference\n );\n } else {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.prefix);\n }\n state.lastAppendedTokenIsSeparator = false;\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 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);\n state.lastAppendedTokenIsSeparator = false;\n }\n if (span.separator) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.separator);\n state.lastAppendedTokenIsSeparator = true;\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\n // that was appended so far. However, if the last appended token was a separator, omit\n // it from the range.\n let excerptEndIndex: number = excerptTokens.length;\n if (state.lastAppendedTokenIsSeparator) {\n excerptEndIndex--;\n }\n\n capturedTokenRange.endIndex = excerptEndIndex;\n }\n\n return true;\n }\n\n private static _appendToken(\n excerptTokens: IExcerptToken[],\n excerptTokenKind: ExcerptTokenKind,\n text: string,\n canonicalReference?: DeclarationReference\n ): void {\n if (text.length === 0) {\n return;\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 }\n\n /**\n * Condenses the provided excerpt tokens by merging tokens where possible. Updates the provided token ranges to\n * remain accurate after token merging.\n *\n * @remarks\n * For example, suppose we have excerpt tokens [\"A\", \"B\", \"C\"] and a token range [0, 2]. If the excerpt tokens\n * are condensed to [\"AB\", \"C\"], then the token range would be updated to [0, 1]. Note that merges are only\n * performed if they are compatible with the provided token ranges. In the example above, if our token range was\n * originally [0, 1], we would not be able to merge tokens \"A\" and \"B\".\n */\n private static _condenseTokens(excerptTokens: IExcerptToken[], tokenRanges: IExcerptTokenRange[]): void {\n // This set is used to quickly lookup a start or end index.\n const startOrEndIndices: Set<number> = new Set();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n\n for (let currentIndex: number = 1; currentIndex < excerptTokens.length; ++currentIndex) {\n while (currentIndex < excerptTokens.length) {\n const prevPrevToken: IExcerptToken = excerptTokens[currentIndex - 2]; // May be undefined\n const prevToken: IExcerptToken = excerptTokens[currentIndex - 1];\n const currentToken: IExcerptToken = excerptTokens[currentIndex];\n\n // The number of excerpt tokens that are merged in this iteration. We need this to determine\n // how to update the start and end indices of our token ranges.\n let mergeCount: number;\n\n // There are two types of merges that can occur. We only perform these merges if they are\n // compatible with all of our token ranges.\n if (\n prevPrevToken &&\n prevPrevToken.kind === ExcerptTokenKind.Reference &&\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.text.trim() === '.' &&\n currentToken.kind === ExcerptTokenKind.Reference &&\n !startOrEndIndices.has(currentIndex) &&\n !startOrEndIndices.has(currentIndex - 1)\n ) {\n // If the current token is a reference token, the previous token is a \".\", and the previous-\n // previous token is a reference token, then merge all three tokens into a reference token.\n //\n // For example: Given [\"MyNamespace\" (R), \".\", \"MyClass\" (R)], tokens \".\" and \"MyClass\" might\n // be merged into \"MyNamespace\". The condensed token would be [\"MyNamespace.MyClass\" (R)].\n prevPrevToken.text += prevToken.text + currentToken.text;\n prevPrevToken.canonicalReference = currentToken.canonicalReference;\n mergeCount = 2;\n currentIndex--;\n } else if (\n // If the current and previous tokens are both content tokens, then merge the tokens into a\n // single content token. For example: Given [\"export \", \"declare class\"], these tokens\n // might be merged into \"export declare class\".\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.kind === currentToken.kind &&\n !startOrEndIndices.has(currentIndex)\n ) {\n prevToken.text += currentToken.text;\n mergeCount = 1;\n } else {\n // Otherwise, no merging can occur here. Continue to the next index.\n break;\n }\n\n // Remove the now redundant excerpt token(s), as they were merged into a previous token.\n excerptTokens.splice(currentIndex, mergeCount);\n\n // Update the start and end indices for all token ranges based upon how many excerpt\n // tokens were merged and in what positions.\n for (const tokenRange of tokenRanges) {\n if (tokenRange.startIndex > currentIndex) {\n tokenRange.startIndex -= mergeCount;\n }\n\n if (tokenRange.endIndex > currentIndex) {\n tokenRange.endIndex -= mergeCount;\n }\n }\n\n // Clear and repopulate our set with the updated indices.\n startOrEndIndices.clear();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n }\n }\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
+ {"version":3,"file":"ExcerptBuilder.js","sourceRoot":"","sources":["../../src/generators/ExcerptBuilder.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,+CAAiC;A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,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;QACjB,CAAC;IACH,CAAC;CACF;AAvRD,wCAuRC","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 type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\nimport {\n ExcerptTokenKind,\n type IExcerptToken,\n type IExcerptTokenRange\n} from '@microsoft/api-extractor-model';\n\nimport { Span } from '../analyzer/Span';\nimport type { DeclarationReferenceGenerator } from './DeclarationReferenceGenerator';\nimport type { 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 * Tracks whether the last appended token was a separator. If so, and we're in the middle of\n * capturing a token range, then omit the separator from the range.\n */\n lastAppendedTokenIsSeparator: 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 lastAppendedTokenIsSeparator: false\n });\n ExcerptBuilder._condenseTokens(excerptTokens, [...tokenRangesByNode.values()]);\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 }\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 canonicalReference\n );\n } else {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.prefix);\n }\n state.lastAppendedTokenIsSeparator = false;\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 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);\n state.lastAppendedTokenIsSeparator = false;\n }\n if (span.separator) {\n ExcerptBuilder._appendToken(excerptTokens, ExcerptTokenKind.Content, span.separator);\n state.lastAppendedTokenIsSeparator = true;\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\n // that was appended so far. However, if the last appended token was a separator, omit\n // it from the range.\n let excerptEndIndex: number = excerptTokens.length;\n if (state.lastAppendedTokenIsSeparator) {\n excerptEndIndex--;\n }\n\n capturedTokenRange.endIndex = excerptEndIndex;\n }\n\n return true;\n }\n\n private static _appendToken(\n excerptTokens: IExcerptToken[],\n excerptTokenKind: ExcerptTokenKind,\n text: string,\n canonicalReference?: DeclarationReference\n ): void {\n if (text.length === 0) {\n return;\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 }\n\n /**\n * Condenses the provided excerpt tokens by merging tokens where possible. Updates the provided token ranges to\n * remain accurate after token merging.\n *\n * @remarks\n * For example, suppose we have excerpt tokens [\"A\", \"B\", \"C\"] and a token range [0, 2]. If the excerpt tokens\n * are condensed to [\"AB\", \"C\"], then the token range would be updated to [0, 1]. Note that merges are only\n * performed if they are compatible with the provided token ranges. In the example above, if our token range was\n * originally [0, 1], we would not be able to merge tokens \"A\" and \"B\".\n */\n private static _condenseTokens(excerptTokens: IExcerptToken[], tokenRanges: IExcerptTokenRange[]): void {\n // This set is used to quickly lookup a start or end index.\n const startOrEndIndices: Set<number> = new Set();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n\n for (let currentIndex: number = 1; currentIndex < excerptTokens.length; ++currentIndex) {\n while (currentIndex < excerptTokens.length) {\n const prevPrevToken: IExcerptToken = excerptTokens[currentIndex - 2]; // May be undefined\n const prevToken: IExcerptToken = excerptTokens[currentIndex - 1];\n const currentToken: IExcerptToken = excerptTokens[currentIndex];\n\n // The number of excerpt tokens that are merged in this iteration. We need this to determine\n // how to update the start and end indices of our token ranges.\n let mergeCount: number;\n\n // There are two types of merges that can occur. We only perform these merges if they are\n // compatible with all of our token ranges.\n if (\n prevPrevToken &&\n prevPrevToken.kind === ExcerptTokenKind.Reference &&\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.text.trim() === '.' &&\n currentToken.kind === ExcerptTokenKind.Reference &&\n !startOrEndIndices.has(currentIndex) &&\n !startOrEndIndices.has(currentIndex - 1)\n ) {\n // If the current token is a reference token, the previous token is a \".\", and the previous-\n // previous token is a reference token, then merge all three tokens into a reference token.\n //\n // For example: Given [\"MyNamespace\" (R), \".\", \"MyClass\" (R)], tokens \".\" and \"MyClass\" might\n // be merged into \"MyNamespace\". The condensed token would be [\"MyNamespace.MyClass\" (R)].\n prevPrevToken.text += prevToken.text + currentToken.text;\n prevPrevToken.canonicalReference = currentToken.canonicalReference;\n mergeCount = 2;\n currentIndex--;\n } else if (\n // If the current and previous tokens are both content tokens, then merge the tokens into a\n // single content token. For example: Given [\"export \", \"declare class\"], these tokens\n // might be merged into \"export declare class\".\n prevToken.kind === ExcerptTokenKind.Content &&\n prevToken.kind === currentToken.kind &&\n !startOrEndIndices.has(currentIndex)\n ) {\n prevToken.text += currentToken.text;\n mergeCount = 1;\n } else {\n // Otherwise, no merging can occur here. Continue to the next index.\n break;\n }\n\n // Remove the now redundant excerpt token(s), as they were merged into a previous token.\n excerptTokens.splice(currentIndex, mergeCount);\n\n // Update the start and end indices for all token ranges based upon how many excerpt\n // tokens were merged and in what positions.\n for (const tokenRange of tokenRanges) {\n if (tokenRange.startIndex > currentIndex) {\n tokenRange.startIndex -= mergeCount;\n }\n\n if (tokenRange.endIndex > currentIndex) {\n tokenRange.endIndex -= mergeCount;\n }\n }\n\n // Clear and repopulate our set with the updated indices.\n startOrEndIndices.clear();\n for (const tokenRange of tokenRanges) {\n startOrEndIndices.add(tokenRange.startIndex);\n startOrEndIndices.add(tokenRange.endIndex);\n }\n }\n }\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"]}