@arcgis/codemod 6.0.0-next.43 → 6.0.0-next.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +158 -7
- package/dist/chunks/actions.js +261 -249
- package/dist/chunks/aggregateUsages.js +11 -10
- package/dist/chunks/apiName.js +123 -0
- package/dist/chunks/auditDefinitions.js +49 -47
- package/dist/chunks/auditUsages.js +649 -647
- package/dist/chunks/classification.js +73 -192
- package/dist/chunks/cli.js +79 -79
- package/dist/chunks/codemod.js +46 -46
- package/dist/chunks/codemod10.js +6059 -0
- package/dist/chunks/codemod11.js +83 -0
- package/dist/chunks/codemod12.js +74 -0
- package/dist/chunks/codemod2.js +180 -400
- package/dist/chunks/codemod3.js +77 -292
- package/dist/chunks/codemod4.js +398 -69
- package/dist/chunks/codemod5.js +292 -88
- package/dist/chunks/codemod6.js +71 -223
- package/dist/chunks/codemod7.js +89 -6041
- package/dist/chunks/codemod8.js +215 -49
- package/dist/chunks/codemod9.js +260 -0
- package/dist/chunks/componentAudit.js +141 -216
- package/dist/chunks/format.js +8 -7
- package/dist/chunks/hardcodedBehavior.js +96 -0
- package/dist/chunks/sync.js +1 -1
- package/package.json +4 -4
package/dist/chunks/actions.js
CHANGED
|
@@ -1,395 +1,407 @@
|
|
|
1
|
-
import { path as
|
|
1
|
+
import { path as D } from "@arcgis/node-toolkit/path";
|
|
2
2
|
import { SyntaxKind as I } from "ts-morph";
|
|
3
|
-
import { g as
|
|
3
|
+
import { g as S } from "./cli.js";
|
|
4
4
|
import { ModuleResolutionKind as K } from "typescript";
|
|
5
|
-
import { a as
|
|
6
|
-
import { capitalize as
|
|
7
|
-
import { log as
|
|
8
|
-
function
|
|
5
|
+
import { a as P } from "./log.js";
|
|
6
|
+
import { capitalize as j } from "@arcgis/toolkit/string";
|
|
7
|
+
import { log as q } from "@arcgis/toolkit/log";
|
|
8
|
+
function w(t) {
|
|
9
9
|
const e = t.typeScriptConfig?.compilerOptions?.moduleResolution ?? K.Bundler;
|
|
10
10
|
return e >= K.Node16 && e <= K.NodeNext;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const { specifiers:
|
|
16
|
-
let
|
|
17
|
-
for (const [
|
|
18
|
-
let
|
|
19
|
-
|
|
12
|
+
function Z(t, e) {
|
|
13
|
+
const o = {};
|
|
14
|
+
b(t);
|
|
15
|
+
const { specifiers: r, names: c, lastImportIndex: s } = R(t), i = [], n = {}, m = [], p = [];
|
|
16
|
+
let f = w(S.project.projectData);
|
|
17
|
+
for (const [a, u] of Object.entries(e)) {
|
|
18
|
+
let l = r.get(a) ?? (a.startsWith(".") ? r.get(
|
|
19
|
+
D.relative(t.getDirectoryPath(), D.resolve(S.project.projectData.cwd, a))
|
|
20
20
|
) : void 0);
|
|
21
|
-
if (
|
|
22
|
-
const y =
|
|
23
|
-
y !== void 0 && (
|
|
21
|
+
if (l === void 0) {
|
|
22
|
+
const y = r.get(`${a}.js`);
|
|
23
|
+
y !== void 0 && (f = !0, l === void 0 ? l = y : l = [...l, ...y]);
|
|
24
24
|
}
|
|
25
|
-
for (const [y,
|
|
26
|
-
const
|
|
27
|
-
for (const N of
|
|
28
|
-
N.do === "deprecate" ?
|
|
29
|
-
o,
|
|
25
|
+
for (const [y, v] of Object.entries(u)) {
|
|
26
|
+
const O = Array.isArray(v) ? v : [v];
|
|
27
|
+
for (const N of O)
|
|
28
|
+
N.do === "deprecate" ? C(y, a, o, l) : N.do === "add" ? E(a, y, N, l, i, n, c) : N.do === "rename" ? W(a, y, N, l, i, n, c) : N.do === "remove" ? p.push(() => $(y, N, l)) : N.do === "remove-namespace-import" && M(
|
|
30
29
|
a,
|
|
31
30
|
l,
|
|
31
|
+
i,
|
|
32
32
|
n,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
m,
|
|
34
|
+
c
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
for (let
|
|
41
|
-
const [
|
|
42
|
-
|
|
43
|
-
) :
|
|
44
|
-
if (
|
|
38
|
+
const g = Object.entries(n);
|
|
39
|
+
let d = s;
|
|
40
|
+
for (let a = 0; a < g.length; a += 1) {
|
|
41
|
+
const [u, l] = g[a], y = u.startsWith(".") ? F(
|
|
42
|
+
D.relative(t.getDirectoryPath(), D.resolve(S.project.projectData.cwd, u))
|
|
43
|
+
) : u, v = f && y.startsWith("@arcgis/core") ? `${y}.js` : y, O = l.afterDeclaration === void 0 ? d : l.afterDeclaration.getChildIndex() + 1;
|
|
44
|
+
if (l.named.length > 0) {
|
|
45
45
|
let N = !0;
|
|
46
|
-
for (let h = 0; h <
|
|
47
|
-
N &&=
|
|
48
|
-
t.insertImportDeclaration(
|
|
46
|
+
for (let h = 0; h < l.named.length; h += 1)
|
|
47
|
+
N &&= l.named[h].isTypeOnly;
|
|
48
|
+
t.insertImportDeclaration(O, {
|
|
49
49
|
isTypeOnly: N,
|
|
50
|
-
moduleSpecifier:
|
|
51
|
-
namedImports:
|
|
50
|
+
moduleSpecifier: v,
|
|
51
|
+
namedImports: l.named.map((h) => ({
|
|
52
52
|
name: h.name,
|
|
53
53
|
alias: h.alias,
|
|
54
54
|
isTypeOnly: h.isTypeOnly && !N
|
|
55
55
|
}))
|
|
56
|
-
}),
|
|
56
|
+
}), d += 1;
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
isTypeOnly:
|
|
60
|
-
moduleSpecifier:
|
|
61
|
-
defaultImport:
|
|
62
|
-
}),
|
|
63
|
-
isTypeOnly:
|
|
64
|
-
moduleSpecifier:
|
|
65
|
-
namespaceImport:
|
|
66
|
-
}),
|
|
58
|
+
l.default !== void 0 && (t.insertImportDeclaration(O, {
|
|
59
|
+
isTypeOnly: l.default.isTypeOnly,
|
|
60
|
+
moduleSpecifier: v,
|
|
61
|
+
defaultImport: l.default.name
|
|
62
|
+
}), d += 1), l["*"] !== void 0 && (t.insertImportDeclaration(O, {
|
|
63
|
+
isTypeOnly: l["*"].isTypeOnly,
|
|
64
|
+
moduleSpecifier: v,
|
|
65
|
+
namespaceImport: l["*"].name
|
|
66
|
+
}), d += 1);
|
|
67
67
|
}
|
|
68
|
-
if (Object.keys(
|
|
69
|
-
const
|
|
70
|
-
|
|
68
|
+
if (Object.keys(o).length > 0) {
|
|
69
|
+
const a = Object.entries(o).map(([u, l]) => `${l.join(", ")} from ${u}`).join("; ");
|
|
70
|
+
q("warn", P(t), `Deprecated API usages found: ${a}`);
|
|
71
71
|
}
|
|
72
|
-
for (const
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
for (const a of m)
|
|
73
|
+
a.remove();
|
|
74
|
+
for (const a of p)
|
|
75
|
+
a();
|
|
76
|
+
return i;
|
|
75
77
|
}
|
|
76
|
-
function
|
|
78
|
+
function b(t) {
|
|
77
79
|
const e = t.getChildSyntaxList()?.getFirstChild();
|
|
78
|
-
if (
|
|
80
|
+
if (A === e)
|
|
79
81
|
return;
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
function
|
|
84
|
-
for (const
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
for (const p of
|
|
89
|
-
|
|
90
|
-
} else
|
|
91
|
-
if (!
|
|
82
|
+
A = e, x.clear();
|
|
83
|
+
const o = /* @__PURE__ */ new Set();
|
|
84
|
+
r(t);
|
|
85
|
+
function r(c) {
|
|
86
|
+
for (const s of c.getStatements())
|
|
87
|
+
if (s.isKind(I.ImportDeclaration)) {
|
|
88
|
+
const i = s.getDefaultImport(), n = s.getNamespaceImport(), m = s.getNamedImports();
|
|
89
|
+
i && o.add(i.getText()), n && o.add(n.getText());
|
|
90
|
+
for (const p of m)
|
|
91
|
+
o.add(p.getAliasNode()?.getText() ?? p.getName());
|
|
92
|
+
} else s.isKind(I.ImportEqualsDeclaration) ? o.add(s.getName()) : s.isKind(I.ModuleDeclaration) ? r(s) : c.forEachDescendant((i) => {
|
|
93
|
+
if (!i.isKind(I.Identifier))
|
|
92
94
|
return;
|
|
93
|
-
const n =
|
|
94
|
-
if (n.isKind(I.QualifiedName) && n.getLeft() !==
|
|
95
|
+
const n = i.getParent();
|
|
96
|
+
if (n.isKind(I.QualifiedName) && n.getLeft() !== i || n.isKind(I.PropertyAccessExpression) && n.getExpression() !== i || (n.isKind(I.PropertyDeclaration) || n.isKind(I.PropertySignature) || n.isKind(I.PropertyAssignment)) && n.getNameNode() === i)
|
|
95
97
|
return;
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
+
const m = i.getText();
|
|
99
|
+
o.has(m) || x.add(i.getText());
|
|
98
100
|
});
|
|
99
101
|
}
|
|
100
102
|
}
|
|
101
|
-
function
|
|
102
|
-
const e = /* @__PURE__ */ new Map(),
|
|
103
|
-
let
|
|
104
|
-
for (let
|
|
105
|
-
const n = i
|
|
103
|
+
function R(t) {
|
|
104
|
+
const e = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), r = t.getStatements();
|
|
105
|
+
let c;
|
|
106
|
+
for (let i = 0; i < r.length; i += 1) {
|
|
107
|
+
const n = r[i];
|
|
106
108
|
if (!n.isKind(I.ImportDeclaration)) {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
+
const u = n.getName?.();
|
|
110
|
+
u !== void 0 && o.add(u);
|
|
109
111
|
continue;
|
|
110
112
|
}
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
p === void 0 ? e.set(
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
113
|
+
c = n;
|
|
114
|
+
const m = n.getModuleSpecifierValue(), p = e.get(m);
|
|
115
|
+
p === void 0 ? e.set(m, [n]) : p.push(n);
|
|
116
|
+
const f = n.getImportClause();
|
|
117
|
+
if (f === void 0)
|
|
116
118
|
continue;
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
if (
|
|
122
|
-
for (const
|
|
123
|
-
const
|
|
124
|
-
|
|
119
|
+
const g = f.getDefaultImport()?.getText();
|
|
120
|
+
g !== void 0 && o.add(g);
|
|
121
|
+
const d = f.getNamedBindings();
|
|
122
|
+
if (d !== void 0)
|
|
123
|
+
if (d.isKind(I.NamedImports))
|
|
124
|
+
for (const a of d.getElements()) {
|
|
125
|
+
const u = a.getName();
|
|
126
|
+
o.add(u);
|
|
125
127
|
}
|
|
126
128
|
else {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
+
const a = d.getName();
|
|
130
|
+
o.add(a);
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
|
-
const
|
|
132
|
-
return { specifiers: e, names:
|
|
133
|
+
const s = c === void 0 ? 0 : c.getChildIndex() + 1;
|
|
134
|
+
return { specifiers: e, names: o, lastImportIndex: s };
|
|
133
135
|
}
|
|
134
|
-
function
|
|
135
|
-
if (
|
|
136
|
+
function C(t, e, o, r) {
|
|
137
|
+
if (r !== void 0) {
|
|
136
138
|
if (t === "default")
|
|
137
|
-
for (const
|
|
138
|
-
const
|
|
139
|
-
if (
|
|
140
|
-
|
|
139
|
+
for (const c of r) {
|
|
140
|
+
const s = c.getDefaultImport();
|
|
141
|
+
if (s !== void 0) {
|
|
142
|
+
o[e] ??= [], o[e].push(s.getText());
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
else if (t === "*")
|
|
145
|
-
for (const
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
-
|
|
147
|
+
for (const c of r) {
|
|
148
|
+
const s = c.getNamespaceImport();
|
|
149
|
+
if (s !== void 0) {
|
|
150
|
+
o[e] ??= [], o[e].push(s.getText());
|
|
149
151
|
return;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
else
|
|
153
|
-
for (const
|
|
154
|
-
for (const
|
|
155
|
-
if (
|
|
156
|
-
|
|
155
|
+
for (const c of r)
|
|
156
|
+
for (const s of c.getNamedImports())
|
|
157
|
+
if (s.getName() === t) {
|
|
158
|
+
o[e] ??= [], o[e].push(s.getName());
|
|
157
159
|
return;
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
|
-
function
|
|
163
|
+
function E(t, e, o, r, c, s, i) {
|
|
162
164
|
const n = e === "default";
|
|
163
165
|
if (n || e === "*") {
|
|
164
|
-
if (
|
|
165
|
-
for (const p of
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
|
|
166
|
+
if (r !== void 0)
|
|
167
|
+
for (const p of r) {
|
|
168
|
+
const f = n ? p.getDefaultImport() : p.getNamespaceImport();
|
|
169
|
+
if (f !== void 0) {
|
|
170
|
+
o.isTypeOnly !== !0 && p.isTypeOnly() && p.setIsTypeOnly(!1), c.push({
|
|
169
171
|
specifier: t,
|
|
170
172
|
requestedName: e,
|
|
171
|
-
actualName:
|
|
173
|
+
actualName: f.getText()
|
|
172
174
|
});
|
|
173
175
|
return;
|
|
174
176
|
}
|
|
175
177
|
}
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
+
const m = T(o.preferredAlias, void 0, t, i);
|
|
179
|
+
c.push({ specifier: t, requestedName: e, actualName: m }), s[t] ??= {
|
|
178
180
|
afterDeclaration: void 0,
|
|
179
181
|
named: [],
|
|
180
182
|
default: void 0,
|
|
181
183
|
"*": void 0
|
|
182
|
-
},
|
|
183
|
-
name:
|
|
184
|
-
isTypeOnly:
|
|
184
|
+
}, s[t].afterDeclaration ??= r?.[0], s[t][e] = {
|
|
185
|
+
name: m,
|
|
186
|
+
isTypeOnly: o.isTypeOnly === !0
|
|
185
187
|
};
|
|
186
188
|
} else {
|
|
187
|
-
let
|
|
188
|
-
if (
|
|
189
|
-
let
|
|
190
|
-
for (const
|
|
191
|
-
if (
|
|
192
|
-
p ??=
|
|
193
|
-
for (const
|
|
194
|
-
if (
|
|
195
|
-
if (
|
|
196
|
-
if (
|
|
189
|
+
let m, p;
|
|
190
|
+
if (r !== void 0) {
|
|
191
|
+
let d = !1;
|
|
192
|
+
for (const a of r)
|
|
193
|
+
if (!(a.getNamespaceImport() !== void 0 || o.isTypeOnly === !0 && a.getImportClause() === void 0)) {
|
|
194
|
+
p ??= a, m ??= a.isTypeOnly() && a.getDefaultImport() === void 0 ? a : void 0;
|
|
195
|
+
for (const u of a.getNamedImports())
|
|
196
|
+
if (u.getNameNode().getText() === e) {
|
|
197
|
+
if (d = !0, o.isTypeOnly !== !0) {
|
|
198
|
+
if (u.isTypeOnly())
|
|
199
|
+
u.setIsTypeOnly(!1);
|
|
200
|
+
else if (a.isTypeOnly()) {
|
|
201
|
+
for (const l of a.getNamedImports())
|
|
202
|
+
l !== u && l.setIsTypeOnly(!0);
|
|
197
203
|
a.setIsTypeOnly(!1);
|
|
198
|
-
else if (f.isTypeOnly()) {
|
|
199
|
-
for (const y of f.getNamedImports())
|
|
200
|
-
y !== a && y.setIsTypeOnly(!0);
|
|
201
|
-
f.setIsTypeOnly(!1);
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
|
-
|
|
206
|
+
c.push({
|
|
205
207
|
specifier: t,
|
|
206
208
|
requestedName: e,
|
|
207
|
-
actualName:
|
|
209
|
+
actualName: u.getAliasNode()?.getText() ?? e
|
|
208
210
|
});
|
|
209
211
|
break;
|
|
210
212
|
}
|
|
211
213
|
}
|
|
212
|
-
if (
|
|
214
|
+
if (d)
|
|
213
215
|
return;
|
|
214
216
|
}
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
const f = T(
|
|
218
|
+
o.preferAlias === !0 ? o.preferredAlias : e,
|
|
219
|
+
o.preferAlias === !0 ? e : o.preferredAlias,
|
|
218
220
|
t,
|
|
219
|
-
|
|
220
|
-
),
|
|
221
|
-
if (
|
|
222
|
-
|
|
221
|
+
i
|
|
222
|
+
), g = e === f ? void 0 : f;
|
|
223
|
+
if (o.isTypeOnly && m !== void 0)
|
|
224
|
+
m.addNamedImport({
|
|
223
225
|
name: e,
|
|
224
|
-
alias:
|
|
226
|
+
alias: g
|
|
225
227
|
});
|
|
226
|
-
else if (p !== void 0 && (!
|
|
227
|
-
if (p.isTypeOnly() && !
|
|
228
|
+
else if (p !== void 0 && (!o.isTypeOnly || p.getDefaultImport() === void 0)) {
|
|
229
|
+
if (p.isTypeOnly() && !o.isTypeOnly) {
|
|
228
230
|
p.setIsTypeOnly(!1);
|
|
229
|
-
for (const
|
|
230
|
-
|
|
231
|
+
for (const d of p.getNamedImports())
|
|
232
|
+
d.setIsTypeOnly(!0);
|
|
231
233
|
}
|
|
232
234
|
p.addNamedImport({
|
|
233
235
|
name: e,
|
|
234
|
-
alias:
|
|
235
|
-
isTypeOnly:
|
|
236
|
+
alias: g,
|
|
237
|
+
isTypeOnly: o.isTypeOnly && !p.isTypeOnly()
|
|
236
238
|
});
|
|
237
239
|
} else
|
|
238
|
-
|
|
240
|
+
s[t] ??= {
|
|
239
241
|
afterDeclaration: void 0,
|
|
240
242
|
named: [],
|
|
241
243
|
default: void 0,
|
|
242
244
|
"*": void 0
|
|
243
|
-
},
|
|
245
|
+
}, s[t].afterDeclaration ??= r?.[0], s[t].named.push({
|
|
244
246
|
name: e,
|
|
245
|
-
alias:
|
|
246
|
-
isTypeOnly:
|
|
247
|
+
alias: g,
|
|
248
|
+
isTypeOnly: o.isTypeOnly === !0
|
|
247
249
|
});
|
|
248
|
-
|
|
250
|
+
c.push({ specifier: t, requestedName: e, actualName: f });
|
|
249
251
|
}
|
|
250
252
|
}
|
|
251
|
-
function
|
|
252
|
-
if (
|
|
253
|
+
function W(t, e, o, r, c, s, i) {
|
|
254
|
+
if (r === void 0)
|
|
253
255
|
return;
|
|
254
|
-
const n =
|
|
256
|
+
const n = o.name ?? e, m = o.specifier ?? t, p = e === "default";
|
|
255
257
|
if (p || e === "*") {
|
|
256
|
-
for (const
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
258
|
+
for (const f of r) {
|
|
259
|
+
const g = p ? f.getDefaultImport() : f.getNamespaceImport();
|
|
260
|
+
if (g === void 0)
|
|
259
261
|
continue;
|
|
260
|
-
if (
|
|
261
|
-
|
|
262
|
-
for (const
|
|
263
|
-
|
|
262
|
+
if (o.isTypeOnly === !1 && f.isTypeOnly()) {
|
|
263
|
+
f.setIsTypeOnly(!1);
|
|
264
|
+
for (const a of f.getNamedImports())
|
|
265
|
+
a.setIsTypeOnly(!0);
|
|
264
266
|
}
|
|
265
|
-
let
|
|
267
|
+
let d = n;
|
|
266
268
|
if (n !== e) {
|
|
267
|
-
const
|
|
268
|
-
n ===
|
|
269
|
+
const a = T(n, e, t, i);
|
|
270
|
+
n === a ? g.rename(n) : d = g.getText();
|
|
269
271
|
} else
|
|
270
|
-
|
|
271
|
-
t !==
|
|
272
|
+
d = g.getText();
|
|
273
|
+
t !== m && (f.getNamedImports().length === 0 ? f.setModuleSpecifier(m) : (p ? f.removeDefaultImport() : f.removeNamespaceImport(), s[m] ??= {
|
|
272
274
|
afterDeclaration: void 0,
|
|
273
275
|
named: [],
|
|
274
276
|
default: void 0,
|
|
275
277
|
"*": void 0
|
|
276
|
-
},
|
|
277
|
-
name:
|
|
278
|
-
isTypeOnly:
|
|
279
|
-
})),
|
|
280
|
-
specifier:
|
|
278
|
+
}, s[m].afterDeclaration ??= f, s[m][e] = {
|
|
279
|
+
name: d,
|
|
280
|
+
isTypeOnly: f.isTypeOnly()
|
|
281
|
+
})), c.push({
|
|
282
|
+
specifier: m,
|
|
281
283
|
requestedName: e,
|
|
282
|
-
actualName:
|
|
284
|
+
actualName: d
|
|
283
285
|
});
|
|
284
286
|
break;
|
|
285
287
|
}
|
|
286
288
|
return;
|
|
287
289
|
}
|
|
288
|
-
for (const
|
|
289
|
-
for (const
|
|
290
|
-
if (
|
|
290
|
+
for (const f of r) {
|
|
291
|
+
for (const d of f.getNamedImports()) {
|
|
292
|
+
if (d.getNameNode().getText() !== e)
|
|
291
293
|
continue;
|
|
292
|
-
if (
|
|
293
|
-
if (
|
|
294
|
-
o.setIsTypeOnly(!1);
|
|
295
|
-
else if (d.isTypeOnly()) {
|
|
294
|
+
if (o.isTypeOnly === !1) {
|
|
295
|
+
if (d.isTypeOnly())
|
|
296
296
|
d.setIsTypeOnly(!1);
|
|
297
|
-
|
|
298
|
-
|
|
297
|
+
else if (f.isTypeOnly()) {
|
|
298
|
+
f.setIsTypeOnly(!1);
|
|
299
|
+
for (const l of f.getNamedImports())
|
|
300
|
+
l !== d && l.setIsTypeOnly(!0);
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
|
-
let
|
|
302
|
-
const
|
|
303
|
+
let a = n;
|
|
304
|
+
const u = d.getAliasNode();
|
|
303
305
|
if (n !== e)
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
n ===
|
|
306
|
+
if (u === void 0) {
|
|
307
|
+
const l = T(n, e, t, i);
|
|
308
|
+
n === l ? d.getNameNode().asKind(I.Identifier)?.rename(n) : (d.setAlias(e), d.getNameNode().replaceWithText(n), a = e);
|
|
307
309
|
} else
|
|
308
|
-
|
|
309
|
-
if (
|
|
310
|
-
const
|
|
311
|
-
|
|
310
|
+
d.getNameNode().replaceWithText(n), a = u.getText();
|
|
311
|
+
if (m !== t) {
|
|
312
|
+
const y = (w(S.project.projectData) || f.getModuleSpecifierValue().endsWith(".js")) && m.startsWith("@arcgis/core") ? `${m}.js` : m;
|
|
313
|
+
f.getNamedImports().length === 1 && f.getDefaultImport() === void 0 ? f.setModuleSpecifier(y) : (s[y] ??= { named: [] }, s[y].afterDeclaration ??= r?.[0], s[y].named.push({
|
|
312
314
|
name: n,
|
|
313
|
-
alias: n ===
|
|
314
|
-
isTypeOnly:
|
|
315
|
-
}),
|
|
315
|
+
alias: n === a ? void 0 : a,
|
|
316
|
+
isTypeOnly: d.isTypeOnly()
|
|
317
|
+
}), d.remove());
|
|
316
318
|
}
|
|
317
|
-
|
|
318
|
-
specifier:
|
|
319
|
+
c.push({
|
|
320
|
+
specifier: m,
|
|
319
321
|
requestedName: n,
|
|
320
|
-
actualName:
|
|
322
|
+
actualName: u?.getText() ?? a
|
|
321
323
|
});
|
|
322
324
|
return;
|
|
323
325
|
}
|
|
324
|
-
const
|
|
325
|
-
if (
|
|
326
|
-
for (const
|
|
327
|
-
const
|
|
328
|
-
if (!
|
|
326
|
+
const g = f.getNamespaceImport();
|
|
327
|
+
if (g)
|
|
328
|
+
for (const d of g.findReferencesAsNodes().slice(1)) {
|
|
329
|
+
const a = d.getParentIfKind(I.PropertyAccessExpression), u = d.getParentIfKind(I.QualifiedName)?.getParentIfKind(I.TypeReference), l = a ?? u;
|
|
330
|
+
if (!l)
|
|
329
331
|
continue;
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
+
const y = l.getText();
|
|
333
|
+
y.endsWith(e) && l.replaceWithText(y.replaceAll(e, n));
|
|
332
334
|
}
|
|
333
335
|
}
|
|
334
336
|
}
|
|
335
|
-
function
|
|
336
|
-
|
|
337
|
+
function $(t, e, o) {
|
|
338
|
+
for (const r of o ?? []) {
|
|
339
|
+
if (r.wasForgotten())
|
|
340
|
+
continue;
|
|
341
|
+
const c = r.getNamedImports().find((i) => i.getName() === t), s = t === "default" ? r.getDefaultImport() : t === "*" ? r.getNamespaceImport() : c?.getAliasNode() ?? c?.getNameNode().asKind(I.Identifier);
|
|
342
|
+
s !== void 0 && (e.unusedOnly && s.findReferencesAsNodes().some(
|
|
343
|
+
(i) => i.getSourceFile() === r.getSourceFile() && i !== s && i.getParent()?.getKind() !== I.ImportSpecifier
|
|
344
|
+
) || (t === "default" ? r.removeDefaultImport() : t === "*" ? r.removeNamespaceImport() : s.getParentIfKindOrThrow(I.ImportSpecifier).remove(), r.getNamedImports().length === 0 && r.getDefaultImport() === void 0 && r.getNamespaceImport() === void 0 && r.remove()));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function M(t, e, o, r, c, s) {
|
|
348
|
+
if (e = e?.filter((g) => g.getNamespaceImport() != null), e === void 0 || e.length === 0)
|
|
337
349
|
return;
|
|
338
350
|
if (e.length !== 1)
|
|
339
351
|
throw Error(
|
|
340
352
|
`Multiple namespace imports of the same specifier (${JSON.stringify(t)}, #${e.length}) are not supported.`
|
|
341
353
|
);
|
|
342
|
-
const [
|
|
343
|
-
for (const
|
|
344
|
-
const
|
|
345
|
-
if (!
|
|
354
|
+
const [i] = e, n = i.getNamespaceImport(), m = {}, p = /* @__PURE__ */ new Set();
|
|
355
|
+
for (const g of n.findReferencesAsNodes()) {
|
|
356
|
+
const d = g.getParentIfKind(I.PropertyAccessExpression), a = g.getParentIfKind(I.QualifiedName)?.getParentIfKind(I.TypeReference), u = d ?? a;
|
|
357
|
+
if (!u)
|
|
346
358
|
continue;
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
|
|
359
|
+
const l = u.getText().split(".").pop().trim();
|
|
360
|
+
m[l] ??= T(l, void 0, t, s);
|
|
361
|
+
const y = m[l];
|
|
362
|
+
u.replaceWithText(y), a || p.add(y);
|
|
351
363
|
}
|
|
352
|
-
|
|
353
|
-
afterDeclaration:
|
|
364
|
+
r[t] ??= {
|
|
365
|
+
afterDeclaration: i,
|
|
354
366
|
named: []
|
|
355
367
|
};
|
|
356
|
-
const { named:
|
|
357
|
-
for (const [
|
|
358
|
-
|
|
359
|
-
name:
|
|
360
|
-
alias:
|
|
361
|
-
isTypeOnly: !p.has(
|
|
362
|
-
}),
|
|
368
|
+
const { named: f } = r[t];
|
|
369
|
+
for (const [g, d] of Object.entries(m))
|
|
370
|
+
f.push({
|
|
371
|
+
name: g,
|
|
372
|
+
alias: d === g ? void 0 : d,
|
|
373
|
+
isTypeOnly: !p.has(d)
|
|
374
|
+
}), o.push({
|
|
363
375
|
specifier: t,
|
|
364
|
-
requestedName:
|
|
365
|
-
actualName:
|
|
376
|
+
requestedName: g,
|
|
377
|
+
actualName: d
|
|
366
378
|
});
|
|
367
|
-
|
|
379
|
+
c.push(i);
|
|
368
380
|
}
|
|
369
|
-
function T(t, e,
|
|
381
|
+
function T(t, e, o, r) {
|
|
370
382
|
if (t !== void 0) {
|
|
371
|
-
if (!
|
|
372
|
-
return
|
|
383
|
+
if (!r.has(t) && !x.has(t))
|
|
384
|
+
return r.add(t), t;
|
|
373
385
|
if (e !== void 0)
|
|
374
|
-
return T(e, void 0,
|
|
386
|
+
return T(e, void 0, o, r);
|
|
375
387
|
}
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
let
|
|
379
|
-
for (let
|
|
380
|
-
const n =
|
|
381
|
-
if (n !==
|
|
382
|
-
return
|
|
388
|
+
o.startsWith("@arcgis/core") && (o = `arcgisCore${o.slice(12)}`);
|
|
389
|
+
const c = o.split("/");
|
|
390
|
+
let s = t ?? "";
|
|
391
|
+
for (let i = c.length - 1; i >= 0; i--) {
|
|
392
|
+
const n = c[i].replaceAll(U, "");
|
|
393
|
+
if (n !== s && (s = n + j(s), !r.has(s) && !x.has(s)))
|
|
394
|
+
return r.add(s), s;
|
|
383
395
|
}
|
|
384
|
-
for (let
|
|
385
|
-
const n =
|
|
386
|
-
if (!
|
|
387
|
-
return
|
|
396
|
+
for (let i = 2; ; i++) {
|
|
397
|
+
const n = s + i;
|
|
398
|
+
if (!r.has(n) && !x.has(n))
|
|
399
|
+
return r.add(n), n;
|
|
388
400
|
}
|
|
389
401
|
}
|
|
390
|
-
const
|
|
391
|
-
let
|
|
402
|
+
const U = /[^a-zA-Z0-9$_]/gu, F = (t) => t.startsWith(".") ? t : `./${t}`, x = /* @__PURE__ */ new Set();
|
|
403
|
+
let A;
|
|
392
404
|
export {
|
|
393
|
-
|
|
394
|
-
|
|
405
|
+
Z as p,
|
|
406
|
+
b as u
|
|
395
407
|
};
|