vue-tsc 0.33.0 → 0.33.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/out/apis.d.ts ADDED
@@ -0,0 +1,10 @@
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 ADDED
@@ -0,0 +1,130 @@
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 ADDED
@@ -0,0 +1,3 @@
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/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "0.33.0",
3
+ "version": "0.33.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "bin",
7
- "out/proxy.js"
7
+ "out/**/*.js",
8
+ "out/**/*.d.ts"
8
9
  ],
9
10
  "repository": {
10
11
  "type": "git",
@@ -15,11 +16,11 @@
15
16
  "vue-tsc": "./bin/vue-tsc.js"
16
17
  },
17
18
  "dependencies": {
18
- "@volar/shared": "0.33.0",
19
- "@volar/vue-typescript": "0.33.0"
19
+ "@volar/shared": "0.33.1",
20
+ "@volar/vue-typescript": "0.33.1"
20
21
  },
21
22
  "peerDependencies": {
22
23
  "typescript": "*"
23
24
  },
24
- "gitHead": "6f5f0e354fd2105e48de12fa67acdca2157202f4"
25
+ "gitHead": "03eaf26e0b1259ffa2b5690168a2d6a8baa81cbc"
25
26
  }