@analogjs/vite-plugin-angular 3.0.0-beta.13 → 3.0.0-beta.14
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/ngp/LICENSE +21 -0
- package/ngp/api.mjs +46048 -0
- package/ngp/build.json +4 -0
- package/ngp/ng_analyze.cjs +504 -0
- package/ngp/ng_analyze_bg.wasm +0 -0
- package/package.json +1 -1
- package/src/lib/angular-vite-plugin.d.ts +9 -2
- package/src/lib/angular-vite-plugin.js +11 -6
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/fast-compile-plugin.d.ts +1 -0
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/ngp-compile-plugin.d.ts +3 -0
- package/src/lib/ngp-compile-plugin.js +262 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/utils/tsgo-checker.d.ts +42 -0
- package/src/lib/utils/tsgo-checker.js +467 -0
- package/src/lib/utils/tsgo-checker.js.map +1 -0
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, relative, resolve } from "node:path";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { parseSync } from "oxc-parser";
|
|
5
|
+
import MagicString from "magic-string";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
//#region packages/vite-plugin-angular/src/lib/utils/tsgo-checker.ts
|
|
9
|
+
/** NGP's footer comment mapping TCB ids to the template they were generated from. */
|
|
10
|
+
var TCB_TEMPLATE_SOURCES_PREFIX = "ngp-tcb-template-sources:";
|
|
11
|
+
var IGNORED_TCB_CODES = /* @__PURE__ */ new Set([
|
|
12
|
+
6133,
|
|
13
|
+
6199,
|
|
14
|
+
2695,
|
|
15
|
+
7006
|
|
16
|
+
]);
|
|
17
|
+
var BATCH_SIZE = 32;
|
|
18
|
+
var TCB_IMPORT_ALIAS = /^(?:_tcb_)?_?i\d+$/;
|
|
19
|
+
var TCB_LOCAL_NAME = /^(?:_tcb|_ctor|_pipe)\d+$/;
|
|
20
|
+
var SPAN_COMMENT = /^(\d+),(\d+)$/;
|
|
21
|
+
function readSpanComment(value) {
|
|
22
|
+
const match = SPAN_COMMENT.exec(value);
|
|
23
|
+
return match ? {
|
|
24
|
+
start: Number(match[1]),
|
|
25
|
+
end: Number(match[2])
|
|
26
|
+
} : null;
|
|
27
|
+
}
|
|
28
|
+
function walk(node, visit) {
|
|
29
|
+
if (Array.isArray(node)) {
|
|
30
|
+
for (const child of node) walk(child, visit);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (!node || typeof node.type !== "string") return;
|
|
34
|
+
visit(node);
|
|
35
|
+
for (const key in node) {
|
|
36
|
+
const value = node[key];
|
|
37
|
+
if (value && typeof value === "object") walk(value, visit);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function declaredName(stmt) {
|
|
41
|
+
if (stmt.type === "VariableDeclaration") return stmt.declarations[0]?.id?.name;
|
|
42
|
+
if (stmt.type === "FunctionDeclaration" || stmt.type === "TSDeclareFunction") return stmt.id?.name;
|
|
43
|
+
}
|
|
44
|
+
function isTcbImport(stmt) {
|
|
45
|
+
const ns = stmt.type === "ImportDeclaration" && stmt.specifiers[0];
|
|
46
|
+
return ns?.type === "ImportNamespaceSpecifier" && TCB_IMPORT_ALIAS.test(ns.local.name);
|
|
47
|
+
}
|
|
48
|
+
function splitTcb(tcbCode) {
|
|
49
|
+
if (!tcbCode.includes("/*tcb")) return null;
|
|
50
|
+
const { program, comments, errors } = parseSync("tcb.ts", tcbCode);
|
|
51
|
+
if (errors.length > 0) return null;
|
|
52
|
+
const parts = {
|
|
53
|
+
source: [],
|
|
54
|
+
imports: [],
|
|
55
|
+
blocks: [],
|
|
56
|
+
templateSources: {}
|
|
57
|
+
};
|
|
58
|
+
const footer = comments.find((c) => c.value.startsWith(TCB_TEMPLATE_SOURCES_PREFIX));
|
|
59
|
+
if (footer) parts.templateSources = JSON.parse(footer.value.slice(25));
|
|
60
|
+
for (const stmt of program.body) if (TCB_LOCAL_NAME.test(declaredName(stmt) ?? "")) parts.blocks.push(stmt);
|
|
61
|
+
else {
|
|
62
|
+
parts.source.push(stmt);
|
|
63
|
+
if (isTcbImport(stmt)) parts.imports.push(stmt);
|
|
64
|
+
}
|
|
65
|
+
return parts.blocks.length > 0 ? parts : null;
|
|
66
|
+
}
|
|
67
|
+
function inPlaceDocument(filePath, sourceCode, tcbCode) {
|
|
68
|
+
const lines = sourceCode.split("\n");
|
|
69
|
+
const sourceLineCount = lines.length;
|
|
70
|
+
if (!tcbCode) return {
|
|
71
|
+
text: sourceCode,
|
|
72
|
+
meta: {
|
|
73
|
+
filePath,
|
|
74
|
+
sourceLineCount
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const parts = splitTcb(tcbCode);
|
|
78
|
+
const suffix = parts ? [...parts.imports, ...parts.blocks].map((stmt) => tcbCode.slice(stmt.start, stmt.end)).join("\n") : tcbCode;
|
|
79
|
+
lines.push(...suffix.split("\n"));
|
|
80
|
+
const range = {
|
|
81
|
+
startLine: sourceLineCount,
|
|
82
|
+
endLine: lines.length,
|
|
83
|
+
filePath,
|
|
84
|
+
sourceCode,
|
|
85
|
+
templateSources: parts?.templateSources ?? {}
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
text: lines.join("\n"),
|
|
89
|
+
meta: {
|
|
90
|
+
filePath,
|
|
91
|
+
sourceLineCount,
|
|
92
|
+
lines,
|
|
93
|
+
tcbRanges: [range]
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function trailingSpan(text, pos, commentsByStart) {
|
|
98
|
+
while (true) {
|
|
99
|
+
while (pos < text.length && /\s/.test(text[pos])) pos++;
|
|
100
|
+
const comment = commentsByStart.get(pos);
|
|
101
|
+
if (!comment) return null;
|
|
102
|
+
const span = readSpanComment(comment.value);
|
|
103
|
+
if (span) return span;
|
|
104
|
+
pos = comment.end;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function lineAndCharacter(text, offset) {
|
|
108
|
+
const before = text.slice(0, offset).split("\n");
|
|
109
|
+
return {
|
|
110
|
+
line: before.length,
|
|
111
|
+
character: before[before.length - 1].length + 1
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function templateLocation(range, lines, position) {
|
|
115
|
+
const chunk = lines.slice(range.startLine, range.endLine).join("\n");
|
|
116
|
+
let offset = position.character;
|
|
117
|
+
for (let i = range.startLine; i < position.line; i++) offset += lines[i].length + 1;
|
|
118
|
+
const { program, comments } = parseSync("tcb.ts", chunk);
|
|
119
|
+
const commentsByStart = new Map(comments.map((c) => [c.start, c]));
|
|
120
|
+
const ancestors = [];
|
|
121
|
+
walk(program.body, (node) => {
|
|
122
|
+
if (node.start <= offset && offset < node.end) ancestors.push(node);
|
|
123
|
+
});
|
|
124
|
+
const tcbFunction = ancestors.find((node) => node.type === "FunctionDeclaration" && /_tcb\d+$/.test(node.id?.name));
|
|
125
|
+
let span = null;
|
|
126
|
+
for (let i = ancestors.length - 1; i >= 0 && !span; i--) span = trailingSpan(chunk, ancestors[i].end, commentsByStart);
|
|
127
|
+
if (!tcbFunction || !span) return null;
|
|
128
|
+
const id = /(tcb\d+)$/.exec(tcbFunction.id.name)[1];
|
|
129
|
+
const source = range.templateSources[id];
|
|
130
|
+
const file = source?.templateFile ?? range.filePath;
|
|
131
|
+
let content = range.sourceCode;
|
|
132
|
+
if (source?.templateFile) try {
|
|
133
|
+
content = readFileSync(source.templateFile, "utf-8");
|
|
134
|
+
} catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const start = source?.templateExpression?.start ?? span.start;
|
|
138
|
+
return {
|
|
139
|
+
file,
|
|
140
|
+
...lineAndCharacter(content, start)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function isBareTypeReference(type) {
|
|
144
|
+
return type?.type === "TSTypeReference" && type.typeName.type === "Identifier";
|
|
145
|
+
}
|
|
146
|
+
function collectExportedClasses(header) {
|
|
147
|
+
const exported = /* @__PURE__ */ new Map();
|
|
148
|
+
for (const stmt of header) {
|
|
149
|
+
const cls = stmt.declaration;
|
|
150
|
+
if (cls?.type !== "ClassDeclaration" || !cls.id) continue;
|
|
151
|
+
if (stmt.type === "ExportDefaultDeclaration") exported.set(cls.id.name, "default");
|
|
152
|
+
else if (stmt.type === "ExportNamedDeclaration") exported.set(cls.id.name, cls.id.name);
|
|
153
|
+
}
|
|
154
|
+
return exported;
|
|
155
|
+
}
|
|
156
|
+
function hostRelativeSpecifier(absPath, hostDir) {
|
|
157
|
+
const spec = relative(hostDir, absPath).replace(/\\/g, "/");
|
|
158
|
+
return spec.startsWith(".") ? spec : "./" + spec;
|
|
159
|
+
}
|
|
160
|
+
function sharedAliasFor(spec, sharedImports) {
|
|
161
|
+
let alias = sharedImports.get(spec);
|
|
162
|
+
if (!alias) {
|
|
163
|
+
alias = `_si${sharedImports.size}`;
|
|
164
|
+
sharedImports.set(spec, alias);
|
|
165
|
+
}
|
|
166
|
+
return alias;
|
|
167
|
+
}
|
|
168
|
+
function relocateTcb(filePath, tcbCode, hostDir, fileIdx, sharedImports) {
|
|
169
|
+
const parts = splitTcb(tcbCode);
|
|
170
|
+
if (!parts) return null;
|
|
171
|
+
const aliasSpecs = /* @__PURE__ */ new Map();
|
|
172
|
+
for (const stmt of parts.imports) aliasSpecs.set(stmt.specifiers[0].local.name, stmt.source.value);
|
|
173
|
+
const exportedClasses = collectExportedClasses(parts.source);
|
|
174
|
+
const identifiers = [];
|
|
175
|
+
const thisTypes = [];
|
|
176
|
+
let relocatable = true;
|
|
177
|
+
walk(parts.blocks, (node) => {
|
|
178
|
+
if (node.type === "Identifier") {
|
|
179
|
+
identifiers.push(node);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (node.type === "VariableDeclarator" && /^_pipe\d+$/.test(node.id.name) && isBareTypeReference(node.init?.typeAnnotation) || node.type === "TSFunctionType" && node.params[0]?.name === "init" && isBareTypeReference(node.returnType?.typeAnnotation)) {
|
|
183
|
+
relocatable = false;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (node.type !== "FunctionDeclaration" || !/^_tcb\d+$/.test(node.id?.name)) return;
|
|
187
|
+
const thisType = node.params[0]?.typeAnnotation?.typeAnnotation;
|
|
188
|
+
if (node.params[0]?.name !== "this" || !isBareTypeReference(thisType)) return;
|
|
189
|
+
const exportProp = exportedClasses.get(thisType.typeName.name);
|
|
190
|
+
if (node.typeParameters || !exportProp) {
|
|
191
|
+
relocatable = false;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
thisTypes.push({
|
|
195
|
+
node: thisType.typeName,
|
|
196
|
+
exportProp
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
if (!relocatable) return null;
|
|
200
|
+
const fileDir = dirname(resolve(filePath));
|
|
201
|
+
const aliasMap = /* @__PURE__ */ new Map();
|
|
202
|
+
for (const [alias, rawSpec] of aliasSpecs) {
|
|
203
|
+
const spec = rawSpec.startsWith(".") ? hostRelativeSpecifier(resolve(fileDir, rawSpec), hostDir) : rawSpec;
|
|
204
|
+
aliasMap.set(alias, sharedAliasFor(spec, sharedImports));
|
|
205
|
+
}
|
|
206
|
+
const ms = new MagicString(tcbCode);
|
|
207
|
+
for (const node of identifiers) if (TCB_LOCAL_NAME.test(node.name)) ms.overwrite(node.start, node.end, `_f${fileIdx}_${node.name}`);
|
|
208
|
+
else if (aliasMap.has(node.name)) ms.overwrite(node.start, node.end, aliasMap.get(node.name));
|
|
209
|
+
if (thisTypes.length > 0) {
|
|
210
|
+
const selfAlias = sharedAliasFor(hostRelativeSpecifier(resolve(filePath).replace(/\.[cm]?tsx?$/, ""), hostDir), sharedImports);
|
|
211
|
+
for (const { node, exportProp } of thisTypes) ms.overwrite(node.start, node.end, `${selfAlias}.${exportProp}`);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
body: parts.blocks.map((stmt) => ms.slice(stmt.start, stmt.end)).join("\n"),
|
|
215
|
+
templateSources: parts.templateSources
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
function resolveTsgoBinary(tsconfig) {
|
|
219
|
+
if (process.env["TSNATIVE_BINARY_PATH"]) return process.env["TSNATIVE_BINARY_PATH"];
|
|
220
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
221
|
+
const candidates = [{
|
|
222
|
+
parent: "typescript/package.json",
|
|
223
|
+
platform: `@typescript/typescript-${process.platform}-${process.arch}/package.json`,
|
|
224
|
+
bin: `tsc${ext}`
|
|
225
|
+
}, {
|
|
226
|
+
parent: "@typescript/native-preview/package.json",
|
|
227
|
+
platform: `@typescript/native-preview-${process.platform}-${process.arch}/package.json`,
|
|
228
|
+
bin: `tsgo${ext}`
|
|
229
|
+
}];
|
|
230
|
+
for (const base of [tsconfig, import.meta.url]) {
|
|
231
|
+
const req = createRequire(base);
|
|
232
|
+
for (const candidate of candidates) try {
|
|
233
|
+
const parentPkg = req.resolve(candidate.parent);
|
|
234
|
+
const platformPkg = createRequire(parentPkg).resolve(candidate.platform);
|
|
235
|
+
return resolve(dirname(platformPkg), "lib", candidate.bin);
|
|
236
|
+
} catch {}
|
|
237
|
+
}
|
|
238
|
+
throw new Error("disableTypeChecking: false requires TypeScript 7 (typescript@^7.0.0), @typescript/native-preview, or TSNATIVE_BINARY_PATH.");
|
|
239
|
+
}
|
|
240
|
+
var TsgoChecker = class {
|
|
241
|
+
proc;
|
|
242
|
+
seq = 1;
|
|
243
|
+
pending = /* @__PURE__ */ new Map();
|
|
244
|
+
versions = /* @__PURE__ */ new Map();
|
|
245
|
+
queued = /* @__PURE__ */ new Map();
|
|
246
|
+
buffer = Buffer.alloc(0);
|
|
247
|
+
exitError;
|
|
248
|
+
ready;
|
|
249
|
+
constructor(tsconfig) {
|
|
250
|
+
const cwd = dirname(tsconfig);
|
|
251
|
+
this.proc = spawn(resolveTsgoBinary(tsconfig), ["--lsp", "--stdio"], {
|
|
252
|
+
cwd,
|
|
253
|
+
stdio: [
|
|
254
|
+
"pipe",
|
|
255
|
+
"pipe",
|
|
256
|
+
"ignore"
|
|
257
|
+
]
|
|
258
|
+
});
|
|
259
|
+
this.proc.stdout.on("data", (chunk) => this.onData(chunk));
|
|
260
|
+
const fail = (error) => {
|
|
261
|
+
this.exitError ??= error;
|
|
262
|
+
for (const { reject } of this.pending.values()) reject(this.exitError);
|
|
263
|
+
this.pending.clear();
|
|
264
|
+
};
|
|
265
|
+
this.proc.on("error", fail);
|
|
266
|
+
this.proc.stdin.on("error", fail);
|
|
267
|
+
this.proc.on("exit", (code) => fail(/* @__PURE__ */ new Error(`tsgo exited with code ${code}`)));
|
|
268
|
+
const rootUri = pathToFileURL(cwd).href;
|
|
269
|
+
this.ready = this.request("initialize", {
|
|
270
|
+
processId: process.pid,
|
|
271
|
+
rootUri,
|
|
272
|
+
capabilities: { textDocument: { diagnostic: {} } },
|
|
273
|
+
workspaceFolders: [{
|
|
274
|
+
uri: rootUri,
|
|
275
|
+
name: "root"
|
|
276
|
+
}]
|
|
277
|
+
}).then(() => this.notify("initialized", {}));
|
|
278
|
+
this.ready.catch(() => {});
|
|
279
|
+
}
|
|
280
|
+
onData(chunk) {
|
|
281
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
282
|
+
while (true) {
|
|
283
|
+
const headerEnd = this.buffer.indexOf("\r\n\r\n");
|
|
284
|
+
if (headerEnd === -1) break;
|
|
285
|
+
const match = /Content-Length: (\d+)/i.exec(this.buffer.subarray(0, headerEnd).toString("utf8"));
|
|
286
|
+
if (!match) break;
|
|
287
|
+
const bodyStart = headerEnd + 4;
|
|
288
|
+
const bodyEnd = bodyStart + Number(match[1]);
|
|
289
|
+
if (this.buffer.length < bodyEnd) break;
|
|
290
|
+
const msg = JSON.parse(this.buffer.subarray(bodyStart, bodyEnd).toString("utf8"));
|
|
291
|
+
this.buffer = this.buffer.subarray(bodyEnd);
|
|
292
|
+
if (msg.id !== void 0 && msg.method !== void 0) this.send({
|
|
293
|
+
jsonrpc: "2.0",
|
|
294
|
+
id: msg.id,
|
|
295
|
+
result: null
|
|
296
|
+
});
|
|
297
|
+
else if (msg.id !== void 0 && this.pending.has(msg.id)) {
|
|
298
|
+
const entry = this.pending.get(msg.id);
|
|
299
|
+
this.pending.delete(msg.id);
|
|
300
|
+
if (msg.error) entry.reject(new Error(msg.error.message));
|
|
301
|
+
else entry.resolve(msg.result);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
send(payload) {
|
|
306
|
+
const json = JSON.stringify(payload);
|
|
307
|
+
this.proc.stdin.write(`Content-Length: ${Buffer.byteLength(json, "utf8")}\r\n\r\n${json}`);
|
|
308
|
+
}
|
|
309
|
+
notify(method, params) {
|
|
310
|
+
this.send({
|
|
311
|
+
jsonrpc: "2.0",
|
|
312
|
+
method,
|
|
313
|
+
params
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
request(method, params) {
|
|
317
|
+
if (this.exitError) return Promise.reject(this.exitError);
|
|
318
|
+
const id = this.seq++;
|
|
319
|
+
return new Promise((resolve, reject) => {
|
|
320
|
+
this.pending.set(id, {
|
|
321
|
+
resolve,
|
|
322
|
+
reject
|
|
323
|
+
});
|
|
324
|
+
this.send({
|
|
325
|
+
jsonrpc: "2.0",
|
|
326
|
+
id,
|
|
327
|
+
method,
|
|
328
|
+
params
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
updateDocument(filePath, text) {
|
|
333
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
334
|
+
if (!this.versions.has(uri)) {
|
|
335
|
+
this.versions.set(uri, 1);
|
|
336
|
+
this.notify("textDocument/didOpen", { textDocument: {
|
|
337
|
+
uri,
|
|
338
|
+
languageId: "typescript",
|
|
339
|
+
version: 1,
|
|
340
|
+
text
|
|
341
|
+
} });
|
|
342
|
+
}
|
|
343
|
+
const version = this.versions.get(uri) + 1;
|
|
344
|
+
this.versions.set(uri, version);
|
|
345
|
+
this.notify("textDocument/didChange", {
|
|
346
|
+
textDocument: {
|
|
347
|
+
uri,
|
|
348
|
+
version
|
|
349
|
+
},
|
|
350
|
+
contentChanges: [{ text }]
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
async checkFile(filePath, sourceLineCount, lines, tcbRanges) {
|
|
354
|
+
const resolvedPath = resolve(filePath);
|
|
355
|
+
const errors = [];
|
|
356
|
+
const diag = await this.request("textDocument/diagnostic", { textDocument: { uri: pathToFileURL(resolvedPath).href } });
|
|
357
|
+
for (const item of diag?.items ?? []) {
|
|
358
|
+
if (item.severity !== 1) continue;
|
|
359
|
+
const line = item.range.start.line;
|
|
360
|
+
if (sourceLineCount !== void 0 && line >= sourceLineCount) {
|
|
361
|
+
if (!IGNORED_TCB_CODES.has(Number(item.code)) && !lines?.[line]?.includes("/*D:ignore*/")) {
|
|
362
|
+
const range = tcbRanges?.find((r) => line >= r.startLine && line < r.endLine);
|
|
363
|
+
const location = range && lines && templateLocation(range, lines, item.range.start);
|
|
364
|
+
errors.push(location ? `${location.file}:${location.line}:${location.character} - error TS${item.code}: ${item.message}` : `${range?.filePath ?? filePath} (template): error TS${item.code}: ${item.message}`);
|
|
365
|
+
}
|
|
366
|
+
} else errors.push(`${filePath}:${line + 1}:${item.range.start.character + 1} - error TS${item.code}: ${item.message}`);
|
|
367
|
+
}
|
|
368
|
+
return errors;
|
|
369
|
+
}
|
|
370
|
+
queueFile(filePath, sourceCode, tcbCode) {
|
|
371
|
+
this.queued.set(filePath, {
|
|
372
|
+
sourceCode,
|
|
373
|
+
tcbCode
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
async flushQueue(watchMode = false) {
|
|
377
|
+
if (this.queued.size === 0) return [];
|
|
378
|
+
const entries = Array.from(this.queued.entries());
|
|
379
|
+
this.queued.clear();
|
|
380
|
+
await this.ready;
|
|
381
|
+
const metas = [];
|
|
382
|
+
let updatesCount = 0;
|
|
383
|
+
const update = async (filePath, text) => {
|
|
384
|
+
this.updateDocument(filePath, text);
|
|
385
|
+
updatesCount++;
|
|
386
|
+
if (updatesCount % BATCH_SIZE === 0) await new Promise((r) => setTimeout(r, 5));
|
|
387
|
+
};
|
|
388
|
+
if (!watchMode && entries.length > 1) {
|
|
389
|
+
const [hostFilePath, hostItem] = entries[0];
|
|
390
|
+
const hostDir = dirname(resolve(hostFilePath));
|
|
391
|
+
const hostUri = pathToFileURL(resolve(hostFilePath)).href;
|
|
392
|
+
const sharedImports = /* @__PURE__ */ new Map();
|
|
393
|
+
const relocatedChunks = [];
|
|
394
|
+
let hostRelocated = false;
|
|
395
|
+
for (let i = 0; i < entries.length; i++) {
|
|
396
|
+
const [filePath, { sourceCode, tcbCode }] = entries[i];
|
|
397
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
398
|
+
if (tcbCode && !this.versions.has(uri)) {
|
|
399
|
+
const relocated = relocateTcb(filePath, tcbCode, hostDir, i, sharedImports);
|
|
400
|
+
if (relocated !== null) {
|
|
401
|
+
relocatedChunks.push({
|
|
402
|
+
filePath,
|
|
403
|
+
sourceCode,
|
|
404
|
+
...relocated
|
|
405
|
+
});
|
|
406
|
+
if (i === 0) hostRelocated = true;
|
|
407
|
+
else metas.push({
|
|
408
|
+
filePath,
|
|
409
|
+
sourceLineCount: sourceCode.split("\n").length
|
|
410
|
+
});
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (i === 0) continue;
|
|
415
|
+
const { text, meta } = inPlaceDocument(filePath, sourceCode, tcbCode);
|
|
416
|
+
if (tcbCode || this.versions.has(uri)) await update(filePath, text);
|
|
417
|
+
metas.push(meta);
|
|
418
|
+
}
|
|
419
|
+
const { meta: hostMeta } = inPlaceDocument(hostFilePath, hostItem.sourceCode, hostRelocated ? null : hostItem.tcbCode);
|
|
420
|
+
const hostLines = hostMeta.lines ?? hostItem.sourceCode.split("\n");
|
|
421
|
+
const hostTcbRanges = hostMeta.tcbRanges ?? [];
|
|
422
|
+
if (relocatedChunks.length > 0) {
|
|
423
|
+
for (const [spec, alias] of sharedImports) hostLines.push(`import * as ${alias} from '${spec}';`);
|
|
424
|
+
for (const { filePath, sourceCode, body, templateSources } of relocatedChunks) {
|
|
425
|
+
const startLine = hostLines.length;
|
|
426
|
+
hostLines.push(...body.split("\n"));
|
|
427
|
+
hostTcbRanges.push({
|
|
428
|
+
startLine,
|
|
429
|
+
endLine: hostLines.length,
|
|
430
|
+
filePath,
|
|
431
|
+
sourceCode,
|
|
432
|
+
templateSources
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
const hasHostTcb = hostTcbRanges.length > 0;
|
|
437
|
+
if (hasHostTcb || this.versions.has(hostUri)) this.updateDocument(hostFilePath, hostLines.join("\n"));
|
|
438
|
+
metas.unshift({
|
|
439
|
+
filePath: hostFilePath,
|
|
440
|
+
sourceLineCount: hostMeta.sourceLineCount,
|
|
441
|
+
lines: hasHostTcb ? hostLines : void 0,
|
|
442
|
+
tcbRanges: hasHostTcb ? hostTcbRanges : void 0
|
|
443
|
+
});
|
|
444
|
+
} else for (const [filePath, { sourceCode, tcbCode }] of entries) {
|
|
445
|
+
const { text, meta } = inPlaceDocument(filePath, sourceCode, tcbCode);
|
|
446
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
447
|
+
if (tcbCode || watchMode || this.versions.has(uri)) await update(filePath, text);
|
|
448
|
+
metas.push(meta);
|
|
449
|
+
}
|
|
450
|
+
const errors = [];
|
|
451
|
+
const first = metas[0];
|
|
452
|
+
errors.push(...await this.checkFile(first.filePath, first.sourceLineCount, first.lines, first.tcbRanges));
|
|
453
|
+
for (let i = 1; i < metas.length; i += BATCH_SIZE) {
|
|
454
|
+
const slice = metas.slice(i, i + BATCH_SIZE);
|
|
455
|
+
const batchResults = await Promise.all(slice.map(({ filePath, sourceLineCount, lines, tcbRanges }) => this.checkFile(filePath, sourceLineCount, lines, tcbRanges)));
|
|
456
|
+
for (const res of batchResults) errors.push(...res);
|
|
457
|
+
}
|
|
458
|
+
return errors;
|
|
459
|
+
}
|
|
460
|
+
close() {
|
|
461
|
+
this.proc.kill();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
//#endregion
|
|
465
|
+
export { TCB_TEMPLATE_SOURCES_PREFIX, TsgoChecker, readSpanComment };
|
|
466
|
+
|
|
467
|
+
//# sourceMappingURL=tsgo-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsgo-checker.js","names":[],"sources":["../../../../src/lib/utils/tsgo-checker.ts"],"sourcesContent":["import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport { dirname, relative, resolve } from 'node:path';\nimport { readFileSync } from 'node:fs';\nimport { pathToFileURL } from 'node:url';\nimport MagicString from 'magic-string';\nimport { parseSync } from 'oxc-parser';\n\ninterface LspDiagnostic {\n range: { start: { line: number; character: number } };\n severity?: number;\n code?: number | string;\n message: string;\n}\n\n// Same shape as NGP's `TcbTemplateSource`\nexport interface TcbTemplateSource {\n templateFile?: string;\n templateExpression?: { start: number; end: number };\n}\n\ntype TemplateSources = Record<string, TcbTemplateSource>;\n\ninterface TcbLineRange {\n startLine: number;\n endLine: number;\n filePath: string;\n sourceCode: string;\n templateSources: TemplateSources;\n}\n\ninterface FileMeta {\n filePath: string;\n sourceLineCount: number;\n lines?: string[];\n tcbRanges?: TcbLineRange[];\n}\n\n/** NGP's footer comment mapping TCB ids to the template they were generated from. */\nexport const TCB_TEMPLATE_SOURCES_PREFIX = 'ngp-tcb-template-sources:';\n\nconst IGNORED_TCB_CODES = new Set([6133, 6199, 2695, 7006]);\nconst BATCH_SIZE = 32;\n\nconst TCB_IMPORT_ALIAS = /^(?:_tcb_)?_?i\\d+$/;\nconst TCB_LOCAL_NAME = /^(?:_tcb|_ctor|_pipe)\\d+$/;\nconst SPAN_COMMENT = /^(\\d+),(\\d+)$/;\n\nexport function readSpanComment(\n value: string,\n): { start: number; end: number } | null {\n const match = SPAN_COMMENT.exec(value);\n return match ? { start: Number(match[1]), end: Number(match[2]) } : null;\n}\n\nfunction walk(node: any, visit: (node: any) => void): void {\n if (Array.isArray(node)) {\n for (const child of node) walk(child, visit);\n return;\n }\n if (!node || typeof node.type !== 'string') return;\n visit(node);\n for (const key in node) {\n const value = node[key];\n if (value && typeof value === 'object') walk(value, visit);\n }\n}\n\nfunction declaredName(stmt: any): string | undefined {\n if (stmt.type === 'VariableDeclaration')\n return stmt.declarations[0]?.id?.name;\n if (stmt.type === 'FunctionDeclaration' || stmt.type === 'TSDeclareFunction')\n return stmt.id?.name;\n return undefined;\n}\n\nfunction isTcbImport(stmt: any): boolean {\n const ns = stmt.type === 'ImportDeclaration' && stmt.specifiers[0];\n return (\n ns?.type === 'ImportNamespaceSpecifier' &&\n TCB_IMPORT_ALIAS.test(ns.local.name)\n );\n}\n\ninterface TcbParts {\n source: any[];\n imports: any[];\n blocks: any[];\n templateSources: TemplateSources;\n}\n\n// NGP places each block right after its class, so source can follow a block\nfunction splitTcb(tcbCode: string): TcbParts | null {\n if (!tcbCode.includes('/*tcb')) return null;\n const { program, comments, errors } = parseSync('tcb.ts', tcbCode);\n if (errors.length > 0) return null;\n const parts: TcbParts = {\n source: [],\n imports: [],\n blocks: [],\n templateSources: {},\n };\n const footer = comments.find((c) =>\n c.value.startsWith(TCB_TEMPLATE_SOURCES_PREFIX),\n );\n if (footer) {\n parts.templateSources = JSON.parse(\n footer.value.slice(TCB_TEMPLATE_SOURCES_PREFIX.length),\n );\n }\n for (const stmt of program.body) {\n if (TCB_LOCAL_NAME.test(declaredName(stmt) ?? '')) {\n parts.blocks.push(stmt);\n } else {\n parts.source.push(stmt);\n if (isTcbImport(stmt)) parts.imports.push(stmt);\n }\n }\n return parts.blocks.length > 0 ? parts : null;\n}\n\nfunction inPlaceDocument(\n filePath: string,\n sourceCode: string,\n tcbCode?: string | null,\n): { text: string; meta: FileMeta } {\n const lines = sourceCode.split('\\n');\n const sourceLineCount = lines.length;\n if (!tcbCode)\n return { text: sourceCode, meta: { filePath, sourceLineCount } };\n const parts = splitTcb(tcbCode);\n const suffix = parts\n ? [...parts.imports, ...parts.blocks]\n .map((stmt) => tcbCode.slice(stmt.start, stmt.end))\n .join('\\n')\n : tcbCode;\n lines.push(...suffix.split('\\n'));\n const range: TcbLineRange = {\n startLine: sourceLineCount,\n endLine: lines.length,\n filePath,\n sourceCode,\n templateSources: parts?.templateSources ?? {},\n };\n return {\n text: lines.join('\\n'),\n meta: { filePath, sourceLineCount, lines, tcbRanges: [range] },\n };\n}\n\nfunction trailingSpan(\n text: string,\n pos: number,\n commentsByStart: Map<number, any>,\n): { start: number; end: number } | null {\n while (true) {\n while (pos < text.length && /\\s/.test(text[pos])) pos++;\n const comment = commentsByStart.get(pos);\n if (!comment) return null;\n const span = readSpanComment(comment.value);\n if (span) return span;\n pos = comment.end;\n }\n}\n\nfunction lineAndCharacter(text: string, offset: number) {\n const before = text.slice(0, offset).split('\\n');\n return {\n line: before.length,\n character: before[before.length - 1].length + 1,\n };\n}\n\n// Mirrors ngtsc: the span comment trailing the innermost node at the diagnostic\nfunction templateLocation(\n range: TcbLineRange,\n lines: string[],\n position: { line: number; character: number },\n): { file: string; line: number; character: number } | null {\n const chunk = lines.slice(range.startLine, range.endLine).join('\\n');\n let offset = position.character;\n for (let i = range.startLine; i < position.line; i++) {\n offset += lines[i].length + 1;\n }\n const { program, comments } = parseSync('tcb.ts', chunk);\n const commentsByStart = new Map(comments.map((c) => [c.start, c]));\n const ancestors: any[] = [];\n walk(program.body, (node) => {\n if (node.start <= offset && offset < node.end) ancestors.push(node);\n });\n const tcbFunction = ancestors.find(\n (node) =>\n node.type === 'FunctionDeclaration' && /_tcb\\d+$/.test(node.id?.name),\n );\n let span: { start: number; end: number } | null = null;\n for (let i = ancestors.length - 1; i >= 0 && !span; i--) {\n span = trailingSpan(chunk, ancestors[i].end, commentsByStart);\n }\n if (!tcbFunction || !span) return null;\n\n const id = /(tcb\\d+)$/.exec(tcbFunction.id.name)![1];\n const source = range.templateSources[id];\n const file = source?.templateFile ?? range.filePath;\n let content = range.sourceCode;\n if (source?.templateFile) {\n try {\n content = readFileSync(source.templateFile, 'utf-8');\n } catch {\n return null;\n }\n }\n const start = source?.templateExpression?.start ?? span.start;\n return { file, ...lineAndCharacter(content, start) };\n}\n\nfunction isBareTypeReference(type: any): boolean {\n return (\n type?.type === 'TSTypeReference' && type.typeName.type === 'Identifier'\n );\n}\n\nfunction collectExportedClasses(header: any[]): Map<string, string> {\n const exported = new Map<string, string>();\n for (const stmt of header) {\n const cls = stmt.declaration;\n if (cls?.type !== 'ClassDeclaration' || !cls.id) continue;\n if (stmt.type === 'ExportDefaultDeclaration') {\n exported.set(cls.id.name, 'default');\n } else if (stmt.type === 'ExportNamedDeclaration') {\n exported.set(cls.id.name, cls.id.name);\n }\n }\n return exported;\n}\n\nfunction hostRelativeSpecifier(absPath: string, hostDir: string): string {\n const spec = relative(hostDir, absPath).replace(/\\\\/g, '/');\n return spec.startsWith('.') ? spec : './' + spec;\n}\n\nfunction sharedAliasFor(spec: string, sharedImports: Map<string, string>) {\n let alias = sharedImports.get(spec);\n if (!alias) {\n alias = `_si${sharedImports.size}`;\n sharedImports.set(spec, alias);\n }\n return alias;\n}\n\nfunction relocateTcb(\n filePath: string,\n tcbCode: string,\n hostDir: string,\n fileIdx: number,\n sharedImports: Map<string, string>,\n): { body: string; templateSources: TemplateSources } | null {\n const parts = splitTcb(tcbCode);\n if (!parts) return null;\n\n const aliasSpecs = new Map<string, string>();\n for (const stmt of parts.imports) {\n aliasSpecs.set(stmt.specifiers[0].local.name, stmt.source.value);\n }\n\n const exportedClasses = collectExportedClasses(parts.source);\n const identifiers: any[] = [];\n const thisTypes: Array<{ node: any; exportProp: string }> = [];\n let relocatable = true;\n\n walk(parts.blocks, (node) => {\n if (node.type === 'Identifier') {\n identifiers.push(node);\n return;\n }\n // Same-file directives or pipes have no namespace import to relocate\n if (\n (node.type === 'VariableDeclarator' &&\n /^_pipe\\d+$/.test(node.id.name) &&\n isBareTypeReference(node.init?.typeAnnotation)) ||\n (node.type === 'TSFunctionType' &&\n node.params[0]?.name === 'init' &&\n isBareTypeReference(node.returnType?.typeAnnotation))\n ) {\n relocatable = false;\n return;\n }\n if (node.type !== 'FunctionDeclaration' || !/^_tcb\\d+$/.test(node.id?.name))\n return;\n const thisType = node.params[0]?.typeAnnotation?.typeAnnotation;\n if (node.params[0]?.name !== 'this' || !isBareTypeReference(thisType))\n return;\n const exportProp = exportedClasses.get(thisType.typeName.name);\n if (node.typeParameters || !exportProp) {\n relocatable = false;\n return;\n }\n thisTypes.push({ node: thisType.typeName, exportProp });\n });\n if (!relocatable) return null;\n\n const fileDir = dirname(resolve(filePath));\n const aliasMap = new Map<string, string>();\n for (const [alias, rawSpec] of aliasSpecs) {\n const spec = rawSpec.startsWith('.')\n ? hostRelativeSpecifier(resolve(fileDir, rawSpec), hostDir)\n : rawSpec;\n aliasMap.set(alias, sharedAliasFor(spec, sharedImports));\n }\n\n const ms = new MagicString(tcbCode);\n for (const node of identifiers) {\n if (TCB_LOCAL_NAME.test(node.name)) {\n ms.overwrite(node.start, node.end, `_f${fileIdx}_${node.name}`);\n } else if (aliasMap.has(node.name)) {\n ms.overwrite(node.start, node.end, aliasMap.get(node.name)!);\n }\n }\n if (thisTypes.length > 0) {\n const selfSpec = hostRelativeSpecifier(\n resolve(filePath).replace(/\\.[cm]?tsx?$/, ''),\n hostDir,\n );\n const selfAlias = sharedAliasFor(selfSpec, sharedImports);\n for (const { node, exportProp } of thisTypes) {\n ms.overwrite(node.start, node.end, `${selfAlias}.${exportProp}`);\n }\n }\n\n return {\n body: parts.blocks.map((stmt) => ms.slice(stmt.start, stmt.end)).join('\\n'),\n templateSources: parts.templateSources,\n };\n}\n\nfunction resolveTsgoBinary(tsconfig: string): string {\n if (process.env['TSNATIVE_BINARY_PATH'])\n return process.env['TSNATIVE_BINARY_PATH'];\n const ext = process.platform === 'win32' ? '.exe' : '';\n const candidates = [\n {\n parent: 'typescript/package.json',\n platform: `@typescript/typescript-${process.platform}-${process.arch}/package.json`,\n bin: `tsc${ext}`,\n },\n {\n parent: '@typescript/native-preview/package.json',\n platform: `@typescript/native-preview-${process.platform}-${process.arch}/package.json`,\n bin: `tsgo${ext}`,\n },\n ];\n for (const base of [tsconfig, import.meta.url]) {\n const req = createRequire(base);\n for (const candidate of candidates) {\n try {\n const parentPkg = req.resolve(candidate.parent);\n const platformPkg = createRequire(parentPkg).resolve(\n candidate.platform,\n );\n return resolve(dirname(platformPkg), 'lib', candidate.bin);\n } catch {\n // try next candidate\n }\n }\n }\n throw new Error(\n 'disableTypeChecking: false requires TypeScript 7 (typescript@^7.0.0), @typescript/native-preview, or TSNATIVE_BINARY_PATH.',\n );\n}\n\nexport class TsgoChecker {\n private proc: ChildProcessWithoutNullStreams;\n private seq = 1;\n private pending = new Map<\n number,\n { resolve: (value: any) => void; reject: (error: Error) => void }\n >();\n private versions = new Map<string, number>();\n private queued = new Map<\n string,\n { sourceCode: string; tcbCode?: string | null }\n >();\n private buffer = Buffer.alloc(0);\n private exitError: Error | undefined;\n readonly ready: Promise<void>;\n\n constructor(tsconfig: string) {\n const cwd = dirname(tsconfig);\n this.proc = spawn(resolveTsgoBinary(tsconfig), ['--lsp', '--stdio'], {\n cwd,\n stdio: ['pipe', 'pipe', 'ignore'],\n });\n this.proc.stdout.on('data', (chunk: Buffer) => this.onData(chunk));\n const fail = (error: Error) => {\n this.exitError ??= error;\n for (const { reject } of this.pending.values()) reject(this.exitError);\n this.pending.clear();\n };\n this.proc.on('error', fail);\n this.proc.stdin.on('error', fail);\n this.proc.on('exit', (code) =>\n fail(new Error(`tsgo exited with code ${code}`)),\n );\n const rootUri = pathToFileURL(cwd).href;\n this.ready = this.request('initialize', {\n processId: process.pid,\n rootUri,\n capabilities: { textDocument: { diagnostic: {} } },\n workspaceFolders: [{ uri: rootUri, name: 'root' }],\n }).then(() => this.notify('initialized', {}));\n this.ready.catch(() => {});\n }\n\n private onData(chunk: Buffer) {\n this.buffer = Buffer.concat([this.buffer, chunk]);\n while (true) {\n const headerEnd = this.buffer.indexOf('\\r\\n\\r\\n');\n if (headerEnd === -1) break;\n const match = /Content-Length: (\\d+)/i.exec(\n this.buffer.subarray(0, headerEnd).toString('utf8'),\n );\n if (!match) break;\n const bodyStart = headerEnd + 4;\n const bodyEnd = bodyStart + Number(match[1]);\n if (this.buffer.length < bodyEnd) break;\n const msg = JSON.parse(\n this.buffer.subarray(bodyStart, bodyEnd).toString('utf8'),\n );\n this.buffer = this.buffer.subarray(bodyEnd);\n if (msg.id !== undefined && msg.method !== undefined) {\n this.send({ jsonrpc: '2.0', id: msg.id, result: null });\n } else if (msg.id !== undefined && this.pending.has(msg.id)) {\n const entry = this.pending.get(msg.id)!;\n this.pending.delete(msg.id);\n if (msg.error) entry.reject(new Error(msg.error.message));\n else entry.resolve(msg.result);\n }\n }\n }\n\n private send(payload: unknown) {\n const json = JSON.stringify(payload);\n this.proc.stdin.write(\n `Content-Length: ${Buffer.byteLength(json, 'utf8')}\\r\\n\\r\\n${json}`,\n );\n }\n\n private notify(method: string, params: unknown) {\n this.send({ jsonrpc: '2.0', method, params });\n }\n\n private request(method: string, params: unknown): Promise<any> {\n if (this.exitError) return Promise.reject(this.exitError);\n const id = this.seq++;\n return new Promise((resolve, reject) => {\n this.pending.set(id, { resolve, reject });\n this.send({ jsonrpc: '2.0', id, method, params });\n });\n }\n\n updateDocument(filePath: string, text: string) {\n const uri = pathToFileURL(resolve(filePath)).href;\n if (!this.versions.has(uri)) {\n // tsgo 7.0.0-dev.20260412 ignores didOpen text once other documents are open\n this.versions.set(uri, 1);\n this.notify('textDocument/didOpen', {\n textDocument: { uri, languageId: 'typescript', version: 1, text },\n });\n }\n const version = this.versions.get(uri)! + 1;\n this.versions.set(uri, version);\n this.notify('textDocument/didChange', {\n textDocument: { uri, version },\n contentChanges: [{ text }],\n });\n }\n\n async checkFile(\n filePath: string,\n sourceLineCount?: number,\n lines?: string[],\n tcbRanges?: TcbLineRange[],\n ): Promise<string[]> {\n const resolvedPath = resolve(filePath);\n const errors: string[] = [];\n const diag = await this.request('textDocument/diagnostic', {\n textDocument: { uri: pathToFileURL(resolvedPath).href },\n });\n for (const item of (diag?.items ?? []) as LspDiagnostic[]) {\n if (item.severity !== 1) continue;\n const line = item.range.start.line;\n if (sourceLineCount !== undefined && line >= sourceLineCount) {\n if (\n !IGNORED_TCB_CODES.has(Number(item.code)) &&\n !lines?.[line]?.includes('/*D:ignore*/')\n ) {\n const range = tcbRanges?.find(\n (r) => line >= r.startLine && line < r.endLine,\n );\n const location =\n range && lines && templateLocation(range, lines, item.range.start);\n errors.push(\n location\n ? `${location.file}:${location.line}:${location.character} - error TS${item.code}: ${item.message}`\n : `${range?.filePath ?? filePath} (template): error TS${item.code}: ${item.message}`,\n );\n }\n } else {\n errors.push(\n `${filePath}:${line + 1}:${item.range.start.character + 1} - error TS${item.code}: ${item.message}`,\n );\n }\n }\n return errors;\n }\n\n queueFile(filePath: string, sourceCode: string, tcbCode?: string | null) {\n this.queued.set(filePath, { sourceCode, tcbCode });\n }\n\n async flushQueue(watchMode = false): Promise<string[]> {\n if (this.queued.size === 0) return [];\n const entries = Array.from(this.queued.entries());\n this.queued.clear();\n await this.ready;\n\n const metas: FileMeta[] = [];\n let updatesCount = 0;\n const update = async (filePath: string, text: string) => {\n this.updateDocument(filePath, text);\n updatesCount++;\n if (updatesCount % BATCH_SIZE === 0) {\n await new Promise((r) => setTimeout(r, 5));\n }\n };\n\n if (!watchMode && entries.length > 1) {\n const [hostFilePath, hostItem] = entries[0];\n const hostDir = dirname(resolve(hostFilePath));\n const hostUri = pathToFileURL(resolve(hostFilePath)).href;\n const sharedImports = new Map<string, string>();\n const relocatedChunks: Array<{\n filePath: string;\n sourceCode: string;\n body: string;\n templateSources: TemplateSources;\n }> = [];\n let hostRelocated = false;\n\n for (let i = 0; i < entries.length; i++) {\n const [filePath, { sourceCode, tcbCode }] = entries[i];\n const uri = pathToFileURL(resolve(filePath)).href;\n if (tcbCode && !this.versions.has(uri)) {\n const relocated = relocateTcb(\n filePath,\n tcbCode,\n hostDir,\n i,\n sharedImports,\n );\n if (relocated !== null) {\n relocatedChunks.push({ filePath, sourceCode, ...relocated });\n if (i === 0) {\n hostRelocated = true;\n } else {\n metas.push({\n filePath,\n sourceLineCount: sourceCode.split('\\n').length,\n });\n }\n continue;\n }\n }\n if (i === 0) continue;\n\n const { text, meta } = inPlaceDocument(filePath, sourceCode, tcbCode);\n if (tcbCode || this.versions.has(uri)) await update(filePath, text);\n metas.push(meta);\n }\n\n const { meta: hostMeta } = inPlaceDocument(\n hostFilePath,\n hostItem.sourceCode,\n hostRelocated ? null : hostItem.tcbCode,\n );\n const hostLines = hostMeta.lines ?? hostItem.sourceCode.split('\\n');\n const hostTcbRanges = hostMeta.tcbRanges ?? [];\n\n if (relocatedChunks.length > 0) {\n for (const [spec, alias] of sharedImports) {\n hostLines.push(`import * as ${alias} from '${spec}';`);\n }\n for (const {\n filePath,\n sourceCode,\n body,\n templateSources,\n } of relocatedChunks) {\n const startLine = hostLines.length;\n hostLines.push(...body.split('\\n'));\n hostTcbRanges.push({\n startLine,\n endLine: hostLines.length,\n filePath,\n sourceCode,\n templateSources,\n });\n }\n }\n\n const hasHostTcb = hostTcbRanges.length > 0;\n if (hasHostTcb || this.versions.has(hostUri)) {\n this.updateDocument(hostFilePath, hostLines.join('\\n'));\n }\n metas.unshift({\n filePath: hostFilePath,\n sourceLineCount: hostMeta.sourceLineCount,\n lines: hasHostTcb ? hostLines : undefined,\n tcbRanges: hasHostTcb ? hostTcbRanges : undefined,\n });\n } else {\n for (const [filePath, { sourceCode, tcbCode }] of entries) {\n const { text, meta } = inPlaceDocument(filePath, sourceCode, tcbCode);\n const uri = pathToFileURL(resolve(filePath)).href;\n if (tcbCode || watchMode || this.versions.has(uri)) {\n await update(filePath, text);\n }\n metas.push(meta);\n }\n }\n\n const errors: string[] = [];\n const first = metas[0];\n errors.push(\n ...(await this.checkFile(\n first.filePath,\n first.sourceLineCount,\n first.lines,\n first.tcbRanges,\n )),\n );\n\n for (let i = 1; i < metas.length; i += BATCH_SIZE) {\n const slice = metas.slice(i, i + BATCH_SIZE);\n const batchResults = await Promise.all(\n slice.map(({ filePath, sourceLineCount, lines, tcbRanges }) =>\n this.checkFile(filePath, sourceLineCount, lines, tcbRanges),\n ),\n );\n for (const res of batchResults) {\n errors.push(...res);\n }\n }\n return errors;\n }\n\n close() {\n this.proc.kill();\n }\n}\n"],"mappings":";;;;;;;;;AAuCA,IAAa,8BAA8B;AAE3C,IAAM,oCAAoB,IAAI,IAAI;CAAC;CAAM;CAAM;CAAM;AAAI,CAAC;AAC1D,IAAM,aAAa;AAEnB,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AACvB,IAAM,eAAe;AAErB,SAAgB,gBACd,OACuC;CACvC,MAAM,QAAQ,aAAa,KAAK,KAAK;CACrC,OAAO,QAAQ;EAAE,OAAO,OAAO,MAAM,EAAE;EAAG,KAAK,OAAO,MAAM,EAAE;CAAE,IAAI;AACtE;AAEA,SAAS,KAAK,MAAW,OAAkC;CACzD,IAAI,MAAM,QAAQ,IAAI,GAAG;EACvB,KAAK,MAAM,SAAS,MAAM,KAAK,OAAO,KAAK;EAC3C;CACF;CACA,IAAI,CAAC,QAAQ,OAAO,KAAK,SAAS,UAAU;CAC5C,MAAM,IAAI;CACV,KAAK,MAAM,OAAO,MAAM;EACtB,MAAM,QAAQ,KAAK;EACnB,IAAI,SAAS,OAAO,UAAU,UAAU,KAAK,OAAO,KAAK;CAC3D;AACF;AAEA,SAAS,aAAa,MAA+B;CACnD,IAAI,KAAK,SAAS,uBAChB,OAAO,KAAK,aAAa,EAAE,EAAE,IAAI;CACnC,IAAI,KAAK,SAAS,yBAAyB,KAAK,SAAS,qBACvD,OAAO,KAAK,IAAI;AAEpB;AAE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