@arcgis/api-extractor 5.0.0-next.14 → 5.0.0-next.141

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.
Files changed (56) hide show
  1. package/dist/ApiExtractor-DIfug_xm.js +2644 -0
  2. package/dist/apiJson.d.ts +783 -1011
  3. package/dist/cli.js +38 -0
  4. package/dist/compilerHints.d.ts +62 -0
  5. package/dist/diff/diffApiJson.d.ts +26 -3
  6. package/dist/diff/diffApiJson.js +142 -0
  7. package/dist/diff/fetchApiJsonFromNpm.d.ts +5 -2
  8. package/dist/diff/fetchApiJsonFromNpm.js +9 -0
  9. package/dist/diff/types.d.ts +80 -49
  10. package/dist/diffTypes/index.d.ts +21 -0
  11. package/dist/diffTypes/index.js +71 -0
  12. package/dist/extractor/ApiExtractor.d.ts +74 -0
  13. package/dist/extractor/ApiExtractor.js +9 -0
  14. package/dist/extractor/config.d.ts +452 -0
  15. package/dist/extractor/config.js +17 -0
  16. package/dist/extractor/extractors/copyDoc.d.ts +25 -0
  17. package/dist/extractor/privateContext.d.ts +19 -0
  18. package/dist/extractor/privateContext.js +84 -0
  19. package/dist/extractor/processing/links.d.ts +12 -0
  20. package/dist/extractor/processing/links.js +174 -0
  21. package/dist/extractor/types.d.ts +40 -0
  22. package/dist/extractor/webComponent/findComponents.d.ts +19 -0
  23. package/dist/extractor/webComponent/findComponents.js +36 -0
  24. package/dist/extractor/webComponent/pathMapping.d.ts +11 -0
  25. package/dist/extractor/webComponent/pathMapping.js +44 -0
  26. package/dist/index.d.ts +164 -8
  27. package/dist/index.js +3 -283
  28. package/dist/typeScript-soMJqHns.js +64 -0
  29. package/dist/uiUtils/index.d.ts +12 -0
  30. package/dist/uiUtils/index.js +5 -0
  31. package/dist/utils/apiHelpers.d.ts +43 -17
  32. package/dist/utils/apiHelpers.js +80 -0
  33. package/dist/utils/astHelpers.d.ts +24 -11
  34. package/dist/utils/astHelpers.js +67 -0
  35. package/dist/utils/hydrateApiType.d.ts +26 -0
  36. package/dist/utils/hydrateApiType.js +62 -0
  37. package/dist/utils/inferEntrypoints.d.ts +17 -0
  38. package/dist/utils/inferEntrypoints.js +26 -0
  39. package/dist/utils/internalTypeScriptApis.d.ts +92 -0
  40. package/dist/utils/internalTypeScriptApis.js +58 -0
  41. package/dist/utils/partPrinter.d.ts +29 -0
  42. package/dist/utils/partPrinter.js +82 -0
  43. package/dist/vite/plugin.d.ts +53 -0
  44. package/dist/vite/plugin.js +107 -0
  45. package/dist/vite/typeScript.d.ts +16 -0
  46. package/dist/vite/typeScript.js +6 -0
  47. package/dist/worker-On5v54cw.js +3597 -0
  48. package/package.json +46 -5
  49. package/dist/diff/index.d.ts +0 -3
  50. package/dist/diff.js +0 -147
  51. package/dist/ensureValidType.d.ts +0 -1
  52. package/dist/extractor/index.d.ts +0 -46
  53. package/dist/types.d.ts +0 -25
  54. package/dist/utils/docHelpers.d.ts +0 -9
  55. package/dist/utils/error.d.ts +0 -12
  56. package/dist/utils/print.d.ts +0 -7
