vue-tsc 0.38.5 → 0.38.9

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 CHANGED
@@ -24,10 +24,6 @@ fs.readFileSync = (...args) => {
24
24
  );
25
25
 
26
26
  // proxy createProgram apis
27
- tsc = tsc.replace(
28
- `function createIncrementalProgram(_a) {`,
29
- `function createIncrementalProgram(_a) { console.error('incremental mode is not yet supported'); throw 'incremental mode is not yet supported';`,
30
- );
31
27
  tsc = tsc.replace(
32
28
  `function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {`,
33
29
  `function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) { return require(${JSON.stringify(proxyPath)}).createProgramProxy(...arguments);`,
package/out/apis.d.ts CHANGED
@@ -3,8 +3,8 @@ import type * as vueTs from '@volar/vue-typescript';
3
3
  export declare function register(ts: typeof import('typescript/lib/tsserverlibrary'), vueLsCtx: vueTs.LanguageServiceContext): {
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.DiagnosticWithLocation[] | readonly ts.Diagnostic[];
7
- getSemanticDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.DiagnosticWithLocation[] | readonly ts.Diagnostic[];
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.DiagnosticWithLocation[] | readonly ts.Diagnostic[];
9
+ getBindAndCheckDiagnostics: (sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken) => readonly ts.Diagnostic[] | readonly ts.DiagnosticWithLocation[];
10
10
  };
package/out/proxy.d.ts CHANGED
@@ -1,4 +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
- _options?: ts.CompilerOptions, _host?: ts.CompilerHost, _oldProgram?: ts.Program, _configFileParsingDiagnostics?: readonly ts.Diagnostic[]): void | ts.Program;
3
+ _options?: ts.CompilerOptions, _host?: ts.CompilerHost, _oldProgram?: ts.Program, _configFileParsingDiagnostics?: readonly ts.Diagnostic[]): any;
4
4
  export declare function loadTsLib(): typeof ts;
package/out/proxy.js CHANGED
@@ -4,83 +4,108 @@ exports.loadTsLib = exports.createProgramProxy = void 0;
4
4
  const ts = require("typescript/lib/tsserverlibrary");
5
5
  const apis = require("./apis");
6
6
  const vueTs = require("@volar/vue-typescript");
7
- let projectVersion = 0;
8
7
  function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
