@volar/language-core 1.6.7 → 1.6.9

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.
@@ -61,8 +61,9 @@ function createLanguageContext(modules, host, languages) {
61
61
  }
62
62
  : undefined,
63
63
  getProjectVersion: () => {
64
- return tsProjectVersion.toString();
64
+ return host.getTypeRootsVersion?.() + ':' + tsProjectVersion.toString();
65
65
  },
66
+ getTypeRootsVersion: host.getTypeRootsVersion,
66
67
  getScriptFileNames,
67
68
  getScriptVersion,
68
69
  getScriptSnapshot,
@@ -123,6 +124,15 @@ function createLanguageContext(modules, host, languages) {
123
124
  let shouldUpdateTsProject = false;
124
125
  let virtualFilesUpdatedNum = 0;
125
126
  const remainRootFiles = new Set(host.getScriptFileNames());
127
+ const oldVirtualTsFileNames = new Set();
128
+ const newVirtualTsFileNames = new Set();
129
+ for (const { root: rootVirtualFile } of virtualFiles.allSources()) {
130
+ (0, virtualFiles_1.forEachEmbeddedFile)(rootVirtualFile, embedded => {
131
+ if (embedded.kind === types_1.FileKind.TypeScriptHostFile) {
132
+ oldVirtualTsFileNames.add(embedded.fileName);
133
+ }
134
+ });
135
+ }
126
136
  // .vue
127
137
  for (const { fileName } of virtualFiles.allSources()) {
128
138
  remainRootFiles.delete(fileName);
@@ -179,10 +189,12 @@ function createLanguageContext(modules, host, languages) {
179
189
  shouldUpdateTsProject = true;
180
190
  }
181
191
  }
182
- for (const { root: rootVirtualFile } of virtualFiles.allSources()) {
183
- if (!shouldUpdateTsProject) {
192
+ // check virtual file update
193
+ if (!shouldUpdateTsProject) {
194
+ for (const { root: rootVirtualFile } of virtualFiles.allSources()) {
184
195
  (0, virtualFiles_1.forEachEmbeddedFile)(rootVirtualFile, embedded => {
185
196
  if (embedded.kind === types_1.FileKind.TypeScriptHostFile) {
197
+ newVirtualTsFileNames.add(embedded.fileName);
186
198
  if (virtualFileVersions.has(embedded.fileName) && virtualFileVersions.get(embedded.fileName)?.virtualFileSnapshot !== embedded.snapshot) {
187
199
  shouldUpdateTsProject = true;
188
200
  }
@@ -190,6 +202,20 @@ function createLanguageContext(modules, host, languages) {
190
202
  });
191
203
  }
192
204
  }
205
+ // check virtual file create / delete
206
+ if (!shouldUpdateTsProject) {
207
+ if (oldVirtualTsFileNames.size !== newVirtualTsFileNames.size) {
208
+ shouldUpdateTsProject = true;
209
+ }
210
+ else {
211
+ for (const fileName of oldVirtualTsFileNames) {
212
+ if (!newVirtualTsFileNames.has(fileName)) {
213
+ shouldUpdateTsProject = true;
214
+ break;
215
+ }
216
+ }
217
+ }
218
+ }
193
219
  if (shouldUpdateTsProject) {
194
220
  tsProjectVersion++;
195
221
  }
package/out/types.d.ts CHANGED
@@ -20,7 +20,9 @@ export interface FileRangeCapabilities {
20
20
  additional?: boolean;
21
21
  autoImportOnly?: boolean;
22
22
  };
23
- diagnostic?: boolean;
23
+ diagnostic?: boolean | {
24
+ shouldReport(): boolean;
25
+ };
24
26
  semanticTokens?: boolean;
25
27
  referencesCodeLens?: boolean;
26
28
  displayWithLink?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-core",
3
- "version": "1.6.7",
3
+ "version": "1.6.9",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -13,7 +13,7 @@
13
13
  "directory": "packages/language-core"
14
14
  },
15
15
  "dependencies": {
16
- "@volar/source-map": "1.6.7"
16
+ "@volar/source-map": "1.6.9"
17
17
  },
18
- "gitHead": "17154cd7d468c5b45baf50ea4b2e0f83406b6c03"
18
+ "gitHead": "e676fa08e4186bd2f8cc14861ef65f8d8c855ea1"
19
19
  }