@volar/language-core 2.3.0-alpha.6 → 2.3.0-alpha.7
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/index.d.ts +1 -1
- package/lib/types.d.ts +19 -19
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export * from './lib/types';
|
|
|
5
5
|
export * from './lib/utils';
|
|
6
6
|
import type { Language, LanguagePlugin, SourceScript, VirtualCode } from './lib/types';
|
|
7
7
|
export declare function createLanguage<T>(plugins: LanguagePlugin<T>[], scriptRegistry: Map<T, SourceScript<T>>, sync: (id: T) => void): Language<T>;
|
|
8
|
-
export declare function forEachEmbeddedCode
|
|
8
|
+
export declare function forEachEmbeddedCode(virtualCode: VirtualCode): Generator<VirtualCode>;
|
package/lib/types.d.ts
CHANGED
|
@@ -7,14 +7,14 @@ export interface Language<T = unknown> {
|
|
|
7
7
|
get(id: T): SourceScript<T> | undefined;
|
|
8
8
|
set(id: T, snapshot: ts.IScriptSnapshot, languageId?: string, plugins?: LanguagePlugin<T>[]): SourceScript<T> | undefined;
|
|
9
9
|
delete(id: T): void;
|
|
10
|
-
fromVirtualCode(virtualCode: VirtualCode
|
|
10
|
+
fromVirtualCode(virtualCode: VirtualCode): SourceScript<T>;
|
|
11
11
|
};
|
|
12
12
|
maps: {
|
|
13
|
-
get(virtualCode: VirtualCode
|
|
14
|
-
forEach(virtualCode: VirtualCode
|
|
13
|
+
get(virtualCode: VirtualCode): SourceMap<CodeInformation>;
|
|
14
|
+
forEach(virtualCode: VirtualCode): Generator<[id: T, snapshot: ts.IScriptSnapshot, map: SourceMap<CodeInformation>]>;
|
|
15
15
|
};
|
|
16
16
|
linkedCodeMaps: {
|
|
17
|
-
get(virtualCode: VirtualCode
|
|
17
|
+
get(virtualCode: VirtualCode): LinkedCodeMap | undefined;
|
|
18
18
|
};
|
|
19
19
|
typescript?: {
|
|
20
20
|
configFileName: string | undefined;
|
|
@@ -23,7 +23,7 @@ export interface Language<T = unknown> {
|
|
|
23
23
|
sync?(): Promise<number>;
|
|
24
24
|
};
|
|
25
25
|
languageServiceHost: ts.LanguageServiceHost;
|
|
26
|
-
getExtraServiceScript(fileName: string): TypeScriptExtraServiceScript
|
|
26
|
+
getExtraServiceScript(fileName: string): TypeScriptExtraServiceScript | undefined;
|
|
27
27
|
asScriptId(fileName: string): T;
|
|
28
28
|
asFileName(scriptId: T): string;
|
|
29
29
|
};
|
|
@@ -36,19 +36,19 @@ export interface SourceScript<T = unknown> {
|
|
|
36
36
|
associatedIds: Set<T>;
|
|
37
37
|
isAssociationDirty?: boolean;
|
|
38
38
|
generated?: {
|
|
39
|
-
root: VirtualCode
|
|
39
|
+
root: VirtualCode;
|
|
40
40
|
languagePlugin: LanguagePlugin<T>;
|
|
41
|
-
embeddedCodes: Map<string, VirtualCode
|
|
41
|
+
embeddedCodes: Map<string, VirtualCode>;
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
export type CodeMapping = Mapping<CodeInformation>;
|
|
45
|
-
export interface VirtualCode
|
|
45
|
+
export interface VirtualCode {
|
|
46
46
|
id: string;
|
|
47
47
|
languageId: string;
|
|
48
48
|
snapshot: ts.IScriptSnapshot;
|
|
49
49
|
mappings: CodeMapping[];
|
|
50
|
-
associatedScriptMappings?: Map<
|
|
51
|
-
embeddedCodes?: VirtualCode
|
|
50
|
+
associatedScriptMappings?: Map<unknown, CodeMapping[]>;
|
|
51
|
+
embeddedCodes?: VirtualCode[];
|
|
52
52
|
linkedCodeMappings?: Mapping[];
|
|
53
53
|
}
|
|
54
54
|
export interface CodeInformation {
|
|
@@ -76,17 +76,17 @@ export interface CodeInformation {
|
|
|
76
76
|
/** virtual code is expected correctly reflect the format information of the source code */
|
|
77
77
|
format?: boolean;
|
|
78
78
|
}
|
|
79
|
-
export interface TypeScriptServiceScript
|
|
80
|
-
code: VirtualCode
|
|
79
|
+
export interface TypeScriptServiceScript {
|
|
80
|
+
code: VirtualCode;
|
|
81
81
|
extension: '.ts' | '.js' | '.mts' | '.mjs' | '.cjs' | '.cts' | '.d.ts' | string;
|
|
82
82
|
scriptKind: ts.ScriptKind;
|
|
83
83
|
/** See #188 */
|
|
84
84
|
preventLeadingOffset?: boolean;
|
|
85
85
|
}
|
|
86
|
-
export interface TypeScriptExtraServiceScript
|
|
86
|
+
export interface TypeScriptExtraServiceScript extends TypeScriptServiceScript {
|
|
87
87
|
fileName: string;
|
|
88
88
|
}
|
|
89
|
-
export interface LanguagePlugin<T = unknown, K extends VirtualCode
|
|
89
|
+
export interface LanguagePlugin<T = unknown, K extends VirtualCode = VirtualCode> {
|
|
90
90
|
/**
|
|
91
91
|
* For files that are not opened in the IDE, the language ID will not be synchronized to the language server, so a hook is needed to parse the language ID of files that are known extension but not opened in the IDE.
|
|
92
92
|
*/
|
|
@@ -103,7 +103,7 @@ export interface LanguagePlugin<T = unknown, K extends VirtualCode<T> = VirtualC
|
|
|
103
103
|
* Cleanup a virtual code.
|
|
104
104
|
*/
|
|
105
105
|
disposeVirtualCode?(scriptId: T, virtualCode: K): void;
|
|
106
|
-
typescript?: TypeScriptGenericOptions<
|
|
106
|
+
typescript?: TypeScriptGenericOptions<K> & TypeScriptNonTSPluginOptions<K>;
|
|
107
107
|
}
|
|
108
108
|
export interface CodegenContext<T = unknown> {
|
|
109
109
|
getAssociatedScript(scriptId: T): SourceScript<T> | undefined;
|
|
@@ -111,16 +111,16 @@ export interface CodegenContext<T = unknown> {
|
|
|
111
111
|
/**
|
|
112
112
|
* The following options available to all situations.
|
|
113
113
|
*/
|
|
114
|
-
interface TypeScriptGenericOptions<
|
|
114
|
+
interface TypeScriptGenericOptions<K> {
|
|
115
115
|
extraFileExtensions: ts.FileExtensionInfo[];
|
|
116
116
|
resolveHiddenExtensions?: boolean;
|
|
117
|
-
getServiceScript(root: K): TypeScriptServiceScript
|
|
117
|
+
getServiceScript(root: K): TypeScriptServiceScript | undefined;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* The following options will not be available in TS plugin.
|
|
121
121
|
*/
|
|
122
|
-
interface TypeScriptNonTSPluginOptions<
|
|
123
|
-
getExtraServiceScripts?(fileName: string, rootVirtualCode: K): TypeScriptExtraServiceScript
|
|
122
|
+
interface TypeScriptNonTSPluginOptions<K> {
|
|
123
|
+
getExtraServiceScripts?(fileName: string, rootVirtualCode: K): TypeScriptExtraServiceScript[];
|
|
124
124
|
resolveLanguageServiceHost?(host: ts.LanguageServiceHost): ts.LanguageServiceHost;
|
|
125
125
|
}
|
|
126
126
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-core",
|
|
3
|
-
"version": "2.3.0-alpha.
|
|
3
|
+
"version": "2.3.0-alpha.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/language-core"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/source-map": "2.3.0-alpha.
|
|
15
|
+
"@volar/source-map": "2.3.0-alpha.7"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "3cc2a62516113c5789e4f54766e25063099a13a5"
|
|
18
18
|
}
|