@volar/language-server 1.7.7 → 1.7.8

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.
@@ -13,7 +13,7 @@ export interface ProjectContext extends WorkspaceContext {
13
13
  export type Project = ReturnType<typeof createProject>;
14
14
  export declare function createProject(context: ProjectContext): Promise<{
15
15
  context: ProjectContext;
16
- tsConfig: path.PosixPath | ts.CompilerOptions;
16
+ tsConfig: ts.CompilerOptions | path.PosixPath;
17
17
  scripts: {
18
18
  clear: () => void;
19
19
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -106,7 +106,7 @@ async function createProject(context) {
106
106
  let dirty = false;
107
107
  for (const fileName of parsedCommandLine.fileNames) {
108
108
  const uri = fileNameToUri(fileName);
109
- if (!fsScriptsCache.uriHas(uri)) {
109
+ if (!fsScriptsCache.uriGet(uri)) {
110
110
  dirty = true;
111
111
  promises.push(updateRootScriptSnapshot(uri));
112
112
  }
@@ -14,7 +14,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
14
14
  clear: () => void;
15
15
  values: () => IterableIterator<Promise<{
16
16
  context: import("./project").ProjectContext;
17
- tsConfig: path.PosixPath | ts.CompilerOptions;
17
+ tsConfig: ts.CompilerOptions | path.PosixPath;
18
18
  scripts: {
19
19
  clear: () => void;
20
20
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -153,7 +153,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
153
153
  uriDelete: (_uri: string) => boolean;
154
154
  uriGet: (_uri: string) => Promise<{
155
155
  context: import("./project").ProjectContext;
156
- tsConfig: path.PosixPath | ts.CompilerOptions;
156
+ tsConfig: ts.CompilerOptions | path.PosixPath;
157
157
  scripts: {
158
158
  clear: () => void;
159
159
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -292,7 +292,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
292
292
  uriHas: (_uri: string) => boolean;
293
293
  uriSet: (_uri: string, item: Promise<{
294
294
  context: import("./project").ProjectContext;
295
- tsConfig: path.PosixPath | ts.CompilerOptions;
295
+ tsConfig: ts.CompilerOptions | path.PosixPath;
296
296
  scripts: {
297
297
  clear: () => void;
298
298
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -431,7 +431,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
431
431
  pathDelete: (path: string) => boolean;
432
432
  pathGet: (path: string) => Promise<{
433
433
  context: import("./project").ProjectContext;
434
- tsConfig: path.PosixPath | ts.CompilerOptions;
434
+ tsConfig: ts.CompilerOptions | path.PosixPath;
435
435
  scripts: {
436
436
  clear: () => void;
437
437
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -569,7 +569,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
569
569
  }> | undefined;
570
570
  pathHas: (path: string) => Promise<{
571
571
  context: import("./project").ProjectContext;
572
- tsConfig: path.PosixPath | ts.CompilerOptions;
572
+ tsConfig: ts.CompilerOptions | path.PosixPath;
573
573
  scripts: {
574
574
  clear: () => void;
575
575
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -707,7 +707,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
707
707
  }> | undefined;
708
708
  pathSet: (path: string, item: Promise<{
709
709
  context: import("./project").ProjectContext;
710
- tsConfig: path.PosixPath | ts.CompilerOptions;
710
+ tsConfig: ts.CompilerOptions | path.PosixPath;
711
711
  scripts: {
712
712
  clear: () => void;
713
713
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -848,7 +848,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
848
848
  tsconfig: string;
849
849
  project: {
850
850
  context: import("./project").ProjectContext;
851
- tsConfig: path.PosixPath | ts.CompilerOptions;
851
+ tsConfig: ts.CompilerOptions | path.PosixPath;
852
852
  scripts: {
853
853
  clear: () => void;
854
854
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -987,7 +987,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
987
987
  } | undefined>;
988
988
  getInferredProject: () => Promise<{
989
989
  context: import("./project").ProjectContext;
990
- tsConfig: path.PosixPath | ts.CompilerOptions;
990
+ tsConfig: ts.CompilerOptions | path.PosixPath;
991
991
  scripts: {
992
992
  clear: () => void;
993
993
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -1125,7 +1125,7 @@ export declare function createWorkspace(context: WorkspaceContext): Promise<{
1125
1125
  }>;
1126
1126
  getInferredProjectDontCreate: () => Promise<{
1127
1127
  context: import("./project").ProjectContext;
1128
- tsConfig: path.PosixPath | ts.CompilerOptions;
1128
+ tsConfig: ts.CompilerOptions | path.PosixPath;
1129
1129
  scripts: {
1130
1130
  clear: () => void;
1131
1131
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -25,7 +25,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
25
25
  clear: () => void;
26
26
  values: () => IterableIterator<Promise<{
27
27
  context: import("./project").ProjectContext;
28
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
28
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
29
29
  scripts: {
30
30
  clear: () => void;
31
31
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -164,7 +164,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
164
164
  uriDelete: (_uri: string) => boolean;
165
165
  uriGet: (_uri: string) => Promise<{
166
166
  context: import("./project").ProjectContext;
167
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
167
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
168
168
  scripts: {
169
169
  clear: () => void;
170
170
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -303,7 +303,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
303
303
  uriHas: (_uri: string) => boolean;
304
304
  uriSet: (_uri: string, item: Promise<{
305
305
  context: import("./project").ProjectContext;
306
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
306
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
307
307
  scripts: {
308
308
  clear: () => void;
309
309
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -442,7 +442,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
442
442
  pathDelete: (path: string) => boolean;
443
443
  pathGet: (path: string) => Promise<{
444
444
  context: import("./project").ProjectContext;
445
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
445
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
446
446
  scripts: {
447
447
  clear: () => void;
448
448
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -580,7 +580,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
580
580
  }> | undefined;
581
581
  pathHas: (path: string) => Promise<{
582
582
  context: import("./project").ProjectContext;
583
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
583
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
584
584
  scripts: {
585
585
  clear: () => void;
586
586
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -718,7 +718,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
718
718
  }> | undefined;
719
719
  pathSet: (path: string, item: Promise<{
720
720
  context: import("./project").ProjectContext;
721
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
721
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
722
722
  scripts: {
723
723
  clear: () => void;
724
724
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -859,7 +859,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
859
859
  tsconfig: string;
860
860
  project: {
861
861
  context: import("./project").ProjectContext;
862
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
862
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
863
863
  scripts: {
864
864
  clear: () => void;
865
865
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -998,7 +998,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
998
998
  } | undefined>;
999
999
  getInferredProject: () => Promise<{
1000
1000
  context: import("./project").ProjectContext;
1001
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
1001
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
1002
1002
  scripts: {
1003
1003
  clear: () => void;
1004
1004
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -1136,7 +1136,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
1136
1136
  }>;
1137
1137
  getInferredProjectDontCreate: () => Promise<{
1138
1138
  context: import("./project").ProjectContext;
1139
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
1139
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
1140
1140
  scripts: {
1141
1141
  clear: () => void;
1142
1142
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -1279,7 +1279,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
1279
1279
  tsconfig: string;
1280
1280
  project: {
1281
1281
  context: import("./project").ProjectContext;
1282
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
1282
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
1283
1283
  scripts: {
1284
1284
  clear: () => void;
1285
1285
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
@@ -1419,7 +1419,7 @@ export declare function createWorkspaces(context: WorkspacesContext): {
1419
1419
  tsconfig: undefined;
1420
1420
  project: {
1421
1421
  context: import("./project").ProjectContext;
1422
- tsConfig: import("typesafe-path/posix").PosixPath | ts.CompilerOptions;
1422
+ tsConfig: ts.CompilerOptions | import("typesafe-path/posix").PosixPath;
1423
1423
  scripts: {
1424
1424
  clear: () => void;
1425
1425
  values: () => IterableIterator<ts.IScriptSnapshot | undefined>;
File without changes
package/out/node/fs.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=fs.js.map
@@ -1,5 +1,9 @@
1
1
  import * as vscode from 'vscode-languageserver/node';
2
- import { LanguageServerPlugin } from '../types';
2
+ import { InitializationOptions, LanguageServerPlugin } from '../types';
3
+ import { FileSystem } from '@volar/language-service';
3
4
  export * from '../index';
5
+ export declare const uriToFileName: (uri: string) => string;
6
+ export declare const fileNameToUri: (fileName: string) => string;
7
+ export declare function createFs(options: InitializationOptions): FileSystem;
4
8
  export declare function createConnection(): vscode._Connection<vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, vscode._, vscode._>;
5
9
  export declare function startLanguageServer(connection: vscode.Connection, ...plugins: LanguageServerPlugin[]): void;
package/out/node/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.startLanguageServer = exports.createConnection = void 0;
17
+ exports.startLanguageServer = exports.createConnection = exports.createFs = exports.fileNameToUri = exports.uriToFileName = void 0;
18
18
  const fs = require("fs");
19
19
  const vscode = require("vscode-languageserver/node");
20
20
  const vscode_uri_1 = require("vscode-uri");
@@ -22,16 +22,82 @@ const http_1 = require("../common/schemaRequestHandlers/http");
22
22
  const server_1 = require("../common/server");
23
23
  const language_service_1 = require("@volar/language-service");
24
24
  __exportStar(require("../index"), exports);
25
+ const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
26
+ exports.uriToFileName = uriToFileName;
27
+ const fileNameToUri = (fileName) => vscode_uri_1.URI.file(fileName).toString();
28
+ exports.fileNameToUri = fileNameToUri;
29
+ function createFs(options) {
30
+ return {
31
+ stat(uri) {
32
+ if (uri.startsWith('file://')) {
33
+ try {
34
+ const stats = fs.statSync((0, exports.uriToFileName)(uri), { throwIfNoEntry: false });
35
+ if (stats) {
36
+ return {
37
+ type: stats.isFile() ? language_service_1.FileType.File
38
+ : stats.isDirectory() ? language_service_1.FileType.Directory
39
+ : stats.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
40
+ : language_service_1.FileType.Unknown,
41
+ ctime: stats.ctimeMs,
42
+ mtime: stats.mtimeMs,
43
+ size: stats.size,
44
+ };
45
+ }
46
+ }
47
+ catch {
48
+ return undefined;
49
+ }
50
+ }
51
+ },
52
+ readFile(uri, encoding) {
53
+ if (uri.startsWith('file://')) {
54
+ try {
55
+ if (options.maxFileSize) {
56
+ const stats = fs.statSync((0, exports.uriToFileName)(uri), { throwIfNoEntry: false });
57
+ if (stats && stats.size > options.maxFileSize) {
58
+ console.warn(`[volar] file size exceeded limit: ${uri} (${stats.size} > ${options.maxFileSize})`);
59
+ return undefined;
60
+ }
61
+ }
62
+ return fs.readFileSync((0, exports.uriToFileName)(uri), { encoding: encoding ?? 'utf-8' });
63
+ }
64
+ catch {
65
+ return undefined;
66
+ }
67
+ }
68
+ if (uri.startsWith('http://') || uri.startsWith('https://')) {
69
+ return (0, http_1.default)(uri);
70
+ }
71
+ },
72
+ readDirectory(uri) {
73
+ if (uri.startsWith('file://')) {
74
+ try {
75
+ const dirName = (0, exports.uriToFileName)(uri);
76
+ const files = fs.readdirSync(dirName, { withFileTypes: true });
77
+ return files.map(file => {
78
+ return [file.name, file.isFile() ? language_service_1.FileType.File
79
+ : file.isDirectory() ? language_service_1.FileType.Directory
80
+ : file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
81
+ : language_service_1.FileType.Unknown];
82
+ });
83
+ }
84
+ catch {
85
+ return [];
86
+ }
87
+ }
88
+ return [];
89
+ },
90
+ };
91
+ }
92
+ exports.createFs = createFs;
25
93
  function createConnection() {
26
94
  return vscode.createConnection(vscode.ProposedFeatures.all);
27
95
  }
28
96
  exports.createConnection = createConnection;
29
97
  function startLanguageServer(connection, ...plugins) {
30
- const uriToFileName = (uri) => vscode_uri_1.URI.parse(uri).fsPath.replace(/\\/g, '/');
31
- const fileNameToUri = (fileName) => vscode_uri_1.URI.file(fileName).toString();
32
98
  (0, server_1.startCommonLanguageServer)(connection, plugins, (_, options) => ({
33
- uriToFileName,
34
- fileNameToUri,
99
+ uriToFileName: exports.uriToFileName,
100
+ fileNameToUri: exports.fileNameToUri,
35
101
  timer: {
36
102
  setImmediate(callback, ...args) {
37
103
  const handle = setImmediate(callback, ...args);
@@ -61,67 +127,7 @@ function startLanguageServer(connection, ...plugins) {
61
127
  }
62
128
  catch { }
63
129
  },
64
- fs: {
65
- stat(uri) {
66
- if (uri.startsWith('file://')) {
67
- try {
68
- const stats = fs.statSync(uriToFileName(uri), { throwIfNoEntry: false });
69
- if (stats) {
70
- return {
71
- type: stats.isFile() ? language_service_1.FileType.File
72
- : stats.isDirectory() ? language_service_1.FileType.Directory
73
- : stats.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
74
- : language_service_1.FileType.Unknown,
75
- ctime: stats.ctimeMs,
76
- mtime: stats.mtimeMs,
77
- size: stats.size,
78
- };
79
- }
80
- }
81
- catch {
82
- return undefined;
83
- }
84
- }
85
- },
86
- readFile(uri, encoding) {
87
- if (uri.startsWith('file://')) {
88
- try {
89
- if (options.maxFileSize) {
90
- const stats = fs.statSync(uriToFileName(uri), { throwIfNoEntry: false });
91
- if (stats && stats.size > options.maxFileSize) {
92
- console.warn(`[volar] file size exceeded limit: ${uri} (${stats.size} > ${options.maxFileSize})`);
93
- return undefined;
94
- }
95
- }
96
- return fs.readFileSync(uriToFileName(uri), { encoding: encoding ?? 'utf-8' });
97
- }
98
- catch {
99
- return undefined;
100
- }
101
- }
102
- if (uri.startsWith('http://') || uri.startsWith('https://')) {
103
- return (0, http_1.default)(uri);
104
- }
105
- },
106
- readDirectory(uri) {
107
- if (uri.startsWith('file://')) {
108
- try {
109
- const dirName = uriToFileName(uri);
110
- const files = fs.readdirSync(dirName, { withFileTypes: true });
111
- return files.map(file => {
112
- return [file.name, file.isFile() ? language_service_1.FileType.File
113
- : file.isDirectory() ? language_service_1.FileType.Directory
114
- : file.isSymbolicLink() ? language_service_1.FileType.SymbolicLink
115
- : language_service_1.FileType.Unknown];
116
- });
117
- }
118
- catch {
119
- return [];
120
- }
121
- }
122
- return [];
123
- },
124
- },
130
+ fs: createFs(options),
125
131
  }));
126
132
  }
127
133
  exports.startLanguageServer = startLanguageServer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/language-server",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -15,9 +15,9 @@
15
15
  "directory": "packages/language-server"
16
16
  },
17
17
  "dependencies": {
18
- "@volar/language-core": "1.7.7",
19
- "@volar/language-service": "1.7.7",
20
- "@volar/typescript": "1.7.7",
18
+ "@volar/language-core": "1.7.8",
19
+ "@volar/language-service": "1.7.8",
20
+ "@volar/typescript": "1.7.8",
21
21
  "@vscode/l10n": "^0.0.11",
22
22
  "request-light": "^0.7.0",
23
23
  "typesafe-path": "^0.2.2",
@@ -27,7 +27,7 @@
27
27
  "vscode-uri": "^3.0.7"
28
28
  },
29
29
  "devDependencies": {
30
- "@volar/source-map": "1.7.7"
30
+ "@volar/source-map": "1.7.8"
31
31
  },
32
- "gitHead": "ad13290da9f223f6d198d858faf5349933112200"
32
+ "gitHead": "e7c1b16e5c78702de6986eafa17ae96000ffe0cb"
33
33
  }