vue-tsc 0.33.1 → 0.33.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "0.33.1",
3
+ "version": "0.33.3",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "bin",
@@ -16,11 +16,10 @@
16
16
  "vue-tsc": "./bin/vue-tsc.js"
17
17
  },
18
18
  "dependencies": {
19
- "@volar/shared": "0.33.1",
20
- "@volar/vue-typescript": "0.33.1"
19
+ "@volar/vue-typescript": "0.33.3"
21
20
  },
22
21
  "peerDependencies": {
23
22
  "typescript": "*"
24
23
  },
25
- "gitHead": "03eaf26e0b1259ffa2b5690168a2d6a8baa81cbc"
24
+ "gitHead": "bfc0d807da4448e1628048728950cdcf27582ae3"
26
25
  }
package/out/apis.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import type * as ts from 'typescript/lib/tsserverlibrary';
2
- import type { TypeScriptFeaturesRuntimeContext } from '@volar/vue-typescript';
3
- export declare function register(ts: typeof import('typescript/lib/tsserverlibrary'), { vueDocuments, templateTsLsRaw, scriptTsLsRaw, templateTsHost, scriptTsHost, vueHost }: TypeScriptFeaturesRuntimeContext): {
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,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.register = void 0;
4
- const shared = require("@volar/shared");
5
- const lsTypes = ['script', 'template'];
6
- function register(ts, { vueDocuments, templateTsLsRaw, scriptTsLsRaw, templateTsHost, scriptTsHost, vueHost }) {
7
- return {
8
- getRootFileNames,
9
- emit,
10
- getSyntacticDiagnostics,
11
- getSemanticDiagnostics,
12
- getGlobalDiagnostics,
13
- getBindAndCheckDiagnostics,
14
- };
15
- function getRootFileNames() {
16
- const set = new Set([
17
- ...getProgram('script').getRootFileNames().filter(fileName => { var _a; return (_a = scriptTsHost.fileExists) === null || _a === void 0 ? void 0 : _a.call(scriptTsHost, fileName); }),
18
- ...getProgram('template').getRootFileNames().filter(fileName => { var _a; return (_a = templateTsHost.fileExists) === null || _a === void 0 ? void 0 : _a.call(templateTsHost, fileName); }),
19
- ]);
20
- return [...set.values()];
21
- }
22
- // for vue-tsc --noEmit --watch
23
- function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
24
- return getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, 'getBindAndCheckDiagnostics');
25
- }
26
- // for vue-tsc --noEmit
27
- function getSyntacticDiagnostics(sourceFile, cancellationToken) {
28
- return getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, 'getSyntacticDiagnostics');
29
- }
30
- function getSemanticDiagnostics(sourceFile, cancellationToken) {
31
- return getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, 'getSemanticDiagnostics');
32
- }
33
- function getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, api) {
34
- if (sourceFile) {
35
- const sourceMap = vueDocuments.fromEmbeddedDocumentUri('script', shared.fsPathToUri(sourceFile.fileName));
36
- const vueDocument = sourceMap ? vueDocuments.get(sourceMap.sourceDocument.uri) : undefined;
37
- if (vueDocument) {
38
- let results = [];
39
- const sourceMaps = vueDocument.getSourceMaps();
40
- for (const sourceMap of sourceMaps) {
41
- if (sourceMap.lsType === 'nonTs' || !sourceMap.capabilities.diagnostics)
42
- continue;
43
- const program = getProgram(sourceMap.lsType);
44
- const embeddedSourceFile = program.getSourceFile(shared.uriToFsPath(sourceMap.mappedDocument.uri));
45
- if (embeddedSourceFile) {
46
- const errors = transformDiagnostics(sourceMap.lsType, program[api](embeddedSourceFile, cancellationToken));
47
- results = results.concat(errors);
48
- }
49
- }
50
- return results;
51
- }
52
- else {
53
- return getProgram('script')[api](sourceFile, cancellationToken);
54
- }
55
- }
56
- return lsTypes.map(lsType => transformDiagnostics(lsType, getProgram(lsType)[api](sourceFile, cancellationToken))).flat();
57
- }
58
- function getGlobalDiagnostics(cancellationToken) {
59
- return lsTypes.map(lsType => transformDiagnostics(lsType, getProgram(lsType).getGlobalDiagnostics(cancellationToken))).flat();
60
- }
61
- function emit(targetSourceFile, _writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
62
- var _a;
63
- const scriptResult = getProgram('script').emit(targetSourceFile, ((_a = vueHost.writeFile) !== null && _a !== void 0 ? _a : ts.sys.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
64
- const templateResult = getProgram('template').emit(targetSourceFile, undefined, cancellationToken, emitOnlyDtsFiles, customTransformers);
65
- return {
66
- emitSkipped: scriptResult.emitSkipped,
67
- emittedFiles: scriptResult.emittedFiles,
68
- diagnostics: [
69
- ...transformDiagnostics('script', scriptResult.diagnostics),
70
- ...transformDiagnostics('template', templateResult.diagnostics),
71
- ],
72
- };
73
- }
74
- function getProgram(lsType) {
75
- const program = (lsType === 'script' ? scriptTsLsRaw : templateTsLsRaw).getProgram();
76
- if (!program)
77
- throw '!program';
78
- return program;
79
- }
80
- // transform
81
- function transformDiagnostics(lsType, diagnostics) {
82
- var _a, _b;
83
- const result = [];
84
- for (const diagnostic of diagnostics) {
85
- if (diagnostic.file !== undefined
86
- && diagnostic.start !== undefined
87
- && diagnostic.length !== undefined) {
88
- const fileName = shared.normalizeFileName(diagnostic.file.fileName);
89
- for (const tsOrVueLoc of vueDocuments.fromEmbeddedLocation(lsType, shared.fsPathToUri(fileName), diagnostic.start, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
90
- if (!((_a = vueHost.fileExists) === null || _a === void 0 ? void 0 : _a.call(vueHost, shared.uriToFsPath(tsOrVueLoc.uri))))
91
- continue;
92
- if (tsOrVueLoc.type === 'source-ts' && lsType !== 'script')
93
- continue;
94
- let file = shared.uriToFsPath(tsOrVueLoc.uri) === fileName
95
- ? diagnostic.file
96
- : undefined;
97
- if (!file) {
98
- let docText = (_b = tsOrVueLoc.sourceMap) === null || _b === void 0 ? void 0 : _b.sourceDocument.getText();
99
- if (docText === undefined) {
100
- const snapshot = vueHost.getScriptSnapshot(shared.uriToFsPath(tsOrVueLoc.uri));
101
- if (snapshot) {
102
- docText = snapshot.getText(0, snapshot.getLength());
103
- }
104
- }
105
- if (docText !== undefined) {
106
- file = ts.createSourceFile(shared.uriToFsPath(tsOrVueLoc.uri), docText, tsOrVueLoc.uri.endsWith('.vue') ? ts.ScriptTarget.JSON : ts.ScriptTarget.Latest);
107
- }
108
- }
109
- const newDiagnostic = {
110
- ...diagnostic,
111
- file,
112
- start: tsOrVueLoc.range.start,
113
- length: tsOrVueLoc.range.end - tsOrVueLoc.range.start,
114
- };
115
- const relatedInformation = diagnostic.relatedInformation;
116
- if (relatedInformation) {
117
- newDiagnostic.relatedInformation = transformDiagnostics(lsType, relatedInformation);
118
- }
119
- result.push(newDiagnostic);
120
- }
121
- }
122
- else if (diagnostic.file === undefined) {
123
- result.push(diagnostic);
124
- }
125
- }
126
- return result;
127
- }
128
- }
129
- exports.register = register;
130
- //# 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,78 +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 shared = require("@volar/shared");
6
- const apis = require("./apis");
7
- const vue_typescript_1 = require("@volar/vue-typescript");
8
- function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
9
- _options, _host, _oldProgram, _configFileParsingDiagnostics) {
10
- if (!options.options.noEmit && !options.options.emitDeclarationOnly)
11
- return doThrow('js emit is not support');
12
- if (!options.host)
13
- return doThrow('!options.host');
14
- const host = options.host;
15
- const vueCompilerOptions = getVueCompilerOptions();
16
- const scripts = new Map();
17
- const vueLsHost = {
18
- ...host,
19
- resolveModuleNames: undefined,
20
- writeFile: undefined,
21
- getCompilationSettings: () => options.options,
22
- getVueCompilationSettings: () => vueCompilerOptions,
23
- getScriptFileNames: () => options.rootNames,
24
- getScriptVersion: (fileName) => { var _a, _b; return (_b = (_a = scripts.get(fileName)) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : ''; },
25
- getScriptSnapshot,
26
- getProjectVersion: () => '',
27
- getVueProjectVersion: () => '',
28
- getProjectReferences: () => options.projectReferences,
29
- };
30
- const services = (0, vue_typescript_1.createBasicRuntime)();
31
- const tsRuntime = (0, vue_typescript_1.createTypeScriptRuntime)({ typescript: ts, ...services, compilerOptions: vueCompilerOptions }, vueLsHost, false);
32
- const tsProgram = tsRuntime.context.scriptTsLsRaw.getProgram(); // TODO: handle template ls?
33
- if (!tsProgram)
34
- throw '!tsProgram';
35
- const tsProgramApis_2 = apis.register(ts, tsRuntime.context);
36
- const tsProgramProxy = new Proxy(tsProgram, {
37
- get: (target, property) => {
38
- tsRuntime.update(true);
39
- return tsProgramApis_2[property] || target[property];
40
- },
41
- });
42
- for (const rootName of options.rootNames) {
43
- // register file watchers
44
- host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
45
- }
46
- return tsProgramProxy;
47
- function getVueCompilerOptions() {
48
- const tsConfig = options.options.configFilePath;
49
- if (typeof tsConfig === 'string') {
50
- return shared.createParsedCommandLine(ts, ts.sys, tsConfig).vueOptions;
51
- }
52
- return {};
53
- }
54
- function getScriptSnapshot(fileName) {
55
- var _a, _b, _c;
56
- const script = scripts.get(fileName);
57
- if (script) {
58
- return script.scriptSnapshot;
59
- }
60
- if (host.fileExists(fileName)) {
61
- const fileContent = host.readFile(fileName);
62
- if (fileContent !== undefined) {
63
- const scriptSnapshot = ts.ScriptSnapshot.fromString(fileContent);
64
- scripts.set(fileName, {
65
- scriptSnapshot: scriptSnapshot,
66
- version: (_c = (_b = (_a = ts.sys).createHash) === null || _b === void 0 ? void 0 : _b.call(_a, fileContent)) !== null && _c !== void 0 ? _c : fileContent,
67
- });
68
- return scriptSnapshot;
69
- }
70
- }
71
- }
72
- }
73
- exports.createProgramProxy = createProgramProxy;
74
- function doThrow(msg) {
75
- console.error(msg);
76
- throw msg;
77
- }
78
- //# sourceMappingURL=proxy.js.map