@volar/typescript 2.3.5-alpha.2 → 2.4.0-alpha.0

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.
@@ -1,3 +1,6 @@
1
- import { LanguagePlugin } from '@volar/language-core';
1
+ import { Language, LanguagePlugin } from '@volar/language-core';
2
2
  import type * as ts from 'typescript';
3
- export declare function proxyCreateProgram(ts: typeof import('typescript'), original: typeof ts['createProgram'], getLanguagePlugins: (ts: typeof import('typescript'), options: ts.CreateProgramOptions) => LanguagePlugin<string>[]): typeof import("typescript").createProgram;
3
+ export declare function proxyCreateProgram(ts: typeof import('typescript'), original: typeof ts['createProgram'], create: (ts: typeof import('typescript'), options: ts.CreateProgramOptions) => LanguagePlugin<string>[] | {
4
+ languagePlugins: LanguagePlugin<string>[];
5
+ setup?(language: Language<string>): void;
6
+ }): typeof import("typescript").createProgram;
@@ -29,7 +29,7 @@ const objectEqual = (a, b) => {
29
29
  }
30
30
  return true;
31
31
  };
32
- function proxyCreateProgram(ts, original, getLanguagePlugins) {
32
+ function proxyCreateProgram(ts, original, create) {
33
33
  const sourceFileSnapshots = new language_core_1.FileMap(ts.sys.useCaseSensitiveFileNames);
34
34
  const parsedSourceFiles = new WeakMap();
35
35
  let lastOptions;
@@ -47,7 +47,13 @@ function proxyCreateProgram(ts, original, getLanguagePlugins) {
47
47
  || !objectEqual(options.options, lastOptions.options)) {
48
48
  moduleResolutionCache = ts.createModuleResolutionCache(options.host.getCurrentDirectory(), options.host.getCanonicalFileName, options.options);
49
49
  lastOptions = options;
50
- languagePlugins = getLanguagePlugins(ts, options);
50
+ const created = create(ts, options);
51
+ if (Array.isArray(created)) {
52
+ languagePlugins = created;
53
+ }
54
+ else {
55
+ languagePlugins = created.languagePlugins;
56
+ }
51
57
  language = (0, language_core_1.createLanguage)([
52
58
  ...languagePlugins,
53
59
  { getLanguageId: common_1.resolveFileLanguageId },
@@ -79,6 +85,9 @@ function proxyCreateProgram(ts, original, getLanguagePlugins) {
79
85
  language.scripts.delete(fileName);
80
86
  }
81
87
  });
88
+ if ('setup' in created) {
89
+ created.setup?.(language);
90
+ }
82
91
  }
83
92
  const originalHost = options.host;
84
93
  const extensions = languagePlugins
@@ -1,4 +1,7 @@
1
1
  import type * as ts from 'typescript';
2
- import type { LanguagePlugin } from '@volar/language-core';
3
- export declare let getLanguagePlugins: (ts: typeof import('typescript'), options: ts.CreateProgramOptions) => LanguagePlugin<string>[];
2
+ import type { Language, LanguagePlugin } from '@volar/language-core';
3
+ export declare let getLanguagePlugins: (ts: typeof import('typescript'), options: ts.CreateProgramOptions) => LanguagePlugin<string>[] | {
4
+ plugins: LanguagePlugin<string>[];
5
+ setup?(language: Language<string>): void;
6
+ };
4
7
  export declare function runTsc(tscPath: string, extensions: string[], _getLanguagePlugins: typeof getLanguagePlugins): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/typescript",
3
- "version": "2.3.5-alpha.2",
3
+ "version": "2.4.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,14 +12,14 @@
12
12
  "directory": "packages/typescript"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-core": "2.3.5-alpha.2",
15
+ "@volar/language-core": "2.4.0-alpha.0",
16
16
  "path-browserify": "^1.0.1",
17
17
  "vscode-uri": "^3.0.8"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/node": "latest",
21
21
  "@types/path-browserify": "latest",
22
- "@volar/language-service": "2.3.5-alpha.2"
22
+ "@volar/language-service": "2.4.0-alpha.0"
23
23
  },
24
- "gitHead": "875106ba581210ab30829170585205cdb69b73ec"
24
+ "gitHead": "007fc74c461e2fd3fb269bf4f3924cc23c35ba56"
25
25
  }