vue-tsc 0.33.7 → 0.33.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/out/apis.js CHANGED
@@ -31,10 +31,10 @@ function register(ts, context) {
31
31
  }
32
32
  function getSourceFileDiagnosticsWorker(sourceFile, cancellationToken, api) {
33
33
  if (sourceFile) {
34
- const maped = context.vueFiles.fromEmbeddedFileName('script', sourceFile.fileName);
35
- if (maped) {
34
+ const mapped = context.vueFiles.fromEmbeddedFileName('script', sourceFile.fileName);
35
+ if (mapped) {
36
36
  let results = [];
37
- const embeddeds = maped.vueFile.getAllEmbeddeds();
37
+ const embeddeds = mapped.vueFile.getAllEmbeddeds();
38
38
  for (const embedded of embeddeds) {
39
39
  if (embedded.file.lsType === 'nonTs' || !embedded.file.capabilities.diagnostics)
40
40
  continue;
@@ -81,13 +81,13 @@ function register(ts, context) {
81
81
  for (const tsOrVueLoc of context.vueFiles.fromEmbeddedLocation(lsType, diagnostic.file.fileName, diagnostic.start, diagnostic.start + diagnostic.length, data => !!data.capabilities.diagnostic)) {
82
82
  if (!context.vueLsHost.fileExists?.(tsOrVueLoc.fileName))
83
83
  continue;
84
- if (!tsOrVueLoc.maped && lsType !== 'script')
84
+ if (!tsOrVueLoc.mapped && lsType !== 'script')
85
85
  continue;
86
86
  let file = tsOrVueLoc.fileName === diagnostic.file.fileName
87
87
  ? diagnostic.file
88
88
  : undefined;
89
89
  if (!file) {
90
- let docText = tsOrVueLoc.maped?.vueFile.getContent();
90
+ let docText = tsOrVueLoc.mapped?.vueFile.getContent();
91
91
  if (docText === undefined) {
92
92
  const snapshot = context.vueLsHost.getScriptSnapshot(tsOrVueLoc.fileName);
93
93
  if (snapshot) {
package/out/proxy.js CHANGED
@@ -5,12 +5,14 @@ const ts = require("typescript/lib/tsserverlibrary");
5
5
  const apis = require("./apis");
6
6
  const vue_typescript_1 = require("@volar/vue-typescript");
7
7
  const vue_typescript_2 = require("@volar/vue-typescript");
8
+ let projectVersion = 0;
8
9
  function createProgramProxy(options, // rootNamesOrOptions: readonly string[] | CreateProgramOptions,
9
10
  _options, _host, _oldProgram, _configFileParsingDiagnostics) {
10
11
  if (!options.options.noEmit && !options.options.emitDeclarationOnly)
11
12
  return doThrow('js emit is not support');
12
13
  if (!options.host)
13
14
  return doThrow('!options.host');
15
+ projectVersion++;
14
16
  const host = options.host;
15
17
  const vueCompilerOptions = getVueCompilerOptions();
16
18
  const scripts = new Map();
@@ -20,14 +22,20 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
20
22
  writeFile: undefined,
21
23
  getCompilationSettings: () => options.options,
22
24
  getVueCompilationSettings: () => vueCompilerOptions,
23
- getScriptFileNames: () => options.rootNames,
24
- getScriptVersion: (fileName) => scripts.get(fileName)?.version ?? '',
25
+ getScriptFileNames: () => {
26
+ return options.rootNames;
27
+ },
28
+ getScriptVersion,
25
29
  getScriptSnapshot,
26
- getProjectVersion: () => '',
27
- getVueProjectVersion: () => '',
30
+ getProjectVersion: () => {
31
+ return projectVersion.toString();
32
+ },
33
+ getVueProjectVersion: () => {
34
+ return projectVersion.toString();
35
+ },
28
36
  getProjectReferences: () => options.projectReferences,
29
37
  };
30
- const tsRuntime = (0, vue_typescript_1.createTypeScriptRuntime)({
38
+ const tsRuntime = options.oldProgram?.__VLS_tsRuntime ?? (0, vue_typescript_1.createTypeScriptRuntime)({
31
39
  typescript: ts,
32
40
  baseCssModuleType: 'any',
33
41
  getCssClasses: () => ({}),
@@ -35,21 +43,23 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
35
43
  vueLsHost: vueLsHost,
36
44
  isVueTsc: true,
37
45
  });
46
+ tsRuntime.update(true); // must update before getProgram() to update virtual scripts
38
47
  const tsProgram = tsRuntime.getTsLs('script').getProgram();
39
48
  if (!tsProgram)
40
49
  throw '!tsProgram';
41
- const tsProgramApis_2 = apis.register(ts, tsRuntime);
42
- const tsProgramProxy = new Proxy(tsProgram, {
50
+ const proxyApis = apis.register(ts, tsRuntime);
51
+ const program = new Proxy(tsProgram, {
43
52
  get: (target, property) => {
44
53
  tsRuntime.update(true);
45
- return tsProgramApis_2[property] || target[property];
54
+ return proxyApis[property] || target[property];
46
55
  },
47
56
  });
57
+ program.__VLS_tsRuntime = tsRuntime;
48
58
  for (const rootName of options.rootNames) {
49
59
  // register file watchers
50
60
  host.getSourceFile(rootName, ts.ScriptTarget.ESNext);
51
61
  }
52
- return tsProgramProxy;
62
+ return program;
53
63
  function getVueCompilerOptions() {
54
64
  const tsConfig = options.options.configFilePath;
55
65
  if (typeof tsConfig === 'string') {
@@ -57,20 +67,32 @@ _options, _host, _oldProgram, _configFileParsingDiagnostics) {
57
67
  }
58
68
  return {};
59
69
  }
70
+ function getScriptVersion(fileName) {
71
+ return getScript(fileName)?.version ?? '';
72
+ }
60
73
  function getScriptSnapshot(fileName) {
74
+ return getScript(fileName)?.scriptSnapshot;
75
+ }
76
+ function getScript(fileName) {
61
77
  const script = scripts.get(fileName);
62
- if (script) {
63
- return script.scriptSnapshot;
78
+ if (script?.projectVersion === projectVersion) {
79
+ return script;
80
+ }
81
+ const modifiedTime = ts.sys.getModifiedTime?.(fileName)?.valueOf() ?? 0;
82
+ if (script?.modifiedTime === modifiedTime) {
83
+ return script;
64
84
  }
65
85
  if (host.fileExists(fileName)) {
66
86
  const fileContent = host.readFile(fileName);
67
87
  if (fileContent !== undefined) {
68
- const scriptSnapshot = ts.ScriptSnapshot.fromString(fileContent);
69
- scripts.set(fileName, {
70
- scriptSnapshot: scriptSnapshot,
71
- version: ts.sys.createHash?.(fileContent) ?? fileContent,
72
- });
73
- return scriptSnapshot;
88
+ const script = {
89
+ projectVersion,
90
+ modifiedTime,
91
+ scriptSnapshot: ts.ScriptSnapshot.fromString(fileContent),
92
+ version: host.createHash?.(fileContent) ?? fileContent,
93
+ };
94
+ scripts.set(fileName, script);
95
+ return script;
74
96
  }
75
97
  }
76
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-tsc",
3
- "version": "0.33.7",
3
+ "version": "0.33.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.33.7"
19
+ "@volar/vue-typescript": "0.33.9"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "typescript": "*"
23
23
  },
24
- "gitHead": "1b89d4dc2fb0fa5b7c17aa9dbff4b0fc62a108f4"
24
+ "gitHead": "9031e662fe238df7ec385ddde6a91e1e363a4af4"
25
25
  }