This commit is contained in:
2024-02-07 01:33:07 -05:00
commit c1af19d441
4088 changed files with 1260170 additions and 0 deletions

View File

@ -0,0 +1,72 @@
import { ApiDocumentedItem, type IApiDocumentedItemJson, type IApiDocumentedItemOptions } from './ApiDocumentedItem';
import { Excerpt, ExcerptToken, type IExcerptTokenRange, type IExcerptToken } from '../mixins/Excerpt';
import type { DeserializerContext } from '../model/DeserializerContext';
import { SourceLocation } from '../model/SourceLocation';
/**
* Constructor options for {@link ApiDeclaredItem}.
* @public
*/
export interface IApiDeclaredItemOptions extends IApiDocumentedItemOptions {
excerptTokens: IExcerptToken[];
fileUrlPath?: string;
}
export interface IApiDeclaredItemJson extends IApiDocumentedItemJson {
excerptTokens: IExcerptToken[];
fileUrlPath?: string;
}
/**
* The base class for API items that have an associated source code excerpt containing a TypeScript declaration.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
*
* Most `ApiItem` subclasses have declarations and thus extend `ApiDeclaredItem`. Counterexamples include
* `ApiModel` and `ApiPackage`, which do not have any corresponding TypeScript source code.
*
* @public
*/
export declare class ApiDeclaredItem extends ApiDocumentedItem {
private _excerptTokens;
private _excerpt;
private _fileUrlPath?;
private _sourceLocation?;
constructor(options: IApiDeclaredItemOptions);
/** @override */
static onDeserializeInto(options: Partial<IApiDeclaredItemOptions>, context: DeserializerContext, jsonObject: IApiDeclaredItemJson): void;
/**
* The source code excerpt where the API item is declared.
*/
get excerpt(): Excerpt;
/**
* The individual source code tokens that comprise the main excerpt.
*/
get excerptTokens(): ReadonlyArray<ExcerptToken>;
/**
* The file URL path relative to the `projectFolder` and `projectFolderURL` fields
* as defined in the `api-extractor.json` config. Is `undefined` if the path is
* the same as the parent API item's.
*/
get fileUrlPath(): string | undefined;
/**
* Returns the source location where the API item is declared.
*/
get sourceLocation(): SourceLocation;
/**
* If the API item has certain important modifier tags such as `@sealed`, `@virtual`, or `@override`,
* this prepends them as a doc comment above the excerpt.
*/
getExcerptWithModifiers(): string;
/** @override */
serializeInto(jsonObject: Partial<IApiDeclaredItemJson>): void;
/**
* Constructs a new {@link Excerpt} corresponding to the provided token range.
*/
buildExcerpt(tokenRange: IExcerptTokenRange): Excerpt;
/**
* Builds the cached object used by the `sourceLocation` property.
*/
private _buildSourceLocation;
}
//# sourceMappingURL=ApiDeclaredItem.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ApiDeclaredItem.d.ts","sourceRoot":"","sources":["../../src/items/ApiDeclaredItem.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,uBAAwB,SAAQ,yBAAyB;IACxE,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,oBAAqB,SAAQ,sBAAsB;IAClE,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;GAYG;AAEH,qBAAa,eAAgB,SAAQ,iBAAiB;IACpD,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,eAAe,CAAC,CAAiB;gBAEtB,OAAO,EAAE,uBAAuB;IAcnD,gBAAgB;WACF,iBAAiB,CAC7B,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,EACzC,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,oBAAoB,GAC/B,IAAI;IAOP;;OAEG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;OAEG;IACH,IAAW,aAAa,IAAI,aAAa,CAAC,YAAY,CAAC,CAEtD;IAED;;;;OAIG;IACH,IAAW,WAAW,IAAI,MAAM,GAAG,SAAS,CAE3C;IAED;;OAEG;IACH,IAAW,cAAc,IAAI,cAAc,CAK1C;IAED;;;OAGG;IACI,uBAAuB,IAAI,MAAM;IA0BxC,gBAAgB;IACT,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;IAmBrE;;OAEG;IACI,YAAY,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO;IAI5D;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAgB7B"}

View File

