@arcgis/codemod 6.0.0-next.4 → 6.0.0-next.40

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