@master/css-language-server 2.0.0-rc.3 → 2.0.0-rc.30
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/dist/core.cjs +152 -0
- package/dist/core.d.ts +21 -0
- package/dist/core.mjs +150 -0
- package/dist/index.cjs +12 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/settings.cjs +10 -0
- package/dist/settings.d.ts +6 -0
- package/dist/settings.mjs +8 -0
- package/package.json +1 -1
- package/dist/server.bundle.js +0 -1
- package/dist/server.d.ts +0 -1
package/dist/core.cjs
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var node = require('vscode-languageserver/node');
|
|
4
|
+
var vscodeLanguageserverTextdocument = require('vscode-languageserver-textdocument');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var url = require('url');
|
|
7
|
+
var cssLanguageServiceSettings = require('@master/css-language-service');
|
|
8
|
+
var exploreConfig = require('@master/css-explore-config');
|
|
9
|
+
var extend = require('@techor/extend');
|
|
10
|
+
var settings = require('./settings.cjs');
|
|
11
|
+
|
|
12
|
+
class CSSLanguageServer {
|
|
13
|
+
customSettings;
|
|
14
|
+
workspaceFolders;
|
|
15
|
+
workspaceCSSLanguageService;
|
|
16
|
+
workspaceSettings;
|
|
17
|
+
workspaceConfigs;
|
|
18
|
+
connection;
|
|
19
|
+
documents;
|
|
20
|
+
constructor(customSettings){
|
|
21
|
+
this.customSettings = customSettings;
|
|
22
|
+
this.workspaceFolders = [];
|
|
23
|
+
this.workspaceCSSLanguageService = {};
|
|
24
|
+
this.workspaceSettings = {};
|
|
25
|
+
this.workspaceConfigs = {};
|
|
26
|
+
this.connection = node.createConnection(node.ProposedFeatures.all);
|
|
27
|
+
this.documents = new node.TextDocuments(vscodeLanguageserverTextdocument.TextDocument);
|
|
28
|
+
this.connection.onDidChangeConfiguration(this.revalidate);
|
|
29
|
+
this.documents.onDidSave(async (change)=>{
|
|
30
|
+
// if the saved file is the master.css file, we need to refresh the css instance
|
|
31
|
+
if (path.parse(change.document.uri).name === 'master.css') {
|
|
32
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(change.document.uri);
|
|
33
|
+
const workspaceFolder = this.findWorkspaceFolder(change.document.uri);
|
|
34
|
+
if (cssLanguageService) cssLanguageService.css.refresh(this.updateWorkspaceConfig(workspaceFolder.uri));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
this.connection.onInitialize((params)=>{
|
|
38
|
+
if (params.workspaceFolders?.length) {
|
|
39
|
+
this.workspaceFolders = params.workspaceFolders;
|
|
40
|
+
} else {
|
|
41
|
+
if (params.rootUri) {
|
|
42
|
+
this.workspaceFolders.push({
|
|
43
|
+
name: '',
|
|
44
|
+
uri: params.rootUri
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
capabilities: cssLanguageServiceSettings.SERVER_CAPABILITIES
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
this.connection.onInitialized(async ()=>{
|
|
53
|
+
await this.workspaceFolders.map(async (folder)=>{
|
|
54
|
+
this.workspaceCSSLanguageService[folder.uri] = await this.createLanguageService(folder.uri);
|
|
55
|
+
});
|
|
56
|
+
this.connection.client.register(node.DidChangeConfigurationNotification.type, undefined);
|
|
57
|
+
});
|
|
58
|
+
this.connection.onHover((params)=>{
|
|
59
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
60
|
+
if (cssLanguageService) {
|
|
61
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
62
|
+
if (document) return cssLanguageService.inspectSyntax(document, params.position);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.connection.onCompletion((params)=>{
|
|
66
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
67
|
+
if (cssLanguageService) {
|
|
68
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
69
|
+
if (document) return cssLanguageService.suggestSyntax(document, params.position, params.context);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
this.connection.onDocumentColor((params)=>{
|
|
73
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
74
|
+
if (cssLanguageService) {
|
|
75
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
76
|
+
if (document) return cssLanguageService.renderSyntaxColors(document);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
this.connection.onColorPresentation((params)=>{
|
|
80
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
81
|
+
if (cssLanguageService) {
|
|
82
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
83
|
+
if (document) return cssLanguageService.editSyntaxColors(document, params.color, params.range);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
// Make the text document manager listen on the connection
|
|
87
|
+
// for open, change and close text document events
|
|
88
|
+
this.documents.listen(this.connection);
|
|
89
|
+
}
|
|
90
|
+
async createLanguageService(workspaceURI) {
|
|
91
|
+
const { config, ...workspaceCSSLanguageServiceSettings } = await this.updateWorkspaceSettings(workspaceURI);
|
|
92
|
+
const workspaceConfig = this.workspaceConfigs[workspaceURI];
|
|
93
|
+
return new cssLanguageServiceSettings({
|
|
94
|
+
...workspaceCSSLanguageServiceSettings,
|
|
95
|
+
config: workspaceConfig
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async updateWorkspaceSettings(workspaceURI) {
|
|
99
|
+
const customWorkspaceSettings = await this.connection.workspace.getConfiguration({
|
|
100
|
+
scopeUri: workspaceURI,
|
|
101
|
+
section: 'masterCSS'
|
|
102
|
+
});
|
|
103
|
+
const resolvedSettings = extend(settings, this.customSettings, customWorkspaceSettings);
|
|
104
|
+
this.workspaceSettings[workspaceURI] = resolvedSettings;
|
|
105
|
+
this.updateWorkspaceConfig(workspaceURI);
|
|
106
|
+
return resolvedSettings;
|
|
107
|
+
}
|
|
108
|
+
updateWorkspaceConfig(workspaceURI) {
|
|
109
|
+
const workspaceSettings = this.workspaceSettings[workspaceURI];
|
|
110
|
+
const workspaceCWD = url.fileURLToPath(workspaceURI.replace('%3A', ':'));
|
|
111
|
+
let workspaceConfig;
|
|
112
|
+
if (typeof workspaceSettings.config === 'string') {
|
|
113
|
+
try {
|
|
114
|
+
workspaceConfig = exploreConfig({
|
|
115
|
+
name: workspaceSettings.config,
|
|
116
|
+
cwd: workspaceCWD
|
|
117
|
+
});
|
|
118
|
+
} catch (e) {
|
|
119
|
+
console.log('Config loading failed from', workspaceCWD);
|
|
120
|
+
console.error(e);
|
|
121
|
+
console.log('Fall back to default config');
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
workspaceConfig = workspaceSettings.config;
|
|
125
|
+
}
|
|
126
|
+
return this.workspaceConfigs[workspaceURI] = workspaceConfig;
|
|
127
|
+
}
|
|
128
|
+
// find the workspace language service for the given uri
|
|
129
|
+
findWorkspaceCSSLanguageService(uri) {
|
|
130
|
+
for(const workspaceURI in this.workspaceCSSLanguageService){
|
|
131
|
+
if (uri.startsWith(workspaceURI)) {
|
|
132
|
+
return this.workspaceCSSLanguageService[workspaceURI];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
findWorkspaceFolder(uri) {
|
|
137
|
+
const workspaceFolder = this.workspaceFolders.find((workspace)=>uri.startsWith(workspace.uri));
|
|
138
|
+
if (!workspaceFolder) {
|
|
139
|
+
throw new Error(`Workspace folder not found for ${uri}`);
|
|
140
|
+
}
|
|
141
|
+
return workspaceFolder;
|
|
142
|
+
}
|
|
143
|
+
// revalidate workspace language services by all documents
|
|
144
|
+
async revalidate() {
|
|
145
|
+
return await Promise.all(this.documents.all().map(async (textDocument)=>{
|
|
146
|
+
const workspaceFolder = this.findWorkspaceFolder(textDocument.uri);
|
|
147
|
+
return this.workspaceCSSLanguageService[workspaceFolder.uri] = await this.createLanguageService(workspaceFolder.uri);
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
module.exports = CSSLanguageServer;
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TextDocuments, WorkspaceFolder } from 'vscode-languageserver/node';
|
|
2
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
+
import CSSLanguageService from '@master/css-language-service';
|
|
4
|
+
import { Settings } from './settings';
|
|
5
|
+
import { Config } from '@master/css';
|
|
6
|
+
export default class CSSLanguageServer {
|
|
7
|
+
customSettings?: Settings | undefined;
|
|
8
|
+
workspaceFolders: WorkspaceFolder[];
|
|
9
|
+
workspaceCSSLanguageService: Record<string, CSSLanguageService>;
|
|
10
|
+
workspaceSettings: Record<string, Settings>;
|
|
11
|
+
workspaceConfigs: Record<string, Config | undefined>;
|
|
12
|
+
connection: import("vscode-languageserver/node")._Connection<import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._>;
|
|
13
|
+
documents: TextDocuments<TextDocument>;
|
|
14
|
+
constructor(customSettings?: Settings | undefined);
|
|
15
|
+
createLanguageService(workspaceURI: string): Promise<CSSLanguageService>;
|
|
16
|
+
updateWorkspaceSettings(workspaceURI: string): Promise<Settings>;
|
|
17
|
+
updateWorkspaceConfig(workspaceURI: string): Config | undefined;
|
|
18
|
+
findWorkspaceCSSLanguageService(uri: string): CSSLanguageService | undefined;
|
|
19
|
+
findWorkspaceFolder(uri: string): WorkspaceFolder;
|
|
20
|
+
revalidate(): Promise<CSSLanguageService[]>;
|
|
21
|
+
}
|
package/dist/core.mjs
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createConnection, ProposedFeatures, TextDocuments, DidChangeConfigurationNotification } from 'vscode-languageserver/node';
|
|
2
|
+
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import cssLanguageServiceSettings, { SERVER_CAPABILITIES } from '@master/css-language-service';
|
|
6
|
+
import exploreConfig from '@master/css-explore-config';
|
|
7
|
+
import extend from '@techor/extend';
|
|
8
|
+
import settings from './settings.mjs';
|
|
9
|
+
|
|
10
|
+
class CSSLanguageServer {
|
|
11
|
+
customSettings;
|
|
12
|
+
workspaceFolders;
|
|
13
|
+
workspaceCSSLanguageService;
|
|
14
|
+
workspaceSettings;
|
|
15
|
+
workspaceConfigs;
|
|
16
|
+
connection;
|
|
17
|
+
documents;
|
|
18
|
+
constructor(customSettings){
|
|
19
|
+
this.customSettings = customSettings;
|
|
20
|
+
this.workspaceFolders = [];
|
|
21
|
+
this.workspaceCSSLanguageService = {};
|
|
22
|
+
this.workspaceSettings = {};
|
|
23
|
+
this.workspaceConfigs = {};
|
|
24
|
+
this.connection = createConnection(ProposedFeatures.all);
|
|
25
|
+
this.documents = new TextDocuments(TextDocument);
|
|
26
|
+
this.connection.onDidChangeConfiguration(this.revalidate);
|
|
27
|
+
this.documents.onDidSave(async (change)=>{
|
|
28
|
+
// if the saved file is the master.css file, we need to refresh the css instance
|
|
29
|
+
if (path.parse(change.document.uri).name === 'master.css') {
|
|
30
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(change.document.uri);
|
|
31
|
+
const workspaceFolder = this.findWorkspaceFolder(change.document.uri);
|
|
32
|
+
if (cssLanguageService) cssLanguageService.css.refresh(this.updateWorkspaceConfig(workspaceFolder.uri));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
this.connection.onInitialize((params)=>{
|
|
36
|
+
if (params.workspaceFolders?.length) {
|
|
37
|
+
this.workspaceFolders = params.workspaceFolders;
|
|
38
|
+
} else {
|
|
39
|
+
if (params.rootUri) {
|
|
40
|
+
this.workspaceFolders.push({
|
|
41
|
+
name: '',
|
|
42
|
+
uri: params.rootUri
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
capabilities: SERVER_CAPABILITIES
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
this.connection.onInitialized(async ()=>{
|
|
51
|
+
await this.workspaceFolders.map(async (folder)=>{
|
|
52
|
+
this.workspaceCSSLanguageService[folder.uri] = await this.createLanguageService(folder.uri);
|
|
53
|
+
});
|
|
54
|
+
this.connection.client.register(DidChangeConfigurationNotification.type, undefined);
|
|
55
|
+
});
|
|
56
|
+
this.connection.onHover((params)=>{
|
|
57
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
58
|
+
if (cssLanguageService) {
|
|
59
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
60
|
+
if (document) return cssLanguageService.inspectSyntax(document, params.position);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this.connection.onCompletion((params)=>{
|
|
64
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
65
|
+
if (cssLanguageService) {
|
|
66
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
67
|
+
if (document) return cssLanguageService.suggestSyntax(document, params.position, params.context);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
this.connection.onDocumentColor((params)=>{
|
|
71
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
72
|
+
if (cssLanguageService) {
|
|
73
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
74
|
+
if (document) return cssLanguageService.renderSyntaxColors(document);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
this.connection.onColorPresentation((params)=>{
|
|
78
|
+
const cssLanguageService = this.findWorkspaceCSSLanguageService(params.textDocument.uri);
|
|
79
|
+
if (cssLanguageService) {
|
|
80
|
+
const document = this.documents.get(params.textDocument.uri);
|
|
81
|
+
if (document) return cssLanguageService.editSyntaxColors(document, params.color, params.range);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
// Make the text document manager listen on the connection
|
|
85
|
+
// for open, change and close text document events
|
|
86
|
+
this.documents.listen(this.connection);
|
|
87
|
+
}
|
|
88
|
+
async createLanguageService(workspaceURI) {
|
|
89
|
+
const { config, ...workspaceCSSLanguageServiceSettings } = await this.updateWorkspaceSettings(workspaceURI);
|
|
90
|
+
const workspaceConfig = this.workspaceConfigs[workspaceURI];
|
|
91
|
+
return new cssLanguageServiceSettings({
|
|
92
|
+
...workspaceCSSLanguageServiceSettings,
|
|
93
|
+
config: workspaceConfig
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async updateWorkspaceSettings(workspaceURI) {
|
|
97
|
+
const customWorkspaceSettings = await this.connection.workspace.getConfiguration({
|
|
98
|
+
scopeUri: workspaceURI,
|
|
99
|
+
section: 'masterCSS'
|
|
100
|
+
});
|
|
101
|
+
const resolvedSettings = extend(settings, this.customSettings, customWorkspaceSettings);
|
|
102
|
+
this.workspaceSettings[workspaceURI] = resolvedSettings;
|
|
103
|
+
this.updateWorkspaceConfig(workspaceURI);
|
|
104
|
+
return resolvedSettings;
|
|
105
|
+
}
|
|
106
|
+
updateWorkspaceConfig(workspaceURI) {
|
|
107
|
+
const workspaceSettings = this.workspaceSettings[workspaceURI];
|
|
108
|
+
const workspaceCWD = fileURLToPath(workspaceURI.replace('%3A', ':'));
|
|
109
|
+
let workspaceConfig;
|
|
110
|
+
if (typeof workspaceSettings.config === 'string') {
|
|
111
|
+
try {
|
|
112
|
+
workspaceConfig = exploreConfig({
|
|
113
|
+
name: workspaceSettings.config,
|
|
114
|
+
cwd: workspaceCWD
|
|
115
|
+
});
|
|
116
|
+
} catch (e) {
|
|
117
|
+
console.log('Config loading failed from', workspaceCWD);
|
|
118
|
+
console.error(e);
|
|
119
|
+
console.log('Fall back to default config');
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
workspaceConfig = workspaceSettings.config;
|
|
123
|
+
}
|
|
124
|
+
return this.workspaceConfigs[workspaceURI] = workspaceConfig;
|
|
125
|
+
}
|
|
126
|
+
// find the workspace language service for the given uri
|
|
127
|
+
findWorkspaceCSSLanguageService(uri) {
|
|
128
|
+
for(const workspaceURI in this.workspaceCSSLanguageService){
|
|
129
|
+
if (uri.startsWith(workspaceURI)) {
|
|
130
|
+
return this.workspaceCSSLanguageService[workspaceURI];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
findWorkspaceFolder(uri) {
|
|
135
|
+
const workspaceFolder = this.workspaceFolders.find((workspace)=>uri.startsWith(workspace.uri));
|
|
136
|
+
if (!workspaceFolder) {
|
|
137
|
+
throw new Error(`Workspace folder not found for ${uri}`);
|
|
138
|
+
}
|
|
139
|
+
return workspaceFolder;
|
|
140
|
+
}
|
|
141
|
+
// revalidate workspace language services by all documents
|
|
142
|
+
async revalidate() {
|
|
143
|
+
return await Promise.all(this.documents.all().map(async (textDocument)=>{
|
|
144
|
+
const workspaceFolder = this.findWorkspaceFolder(textDocument.uri);
|
|
145
|
+
return this.workspaceCSSLanguageService[workspaceFolder.uri] = await this.createLanguageService(workspaceFolder.uri);
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export { CSSLanguageServer as default };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('./core.cjs');
|
|
6
|
+
var settings = require('./settings.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.CSSLanguageServer = core;
|
|
11
|
+
exports.default = core;
|
|
12
|
+
exports.settings = settings;
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/css-language-server","scripts":{"build":"techor
|
|
1
|
+
{"name":"@master/css-language-server","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","type-check":"tsc --noEmit","lint":"eslint src","test":"jest"},"description":"Master CSS Language Server","author":"Aoyue Design LLC.","license":"MIT","repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/language-server"},"dependencies":{"@master/css":"^2.0.0-rc.30","@master/css-language-service":"^2.0.0-rc.30","@master/css-explore-config":"^2.0.0-rc.30","@techor/extend":"^3.0.18","js-beautify":"^1.15.1","vscode-languageserver":"^7.0.0","vscode-languageserver-textdocument":"^1.0.11"},"devDependencies":{"@master/css-shared":"^2.0.0-rc.30"},"sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.mjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"files":["dist"],"publishConfig":{"access":"public","provenance":true},"version":"2.0.0-rc.30"}
|
package/dist/server.bundle.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var W=Object.create;var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var E=(t,e,n,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of H(e))!L.call(t,i)&&i!==n&&S(t,i,{get:()=>e[i],enumerable:!(s=U(e,i))||s.enumerable});return t};var h=(t,e,n)=>(n=t!=null?W(K(t)):{},E(e||!t||!t.__esModule?S(n,"default",{value:t,enumerable:!0}):n,t));var u=require("vscode-languageserver/node"),w=require("@master/css"),b=require("minimatch"),P=require("vscode-languageserver-textdocument"),k=h(require("path")),T=require("url"),o=require("@master/css-language-service"),v=h(require("explore-config")),a=(0,u.createConnection)(u.ProposedFeatures.all),f=new u.TextDocuments(P.TextDocument),C=!1,D=!1,O=!1,l,g,I;var M=o.settings,p=new Map;a.onDidChangeConfiguration(t=>{C?p.clear():M=t.settings.masterCSS||o.settings,f.all().forEach(y)});async function B(t){if(!C)return Promise.resolve(M);let e=p.get(t);return e||(e=a.workspace.getConfiguration({scopeUri:t,section:"masterCSS"}),p.set(t,e)),e}f.onDidClose(t=>{p.delete(t.document.uri)});f.onDidOpen(t=>{y(t.document)});f.onDidSave(async t=>{k.default.parse(t.document.uri).name==="master.css"&&await A(t.document.uri)});async function y(t){l=await B(t.uri),await A(t.uri)}async function A(t){let e=await a.workspace.getWorkspaceFolders(),n;if(e?.length===1?n=e[0]:n=e?.find(s=>t.includes(s.uri)),n?.uri){let s=(0,T.fileURLToPath)(n.uri.replace("%3A",":"));I=(0,v.default)(l.config||"master.css.*",{cwd:s}),g=new w.MasterCSS(I)}}a.onInitialize(t=>{let e=t.capabilities;C=!!(e.workspace&&e.workspace.configuration),D=!!(e.workspace&&e.workspace.workspaceFolders),O=!!(e.textDocument&&e.textDocument.publishDiagnostics&&e.textDocument.publishDiagnostics.relatedInformation);let n={capabilities:{textDocumentSync:u.TextDocumentSyncKind.Incremental,completionProvider:{resolveProvider:!0,workDoneProgress:!1,triggerCharacters:[":","@","'"]},colorProvider:{},hoverProvider:!0}};return D&&(n.capabilities.workspace={workspaceFolders:{supported:!0}}),n});a.onInitialized(()=>{C&&a.client.register(u.DidChangeConfigurationNotification.type,void 0)});a.onCompletion(t=>{if(l.suggestions==!0&&x(t.textDocument.uri)){let e=t.textDocument.uri,n=f.get(e),s=e.substring(e.lastIndexOf(".")+1),i=t.position;if(n){let c=n.getText(),d=n.offsetAt(i)??0,r=n.offsetAt({line:i.line-100,character:0})??0,F=n.offsetAt({line:i.line+100,character:0})??void 0,R=(0,o.positionCheck)(c.substring(r,F),d,r,l.classMatch).IsMatch,z=n.getText({start:{line:i.line,character:0},end:{line:i.line,character:i.character}}).trim(),m=(0,o.getLastInstance)(z,i,s);if(m.isInstance==!0&&R==!0)return(0,o.getCompletionItem)(m.lastKey,m.triggerKey,m.isStart,m.language,g);if(m.isInstance==!0&&(0,o.checkConfigColorsBlock)(n,t.position)==!0)return(0,o.getConfigColorsCompletionItem)(g)}}return[]});a.onCompletionResolve(t=>t);a.onDocumentColor(async t=>{if(l==null)return[];if(l.previewColors==!0&&x(t.textDocument.uri)){let e=t.textDocument.uri,n=f.get(e);if(n){let s=n.getText()??"";if(typeof n==null)return[];let i=await(0,o.getDocumentColors)(s,g),c=new Set;return i.filter(r=>c.has(r.index.start)?!1:(c.add(r.index.start),!0)).map(r=>({range:{start:n.positionAt(r.index.start),end:n.positionAt(r.index.end)},color:r.color}))}}return[]});a.onColorPresentation(t=>{if(l.previewColors==!0&&x(t.textDocument.uri)){let e=f.get(t.textDocument.uri);if(e){let n=e.getText(),s=["(?<=colors:\\s*{\\s*.*)([^}]*)}"],i=e.offsetAt(t.range.start)??0,c=e.offsetAt({line:t.range.start.line-100,character:0})??0,d=e.offsetAt({line:t.range.start.line+100,character:0})??void 0,r=(0,o.positionCheck)(n.substring(c,d),i,c,s);return(0,o.getColorPresentation)(t,r.IsMatch)}}return[]});a.onHover(t=>{if(l.inspect==!0&&x(t.textDocument.uri)){let e=f.get(t.textDocument.uri),n=t.position;if(e){let s=e.getText(),i=e.offsetAt(n)??0,c=e.offsetAt({line:n.line-100,character:0})??0,d=e.offsetAt({line:n.line+100,character:0})??void 0,r=(0,o.positionCheck)(s.substring(c,d),i,c,l.classMatch);if(r.IsMatch)return(0,o.doHover)(r.instance.instanceString,N(r.instance.index,e),I)}}return null});function x(t){for(let e of l.files.exclude)if((0,b.minimatch)(t,e))return!1;return!0}function N(t,e){return{start:e.positionAt(t.start),end:e.positionAt(t.end)}}f.listen(a);a.listen();
|
package/dist/server.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|