@ -0,0 +1,142 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiDeclaredItem = void 0;
const DeclarationReference_1 = require("@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference");
const ApiDocumentedItem_1 = require("./ApiDocumentedItem");
const Excerpt_1 = require("../mixins/Excerpt");
const SourceLocation_1 = require("../model/SourceLocation");
/**
* The base class for API items that have an associated source code excerpt containing a TypeScript declaration.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
*
* Most `ApiItem` subclasses have declarations and thus extend `ApiDeclaredItem`. Counterexamples include
* `ApiModel` and `ApiPackage`, which do not have any corresponding TypeScript source code.
*
* @public
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
class ApiDeclaredItem extends ApiDocumentedItem_1.ApiDocumentedItem {
constructor(options) {
super(options);
this._excerptTokens = options.excerptTokens.map((token) => {
const canonicalReference = token.canonicalReference === undefined
? undefined
: DeclarationReference_1.DeclarationReference.parse(token.canonicalReference);
return new Excerpt_1.ExcerptToken(token.kind, token.text, canonicalReference);
});
this._excerpt = new Excerpt_1.Excerpt(this.excerptTokens, { startIndex: 0, endIndex: this.excerptTokens.length });
this._fileUrlPath = options.fileUrlPath;
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
super.onDeserializeInto(options, context, jsonObject);
options.excerptTokens = jsonObject.excerptTokens;
options.fileUrlPath = jsonObject.fileUrlPath;
}
/**
* The source code excerpt where the API item is declared.
*/
get excerpt() {
return this._excerpt;
}
/**
* The individual source code tokens that comprise the main excerpt.
*/
get excerptTokens() {
return this._excerptTokens;
}
/**
* The file URL path relative to the `projectFolder` and `projectFolderURL` fields
* as defined in the `api-extractor.json` config. Is `undefined` if the path is
* the same as the parent API item's.
*/
get fileUrlPath() {
return this._fileUrlPath;
}
/**
* Returns the source location where the API item is declared.
*/
get sourceLocation() {
if (!this._sourceLocation) {
this._sourceLocation = this._buildSourceLocation();
}
return this._sourceLocation;
}
/**
* If the API item has certain important modifier tags such as `@sealed`, `@virtual`, or `@override`,
* this prepends them as a doc comment above the excerpt.
*/
getExcerptWithModifiers() {
const excerpt = this.excerpt.text;
const modifierTags = [];
if (excerpt.length > 0) {
if (this instanceof ApiDocumentedItem_1.ApiDocumentedItem) {
if (this.tsdocComment) {
if (this.tsdocComment.modifierTagSet.isSealed()) {
modifierTags.push('@sealed');
}
if (this.tsdocComment.modifierTagSet.isVirtual()) {
modifierTags.push('@virtual');
}
if (this.tsdocComment.modifierTagSet.isOverride()) {
modifierTags.push('@override');
}
}
if (modifierTags.length > 0) {
return '/** ' + modifierTags.join(' ') + ' */\n' + excerpt;
}
}
}
return excerpt;
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
jsonObject.excerptTokens = this.excerptTokens.map((x) => {
const excerptToken = { kind: x.kind, text: x.text };
if (x.canonicalReference !== undefined) {
excerptToken.canonicalReference = x.canonicalReference.toString();
}
return excerptToken;
});
// Only serialize this API item's file URL path if it exists and it's different from its parent's
// (a little optimization to keep the doc model succinct).
if (this.fileUrlPath) {
if (!(this.parent instanceof ApiDeclaredItem) || this.fileUrlPath !== this.parent.fileUrlPath) {
jsonObject.fileUrlPath = this.fileUrlPath;
}
}
}
/**
* Constructs a new {@link Excerpt} corresponding to the provided token range.
*/
buildExcerpt(tokenRange) {
return new Excerpt_1.Excerpt(this.excerptTokens, tokenRange);
}
/**
* Builds the cached object used by the `sourceLocation` property.
*/
_buildSourceLocation() {
var _a;
const projectFolderUrl = (_a = this.getAssociatedPackage()) === null || _a === void 0 ? void 0 : _a.projectFolderUrl;
let fileUrlPath;
for (let current = this; current !== undefined; current = current.parent) {
if (current instanceof ApiDeclaredItem && current.fileUrlPath) {
fileUrlPath = current.fileUrlPath;
break;
}
}
return new SourceLocation_1.SourceLocation({
projectFolderUrl: projectFolderUrl,
fileUrlPath: fileUrlPath
});
}
}
exports.ApiDeclaredItem = ApiDeclaredItem;
//# sourceMappingURL=ApiDeclaredItem.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,33 @@
import * as tsdoc from '@microsoft/tsdoc';
import { ApiItem, type IApiItemOptions, type IApiItemJson } from './ApiItem';
import type { DeserializerContext } from '../model/DeserializerContext';
/**
* Constructor options for {@link ApiDocumentedItem}.
* @public
*/
export interface IApiDocumentedItemOptions extends IApiItemOptions {
docComment: tsdoc.DocComment | undefined;
}
export interface IApiDocumentedItemJson extends IApiItemJson {
docComment: string;
}
/**
* An abstract base class for API declarations that can have an associated TSDoc comment.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
*
* @public
*/
export declare class ApiDocumentedItem extends ApiItem {
private _tsdocComment;
constructor(options: IApiDocumentedItemOptions);
/** @override */
static onDeserializeInto(options: Partial<IApiDocumentedItemOptions>, context: DeserializerContext, jsonObject: IApiItemJson): void;
get tsdocComment(): tsdoc.DocComment | undefined;
/** @override */
serializeInto(jsonObject: Partial<IApiDocumentedItemJson>): void;
}
//# sourceMappingURL=ApiDocumentedItem.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ApiDocumentedItem.d.ts","sourceRoot":"","sources":["../../src/items/ApiDocumentedItem.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,eAAe;IAChE,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IAC1D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,qBAAa,iBAAkB,SAAQ,OAAO;IAC5C,OAAO,CAAC,aAAa,CAA+B;gBAEjC,OAAO,EAAE,yBAAyB;IAKrD,gBAAgB;WACF,iBAAiB,CAC7B,OAAO,EAAE,OAAO,CAAC,yBAAyB,CAAC,EAC3C,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,YAAY,GACvB,IAAI;IAkBP,IAAW,YAAY,IAAI,KAAK,CAAC,UAAU,GAAG,SAAS,CAEtD;IAED,gBAAgB;IACT,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,sBAAsB,CAAC,GAAG,IAAI;CAQxE"}

View File

