@master/css-language-server 2.0.0-rc.71 → 2.0.0-rc.73
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/README.md +1 -1
- package/dist/core.d.ts +7 -0
- package/dist/core.mjs +77 -4
- package/dist/server.d.ts +1 -0
- package/dist/server.mjs +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -99,4 +99,4 @@ import { settings } from '@master/css-language-server'
|
|
|
99
99
|
| `verbose` | `boolean` | `false` | Print server logs. |
|
|
100
100
|
| `embeddedSyntaxHighlighting` | `'active' \| 'always' \| 'off'` | `'active'` | Inherited language-service semantic token mode. |
|
|
101
101
|
|
|
102
|
-
With `workspaces: 'auto'`, the server creates workspaces from CSS files containing `@master;` or `@import '@master/css'`, and from `package.json` files that declare Master CSS package dependencies.
|
|
102
|
+
With `workspaces: 'auto'`, the server creates workspaces from CSS files containing `@master entry;` or `@import '@master/css'`, and from `package.json` files that declare Master CSS package dependencies.
|
package/dist/core.d.ts
CHANGED
|
@@ -2,11 +2,16 @@ import { TextDocuments, InitializeParams, InitializeResult, WorkspaceFolder, Con
|
|
|
2
2
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import CSSLanguageService, { Settings as CSSLanguageServiceSettings } from '@master/css-language-service';
|
|
4
4
|
import { Settings } from './settings';
|
|
5
|
+
import { type MasterCSSWorkspacePackageResolution } from '@master/css-project/workspace';
|
|
6
|
+
import { type CSSLanguageRuntime } from '@master/css-language';
|
|
5
7
|
export declare interface Workspace {
|
|
6
8
|
uri: string;
|
|
7
9
|
openedTextDocuments: TextDocument[];
|
|
8
10
|
languageService?: CSSLanguageService;
|
|
9
11
|
languageServiceSettings: CSSLanguageServiceSettings;
|
|
12
|
+
languageRuntime?: CSSLanguageRuntime;
|
|
13
|
+
languageRuntimeResolution?: MasterCSSWorkspacePackageResolution;
|
|
14
|
+
languageRuntimeSource?: 'workspace' | 'bundled';
|
|
10
15
|
planEntries?: string[];
|
|
11
16
|
}
|
|
12
17
|
export declare const ACTIVE_SEMANTIC_TOKENS_REQUEST = "masterCSS/renderActiveSemanticTokens";
|
|
@@ -42,6 +47,8 @@ export default class CSSLanguageServer {
|
|
|
42
47
|
private initWorkspaceFolder;
|
|
43
48
|
initWorkspaceLanguageService(workspace: Workspace): Promise<void>;
|
|
44
49
|
private loadWorkspacePlan;
|
|
50
|
+
private loadWorkspaceLanguageRuntime;
|
|
51
|
+
private importWorkspaceModule;
|
|
45
52
|
destroyLanguageService(workspace: Workspace): void;
|
|
46
53
|
findClosestWorkspace(textDocumentURI: string): Workspace;
|
|
47
54
|
private publishCSSDirectiveDiagnostics;
|
package/dist/core.mjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { TextDocumentSyncKind, TextDocuments, createConnection, DiagnosticSeverity } from 'vscode-languageserver/node';
|
|
2
2
|
import { TextDocument } from 'vscode-languageserver-textdocument';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
4
6
|
import CSSLanguageService from '@master/css-language-service';
|
|
5
7
|
import { compileCSSManifest } from '@master/css-compiler';
|
|
6
8
|
import { findMasterCSSWorkspaceDirectories, findCSSManifestEntryFiles } from '@master/css-project/entries';
|
|
7
9
|
import { loadProjectManifest } from '@master/css-project/manifest';
|
|
10
|
+
import { resolveMasterCSSWorkspacePackages } from '@master/css-project/workspace';
|
|
8
11
|
import extend from '@techor/extend';
|
|
9
12
|
import settings from './settings.mjs';
|
|
10
13
|
import { INVOKED_TRIGGER_CHARACTERS, VALUE_TRIGGER_CHARACTERS, SELECTOR_TRIGGER_CHARACTERS, QUERY_TRIGGER_CHARACTERS, DECLARATION_SEPARATOR_TRIGGER_CHARACTER, AT_TRIGGER_CHARACTER, GROUP_TRIGGER_CHARACTER } from '@master/css-language-service/common';
|
|
11
|
-
import { SEMANTIC_TOKENS_LEGEND } from '@master/css-language';
|
|
14
|
+
import { defaultCSSLanguageRuntime, SEMANTIC_TOKENS_LEGEND, matchesLanguageServiceNativeDeclaration } from '@master/css-language';
|
|
12
15
|
import glob from 'fast-glob';
|
|
13
16
|
import { URI } from 'vscode-uri';
|
|
14
17
|
import { CSSDirectiveError } from '@master/css-schema/css-directives';
|
|
@@ -123,7 +126,9 @@ class CSSLanguageServer {
|
|
|
123
126
|
globalWorkspace = {
|
|
124
127
|
uri: '',
|
|
125
128
|
openedTextDocuments: [],
|
|
126
|
-
languageServiceSettings: this.settings
|
|
129
|
+
languageServiceSettings: this.settings,
|
|
130
|
+
languageRuntime: defaultCSSLanguageRuntime,
|
|
131
|
+
languageRuntimeSource: 'bundled'
|
|
127
132
|
};
|
|
128
133
|
documents;
|
|
129
134
|
initializing;
|
|
@@ -350,6 +355,7 @@ class CSSLanguageServer {
|
|
|
350
355
|
}
|
|
351
356
|
}
|
|
352
357
|
async initWorkspaceLanguageService(workspace) {
|
|
358
|
+
workspace.languageRuntime = await this.loadWorkspaceLanguageRuntime(workspace);
|
|
353
359
|
let workspacePlan;
|
|
354
360
|
if (workspace !== this.globalWorkspace) {
|
|
355
361
|
try {
|
|
@@ -367,13 +373,79 @@ class CSSLanguageServer {
|
|
|
367
373
|
workspace.languageService = new CSSLanguageService({
|
|
368
374
|
...workspace.languageServiceSettings,
|
|
369
375
|
manifest: workspacePlan
|
|
376
|
+
}, {
|
|
377
|
+
runtime: workspace.languageRuntime
|
|
370
378
|
});
|
|
371
379
|
}
|
|
372
380
|
async loadWorkspacePlan(workspace) {
|
|
373
381
|
const cwd = workspace.uri ? URI.parse(workspace.uri).fsPath : process.cwd();
|
|
374
|
-
const result = await loadProjectManifest(cwd
|
|
382
|
+
const result = await loadProjectManifest(cwd, {
|
|
383
|
+
baseManifest: (workspace.languageRuntime ?? defaultCSSLanguageRuntime).defaultManifest
|
|
384
|
+
});
|
|
375
385
|
return result.entries.length ? result.manifest : workspace.languageServiceSettings.manifest;
|
|
376
386
|
}
|
|
387
|
+
async loadWorkspaceLanguageRuntime(workspace) {
|
|
388
|
+
if (workspace === this.globalWorkspace || !workspace.uri) {
|
|
389
|
+
workspace.languageRuntimeSource = 'bundled';
|
|
390
|
+
return defaultCSSLanguageRuntime;
|
|
391
|
+
}
|
|
392
|
+
const cwd = URI.parse(workspace.uri).fsPath;
|
|
393
|
+
let resolution;
|
|
394
|
+
try {
|
|
395
|
+
resolution = resolveMasterCSSWorkspacePackages(cwd);
|
|
396
|
+
workspace.languageRuntimeResolution = resolution;
|
|
397
|
+
const missingPackages = [
|
|
398
|
+
!resolution.css && '@master/css',
|
|
399
|
+
!resolution.engine && '@master/css-engine',
|
|
400
|
+
!resolution.presetManifest && '@master/css-preset/default-manifest.json'
|
|
401
|
+
].filter(Boolean);
|
|
402
|
+
if (missingPackages.length) {
|
|
403
|
+
throw new Error(`Missing workspace package(s): ${missingPackages.join(', ')}`);
|
|
404
|
+
}
|
|
405
|
+
const cssPackage = resolution.css;
|
|
406
|
+
const enginePackage = resolution.engine;
|
|
407
|
+
const presetManifestPackage = resolution.presetManifest;
|
|
408
|
+
if (!cssPackage || !enginePackage || !presetManifestPackage) {
|
|
409
|
+
throw new Error('Missing required workspace Master CSS runtime packages.');
|
|
410
|
+
}
|
|
411
|
+
const [cssModule, engineModule, utilityTypeModule] = await Promise.all([
|
|
412
|
+
this.importWorkspaceModule(cssPackage.entry),
|
|
413
|
+
this.importWorkspaceModule(enginePackage.entry),
|
|
414
|
+
resolution.utilityType ? this.importWorkspaceModule(resolution.utilityType.entry) : undefined
|
|
415
|
+
]);
|
|
416
|
+
const MasterCSS = cssModule.MasterCSS || cssModule.default;
|
|
417
|
+
const builtinKeyAliases = engineModule.builtinKeyAliases;
|
|
418
|
+
const builtinNativeValueNamespaces = engineModule.builtinNativeValueNamespaces;
|
|
419
|
+
if (!MasterCSS) throw new Error(`Missing MasterCSS export from ${cssPackage.entry}`);
|
|
420
|
+
if (!builtinKeyAliases) throw new Error(`Missing builtinKeyAliases export from ${enginePackage.entry}`);
|
|
421
|
+
if (!builtinNativeValueNamespaces) throw new Error(`Missing builtinNativeValueNamespaces export from ${enginePackage.entry}`);
|
|
422
|
+
const manifest = JSON.parse(await readFile(presetManifestPackage.entry, 'utf8'));
|
|
423
|
+
workspace.languageRuntimeSource = 'workspace';
|
|
424
|
+
this.console.info(`Using workspace Master CSS runtime ${cssPackage.version ?? '(unknown version)'} from ${cssPackage.directory}`);
|
|
425
|
+
if (resolution.errors.length) {
|
|
426
|
+
this.console.info(`Workspace Master CSS runtime optional resolution warnings: ${resolution.errors.map(({ name, message })=>`${name}: ${message}`).join('; ')}`);
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
MasterCSS,
|
|
430
|
+
UtilityType: utilityTypeModule?.UtilityType || utilityTypeModule?.default || defaultCSSLanguageRuntime.UtilityType,
|
|
431
|
+
defaultManifest: manifest,
|
|
432
|
+
builtinKeyAliases,
|
|
433
|
+
builtinNativeValueNamespaces,
|
|
434
|
+
nativeDeclarationMatcher: matchesLanguageServiceNativeDeclaration
|
|
435
|
+
};
|
|
436
|
+
} catch (error) {
|
|
437
|
+
workspace.languageRuntimeSource = 'bundled';
|
|
438
|
+
this.console.info(`Using bundled Master CSS runtime for ${workspace.uri}`);
|
|
439
|
+
if (resolution?.errors.length) {
|
|
440
|
+
this.console.info(`Workspace Master CSS package resolution errors: ${resolution.errors.map(({ name, message })=>`${name}: ${message}`).join('; ')}`);
|
|
441
|
+
}
|
|
442
|
+
this.console.error(error instanceof Error ? error.stack || error.message : String(error));
|
|
443
|
+
return defaultCSSLanguageRuntime;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
async importWorkspaceModule(path) {
|
|
447
|
+
return await import(pathToFileURL(path).href);
|
|
448
|
+
}
|
|
377
449
|
destroyLanguageService(workspace) {
|
|
378
450
|
this.console.info(`Destroyed workspace ${workspace.uri}`);
|
|
379
451
|
delete workspace.languageService;
|
|
@@ -406,7 +478,8 @@ class CSSLanguageServer {
|
|
|
406
478
|
for (const { source, offset } of getCSSDiagnosticSources(textDocument)){
|
|
407
479
|
try {
|
|
408
480
|
compileCSSManifest(source, {
|
|
409
|
-
from: documentFile
|
|
481
|
+
from: documentFile,
|
|
482
|
+
baseManifest: (workspace.languageRuntime ?? defaultCSSLanguageRuntime).defaultManifest
|
|
410
483
|
});
|
|
411
484
|
} catch (error) {
|
|
412
485
|
if (!isCSSDirectiveError(error)) continue;
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/server.mjs
ADDED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/css-language-server","type":"module","scripts":{"build":"techor build \"src/**/*.ts\" --formats esm","dev":"pnpm build --watch","type-check":"tsc --noEmit","lint":"eslint","test":"vitest"},"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.
|
|
1
|
+
{"name":"@master/css-language-server","type":"module","scripts":{"build":"techor build \"src/**/*.ts\" --formats esm","dev":"pnpm build --watch","type-check":"tsc --noEmit","lint":"eslint","test":"vitest"},"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.73","@master/css-compiler":"^2.0.0-rc.73","@master/css-language":"^2.0.0-rc.73","@master/css-language-service":"^2.0.0-rc.73","@master/css-project":"^2.0.0-rc.73","@techor/extend":"^3.2.5","fast-glob":"^3.3.3","js-beautify":"^1.15.4","nanoid":"^5.1.15","vscode-languageserver":"^10.0.0","vscode-languageserver-textdocument":"^1.0.12","vscode-uri":"^3.1.0","@master/css-schema":"^2.0.0-rc.73"},"sideEffects":false,"main":"./dist/index.mjs","module":"./dist/index.mjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","default":"./dist/index.mjs"},"./server":{"types":"./dist/server.d.ts","import":"./dist/server.mjs","default":"./dist/server.mjs"}},"files":["dist"],"publishConfig":{"access":"public","provenance":true},"version":"2.0.0-rc.73"}
|