vue-tsc 0.38.8 → 0.39.2
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/README.md +1 -1
- package/out/proxy.js +5 -13
- package/package.json +24 -23
- package/out/apis.d.ts +0 -10
- package/out/apis.js +0 -124
package/README.md
CHANGED
package/out/proxy.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadTsLib = exports.createProgramProxy = void 0;
|
|
4
4
|
const ts = require("typescript/lib/tsserverlibrary");
|
|
5
|
-
const
|
|
5
|
+
const vue = require("@volar/vue-language-core");
|
|
6
6
|
const vueTs = require("@volar/vue-typescript");
|
|
7
7
|
function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
|
|
8
8
|
_options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
@@ -36,6 +36,7 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
|
36
36
|
return ctx.projectVersion.toString();
|
|
37
37
|
},
|
|
38
38
|
getProjectReferences: () => ctx.options.projectReferences,
|
|
39
|
+
getTypeScriptModule: () => ts,
|
|
39
40
|
isTsc: true,
|
|
40
41
|
}, {
|
|
41
42
|
get: (target, property) => {
|
|
@@ -45,22 +46,13 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
|
45
46
|
return ctx.options.host[property];
|
|
46
47
|
},
|
|
47
48
|
});
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
program = new Proxy({}, {
|
|
51
|
-
get: (target, property) => {
|
|
52
|
-
var _a;
|
|
53
|
-
if (property in proxyApis) {
|
|
54
|
-
return proxyApis[property];
|
|
55
|
-
}
|
|
56
|
-
return (_a = vueLsCtx.typescriptLanguageService.getProgram()[property]) !== null && _a !== void 0 ? _a : target[property];
|
|
57
|
-
},
|
|
58
|
-
});
|
|
49
|
+
const vueTsLs = vueTs.createLanguageService(vueLsHost);
|
|
50
|
+
program = vueTsLs.getProgram();
|
|
59
51
|
program.__VLS_ctx = ctx;
|
|
60
52
|
function getVueCompilerOptions() {
|
|
61
53
|
const tsConfig = ctx.options.options.configFilePath;
|
|
62
54
|
if (typeof tsConfig === 'string') {
|
|
63
|
-
return
|
|
55
|
+
return vue.tsShared.createParsedCommandLine(ts, ts.sys, tsConfig).vueOptions;
|
|
64
56
|
}
|
|
65
57
|
return {};
|
|
66
58
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
"name": "vue-tsc",
|
|
3
|
+
"version": "0.39.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"files": [
|
|
6
|
+
"bin",
|
|
7
|
+
"out/**/*.js",
|
|
8
|
+
"out/**/*.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/johnsoncodehk/volar.git",
|
|
13
|
+
"directory": "packages/vue-tsc"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"vue-tsc": "./bin/vue-tsc.js"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@volar/vue-language-core": "0.39.2",
|
|
20
|
+
"@volar/vue-typescript": "0.39.2"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"typescript": "*"
|
|
24
|
+
},
|
|
25
|
+
"gitHead": "eac2dca4206dfa3f92ad50dd53650f924a9e6f94"
|
|
25
26
|
}
|
package/out/apis.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type * as vueTs from '@volar/vue-typescript';
|
|
3
|
-
export declare function register(ts: typeof import('typescript/lib/tsserverlibrary'), vueLsCtx: vueTs.LanguageServiceContext): {
|
|
4
|
-
getRootFileNames: () => string[];
|
|
5
|
-
emit: (targetSourceFile?: ts.SourceFile, _writeFile?: ts.WriteFileCallback, cancellationToken?: ts.CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: ts.CustomTransformers) => ts.EmitResult;
|
|
6
|
-
getSyntacticDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.Diagnostic[] | readonly ts.DiagnosticWithLocation[];
|
|
7
|
-
getSemanticDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.Diagnostic[] | readonly ts.DiagnosticWithLocation[];
|
|
8
|
-
getGlobalDiagnostics: (cancellationToken?: ts.CancellationToken) => readonly ts.Diagnostic[];
|
|
9
|
-
getBindAndCheckDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.Diagnostic[] | readonly ts.DiagnosticWithLocation[];
|
|
10
|
-
};
|
package/out/apis.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = void 0;
|
|
4
|
-
function register(ts, vueLsCtx) {
|
|
5
|
-
return {
|
|
6
|
-
getRootFileNames,
|
|
7
|
-
emit,
|
|
8
|
-
getSyntacticDiagnostics,
|
|
9
|
-
getSemanticDiagnostics,
|
|
10
|
-
getGlobalDiagnostics,
|
|
11
|
-
getBindAndCheckDiagnostics,
|
|
12
|
-
};
|
|
13
|
-
function getRootFileNames() {
|
|
14
|
-
return getProgram().getRootFileNames().filter(fileName => { var _a, _b; return (_b = (_a = vueLsCtx.typescriptLanguageServiceHost).fileExists) === null || _b === void 0 ? void 0 : _b.call(_a, fileName); });
|
|
15
|
-
}
|
|
16
|
-
// for vue-tsc --noEmit --watch
|
|
17
|
-
function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
|
|
18
|
-
return getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, 'getBindAndCheckDiagnostics');
|
|
19
|
-
}
|
|
20
|
-
// for vue-tsc --noEmit
|
|
21
|
-
function getSyntacticDiagnostics(sourceFile, cancellationToken) {
|
|
22
|
-
return getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, 'getSyntacticDiagnostics');
|
|
23
|
-
}
|
|
24
|
-
function getSemanticDiagnostics(sourceFile, cancellationToken) {
|
|
25
|
-
return getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, 'getSemanticDiagnostics');
|
|
26
|
-
}
|
|
27
|
-
function getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, api) {
|
|
28
|
-
var _a, _b;
|
|
29
|
-
if (sourceFile) {
|
|
30
|
-
const mapped = vueLsCtx.sourceFiles.fromEmbeddedFileName(sourceFile.fileName);
|
|
31
|
-
if (mapped) {
|
|
32
|
-
if (!mapped.embedded.file.capabilities.diagnostics)
|
|
33
|
-
return [];
|
|
34
|
-
const program = getProgram();
|
|
35
|
-
const errors = transformDiagnostics((_a = program === null || program === void 0 ? void 0 : program[api](sourceFile, cancellationToken)) !== null && _a !== void 0 ? _a : []);
|
|
36
|
-
return errors;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return transformDiagnostics((_b = getProgram()[api](sourceFile, cancellationToken)) !== null && _b !== void 0 ? _b : []);
|
|
40
|
-
}
|
|
41
|
-
function getGlobalDiagnostics(cancellationToken) {
|
|
42
|
-
var _a;
|
|
43
|
-
return transformDiagnostics((_a = getProgram().getGlobalDiagnostics(cancellationToken)) !== null && _a !== void 0 ? _a : []);
|
|
44
|
-
}
|
|
45
|
-
function emit(targetSourceFile, _writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
46
|
-
var _a;
|
|
47
|
-
const scriptResult = getProgram().emit(targetSourceFile, ((_a = vueLsCtx.typescriptLanguageServiceHost.writeFile) !== null && _a !== void 0 ? _a : ts.sys.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
48
|
-
return {
|
|
49
|
-
emitSkipped: scriptResult.emitSkipped,
|
|
50
|
-
emittedFiles: scriptResult.emittedFiles,
|
|
51
|
-
diagnostics: transformDiagnostics(scriptResult.diagnostics),
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
function getProgram() {
|
|
55
|
-
return vueLsCtx.typescriptLanguageService.getProgram();
|
|
56
|
-
}
|
|
57
|
-
// transform
|
|
58
|
-
function transformDiagnostics(diagnostics) {
|
|
59
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
60
|
-
const result = [];
|
|
61
|
-
for (const diagnostic of diagnostics) {
|
|
62
|
-
if (diagnostic.file !== undefined
|
|
63
|
-
&& diagnostic.start !== undefined
|
|
64
|
-
&& diagnostic.length !== undefined) {
|
|
65
|
-
let founded = false;
|
|
66
|
-
for (const tsOrVueLoc of vueLsCtx.sourceFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
|
|
67
|
-
if (!((_b = (_a = vueLsCtx.typescriptLanguageServiceHost).fileExists) === null || _b === void 0 ? void 0 : _b.call(_a, tsOrVueLoc.fileName)))
|
|
68
|
-
continue;
|
|
69
|
-
onMapping(diagnostic, tsOrVueLoc.fileName, tsOrVueLoc.range.start, tsOrVueLoc.range.end, (_c = tsOrVueLoc.mapped) === null || _c === void 0 ? void 0 : _c.vueFile.text);
|
|
70
|
-
founded = true;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
// fix https://github.com/johnsoncodehk/volar/issues/1372
|
|
74
|
-
if (!founded) {
|
|
75
|
-
for (const start of vueLsCtx.sourceFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start, diagnostic.start, data => !!data.capabilities.diagnostic)) {
|
|
76
|
-
if (!((_e = (_d = vueLsCtx.typescriptLanguageServiceHost).fileExists) === null || _e === void 0 ? void 0 : _e.call(_d, start.fileName)))
|
|
77
|
-
continue;
|
|
78
|
-
for (const end of vueLsCtx.sourceFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start + diagnostic.length, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
|
|
79
|
-
if (!((_g = (_f = vueLsCtx.typescriptLanguageServiceHost).fileExists) === null || _g === void 0 ? void 0 : _g.call(_f, end.fileName)))
|
|
80
|
-
continue;
|
|
81
|
-
if (start.fileName !== end.fileName)
|
|
82
|
-
continue;
|
|
83
|
-
onMapping(diagnostic, start.fileName, start.range.start, end.range.end, (_h = start.mapped) === null || _h === void 0 ? void 0 : _h.vueFile.text);
|
|
84
|
-
founded = true;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
if (founded) {
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else if (diagnostic.file === undefined) {
|
|
94
|
-
result.push(diagnostic);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return result;
|
|
98
|
-
function onMapping(diagnostic, fileName, start, end, docText) {
|
|
99
|
-
var _a;
|
|
100
|
-
let file = fileName === ((_a = diagnostic.file) === null || _a === void 0 ? void 0 : _a.fileName)
|
|
101
|
-
? diagnostic.file
|
|
102
|
-
: undefined;
|
|
103
|
-
if (!file) {
|
|
104
|
-
if (docText === undefined) {
|
|
105
|
-
const snapshot = vueLsCtx.typescriptLanguageServiceHost.getScriptSnapshot(fileName);
|
|
106
|
-
if (snapshot) {
|
|
107
|
-
docText = snapshot.getText(0, snapshot.getLength());
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
file = ts.createSourceFile(fileName, docText, fileName.endsWith('.vue') || fileName.endsWith('.md') || fileName.endsWith('.html') ? ts.ScriptTarget.JSON : ts.ScriptTarget.Latest);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const newDiagnostic = Object.assign(Object.assign({}, diagnostic), { file, start: start, length: end - start });
|
|
115
|
-
const relatedInformation = diagnostic.relatedInformation;
|
|
116
|
-
if (relatedInformation) {
|
|
117
|
-
newDiagnostic.relatedInformation = transformDiagnostics(relatedInformation);
|
|
118
|
-
}
|
|
119
|
-
result.push(newDiagnostic);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.register = register;
|
|
124
|
-
//# sourceMappingURL=apis.js.map
|