package/dist/cli.js ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env node
2
+ import { Command as p } from "@commander-js/extra-typings";
3
+ const e = new p();
4
+ e.name("api-extractor").description("Extract public API from a TypeScript project to produce .d.ts types and api.json docs");
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(
6
+ "--config <configPath>",
7
+ "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
+ ).option(
9
+ "--silence-broken-links",
10
+ "(deprecated) Do not emit errors for broken @links in JSDoc comments. Temporary option for migration period (default: false)"
11
+ ).action(async (t) => {
12
+ const { loadApiExtractorConfig: o, mergeApiExtractorConfigs: n } = await import("./extractor/config.js"), a = await o(t.cwd, t.config), r = n(a, {
13
+ context: {
14
+ dtsEmitPath: t.dts,
15
+ apiJsonEmitPath: t.apiJson,
16
+ environment: t.environment === "development" ? "development" : void 0,
17
+ cwd: t.cwd
18
+ },
19
+ types: {
20
+ fullTypeCheck: t.typeCheck
21
+ },
22
+ verify: {
23
+ typeCheckTypes: t.verify,
24
+ detectBrokenLinks: t.silenceBrokenLinks === !0 ? !1 : void 0
25
+ }
26
+ }), { ApiExtractor: c } = await import("./extractor/ApiExtractor.js"), i = new c(r);
27
+ t.watch ? await i.watch() : await i.run();
28
+ });
29
+ e.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) => {
30
+ const { diffTypes: o } = await import("./diffTypes/index.js");
31
+ await o({
32
+ originalDtsPath: t.originalDts,
33
+ newDtsPath: t.newDts,
34
+ outputMdPath: t.outputMd,
35
+ truncate: t.truncate
36
+ });
37
+ });
38
+ e.parse();
@@ -0,0 +1,62 @@
1
+ /**
2
+ * We try to keep public and private types close to keep the API more
3
+ * maintainable. However, occasionally we must diverge to hide some private
4
+ * details from the public API.
5
+ *
6
+ * Use this type helper when public TypeScript type must diverge from the
7
+ * private type.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * type ActionType = PublicApiNarrowType<
12
+ * "create" | "update" | "delete",
13
+ * "create" | "delete"
14
+ * >;
15
+ * ```
16
+ *
17
+ * In private types, the 1st type parameter will be used for type checking,
18
+ * making the effective type `"create" | "update" | "delete"`.
19
+ *
20
+ * But in public `.d.ts` and public docs, the above will appear like this:
21
+ *
22
+ * ```ts
23
+ * type ActionType = "create" | "delete";
24
+ * ```
25
+ *
26
+ * Remember that properties without `public` tag are not publicly exposed.
27
+ * Thus, in practice, `PublicApiNarrowType` is most commonly needed to hide
28
+ * private union members.
29
+ *
30
+ * To ensure public type does not get out of date, `PublicApiNarrowType`
31
+ * requires that the public type extends the private type (or in other words, a
32
+ * subset of the private type). If that restriction is too tight, use
33
+ * `PublicApiRelaxType` instead.
34
+ */
35
+ export type PublicApiNarrowType<PrivateType, _PublicType extends PrivateType> = PrivateType;
36
+
37
+ /**
38
+ * Most of the time, when the public type must diverge from the private type,
39
+ * the public type is a subset of the private type - in such cases use
40
+ * `PublicApiNarrowType`.
41
+ *
42
+ * Occasionally, the public type may need to be a superset of the private type
43
+ * or even an unrelated type. For those cases, use `PublicApiRelaxType`.
44
+ *
45
+ * Keep usages of `PublicApiRelaxType` at minimum as it disables type
46
+ * checking between public and private types.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * type EditableLayers = FeatureLayer | ...;
51
+ * class MyClass {
52
+ * // Layer is a superset of EditableLayers, not subset,
53
+ * // so we must use PublicApiRelaxType.
54
+ * layer: PublicApiRelaxType<EditableLayers, Layer>;
55
+ *
56
+ * // StrictNumberType is a branded type that is incompatible
57
+ * // with regular number type.
58
+ * jobId: PublicApiRelaxType<StrictNumberType<"JobId">, number>;
59
+ * }
60
+ * ```
61
+ */
62
+ export type PublicApiRelaxType<PrivateType, _PublicType> = PrivateType;
@@ -1,3 +1,26 @@
1
- import { ApiJson } from '../apiJson';
2
- import { ApiDiff } from './types';
3
- export declare function diffApiJson(oldApiJson: Pick<ApiJson, "modules">, newApiJson: Pick<ApiJson, "modules">): ApiDiff;
1
+ import type { ApiJson } from "../apiJson.js";
2
+ import type { ApiDiff } from "./types.js";
3
+
4
+ /**
5
+ * @param oldApiJson
6
+ * @param newApiJson
7
+ * @example
8
+ * ```js
9
+ * import { diffApiJson, fetchApiJsonFromNpm } from "@arcgis/api-extractor/diff";
10
+ * import { readFileSync, writeFileSync } from "node:fs";
11
+ *
12
+ * // Read -next api.json from file system:
13
+ * const apiJson = JSON.parse(
14
+ * readFileSync("packages/map-packages/map-components/dist/docs/api.json", "utf8"),
15
+ * );
16
+ * // Read -latest api.json from NPM
17
+ * const npmApiJson = await fetchApiJsonFromNpm("@arcgis/map-components", "latest");
18
+ *
19
+ * // Compute diff
20
+ * const diff = diffApiJson(npmApiJson, apiJson);
21
+ *
22
+ * // Do something with the diff
23
+ * writeFileSync("api-diff.json", JSON.stringify(diff, null, 2));
24
+ * ```
25
+ */
26
+ export function diffApiJson(oldApiJson: Pick<ApiJson, "modules">, newApiJson: Pick<ApiJson, "modules">): ApiDiff;
@@ -0,0 +1,142 @@
1
+ function M(r, a) {
2
+ const n = new Map(r.modules.map((e) => [e.path, e])), t = [];
3
+ for (const e of a.modules) {
4
+ const s = n.get(e.path), i = k(s, e, !0);
5
+ i !== void 0 && t.push(i), n.delete(e.path);
6
+ }
7
+ for (const e of n.values()) {
8
+ const s = k(void 0, e, !1);
9
+ s !== void 0 && t.push(s);
10
+ }
11
+ return { modules: t };
12
+ }
13
+ function k(r, a, n) {
14
+ const t = [], e = h(r?.declarations ?? []), s = h(a.declarations ?? []);
15
+ for (const i of s.values()) {
16
+ const o = i.at(-1), p = o.tagName, u = p ?? o.name, f = e.get(u);
17
+ e.delete(u);
18
+ const g = f === void 0 && !n ? !0 : void 0, m = n && // Only mark as deprecated if all overloads are deprecated
19
+ (i.length === 1 || i.every((d) => d.deprecated !== void 0)) ? o.deprecated : void 0, D = !m && f === void 0 && n ? !0 : void 0;
20
+ if (g || D) {
21
+ t.push({
22
+ kind: o.kind,
23
+ name: o.name,
24
+ tagName: p,
25
+ members: void 0,
26
+ removed: g,
27
+ added: D,
28
+ deprecated: m
29
+ });
30
+ continue;
31
+ } else if (!n)
32
+ continue;
33
+ if (p !== void 0) {
34
+ const d = o, c = f?.[0], l = {
35
+ kind: d.kind,
36
+ name: d.name,
37
+ tagName: d.tagName,
38
+ deprecated: m,
39
+ added: void 0,
40
+ removed: void 0,
41
+ members: b(c?.members, d.members),
42
+ events: v(c?.events, d.events),
43
+ slots: v(c?.slots, d.slots),
44
+ cssParts: v(c?.cssParts, d.cssParts),
45
+ cssProperties: v(c?.cssProperties, d.cssProperties),
46
+ cssStates: v(c?.cssStates, d.cssStates)
47
+ };
48
+ (m !== void 0 || l.members !== void 0 || l.events !== void 0 || l.slots !== void 0 || l.cssParts !== void 0 || l.cssProperties !== void 0 || l.cssStates !== void 0) && t.push(l);
49
+ } else if (o.kind === "class" || o.kind === "interface" || o.kind === "mixin") {
50
+ const d = f?.[0], c = {
51
+ kind: o.kind,
52
+ name: o.name,
53
+ deprecated: m,
54
+ added: void 0,
55
+ removed: void 0,
56
+ members: b(d?.members, o.members),
57
+ events: "events" in o ? v(d?.events, o.events) : void 0
58
+ };
59
+ (m !== void 0 || c.members !== void 0 || c.events !== void 0) && t.push(c);
60
+ } else m !== void 0 && t.push({
61
+ kind: o.kind,
62
+ name: o.name,
63
+ deprecated: m,
64
+ added: void 0,
65
+ removed: void 0
66
+ });
67
+ }
68
+ if (n)
69
+ for (const [i] of e.values())
70
+ t.push({
71
+ kind: i.kind,
72
+ name: i.name,
73
+ tagName: i.tagName,
74
+ members: void 0,
75
+ removed: !0,
76
+ added: void 0,
77
+ deprecated: void 0
78
+ });
79
+ if (t.length !== 0)
80
+ return {
81
+ path: a.path,
82
+ declarations: t
83
+ };
84
+ }
85
+ function h(r) {
86
+ const a = /* @__PURE__ */ new Map();
87
+ for (let n = 0; n < r.length; ++n) {
88
+ const t = r[n], e = t.tagName ?? t.name ?? t.kind, s = a.get(e);
89
+ s === void 0 ? a.set(e, [t]) : s.push(t);
90
+ }
91
+ return a;
92
+ }
93
+ function v(r, a) {
94
+ const n = h(r ?? []), t = [];
95
+ if (a !== void 0)
96
+ for (const e of a)
97
+ n.get(e.name) === void 0 ? t.push({
98
+ name: e.name,
99
+ added: !0
100
+ }) : e.deprecated && t.push({
101
+ name: e.name,
102
+ deprecated: e.deprecated
103
+ }), n.delete(e.name);
104
+ for (const [e] of n.values())
105
+ t.push({
106
+ name: e.name,
107
+ removed: !0
108
+ });
109
+ return t.length ? t : void 0;
110
+ }
111
+ function b(r, a) {
112
+ const n = h(r ?? []), t = h(a ?? []), e = [];
113
+ for (const [s, i] of t.entries()) {
114
+ const o = i.at(-1), p = n.get(s);
115
+ n.delete(s);
116
+ const u = (
117
+ // Only mark as deprecated if all overloads are deprecated
118
+ i.length === 1 || i.every((g) => g.deprecated !== void 0) ? o.deprecated : void 0
119
+ ), f = s === "constructor" || s === "call-signature" ? void 0 : s;
120
+ u ? e.push({
121
+ kind: o.kind,
122
+ name: f,
123
+ deprecated: u
124
+ }) : p === void 0 && e.push({
125
+ kind: o.kind,
126
+ name: f,
127
+ added: !0
128
+ });
129
+ }
130
+ for (const [s, [i]] of n.entries()) {
131
+ const o = s === "constructor" || s === "call-signature" ? void 0 : s;
132
+ e.push({
133
+ kind: i.kind,
134
+ name: o,
135
+ removed: !0
136
+ });
137
+ }
138
+ return e.length ? e : void 0;
139
+ }
140
+ export {
141
+ M as diffApiJson
142
+ };
@@ -1,7 +1,10 @@
1
- import { ApiJson } from '../apiJson';
1
+ import type { ApiJson } from "../apiJson.js";
2
+
2
3
  /**
3
4
  * Read dist/docs/api.json for a given NPM package.
4
5
  *
6
+ * @param packageName
7
+ * @param semverVersion
5
8
  * @example fetchApiJsonFromNpm("@arcgis/map-components", "latest");
6
9
  */
