@arcgis/api-extractor 5.0.0-next.58 → 5.0.0-next.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { ApiClassDeclaration, ApiClassField, ApiClassMethod, ApiCustomElementDeclaration, ApiFunctionDeclaration, ApiModule, ApiVariableDeclaration } from '../apiJson';
1
+ import { ApiClassCallSignature, ApiClassConstructor, ApiClassDeclaration, ApiClassField, ApiClassMethod, ApiCustomElementDeclaration, ApiFunctionDeclaration, ApiInterfaceDeclaration, ApiMixinDeclaration, ApiModule, ApiVariableDeclaration } from '../apiJson';
2
2
  export interface ApiDiff {
3
3
  modules: ApiModuleDiff[];
4
4
  }
@@ -31,7 +31,7 @@ export interface ApiDiffBase {
31
31
  */
32
32
  deprecated?: boolean | string;
33
33
  }
34
- export type ApiDeclarationDiff = ApiClassDeclarationDiff | ApiCustomElementDeclarationDiff | ApiFunctionDeclarationDiff | ApiVariableDeclarationDiff;
34
+ export type ApiDeclarationDiff = ApiClassDeclarationDiff | ApiCustomElementDeclarationDiff | ApiFunctionDeclarationDiff | ApiInterfaceDeclarationDiff | ApiMixinDeclarationDiff | ApiVariableDeclarationDiff;
35
35
  export interface ApiClassDeclarationDiff extends ApiDiffBase {
36
36
  kind: ApiClassDeclaration["kind"];
37
37
  /**
@@ -41,6 +41,17 @@ export interface ApiClassDeclarationDiff extends ApiDiffBase {
41
41
  members?: ApiClassMemberDiff[];
42
42
  events?: ApiDiffBase[];
43
43
  }
44
+ export interface ApiInterfaceDeclarationDiff extends ApiDiffBase {
45
+ kind: ApiInterfaceDeclaration["kind"];
46
+ /**
47
+ * Inherited members are not included in the diff.
48
+ * Also, if entire class is added/removed, members are not included in the diff.
49
+ */
50
+ members?: ApiClassMemberDiff[];
51
+ }
52
+ export interface ApiMixinDeclarationDiff extends Omit<ApiClassDeclarationDiff, "kind"> {
53
+ kind: ApiMixinDeclaration["kind"];
54
+ }
44
55
  export interface ApiCustomElementDeclarationDiff extends ApiClassDeclarationDiff {
45
56
  /**
46
57
  * Attributes diff is not included as attributes are based on members.
@@ -51,13 +62,19 @@ export interface ApiCustomElementDeclarationDiff extends ApiClassDeclarationDiff
51
62
  cssProperties?: ApiDiffBase[];
52
63
  cssStates?: ApiDiffBase[];
53
64
  }
54
- export type ApiClassMemberDiff = ApiClassFieldDiff | ApiClassMethodDiff;
65
+ export type ApiClassMemberDiff = ApiClassCallSignatureDiff | ApiClassConstructorDiff | ApiClassFieldDiff | ApiClassMethodDiff;
55
66
  export interface ApiClassFieldDiff extends ApiDiffBase {
56
67
  kind: ApiClassField["kind"];
57
68
  }
58
69
  export interface ApiClassMethodDiff extends ApiDiffBase {
59
70
  kind: ApiClassMethod["kind"];
60
71
  }
72
+ export interface ApiClassConstructorDiff extends Omit<ApiDiffBase, "name"> {
73
+ kind: ApiClassConstructor["kind"];
74
+ }
75
+ export interface ApiClassCallSignatureDiff extends Omit<ApiDiffBase, "name"> {
76
+ kind: ApiClassCallSignature["kind"];
77
+ }
61
78
  export interface ApiFunctionDeclarationDiff extends ApiDiffBase {
62
79
  kind: ApiFunctionDeclaration["kind"];
63
80
  }
@@ -0,0 +1,137 @@
1
+ import { ApiClassMethod, ApiClassDeclaration, ApiCustomElementField, ApiDeclaration, ApiEvent, ApiJson, ApiModule, ApiCustomElementDeclaration, ApiFunctionDeclaration, ApiVariableDeclaration, ApiInterfaceDeclaration, ApiObjectLikeDeclaration, ApiCustomElementMember, ApiReference, ApiClassMember, ApiAttribute, ApiSlot, ApiCssPart, ApiCssCustomProperty, ApiCssCustomState, ApiMixinDeclaration, ApiClassField } from '../apiJson';
2
+ import { default as ts } from 'typescript';
3
+ import { CopyDocDefinitions } from '../types';
4
+ export type ApiExtractorOptions = {
5
+ sortModules: boolean;
6
+ /** The path relative to which module.path will be resolved */
7
+ cwd: string;
8
+ environment: "development" | "production";
9
+ };
10
+ /**
11
+ * This is a base abstract class. It should be subclassed to implement the
12
+ * specific extraction logic.
13
+ */
14
+ export declare abstract class ApiExtractor {
15
+ options: ApiExtractorOptions;
16
+ constructor(options: ApiExtractorOptions);
17
+ /** File that is currently being extracted */
18
+ file: ts.SourceFile;
19
+ /** The module that is currently being produced */
20
+ apiModule: ApiModule;
21
+ /** Given an array of TypeScript source files, generate an api.json file */
22
+ extract(files: readonly ts.SourceFile[]): ApiJson;
23
+ /**
24
+ * Hostname of the documentation site for the current environment.
25
+ */
26
+ normalizedDocumentationHost: string;
27
+ /**
28
+ * Hostname of the documentation site that is not for the current environment.
29
+ * These references will be replaced by the extractor to point to the
30
+ * normalizedDocumentationHost instead.
31
+ *
32
+ * Use case:
33
+ * - In source code, link to internal docs only. This gives more up to date
34
+ * docs and avoids 404 errors for pages that are not yet part of public
35
+ * release.
36
+ * - In production builds, the URLs are replaced with the public docs hostname.
37
+ */
38
+ alternativeDocumentationHost: string;
39
+ extractModules(files: readonly ts.SourceFile[]): ApiModule[];
40
+ /**
41
+ * @param module
42
+ * @param sourcePath cwd-relative path to the source file (esri/core/Accessor.ts)
43
+ * @param importPath public import path of the module without package name or file extension (core/Accessor)
44
+ */
45
+ extractModule(module: ts.SourceFile, sourcePath?: string, importPath?: string): ApiModule;
46
+ /**
47
+ * For a given module, extract all public declarations.
48
+ */
49
+ protected extractDeclarations(module: ts.SourceFile): void;
50
+ /**
51
+ * For each statement in a module, extract a declaration if it is a public API
52
+ */
53
+ protected abstract extractDeclaration(statement: ts.Statement, index: number): ApiDeclaration | undefined;
54
+ /**
55
+ * Add ApiModule.exports entry based on ApiDeclaration
56
+ *
57
+ * To reduce the size of the api.json, we only add exports entries for web
58
+ * components or default exports.
59
+ */
60
+ addExport(declaration: ApiDeclaration, isDefault: boolean): void;
61
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["properties"], apiProperty: ApiCustomElementField, apiComponent: ApiObjectLikeDeclaration, apiModule: ApiModule): void;
62
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["methods"], method: ApiClassMethod, component: ApiObjectLikeDeclaration, apiModule: ApiModule): void;
63
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["events"], event: ApiEvent, component: ApiObjectLikeDeclaration, apiModule: ApiModule): void;
64
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["functions"], apiFunction: ApiFunctionDeclaration, apiModule: ApiModule): void;
65
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["variables"], variable: ApiVariableDeclaration, apiModule: ApiModule): void;
66
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["classes"], classDeclaration: ApiClassDeclaration, apiModule: ApiModule): void;
67
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["customElements"], componentDeclaration: ApiCustomElementDeclaration, apiModule: ApiModule): void;
68
+ copyDoc(errorReportingNode: ts.Node, copyDocDefinitions: CopyDocDefinitions["interfaces"], interfaceDeclaration: ApiInterfaceDeclaration, apiModule: ApiModule): void;
69
+ /**
70
+ * Inherit public members from mixins and superclass.
71
+ *
72
+ * In cast of Lumina, for this to work, the superclass needs to be in a file
73
+ * named like a component (src/components/name/name.tsx), even if it is not a
74
+ * standalone component. See
75
+ * https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/3212
76
+ */
77
+ inheritMembers(moduleName: string, component: ApiClassDeclaration | ApiMixinDeclaration, modules: ApiModule[]): void;
78
+ /**
79
+ * Inherit members from a superclass or mixin.
80
+ */
81
+ protected inheritMembersFrom(parent: ApiExtractorInheritanceData, destination: ApiClassDeclaration | ApiMixinDeclaration, destinationModuleName: string): void;
82
+ protected inheritMembersOfKind<T extends ApiAttribute | ApiCssCustomProperty | ApiCssCustomState | ApiCssPart | ApiEvent | ApiSlot>(members: T[] | undefined, parentMembers: T[], parentIndexedMembers: Record<string, T>, inheritedFrom?: ApiReference): T[];
83
+ resolvedInheritance: Record<string,
84
+ /**
85
+ * `false` means don't inherit (or resolution failed).
86
+ *
87
+ * `undefined` means we already inherited the members, but have not yet
88
+ * computed the inheritance data for this module (almost every class
89
+ * inherits some class, but only a few are inherited by other classes, so
90
+ * we compute inheritance data lazily).
91
+ */
92
+ ApiExtractorInheritanceData | false | undefined>;
93
+ noInheritMembers: Record<string, string[] | undefined>;
94
+ /**
95
+ * Based on the superclass name, find the actual declaration in the modules.
96
+ */
97
+ protected resolveInheritance(superClassModule: string, modules: ApiModule[]): ApiExtractorInheritanceData | false;
98
+ /**
99
+ * Overwrite point
100
+ *
101
+ * FINAL: jsapi-extractor has a more efficient implementation because it
102
+ * has to deal with inheritance a lot. Unify it with Lumina.
103
+ */
104
+ protected findSuperclassDeclaration(moduleName: string, modules: ApiModule[]): readonly [string, ApiClassDeclaration | ApiMixinDeclaration] | false;
105
+ protected handleEventTypesProperty(_apiMember: ApiClassMember, _apiComponent: ApiClassDeclaration | ApiMixinDeclaration, _moduleName: string): void;
106
+ /**
107
+ * This method should check if the super property is an accessor, then the
108
+ * override property should be promoted to an accessor too.
109
+ * This is necessary until we migrate to standard decorators since - after
110
+ * that internal accessor status will match the status in the public typings.
111
+ */
112
+ protected maybePromotePropertyToAutoAccessor(_apiProperty: ApiClassField, _superApiProperty: ApiClassField): void;
113
+ }
114
+ type ApiExtractorInheritanceData = {
115
+ inheritanceData: ApiReference;
116
+ declaration: ApiClassDeclaration | ApiMixinDeclaration;
117
+ /**
118
+ * Used for validation only. If class has any settable fields, and class is
119
+ * extended by another one, require that the class module exports the
120
+ * `<className>Properties` interface. It will be extended by the superclass'
121
+ * properties interface.
122
+ */
123
+ hasSettableField: boolean;
124
+ /**
125
+ * Indexed by name for quick lookup of "overridden" status.
126
+ * Using a map because we do .get() during constructor of the Map, and because
127
+ * there are often 10+ items with random access.
128
+ */
129
+ indexedMembers: Map<string, ApiClassMember | ApiCustomElementMember | undefined> | undefined;
130
+ indexedEvents: Record<string, ApiEvent> | undefined;
131
+ indexedAttributes: Record<string, ApiAttribute> | undefined;
132
+ indexedSlots: Record<string, ApiSlot> | undefined;
133
+ indexedCssParts: Record<string, ApiCssPart> | undefined;
134
+ indexedCssProperties: Record<string, ApiCssCustomProperty> | undefined;
135
+ indexedCssStates: Record<string, ApiCssCustomState> | undefined;
136
+ };
137
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,8 +1,12 @@
1
- export { ApiExtractor, type ApiExtractorOptions } from './extractor';
2
1
  export type * from './apiJson';