@ -0,0 +1,75 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiDocumentedItem = void 0;
const tsdoc = __importStar(require("@microsoft/tsdoc"));
const ApiItem_1 = require("./ApiItem");
/**
* An abstract base class for API declarations that can have an associated TSDoc comment.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
*
* @public
*/
class ApiDocumentedItem extends ApiItem_1.ApiItem {
constructor(options) {
super(options);
this._tsdocComment = options.docComment;
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
super.onDeserializeInto(options, context, jsonObject);
const documentedJson = jsonObject;
if (documentedJson.docComment) {
const tsdocParser = new tsdoc.TSDocParser(context.tsdocConfiguration);
// NOTE: For now, we ignore TSDoc errors found in a serialized .api.json file.
// Normally these errors would have already been reported by API Extractor during analysis.
// However, they could also arise if the JSON file was edited manually, or if the file was saved
// using a different release of the software that used an incompatible syntax.
const parserContext = tsdocParser.parseString(documentedJson.docComment);
options.docComment = parserContext.docComment;
}
}
get tsdocComment() {
return this._tsdocComment;
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
if (this.tsdocComment !== undefined) {
jsonObject.docComment = this.tsdocComment.emitAsTsdoc();
}
else {
jsonObject.docComment = '';
}
}
}
exports.ApiDocumentedItem = ApiDocumentedItem;
//# sourceMappingURL=ApiDocumentedItem.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ApiDocumentedItem.js","sourceRoot":"","sources":["../../src/items/ApiDocumentedItem.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,wDAA0C;AAC1C,uCAA6E;AAe7E;;;;;;;;;GASG;AACH,MAAa,iBAAkB,SAAQ,iBAAO;IAG5C,YAAmB,OAAkC;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC;IAC1C,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,iBAAiB,CAC7B,OAA2C,EAC3C,OAA4B,EAC5B,UAAwB;QAExB,KAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAEtD,MAAM,cAAc,GAA2B,UAAoC,CAAC;QAEpF,IAAI,cAAc,CAAC,UAAU,EAAE;YAC7B,MAAM,WAAW,GAAsB,IAAI,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;YAEzF,8EAA8E;YAC9E,2FAA2F;YAC3F,gGAAgG;YAChG,8EAA8E;YAC9E,MAAM,aAAa,GAAwB,WAAW,CAAC,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;YAE9F,OAAO,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;SAC/C;IACH,CAAC;IAED,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,gBAAgB;IACT,aAAa,CAAC,UAA2C;QAC9D,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE;YACnC,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;SACzD;aAAM;YACL,UAAU,CAAC,UAAU,GAAG,EAAE,CAAC;SAC5B;IACH,CAAC;CACF;AA5CD,8CA4CC","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 tsdoc from '@microsoft/tsdoc';\nimport { ApiItem, type IApiItemOptions, type IApiItemJson } from './ApiItem';\nimport type { DeserializerContext } from '../model/DeserializerContext';\n\n/**\n * Constructor options for {@link ApiDocumentedItem}.\n * @public\n */\nexport interface IApiDocumentedItemOptions extends IApiItemOptions {\n docComment: tsdoc.DocComment | undefined;\n}\n\nexport interface IApiDocumentedItemJson extends IApiItemJson {\n docComment: string;\n}\n\n/**\n * An abstract base class for API declarations that can have an associated TSDoc comment.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations.\n *\n * @public\n */\nexport class ApiDocumentedItem extends ApiItem {\n private _tsdocComment: tsdoc.DocComment | undefined;\n\n public constructor(options: IApiDocumentedItemOptions) {\n super(options);\n this._tsdocComment = options.docComment;\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiDocumentedItemOptions>,\n context: DeserializerContext,\n jsonObject: IApiItemJson\n ): void {\n super.onDeserializeInto(options, context, jsonObject);\n\n const documentedJson: IApiDocumentedItemJson = jsonObject as IApiDocumentedItemJson;\n\n if (documentedJson.docComment) {\n const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(context.tsdocConfiguration);\n\n // NOTE: For now, we ignore TSDoc errors found in a serialized .api.json file.\n // Normally these errors would have already been reported by API Extractor during analysis.\n // However, they could also arise if the JSON file was edited manually, or if the file was saved\n // using a different release of the software that used an incompatible syntax.\n const parserContext: tsdoc.ParserContext = tsdocParser.parseString(documentedJson.docComment);\n\n options.docComment = parserContext.docComment;\n }\n }\n\n public get tsdocComment(): tsdoc.DocComment | undefined {\n return this._tsdocComment;\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiDocumentedItemJson>): void {\n super.serializeInto(jsonObject);\n if (this.tsdocComment !== undefined) {\n jsonObject.docComment = this.tsdocComment.emitAsTsdoc();\n } else {\n jsonObject.docComment = '';\n }\n }\n}\n"]}

View File