7
- export declare function fetchApiJsonFromNpm(packageName: string, semverVersion: string): Promise<ApiJson>;
10
+ export function fetchApiJsonFromNpm(packageName: string, semverVersion: string): Promise<ApiJson>;
@@ -0,0 +1,9 @@
1
+ async function a(t, s) {
2
+ const o = await fetch(`https://unpkg.com/${t}@${s}/dist/docs/api.json`);
3
+ if (!o.ok)
4
+ throw new Error(`Failed to fetch api.json: ${o.statusText}`);
5
+ return await o.json();
6
+ }
7
+ export {
8
+ a as fetchApiJsonFromNpm
9
+ };
@@ -1,66 +1,97 @@
1
- import { ApiClassDeclaration, ApiClassField, ApiClassMethod, ApiCustomElementDeclaration, ApiFunctionDeclaration, ApiModule, ApiVariableDeclaration } from '../apiJson';
1
+ import type { ApiClassCallSignature, ApiClassConstructor, ApiClassDeclaration, ApiClassField, ApiClassMethod, ApiCustomElementDeclaration, ApiFunctionDeclaration, ApiInterfaceDeclaration, ApiMixinDeclaration, ApiModule, ApiVariableDeclaration } from "../apiJson.js";
2
+
2
3
  export interface ApiDiff {
3
- modules: ApiModuleDiff[];
4
+ modules: ApiModuleDiff[];
4
5
  }
