/
types.ts
61 lines (55 loc) · 2.43 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import type * as css from 'vscode-css-languageservice';
import type { DocumentContext, TextDocument } from 'vscode-css-languageservice';
import type * as html from 'vscode-html-languageservice';
import type * as vscode from 'vscode-languageserver-protocol';
import type * as pug from '@volar/pug-language-service';
import type * as ts2 from '@volar/typescript-language-service';
import type { VueDocuments } from './vueDocuments';
import type { TextRange } from './utils/sourceMaps';
export type LanguageServiceHostBase = ts2.LanguageServiceHost & {
getVueCompilationSettings?(): VueCompilerOptions,
getVueProjectVersion?(): string;
};
export interface ITemplateScriptData {
projectVersion: string | undefined;
context: string[];
contextItems: vscode.CompletionItem[];
components: string[];
componentItems: vscode.CompletionItem[];
props: string[];
setupReturns: string[];
}
export interface VueCompilerOptions {
experimentalCompatMode?: 2 | 3;
experimentalTemplateCompilerOptions?: any;
experimentalTemplateCompilerOptionsRequirePath?: string;
experimentalDisableTemplateSupport?: boolean;
}
export type BasicRuntimeContext = {
typescript: typeof import('typescript/lib/tsserverlibrary'),
vueCompilerOptions: VueCompilerOptions,
compileTemplate(templateTextDocument: TextDocument): {
htmlTextDocument: TextDocument;
htmlToTemplate: (start: number, end: number) => { start: number, end: number } | undefined;
} | undefined
getCssVBindRanges: (documrnt: TextDocument) => TextRange[],
getCssClasses: (documrnt: TextDocument) => Record<string, [number, number][]>,
htmlLs: html.LanguageService,
pugLs: pug.LanguageService,
getCssLs: (lang: string) => css.LanguageService | undefined,
getStylesheet: (documrnt: TextDocument) => css.Stylesheet | undefined,
getHtmlDocument: (documrnt: TextDocument) => html.HTMLDocument | undefined,
getPugDocument: (documrnt: TextDocument) => pug.PugDocument | undefined,
}
export type TypeScriptFeaturesRuntimeContext = {
vueDocuments: VueDocuments;
vueHost: LanguageServiceHostBase;
documentContext: DocumentContext;
scriptTsHost: ts.LanguageServiceHost;
templateTsHost: ts.LanguageServiceHost | undefined;
scriptTsLsRaw: ts.LanguageService;
templateTsLsRaw: ts.LanguageService | undefined;
scriptTsLs: ts2.LanguageService;
templateTsLs: ts2.LanguageService | undefined;
getTsLs: <T extends 'template' | 'script'>(lsType: T) => T extends 'script' ? ts2.LanguageService : (ts2.LanguageService | undefined);
}