vue-tsc 0.36.1 → 0.37.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/bin/vue-tsc.js +15 -3
- package/out/apis.d.ts +5 -5
- package/out/apis.js +10 -10
- package/out/proxy.d.ts +1 -0
- package/out/proxy.js +6 -4
- package/package.json +3 -3
package/bin/vue-tsc.js
CHANGED
|
@@ -12,15 +12,15 @@ fs.readFileSync = (...args) => {
|
|
|
12
12
|
// add *.vue files to allow extensions
|
|
13
13
|
tsc = tsc.replace(
|
|
14
14
|
`ts.supportedTSExtensions = [[".ts", ".tsx", ".d.ts"], [".cts", ".d.cts"], [".mts", ".d.mts"]];`,
|
|
15
|
-
`ts.supportedTSExtensions = [[".ts", ".tsx", ".d.ts"], [".cts", ".d.cts"], [".mts", ".d.mts"], [".vue"]];`,
|
|
15
|
+
`ts.supportedTSExtensions = [[".ts", ".tsx", ".d.ts"], [".cts", ".d.cts"], [".mts", ".d.mts"], [".vue", ".md"]];`,
|
|
16
16
|
);
|
|
17
17
|
tsc = tsc.replace(
|
|
18
18
|
`ts.supportedJSExtensions = [[".js", ".jsx"], [".mjs"], [".cjs"]];`,
|
|
19
|
-
`ts.supportedJSExtensions = [[".js", ".jsx"], [".mjs"], [".cjs"], [".vue"]];`,
|
|
19
|
+
`ts.supportedJSExtensions = [[".js", ".jsx"], [".mjs"], [".cjs"], [".vue", ".md"]];`,
|
|
20
20
|
);
|
|
21
21
|
tsc = tsc.replace(
|
|
22
22
|
`var allSupportedExtensions = [[".ts", ".tsx", ".d.ts", ".js", ".jsx"], [".cts", ".d.cts", ".cjs"], [".mts", ".d.mts", ".mjs"]];`,
|
|
23
|
-
`var allSupportedExtensions = [[".ts", ".tsx", ".d.ts", ".js", ".jsx"], [".cts", ".d.cts", ".cjs"], [".mts", ".d.mts", ".mjs"], [".vue"]];`,
|
|
23
|
+
`var allSupportedExtensions = [[".ts", ".tsx", ".d.ts", ".js", ".jsx"], [".cts", ".d.cts", ".cjs"], [".mts", ".d.mts", ".mjs"], [".vue", ".md"]];`,
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
// proxy createProgram apis
|
|
@@ -32,6 +32,18 @@ fs.readFileSync = (...args) => {
|
|
|
32
32
|
`function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {`,
|
|
33
33
|
`function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { return require(${JSON.stringify(proxyPath)}).createProgramProxy(...arguments);`,
|
|
34
34
|
);
|
|
35
|
+
|
|
36
|
+
// proxy tracing
|
|
37
|
+
tsc = tsc.replace(
|
|
38
|
+
`ts.startTracing = tracingEnabled.startTracing;`,
|
|
39
|
+
`ts.startTracing = require(${JSON.stringify(proxyPath)}).loadTsLib().startTracing;`,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
tsc = tsc.replace(
|
|
43
|
+
`ts.dumpTracingLegend = tracingEnabled.dumpLegend;`,
|
|
44
|
+
`ts.dumpTracingLegend = require(${JSON.stringify(proxyPath)}).loadTsLib().dumpTracingLegend;`,
|
|
45
|
+
);
|
|
46
|
+
|
|
35
47
|
return tsc;
|
|
36
48
|
}
|
|
37
49
|
return readFileSync(...args);
|
package/out/apis.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
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): {
|
|
2
|
+
import type { TypeScriptRuntime, LanguageServiceHost } from '@volar/vue-typescript';
|
|
3
|
+
export declare function register(ts: typeof import('typescript/lib/tsserverlibrary'), context: TypeScriptRuntime, vueLsHost: LanguageServiceHost): {
|
|
4
4
|
getRootFileNames: () => string[];
|
|
5
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.
|
|
7
|
-
getSemanticDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.
|
|
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
8
|
getGlobalDiagnostics: (cancellationToken?: ts.CancellationToken) => readonly ts.Diagnostic[];
|
|
9
|
-
getBindAndCheckDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.
|
|
9
|
+
getBindAndCheckDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.Diagnostic[] | readonly ts.DiagnosticWithLocation[];
|
|
10
10
|
};
|
package/out/apis.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
-
function register(ts, context) {
|
|
4
|
+
function register(ts, context, vueLsHost) {
|
|
5
5
|
return {
|
|
6
6
|
getRootFileNames,
|
|
7
7
|
emit,
|
|
@@ -44,7 +44,7 @@ function register(ts, context) {
|
|
|
44
44
|
}
|
|
45
45
|
function emit(targetSourceFile, _writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
|
|
46
46
|
var _a;
|
|
47
|
-
const scriptResult = getProgram().emit(targetSourceFile, ((_a =
|
|
47
|
+
const scriptResult = getProgram().emit(targetSourceFile, ((_a = vueLsHost.writeFile) !== null && _a !== void 0 ? _a : ts.sys.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
48
48
|
return {
|
|
49
49
|
emitSkipped: scriptResult.emitSkipped,
|
|
50
50
|
emittedFiles: scriptResult.emittedFiles,
|
|
@@ -56,7 +56,7 @@ function register(ts, context) {
|
|
|
56
56
|
}
|
|
57
57
|
// transform
|
|
58
58
|
function transformDiagnostics(diagnostics) {
|
|
59
|
-
var _a, _b, _c, _d, _e
|
|
59
|
+
var _a, _b, _c, _d, _e;
|
|
60
60
|
const result = [];
|
|
61
61
|
for (const diagnostic of diagnostics) {
|
|
62
62
|
if (diagnostic.file !== undefined
|
|
@@ -64,23 +64,23 @@ function register(ts, context) {
|
|
|
64
64
|
&& diagnostic.length !== undefined) {
|
|
65
65
|
let founded = false;
|
|
66
66
|
for (const tsOrVueLoc of context.vueFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
|
|
67
|
-
if (!((
|
|
67
|
+
if (!((_a = vueLsHost.fileExists) === null || _a === void 0 ? void 0 : _a.call(vueLsHost, tsOrVueLoc.fileName)))
|
|
68
68
|
continue;
|
|
69
|
-
onMapping(diagnostic, tsOrVueLoc.fileName, tsOrVueLoc.range.start, tsOrVueLoc.range.end, (
|
|
69
|
+
onMapping(diagnostic, tsOrVueLoc.fileName, tsOrVueLoc.range.start, tsOrVueLoc.range.end, (_b = tsOrVueLoc.mapped) === null || _b === void 0 ? void 0 : _b.vueFile.getContent());
|
|
70
70
|
founded = true;
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
// fix https://github.com/johnsoncodehk/volar/issues/1372
|
|
74
74
|
if (!founded) {
|
|
75
75
|
for (const start of context.vueFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start, diagnostic.start, data => !!data.capabilities.diagnostic)) {
|
|
76
|
-
if (!((
|
|
76
|
+
if (!((_c = vueLsHost.fileExists) === null || _c === void 0 ? void 0 : _c.call(vueLsHost, start.fileName)))
|
|
77
77
|
continue;
|
|
78
78
|
for (const end of context.vueFiles.fromEmbeddedLocation(diagnostic.file.fileName, diagnostic.start + diagnostic.length, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
|
|
79
|
-
if (!((
|
|
79
|
+
if (!((_d = vueLsHost.fileExists) === null || _d === void 0 ? void 0 : _d.call(vueLsHost, end.fileName)))
|
|
80
80
|
continue;
|
|
81
81
|
if (start.fileName !== end.fileName)
|
|
82
82
|
continue;
|
|
83
|
-
onMapping(diagnostic, start.fileName, start.range.start, end.range.end, (
|
|
83
|
+
onMapping(diagnostic, start.fileName, start.range.start, end.range.end, (_e = start.mapped) === null || _e === void 0 ? void 0 : _e.vueFile.getContent());
|
|
84
84
|
founded = true;
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
@@ -102,13 +102,13 @@ function register(ts, context) {
|
|
|
102
102
|
: undefined;
|
|
103
103
|
if (!file) {
|
|
104
104
|
if (docText === undefined) {
|
|
105
|
-
const snapshot =
|
|
105
|
+
const snapshot = vueLsHost.getScriptSnapshot(fileName);
|
|
106
106
|
if (snapshot) {
|
|
107
107
|
docText = snapshot.getText(0, snapshot.getLength());
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
|
-
file = ts.createSourceFile(fileName, docText, fileName.endsWith('.vue') ? ts.ScriptTarget.JSON : ts.ScriptTarget.Latest);
|
|
111
|
+
file = ts.createSourceFile(fileName, docText, fileName.endsWith('.vue') || fileName.endsWith('.md') ? ts.ScriptTarget.JSON : ts.ScriptTarget.Latest);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
const newDiagnostic = Object.assign(Object.assign({}, diagnostic), { file, start: start, length: end - start });
|
package/out/proxy.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
2
|
export declare function createProgramProxy(options: ts.CreateProgramOptions, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
|
|
3
3
|
_options?: ts.CompilerOptions, _host?: ts.CompilerHost, _oldProgram?: ts.Program, _configFileParsingDiagnostics?: readonly ts.Diagnostic[]): void | ts.Program;
|
|
4
|
+
export declare function loadTsLib(): typeof ts;
|
package/out/proxy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProgramProxy = void 0;
|
|
3
|
+
exports.loadTsLib = exports.createProgramProxy = void 0;
|
|
4
4
|
const ts = require("typescript/lib/tsserverlibrary");
|
|
5
5
|
const apis = require("./apis");
|
|
6
6
|
const vue_typescript_1 = require("@volar/vue-typescript");
|
|
@@ -29,13 +29,11 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
|
29
29
|
}, getProjectReferences: () => options.projectReferences });
|
|
30
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
31
|
typescript: ts,
|
|
32
|
-
baseCssModuleType: 'any',
|
|
33
|
-
getCssClasses: () => ({}),
|
|
34
32
|
vueLsHost: vueLsHost,
|
|
35
33
|
isVueTsc: true,
|
|
36
34
|
});
|
|
37
35
|
tsRuntime.update(); // must update before getProgram() to update virtual scripts
|
|
38
|
-
const proxyApis = apis.register(ts, tsRuntime);
|
|
36
|
+
const proxyApis = apis.register(ts, tsRuntime, vueLsHost);
|
|
39
37
|
const program = new Proxy({}, {
|
|
40
38
|
get: (_, property) => {
|
|
41
39
|
tsRuntime.update();
|
|
@@ -92,6 +90,10 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
exports.createProgramProxy = createProgramProxy;
|
|
93
|
+
function loadTsLib() {
|
|
94
|
+
return ts;
|
|
95
|
+
}
|
|
96
|
+
exports.loadTsLib = loadTsLib;
|
|
95
97
|
function doThrow(msg) {
|
|
96
98
|
console.error(msg);
|
|
97
99
|
throw msg;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-tsc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.2",
|
|
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.37.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"typescript": "*"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "58de272d1750c161089a6c439e1141470cf2e96b"
|
|
25
25
|
}
|