@arcgis/codemod 5.2.0-next.98 → 6.0.0-next.0
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 +83 -33
- package/dist/chunks/actions.js +395 -0
- package/dist/chunks/cli.js +380 -0
- package/dist/{codemod-BWZ_CtnT.js → chunks/codemod.js} +3 -3
- package/dist/chunks/codemod2.js +417 -0
- package/dist/{codemod-v9PNv3xH.js → chunks/codemod3.js} +2 -2
- package/dist/chunks/codemod4.js +88 -0
- package/dist/{codemod-Bk-5zHaA.js → chunks/codemod5.js} +44 -76
- package/dist/{codemod-DgXtIN7a.js → chunks/codemod6.js} +1 -1
- package/dist/{codemod-DkEa3nwr.js → chunks/codemod7.js} +19 -18
- package/dist/{codemod-B9tWi9M_.js → chunks/codemod8.js} +3 -3
- package/dist/chunks/format.js +255 -0
- package/dist/chunks/hardcodedBehavior.js +93 -0
- package/dist/chunks/index.js +404 -0
- package/dist/chunks/index2.js +143 -0
- package/dist/chunks/log.js +11 -0
- package/dist/chunks/packageJson.js +39 -0
- package/dist/chunks/sync.js +165 -0
- package/dist/chunks/useProjectInstance.js +51 -0
- package/dist/cli.js +3 -2
- package/package.json +4 -4
- package/dist/actions-CE74rP-z.js +0 -354
- package/dist/cli-x1Uhjnb_.js +0 -269
- package/dist/useProjectInstance-BAlKm1ad.js +0 -47
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { readFile as f } from "node:fs/promises";
|
|
2
|
+
import { log as h } from "@arcgis/toolkit/log";
|
|
3
|
+
import { a as m, b as g, d as c, e as d } from "./format.js";
|
|
4
|
+
import { collectOutput as u } from "@arcgis/node-toolkit/shell";
|
|
5
|
+
class l {
|
|
6
|
+
constructor(s, e = !1) {
|
|
7
|
+
this.changes = [], this.#i = /* @__PURE__ */ new Map(), this.#n = -1;
|
|
8
|
+
const [i, t, o, ...r] = s.split("/");
|
|
9
|
+
if (i === void 0 || t === void 0 || o === void 0 || r.length > 0)
|
|
10
|
+
throw new Error(`Invalid repository: ${s}`);
|
|
11
|
+
this.#e = i, this.#s = `${t}/${o}`, this.dryRun = e;
|
|
12
|
+
}
|
|
13
|
+
#e;
|
|
14
|
+
#s;
|
|
15
|
+
#i;
|
|
16
|
+
#n;
|
|
17
|
+
async #t(s, e, i) {
|
|
18
|
+
if (process.env.VITEST !== void 0)
|
|
19
|
+
throw new Error("GitHub requests are disabled while running Vitest.");
|
|
20
|
+
const t = await u(
|
|
21
|
+
"gh",
|
|
22
|
+
["api", "--hostname", this.#e, "--method", s, e, ...i === void 0 ? [] : ["--input", "-"]],
|
|
23
|
+
i === void 0 ? {} : { input: JSON.stringify(i) }
|
|
24
|
+
);
|
|
25
|
+
return t === "" ? void 0 : JSON.parse(t);
|
|
26
|
+
}
|
|
27
|
+
async listOpenIssues(s) {
|
|
28
|
+
const e = await u("gh", [
|
|
29
|
+
"api",
|
|
30
|
+
"--hostname",
|
|
31
|
+
this.#e,
|
|
32
|
+
"--method",
|
|
33
|
+
"GET",
|
|
34
|
+
"--paginate",
|
|
35
|
+
"--slurp",
|
|
36
|
+
"-f",
|
|
37
|
+
`q="${s}" in:title repo:${this.#s} is:issue is:open`,
|
|
38
|
+
"-f",
|
|
39
|
+
"per_page=100",
|
|
40
|
+
"/search/issues"
|
|
41
|
+
]);
|
|
42
|
+
return JSON.parse(e).flatMap(({ items: i }) => i);
|
|
43
|
+
}
|
|
44
|
+
async createIssue(s, e, i, t) {
|
|
45
|
+
if (this.dryRun) {
|
|
46
|
+
const o = this.#n--;
|
|
47
|
+
return this.#i.set(o, s), this.changes.push(`CREATE issue: ${s}`), { number: o, title: s, body: e, assignees: i.map((r) => ({ login: r })) };
|
|
48
|
+
}
|
|
49
|
+
return await this.#t("POST", `/repos/${this.#s}/issues`, {
|
|
50
|
+
title: s,
|
|
51
|
+
body: e,
|
|
52
|
+
assignees: i,
|
|
53
|
+
labels: t,
|
|
54
|
+
type: m
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async updateIssueBody(s, e) {
|
|
58
|
+
if (this.dryRun) {
|
|
59
|
+
this.changes.push(`UPDATE issue #${s} body`);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
await this.#t("PATCH", `/repos/${this.#s}/issues/${s}`, { body: e });
|
|
63
|
+
}
|
|
64
|
+
async listComments(s) {
|
|
65
|
+
if (this.#i.has(s))
|
|
66
|
+
return [];
|
|
67
|
+
const e = await u("gh", [
|
|
68
|
+
"api",
|
|
69
|
+
"--hostname",
|
|
70
|
+
this.#e,
|
|
71
|
+
"--method",
|
|
72
|
+
"GET",
|
|
73
|
+
"--paginate",
|
|
74
|
+
"--slurp",
|
|
75
|
+
`/repos/${this.#s}/issues/${s}/comments?per_page=100`
|
|
76
|
+
]);
|
|
77
|
+
return JSON.parse(e).flat();
|
|
78
|
+
}
|
|
79
|
+
async createComment(s, e) {
|
|
80
|
+
if (this.dryRun) {
|
|
81
|
+
const i = this.#i.get(s), t = i === void 0 ? `issue #${s}` : `new issue: ${i}`;
|
|
82
|
+
this.changes.push(`ADD comment to ${t}`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
await this.#t("POST", `/repos/${this.#s}/issues/${s}/comments`, { body: e });
|
|
86
|
+
}
|
|
87
|
+
async updateComment(s, e) {
|
|
88
|
+
if (this.dryRun) {
|
|
89
|
+
this.changes.push(`UPDATE comment #${s}`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
await this.#t("PATCH", `/repos/${this.#s}/issues/comments/${s}`, { body: e });
|
|
93
|
+
}
|
|
94
|
+
async deleteComment(s) {
|
|
95
|
+
if (this.dryRun) {
|
|
96
|
+
this.changes.push(`REMOVE comment #${s}`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
await this.#t("DELETE", `/repos/${this.#s}/issues/comments/${s}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function k(n, s, e = 0, i, t = []) {
|
|
103
|
+
const o = w(await f(n, "utf8")), r = y(g(o), e, i), a = new l(o.repository, s);
|
|
104
|
+
await $(r, a, t), s && process.stdout.write(`${E(r)}
|
|
105
|
+
`);
|
|
106
|
+
}
|
|
107
|
+
function y(n, s, e) {
|
|
108
|
+
return n.slice(s, e === void 0 ? void 0 : s + e);
|
|
109
|
+
}
|
|
110
|
+
async function $(n, s, e = []) {
|
|
111
|
+
const i = /* @__PURE__ */ new Map();
|
|
112
|
+
for (const t of n) {
|
|
113
|
+
let o = i.get(t.title);
|
|
114
|
+
o === void 0 && (o = await s.listOpenIssues(t.title), i.set(t.title, o));
|
|
115
|
+
const r = I(o, t);
|
|
116
|
+
let a;
|
|
117
|
+
r === void 0 ? (a = (await s.createIssue(t.title, t.chunks[0], t.assignees, e)).number, s.dryRun || h("info", c, `Created issue #${a}: ${t.title}`)) : (a = r.number, r.body !== t.chunks[0] && (await s.updateIssueBody(a, t.chunks[0]), s.dryRun || h("info", c, `Updated issue #${a}: ${t.title}`))), await T(s, a, t.chunks.slice(1)), t.changes.push(...s.changes.splice(0));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function w(n) {
|
|
121
|
+
const s = JSON.parse(n);
|
|
122
|
+
if (s.kind !== "usages" && s.kind !== "definitions" || typeof s.repository != "string" || typeof s.ref != "string" || !Array.isArray(s.findings))
|
|
123
|
+
throw new Error("Invalid deprecation audit JSON.");
|
|
124
|
+
return s;
|
|
125
|
+
}
|
|
126
|
+
function E(n) {
|
|
127
|
+
return n.map(
|
|
128
|
+
(s) => `ACTIONS: ${s.changes.length === 0 ? "No changes" : s.changes.join("; ")}
|
|
129
|
+
|
|
130
|
+
CODEOWNERS: ${s.owners.length === 0 ? "unowned" : s.owners.join(", ")}
|
|
131
|
+
ASSIGNEES: ${s.assignees.length === 0 ? "none" : s.assignees.join(", ")}
|
|
132
|
+
TITLE: ${s.title}
|
|
133
|
+
|
|
134
|
+
${s.chunks.map((e, i) => `--- ${i === 0 ? "BODY" : "COMMENT"} (${i + 1}/${s.chunks.length}) ---
|
|
135
|
+
${e}`).join(`
|
|
136
|
+
|
|
137
|
+
`)}`
|
|
138
|
+
).join(`
|
|
139
|
+
|
|
140
|
+
`);
|
|
141
|
+
}
|
|
142
|
+
function I(n, s) {
|
|
143
|
+
const e = p(s.chunks[0]);
|
|
144
|
+
return n.find((i) => i.title === s.title && p(i.body) === e);
|
|
145
|
+
}
|
|
146
|
+
function p(n) {
|
|
147
|
+
const s = n?.split(`
|
|
148
|
+
`, 1)[0];
|
|
149
|
+
return s?.startsWith(d) === !0 ? s : void 0;
|
|
150
|
+
}
|
|
151
|
+
async function T(n, s, e) {
|
|
152
|
+
const i = (await n.listComments(s)).filter(({ body: t }) => t.startsWith(d));
|
|
153
|
+
for (const [t, o] of e.entries()) {
|
|
154
|
+
const r = i[t];
|
|
155
|
+
r === void 0 ? await n.createComment(s, o) : r.body !== o && await n.updateComment(r.id, o);
|
|
156
|
+
}
|
|
157
|
+
for (const t of i.slice(e.length))
|
|
158
|
+
await n.deleteComment(t.id);
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
E as formatDryRun,
|
|
162
|
+
y as sliceIssuePlans,
|
|
163
|
+
k as syncDeprecationIssues,
|
|
164
|
+
$ as synchronizeIssuePlans
|
|
165
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Project as p } from "ts-morph";
|
|
2
|
+
import { log as d } from "@arcgis/toolkit/log";
|
|
3
|
+
import { path as a } from "@arcgis/node-toolkit/path";
|
|
4
|
+
import { g as i, a as m } from "./cli.js";
|
|
5
|
+
import { styleText as s } from "node:util";
|
|
6
|
+
function v(e, l = !0) {
|
|
7
|
+
if (i.project !== void 0)
|
|
8
|
+
throw Error(
|
|
9
|
+
"A different ts-morph Project is already in use. Dispose of it before creating a new one. Example: using project = createProjectInstance(...)"
|
|
10
|
+
);
|
|
11
|
+
const n = i.codemod.meta.needsTypeInformation, t = new p({
|
|
12
|
+
// If tsconfig is missing, or project is untyped, use a permissive and
|
|
13
|
+
// compatible default config
|
|
14
|
+
compilerOptions: e.typeScriptConfig?.compilerOptions ?? {
|
|
15
|
+
...m,
|
|
16
|
+
// Read types from JSDoc annotations if present
|
|
17
|
+
checkJs: n
|
|
18
|
+
},
|
|
19
|
+
// We take care of reading the config file
|
|
20
|
+
tsConfigFilePath: void 0,
|
|
21
|
+
// We add files manually below
|
|
22
|
+
skipAddingFilesFromTsConfig: !0,
|
|
23
|
+
// We call this manually if needed below.
|
|
24
|
+
skipFileDependencyResolution: !0,
|
|
25
|
+
skipLoadingLibFiles: !n
|
|
26
|
+
}), f = e.filePaths.flatMap((o) => {
|
|
27
|
+
const c = t.addSourceFileAtPathIfExists(o);
|
|
28
|
+
return c === void 0 ? [] : [c];
|
|
29
|
+
});
|
|
30
|
+
if (n && t.resolveSourceFileDependencies(), l) {
|
|
31
|
+
const o = a.relative(process.cwd(), e.cwd);
|
|
32
|
+
process.stdout.write(""), d(
|
|
33
|
+
"info",
|
|
34
|
+
s("blue", o === "" ? process.cwd() : o),
|
|
35
|
+
`Running the codemod on ${s("blue", String(e.filePaths.length))} file${e.filePaths.length !== 1 ? "s" : ""}${e.packageJson?.contents.name === void 0 ? "" : ` from ${s("blue", e.packageJson.contents.name)}`}`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const r = {
|
|
39
|
+
[Symbol.dispose]() {
|
|
40
|
+
t.saveSync(), t.getRootDirectories().forEach((o) => o.forget()), i.project = void 0;
|
|
41
|
+
},
|
|
42
|
+
projectData: e,
|
|
43
|
+
// Resolved dependencies support type checking but are not codemod targets.
|
|
44
|
+
getCodemodFiles: () => f,
|
|
45
|
+
tsMorph: t
|
|
46
|
+
};
|
|
47
|
+
return i.project = r, r;
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
v as c
|
|
51
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "./cli
|
|
1
|
+
import "./chunks/cli.js";
|
|
2
2
|
import "@arcgis/toolkit/log";
|
|
3
3
|
import "@commander-js/extra-typings";
|
|
4
|
-
import "node:fs";
|
|
4
|
+
import "node:fs/promises";
|
|
5
5
|
import "@arcgis/node-toolkit/path";
|
|
6
|
+
import "@arcgis/node-toolkit/file";
|
|
6
7
|
import "node:util";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/codemod",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-next.0",
|
|
4
4
|
"description": "A codemod toolkit for updating and modernizing ArcGIS Maps SDK for JavaScript codebases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@arcgis/api-extractor": "
|
|
15
|
-
"@arcgis/node-toolkit": "
|
|
16
|
-
"@arcgis/toolkit": "
|
|
14
|
+
"@arcgis/api-extractor": "6.0.0-next.0",
|
|
15
|
+
"@arcgis/node-toolkit": "6.0.0-next.0",
|
|
16
|
+
"@arcgis/toolkit": "6.0.0-next.0",
|
|
17
17
|
"@commander-js/extra-typings": "^15.0.0",
|
|
18
18
|
"commander": "^15.0.0",
|
|
19
19
|
"tinyglobby": "~0.2.17",
|
package/dist/actions-CE74rP-z.js
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
import { path as T } from "@arcgis/node-toolkit/path";
|
|
2
|
-
import { SyntaxKind as g } from "ts-morph";
|
|
3
|
-
import { g as x } from "./cli-x1Uhjnb_.js";
|
|
4
|
-
import { ModuleResolutionKind as D } from "typescript";
|
|
5
|
-
import { capitalize as S } from "@arcgis/toolkit/string";
|
|
6
|
-
import { log as q } from "@arcgis/toolkit/log";
|
|
7
|
-
function w(e) {
|
|
8
|
-
const n = e.typeScriptConfig?.compilerOptions?.moduleResolution ?? D.Bundler;
|
|
9
|
-
return n >= D.Node16 && n <= D.NodeNext;
|
|
10
|
-
}
|
|
11
|
-
function b(e) {
|
|
12
|
-
return C(e.getFilePath());
|
|
13
|
-
}
|
|
14
|
-
function C(e) {
|
|
15
|
-
return T.relative(process.cwd(), e);
|
|
16
|
-
}
|
|
17
|
-
function J(e, n) {
|
|
18
|
-
const o = {};
|
|
19
|
-
K(e);
|
|
20
|
-
const { specifiers: l, names: u, lastImportIndex: a } = A(e), d = [], t = {};
|
|
21
|
-
let c = w(x.project.projectData);
|
|
22
|
-
for (const [i, m] of Object.entries(n)) {
|
|
23
|
-
let s = l.get(i) ?? (i.startsWith(".") ? l.get(
|
|
24
|
-
T.relative(e.getDirectoryPath(), T.resolve(x.project.projectData.cwd, i))
|
|
25
|
-
) : void 0);
|
|
26
|
-
if (s === void 0) {
|
|
27
|
-
const f = l.get(`${i}.js`);
|
|
28
|
-
f !== void 0 && (c = !0, s === void 0 ? s = f : s = [...s, ...f]);
|
|
29
|
-
}
|
|
30
|
-
for (const [f, y] of Object.entries(m)) {
|
|
31
|
-
const N = Array.isArray(y) ? y : [y];
|
|
32
|
-
for (const I of N)
|
|
33
|
-
I.do === "deprecate" ? P(f, i, o, s) : I.do === "add" ? E(i, f, I, s, d, t, u) : I.do === "rename" && W(i, f, I, s, d, t, u);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const p = Object.entries(t);
|
|
37
|
-
let r = a;
|
|
38
|
-
for (let i = 0; i < p.length; i += 1) {
|
|
39
|
-
const [m, s] = p[i], f = m.startsWith(".") ? M(
|
|
40
|
-
T.relative(e.getDirectoryPath(), T.resolve(x.project.projectData.cwd, m))
|
|
41
|
-
) : m, y = c && f.startsWith("@arcgis/core") ? `${f}.js` : f, N = s.afterDeclaration === void 0 ? r : s.afterDeclaration.getChildIndex() + 1;
|
|
42
|
-
if (s.named.length > 0) {
|
|
43
|
-
let I = !0;
|
|
44
|
-
for (let v = 0; v < s.named.length; v += 1)
|
|
45
|
-
I &&= s.named[v].isTypeOnly;
|
|
46
|
-
e.insertImportDeclaration(N, {
|
|
47
|
-
isTypeOnly: I,
|
|
48
|
-
moduleSpecifier: y,
|
|
49
|
-
namedImports: s.named.map((v) => ({
|
|
50
|
-
name: v.name,
|
|
51
|
-
alias: v.alias,
|
|
52
|
-
isTypeOnly: v.isTypeOnly && !I
|
|
53
|
-
}))
|
|
54
|
-
}), r += 1;
|
|
55
|
-
}
|
|
56
|
-
s.default !== void 0 && (e.insertImportDeclaration(N, {
|
|
57
|
-
isTypeOnly: s.default.isTypeOnly,
|
|
58
|
-
moduleSpecifier: y,
|
|
59
|
-
defaultImport: s.default.name
|
|
60
|
-
}), r += 1), s["*"] !== void 0 && (e.insertImportDeclaration(N, {
|
|
61
|
-
isTypeOnly: s["*"].isTypeOnly,
|
|
62
|
-
moduleSpecifier: y,
|
|
63
|
-
namespaceImport: s["*"].name
|
|
64
|
-
}), r += 1);
|
|
65
|
-
}
|
|
66
|
-
if (Object.keys(o).length > 0) {
|
|
67
|
-
const i = Object.entries(o).map(([m, s]) => `${s.join(", ")} from ${m}`).join("; ");
|
|
68
|
-
q("warn", b(e), `Deprecated API usages found: ${i}`);
|
|
69
|
-
}
|
|
70
|
-
return d;
|
|
71
|
-
}
|
|
72
|
-
function K(e) {
|
|
73
|
-
const n = e.getChildSyntaxList()?.getFirstChild();
|
|
74
|
-
if (j === n)
|
|
75
|
-
return;
|
|
76
|
-
j = n, h.clear();
|
|
77
|
-
const o = /* @__PURE__ */ new Set();
|
|
78
|
-
l(e);
|
|
79
|
-
function l(u) {
|
|
80
|
-
for (const a of u.getStatements())
|
|
81
|
-
if (a.isKind(g.ImportDeclaration)) {
|
|
82
|
-
const d = a.getDefaultImport(), t = a.getNamespaceImport(), c = a.getNamedImports();
|
|
83
|
-
d && o.add(d.getText()), t && o.add(t.getText());
|
|
84
|
-
for (const p of c)
|
|
85
|
-
o.add(p.getAliasNode()?.getText() ?? p.getName());
|
|
86
|
-
} else a.isKind(g.ImportEqualsDeclaration) ? o.add(a.getName()) : a.isKind(g.ModuleDeclaration) ? l(a) : u.forEachDescendant((d) => {
|
|
87
|
-
if (!d.isKind(g.Identifier))
|
|
88
|
-
return;
|
|
89
|
-
const t = d.getParent();
|
|
90
|
-
if (t.isKind(g.QualifiedName) && t.getLeft() !== d || t.isKind(g.PropertyAccessExpression) && t.getExpression() !== d || (t.isKind(g.PropertyDeclaration) || t.isKind(g.PropertySignature) || t.isKind(g.PropertyAssignment)) && t.getNameNode() === d)
|
|
91
|
-
return;
|
|
92
|
-
const c = d.getText();
|
|
93
|
-
o.has(c) || h.add(d.getText());
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function A(e) {
|
|
98
|
-
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), l = e.getStatements();
|
|
99
|
-
let u;
|
|
100
|
-
for (let d = 0; d < l.length; d += 1) {
|
|
101
|
-
const t = l[d];
|
|
102
|
-
if (!t.isKind(g.ImportDeclaration)) {
|
|
103
|
-
const f = t.getName?.();
|
|
104
|
-
f !== void 0 && o.add(f);
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
u = t;
|
|
108
|
-
const c = t.getModuleSpecifierValue(), p = n.get(c);
|
|
109
|
-
p === void 0 ? n.set(c, [t]) : p.push(t);
|
|
110
|
-
const r = t.getImportClause();
|
|
111
|
-
if (r === void 0)
|
|
112
|
-
continue;
|
|
113
|
-
const i = r.getDefaultImport()?.getText();
|
|
114
|
-
i !== void 0 && o.add(i);
|
|
115
|
-
const m = r.getNamedBindings();
|
|
116
|
-
if (m !== void 0)
|
|
117
|
-
if (m.isKind(g.NamedImports))
|
|
118
|
-
for (const s of m.getElements()) {
|
|
119
|
-
const f = s.getName();
|
|
120
|
-
o.add(f);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
const s = m.getName();
|
|
124
|
-
o.add(s);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const a = u === void 0 ? 0 : u.getChildIndex() + 1;
|
|
128
|
-
return { specifiers: n, names: o, lastImportIndex: a };
|
|
129
|
-
}
|
|
130
|
-
function P(e, n, o, l) {
|
|
131
|
-
if (l !== void 0) {
|
|
132
|
-
if (e === "default")
|
|
133
|
-
for (const u of l) {
|
|
134
|
-
const a = u.getDefaultImport();
|
|
135
|
-
if (a !== void 0) {
|
|
136
|
-
o[n] ??= [], o[n].push(a.getText());
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else if (e === "*")
|
|
141
|
-
for (const u of l) {
|
|
142
|
-
const a = u.getNamespaceImport();
|
|
143
|
-
if (a !== void 0) {
|
|
144
|
-
o[n] ??= [], o[n].push(a.getText());
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else
|
|
149
|
-
for (const u of l)
|
|
150
|
-
for (const a of u.getNamedImports())
|
|
151
|
-
if (a.getName() === e) {
|
|
152
|
-
o[n] ??= [], o[n].push(a.getName());
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
function E(e, n, o, l, u, a, d) {
|
|
158
|
-
const t = n === "default";
|
|
159
|
-
if (t || n === "*") {
|
|
160
|
-
if (l !== void 0)
|
|
161
|
-
for (const p of l) {
|
|
162
|
-
const r = t ? p.getDefaultImport() : p.getNamespaceImport();
|
|
163
|
-
if (r !== void 0) {
|
|
164
|
-
o.isTypeOnly !== !0 && p.isTypeOnly() && p.setIsTypeOnly(!1), u.push({
|
|
165
|
-
specifier: e,
|
|
166
|
-
requestedName: n,
|
|
167
|
-
actualName: r.getText()
|
|
168
|
-
});
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
const c = O(o.preferredAlias, void 0, e, d);
|
|
173
|
-
u.push({ specifier: e, requestedName: n, actualName: c }), a[e] ??= {
|
|
174
|
-
afterDeclaration: void 0,
|
|
175
|
-
named: [],
|
|
176
|
-
default: void 0,
|
|
177
|
-
"*": void 0
|
|
178
|
-
}, a[e].afterDeclaration ??= l?.[0], a[e][n] = {
|
|
179
|
-
name: c,
|
|
180
|
-
isTypeOnly: o.isTypeOnly === !0
|
|
181
|
-
};
|
|
182
|
-
} else {
|
|
183
|
-
let c, p;
|
|
184
|
-
if (l !== void 0) {
|
|
185
|
-
let m = !1;
|
|
186
|
-
for (const s of l)
|
|
187
|
-
if (s.getNamespaceImport() === void 0) {
|
|
188
|
-
p ??= s, c ??= s.isTypeOnly() && s.getDefaultImport() === void 0 ? s : void 0;
|
|
189
|
-
for (const f of s.getNamedImports())
|
|
190
|
-
if (f.getNameNode().getText() === n) {
|
|
191
|
-
if (m = !0, o.isTypeOnly !== !0) {
|
|
192
|
-
if (f.isTypeOnly())
|
|
193
|
-
f.setIsTypeOnly(!1);
|
|
194
|
-
else if (s.isTypeOnly()) {
|
|
195
|
-
for (const y of s.getNamedImports())
|
|
196
|
-
y !== f && y.setIsTypeOnly(!0);
|
|
197
|
-
s.setIsTypeOnly(!1);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
u.push({
|
|
201
|
-
specifier: e,
|
|
202
|
-
requestedName: n,
|
|
203
|
-
actualName: f.getAliasNode()?.getText() ?? n
|
|
204
|
-
});
|
|
205
|
-
break;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (m)
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
const r = O(
|
|
212
|
-
o.preferAlias === !0 ? o.preferredAlias : n,
|
|
213
|
-
o.preferAlias === !0 ? n : o.preferredAlias,
|
|
214
|
-
e,
|
|
215
|
-
d
|
|
216
|
-
), i = n === r ? void 0 : r;
|
|
217
|
-
if (o.isTypeOnly && c !== void 0)
|
|
218
|
-
c.addNamedImport({
|
|
219
|
-
name: n,
|
|
220
|
-
alias: i
|
|
221
|
-
});
|
|
222
|
-
else if (p !== void 0 && (!o.isTypeOnly || p.getDefaultImport() === void 0)) {
|
|
223
|
-
if (p.isTypeOnly() && !o.isTypeOnly) {
|
|
224
|
-
p.setIsTypeOnly(!1);
|
|
225
|
-
for (const m of p.getNamedImports())
|
|
226
|
-
m.setIsTypeOnly(!0);
|
|
227
|
-
}
|
|
228
|
-
p.addNamedImport({
|
|
229
|
-
name: n,
|
|
230
|
-
alias: i,
|
|
231
|
-
isTypeOnly: o.isTypeOnly && !p.isTypeOnly()
|
|
232
|
-
});
|
|
233
|
-
} else
|
|
234
|
-
a[e] ??= {
|
|
235
|
-
afterDeclaration: void 0,
|
|
236
|
-
named: [],
|
|
237
|
-
default: void 0,
|
|
238
|
-
"*": void 0
|
|
239
|
-
}, a[e].afterDeclaration ??= l?.[0], a[e].named.push({
|
|
240
|
-
name: n,
|
|
241
|
-
alias: i,
|
|
242
|
-
isTypeOnly: o.isTypeOnly === !0
|
|
243
|
-
});
|
|
244
|
-
u.push({ specifier: e, requestedName: n, actualName: r });
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
function W(e, n, o, l, u, a, d) {
|
|
248
|
-
if (l === void 0)
|
|
249
|
-
return;
|
|
250
|
-
const t = o.name ?? n, c = o.specifier ?? e, p = n === "default";
|
|
251
|
-
if (p || n === "*") {
|
|
252
|
-
for (const r of l) {
|
|
253
|
-
const i = p ? r.getDefaultImport() : r.getNamespaceImport();
|
|
254
|
-
if (i === void 0)
|
|
255
|
-
continue;
|
|
256
|
-
if (o.isTypeOnly === !1 && r.isTypeOnly()) {
|
|
257
|
-
r.setIsTypeOnly(!1);
|
|
258
|
-
for (const s of r.getNamedImports())
|
|
259
|
-
s.setIsTypeOnly(!0);
|
|
260
|
-
}
|
|
261
|
-
let m = t;
|
|
262
|
-
if (t !== n) {
|
|
263
|
-
const s = O(t, n, e, d);
|
|
264
|
-
t === s ? i.rename(t) : m = i.getText();
|
|
265
|
-
} else
|
|
266
|
-
m = i.getText();
|
|
267
|
-
e !== c && (r.getNamedImports().length === 0 ? r.setModuleSpecifier(c) : (p ? r.removeDefaultImport() : r.removeNamespaceImport(), a[c] ??= {
|
|
268
|
-
afterDeclaration: void 0,
|
|
269
|
-
named: [],
|
|
270
|
-
default: void 0,
|
|
271
|
-
"*": void 0
|
|
272
|
-
}, a[c].afterDeclaration ??= r, a[c][n] = {
|
|
273
|
-
name: m,
|
|
274
|
-
isTypeOnly: r.isTypeOnly()
|
|
275
|
-
})), u.push({
|
|
276
|
-
specifier: c,
|
|
277
|
-
requestedName: n,
|
|
278
|
-
actualName: m
|
|
279
|
-
});
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
for (const r of l)
|
|
285
|
-
for (const i of r.getNamedImports()) {
|
|
286
|
-
if (i.getNameNode().getText() !== n)
|
|
287
|
-
continue;
|
|
288
|
-
if (o.isTypeOnly === !1) {
|
|
289
|
-
if (i.isTypeOnly())
|
|
290
|
-
i.setIsTypeOnly(!1);
|
|
291
|
-
else if (r.isTypeOnly()) {
|
|
292
|
-
r.setIsTypeOnly(!1);
|
|
293
|
-
for (const f of r.getNamedImports())
|
|
294
|
-
f !== i && f.setIsTypeOnly(!0);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
let m = t;
|
|
298
|
-
const s = i.getAliasNode();
|
|
299
|
-
if (t !== n)
|
|
300
|
-
if (s === void 0) {
|
|
301
|
-
const f = O(t, n, e, d);
|
|
302
|
-
t === f ? i.getNameNode().asKind(g.Identifier)?.rename(t) : (i.setAlias(n), i.getNameNode().replaceWithText(t), m = n);
|
|
303
|
-
} else
|
|
304
|
-
i.getNameNode().replaceWithText(t), m = s.getText();
|
|
305
|
-
if (c !== e) {
|
|
306
|
-
const y = (w(x.project.projectData) || r.getModuleSpecifierValue().endsWith(".js")) && c.startsWith("@arcgis/core") ? `${c}.js` : c;
|
|
307
|
-
r.getNamedImports().length === 1 && r.getDefaultImport() === void 0 ? r.setModuleSpecifier(y) : (a[y] ??= {
|
|
308
|
-
afterDeclaration: void 0,
|
|
309
|
-
named: [],
|
|
310
|
-
default: void 0,
|
|
311
|
-
"*": void 0
|
|
312
|
-
}, a[y].afterDeclaration ??= l?.[0], a[y].named.push({
|
|
313
|
-
name: t,
|
|
314
|
-
alias: t === m ? void 0 : m,
|
|
315
|
-
isTypeOnly: i.isTypeOnly()
|
|
316
|
-
}), i.remove());
|
|
317
|
-
}
|
|
318
|
-
u.push({
|
|
319
|
-
specifier: c,
|
|
320
|
-
requestedName: t,
|
|
321
|
-
actualName: s?.getText() ?? m
|
|
322
|
-
});
|
|
323
|
-
return;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
function O(e, n, o, l) {
|
|
327
|
-
if (e !== void 0) {
|
|
328
|
-
if (!l.has(e) && !h.has(e))
|
|
329
|
-
return l.add(e), e;
|
|
330
|
-
if (n !== void 0)
|
|
331
|
-
return O(n, void 0, o, l);
|
|
332
|
-
}
|
|
333
|
-
o.startsWith("@arcgis/core") && (o = `arcgisCore${o.slice(12)}`);
|
|
334
|
-
const u = o.split("/");
|
|
335
|
-
let a = e ?? "";
|
|
336
|
-
for (let d = u.length - 1; d >= 0; d--) {
|
|
337
|
-
const t = u[d].replaceAll($, "");
|
|
338
|
-
if (t !== a && (a = t + S(a), !l.has(a) && !h.has(a)))
|
|
339
|
-
return l.add(a), a;
|
|
340
|
-
}
|
|
341
|
-
for (let d = 2; ; d++) {
|
|
342
|
-
const t = a + d;
|
|
343
|
-
if (!l.has(t) && !h.has(t))
|
|
344
|
-
return l.add(t), t;
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
const $ = /[^a-zA-Z0-9$_]/gu, M = (e) => e.startsWith(".") ? e : `./${e}`, h = /* @__PURE__ */ new Set();
|
|
348
|
-
let j;
|
|
349
|
-
export {
|
|
350
|
-
b as a,
|
|
351
|
-
C as f,
|
|
352
|
-
J as p,
|
|
353
|
-
K as u
|
|
354
|
-
};
|