6
+
5
7
  export interface ApiModuleDiff {
6
- path: ApiModule["path"];
7
- declarations: ApiDeclarationDiff[];
8
+ path: ApiModule["path"];
9
+ declarations: ApiDeclarationDiff[];
8
10
  }
11
+
9
12
  export interface ApiDiffBase {
10
- name: string;
11
- /**
12
- * True if this declaration was removed in the new api.json.
13
- * If class is removed, members are not listed.
14
- * @default false
15
- */
16
- removed?: true;
17
- /**
18
- * True if this declaration was added in the new api.json.
19
- * If class is added, members are not listed.
20
- *
21
- * @default false
22
- */
23
- added?: true;
24
- /**
25
- * Whether this declaration is deprecated in the new api.json, regardless of
26
- * whether it was deprecated in the old api.json.
27
- * If the value is a string, it's the reason for the deprecation.
28
- * Deprecated takes precedence over added.
29
- *
30
- * @default false
31
- */
32
- deprecated?: boolean | string;
13
+ name: string;
14
+ /**
15
+ * True if this declaration was removed in the new api.json.
16
+ * If class is removed, members are not listed.
17
+ *
18
+ * @default false
19
+ */
20
+ removed?: true;
21
+ /**
22
+ * True if this declaration was added in the new api.json.
23
+ * If class is added, members are not listed.
24
+ *
25
+ * @default false
26
+ */
27
+ added?: true;
28
+ /**
29
+ * Whether this declaration is deprecated in the new api.json, regardless of
30
+ * whether it was deprecated in the old api.json.
31
+ * If the value is a string, it's the reason for the deprecation.
32
+ * Deprecated takes precedence over added.
33
+ *
34
+ * @default false
35
+ */
36
+ deprecated?: boolean | string;
33
37
  }
34
- export type ApiDeclarationDiff = ApiClassDeclarationDiff | ApiCustomElementDeclarationDiff | ApiFunctionDeclarationDiff | ApiVariableDeclarationDiff;
38
+
39
+ export type ApiDeclarationDiff = ApiClassDeclarationDiff | ApiCustomElementDeclarationDiff | ApiFunctionDeclarationDiff | ApiInterfaceDeclarationDiff | ApiMixinDeclarationDiff | ApiVariableDeclarationDiff;
40
+
35
41
  export interface ApiClassDeclarationDiff extends ApiDiffBase {
36
- kind: ApiClassDeclaration["kind"];
37
- /**
38
- * Inherited members are not included in the diff.
39
- * Also, if entire class is added/removed, members are not included in the diff.
40
- */
41
- members?: ApiClassMemberDiff[];
42
- events?: ApiDiffBase[];
42
+ kind: ApiClassDeclaration["kind"];
43
+ /**
44
+ * Inherited members are not included in the diff.
45
+ * Also, if entire class is added/removed, members are not included in the diff.
46
+ */
47
+ members?: ApiClassMemberDiff[];
48
+ events?: ApiDiffBase[];
43
49
  }
50
+
51
+ export interface ApiInterfaceDeclarationDiff extends ApiDiffBase {
52
+ kind: ApiInterfaceDeclaration["kind"];
53
+ /**
54
+ * Inherited members are not included in the diff.
55
+ * Also, if entire class is added/removed, members are not included in the diff.
56
+ */
57
+ members?: ApiClassMemberDiff[];
58
+ }
59
+
60
+ export interface ApiMixinDeclarationDiff extends Omit<ApiClassDeclarationDiff, "kind"> {
61
+ kind: ApiMixinDeclaration["kind"];
62
+ }
63
+
44
64
  export interface ApiCustomElementDeclarationDiff extends ApiClassDeclarationDiff {
45
- /**
46
- * Attributes diff is not included as attributes are based on members.
47
- */
48
- tagName: ApiCustomElementDeclaration["tagName"];
49
- slots?: ApiDiffBase[];
50
- cssParts?: ApiDiffBase[];
51
- cssProperties?: ApiDiffBase[];
52
- cssStates?: ApiDiffBase[];
65
+ /** Attributes diff is not included as attributes are based on members. */
66
+ tagName: ApiCustomElementDeclaration["tagName"];
67
+ slots?: ApiDiffBase[];
68
+ cssParts?: ApiDiffBase[];
69
+ cssProperties?: ApiDiffBase[];
70
+ cssStates?: ApiDiffBase[];
53
71
  }
54
- export type ApiClassMemberDiff = ApiClassFieldDiff | ApiClassMethodDiff;
72
+
73
+ export type ApiClassMemberDiff = ApiClassCallSignatureDiff | ApiClassConstructorDiff | ApiClassFieldDiff | ApiClassMethodDiff;
74
+
55
75
  export interface ApiClassFieldDiff extends ApiDiffBase {
56
- kind: ApiClassField["kind"];
76
+ kind: ApiClassField["kind"];
57
77
  }
78
+
58
79
  export interface ApiClassMethodDiff extends ApiDiffBase {
59
- kind: ApiClassMethod["kind"];
80
+ kind: ApiClassMethod["kind"];
81
+ }
82
+
83
+ export interface ApiClassConstructorDiff extends Omit<ApiDiffBase, "name"> {
84
+ kind: ApiClassConstructor["kind"];
60
85
  }
86
+
87
+ export interface ApiClassCallSignatureDiff extends Omit<ApiDiffBase, "name"> {
88
+ kind: ApiClassCallSignature["kind"];
89
+ }
90
+
61
91
  export interface ApiFunctionDeclarationDiff extends ApiDiffBase {
62
- kind: ApiFunctionDeclaration["kind"];
92
+ kind: ApiFunctionDeclaration["kind"];
63
93
  }
94
+
64
95
  export interface ApiVariableDeclarationDiff extends ApiDiffBase {
65
- kind: ApiVariableDeclaration["kind"];
66
- }
96
+ kind: ApiVariableDeclaration["kind"];
97
+ }
@@ -0,0 +1,21 @@
1
+ export interface DiffTypesOptions {
2
+ /** Path to the original types folder. */
3
+ originalDtsPath: string;
4
+ /** Path to the new types folder. */
5
+ newDtsPath: string;
6
+ /**
7
+ * Path to the output markdown file.
8
+ *
9
+ * @default "types-diff.md"
10
+ */
11
+ outputMdPath: string;
12
+ /**
13
+ * Whether to truncate output if the diff is longer than 1000 lines.
14
+ *
15
+ * @default true
16
+ */
17
+ truncate?: boolean;
18
+ }
19
+
20
+ /** @param options */
21
+ export function diffTypes(options: DiffTypesOptions): Promise<void>;
@@ -0,0 +1,71 @@
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
+
26
+ `;
27
+ let f = g(r.split(`
28
+ `), n);
29
+ i && f.length > l && (o += `> [!WARNING]
30
+ > 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.
31
+
32
+ `, f = f.slice(0, l)), o += `${h(f)}
33
+
34
+ `, console.log(`Wrote diff to ${e}`);
35
+ }
36
+ await m(s.dirname(e), { recursive: !0 }), await d(e, o);
37
+ }
38
+ function g(t, n) {
39
+ for (let e = 0; e < t.length; ++e) {
40
+ const i = t[e];
41
+ if (
42
+ // Make diff smaller by excluding the `diff ...` lines
43
+ (i.startsWith(a) || // Redundant line - make file header smaller
44
+ i.startsWith("---") || // Not important
45
+ i === "\") && (t.splice(e, 1), e--), i.startsWith("+++")
46
+ ) {
47
+ const r = i.indexOf(" ");
48
+ let o = i.slice(4, r === -1 ? i.length : r);
49
+ o.startsWith(n) && (o = o.slice(n.length)), t[e] = `🟦 ${o}`;
50
+ }
51
+ }
52
+ return t;
53
+ }
54
+ const l = 1e3;
55
+ function h(t) {
56
+ const n = t.length, e = p(t.join(`
57
+ `));
58
+ return n <= 10 ? e : `<details><summary>See diff</summary>
59
+
60
+ ${e}
61
+
62
+ </details>`;
63
+ }
64
+ function p(t) {
65
+ return `\`\`\`diff
66
+ ${t}
67
+ \`\`\``;
68
+ }
69
+ export {
70
+ b as diffTypes
71
+ };
@@ -0,0 +1,74 @@
1
+ import type ts from "typescript";
2
+ import type { ApiModule } from "../apiJson.js";
3
+ import type { ApiExtractorConfig, ResolvedApiExtractorConfig } from "./config.js";
4
+ import type { ApiExtractorResult, ApiExtractorWatcher } from "./types.js";
5
+
6
+ /**
7
+ * ApiExtractor's main JavaScript entrypoint.
8
+ *
9
+ * @example
10
+ * ```js
11
+ *
12
+ * import { loadApiExtractorConfig, mergeApiExtractorConfigs } from "@arcgis/api-extractor/extractor/config";
13
+ * import { ApiExtractor } from "@arcgis/api-extractor/extractor/ApiExtractor";
14
+ *
15
+ * const baseConfig = await loadApiExtractorConfig(process.cwd(), "api-extractor.config.ts");
16
+ *
17
+ * // Optionally override parts of the config
18
+ * const mergedConfig = mergeApiExtractorConfigs(baseConfig, {
19
+ * types: {
20
+ * fullTypeCheck: true,
21
+ * },
22
+ * });
23
+ *
24
+ * const extractor = new ApiExtractor(mergedConfig);
25
+ *
26
+ * const { apiJson, dtsFiles } = await extractor.run();
27
+ * // OR, start a watcher:
28
+ * const watcher = await extractor.watch();
29
+ * ```
30
+ */
31
+ export class ApiExtractor {
32
+ constructor(rawConfig?: ApiExtractorConfig);
33
+ readonly config: ResolvedApiExtractorConfig;
34
+ /**
35
+ * Number of errors logged during the extraction process.
36
+ * Errors will be logged using the `config.logger.error` callback if provided.
37
+ * Otherwise, they will be logged using `console.error`.
38
+ *
39
+ * @default 0
40
+ */
41
+ errorCount: number;
42
+ /** @experimental */
43
+ moduleMap: Map<string, ApiModule>;
44
+ /**
45
+ * @experimental
46
+ * @example "https://developers.arcgis.com/javascript/latest/api-reference/esri-"
47
+ */
48
+ readonly normalizedApiReferencePrefix: string;
49
+ /**
50
+ * If doing typed extraction or full type check, this will be the ts.Program.
51
+ * If doing untyped watch, this will be a minimal Program-like object to reuse
52
+ * SourceFiles for unchanged files.
53
+ * Otherwise, undefined.
54
+ */
55
+ program?: {
56
+ getSourceFile: ts.Program["getSourceFile"];
57
+ getSourceFiles: ts.Program["getSourceFiles"];
58
+ getTypeChecker?: ts.Program["getTypeChecker"];
59
+ };
60
+ /**
61
+ * @deprecated
62
+ * @default 0
63
+ */
64
+ silencedBrokenLinkCount: number;
65
+ /** The high-level API for running the extractor on the current project. */
66
+ run(): Promise<ApiExtractorResult>;
67
+ /**
68
+ * The high-level API for starting a watch-mode extraction on the current project.
69
+ * When watching, double check that the configuration options the ApiExtractor
70
+ * was created with are appropriate for watch mode (disable full type check
71
+ * and type verifier if not necessary).
72
+ */
73
+ watch(): Promise<ApiExtractorWatcher>;
74
+ }
@@ -0,0 +1,9 @@
1
+ import "../typeScript-soMJqHns.js";
2
+ import { A as x } from "../ApiExtractor-DIfug_xm.js";
3
+ import "../worker-On5v54cw.js";
4
+ import "./processing/links.js";
5
+ import "typescript";
6
+ import "@arcgis/toolkit/function";
7
+ export {
8
+ x as ApiExtractor
9
+ };