@arcgis/codemod 6.0.0-next.2 → 6.0.0-next.21

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,404 +1,1070 @@
1
- var C = (t, o) => (o = Symbol[t]) ? o : /* @__PURE__ */ Symbol.for("Symbol." + t), I = (t) => {
2
- throw TypeError(t);
1
+ var ee = (s, e) => (e = Symbol[s]) ? e : /* @__PURE__ */ Symbol.for("Symbol." + s), te = (s) => {
2
+ throw TypeError(s);
3
3
  };
4
- var F = (t, o, e) => {
5
- if (o != null) {
6
- typeof o != "object" && typeof o != "function" && I("Object expected");
7
- var n, r;
8
- e && (n = o[C("asyncDispose")]), n === void 0 && (n = o[C("dispose")], e && (r = n)), typeof n != "function" && I("Object not disposable"), r && (n = function() {
4
+ var ne = (s, e, t) => {
5
+ if (e != null) {
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
- r.call(this);
11
- } catch (a) {
12
- return Promise.reject(a);
10
+ o.call(this);
11
+ } catch (r) {
12
+ return Promise.reject(r);
13
13
  }
14
- }), t.push([e, n, o]);
15
- } else e && t.push([e]);
16
- return o;
17
- }, R = (t, o, e) => {
18
- var n = typeof SuppressedError == "function" ? SuppressedError : function(i, s, l, u) {
19
- return u = Error(l), u.name = "SuppressedError", u.error = i, u.suppressed = s, u;
20
- }, r = (i) => o = e ? new n(i, o, "An error was suppressed during disposal") : (e = !0, i), a = (i) => {
21
- for (; i = t.pop(); )
14
+ }), s.push([t, n, e]);
15
+ } else t && s.push([t]);
16
+ return e;
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 s = i[1] && i[1].call(i[2]);
24
- if (i[0]) return Promise.resolve(s).then(a, (l) => (r(l), a()));
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
25
  } catch (l) {
26
- r(l);
26
+ o(l);
27
27
  }
28
- if (e) throw o;
28
+ if (t) throw e;
29
29
  };
30
- return a();
30
+ return r();
31
31
  };
32
- import { c as _ } from "./useProjectInstance.js";
33
- import { d as P, r as Q } from "./cli.js";
34
- import { f as y } from "./log.js";
35
- import { path as d, toPosixPathSeparators as H } from "@arcgis/node-toolkit/path";
36
- import { log as q } from "@arcgis/toolkit/log";
37
- import f from "typescript";
38
- import { g as D, a as G, s as K, p as V, b as X, c as Y, d as Z } from "./hardcodedBehavior.js";
39
- import { f as B, c as T, g as ee, i as te } from "./format.js";
40
- import { styleText as w } from "node:util";
41
- import { loadCodeowners as oe } from "@arcgis/node-toolkit/codeowners";
42
- function ne(t, o) {
43
- if (o === "json") {
44
- const e = D();
45
- process.stdout.write(`${le(t, oe(), 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) {
51
+ if (e === "json") {
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)}
46
59
  `);
47
60
  return;
48
61
  }
49
- if (o === "md") {
50
- process.stdout.write(`${ue(t)}
51
- `);
62
+ if (e === "md") {
63
+ process.stdout.write(
64
+ `${t === void 0 ? Ye(s) : ve(t)}
65
+ `
66
+ );
52
67
  return;
53
68
  }
54
- process.stdout.write(`${ae(t)}
69
+ process.stdout.write(`${He(s)}
55
70
  `);
56
71
  }
57
- function ae(t) {
58
- const o = L(t), e = o.reduce((r, a) => r + a.count, 0), n = [J("Deprecation summary", e)];
59
- for (const { categoryName: r, count: a, packages: i } of o) {
60
- n.push(`${P[r].label} (${a})`);
61
- for (const { packageName: s, count: l } of i)
62
- n.push(` ${M(s)} (${l})`);
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})`);
63
78
  }
64
- n.push("", "", J("Deprecation details", e));
65
- for (const { categoryName: r, count: a, packages: i } of o) {
66
- const s = P[r];
67
- n.push("", `${s.label} (${a})`), "description" in s && n.push(` ${s.description}`);
68
- for (const { packageName: l, count: u, apis: p } of i) {
69
- n.push("", ` ${M(l)} (${u})`);
70
- for (const { api: c, reasons: m, items: g } of p) {
71
- n.push(` ${ie(c)} (${g.length})`);
72
- for (const v of m)
73
- n.push(re(v, 6));
74
- for (const { sourceFileName: v, usage: h } of se(g))
75
- n.push(` ${y(v)}:${h.line}:${h.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}`);
76
92
  }
77
93
  }
78
94
  }
79
95
  return n.join(`
80
96
  `);
81
97
  }