@ -0,0 +1,180 @@
import type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';
import type { Constructor, PropertiesOf } from '../mixins/Mixin';
import type { ApiPackage } from '../model/ApiPackage';
import type { DeserializerContext } from '../model/DeserializerContext';
import type { ApiModel } from '../model/ApiModel';
/**
* The type returned by the {@link ApiItem.kind} property, which can be used to easily distinguish subclasses of
* {@link ApiItem}.
*
* @public
*/
export declare enum ApiItemKind {
CallSignature = "CallSignature",
Class = "Class",
Constructor = "Constructor",
ConstructSignature = "ConstructSignature",
EntryPoint = "EntryPoint",
Enum = "Enum",
EnumMember = "EnumMember",
Function = "Function",
IndexSignature = "IndexSignature",
Interface = "Interface",
Method = "Method",
MethodSignature = "MethodSignature",
Model = "Model",
Namespace = "Namespace",
Package = "Package",
Property = "Property",
PropertySignature = "PropertySignature",
TypeAlias = "TypeAlias",
Variable = "Variable",
None = "None"
}
/**
* Constructor options for {@link ApiItem}.
* @public
*/
export interface IApiItemOptions {
}
export interface IApiItemJson {
kind: ApiItemKind;
canonicalReference: string;
}
export declare const apiItem_onParentChanged: unique symbol;
/**
* The abstract base class for all members of an `ApiModel` object.
*
* @remarks
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
* @public
*/
export declare class ApiItem {
private _canonicalReference;
private _parent;
constructor(options: IApiItemOptions);
static deserialize(jsonObject: IApiItemJson, context: DeserializerContext): ApiItem;
/** @virtual */
static onDeserializeInto(options: Partial<IApiItemOptions>, context: DeserializerContext, jsonObject: IApiItemJson): void;
/** @virtual */
serializeInto(jsonObject: Partial<IApiItemJson>): void;
/**
* Identifies the subclass of the `ApiItem` base class.
* @virtual
*/
get kind(): ApiItemKind;
/**
* Warning: This API is used internally by API extractor but is not yet ready for general usage.
*
* @remarks
*
* Returns a `DeclarationReference` object using the experimental new declaration reference notation.
*
* @beta
*/
get canonicalReference(): DeclarationReference;
/**
* Returns a string key that can be used to efficiently retrieve an `ApiItem` from an `ApiItemContainerMixin`.
* The key is unique within the container. Its format is undocumented and may change at any time.
*
* @remarks
* Use the `getContainerKey()` static member to construct the key. Each subclass has a different implementation
* of this function, according to the aspects that are important for identifying it.
*
* @virtual
*/
get containerKey(): string;
/**
* Returns a name for this object that can be used in diagnostic messages, for example.
*
* @remarks
* For an object that inherits ApiNameMixin, this will return the declared name (e.g. the name of a TypeScript
* function). Otherwise, it will return a string such as "(call signature)" or "(model)".
*
* @virtual
*/
get displayName(): string;
/**
* If this item was added to a ApiItemContainerMixin item, then this returns the container item.
* If this is an Parameter that was added to a method or function, then this returns the function item.
* Otherwise, it returns undefined.
* @virtual
*/
get parent(): ApiItem | undefined;
/**
* This property supports a visitor pattern for walking the tree.
* For items with ApiItemContainerMixin, it returns the contained items, sorted alphabetically.
* Otherwise it returns an empty array.
* @virtual
*/
get members(): ReadonlyArray<ApiItem>;
/**
* If this item has a name (i.e. extends `ApiNameMixin`), then return all items that have the same parent
* and the same name. Otherwise, return all items that have the same parent and the same `ApiItemKind`.
*
* @remarks
* Examples: For a function, this would return all overloads for the function. For a constructor, this would
* return all overloads for the constructor. For a merged declaration (e.g. a `namespace` and `enum` with the
* same name), this would return both declarations. If this item does not have a parent, or if it is the only
* item of its name/kind, then the result is an array containing only this item.
*/
getMergedSiblings(): ReadonlyArray<ApiItem>;
/**
* Returns the chain of ancestors, starting from the root of the tree, and ending with the this item.
*/
getHierarchy(): ReadonlyArray<ApiItem>;
/**
* This returns a scoped name such as `"Namespace1.Namespace2.MyClass.myMember()"`. It does not include the
* package name or entry point.
*
* @remarks
* If called on an ApiEntrypoint, ApiPackage, or ApiModel item, the result is an empty string.
*/
getScopedNameWithinPackage(): string;
/**
* If this item is an ApiPackage or has an ApiPackage as one of its parents, then that object is returned.
* Otherwise undefined is returned.
*/
getAssociatedPackage(): ApiPackage | undefined;
/**
* If this item is an ApiModel or has an ApiModel as one of its parents, then that object is returned.
* Otherwise undefined is returned.
*/
getAssociatedModel(): ApiModel | undefined;
/**
* A text string whose value determines the sort order that is automatically applied by the
* {@link (ApiItemContainerMixin:interface)} class.
*
* @remarks
* The value of this string is undocumented and may change at any time.
* If {@link (ApiItemContainerMixin:interface).preserveMemberOrder} is enabled for the `ApiItem`'s parent,
* then no sorting is performed, and this key is not used.
*
* @virtual
*/
getSortKey(): string;
/**
* PRIVATE
*
* @privateRemarks
* Allows ApiItemContainerMixin to assign the parent when the item is added to a container.
*
* @internal
*/
[apiItem_onParentChanged](parent: ApiItem | undefined): void;
/**
* Builds the cached object used by the `canonicalReference` property.
* @virtual
*/
protected buildCanonicalReference(): DeclarationReference;
}
/**
* This abstraction is used by the mixin pattern.
* It describes a class type that inherits from {@link ApiItem}.
*
* @public
*/
export interface IApiItemConstructor extends Constructor<ApiItem>, PropertiesOf<typeof ApiItem> {
}
//# sourceMappingURL=ApiItem.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ApiItem.d.ts","sourceRoot":"","sources":["../../src/items/ApiItem.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yDAAyD,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;GAKG;AACH,oBAAY,WAAW;IACrB,aAAa,kBAAkB;IAC/B,KAAK,UAAU;IACf,WAAW,gBAAgB;IAC3B,kBAAkB,uBAAuB;IACzC,UAAU,eAAe;IACzB,IAAI,SAAS;IACb,UAAU,eAAe;IACzB,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,eAAe,oBAAoB;IACnC,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,iBAAiB,sBAAsB;IACvC,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,IAAI,SAAS;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;CAAG;AAEnC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,WAAW,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAID,eAAO,MAAM,uBAAuB,EAAE,OAAO,MAA4C,CAAC;AAE1F;;;;;;;GAOG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,mBAAmB,CAAmC;IAC9D,OAAO,CAAC,OAAO,CAAsB;gBAElB,OAAO,EAAE,eAAe;WAI7B,WAAW,CAAC,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO;IAO1F,eAAe;WACD,iBAAiB,CAC7B,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,YAAY,GACvB,IAAI;IAIP,eAAe;IACR,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI;IAK7D;;;OAGG;IACH,IAAW,IAAI,IAAI,WAAW,CAE7B;IAED;;;;;;;;OAQG;IACH,IAAW,kBAAkB,IAAI,oBAAoB,CAUpD;IAED;;;;;;;;;OASG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;;;;;;;OAQG;IACH,IAAW,WAAW,IAAI,MAAM,CAc/B;IAED;;;;;OAKG;IACH,IAAW,MAAM,IAAI,OAAO,GAAG,SAAS,CAEvC;IAED;;;;;OAKG;IACH,IAAW,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAE3C;IAED;;;;;;;;;OASG;IACI,iBAAiB,IAAI,aAAa,CAAC,OAAO,CAAC;IAQlD;;OAEG;IACI,YAAY,IAAI,aAAa,CAAC,OAAO,CAAC;IAS7C;;;;;;OAMG;IACI,0BAA0B,IAAI,MAAM;IAiC3C;;;OAGG;IACI,oBAAoB,IAAI,UAAU,GAAG,SAAS;IASrD;;;OAGG;IACI,kBAAkB,IAAI,QAAQ,GAAG,SAAS;IASjD;;;;;;;;;;OAUG;IACI,UAAU,IAAI,MAAM;IAI3B;;;;;;;OAOG;IACI,CAAC,uBAAuB,CAAC,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI;IAKnE;;;OAGG;IACH,SAAS,CAAC,uBAAuB,IAAI,oBAAoB;CAG1D;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW,CAAC,OAAO,CAAC,EAAE,YAAY,CAAC,OAAO,OAAO,CAAC;CAAG"}

