@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 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<T>(virtualCode: VirtualCode<T>): Generator<VirtualCode<T>>;
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<T>): SourceScript<T>;
10
+ fromVirtualCode(virtualCode: VirtualCode): SourceScript<T>;
11
11
  };
12
12
  maps: {
13
- get(virtualCode: VirtualCode<T>): SourceMap<CodeInformation>;
14
- forEach(virtualCode: VirtualCode<T>): Generator<[id: T, snapshot: ts.IScriptSnapshot, map: SourceMap<CodeInformation>]>;
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<T>): LinkedCodeMap | undefined;
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<T> | undefined;
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<T>;
39
+ root: VirtualCode;
40
40
  languagePlugin: LanguagePlugin<T>;
41
- embeddedCodes: Map<string, VirtualCode<T>>;
41
+ embeddedCodes: Map<string, VirtualCode>;
42
42
  };
43
43
  }
44
44
  export type CodeMapping = Mapping<CodeInformation>;
45
- export interface VirtualCode<T = unknown> {
45
+ export interface VirtualCode {
46
46
  id: string;
47
47
  languageId: string;
48
48
  snapshot: ts.IScriptSnapshot;
49
49
  mappings: CodeMapping[];
50
- associatedScriptMappings?: Map<T, CodeMapping[]>;
51
- embeddedCodes?: VirtualCode<T>[];
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<T = unknown> {
80
- code: VirtualCode<T>;
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<T = unknown> extends TypeScriptServiceScript<T> {
86
+ export interface TypeScriptExtraServiceScript extends TypeScriptServiceScript {
87
87
  fileName: string;
88
88
  }
89
- export interface LanguagePlugin<T = unknown, K extends VirtualCode<T> = VirtualCode<T>> {
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<T, K> & TypeScriptNonTSPluginOptions<T, K>;
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<T, K> {
114
+ interface TypeScriptGenericOptions<K> {
115
115
  extraFileExtensions: ts.FileExtensionInfo[];
116
116
  resolveHiddenExtensions?: boolean;
117
- getServiceScript(root: K): TypeScriptServiceScript<T> | undefined;
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<T, K> {
123
- getExtraServiceScripts?(fileName: string, rootVirtualCode: K): TypeScriptExtraServiceScript<T>[];
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.6",
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.6"
15
+ "@volar/source-map": "2.3.0-alpha.7"
16
16
  },
17
- "gitHead": "f3103e86be8d80cb36f66be4c054ef9a255c29b1"
17
+ "gitHead": "3cc2a62516113c5789e4f54766e25063099a13a5"
18
18
  }