@arcgis/api-extractor 5.0.0-next.9 → 5.0.0-next.91
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.
- package/dist/apiJson.d.ts +342 -516
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +14 -0
- package/dist/config/typeReferences/docLinkAdditions.d.ts +51 -0
- package/dist/config/typeReferences/globals.d.ts +11 -0
- package/dist/config/typeReferences/stringDocLinkAdditions.d.ts +17 -0
- package/dist/config/typeReferences/typeScriptGlobals.json.d.ts +3 -0
- package/dist/diff/diffApiJson.d.ts +22 -2
- package/dist/diff/fetchApiJsonFromNpm.d.ts +1 -1
- package/dist/diff/index.d.ts +3 -3
- package/dist/diff/index.js +149 -0
- package/dist/diff/types.d.ts +20 -3
- package/dist/diffTypes/index.d.ts +24 -0
- package/dist/diffTypes/index.js +69 -0
- package/dist/extractor/ApiExtractor.d.ts +139 -0
- package/dist/extractor/config.d.ts +66 -0
- package/dist/index.d.ts +12 -8
- package/dist/index.js +782 -228
- package/dist/internalTypeScriptApis.d.ts +31 -0
- package/dist/types.d.ts +18 -21
- package/dist/uiUtils/index.d.ts +21 -0
- package/dist/uiUtils/index.js +57 -0
- package/dist/utils/apiHelpers.d.ts +61 -2
- package/dist/utils/astHelpers.d.ts +14 -2
- package/dist/utils/error.d.ts +6 -1
- package/dist/utils/jsDocHelpers.d.ts +2 -0
- package/dist/utils/jsDocParser.d.ts +46 -0
- package/dist/utils/jsDocPrinter.d.ts +13 -0
- package/dist/utils/partPrinter.d.ts +23 -0
- package/dist/utils/print.d.ts +0 -1
- package/package.json +15 -5
- package/dist/diff.js +0 -147
- package/dist/extractor/index.d.ts +0 -46
- package/dist/utils/docHelpers.d.ts +0 -9
- /package/dist/{ensureValidType.d.ts → ensureCemCompatibility.d.ts} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { path as s } from "@arcgis/components-build-utils";
|
|
2
|
+
import { execSync as c } from "node:child_process";
|
|
3
|
+
import { mkdir as m, writeFile as d } from "node:fs/promises";
|
|
4
|
+
const a = "diff --new-file --recursive", u = `${a} --unified=2`;
|
|
5
|
+
async function b({
|
|
6
|
+
originalDtsPath: t,
|
|
7
|
+
newDtsPath: n,
|
|
8
|
+
outputMdPath: e = "types-diff.md",
|
|
9
|
+
truncate: i = !0
|
|
10
|
+
}) {
|
|
11
|
+
n = s.join(s.resolve(n), "/");
|
|
12
|
+
const r = c(`${u} ${t} ${n} || true`, {
|
|
13
|
+
encoding: "utf8",
|
|
14
|
+
maxBuffer: 1024 * 1024 * 20
|
|
15
|
+
}).trim();
|
|
16
|
+
let o = "";
|
|
17
|
+
if (r.length === 0)
|
|
18
|
+
console.log("Public types did not change.");
|
|
19
|
+
else {
|
|
20
|
+
o = `### Public types changes
|
|
21
|
+
|
|
22
|
+
🧐 please verify that the changes to the public API/doc below are intentional.
|
|
23
|
+
🟥 If removing/changing APIs, remember the semver promise.
|
|
24
|
+
🟩 If adding APIs, add to release notes.`;
|
|
25
|
+
let f = g(r.split(`
|
|
26
|
+
`), n);
|
|
27
|
+
i && f.length > l && (o += `> [!WARNING]
|
|
28
|
+
> Too many changes. Only displaying the first ${l} lines (total ${f.length}) of the diff. If you need to see complete diff, re-run this command with --no-truncate.
|
|
29
|
+
|
|
30
|
+
`, f = f.slice(0, l)), o += `${h(f)}
|
|
31
|
+
|
|
32
|
+
`, console.log(`Wrote diff to ${e}`);
|
|
33
|
+
}
|
|
34
|
+
await m(s.dirname(e), { recursive: !0 }), await d(e, o);
|
|
35
|
+
}
|
|
36
|
+
function g(t, n) {
|
|
37
|
+
for (let e = 0; e < t.length; e++) {
|
|
38
|
+
const i = t[e];
|
|
39
|
+
if (
|
|
40
|
+
// Make diff smaller by excluding the `diff ...` lines
|
|
41
|
+
(i.startsWith(a) || // Redundant line - make file header smaller
|
|
42
|
+
i.startsWith("---") || // Not important
|
|
43
|
+
i === "\") && (t.splice(e, 1), e--), i.startsWith("+++")
|
|
44
|
+
) {
|
|
45
|
+
const r = i.indexOf(" ");
|
|
46
|
+
let o = i.slice(4, r === -1 ? i.length : r);
|
|
47
|
+
o.startsWith(n) && (o = o.slice(n.length)), t[e] = `🟦 ${o}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return t;
|
|
51
|
+
}
|
|
52
|
+
const l = 1e3;
|
|
53
|
+
function h(t) {
|
|
54
|
+
const n = t.length, e = p(t.join(`
|
|
55
|
+
`));
|
|
56
|
+
return n <= 10 ? e : `<details><summary>See diff</summary>
|
|
57
|
+
|
|
58
|
+
${e}
|
|
59
|
+
|
|
60
|
+
</details>`;
|
|
61
|
+
}
|
|
62
|
+
function p(t) {
|
|
63
|
+
return `\`\`\`diff
|
|
64
|
+
${t}
|
|
65
|
+
\`\`\``;
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
b as diffTypes
|
|
69
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { ApiClassMethod, ApiClassDeclaration, ApiCustomElementField, ApiDeclaration, ApiEvent, ApiJson, ApiModule, ApiCustomElementDeclaration, ApiFunctionDeclaration, ApiVariableDeclaration, ApiInterfaceDeclaration, ApiObjectLikeDeclaration, ApiCustomElementMember, ApiReference, ApiClassMember, ApiAttribute, ApiSlot, ApiCssPart, ApiCssCustomProperty, ApiCssCustomState, ApiMixinDeclaration, ApiClassField, ApiReferenceWithTypeArguments } from '../apiJson.ts';
|
|
2
|
+
import { default as ts } from 'typescript';
|
|
3
|
+
import { CopyDocDefinitions } from '../types.ts';
|
|
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
|
+
constructor(options: ApiExtractorOptions);
|
|
16
|
+
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, eventsWereExplicitlyInherited: boolean): 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: Readonly<Record<string, readonly string[]>>;
|
|
94
|
+
/**
|
|
95
|
+
* Based on the superclass name, find the actual declaration in the modules.
|
|
96
|
+
*/
|
|
97
|
+
protected resolveInheritance(superClassModule: string, modules: ApiModule[], isMixin: boolean): 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[], _isMixin: boolean): readonly [string, ApiClassDeclaration | ApiMixinDeclaration] | false;
|
|
105
|
+
protected handleEventTypesProperty(_apiMember: ApiClassMember, _apiComponent: ApiClassDeclaration | ApiMixinDeclaration, _moduleName: string): void;
|
|
106
|
+
protected resolvePropertyAutoCastingType(_apiMember: ApiClassMember, _moduleName: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* This method should check if the super property is an accessor, then the
|
|
109
|
+
* override property should be promoted to an accessor too.
|
|
110
|
+
* This is necessary until we migrate to standard decorators since - after
|
|
111
|
+
* that internal accessor status will match the status in the public typings.
|
|
112
|
+
*/
|
|
113
|
+
protected maybePromotePropertyToAutoAccessor(_apiProperty: ApiClassField, _superApiProperty: ApiClassField): void;
|
|
114
|
+
protected maybeResolveMixinBaseClass(_apiReference: ApiReferenceWithTypeArguments, _currentModule: string): ApiInterfaceDeclaration | undefined;
|
|
115
|
+
}
|
|
116
|
+
type ApiExtractorInheritanceData = {
|
|
117
|
+
inheritanceData: ApiReference;
|
|
118
|
+
declaration: ApiClassDeclaration | ApiMixinDeclaration;
|
|
119
|
+
/**
|
|
120
|
+
* Used for validation only. If class has any settable fields, and class is
|
|
121
|
+
* extended by another one, require that the class module exports the
|
|
122
|
+
* `<className>Properties` interface. It will be extended by the superclass'
|
|
123
|
+
* properties interface.
|
|
124
|
+
*/
|
|
125
|
+
hasSettableField: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* Indexed by name for quick lookup of "overridden" status.
|
|
128
|
+
* Using a map because we do .get() during constructor of the Map, and because
|
|
129
|
+
* there are often 10+ items with random access.
|
|
130
|
+
*/
|
|
131
|
+
indexedMembers: Map<string, ApiClassMember | ApiCustomElementMember | undefined> | undefined;
|
|
132
|
+
indexedEvents: Record<string, ApiEvent> | undefined;
|
|
133
|
+
indexedAttributes: Record<string, ApiAttribute> | undefined;
|
|
134
|
+
indexedSlots: Record<string, ApiSlot> | undefined;
|
|
135
|
+
indexedCssParts: Record<string, ApiCssPart> | undefined;
|
|
136
|
+
indexedCssProperties: Record<string, ApiCssCustomProperty> | undefined;
|
|
137
|
+
indexedCssStates: Record<string, ApiCssCustomState> | undefined;
|
|
138
|
+
};
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CopyDocDefinitions } from '../types.ts';
|
|
2
|
+
export interface ApiExtractorConfig {
|
|
3
|
+
/**
|
|
4
|
+
* The environment in which the extractor is running.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @default "production"
|
|
8
|
+
*/
|
|
9
|
+
readonly environment?: "development" | "production";
|
|
10
|
+
/**
|
|
11
|
+
* The path to the root of the project to extract.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @default process.cwd()
|
|
15
|
+
*/
|
|
16
|
+
readonly cwd?: string;
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
21
|
+
readonly copyDocDefinitions?: CopyDocDefinitions;
|
|
22
|
+
/** @public */
|
|
23
|
+
readonly typeReplacements?: TypeReplacements;
|
|
24
|
+
/**
|
|
25
|
+
* api-extractor automatically discovers files that contain `@public`. Not
|
|
26
|
+
* having to manually maintain a list of entries saves labor.
|
|
27
|
+
*
|
|
28
|
+
* As a performance optimization, you can exclude some directories from
|
|
29
|
+
* `@public` file discovery. This should be a flat list of folders inside
|
|
30
|
+
* basePath without slashes or deep paths.
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
* @example ["tests"]
|
|
34
|
+
*/
|
|
35
|
+
readonly excludedDirectories?: Set<string>;
|
|
36
|
+
/** @public */
|
|
37
|
+
readonly noInheritMembers?: NoInheritMembers;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Privately, arcgis-js-api has interfaces that mirror some of the most widely
|
|
41
|
+
* used types. They are in the process of refactoring out many of them. Until
|
|
42
|
+
* that is complete, this hardcoded table is used to replace the usages of these
|
|
43
|
+
* interfaces with their concrete types.
|
|
44
|
+
*
|
|
45
|
+
* Keep this list minimal. Type replacements have pitfalls:
|
|
46
|
+
* - In a .ts file there is no indication that a given type will be replaced.
|
|
47
|
+
* It can be surprising why some types are replaced and some are not.
|
|
48
|
+
* - The replaced type is not equivalent (LayerUnion=>Layer). These do affect
|
|
49
|
+
* type checking in some cases.
|
|
50
|
+
* - If the name we are replacing with is already present in the current scope,
|
|
51
|
+
* there will be a collision. Detecting such collisions is tricky - extractor
|
|
52
|
+
* does it minimally.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @see https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/60843
|
|
56
|
+
* @see https://devtopia.esri.com/WebGIS/arcgis-js-api/issues/69911
|
|
57
|
+
* @see https://devtopia.esri.com/WebGIS/arcgis-js-api/issues/73395
|
|
58
|
+
*/
|
|
59
|
+
export type TypeReplacements = Record<string, Record<string, readonly [modulePath: string, name: string, type: "default" | "named"] | undefined> | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Don't include these members in each subclass to keep api reference pages cleaner.
|
|
62
|
+
* These has no typings impact since their inheritance is still done by TypeScript.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export type NoInheritMembers = Readonly<Record<string, readonly string[]>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
1
|
+
export type * from './apiJson.ts';
|
|
2
|
+
export { ApiExtractor, type ApiExtractorOptions } from './extractor/ApiExtractor.ts';
|
|
3
|
+
export { unsafeGetUndocumentedPrinter, unsafeUndocumentedTs } from './internalTypeScriptApis.ts';
|
|
4
|
+
export type { CopyDocDefinitions, NodeDoc } from './types.ts';
|
|
5
|
+
export { findReferenceRanges, getApiMemberName, getMaybeStaticApiMemberName, getApiNodeLabel, globalPackageIdentifier, isApiMethod, isApiProperty, multipleJsDocTags, naturalSortModules, postProcessLinks, apiExtractorJsDocError, compareClassMembers, compareNamedNodes, compareStrings, } from './utils/apiHelpers.ts';
|
|
6
|
+
export { extractBooleanInitializer, findDecorator, getMemberName, hasIgnoredModifier, setDefaultFromInitializer, getBasename, } from './utils/astHelpers.ts';
|
|
7
|
+
export { alternativeDocumentationHost, normalizedDocumentationHost } from './utils/jsDocHelpers.ts';
|
|
8
|
+
export { apiMemberToNodeDoc, nodeDocToString, nodeDocToSynthesizedComment } from './utils/jsDocPrinter.ts';
|
|
9
|
+
export { setApiDocFromJsDoc, setApiDocFromSymbol, symbolToDocs, getNodeDoc } from './utils/jsDocParser.ts';
|
|
10
|
+
export { typeScriptGlobals, typeScriptGlobalsViewUrlCommonPrefix } from './config/typeReferences/globals.ts';
|
|
11
|
+
export { printClass, printInterface, printMethod, printFunction, printSignature, printProperty, printGetterSetter, printVariable, printTypeAlias, printTypeParameters, } from './utils/partPrinter.ts';
|
|
12
|
+
export { apiExtractorError, apiExtractorErrorCount, resetApiExtractorErrorCount, setApiExtractorErrorLogger, apiExtractorDiagnosticContext, type ApiExtractorErrorContext, } from './utils/error.ts';
|