@arcgis/api-extractor 5.1.0-next.1 → 5.1.0-next.100
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/bin/cli.js +2 -0
- package/dist/{ApiExtractor-DByayOhi.js → ApiExtractor-KGzi9B02.js} +224 -220
- package/dist/apiJson.d.ts +10 -3
- package/dist/cli-7PX_wNxb.js +34 -0
- package/dist/cli.js +29 -11
- package/dist/diff/apiDiffToMarkdown.d.ts +9 -0
- package/dist/diff/apiDiffToMarkdown.js +140 -0
- package/dist/diff/diffApiJson.d.ts +4 -4
- package/dist/diff/diffApiJson.js +220 -97
- package/dist/diff/types.d.ts +3 -2
- package/dist/extractor/ApiExtractor.js +3 -3
- package/dist/extractor/config.d.ts +12 -3
- package/dist/extractor/config.js +7 -8
- package/dist/extractor/extractors/copyDoc.d.ts +1 -1
- package/dist/extractor/processing/links.js +65 -64
- package/dist/privateContext-CB7P40up.js +86 -0
- package/dist/typeScript-CjWB1rJ_.js +66 -0
- package/dist/utils/apiHelpers.js +78 -15
- package/dist/utils/createIndex.d.ts +1 -1
- package/dist/utils/createIndex.js +46 -45
- package/dist/utils/partPrinter.js +29 -28
- package/dist/vite/plugin.js +41 -39
- package/dist/vite/typeScript.js +1 -1
- package/dist/worker-OTZkb-ju.js +3684 -0
- package/package.json +11 -7
- package/dist/apiHelpers-BYzO767m.js +0 -161
- package/dist/typeScript-D4_nAmBW.js +0 -64
- package/dist/worker-Btg0KdqM.js +0 -3677
package/dist/apiJson.d.ts
CHANGED
|
@@ -328,6 +328,13 @@ export interface ApiCustomElementDeclaration extends ApiClassDeclaration, ApiWit
|
|
|
328
328
|
* @example "ArcgisCounter" (even if class name is `Counter`)
|
|
329
329
|
*/
|
|
330
330
|
pascalCaseName: string;
|
|
331
|
+
/**
|
|
332
|
+
* True if the custom element is
|
|
333
|
+
* [form-associated](https://html.spec.whatwg.org/dev/custom-elements.html).
|
|
334
|
+
*
|
|
335
|
+
* @default false
|
|
336
|
+
*/
|
|
337
|
+
formAssociated?: boolean;
|
|
331
338
|
members: ApiCustomElementMember[];
|
|
332
339
|
/**
|
|
333
340
|
* The attributes that this element is known to understand.
|
|
@@ -651,7 +658,7 @@ export interface ApiClassDeclaration extends ApiObjectLikeDeclaration, ApiWithEv
|
|
|
651
658
|
* matches the order of language used to describe mixin application, like
|
|
652
659
|
* "S with A, B".
|
|
653
660
|
*
|
|
654
|
-
* @see https://webgis.esri.com/
|
|
661
|
+
* @see https://webgis.esri.com/sdk/contributing/core/core/mixins
|
|
655
662
|
*/
|
|
656
663
|
mixins?: ApiReferenceWithTypeArguments[];
|
|
657
664
|
}
|
|
@@ -778,7 +785,7 @@ export interface ApiClassMethod extends ApiFunctionLike, ApiWithInheritance, Api
|
|
|
778
785
|
* displaying the signature is redundant.
|
|
779
786
|
* Still, if needed, you can use printSignature() util from
|
|
780
787
|
* `@arcgis/api-extractor`.
|
|
781
|
-
* @example "(options?:
|
|
788
|
+
* @example "(options?: PopupViewOpenPopupOptions): Promise<void>"
|
|
782
789
|
*/
|
|
783
790
|
signature: string;
|
|
784
791
|
}
|
|
@@ -796,7 +803,7 @@ export interface ApiClassCallSignature extends Omit<ApiFunctionLike, "name">, Ap
|
|
|
796
803
|
/**
|
|
797
804
|
* A description of a class mixin.
|
|
798
805
|
*
|
|
799
|
-
* @see [WebGIS - Mixins](https://webgis.esri.com/
|
|
806
|
+
* @see [WebGIS - Mixins](https://webgis.esri.com/sdk/contributing/core/core/mixins)
|
|
800
807
|
*/
|
|
801
808
|
export interface ApiMixinDeclaration extends Omit<ApiFunctionLike, "return">, ApiObjectLikeDeclaration, ApiWithEvents {
|
|
802
809
|
kind: "mixin";
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { writeFile as r, readFile as d } from "node:fs/promises";
|
|
2
|
+
import { diffApiJson as m } from "./diff/diffApiJson.js";
|
|
3
|
+
async function k({
|
|
4
|
+
oldPath: t,
|
|
5
|
+
newPath: i,
|
|
6
|
+
outputPath: o,
|
|
7
|
+
docsUrlPrefix: e
|
|
8
|
+
}) {
|
|
9
|
+
const c = f(t), w = f(i), p = await c, l = await w, n = m(p, l);
|
|
10
|
+
if (typeof o == "string")
|
|
11
|
+
if (o.endsWith(".md")) {
|
|
12
|
+
const { apiDiffToMarkdown: s } = await import("./diff/apiDiffToMarkdown.js"), a = s(n, e);
|
|
13
|
+
await r(o, a, "utf-8");
|
|
14
|
+
} else
|
|
15
|
+
await r(o, JSON.stringify(n, null, 2), "utf-8");
|
|
16
|
+
else {
|
|
17
|
+
const { apiDiffToMarkdown: s } = await import("./diff/apiDiffToMarkdown.js"), a = s(n, e);
|
|
18
|
+
console.log(a);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function f(t) {
|
|
22
|
+
if (t.startsWith("http://") || t.startsWith("https://")) {
|
|
23
|
+
const i = await fetch(t);
|
|
24
|
+
if (!i.ok)
|
|
25
|
+
throw new Error(`Failed to fetch api.json: ${i.statusText}`);
|
|
26
|
+
return await i.json();
|
|
27
|
+
} else {
|
|
28
|
+
const i = await d(t, "utf-8");
|
|
29
|
+
return JSON.parse(i);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
k as diffApiCli
|
|
34
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
e.command("run").description("Generate .d.ts types and api.json API reference for a project").option("--cwd <arcgis-js-api>", "Path to the root of the project (default: process.cwd())").option("--dts <outputDirectory>", "Destination for the .d.ts files (example: dist/)").option("--api-json <outputLocation>", "Destination for the api.json file (example: dist/docs/api.json)").option("--environment <environment>", "Environment to run in (production or development) (default: production)").option("--type-check", "Run full type checking before the extraction (default: false)").option("--verify", "Run type checker on the emitted types (default: false)").option("--watch", "Watch for file changes and re-run the extraction automatically", !1).option(
|
|
1
|
+
import { Command as c } from "@commander-js/extra-typings";
|
|
2
|
+
const o = new c();
|
|
3
|
+
o.name("api-extractor").description("Extract public API from a TypeScript project to produce .d.ts types and api.json docs");
|
|
4
|
+
o.command("run").description("Generate .d.ts types and api.json API reference for a project").option("--cwd <arcgis-js-api>", "Path to the root of the project (default: process.cwd())").option("--dts <outputDirectory>", "Destination for the .d.ts files (example: dist/)").option("--api-json <outputLocation>", "Destination for the api.json file (example: dist/docs/api.json)").option("--environment <environment>", "Environment to run in (production or development) (default: production)").option("--type-check", "Run full type checking before the extraction (default: false)").option("--verify", "Run type checker on the emitted types (default: false)").option("--watch", "Watch for file changes and re-run the extraction automatically", !1).option(
|
|
6
5
|
"--config <configPath>",
|
|
7
6
|
"Path to the ./api-extractor.config.ts file. The provided path will be used as is in import(). The config file should export a `config` object of type ApiExtractorConfig (default: api-extractor.config.ts in the cwd)"
|
|
8
7
|
).option(
|
|
9
8
|
"--silence-broken-links",
|
|
10
9
|
"(deprecated) Do not emit errors for broken @links in JSDoc comments. Temporary option for migration period (default: false)"
|
|
11
10
|
).action(async (t) => {
|
|
12
|
-
const { loadApiExtractorConfig:
|
|
11
|
+
const { loadApiExtractorConfig: e, mergeApiExtractorConfigs: n } = await import("./extractor/config.js"), a = await e(t.cwd, t.config), r = n(a, {
|
|
13
12
|
context: {
|
|
14
13
|
dtsEmitPath: t.dts,
|
|
15
14
|
apiJsonEmitPath: t.apiJson,
|
|
@@ -23,16 +22,35 @@ e.command("run").description("Generate .d.ts types and api.json API reference fo
|
|
|
23
22
|
typeCheckTypes: t.verify,
|
|
24
23
|
detectBrokenLinks: t.silenceBrokenLinks === !0 ? !1 : void 0
|
|
25
24
|
}
|
|
26
|
-
}), { ApiExtractor:
|
|
25
|
+
}), { ApiExtractor: p } = await import("./extractor/ApiExtractor.js"), i = new p(r);
|
|
27
26
|
t.watch ? await i.watch() : await i.run();
|
|
28
27
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
o.command("diff").description("Produce a diff of two api.json files").requiredOption(
|
|
29
|
+
"--old <string>",
|
|
30
|
+
"URL or file path to the old api.json file. Example: https://unpkg.com/@arcgis/map-components@latest/dist/docs/api.json"
|
|
31
|
+
).requiredOption(
|
|
32
|
+
"--new <string>",
|
|
33
|
+
"URL or file path to the new api.json file. Example: ./packages/map-packages/map-components/dist/docs/api.json"
|
|
34
|
+
).option("--output <path>", "Path to the output .md or .json file. If not provided, will print markdown to console").option(
|
|
35
|
+
"--docs-url-prefix <string>",
|
|
36
|
+
"Base URL for documentation links. Used only if output format is Markdown",
|
|
37
|
+
"https://developers.arcgis.com/javascript/latest/references/core/"
|
|
38
|
+
).action(async (t) => {
|
|
39
|
+
const { diffApiCli: e } = await import("./cli-7PX_wNxb.js");
|
|
40
|
+
await e({
|
|
41
|
+
oldPath: t.old,
|
|
42
|
+
newPath: t.new,
|
|
43
|
+
outputPath: t.output,
|
|
44
|
+
docsUrlPrefix: t.docsUrlPrefix
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
o.command("diff-types").description("Generate a types diff summary .md file").requiredOption("--original-dts <originalTypings>", "Path to the original types folder").requiredOption("--new-dts <newTypings>", "Path to the new types folder").option("--output-md <outputMd>", "Path to the output markdown file", "types-diff.md").option("--no-truncate", "Do not truncate output if it is longer than 1000 lines", !0).action(async (t) => {
|
|
48
|
+
const { diffTypes: e } = await import("./diffTypes/index.js");
|
|
49
|
+
await e({
|
|
32
50
|
originalDtsPath: t.originalDts,
|
|
33
51
|
newDtsPath: t.newDts,
|
|
34
52
|
outputMdPath: t.outputMd,
|
|
35
53
|
truncate: t.truncate
|
|
36
54
|
});
|
|
37
55
|
});
|
|
38
|
-
|
|
56
|
+
o.parse();
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { buildViewUrl as T } from "../extractor/processing/links.js";
|
|
2
|
+
function K({ modules: e }, t) {
|
|
3
|
+
const o = {
|
|
4
|
+
children: /* @__PURE__ */ new Map(),
|
|
5
|
+
members: []
|
|
6
|
+
};
|
|
7
|
+
for (let n = 0; n < e.length; ++n) {
|
|
8
|
+
const i = e[n], w = i.path.split("/");
|
|
9
|
+
let y = w;
|
|
10
|
+
const M = w.at(-1);
|
|
11
|
+
i.declarations.length === 1 && i.declarations[0].name === M && (y = w.slice(0, -1));
|
|
12
|
+
let U = o;
|
|
13
|
+
for (const g of y)
|
|
14
|
+
U = D(U, g);
|
|
15
|
+
for (let g = 0; g < i.declarations.length; ++g) {
|
|
16
|
+
const f = i.declarations[g], S = B(f), O = f.removed === !0 ? void 0 : $(t, i.path, f, void 0), C = j(f), N = { label: S, viewUrl: O, change: C }, d = f, h = [];
|
|
17
|
+
if (d.members !== void 0)
|
|
18
|
+
for (let l = 0; l < d.members.length; ++l) {
|
|
19
|
+
const r = d.members[l], m = r.kind === "field" ? "property" : r.kind === "call-signature" ? "call signature" : r.kind, p = v(m, r);
|
|
20
|
+
if (p === void 0)
|
|
21
|
+
continue;
|
|
22
|
+
const s = F(r), a = r.removed === !0 ? void 0 : $(
|
|
23
|
+
t,
|
|
24
|
+
i.path,
|
|
25
|
+
f,
|
|
26
|
+
"name" in r ? r.name : `${f.name}Properties`
|
|
27
|
+
);
|
|
28
|
+
h.push({ label: s, viewUrl: a, change: p });
|
|
29
|
+
}
|
|
30
|
+
if (d.events !== void 0)
|
|
31
|
+
for (let l = 0; l < d.events.length; ++l) {
|
|
32
|
+
const r = d.events[l], m = v("event", r);
|
|
33
|
+
if (m === void 0)
|
|
34
|
+
continue;
|
|
35
|
+
const p = r.removed === !0 ? void 0 : $(t, i.path, f, `event-${r.name}`);
|
|
36
|
+
h.push({ label: `@${r.name}`, viewUrl: p, change: m });
|
|
37
|
+
}
|
|
38
|
+
if (typeof d.tagName == "string") {
|
|
39
|
+
const l = d.slots, r = d.cssParts, m = d.cssProperties, p = d.cssStates;
|
|
40
|
+
if (l !== void 0)
|
|
41
|
+
for (let s = 0; s < l.length; ++s) {
|
|
42
|
+
const a = l[s], u = v("slot", a);
|
|
43
|
+
if (u === void 0)
|
|
44
|
+
continue;
|
|
45
|
+
const b = a.removed === !0 ? void 0 : $(t, i.path, f, `slot-${a.name}`);
|
|
46
|
+
h.push({ label: a.name, viewUrl: b, change: u });
|
|
47
|
+
}
|
|
48
|
+
if (r !== void 0)
|
|
49
|
+
for (let s = 0; s < r.length; ++s) {
|
|
50
|
+
const a = r[s], u = v("css part", a);
|
|
51
|
+
if (u === void 0)
|
|
52
|
+
continue;
|
|
53
|
+
h.push({ label: a.name, viewUrl: void 0, change: u });
|
|
54
|
+
}
|
|
55
|
+
if (m !== void 0)
|
|
56
|
+
for (let s = 0; s < m.length; ++s) {
|
|
57
|
+
const a = m[s], u = v("css property", a);
|
|
58
|
+
if (u === void 0)
|
|
59
|
+
continue;
|
|
60
|
+
const b = a.removed === !0 ? void 0 : $(t, i.path, f, a.name);
|
|
61
|
+
h.push({ label: a.name, viewUrl: b, change: u });
|
|
62
|
+
}
|
|
63
|
+
if (p !== void 0)
|
|
64
|
+
for (let s = 0; s < p.length; ++s) {
|
|
65
|
+
const a = p[s], u = v("css state", a);
|
|
66
|
+
if (u === void 0)
|
|
67
|
+
continue;
|
|
68
|
+
h.push({ label: a.name, viewUrl: void 0, change: u });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
h.length > 0 ? E(U, N).members.push(...h) : C !== void 0 && U.members.push(N);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const c = [];
|
|
75
|
+
for (const n of o.children.values())
|
|
76
|
+
L(n, "", c);
|
|
77
|
+
return c.join(`
|
|
78
|
+
`);
|
|
79
|
+
}
|
|
80
|
+
function D(e, t) {
|
|
81
|
+
const o = e.children.get(t);
|
|
82
|
+
if (o !== void 0)
|
|
83
|
+
return o;
|
|
84
|
+
const c = { name: t, children: /* @__PURE__ */ new Map(), members: [], node: void 0 };
|
|
85
|
+
return e.children.set(t, c), c;
|
|
86
|
+
}
|
|
87
|
+
function j(e) {
|
|
88
|
+
const t = e.tagName !== void 0 ? "component" : e.kind === "interface" ? "type declaration" : e.kind;
|
|
89
|
+
return v(t, e);
|
|
90
|
+
}
|
|
91
|
+
function v(e, t) {
|
|
92
|
+
const { added: o, removed: c, deprecated: n } = t;
|
|
93
|
+
if (c) {
|
|
94
|
+
const i = `**removed** ${e}`;
|
|
95
|
+
return typeof n == "string" ? `${i} - deprecated ${x(n)}` : i;
|
|
96
|
+
}
|
|
97
|
+
if (n)
|
|
98
|
+
return typeof n == "string" ? `**deprecated** ${e} ${x(n)}` : `**deprecated** ${e}`;
|
|
99
|
+
if (o)
|
|
100
|
+
return `**added** ${e}`;
|
|
101
|
+
}
|
|
102
|
+
function B(e) {
|
|
103
|
+
const t = e.tagName;
|
|
104
|
+
return typeof t == "string" && t.length > 0 ? t : k(e.name) + (e.kind === "function" ? "()" : "");
|
|
105
|
+
}
|
|
106
|
+
function $(e, t, o, c) {
|
|
107
|
+
const n = `${e}${t}/`;
|
|
108
|
+
return T(n, o.kind === "class" ? void 0 : o.name, c);
|
|
109
|
+
}
|
|
110
|
+
function E(e, t) {
|
|
111
|
+
const o = D(e, t.label);
|
|
112
|
+
return o.node = t, o;
|
|
113
|
+
}
|
|
114
|
+
function F(e) {
|
|
115
|
+
return e.kind === "constructor" ? "constructor" : e.kind === "call-signature" ? "call signature" : e.kind === "method" ? `${k(e.name)}()` : k(e.name);
|
|
116
|
+
}
|
|
117
|
+
function k(e) {
|
|
118
|
+
return e.replace(/[\\\[\]\(\)]/gu, "\\$&");
|
|
119
|
+
}
|
|
120
|
+
function x(e) {
|
|
121
|
+
return e.split(`
|
|
122
|
+
`)[0];
|
|
123
|
+
}
|
|
124
|
+
function L(e, t, o) {
|
|
125
|
+
if (e.node) {
|
|
126
|
+
const n = e.node.viewUrl === void 0 ? e.node.label : `[${e.node.label}](${e.node.viewUrl})`;
|
|
127
|
+
e.node.change ? o.push(`${t}- ${n} - ${e.node.change}`) : o.push(`${t}- ${n}`);
|
|
128
|
+
} else
|
|
129
|
+
o.push(`${t}- ${e.name}/`);
|
|
130
|
+
const c = `${t} `;
|
|
131
|
+
for (const n of e.members) {
|
|
132
|
+
const i = n.viewUrl === void 0 ? n.label : `[${n.label}](${n.viewUrl})`;
|
|
133
|
+
n.change ? o.push(`${c}- ${i} - ${n.change}`) : o.push(`${c}- ${i}`);
|
|
134
|
+
}
|
|
135
|
+
for (const n of e.children.values())
|
|
136
|
+
L(n, c, o);
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
K as apiDiffToMarkdown
|
|
140
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApiJson } from "../apiJson.js";
|
|
1
|
+
import type { ApiJson, ApiJsonCompiler } from "../apiJson.js";
|
|
2
2
|
import type { ApiDiff } from "./types.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,8 +6,8 @@ import type { ApiDiff } from "./types.js";
|
|
|
6
6
|
* @param newApiJson
|
|
7
7
|
* @example
|
|
8
8
|
* ```js
|
|
9
|
-
* import { diffApiJson
|
|
10
|
-
* import {
|
|
9
|
+
* import { diffApiJson } from "@arcgis/api-extractor/diff/diffApiJson";
|
|
10
|
+
* import { fetchApiJsonFromNpm } from "@arcgis/api-extractor/diff/fetchApiJsonFromNpm";
|
|
11
11
|
*
|
|
12
12
|
* // Read -next api.json from file system:
|
|
13
13
|
* const apiJson = JSON.parse(
|
|
@@ -23,4 +23,4 @@ import type { ApiDiff } from "./types.js";
|
|
|
23
23
|
* writeFileSync("api-diff.json", JSON.stringify(diff, null, 2));
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
export function diffApiJson(oldApiJson: Pick<ApiJson, "modules"
|
|
26
|
+
export function diffApiJson(oldApiJson: Pick<ApiJson, "modules"> & { compiler?: ApiJsonCompiler; }, newApiJson: Pick<ApiJson, "modules"> & { compiler?: ApiJsonCompiler; }): ApiDiff;
|