vue-tsc 1.0.13 → 1.0.16
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 +17 -5
- package/out/index.d.ts +16 -0
- package/out/index.js +149 -0
- package/out/proxy.d.ts +1 -4
- package/out/proxy.js +4 -110
- package/out/shared.d.ts +8 -0
- package/out/shared.js +4 -0
- package/package.json +5 -4
package/bin/vue-tsc.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
|
|
4
3
|
const readFileSync = fs.readFileSync;
|
|
5
4
|
const tscPath = require.resolve('typescript/lib/tsc');
|
|
6
|
-
const
|
|
5
|
+
const proxyApiPath = require.resolve('../out/index');
|
|
6
|
+
const { state } = require('../out/shared');
|
|
7
7
|
|
|
8
8
|
fs.readFileSync = (...args) => {
|
|
9
9
|
if (args[0] === tscPath) {
|
|
@@ -15,10 +15,10 @@ fs.readFileSync = (...args) => {
|
|
|
15
15
|
tryReplace(/allSupportedExtensions = .*(?=;)/, s => s + '.concat([[".vue"]])');
|
|
16
16
|
|
|
17
17
|
// proxy startTracing, dumpTracingLegend
|
|
18
|
-
tryReplace(/ = tracingEnabled\./g, ` = require(${JSON.stringify(
|
|
18
|
+
tryReplace(/ = tracingEnabled\./g, ` = require(${JSON.stringify(proxyApiPath)}).loadTsLib().`);
|
|
19
19
|
|
|
20
20
|
// proxy createProgram apis
|
|
21
|
-
tryReplace(/function createProgram\(.+\) {/, s => s + ` return require(${JSON.stringify(
|
|
21
|
+
tryReplace(/function createProgram\(.+\) {/, s => s + ` return require(${JSON.stringify(proxyApiPath)}).createProgram(...arguments);`);
|
|
22
22
|
|
|
23
23
|
return tsc;
|
|
24
24
|
|
|
@@ -34,4 +34,16 @@ fs.readFileSync = (...args) => {
|
|
|
34
34
|
return readFileSync(...args);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
(function main() {
|
|
38
|
+
try {
|
|
39
|
+
require(tscPath);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
if (err === 'hook') {
|
|
43
|
+
state.hook.worker.then(main);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
})();
|
package/out/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as ts from 'typescript/lib/tsserverlibrary';
|
|
2
|
+
import * as vue from '@volar/vue-language-core';
|
|
3
|
+
import * as vueTs from '@volar/vue-typescript';
|
|
4
|
+
export type _Program = ts.Program & {
|
|
5
|
+
__vue: ProgramContext;
|
|
6
|
+
};
|
|
7
|
+
interface ProgramContext {
|
|
8
|
+
projectVersion: number;
|
|
9
|
+
options: ts.CreateProgramOptions;
|
|
10
|
+
languageServiceHost: vue.LanguageServiceHost;
|
|
11
|
+
languageService: ReturnType<typeof vueTs.createLanguageService>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createProgram(options: ts.CreateProgramOptions, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
|
|
14
|
+
_options?: ts.CompilerOptions, _host?: ts.CompilerHost, _oldProgram?: ts.Program, _configFileParsingDiagnostics?: readonly ts.Diagnostic[]): _Program;
|
|
15
|
+
export declare function loadTsLib(): typeof ts;
|
|
16
|
+
export {};
|
package/out/index.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.loadTsLib = exports.createProgram = void 0;
|
|
12
|
+
const ts = require("typescript/lib/tsserverlibrary");
|
|
13
|
+
const vue = require("@volar/vue-language-core");
|
|
14
|
+
const vueTs = require("@volar/vue-typescript");
|
|
15
|
+
const shared_1 = require("./shared");
|
|
16
|
+
function createProgram(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
|
|
17
|
+
_options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
if (!options.options.noEmit && !options.options.emitDeclarationOnly)
|
|
20
|
+
throw toThrow('js emit is not supported');
|
|
21
|
+
if (!options.options.noEmit && options.options.noEmitOnError)
|
|
22
|
+
throw toThrow('noEmitOnError is not supported');
|
|
23
|
+
if (!options.host)
|
|
24
|
+
throw toThrow('!options.host');
|
|
25
|
+
let program = options.oldProgram;
|
|
26
|
+
if (shared_1.state.hook) {
|
|
27
|
+
program = shared_1.state.hook.program;
|
|
28
|
+
program.__vue.options = options;
|
|
29
|
+
}
|
|
30
|
+
else if (!program) {
|
|
31
|
+
const ctx = {
|
|
32
|
+
projectVersion: 0,
|
|
33
|
+
options,
|
|
34
|
+
get languageServiceHost() {
|
|
35
|
+
return vueLsHost;
|
|
36
|
+
},
|
|
37
|
+
get languageService() {
|
|
38
|
+
return vueTsLs;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const vueCompilerOptions = getVueCompilerOptions();
|
|
42
|
+
const scripts = new Map();
|
|
43
|
+
const vueLsHost = new Proxy({
|
|
44
|
+
resolveModuleNames: undefined,
|
|
45
|
+
writeFile: (fileName, content) => {
|
|
46
|
+
if (fileName.indexOf('__VLS_') === -1) {
|
|
47
|
+
ctx.options.host.writeFile(fileName, content, false);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
getCompilationSettings: () => ctx.options.options,
|
|
51
|
+
getVueCompilationSettings: () => vueCompilerOptions,
|
|
52
|
+
getScriptFileNames: () => {
|
|
53
|
+
return ctx.options.rootNames;
|
|
54
|
+
},
|
|
55
|
+
getScriptVersion,
|
|
56
|
+
getScriptSnapshot,
|
|
57
|
+
getProjectVersion: () => {
|
|
58
|
+
return ctx.projectVersion.toString();
|
|
59
|
+
},
|
|
60
|
+
getProjectReferences: () => ctx.options.projectReferences,
|
|
61
|
+
getTypeScriptModule: () => ts,
|
|
62
|
+
isTsc: true,
|
|
63
|
+
}, {
|
|
64
|
+
get: (target, property) => {
|
|
65
|
+
if (property in target) {
|
|
66
|
+
return target[property];
|
|
67
|
+
}
|
|
68
|
+
return ctx.options.host[property];
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
const vueTsLs = vueTs.createLanguageService(vueLsHost);
|
|
72
|
+
program = vueTsLs.getProgram();
|
|
73
|
+
program.__vue = ctx;
|
|
74
|
+
function getVueCompilerOptions() {
|
|
75
|
+
const tsConfig = ctx.options.options.configFilePath;
|
|
76
|
+
if (typeof tsConfig === 'string') {
|
|
77
|
+
return vue.createParsedCommandLine(ts, ts.sys, tsConfig, []).vueOptions;
|
|
78
|
+
}
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
function getScriptVersion(fileName) {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
return (_b = (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : '';
|
|
84
|
+
}
|
|
85
|
+
function getScriptSnapshot(fileName) {
|
|
86
|
+
var _a;
|
|
87
|
+
return (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.scriptSnapshot;
|
|
88
|
+
}
|
|
89
|
+
function getScript(fileName) {
|
|
90
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
91
|
+
const script = scripts.get(fileName);
|
|
92
|
+
if ((script === null || script === void 0 ? void 0 : script.projectVersion) === ctx.projectVersion) {
|
|
93
|
+
return script;
|
|
94
|
+
}
|
|
95
|
+
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;
|
|
96
|
+
if ((script === null || script === void 0 ? void 0 : script.modifiedTime) === modifiedTime) {
|
|
97
|
+
return script;
|
|
98
|
+
}
|
|
99
|
+
if (ctx.options.host.fileExists(fileName)) {
|
|
100
|
+
const fileContent = ctx.options.host.readFile(fileName);
|
|
101
|
+
if (fileContent !== undefined) {
|
|
102
|
+
const script = {
|
|
103
|
+
projectVersion: ctx.projectVersion,
|
|
104
|
+
modifiedTime,
|
|
105
|
+
scriptSnapshot: ts.ScriptSnapshot.fromString(fileContent),
|
|
106
|
+
version: (_g = (_f = (_e = ctx.options.host).createHash) === null || _f === void 0 ? void 0 : _f.call(_e, fileContent)) !== null && _g !== void 0 ? _g : fileContent,
|
|
107
|
+
};
|
|
108
|
+
scripts.set(fileName, script);
|
|
109
|
+
return script;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const ctx = program.__vue;
|
|
116
|
+
ctx.options = options;
|
|
117
|
+
ctx.projectVersion++;
|
|
118
|
+
}
|
|
119
|
+
const vueCompilerOptions = program.__vue.languageServiceHost.getVueCompilationSettings();
|
|
120
|
+
if (vueCompilerOptions.hooks) {
|
|
121
|
+
const index = ((_b = (_a = shared_1.state.hook) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : -1) + 1;
|
|
122
|
+
if (index < vueCompilerOptions.hooks.length) {
|
|
123
|
+
const cbPath = vueCompilerOptions.hooks[index];
|
|
124
|
+
const dir = program.__vue.languageServiceHost.getCurrentDirectory();
|
|
125
|
+
const cb = require(require.resolve(cbPath, { paths: [dir] }));
|
|
126
|
+
shared_1.state.hook = {
|
|
127
|
+
program,
|
|
128
|
+
index,
|
|
129
|
+
worker: (() => __awaiter(this, void 0, void 0, function* () { return yield cb(program); }))(),
|
|
130
|
+
};
|
|
131
|
+
throw 'hook';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const rootName of options.rootNames) {
|
|
135
|
+
// register file watchers
|
|
136
|
+
options.host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
|
|
137
|
+
}
|
|
138
|
+
return program;
|
|
139
|
+
}
|
|
140
|
+
exports.createProgram = createProgram;
|
|
141
|
+
function loadTsLib() {
|
|
142
|
+
return ts;
|
|
143
|
+
}
|
|
144
|
+
exports.loadTsLib = loadTsLib;
|
|
145
|
+
function toThrow(msg) {
|
|
146
|
+
console.error(msg);
|
|
147
|
+
return msg;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=index.js.map
|
package/out/proxy.d.ts
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
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[]): any;
|
|
4
|
-
export declare function loadTsLib(): typeof ts;
|
|
1
|
+
export { createProgram as createProgramProxy } from './index';
|
package/out/proxy.js
CHANGED
|
@@ -1,112 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
|
|
7
|
-
_options, _host, _oldProgram, _configFileParsingDiagnostics) {
|
|
8
|
-
if (!options.options.noEmit && !options.options.emitDeclarationOnly)
|
|
9
|
-
return doThrow('js emit is not supported');
|
|
10
|
-
if (!options.options.noEmit && options.options.noEmitOnError)
|
|
11
|
-
return doThrow('noEmitOnError is not supported');
|
|
12
|
-
if (!options.host)
|
|
13
|
-
return doThrow('!options.host');
|
|
14
|
-
let program = options.oldProgram;
|
|
15
|
-
if (!program) {
|
|
16
|
-
const ctx = {
|
|
17
|
-
projectVersion: 0,
|
|
18
|
-
options: options,
|
|
19
|
-
};
|
|
20
|
-
const vueCompilerOptions = getVueCompilerOptions();
|
|
21
|
-
const scripts = new Map();
|
|
22
|
-
const vueLsHost = new Proxy({
|
|
23
|
-
resolveModuleNames: undefined,
|
|
24
|
-
writeFile: (fileName, content) => {
|
|
25
|
-
if (fileName.indexOf('__VLS_') === -1) {
|
|
26
|
-
ctx.options.host.writeFile(fileName, content, false);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
getCompilationSettings: () => ctx.options.options,
|
|
30
|
-
getVueCompilationSettings: () => vueCompilerOptions,
|
|
31
|
-
getScriptFileNames: () => {
|
|
32
|
-
return ctx.options.rootNames;
|
|
33
|
-
},
|
|
34
|
-
getScriptVersion,
|
|
35
|
-
getScriptSnapshot,
|
|
36
|
-
getProjectVersion: () => {
|
|
37
|
-
return ctx.projectVersion.toString();
|
|
38
|
-
},
|
|
39
|
-
getProjectReferences: () => ctx.options.projectReferences,
|
|
40
|
-
getTypeScriptModule: () => ts,
|
|
41
|
-
isTsc: true,
|
|
42
|
-
}, {
|
|
43
|
-
get: (target, property) => {
|
|
44
|
-
if (property in target) {
|
|
45
|
-
return target[property];
|
|
46
|
-
}
|
|
47
|
-
return ctx.options.host[property];
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
const vueTsLs = vueTs.createLanguageService(vueLsHost);
|
|
51
|
-
program = vueTsLs.getProgram();
|
|
52
|
-
program.__vue = ctx;
|
|
53
|
-
function getVueCompilerOptions() {
|
|
54
|
-
const tsConfig = ctx.options.options.configFilePath;
|
|
55
|
-
if (typeof tsConfig === 'string') {
|
|
56
|
-
return vue.createParsedCommandLine(ts, ts.sys, tsConfig, []).vueOptions;
|
|
57
|
-
}
|
|
58
|
-
return {};
|
|
59
|
-
}
|
|
60
|
-
function getScriptVersion(fileName) {
|
|
61
|
-
var _a, _b;
|
|
62
|
-
return (_b = (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : '';
|
|
63
|
-
}
|
|
64
|
-
function getScriptSnapshot(fileName) {
|
|
65
|
-
var _a;
|
|
66
|
-
return (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.scriptSnapshot;
|
|
67
|
-
}
|
|
68
|
-
function getScript(fileName) {
|
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
70
|
-
const script = scripts.get(fileName);
|
|
71
|
-
if ((script === null || script === void 0 ? void 0 : script.projectVersion) === ctx.projectVersion) {
|
|
72
|
-
return script;
|
|
73
|
-
}
|
|
74
|
-
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;
|
|
75
|
-
if ((script === null || script === void 0 ? void 0 : script.modifiedTime) === modifiedTime) {
|
|
76
|
-
return script;
|
|
77
|
-
}
|
|
78
|
-
if (ctx.options.host.fileExists(fileName)) {
|
|
79
|
-
const fileContent = ctx.options.host.readFile(fileName);
|
|
80
|
-
if (fileContent !== undefined) {
|
|
81
|
-
const script = {
|
|
82
|
-
projectVersion: ctx.projectVersion,
|
|
83
|
-
modifiedTime,
|
|
84
|
-
scriptSnapshot: ts.ScriptSnapshot.fromString(fileContent),
|
|
85
|
-
version: (_g = (_f = (_e = ctx.options.host).createHash) === null || _f === void 0 ? void 0 : _f.call(_e, fileContent)) !== null && _g !== void 0 ? _g : fileContent,
|
|
86
|
-
};
|
|
87
|
-
scripts.set(fileName, script);
|
|
88
|
-
return script;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
program.__vue.options = options;
|
|
95
|
-
program.__vue.projectVersion++;
|
|
96
|
-
}
|
|
97
|
-
for (const rootName of options.rootNames) {
|
|
98
|
-
// register file watchers
|
|
99
|
-
options.host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
|
|
100
|
-
}
|
|
101
|
-
return program;
|
|
102
|
-
}
|
|
103
|
-
exports.createProgramProxy = createProgramProxy;
|
|
104
|
-
function loadTsLib() {
|
|
105
|
-
return ts;
|
|
106
|
-
}
|
|
107
|
-
exports.loadTsLib = loadTsLib;
|
|
108
|
-
function doThrow(msg) {
|
|
109
|
-
console.error(msg);
|
|
110
|
-
throw msg;
|
|
111
|
-
}
|
|
2
|
+
exports.createProgramProxy = void 0;
|
|
3
|
+
// temporary fix for https://github.com/fi3ework/vite-plugin-checker/pull/194
|
|
4
|
+
var index_1 = require("./index");
|
|
5
|
+
Object.defineProperty(exports, "createProgramProxy", { enumerable: true, get: function () { return index_1.createProgram; } });
|
|
112
6
|
//# sourceMappingURL=proxy.js.map
|
package/out/shared.d.ts
ADDED
package/out/shared.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-tsc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
|
+
"main": "out/index.js",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"files": [
|
|
6
7
|
"bin",
|
|
@@ -16,11 +17,11 @@
|
|
|
16
17
|
"vue-tsc": "./bin/vue-tsc.js"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@volar/vue-language-core": "1.0.
|
|
20
|
-
"@volar/vue-typescript": "1.0.
|
|
20
|
+
"@volar/vue-language-core": "1.0.16",
|
|
21
|
+
"@volar/vue-typescript": "1.0.16"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"typescript": "*"
|
|
24
25
|
},
|
|
25
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "af476047d8859652254ed36f8aee184f1972a97a"
|
|
26
27
|
}
|