@volar/language-server 1.0.12 → 1.0.13

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/browser.js CHANGED
@@ -12,6 +12,15 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
12
12
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
13
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
14
  };
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
15
24
  Object.defineProperty(exports, "__esModule", { value: true });
16
25
  exports.createLanguageServer = void 0;
17
26
  const request_light_1 = require("request-light");
@@ -20,6 +29,7 @@ const vscode = require("vscode-languageserver/browser");
20
29
  const server_1 = require("./server");
21
30
  const http_1 = require("./schemaRequestHandlers/http");
22
31
  const webFileSystemHost_1 = require("./utils/webFileSystemHost");
32
+ const shared = require("@volar/shared");
23
33
  function createLanguageServer(plugins) {
24
34
  const messageReader = new vscode.BrowserMessageReader(self);
25
35
  const messageWriter = new vscode.BrowserMessageWriter(self);
@@ -28,8 +38,15 @@ function createLanguageServer(plugins) {
28
38
  loadTypescript() {
29
39
  return ts; // not support load by user config in web
30
40
  },
31
- loadTypescriptLocalized() {
32
- // TODO
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
+ });
33
50
  },
34
51
  schemaRequestHandlers: {
35
52
  http: http_1.default,
@@ -68,10 +68,8 @@ function register(connection, projects) {
68
68
  }));
69
69
  connection.onRequest(protocol_1.GetMatchTsConfigRequest.type, (params) => __awaiter(this, void 0, void 0, function* () {
70
70
  const project = (yield projects.getProject(params.uri));
71
- if (project) {
72
- return {
73
- fileName: project.tsconfig,
74
- };
71
+ if (project === null || project === void 0 ? void 0 : project.tsconfig) {
72
+ return { uri: shared.getUriByPath(project.tsconfig) };
75
73
  }
76
74
  }));
77
75
  connection.onRequest(protocol_1.GetVirtualFileNamesRequest.type, (document) => __awaiter(this, void 0, void 0, function* () {
package/out/node.js CHANGED
@@ -12,6 +12,15 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
12
12
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
13
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
14
  };
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
15
24
  Object.defineProperty(exports, "__esModule", { value: true });
16
25
  exports.createLanguageServer = void 0;
17
26
  const shared = require("@volar/shared");
@@ -36,11 +45,13 @@ function createLanguageServer(plugins) {
36
45
  }
37
46
  },
38
47
  loadTypescriptLocalized(tsdk, locale) {
39
- try {
40
- const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
41
- return require(path);
42
- }
43
- catch (_a) { }
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ try {
50
+ const path = require.resolve(`./${locale}/diagnosticMessages.generated.json`, { paths: [tsdk] });
51
+ return require(path);
52
+ }
53
+ catch (_a) { }
54
+ });
44
55
  },
45
56
  schemaRequestHandlers: {
46
57
  file: file_1.default,
package/out/protocol.d.ts CHANGED
@@ -9,6 +9,15 @@ export declare namespace ShowReferencesNotification {
9
9
  };
10
10
  const type: vscode.NotificationType<ResponseType>;
11
11
  }
12
+ export declare namespace FsStatRequest {
13
+ const type: vscode.RequestType<string, html.FileStat | null | undefined, unknown>;
14
+ }
15
+ export declare namespace FsReadFileRequest {
16
+ const type: vscode.RequestType<string, string | null | undefined, unknown>;
17
+ }
18
+ export declare namespace FsReadDirectoryRequest {
19
+ const type: vscode.RequestType<string, [string, html.FileType][], unknown>;
20
+ }
12
21
  /**
13
22
  * Client request server
14
23
  */
