Commit 956c501c authored by DatHV's avatar DatHV
Browse files

update build x-app-sdk

parent 9bb8aadd
"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.ApiItemContainerMixin = ApiItemContainerMixin;
/* eslint-disable @typescript-eslint/no-redeclare */
const node_core_library_1 = require("@rushstack/node-core-library");
const ApiItem_1 = require("../items/ApiItem");
const ApiNameMixin_1 = require("./ApiNameMixin");
const Excerpt_1 = require("./Excerpt");
const IFindApiItemsResult_1 = require("./IFindApiItemsResult");
const _members = Symbol('ApiItemContainerMixin._members');
const _membersSorted = Symbol('ApiItemContainerMixin._membersSorted');
const _membersByContainerKey = Symbol('ApiItemContainerMixin._membersByContainerKey');
const _membersByName = Symbol('ApiItemContainerMixin._membersByName');
const _membersByKind = Symbol('ApiItemContainerMixin._membersByKind');
const _preserveMemberOrder = Symbol('ApiItemContainerMixin._preserveMemberOrder');
/**
* Mixin function for {@link ApiDeclaredItem}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiItemContainerMixin:interface)} functionality.
*
* @public
*/
function ApiItemContainerMixin(baseClass
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
class MixedClass extends baseClass {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args) {
var _a;
super(...args);
const options = args[0];
this[_members] = [];
this[_membersSorted] = false;
this[_membersByContainerKey] = new Map();
this[_preserveMemberOrder] = (_a = options.preserveMemberOrder) !== null && _a !== void 0 ? _a : false;
if (options.members) {
for (const member of options.members) {
this.addMember(member);
}
}
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
baseClass.onDeserializeInto(options, context, jsonObject);
options.preserveMemberOrder = jsonObject.preserveMemberOrder;
options.members = [];
for (const memberObject of jsonObject.members) {
options.members.push(ApiItem_1.ApiItem.deserialize(memberObject, context));
}
}
/** @override */
get members() {
if (!this[_membersSorted] && !this[_preserveMemberOrder]) {
this[_members].sort((x, y) => x.getSortKey().localeCompare(y.getSortKey()));
this[_membersSorted] = true;
}
return this[_members];
}
get preserveMemberOrder() {
return this[_preserveMemberOrder];
}
addMember(member) {
if (this[_membersByContainerKey].has(member.containerKey)) {
throw new Error(`Another member has already been added with the same name (${member.displayName})` +
` and containerKey (${member.containerKey})`);
}
const existingParent = member.parent;
if (existingParent !== undefined) {
throw new Error(`This item has already been added to another container: "${existingParent.displayName}"`);
}
this[_members].push(member);
this[_membersByName] = undefined; // invalidate the lookup
this[_membersByKind] = undefined; // invalidate the lookup
this[_membersSorted] = false;
this[_membersByContainerKey].set(member.containerKey, member);
member[ApiItem_1.apiItem_onParentChanged](this);
}
tryGetMemberByKey(containerKey) {
return this[_membersByContainerKey].get(containerKey);
}
findMembersByName(name) {
this._ensureMemberMaps();
return this[_membersByName].get(name) || [];
}
findMembersWithInheritance() {
const messages = [];
let maybeIncompleteResult = false;
// For API items that don't support inheritance, this method just returns the item's
// immediate members.
switch (this.kind) {
case ApiItem_1.ApiItemKind.Class:
case ApiItem_1.ApiItemKind.Interface:
break;
default: {
return {
items: this.members.concat(),
messages,
maybeIncompleteResult
};
}
}
const membersByName = new Map();
const membersByKind = new Map();
const toVisit = [];
let next = this;
while (next) {
const membersToAdd = [];
// For each member, check to see if we've already seen a member with the same name
// previously in the inheritance tree. If so, we know we won't inherit it, and thus
// do not add it to our `membersToAdd` array.
for (const member of next.members) {
// We add the to-be-added members to an intermediate array instead of immediately
// to the maps themselves to support method overloads with the same name.
if (ApiNameMixin_1.ApiNameMixin.isBaseClassOf(member)) {
if (!membersByName.has(member.name)) {
membersToAdd.push(member);
}
}
else {
if (!membersByKind.has(member.kind)) {
membersToAdd.push(member);
}
}
}
for (const member of membersToAdd) {
if (ApiNameMixin_1.ApiNameMixin.isBaseClassOf(member)) {
const members = membersByName.get(member.name) || [];
members.push(member);
membersByName.set(member.name, members);
}
else {
const members = membersByKind.get(member.kind) || [];
members.push(member);
membersByKind.set(member.kind, members);
}
}
// Interfaces can extend multiple interfaces, so iterate through all of them.
const extendedItems = [];
let extendsTypes;
switch (next.kind) {
case ApiItem_1.ApiItemKind.Class: {
const apiClass = next;
extendsTypes = apiClass.extendsType ? [apiClass.extendsType] : [];
break;
}
case ApiItem_1.ApiItemKind.Interface: {
const apiInterface = next;
extendsTypes = apiInterface.extendsTypes;
break;
}
}
if (extendsTypes === undefined) {
messages.push({
messageId: IFindApiItemsResult_1.FindApiItemsMessageId.UnsupportedKind,
text: `Unable to analyze references of API item ${next.displayName} because it is of unsupported kind ${next.kind}`
});
maybeIncompleteResult = true;
next = toVisit.shift();
continue;
}
for (const extendsType of extendsTypes) {
// We want to find the reference token associated with the actual inherited declaration.
// In every case we support, this is the first reference token. For example:
//
// ```
// export class A extends B {}
// ^
// export class A extends B<C> {}
// ^
// export class A extends B.C {}
// ^^^
// ```
const firstReferenceToken = extendsType.excerpt.spannedTokens.find((token) => {
return token.kind === Excerpt_1.ExcerptTokenKind.Reference && token.canonicalReference;
});
if (!firstReferenceToken) {
messages.push({
messageId: IFindApiItemsResult_1.FindApiItemsMessageId.ExtendsClauseMissingReference,
text: `Unable to analyze extends clause ${extendsType.excerpt.text} of API item ${next.displayName} because no canonical reference was found`
});
maybeIncompleteResult = true;
continue;
}
const apiModel = this.getAssociatedModel();
if (!apiModel) {
messages.push({
messageId: IFindApiItemsResult_1.FindApiItemsMessageId.NoAssociatedApiModel,
text: `Unable to analyze references of API item ${next.displayName} because it is not associated with an ApiModel`
});
maybeIncompleteResult = true;
continue;
}
const canonicalReference = firstReferenceToken.canonicalReference;
const apiItemResult = apiModel.resolveDeclarationReference(canonicalReference, undefined);
const apiItem = apiItemResult.resolvedApiItem;
if (!apiItem) {
messages.push({
messageId: IFindApiItemsResult_1.FindApiItemsMessageId.DeclarationResolutionFailed,
text: `Unable to resolve declaration reference within API item ${next.displayName}: ${apiItemResult.errorMessage}`
});
maybeIncompleteResult = true;
continue;
}
extendedItems.push(apiItem);
}
// For classes, this array will only have one item. For interfaces, there may be multiple items. Sort the array
// into alphabetical order before adding to our list of API items to visit. This ensures that in the case
// of multiple interface inheritance, a member inherited from multiple interfaces is attributed to the interface
// earlier in alphabetical order (as opposed to source order).
//
// For example, in the code block below, `Bar.x` is reported as the inherited item, not `Foo.x`.
//
// ```
// interface Foo {
// public x: string;
// }
//
// interface Bar {
// public x: string;
// }
//
// interface FooBar extends Foo, Bar {}
// ```
extendedItems.sort((x, y) => x.getSortKey().localeCompare(y.getSortKey()));
toVisit.push(...extendedItems);
next = toVisit.shift();
}
const items = [];
for (const members of membersByName.values()) {
items.push(...members);
}
for (const members of membersByKind.values()) {
items.push(...members);
}
items.sort((x, y) => x.getSortKey().localeCompare(y.getSortKey()));
return {
items,
messages,
maybeIncompleteResult
};
}
/** @internal */
_getMergedSiblingsForMember(memberApiItem) {
this._ensureMemberMaps();
let result;
if (ApiNameMixin_1.ApiNameMixin.isBaseClassOf(memberApiItem)) {
result = this[_membersByName].get(memberApiItem.name);
}
else {
result = this[_membersByKind].get(memberApiItem.kind);
}
if (!result) {
throw new node_core_library_1.InternalError('Item was not found in the _membersByName/_membersByKind lookup');
}
return result;
}
/** @internal */
_ensureMemberMaps() {
// Build the _membersByName and _membersByKind tables if they don't already exist
if (this[_membersByName] === undefined) {
const membersByName = new Map();
const membersByKind = new Map();
for (const member of this[_members]) {
let map;
let key;
if (ApiNameMixin_1.ApiNameMixin.isBaseClassOf(member)) {
map = membersByName;
key = member.name;
}
else {
map = membersByKind;
key = member.kind;
}
let list = map.get(key);
if (list === undefined) {
list = [];
map.set(key, list);
}
list.push(member);
}
this[_membersByName] = membersByName;
this[_membersByKind] = membersByKind;
}
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
const memberObjects = [];
for (const member of this.members) {
const memberJsonObject = {};
member.serializeInto(memberJsonObject);
memberObjects.push(memberJsonObject);
}
jsonObject.preserveMemberOrder = this.preserveMemberOrder;
jsonObject.members = memberObjects;
}
}
return MixedClass;
}
/**
* Static members for {@link (ApiItemContainerMixin:interface)}.
* @public
*/
(function (ApiItemContainerMixin) {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiItemContainerMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem) {
return apiItem.hasOwnProperty(_members);
}
ApiItemContainerMixin.isBaseClassOf = isBaseClassOf;
})(ApiItemContainerMixin || (exports.ApiItemContainerMixin = ApiItemContainerMixin = {}));
//# sourceMappingURL=ApiItemContainerMixin.js.map
\ No newline at end of file
{"version":3,"file":"ApiItemContainerMixin.js","sourceRoot":"","sources":["../../src/mixins/ApiItemContainerMixin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AA2L3D,sDAqVC;AA9gBD,oDAAoD;AAEpD,oEAA6D;AAG7D,8CAO0B;AAC1B,iDAA8C;AAK9C,uCAAgE;AAChE,+DAI+B;AAkB/B,MAAM,QAAQ,GAAkB,MAAM,CAAC,gCAAgC,CAAC,CAAC;AACzE,MAAM,cAAc,GAAkB,MAAM,CAAC,sCAAsC,CAAC,CAAC;AACrF,MAAM,sBAAsB,GAAkB,MAAM,CAAC,8CAA8C,CAAC,CAAC;AACrG,MAAM,cAAc,GAAkB,MAAM,CAAC,sCAAsC,CAAC,CAAC;AACrF,MAAM,cAAc,GAAkB,MAAM,CAAC,sCAAsC,CAAC,CAAC;AACrF,MAAM,oBAAoB,GAAkB,MAAM,CAAC,4CAA4C,CAAC,CAAC;AAmIjG;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,SAAqB;AACrB,8DAA8D;;IAE9D,MAAM,UAAW,SAAQ,SAAS;QAchC,8DAA8D;QAC9D,YAAmB,GAAG,IAAW;;YAC/B,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YACf,MAAM,OAAO,GAAkC,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;QAC5C,OAAO,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAFe,mCAAa,gBAE5B,CAAA;AACH,CAAC,EAbgB,qBAAqB,qCAArB,qBAAqB,QAarC","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 @typescript-eslint/no-redeclare */\n\nimport { InternalError } from '@rushstack/node-core-library';\nimport type { DeclarationReference } from '@microsoft/tsdoc/lib-commonjs/beta/DeclarationReference';\n\nimport {\n ApiItem,\n apiItem_onParentChanged,\n type IApiItemJson,\n type IApiItemOptions,\n type IApiItemConstructor,\n ApiItemKind\n} from '../items/ApiItem';\nimport { ApiNameMixin } from './ApiNameMixin';\nimport type { DeserializerContext } from '../model/DeserializerContext';\nimport type { ApiModel } from '../model/ApiModel';\nimport type { ApiClass } from '../model/ApiClass';\nimport type { ApiInterface } from '../model/ApiInterface';\nimport { type ExcerptToken, ExcerptTokenKind } from './Excerpt';\nimport {\n type IFindApiItemsResult,\n type IFindApiItemsMessage,\n FindApiItemsMessageId\n} from './IFindApiItemsResult';\nimport type { HeritageType } from '../model/HeritageType';\nimport type { IResolveDeclarationReferenceResult } from '../model/ModelReferenceResolver';\n\n/**\n * Constructor options for {@link (ApiItemContainerMixin:interface)}.\n * @public\n */\nexport interface IApiItemContainerMixinOptions extends IApiItemOptions {\n preserveMemberOrder?: boolean;\n members?: ApiItem[];\n}\n\nexport interface IApiItemContainerJson extends IApiItemJson {\n preserveMemberOrder?: boolean;\n members: IApiItemJson[];\n}\n\nconst _members: unique symbol = Symbol('ApiItemContainerMixin._members');\nconst _membersSorted: unique symbol = Symbol('ApiItemContainerMixin._membersSorted');\nconst _membersByContainerKey: unique symbol = Symbol('ApiItemContainerMixin._membersByContainerKey');\nconst _membersByName: unique symbol = Symbol('ApiItemContainerMixin._membersByName');\nconst _membersByKind: unique symbol = Symbol('ApiItemContainerMixin._membersByKind');\nconst _preserveMemberOrder: unique symbol = Symbol('ApiItemContainerMixin._preserveMemberOrder');\n\n/**\n * The mixin base class for API items that act as containers for other child items.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\n * TypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\n * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\n * to extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\n * the function that generates a subclass, an interface that describes the members of the subclass, and\n * a namespace containing static members of the class.\n *\n * Examples of `ApiItemContainerMixin` child classes include `ApiModel`, `ApiPackage`, `ApiEntryPoint`,\n * and `ApiEnum`. But note that `Parameter` is not considered a \"member\" of an `ApiMethod`; this relationship\n * is modeled using {@link (ApiParameterListMixin:interface).parameters} instead\n * of {@link ApiItem.members}.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ApiItemContainerMixin extends ApiItem {\n /**\n * Disables automatic sorting of {@link ApiItem.members}.\n *\n * @remarks\n * By default `ApiItemContainerMixin` will automatically sort its members according to their\n * {@link ApiItem.getSortKey} string, which provides a standardized mostly alphabetical ordering\n * that is appropriate for most API items. When loading older .api.json files the automatic sorting\n * is reapplied and may update the ordering.\n *\n * Set `preserveMemberOrder` to true to disable automatic sorting for this container; instead, the\n * members will retain whatever ordering appeared in the {@link IApiItemContainerMixinOptions.members} array.\n * The `preserveMemberOrder` option is saved in the .api.json file.\n */\n readonly preserveMemberOrder: boolean;\n\n /**\n * Adds a new member to the container.\n *\n * @remarks\n * An ApiItem cannot be added to more than one container.\n */\n addMember(member: ApiItem): void;\n\n /**\n * Attempts to retrieve a member using its containerKey, or returns `undefined` if no matching member was found.\n *\n * @remarks\n * Use the `getContainerKey()` static member to construct the key. Each subclass has a different implementation\n * of this function, according to the aspects that are important for identifying it.\n *\n * See {@link ApiItem.containerKey} for more information.\n */\n tryGetMemberByKey(containerKey: string): ApiItem | undefined;\n\n /**\n * Returns a list of members with the specified name.\n */\n findMembersByName(name: string): ReadonlyArray<ApiItem>;\n\n /**\n * Finds all of the ApiItem's immediate and inherited members by walking up the inheritance tree.\n *\n * @remarks\n *\n * Given the following class heritage:\n *\n * ```\n * export class A {\n * public a: number|boolean;\n * }\n *\n * export class B extends A {\n * public a: number;\n * public b: string;\n * }\n *\n * export class C extends B {\n * public c: boolean;\n * }\n * ```\n *\n * Calling `findMembersWithInheritance` on `C` will return `B.a`, `B.b`, and `C.c`. Calling the\n * method on `B` will return `B.a` and `B.b`. And calling the method on `A` will return just\n * `A.a`.\n *\n * The inherited members returned by this method may be incomplete. If so, there will be a flag\n * on the result object indicating this as well as messages explaining the errors in more detail.\n * Some scenarios include:\n *\n * - Interface extending from a type alias.\n *\n * - Class extending from a variable.\n *\n * - Extending from a declaration not present in the model (e.g. external package).\n *\n * - Extending from an unexported declaration (e.g. ae-forgotten-export). Common in mixin\n * patterns.\n *\n * - Unexpected runtime errors...\n *\n * Lastly, be aware that the types of inherited members are returned with respect to their\n * defining class as opposed to with respect to the inheriting class. For example, consider\n * the following:\n *\n * ```\n * export class A<T> {\n * public a: T;\n * }\n *\n * export class B extends A<number> {}\n * ```\n *\n * When called on `B`, this method will return `B.a` with type `T` as opposed to type\n * `number`, although the latter is more accurate.\n */\n findMembersWithInheritance(): IFindApiItemsResult;\n\n /**\n * For a given member of this container, return its `ApiItem.getMergedSiblings()` list.\n * @internal\n */\n _getMergedSiblingsForMember(memberApiItem: ApiItem): ReadonlyArray<ApiItem>;\n\n /** @override */\n serializeInto(jsonObject: Partial<IApiItemJson>): void;\n}\n\n/**\n * Mixin function for {@link ApiDeclaredItem}.\n *\n * @param baseClass - The base class to be extended\n * @returns A child class that extends baseClass, adding the {@link (ApiItemContainerMixin:interface)} functionality.\n *\n * @public\n */\nexport function ApiItemContainerMixin<TBaseClass extends IApiItemConstructor>(\n baseClass: TBaseClass\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): TBaseClass & (new (...args: any[]) => ApiItemContainerMixin) {\n class MixedClass extends baseClass implements ApiItemContainerMixin {\n public readonly [_members]: ApiItem[];\n public [_membersSorted]: boolean;\n public [_membersByContainerKey]: Map<string, ApiItem>;\n public [_preserveMemberOrder]: boolean;\n\n // For members of this container that extend ApiNameMixin, this stores the list of members with a given name.\n // Examples include merged declarations, overloaded functions, etc.\n public [_membersByName]: Map<string, ApiItem[]> | undefined;\n\n // For members of this container that do NOT extend ApiNameMixin, this stores the list of members\n // that share a common ApiItemKind. Examples include overloaded constructors or index signatures.\n public [_membersByKind]: Map<string, ApiItem[]> | undefined; // key is ApiItemKind\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(...args: any[]) {\n super(...args);\n const options: IApiItemContainerMixinOptions = args[0] as IApiItemContainerMixinOptions;\n\n this[_members] = [];\n this[_membersSorted] = false;\n this[_membersByContainerKey] = new Map<string, ApiItem>();\n this[_preserveMemberOrder] = options.preserveMemberOrder ?? false;\n\n if (options.members) {\n for (const member of options.members) {\n this.addMember(member);\n }\n }\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiItemContainerMixinOptions>,\n context: DeserializerContext,\n jsonObject: IApiItemContainerJson\n ): void {\n baseClass.onDeserializeInto(options, context, jsonObject);\n options.preserveMemberOrder = jsonObject.preserveMemberOrder;\n options.members = [];\n for (const memberObject of jsonObject.members) {\n options.members.push(ApiItem.deserialize(memberObject, context));\n }\n }\n\n /** @override */\n public get members(): ReadonlyArray<ApiItem> {\n if (!this[_membersSorted] && !this[_preserveMemberOrder]) {\n this[_members].sort((x, y) => x.getSortKey().localeCompare(y.getSortKey()));\n this[_membersSorted] = true;\n }\n\n return this[_members];\n }\n\n public get preserveMemberOrder(): boolean {\n return this[_preserveMemberOrder];\n }\n\n public addMember(member: ApiItem): void {\n if (this[_membersByContainerKey].has(member.containerKey)) {\n throw new Error(\n `Another member has already been added with the same name (${member.displayName})` +\n ` and containerKey (${member.containerKey})`\n );\n }\n\n const existingParent: ApiItem | undefined = member.parent;\n if (existingParent !== undefined) {\n throw new Error(\n `This item has already been added to another container: \"${existingParent.displayName}\"`\n );\n }\n\n this[_members].push(member);\n this[_membersByName] = undefined; // invalidate the lookup\n this[_membersByKind] = undefined; // invalidate the lookup\n this[_membersSorted] = false;\n this[_membersByContainerKey].set(member.containerKey, member);\n\n member[apiItem_onParentChanged](this);\n }\n\n public tryGetMemberByKey(containerKey: string): ApiItem | undefined {\n return this[_membersByContainerKey].get(containerKey);\n }\n\n public findMembersByName(name: string): ReadonlyArray<ApiItem> {\n this._ensureMemberMaps();\n return this[_membersByName]!.get(name) || [];\n }\n\n public findMembersWithInheritance(): IFindApiItemsResult {\n const messages: IFindApiItemsMessage[] = [];\n let maybeIncompleteResult: boolean = false;\n\n // For API items that don't support inheritance, this method just returns the item's\n // immediate members.\n switch (this.kind) {\n case ApiItemKind.Class:\n case ApiItemKind.Interface:\n break;\n default: {\n return {\n items: this.members.concat(),\n messages,\n maybeIncompleteResult\n };\n }\n }\n\n const membersByName: Map<string, ApiItem[]> = new Map();\n const membersByKind: Map<ApiItemKind, ApiItem[]> = new Map();\n\n const toVisit: ApiItem[] = [];\n let next: ApiItem | undefined = this;\n\n while (next) {\n const membersToAdd: ApiItem[] = [];\n\n // For each member, check to see if we've already seen a member with the same name\n // previously in the inheritance tree. If so, we know we won't inherit it, and thus\n // do not add it to our `membersToAdd` array.\n for (const member of next.members) {\n // We add the to-be-added members to an intermediate array instead of immediately\n // to the maps themselves to support method overloads with the same name.\n if (ApiNameMixin.isBaseClassOf(member)) {\n if (!membersByName.has(member.name)) {\n membersToAdd.push(member);\n }\n } else {\n if (!membersByKind.has(member.kind)) {\n membersToAdd.push(member);\n }\n }\n }\n\n for (const member of membersToAdd) {\n if (ApiNameMixin.isBaseClassOf(member)) {\n const members: ApiItem[] = membersByName.get(member.name) || [];\n members.push(member);\n membersByName.set(member.name, members);\n } else {\n const members: ApiItem[] = membersByKind.get(member.kind) || [];\n members.push(member);\n membersByKind.set(member.kind, members);\n }\n }\n\n // Interfaces can extend multiple interfaces, so iterate through all of them.\n const extendedItems: ApiItem[] = [];\n let extendsTypes: readonly HeritageType[] | undefined;\n\n switch (next.kind) {\n case ApiItemKind.Class: {\n const apiClass: ApiClass = next as ApiClass;\n extendsTypes = apiClass.extendsType ? [apiClass.extendsType] : [];\n break;\n }\n case ApiItemKind.Interface: {\n const apiInterface: ApiInterface = next as ApiInterface;\n extendsTypes = apiInterface.extendsTypes;\n break;\n }\n }\n\n if (extendsTypes === undefined) {\n messages.push({\n messageId: FindApiItemsMessageId.UnsupportedKind,\n text: `Unable to analyze references of API item ${next.displayName} because it is of unsupported kind ${next.kind}`\n });\n maybeIncompleteResult = true;\n next = toVisit.shift();\n continue;\n }\n\n for (const extendsType of extendsTypes) {\n // We want to find the reference token associated with the actual inherited declaration.\n // In every case we support, this is the first reference token. For example:\n //\n // ```\n // export class A extends B {}\n // ^\n // export class A extends B<C> {}\n // ^\n // export class A extends B.C {}\n // ^^^\n // ```\n const firstReferenceToken: ExcerptToken | undefined = extendsType.excerpt.spannedTokens.find(\n (token: ExcerptToken) => {\n return token.kind === ExcerptTokenKind.Reference && token.canonicalReference;\n }\n );\n\n if (!firstReferenceToken) {\n messages.push({\n messageId: FindApiItemsMessageId.ExtendsClauseMissingReference,\n text: `Unable to analyze extends clause ${extendsType.excerpt.text} of API item ${next.displayName} because no canonical reference was found`\n });\n maybeIncompleteResult = true;\n continue;\n }\n\n const apiModel: ApiModel | undefined = this.getAssociatedModel();\n if (!apiModel) {\n messages.push({\n messageId: FindApiItemsMessageId.NoAssociatedApiModel,\n text: `Unable to analyze references of API item ${next.displayName} because it is not associated with an ApiModel`\n });\n maybeIncompleteResult = true;\n continue;\n }\n\n const canonicalReference: DeclarationReference = firstReferenceToken.canonicalReference!;\n const apiItemResult: IResolveDeclarationReferenceResult = apiModel.resolveDeclarationReference(\n canonicalReference,\n undefined\n );\n\n const apiItem: ApiItem | undefined = apiItemResult.resolvedApiItem;\n if (!apiItem) {\n messages.push({\n messageId: FindApiItemsMessageId.DeclarationResolutionFailed,\n text: `Unable to resolve declaration reference within API item ${next.displayName}: ${apiItemResult.errorMessage}`\n });\n maybeIncompleteResult = true;\n continue;\n }\n\n extendedItems.push(apiItem);\n }\n\n // For classes, this array will only have one item. For interfaces, there may be multiple items. Sort the array\n // into alphabetical order before adding to our list of API items to visit. This ensures that in the case\n // of multiple interface inheritance, a member inherited from multiple interfaces is attributed to the interface\n // earlier in alphabetical order (as opposed to source order).\n //\n // For example, in the code block below, `Bar.x` is reported as the inherited item, not `Foo.x`.\n //\n // ```\n // interface Foo {\n // public x: string;\n // }\n //\n // interface Bar {\n // public x: string;\n // }\n //\n // interface FooBar extends Foo, Bar {}\n // ```\n extendedItems.sort((x: ApiItem, y: ApiItem) => x.getSortKey().localeCompare(y.getSortKey()));\n\n toVisit.push(...extendedItems);\n next = toVisit.shift();\n }\n\n const items: ApiItem[] = [];\n for (const members of membersByName.values()) {\n items.push(...members);\n }\n for (const members of membersByKind.values()) {\n items.push(...members);\n }\n items.sort((x: ApiItem, y: ApiItem) => x.getSortKey().localeCompare(y.getSortKey()));\n\n return {\n items,\n messages,\n maybeIncompleteResult\n };\n }\n\n /** @internal */\n public _getMergedSiblingsForMember(memberApiItem: ApiItem): ReadonlyArray<ApiItem> {\n this._ensureMemberMaps();\n let result: ApiItem[] | undefined;\n if (ApiNameMixin.isBaseClassOf(memberApiItem)) {\n result = this[_membersByName]!.get(memberApiItem.name);\n } else {\n result = this[_membersByKind]!.get(memberApiItem.kind);\n }\n if (!result) {\n throw new InternalError('Item was not found in the _membersByName/_membersByKind lookup');\n }\n return result;\n }\n\n /** @internal */\n public _ensureMemberMaps(): void {\n // Build the _membersByName and _membersByKind tables if they don't already exist\n if (this[_membersByName] === undefined) {\n const membersByName: Map<string, ApiItem[]> = new Map<string, ApiItem[]>();\n const membersByKind: Map<string, ApiItem[]> = new Map<string, ApiItem[]>();\n\n for (const member of this[_members]) {\n let map: Map<string, ApiItem[]> | Map<ApiItemKind, ApiItem[]>;\n let key: string | ApiItemKind;\n\n if (ApiNameMixin.isBaseClassOf(member)) {\n map = membersByName;\n key = member.name;\n } else {\n map = membersByKind;\n key = member.kind;\n }\n\n let list: ApiItem[] | undefined = map.get(key);\n if (list === undefined) {\n list = [];\n map.set(key, list);\n }\n list.push(member);\n }\n\n this[_membersByName] = membersByName;\n this[_membersByKind] = membersByKind;\n }\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiItemContainerJson>): void {\n super.serializeInto(jsonObject);\n\n const memberObjects: IApiItemJson[] = [];\n\n for (const member of this.members) {\n const memberJsonObject: Partial<IApiItemJson> = {};\n member.serializeInto(memberJsonObject);\n memberObjects.push(memberJsonObject as IApiItemJson);\n }\n\n jsonObject.preserveMemberOrder = this.preserveMemberOrder;\n jsonObject.members = memberObjects;\n }\n }\n\n return MixedClass;\n}\n\n/**\n * Static members for {@link (ApiItemContainerMixin:interface)}.\n * @public\n */\nexport namespace ApiItemContainerMixin {\n /**\n * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiItemContainerMixin` mixin.\n *\n * @remarks\n *\n * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of\n * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however\n * the TypeScript type system cannot invoke a runtime test.)\n */\n export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiItemContainerMixin {\n return apiItem.hasOwnProperty(_members);\n }\n}\n"]}
\ No newline at end of file
import type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';
/**
* Constructor options for {@link (IApiNameMixinOptions:interface)}.
* @public
*/
export interface IApiNameMixinOptions extends IApiItemOptions {
name: string;
}
export interface IApiNameMixinJson extends IApiItemJson {
name: string;
}
/**
* The mixin base class for API items that have a name. For example, a class has a name, but a class constructor
* does not.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
* TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
* features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
* to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
* the function that generates a subclass, an interface that describes the members of the subclass, and
* a namespace containing static members of the class.
*
* @public
*/
export interface ApiNameMixin extends ApiItem {
/**
* The exported name of this API item.
*
* @remarks
* Note that due tue type aliasing, the exported name may be different from the locally declared name.
*/
readonly name: string;
/** @override */
serializeInto(jsonObject: Partial<IApiItemJson>): void;
}
/**
* Mixin function for {@link (ApiNameMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiNameMixin:interface)} functionality.
*
* @public
*/
export declare function ApiNameMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiNameMixin);
/**
* Static members for {@link (ApiNameMixin:interface)}.
* @public
*/
export declare namespace ApiNameMixin {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiNameMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem: ApiItem): apiItem is ApiNameMixin;
}
//# sourceMappingURL=ApiNameMixin.d.ts.map
\ No newline at end of file
{"version":3,"file":"ApiNameMixin.d.ts","sourceRoot":"","sources":["../../src/mixins/ApiNameMixin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGpG;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,IAAI,EAAE,MAAM,CAAC;CACd;AAID;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,YAAa,SAAQ,OAAO;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,gBAAgB;IAChB,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,UAAU,SAAS,mBAAmB,EACjE,SAAS,EAAE,UAAU,GAEpB,UAAU,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,CAAC,CAyCrD;AAED;;;GAGG;AACH,yBAAiB,YAAY,CAAC;IAC5B;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,YAAY,CAEvE;CACF"}
\ No newline at end of file
"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.ApiNameMixin = ApiNameMixin;
const _name = Symbol('ApiNameMixin._name');
/**
* Mixin function for {@link (ApiNameMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiNameMixin:interface)} functionality.
*
* @public
*/
function ApiNameMixin(baseClass
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
class MixedClass extends baseClass {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args) {
super(...args);
const options = args[0];
this[_name] = options.name;
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
baseClass.onDeserializeInto(options, context, jsonObject);
options.name = jsonObject.name;
}
get name() {
return this[_name];
}
/** @override */
get displayName() {
return this[_name];
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
jsonObject.name = this.name;
}
}
return MixedClass;
}
/**
* Static members for {@link (ApiNameMixin:interface)}.
* @public
*/
(function (ApiNameMixin) {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiNameMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem) {
return apiItem.hasOwnProperty(_name);
}
ApiNameMixin.isBaseClassOf = isBaseClassOf;
})(ApiNameMixin || (exports.ApiNameMixin = ApiNameMixin = {}));
//# sourceMappingURL=ApiNameMixin.js.map
\ No newline at end of file
{"version":3,"file":"ApiNameMixin.js","sourceRoot":"","sources":["../../src/mixins/ApiNameMixin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AA2D3D,oCA4CC;AApFD,MAAM,KAAK,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAgC1D;;;;;;;GAOG;AACH,SAAgB,YAAY,CAC1B,SAAqB;AACrB,8DAA8D;;IAE9D,MAAM,UAAW,SAAQ,SAAS;QAGhC,8DAA8D;QAC9D,YAAmB,GAAG,IAAW;YAC/B,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YAEf,MAAM,OAAO,GAAyB,IAAI,CAAC,CAAC,CAAC,CAAC;YAC9C,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;QAC7B,CAAC;QAED,gBAAgB;QACT,MAAM,CAAC,iBAAiB,CAC7B,OAAsC,EACtC,OAA4B,EAC5B,UAA6B;YAE7B,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YAE1D,OAAO,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QACjC,CAAC;QAED,IAAW,IAAI;YACb,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,gBAAgB;QAChB,IAAW,WAAW;YACpB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAED,gBAAgB;QACT,aAAa,CAAC,UAAsC;YACzD,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAEhC,UAAU,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAC9B,CAAC;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,WAAiB,YAAY;IAC3B;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAgB;QAC5C,OAAO,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAFe,0BAAa,gBAE5B,CAAA;AACH,CAAC,EAbgB,YAAY,4BAAZ,YAAY,QAa5B","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 @typescript-eslint/no-redeclare */\n\nimport type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';\nimport type { DeserializerContext } from '../model/DeserializerContext';\n\n/**\n * Constructor options for {@link (IApiNameMixinOptions:interface)}.\n * @public\n */\nexport interface IApiNameMixinOptions extends IApiItemOptions {\n name: string;\n}\n\nexport interface IApiNameMixinJson extends IApiItemJson {\n name: string;\n}\n\nconst _name: unique symbol = Symbol('ApiNameMixin._name');\n\n/**\n * The mixin base class for API items that have a name. For example, a class has a name, but a class constructor\n * does not.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\n * TypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\n * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\n * to extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\n * the function that generates a subclass, an interface that describes the members of the subclass, and\n * a namespace containing static members of the class.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ApiNameMixin extends ApiItem {\n /**\n * The exported name of this API item.\n *\n * @remarks\n * Note that due tue type aliasing, the exported name may be different from the locally declared name.\n */\n readonly name: string;\n\n /** @override */\n serializeInto(jsonObject: Partial<IApiItemJson>): void;\n}\n\n/**\n * Mixin function for {@link (ApiNameMixin:interface)}.\n *\n * @param baseClass - The base class to be extended\n * @returns A child class that extends baseClass, adding the {@link (ApiNameMixin:interface)} functionality.\n *\n * @public\n */\nexport function ApiNameMixin<TBaseClass extends IApiItemConstructor>(\n baseClass: TBaseClass\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): TBaseClass & (new (...args: any[]) => ApiNameMixin) {\n class MixedClass extends baseClass implements ApiNameMixin {\n public readonly [_name]: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(...args: any[]) {\n super(...args);\n\n const options: IApiNameMixinOptions = args[0];\n this[_name] = options.name;\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiNameMixinOptions>,\n context: DeserializerContext,\n jsonObject: IApiNameMixinJson\n ): void {\n baseClass.onDeserializeInto(options, context, jsonObject);\n\n options.name = jsonObject.name;\n }\n\n public get name(): string {\n return this[_name];\n }\n\n /** @override */\n public get displayName(): string {\n return this[_name];\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiNameMixinJson>): void {\n super.serializeInto(jsonObject);\n\n jsonObject.name = this.name;\n }\n }\n\n return MixedClass;\n}\n\n/**\n * Static members for {@link (ApiNameMixin:interface)}.\n * @public\n */\nexport namespace ApiNameMixin {\n /**\n * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiNameMixin` mixin.\n *\n * @remarks\n *\n * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of\n * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however\n * the TypeScript type system cannot invoke a runtime test.)\n */\n export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiNameMixin {\n return apiItem.hasOwnProperty(_name);\n }\n}\n"]}
\ No newline at end of file
import type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';
/**
* Constructor options for {@link (IApiOptionalMixinOptions:interface)}.
* @public
*/
export interface IApiOptionalMixinOptions extends IApiItemOptions {
isOptional: boolean;
}
export interface IApiOptionalMixinJson extends IApiItemJson {
isOptional: boolean;
}
/**
* The mixin base class for API items that can be marked as optional by appending a `?` to them.
* For example, a property of an interface can be optional.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
* TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
* features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
* to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
* the function that generates a subclass, an interface that describes the members of the subclass, and
* a namespace containing static members of the class.
*
* @public
*/
export interface ApiOptionalMixin extends ApiItem {
/**
* True if this is an optional property.
* @remarks
* For example:
* ```ts
* interface X {
* y: string; // not optional
* z?: string; // optional
* }
* ```
*/
readonly isOptional: boolean;
/** @override */
serializeInto(jsonObject: Partial<IApiItemJson>): void;
}
/**
* Mixin function for {@link (ApiOptionalMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiOptionalMixin:interface)} functionality.
*
* @public
*/
export declare function ApiOptionalMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiOptionalMixin);
/**
* Optional members for {@link (ApiOptionalMixin:interface)}.
* @public
*/
export declare namespace ApiOptionalMixin {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiOptionalMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem: ApiItem): apiItem is ApiOptionalMixin;
}
//# sourceMappingURL=ApiOptionalMixin.d.ts.map
\ No newline at end of file
{"version":3,"file":"ApiOptionalMixin.d.ts","sourceRoot":"","sources":["../../src/mixins/ApiOptionalMixin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGpG;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAC/D,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,UAAU,EAAE,OAAO,CAAC;CACrB;AAID;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,gBAAiB,SAAQ,OAAO;IAC/C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,gBAAgB;IAChB,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,SAAS,mBAAmB,EACrE,SAAS,EAAE,UAAU,GAEpB,UAAU,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,gBAAgB,CAAC,CAoCzD;AAED;;;GAGG;AACH,yBAAiB,gBAAgB,CAAC;IAChC;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,gBAAgB,CAE3E;CACF"}
\ No newline at end of file
"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.ApiOptionalMixin = ApiOptionalMixin;
const _isOptional = Symbol('ApiOptionalMixin._isOptional');
/**
* Mixin function for {@link (ApiOptionalMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiOptionalMixin:interface)} functionality.
*
* @public
*/
function ApiOptionalMixin(baseClass
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
class MixedClass extends baseClass {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args) {
super(...args);
const options = args[0];
this[_isOptional] = !!options.isOptional;
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
baseClass.onDeserializeInto(options, context, jsonObject);
options.isOptional = !!jsonObject.isOptional;
}
get isOptional() {
return this[_isOptional];
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
jsonObject.isOptional = this.isOptional;
}
}
return MixedClass;
}
/**
* Optional members for {@link (ApiOptionalMixin:interface)}.
* @public
*/
(function (ApiOptionalMixin) {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiOptionalMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem) {
return apiItem.hasOwnProperty(_isOptional);
}
ApiOptionalMixin.isBaseClassOf = isBaseClassOf;
})(ApiOptionalMixin || (exports.ApiOptionalMixin = ApiOptionalMixin = {}));
//# sourceMappingURL=ApiOptionalMixin.js.map
\ No newline at end of file
{"version":3,"file":"ApiOptionalMixin.js","sourceRoot":"","sources":["../../src/mixins/ApiOptionalMixin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAgE3D,4CAuCC;AApFD,MAAM,WAAW,GAAkB,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAqC1E;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,SAAqB;AACrB,8DAA8D;;IAE9D,MAAM,UAAW,SAAQ,SAAS;QAGhC,8DAA8D;QAC9D,YAAmB,GAAG,IAAW;YAC/B,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YAEf,MAAM,OAAO,GAA6B,IAAI,CAAC,CAAC,CAAC,CAAC;YAClD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QAC3C,CAAC;QAED,gBAAgB;QACT,MAAM,CAAC,iBAAiB,CAC7B,OAA0C,EAC1C,OAA4B,EAC5B,UAAiC;YAEjC,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YAE1D,OAAO,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;QAC/C,CAAC;QAED,IAAW,UAAU;YACnB,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3B,CAAC;QAED,gBAAgB;QACT,aAAa,CAAC,UAA0C;YAC7D,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAEhC,UAAU,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAC1C,CAAC;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,WAAiB,gBAAgB;IAC/B;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAgB;QAC5C,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAFe,8BAAa,gBAE5B,CAAA;AACH,CAAC,EAbgB,gBAAgB,gCAAhB,gBAAgB,QAahC","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 @typescript-eslint/no-redeclare */\n\nimport type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';\nimport type { DeserializerContext } from '../model/DeserializerContext';\n\n/**\n * Constructor options for {@link (IApiOptionalMixinOptions:interface)}.\n * @public\n */\nexport interface IApiOptionalMixinOptions extends IApiItemOptions {\n isOptional: boolean;\n}\n\nexport interface IApiOptionalMixinJson extends IApiItemJson {\n isOptional: boolean;\n}\n\nconst _isOptional: unique symbol = Symbol('ApiOptionalMixin._isOptional');\n\n/**\n * The mixin base class for API items that can be marked as optional by appending a `?` to them.\n * For example, a property of an interface can be optional.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\n * TypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\n * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\n * to extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\n * the function that generates a subclass, an interface that describes the members of the subclass, and\n * a namespace containing static members of the class.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ApiOptionalMixin extends ApiItem {\n /**\n * True if this is an optional property.\n * @remarks\n * For example:\n * ```ts\n * interface X {\n * y: string; // not optional\n * z?: string; // optional\n * }\n * ```\n */\n readonly isOptional: boolean;\n\n /** @override */\n serializeInto(jsonObject: Partial<IApiItemJson>): void;\n}\n\n/**\n * Mixin function for {@link (ApiOptionalMixin:interface)}.\n *\n * @param baseClass - The base class to be extended\n * @returns A child class that extends baseClass, adding the {@link (ApiOptionalMixin:interface)} functionality.\n *\n * @public\n */\nexport function ApiOptionalMixin<TBaseClass extends IApiItemConstructor>(\n baseClass: TBaseClass\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): TBaseClass & (new (...args: any[]) => ApiOptionalMixin) {\n class MixedClass extends baseClass implements ApiOptionalMixin {\n public [_isOptional]: boolean;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(...args: any[]) {\n super(...args);\n\n const options: IApiOptionalMixinOptions = args[0];\n this[_isOptional] = !!options.isOptional;\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiOptionalMixinOptions>,\n context: DeserializerContext,\n jsonObject: IApiOptionalMixinJson\n ): void {\n baseClass.onDeserializeInto(options, context, jsonObject);\n\n options.isOptional = !!jsonObject.isOptional;\n }\n\n public get isOptional(): boolean {\n return this[_isOptional];\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiOptionalMixinJson>): void {\n super.serializeInto(jsonObject);\n\n jsonObject.isOptional = this.isOptional;\n }\n }\n\n return MixedClass;\n}\n\n/**\n * Optional members for {@link (ApiOptionalMixin:interface)}.\n * @public\n */\nexport namespace ApiOptionalMixin {\n /**\n * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiOptionalMixin` mixin.\n *\n * @remarks\n *\n * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of\n * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however\n * the TypeScript type system cannot invoke a runtime test.)\n */\n export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiOptionalMixin {\n return apiItem.hasOwnProperty(_isOptional);\n }\n}\n"]}
\ No newline at end of file
import type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';
import { Parameter } from '../model/Parameter';
import type { IExcerptTokenRange } from './Excerpt';
/**
* Represents parameter information that is part of {@link IApiParameterListMixinOptions}
* @public
*/
export interface IApiParameterOptions {
parameterName: string;
parameterTypeTokenRange: IExcerptTokenRange;
isOptional: boolean;
}
/**
* Constructor options for {@link (ApiParameterListMixin:interface)}.
* @public
*/
export interface IApiParameterListMixinOptions extends IApiItemOptions {
overloadIndex: number;
parameters: IApiParameterOptions[];
}
export interface IApiParameterListJson extends IApiItemJson {
overloadIndex: number;
parameters: IApiParameterOptions[];
}
/**
* The mixin base class for API items that can have function parameters (but not necessarily a return value).
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
* TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
* features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
* to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
* the function that generates a subclass, an interface that describes the members of the subclass, and
* a namespace containing static members of the class.
*
* @public
*/
export interface ApiParameterListMixin extends ApiItem {
/**
* When a function has multiple overloaded declarations, this one-based integer index can be used to uniquely
* identify them.
*
* @remarks
*
* Consider this overloaded declaration:
*
* ```ts
* export namespace Versioning {
* // TSDoc: Versioning.(addVersions:1)
* export function addVersions(x: number, y: number): number;
*
* // TSDoc: Versioning.(addVersions:2)
* export function addVersions(x: string, y: string): string;
*
* // (implementation)
* export function addVersions(x: number|string, y: number|string): number|string {
* // . . .
* }
* }
* ```
*
* In the above example, there are two overloaded declarations. The overload using numbers will have
* `overloadIndex = 1`. The overload using strings will have `overloadIndex = 2`. The third declaration that
* accepts all possible inputs is considered part of the implementation, and is not processed by API Extractor.
*/
readonly overloadIndex: number;
/**
* The function parameters.
*/
readonly parameters: ReadonlyArray<Parameter>;
serializeInto(jsonObject: Partial<IApiItemJson>): void;
}
/**
* Mixin function for {@link (ApiParameterListMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiParameterListMixin:interface)} functionality.
*
* @public
*/
export declare function ApiParameterListMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiParameterListMixin);
/**
* Static members for {@link (ApiParameterListMixin:interface)}.
* @public
*/
export declare namespace ApiParameterListMixin {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiParameterListMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem: ApiItem): apiItem is ApiParameterListMixin;
}
//# sourceMappingURL=ApiParameterListMixin.d.ts.map
\ No newline at end of file
{"version":3,"file":"ApiParameterListMixin.d.ts","sourceRoot":"","sources":["../../src/mixins/ApiParameterListMixin.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,EAAE,kBAAkB,CAAC;IAC5C,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,6BAA8B,SAAQ,eAAe;IACpE,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACpC;AAKD;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,qBAAsB,SAAQ,OAAO;IACpD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IAE9C,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,SAAS,mBAAmB,EAC1E,SAAS,EAAE,UAAU,GAEpB,UAAU,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,qBAAqB,CAAC,CAyE9D;AAED;;;GAGG;AACH,yBAAiB,qBAAqB,CAAC;IACrC;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,qBAAqB,CAEhF;CACF"}
\ No newline at end of file
"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.ApiParameterListMixin = ApiParameterListMixin;
/* eslint-disable @typescript-eslint/no-redeclare */
const node_core_library_1 = require("@rushstack/node-core-library");
const Parameter_1 = require("../model/Parameter");
const ApiDeclaredItem_1 = require("../items/ApiDeclaredItem");
const _overloadIndex = Symbol('ApiParameterListMixin._overloadIndex');
const _parameters = Symbol('ApiParameterListMixin._parameters');
/**
* Mixin function for {@link (ApiParameterListMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiParameterListMixin:interface)} functionality.
*
* @public
*/
function ApiParameterListMixin(baseClass
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
class MixedClass extends baseClass {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args) {
super(...args);
const options = args[0];
this[_overloadIndex] = options.overloadIndex;
this[_parameters] = [];
if (this instanceof ApiDeclaredItem_1.ApiDeclaredItem) {
if (options.parameters) {
for (const parameterOptions of options.parameters) {
const parameter = new Parameter_1.Parameter({
name: parameterOptions.parameterName,
parameterTypeExcerpt: this.buildExcerpt(parameterOptions.parameterTypeTokenRange),
// Prior to ApiJsonSchemaVersion.V_1005 this input will be undefined
isOptional: !!parameterOptions.isOptional,
parent: this
});
this[_parameters].push(parameter);
}
}
}
else {
throw new node_core_library_1.InternalError('ApiReturnTypeMixin expects a base class that inherits from ApiDeclaredItem');
}
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
baseClass.onDeserializeInto(options, context, jsonObject);
options.overloadIndex = jsonObject.overloadIndex;
options.parameters = jsonObject.parameters || [];
}
get overloadIndex() {
return this[_overloadIndex];
}
get parameters() {
return this[_parameters];
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
jsonObject.overloadIndex = this.overloadIndex;
const parameterObjects = [];
for (const parameter of this.parameters) {
parameterObjects.push({
parameterName: parameter.name,
parameterTypeTokenRange: parameter.parameterTypeExcerpt.tokenRange,
isOptional: parameter.isOptional
});
}
jsonObject.parameters = parameterObjects;
}
}
return MixedClass;
}
/**
* Static members for {@link (ApiParameterListMixin:interface)}.
* @public
*/
(function (ApiParameterListMixin) {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiParameterListMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem) {
return apiItem.hasOwnProperty(_parameters);
}
ApiParameterListMixin.isBaseClassOf = isBaseClassOf;
})(ApiParameterListMixin || (exports.ApiParameterListMixin = ApiParameterListMixin = {}));
//# sourceMappingURL=ApiParameterListMixin.js.map
\ No newline at end of file
{"version":3,"file":"ApiParameterListMixin.js","sourceRoot":"","sources":["../../src/mixins/ApiParameterListMixin.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAqG3D,sDA4EC;AA/KD,oDAAoD;AAEpD,oEAA6D;AAG7D,kDAA+C;AAC/C,8DAA2D;AA4B3D,MAAM,cAAc,GAAkB,MAAM,CAAC,sCAAsC,CAAC,CAAC;AACrF,MAAM,WAAW,GAAkB,MAAM,CAAC,mCAAmC,CAAC,CAAC;AAwD/E;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,SAAqB;AACrB,8DAA8D;;IAE9D,MAAM,UAAW,SAAQ,SAAS;QAIhC,8DAA8D;QAC9D,YAAmB,GAAG,IAAW;YAC/B,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;YAEf,MAAM,OAAO,GAAkC,IAAI,CAAC,CAAC,CAAC,CAAC;YACvD,IAAI,CAAC,cAAc,C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CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;YAE9C,MAAM,gBAAgB,GAA2B,EAAE,CAAC;YACpD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACxC,gBAAgB,CAAC,IAAI,CAAC;oBACpB,aAAa,EAAE,SAAS,CAAC,IAAI;oBAC7B,uBAAuB,EAAE,SAAS,CAAC,oBAAoB,CAAC,UAAU;oBAClE,UAAU,EAAE,SAAS,CAAC,UAAU;iBACjC,CAAC,CAAC;YACL,CAAC;YAED,UAAU,CAAC,UAAU,GAAG,gBAAgB,CAAC;QAC3C,CAAC;KACF;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;GAGG;AACH,WAAiB,qBAAqB;IACpC;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAgB;QAC5C,OAAO,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAFe,mCAAa,gBAE5B,CAAA;AACH,CAAC,EAbgB,qBAAqB,qCAArB,qBAAqB,QAarC","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 @typescript-eslint/no-redeclare */\n\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';\nimport { Parameter } from '../model/Parameter';\nimport { ApiDeclaredItem } from '../items/ApiDeclaredItem';\nimport type { IExcerptTokenRange } from './Excerpt';\nimport type { DeserializerContext } from '../model/DeserializerContext';\n\n/**\n * Represents parameter information that is part of {@link IApiParameterListMixinOptions}\n * @public\n */\nexport interface IApiParameterOptions {\n parameterName: string;\n parameterTypeTokenRange: IExcerptTokenRange;\n isOptional: boolean;\n}\n\n/**\n * Constructor options for {@link (ApiParameterListMixin:interface)}.\n * @public\n */\nexport interface IApiParameterListMixinOptions extends IApiItemOptions {\n overloadIndex: number;\n parameters: IApiParameterOptions[];\n}\n\nexport interface IApiParameterListJson extends IApiItemJson {\n overloadIndex: number;\n parameters: IApiParameterOptions[];\n}\n\nconst _overloadIndex: unique symbol = Symbol('ApiParameterListMixin._overloadIndex');\nconst _parameters: unique symbol = Symbol('ApiParameterListMixin._parameters');\n\n/**\n * The mixin base class for API items that can have function parameters (but not necessarily a return value).\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\n * TypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\n * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\n * to extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\n * the function that generates a subclass, an interface that describes the members of the subclass, and\n * a namespace containing static members of the class.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ApiParameterListMixin extends ApiItem {\n /**\n * When a function has multiple overloaded declarations, this one-based integer index can be used to uniquely\n * identify them.\n *\n * @remarks\n *\n * Consider this overloaded declaration:\n *\n * ```ts\n * export namespace Versioning {\n * // TSDoc: Versioning.(addVersions:1)\n * export function addVersions(x: number, y: number): number;\n *\n * // TSDoc: Versioning.(addVersions:2)\n * export function addVersions(x: string, y: string): string;\n *\n * // (implementation)\n * export function addVersions(x: number|string, y: number|string): number|string {\n * // . . .\n * }\n * }\n * ```\n *\n * In the above example, there are two overloaded declarations. The overload using numbers will have\n * `overloadIndex = 1`. The overload using strings will have `overloadIndex = 2`. The third declaration that\n * accepts all possible inputs is considered part of the implementation, and is not processed by API Extractor.\n */\n readonly overloadIndex: number;\n\n /**\n * The function parameters.\n */\n readonly parameters: ReadonlyArray<Parameter>;\n\n serializeInto(jsonObject: Partial<IApiItemJson>): void;\n}\n\n/**\n * Mixin function for {@link (ApiParameterListMixin:interface)}.\n *\n * @param baseClass - The base class to be extended\n * @returns A child class that extends baseClass, adding the {@link (ApiParameterListMixin:interface)} functionality.\n *\n * @public\n */\nexport function ApiParameterListMixin<TBaseClass extends IApiItemConstructor>(\n baseClass: TBaseClass\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): TBaseClass & (new (...args: any[]) => ApiParameterListMixin) {\n class MixedClass extends baseClass implements ApiParameterListMixin {\n public readonly [_overloadIndex]: number;\n public readonly [_parameters]: Parameter[];\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(...args: any[]) {\n super(...args);\n\n const options: IApiParameterListMixinOptions = args[0];\n this[_overloadIndex] = options.overloadIndex;\n\n this[_parameters] = [];\n\n if (this instanceof ApiDeclaredItem) {\n if (options.parameters) {\n for (const parameterOptions of options.parameters) {\n const parameter: Parameter = new Parameter({\n name: parameterOptions.parameterName,\n parameterTypeExcerpt: this.buildExcerpt(parameterOptions.parameterTypeTokenRange),\n // Prior to ApiJsonSchemaVersion.V_1005 this input will be undefined\n isOptional: !!parameterOptions.isOptional,\n parent: this\n });\n\n this[_parameters].push(parameter);\n }\n }\n } else {\n throw new InternalError('ApiReturnTypeMixin expects a base class that inherits from ApiDeclaredItem');\n }\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiParameterListMixinOptions>,\n context: DeserializerContext,\n jsonObject: IApiParameterListJson\n ): void {\n baseClass.onDeserializeInto(options, context, jsonObject);\n\n options.overloadIndex = jsonObject.overloadIndex;\n options.parameters = jsonObject.parameters || [];\n }\n\n public get overloadIndex(): number {\n return this[_overloadIndex];\n }\n\n public get parameters(): ReadonlyArray<Parameter> {\n return this[_parameters];\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiParameterListJson>): void {\n super.serializeInto(jsonObject);\n\n jsonObject.overloadIndex = this.overloadIndex;\n\n const parameterObjects: IApiParameterOptions[] = [];\n for (const parameter of this.parameters) {\n parameterObjects.push({\n parameterName: parameter.name,\n parameterTypeTokenRange: parameter.parameterTypeExcerpt.tokenRange,\n isOptional: parameter.isOptional\n });\n }\n\n jsonObject.parameters = parameterObjects;\n }\n }\n\n return MixedClass;\n}\n\n/**\n * Static members for {@link (ApiParameterListMixin:interface)}.\n * @public\n */\nexport namespace ApiParameterListMixin {\n /**\n * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiParameterListMixin` mixin.\n *\n * @remarks\n *\n * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of\n * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however\n * the TypeScript type system cannot invoke a runtime test.)\n */\n export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiParameterListMixin {\n return apiItem.hasOwnProperty(_parameters);\n }\n}\n"]}
\ No newline at end of file
import type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';
/**
* Constructor options for {@link (IApiProtectedMixinOptions:interface)}.
* @public
*/
export interface IApiProtectedMixinOptions extends IApiItemOptions {
isProtected: boolean;
}
export interface IApiProtectedMixinJson extends IApiItemJson {
isProtected: boolean;
}
/**
* The mixin base class for API items that can have the TypeScript `protected` keyword applied to them.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
* TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
* features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
* to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
* the function that generates a subclass, an interface that describes the members of the subclass, and
* a namespace containing static members of the class.
*
* @public
*/
export interface ApiProtectedMixin extends ApiItem {
/**
* Whether the declaration has the TypeScript `protected` keyword.
*/
readonly isProtected: boolean;
/** @override */
serializeInto(jsonObject: Partial<IApiItemJson>): void;
}
/**
* Mixin function for {@link (ApiProtectedMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiProtectedMixin:interface)} functionality.
*
* @public
*/
export declare function ApiProtectedMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiProtectedMixin);
/**
* Static members for {@link (ApiProtectedMixin:interface)}.
* @public
*/
export declare namespace ApiProtectedMixin {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiProtectedMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem: ApiItem): apiItem is ApiProtectedMixin;
}
//# sourceMappingURL=ApiProtectedMixin.d.ts.map
\ No newline at end of file
{"version":3,"file":"ApiProtectedMixin.d.ts","sourceRoot":"","sources":["../../src/mixins/ApiProtectedMixin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGpG;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,eAAe;IAChE,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IAC1D,WAAW,EAAE,OAAO,CAAC;CACtB;AAID;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAChD;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAE9B,gBAAgB;IAChB,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,SAAS,mBAAmB,EACtE,SAAS,EAAE,UAAU,GAEpB,UAAU,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,iBAAiB,CAAC,CAoC1D;AAED;;;GAGG;AACH,yBAAiB,iBAAiB,CAAC;IACjC;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,iBAAiB,CAE5E;CACF"}
\ No newline at end of file
"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.ApiProtectedMixin = ApiProtectedMixin;
const _isProtected = Symbol('ApiProtectedMixin._isProtected');
/**
* Mixin function for {@link (ApiProtectedMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiProtectedMixin:interface)} functionality.
*
* @public
*/
function ApiProtectedMixin(baseClass
// eslint-disable-next-line @typescript-eslint/no-explicit-any
) {
class MixedClass extends baseClass {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(...args) {
super(...args);
const options = args[0];
this[_isProtected] = options.isProtected;
}
/** @override */
static onDeserializeInto(options, context, jsonObject) {
baseClass.onDeserializeInto(options, context, jsonObject);
options.isProtected = jsonObject.isProtected;
}
get isProtected() {
return this[_isProtected];
}
/** @override */
serializeInto(jsonObject) {
super.serializeInto(jsonObject);
jsonObject.isProtected = this.isProtected;
}
}
return MixedClass;
}
/**
* Static members for {@link (ApiProtectedMixin:interface)}.
* @public
*/
(function (ApiProtectedMixin) {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiProtectedMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem) {
return apiItem.hasOwnProperty(_isProtected);
}
ApiProtectedMixin.isBaseClassOf = isBaseClassOf;
})(ApiProtectedMixin || (exports.ApiProtectedMixin = ApiProtectedMixin = {}));
//# sourceMappingURL=ApiProtectedMixin.js.map
\ No newline at end of file
{"version":3,"file":"ApiProtectedMixin.js","sourceRoot":"","sources":["../../src/mix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T license.\n// See LICENSE in the project root for license information.\n\n/* eslint-disable @typescript-eslint/no-redeclare */\n\nimport type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';\nimport type { DeserializerContext } from '../model/DeserializerContext';\n\n/**\n * Constructor options for {@link (IApiProtectedMixinOptions:interface)}.\n * @public\n */\nexport interface IApiProtectedMixinOptions extends IApiItemOptions {\n isProtected: boolean;\n}\n\nexport interface IApiProtectedMixinJson extends IApiItemJson {\n isProtected: boolean;\n}\n\nconst _isProtected: unique symbol = Symbol('ApiProtectedMixin._isProtected');\n\n/**\n * The mixin base class for API items that can have the TypeScript `protected` keyword applied to them.\n *\n * @remarks\n *\n * This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of\n * API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use\n * TypeScript \"mixin\" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various\n * features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class\n * to extend more than one base class). The \"mixin\" is a TypeScript merged declaration with three components:\n * the function that generates a subclass, an interface that describes the members of the subclass, and\n * a namespace containing static members of the class.\n *\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface ApiProtectedMixin extends ApiItem {\n /**\n * Whether the declaration has the TypeScript `protected` keyword.\n */\n readonly isProtected: boolean;\n\n /** @override */\n serializeInto(jsonObject: Partial<IApiItemJson>): void;\n}\n\n/**\n * Mixin function for {@link (ApiProtectedMixin:interface)}.\n *\n * @param baseClass - The base class to be extended\n * @returns A child class that extends baseClass, adding the {@link (ApiProtectedMixin:interface)} functionality.\n *\n * @public\n */\nexport function ApiProtectedMixin<TBaseClass extends IApiItemConstructor>(\n baseClass: TBaseClass\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): TBaseClass & (new (...args: any[]) => ApiProtectedMixin) {\n class MixedClass extends baseClass implements ApiProtectedMixin {\n public [_isProtected]: boolean;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n public constructor(...args: any[]) {\n super(...args);\n\n const options: IApiProtectedMixinOptions = args[0];\n this[_isProtected] = options.isProtected;\n }\n\n /** @override */\n public static onDeserializeInto(\n options: Partial<IApiProtectedMixinOptions>,\n context: DeserializerContext,\n jsonObject: IApiProtectedMixinJson\n ): void {\n baseClass.onDeserializeInto(options, context, jsonObject);\n\n options.isProtected = jsonObject.isProtected;\n }\n\n public get isProtected(): boolean {\n return this[_isProtected];\n }\n\n /** @override */\n public serializeInto(jsonObject: Partial<IApiProtectedMixinJson>): void {\n super.serializeInto(jsonObject);\n\n jsonObject.isProtected = this.isProtected;\n }\n }\n\n return MixedClass;\n}\n\n/**\n * Static members for {@link (ApiProtectedMixin:interface)}.\n * @public\n */\nexport namespace ApiProtectedMixin {\n /**\n * A type guard that tests whether the specified `ApiItem` subclass extends the `ApiProtectedMixin` mixin.\n *\n * @remarks\n *\n * The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of\n * the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however\n * the TypeScript type system cannot invoke a runtime test.)\n */\n export function isBaseClassOf(apiItem: ApiItem): apiItem is ApiProtectedMixin {\n return apiItem.hasOwnProperty(_isProtected);\n }\n}\n"]}
\ No newline at end of file
import type { ApiItem, IApiItemJson, IApiItemConstructor, IApiItemOptions } from '../items/ApiItem';
/**
* Constructor options for {@link (ApiReadonlyMixin:interface)}.
* @public
*/
export interface IApiReadonlyMixinOptions extends IApiItemOptions {
isReadonly: boolean;
}
export interface IApiReadonlyMixinJson extends IApiItemJson {
isReadonly: boolean;
}
/**
* The mixin base class for API items that cannot be modified after instantiation.
* Examples such as the readonly modifier and only having a getter but no setter.
*
* @remarks
*
* This is part of the {@link ApiModel} hierarchy of classes, which are serializable representations of
* API declarations. The non-abstract classes (e.g. `ApiClass`, `ApiEnum`, `ApiInterface`, etc.) use
* TypeScript "mixin" functions (e.g. `ApiDeclaredItem`, `ApiItemContainerMixin`, etc.) to add various
* features that cannot be represented as a normal inheritance chain (since TypeScript does not allow a child class
* to extend more than one base class). The "mixin" is a TypeScript merged declaration with three components:
* the function that generates a subclass, an interface that describes the members of the subclass, and
* a namespace containing static members of the class.
*
* @public
*/
export interface ApiReadonlyMixin extends ApiItem {
/**
* Indicates that the API item's value cannot be assigned by an external consumer.
*
* @remarks
* Examples of API items that would be considered "read only" by API Extractor:
*
* - A class or interface's property that has the `readonly` modifier.
*
* - A variable that has the `const` modifier.
*
* - A property or variable whose TSDoc comment includes the `@readonly` tag.
*
* - A property declaration with a getter but no setter.
*
* Note that if the `readonly` keyword appears in a type annotation, this does not
* guarantee that that the API item will be considered readonly. For example:
*
* ```ts
* declare class C {
* // isReadonly=false in this case, because C.x is assignable
* public x: readonly string[];
* }
* ```
*/
readonly isReadonly: boolean;
serializeInto(jsonObject: Partial<IApiItemJson>): void;
}
/**
* Mixin function for {@link (ApiReadonlyMixin:interface)}.
*
* @param baseClass - The base class to be extended
* @returns A child class that extends baseClass, adding the {@link (ApiReadonlyMixin:interface)}
* functionality.
*
* @public
*/
export declare function ApiReadonlyMixin<TBaseClass extends IApiItemConstructor>(baseClass: TBaseClass): TBaseClass & (new (...args: any[]) => ApiReadonlyMixin);
/**
* Static members for {@link (ApiReadonlyMixin:interface)}.
* @public
*/
export declare namespace ApiReadonlyMixin {
/**
* A type guard that tests whether the specified `ApiItem` subclass extends the `ApiReadonlyMixin` mixin.
*
* @remarks
*
* The JavaScript `instanceof` operator cannot be used to test for mixin inheritance, because each invocation of
* the mixin function produces a different subclass. (This could be mitigated by `Symbol.hasInstance`, however
* the TypeScript type system cannot invoke a runtime test.)
*/
function isBaseClassOf(apiItem: ApiItem): apiItem is ApiReadonlyMixin;
}
//# sourceMappingURL=ApiReadonlyMixin.d.ts.map
\ No newline at end of file
{"version":3,"file":"ApiReadonlyMixin.d.ts","sourceRoot":"","sources":["../../src/mixins/ApiReadonlyMixin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGpG;;;GAGG;AACH,MAAM,WAAW,wBAAyB,SAAQ,eAAe;IAC/D,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,UAAU,EAAE,OAAO,CAAC;CACrB;AAID;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,gBAAiB,SAAQ,OAAO;IAC/C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,aAAa,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,SAAS,mBAAmB,EACrE,SAAS,EAAE,UAAU,GAEpB,UAAU,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,gBAAgB,CAAC,CAoCzD;AAED;;;GAGG;AACH,yBAAiB,gBAAgB,CAAC;IAChC;;;;;;;;OAQG;IACH,SAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,gBAAgB,CAE3E;CACF"}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment