@arcgis/api-extractor 5.0.0-next.8 → 5.0.0-next.9

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 CHANGED
@@ -115,6 +115,12 @@ export type ApiJavaScriptModule = {
115
115
  * Whether the module is deprecated.
116
116
  * If the value is a string, it's the reason for the deprecation.
117
117
  *
118
+ * @remarks
119
+ * If module is marked as deprecated, all its declarations should also be
120
+ * marked as deprecated. This is because in TypeScript, a usage of a
121
+ * declaration will only be marked as deprecated if the declaration itself
122
+ * is marked as deprecated, rather than its module.
123
+ *
118
124
  * @default false
119
125
  */
120
126
  deprecated?: boolean | string;
@@ -283,10 +289,6 @@ export type ApiCustomElementDeclaration = Omit<ApiClassDeclaration, "members"> &
283
289
  * "attributes" is not necessary.
284
290
  */
285
291
  attributes?: ApiAttribute[];
286
- /**
287
- * The events that this element fires.
288
- */
289
- events?: ApiEvent[];
290
292
  /**
291
293
  * The shadow dom content slots that this element accepts.
292
294
  */
@@ -736,6 +738,10 @@ export type ApiClassDeclaration = {
736
738
  */
737
739
  mixins?: ApiReference[];
738
740
  members?: ApiClassMember[];
741
+ /**
742
+ * The events that this element fires.
743
+ */
744
+ events?: ApiEvent[];
739
745
  /**
740
746
  * @remarks
741
747
  * Not used by `@arcgis/api-extractor`. Preserved in typings for compatibility
@@ -0,0 +1,3 @@
1
+ import { ApiJson } from '../apiJson';
2
+ import { ApiDiff } from './types';
3
+ export declare function diffApiJson(oldApiJson: Pick<ApiJson, "modules">, newApiJson: Pick<ApiJson, "modules">): ApiDiff;
@@ -0,0 +1,7 @@
1
+ import { ApiJson } from '../apiJson';
2
+ /**
3
+ * Read dist/docs/api.json for a given NPM package.
4
+ *
5
+ * @example fetchApiJsonFromNpm("@arcgis/map-components", "latest");
6
+ */
7
+ export declare function fetchApiJsonFromNpm(packageName: string, semverVersion: string): Promise<ApiJson>;
@@ -0,0 +1,3 @@
1
+ export { fetchApiJsonFromNpm } from './fetchApiJsonFromNpm';
2
+ export { diffApiJson } from './diffApiJson';
3
+ export type * from './types';
@@ -0,0 +1,66 @@
1
+ import { ApiClassDeclaration, ApiClassField, ApiClassMethod, ApiCustomElementDeclaration, ApiFunctionDeclaration, ApiModule, ApiVariableDeclaration } from '../apiJson';
2
+ export interface ApiDiff {
3
+ modules: ApiModuleDiff[];
4
+ }
5
+ export interface ApiModuleDiff {
6
+ path: ApiModule["path"];
7
+ declarations: ApiDeclarationDiff[];
8
+ }
9
+ 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;
33
+ }
34
+ export type ApiDeclarationDiff = ApiClassDeclarationDiff | ApiCustomElementDeclarationDiff | ApiFunctionDeclarationDiff | ApiVariableDeclarationDiff;
35
+ 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[];
43
+ }
44
+ 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[];
53
+ }
54
+ export type ApiClassMemberDiff = ApiClassFieldDiff | ApiClassMethodDiff;
55
+ export interface ApiClassFieldDiff extends ApiDiffBase {
56
+ kind: ApiClassField["kind"];
57
+ }
58
+ export interface ApiClassMethodDiff extends ApiDiffBase {
59
+ kind: ApiClassMethod["kind"];
60
+ }
61
+ export interface ApiFunctionDeclarationDiff extends ApiDiffBase {
62
+ kind: ApiFunctionDeclaration["kind"];
63
+ }
64
+ export interface ApiVariableDeclarationDiff extends ApiDiffBase {
65
+ kind: ApiVariableDeclaration["kind"];
66
+ }
package/dist/diff.js ADDED
@@ -0,0 +1,147 @@
1
+ async function b(d, i) {
2
+ const o = await fetch(`https://unpkg.com/${d}@${i}/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
+ function M(d, i) {
8
+ const o = new Map(d.modules.map((e) => [e.path, e])), t = [];
9
+ for (const e of i.modules) {
10
+ const a = o.get(e.path), s = D(a, e, !0);
11
+ s !== void 0 && t.push(s), o.delete(e.path);
12
+ }
13
+ for (const e of o.values()) {
14
+ const a = D(void 0, e, !1);
15
+ a !== void 0 && t.push(a);
16
+ }
17
+ return { modules: t };
18
+ }
19
+ function D(d, i, o) {
20
+ const t = [], e = p(d?.declarations ?? []), a = p(i.declarations ?? []);
21
+ for (const s of a.values()) {
22
+ const n = s.at(-1), l = "tagName" in n ? n.tagName : void 0, v = l ?? n.name, u = e.get(v);
23
+ e.delete(v);
24
+ const h = u === void 0 && !o ? !0 : void 0, m = o && // Only mark as deprecated if all overloads are deprecated
25
+ (s.length === 1 || s.every((r) => r.deprecated !== void 0)) ? n.deprecated : void 0, g = !m && u === void 0 && o ? !0 : void 0;
26
+ if (h || g) {
27
+ t.push({
28
+ kind: n.kind,
29
+ name: n.name,
30
+ tagName: l,
31
+ members: void 0,
32
+ removed: h,
33
+ added: g,
34
+ deprecated: m
35
+ });
36
+ continue;
37
+ } else if (!o)
38
+ continue;
39
+ if ("tagName" in n) {
40
+ const r = u?.[0], c = {
41
+ kind: n.kind,
42
+ name: n.name,
43
+ tagName: n.tagName,
44
+ deprecated: m,
45
+ added: void 0,
46
+ removed: void 0,
47
+ members: k(r?.members, n.members),
48
+ events: f(r?.events, n.events),
49
+ slots: f(r?.slots, n.slots),
50
+ cssParts: f(r?.cssParts, n.cssParts),
51
+ cssProperties: f(r?.cssProperties, n.cssProperties),
52
+ cssStates: f(r?.cssStates, n.cssStates)
53
+ };
54
+ (m !== void 0 || c.members !== void 0 || c.events !== void 0 || c.slots !== void 0 || c.cssParts !== void 0 || c.cssProperties !== void 0 || c.cssStates !== void 0) && t.push(c);
55
+ } else if (n.kind === "class") {
56
+ const r = u?.[0], c = {
57
+ kind: n.kind,
58
+ name: n.name,
59
+ deprecated: m,
60
+ added: void 0,
61
+ removed: void 0,
62
+ members: k(r?.members, n.members),
63
+ events: f(r?.events, n.events)
64
+ };
65
+ (m !== void 0 || c.members !== void 0 || c.events !== void 0) && t.push(c);
66
+ } else m !== void 0 && t.push({
67
+ kind: n.kind,
68
+ name: n.name,
69
+ deprecated: m,
70
+ added: void 0,
71
+ removed: void 0
72
+ });
73
+ }
74
+ if (o)
75
+ for (const [s] of e.values())
76
+ t.push({
77
+ kind: s.kind,
78
+ name: s.name,
79
+ tagName: "tagName" in s ? s.tagName : void 0,
80
+ members: void 0,
81
+ removed: !0,
82
+ added: void 0,
83
+ deprecated: void 0
84
+ });
85
+ if (t.length !== 0)
86
+ return {
87
+ path: i.path,
88
+ declarations: t
89
+ };
90
+ }
91
+ function p(d) {
92
+ const i = /* @__PURE__ */ new Map();
93
+ for (let o = 0; o < d.length; o++) {
94
+ const t = d[o], e = "tagName" in t ? t.tagName : t.name, a = i.get(e);
95
+ a === void 0 ? i.set(e, [t]) : a.push(t);
96
+ }
97
+ return i;
98
+ }
99
+ function f(d, i) {
100
+ const o = p(d ?? []), t = [];
101
+ if (i !== void 0)
102
+ for (const e of i)
103
+ o.get(e.name) === void 0 ? t.push({
104
+ name: e.name,
105
+ added: !0
106
+ }) : e.deprecated && t.push({
107
+ name: e.name,
108
+ deprecated: e.deprecated
109
+ }), o.delete(e.name);
110
+ for (const [e] of o.values())
111
+ t.push({
112
+ name: e.name,
113
+ removed: !0
114
+ });
115
+ return t.length ? t : void 0;
116
+ }
117
+ function k(d, i) {
118
+ const o = p(d ?? []), t = p(i ?? []), e = [];
119
+ for (const a of t.values()) {
120
+ const s = a.at(-1), n = o.get(s.name);
121
+ o.delete(s.name);
122
+ const l = (
123
+ // Only mark as deprecated if all overloads are deprecated
124
+ a.length === 1 || a.every((v) => v.deprecated !== void 0) ? s.deprecated : void 0
125
+ );
126
+ l ? e.push({
127
+ kind: s.kind,
128
+ name: s.name,
129
+ deprecated: l
130
+ }) : n === void 0 && e.push({
131
+ kind: s.kind,
132
+ name: s.name,
133
+ added: !0
134
+ });
135
+ }
136
+ for (const [a] of o.values())
137
+ e.push({
138
+ kind: a.kind,
139
+ name: a.name,
140
+ removed: !0
141
+ });
142
+ return e.length ? e : void 0;
143
+ }
144
+ export {
145
+ M as diffApiJson,
146
+ b as fetchApiJsonFromNpm
147
+ };
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import c from "typescript";
2
2
  import { path as y } from "@arcgis/components-build-utils";
3
3
  import T, { supportsColorStderr as S } from "chalk";
4
4
  import { mappedFind as D } from "@arcgis/toolkit/array";
5
- const m = "@arcgis/api-extractor", E = "5.0.0-next.8", H = (t) => t.kind === "method", q = (t) => t.kind === "field";
5
+ const m = "@arcgis/api-extractor", E = "5.0.0-next.9", H = (t) => t.kind === "method", q = (t) => t.kind === "field";
6
6
  function k(t, e) {
7
7
  const s = t.path.split("/"), n = s.pop(), o = s.join("/"), i = e.path.split("/"), r = i.pop(), a = i.join("/");
8
8
  return o === a ? n < r ? -1 : 1 : o.startsWith(a) ? 1 : a.startsWith(o) || o < a ? -1 : 1;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@arcgis/api-extractor",
3
- "version": "5.0.0-next.8",
3
+ "version": "5.0.0-next.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "exports": {
9
9
  ".": "./dist/index.js",
10
+ "./diff": "./dist/diff/index.js",
10
11
  "./package.json": "./package.json"
11
12
  },
12
13
  "files": [
@@ -14,8 +15,8 @@
14
15
  ],
15
16
  "license": "SEE LICENSE IN LICENSE.md",
16
17
  "dependencies": {
17
- "@arcgis/components-build-utils": "5.0.0-next.8",
18
- "@arcgis/toolkit": "5.0.0-next.8",
18
+ "@arcgis/components-build-utils": "5.0.0-next.9",
19
+ "@arcgis/toolkit": "5.0.0-next.9",
19
20
  "chalk": "^5.4.1",
20
21
  "tslib": "^2.8.1",
21
22
  "typescript": "~5.8.3"