@analogjs/vite-plugin-angular 3.0.0-beta.9 → 3.0.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/migrations/migrate-setup-vitest/migrate-setup-vitest.js +3 -3
- package/migrations/migrate-setup-vitest/migrate-setup-vitest.js.map +1 -1
- package/ngp/LICENSE +21 -0
- package/ngp/api.mjs +46806 -0
- package/ngp/build.json +4 -0
- package/ngp/ng_analyze.cjs +601 -0
- package/ngp/ng_analyze_bg.wasm +0 -0
- package/package.json +5 -2
- package/src/index.d.ts +2 -0
- package/src/index.js +4 -3
- package/src/index.js.map +1 -1
- package/src/lib/analog-plugin-interop.js +2 -3
- package/src/lib/angular-build-context.d.ts +215 -0
- package/src/lib/angular-build-context.js +360 -0
- package/src/lib/angular-build-context.js.map +1 -0
- package/src/lib/angular-build-optimizer-plugin.d.ts +6 -4
- package/src/lib/angular-build-optimizer-plugin.js +25 -11
- package/src/lib/angular-build-optimizer-plugin.js.map +1 -1
- package/src/lib/angular-jit-plugin.d.ts +5 -3
- package/src/lib/angular-jit-plugin.js +16 -9
- package/src/lib/angular-jit-plugin.js.map +1 -1
- package/src/lib/angular-vite-plugin.d.ts +6 -109
- package/src/lib/angular-vite-plugin.js +9 -1251
- package/src/lib/angular-vite-plugin.js.map +1 -1
- package/src/lib/angular-vitest-plugin.d.ts +3 -2
- package/src/lib/angular-vitest-plugin.js +7 -5
- package/src/lib/angular-vitest-plugin.js.map +1 -1
- package/src/lib/companion-plugins.d.ts +7 -0
- package/src/lib/companion-plugins.js +37 -0
- package/src/lib/companion-plugins.js.map +1 -0
- package/src/lib/compilation-api/compilation-api-plugin.d.ts +11 -2
- package/src/lib/compilation-api/compilation-api-plugin.js +156 -285
- package/src/lib/compilation-api/compilation-api-plugin.js.map +1 -1
- package/src/lib/compilation-api/index.js +1 -2
- package/src/lib/compiler/angular-version.js +0 -1
- package/src/lib/compiler/class-field-lowering.js +1 -2
- package/src/lib/compiler/compile.d.ts +1 -1
- package/src/lib/compiler/compile.js +224 -151
- package/src/lib/compiler/compile.js.map +1 -1
- package/src/lib/compiler/constants.js +1 -2
- package/src/lib/compiler/debug.js +1 -2
- package/src/lib/compiler/defer.d.ts +2 -3
- package/src/lib/compiler/defer.js +13 -16
- package/src/lib/compiler/defer.js.map +1 -1
- package/src/lib/compiler/dts-reader.d.ts +6 -1
- package/src/lib/compiler/dts-reader.js +20 -12
- package/src/lib/compiler/dts-reader.js.map +1 -1
- package/src/lib/compiler/hmr.d.ts +4 -0
- package/src/lib/compiler/hmr.js +8 -4
- package/src/lib/compiler/hmr.js.map +1 -1
- package/src/lib/compiler/index.d.ts +2 -2
- package/src/lib/compiler/index.js +6 -6
- package/src/lib/compiler/jit-metadata.js +1 -2
- package/src/lib/compiler/jit-transform.js +37 -15
- package/src/lib/compiler/jit-transform.js.map +1 -1
- package/src/lib/compiler/js-emitter.d.ts +0 -3
- package/src/lib/compiler/js-emitter.js +4 -23
- package/src/lib/compiler/js-emitter.js.map +1 -1
- package/src/lib/compiler/metadata.js +2 -3
- package/src/lib/compiler/registry.d.ts +9 -1
- package/src/lib/compiler/registry.js +36 -8
- package/src/lib/compiler/registry.js.map +1 -1
- package/src/lib/compiler/resource-inliner.d.ts +8 -9
- package/src/lib/compiler/resource-inliner.js +11 -20
- package/src/lib/compiler/resource-inliner.js.map +1 -1
- package/src/lib/compiler/style-ast.d.ts +22 -1
- package/src/lib/compiler/style-ast.js +37 -20
- package/src/lib/compiler/style-ast.js.map +1 -1
- package/src/lib/compiler/type-elision.d.ts +4 -3
- package/src/lib/compiler/type-elision.js +11 -13
- package/src/lib/compiler/type-elision.js.map +1 -1
- package/src/lib/compiler/utils.d.ts +9 -7
- package/src/lib/compiler/utils.js +50 -11
- package/src/lib/compiler/utils.js.map +1 -1
- package/src/lib/compiler-plugin.js +1 -2
- package/src/lib/component-resolvers.js +1 -2
- package/src/lib/component-scanner.d.ts +101 -0
- package/src/lib/component-scanner.js +331 -0
- package/src/lib/component-scanner.js.map +1 -0
- package/src/lib/component-styles-plugin.d.ts +52 -0
- package/src/lib/component-styles-plugin.js +352 -0
- package/src/lib/component-styles-plugin.js.map +1 -0
- package/src/lib/compose-angular-plugins.d.ts +12 -0
- package/src/lib/compose-angular-plugins.js +30 -0
- package/src/lib/compose-angular-plugins.js.map +1 -0
- package/src/lib/dev-server-mode-plugin.d.ts +7 -0
- package/src/lib/dev-server-mode-plugin.js +22 -0
- package/src/lib/dev-server-mode-plugin.js.map +1 -0
- package/src/lib/encapsulation-plugin.js +1 -2
- package/src/lib/fast-compile-api.d.ts +62 -0
- package/src/lib/fast-compile-api.js +11 -0
- package/src/lib/fast-compile-api.js.map +1 -0
- package/src/lib/fast-compile-plugin.d.ts +6 -1
- package/src/lib/fast-compile-plugin.js +222 -117
- package/src/lib/fast-compile-plugin.js.map +1 -1
- package/src/lib/host.d.ts +3 -0
- package/src/lib/host.js +5 -4
- package/src/lib/host.js.map +1 -1
- package/src/lib/hot-update-batch.js +1 -2
- package/src/lib/live-reload-plugin.d.ts +6 -3
- package/src/lib/live-reload-plugin.js +14 -8
- package/src/lib/live-reload-plugin.js.map +1 -1
- package/src/lib/ngp-compile-api.d.ts +55 -0
- package/src/lib/ngp-compile-api.js +11 -0
- package/src/lib/ngp-compile-api.js.map +1 -0
- package/src/lib/ngp-compile-plugin.d.ts +4 -0
- package/src/lib/ngp-compile-plugin.js +675 -0
- package/src/lib/ngp-compile-plugin.js.map +1 -0
- package/src/lib/ngtsc-compile-plugin.d.ts +23 -0
- package/src/lib/ngtsc-compile-plugin.js +776 -0
- package/src/lib/ngtsc-compile-plugin.js.map +1 -0
- package/src/lib/nx-folder-plugin.d.ts +6 -5
- package/src/lib/nx-folder-plugin.js +13 -9
- package/src/lib/nx-folder-plugin.js.map +1 -1
- package/src/lib/plugins/file-replacements.plugin.d.ts +6 -0
- package/src/lib/plugins/file-replacements.plugin.js +2 -2
- package/src/lib/plugins/file-replacements.plugin.js.map +1 -1
- package/src/lib/router-plugin.d.ts +5 -1
- package/src/lib/router-plugin.js +14 -6
- package/src/lib/router-plugin.js.map +1 -1
- package/src/lib/style-preprocessor.js +1 -2
- package/src/lib/stylesheet-registry.js +1 -2
- package/src/lib/stylesheet-registry.js.map +1 -1
- package/src/lib/tools/src/builders/vite/vite-build.impl.js +2 -3
- package/src/lib/tools/src/builders/vite/vite-build.impl.js.map +1 -1
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js +1 -2
- package/src/lib/tools/src/builders/vite-dev-server/dev-server.impl.js.map +1 -1
- package/src/lib/utils/compilation-shared.js +3 -4
- package/src/lib/utils/css-extension-resolver.js +1 -2
- package/src/lib/utils/css-preprocessor-workers.js +1 -2
- package/src/lib/utils/debug-harness.js +1 -2
- package/src/lib/utils/debug-log-file.js +1 -2
- package/src/lib/utils/debug.js +1 -2
- package/src/lib/utils/devkit.js +2 -3
- package/src/lib/utils/hmr-component-updates.d.ts +7 -0
- package/src/lib/utils/hmr-component-updates.js +86 -0
- package/src/lib/utils/hmr-component-updates.js.map +1 -0
- package/src/lib/utils/jit-inline-styles.js +1 -2
- package/src/lib/utils/lsp-type-checker.d.ts +75 -0
- package/src/lib/utils/lsp-type-checker.js +532 -0
- package/src/lib/utils/lsp-type-checker.js.map +1 -0
- package/src/lib/utils/ngp-host-fs.d.ts +43 -0
- package/src/lib/utils/ngp-host-fs.js +128 -0
- package/src/lib/utils/ngp-host-fs.js.map +1 -0
- package/src/lib/utils/plugin-config.d.ts +15 -8
- package/src/lib/utils/plugin-config.js +19 -7
- package/src/lib/utils/plugin-config.js.map +1 -1
- package/src/lib/utils/rolldown.js +1 -2
- package/src/lib/utils/safe-module-paths.js +1 -2
- package/src/lib/utils/stylesheet-warning.d.ts +2 -0
- package/src/lib/utils/stylesheet-warning.js +10 -0
- package/src/lib/utils/stylesheet-warning.js.map +1 -0
- package/src/lib/utils/transform-cache.js +1 -2
- package/src/lib/utils/transform-cache.js.map +1 -1
- package/src/lib/utils/tsconfig-resolver.js +2 -3
- package/src/lib/utils/virtual-ids.js +1 -2
- package/src/lib/utils/virtual-resources.js +1 -2
- package/src/lib/utils/virtual-resources.js.map +1 -1
- package/src/lib/virtual-modules-plugin.d.ts +11 -3
- package/src/lib/virtual-modules-plugin.js +70 -15
- package/src/lib/virtual-modules-plugin.js.map +1 -1
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { fromWasmPath } from "./ngp-host-fs.js";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { dirname, relative, resolve } from "node:path";
|
|
5
|
+
import { parseSync } from "oxc-parser";
|
|
6
|
+
import MagicString from "magic-string";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
import { spawn } from "node:child_process";
|
|
9
|
+
// packages/vite-plugin-angular/src/lib/utils/lsp-type-checker.ts
|
|
10
|
+
/** NGP's footer comment mapping TCB ids to the template they were generated from. */
|
|
11
|
+
var TCB_TEMPLATE_SOURCES_PREFIX = "ngp-tcb-template-sources:";
|
|
12
|
+
var IGNORED_TCB_CODES = /* @__PURE__ */ new Set([
|
|
13
|
+
6133,
|
|
14
|
+
6199,
|
|
15
|
+
2695,
|
|
16
|
+
7006
|
|
17
|
+
]);
|
|
18
|
+
var IGNORED_IN_MEMORY_CODES = /* @__PURE__ */ new Set([2742, 2883]);
|
|
19
|
+
var BATCH_SIZE = 32;
|
|
20
|
+
var TCB_IMPORT_ALIAS = /^(?:_tcb_)?_?i\d+$/;
|
|
21
|
+
var TCB_LOCAL_NAME = /^(?:_tcb|_ctor|_pipe)\d+$/;
|
|
22
|
+
var SPAN_COMMENT = /^(\d+),(\d+)$/;
|
|
23
|
+
function readSpanComment(value) {
|
|
24
|
+
const match = SPAN_COMMENT.exec(value);
|
|
25
|
+
return match ? {
|
|
26
|
+
start: Number(match[1]),
|
|
27
|
+
end: Number(match[2])
|
|
28
|
+
} : null;
|
|
29
|
+
}
|
|
30
|
+
function walk(node, visit) {
|
|
31
|
+
if (Array.isArray(node)) {
|
|
32
|
+
for (const child of node) walk(child, visit);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (!node || typeof node.type !== "string") return;
|
|
36
|
+
visit(node);
|
|
37
|
+
for (const key in node) {
|
|
38
|
+
const value = node[key];
|
|
39
|
+
if (value && typeof value === "object") walk(value, visit);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function declaredName(stmt) {
|
|
43
|
+
if (stmt.type === "VariableDeclaration") return stmt.declarations[0]?.id?.name;
|
|
44
|
+
if (stmt.type === "FunctionDeclaration" || stmt.type === "TSDeclareFunction") return stmt.id?.name;
|
|
45
|
+
}
|
|
46
|
+
function isTcbImport(stmt) {
|
|
47
|
+
const ns = stmt.type === "ImportDeclaration" && stmt.specifiers[0];
|
|
48
|
+
return ns?.type === "ImportNamespaceSpecifier" && TCB_IMPORT_ALIAS.test(ns.local.name);
|
|
49
|
+
}
|
|
50
|
+
function splitTcb(tcbCode) {
|
|
51
|
+
if (!tcbCode.includes("/*tcb")) return null;
|
|
52
|
+
const { program, comments, errors } = parseSync("tcb.ts", tcbCode);
|
|
53
|
+
if (errors.length > 0) return null;
|
|
54
|
+
const parts = {
|
|
55
|
+
source: [],
|
|
56
|
+
imports: [],
|
|
57
|
+
blocks: [],
|
|
58
|
+
templateSources: {}
|
|
59
|
+
};
|
|
60
|
+
const footer = comments.find((c) => c.value.startsWith(TCB_TEMPLATE_SOURCES_PREFIX));
|
|
61
|
+
if (footer) parts.templateSources = JSON.parse(footer.value.slice(25));
|
|
62
|
+
for (const stmt of program.body) if (TCB_LOCAL_NAME.test(declaredName(stmt) ?? "")) parts.blocks.push(stmt);
|
|
63
|
+
else {
|
|
64
|
+
parts.source.push(stmt);
|
|
65
|
+
if (isTcbImport(stmt)) parts.imports.push(stmt);
|
|
66
|
+
}
|
|
67
|
+
return parts.blocks.length > 0 ? parts : null;
|
|
68
|
+
}
|
|
69
|
+
function inPlaceDocument(filePath, sourceCode, tcbCode) {
|
|
70
|
+
const lines = sourceCode.split("\n");
|
|
71
|
+
const sourceLineCount = lines.length;
|
|
72
|
+
if (!tcbCode) return {
|
|
73
|
+
text: sourceCode,
|
|
74
|
+
meta: {
|
|
75
|
+
filePath,
|
|
76
|
+
sourceLineCount
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const parts = splitTcb(tcbCode);
|
|
80
|
+
const suffix = parts ? [...parts.imports, ...parts.blocks].map((stmt) => tcbCode.slice(stmt.start, stmt.end)).join("\n") : tcbCode;
|
|
81
|
+
lines.push(...suffix.split("\n"));
|
|
82
|
+
const range = {
|
|
83
|
+
startLine: sourceLineCount,
|
|
84
|
+
endLine: lines.length,
|
|
85
|
+
filePath,
|
|
86
|
+
sourceCode,
|
|
87
|
+
templateSources: parts?.templateSources ?? {}
|
|
88
|
+
};
|
|
89
|
+
return {
|
|
90
|
+
text: lines.join("\n"),
|
|
91
|
+
meta: {
|
|
92
|
+
filePath,
|
|
93
|
+
sourceLineCount,
|
|
94
|
+
lines,
|
|
95
|
+
tcbRanges: [range]
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function trailingSpan(text, pos, commentsByStart) {
|
|
100
|
+
while (true) {
|
|
101
|
+
while (pos < text.length && /\s/.test(text[pos])) pos++;
|
|
102
|
+
const comment = commentsByStart.get(pos);
|
|
103
|
+
if (!comment) return null;
|
|
104
|
+
const span = readSpanComment(comment.value);
|
|
105
|
+
if (span) return span;
|
|
106
|
+
pos = comment.end;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function lineAndCharacter(text, offset) {
|
|
110
|
+
const before = text.slice(0, offset).split("\n");
|
|
111
|
+
return {
|
|
112
|
+
line: before.length,
|
|
113
|
+
character: before[before.length - 1].length + 1
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function templateLocation(range, lines, position) {
|
|
117
|
+
const chunk = lines.slice(range.startLine, range.endLine).join("\n");
|
|
118
|
+
let offset = position.character;
|
|
119
|
+
for (let i = range.startLine; i < position.line; i++) offset += lines[i].length + 1;
|
|
120
|
+
const { program, comments } = parseSync("tcb.ts", chunk);
|
|
121
|
+
const commentsByStart = new Map(comments.map((c) => [c.start, c]));
|
|
122
|
+
const ancestors = [];
|
|
123
|
+
walk(program.body, (node) => {
|
|
124
|
+
if (node.start <= offset && offset < node.end) ancestors.push(node);
|
|
125
|
+
});
|
|
126
|
+
const tcbFunction = ancestors.find((node) => node.type === "FunctionDeclaration" && /_tcb\d+$/.test(node.id?.name));
|
|
127
|
+
let span = null;
|
|
128
|
+
for (let i = ancestors.length - 1; i >= 0 && !span; i--) span = trailingSpan(chunk, ancestors[i].end, commentsByStart);
|
|
129
|
+
if (!tcbFunction || !span) return null;
|
|
130
|
+
const id = /(tcb\d+)$/.exec(tcbFunction.id.name)[1];
|
|
131
|
+
const source = range.templateSources[id];
|
|
132
|
+
const templateFile = source?.templateFile ? fromWasmPath(source.templateFile) : void 0;
|
|
133
|
+
const file = templateFile ?? range.filePath;
|
|
134
|
+
let content = range.sourceCode;
|
|
135
|
+
if (templateFile) try {
|
|
136
|
+
content = readFileSync(templateFile, "utf-8");
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const start = source?.templateExpression?.start ?? span.start;
|
|
141
|
+
return {
|
|
142
|
+
file,
|
|
143
|
+
...lineAndCharacter(content, start)
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function isBareTypeReference(type) {
|
|
147
|
+
return type?.type === "TSTypeReference" && type.typeName.type === "Identifier";
|
|
148
|
+
}
|
|
149
|
+
function collectExportedClasses(header) {
|
|
150
|
+
const exported = /* @__PURE__ */ new Map();
|
|
151
|
+
for (const stmt of header) {
|
|
152
|
+
const cls = stmt.declaration;
|
|
153
|
+
if (cls?.type !== "ClassDeclaration" || !cls.id) continue;
|
|
154
|
+
if (stmt.type === "ExportDefaultDeclaration") exported.set(cls.id.name, "default");
|
|
155
|
+
else if (stmt.type === "ExportNamedDeclaration") exported.set(cls.id.name, cls.id.name);
|
|
156
|
+
}
|
|
157
|
+
return exported;
|
|
158
|
+
}
|
|
159
|
+
function hostRelativeSpecifier(absPath, hostDir) {
|
|
160
|
+
const spec = relative(hostDir, absPath).replace(/\\/g, "/");
|
|
161
|
+
return spec.startsWith(".") ? spec : "./" + spec;
|
|
162
|
+
}
|
|
163
|
+
function sharedAliasFor(spec, sharedImports) {
|
|
164
|
+
let alias = sharedImports.get(spec);
|
|
165
|
+
if (!alias) {
|
|
166
|
+
alias = `_si${sharedImports.size}`;
|
|
167
|
+
sharedImports.set(spec, alias);
|
|
168
|
+
}
|
|
169
|
+
return alias;
|
|
170
|
+
}
|
|
171
|
+
function relocateTcb(filePath, tcbCode, hostDir, fileIdx, sharedImports) {
|
|
172
|
+
const parts = splitTcb(tcbCode);
|
|
173
|
+
if (!parts) return null;
|
|
174
|
+
const aliasSpecs = /* @__PURE__ */ new Map();
|
|
175
|
+
for (const stmt of parts.imports) aliasSpecs.set(stmt.specifiers[0].local.name, stmt.source.value);
|
|
176
|
+
const exportedClasses = collectExportedClasses(parts.source);
|
|
177
|
+
const identifiers = [];
|
|
178
|
+
const thisTypes = [];
|
|
179
|
+
let relocatable = true;
|
|
180
|
+
walk(parts.blocks, (node) => {
|
|
181
|
+
if (node.type === "Identifier") {
|
|
182
|
+
identifiers.push(node);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
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)) {
|
|
186
|
+
relocatable = false;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (node.type !== "FunctionDeclaration" || !/^_tcb\d+$/.test(node.id?.name)) return;
|
|
190
|
+
const thisType = node.params[0]?.typeAnnotation?.typeAnnotation;
|
|
191
|
+
if (node.params[0]?.name !== "this" || !isBareTypeReference(thisType)) return;
|
|
192
|
+
const exportProp = exportedClasses.get(thisType.typeName.name);
|
|
193
|
+
if (node.typeParameters || !exportProp) {
|
|
194
|
+
relocatable = false;
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
thisTypes.push({
|
|
198
|
+
node: thisType.typeName,
|
|
199
|
+
exportProp
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
if (!relocatable) return null;
|
|
203
|
+
const fileDir = dirname(resolve(filePath));
|
|
204
|
+
const aliasMap = /* @__PURE__ */ new Map();
|
|
205
|
+
for (const [alias, rawSpec] of aliasSpecs) {
|
|
206
|
+
const spec = rawSpec.startsWith(".") ? hostRelativeSpecifier(resolve(fileDir, rawSpec), hostDir) : rawSpec;
|
|
207
|
+
aliasMap.set(alias, sharedAliasFor(spec, sharedImports));
|
|
208
|
+
}
|
|
209
|
+
const ms = new MagicString(tcbCode);
|
|
210
|
+
for (const node of identifiers) if (TCB_LOCAL_NAME.test(node.name)) ms.overwrite(node.start, node.end, `_f${fileIdx}_${node.name}`);
|
|
211
|
+
else if (aliasMap.has(node.name)) ms.overwrite(node.start, node.end, aliasMap.get(node.name));
|
|
212
|
+
if (thisTypes.length > 0) {
|
|
213
|
+
const selfAlias = sharedAliasFor(hostRelativeSpecifier(resolve(filePath).replace(/\.[cm]?tsx?$/, ""), hostDir), sharedImports);
|
|
214
|
+
for (const { node, exportProp } of thisTypes) ms.overwrite(node.start, node.end, `${selfAlias}.${exportProp}`);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
body: parts.blocks.map((stmt) => ms.slice(stmt.start, stmt.end)).join("\n"),
|
|
218
|
+
templateSources: parts.templateSources
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
var LSP_ARGS = ["--lsp", "--stdio"];
|
|
222
|
+
function resolveTsgoBinary(tsconfig) {
|
|
223
|
+
if (process.env["TSNATIVE_BINARY_PATH"]) return process.env["TSNATIVE_BINARY_PATH"];
|
|
224
|
+
const ext = process.platform === "win32" ? ".exe" : "";
|
|
225
|
+
const candidates = [{
|
|
226
|
+
parent: "typescript/package.json",
|
|
227
|
+
platform: `@typescript/typescript-${process.platform}-${process.arch}/package.json`,
|
|
228
|
+
bin: `tsc${ext}`
|
|
229
|
+
}, {
|
|
230
|
+
parent: "@typescript/native-preview/package.json",
|
|
231
|
+
platform: `@typescript/native-preview-${process.platform}-${process.arch}/package.json`,
|
|
232
|
+
bin: `tsgo${ext}`
|
|
233
|
+
}];
|
|
234
|
+
for (const base of [tsconfig, import.meta.url]) {
|
|
235
|
+
const req = createRequire(base);
|
|
236
|
+
for (const candidate of candidates) try {
|
|
237
|
+
const parentPkg = req.resolve(candidate.parent);
|
|
238
|
+
const platformPkg = createRequire(parentPkg).resolve(candidate.platform);
|
|
239
|
+
return resolve(dirname(platformPkg), "lib", candidate.bin);
|
|
240
|
+
} catch {}
|
|
241
|
+
}
|
|
242
|
+
throw new Error("disableTypeChecking: false requires TypeScript 7 (typescript@^7.0.0), @typescript/native-preview, or TSNATIVE_BINARY_PATH.");
|
|
243
|
+
}
|
|
244
|
+
function resolveTsrs(tsconfig) {
|
|
245
|
+
for (const base of [tsconfig, import.meta.url]) try {
|
|
246
|
+
const pkg = createRequire(base).resolve("tsrs/package.json");
|
|
247
|
+
return {
|
|
248
|
+
command: process.execPath,
|
|
249
|
+
args: [resolve(dirname(pkg), "bin", "tsrs"), ...LSP_ARGS]
|
|
250
|
+
};
|
|
251
|
+
} catch {}
|
|
252
|
+
throw new Error("typeChecker: 'tsrs' requires the tsrs package.");
|
|
253
|
+
}
|
|
254
|
+
function resolveTypeChecker(tsconfig, option) {
|
|
255
|
+
if (typeof option === "object") return {
|
|
256
|
+
command: option.command,
|
|
257
|
+
args: option.args ?? LSP_ARGS
|
|
258
|
+
};
|
|
259
|
+
if (option === "tsrs") return resolveTsrs(tsconfig);
|
|
260
|
+
return {
|
|
261
|
+
command: resolveTsgoBinary(tsconfig),
|
|
262
|
+
args: LSP_ARGS
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
var LspTypeChecker = class {
|
|
266
|
+
host;
|
|
267
|
+
proc;
|
|
268
|
+
seq = 1;
|
|
269
|
+
pending = /* @__PURE__ */ new Map();
|
|
270
|
+
versions = /* @__PURE__ */ new Map();
|
|
271
|
+
queued = /* @__PURE__ */ new Map();
|
|
272
|
+
/** The text last sent for each open in-memory file. */
|
|
273
|
+
inMemoryText = /* @__PURE__ */ new Map();
|
|
274
|
+
buffer = Buffer.alloc(0);
|
|
275
|
+
exitError;
|
|
276
|
+
ready;
|
|
277
|
+
constructor(tsconfig, option = "tsgo", host) {
|
|
278
|
+
this.host = host;
|
|
279
|
+
const cwd = dirname(tsconfig);
|
|
280
|
+
const { command, args } = resolveTypeChecker(tsconfig, option);
|
|
281
|
+
this.proc = spawn(command, args, {
|
|
282
|
+
cwd,
|
|
283
|
+
stdio: [
|
|
284
|
+
"pipe",
|
|
285
|
+
"pipe",
|
|
286
|
+
"ignore"
|
|
287
|
+
]
|
|
288
|
+
});
|
|
289
|
+
this.proc.stdout.on("data", (chunk) => this.onData(chunk));
|
|
290
|
+
const fail = (error) => {
|
|
291
|
+
this.exitError ??= error;
|
|
292
|
+
for (const { reject } of this.pending.values()) reject(this.exitError);
|
|
293
|
+
this.pending.clear();
|
|
294
|
+
};
|
|
295
|
+
this.proc.on("error", fail);
|
|
296
|
+
this.proc.stdin.on("error", fail);
|
|
297
|
+
this.proc.on("exit", (code) => fail(/* @__PURE__ */ new Error(`type checker exited with code ${code}`)));
|
|
298
|
+
const rootUri = pathToFileURL(cwd).href;
|
|
299
|
+
this.ready = this.request("initialize", {
|
|
300
|
+
processId: process.pid,
|
|
301
|
+
rootUri,
|
|
302
|
+
capabilities: { textDocument: { diagnostic: {} } },
|
|
303
|
+
workspaceFolders: [{
|
|
304
|
+
uri: rootUri,
|
|
305
|
+
name: "root"
|
|
306
|
+
}]
|
|
307
|
+
}).then(() => this.notify("initialized", {}));
|
|
308
|
+
this.ready.catch(() => {});
|
|
309
|
+
}
|
|
310
|
+
onData(chunk) {
|
|
311
|
+
this.buffer = Buffer.concat([this.buffer, chunk]);
|
|
312
|
+
while (true) {
|
|
313
|
+
const headerEnd = this.buffer.indexOf("\r\n\r\n");
|
|
314
|
+
if (headerEnd === -1) break;
|
|
315
|
+
const match = /Content-Length: (\d+)/i.exec(this.buffer.subarray(0, headerEnd).toString("utf8"));
|
|
316
|
+
if (!match) break;
|
|
317
|
+
const bodyStart = headerEnd + 4;
|
|
318
|
+
const bodyEnd = bodyStart + Number(match[1]);
|
|
319
|
+
if (this.buffer.length < bodyEnd) break;
|
|
320
|
+
const msg = JSON.parse(this.buffer.subarray(bodyStart, bodyEnd).toString("utf8"));
|
|
321
|
+
this.buffer = this.buffer.subarray(bodyEnd);
|
|
322
|
+
if (msg.id !== void 0 && msg.method !== void 0) this.send({
|
|
323
|
+
jsonrpc: "2.0",
|
|
324
|
+
id: msg.id,
|
|
325
|
+
result: null
|
|
326
|
+
});
|
|
327
|
+
else if (msg.id !== void 0 && this.pending.has(msg.id)) {
|
|
328
|
+
const entry = this.pending.get(msg.id);
|
|
329
|
+
this.pending.delete(msg.id);
|
|
330
|
+
if (msg.error) entry.reject(new Error(msg.error.message));
|
|
331
|
+
else entry.resolve(msg.result);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
send(payload) {
|
|
336
|
+
const json = JSON.stringify(payload);
|
|
337
|
+
this.proc.stdin.write(`Content-Length: ${Buffer.byteLength(json, "utf8")}\r\n\r\n${json}`);
|
|
338
|
+
}
|
|
339
|
+
notify(method, params) {
|
|
340
|
+
this.send({
|
|
341
|
+
jsonrpc: "2.0",
|
|
342
|
+
method,
|
|
343
|
+
params
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
request(method, params) {
|
|
347
|
+
if (this.exitError) return Promise.reject(this.exitError);
|
|
348
|
+
const id = this.seq++;
|
|
349
|
+
return new Promise((resolve, reject) => {
|
|
350
|
+
this.pending.set(id, {
|
|
351
|
+
resolve,
|
|
352
|
+
reject
|
|
353
|
+
});
|
|
354
|
+
this.send({
|
|
355
|
+
jsonrpc: "2.0",
|
|
356
|
+
id,
|
|
357
|
+
method,
|
|
358
|
+
params
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
updateDocument(filePath, text) {
|
|
363
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
364
|
+
if (!this.versions.has(uri)) {
|
|
365
|
+
this.versions.set(uri, 1);
|
|
366
|
+
this.notify("textDocument/didOpen", { textDocument: {
|
|
367
|
+
uri,
|
|
368
|
+
languageId: "typescript",
|
|
369
|
+
version: 1,
|
|
370
|
+
text
|
|
371
|
+
} });
|
|
372
|
+
}
|
|
373
|
+
const version = this.versions.get(uri) + 1;
|
|
374
|
+
this.versions.set(uri, version);
|
|
375
|
+
this.notify("textDocument/didChange", {
|
|
376
|
+
textDocument: {
|
|
377
|
+
uri,
|
|
378
|
+
version
|
|
379
|
+
},
|
|
380
|
+
contentChanges: [{ text }]
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
async checkFile(filePath, sourceLineCount, lines, tcbRanges, inMemory = false) {
|
|
384
|
+
const resolvedPath = resolve(filePath);
|
|
385
|
+
const errors = [];
|
|
386
|
+
const diag = await this.request("textDocument/diagnostic", { textDocument: { uri: pathToFileURL(resolvedPath).href } });
|
|
387
|
+
for (const item of diag?.items ?? []) {
|
|
388
|
+
if (item.severity !== 1) continue;
|
|
389
|
+
if (inMemory && IGNORED_IN_MEMORY_CODES.has(Number(item.code))) continue;
|
|
390
|
+
const line = item.range.start.line;
|
|
391
|
+
if (sourceLineCount !== void 0 && line >= sourceLineCount) {
|
|
392
|
+
if (!IGNORED_TCB_CODES.has(Number(item.code)) && !lines?.[line]?.includes("/*D:ignore*/")) {
|
|
393
|
+
const range = tcbRanges?.find((r) => line >= r.startLine && line < r.endLine);
|
|
394
|
+
const location = range && lines && templateLocation(range, lines, item.range.start);
|
|
395
|
+
errors.push(location ? `${this.formatLocation(location)} - error TS${item.code}: ${item.message}` : `${range?.filePath ?? filePath} (template): error TS${item.code}: ${item.message}`);
|
|
396
|
+
}
|
|
397
|
+
} else {
|
|
398
|
+
const location = {
|
|
399
|
+
file: filePath,
|
|
400
|
+
line: line + 1,
|
|
401
|
+
character: item.range.start.character + 1
|
|
402
|
+
};
|
|
403
|
+
errors.push(`${this.formatLocation(location)} - error TS${item.code}: ${item.message}`);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return errors;
|
|
407
|
+
}
|
|
408
|
+
formatLocation(location) {
|
|
409
|
+
const { file, line, character } = this.host?.mapLocation(location) ?? location;
|
|
410
|
+
return `${file}:${line}:${character}`;
|
|
411
|
+
}
|
|
412
|
+
/** Reports a change on disk; an open copy is closed so the checker rereads the file. */
|
|
413
|
+
notifyFileChanged(filePath, type) {
|
|
414
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
415
|
+
const wasOpen = this.versions.delete(uri);
|
|
416
|
+
this.ready.then(() => {
|
|
417
|
+
if (wasOpen) this.notify("textDocument/didClose", { textDocument: { uri } });
|
|
418
|
+
this.notify("workspace/didChangeWatchedFiles", { changes: [{
|
|
419
|
+
uri,
|
|
420
|
+
type
|
|
421
|
+
}] });
|
|
422
|
+
}, () => {});
|
|
423
|
+
}
|
|
424
|
+
queueFile(filePath, sourceCode, tcbCode) {
|
|
425
|
+
this.queued.set(filePath, {
|
|
426
|
+
sourceCode,
|
|
427
|
+
tcbCode
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
async flushQueue(watchMode = false) {
|
|
431
|
+
if (this.queued.size === 0) return [];
|
|
432
|
+
const entries = Array.from(this.queued.entries());
|
|
433
|
+
this.queued.clear();
|
|
434
|
+
await this.ready;
|
|
435
|
+
const toKey = (filePath) => filePath.replace(/\\/g, "/");
|
|
436
|
+
const inMemoryFiles = new Map([...this.host?.inMemoryFiles() ?? []].map(([filePath, text]) => [toKey(filePath), text]));
|
|
437
|
+
const isInMemory = (filePath) => inMemoryFiles.has(toKey(filePath));
|
|
438
|
+
for (const filePath of this.inMemoryText.keys()) if (!inMemoryFiles.has(filePath)) {
|
|
439
|
+
this.inMemoryText.delete(filePath);
|
|
440
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
441
|
+
if (this.versions.delete(uri)) this.notify("textDocument/didClose", { textDocument: { uri } });
|
|
442
|
+
}
|
|
443
|
+
for (const [filePath, text] of inMemoryFiles) if (this.inMemoryText.get(filePath) !== text) {
|
|
444
|
+
this.inMemoryText.set(filePath, text);
|
|
445
|
+
this.updateDocument(filePath, text);
|
|
446
|
+
}
|
|
447
|
+
const metas = [];
|
|
448
|
+
let updatesCount = 0;
|
|
449
|
+
const update = async (filePath, text) => {
|
|
450
|
+
this.updateDocument(filePath, text);
|
|
451
|
+
updatesCount++;
|
|
452
|
+
if (updatesCount % BATCH_SIZE === 0) await new Promise((r) => setTimeout(r, 5));
|
|
453
|
+
};
|
|
454
|
+
if (!watchMode && entries.length > 1) {
|
|
455
|
+
const [hostFilePath, hostItem] = entries[0];
|
|
456
|
+
const hostDir = dirname(resolve(hostFilePath));
|
|
457
|
+
const hostUri = pathToFileURL(resolve(hostFilePath)).href;
|
|
458
|
+
const sharedImports = /* @__PURE__ */ new Map();
|
|
459
|
+
const relocatedChunks = [];
|
|
460
|
+
let hostRelocated = false;
|
|
461
|
+
for (let i = 0; i < entries.length; i++) {
|
|
462
|
+
const [filePath, { sourceCode, tcbCode }] = entries[i];
|
|
463
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
464
|
+
if (tcbCode && !this.versions.has(uri) && !isInMemory(filePath)) {
|
|
465
|
+
const relocated = relocateTcb(filePath, tcbCode, hostDir, i, sharedImports);
|
|
466
|
+
if (relocated !== null) {
|
|
467
|
+
relocatedChunks.push({
|
|
468
|
+
filePath,
|
|
469
|
+
sourceCode,
|
|
470
|
+
...relocated
|
|
471
|
+
});
|
|
472
|
+
if (i === 0) hostRelocated = true;
|
|
473
|
+
else metas.push({
|
|
474
|
+
filePath,
|
|
475
|
+
sourceLineCount: sourceCode.split("\n").length
|
|
476
|
+
});
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
if (i === 0) continue;
|
|
481
|
+
const { text, meta } = inPlaceDocument(filePath, sourceCode, tcbCode);
|
|
482
|
+
if (tcbCode || this.versions.has(uri) || isInMemory(filePath)) await update(filePath, text);
|
|
483
|
+
metas.push(meta);
|
|
484
|
+
}
|
|
485
|
+
const { meta: hostMeta } = inPlaceDocument(hostFilePath, hostItem.sourceCode, hostRelocated ? null : hostItem.tcbCode);
|
|
486
|
+
const hostLines = hostMeta.lines ?? hostItem.sourceCode.split("\n");
|
|
487
|
+
const hostTcbRanges = hostMeta.tcbRanges ?? [];
|
|
488
|
+
if (relocatedChunks.length > 0) {
|
|
489
|
+
for (const [spec, alias] of sharedImports) hostLines.push(`import * as ${alias} from '${spec}';`);
|
|
490
|
+
for (const { filePath, sourceCode, body, templateSources } of relocatedChunks) {
|
|
491
|
+
const startLine = hostLines.length;
|
|
492
|
+
hostLines.push(...body.split("\n"));
|
|
493
|
+
hostTcbRanges.push({
|
|
494
|
+
startLine,
|
|
495
|
+
endLine: hostLines.length,
|
|
496
|
+
filePath,
|
|
497
|
+
sourceCode,
|
|
498
|
+
templateSources
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const hasHostTcb = hostTcbRanges.length > 0;
|
|
503
|
+
if (hasHostTcb || this.versions.has(hostUri) || isInMemory(hostFilePath)) this.updateDocument(hostFilePath, hostLines.join("\n"));
|
|
504
|
+
metas.unshift({
|
|
505
|
+
filePath: hostFilePath,
|
|
506
|
+
sourceLineCount: hostMeta.sourceLineCount,
|
|
507
|
+
lines: hasHostTcb ? hostLines : void 0,
|
|
508
|
+
tcbRanges: hasHostTcb ? hostTcbRanges : void 0
|
|
509
|
+
});
|
|
510
|
+
} else for (const [filePath, { sourceCode, tcbCode }] of entries) {
|
|
511
|
+
const { text, meta } = inPlaceDocument(filePath, sourceCode, tcbCode);
|
|
512
|
+
const uri = pathToFileURL(resolve(filePath)).href;
|
|
513
|
+
if (tcbCode || watchMode || this.versions.has(uri) || isInMemory(filePath)) await update(filePath, text);
|
|
514
|
+
metas.push(meta);
|
|
515
|
+
}
|
|
516
|
+
const errors = [];
|
|
517
|
+
const first = metas[0];
|
|
518
|
+
errors.push(...await this.checkFile(first.filePath, first.sourceLineCount, first.lines, first.tcbRanges, isInMemory(first.filePath)));
|
|
519
|
+
for (let i = 1; i < metas.length; i += BATCH_SIZE) {
|
|
520
|
+
const slice = metas.slice(i, i + BATCH_SIZE);
|
|
521
|
+
const batchResults = await Promise.all(slice.map(({ filePath, sourceLineCount, lines, tcbRanges }) => this.checkFile(filePath, sourceLineCount, lines, tcbRanges, isInMemory(filePath))));
|
|
522
|
+
for (const res of batchResults) errors.push(...res);
|
|
523
|
+
}
|
|
524
|
+
return errors;
|
|
525
|
+
}
|
|
526
|
+
close() {
|
|
527
|
+
this.proc.kill();
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
export { LspTypeChecker, TCB_TEMPLATE_SOURCES_PREFIX, readSpanComment, resolveTypeChecker };
|
|
531
|
+
|
|
532
|
+
//# sourceMappingURL=lsp-type-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lsp-type-checker.js","names":[],"sources":["../../../../src/lib/utils/lsp-type-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';\nimport { fromWasmPath } from './ngp-host-fs.js';\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]);\n// \"The inferred type of 'x' cannot be named\": in-memory files are never emitted\nconst IGNORED_IN_MEMORY_CODES = new Set([2742, 2883]);\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 templateFile = source?.templateFile\n ? fromWasmPath(source.templateFile)\n : undefined;\n const file = templateFile ?? range.filePath;\n let content = range.sourceCode;\n if (templateFile) {\n try {\n content = readFileSync(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\nexport type TypeCheckerOption =\n | 'tsgo'\n | 'tsrs'\n | { command: string; args?: string[] };\n\ninterface TypeCheckerCommand {\n command: string;\n args: string[];\n}\n\nconst LSP_ARGS = ['--lsp', '--stdio'];\n\n/** LSP `FileChangeType`: 1 created, 2 changed, 3 deleted. */\nexport type FileChangeType = 1 | 2 | 3;\n\n/** A reported location, with a one-based line and character. */\nexport interface SourceLocation {\n file: string;\n line: number;\n character: number;\n}\n\n/** Hooks for checking files that don't exist on disk. */\nexport interface LspTypeCheckerHost {\n /**\n * The text of files that exist only in memory, by normalized path. They're\n * opened before any check, so imports of them resolve.\n */\n inMemoryFiles(): ReadonlyMap<string, string>;\n /** Maps a reported location to the source it was generated from. */\n mapLocation(location: SourceLocation): SourceLocation;\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\n// Run tsrs through its launcher, which selects the platform binary.\nfunction resolveTsrs(tsconfig: string): TypeCheckerCommand {\n for (const base of [tsconfig, import.meta.url]) {\n try {\n const pkg = createRequire(base).resolve('tsrs/package.json');\n return {\n command: process.execPath,\n args: [resolve(dirname(pkg), 'bin', 'tsrs'), ...LSP_ARGS],\n };\n } catch {\n // try next base\n }\n }\n throw new Error(\"typeChecker: 'tsrs' requires the tsrs package.\");\n}\n\nexport function resolveTypeChecker(\n tsconfig: string,\n option: TypeCheckerOption,\n): TypeCheckerCommand {\n if (typeof option === 'object') {\n return { command: option.command, args: option.args ?? LSP_ARGS };\n }\n if (option === 'tsrs') return resolveTsrs(tsconfig);\n return { command: resolveTsgoBinary(tsconfig), args: LSP_ARGS };\n}\n\nexport class LspTypeChecker {\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 /** The text last sent for each open in-memory file. */\n private inMemoryText = new Map<string, string>();\n private buffer = Buffer.alloc(0);\n private exitError: Error | undefined;\n readonly ready: Promise<void>;\n\n constructor(\n tsconfig: string,\n option: TypeCheckerOption = 'tsgo',\n private readonly host?: LspTypeCheckerHost,\n ) {\n const cwd = dirname(tsconfig);\n const { command, args } = resolveTypeChecker(tsconfig, option);\n this.proc = spawn(command, args, {\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(`type checker 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 inMemory = false,\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 if (inMemory && IGNORED_IN_MEMORY_CODES.has(Number(item.code))) 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 ? `${this.formatLocation(location)} - error TS${item.code}: ${item.message}`\n : `${range?.filePath ?? filePath} (template): error TS${item.code}: ${item.message}`,\n );\n }\n } else {\n const location = {\n file: filePath,\n line: line + 1,\n character: item.range.start.character + 1,\n };\n errors.push(\n `${this.formatLocation(location)} - error TS${item.code}: ${item.message}`,\n );\n }\n }\n return errors;\n }\n\n private formatLocation(location: SourceLocation): string {\n const { file, line, character } =\n this.host?.mapLocation(location) ?? location;\n return `${file}:${line}:${character}`;\n }\n\n /** Reports a change on disk; an open copy is closed so the checker rereads the file. */\n notifyFileChanged(filePath: string, type: FileChangeType) {\n const uri = pathToFileURL(resolve(filePath)).href;\n const wasOpen = this.versions.delete(uri);\n this.ready.then(\n () => {\n if (wasOpen)\n this.notify('textDocument/didClose', { textDocument: { uri } });\n this.notify('workspace/didChangeWatchedFiles', {\n changes: [{ uri, type }],\n });\n },\n () => {},\n );\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 toKey = (filePath: string) => filePath.replace(/\\\\/g, '/');\n const inMemoryFiles = new Map(\n [...(this.host?.inMemoryFiles() ?? [])].map(([filePath, text]) => [\n toKey(filePath),\n text,\n ]),\n );\n const isInMemory = (filePath: string) => inMemoryFiles.has(toKey(filePath));\n // Keep the checker's in-memory files in step with the host's\n for (const filePath of this.inMemoryText.keys()) {\n if (!inMemoryFiles.has(filePath)) {\n this.inMemoryText.delete(filePath);\n const uri = pathToFileURL(resolve(filePath)).href;\n if (this.versions.delete(uri)) {\n this.notify('textDocument/didClose', { textDocument: { uri } });\n }\n }\n }\n for (const [filePath, text] of inMemoryFiles) {\n if (this.inMemoryText.get(filePath) !== text) {\n this.inMemoryText.set(filePath, text);\n this.updateDocument(filePath, text);\n }\n }\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) && !isInMemory(filePath)) {\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) || isInMemory(filePath)) {\n await update(filePath, text);\n }\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 (\n hasHostTcb ||\n this.versions.has(hostUri) ||\n isInMemory(hostFilePath)\n ) {\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 (\n tcbCode ||\n watchMode ||\n this.versions.has(uri) ||\n isInMemory(filePath)\n ) {\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 isInMemory(first.filePath),\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(\n filePath,\n sourceLineCount,\n lines,\n tcbRanges,\n isInMemory(filePath),\n ),\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":";;;;;;;;;;AAwCA,IAAa,8BAA8B;AAE3C,IAAM,oCAAoB,IAAI,IAAI;CAAC;CAAM;CAAM;CAAM;AAAI,CAAC;AAE1D,IAAM,0CAA0B,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;AACpD,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;E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UAAU,KAAK,IAAI,CAAC;GAExD,MAAM,QAAQ;IACZ,UAAU;IACV,iBAAiB,SAAS;IAC1B,OAAO,aAAa,YAAY,KAAA;IAChC,WAAW,aAAa,gBAAgB,KAAA;GAC1C,CAAC;EACH,OACE,KAAK,MAAM,CAAC,UAAU,EAAE,YAAY,cAAc,SAAS;GACzD,MAAM,EAAE,MAAM,SAAS,gBAAgB,UAAU,YAAY,OAAO;GACpE,MAAM,MAAM,cAAc,QAAQ,QAAQ,CAAC,CAAC,CAAC;GAC7C,IACE,WACA,aACA,KAAK,SAAS,IAAI,GAAG,KACrB,WAAW,QAAQ,GAEnB,MAAM,OAAO,UAAU,IAAI;GAE7B,MAAM,KAAK,IAAI;EACjB;EAGF,MAAM,SAAmB,CAAC;EAC1B,MAAM,QAAQ,MAAM;EACpB,OAAO,KACL,GAAI,MAAM,KAAK,UACb,MAAM,UACN,MAAM,iBACN,MAAM,OACN,MAAM,WACN,WAAW,MAAM,QAAQ,CAC3B,CACF;EAEA,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,YAAY;GACjD,MAAM,QAAQ,MAAM,MAAM,GAAG,IAAI,UAAU;GAC3C,MAAM,eAAe,MAAM,QAAQ,IACjC,MAAM,KAAK,EAAE,UAAU,iBAAiB,OAAO,gBAC7C,KAAK,UACH,UACA,iBACA,OACA,WACA,WAAW,QAAQ,CACrB,CACF,CACF;GACA,KAAK,MAAM,OAAO,cAChB,OAAO,KAAK,GAAG,GAAG;EAEtB;EACA,OAAO;CACT;CAEA,QAAQ;EACN,KAAK,KAAK,KAAK;CACjB;AACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface HostStat {
|
|
2
|
+
isFile: boolean;
|
|
3
|
+
isDir: boolean;
|
|
4
|
+
isSymlink: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface HostDirEntry extends HostStat {
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
/** The file system NGP's WebAssembly backend reads through (`hostFs`). */
|
|
10
|
+
export interface NgpHostFs {
|
|
11
|
+
read(path: string): Uint8Array | null;
|
|
12
|
+
metadata(path: string): HostStat | null;
|
|
13
|
+
symlinkMetadata(path: string): HostStat | null;
|
|
14
|
+
readLink(path: string): string | null;
|
|
15
|
+
canonicalize(path: string): string | null;
|
|
16
|
+
readDir(path: string): HostDirEntry[] | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `path`, normalized, with the symlinks of its directory resolved. Lowered
|
|
20
|
+
* modules are keyed by these paths, whichever path a file is reached by.
|
|
21
|
+
*/
|
|
22
|
+
export declare function canonicalPath(path: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Converts a host path to the POSIX-absolute form NGP's WebAssembly backend
|
|
25
|
+
* expects (`D:\a\b` → `/D:/a/b`). POSIX and relative paths are unchanged.
|
|
26
|
+
*/
|
|
27
|
+
export declare function toWasmPath(path: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Converts a path returned by NGP's WebAssembly backend back to a normalized
|
|
30
|
+
* host path (`/D:/a/b` → `D:/a/b`).
|
|
31
|
+
*/
|
|
32
|
+
export declare function fromWasmPath(path: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* The disk, with each module of a source format served as a TypeScript file
|
|
35
|
+
* named after it (`x.tsrx` as `x.tsrx.ts`) and the module itself hidden, so an
|
|
36
|
+
* import of `./x.tsrx` resolves to its TypeScript. Also translates Windows
|
|
37
|
+
* drive paths at the WebAssembly boundary.
|
|
38
|
+
*
|
|
39
|
+
* @param programCode The TypeScript of a module's program file, by the file's
|
|
40
|
+
* normalized, canonical path.
|
|
41
|
+
*/
|
|
42
|
+
export declare function createNgpHostFs(programCode?: (path: string) => string | undefined): NgpHostFs;
|
|
43
|
+
export {};
|