3
- export { hasIgnoredModifier, setDefaultFromInitializer, getMemberName, findDecorator } from './utils/astHelpers';
4
- export { isApiMethod, isApiProperty, globalPackageIdentifier, multipleJsDocTags } from './utils/apiHelpers';
5
- export { apiExtractorError, apiExtractorErrorCount, apiExtractorErrorFiles, setApiExtractorErrorLogger, type ApiExtractorErrorContext, } from './utils/error';
6
- export { debugPrintNode, printNode } from './utils/print';
7
- export type { CopyDocDefinitions } from './types';
8
- export { symbolToDocs, apiMemberToSynthesizedComments, setApiDocFromJsDoc } from './utils/docHelpers';
2
+ export { ApiExtractor, type ApiExtractorOptions } from './extractor/ApiExtractor';
3
+ export { unsafeGetUndocumentedPrinter, unsafeUndocumentedTs } from './internalTypeScriptApis';
4
+ export type { CopyDocDefinitions, NodeDoc } from './types';
5
+ export { findReferenceRanges, getApiMemberName, getMaybeStaticApiMemberName, getApiNodeLabel, globalPackageIdentifier, isApiMethod, isApiProperty, multipleJsDocTags, naturalSortModules, postProcessLinks, apiExtractorJsDocError, compareClassMembers, compareNamedNodes, compareStrings, } from './utils/apiHelpers';
6
+ export { extractBooleanInitializer, findDecorator, getMemberName, hasIgnoredModifier, setDefaultFromInitializer, getBasename, } from './utils/astHelpers';
7
+ export { alternativeDocumentationHost, normalizedDocumentationHost } from './utils/jsDocHelpers';
8
+ export { apiMemberToNodeDoc, nodeDocToString, nodeDocToSynthesizedComment } from './utils/jsDocPrinter';
9
+ export { setApiDocFromJsDoc, setApiDocFromSymbol, symbolToDocs, getNodeDoc } from './utils/jsDocParser';
10
+ export { typeScriptGlobals, typeScriptGlobalsViewUrlCommonPrefix } from './config/typeReferences/globals';
11
+ export { printClass, printInterface, printMethod, printFunction, printSignature, printProperty, printGetterSetter, printVariable, printTypeAlias, printTypeParameters, } from './utils/partPrinter';
12
+ export { apiExtractorError, apiExtractorErrorCount, resetApiExtractorErrorCount, setApiExtractorErrorLogger, type ApiExtractorErrorContext, } from './utils/error';