View File

@ -0,0 +1,274 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiItem = exports.apiItem_onParentChanged = exports.ApiItemKind = void 0;
const ApiParameterListMixin_1 = require("../mixins/ApiParameterListMixin");
const node_core_library_1 = require("@rushstack/node-core-library");
const ApiItemContainerMixin_1 = require("../mixins/ApiItemContainerMixin");
/**
* The type returned by the {@link ApiItem.kind} property, which can be used to easily distinguish subclasses of
* {@link ApiItem}.
*
* @public
*/
var ApiItemKind;
(function (ApiItemKind) {
ApiItemKind["CallSignature"] = "CallSignature";
ApiItemKind["Class"] = "Class";
ApiItemKind["Constructor"] = "Constructor";
ApiItemKind["ConstructSignature"] = "ConstructSignature";
ApiItemKind["EntryPoint"] = "EntryPoint";
ApiItemKind["Enum"] = "Enum";
ApiItemKind["EnumMember"] = "EnumMember";
ApiItemKind["Function"] = "Function";
ApiItemKind["IndexSignature"] = "IndexSignature";
ApiItemKind["Interface"] = "Interface";
ApiItemKind["Method"] = "Method";
ApiItemKind["MethodSignature"] = "MethodSignature";
ApiItemKind["Model"] = "Model";
ApiItemKind["Namespace"] = "Namespace";
ApiItemKind["Package"] = "Package";
ApiItemKind["Property"] = "Property";
ApiItemKind["PropertySignature"] = "PropertySignature";
ApiItemKind["TypeAlias"] = "TypeAlias";
ApiItemKind["Variable"] = "Variable";
ApiItemKind["None"] = "None";
})(ApiItemKind = exports.ApiItemKind || (exports.ApiItemKind = {}));
// PRIVATE - Allows ApiItemContainerMixin to assign the parent.
//
exports.apiItem_onParentChanged = Symbol('ApiItem._onAddToContainer');
/**
* The abstract base class for all members of an `ApiModel` object.
*
* @remarks
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations.
* @public
*/
class ApiItem {
constructor(options) {
// ("options" is not used here, but part of the inheritance pattern)
}
static deserialize(jsonObject, context) {
// The Deserializer class is coupled with a ton of other classes, so we delay loading it
// to avoid ES5 circular imports.
const deserializerModule = require('../model/Deserializer');
return deserializerModule.Deserializer.deserialize(context, jsonObject);
}
/** @virtual */
static onDeserializeInto(options, context, jsonObject) {
// (implemented by subclasses)
}
/** @virtual */
serializeInto(jsonObject) {
jsonObject.kind = this.kind;
jsonObject.canonicalReference = this.canonicalReference.toString();
}
/**
* Identifies the subclass of the `ApiItem` base class.
* @virtual
*/
get kind() {
throw new Error('ApiItem.kind was not implemented by the child class');
}
/**
* Warning: This API is used internally by API extractor but is not yet ready for general usage.
*
* @remarks
*
* Returns a `DeclarationReference` object using the experimental new declaration reference notation.
*
* @beta
*/
get canonicalReference() {
if (!this._canonicalReference) {
try {
this._canonicalReference = this.buildCanonicalReference();
}
catch (e) {
const name = this.getScopedNameWithinPackage() || this.displayName;
throw new node_core_library_1.InternalError(`Error building canonical reference for ${name}:\n` + e.message);
}
}
return this._canonicalReference;
}
/**
* Returns a string key that can be used to efficiently retrieve an `ApiItem` from an `ApiItemContainerMixin`.
* The key is unique within the container. Its format is undocumented and may change at any time.
*
* @remarks
* Use the `getContainerKey()` static member to construct the key. Each subclass has a different implementation
* of this function, according to the aspects that are important for identifying it.
*
* @virtual
*/
get containerKey() {
throw new node_core_library_1.InternalError('ApiItem.containerKey was not implemented by the child class');
}
/**
* Returns a name for this object that can be used in diagnostic messages, for example.
*
* @remarks
* For an object that inherits ApiNameMixin, this will return the declared name (e.g. the name of a TypeScript
* function). Otherwise, it will return a string such as "(call signature)" or "(model)".
*
* @virtual
*/
get displayName() {
switch (this.kind) {
case ApiItemKind.CallSignature:
return '(call)';
case ApiItemKind.Constructor:
return '(constructor)';
case ApiItemKind.ConstructSignature:
return '(new)';
case ApiItemKind.IndexSignature:
return '(indexer)';
case ApiItemKind.Model:
return '(model)';
}
return '(???)'; // All other types should inherit ApiNameMixin which will override this property
}
/**
* If this item was added to a ApiItemContainerMixin item, then this returns the container item.
* If this is an Parameter that was added to a method or function, then this returns the function item.
* Otherwise, it returns undefined.
* @virtual
*/
get parent() {
return this._parent;
}
/**
* This property supports a visitor pattern for walking the tree.
* For items with ApiItemContainerMixin, it returns the contained items, sorted alphabetically.
* Otherwise it returns an empty array.
* @virtual
*/
get members() {
return [];
}
/**
* If this item has a name (i.e. extends `ApiNameMixin`), then return all items that have the same parent
* and the same name. Otherwise, return all items that have the same parent and the same `ApiItemKind`.
*
* @remarks
* Examples: For a function, this would return all overloads for the function. For a constructor, this would
* return all overloads for the constructor. For a merged declaration (e.g. a `namespace` and `enum` with the
* same name), this would return both declarations. If this item does not have a parent, or if it is the only
* item of its name/kind, then the result is an array containing only this item.
*/
getMergedSiblings() {
const parent = this._parent;
if (parent && ApiItemContainerMixin_1.ApiItemContainerMixin.isBaseClassOf(parent)) {
return parent._getMergedSiblingsForMember(this);
}
return [];
}
/**
* Returns the chain of ancestors, starting from the root of the tree, and ending with the this item.
*/
getHierarchy() {
const hierarchy = [];
for (let current = this; current !== undefined; current = current.parent) {
hierarchy.push(current);
}
hierarchy.reverse();
return hierarchy;
}
/**
* This returns a scoped name such as `"Namespace1.Namespace2.MyClass.myMember()"`. It does not include the
* package name or entry point.
*
* @remarks
* If called on an ApiEntrypoint, ApiPackage, or ApiModel item, the result is an empty string.
*/
getScopedNameWithinPackage() {
const reversedParts = [];
for (let current = this; current !== undefined; current = current.parent) {
if (current.kind === ApiItemKind.Model ||
current.kind === ApiItemKind.Package ||
current.kind === ApiItemKind.EntryPoint) {
break;
}
if (reversedParts.length !== 0) {
reversedParts.push('.');
}
else {
switch (current.kind) {
case ApiItemKind.CallSignature:
case ApiItemKind.ConstructSignature:
case ApiItemKind.Constructor:
case ApiItemKind.IndexSignature:
// These functional forms don't have a proper name, so we don't append the "()" suffix
break;
default:
if (ApiParameterListMixin_1.ApiParameterListMixin.isBaseClassOf(current)) {
reversedParts.push('()');
}
}
}
reversedParts.push(current.displayName);
}
return reversedParts.reverse().join('');
}
/**
* If this item is an ApiPackage or has an ApiPackage as one of its parents, then that object is returned.
* Otherwise undefined is returned.
*/
getAssociatedPackage() {
for (let current = this; current !== undefined; current = current.parent) {
if (current.kind === ApiItemKind.Package) {
return current;
}
}
return undefined;
}
/**
* If this item is an ApiModel or has an ApiModel as one of its parents, then that object is returned.
* Otherwise undefined is returned.
*/
getAssociatedModel() {
for (let current = this; current !== undefined; current = current.parent) {
if (current.kind === ApiItemKind.Model) {
return current;
}
}
return undefined;
}
/**
* A text string whose value determines the sort order that is automatically applied by the
* {@link (ApiItemContainerMixin:interface)} class.
*
* @remarks
* The value of this string is undocumented and may change at any time.
* If {@link (ApiItemContainerMixin:interface).preserveMemberOrder} is enabled for the `ApiItem`'s parent,
* then no sorting is performed, and this key is not used.
*
* @virtual
*/
getSortKey() {
return this.containerKey;
}
/**
* PRIVATE
*
* @privateRemarks
* Allows ApiItemContainerMixin to assign the parent when the item is added to a container.
*
* @internal
*/
[exports.apiItem_onParentChanged](parent) {
this._parent = parent;
this._canonicalReference = undefined;
}
/**
* Builds the cached object used by the `canonicalReference` property.
* @virtual
*/
buildCanonicalReference() {
throw new node_core_library_1.InternalError('ApiItem.canonicalReference was not implemented by the child class');
}
}
exports.ApiItem = ApiItem;
//# sourceMappingURL=ApiItem.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
import type { Excerpt, IExcerptTokenRange } from '../mixins/Excerpt';
import { type IApiDeclaredItemOptions, ApiDeclaredItem, type IApiDeclaredItemJson } from '../items/ApiDeclaredItem';
import { ApiReleaseTagMixin, type IApiReleaseTagMixinOptions } from '../mixins/ApiReleaseTagMixin';
import { type IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';
import type { DeserializerContext } from '../model/DeserializerContext';
import { ApiOptionalMixin, type IApiOptionalMixinOptions } from '../mixins/ApiOptionalMixin';
import { ApiReadonlyMixin, type IApiReadonlyMixinOptions } from '../mixins/ApiReadonlyMixin';
/**
* Constructor options for {@link ApiPropertyItem}.
* @public
*/
export interface IApiPropertyItemOptions extends IApiNameMixinOptions, IApiReleaseTagMixinOptions, IApiOptionalMixinOptions, IApiReadonlyMixinOptions, IApiDeclaredItemOptions {
propertyTypeTokenRange: IExcerptTokenRange;
}
export interface IApiPropertyItemJson extends IApiDeclaredItemJson {
propertyTypeTokenRange: IExcerptTokenRange;
}
declare const ApiPropertyItem_base: typeof ApiDeclaredItem & (new (...args: any[]) => ApiReadonlyMixin) & (new (...args: any[]) => ApiOptionalMixin) & (new (...args: any[]) => ApiReleaseTagMixin) & (new (...args: any[]) => ApiNameMixin);
/**
* The abstract base class for {@link ApiProperty} and {@link ApiPropertySignature}.
*
* @public
*/
export declare class ApiPropertyItem extends ApiPropertyItem_base {
/**
* An {@link Excerpt} that describes the type of the property.
*/
readonly propertyTypeExcerpt: Excerpt;
constructor(options: IApiPropertyItemOptions);
/** @override */
static onDeserializeInto(options: Partial<IApiPropertyItemOptions>, context: DeserializerContext, jsonObject: IApiPropertyItemJson): void;
/**
* Returns true if this property should be documented as an event.
*
* @remarks
* The `@eventProperty` TSDoc modifier can be added to readonly properties to indicate that they return an
* event object that event handlers can be attached to. The event-handling API is implementation-defined, but
* typically the return type would be a class with members such as `addHandler()` and `removeHandler()`.
* The documentation should display such properties under an "Events" heading instead of the
* usual "Properties" heading.
*/
get isEventProperty(): boolean;
/** @override */
serializeInto(jsonObject: Partial<IApiPropertyItemJson>): void;
}
export {};
//# sourceMappingURL=ApiPropertyItem.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ApiPropertyItem.d.ts","sourceRoot":"","sources":["../../src/items/ApiPropertyItem.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EACL,KAAK,uBAAuB,EAC5B,eAAe,EACf,KAAK,oBAAoB,EAC1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,KAAK,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AACnG,OAAO,EAAE,KAAK,oBAAoB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,KAAK,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE7F;;;GAGG;AACH,MAAM,WAAW,uBACf,SAAQ,oBAAoB,EAC1B,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB;IACzB,sBAAsB,EAAE,kBAAkB,CAAC;CAC5C;AAED,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,sBAAsB,EAAE,kBAAkB,CAAC;CAC5C;;AAED;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,oBAEpC;IACC;;OAEG;IACH,SAAgB,mBAAmB,EAAE,OAAO,CAAC;gBAE1B,OAAO,EAAE,uBAAuB;IAMnD,gBAAgB;WACF,iBAAiB,CAC7B,OAAO,EAAE,OAAO,CAAC,uBAAuB,CAAC,EACzC,OAAO,EAAE,mBAAmB,EAC5B,UAAU,EAAE,oBAAoB,GAC/B,IAAI;IAMP;;;;;;;;;OASG;IACH,IAAW,eAAe,IAAI,OAAO,CAKpC;IAED,gBAAgB;IACT,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;CAKtE"}

View File

@ -0,0 +1,49 @@
"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiPropertyItem = void 0;
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
const ApiReleaseTagMixin_1 = require("../mixins/ApiReleaseTagMixin");
const ApiNameMixin_1 = require("../mixins/ApiNameMixin");
const ApiOptionalMixin_1 = require("../mixins/ApiOptionalMixin");
const ApiReadonlyMixin_1 = require("../mixins/ApiReadonlyMixin");
/**
* The abstract base class for {@link ApiProperty} and {@link ApiPropertySignature}.
*
* @public
*/
class ApiPropertyItem extends (0, ApiNameMixin_1.ApiNameMixin)((0, ApiReleaseTagMixin_1.ApiReleaseTagMixin)((0, ApiOptionalMixin_1.ApiOptionalMixin)((0, ApiReadonlyMixin_1.ApiReadonlyMixin)(ApiDeclaredItem_1.ApiDeclaredItem)))) {
constructor(options) {
super(options);
this.propertyTypeExcerpt = this.buildExcerpt(options.propertyTypeTokenRange);
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
super.onDeserializeInto(options, context, jsonObject);
options.propertyTypeTokenRange = jsonObject.propertyTypeTokenRange;
}
/**
* Returns true if this property should be documented as an event.
*
* @remarks
* The `@eventProperty` TSDoc modifier can be added to readonly properties to indicate that they return an
* event object that event handlers can be attached to. The event-handling API is implementation-defined, but
* typically the return type would be a class with members such as `addHandler()` and `removeHandler()`.
* The documentation should display such properties under an "Events" heading instead of the
* usual "Properties" heading.
*/
get isEventProperty() {
if (this.tsdocComment) {
return this.tsdocComment.modifierTagSet.isEventProperty();
}
return false;
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
jsonObject.propertyTypeTokenRange = this.propertyTypeExcerpt.tokenRange;
}
}
exports.ApiPropertyItem = ApiPropertyItem;
//# sourceMappingURL=ApiPropertyItem.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ApiPropertyItem.js","sourceRoot":"","sources":["../../src/items/ApiPropertyItem.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,8DAIkC;AAClC,qEAAmG;AACnG,yDAAiF;AAEjF,iEAA6F;AAC7F,iEAA6F;AAmB7F;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,IAAA,2BAAY,EAC/C,IAAA,uCAAkB,EAAC,IAAA,mCAAgB,EAAC,IAAA,mCAAgB,EAAC,iCAAe,CAAC,CAAC,CAAC,CACxE;IAMC,YAAmB,OAAgC;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAC/E,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,iBAAiB,CAC7B,OAAyC,EACzC,OAA4B,EAC5B,UAAgC;QAEhC,KAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QAEtD,OAAO,CAAC,sBAAsB,GAAG,UAAU,CAAC,sBAAsB,CAAC;IACrE,CAAC;IAED;;;;;;;;;OASG;IACH,IAAW,eAAe;QACxB,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;SAC3D;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,gBAAgB;IACT,aAAa,CAAC,UAAyC;QAC5D,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAEhC,UAAU,CAAC,sBAAsB,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC;IAC1E,CAAC;CACF;AAhDD,0CAgDC","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 type { Excerpt, IExcerptTokenRange } from '../mixins/Excerpt';\nimport {\n type IApiDeclaredItemOptions,\n ApiDeclaredItem,\n type IApiDeclaredItemJson\n} from '../items/ApiDeclaredItem';\nimport { ApiReleaseTagMixin, type IApiReleaseTagMixinOptions } from '../mixins/ApiReleaseTagMixin';\nimport { type IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin';\nimport type { DeserializerContext } from '../model/DeserializerContext';\nimport { ApiOptionalMixin, type IApiOptionalMixinOptions } from '../mixins/ApiOptionalMixin';\nimport { ApiReadonlyMixin, type IApiReadonlyMixinOptions } from '../mixins/ApiReadonlyMixin';\n\n/**\n * Constructor options for {@link ApiPropertyItem}.\n * @public\n */\nexport interface IApiPropertyItemOptions\n extends IApiNameMixinOptions,\n IApiReleaseTagMixinOptions,\n IApiOptionalMixinOptions,\n IApiReadonlyMixinOptions,\n IApiDeclaredItemOptions {\n propertyTypeTokenRange: IExcerptTokenRange;\n}\n\nexport interface IApiPropertyItemJson extends IApiDeclaredItemJson {\n propertyTypeTokenRange: IExcerptTokenRange;\n}\n\n/**\n * The abstract base class for {@link ApiProperty} and {@link ApiPropertySignature}.\n *\n * @public\n */\nexport class ApiPropertyItem extends ApiNameMixin(\n ApiReleaseTagMixin(ApiOptionalMixin(ApiReadonlyMixin(ApiDeclaredItem)))\n) {\n /**\n * An {@link Excerpt} that describes the type of the property.\n */\n public readonly propertyTypeExcerpt: Excerpt;\n\n public constructor(options: IApiPropertyItemOptions) {\n super(options);\n\n this.propertyTypeExcerpt = this.buildExcerpt(options.propertyTypeTokenRange);\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiPropertyItemOptions>,\n context: DeserializerContext,\n jsonObject: IApiPropertyItemJson\n ): void {\n super.onDeserializeInto(options, context, jsonObject);\n\n options.propertyTypeTokenRange = jsonObject.propertyTypeTokenRange;\n }\n\n /**\n * Returns true if this property should be documented as an event.\n *\n * @remarks\n * The `@eventProperty` TSDoc modifier can be added to readonly properties to indicate that they return an\n * event object that event handlers can be attached to. The event-handling API is implementation-defined, but\n * typically the return type would be a class with members such as `addHandler()` and `removeHandler()`.\n * The documentation should display such properties under an \"Events\" heading instead of the\n * usual \"Properties\" heading.\n */\n public get isEventProperty(): boolean {\n if (this.tsdocComment) {\n return this.tsdocComment.modifierTagSet.isEventProperty();\n }\n return false;\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiPropertyItemJson>): void {\n super.serializeInto(jsonObject);\n\n jsonObject.propertyTypeTokenRange = this.propertyTypeExcerpt.tokenRange;\n }\n}\n"]}