@@ -23,7 +32,7 @@ export declare namespace FindFileReferenceRequest {
23
32
  export declare namespace GetMatchTsConfigRequest {
24
33
  type ParamsType = vscode.TextDocumentIdentifier;
25
34
  type ResponseType = {
26
- fileName: string;
35
+ uri: string;
27
36
  } | null | undefined;
28
37
  type ErrorType = never;
29
38
  const type: vscode.RequestType<vscode.TextDocumentIdentifier, ResponseType, never>;
@@ -77,15 +86,3 @@ export declare namespace GetVirtualFileRequest {
77
86
  export declare namespace ReportStats {
78
87
  const type: vscode.NotificationType0;
79
88
  }
80
- /**
81
- * FS request for browser
82
- */
83
- export declare namespace FsStatRequest {
84
- const type: vscode.RequestType<string, html.FileStat | undefined, unknown>;
85
- }
86
- export declare namespace FsReadFileRequest {
87
- const type: vscode.RequestType<string, string | undefined, unknown>;
88
- }
89
- export declare namespace FsReadDirectoryRequest {
90
- const type: vscode.RequestType<string, [string, html.FileType][], unknown>;
91
- }
package/out/protocol.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.FsStatRequest = exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.VerifyAllScriptsNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.ShowReferencesNotification = void 0;
2
+ exports.ReportStats = exports.GetVirtualFileRequest = exports.GetVirtualFileNamesRequest = exports.ReloadProjectNotification = exports.WriteVirtualFilesNotification = exports.VerifyAllScriptsNotification = exports.AutoInsertRequest = exports.GetMatchTsConfigRequest = exports.FindFileReferenceRequest = exports.FsReadDirectoryRequest = exports.FsReadFileRequest = exports.FsStatRequest = exports.ShowReferencesNotification = void 0;
3
3
  const vscode = require("vscode-languageserver-protocol");
4
4
  /**
5
5
  * Server request client
@@ -8,6 +8,18 @@ var ShowReferencesNotification;
8
8
  (function (ShowReferencesNotification) {
9
9
  ShowReferencesNotification.type = new vscode.NotificationType('vue.findReferences');
10
10
  })(ShowReferencesNotification = exports.ShowReferencesNotification || (exports.ShowReferencesNotification = {}));
11
+ var FsStatRequest;
12
+ (function (FsStatRequest) {
13
+ FsStatRequest.type = new vscode.RequestType('fs/stat');
14
+ })(FsStatRequest = exports.FsStatRequest || (exports.FsStatRequest = {}));
15
+ var FsReadFileRequest;
16
+ (function (FsReadFileRequest) {
17
+ FsReadFileRequest.type = new vscode.RequestType('fs/readFile');
18
+ })(FsReadFileRequest = exports.FsReadFileRequest || (exports.FsReadFileRequest = {}));
19
+ var FsReadDirectoryRequest;
20
+ (function (FsReadDirectoryRequest) {
21
+ FsReadDirectoryRequest.type = new vscode.RequestType('fs/readDirectory');
22
+ })(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
11
23
  /**
12
24
  * Client request server
13
25
  */
@@ -47,19 +59,4 @@ var ReportStats;
47
59
  (function (ReportStats) {
48
60
  ReportStats.type = new vscode.NotificationType0('vue/stats');
49
61
  })(ReportStats = exports.ReportStats || (exports.ReportStats = {}));
50
- /**
51
- * FS request for browser
52
- */
53
- var FsStatRequest;
54
- (function (FsStatRequest) {
55
- FsStatRequest.type = new vscode.RequestType('fs/stat');
56
- })(FsStatRequest = exports.FsStatRequest || (exports.FsStatRequest = {}));
57
- var FsReadFileRequest;
58
- (function (FsReadFileRequest) {
59
- FsReadFileRequest.type = new vscode.RequestType('fs/readFile');
60
- })(FsReadFileRequest = exports.FsReadFileRequest || (exports.FsReadFileRequest = {}));
61
- var FsReadDirectoryRequest;
62
- (function (FsReadDirectoryRequest) {
63
- FsReadDirectoryRequest.type = new vscode.RequestType('fs/readDirectory');
64
- })(FsReadDirectoryRequest = exports.FsReadDirectoryRequest || (exports.FsReadDirectoryRequest = {}));
65
62
  //# sourceMappingURL=protocol.js.map
package/out/server.js CHANGED
@@ -126,7 +126,7 @@ function createCommonLanguageServer(connection, runtimeEnv, _plugins) {
126
126
  return __awaiter(this, void 0, void 0, function* () {
127
127
  const ts = runtimeEnv.loadTypescript(options.typescript.tsdk);
128
128
  fsHost = runtimeEnv.createFileSystemHost(ts, params.capabilities);
129
- const tsLocalized = params.locale ? runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, params.locale) : undefined;
129
+ const tsLocalized = params.locale ? yield runtimeEnv.loadTypescriptLocalized(options.typescript.tsdk, params.locale) : undefined;
130
130
  const cancelTokenHost = (0, cancellationPipe_1.createCancellationTokenHost)(options.cancellationPipeName);
131
131
  const _projects = (0, workspaces_1.createWorkspaces)(runtimeEnv, plugins, fsHost, configHost, ts, tsLocalized, params.capabilities, options, documents, connection, cancelTokenHost);
132
132
  projects = _projects;
package/out/types.d.ts CHANGED
@@ -11,12 +11,12 @@ export type FileSystemHost = {
11
11
  ready(connection: vscode.Connection): void;
12
12
  clearCache(): void;
13
13
  getWorkspaceFileSystem(rootUri: URI): FileSystem;
14
- onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams, reason: 'lsp' | 'web-cache-updated') => void): () => void;
14
+ onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams) => void): () => void;
15
15
  };
16
16
  export type FileSystem = Pick<ts.System, 'newLine' | 'useCaseSensitiveFileNames' | 'fileExists' | 'readFile' | 'readDirectory' | 'getCurrentDirectory' | 'realpath' | 'resolvePath'> & Partial<ts.System>;
17
17
  export interface RuntimeEnvironment {
18
18
  loadTypescript: (tsdk: string) => typeof import('typescript/lib/tsserverlibrary');
19
- loadTypescriptLocalized: (tsdk: string, locale: string) => any;
19
+ loadTypescriptLocalized: (tsdk: string, locale: string) => Promise<{} | undefined>;
20
20
  schemaRequestHandlers: {
21
21
  [schema: string]: (uri: string, encoding?: BufferEncoding) => Promise<string>;
22
22
  };
@@ -10,6 +10,7 @@ function loadCustomPlugins(dir) {
10
10
  try {
11
11
  if (configPath) {
12
12
  const config = require(configPath);
13
+ delete require.cache[configPath];
13
14
  return (_a = config.plugins) !== null && _a !== void 0 ? _a : [];
14
15
  }
15
16
  }
@@ -28,7 +28,7 @@ function createNodeFileSystemHost(ts, capabilities) {
28
28
  }
29
29
  for (const cb of [...onDidChangeWatchedFilesCb]) {
30
30
  if (onDidChangeWatchedFilesCb.has(cb)) {
31
- yield cb(params, 'lsp');
31
+ yield cb(params);
32
32
  }
33
33
  }
34
34
  }));
@@ -1,4 +1,3 @@
1
- import * as shared from '@volar/shared';
2
1
  import * as embeddedLS from '@volar/language-service';
3
2
  import type * as ts from 'typescript/lib/tsserverlibrary';
4
3
  import * as vscode from 'vscode-languageserver';
@@ -34,20 +33,20 @@ export declare function createProject(runtimeEnv: RuntimeEnvironment, plugins: R
34
33
  snapshot: ts.IScriptSnapshot | undefined;
35
34
  snapshotVersion: number | undefined;
36
35
  }) => void;
