@master/css-language-service 2.0.0-rc.85 → 2.0.0-rc.87
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.d.ts +0 -1
- package/dist/features/edit-syntax-colors.d.ts +0 -1
- package/dist/features/format-directives.d.ts +0 -1
- package/dist/features/inspect-syntax.d.ts +0 -1
- package/dist/features/render-semantic-tokens.d.ts +0 -1
- package/dist/features/render-syntax-colors.d.ts +0 -1
- package/dist/features/suggest-syntax.d.ts +0 -1
- package/dist/settings.d.ts +0 -1
- package/dist/utils/completion-index.d.ts +2 -3
- package/dist/utils/completion-index.js +7 -12
- package/dist/utils/convert-color-token.d.ts +0 -1
- package/dist/utils/create-doc.d.ts +0 -1
- package/dist/utils/get-class-completion-items.d.ts +0 -1
- package/dist/utils/get-color-completion-items.d.ts +0 -1
- package/dist/utils/get-pseudo-class-completion-items.d.ts +0 -1
- package/dist/utils/get-pseudo-class-completion-items.js +0 -2
- package/dist/utils/get-pseudo-element-completion-items.d.ts +0 -1
- package/dist/utils/get-query-completion-items.d.ts +0 -1
- package/dist/utils/get-query-completion-items.js +8 -8
- package/dist/utils/get-range.d.ts +0 -1
- package/dist/utils/get-utility-info.d.ts +0 -1
- package/dist/utils/get-value-completion-items.d.ts +0 -1
- package/dist/utils/query-syntax-completions.d.ts +0 -1
- package/dist/utils/sort-completion-items.d.ts +0 -1
- package/package.json +5 -5
package/dist/core.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ import editSyntaxColors from "./features/edit-syntax-colors.js";
|
|
|
9
9
|
import formatDirectives from "./features/format-directives.js";
|
|
10
10
|
import renderSemanticTokens$1, { renderSemanticTokensAtPosition as renderSemanticTokensAtPosition$1 } from "./features/render-semantic-tokens.js";
|
|
11
11
|
import suggestSyntax from "./features/suggest-syntax.js";
|
|
12
|
-
|
|
13
12
|
//#region src/core.d.ts
|
|
14
13
|
interface CSSLanguageServiceOptions {
|
|
15
14
|
runtime?: CSSLanguageRuntime;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ColorPresentation, ColorPresentationParams } from "vscode-languageserver-protocol";
|
|
2
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
3
|
import CSSLanguageService from "../core.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/edit-syntax-colors.d.ts
|
|
6
5
|
declare function editSyntaxColors(this: CSSLanguageService, document: TextDocument, color: ColorPresentationParams['color'], range: ColorPresentationParams['range']): ColorPresentation[];
|
|
7
6
|
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Range, TextEdit } from "vscode-languageserver-protocol";
|
|
2
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
|
-
|
|
4
3
|
//#region src/features/format-directives.d.ts
|
|
5
4
|
declare function formatDirectives(document: TextDocument, range?: Range): TextEdit[] | undefined;
|
|
6
5
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Hover, HoverParams } from "vscode-languageserver-protocol";
|
|
2
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
3
|
import CSSLanguageService from "../core.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/inspect-syntax.d.ts
|
|
6
5
|
declare function inspectSyntax(this: CSSLanguageService, document: TextDocument, position: HoverParams['position']): Hover | undefined;
|
|
7
6
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SemanticTokens } from "vscode-languageserver-protocol";
|
|
2
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
3
|
import CSSLanguageService from "../core.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/render-semantic-tokens.d.ts
|
|
6
5
|
declare function renderSemanticTokensAtPosition(this: CSSLanguageService, document: TextDocument, position: Parameters<CSSLanguageService['getClassPosition']>[1]): SemanticTokens | undefined;
|
|
7
6
|
declare function renderSemanticTokens(this: CSSLanguageService, document: TextDocument): SemanticTokens | undefined;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ColorInformation } from "vscode-languageserver-protocol";
|
|
2
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
3
|
import CSSLanguageService from "../core.js";
|
|
4
|
-
|
|
5
4
|
//#region src/features/render-syntax-colors.d.ts
|
|
6
5
|
declare function renderSyntaxColors(this: CSSLanguageService, document: TextDocument): Promise<ColorInformation[] | undefined>;
|
|
7
6
|
//#endregion
|
|
@@ -2,7 +2,6 @@ import { CompletionItem, CompletionParams } from "vscode-languageserver-protocol
|
|
|
2
2
|
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
3
3
|
import CSSLanguageService from "../core.js";
|
|
4
4
|
import { CompletionIndex } from "../utils/completion-index.js";
|
|
5
|
-
|
|
6
5
|
//#region src/features/suggest-syntax.d.ts
|
|
7
6
|
declare function suggestSyntax(this: CSSLanguageService, document: TextDocument, position: CompletionParams['position'], context: CompletionParams['context'], completionIndex?: CompletionIndex): CompletionItem[] | undefined;
|
|
8
7
|
//#endregion
|
package/dist/settings.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CSSLanguageRuntime, Condition, MasterCSS, Variable } from "@master/css-language";
|
|
2
2
|
import { CompletionItem } from "vscode-languageserver-protocol";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/completion-index.d.ts
|
|
5
4
|
interface ClassCompletionEntry extends CompletionItem {
|
|
6
5
|
documentationClassName?: string;
|
|
@@ -35,7 +34,7 @@ interface CompletionIndex {
|
|
|
35
34
|
pseudoClassSelectors: SelectorVariantCandidate[];
|
|
36
35
|
pseudoElementNames: string[];
|
|
37
36
|
pseudoElementSelectors: SelectorVariantCandidate[];
|
|
38
|
-
|
|
37
|
+
conditions: [string, Condition][];
|
|
39
38
|
}
|
|
40
39
|
declare function createCompletionIndex(css?: MasterCSS, runtime?: CSSLanguageRuntime): CompletionIndex;
|
|
41
40
|
declare function matchesIndexedName(field: string, name: string): boolean;
|
|
@@ -2,6 +2,7 @@ import sortCompletionItems from "./sort-completion-items.js";
|
|
|
2
2
|
import getUtilityInfo from "./get-utility-info.js";
|
|
3
3
|
import { createDefaultCSS, defaultCSSLanguageRuntime, getMdnPseudoClassNames, getMdnPseudoElementNames } from "@master/css-language";
|
|
4
4
|
import { CompletionItemKind } from "vscode-languageserver-protocol";
|
|
5
|
+
import { generateSelector } from "@master/css-engine/compiler";
|
|
5
6
|
//#region src/utils/completion-index.ts
|
|
6
7
|
const ANIMATION_REFERENCE_PROPERTIES = /* @__PURE__ */ new Set(["animation", "animation-name"]);
|
|
7
8
|
function utilityMayReferenceAnimations(utility) {
|
|
@@ -92,10 +93,7 @@ function collectClassEntries(css, runtime) {
|
|
|
92
93
|
}
|
|
93
94
|
function createPseudoClassSelectors(css) {
|
|
94
95
|
const selectors = /* @__PURE__ */ new Map([[":of", ":of"]]);
|
|
95
|
-
for (const [token,
|
|
96
|
-
const selector = branches.find((branch) => branch.selector)?.selector;
|
|
97
|
-
if (selector && token.startsWith(":") && !token.startsWith("::")) selectors.set(token, selector);
|
|
98
|
-
}
|
|
96
|
+
for (const [token, nodes] of css.selectors) if (token.startsWith(":") && !token.startsWith("::")) selectors.set(token, generateSelector(nodes, "&"));
|
|
99
97
|
return Array.from(selectors, ([token, selector]) => ({
|
|
100
98
|
token,
|
|
101
99
|
selector
|
|
@@ -103,13 +101,10 @@ function createPseudoClassSelectors(css) {
|
|
|
103
101
|
}
|
|
104
102
|
function createPseudoElementSelectors(css) {
|
|
105
103
|
const selectors = [];
|
|
106
|
-
for (const [token,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
selector
|
|
111
|
-
});
|
|
112
|
-
}
|
|
104
|
+
for (const [token, nodes] of css.selectors) if (token.startsWith("::")) selectors.push({
|
|
105
|
+
token,
|
|
106
|
+
selector: generateSelector(nodes, "&")
|
|
107
|
+
});
|
|
113
108
|
return selectors;
|
|
114
109
|
}
|
|
115
110
|
function createNativeVariableNamespacesByProperty(runtime) {
|
|
@@ -182,7 +177,7 @@ function createCompletionIndex(css = createDefaultCSS(), runtime = defaultCSSLan
|
|
|
182
177
|
pseudoClassSelectors: createPseudoClassSelectors(css),
|
|
183
178
|
pseudoElementNames: getMdnPseudoElementNames(),
|
|
184
179
|
pseudoElementSelectors: createPseudoElementSelectors(css),
|
|
185
|
-
|
|
180
|
+
conditions: Array.from(css.conditions.entries())
|
|
186
181
|
};
|
|
187
182
|
}
|
|
188
183
|
function matchesIndexedName(field, name) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MasterCSS } from "@master/css-language";
|
|
2
2
|
import { ColorPresentationParams } from "vscode-languageserver-protocol";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/convert-color-token.d.ts
|
|
5
4
|
declare function convertColorByToken(color: ColorPresentationParams['color'], colorToken: string, css: MasterCSS): string | undefined;
|
|
6
5
|
declare function normalizeCSSColorFunctionName(fn: string): string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MasterCSS } from "@master/css-language";
|
|
2
2
|
import { CompletionItem } from "vscode-languageserver-protocol";
|
|
3
3
|
import { CompletionIndex } from "./completion-index.js";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/get-class-completion-items.d.ts
|
|
6
5
|
declare function getClassCompletionItems(css?: MasterCSS, completionIndex?: CompletionIndex): CompletionItem[];
|
|
7
6
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MasterCSS } from "@master/css-language";
|
|
2
2
|
import { CompletionItem } from "vscode-languageserver-protocol";
|
|
3
3
|
import { CompletionIndex } from "./completion-index.js";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/get-pseudo-class-completion-items.d.ts
|
|
6
5
|
declare function getPseudoClassCompletionItems(css: MasterCSS | undefined, syntax: string, completionIndex?: CompletionIndex): CompletionItem[];
|
|
7
6
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MasterCSS } from "@master/css-language";
|
|
2
2
|
import { CompletionItem } from "vscode-languageserver-protocol";
|
|
3
3
|
import { CompletionIndex } from "./completion-index.js";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/get-pseudo-element-completion-items.d.ts
|
|
6
5
|
declare function getPseudoElementCompletionItems(css: MasterCSS | undefined, syntax: string, completionIndex?: CompletionIndex): CompletionItem[];
|
|
7
6
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MasterCSS } from "@master/css-language";
|
|
2
2
|
import { CompletionItem } from "vscode-languageserver-protocol";
|
|
3
3
|
import { CompletionIndex } from "./completion-index.js";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/get-query-completion-items.d.ts
|
|
6
5
|
declare function getQueryCompletionItems(css: MasterCSS | undefined, triggerCharacter: string | undefined, syntax: string, completionIndex?: CompletionIndex): CompletionItem[];
|
|
7
6
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import createCSSMarkdownDocumentation from "./create-css-markdown-documentation.js";
|
|
2
2
|
import sortCompletionItems from "./sort-completion-items.js";
|
|
3
3
|
import { createCompletionIndex } from "./completion-index.js";
|
|
4
|
-
import { AT_SIGN, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, createDefaultCSS,
|
|
4
|
+
import { AT_SIGN, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, createDefaultCSS, generateCSS, generateCondition, getSingleConditionNumberNode, parseCondition } from "@master/css-language";
|
|
5
5
|
import { CompletionItemKind } from "vscode-languageserver-protocol";
|
|
6
6
|
//#region src/utils/get-query-completion-items.ts
|
|
7
7
|
function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT_SIGN, syntax, completionIndex = createCompletionIndex(css)) {
|
|
@@ -19,12 +19,12 @@ function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT
|
|
|
19
19
|
documentation: createCSSMarkdownDocumentation(generateCSS([syntax + name + "()"], css, completionIndex.runtime))
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
-
const handleNumberNodes = (
|
|
23
|
-
const numberNode =
|
|
22
|
+
const handleNumberNodes = (condition, token) => {
|
|
23
|
+
const numberNode = getSingleConditionNumberNode(condition.nodes);
|
|
24
24
|
if (numberNode) {
|
|
25
25
|
const prevComparisonCharacter = syntax.charAt(syntax.length - 2);
|
|
26
26
|
const comparisonCharacter = prevComparisonCharacter === ">" || prevComparisonCharacter === "<" ? prevComparisonCharacter + triggerCharacter : triggerCharacter;
|
|
27
|
-
const text =
|
|
27
|
+
const text = generateCondition(parseCondition(comparisonCharacter + token, css));
|
|
28
28
|
completionItems.push({
|
|
29
29
|
label: comparisonCharacter + token,
|
|
30
30
|
sortText: CompletionItemKind.Keyword + comparisonCharacter + String(Math.round(numberNode.value)).padStart(12, "0"),
|
|
@@ -37,15 +37,15 @@ function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT
|
|
|
37
37
|
return true;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
for (const [token,
|
|
40
|
+
for (const [token, condition] of completionIndex.conditions) {
|
|
41
41
|
const completionItem = {
|
|
42
42
|
filterText: token,
|
|
43
43
|
insertText: token,
|
|
44
44
|
documentation: createCSSMarkdownDocumentation(generateCSS([syntax + token], css, completionIndex.runtime))
|
|
45
45
|
};
|
|
46
46
|
if ([AT_SIGN, ...QUERY_LOGICAL_OPERATORS].includes(triggerCharacter)) {
|
|
47
|
-
if (handleNumberNodes(
|
|
48
|
-
const text =
|
|
47
|
+
if (handleNumberNodes(condition, token)) continue;
|
|
48
|
+
const text = generateCondition(parseCondition(triggerCharacter + token, css));
|
|
49
49
|
completionItems.push({
|
|
50
50
|
...completionItem,
|
|
51
51
|
label: triggerCharacter + token,
|
|
@@ -54,7 +54,7 @@ function getQueryCompletionItems(css = createDefaultCSS(), triggerCharacter = AT
|
|
|
54
54
|
kind: CompletionItemKind.Keyword,
|
|
55
55
|
documentation: createCSSMarkdownDocumentation(generateCSS([syntax + token], css, completionIndex.runtime))
|
|
56
56
|
});
|
|
57
|
-
} else if (QUERY_COMPARISON_OPERATORS.includes(triggerCharacter)) handleNumberNodes(
|
|
57
|
+
} else if (QUERY_COMPARISON_OPERATORS.includes(triggerCharacter)) handleNumberNodes(condition, token);
|
|
58
58
|
}
|
|
59
59
|
return sortCompletionItems(completionItems);
|
|
60
60
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MasterCSS } from "@master/css-language";
|
|
2
2
|
import { CompletionItem } from "vscode-languageserver-protocol";
|
|
3
3
|
import { CompletionIndex } from "./completion-index.js";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/get-value-completion-items.d.ts
|
|
6
5
|
declare function getValueCompletionItems(css: MasterCSS | undefined, ruleKey: string, valuePrefix?: string, completionIndex?: CompletionIndex): CompletionItem[];
|
|
7
6
|
//#endregion
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MasterCSS } from "@master/css-language";
|
|
2
2
|
import { CompletionItem } from "vscode-languageserver-protocol";
|
|
3
3
|
import { CompletionIndex } from "./completion-index.js";
|
|
4
|
-
|
|
5
4
|
//#region src/utils/query-syntax-completions.d.ts
|
|
6
5
|
declare function querySyntaxCompletions(q?: string, css?: MasterCSS, completionIndex?: CompletionIndex): CompletionItem[] | undefined;
|
|
7
6
|
//#endregion
|
package/package.json
CHANGED
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"minimatch": "^10.2.5",
|
|
17
17
|
"vscode-languageserver-protocol": "^3.18.0",
|
|
18
18
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
19
|
-
"@master/css": "^2.0.0-rc.
|
|
20
|
-
"@master/css-engine": "^2.0.0-rc.
|
|
21
|
-
"@master/css-language": "^2.0.0-rc.
|
|
19
|
+
"@master/css": "^2.0.0-rc.87",
|
|
20
|
+
"@master/css-engine": "^2.0.0-rc.87",
|
|
21
|
+
"@master/css-language": "^2.0.0-rc.87"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/vscode": "^1.125.0",
|
|
25
25
|
"vscode-languageserver": "^10.0.0",
|
|
26
|
-
"@master/css-schema": "^2.0.0-rc.
|
|
26
|
+
"@master/css-schema": "^2.0.0-rc.87"
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"main": "./dist/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"access": "public",
|
|
51
51
|
"provenance": true
|
|
52
52
|
},
|
|
53
|
-
"version": "2.0.0-rc.
|
|
53
|
+
"version": "2.0.0-rc.87",
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsdown --config ../../shared/tsdown-package.config.ts",
|
|
56
56
|
"dev": "tsdown --config ../../shared/tsdown-package.config.ts --watch",
|