@volar/typescript 1.7.0 → 1.7.1-patch.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/out/documentRegistry.d.ts +2 -0
- package/out/documentRegistry.js +14 -0
- package/out/index.d.ts +2 -1
- package/out/index.js +2 -1
- package/out/languageService.js +3 -2
- package/out/languageServiceHost.js +10 -18
- package/out/sys.js +12 -7
- package/package.json +4 -5
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDocumentRegistry = void 0;
|
|
4
|
+
const documentRegistries = [];
|
|
5
|
+
function getDocumentRegistry(ts, useCaseSensitiveFileNames, currentDirectory) {
|
|
6
|
+
let documentRegistry = documentRegistries.find(item => item[0] === useCaseSensitiveFileNames && item[1] === currentDirectory)?.[2];
|
|
7
|
+
if (!documentRegistry) {
|
|
8
|
+
documentRegistry = ts.createDocumentRegistry(useCaseSensitiveFileNames, currentDirectory);
|
|
9
|
+
documentRegistries.push([useCaseSensitiveFileNames, currentDirectory, documentRegistry]);
|
|
10
|
+
}
|
|
11
|
+
return documentRegistry;
|
|
12
|
+
}
|
|
13
|
+
exports.getDocumentRegistry = getDocumentRegistry;
|
|
14
|
+
//# sourceMappingURL=documentRegistry.js.map
|
package/out/index.d.ts
CHANGED
package/out/index.js
CHANGED
|
@@ -14,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./documentRegistry"), exports);
|
|
18
|
+
__exportStar(require("./dtsHost"), exports);
|
|
17
19
|
__exportStar(require("./languageService"), exports);
|
|
18
20
|
__exportStar(require("./languageServiceHost"), exports);
|
|
19
21
|
__exportStar(require("./sys"), exports);
|
|
20
|
-
__exportStar(require("./dtsHost"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/out/languageService.js
CHANGED
|
@@ -4,13 +4,13 @@ exports.createLanguageService = void 0;
|
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const getProgram_1 = require("./getProgram");
|
|
6
6
|
const languageServiceHost_1 = require("./languageServiceHost");
|
|
7
|
-
|
|
7
|
+
const documentRegistry_1 = require("./documentRegistry");
|
|
8
8
|
function createLanguageService(core, ts, sys) {
|
|
9
9
|
if (!ts) {
|
|
10
10
|
throw new Error('TypeScript module not provided.');
|
|
11
11
|
}
|
|
12
12
|
const lsHost = (0, languageServiceHost_1.createLanguageServiceHost)(core, ts, sys);
|
|
13
|
-
const ls = ts.createLanguageService(lsHost,
|
|
13
|
+
const ls = ts.createLanguageService(lsHost, (0, documentRegistry_1.getDocumentRegistry)(ts, sys.useCaseSensitiveFileNames, core.host.getCurrentDirectory()));
|
|
14
14
|
return new Proxy({
|
|
15
15
|
organizeImports,
|
|
16
16
|
// only support for .ts for now, not support for .vue
|
|
@@ -93,6 +93,7 @@ function createLanguageService(core, ts, sys) {
|
|
|
93
93
|
: mode === 'typeDefinition' ? ls.getTypeDefinitionAtPosition(fileName, position)
|
|
94
94
|
: mode === 'references' ? ls.getReferencesAtPosition(fileName, position)
|
|
95
95
|
: mode === 'implementation' ? ls.getImplementationAtPosition(fileName, position)
|
|
96
|
+
// @ts-expect-error
|
|
96
97
|
: mode === 'rename' && preferences ? ls.findRenameLocations(fileName, position, findInStrings, findInComments, preferences)
|
|
97
98
|
: undefined;
|
|
98
99
|
if (!_symbols)
|
|
@@ -21,8 +21,8 @@ function createLanguageServiceHost(ctx, ts, sys) {
|
|
|
21
21
|
return `/node_modules/typescript/lib/${ts.getDefaultLibFileName(options)}`;
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
useCaseSensitiveFileNames:
|
|
25
|
-
getNewLine:
|
|
24
|
+
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
|
25
|
+
getNewLine: () => sys.newLine,
|
|
26
26
|
readFile: fileName => {
|
|
27
27
|
const snapshot = getScriptSnapshot(fileName);
|
|
28
28
|
if (snapshot) {
|
|
@@ -140,27 +140,19 @@ function createLanguageServiceHost(ctx, ts, sys) {
|
|
|
140
140
|
return fsFileSnapshots.get(fileName)?.[1];
|
|
141
141
|
}
|
|
142
142
|
function getScriptVersion(fileName) {
|
|
143
|
-
// virtual files
|
|
143
|
+
// virtual files / root files / opened files
|
|
144
144
|
const [virtualFile] = ctx.virtualFiles.getVirtualFile(fileName);
|
|
145
145
|
const snapshot = virtualFile?.snapshot ?? ctx.host.getScriptSnapshot(fileName);
|
|
146
146
|
if (snapshot) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
version = {
|
|
150
|
-
value: 0,
|
|
151
|
-
versions: new WeakMap(),
|
|
152
|
-
};
|
|
153
|
-
fileVersions.set(fileName, version);
|
|
147
|
+
if (!fileVersions.has(fileName)) {
|
|
148
|
+
fileVersions.set(fileName, { value: 0, snapshot });
|
|
154
149
|
}
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
const version = fileVersions.get(fileName);
|
|
151
|
+
if (version.snapshot !== snapshot) {
|
|
152
|
+
version.value++;
|
|
153
|
+
version.snapshot = snapshot;
|
|
157
154
|
}
|
|
158
|
-
return version.
|
|
159
|
-
}
|
|
160
|
-
// root files / opened files
|
|
161
|
-
const version = ctx.host.getScriptVersion(fileName);
|
|
162
|
-
if (version !== undefined) {
|
|
163
|
-
return version;
|
|
155
|
+
return version.value.toString();
|
|
164
156
|
}
|
|
165
157
|
// fs files
|
|
166
158
|
return sys.getModifiedTime?.(fileName)?.valueOf().toString() ?? '';
|
package/out/sys.js
CHANGED
|
@@ -82,9 +82,9 @@ function createSys(ctx, ts, env, dtsHost) {
|
|
|
82
82
|
catch { }
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
return sys.resolvePath(fsPath);
|
|
85
|
+
return sys.resolvePath(fsPath).replace(/\\/g, '/');
|
|
86
86
|
}
|
|
87
|
-
return path_1.posix.resolve(fsPath);
|
|
87
|
+
return path_1.posix.resolve(fsPath).replace(/\\/g, '/');
|
|
88
88
|
}
|
|
89
89
|
function getModifiedTime(fileName) {
|
|
90
90
|
fileName = resolvePath(fileName);
|
|
@@ -244,7 +244,6 @@ function createSys(ctx, ts, env, dtsHost) {
|
|
|
244
244
|
file.text = result;
|
|
245
245
|
const time = Date.now();
|
|
246
246
|
file.modifiedTime = time !== file.modifiedTime ? time : time + 1;
|
|
247
|
-
version++;
|
|
248
247
|
}
|
|
249
248
|
else {
|
|
250
249
|
file.exists = false;
|
|
@@ -265,7 +264,9 @@ function createSys(ctx, ts, env, dtsHost) {
|
|
|
265
264
|
promises.add(promise);
|
|
266
265
|
result.then((result) => {
|
|
267
266
|
promises.delete(promise);
|
|
268
|
-
onReadDirectoryResult(dir, result)
|
|
267
|
+
if (onReadDirectoryResult(dir, result)) {
|
|
268
|
+
version++;
|
|
269
|
+
}
|
|
269
270
|
});
|
|
270
271
|
}
|
|
271
272
|
else {
|
|
@@ -273,28 +274,32 @@ function createSys(ctx, ts, env, dtsHost) {
|
|
|
273
274
|
}
|
|
274
275
|
}
|
|
275
276
|
function onReadDirectoryResult(dir, result) {
|
|
277
|
+
let updated = false;
|
|
276
278
|
for (const [name, fileType] of result) {
|
|
277
279
|
if (fileType === 1 || fileType === 64) {
|
|
278
280
|
dir.files[name] ??= {};
|
|
279
281
|
if (!dir.files[name].exists) {
|
|
280
282
|
dir.files[name].exists = true;
|
|
281
|
-
|
|
283
|
+
updated = true;
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
286
|
else if (fileType === 2) {
|
|
285
287
|
const childDir = getDirFromDir(dir, name);
|
|
286
288
|
if (!childDir.exists) {
|
|
287
289
|
childDir.exists = true;
|
|
288
|
-
|
|
290
|
+
updated = true;
|
|
289
291
|
}
|
|
290
292
|
}
|
|
291
293
|
}
|
|
294
|
+
return updated;
|
|
292
295
|
}
|
|
293
296
|
function getDir(dirName) {
|
|
294
297
|
const dirNames = [];
|
|
295
298
|
let currentDirPath = dirName;
|
|
296
299
|
let currentDirName = path_1.posix.basename(currentDirPath);
|
|
297
|
-
|
|
300
|
+
let lastDirName;
|
|
301
|
+
while (lastDirName !== currentDirName) {
|
|
302
|
+
lastDirName = currentDirName;
|
|
298
303
|
dirNames.push(currentDirName);
|
|
299
304
|
currentDirPath = path_1.posix.dirname(currentDirPath);
|
|
300
305
|
currentDirName = path_1.posix.basename(currentDirPath);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/typescript",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1-patch.1",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
"directory": "packages/typescript"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.7.
|
|
16
|
+
"@volar/language-core": "1.7.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@volar/language-service": "1.7.
|
|
20
|
-
}
|
|
21
|
-
"gitHead": "38ec4f727b32dbf2cf3284ab02695e3a8effacc5"
|
|
19
|
+
"@volar/language-service": "1.7.1"
|
|
20
|
+
}
|
|
22
21
|
}
|