@bascik/language-server 0.1.0-rc.5 → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -30
- package/dist/analyzer.d.ts +75 -1
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +727 -76
- package/dist/analyzer.js.map +1 -1
- package/dist/api-rules.d.ts +7 -0
- package/dist/api-rules.d.ts.map +1 -1
- package/dist/api-rules.js +282 -17
- package/dist/api-rules.js.map +1 -1
- package/dist/bin-args.d.ts +11 -0
- package/dist/bin-args.d.ts.map +1 -0
- package/dist/bin-args.js +21 -0
- package/dist/bin-args.js.map +1 -0
- package/dist/bin.js +17 -5
- package/dist/bin.js.map +1 -1
- package/dist/check.d.ts +14 -1
- package/dist/check.d.ts.map +1 -1
- package/dist/check.js +116 -10
- package/dist/check.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +27 -8
- package/dist/cli.js.map +1 -1
- package/dist/compatibility-rules.json +21 -3
- package/dist/component-metadata.d.ts.map +1 -1
- package/dist/component-metadata.js +3 -1
- package/dist/component-metadata.js.map +1 -1
- package/dist/component-usages.d.ts +47 -0
- package/dist/component-usages.d.ts.map +1 -0
- package/dist/component-usages.js +495 -0
- package/dist/component-usages.js.map +1 -0
- package/dist/config-reader.d.ts +41 -0
- package/dist/config-reader.d.ts.map +1 -0
- package/dist/config-reader.js +461 -0
- package/dist/config-reader.js.map +1 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +25 -30
- package/dist/config.js.map +1 -1
- package/dist/css-brace-balance.d.ts +33 -0
- package/dist/css-brace-balance.d.ts.map +1 -0
- package/dist/css-brace-balance.js +99 -0
- package/dist/css-brace-balance.js.map +1 -0
- package/dist/hand-written-escaper.d.ts +35 -0
- package/dist/hand-written-escaper.d.ts.map +1 -0
- package/dist/hand-written-escaper.js +739 -0
- package/dist/hand-written-escaper.js.map +1 -0
- package/dist/module-specifiers.d.ts +25 -0
- package/dist/module-specifiers.d.ts.map +1 -1
- package/dist/module-specifiers.js +234 -165
- package/dist/module-specifiers.js.map +1 -1
- package/dist/name-groups.d.ts +36 -0
- package/dist/name-groups.d.ts.map +1 -0
- package/dist/name-groups.js +198 -0
- package/dist/name-groups.js.map +1 -0
- package/dist/plain-holes.d.ts +116 -0
- package/dist/plain-holes.d.ts.map +1 -0
- package/dist/plain-holes.js +1970 -0
- package/dist/plain-holes.js.map +1 -0
- package/dist/preserved-targets.d.ts +50 -0
- package/dist/preserved-targets.d.ts.map +1 -0
- package/dist/preserved-targets.js +358 -0
- package/dist/preserved-targets.js.map +1 -0
- package/dist/project.d.ts +68 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +157 -8
- package/dist/project.js.map +1 -1
- package/dist/references.d.ts +47 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +241 -0
- package/dist/references.js.map +1 -0
- package/dist/script-modules.d.ts +60 -0
- package/dist/script-modules.d.ts.map +1 -0
- package/dist/script-modules.js +382 -0
- package/dist/script-modules.js.map +1 -0
- package/dist/server-script-rules.d.ts +94 -1
- package/dist/server-script-rules.d.ts.map +1 -1
- package/dist/server-script-rules.js +2572 -230
- package/dist/server-script-rules.js.map +1 -1
- package/dist/server-script-templates.d.ts +250 -0
- package/dist/server-script-templates.d.ts.map +1 -0
- package/dist/server-script-templates.js +1685 -0
- package/dist/server-script-templates.js.map +1 -0
- package/dist/server.d.ts +191 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +822 -50
- package/dist/server.js.map +1 -1
- package/dist/start.d.ts +10 -1
- package/dist/start.d.ts.map +1 -1
- package/dist/start.js +14 -2
- package/dist/start.js.map +1 -1
- package/dist/string-typed-flow.d.ts +26 -0
- package/dist/string-typed-flow.d.ts.map +1 -0
- package/dist/string-typed-flow.js +496 -0
- package/dist/string-typed-flow.js.map +1 -0
- package/dist/typescript-blocks.d.ts +205 -0
- package/dist/typescript-blocks.d.ts.map +1 -0
- package/dist/typescript-blocks.js +464 -0
- package/dist/typescript-blocks.js.map +1 -0
- package/dist/typescript-editor-mode.d.ts +28 -0
- package/dist/typescript-editor-mode.d.ts.map +1 -0
- package/dist/typescript-editor-mode.js +161 -0
- package/dist/typescript-editor-mode.js.map +1 -0
- package/dist/typescript-engine.d.ts +115 -0
- package/dist/typescript-engine.d.ts.map +1 -0
- package/dist/typescript-engine.js +286 -0
- package/dist/typescript-engine.js.map +1 -0
- package/dist/typescript-features.d.ts +136 -0
- package/dist/typescript-features.d.ts.map +1 -0
- package/dist/typescript-features.js +374 -0
- package/dist/typescript-features.js.map +1 -0
- package/dist/typescript-loader.d.ts +55 -0
- package/dist/typescript-loader.d.ts.map +1 -0
- package/dist/typescript-loader.js +202 -0
- package/dist/typescript-loader.js.map +1 -0
- package/dist/typescript-lsp.d.ts +8 -0
- package/dist/typescript-lsp.d.ts.map +1 -0
- package/dist/typescript-lsp.js +115 -0
- package/dist/typescript-lsp.js.map +1 -0
- package/dist/typescript-service.d.ts +350 -0
- package/dist/typescript-service.d.ts.map +1 -0
- package/dist/typescript-service.js +1465 -0
- package/dist/typescript-service.js.map +1 -0
- package/dist/typescript-worker.d.ts +11 -0
- package/dist/typescript-worker.d.ts.map +1 -0
- package/dist/typescript-worker.js +107 -0
- package/dist/typescript-worker.js.map +1 -0
- package/package.json +34 -12
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import type * as TS from "typescript";
|
|
2
|
+
import type { ComponentSource } from "./project.js";
|
|
3
|
+
import { type TypeScriptProgramKind } from "./typescript-blocks.js";
|
|
4
|
+
import { type TypeScriptFeatureAnswers, type TypeScriptFeatureKind, type TypeScriptFeatureQuery } from "./typescript-features.js";
|
|
5
|
+
import { type TypeScriptModule, type TypeScriptResolution } from "./typescript-loader.js";
|
|
6
|
+
/** One TypeScript error or warning, located by offsets in the HTML file's text. */
|
|
7
|
+
export interface TypeScriptDiagnostic {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
message: string;
|
|
11
|
+
/** TypeScript's error number, such as 2322. */
|
|
12
|
+
code: number;
|
|
13
|
+
category: "error" | "warning";
|
|
14
|
+
}
|
|
15
|
+
/** What a diagnostics request returns. */
|
|
16
|
+
export type TypeScriptDiagnosticsResult = {
|
|
17
|
+
status: "ok";
|
|
18
|
+
diagnostics: TypeScriptDiagnostic[];
|
|
19
|
+
/** Why the client's TypeScript path was not used (another copy was), for the editor to show. */
|
|
20
|
+
clientPathProblem?: string;
|
|
21
|
+
}
|
|
22
|
+
/** No usable TypeScript for the project; `message` says why, once per project. */
|
|
23
|
+
| {
|
|
24
|
+
status: "unavailable";
|
|
25
|
+
message: string;
|
|
26
|
+
clientPathProblem?: string;
|
|
27
|
+
}
|
|
28
|
+
/** A newer edit made the request stale before it finished. */
|
|
29
|
+
| {
|
|
30
|
+
status: "cancelled";
|
|
31
|
+
}
|
|
32
|
+
/** TypeScript threw (a bug, or a broken install); `message` is for the log. */
|
|
33
|
+
| {
|
|
34
|
+
status: "failed";
|
|
35
|
+
message: string;
|
|
36
|
+
};
|
|
37
|
+
/** What a language feature request returns: the answer (or none), or why there is none. */
|
|
38
|
+
export type TypeScriptFeatureResult<K extends TypeScriptFeatureKind = TypeScriptFeatureKind> = {
|
|
39
|
+
status: "ok";
|
|
40
|
+
answer: TypeScriptFeatureAnswers[K] | undefined;
|
|
41
|
+
} | {
|
|
42
|
+
status: "unavailable";
|
|
43
|
+
message: string;
|
|
44
|
+
} | {
|
|
45
|
+
status: "cancelled";
|
|
46
|
+
} | {
|
|
47
|
+
status: "failed";
|
|
48
|
+
message: string;
|
|
49
|
+
};
|
|
50
|
+
/** The source tag on every published TypeScript diagnostic, so they read apart from Bascik's own. */
|
|
51
|
+
export declare const TYPESCRIPT_DIAGNOSTIC_SOURCE = "ts (bascik)";
|
|
52
|
+
/** How an HTML file's blocks are checked, from where it sits in the project (see `hasIsolatedClientBlocks`). */
|
|
53
|
+
export interface PageCheckOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Each client block runs in its own scope (a component with `scoping.scriptBlocks` on). Otherwise, as in a
|
|
56
|
+
* page, the client blocks share one scope. Default `false`.
|
|
57
|
+
*/
|
|
58
|
+
isolatedClientBlocks?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* The HTML of the components whose client scripts run in this page's scope (with `scoping.scriptBlocks` off),
|
|
61
|
+
* so the names they declare are known. Default none.
|
|
62
|
+
*/
|
|
63
|
+
pageScopeHtml?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* The components the page uses, directly or through others, that have TypeScript blocks. Their scripts run on
|
|
66
|
+
* the page, so what their client blocks add to the browser's globals (`interface Window { ... }`, `declare
|
|
67
|
+
* global`) holds on the page too, whatever the script scoping. Default none.
|
|
68
|
+
*/
|
|
69
|
+
usedComponents?: ComponentSource[];
|
|
70
|
+
}
|
|
71
|
+
export interface TypeScriptProjectOptions {
|
|
72
|
+
ts: TypeScriptModule;
|
|
73
|
+
projectRoot: string;
|
|
74
|
+
/** `scripts.importRoot`, resolved: where `@/` points. */
|
|
75
|
+
importRoot: string;
|
|
76
|
+
/**
|
|
77
|
+
* The unsaved text of a file open in an editor, or `undefined` to read it from disk. Asked with the file's
|
|
78
|
+
* absolute path spelled with forward slashes (`tsPath`), on every platform.
|
|
79
|
+
*/
|
|
80
|
+
readOpenFile?: (fsPath: string) => string | undefined;
|
|
81
|
+
/** Polled by TypeScript while it checks; `true` stops the check with `OperationCanceledException`. */
|
|
82
|
+
isCancellationRequested?: () => boolean;
|
|
83
|
+
/** Shares parsed files (the large library files above all) with other projects using the same TypeScript. */
|
|
84
|
+
registry?: TS.DocumentRegistry;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The web-standard globals a server-side block has without `@types/node`: `Request`, `Response`, `URL`, `fetch`,
|
|
88
|
+
* `Headers`, `AbortSignal`, streams, `crypto` and `import.meta.url`, which Node and workerd both provide. A web
|
|
89
|
+
* worker's library has them and, unlike the browser's, no `document` or `window`.
|
|
90
|
+
*/
|
|
91
|
+
export declare const SERVER_WEB_LIBS: string[];
|
|
92
|
+
/**
|
|
93
|
+
* Node's globals and built-in modules, untyped, for server-side blocks in a project without `@types/node`. Code
|
|
94
|
+
* that runs in Node is never reported for using them; installing `@types/node` gives them their types.
|
|
95
|
+
*/
|
|
96
|
+
export declare function untypedNodeDeclarations(): string;
|
|
97
|
+
/** Whether `@types/node` can be found from the project, so server-side blocks get Node's globals and modules. */
|
|
98
|
+
export declare function hasNodeTypes(projectRoot: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* The compiler options for one program: the project's `tsconfig.json` (when it has one), then Bascik's settings,
|
|
101
|
+
* then the libraries and global types that program's scripts run with.
|
|
102
|
+
*/
|
|
103
|
+
export declare function compilerOptionsFor(ts: TypeScriptModule, projectRoot: string, importRoot: string, program: TypeScriptProgramKind, nodeTypes?: boolean): TS.CompilerOptions;
|
|
104
|
+
/** What a client script declares and how it parses, read once per distinct text (see `classicScriptInfo`). */
|
|
105
|
+
interface ClassicScriptInfo {
|
|
106
|
+
/** Top-level value names: the globals a classic script adds for the scripts after it. */
|
|
107
|
+
names: string[];
|
|
108
|
+
/** The top-level `var` and `function` names (declared ones too): those that are properties of `window`. */
|
|
109
|
+
windowNames: string[];
|
|
110
|
+
/** The script's own `declare global { }` blocks, which add to the browser's globals, as written. */
|
|
111
|
+
globalAugmentations: string[];
|
|
112
|
+
/** Top-level type names other than interfaces (type aliases, namespaces) and the names its imports bind. */
|
|
113
|
+
localNames: string[];
|
|
114
|
+
/** Top-level interfaces with no modifiers, by name, offsets in the script and text. */
|
|
115
|
+
interfaces: {
|
|
116
|
+
name: string;
|
|
117
|
+
start: number;
|
|
118
|
+
end: number;
|
|
119
|
+
text: string;
|
|
120
|
+
}[];
|
|
121
|
+
/** Syntax errors, in offsets of the script, clamped to its length. */
|
|
122
|
+
syntaxErrors: Omit<TypeScriptDiagnostic, "category">[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Reads a client script on its own: the names it declares at the top level, its interfaces and (for a typed one)
|
|
126
|
+
* its syntax errors. A program of that one file, with no libraries and no imports, finds the syntax errors with
|
|
127
|
+
* TypeScript's public API.
|
|
128
|
+
*/
|
|
129
|
+
export declare function readClassicScript(ts: TypeScriptModule, content: string, typed: boolean): ClassicScriptInfo;
|
|
130
|
+
/**
|
|
131
|
+
* The TypeScript blocks of one project: two LanguageServices (client and server), the virtual files of every
|
|
132
|
+
* HTML file it was given, and the versions that tell TypeScript what changed.
|
|
133
|
+
*/
|
|
134
|
+
export declare class TypeScriptProject {
|
|
135
|
+
readonly projectRoot: string;
|
|
136
|
+
readonly importRoot: string;
|
|
137
|
+
private readonly ts;
|
|
138
|
+
private readonly readOpenFile;
|
|
139
|
+
private readonly files;
|
|
140
|
+
private readonly pages;
|
|
141
|
+
/** Versions of real files reported changed (an editor buffer or a file on disk). */
|
|
142
|
+
private readonly fileVersions;
|
|
143
|
+
/** `client` and `server`, and a page's own client service once it augments the globals (see `serviceKey`). */
|
|
144
|
+
private readonly services;
|
|
145
|
+
private readonly registry;
|
|
146
|
+
private readonly cancellationToken;
|
|
147
|
+
private readonly clientOptions;
|
|
148
|
+
private projectVersion;
|
|
149
|
+
private nextFileVersion;
|
|
150
|
+
/** How many times a program was brought up to date with a changed project (see `programUpdates`). */
|
|
151
|
+
private updates;
|
|
152
|
+
/**
|
|
153
|
+
* Whether directive scripts get their types from `@bascik/bascik`. It turns false the first time the typed
|
|
154
|
+
* footer fails to resolve (no `@bascik/bascik`, or one from before the types), until the project is made again.
|
|
155
|
+
*/
|
|
156
|
+
private scriptTypes;
|
|
157
|
+
/** Node's untyped globals and modules for the server program, when the project has no `@types/node`. */
|
|
158
|
+
private readonly nodeDeclarations;
|
|
159
|
+
/** Each program's compiler options, for `missingLibraryFiles`. */
|
|
160
|
+
private readonly programOptions;
|
|
161
|
+
/** `readClassicScript` results by kind and text: most scripts do not change between edits. */
|
|
162
|
+
private readonly scriptInfo;
|
|
163
|
+
/**
|
|
164
|
+
* Files and folders TypeScript looked for and did not find, while resolving an import. Creating one of them
|
|
165
|
+
* (or a file inside one of the folders) can make a failed import resolve, which TypeScript does not notice on
|
|
166
|
+
* its own: a block whose text did not change keeps its old resolutions.
|
|
167
|
+
*/
|
|
168
|
+
private readonly missingPaths;
|
|
169
|
+
/** Files TypeScript read: deleting one can make an import fail. */
|
|
170
|
+
private readonly foundFiles;
|
|
171
|
+
/**
|
|
172
|
+
* Bumped when a file TypeScript looked for appears or disappears. It is part of every project file's version
|
|
173
|
+
* (not a library's or a package's), so TypeScript parses those files again and resolves their imports anew: a
|
|
174
|
+
* file whose version did not change keeps its old resolutions.
|
|
175
|
+
*/
|
|
176
|
+
private resolutionGeneration;
|
|
177
|
+
/** The globals the client program's libraries declare, such as `Window` and `close`; read on first need. */
|
|
178
|
+
private clientGlobals;
|
|
179
|
+
/** The client programs' declaration of `GLOBAL_THIS_TYPE`. */
|
|
180
|
+
private readonly clientDeclarations;
|
|
181
|
+
constructor(options: TypeScriptProjectOptions);
|
|
182
|
+
/**
|
|
183
|
+
* The service a virtual file is checked by. A page whose client blocks add to the browser's globals (a
|
|
184
|
+
* `declare global`, or an interface such as `Window` that Bascik wraps in one) is kept out of the shared client
|
|
185
|
+
* service, where its additions would reach every other page although no two pages run together. Pages whose
|
|
186
|
+
* additions are written the same and refer to none of their own names (the same analytics snippet on every page)
|
|
187
|
+
* mean the same thing, and share a service; any other such page gets one of its own. A page that uses components
|
|
188
|
+
* whose blocks add to the globals is kept out too, as their additions hold on it (`componentBlocks`, each
|
|
189
|
+
* `path#index`); pages that use the same ones share a service.
|
|
190
|
+
*/
|
|
191
|
+
private serviceKey;
|
|
192
|
+
private createService;
|
|
193
|
+
private serviceFor;
|
|
194
|
+
/** Drops a client service of pages that augment the globals, once no page uses it. */
|
|
195
|
+
private dropService;
|
|
196
|
+
/**
|
|
197
|
+
* The library files either program loads that the TypeScript copy does not have, such as one the project's
|
|
198
|
+
* `tsconfig.json` adds to `lib`. Checking without them would report every use of their globals.
|
|
199
|
+
*/
|
|
200
|
+
missingLibraryFiles(): string[];
|
|
201
|
+
private host;
|
|
202
|
+
private recordLookup;
|
|
203
|
+
private readFile;
|
|
204
|
+
/** What a client script declares and how it parses, cached by its text. */
|
|
205
|
+
private classicScript;
|
|
206
|
+
private libraryGlobals;
|
|
207
|
+
/**
|
|
208
|
+
* How a page's shared text declares the names of the page's classic scripts. `typed` are the infos of the typed
|
|
209
|
+
* blocks it joins, `untyped` those of every other classic script in the page's scope (plain scripts, components'
|
|
210
|
+
* scripts, blocks left out for a syntax error).
|
|
211
|
+
*/
|
|
212
|
+
private pageGlobals;
|
|
213
|
+
/** Adds what a client script adds to the browser's globals, and the names it declares, to `into`. */
|
|
214
|
+
private collectAugmentations;
|
|
215
|
+
/**
|
|
216
|
+
* In a classic script, a top-level `interface Window { ... }` adds to the global interface; the block is checked
|
|
217
|
+
* as a module, where it would declare a new one. Wrapping it in `declare global { }` keeps the browser's meaning.
|
|
218
|
+
*/
|
|
219
|
+
private globalInterfaceWraps;
|
|
220
|
+
/**
|
|
221
|
+
* The client blocks of the components a page uses that add to the browser's globals (a `declare global`, or an
|
|
222
|
+
* interface such as `Window` that Bascik wraps in one), each as the virtual text it is checked as on its own.
|
|
223
|
+
* The page's service gets a copy of each, so their additions hold on the page; the rest of a component's code
|
|
224
|
+
* is never reported there. A block mid-edit (a syntax error) adds nothing.
|
|
225
|
+
*/
|
|
226
|
+
private componentGlobalBlocks;
|
|
227
|
+
/** Deletes the component files no page lists any more. True when one was deleted. */
|
|
228
|
+
private dropComponentFiles;
|
|
229
|
+
/**
|
|
230
|
+
* Records an HTML file's text. Only virtual files whose text changed get a new version, so TypeScript reuses
|
|
231
|
+
* what it knows about the rest.
|
|
232
|
+
*/
|
|
233
|
+
updatePage(htmlPath: string, text: string, options?: PageCheckOptions): void;
|
|
234
|
+
/**
|
|
235
|
+
* A page's client blocks as the one classic script the browser runs them as. A block with a syntax error does
|
|
236
|
+
* not run at all in a browser, while the others do, so it is left out and reported on its own; its names stay
|
|
237
|
+
* declared (`any`), so the error is not repeated as unknown names in the blocks after it. The page's plain
|
|
238
|
+
* JavaScript scripts and the component scripts that share its scope add their names the same way.
|
|
239
|
+
*/
|
|
240
|
+
private sharedClientText;
|
|
241
|
+
/** The page's plain classic scripts, and the scripts of components that run in its scope. */
|
|
242
|
+
private otherPageScopeScripts;
|
|
243
|
+
private virtualFile;
|
|
244
|
+
/** Rewrites every directive block with the untyped footer, after the typed one failed to resolve. */
|
|
245
|
+
private dropScriptTypes;
|
|
246
|
+
/** Forgets an HTML file, so its blocks are no longer part of either program. */
|
|
247
|
+
removePage(htmlPath: string): void;
|
|
248
|
+
/**
|
|
249
|
+
* How many times either program was brought up to date with a changed project. Each one makes TypeScript build
|
|
250
|
+
* a new program and type checker, and work out the libraries' globals again, so pages are given to the project
|
|
251
|
+
* together (`updatePage` for each, then `diagnostics`) rather than one per check.
|
|
252
|
+
*/
|
|
253
|
+
get programUpdates(): number;
|
|
254
|
+
/** How many LanguageServices the project holds: client, server, and those of pages that augment the globals. */
|
|
255
|
+
get serviceCount(): number;
|
|
256
|
+
/** A file the blocks may import changed, appeared or disappeared, in an editor buffer or on disk. */
|
|
257
|
+
fileChanged(fsPath: string): void;
|
|
258
|
+
/** The TypeScript errors and warnings of an HTML file's blocks, located in its text. */
|
|
259
|
+
diagnostics(htmlPath: string, text: string, options?: PageCheckOptions): TypeScriptDiagnostic[];
|
|
260
|
+
/**
|
|
261
|
+
* Answers a language feature at an offset of an HTML file, inside one of its TypeScript blocks; `undefined`
|
|
262
|
+
* outside them or with nothing to say. See `typescript-features.ts`.
|
|
263
|
+
*/
|
|
264
|
+
feature<K extends TypeScriptFeatureKind>(htmlPath: string, text: string, options: PageCheckOptions, query: TypeScriptFeatureQuery<K>): TypeScriptFeatureAnswers[K] | undefined;
|
|
265
|
+
/** Where an HTML offset is in the page's virtual files, or `undefined` outside its blocks. */
|
|
266
|
+
private virtualOffset;
|
|
267
|
+
/** The page's client blocks, broken ones included, in one virtual file for language features (see `Page`). */
|
|
268
|
+
private editingFile;
|
|
269
|
+
/** A span of a real file by line and character, read from the program (or the file, if it holds none). */
|
|
270
|
+
private locateInFile;
|
|
271
|
+
dispose(): void;
|
|
272
|
+
}
|
|
273
|
+
/** One page's current text and how its blocks are checked. */
|
|
274
|
+
export interface TypeScriptPageText extends PageCheckOptions {
|
|
275
|
+
htmlPath: string;
|
|
276
|
+
/** The page's current text, which may be unsaved. */
|
|
277
|
+
text: string;
|
|
278
|
+
}
|
|
279
|
+
/** Several pages of one project, given together (see `TypeScriptProjects.preparePages`). */
|
|
280
|
+
export interface TypeScriptPagesRequest {
|
|
281
|
+
projectRoot: string;
|
|
282
|
+
/** `scripts.importRoot`, resolved. */
|
|
283
|
+
importRoot: string;
|
|
284
|
+
pages: TypeScriptPageText[];
|
|
285
|
+
}
|
|
286
|
+
export interface TypeScriptProjectsOptions {
|
|
287
|
+
/** The TypeScript the client asked for (a package folder); see `typescript-loader.ts`. */
|
|
288
|
+
clientPath?: string;
|
|
289
|
+
/** The editor's own TypeScript, tried after `clientPath`. */
|
|
290
|
+
editorPath?: string;
|
|
291
|
+
/** Where to resolve an installed peer `typescript` from after the project. */
|
|
292
|
+
fallbackFrom?: string;
|
|
293
|
+
/** Whether the request that is running is stale. */
|
|
294
|
+
isCancellationRequested?: () => boolean;
|
|
295
|
+
/** Overrides how TypeScript is found (tests). */
|
|
296
|
+
resolve?: (projectRoot: string) => TypeScriptResolution;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Every project's TypeScript blocks, keyed by project root: the synchronous engine behind the language server's
|
|
300
|
+
* worker and `bascik --check`. TypeScript is looked up once per project, on the first request.
|
|
301
|
+
*/
|
|
302
|
+
export declare class TypeScriptProjects {
|
|
303
|
+
private readonly options;
|
|
304
|
+
private readonly projects;
|
|
305
|
+
private readonly resolutions;
|
|
306
|
+
/** Unsaved editor buffers of files the blocks may import. */
|
|
307
|
+
private readonly openFiles;
|
|
308
|
+
/** One per TypeScript copy, shared by its projects. */
|
|
309
|
+
private readonly registries;
|
|
310
|
+
constructor(options?: TypeScriptProjectsOptions);
|
|
311
|
+
private resolution;
|
|
312
|
+
/** The project for a root and import root, made again when the import root changed. */
|
|
313
|
+
private project;
|
|
314
|
+
private registryFor;
|
|
315
|
+
/** The TypeScript the project uses, or why it has none. */
|
|
316
|
+
describe(projectRoot: string): TypeScriptResolution;
|
|
317
|
+
diagnostics(request: {
|
|
318
|
+
projectRoot: string;
|
|
319
|
+
importRoot: string;
|
|
320
|
+
htmlPath: string;
|
|
321
|
+
text: string;
|
|
322
|
+
} & PageCheckOptions): TypeScriptDiagnosticsResult;
|
|
323
|
+
/** Answers a language feature inside a page's TypeScript blocks (see `TypeScriptProject.feature`). */
|
|
324
|
+
feature<K extends TypeScriptFeatureKind>(request: {
|
|
325
|
+
projectRoot: string;
|
|
326
|
+
importRoot: string;
|
|
327
|
+
htmlPath: string;
|
|
328
|
+
text: string;
|
|
329
|
+
} & PageCheckOptions, query: TypeScriptFeatureQuery<K>): TypeScriptFeatureResult<K>;
|
|
330
|
+
/**
|
|
331
|
+
* Records the current text of several pages before any of them is checked, so the programs are brought up to
|
|
332
|
+
* date once for all of them instead of once per page. Without a usable TypeScript it does nothing.
|
|
333
|
+
*/
|
|
334
|
+
preparePages(request: TypeScriptPagesRequest): void;
|
|
335
|
+
/** How many times the project's programs were brought up to date (see `TypeScriptProject.programUpdates`). */
|
|
336
|
+
programUpdates(projectRoot: string): number;
|
|
337
|
+
/** Records (or, with `undefined`, drops) the unsaved text of an editor buffer. */
|
|
338
|
+
setOpenFile(fsPath: string, text: string | undefined): void;
|
|
339
|
+
/**
|
|
340
|
+
* A file changed. A `tsconfig.json` remakes its project (with the new options); anything else gets a new
|
|
341
|
+
* version in every project, which is cheap: TypeScript re-reads it only where a program holds it.
|
|
342
|
+
*/
|
|
343
|
+
fileChanged(fsPath: string): void;
|
|
344
|
+
closePage(projectRoot: string, htmlPath: string): void;
|
|
345
|
+
forgetProject(projectRoot: string): void;
|
|
346
|
+
/** Drops every project and the parsed files they share, which frees TypeScript's memory until the next check. */
|
|
347
|
+
dispose(): void;
|
|
348
|
+
}
|
|
349
|
+
export {};
|
|
350
|
+
//# sourceMappingURL=typescript-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-service.d.ts","sourceRoot":"","sources":["../src/typescript-service.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAUL,KAAK,qBAAqB,EAQ3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAG5B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CAC/B;AAED,0CAA0C;AAC1C,MAAM,MAAM,2BAA2B,GACnC;IACE,MAAM,EAAE,IAAI,CAAC;IACb,WAAW,EAAE,oBAAoB,EAAE,CAAC;IACpC,gGAAgG;IAChG,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AACH,kFAAkF;GAChF;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAAE;AACxE,8DAA8D;GAC5D;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE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