@volar/language-server 1.0.14 → 1.0.17

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.
Files changed (64) hide show
  1. package/out/{utils/webFileSystemHost.d.ts → browser/fileSystems.d.ts} +0 -0
  2. package/out/{utils/webFileSystemHost.js → browser/fileSystems.js} +4 -4
  3. package/out/{browser.d.ts → browser/index.d.ts} +2 -2
  4. package/out/{browser.js → browser/index.js} +32 -28
  5. package/out/{utils/ts → browser/typescript}/core.d.ts +0 -0
  6. package/out/{utils/ts → browser/typescript}/core.js +0 -0
  7. package/out/{utils/ts → browser/typescript}/corePublic.d.ts +0 -0
  8. package/out/{utils/ts → browser/typescript}/corePublic.js +0 -0
  9. package/out/{utils/ts → browser/typescript}/path.d.ts +0 -0
  10. package/out/{utils/ts → browser/typescript}/path.js +0 -0
  11. package/out/{utils/ts → browser/typescript}/types.d.ts +0 -0
  12. package/out/{utils/ts → browser/typescript}/types.js +0 -0
  13. package/out/{utils/ts → browser/typescript}/utilities.d.ts +0 -0
  14. package/out/{utils/ts → browser/typescript}/utilities.js +0 -0
  15. package/out/{utils → common}/cancellationPipe.d.ts +0 -0
  16. package/out/{utils → common}/cancellationPipe.js +0 -0
  17. package/out/{utils → common}/configurationHost.d.ts +1 -1
  18. package/out/{utils → common}/configurationHost.js +7 -5
  19. package/out/{utils/snapshots.d.ts → common/documents.d.ts} +1 -1
  20. package/out/{utils/snapshots.js → common/documents.js} +5 -5
  21. package/out/{features → common/features}/customFeatures.d.ts +1 -1
  22. package/out/{features → common/features}/customFeatures.js +20 -42
  23. package/out/common/features/documentFeatures.d.ts +4 -0
  24. package/out/{features → common/features}/documentFeatures.js +1 -1
  25. package/out/common/features/languageFeatures.d.ts +4 -0
  26. package/out/{features → common/features}/languageFeatures.js +4 -5
  27. package/out/{utils → common}/project.d.ts +13 -8
  28. package/out/{utils → common}/project.js +19 -16
  29. package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/file.d.ts +0 -0
  30. package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/file.js +0 -0
  31. package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/http.d.ts +0 -0
  32. package/out/{schemaRequestHandlers → common/schemaRequestHandlers}/http.js +0 -0
  33. package/out/common/server.d.ts +8 -0
  34. package/out/{server.js → common/server.js} +94 -33
  35. package/out/{utils/documentServiceHost.d.ts → common/syntaxServicesHost.d.ts} +2 -2
  36. package/out/{utils/documentServiceHost.js → common/syntaxServicesHost.js} +10 -10
  37. package/out/{utils → common/utils}/inferredCompilerOptions.d.ts +0 -0
  38. package/out/{utils → common/utils}/inferredCompilerOptions.js +0 -0
  39. package/out/{registerFeatures.d.ts → common/utils/registerFeatures.d.ts} +2 -3
  40. package/out/{registerFeatures.js → common/utils/registerFeatures.js} +6 -53
  41. package/out/{utils/config.d.ts → common/utils/serverConfig.d.ts} +0 -0
  42. package/out/{utils/config.js → common/utils/serverConfig.js} +1 -1
  43. package/out/{utils → common/utils}/uriMap.d.ts +0 -0
  44. package/out/{utils → common/utils}/uriMap.js +0 -0
  45. package/out/common/workspace.d.ts +1186 -0
  46. package/out/{utils/workspaceProjects.js → common/workspace.js} +29 -13
  47. package/out/common/workspaces.d.ts +1465 -0
  48. package/out/{utils → common}/workspaces.js +15 -10
  49. package/out/{utils/nodeFileSystemHost.d.ts → node/fileSystem.d.ts} +0 -0
  50. package/out/{utils/nodeFileSystemHost.js → node/fileSystem.js} +17 -19
  51. package/out/{node.d.ts → node/index.d.ts} +2 -2
  52. package/out/node/index.js +107 -0
  53. package/out/protocol.d.ts +4 -6
  54. package/out/protocol.js +1 -5
  55. package/out/types.d.ts +5 -3
  56. package/package.json +7 -7
  57. package/out/features/documentFeatures.d.ts +0 -4
  58. package/out/features/languageFeatures.d.ts +0 -4
  59. package/out/node.js +0 -103
  60. package/out/server.d.ts +0 -3
  61. package/out/utils/iterableWeakSet.d.ts +0 -7
  62. package/out/utils/iterableWeakSet.js +0 -40
  63. package/out/utils/workspaceProjects.d.ts +0 -162
  64. package/out/utils/workspaces.d.ts +0 -429
