@arcgis/codemod 6.0.0-next.3 → 6.0.0-next.30

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,459 +1,1070 @@
1
- var M = (o, e) => (e = Symbol[o]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + o), O = (o) => {
2
- throw TypeError(o);
1
+ var ee = (s, e) => (e = Symbol[s]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + s), te = (s) => {
2
+ throw TypeError(s);
3
3
  };
4
- var J = (o, e, t) => {
4
+ var ne = (s, e, t) => {
5
5
  if (e != null) {
6
- typeof e != "object" && typeof e != "function" && O("Object expected");
7
- var a, i;
8
- t && (a = e[M("asyncDispose")]), a === void 0 && (a = e[M("dispose")], t && (i = a)), typeof a != "function" && O("Object not disposable"), i && (a = function() {
6
+ typeof e != "object" && typeof e != "function" && te("Object expected");
7
+ var n, o;
8
+ t && (n = e[ee("asyncDispose")]), n === void 0 && (n = e[ee("dispose")], t && (o = n)), typeof n != "function" && te("Object not disposable"), o && (n = function() {
9
9
  try {
10
- i.call(this);
11
- } catch (s) {
12
- return Promise.reject(s);
10
+ o.call(this);
11
+ } catch (r) {
12
+ return Promise.reject(r);
13
13
  }
14
- }), o.push([t, a, e]);
15
- } else t && o.push([t]);
14
+ }), s.push([t, n, e]);
15
+ } else t && s.push([t]);
16
16
  return e;
17
- }, R = (o, e, t) => {
18
- var a = typeof SuppressedError == "function" ? SuppressedError : function(n, r, m, c) {
19
- return c = Error(m), c.name = "SuppressedError", c.error = n, c.suppressed = r, c;
20
- }, i = (n) => e = t ? new a(n, e, "An error was suppressed during disposal") : (t = !0, n), s = (n) => {
21
- for (; n = o.pop(); )
17
+ }, se = (s, e, t) => {
18
+ var n = typeof SuppressedError == "function" ? SuppressedError : function(i, d, l, c) {
19
+ return c = Error(l), c.name = "SuppressedError", c.error = i, c.suppressed = d, c;
20
+ }, o = (i) => e = t ? new n(i, e, "An error was suppressed during disposal") : (t = !0, i), r = (i) => {
21
+ for (; i = s.pop(); )
22
22
  try {
23
- var r = n[1] && n[1].call(n[2]);
24
- if (n[0]) return Promise.resolve(r).then(s, (m) => (i(m), s()));
25
- } catch (m) {
26
- i(m);
23
+ var d = i[1] && i[1].call(i[2]);
24
+ if (i[0]) return Promise.resolve(d).then(r, (l) => (o(l), r()));
25
+ } catch (l) {
26
+ o(l);
27
27
  }
28
28
  if (t) throw e;
29
29
  };
30
- return s();
30
+ return r();
31
31
  };
32
- import { c as H } from "./useProjectInstance.js";
33
- import { d as b, r as q } from "./cli.js";
34
- import { f as x } from "./log.js";
35
- import { path as v, toPosixPathSeparators as X } from "@arcgis/node-toolkit/path";
36
- import { log as Y } from "@arcgis/toolkit/log";
37
- import l from "typescript";
38
- import { g as A, a as Z, b as ee, c as te, d as w, e as oe, f as z, p as ne, i as ae, h as D, j, k as ie } from "./classification.js";
39
- import { s as se, g as W, a as re, b as ce, c as me } from "./hardcodedBehavior.js";
40
- import { styleText as k } from "node:util";
41
- import { loadCodeowners as le } from "@arcgis/node-toolkit/codeowners";
42
- import { f as pe } from "./format.js";
43
- function ue(o, e) {
32
+ import { c as be } from "./useProjectInstance.js";
33
+ import { d as V, r as ke, i as Ae, a as Pe, b as De } from "./cli.js";
34
+ import { f as I } from "./log.js";
35
+ import { path as $, toPosixPathSeparators as $e } from "@arcgis/node-toolkit/path";
36
+ import { log as R } from "@arcgis/toolkit/log";
37
+ import { forEachWithConcurrency as me } from "@arcgis/toolkit/promise";
38
+ import a from "typescript";
39
+ import { s as Ce, g as J, a as Ee, c as Le, p as Te } from "./artifact.js";
40
+ import { loadCodeowners as ue } from "@arcgis/node-toolkit/codeowners";
41
+ import { c as ie, s as U, g as Oe, a as oe, l as Fe, b as ge, d as fe, e as Ie, f as Me, h as Je } from "./componentAudit.js";
42
+ import { g as je, a as K, c as he, b as Re, d as ze, e as B, f as ae, h as Ue } from "./classification.js";
43
+ import { styleText as q } from "node:util";
44
+ import { f as ve } from "./format.js";
45
+ import { realpath as j, readFile as z } from "node:fs/promises";
46
+ import L from "semver";
47
+ import { asyncFindPath as ye } from "@arcgis/node-toolkit/file";
48
+ import { asyncRetrievePackageJson as We } from "@arcgis/node-toolkit/packageJson";
49
+ import { LineCounter as Ve, parseDocument as Be, isMap as Ke, isScalar as re } from "yaml";
50
+ function qe(s, e, t) {
44
51
  if (e === "json") {
45
- const t = A();
46
- process.stdout.write(`${Ne(o, le(), t)}
52
+ if (t !== void 0) {
53
+ process.stdout.write(`${JSON.stringify(t, void 0, 2)}
54
+ `);
55
+ return;
56
+ }
57
+ const n = J();
58
+ process.stdout.write(`${Xe(s, ue(), n)}
47
59
  `);
48
60
  return;
49
61
  }
50
62
  if (e === "md") {
51
- process.stdout.write(`${he(o)}
52
- `);
63
+ process.stdout.write(
64
+ `${t === void 0 ? Ye(s) : ve(t)}
65
+ `
66
+ );
53
67
  return;
54
68
  }
55
- process.stdout.write(`${ge(o)}
69
+ process.stdout.write(`${He(s)}
56
70
  `);
57
71
  }
58
- function ge(o) {
59
- const e = Q(o), t = e.reduce((i, s) => i + s.count, 0), a = [U("Deprecation summary", t)];
60
- for (const { categoryName: i, count: s, packages: n } of e) {
61
- a.push(`${b[i].label} (${s})`);
62
- for (const { packageName: r, count: m } of n)
63
- a.push(` ${K(r)} (${m})`);
72
+ function He(s) {
73
+ const e = xe(s), t = e.reduce((o, r) => o + r.count, 0), n = [ce("Deprecation summary", t)];
74
+ for (const { categoryName: o, count: r, packages: i } of e) {
75
+ n.push(`${V[o].label} (${r})`);
76
+ for (const { displayName: d, count: l } of i)
77
+ n.push(` ${le(d)} (${l})`);
64
78
  }
65
- a.push("", "", U("Deprecation details", t));
66
- for (const { categoryName: i, count: s, packages: n } of e) {
67
- const r = b[i];
68
- a.push("", `${r.label} (${s})`), "description" in r && a.push(` ${r.description}`);
69
- for (const { packageName: m, count: c, apis: u } of n) {
70
- a.push("", ` ${K(m)} (${c})`);
71
- for (const { api: p, reasons: g, items: d } of u) {
72
- const y = d[0].usage, h = Z({ api: p, memberOf: y.memberOf, apiKind: y.apiKind });
73
- a.push(` ${fe(h)}${ee(y.apiKind)} (${d.length})`);
74
- for (const f of g)
75
- a.push(de(f, 6));
76
- for (const { sourceFileName: f, usage: N } of ve(d))
77
- a.push(` ${x(f)}:${N.line}:${N.column}`);
79
+ n.push("", "", ce("Deprecation details", t));
80
+ for (const { categoryName: o, count: r, packages: i } of e) {
81
+ const d = V[o];
82
+ n.push("", `${d.label} (${r})`), "description" in d && n.push(` ${d.description}`);
83
+ for (const { displayName: l, count: c, apis: f } of i) {
84
+ n.push("", ` ${le(l)} (${c})`);
85
+ for (const { name: g, reasons: p, items: m } of f) {
86
+ const y = m[0].usage, h = Re({ name: g, memberOf: y.memberOf, kind: y.kind });
87
+ n.push(` ${Qe(h)}${ze(y.kind)} (${m.length})`);
88
+ for (const v of p)
89
+ n.push(Ge(v, 6));
90
+ for (const { sourceFileName: v, usage: w } of _e(m))
91
+ n.push(` ${I(v)}:${w.line}:${w.column}`);
78
92
  }
79
93
  }
80
94
  }
81
- return a.join(`
95
+ return n.join(`
82
96
  `);
83
97
  }
84
- function Q(o) {
85
- const e = [...o].flatMap(
86
- ([t, a]) => a.map((i) => ({ ...i, packageName: t }))
98
+ function xe(s) {
99
+ const e = [...s].flatMap(
100
+ ([t, n]) => n.map((o) => ({ ...o, packageName: t }))
87
101
  );
88
- return te(e, ({ packageName: t, usage: a }) => ({
102
+ return je(e, ({ packageName: t, usage: n }) => ({
89
103
  package: t,
90
- api: a.name,
91
- category: a.category,
92
- memberOf: a.memberOf,
93
- module: w(a.originFileNames, t),
94
- reason: a.reason ?? null
104
+ name: n.name,
105
+ kind: n.kind,
106
+ category: n.category,
107
+ memberOf: n.memberOf,
108
+ module: n.module ?? K(n.originFileNames, t),
109
+ deprecated: n.reason ?? !0
95
110
  }));
96
111
  }
97
- function U(o, e) {
98
- return k(["bold", "yellow"], `${o} (${e})`);
112
+ function ce(s, e) {
113
+ return q(["bold", "yellow"], `${s} (${e})`);
99
114
  }
100
- function K(o) {
101
- return k("blue", o);
115
+ function le(s) {
116
+ return q("blue", s);
102
117
  }
103
- function fe(o) {
104
- return k(["bold", "white"], o);
118
+ function Qe(s) {
119
+ return q(["bold", "white"], s);
105
120
  }
106
- function de(o, e) {
121
+ function Ge(s, e) {
107
122
  const t = " ".repeat(e);
108
- return o.split(/\r?\n/u).map((a) => `${t}${a}`).join(`
123
+ return s.split(/\r?\n/u).map((n) => `${t}${n}`).join(`
109
124
  `);
110
125
  }
111
- function ve(o) {
112
- return o.toSorted(
126
+ function _e(s) {
127
+ return s.toSorted(
113
128
  (e, t) => e.sourceFileName.localeCompare(t.sourceFileName) || e.usage.line - t.usage.line || e.usage.column - t.usage.column
114
129
  );
115
130
  }
116
- function ye(o) {
117
- return [...o].sort(([e], [t]) => e.localeCompare(t));
131
+ function Xe(s, e, t = J()) {
132
+ return JSON.stringify(H(s, e, t), void 0, 2);
118
133
  }
119
- function Ne(o, e, t = A()) {
120
- return JSON.stringify(V(o, e, t), void 0, 2);
134
+ function Ye(s, e = J()) {
135
+ return ve(H(s, void 0, e));
121
136
  }
122
- function he(o, e = A()) {
123
- return pe(V(o, void 0, e));
124
- }
125
- function V(o, e, t) {
126
- const a = Q(o);
137
+ function H(s, e, t, n) {
138
+ const o = xe(s);
127
139
  return {
128
- kind: "usages",
140
+ auditKind: "usages",
129
141
  repository: t.repository,
130
142
  ref: t.ref,
143
+ branch: t.branch,
144
+ scannerVersion: Ce,
145
+ scanDate: Date.now(),
146
+ ...n === void 0 ? {} : { complete: n },
131
147
  summary: {
132
- total: a.reduce((s, { count: n }) => s + n, 0),
133
- categories: a.map(({ categoryName: s, count: n, packages: r }) => ({
134
- category: s,
135
- label: b[s].label,
136
- count: n,
137
- packages: r.map(({ packageName: m, count: c }) => ({
138
- package: m,
139
- count: c
148
+ total: o.reduce((i, { count: d }) => i + d, 0),
149
+ categories: o.map(({ categoryName: i, count: d, packages: l }) => ({
150
+ category: i,
151
+ label: V[i].label,
152
+ count: d,
153
+ packages: l.map(({ packageName: c, displayName: f, count: g }) => ({
154
+ package: c,
155
+ ...f === c ? {} : { displayName: f },
156
+ count: g
140
157
  }))
141
158
  }))
142
159
  },
143
- findings: xe(o, e, t)
160
+ findings: Ze(s, e, t)
144
161
  };
145
162
  }
146
- function xe(o, e, t) {
147
- return ye(o).flatMap(
148
- ([a, i]) => i.map((s) => {
149
- const n = w(s.usage.originFileNames, a), r = {
150
- package: a,
151
- api: s.usage.name,
152
- category: s.usage.category,
153
- memberOf: s.usage.memberOf,
154
- module: n,
155
- reason: s.usage.reason ?? null
163
+ function Ze(s, e, t) {
164
+ return [...s].flatMap(
165
+ ([n, o]) => o.map((r) => {
166
+ const i = r.usage.module ?? K(r.usage.originFileNames, n), d = {
167
+ package: n,
168
+ name: r.usage.name,
169
+ category: r.usage.category,
170
+ memberOf: r.usage.memberOf,
171
+ module: i,
172
+ deprecated: r.usage.reason ?? !0
156
173
  };
157
174
  return {
158
- ...r,
159
- category: z(r),
160
- apiKind: s.usage.apiKind,
161
- memberOf: s.usage.memberOf,
162
- file: oe(s.sourceFileName, t.repositoryRoot),
163
- line: s.usage.line,
164
- column: s.usage.column,
165
- codeowners: e?.getOwners(s.sourceFileName) ?? []
175
+ ...d,
176
+ category: he(d),
177
+ kind: r.usage.kind,
178
+ memberOf: r.usage.memberOf,
179
+ file: Ee(r.sourceFileName, t.repositoryRoot),
180
+ line: r.usage.line,
181
+ column: r.usage.column,
182
+ codeowners: e?.getOwners(r.sourceFileName) ?? []
166
183
  };
167
184
  })
185
+ ).sort(Le);
186
+ }
187
+ function pe(s, e, t) {
188
+ const n = $.extname(s.fileName).slice(1).toLowerCase();
189
+ if (!e.hasDeprecatedApis && t === void 0 && n !== "html")
190
+ return [];
191
+ const o = "getLineAndCharacterOfPosition" in s ? (p) => s.getLineAndCharacterOfPosition(p) : nt(s.text), r = /* @__PURE__ */ new Map(), i = /\bdefine\s*(?:\.\s*amd\b|\[\s*(?:"amd"|'amd')\s*\])/u.test(s.text);
192
+ for (const p of s.text.matchAll(/(?<![-\w\u0080-\uFFFF])--[-\w\u0080-\uFFFF]+/gu)) {
193
+ const m = e.cssVariables.get(p[0]);
194
+ m !== void 0 && d(m, p.index, p[0].length);
195
+ }
196
+ if (n === "html") {
197
+ const p = /* @__PURE__ */ new Map();
198
+ if (ot({
199
+ contents: s.text,
200
+ scanElement: (m, y, h) => {
201
+ c(
202
+ m,
203
+ y,
204
+ h.map(({ name: v, start: w }) => ({ name: v, start: w }))
205
+ );
206
+ },
207
+ scanStyle: (m, y) => de(m, y, f),
208
+ scanScript: (m, y, h) => {
209
+ const v = h.find(({ name: N }) => N === "type")?.value?.trim().toLowerCase() ?? "";
210
+ if (h.some(({ name: N }) => N === "src") || ![
211
+ "",
212
+ "module",
213
+ "text/javascript",
214
+ "application/javascript",
215
+ "text/ecmascript",
216
+ "application/ecmascript"
217
+ ].includes(v.split(";")[0]))
218
+ return;
219
+ const w = `${s.fileName}.script-${p.size}.js`;
220
+ p.set(w, {
221
+ source: a.createSourceFile(
222
+ w,
223
+ v === "module" ? `${m}
224
+ export {};` : m,
225
+ a.ScriptTarget.Latest,
226
+ !0,
227
+ a.ScriptKind.JS
228
+ ),
229
+ offset: y
230
+ });
231
+ }
232
+ }), p.size > 0) {
233
+ const m = {
234
+ allowJs: !0,
235
+ noLib: !0,
236
+ noResolve: !0,
237
+ types: [],
238
+ target: a.ScriptTarget.Latest
239
+ }, h = a.createProgram([...p.keys()], m, {
240
+ ...a.createCompilerHost(m),
241
+ getSourceFile: (v) => p.get(v)?.source
242
+ }).getTypeChecker();
243
+ for (const { source: v, offset: w } of p.values())
244
+ g({ node: v, jsxSourceFile: v, typeChecker: h, offset: w });
245
+ }
246
+ } else n === "css" || n === "scss" || n === "sass" ? de(s.text, 0, f, n !== "css") : "kind" in s && g({ node: s, jsxSourceFile: s, typeChecker: t });
247
+ return [...r.values()].sort((p, m) => p.usage.start - m.usage.start);
248
+ function d(p, m, y) {
249
+ const { line: h, character: v } = o(m);
250
+ r.set(JSON.stringify([p.package, p.kind, p.memberOf, p.name, m]), {
251
+ packageName: p.package,
252
+ sourceFileName: s.fileName,
253
+ usage: {
254
+ name: p.name,
255
+ kind: p.kind,
256
+ memberOf: p.kind === "css-property" ? void 0 : p.memberOf,
257
+ module: p.module,
258
+ reason: p.reason,
259
+ originFileNames: [p.sourceFileName],
260
+ start: m,
261
+ length: y,
262
+ line: h + 1,
263
+ column: v + 1
264
+ }
265
+ });
266
+ }
267
+ function l(p, m, y) {
268
+ const h = e.components.get(p);
269
+ if (h?.length === 1)
270
+ return h[0].definitions.find((v) => et({ entry: v, tag: p, kind: m, name: y }));
271
+ }
272
+ function c(p, m, y) {
273
+ const h = l(p, "element", p);
274
+ h !== void 0 && d(h, m, p.length);
275
+ for (const v of y) {
276
+ const w = l(p, "attribute", v.name);
277
+ w !== void 0 && d(w, v.start, v.name.length);
278
+ }
279
+ }
280
+ function f(p, m, y, h) {
281
+ const v = l(p, m, y);
282
+ v !== void 0 && d(v, h, y.length);
283
+ }
284
+ function g({
285
+ node: p,
286
+ jsxSourceFile: m,
287
+ typeChecker: y,
288
+ offset: h = 0
289
+ }) {
290
+ const v = tt({ node: p, checker: y });
291
+ if (v !== void 0 && (v.text !== "define" || !i)) {
292
+ const w = h + v.getStart(m), { line: N, character: b } = o(w);
293
+ r.set(`amd:${w}`, {
294
+ packageName: "@arcgis/core",
295
+ sourceFileName: s.fileName,
296
+ usage: {
297
+ name: v.text,
298
+ kind: "function",
299
+ module: "amd",
300
+ reason: "require/define is deprecated. Use $arcgis.import() or ESM instead. See https://developers.arcgis.com/javascript/latest/get-started/",
301
+ originFileNames: [],
302
+ start: w,
303
+ length: v.getWidth(m),
304
+ line: N + 1,
305
+ column: b + 1
306
+ }
307
+ });
308
+ }
309
+ if (a.isJsxOpeningElement(p) || a.isJsxSelfClosingElement(p)) {
310
+ const w = p.tagName.getText(m), N = p.attributes.properties.filter(a.isJsxAttribute);
311
+ if (c(
312
+ w,
313
+ p.tagName.getStart(m),
314
+ N.map((b) => ({
315
+ name: b.name.getText(m),
316
+ start: b.name.getStart(m)
317
+ }))
318
+ ), /^[a-z][\w-]*$/u.test(w)) {
319
+ const b = N.find((A) => A.name.getText(m) === "slot"), k = b?.initializer, u = k !== void 0 && a.isJsxExpression(k) ? k.expression : k, x = b === void 0 ? -1 : p.attributes.properties.indexOf(b), S = p.attributes.properties.slice(x + 1).some(a.isJsxSpreadAttribute);
320
+ if (u !== void 0 && (a.isStringLiteral(u) || a.isNoSubstitutionTemplateLiteral(u)) && !S) {
321
+ const A = st(a.isJsxOpeningElement(p) ? p.parent : p, y), C = A === void 0 ? void 0 : l(A, "slot", u.text);
322
+ C !== void 0 && d(C, u.getStart(m) + 1, u.getWidth(m) - 2);
323
+ }
324
+ }
325
+ }
326
+ a.forEachChild(p, (w) => g({ node: w, jsxSourceFile: m, typeChecker: y, offset: h }));
327
+ }
328
+ }
329
+ function et({
330
+ entry: s,
331
+ tag: e,
332
+ kind: t,
333
+ name: n
334
+ }) {
335
+ const o = s.attribute;
336
+ if (t === "attribute" && o !== void 0) {
337
+ const r = o.tagName === e, i = o.name === n;
338
+ return r && i;
339
+ }
340
+ return s.kind !== t || s.name !== n ? !1 : t === "element" ? !0 : s.memberOf === e;
341
+ }
342
+ function tt({
343
+ node: s,
344
+ checker: e
345
+ }) {
346
+ if (e === void 0 || !a.isCallExpression(s))
347
+ return;
348
+ const t = s.expression;
349
+ let n, o;
350
+ if (a.isIdentifier(t))
351
+ n = t, o = t;
352
+ else if (a.isPropertyAccessExpression(t) && a.isIdentifier(t.name) && a.isIdentifier(t.expression) && ["window", "opener", "globalThis"].includes(t.expression.text))
353
+ n = t.name, o = t.expression;
354
+ else
355
+ return;
356
+ if (n.text !== "define" && n.text !== "require")
357
+ return;
358
+ if (n.text === "require") {
359
+ const i = s.arguments[0];
360
+ if (!(i !== void 0 && a.isArrayLiteralExpression(i)) && s.getSourceFile().fileName.toLowerCase().endsWith(".cjs") || i !== void 0 && a.isStringLiteralLike(i) && !i.text.startsWith("esri/"))
361
+ return;
362
+ }
363
+ return (e.getSymbolAtLocation(o)?.declarations ?? []).every(
364
+ (i) => a.isPropertyAccessExpression(t) && i.getSourceFile().isDeclarationFile
365
+ ) ? n : void 0;
366
+ }
367
+ function nt(s) {
368
+ const e = [
369
+ 0,
370
+ ...Array.from(s.matchAll(/\r\n|[\r\n\u2028\u2029]/gu), (t) => t.index + t[0].length)
371
+ ];
372
+ return (t) => {
373
+ let n = 0, o = e.length;
374
+ for (; n + 1 < o; ) {
375
+ const r = Math.floor((n + o) / 2);
376
+ e[r] <= t ? n = r : o = r;
377
+ }
378
+ return { line: n, character: t - e[n] };
379
+ };
380
+ }
381
+ function st(s, e) {
382
+ let t = s;
383
+ for (let n = t.parent; n !== void 0; t = n, n = n.parent) {
384
+ if (a.isJsxElement(n))
385
+ return n.openingElement.tagName.getText();
386
+ if (!(a.isJsxFragment(n) || a.isJsxExpression(n) || a.isParenthesizedExpression(n)) && !(a.isConditionalExpression(n) && t !== n.condition) && !(a.isBinaryExpression(n) && (n.operatorToken.kind === a.SyntaxKind.AmpersandAmpersandToken && t === n.right || n.operatorToken.kind === a.SyntaxKind.BarBarToken || n.operatorToken.kind === a.SyntaxKind.QuestionQuestionToken))) {
387
+ if (a.isReturnStatement(n)) {
388
+ const o = a.findAncestor(n, a.isFunctionLike);
389
+ if (o === void 0 || !a.isArrowFunction(o) && !a.isFunctionExpression(o))
390
+ return;
391
+ t = o.body, n = o;
392
+ }
393
+ if ((a.isArrowFunction(n) || a.isFunctionExpression(n)) && t === n.body) {
394
+ const o = n.parent;
395
+ if (!a.isCallExpression(o) || o.arguments[0] !== n || !a.isPropertyAccessExpression(o.expression) || o.expression.name.text !== "map")
396
+ return;
397
+ const r = o.expression.expression, i = e?.getTypeAtLocation(r);
398
+ if (!a.isArrayLiteralExpression(r) && (i === void 0 || !e.isArrayType(i) && !e.isTupleType(i)))
399
+ return;
400
+ t = n, n = o;
401
+ continue;
402
+ }
403
+ return;
404
+ }
405
+ }
406
+ }
407
+ function de(s, e, t, n = !1) {
408
+ const o = n ? /\/\*[\s\S]*?(?:\*\/|$)|"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\/\/[^\r\n]*/gu : /\/\*[\s\S]*?(?:\*\/|$)|"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'/gu, r = s.replace(o, (c) => c.replace(/[^\r\n]/gu, " ")), i = [];
409
+ let d = 0, l = 0;
410
+ for (const c of r.matchAll(/[{};]/gu)) {
411
+ const f = c.index;
412
+ if (l > 0) {
413
+ l += c[0] === "{" ? 1 : c[0] === "}" ? -1 : 0, d = f + 1;
414
+ continue;
415
+ }
416
+ if (c[0] === "}")
417
+ i.pop();
418
+ else if (c[0] === "{") {
419
+ const g = r.slice(d, f), p = i.at(-1) ?? [];
420
+ if (/^\s*--[\w-]+\s*:/u.test(g))
421
+ l = 1;
422
+ else if (g.trimStart().startsWith("@"))
423
+ i.push(p);
424
+ else {
425
+ const y = g.split(",").map((h) => h.trim()).flatMap(
426
+ (h) => p.length === 0 ? [h] : p.map(
427
+ (v) => h.includes("&") ? h.replaceAll("&", v) : `${v} ${h}`
428
+ )
429
+ );
430
+ for (const h of g.matchAll(/::part\(\s*([\w\s-]+?)\s*\)|:state\(\s*([\w-]+)\s*\)/gu)) {
431
+ const v = g.lastIndexOf(",", h.index) + 1, w = g.slice(v, h.index), b = (p.length === 0 ? [w] : p.map(
432
+ (S) => w.includes("&") ? w.replaceAll("&", S) : `${S} ${w}`
433
+ )).map(it);
434
+ if (b.includes(void 0) || new Set(b).size !== 1)
435
+ continue;
436
+ const k = h[1] === void 0 ? "css-state" : "css-part", u = h[1] ?? h[2], x = h.index + h[0].indexOf(u);
437
+ for (const S of u.matchAll(/[\w-]+/gu))
438
+ t(b[0], k, S[0], e + d + x + S.index);
439
+ }
440
+ i.push(y);
441
+ }
442
+ }
443
+ d = f + 1;
444
+ }
445
+ }
446
+ function it(s) {
447
+ const e = s.replace(/:state\([\w-]+\)/gu, "").trimStart();
448
+ return /(?:^|[\s>+~])([a-z][\w-]*)(?:[.#:][\w-]+|\[[^\]]*\])*$/iu.exec(e)?.[1]?.toLowerCase();
449
+ }
450
+ function ot({
451
+ contents: s,
452
+ scanElement: e,
453
+ scanStyle: t,
454
+ scanScript: n
455
+ }) {
456
+ const o = /<!--[\s\S]*?(?:-->|$)|<![^>]*>|<\/?([a-z][\w:-]*)\b((?:"[^"]*"|'[^']*'|[^'">])*)>/giu;
457
+ for (let r = o.exec(s); r !== null; r = o.exec(s)) {
458
+ if (r[1] === void 0 || r[0].startsWith("</"))
459
+ continue;
460
+ const i = r[1].toLowerCase(), d = r.index + 1 + r[1].length, l = [...r[2].matchAll(/([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'=<>`]+)))?/gu)].map(
461
+ (c) => ({
462
+ name: c[1].toLowerCase(),
463
+ start: d + c.index,
464
+ value: c[2] ?? c[3] ?? c[4]
465
+ })
466
+ );
467
+ if (e(i, r.index + 1, l), i === "plaintext")
468
+ break;
469
+ if (["script", "style", "textarea", "title", "xmp", "iframe", "noembed", "noframes"].includes(i)) {
470
+ const c = new RegExp(`</${i}\\s*>`, "giu");
471
+ c.lastIndex = o.lastIndex;
472
+ const f = c.exec(s);
473
+ i === "style" ? t(s.slice(o.lastIndex, f?.index ?? s.length), o.lastIndex) : i === "script" && n?.(s.slice(o.lastIndex, f?.index ?? s.length), o.lastIndex, l), o.lastIndex = f === null ? s.length : c.lastIndex;
474
+ }
475
+ }
476
+ }
477
+ const at = /[:/@\\]|^\.{1,2}$|\.(?:tgz|tar(?:\.gz)?)$/iu;
478
+ async function rt(s, e, t) {
479
+ const n = JSON.parse('["@arcgis/ai-components","@arcgis/api-extractor","@arcgis/arcade-parser","@arcgis/arcade-languageservice","@arcgis/charts-components","@arcgis/codemod","@arcgis/coding-components","@arcgis/common-components","@arcgis/core","@arcgis/lumina-toolkit","@arcgis/create","@arcgis/eslint-config","@arcgis/languages-api-utils","@arcgis/languages-sdk-spec","@arcgis/lumina","@arcgis/lumina-compiler","@arcgis/map-components","@arcgis/node-toolkit","@arcgis/portal-components","@arcgis/toolkit"]'), o = new Set(n), r = /* @__PURE__ */ new Set([...n, "@esri/calcite-components"]), i = [...new Map(s.map((g) => [g.filePath, g])).values()], d = new Set(
480
+ (await Promise.all(
481
+ i.map(async ({ filePath: g, contents: p }) => {
482
+ const m = [await j(g)], y = p.publishConfig?.directory;
483
+ if (typeof y == "string") {
484
+ const h = $.resolve($.dirname(g), y, "package.json");
485
+ a.sys.fileExists(h) && m.push(await j(h));
486
+ }
487
+ return m;
488
+ })
489
+ )).flat()
490
+ ), l = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), f = [];
491
+ await me(i, 4, async (g) => {
492
+ let p;
493
+ const m = [], y = {
494
+ ...g.contents.peerDependencies,
495
+ ...g.contents.optionalDependencies,
496
+ ...g.contents.devDependencies,
497
+ ...g.contents.dependencies
498
+ };
499
+ for (const [N, b] of Object.entries(y)) {
500
+ const k = b.replace(/^npm:/u, "");
501
+ if (!r.has(N) || !b.startsWith("catalog:") && at.test(k))
502
+ continue;
503
+ const u = await ye(
504
+ $.join("node_modules", N, "package.json"),
505
+ $.dirname(g.filePath)
506
+ );
507
+ if (u === void 0) {
508
+ (e === void 0 || N === e) && f.push(`${N} (${g.contents.name ?? g.filePath})`);
509
+ continue;
510
+ }
511
+ if (d.has(await j(u)))
512
+ continue;
513
+ const x = await We($.dirname(u));
514
+ !x.name || !x.version || !r.has(x.name) || m.push({ declared: b, location: u, name: x.name, version: x.version });
515
+ }
516
+ const h = Map.groupBy(
517
+ m.filter(({ name: N }) => o.has(N)),
518
+ ({ version: N }) => N
519
+ ), v = L.maxSatisfying([...h.keys()], "*", {
520
+ includePrerelease: !0
521
+ }), w = [...h].sort(([N], [b]) => N.localeCompare(b)).map(
522
+ ([N, b]) => `${N}: ${b.map(({ name: k }) => `\`${k}\``).sort().join(", ")}`
523
+ ).join("; ");
524
+ for (const { declared: N, location: b, name: k, version: u } of m) {
525
+ if (e !== void 0 && k !== e)
526
+ continue;
527
+ let x = l.get(k);
528
+ x === void 0 && (x = lt(k), l.set(k, x));
529
+ const S = await x;
530
+ S === void 0 && t?.();
531
+ const A = S === void 0 ? void 0 : dt(u, S), C = [];
532
+ A !== void 0 && C.push({
533
+ category: "outdatedDependencies",
534
+ targetVersion: A.expected,
535
+ reason: `Update to ${A.expected} (declared ${N}). ${A.reason}`
536
+ }), o.has(k) && v !== null && L.lt(u, v) && C.push({
537
+ category: "mismatchedDependencies",
538
+ targetVersion: v,
539
+ reason: `Web GIS SDK packages within the same package.json must use the same exact version (found ${w}).`
540
+ });
541
+ for (const { category: E, targetVersion: T, reason: P } of C) {
542
+ let D;
543
+ if (E === "outdatedDependencies" && N.startsWith("catalog:"))
544
+ try {
545
+ D = await ct(g.filePath, k, N);
546
+ } catch (O) {
547
+ t?.(), R(
548
+ "warn",
549
+ I(g.filePath),
550
+ `Unable to locate dependency catalog: ${String(O)}`
551
+ );
552
+ }
553
+ D === void 0 && (p ??= a.parseJsonText(g.filePath, await z(g.filePath, "utf8")));
554
+ const F = c.get(k) ?? [];
555
+ D !== void 0 && F.some(
556
+ (O) => O.sourceFileName === D.sourceFileName && O.usage.start === D.location.start && O.usage.category === E
557
+ ) || (F.push({
558
+ sourceFileName: D?.sourceFileName ?? g.filePath,
559
+ usage: {
560
+ name: `${u} => ${T}`,
561
+ category: E,
562
+ module: D === void 0 ? "package.json" : "pnpm-workspace.yaml",
563
+ originFileNames: [b],
564
+ reason: P,
565
+ ...D?.location ?? pt(p, k, N)
566
+ }
567
+ }), c.set(k, F));
568
+ }
569
+ }
570
+ });
571
+ for (const g of c.values())
572
+ g.sort(
573
+ (p, m) => p.sourceFileName.localeCompare(m.sourceFileName) || p.usage.start - m.usage.start
574
+ );
575
+ return f.length > 0 && (t?.(), f.sort(), R(
576
+ "warn",
577
+ "dependency-versions",
578
+ `Failed to find installed locations for ${f.length} dependencies: ${f.slice(0, 15).join(", ")}${f.length > 15 ? `, and ${f.length - 15} more` : ""}.`
579
+ )), c;
580
+ }
581
+ async function ct(s, e, t) {
582
+ const n = await ye("pnpm-workspace.yaml", $.dirname(s));
583
+ if (n === void 0)
584
+ throw new Error(`Missing pnpm-workspace.yaml for ${t}`);
585
+ const o = await j(n), r = new Ve(), i = Be(await z(o, "utf8"), { lineCounter: r });
586
+ if (i.errors.length > 0)
587
+ throw i.errors[0];
588
+ const d = t.slice(8), l = i.getIn(
589
+ d === "" || d === "default" ? ["catalog"] : ["catalogs", d],
590
+ !0
591
+ ), c = Ke(l) ? l.items.find(({ key: y }) => re(y) && y.value === e)?.key : void 0;
592
+ if (!re(c) || c.range === void 0)
593
+ throw new Error(`Missing ${e} in ${t} in ${o}`);
594
+ const [f, g] = c.range, { line: p, col: m } = r.linePos(f);
595
+ return { sourceFileName: o, location: { start: f, length: g - f, line: p, column: m } };
596
+ }
597
+ async function lt(s) {
598
+ try {
599
+ const e = await fetch(`https://registry.npmjs.org/-/package/${encodeURIComponent(s)}/dist-tags`, {
600
+ signal: AbortSignal.timeout(5e3),
601
+ redirect: "error"
602
+ });
603
+ if (!e.ok)
604
+ throw new Error(`Registry returned HTTP ${e.status}`);
605
+ const t = await e.json();
606
+ if (typeof t != "object" || t === null || Array.isArray(t))
607
+ throw new Error("Invalid registry dist-tags response");
608
+ const n = {};
609
+ for (const [o, r] of Object.entries(t))
610
+ ["latest", "rc", "next"].includes(o) && typeof r == "string" && L.valid(r) !== null && (n[o] = r);
611
+ if (Object.keys(n).length === 0)
612
+ throw new Error("Registry returned no supported release tags");
613
+ return n;
614
+ } catch (e) {
615
+ R("warn", s, `Dependency freshness unavailable: ${String(e)}`);
616
+ return;
617
+ }
618
+ }
619
+ function pt(s, e, t) {
620
+ const n = a.forEachChild(s, d), o = n.getStart(s), { line: r, character: i } = s.getLineAndCharacterOfPosition(o);
621
+ return { start: o, length: n.getWidth(s), line: r + 1, column: i + 1 };
622
+ function d(l) {
623
+ return a.isPropertyAssignment(l) && a.isStringLiteral(l.name) && ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"].includes(l.name.text) && a.isObjectLiteralExpression(l.initializer) ? l.initializer.properties.find(
624
+ (c) => a.isPropertyAssignment(c) && a.isStringLiteral(c.name) && c.name.text === e && a.isStringLiteral(c.initializer) && c.initializer.text === t
625
+ )?.name : a.forEachChild(l, d);
626
+ }
627
+ }
628
+ function dt(s, e) {
629
+ const t = L.parse(s), n = L.parse(e.latest ?? "");
630
+ if (t === null)
631
+ return;
632
+ if (
633
+ // Permit packages without latest dist-tag
634
+ n !== null && // Permit installed to be newer than latest
635
+ L.lt(t, n) && // Require using stable over prerelease
636
+ (t.prerelease.length > 0 || // Forbid major being behind stable
637
+ t.major !== n.major || // Forbid minor being behind stable
638
+ t.minor !== n.minor)
639
+ )
640
+ return {
641
+ expected: n.version,
642
+ reason: "A newer stable release is available. Prerelease versions are deprecated."
643
+ };
644
+ if (
645
+ // Enforce policy only for next.N prereleases
646
+ t.prerelease.length !== 2 || // Only enforce policy for -next
647
+ t.prerelease[0] !== "next"
648
+ )
649
+ return;
650
+ const o = t.prerelease[1];
651
+ if (typeof o != "number")
652
+ return;
653
+ const i = [e.next, e.rc].flatMap((d) => {
654
+ const l = L.parse(d ?? "");
655
+ return l !== null && // Support packages without latest dist-tag
656
+ (n === null || // Ignore rc dist-tag if it is behind latest
657
+ L.gt(l, n)) && // Require same major.minor.patch for -next version comparison
658
+ l.major === t.major && l.minor === t.minor && l.patch === t.patch && // Require next.N format for comparison
659
+ l.prerelease.length === 2 && l.prerelease[0] === "next" && typeof l.prerelease[1] == "number" ? [l] : [];
660
+ }).sort(L.rcompare).at(0);
661
+ if (i !== void 0 && Number(i.prerelease[1]) - o >= 30)
662
+ return {
663
+ expected: i.version,
664
+ reason: "Installed -next is significantly behind the most recent -next build."
665
+ };
666
+ }
667
+ const mt = /* @__PURE__ */ new Set(["none", "amd", "umd", "system", "systemjs", "node", "node10", "legacy"]), ut = /* @__PURE__ */ new Set(["node", "node10", "classic"]);
668
+ async function gt(s) {
669
+ const e = "es2024", t = [];
670
+ for (const n of [...new Set(s)].sort()) {
671
+ const o = a.parseJsonText(n, await z(n, "utf8"));
672
+ t.push(...ft(o, e));
673
+ }
674
+ return t;
675
+ }
676
+ function ft(s, e) {
677
+ const t = s.statements[0];
678
+ if (t === void 0 || !a.isExpressionStatement(t) || !a.isObjectLiteralExpression(t.expression))
679
+ return [];
680
+ const n = t.expression.properties.find(
681
+ (i) => a.isPropertyAssignment(i) && a.isStringLiteral(i.name) && i.name.text === "compilerOptions"
168
682
  );
683
+ if (n === void 0 || !a.isObjectLiteralExpression(n.initializer))
684
+ return [];
685
+ const o = a.convertCompilerOptionsFromJson({ target: e }, ".").options.target, r = [];
686
+ for (const i of n.initializer.properties) {
687
+ if (!a.isPropertyAssignment(i) || !a.isStringLiteral(i.name))
688
+ continue;
689
+ const d = i.name.text, l = a.isStringLiteral(i.initializer) ? i.initializer.text.toLowerCase() : void 0;
690
+ let c;
691
+ if (d === "module" && l !== void 0 && mt.has(l))
692
+ c = `The ${l} module setting is legacy or unsupported. Update to newer module setting. See https://webgis.esri.com/references/support-packages/typescript.`;
693
+ else if (d === "moduleResolution" && l !== void 0 && ut.has(l))
694
+ c = `The ${l} module resolution setting is deprecated or unsupported. Update to newer module setting. See https://webgis.esri.com/references/support-packages/typescript.`;
695
+ else if (d === "target" && l !== void 0) {
696
+ const m = a.convertCompilerOptionsFromJson({ target: l }, ".").options.target;
697
+ m !== void 0 && m < o && (c = `Targets below ${e} are older than Maps SDK's for JavaScript supported targets. See https://next.gha.afd.arcgis.com/javascript/latest/system-requirements/.`);
698
+ } else d === "ignoreDeprecations" && (c = "Address deprecations that were suppressed by ignoreDeprecations.");
699
+ if (c === void 0)
700
+ continue;
701
+ const f = i.name.getStart(s), { line: g, character: p } = s.getLineAndCharacterOfPosition(f);
702
+ r.push({
703
+ sourceFileName: s.fileName,
704
+ usage: {
705
+ name: `compilerOptions.${d}${l === void 0 ? "" : `: ${l}`}`,
706
+ category: "outdatedTypeScriptConfig",
707
+ module: "tsconfig.json",
708
+ originFileNames: [],
709
+ reason: c,
710
+ start: f,
711
+ length: i.name.getWidth(s),
712
+ line: g + 1,
713
+ column: p + 1
714
+ }
715
+ });
716
+ }
717
+ return r;
169
718
  }
170
- async function We(o, e) {
171
- await q(
719
+ async function Kt(s, e) {
720
+ if (e.reportingUrl && (s || e.esriOnly || e.category || e.packageName))
721
+ throw new Error("Reporting requires a complete, unfiltered repository scan.");
722
+ const t = e.outputFormat === "json" || e.reportingUrl ? process.cwd() === J().repositoryRoot : !1;
723
+ if (e.reportingUrl && !t)
724
+ throw new Error("Reporting requires scanning from the Git repository root.");
725
+ let n = !s && !e.esriOnly && !e.category && !e.packageName;
726
+ (e.outputFormat === "json" || e.reportingUrl) && (n &&= t), await ke(
172
727
  {
173
728
  meta: {
174
729
  needsTypeInformation: !0,
175
- needsFooter: !1
730
+ needsFooter: !1,
731
+ includeComponentFiles: !0,
732
+ includeTsConfigFiles: !0
176
733
  },
177
- run(t) {
178
- Se(t, e);
734
+ async run(o) {
735
+ await ht(o, e, n, s);
179
736
  }
180
737
  },
181
738
  "deprecations audit-usages",
182
- o
739
+ s
183
740
  );
184
741
  }
185
- function Se(o, e) {
186
- const t = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), i = [
742
+ async function ht(s, e, t, n) {
743
+ const o = /* @__PURE__ */ new Map(), r = Ie("warn", () => {
744
+ t = !1;
745
+ }), i = /* @__PURE__ */ new Map(), d = ie([]), l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), f = [
187
746
  ...new Map(
188
- o.flatMap(({ packageJson: p }) => {
189
- const g = p === void 0 ? void 0 : v.dirname(p.filePath), d = p?.contents.name;
190
- return g !== void 0 && d !== void 0 && S(g, process.cwd()) ? [[g, { root: g, name: d }]] : [];
747
+ s.flatMap(({ packageJson: u }) => {
748
+ const x = u === void 0 ? void 0 : $.dirname(u.filePath), S = u?.contents.name;
749
+ return x !== void 0 && S !== void 0 && M(x, process.cwd()) ? [[x, { root: x, name: S }]] : [];
191
750
  })
192
751
  ).values()
193
- ].toSorted((p, g) => g.root.length - p.root.length);
194
- for (const p of o) {
195
- var r = [];
752
+ ].toSorted((u, x) => x.root.length - u.root.length);
753
+ for (const u of s) {
754
+ var w = [];
196
755
  try {
197
- if (se(p.packageJson?.contents.name)) {
198
- const f = p.packageJson?.filePath;
199
- f !== void 0 && !a.has(f) && (a.add(f), Y(
756
+ if (U(u.packageJson?.contents.name)) {
757
+ const P = u.packageJson?.filePath;
758
+ P !== void 0 && !c.has(P) && (c.add(P), R(
200
759
  "warn",
201
- x(f),
202
- `Skipping excluded package \`${p.packageJson?.contents.name ?? p.cwd}\`.`
760
+ I(P),
761
+ `Skipping excluded package \`${u.packageJson?.contents.name ?? u.cwd}\`.`
203
762
  ));
204
763
  continue;
205
764
  }
206
- const g = J(r, H(p, !1));
207
- const d = g.tsMorph.getLanguageService().compilerObject;
208
- const y = d.getProgram()?.getTypeChecker();
209
- if (y === void 0)
765
+ if (u.filePaths.length === 0)
210
766
  continue;
211
- const h = p.packageJson === void 0 ? void 0 : v.dirname(p.packageJson.filePath);
212
- for (const f of g.getCodemodFiles()) {
213
- const N = f.compilerNode;
214
- for (const I of be(
215
- N,
216
- d,
217
- y,
218
- h,
219
- e.esriOnly
220
- )) {
221
- const T = Ee(I.originFileNames, i, h), L = t.get(T) ?? [];
222
- L.push({ sourceFileName: N.fileName, usage: I }), t.set(T, L);
767
+ const x = Oe(u.packageJson);
768
+ const S = await h(u.packageJson, x.packages);
769
+ const A = u.packageJson === void 0 ? void 0 : $.dirname(u.packageJson.filePath);
770
+ const C = ne(w, u.filePaths.some(Ae) ? be(u, !1, {
771
+ paths: { ...u.typeScriptConfig?.compilerOptions.paths, ...x.paths }
772
+ }) : void 0);
773
+ const E = C?.tsMorph.getLanguageService().compilerObject;
774
+ const T = E?.getProgram()?.getTypeChecker();
775
+ for (const P of C?.getCodemodFiles() ?? []) {
776
+ const D = P.compilerNode;
777
+ if (!oe(D.fileName)) {
778
+ if (E !== void 0 && T !== void 0) {
779
+ const F = yt(
780
+ D,
781
+ E,
782
+ T,
783
+ A,
784
+ e.esriOnly
785
+ );
786
+ for (const O of F) {
787
+ const Y = At(O.originFileNames, f, A), Z = o.get(Y) ?? [];
788
+ Z.push({ sourceFileName: D.fileName, usage: O }), o.set(Y, Z);
789
+ }
790
+ }
791
+ v(pe(D, S, T)), l.add(D.fileName);
223
792
  }
224
793
  }
225
- } catch (m) {
226
- var c = m, u = !0;
794
+ await me(u.filePaths, 8, async (P) => {
795
+ const D = P.toLowerCase().endsWith(".html");
796
+ if (l.has(P) || oe(P) || !S.hasDeprecatedApis && !D)
797
+ return;
798
+ const F = await z(P, "utf8");
799
+ v(pe({ fileName: P, text: F }, S)), l.add(P);
800
+ });
801
+ } catch (N) {
802
+ var b = N, k = !0;
227
803
  } finally {
228
- R(r, c, u);
804
+ se(w, b, k);
229
805
  }
230
806
  }
231
- const s = Pe(t, e);
232
- ue(s, e.outputFormat);
233
- const n = [...s.values()].flat();
234
- ne(
235
- "usages",
236
- n.length,
237
- new Set(n.map(({ sourceFileName: p }) => p)).size,
238
- s.size
807
+ const g = await rt(
808
+ s.flatMap(
809
+ ({ packageJson: u }) => u === void 0 || U(u.contents.name) ? [] : [u]
810
+ ),
811
+ e.packageName,
812
+ () => {
813
+ t = !1;
814
+ }
239
815
  );
816
+ for (const [u, x] of g)
817
+ o.set(u, [...o.get(u) ?? [], ...x]);
818
+ if (!e.esriOnly && (e.packageName === void 0 || e.packageName === "typescript") && (e.category === void 0 || e.category === "outdatedTypeScriptConfig")) {
819
+ const u = s.flatMap(
820
+ ({ typeScriptConfig: S, packageJson: A }) => S !== void 0 && !U(A?.contents.name) && M(S.filePath, process.cwd()) && (n === void 0 || n === S.filePath) ? [S.filePath] : []
821
+ ), x = await gt(u);
822
+ x.length > 0 && o.set("typescript", [...o.get("typescript") ?? [], ...x]);
823
+ }
824
+ const p = vt(o, e), m = e.reportingUrl || e.outputFormat === "json" ? H(p, ue(), J(), t) : void 0;
825
+ qe(p, e.outputFormat, m);
826
+ const y = [...p.values()].flat();
827
+ Te(
828
+ "usages",
829
+ y.length,
830
+ new Set(y.map(({ sourceFileName: u }) => u)).size,
831
+ p.size
832
+ ), e.reportingUrl && m !== void 0 && await Pe(m, e.reportingUrl);
833
+ async function h(u, x) {
834
+ if (u === void 0)
835
+ return d;
836
+ let S = i.get(u.filePath);
837
+ return S === void 0 && (S = ie(
838
+ await Fe(u, r, e.esriOnly, x)
839
+ ), i.set(u.filePath, S)), S;
840
+ }
841
+ function v(u) {
842
+ for (const { packageName: x, sourceFileName: S, usage: A } of u) {
843
+ if (ge(A.name, A.reason))
844
+ continue;
845
+ const C = o.get(x) ?? [], E = C.findIndex(
846
+ (P) => P.sourceFileName === S && P.usage.start === A.start && P.usage.length === A.length
847
+ ), T = { sourceFileName: S, usage: A };
848
+ E === -1 ? C.push(T) : C[E] = T, o.set(x, C);
849
+ }
850
+ }
240
851
  }
241
- function Pe(o, e) {
852
+ function vt(s, e) {
242
853
  const t = /* @__PURE__ */ new Map();
243
- for (const [a, i] of o) {
244
- if (e.packageName !== void 0 && a !== e.packageName)
854
+ for (const [n, o] of s) {
855
+ if (e.packageName !== void 0 && n !== e.packageName)
245
856
  continue;
246
- const s = i.filter(
247
- ({ usage: n }) => e.category === void 0 || z({
248
- package: a,
249
- api: n.name,
250
- category: n.category,
251
- memberOf: n.memberOf,
252
- module: w(n.originFileNames, a),
253
- reason: n.reason ?? null
857
+ const r = o.filter(
858
+ ({ usage: i }) => e.category === void 0 || he({
859
+ package: n,
860
+ name: i.name,
861
+ category: i.category,
862
+ memberOf: i.memberOf,
863
+ module: i.module ?? K(i.originFileNames, n),
864
+ deprecated: i.reason ?? !0
254
865
  }) === e.category
255
866
  );
256
- s.length > 0 && t.set(a, s);
867
+ r.length > 0 && t.set(n, r);
257
868
  }
258
869
  return t;
259
870
  }
260
- function be(o, e, t, a, i = !1) {
261
- const s = /* @__PURE__ */ new Map();
262
- for (const n of e.getSuggestionDiagnostics(o.fileName)) {
263
- if (n.reportsDeprecated === void 0)
871
+ function yt(s, e, t, n, o = !1) {
872
+ const r = /* @__PURE__ */ new Map();
873
+ for (const i of e.getSuggestionDiagnostics(s.fileName)) {
874
+ if (i.reportsDeprecated === void 0)
264
875
  continue;
265
- const r = _(o, n.start, n.start + n.length);
876
+ const d = we(s, i.start, i.start + i.length);
266
877
  if (
267
878
  // Don't report for imports, only for usages
268
- l.findAncestor(r, l.isImportDeclaration) !== void 0 || // Don't report closing JSX - only for opening
269
- l.findAncestor(r, l.isJsxClosingElement) !== void 0
879
+ a.findAncestor(d, a.isImportDeclaration) !== void 0 || // Don't report closing JSX - only for opening
880
+ a.findAncestor(d, a.isJsxClosingElement) !== void 0
270
881
  )
271
882
  continue;
272
- const m = we(r, t), c = m.reason === void 0 ? [] : $(m.symbol), u = c.length > 0 ? void 0 : e.getDefinitionAtPosition(o.fileName, n.start), p = c.length > 0 ? c : [...new Set(u?.map(({ fileName: g }) => g))];
273
- E(p, i, a) && C(s, o, {
274
- start: n.start,
275
- length: n.length,
276
- ...ke(r, m, t, e, u?.[0]),
277
- originFileNames: p,
278
- reason: Ce(e, o.fileName, n.start) ?? m.reason
883
+ const l = St(d, t), c = l.reason === void 0 ? [] : Q(l.symbol), f = c.length > 0 ? void 0 : e.getDefinitionAtPosition(s.fileName, i.start), g = c.length > 0 ? c : [...new Set(f?.map(({ fileName: p }) => p))];
884
+ _(g, o, n) && G(r, s, {
885
+ start: i.start,
886
+ length: i.length,
887
+ ...Nt(d, l, t, e, f?.[0]),
888
+ originFileNames: g,
889
+ reason: kt(e, s.fileName, i.start) ?? l.reason
279
890
  });
280
891
  }
281
- return De(o, t, s, a, i), [...s.values()].toSorted((n, r) => n.start - r.start);
282
- }
283
- function De(o, e, t, a, i) {
284
- function s(n) {
285
- l.isNewExpression(n) && Ae(n, e, t, a, i);
286
- let r, m;
287
- if (l.isJsxAttribute(n) && l.isIdentifier(n.name)) {
288
- const c = n.parent.parent;
289
- (l.isJsxOpeningElement(c) || l.isJsxSelfClosingElement(c)) && (m = e.getContextualType(c.tagName)?.getProperty(n.name.text), r = n.name);
290
- } else if ((l.isPropertyAssignment(n) || l.isShorthandPropertyAssignment(n) || l.isMethodDeclaration(n)) && l.isObjectLiteralExpression(n.parent)) {
291
- const c = l.isComputedPropertyName(n.name) ? P(n.name.expression, e) : n.name.text, u = e.getContextualType(n.parent);
292
- m = c === void 0 || u === void 0 ? void 0 : e.getNonNullableType(u).getProperty(c), r = n.name;
293
- } else if (l.isPropertyAccessExpression(n))
294
- m = e.getSymbolAtLocation(n.name), r = n.name;
295
- else if (l.isElementAccessExpression(n)) {
296
- const c = P(n.argumentExpression, e);
297
- m = c === void 0 ? void 0 : e.getTypeAtLocation(n.expression).getProperty(c), r = n.argumentExpression;
298
- } else if (l.isBindingElement(n) && l.isObjectBindingPattern(n.parent) && n.dotDotDotToken === void 0) {
299
- const c = n.propertyName ?? (l.isIdentifier(n.name) ? n.name : void 0), u = c === void 0 ? void 0 : l.isComputedPropertyName(c) ? P(c.expression, e) : c.text;
300
- m = u === void 0 ? void 0 : e.getTypeAtLocation(n.parent).getProperty(u), r = c;
892
+ return xt(s, t, r, n, o), [...r.values()].toSorted((i, d) => i.start - d.start);
893
+ }
894
+ function xt(s, e, t, n, o) {
895
+ function r(i) {
896
+ a.isNewExpression(i) && wt(i, e, t, n, o);
897
+ let d, l;
898
+ if (a.isJsxAttribute(i) && a.isIdentifier(i.name)) {
899
+ const c = i.parent.parent;
900
+ (a.isJsxOpeningElement(c) || a.isJsxSelfClosingElement(c)) && (l = e.getContextualType(c.tagName)?.getProperty(i.name.text), d = i.name);
901
+ } else if ((a.isPropertyAssignment(i) || a.isShorthandPropertyAssignment(i) || a.isMethodDeclaration(i)) && a.isObjectLiteralExpression(i.parent)) {
902
+ const c = a.isComputedPropertyName(i.name) ? W(i.name.expression, e) : i.name.text, f = e.getContextualType(i.parent);
903
+ l = c === void 0 || f === void 0 ? void 0 : e.getNonNullableType(f).getProperty(c), d = i.name;
904
+ } else if (a.isPropertyAccessExpression(i))
905
+ l = e.getSymbolAtLocation(i.name), d = i.name;
906
+ else if (a.isElementAccessExpression(i)) {
907
+ const c = W(i.argumentExpression, e);
908
+ l = c === void 0 ? void 0 : e.getTypeAtLocation(i.expression).getProperty(c), d = i.argumentExpression;
909
+ } else if (a.isBindingElement(i) && a.isObjectBindingPattern(i.parent) && i.dotDotDotToken === void 0) {
910
+ const c = i.propertyName ?? (a.isIdentifier(i.name) ? i.name : void 0), f = c === void 0 ? void 0 : a.isComputedPropertyName(c) ? W(c.expression, e) : c.text;
911
+ l = f === void 0 ? void 0 : e.getTypeAtLocation(i.parent).getProperty(f), d = c;
301
912
  }
302
- if ((l.isPropertyAccessExpression(n) || l.isElementAccessExpression(n) || l.isBindingElement(n)) && !m?.declarations?.some(
303
- (c) => l.isGetAccessorDeclaration(c) || l.isSetAccessorDeclaration(c)
304
- ) && (m = void 0), m !== void 0 && r !== void 0) {
305
- const c = B(m, e), u = $(m);
306
- c !== void 0 && E(u, i, a) && C(t, o, {
307
- start: r.getStart(o),
308
- length: r.getWidth(o),
309
- name: m.getName(),
310
- ...D(m.declarations?.[0]),
311
- originFileNames: u,
913
+ if ((a.isPropertyAccessExpression(i) || a.isElementAccessExpression(i) || a.isBindingElement(i)) && !l?.declarations?.some(
914
+ (c) => a.isGetAccessorDeclaration(c) || a.isSetAccessorDeclaration(c)
915
+ ) && (l = void 0), l !== void 0 && d !== void 0) {
916
+ const c = Ne(l, e), f = Q(l);
917
+ c !== void 0 && _(f, o, n) && G(t, s, {
918
+ start: d.getStart(s),
919
+ length: d.getWidth(s),
920
+ name: l.getName(),
921
+ ...B(l.declarations?.[0]),
922
+ originFileNames: f,
312
923
  reason: c
313
924
  });
314
925
  }
315
- l.forEachChild(n, s);
926
+ a.forEachChild(i, r);
316
927
  }
317
- s(o);
928
+ r(s);
318
929
  }
319
- function Ae(o, e, t, a, i) {
320
- const s = e.getTypeAtLocation(o).getSymbol(), n = s?.declarations?.[0], r = n !== void 0 && (l.isClassDeclaration(n) || l.isInterfaceDeclaration(n)) ? n.name?.text : void 0, m = r === void 0 ? void 0 : ie.get(r);
321
- if (m === void 0 || r === void 0)
930
+ function wt(s, e, t, n, o) {
931
+ const r = e.getTypeAtLocation(s).getSymbol(), i = r?.declarations?.[0], d = i !== void 0 && (a.isClassDeclaration(i) || a.isInterfaceDeclaration(i)) ? i.name?.text : void 0, l = d === void 0 ? void 0 : Ue.get(d);
932
+ if (l === void 0 || d === void 0)
322
933
  return;
323
- const c = $(s);
934
+ const c = Q(r);
324
935
  if (!c.some(
325
- (g) => (F(g) ?? W(v.dirname(g), "")) === "@arcgis/core"
326
- ) || !E(c, i, a))
936
+ (p) => (X(p) ?? fe($.dirname(p), "")) === "@arcgis/core"
937
+ ) || !_(c, o, n))
327
938
  return;
328
- const u = l.isPropertyAccessExpression(o.expression) ? o.expression.name : o.expression, p = o.getSourceFile();
329
- C(t, p, {
330
- start: u.getStart(p),
331
- length: u.getWidth(p),
332
- name: r,
333
- apiKind: "class",
939
+ const f = a.isPropertyAccessExpression(s.expression) ? s.expression.name : s.expression, g = s.getSourceFile();
940
+ G(t, g, {
941
+ start: f.getStart(g),
942
+ length: f.getWidth(g),
943
+ name: d,
944
+ kind: "class",
334
945
  category: "coreViews",
335
946
  originFileNames: c,
336
- reason: `Direct construction with new ${r}() is discouraged. Use \`<${m}>\` instead. In 6.0, directly constructed views will no longer include .ui; use component slots for UI.`
947
+ reason: `Direct construction with new ${d}() is discouraged. Use \`<${l}>\` instead. In 6.0, directly constructed views will no longer include .ui; use component slots for UI.`
337
948
  });
338
949
  }
339
- function P(o, e) {
340
- const t = e.getTypeAtLocation(o);
950
+ function W(s, e) {
951
+ const t = e.getTypeAtLocation(s);
341
952
  return t.isStringLiteral() || t.isNumberLiteral() ? String(t.value) : void 0;
342
953
  }
343
- function we(o, e) {
344
- let t = e.getSymbolAtLocation(o);
345
- for (; t !== void 0 && (t.flags & l.SymbolFlags.Alias) !== 0; ) {
346
- const a = B(t, e);
347
- if (a !== void 0)
348
- return { symbol: t, reason: a };
954
+ function St(s, e) {
955
+ let t = e.getSymbolAtLocation(s);
956
+ for (; t !== void 0 && (t.flags & a.SymbolFlags.Alias) !== 0; ) {
957
+ const n = Ne(t, e);
958
+ if (n !== void 0)
959
+ return { symbol: t, reason: n };
349
960
  t = t.declarations === void 0 ? void 0 : e.getImmediateAliasedSymbol(t);
350
961
  }
351
962
  return { symbol: t, reason: void 0 };
352
963
  }
353
- function $(o) {
354
- return [...new Set(o?.declarations?.map((e) => e.getSourceFile().fileName))];
964
+ function Q(s) {
965
+ return [...new Set(s?.declarations?.map((e) => e.getSourceFile().fileName))];
355
966
  }
356
- function ke(o, e, t, a, i) {
967
+ function Nt(s, e, t, n, o) {
357
968
  if (e.reason !== void 0)
358
969
  return {
359
- name: j(e.symbol.declarations?.[0], e.symbol.getName()),
360
- ...D(e.symbol.declarations?.[0])
970
+ name: ae(e.symbol.declarations?.[0], e.symbol.getName()),
971
+ ...B(e.symbol.declarations?.[0])
361
972
  };
362
- const s = i === void 0 ? void 0 : a.getProgram()?.getSourceFile(i.fileName), n = i === void 0 || s === void 0 ? void 0 : _(
363
- s,
364
- i.textSpan.start,
365
- i.textSpan.start + i.textSpan.length
366
- ), r = (n === void 0 ? void 0 : t.getSymbolAtLocation(n)?.declarations?.[0]) ?? e.symbol?.declarations?.[0], m = i?.name;
973
+ const r = o === void 0 ? void 0 : n.getProgram()?.getSourceFile(o.fileName), i = o === void 0 || r === void 0 ? void 0 : we(
974
+ r,
975
+ o.textSpan.start,
976
+ o.textSpan.start + o.textSpan.length
977
+ ), d = (i === void 0 ? void 0 : t.getSymbolAtLocation(i)?.declarations?.[0]) ?? e.symbol?.declarations?.[0], l = o?.name;
367
978
  return {
368
- name: m === void 0 ? $e(o) : j(r, m),
369
- ...D(r)
979
+ name: l === void 0 ? bt(s) : ae(d, l),
980
+ ...B(d)
370
981
  };
371
982
  }
372
- function S(o, e) {
373
- const t = v.relative(e, o);
374
- return t !== "" && !t.startsWith("../") && !v.isAbsolute(t) && t !== "node_modules" && !t.startsWith("node_modules/");
983
+ function M(s, e) {
984
+ const t = $.relative(e, s);
985
+ return t !== "" && !t.startsWith("../") && !$.isAbsolute(t) && t !== "node_modules" && !t.startsWith("node_modules/");
375
986
  }
376
- function _(o, e, t) {
377
- let a = o;
987
+ function we(s, e, t) {
988
+ let n = s;
378
989
  for (; ; ) {
379
- let i;
380
- if (l.forEachChild(a, (s) => {
381
- i === void 0 && s.getStart(o) <= e && s.getEnd() >= t && (i = s);
382
- }), i === void 0)
383
- return a;
384
- a = i;
990
+ let o;
991
+ if (a.forEachChild(n, (r) => {
992
+ o === void 0 && r.getStart(s) <= e && r.getEnd() >= t && (o = r);
993
+ }), o === void 0)
994
+ return n;
995
+ n = o;
385
996
  }
386
997
  }
387
- function $e(o) {
388
- return l.isIdentifier(o) || l.isPrivateIdentifier(o) || l.isStringLiteralLike(o) || l.isNumericLiteral(o) ? o.text : o.getText();
998
+ function bt(s) {
999
+ return a.isIdentifier(s) || a.isPrivateIdentifier(s) || a.isStringLiteralLike(s) || a.isNumericLiteral(s) ? s.text : s.getText();
389
1000
  }
390
- function G(o) {
391
- const e = o?.find(({ name: t }) => t === "deprecated");
392
- return e === void 0 ? void 0 : me(e.text) ?? "";
1001
+ function Se(s) {
1002
+ const e = s?.find(({ name: t }) => t === "deprecated");
1003
+ return e === void 0 ? void 0 : Je(e.text) ?? "";
393
1004
  }
394
- function Ce(o, e, t) {
1005
+ function kt(s, e, t) {
395
1006
  try {
396
- return G(o.getQuickInfoAtPosition(e, t)?.tags);
1007
+ return Se(s.getQuickInfoAtPosition(e, t)?.tags);
397
1008
  } catch {
398
1009
  return;
399
1010
  }
400
1011
  }
401
- function B(o, e) {
1012
+ function Ne(s, e) {
402
1013
  try {
403
- const t = G(o?.getJsDocTags(e));
1014
+ const t = Se(s?.getJsDocTags(e));
404
1015
  if (t !== void 0)
405
1016
  return t;
406
- const a = o?.declarations?.filter((i) => l.isGetAccessorDeclaration(i) || l.isSetAccessorDeclaration(i)).map((i) => l.getJSDocDeprecatedTag(i)).find((i) => i !== void 0);
407
- return a === void 0 ? void 0 : a.comment === void 0 ? "" : ce(a.comment);
1017
+ const n = s?.declarations?.filter((o) => a.isGetAccessorDeclaration(o) || a.isSetAccessorDeclaration(o)).map((o) => a.getJSDocDeprecatedTag(o)).find((o) => o !== void 0);
1018
+ return n === void 0 ? void 0 : n.comment === void 0 ? "" : Me(n.comment);
408
1019
  } catch {
409
1020
  return;
410
1021
  }
411
1022
  }
412
- function C(o, e, t) {
413
- if (re(t.name, t.reason))
1023
+ function G(s, e, t) {
1024
+ if (ge(t.name, t.reason))
414
1025
  return;
415
- const { line: a, character: i } = e.getLineAndCharacterOfPosition(t.start);
416
- o.set(`${t.start}:${t.length}`, {
1026
+ const { line: n, character: o } = e.getLineAndCharacterOfPosition(t.start);
1027
+ s.set(`${t.start}:${t.length}`, {
417
1028
  ...t,
418
- line: a + 1,
419
- column: i + 1
1029
+ line: n + 1,
1030
+ column: o + 1
420
1031
  });
421
1032
  }
422
- function E(o, e, t) {
423
- return o.some((a) => t !== void 0 && S(a, t)) ? !1 : !e || o.some((a) => {
424
- const i = F(a);
425
- return i === void 0 ? t === void 0 || !S(a, t) : ae(i);
1033
+ function _(s, e, t) {
1034
+ return s.some((n) => t !== void 0 && M(n, t)) ? !1 : !e || s.some((n) => {
1035
+ const o = X(n);
1036
+ return o === void 0 ? t === void 0 || !M(n, t) : De(o);
426
1037
  });
427
1038
  }
428
- function F(o) {
429
- const e = X(o), t = "/node_modules/", a = e.lastIndexOf(t);
430
- if (a === -1)
1039
+ function X(s) {
1040
+ const e = $e(s), t = "/node_modules/", n = e.lastIndexOf(t);
1041
+ if (n === -1)
431
1042
  return;
432
- const [i, s] = e.slice(a + t.length).split("/");
433
- return i.startsWith("@") ? `${i}/${s}` : i;
1043
+ const [o, r] = e.slice(n + t.length).split("/");
1044
+ return o.startsWith("@") ? `${o}/${r}` : o;
434
1045
  }
435
- function Ee(o, e = [], t) {
436
- const a = o[0];
437
- if (a === void 0)
1046
+ function At(s, e = [], t) {
1047
+ const n = s[0];
1048
+ if (n === void 0)
438
1049
  return "unknown package";
439
- const i = F(a);
440
- if (i !== void 0)
441
- return i;
442
- const s = e.find(({ root: p }) => S(a, p));
443
- if (s !== void 0)
444
- return s.name;
445
- const n = v.dirname(x(a)), r = W(v.dirname(a), n);
446
- if (r !== n)
447
- return r;
1050
+ const o = X(n);
1051
+ if (o !== void 0)
1052
+ return o;
1053
+ const r = e.find(({ root: g }) => M(n, g));
1054
+ if (r !== void 0)
1055
+ return r.name;
1056
+ const i = $.dirname(I(n)), d = fe($.dirname(n), i);
1057
+ if (d !== i)
1058
+ return d;
448
1059
  if (t === void 0)
449
- return n;
450
- const c = v.relative(t, a).split("/"), u = c.findIndex((p) => p !== "..");
451
- return u < 1 ? v.dirname(x(a)) : c.slice(0, u * 2).join("/");
1060
+ return i;
1061
+ const c = $.relative(t, n).split("/"), f = c.findIndex((g) => g !== "..");
1062
+ return f < 1 ? $.dirname(I(n)) : c.slice(0, f * 2).join("/");
452
1063
  }
453
1064
  export {
454
- We as auditDeprecatedUsages,
455
- be as collectDeprecatedApiUsages,
456
- Ee as getDeprecationOriginLabel,
457
- F as getNodeModulesPackageName,
458
- E as shouldIncludeDeprecation
1065
+ Kt as auditDeprecatedUsages,
1066
+ yt as collectDeprecatedApiUsages,
1067
+ At as getDeprecationOriginLabel,
1068
+ X as getNodeModulesPackageName,
1069
+ _ as shouldIncludeDeprecation
459
1070
  };