vue-tsc 0.34.16 → 0.35.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/package.json +3 -3
- package/out/apis.d.ts +0 -10
- package/out/apis.js +0 -100
- package/out/proxy.d.ts +0 -3
- package/out/proxy.js +0 -99
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-tsc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"bin",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"vue-tsc": "./bin/vue-tsc.js"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@volar/vue-typescript": "0.
|
|
19
|
+
"@volar/vue-typescript": "0.35.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"typescript": "*"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "4b4fb92dfdec2581ad167f892547f4a27a379287"
|
|
25
25
|
}
|
package/out/apis.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
import type { TypeScriptRuntime } from '@volar/vue-typescript';
|
|
3
|
-
export declare function register(ts: typeof import('typescript/lib/tsserverlibrary'), context: TypeScriptRuntime): {
|
|
4
|
-
getRootFileNames: () => string[];
|
|
5
|
-
emit: (targetSourceFile?: ts.SourceFile | undefined, _writeFile?: ts.WriteFileCallback | undefined, cancellationToken?: ts.CancellationToken | undefined, emitOnlyDtsFiles?: boolean | undefined, customTransformers?: ts.CustomTransformers | undefined) => ts.EmitResult;
|
|
6
|
-
getSyntacticDiagnostics: (sourceFile?: ts.SourceFile | undefined, cancellationToken?: ts.CancellationToken | undefined) => readonly ts.DiagnosticWithLocation[] | readonly ts.Diagnostic[];
|
|
7
|
-
getSemanticDiagnostics: (sourceFile?: ts.SourceFile | undefined, cancellationToken?: ts.CancellationToken | undefined) => readonly ts.DiagnosticWithLocation[] | readonly ts.Diagnostic[];
|
|
8
|
-
getGlobalDiagnostics: (cancellationToken?: ts.CancellationToken | undefined) => readonly ts.Diagnostic[];
|
|
9
|
-
getBindAndCheckDiagnostics: (sourceFile?: ts.SourceFile | undefined, cancellationToken?: ts.CancellationToken | undefined) => readonly ts.DiagnosticWithLocation[] | readonly ts.Diagnostic[];
|
|
10
|
-
};
|
package/out/apis.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = void 0;
|
|
4
|
-
function register(ts, context) {
|
|
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 = context.getTsLsHost()).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 = context.vueFiles.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 = context.vueLsHost.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 context.getTsLs().getProgram();
|
|
56
|
-
}
|
|
57
|
-
// transform
|
|
58
|
-
function transformDiagnostics(diagnostics) {
|
|
59
|
-
var _a, _b, _c;
|
|
60
|
-
const result = [];
|
|
61
|
-
for (const diagnostic of diagnostics) {
|
|
62
|
-
if (diagnostic.file !== undefined
|
|
63
|
-
&& diagnostic.start !== undefined
|
|
64
|
-
&& diagnostic.length !== undefined) {
|
|
65
|
-
for (const tsOrVueLoc of context.vueFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
|
|
66
|
-
if (!((_b = (_a = context.vueLsHost).fileExists) === null || _b === void 0 ? void 0 : _b.call(_a, tsOrVueLoc.fileName)))
|
|
67
|
-
continue;
|
|
68
|
-
let file = tsOrVueLoc.fileName === diagnostic.file.fileName
|
|
69
|
-
? diagnostic.file
|
|
70
|
-
: undefined;
|
|
71
|
-
if (!file) {
|
|
72
|
-
let docText = (_c = tsOrVueLoc.mapped) === null || _c === void 0 ? void 0 : _c.vueFile.getContent();
|
|
73
|
-
if (docText === undefined) {
|
|
74
|
-
const snapshot = context.vueLsHost.getScriptSnapshot(tsOrVueLoc.fileName);
|
|
75
|
-
if (snapshot) {
|
|
76
|
-
docText = snapshot.getText(0, snapshot.getLength());
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
file = ts.createSourceFile(tsOrVueLoc.fileName, docText, tsOrVueLoc.fileName.endsWith('.vue') ? ts.ScriptTarget.JSON : ts.ScriptTarget.Latest);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
const newDiagnostic = Object.assign(Object.assign({}, diagnostic), { file, start: tsOrVueLoc.range.start, length: tsOrVueLoc.range.end - tsOrVueLoc.range.start });
|
|
84
|
-
const relatedInformation = diagnostic.relatedInformation;
|
|
85
|
-
if (relatedInformation) {
|
|
86
|
-
newDiagnostic.relatedInformation = transformDiagnostics(relatedInformation);
|
|
87
|
-
}
|
|
88
|
-
result.push(newDiagnostic);
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (diagnostic.file === undefined) {
|
|
93
|
-
result.push(diagnostic);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.register = register;
|
|
100
|
-
//# sourceMappingURL=apis.js.map
|
package/out/proxy.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
-
export declare function createProgramProxy(options: ts.CreateProgramOptions, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
|
|
3
|
-
_options?: ts.CompilerOptions, _host?: ts.CompilerHost, _oldProgram?: ts.Program, _configFileParsingDiagnostics?: readonly ts.Diagnostic[]): void | ts.Program;
|
package/out/proxy.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProgramProxy = void 0;
|
|
4
|
-
const ts = require("typescript/lib/tsserverlibrary");
|
|
5
|
-
const apis = require("./apis");
|
|
6
|
-
const vue_typescript_1 = require("@volar/vue-typescript");
|
|
7
|
-
const vue_typescript_2 = require("@volar/vue-typescript");
|
|
8
|
-
let projectVersion = 0;
|
|
9
|
-
function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
|
|
10
|
-
_options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
11
|
-
var _a, _b;
|
|
12
|
-
if (!options.options.noEmit && !options.options.emitDeclarationOnly)
|
|
13
|
-
return doThrow('js emit is not support');
|
|
14
|
-
if (!options.host)
|
|
15
|
-
return doThrow('!options.host');
|
|
16
|
-
projectVersion++;
|
|
17
|
-
const host = options.host;
|
|
18
|
-
const vueCompilerOptions = getVueCompilerOptions();
|
|
19
|
-
const scripts = new Map();
|
|
20
|
-
const vueLsHost = Object.assign(Object.assign({}, host), { resolveModuleNames: undefined, writeFile: (fileName, content) => {
|
|
21
|
-
if (fileName.indexOf('__VLS_') === -1) {
|
|
22
|
-
host.writeFile(fileName, content, false);
|
|
23
|
-
}
|
|
24
|
-
}, getCompilationSettings: () => options.options, getVueCompilationSettings: () => vueCompilerOptions, getScriptFileNames: () => {
|
|
25
|
-
return options.rootNames;
|
|
26
|
-
}, getScriptVersion,
|
|
27
|
-
getScriptSnapshot, getProjectVersion: () => {
|
|
28
|
-
return projectVersion.toString();
|
|
29
|
-
}, getProjectReferences: () => options.projectReferences });
|
|
30
|
-
const tsRuntime = (_b = (_a = options.oldProgram) === null || _a === void 0 ? void 0 : _a.__VLS_tsRuntime) !== null && _b !== void 0 ? _b : (0, vue_typescript_1.createTypeScriptRuntime)({
|
|
31
|
-
typescript: ts,
|
|
32
|
-
baseCssModuleType: 'any',
|
|
33
|
-
getCssClasses: () => ({}),
|
|
34
|
-
vueLsHost: vueLsHost,
|
|
35
|
-
isVueTsc: true,
|
|
36
|
-
});
|
|
37
|
-
tsRuntime.update(); // must update before getProgram() to update virtual scripts
|
|
38
|
-
const tsProgram = tsRuntime.getTsLs().getProgram();
|
|
39
|
-
if (!tsProgram)
|
|
40
|
-
throw '!tsProgram';
|
|
41
|
-
const proxyApis = apis.register(ts, tsRuntime);
|
|
42
|
-
const program = new Proxy(tsProgram, {
|
|
43
|
-
get: (target, property) => {
|
|
44
|
-
tsRuntime.update();
|
|
45
|
-
return proxyApis[property] || target[property];
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
program.__VLS_tsRuntime = tsRuntime;
|
|
49
|
-
for (const rootName of options.rootNames) {
|
|
50
|
-
// register file watchers
|
|
51
|
-
host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
|
|
52
|
-
}
|
|
53
|
-
return program;
|
|
54
|
-
function getVueCompilerOptions() {
|
|
55
|
-
const tsConfig = options.options.configFilePath;
|
|
56
|
-
if (typeof tsConfig === 'string') {
|
|
57
|
-
return vue_typescript_2.tsShared.createParsedCommandLine(ts, ts.sys, tsConfig).vueOptions;
|
|
58
|
-
}
|
|
59
|
-
return {};
|
|
60
|
-
}
|
|
61
|
-
function getScriptVersion(fileName) {
|
|
62
|
-
var _a, _b;
|
|
63
|
-
return (_b = (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : '';
|
|
64
|
-
}
|
|
65
|
-
function getScriptSnapshot(fileName) {
|
|
66
|
-
var _a;
|
|
67
|
-
return (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.scriptSnapshot;
|
|
68
|
-
}
|
|
69
|
-
function getScript(fileName) {
|
|
70
|
-
var _a, _b, _c, _d, _e, _f;
|
|
71
|
-
const script = scripts.get(fileName);
|
|
72
|
-
if ((script === null || script === void 0 ? void 0 : script.projectVersion) === projectVersion) {
|
|
73
|
-
return script;
|
|
74
|
-
}
|
|
75
|
-
const modifiedTime = (_d = (_c = (_b = (_a = ts.sys).getModifiedTime) === null || _b === void 0 ? void 0 : _b.call(_a, fileName)) === null || _c === void 0 ? void 0 : _c.valueOf()) !== null && _d !== void 0 ? _d : 0;
|
|
76
|
-
if ((script === null || script === void 0 ? void 0 : script.modifiedTime) === modifiedTime) {
|
|
77
|
-
return script;
|
|
78
|
-
}
|
|
79
|
-
if (host.fileExists(fileName)) {
|
|
80
|
-
const fileContent = host.readFile(fileName);
|
|
81
|
-
if (fileContent !== undefined) {
|
|
82
|
-
const script = {
|
|
83
|
-
projectVersion,
|
|
84
|
-
modifiedTime,
|
|
85
|
-
scriptSnapshot: ts.ScriptSnapshot.fromString(fileContent),
|
|
86
|
-
version: (_f = (_e = host.createHash) === null || _e === void 0 ? void 0 : _e.call(host, fileContent)) !== null && _f !== void 0 ? _f : fileContent,
|
|
87
|
-
};
|
|
88
|
-
scripts.set(fileName, script);
|
|
89
|
-
return script;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.createProgramProxy = createProgramProxy;
|
|
95
|
-
function doThrow(msg) {
|
|
96
|
-
console.error(msg);
|
|
97
|
-
throw msg;
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=proxy.js.map
|