@@ -14,8 +14,8 @@ const vscode_html_languageservice_1 = require("vscode-html-languageservice");
14
14
  const vscode = require("vscode-languageserver");
15
15
  const vscode_uri_1 = require("vscode-uri");
16
16
  const protocol_1 = require("../protocol");
17
- const utilities_1 = require("./ts/utilities");
18
- const uriMap_1 = require("./uriMap");
17
+ const utilities_1 = require("./typescript/utilities");
18
+ const uriMap_1 = require("../common/utils/uriMap");
19
19
  const shared = require("@volar/shared");
20
20
  let currentCwd = '/';
21
21
  function createWebFileSystemHost() {
@@ -58,7 +58,7 @@ function createWebFileSystemHost() {
58
58
  }
59
59
  onReadys.length = 0;
60
60
  },
61
- clearCache() {
61
+ reload() {
62
62
  root.dirs.clear();
63
63
  root.fileTexts.clear();
64
64
  root.fileTypes.clear();
@@ -315,4 +315,4 @@ function createWebFileSystemHost() {
315
315
  }
316
316
  }
317
317
  exports.createWebFileSystemHost = createWebFileSystemHost;
318
- //# sourceMappingURL=webFileSystemHost.js.map
318
+ //# sourceMappingURL=fileSystems.js.map
@@ -1,3 +1,3 @@
1
- import { LanguageServerPlugin } from './types';
1
+ import { LanguageServerPlugin } from '../types';
2
+ export * from '../index';
2
3
  export declare function createLanguageServer(plugins: LanguageServerPlugin[]): void;
3
- export * from './index';
@@ -26,39 +26,43 @@ exports.createLanguageServer = void 0;
26
26
  const request_light_1 = require("request-light");
27
27
  const ts = require("typescript/lib/tsserverlibrary"); // bundle typescript lib in web
28
28
  const vscode = require("vscode-languageserver/browser");
29
- const server_1 = require("./server");
30
- const http_1 = require("./schemaRequestHandlers/http");
31
- const webFileSystemHost_1 = require("./utils/webFileSystemHost");
29
+ const server_1 = require("../common/server");
30
+ const http_1 = require("../common/schemaRequestHandlers/http");
31
+ const fileSystems_1 = require("./fileSystems");
32
32
  const shared = require("@volar/shared");
33
+ __exportStar(require("../index"), exports);
33
34
  function createLanguageServer(plugins) {
34
35
  const messageReader = new vscode.BrowserMessageReader(self);
35
36
  const messageWriter = new vscode.BrowserMessageWriter(self);
36
37
  const connection = vscode.createConnection(messageReader, messageWriter);
37
- (0, server_1.createCommonLanguageServer)(connection, {
38
- loadTypescript() {
39
- return ts; // not support load by user config in web
38
+ (0, server_1.createCommonLanguageServer)({
39
+ plugins,
40
+ connection,
41
+ runtimeEnv: {
42
+ loadTypescript() {
43
+ return ts; // not support load by user config in web
44
+ },
45
+ loadTypescriptLocalized(tsdk, locale) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ try {
48
+ const uri = shared.getUriByPath(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
49
+ const json = yield (0, http_1.default)(uri);
50
+ return JSON.parse(json);
51
+ }
52
+ catch (_a) { }
53
+ });
54
+ },
55
+ schemaRequestHandlers: {
56
+ http: http_1.default,
57
+ https: http_1.default,
58
+ },
59
+ onDidChangeConfiguration(settings) {
60
+ (0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
61
+ },
62
+ fileSystemProvide: undefined,
63
+ createFileSystemHost: fileSystems_1.createWebFileSystemHost,
40
64
  },
41
- loadTypescriptLocalized(tsdk, locale) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- try {
44
- const uri = shared.getUriByPath(`${tsdk}/${locale}/diagnosticMessages.generated.json`);
45
- const json = yield (0, http_1.default)(uri);
46
- return JSON.parse(json);
47
- }
48
- catch (_a) { }
49
- });
50
- },
51
- schemaRequestHandlers: {
52
- http: http_1.default,
53
- https: http_1.default,
54
- },
55
- onDidChangeConfiguration(settings) {
56
- (0, request_light_1.configure)(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
57
- },
58
- fileSystemProvide: undefined,
59
- createFileSystemHost: webFileSystemHost_1.createWebFileSystemHost,
60
- }, plugins);
65
+ });
61
66
  }
