@volar/language-server 1.1.0-alpha.1 → 1.2.0-alpha.1
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/fileSystems.js +7 -12
- package/out/common/project.d.ts +2 -2
- package/out/common/project.js +29 -35
- package/out/common/utils/serverConfig.d.ts +2 -5
- package/out/common/utils/serverConfig.js +3 -3
- package/out/common/workspace.js +1 -1
- package/out/common/workspaces.d.ts +1 -0
- package/out/types.d.ts +10 -5
- package/package.json +6 -6
|
@@ -170,8 +170,8 @@ function createWebFileSystemHost() {
|
|
|
170
170
|
function statAsync(connection, fsPath, dir) {
|
|
171
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
172
172
|
const uri = shared.fileNameToUri(fsPath);
|
|
173
|
-
if (uri.startsWith('https://
|
|
174
|
-
const text = yield
|
|
173
|
+
if (uri.startsWith('https://unpkg.com/')) { // stat request always response file type for jsdelivr
|
|
174
|
+
const text = yield readWebFile(connection, uri);
|
|
175
175
|
if (text !== undefined) {
|
|
176
176
|
const name = path.basename(fsPath);
|
|
177
177
|
dir.fileTypes.set(name, vscode_html_languageservice_1.FileType.File);
|
|
@@ -198,8 +198,8 @@ function createWebFileSystemHost() {
|
|
|
198
198
|
function readFileAsync(connection, fsPath, dir) {
|
|
199
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
200
|
const uri = shared.fileNameToUri(fsPath);
|
|
201
|
-
if (uri.startsWith('https://
|
|
202
|
-
const text = yield
|
|
201
|
+
if (uri.startsWith('https://unpkg.com/')) {
|
|
202
|
+
const text = yield readWebFile(connection, uri);
|
|
203
203
|
if (text !== undefined) {
|
|
204
204
|
const name = path.basename(fsPath);
|
|
205
205
|
dir.fileTexts.set(name, text);
|
|
@@ -222,17 +222,12 @@ function createWebFileSystemHost() {
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function readWebFile(connection, uri) {
|
|
226
226
|
var _a;
|
|
227
227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
228
|
// ignore .js because it's no help for intellisense
|
|
229
229
|
if (uri.endsWith('.d.ts') || uri.endsWith('.json')) {
|
|
230
|
-
|
|
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
|
-
}
|
|
230
|
+
return (_a = yield connection.sendRequest(protocol_1.FsReadFileRequest.type, uri)) !== null && _a !== void 0 ? _a : undefined;
|
|
236
231
|
}
|
|
237
232
|
});
|
|
238
233
|
}
|
|
@@ -263,7 +258,7 @@ function createWebFileSystemHost() {
|
|
|
263
258
|
while (pendings.length) {
|
|
264
259
|
const current = pendings.shift();
|
|
265
260
|
progress === null || progress === void 0 ? void 0 : progress.report(i / pendings.length, vscode_uri_1.URI.parse(shared.fileNameToUri(current[1])).fsPath);
|
|
266
|
-
yield current;
|
|
261
|
+
yield current[2];
|
|
267
262
|
i++;
|
|
268
263
|
}
|
|
269
264
|
progress === null || progress === void 0 ? void 0 : progress.done();
|
package/out/common/project.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as embedded from '@volar/language-core';
|
|
2
2
|
import * as embeddedLS from '@volar/language-service';
|
|
3
|
+
import { LanguageServiceConfig } from '@volar/language-service';
|
|
3
4
|
import * as path from 'typesafe-path';
|
|
4
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
5
6
|
import { URI } from 'vscode-uri';
|
|
6
7
|
import { WorkspaceContext } from './workspace';
|
|
7
|
-
import { ServerConfig } from './utils/serverConfig';
|
|
8
8
|
export interface ProjectContext {
|
|
9
9
|
workspace: WorkspaceContext;
|
|
10
10
|
rootUri: URI;
|
|
11
11
|
tsConfig: path.PosixPath | ts.CompilerOptions;
|
|
12
12
|
documentRegistry: ts.DocumentRegistry | undefined;
|
|
13
|
-
serverConfig:
|
|
13
|
+
serverConfig: LanguageServiceConfig | undefined;
|
|
14
14
|
}
|
|
15
15
|
export type Project = ReturnType<typeof createProject>;
|
|
16
16
|
export declare function createProject(context: ProjectContext): Promise<{
|
package/out/common/project.js
CHANGED
|
@@ -9,7 +9,6 @@ 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 embedded = require("@volar/language-core");
|
|
13
12
|
const embeddedLS = require("@volar/language-service");
|
|
14
13
|
const shared = require("@volar/shared");
|
|
15
14
|
const path = require("typesafe-path");
|
|
@@ -63,37 +62,37 @@ function createProject(context) {
|
|
|
63
62
|
dispose,
|
|
64
63
|
};
|
|
65
64
|
function getLanguageService() {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
66
|
if (!languageService) {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
const config = {
|
|
68
|
+
languages: Object.assign({}, (_b = (_a = context.serverConfig) === null || _a === void 0 ? void 0 : _a.languages) !== null && _b !== void 0 ? _b : {}),
|
|
69
|
+
plugins: Object.assign({}, (_d = (_c = context.serverConfig) === null || _c === void 0 ? void 0 : _c.plugins) !== null && _d !== void 0 ? _d : {}),
|
|
70
|
+
rules: Object.assign({}, (_e = context.serverConfig) === null || _e === void 0 ? void 0 : _e.rules),
|
|
71
|
+
};
|
|
72
|
+
const env = {
|
|
73
|
+
rootUri: context.rootUri,
|
|
74
|
+
configurationHost: context.workspace.workspaces.configurationHost,
|
|
75
|
+
fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
|
|
76
|
+
documentContext: getDocumentContext(context.workspace.workspaces.ts, languageServiceHost, context.rootUri.toString()),
|
|
77
|
+
schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const protocol = uri.substring(0, uri.indexOf(':'));
|
|
79
|
+
const builtInHandler = context.workspace.workspaces.server.runtimeEnv.schemaRequestHandlers[protocol];
|
|
80
|
+
if (builtInHandler) {
|
|
81
|
+
return yield builtInHandler(uri);
|
|
82
|
+
}
|
|
83
|
+
return '';
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
const lsCtx = {
|
|
87
|
+
project: context,
|
|
88
|
+
env,
|
|
89
|
+
sys,
|
|
70
90
|
host: languageServiceHost,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
...context.workspace.workspaces.plugins.map(plugin => { var _a, _b; return (_b = (_a = plugin.getLanguageServicePlugins) === null || _a === void 0 ? void 0 : _a.call(plugin, languageServiceHost, languageServiceContext)) !== null && _b !== void 0 ? _b : []; }).flat(),
|
|
77
|
-
];
|
|
78
|
-
},
|
|
79
|
-
env: {
|
|
80
|
-
rootUri: context.rootUri,
|
|
81
|
-
configurationHost: context.workspace.workspaces.configurationHost,
|
|
82
|
-
fileSystemProvider: context.workspace.workspaces.server.runtimeEnv.fileSystemProvide,
|
|
83
|
-
documentContext: getDocumentContext(context.workspace.workspaces.ts, languageServiceHost, context.rootUri.toString()),
|
|
84
|
-
schemaRequestService: (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const protocol = uri.substring(0, uri.indexOf(':'));
|
|
86
|
-
const builtInHandler = context.workspace.workspaces.server.runtimeEnv.schemaRequestHandlers[protocol];
|
|
87
|
-
if (builtInHandler) {
|
|
88
|
-
return yield builtInHandler(uri);
|
|
89
|
-
}
|
|
90
|
-
return '';
|
|
91
|
-
}),
|
|
92
|
-
},
|
|
93
|
-
documentRegistry: context.documentRegistry,
|
|
94
|
-
getLanguageService: () => languageService,
|
|
95
|
-
});
|
|
96
|
-
languageService = embeddedLS.createLanguageService(languageServiceContext);
|
|
91
|
+
};
|
|
92
|
+
for (const plugin of context.workspace.workspaces.plugins) {
|
|
93
|
+
(_f = plugin.resolveConfig) === null || _f === void 0 ? void 0 : _f.call(plugin, config, lsCtx);
|
|
94
|
+
}
|
|
95
|
+
languageService = embeddedLS.createLanguageService(languageServiceHost, config, env, context.documentRegistry);
|
|
97
96
|
}
|
|
98
97
|
return languageService;
|
|
99
98
|
}
|
|
@@ -184,11 +183,6 @@ function createProject(context) {
|
|
|
184
183
|
if (context.workspace.workspaces.tsLocalized) {
|
|
185
184
|
host.getLocalizedDiagnosticMessages = () => context.workspace.workspaces.tsLocalized;
|
|
186
185
|
}
|
|
187
|
-
for (const plugin of context.workspace.workspaces.plugins) {
|
|
188
|
-
if (context.workspace.workspaces.ts && plugin.resolveLanguageServiceHost) {
|
|
189
|
-
host = plugin.resolveLanguageServiceHost(context.workspace.workspaces.ts, sys, context.tsConfig, host);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
186
|
return host;
|
|
193
187
|
function getScriptVersion(fileName) {
|
|
194
188
|
var _a, _b;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
plugins?: LanguageServicePlugin[];
|
|
4
|
-
}
|
|
5
|
-
export declare function loadServerConfig(dir: string, configFile: string | undefined): ServerConfig | undefined;
|
|
1
|
+
import { LanguageServiceConfig } from "@volar/language-service";
|
|
2
|
+
export declare function loadConfig(dir: string, configFile: string | undefined): LanguageServiceConfig | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
-
function
|
|
2
|
+
exports.loadConfig = void 0;
|
|
3
|
+
function loadConfig(dir, configFile) {
|
|
4
4
|
let configPath;
|
|
5
5
|
try {
|
|
6
6
|
configPath = require.resolve(configFile !== null && configFile !== void 0 ? configFile : './volar.config.js', { paths: [dir] });
|
|
@@ -17,5 +17,5 @@ function loadServerConfig(dir, configFile) {
|
|
|
17
17
|
console.log(err);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
exports.
|
|
20
|
+
exports.loadConfig = loadConfig;
|
|
21
21
|
//# sourceMappingURL=serverConfig.js.map
|
package/out/common/workspace.js
CHANGED
|
@@ -23,7 +23,7 @@ function createWorkspace(context) {
|
|
|
23
23
|
var _a, _b, _c;
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
let inferredProject;
|
|
26
|
-
const serverConfig = (0, serverConfig_1.
|
|
26
|
+
const serverConfig = (0, serverConfig_1.loadConfig)(shared.uriToFileName(context.rootUri.toString()), context.workspaces.initOptions.configFilePath);
|
|
27
27
|
const sys = (_a = context.workspaces.fileSystemHost) === null || _a === void 0 ? void 0 : _a.getWorkspaceFileSystem(context.rootUri);
|
|
28
28
|
const documentRegistry = sys ? (_b = context.workspaces.ts) === null || _b === void 0 ? void 0 : _b.createDocumentRegistry(sys.useCaseSensitiveFileNames, shared.uriToFileName(context.rootUri.toString())) : undefined;
|
|
29
29
|
const projects = (0, uriMap_1.createUriMap)();
|
package/out/types.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import type { FileSystemProvider } from 'vscode-html-languageservice';
|
|
|
5
5
|
import type * as ts from 'typescript/lib/tsserverlibrary';
|
|
6
6
|
import * as vscode from 'vscode-languageserver';
|
|
7
7
|
import { URI } from 'vscode-uri';
|
|
8
|
-
import { LanguageServiceRuntimeContext } from '@volar/language-service';
|
|
8
|
+
import { LanguageServiceConfig, LanguageServiceRuntimeContext } from '@volar/language-service';
|
|
9
|
+
import { ProjectContext } from './common/project';
|
|
9
10
|
export type FileSystemHost = {
|
|
10
11
|
ready(connection: vscode.Connection): void;
|
|
11
12
|
reload(): void;
|
|
@@ -26,16 +27,20 @@ export interface RuntimeEnvironment {
|
|
|
26
27
|
setImmediate(callback: (...args: any[]) => void, ...args: any[]): vscode.Disposable;
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
export
|
|
30
|
+
export interface LanguageServiceContext {
|
|
31
|
+
project: ProjectContext;
|
|
32
|
+
env: LanguageServiceRuntimeContext['env'];
|
|
33
|
+
host: embedded.LanguageServiceHost;
|
|
34
|
+
sys: FileSystem;
|
|
35
|
+
}
|
|
36
|
+
export type LanguageServerPlugin<A extends LanguageServerInitializationOptions = LanguageServerInitializationOptions, C = embeddedLS.LanguageService> = (initOptions: A) => {
|
|
30
37
|
tsconfigExtraFileExtensions: ts.FileExtensionInfo[];
|
|
31
38
|
diagnosticDocumentSelector: vscode.DocumentSelector;
|
|
32
39
|
extensions: {
|
|
33
40
|
fileRenameOperationFilter: string[];
|
|
34
41
|
fileWatcher: string[];
|
|
35
42
|
};
|
|
36
|
-
|
|
37
|
-
getLanguageModules?(host: B): embedded.LanguageModule[];
|
|
38
|
-
getLanguageServicePlugins?(host: B, context: LanguageServiceRuntimeContext): embeddedLS.LanguageServicePlugin[];
|
|
43
|
+
resolveConfig?(config: LanguageServiceConfig, ctx: LanguageServiceContext): void;
|
|
39
44
|
onInitialize?(_: vscode.InitializeResult): void;
|
|
40
45
|
onInitialized?(getLanguageService: (uri: string) => Promise<C>): void;
|
|
41
46
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-alpha.1",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
],
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/volarjs/
|
|
16
|
+
"url": "https://github.com/volarjs/volar.js.git",
|
|
17
17
|
"directory": "packages/language-server"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@volar/language-core": "1.
|
|
21
|
-
"@volar/language-service": "1.
|
|
22
|
-
"@volar/shared": "1.
|
|
20
|
+
"@volar/language-core": "1.2.0-alpha.1",
|
|
21
|
+
"@volar/language-service": "1.2.0-alpha.1",
|
|
22
|
+
"@volar/shared": "1.2.0-alpha.1",
|
|
23
23
|
"@vscode/l10n": "^0.0.10",
|
|
24
24
|
"request-light": "^0.6.0",
|
|
25
25
|
"typesafe-path": "^0.2.2",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
30
30
|
"vscode-uri": "^3.0.7"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "08f0fd7c8a0ac7ba92de978c3ee7338d1919ebd7"
|
|
33
33
|
}
|