37
- pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
38
- pathGet: (rootUri: shared._2.URI, path: string) => {
36
+ pathDelete: (path: string) => boolean;
37
+ pathGet: (path: string) => {
39
38
  version: number;
40
39
  fileName: string;
41
40
  snapshot: ts.IScriptSnapshot | undefined;
42
41
  snapshotVersion: number | undefined;
43
42
  } | undefined;
44
- pathHas: (rootUri: shared._2.URI, path: string) => {
43
+ pathHas: (path: string) => {
45
44
  version: number;
46
45
  fileName: string;
47
46
  snapshot: ts.IScriptSnapshot | undefined;
48
47
  snapshotVersion: number | undefined;
49
48
  } | undefined;
50
- pathSet: (rootUri: shared._2.URI, path: string, item: {
49
+ pathSet: (path: string, item: {
51
50
  version: number;
52
51
  fileName: string;
53
52
  snapshot: ts.IScriptSnapshot | undefined;
@@ -138,7 +138,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
138
138
  }
139
139
  catch (_a) {
140
140
  // web
141
- return shared.getPathOfUri(serverOptions.typescript.tsdk + '/' + ts.getDefaultLibFileName(options));
141
+ return serverOptions.typescript.tsdk + '/' + ts.getDefaultLibFileName(options);
142
142
  }
143
143
  },
144
144
  getProjectVersion: () => projectVersion.toString(),
@@ -164,18 +164,18 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
164
164
  return host;
165
165
  function getScriptVersion(fileName) {
166
166
  var _a, _b;
167
- const doc = documents.data.pathGet(rootUri, fileName);
167
+ const doc = documents.data.pathGet(fileName);
168
168
  if (doc) {
169
169
  return doc.version.toString();
170
170
  }
171
- return (_b = (_a = scripts.pathGet(rootUri, fileName)) === null || _a === void 0 ? void 0 : _a.version.toString()) !== null && _b !== void 0 ? _b : '';
171
+ return (_b = (_a = scripts.pathGet(fileName)) === null || _a === void 0 ? void 0 : _a.version.toString()) !== null && _b !== void 0 ? _b : '';
172
172
  }
173
173
  function getScriptSnapshot(fileName) {
174
- const doc = documents.data.pathGet(rootUri, fileName);
174
+ const doc = documents.data.pathGet(fileName);
175
175
  if (doc) {
176
176
  return doc.getSnapshot();
177
177
  }
178
- const script = scripts.pathGet(rootUri, fileName);
178
+ const script = scripts.pathGet(fileName);
179
179
  if (script && script.snapshotVersion === script.version) {
180
180
  return script.snapshot;
181
181
  }
@@ -188,7 +188,7 @@ function createProject(runtimeEnv, plugins, fsHost, ts, rootUri, tsConfig, tsLoc
188
188
  script.snapshotVersion = script.version;
189
189
  }
190
190
  else {
191
- scripts.pathSet(rootUri, fileName, {
191
+ scripts.pathSet(fileName, {
192
192
  version: -1,
193
193
  fileName: fileName,
194
194
  snapshot: snapshot,
@@ -1,7 +1,6 @@
1
1
  import { TextDocument } from 'vscode-languageserver-textdocument';
2
2
  import * as vscode from 'vscode-languageserver';
3
3
  import type * as ts from 'typescript/lib/tsserverlibrary';
4
- import type * as _ from 'vscode-uri';
5
4
  interface IncrementalScriptSnapshotChange {
6
5
  applied: boolean;
7
6
  changeRange: ts.TextChangeRange | undefined;
@@ -33,10 +32,10 @@ export declare function createSnapshots(connection: vscode.Connection): {
33
32
  uriGet: (_uri: string) => IncrementalScriptSnapshot | undefined;
34
33
  uriHas: (_uri: string) => boolean;
35
34
  uriSet: (_uri: string, item: IncrementalScriptSnapshot) => void;
36
- pathDelete: (rootUri: _.URI, path: string) => boolean;
37
- pathGet: (rootUri: _.URI, path: string) => IncrementalScriptSnapshot | undefined;
38
- pathHas: (rootUri: _.URI, path: string) => IncrementalScriptSnapshot | undefined;
39
- pathSet: (rootUri: _.URI, path: string, item: IncrementalScriptSnapshot) => void;
35
+ pathDelete: (path: string) => boolean;
36
+ pathGet: (path: string) => IncrementalScriptSnapshot | undefined;
37
+ pathHas: (path: string) => IncrementalScriptSnapshot | undefined;
38
+ pathSet: (path: string, item: IncrementalScriptSnapshot) => void;
40
39
  };
41
40
  onDidChangeContent: (cb: (params: vscode.DidChangeTextDocumentParams) => void) => () => boolean;
42
41
  onDidClose: (cb: (params: vscode.DidCloseTextDocumentParams) => void) => () => boolean;
@@ -1,4 +1,3 @@
1
- import { URI } from 'vscode-uri';
2
1
  export * as _ from 'vscode-uri';
3
2
  interface Options<T> {
4
3
  delete(key: string): boolean;
@@ -15,8 +14,8 @@ export declare function createUriMap<T>(map?: Options<T>): {
15
14
  uriGet: (_uri: string) => T | undefined;
16
15
  uriHas: (_uri: string) => boolean;
17
16
  uriSet: (_uri: string, item: T) => void;
18
- pathDelete: (rootUri: URI, path: string) => boolean;
19
- pathGet: (rootUri: URI, path: string) => T | undefined;
20
- pathHas: (rootUri: URI, path: string) => T | undefined;
21
- pathSet: (rootUri: URI, path: string, item: T) => void;
17
+ pathDelete: (path: string) => boolean;
18
+ pathGet: (path: string) => T | undefined;
19
+ pathHas: (path: string) => T | undefined;
20
+ pathSet: (path: string, item: T) => void;
22
21
  };
@@ -4,8 +4,8 @@ const vscode_uri_1 = require("vscode-uri");
4
4
  const shared = require("@volar/shared");
5
5
  exports._ = require("vscode-uri");
6
6
  function createUriMap(map = new Map()) {
7
- const uriToUriKeys = new Map();
8
- const pathToUriKeys = new WeakMap();
7
+ const uriToUri = new Map();
8
+ const pathToUri = new Map();
9
9
  return {
10
10
  clear,
11
11
  values,
@@ -19,20 +19,15 @@ function createUriMap(map = new Map()) {
19
19
  pathSet,
20
20
  };
21
21
  function getUriByUri(uri) {
22
- if (!uriToUriKeys.has(uri))
23
- uriToUriKeys.set(uri, normalizeUri(uri).toLowerCase());
24
- return uriToUriKeys.get(uri);
22
+ if (!uriToUri.has(uri))
23
+ uriToUri.set(uri, normalizeUri(uri).toLowerCase());
24
+ return uriToUri.get(uri);
25
25
  }
26
- function getUriByPath(rootUri, path) {
27
- let map = pathToUriKeys.get(rootUri);
28
- if (!map) {
29
- map = new Map();
30
- pathToUriKeys.set(rootUri, map);
26
+ function getUriByPath(path) {
27
+ if (!pathToUri.has(path)) {
28
+ pathToUri.set(path, shared.getUriByPath(path).toLowerCase());
31
29
  }
32
- if (!map.has(path)) {
33
- map.set(path, shared.getUriByPath(path).toLowerCase());
34
- }
35
- return map.get(path);
30
+ return pathToUri.get(path);
36
31
  }
37
32
  function clear() {
38
33
  return map.clear();
@@ -52,17 +47,17 @@ function createUriMap(map = new Map()) {
52
47
  function uriSet(_uri, item) {
53
48
  return map.set(getUriByUri(_uri), item);
54
49
  }
55
- function pathDelete(rootUri, path) {
56
- return uriDelete(getUriByPath(rootUri, path));
50
+ function pathDelete(path) {
51
+ return uriDelete(getUriByPath(path));
57
52
  }
58
- function pathGet(rootUri, path) {
59
- return uriGet(getUriByPath(rootUri, path));
53
+ function pathGet(path) {
54
+ return uriGet(getUriByPath(path));
60
55
  }
61
- function pathHas(rootUri, path) {
62
- return uriGet(getUriByPath(rootUri, path));
56
+ function pathHas(path) {
57
+ return uriGet(getUriByPath(path));
63
58
  }
64
- function pathSet(rootUri, path, item) {
65
- return uriSet(getUriByPath(rootUri, path), item);
59
+ function pathSet(path, item) {
60
+ return uriSet(getUriByPath(path), item);
66
61
  }
67
62
  }
68
63
  exports.createUriMap = createUriMap;
@@ -12,6 +12,7 @@ exports.createWebFileSystemHost = void 0;
12
12
  const path = require("typesafe-path");
13
13
  const vscode_html_languageservice_1 = require("vscode-html-languageservice");
14
14
  const vscode = require("vscode-languageserver");
15
+ const vscode_uri_1 = require("vscode-uri");
15
16
  const protocol_1 = require("../protocol");
16
17
  const utilities_1 = require("./ts/utilities");
17
18
  const uriMap_1 = require("./uriMap");
@@ -26,10 +27,10 @@ function createWebFileSystemHost() {
26
27
  fileTypes: new Map(),
27
28
  searched: false,
28
29
  };
29
- const pendings = new Set();
30
+ const pendings = [];
30
31
  const changes = [];
31
32
  const onReadys = [];
32
- let checking = false;
33
+ let loading = false;
33
34
  let connection;
34
35
  return {
35
36
  ready(_connection) {
@@ -50,7 +51,7 @@ function createWebFileSystemHost() {
50
51
  dir.fileTexts.delete(name);
51
52
  }
52
53
  }
53
- fireChanges(params, 'lsp');
54
+ fireChanges(params);
54
55
  });
55
56
  for (const cb of onReadys) {
56
57
  cb(connection);
@@ -105,10 +106,10 @@ function createWebFileSystemHost() {
105
106
  }
106
107
  dir.fileTypes.set(name, undefined);
107
108
  if (connection) {
108
- addPending(statAsync(connection, fsPath, dir));
109
+ addPending('Stat', fsPath, statAsync(connection, fsPath, dir));
109
110
  }
110
111
  else {
111
- onReadys.push((connection) => addPending(statAsync(connection, fsPath, dir)));
112
+ onReadys.push((connection) => addPending('Stat', fsPath, statAsync(connection, fsPath, dir)));
112
113
  }
113
114
  return false;
114
115
  }
@@ -121,10 +122,10 @@ function createWebFileSystemHost() {
121
122
  }
122
123
  dir.fileTexts.set(name, '');
123
124
  if (connection) {
124
- addPending(readFileAsync(connection, fsPath, dir));
125
+ addPending('Read File', fsPath, readFileAsync(connection, fsPath, dir));
125
126
  }
126
127
  else {
127
- onReadys.push((connection) => addPending(readFileAsync(connection, fsPath, dir)));
128
+ onReadys.push((connection) => addPending('Read File', fsPath, readFileAsync(connection, fsPath, dir)));
128
129
  }
129
130
  return '';
130
131
  }
@@ -138,10 +139,10 @@ function createWebFileSystemHost() {
138
139
  if (!dir.searched) {
139
140
  dir.searched = true;
140
141
  if (connection) {
141
- addPending(readDirectoryAsync(connection, dirPath, dir));
142
+ addPending('Read Directory', dirPath, readDirectoryAsync(connection, dirPath, dir));
142
143
  }
143
144
  else {
144
- onReadys.push((connection) => addPending(readDirectoryAsync(connection, dirPath, dir)));
145
+ onReadys.push((connection) => addPending('Read Directory', dirPath, readDirectoryAsync(connection, dirPath, dir)));
145
146
  }
146
147
  }
147
148
  return {
@@ -158,10 +159,10 @@ function createWebFileSystemHost() {
158
159
  if (!dir.searched) {
159
160
  dir.searched = true;
160
161
  if (connection) {
161
- addPending(readDirectoryAsync(connection, fsPath, dir));
162
+ addPending('Read Directory', fsPath, readDirectoryAsync(connection, fsPath, dir));
162
163
  }
163
164
  else {
164
- onReadys.push((connection) => addPending(readDirectoryAsync(connection, fsPath, dir)));
165
+ onReadys.push((connection) => addPending('Read Directory', fsPath, readDirectoryAsync(connection, fsPath, dir)));
165
166
  }
166
167
  }
167
168
  return files.filter(file => file[1] === vscode_html_languageservice_1.FileType.Directory).map(file => file[0]);
@@ -169,28 +170,69 @@ function createWebFileSystemHost() {
169
170
  function statAsync(connection, fsPath, dir) {
170
171
  return __awaiter(this, void 0, void 0, function* () {
171
172
  const uri = shared.getUriByPath(fsPath);
172
- const result = yield connection.sendRequest(protocol_1.FsStatRequest.type, uri);
173
- if ((result === null || result === void 0 ? void 0 : result.type) === vscode_html_languageservice_1.FileType.File || (result === null || result === void 0 ? void 0 : result.type) === vscode_html_languageservice_1.FileType.SymbolicLink) {
174
- const name = path.basename(fsPath);
175
- dir.fileTypes.set(name, result.type);
176
- changes.push({
177
- uri: uri,
178
- type: vscode.FileChangeType.Created,
179
- });
173
+ if (uri.startsWith('https://cdn.jsdelivr.net/npm/')) { // stat request always response file type for jsdelivr
174
+ const text = yield readJsdelivrFile(connection, uri);
175
+ if (text !== undefined) {
176
+ const name = path.basename(fsPath);
177
+ dir.fileTypes.set(name, vscode_html_languageservice_1.FileType.File);
178
+ dir.fileTexts.set(name, text);
179
+ changes.push({
180
+ uri: uri,
181
+ type: vscode.FileChangeType.Created,
182
+ });
183
+ }
184
+ }
185
+ else {
186
+ const result = yield connection.sendRequest(protocol_1.FsStatRequest.type, uri);
187
+ if ((result === null || result === void 0 ? void 0 : result.type) === vscode_html_languageservice_1.FileType.File || (result === null || result === void 0 ? void 0 : result.type) === vscode_html_languageservice_1.FileType.SymbolicLink) {
188
+ const name = path.basename(fsPath);
189
+ dir.fileTypes.set(name, result.type);
190
+ changes.push({
191
+ uri: uri,
192
+ type: vscode.FileChangeType.Created,
193
+ });
194
+ }
180
195
  }
181
196
  });
182
197
  }
183
198
  function readFileAsync(connection, fsPath, dir) {
184
199
  return __awaiter(this, void 0, void 0, function* () {
185
200
  const uri = shared.getUriByPath(fsPath);
186
- const text = yield connection.sendRequest(protocol_1.FsReadFileRequest.type, uri);
187
- if (text) {
188
- const name = path.basename(fsPath);
189
- dir.fileTexts.set(name, text);
190
- changes.push({
191
- uri: uri,
192
- type: vscode.FileChangeType.Changed,
193
- });
201
+ if (uri.startsWith('https://cdn.jsdelivr.net/npm/')) {
202
+ const text = yield readJsdelivrFile(connection, uri);
203
+ if (text !== undefined) {
204
+ const name = path.basename(fsPath);
205
+ dir.fileTexts.set(name, text);
206
+ changes.push({
207
+ uri: uri,
208
+ type: vscode.FileChangeType.Changed,
209
+ });
210
+ }
211
+ }
212
+ else {
213
+ const text = yield connection.sendRequest(protocol_1.FsReadFileRequest.type, uri);
214
+ if (text) {
215
+ const name = path.basename(fsPath);
216
+ dir.fileTexts.set(name, text);
217
+ changes.push({
218
+ uri: uri,
219
+ type: vscode.FileChangeType.Changed,
220
+ });
221
+ }
222
+ }
223
+ });
224
+ }
225
+ function readJsdelivrFile(connection, uri) {
226
+ var _a;
227
+ return __awaiter(this, void 0, void 0, function* () {
228
+ // ignore .js because it's no help for intellisense
229
+ if (uri.endsWith('.d.ts') || uri.endsWith('.json')) {
230
+ const text = (_a = yield connection.sendRequest(protocol_1.FsReadFileRequest.type, uri)) !== null && _a !== void 0 ? _a : undefined;
231
+ if (text !== undefined
232
+ // ignore https://cdn.jsdelivr.net/npm/@vue/runtime-dom
233
+ && text.indexOf('Minified by jsDelivr') === -1) {
234
+ return text;
235
+ }
194
236
  }
195
237
  });
196
238
  }
@@ -210,29 +252,34 @@ function createWebFileSystemHost() {
210
252
  });
211
253
  }
212
254
  }
213
- function addPending(p) {
255
+ function addPending(action, fileName, p) {
214
256
  return __awaiter(this, void 0, void 0, function* () {
215
- pendings.add(p);
216
- if (checking === false) {
217
- checking = true;
218
- while (pendings.size > 0) {
219
- const _pendings = [...pendings];
220
- pendings.clear();
221
- yield Promise.all(_pendings);
257
+ pendings.push([action, fileName, p]);
258
+ if (loading === false) {
259
+ loading = true;
260
+ const progress = yield (connection === null || connection === void 0 ? void 0 : connection.window.createWorkDoneProgress());
261
+ progress === null || progress === void 0 ? void 0 : progress.begin(action);
262
+ let i = 0;
263
+ while (pendings.length) {
264
+ const current = pendings.shift();
265
+ progress === null || progress === void 0 ? void 0 : progress.report(i / pendings.length, vscode_uri_1.URI.parse(shared.getUriByPath(current[1])).fsPath);
266
+ yield current;
267
+ i++;
222
268
  }
269
+ progress === null || progress === void 0 ? void 0 : progress.done();
223
270
  if (changes.length) {
224
- fireChanges({ changes: [...changes] }, 'web-cache-updated');
271
+ fireChanges({ changes: [...changes] });
225
272
  changes.length = 0;
226
273
  }
227
- checking = false;
274
+ loading = false;
228
275
  }
229
276
  });
230
277
  }
231
- function fireChanges(params, reason) {
278
+ function fireChanges(params) {
232
279
  return __awaiter(this, void 0, void 0, function* () {
233
280
  for (const cb of [...onDidChangeWatchedFilesCb]) {
234
281
  if (onDidChangeWatchedFilesCb.has(cb)) {
235
- yield cb(params, reason);
282
+ yield cb(params);
236
283
  }
237
284
  }
238
285
  });
@@ -1,4 +1,3 @@
1
- import * as shared from '@volar/shared';
2
1
  import type * as ts from 'typescript/lib/tsserverlibrary';
3
2
  import * as path from 'typesafe-path';
4
3
  import * as vscode from 'vscode-languageserver';
@@ -17,10 +16,10 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
17
16
  uriGet: (_uri: string) => Project | undefined;
18
17
  uriHas: (_uri: string) => boolean;
19
18
  uriSet: (_uri: string, item: Project) => void;
20
- pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
21
- pathGet: (rootUri: shared._2.URI, path: string) => Project | undefined;
22
- pathHas: (rootUri: shared._2.URI, path: string) => Project | undefined;
23
- pathSet: (rootUri: shared._2.URI, path: string, item: Project) => void;
19
+ pathDelete: (path: string) => boolean;
20
+ pathGet: (path: string) => Project | undefined;
21
+ pathHas: (path: string) => Project | undefined;
22
+ pathSet: (path: string, item: Project) => void;
24
23
  };
25
24
  documentRegistry: ts.DocumentRegistry;
26
25
  getProjectAndTsConfig: (uri: string) => Promise<{
@@ -49,20 +48,20 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
49
48
  snapshot: ts.IScriptSnapshot | undefined;
50
49
  snapshotVersion: number | undefined;
51
50
  }) => void;
52
- pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
53
- pathGet: (rootUri: shared._2.URI, path: string) => {
51
+ pathDelete: (path: string) => boolean;
52
+ pathGet: (path: string) => {
54
53
  version: number;
55
54
  fileName: string;
56
55
  snapshot: ts.IScriptSnapshot | undefined;
57
56
  snapshotVersion: number | undefined;
58
57
  } | undefined;
59
- pathHas: (rootUri: shared._2.URI, path: string) => {
58
+ pathHas: (path: string) => {
60
59
  version: number;
61
60
  fileName: string;
62
61
  snapshot: ts.IScriptSnapshot | undefined;
63
62
  snapshotVersion: number | undefined;
64
63
  } | undefined;
65
- pathSet: (rootUri: shared._2.URI, path: string, item: {
64
+ pathSet: (path: string, item: {
66
65
  version: number;
67
66
  fileName: string;
68
67
  snapshot: ts.IScriptSnapshot | undefined;
@@ -160,4 +159,4 @@ export declare function createWorkspaceProjects(runtimeEnv: RuntimeEnvironment,
160
159
  reload: () => void;
161
160
  dispose(): void;
162
161
  }>;
163
- export declare function sortTsConfigs(fsPath: path.OsPath, a: path.OsPath, b: path.OsPath): number;
162
+ export declare function sortTsConfigs(file: path.PosixPath, a: path.PosixPath, b: path.PosixPath): number;
@@ -21,21 +21,21 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
21
21
  return __awaiter(this, void 0, void 0, function* () {
22
22
  let inferredProject;
23
23
  const sys = fsHost.getWorkspaceFileSystem(rootUri);
24
- const documentRegistry = ts.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.normalizeFileName(rootUri.fsPath));
24
+ const documentRegistry = ts.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.getPathOfUri(rootUri.toString()));
25
25
  const projects = (0, uriMap_1.createUriMap)();
26
- const rootTsConfigs = new Set(sys.readDirectory(rootUri.fsPath, exports.rootTsConfigNames, undefined, ['**/*']));
27
- const disposeWatch = fsHost.onDidChangeWatchedFiles((params, reason) => __awaiter(this, void 0, void 0, function* () {
26
+ const rootTsConfigs = new Set(sys.readDirectory(shared.getPathOfUri(rootUri.toString()), exports.rootTsConfigNames, undefined, ['**/*']).map(fileName => shared.normalizeFileName(fileName)));
27
+ const disposeWatch = fsHost.onDidChangeWatchedFiles((params) => __awaiter(this, void 0, void 0, function* () {
28
28
  const disposes = [];
29
29
  for (const change of params.changes) {
30
30
  if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
31
31
  if (change.type === vscode.FileChangeType.Created) {
32
- if (shared.isFileInDir(vscode_uri_1.URI.parse(change.uri).fsPath, rootUri.fsPath)) {
33
- rootTsConfigs.add(vscode_uri_1.URI.parse(change.uri).fsPath);
32
+ if (shared.isFileInDir(shared.getPathOfUri(change.uri), shared.getPathOfUri(rootUri.toString()))) {
33
+ rootTsConfigs.add(shared.getPathOfUri(change.uri));
34
34
  }
35
35
  }
36
36
  else if ((change.type === vscode.FileChangeType.Changed || change.type === vscode.FileChangeType.Deleted) && projects.uriHas(change.uri)) {
37
37
  if (change.type === vscode.FileChangeType.Deleted) {
38
- rootTsConfigs.delete(vscode_uri_1.URI.parse(change.uri).fsPath);
38
+ rootTsConfigs.delete(shared.getPathOfUri(change.uri));
39
39
  }
40
40
  const _project = projects.uriGet(change.uri);
41
41
  projects.uriDelete(change.uri);
@@ -46,9 +46,6 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
46
46
  }
47
47
  }
48
48
  }
49
- if (reason === 'web-cache-updated' && params.changes.some(change => change.uri.indexOf('/node_modules/') >= 0)) {
50
- clearProjects();
51
- }
52
49
  return Promise.all(disposes);
53
50
  }));
54
51
  return {
@@ -105,11 +102,11 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
105
102
  return __awaiter(this, void 0, void 0, function* () {
106
103
  let matches = [];
107
104
  for (const rootTsConfig of rootTsConfigs) {
108
- if (shared.isFileInDir(uri.fsPath, path.dirname(rootTsConfig))) {
105
+ if (shared.isFileInDir(shared.getPathOfUri(uri.toString()), path.dirname(rootTsConfig))) {
109
106
  matches.push(rootTsConfig);
110
107
  }
111
108
  }
112
- matches = matches.sort((a, b) => sortTsConfigs(uri.fsPath, a, b));
109
+ matches = matches.sort((a, b) => sortTsConfigs(shared.getPathOfUri(uri.toString()), a, b));
113
110
  if (matches.length) {
114
111
  yield getParsedCommandLine(matches[0]);
115
112
  }
@@ -117,16 +114,18 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
117
114
  }
118
115
  function findDirectIncludeTsconfig() {
119
116
  return findTsconfig((tsconfig) => __awaiter(this, void 0, void 0, function* () {
117
+ const map = (0, uriMap_1.createUriMap)();
120
118
  const parsedCommandLine = yield getParsedCommandLine(tsconfig);
121
- // use toLowerCase to fix https://github.com/johnsoncodehk/volar/issues/1125
122
- const fileNames = new Set(parsedCommandLine.fileNames.map(fileName => shared.normalizeFileName(fileName.toLowerCase())));
123
- return fileNames.has(shared.normalizeFileName(uri.fsPath.toLowerCase()));
119
+ for (const fileName of parsedCommandLine.fileNames) {
120
+ map.pathSet(fileName, true);
121
+ }
122
+ return map.uriHas(uri.toString());
124
123
  }));
125
124
  }
126
125
  function findIndirectReferenceTsconfig() {
127
126
  return findTsconfig((tsconfig) => __awaiter(this, void 0, void 0, function* () {
128
127
  var _a;
129
- const project = yield projects.pathGet(rootUri, tsconfig);
128
+ const project = yield projects.pathGet(tsconfig);
130
129
  const ls = project === null || project === void 0 ? void 0 : project.getLanguageServiceDontCreate();
131
130
  const validDoc = (_a = ls === null || ls === void 0 ? void 0 : ls.context.typescriptLanguageService.getProgram()) === null || _a === void 0 ? void 0 : _a.getSourceFile(shared.getPathOfUri(uri.toString()));
132
131
  return !!validDoc;
@@ -135,8 +134,8 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
135
134
  function findTsconfig(match) {
136
135
  return __awaiter(this, void 0, void 0, function* () {
137
136
  const checked = new Set();
138
- for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(uri.fsPath, a, b))) {
139
- const project = yield projects.pathGet(rootUri, rootTsConfig);
137
+ for (const rootTsConfig of [...rootTsConfigs].sort((a, b) => sortTsConfigs(shared.getPathOfUri(uri.toString()), a, b))) {
138
+ const project = yield projects.pathGet(rootTsConfig);
140
139
  if (project) {
141
140
  let chains = yield getReferencesChains(project.getParsedCommandLine(), rootTsConfig, []);
142
141
  if (serverOptions.reverseConfigFilePriority) {
@@ -203,26 +202,26 @@ function createWorkspaceProjects(runtimeEnv, plugins, fsHost, rootUri, ts, tsLoc
203
202
  }
204
203
  function getProjectByCreate(_tsConfig) {
205
204
  const tsConfig = shared.normalizeFileName(_tsConfig);
206
- let project = projects.pathGet(rootUri, tsConfig);
205
+ let project = projects.pathGet(tsConfig);
207
206
  if (!project) {
208
207
  project = (0, project_1.createProject)(runtimeEnv, plugins, fsHost, ts, vscode_uri_1.URI.parse(shared.getUriByPath(path.dirname(tsConfig))), tsConfig, tsLocalized, documents, configHost, documentRegistry, cancelTokenHost, serverOptions);
209
- projects.pathSet(rootUri, tsConfig, project);
208
+ projects.pathSet(tsConfig, project);
210
209
  }
211
210
  return project;
212
211
  }
213
212
  });
214
213
  }
215
214
  exports.createWorkspaceProjects = createWorkspaceProjects;
216
- function sortTsConfigs(fsPath, a, b) {
217
- const inA = shared.isFileInDir(fsPath, path.dirname(a));
218
- const inB = shared.isFileInDir(fsPath, path.dirname(b));
215
+ function sortTsConfigs(file, a, b) {
216
+ const inA = shared.isFileInDir(file, path.dirname(a));
217
+ const inB = shared.isFileInDir(file, path.dirname(b));
219
218
  if (inA !== inB) {
220
219
  const aWeight = inA ? 1 : 0;
221
220
  const bWeight = inB ? 1 : 0;
222
221
  return bWeight - aWeight;
223
222
  }
224
- const aLength = shared.normalizeFileName(a).split('/').length;
225
- const bLength = shared.normalizeFileName(b).split('/').length;
223
+ const aLength = a.split('/').length;
224
+ const bLength = b.split('/').length;
226
225
  if (aLength === bLength) {
227
226
  const aWeight = path.basename(a) === 'tsconfig.json' ? 1 : 0;
228
227
  const bWeight = path.basename(b) === 'tsconfig.json' ? 1 : 0;
@@ -1,11 +1,9 @@
1
- import * as shared from '@volar/shared';
2
1
  import { ConfigurationHost } from '@volar/language-service';
3
2
  import type * as ts from 'typescript/lib/tsserverlibrary';
4
3
  import * as vscode from 'vscode-languageserver';
5
4
  import { URI } from 'vscode-uri';
6
5
  import { FileSystemHost, LanguageServerPlugin, RuntimeEnvironment, LanguageServerInitializationOptions } from '../types';
7
6
  import { createSnapshots } from './snapshots';
8
- import * as path from 'typesafe-path';
9
7
  import { CancellationTokenHost } from './cancellationPipe';
10
8
  export interface Workspaces extends ReturnType<typeof createWorkspaces> {
11
9
  }
@@ -18,16 +16,16 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
18
16
  uriGet: (_uri: string) => import("./project").Project | undefined;
19
17
  uriHas: (_uri: string) => boolean;
20
18
  uriSet: (_uri: string, item: import("./project").Project) => void;
21
- pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
22
- pathGet: (rootUri: shared._2.URI, path: string) => import("./project").Project | undefined;
23
- pathHas: (rootUri: shared._2.URI, path: string) => import("./project").Project | undefined;
24
- pathSet: (rootUri: shared._2.URI, path: string, item: import("./project").Project) => void;
19
+ pathDelete: (path: string) => boolean;
20
+ pathGet: (path: string) => import("./project").Project | undefined;
21
+ pathHas: (path: string) => import("./project").Project | undefined;
22
+ pathSet: (path: string, item: import("./project").Project) => void;
25
23
  };
26
24
  documentRegistry: ts.DocumentRegistry;
27
25
  getProjectAndTsConfig: (uri: string) => Promise<{
28
26
  tsconfig: string;
29
27
  project: {
30
- tsConfig: path.PosixPath | ts.CompilerOptions;
28
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
31
29
  scripts: {
32
30
  clear: () => void;
33
31
  values: () => IterableIterator<{
@@ -50,20 +48,20 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
50
48
  snapshot: ts.IScriptSnapshot | undefined;
51
49
  snapshotVersion: number | undefined;
52
50
  }) => void;
53
- pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
54
- pathGet: (rootUri: shared._2.URI, path: string) => {
51
+ pathDelete: (path: string) => boolean;
52
+ pathGet: (path: string) => {
55
53
  version: number;
56
54
  fileName: string;
57
55
  snapshot: ts.IScriptSnapshot | undefined;
58
56
  snapshotVersion: number | undefined;
59
57
  } | undefined;
60
- pathHas: (rootUri: shared._2.URI, path: string) => {
58
+ pathHas: (path: string) => {
61
59
  version: number;
62
60
  fileName: string;
63
61
  snapshot: ts.IScriptSnapshot | undefined;
64
62
  snapshotVersion: number | undefined;
65
63
  } | undefined;
66
- pathSet: (rootUri: shared._2.URI, path: string, item: {
64
+ pathSet: (path: string, item: {
67
65
  version: number;
68
66
  fileName: string;
69
67
  snapshot: ts.IScriptSnapshot | undefined;
@@ -164,7 +162,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
164
162
  getProject: (uri: string) => Promise<{
165
163
  tsconfig: string;
166
164
  project: {
167
- tsConfig: path.PosixPath | ts.CompilerOptions;
165
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
168
166
  scripts: {
169
167
  clear: () => void;
170
168
  values: () => IterableIterator<{
@@ -187,20 +185,20 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
187
185
  snapshot: ts.IScriptSnapshot | undefined;
188
186
  snapshotVersion: number | undefined;
189
187
  }) => void;
190
- pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
191
- pathGet: (rootUri: shared._2.URI, path: string) => {
188
+ pathDelete: (path: string) => boolean;
189
+ pathGet: (path: string) => {
192
190
  version: number;
193
191
  fileName: string;
194
192
  snapshot: ts.IScriptSnapshot | undefined;
195
193
  snapshotVersion: number | undefined;
196
194
  } | undefined;
197
- pathHas: (rootUri: shared._2.URI, path: string) => {
195
+ pathHas: (path: string) => {
198
196
  version: number;
199
197
  fileName: string;
200
198
  snapshot: ts.IScriptSnapshot | undefined;
201
199
  snapshotVersion: number | undefined;
202
200
  } | undefined;
203
- pathSet: (rootUri: shared._2.URI, path: string, item: {
201
+ pathSet: (path: string, item: {
204
202
  version: number;
205
203
  fileName: string;
206
204
  snapshot: ts.IScriptSnapshot | undefined;
@@ -295,7 +293,7 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
295
293
  } | {
296
294
  tsconfig: undefined;
297
295
  project: {
298
- tsConfig: path.PosixPath | ts.CompilerOptions;
296
+ tsConfig: import("typesafe-path").PosixPath | ts.CompilerOptions;
299
297
  scripts: {
300
298
  clear: () => void;
301
299
  values: () => IterableIterator<{
@@ -318,20 +316,20 @@ export declare function createWorkspaces(runtimeEnv: RuntimeEnvironment, plugins
318
316
  snapshot: ts.IScriptSnapshot | undefined;
319
317
  snapshotVersion: number | undefined;
320
318
  }) => void;
321
- pathDelete: (rootUri: shared._2.URI, path: string) => boolean;
322
- pathGet: (rootUri: shared._2.URI, path: string) => {
319
+ pathDelete: (path: string) => boolean;
320
+ pathGet: (path: string) => {
323
321
  version: number;
324
322
  fileName: string;
325
323
  snapshot: ts.IScriptSnapshot | undefined;
326
324
  snapshotVersion: number | undefined;
327
325
  } | undefined;
328
- pathHas: (rootUri: shared._2.URI, path: string) => {
326
+ pathHas: (path: string) => {
329
327
  version: number;
330
328
  fileName: string;
331
329
  snapshot: ts.IScriptSnapshot | undefined;
332
330
  snapshotVersion: number | undefined;
333
331
  } | undefined;
334
- pathSet: (rootUri: shared._2.URI, path: string, item: {
332
+ pathSet: (path: string, item: {
335
333
  version: number;
336
334
  fileName: string;
337
335
  snapshot: ts.IScriptSnapshot | undefined;
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.createWorkspaces = void 0;
12
12
  const shared = require("@volar/shared");
13
13
  const vscode = require("vscode-languageserver");
14
- const vscode_uri_1 = require("vscode-uri");
15
14
  const types_1 = require("../types");
16
15
  const workspaceProjects_1 = require("./workspaceProjects");
17
16
  function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, tsLocalized, client, options, documents, connection, cancelTokenHost) {
@@ -141,9 +140,8 @@ function createWorkspaces(runtimeEnv, plugins, fsHost, configurationHost, ts, ts
141
140
  var _a;
142
141
  return __awaiter(this, void 0, void 0, function* () {
143
142
  const rootUris = [...workspaces.keys()]
144
- .filter(rootUri => vscode_uri_1.URI.parse(rootUri).scheme === vscode_uri_1.URI.parse(uri).scheme) // fix https://github.com/johnsoncodehk/volar/issues/1946#issuecomment-1272430742
145
- .filter(rootUri => shared.isFileInDir(vscode_uri_1.URI.parse(uri).fsPath, vscode_uri_1.URI.parse(rootUri).fsPath))
146
- .sort((a, b) => (0, workspaceProjects_1.sortTsConfigs)(vscode_uri_1.URI.parse(uri).fsPath, vscode_uri_1.URI.parse(a).fsPath, vscode_uri_1.URI.parse(b).fsPath));
143
+ .filter(rootUri => shared.isFileInDir(shared.getPathOfUri(uri), shared.getPathOfUri(rootUri)))
144
+ .sort((a, b) => (0, workspaceProjects_1.sortTsConfigs)(shared.getPathOfUri(uri), shared.getPathOfUri(a), shared.getPathOfUri(b)));
147
145
  for (const rootUri of rootUris) {
148
146
  const workspace = yield workspaces.get(rootUri);
149
147
  const project = yield (workspace === null || workspace === void 0 ? void 0 : workspace.getProjectAndTsConfig(uri));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,9 +17,9 @@
17
17
  "directory": "packages/language-server"
18
18
  },
19
19
  "dependencies": {
20
- "@volar/language-core": "1.0.12",
21
- "@volar/language-service": "1.0.12",
22
- "@volar/shared": "1.0.12",
20
+ "@volar/language-core": "1.0.13",
21
+ "@volar/language-service": "1.0.13",
22
+ "@volar/shared": "1.0.13",
23
23
  "request-light": "^0.6.0",
24
24
  "typesafe-path": "^0.2.2",
25
25
  "vscode-html-languageservice": "^5.0.3",
@@ -28,5 +28,5 @@
28
28
  "vscode-languageserver-textdocument": "^1.0.7",
29
29
  "vscode-uri": "^3.0.6"
30
30
  },
31
- "gitHead": "2426aa8ec6731a6f6d88086da7021a32d9306de3"
31
+ "gitHead": "cba2eba187b2d82e1d45dd86b3edeab0ca7caad6"
32
32
  }