62
67
  exports.createLanguageServer = createLanguageServer;
63
- __exportStar(require("./index"), exports);
64
- //# sourceMappingURL=browser.js.map
68
+ //# sourceMappingURL=index.js.map
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- import * as vscode from 'vscode-languageserver';
2
1
  import { ConfigurationHost } from '@volar/language-service';
2
+ import * as vscode from 'vscode-languageserver';
3
3
  export declare function createConfigurationHost(params: vscode.InitializeParams, connection: vscode.Connection): ConfigurationHost & {
4
4
  ready(): void;
5
5
  };
@@ -12,9 +12,9 @@ exports.createConfigurationHost = void 0;
12
12
  const vscode = require("vscode-languageserver");
13
13
  function createConfigurationHost(params, connection) {
14
14
  const callbacks = [];
15
- let cache = {};
15
+ const cache = new Map();
16
16
  connection.onDidChangeConfiguration(() => __awaiter(this, void 0, void 0, function* () {
17
- cache = {};
17
+ cache.clear();
18
18
  for (const cb of callbacks) {
19
19
  cb();
20
20
  }
@@ -27,11 +27,13 @@ function createConfigurationHost(params, connection) {
27
27
  }
28
28
  },
29
29
  getConfiguration(section, scopeUri) {
30
- var _a, _b;
30
+ var _a;
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
32
  if (!scopeUri && ((_a = params.capabilities.workspace) === null || _a === void 0 ? void 0 : _a.didChangeConfiguration)) {
33
- (_b = cache[section]) !== null && _b !== void 0 ? _b : (cache[section] = yield getConfigurationWorker(section, scopeUri));
34
- return cache[section];
33
+ if (!cache.has(section)) {
34
+ cache.set(section, yield getConfigurationWorker(section, scopeUri));
35
+ }
36
+ return cache.get(section);
35
37
  }
36
38
  return yield getConfigurationWorker(section, scopeUri);
37
39
  });
@@ -24,7 +24,7 @@ declare class IncrementalScriptSnapshot {
24
24
  applyVersionChanges(version: number, removeBeforeVersions: boolean): void;
25
25
  }
26
26
  export declare function combineContinuousChangeRanges(...changeRanges: ts.TextChangeRange[]): ts.TextChangeRange;
27
- export declare function createSnapshots(connection: vscode.Connection): {
27
+ export declare function createDocuments(connection: vscode.Connection): {
28
28
  data: {
29
29
  clear: () => void;
30
30
  values: () => IterableIterator<IncrementalScriptSnapshot>;
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.createSnapshots = exports.combineContinuousChangeRanges = void 0;
2
+ exports.createDocuments = exports.combineContinuousChangeRanges = void 0;
3
3
  const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument");
4
4
  const vscode = require("vscode-languageserver");
5
- const uriMap_1 = require("./uriMap");
5
+ const uriMap_1 = require("./utils/uriMap");
6
6
  class IncrementalScriptSnapshot {
7
7
  constructor(uri, languageId, version, text) {
8
8
  this.uri = uri;
@@ -145,7 +145,7 @@ function _combineContinuousChangeRanges(a, b) {
145
145
  const newLength = aDiff + bDiff + length;
146
146
  return { span: { start, length }, newLength };
147
147
  }
148
- function createSnapshots(connection) {
148
+ function createDocuments(connection) {
149
149
  const snapshots = (0, uriMap_1.createUriMap)();
150
150
  const onDidChangeContents = new Set();
151
151
  const onDidCloses = new Set();
@@ -195,5 +195,5 @@ function createSnapshots(connection) {
195
195
  },
196
196
  };
197
197
  }
198
- exports.createSnapshots = createSnapshots;
199
- //# sourceMappingURL=snapshots.js.map
198
+ exports.createDocuments = createDocuments;
199
+ //# sourceMappingURL=documents.js.map
@@ -1,3 +1,3 @@
1
1
  import * as vscode from 'vscode-languageserver';
2
- import type { Workspaces } from '../utils/workspaces';
2
+ import type { Workspaces } from '../workspaces';
3
3
  export declare function register(connection: vscode.Connection, projects: Workspaces): void;
@@ -10,9 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.register = void 0;
12
12
  const shared = require("@volar/shared");
13
- const path = require("typesafe-path");
14
- const vscode = require("vscode-languageserver");
15
- const protocol_1 = require("../protocol");
13
+ const protocol_1 = require("../../protocol");
16
14
  const language_core_1 = require("@volar/language-core");
17
15
  function register(connection, projects) {
18
16
  connection.onNotification(protocol_1.ReportStats.type, () => __awaiter(this, void 0, void 0, function* () {
@@ -77,10 +75,10 @@ function register(connection, projects) {
77
75
  const project = yield projects.getProject(document.uri);
78
76
  const fileNames = [];
79
77
  if (project) {
80
- const sourceFile = (_p = (_o = project.project) === null || _o === void 0 ? void 0 : _o.getLanguageService().context.core.mapper.get(shared.getPathOfUri(document.uri))) === null || _p === void 0 ? void 0 : _p[0];
78
+ const sourceFile = (_p = (_o = project.project) === null || _o === void 0 ? void 0 : _o.getLanguageService().context.core.virtualFiles.get(shared.getPathOfUri(document.uri))) === null || _p === void 0 ? void 0 : _p[1];
81
79
  if (sourceFile) {
82
- (0, language_core_1.forEachEmbeddeds)(sourceFile, e => {
83
- if (e.text && e.kind === 1) {
80
+ (0, language_core_1.forEachEmbeddedFile)(sourceFile, e => {
81
+ if (e.snapshot.getLength() && e.kind === 1) {
84
82
  fileNames.push(e.fileName);
85
83
  }
86
84
  });
@@ -89,14 +87,21 @@ function register(connection, projects) {
89
87
  return fileNames;
90
88
  }));
91
89
  connection.onRequest(protocol_1.GetVirtualFileRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
92
- var _q, _r;
90
+ var _q, _r, _s;
93
91
  const project = yield projects.getProject(params.sourceFileUri);
94
92
  if (project) {
95
- const embeddedFile = (_r = (_q = project.project) === null || _q === void 0 ? void 0 : _q.getLanguageService().context.core.mapper.fromEmbeddedFileName(params.virtualFileName)) === null || _r === void 0 ? void 0 : _r.embedded;
96
- if (embeddedFile) {
93
+ const sourceAndVirtual = (_q = project.project) === null || _q === void 0 ? void 0 : _q.getLanguageService().context.core.virtualFiles.getSourceByVirtualFileName(params.virtualFileName);
94
+ if (sourceAndVirtual) {
95
+ const virtualFile = sourceAndVirtual[2];
96
+ const mappings = {};
97
+ for (const mapping of virtualFile.mappings) {
98
+ const sourceUri = shared.getUriByPath((_r = mapping.source) !== null && _r !== void 0 ? _r : sourceAndVirtual[0]);
99
+ (_s = mappings[sourceUri]) !== null && _s !== void 0 ? _s : (mappings[sourceUri] = []);
100
+ mappings[sourceUri].push(mapping);
101
+ }
97
102
  return {
98
- content: embeddedFile.text,
99
- mappings: embeddedFile.mappings,
103
+ content: virtualFile.snapshot.getText(0, virtualFile.snapshot.getLength()),
104
+ mappings,
100
105
  };
101
106
  }
102
107
  }
@@ -105,16 +110,16 @@ function register(connection, projects) {
105
110
  projects.reloadProject();
106
111
  });
107
112
  connection.onNotification(protocol_1.WriteVirtualFilesNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
108
- var _s;
113
+ var _t;
109
114
  const fs = yield Promise.resolve().then(() => require('fs'));
110
115
  const project = yield projects.getProject(params.uri);
111
116
  if (project) {
112
- const ls = (_s = (yield project.project)) === null || _s === void 0 ? void 0 : _s.getLanguageServiceDontCreate();
117
+ const ls = (_t = (yield project.project)) === null || _t === void 0 ? void 0 : _t.getLanguageServiceDontCreate();
113
118
  if (ls) {
114
119
  const sourceFiles = new Set(ls.context.host.getScriptFileNames());
115
- for (const virtualFile of ls.context.core.typescriptLanguageServiceHost.getScriptFileNames()) {
120
+ for (const virtualFile of ls.context.core.typescript.languageServiceHost.getScriptFileNames()) {
116
121
  if (virtualFile.startsWith(ls.context.host.getCurrentDirectory()) && !sourceFiles.has(virtualFile)) {
117
- const snapshot = ls.context.core.typescriptLanguageServiceHost.getScriptSnapshot(virtualFile);
122
+ const snapshot = ls.context.core.typescript.languageServiceHost.getScriptSnapshot(virtualFile);
118
123
  if (snapshot) {
119
124
  fs.writeFile(virtualFile, snapshot.getText(0, snapshot.getLength()), () => { });
120
125
  }
@@ -123,33 +128,6 @@ function register(connection, projects) {
123
128
  }
124
129
  }
125
130
  }));
126
- connection.onNotification(protocol_1.VerifyAllScriptsNotification.type, (params) => __awaiter(this, void 0, void 0, function* () {
127
- var _t;
128
- let errors = 0;
129
- let warnings = 0;
130
- const progress = yield connection.window.createWorkDoneProgress();
131
- progress.begin('Verify', 0, '', true);
132
- const project = yield projects.getProject(params.uri);
133
- if (project) {
134
- const ls = (_t = (yield project.project)) === null || _t === void 0 ? void 0 : _t.getLanguageServiceDontCreate();
135
- if (ls) {
136
- const allVueDocuments = ls.context.documents.getAll();
137
- let i = 0;
138
- for (const vueFile of allVueDocuments) {
139
- progress.report(i++ / allVueDocuments.length * 100, path.relative(ls.context.host.getCurrentDirectory(), shared.getPathOfUri(vueFile.uri)));
140
- if (progress.token.isCancellationRequested) {
141
- continue;
142
- }
143
- let _result = yield ls.doValidation(vueFile.uri, progress.token);
144
- connection.sendDiagnostics({ uri: vueFile.uri, diagnostics: _result });
145
- errors += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Error).length;
146
- warnings += _result.filter(error => error.severity === vscode.DiagnosticSeverity.Warning).length;
147
- }
148
- }
149
- }
150
- progress.done();
151
- connection.window.showInformationMessage(`Verification complete. Found ${errors} errors and ${warnings} warnings.`);
152
- }));
153
131
  }
154
132
  exports.register = register;
155
133
  //# sourceMappingURL=customFeatures.js.map
@@ -0,0 +1,4 @@
1
+ import type * as vscode from 'vscode-languageserver';
2
+ import { createDocuments } from '../documents';
3
+ import { createSyntaxServicesHost } from '../syntaxServicesHost';
4
+ export declare function register(connection: vscode.Connection, documents: ReturnType<typeof createDocuments>, documentServiceHost: ReturnType<typeof createSyntaxServicesHost>): void;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.register = void 0;
12
- const protocol_1 = require("../protocol");
12
+ const protocol_1 = require("../../protocol");
13
13
  function register(connection, documents, documentServiceHost) {
14
14
  connection.onDocumentFormatting(params => {
15
15
  return worker(params.textDocument.uri, document => {
@@ -0,0 +1,4 @@
1
+ import * as vscode from 'vscode-languageserver';
2
+ import { CancellationTokenHost } from '../cancellationPipe';
3
+ import type { Workspaces } from '../workspaces';
4
+ export declare function register(connection: vscode.Connection, projects: Workspaces, initParams: vscode.InitializeParams, cancelHost: CancellationTokenHost, semanticTokensLegend: vscode.SemanticTokensLegend): void;
@@ -11,10 +11,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.register = void 0;
12
12
  const embedded = require("@volar/language-service");
13
13
  const vscode = require("vscode-languageserver");
14
- const protocol_1 = require("../protocol");
14
+ const protocol_1 = require("../../protocol");
15
15
  const shared = require("@volar/shared");
16
- const registerFeatures_1 = require("../registerFeatures");
17
- function register(connection, projects, initParams, cancelHost) {
16
+ function register(connection, projects, initParams, cancelHost, semanticTokensLegend) {
18
17
  let lastCompleteUri;
19
18
  let lastCompleteLs;
20
19
  let lastCodeLensLs;
@@ -181,7 +180,7 @@ function register(connection, projects, initParams, cancelHost) {
181
180
  return buildTokens([]);
182
181
  return (_j = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
183
182
  var _k;
184
- const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, registerFeatures_1.semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
183
+ const result = (_k = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, undefined, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _k !== void 0 ? _k : [];
185
184
  return buildTokens(result);
186
185
  }))) !== null && _j !== void 0 ? _j : buildTokens([]);
187
186
  }));
@@ -192,7 +191,7 @@ function register(connection, projects, initParams, cancelHost) {
192
191
  return buildTokens([]);
193
192
  return (_l = yield worker(params.textDocument.uri, (vueLs) => __awaiter(this, void 0, void 0, function* () {
194
193
  var _m;
195
- const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, registerFeatures_1.semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
194
+ const result = (_m = yield (vueLs === null || vueLs === void 0 ? void 0 : vueLs.getSemanticTokens(params.textDocument.uri, params.range, semanticTokensLegend, token, tokens => resultProgress === null || resultProgress === void 0 ? void 0 : resultProgress.report(buildTokens(tokens))))) !== null && _m !== void 0 ? _m : [];
196
195
  return buildTokens(result);
197
196
  }))) !== null && _l !== void 0 ? _l : buildTokens([]);
198
197
  }));
@@ -1,14 +1,19 @@
1
+ import * as embedded from '@volar/language-core';
1
2
  import * as embeddedLS from '@volar/language-service';
3
+ import * as path from 'typesafe-path';
2
4
  import type * as ts from 'typescript/lib/tsserverlibrary';
3
5
  import { URI } from 'vscode-uri';
4
- import { FileSystemHost, LanguageServerInitializationOptions, LanguageServerPlugin, RuntimeEnvironment } from '../types';
5
- import { createSnapshots } from './snapshots';
6
- import { ConfigurationHost } from '@volar/language-service';
7
- import * as path from 'typesafe-path';
8
- import { CancellationTokenHost } from './cancellationPipe';
9
- export interface Project extends ReturnType<typeof createProject> {
6
+ import { WorkspaceParams } from './workspace';
7
+ import { LanguageServicePlugin } from '@volar/language-service';
8
+ export interface ProjectParams {
9
+ workspace: WorkspaceParams;
10
+ rootUri: URI;
11
+ tsConfig: path.PosixPath | ts.CompilerOptions;
12
+ documentRegistry: ts.DocumentRegistry;
13
+ workspacePlugins: LanguageServicePlugin[];
10
14
  }
11
- export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: ReturnType<LanguageServerPlugin>[], fsHost: FileSystemHost, ts: typeof import('typescript/lib/tsserverlibrary'), rootUri: URI, tsConfig: path.PosixPath | ts.CompilerOptions, tsLocalized: ts.MapLike<string> | undefined, documents: ReturnType<typeof createSnapshots>, configHost: ConfigurationHost | undefined, documentRegistry: ts.DocumentRegistry | undefined, cancelTokenHost: CancellationTokenHost, serverOptions: LanguageServerInitializationOptions): Promise<{
15
+ export type Project = ReturnType<typeof createProject>;
16
+ export declare function createProject(params: ProjectParams): Promise<{
12
17
  tsConfig: ts.CompilerOptions | path.PosixPath;
13
18
  scripts: {
14
19
  clear: () => void;
@@ -52,7 +57,7 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
52
57
  snapshotVersion: number | undefined;
53
58
  }) => void;
54
59
  };
55
- languageServiceHost: embeddedLS.LanguageServiceHost;
60
+ languageServiceHost: embedded.LanguageServiceHost;
56
61
  getLanguageService: () => {
57
62
  doValidation: (uri: string, token?: embeddedLS.CancellationToken | undefined, response?: ((result: embeddedLS.Diagnostic[]) => void) | undefined) => Promise<embeddedLS.Diagnostic[]>;
58
63
  findReferences: (uri: string, position: embeddedLS.Position) => Promise<embeddedLS.Location[] | undefined>;
@@ -9,16 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.createProject = void 0;
12
- const shared = require("@volar/shared");
13
- const embeddedLS = require("@volar/language-service");
14
12
  const embedded = require("@volar/language-core");
15
- const vscode = require("vscode-languageserver");
16
- const config_1 = require("./config");
13
+ const embeddedLS = require("@volar/language-service");
14
+ const shared = require("@volar/shared");
17
15
  const path = require("typesafe-path");
18
- const uriMap_1 = require("./uriMap");
19
- function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLocalized, documents, configHost, documentRegistry, cancelTokenHost, serverOptions) {
16
+ const vscode = require("vscode-languageserver");
17
+ const uriMap_1 = require("./utils/uriMap");
18
+ function createProject(params) {
20
19
  return __awaiter(this, void 0, void 0, function* () {
21
- const sys = fsHost.getWorkspaceFileSystem(rootUri);
20
+ const { tsConfig, documentRegistry, rootUri } = params;
21
+ const { ts, fileSystemHost, documents, cancelTokenHost, tsLocalized, initOptions, configurationHost } = params.workspace.workspaces;
22
+ const { plugins } = params.workspace.workspaces;
23
+ const { runtimeEnv } = params.workspace.workspaces.server;
24
+ const sys = fileSystemHost.getWorkspaceFileSystem(rootUri);
22
25
  let typeRootVersion = 0;
23
26
  let projectVersion = 0;
24
27
  let projectVersionUpdateTime = cancelTokenHost.getMtime();
@@ -26,7 +29,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
26
29
  let parsedCommandLine = createParsedCommandLine(ts, sys, shared.getPathOfUri(rootUri.toString()), tsConfig, plugins);
27
30
  const scripts = (0, uriMap_1.createUriMap)();
28
31
  const languageServiceHost = createLanguageServiceHost();
29
- const disposeWatchEvent = fsHost.onDidChangeWatchedFiles(params => {
32
+ const disposeWatchEvent = fileSystemHost.onDidChangeWatchedFiles(params => {
30
33
  onWorkspaceFilesChanged(params.changes);
31
34
  });
32
35
  const disposeDocChange = documents.onDidChangeContent(() => {
@@ -51,19 +54,19 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
51
54
  function getLanguageService() {
52
55
  if (!vueLs) {
53
56
  const languageModules = plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getLanguageModules) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost)) !== null && _c !== void 0 ? _c : []; }).flat();
54
- const languageContext = embedded.createEmbeddedLanguageServiceHost(languageServiceHost, languageModules);
57
+ const languageContext = embedded.createLanguageContext(languageServiceHost, languageModules);
55
58
  const languageServiceContext = embeddedLS.createLanguageServiceContext({
56
59
  host: languageServiceHost,
57
60
  context: languageContext,
58
61
  getPlugins() {
59
62
  return [
60
- ...(0, config_1.loadCustomPlugins)(languageServiceHost.getCurrentDirectory(), serverOptions.configFilePath),
63
+ ...params.workspacePlugins,
61
64
  ...plugins.map(plugin => { var _a, _b, _c; return (_c = (_b = (_a = plugin.semanticService) === null || _a === void 0 ? void 0 : _a.getServicePlugins) === null || _b === void 0 ? void 0 : _b.call(_a, languageServiceHost, vueLs)) !== null && _c !== void 0 ? _c : []; }).flat(),
62
65
  ];
63
66
  },
64
67
  env: {
65
68
  rootUri,
66
- configurationHost: configHost,
69
+ configurationHost: configurationHost,
67
70
  fileSystemProvider: runtimeEnv.fileSystemProvide,
68
71
  documentContext: getHTMLDocumentContext(ts, languageServiceHost),
69
72
  schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
@@ -138,7 +141,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
138
141
  }
139
142
  catch (_a) {
140
143
  // web
141
- return serverOptions.typescript.tsdk + '/' + ts.getDefaultLibFileName(options);
144
+ return initOptions.typescript.tsdk + '/' + ts.getDefaultLibFileName(options);
142
145
  }
143
146
  },
144
147
  getProjectVersion: () => projectVersion.toString(),
@@ -149,7 +152,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
149
152
  getScriptSnapshot,
150
153
  getTypeScriptModule: () => ts,
151
154
  };
152
- if (serverOptions.noProjectReferences) {
155
+ if (initOptions.noProjectReferences) {
153
156
  host.getProjectReferences = undefined;
154
157
  host.getCompilationSettings = () => (Object.assign(Object.assign({}, parsedCommandLine.options), { rootDir: undefined, composite: false }));
155
158
  }
@@ -181,10 +184,10 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
181
184
  return script.snapshot;
182
185
  }
183
186
  if (sys.fileExists(fileName)) {
184
- if (serverOptions.maxFileSize) {
187
+ if (initOptions.maxFileSize) {
185
188
  const fileSize = (_a = sys.getFileSize) === null || _a === void 0 ? void 0 : _a.call(sys, fileName);
186
- if (fileSize !== undefined && fileSize > serverOptions.maxFileSize) {
187
- console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${serverOptions.maxFileSize}bytes)`);
189
+ if (fileSize !== undefined && fileSize > initOptions.maxFileSize) {
190
+ console.warn(`IGNORING "${fileName}" because it is too large (${fileSize}bytes > ${initOptions.maxFileSize}bytes)`);
188
191
  return ts.ScriptSnapshot.fromString('');
189
192
  }
190
193
  }
@@ -0,0 +1,8 @@
1
+ import * as vscode from 'vscode-languageserver';
2
+ import { LanguageServerPlugin, RuntimeEnvironment } from '../types';
3
+ export interface ServerParams {
4
+ connection: vscode.Connection;
5
+ runtimeEnv: RuntimeEnvironment;
6
+ plugins: LanguageServerPlugin[];
7
+ }
8
+ export declare function createCommonLanguageServer(params: ServerParams): void;