9
8
  _options, _host, _oldProgram, _configFileParsingDiagnostics) {
10
- var _a, _b;
11
9
  if (!options.options.noEmit && !options.options.emitDeclarationOnly)
12
10
  return doThrow('js emit is not support');
13
11
  if (!options.host)
14
12
  return doThrow('!options.host');
15
- projectVersion++;
16
- const host = options.host;
17
- const vueCompilerOptions = getVueCompilerOptions();
18
- const scripts = new Map();
19
- const vueLsHost = Object.assign(Object.assign({}, host), { resolveModuleNames: undefined, writeFile: (fileName, content) => {
20
- if (fileName.indexOf('__VLS_') === -1) {
21
- host.writeFile(fileName, content, false);
13
+ let program = options.oldProgram;
14
+ if (!program) {
15
+ const ctx = {
16
+ projectVersion: 0,
17
+ options: options,
18
+ };
19
+ const vueCompilerOptions = getVueCompilerOptions();
20
+ const scripts = new Map();
21
+ const vueLsHost = new Proxy({
22
+ resolveModuleNames: undefined,
23
+ writeFile: (fileName, content) => {
24
+ if (fileName.indexOf('__VLS_') === -1) {
25
+ ctx.options.host.writeFile(fileName, content, false);
26
+ }
27
+ },
28
+ getCompilationSettings: () => ctx.options.options,
29
+ getVueCompilationSettings: () => vueCompilerOptions,
30
+ getScriptFileNames: () => {
31
+ return ctx.options.rootNames;
32
+ },
33
+ getScriptVersion,
34
+ getScriptSnapshot,
35
+ getProjectVersion: () => {
36
+ return ctx.projectVersion.toString();
37
+ },
38
+ getProjectReferences: () => ctx.options.projectReferences,
39
+ isTsc: true,
40
+ }, {
41
+ get: (target, property) => {
42
+ if (property in target) {
43
+ return target[property];
44
+ }
45
+ return ctx.options.host[property];
46
+ },
47
+ });
48
+ const vueLsCtx = vueTs.createLanguageServiceContext(ts, vueLsHost);
49
+ const proxyApis = apis.register(ts, vueLsCtx);
50
+ program = new Proxy({}, {
51
+ get: (target, property) => {
52
+ var _a;
53
+ if (property in proxyApis) {
54
+ return proxyApis[property];
55
+ }
56
+ return (_a = vueLsCtx.typescriptLanguageService.getProgram()[property]) !== null && _a !== void 0 ? _a : target[property];
57
+ },
58
+ });
59
+ program.__VLS_ctx = ctx;
60
+ function getVueCompilerOptions() {
61
+ const tsConfig = ctx.options.options.configFilePath;
62
+ if (typeof tsConfig === 'string') {
63
+ return vueTs.tsShared.createParsedCommandLine(ts, ts.sys, tsConfig).vueOptions;
22
64
  }
23
- }, getCompilationSettings: () => options.options, getVueCompilationSettings: () => vueCompilerOptions, getScriptFileNames: () => {
24
- return options.rootNames;
25
- }, getScriptVersion,
26
- getScriptSnapshot, getProjectVersion: () => {
27
- return projectVersion.toString();
28
- }, getProjectReferences: () => options.projectReferences, isTsc: true });
29
- const vueLsCtx = (_b = (_a = options.oldProgram) === null || _a === void 0 ? void 0 : _a.__VLS_vueCtx) !== null && _b !== void 0 ? _b : vueTs.createLanguageServiceContext(ts, vueLsHost);
30
- const proxyApis = apis.register(ts, vueLsCtx);
31
- const program = new Proxy({}, {
32
- get: (_, property) => {
33
- if (property in proxyApis) {
34
- return proxyApis[property];
35
- }
36
- return vueLsCtx.typescriptLanguageService.getProgram()[property];
37
- },
38
- });
39
- program.__VLS_vueCtx = vueLsCtx;
40
- for (const rootName of options.rootNames) {
41
- // register file watchers
42
- host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
43
- }
44
- return program;
45
- function getVueCompilerOptions() {
46
- const tsConfig = options.options.configFilePath;
47
- if (typeof tsConfig === 'string') {
48
- return vueTs.tsShared.createParsedCommandLine(ts, ts.sys, tsConfig).vueOptions;
65
+ return {};
49
66
  }
50
- return {};
51
- }
52
- function getScriptVersion(fileName) {
53
- var _a, _b;
54
- return (_b = (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : '';
55
- }
56
- function getScriptSnapshot(fileName) {
57
- var _a;
58
- return (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.scriptSnapshot;
59
- }
60
- function getScript(fileName) {
61
- var _a, _b, _c, _d, _e, _f;
62
- const script = scripts.get(fileName);
63
- if ((script === null || script === void 0 ? void 0 : script.projectVersion) === projectVersion) {
64
- return script;
67
+ function getScriptVersion(fileName) {
68
+ var _a, _b;
69
+ return (_b = (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.version) !== null && _b !== void 0 ? _b : '';
65
70
  }
66
- 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;
67
- if ((script === null || script === void 0 ? void 0 : script.modifiedTime) === modifiedTime) {
68
- return script;
71
+ function getScriptSnapshot(fileName) {
72
+ var _a;
73
+ return (_a = getScript(fileName)) === null || _a === void 0 ? void 0 : _a.scriptSnapshot;
69
74
  }
70
- if (host.fileExists(fileName)) {
71
- const fileContent = host.readFile(fileName);
72
- if (fileContent !== undefined) {
73
- const script = {
74
- projectVersion,
75
- modifiedTime,
76
- scriptSnapshot: ts.ScriptSnapshot.fromString(fileContent),
77
- version: (_f = (_e = host.createHash) === null || _e === void 0 ? void 0 : _e.call(host, fileContent)) !== null && _f !== void 0 ? _f : fileContent,
78
- };
79
- scripts.set(fileName, script);
75
+ function getScript(fileName) {
76
+ var _a, _b, _c, _d, _e, _f, _g;
77
+ const script = scripts.get(fileName);
78
+ if ((script === null || script === void 0 ? void 0 : script.projectVersion) === ctx.projectVersion) {
80
79
  return script;
81
80
  }
81
+ 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;
82
+ if ((script === null || script === void 0 ? void 0 : script.modifiedTime) === modifiedTime) {
83
+ return script;
84
+ }
85
+ if (ctx.options.host.fileExists(fileName)) {
86
+ const fileContent = ctx.options.host.readFile(fileName);
87
+ if (fileContent !== undefined) {
88
+ const script = {
89
+ projectVersion: ctx.projectVersion,
90
+ modifiedTime,
91
+ scriptSnapshot: ts.ScriptSnapshot.fromString(fileContent),
92
+ version: (_g = (_f = (_e = ctx.options.host).createHash) === null || _f === void 0 ? void 0 : _f.call(_e, fileContent)) !== null && _g !== void 0 ? _g : fileContent,
93
+ };
94
+ scripts.set(fileName, script);
95
+ return script;
96
+ }
97
+ }
82
98
  }
83
99
  }
100
+ else {
101
+ program.__VLS_ctx.options = options;
102
+ program.__VLS_ctx.projectVersion++;
103
+ }
104
+ for (const rootName of options.rootNames) {
105
+ // register file watchers
106
+ options.host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
107
+ }
108
+ return program;
84
109
  }
85
110
  exports.createProgramProxy = createProgramProxy;
86
111
  function loadTsLib() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "0.38.5",
3
+ "version": "0.38.9",
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.38.5"
19
+ "@volar/vue-typescript": "0.38.9"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "typescript": "*"
23
23
  },
24
- "gitHead": "537550bae4ac9bcbe021f23dd6a3f7880031a32b"
24
+ "gitHead": "1c77a6212f055edf7c2ae11543be198201cd5b4f"
25
25
  }