82
- function L(t) {
83
- const o = [...t].flatMap(
84
- ([e, n]) => n.map((r) => ({ ...r, packageName: e }))
98
+ function xe(s) {
99
+ const e = [...s].flatMap(
100
+ ([t, n]) => n.map((o) => ({ ...o, packageName: t }))
85
101
  );
86
- return ee(o, ({ packageName: e, usage: n }) => ({
87
- packageName: e,
88
- api: n.name,
89
- reason: n.reason
102
+ return je(e, ({ packageName: t, usage: n }) => ({
103
+ package: t,
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
90
110
  }));
91
111
  }
92
- function J(t, o) {
93
- return w(["bold", "yellow"], `${t} (${o})`);
112
+ function ce(s, e) {
113
+ return q(["bold", "yellow"], `${s} (${e})`);
94
114
  }
95
- function M(t) {
96
- return w("blue", t);
115
+ function le(s) {
116
+ return q("blue", s);
97
117
  }
98
- function ie(t) {
99
- return w(["bold", "white"], t);
118
+ function Qe(s) {
119
+ return q(["bold", "white"], s);
100
120
  }
101
- function re(t, o) {
102
- const e = " ".repeat(o);
103
- return t.split(/\r?\n/u).map((n) => `${e}${n}`).join(`
121
+ function Ge(s, e) {
122
+ const t = " ".repeat(e);
123
+ return s.split(/\r?\n/u).map((n) => `${t}${n}`).join(`
104
124
  `);
105
125
  }
106
- function se(t) {
107
- return t.toSorted(
108
- (o, e) => o.sourceFileName.localeCompare(e.sourceFileName) || o.usage.line - e.usage.line || o.usage.column - e.usage.column
126
+ function _e(s) {
127
+ return s.toSorted(
128
+ (e, t) => e.sourceFileName.localeCompare(t.sourceFileName) || e.usage.line - t.usage.line || e.usage.column - t.usage.column
109
129
  );
110
130
  }
111
- function ce(t) {
112
- return [...t].sort(([o], [e]) => o.localeCompare(e));
113
- }
114
- function le(t, o, e = D()) {
115
- return JSON.stringify(E(t, o, e), void 0, 2);
131
+ function Xe(s, e, t = J()) {
132
+ return JSON.stringify(H(s, e, t), void 0, 2);
116
133
  }
117
- function ue(t, o = D()) {
118
- return B(E(t, void 0, o));
134
+ function Ye(s, e = J()) {
135
+ return ve(H(s, void 0, e));
119
136
  }
120
- function E(t, o, e) {
121
- const n = L(t);
137
+ function H(s, e, t, n) {
138
+ const o = xe(s);
122
139
  return {
123
- kind: "usages",
124
- repository: e.repository,
125
- ref: e.ref,
140
+ auditKind: "usages",
141
+ repository: t.repository,
142
+ ref: t.ref,
143
+ branch: t.branch,
144
+ scannerVersion: Ce,
145
+ scanDate: Date.now(),
146
+ ...n === void 0 ? {} : { complete: n },
126
147
  summary: {
127
- total: n.reduce((a, { count: i }) => a + i, 0),
128
- categories: n.map(({ categoryName: a, count: i, packages: s }) => ({
129
- category: a,
130
- label: P[a].label,
131
- count: i,
132
- packages: s.map(({ packageName: l, count: u }) => ({
133
- package: l,
134
- count: u
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
135
157
  }))
136
158
  }))
137
159
  },
138
- findings: ce(t).flatMap(
139
- ([a, i]) => i.map((s) => ({
140
- category: T({
141
- packageName: a,
142
- api: s.usage.name,
143
- reason: s.usage.reason
144
- }),
145
- package: a,
146
- api: s.usage.name,
147
- reason: s.usage.reason ?? null,
148
- file: G(s.sourceFileName, e.repositoryRoot),
149
- line: s.usage.line,
150
- column: s.usage.column,
151
- codeowners: o?.getOwners(s.sourceFileName) ?? []
152
- }))
153
- )
160
+ findings: Ze(s, e, t)
154
161
  };
155
162
  }
156
- async function Me(t, o) {
157
- await Q(
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
173
+ };
174
+ return {
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) ?? []
183
+ };
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"
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;
718
+ }
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(
158
727
  {
159
728
  meta: {
160
729
  needsTypeInformation: !0,
161
- needsFooter: !1
730
+ needsFooter: !1,
731
+ includeComponentFiles: !0,
732
+ includeTsConfigFiles: !0
162
733
  },
163
- run(e) {
164
- fe(e, o);
734
+ async run(o) {
735
+ await ht(o, e, n, s);
165
736
  }
166
737
  },
167
738
  "deprecations audit-usages",
168
- t
739
+ s
169
740
  );
170
741
  }
171
- function fe(t, o) {
172
- const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), r = [
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 = [
173
746
  ...new Map(
174
- t.flatMap(({ packageJson: c }) => {
175
- const m = c === void 0 ? void 0 : d.dirname(c.filePath), g = c?.contents.name;
176
- return m !== void 0 && g !== void 0 && k(m, process.cwd()) ? [[m, { root: m, name: g }]] : [];
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 }]] : [];
177
750
  })
178
751
  ).values()
179
- ].toSorted((c, m) => m.root.length - c.root.length);
180
- for (const c of t) {
181
- var s = [];
752
+ ].toSorted((u, x) => x.root.length - u.root.length);
753
+ for (const u of s) {
754
+ var w = [];
182
755
  try {
183
- if (K(c.packageJson?.contents.name)) {
184
- const N = c.packageJson?.filePath;
185
- N !== void 0 && !n.has(N) && (n.add(N), q(
756
+ if (U(u.packageJson?.contents.name)) {
757
+ const P = u.packageJson?.filePath;
758
+ P !== void 0 && !c.has(P) && (c.add(P), R(
186
759
  "warn",
187
- y(N),
188
- `Skipping excluded package \`${c.packageJson?.contents.name ?? c.cwd}\`.`
760
+ I(P),
761
+ `Skipping excluded package \`${u.packageJson?.contents.name ?? u.cwd}\`.`
189
762
  ));
190
763
  continue;
191
764
  }
192
- const m = F(s, _(c, !1));
193
- const g = m.tsMorph.getLanguageService().compilerObject;
194
- const v = g.getProgram()?.getTypeChecker();
195
- if (v === void 0)
765
+ if (u.filePaths.length === 0)
196
766
  continue;
197
- const h = c.packageJson === void 0 ? void 0 : d.dirname(c.packageJson.filePath);
198
- for (const N of m.getCodemodFiles()) {
199
- const A = N.compilerNode;
200
- for (const b of pe(
201
- A,
202
- g,
203
- v,
204
- h,
205
- o.esriOnly
206
- )) {
207
- const $ = Pe(b.originFileNames, r, h), x = e.get($) ?? [];
208
- x.push({ sourceFileName: A.fileName, usage: b }), e.set($, x);
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);
209
792
  }
210
793
  }
211
- } catch (l) {
212
- var u = l, p = !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;
213
803
  } finally {
214
- R(s, u, p);
804
+ se(w, b, k);
215
805
  }
216
806
  }
217
- const a = me(e, o);
218
- ne(a, o.outputFormat);
219
- const i = [...a.values()].flat();
220
- V(
221
- "usages",
222
- i.length,
223
- new Set(i.map(({ sourceFileName: c }) => c)).size,
224
- a.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
+ }
225
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
+ }
226
851
  }
227
- function me(t, o) {
228
- const e = /* @__PURE__ */ new Map();
229
- for (const [n, r] of t) {
230
- if (o.packageName !== void 0 && n !== o.packageName)
852
+ function vt(s, e) {
853
+ const t = /* @__PURE__ */ new Map();
854
+ for (const [n, o] of s) {
855
+ if (e.packageName !== void 0 && n !== e.packageName)
231
856
  continue;
232
- const a = r.filter(
233
- ({ usage: i }) => o.category === void 0 || T({ packageName: n, api: i.name, reason: i.reason }) === o.category
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
865
+ }) === e.category
234
866
  );
235
- a.length > 0 && e.set(n, a);
867
+ r.length > 0 && t.set(n, r);
236
868
  }
237
- return e;
869
+ return t;
238
870
  }
239
- function pe(t, o, e, n, r = !1) {
240
- const a = /* @__PURE__ */ new Map();
241
- for (const i of o.getSuggestionDiagnostics(t.fileName)) {
871
+ function yt(s, e, t, n, o = !1) {
872
+ const r = /* @__PURE__ */ new Map();
873
+ for (const i of e.getSuggestionDiagnostics(s.fileName)) {
242
874
  if (i.reportsDeprecated === void 0)
243
875
  continue;
244
- const s = he(t, i.start, i.start + i.length);
876
+ const d = we(s, i.start, i.start + i.length);
245
877
  if (
246
878
  // Don't report for imports, only for usages
247
- f.findAncestor(s, f.isImportDeclaration) !== void 0 || // Don't report closing JSX - only for opening
248
- f.findAncestor(s, f.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
249
881
  )
250
882
  continue;
251
- const l = de(
252
- s,
253
- e,
254
- o,
255
- t.fileName,
256
- i.start
257
- );
258
- U(l, r, n) && z(a, t, {
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, {
259
885
  start: i.start,
260
886
  length: i.length,
261
- name: Ne(s, e, o, t.fileName, i.start) ?? ye(s),
262
- originFileNames: l,
263
- reason: ke(o, t.fileName, i.start) ?? Se(s, e)
887
+ ...Nt(d, l, t, e, f?.[0]),
888
+ originFileNames: g,
889
+ reason: kt(e, s.fileName, i.start) ?? l.reason
264
890
  });
265
891
  }
266
- return ge(t, e, a, n, r), [...a.values()].toSorted((i, s) => i.start - s.start);
267
- }
268
- function ge(t, o, e, n, r) {
269
- function a(i) {
270
- if (f.isJsxAttribute(i) && f.isIdentifier(i.name)) {
271
- const s = i.parent.parent;
272
- if (f.isJsxOpeningElement(s) || f.isJsxSelfClosingElement(s)) {
273
- const u = o.getContextualType(s.tagName)?.getProperty(i.name.text), p = S(u, o), c = j(u);
274
- p !== void 0 && U(c, r, n) && z(e, t, {
275
- start: i.name.getStart(t),
276
- length: i.name.getWidth(t),
277
- name: i.name.text,
278
- originFileNames: c,
279
- reason: p
280
- });
281
- }
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;
912
+ }
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,
923
+ reason: c
924
+ });
282
925
  }
283
- f.forEachChild(i, a);
926
+ a.forEachChild(i, r);
284
927
  }
285
- a(t);
928
+ r(s);
286
929
  }
287
- function de(t, o, e, n, r) {
288
- const a = ve(t, o);
289
- return a.length > 0 ? a : [...new Set(e.getDefinitionAtPosition(n, r)?.map(({ fileName: i }) => i))];
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)
933
+ return;
934
+ const c = Q(r);
935
+ if (!c.some(
936
+ (p) => (X(p) ?? fe($.dirname(p), "")) === "@arcgis/core"
937
+ ) || !_(c, o, n))
938
+ return;
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",
945
+ category: "coreViews",
946
+ originFileNames: c,
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.`
948
+ });
290
949
  }
291
- function j(t) {
292
- return [...new Set(t?.declarations?.map((o) => o.getSourceFile().fileName))];
950
+ function W(s, e) {
951
+ const t = e.getTypeAtLocation(s);
952
+ return t.isStringLiteral() || t.isNumberLiteral() ? String(t.value) : void 0;
293
953
  }
294
- function ve(t, o) {
295
- let e = o.getSymbolAtLocation(t);
296
- for (; e !== void 0 && (e.flags & f.SymbolFlags.Alias) !== 0; ) {
297
- if (S(e, o) !== void 0)
298
- return j(e);
299
- e = e.declarations === void 0 ? void 0 : o.getImmediateAliasedSymbol(e);
300
- }
301
- return [];
302
- }
303
- function Ne(t, o, e, n, r) {
304
- let a = o.getSymbolAtLocation(t);
305
- for (; a !== void 0 && (a.flags & f.SymbolFlags.Alias) !== 0; ) {
306
- if (S(a, o) !== void 0)
307
- return a.getName();
308
- a = a.declarations === void 0 ? void 0 : o.getImmediateAliasedSymbol(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 };
960
+ t = t.declarations === void 0 ? void 0 : e.getImmediateAliasedSymbol(t);
309
961
  }
310
- return e.getDefinitionAtPosition(n, r)?.[0]?.name;
962
+ return { symbol: t, reason: void 0 };
311
963
  }
312
- function k(t, o) {
313
- const e = d.relative(o, t);
314
- return e !== "" && !e.startsWith("../") && !d.isAbsolute(e) && e !== "node_modules" && !e.startsWith("node_modules/");
964
+ function Q(s) {
965
+ return [...new Set(s?.declarations?.map((e) => e.getSourceFile().fileName))];
315
966
  }
316
- function he(t, o, e) {
317
- let n = t;
967
+ function Nt(s, e, t, n, o) {
968
+ if (e.reason !== void 0)
969
+ return {
970
+ name: ae(e.symbol.declarations?.[0], e.symbol.getName()),
971
+ ...B(e.symbol.declarations?.[0])
972
+ };
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;
978
+ return {
979
+ name: l === void 0 ? bt(s) : ae(d, l),
980
+ ...B(d)
981
+ };
982
+ }
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/");
986
+ }
987
+ function we(s, e, t) {
988
+ let n = s;
318
989
  for (; ; ) {
319
- let r;
320
- if (f.forEachChild(n, (a) => {
321
- r === void 0 && a.getStart(t) <= o && a.getEnd() >= e && (r = a);
322
- }), r === void 0)
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)
323
994
  return n;
324
- n = r;
995
+ n = o;
325
996
  }
326
997
  }
327
- function ye(t) {
328
- return f.isIdentifier(t) || f.isPrivateIdentifier(t) || f.isStringLiteralLike(t) || f.isNumericLiteral(t) ? t.text : t.getText();
998
+ function bt(s) {
999
+ return a.isIdentifier(s) || a.isPrivateIdentifier(s) || a.isStringLiteralLike(s) || a.isNumericLiteral(s) ? s.text : s.getText();
329
1000
  }
330
- function O(t) {
331
- const o = t?.find(({ name: e }) => e === "deprecated");
332
- return o === void 0 ? void 0 : Z(o.text);
1001
+ function Se(s) {
1002
+ const e = s?.find(({ name: t }) => t === "deprecated");
1003
+ return e === void 0 ? void 0 : Je(e.text) ?? "";
333
1004
  }
334
- function ke(t, o, e) {
1005
+ function kt(s, e, t) {
335
1006
  try {
336
- return O(t.getQuickInfoAtPosition(o, e)?.tags);
1007
+ return Se(s.getQuickInfoAtPosition(e, t)?.tags);
337
1008
  } catch {
338
1009
  return;
339
1010
  }
340
1011
  }
341
- function S(t, o) {
1012
+ function Ne(s, e) {
342
1013
  try {
343
- return O(t?.getJsDocTags(o));
1014
+ const t = Se(s?.getJsDocTags(e));
1015
+ if (t !== void 0)
1016
+ return t;
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);
344
1019
  } catch {
345
1020
  return;
346
1021
  }
347
1022
  }
348
- function Se(t, o) {
349
- let e = o.getSymbolAtLocation(t);
350
- for (; e !== void 0 && (e.flags & f.SymbolFlags.Alias) !== 0; ) {
351
- const n = S(e, o);
352
- if (n !== void 0)
353
- return n;
354
- e = e.declarations === void 0 ? void 0 : o.getImmediateAliasedSymbol(e);
355
- }
356
- }
357
- function z(t, o, e) {
358
- if (Y(e.name, e.reason))
1023
+ function G(s, e, t) {
1024
+ if (ge(t.name, t.reason))
359
1025
  return;
360
- const { line: n, character: r } = o.getLineAndCharacterOfPosition(e.start);
361
- t.set(`${e.start}:${e.length}`, {
362
- ...e,
1026
+ const { line: n, character: o } = e.getLineAndCharacterOfPosition(t.start);
1027
+ s.set(`${t.start}:${t.length}`, {
1028
+ ...t,
363
1029
  line: n + 1,
364
- column: r + 1
1030
+ column: o + 1
365
1031
  });
366
1032
  }
367
- function U(t, o, e) {
368
- return t.some((n) => e !== void 0 && k(n, e)) ? !1 : !o || t.some((n) => {
369
- const r = W(n);
370
- return r === void 0 ? e === void 0 || !k(n, e) : te(r);
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);
371
1037
  });
372
1038
  }
373
- function W(t) {
374
- const o = H(t), e = "/node_modules/", n = o.lastIndexOf(e);
1039
+ function X(s) {
1040
+ const e = $e(s), t = "/node_modules/", n = e.lastIndexOf(t);
375
1041
  if (n === -1)
376
1042
  return;
377
- const [r, a] = o.slice(n + e.length).split("/");
378
- return r.startsWith("@") ? `${r}/${a}` : r;
1043
+ const [o, r] = e.slice(n + t.length).split("/");
1044
+ return o.startsWith("@") ? `${o}/${r}` : o;
379
1045
  }
380
- function Pe(t, o = [], e) {
381
- const n = t[0];
1046
+ function At(s, e = [], t) {
1047
+ const n = s[0];
382
1048
  if (n === void 0)
383
1049
  return "unknown package";
384
- const r = W(n);
1050
+ const o = X(n);
1051
+ if (o !== void 0)
1052
+ return o;
1053
+ const r = e.find(({ root: g }) => M(n, g));
385
1054
  if (r !== void 0)
386
- return r;
387
- const a = o.find(({ root: c }) => k(n, c));
388
- if (a !== void 0)
389
- return a.name;
390
- const i = d.dirname(y(n)), s = X(d.dirname(n), i);
391
- if (s !== i)
392
- return s;
393
- if (e === void 0)
1055
+ return r.name;
1056
+ const i = $.dirname(I(n)), d = fe($.dirname(n), i);
1057
+ if (d !== i)
1058
+ return d;
1059
+ if (t === void 0)
394
1060
  return i;
395
- const u = d.relative(e, n).split("/"), p = u.findIndex((c) => c !== "..");
396
- return p < 1 ? d.dirname(y(n)) : u.slice(0, p * 2).join("/");
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("/");
397
1063
  }
398
1064
  export {
399
- Me as auditDeprecatedUsages,
400
- pe as collectDeprecatedApiUsages,
401
- Pe as getDeprecationOriginLabel,
402
- W as getNodeModulesPackageName,
403
- U as shouldIncludeDeprecation
1065
+ Kt as auditDeprecatedUsages,
1066
+ yt as collectDeprecatedApiUsages,
1067
+ At as getDeprecationOriginLabel,
1068
+ X as getNodeModulesPackageName,
1069
+ _ as shouldIncludeDeprecation
404
1070
  };