@master/css-language-service 0.0.0-site.1793659883.g69c9aebcf628
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 +131 -0
- package/dist/common.d.ts +2 -0
- package/dist/common.js +1 -0
- package/dist/core.d.ts +34 -0
- package/dist/core.js +81 -0
- package/dist/document-analysis.d.ts +16 -0
- package/dist/document-analysis.js +34 -0
- package/dist/features/edit-syntax-colors.d.ts +5 -0
- package/dist/features/edit-syntax-colors.js +36 -0
- package/dist/features/format-directives.d.ts +5 -0
- package/dist/features/format-directives.js +60 -0
- package/dist/features/inspect-syntax.d.ts +5 -0
- package/dist/features/inspect-syntax.js +48 -0
- package/dist/features/render-semantic-tokens.d.ts +6 -0
- package/dist/features/render-semantic-tokens.js +36 -0
- package/dist/features/render-syntax-colors.d.ts +5 -0
- package/dist/features/render-syntax-colors.js +47 -0
- package/dist/features/suggest-syntax.d.ts +5 -0
- package/dist/features/suggest-syntax.js +165 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/settings.d.ts +21 -0
- package/dist/settings.js +64 -0
- package/dist/shiki/hast.d.ts +13 -0
- package/dist/shiki/hast.js +174 -0
- package/dist/shiki/languages.d.ts +8 -0
- package/dist/shiki/languages.js +69 -0
- package/dist/shiki.d.ts +159 -0
- package/dist/shiki.js +522 -0
- package/dist/utils/beautify-css.d.ts +2 -0
- package/dist/utils/beautify-css.js +12 -0
- package/dist/utils/convert-color-token.d.ts +4 -0
- package/dist/utils/convert-color-token.js +31 -0
- package/dist/utils/create-css-markdown-documentation.d.ts +6 -0
- package/dist/utils/create-css-markdown-documentation.js +12 -0
- package/dist/utils/create-doc.d.ts +17 -0
- package/dist/utils/create-doc.js +20 -0
- package/dist/utils/get-position.d.ts +2 -0
- package/dist/utils/get-position.js +8 -0
- package/dist/utils/get-range.d.ts +3 -0
- package/dist/utils/get-range.js +20 -0
- package/package.json +60 -0
- package/src/shiki.css +7 -0
- package/syntaxes/master-css.tmLanguage.json +881 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { css_beautify } from "js-beautify/js/lib/beautify-css.js";
|
|
2
|
+
// src/utils/beautify-css.ts
|
|
3
|
+
/** Comparisons in a query prelude; js-beautify drops the space after `>=`, `<=`, `<` and `>`. */
|
|
4
|
+
const queryPrelude = /^(\s*@(?:media|container|custom-media|custom-container)\b)([^{;\n]*)/gm;
|
|
5
|
+
function beautifyCSS(text) {
|
|
6
|
+
return css_beautify(text.replace(/@(media|container|supports|layer)\(/g, "@$1 ("), {
|
|
7
|
+
newline_between_rules: false,
|
|
8
|
+
indent_size: 2,
|
|
9
|
+
space_around_combinator: true
|
|
10
|
+
}).replace(queryPrelude, (_match, keyword, prelude) => keyword + prelude.replace(/\([^()]*\)/g, (group) => group.replace(/\s*(<=|>=|<|>|=)\s*/g, " $1 ")));
|
|
11
|
+
}
|
|
12
|
+
export { beautifyCSS as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MasterCSSLanguageColorFormat } from "@master/css-tooling/language";
|
|
2
|
+
import { ColorPresentationParams } from "vscode-languageserver-protocol";
|
|
3
|
+
declare function convertColorInFormat(color: ColorPresentationParams['color'], format: MasterCSSLanguageColorFormat): string;
|
|
4
|
+
export { convertColorInFormat };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Color from "colorjs.io";
|
|
2
|
+
// src/utils/convert-color-token.ts
|
|
3
|
+
const colorJsSpaces = {
|
|
4
|
+
"rgb": "srgb",
|
|
5
|
+
"display-p3": "p3",
|
|
6
|
+
"a98-rgb": "a98rgb",
|
|
7
|
+
"prophoto-rgb": "prophoto",
|
|
8
|
+
"xyz": "xyz-d65"
|
|
9
|
+
};
|
|
10
|
+
function convertColorInFormat(color, format) {
|
|
11
|
+
const source = new Color({
|
|
12
|
+
space: "srgb",
|
|
13
|
+
coords: [
|
|
14
|
+
color.red,
|
|
15
|
+
color.green,
|
|
16
|
+
color.blue
|
|
17
|
+
],
|
|
18
|
+
alpha: color.alpha
|
|
19
|
+
});
|
|
20
|
+
return (format.syntax === "hex" ? `#${[
|
|
21
|
+
color.red,
|
|
22
|
+
color.green,
|
|
23
|
+
color.blue,
|
|
24
|
+
...color.alpha < 1 ? [color.alpha] : []
|
|
25
|
+
].map((channel) => Math.round(Math.min(1, Math.max(0, channel)) * 255).toString(16).padStart(2, "0")).join("")}` : source.to(colorJsSpaces[format.space || format.syntax] || format.space || format.syntax).toString({
|
|
26
|
+
format: "css",
|
|
27
|
+
precision: 4,
|
|
28
|
+
inGamut: false
|
|
29
|
+
})).replace(" / ", "/").replaceAll(" ", "|");
|
|
30
|
+
}
|
|
31
|
+
export { convertColorInFormat };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import beautifyCSS from "./beautify-css.js";
|
|
2
|
+
// src/utils/create-css-markdown-documentation.ts
|
|
3
|
+
function createCSSMarkdownDocumentation(css) {
|
|
4
|
+
if (!css) return;
|
|
5
|
+
const cssLines = beautifyCSS(css).split("\n");
|
|
6
|
+
if (cssLines[0] === "") cssLines.shift();
|
|
7
|
+
return {
|
|
8
|
+
kind: "markdown",
|
|
9
|
+
value: "```css\n" + cssLines.join("\n") + "\n```"
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export { createCSSMarkdownDocumentation as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
2
|
+
declare const languageIdOfExt: {
|
|
3
|
+
ts: string;
|
|
4
|
+
tsx: string;
|
|
5
|
+
js: string;
|
|
6
|
+
jsx: string;
|
|
7
|
+
css: string;
|
|
8
|
+
scss: string;
|
|
9
|
+
less: string;
|
|
10
|
+
html: string;
|
|
11
|
+
json: string;
|
|
12
|
+
vue: string;
|
|
13
|
+
svelte: string;
|
|
14
|
+
astro: string;
|
|
15
|
+
};
|
|
16
|
+
declare function createDoc(ext: keyof typeof languageIdOfExt, content: string): TextDocument;
|
|
17
|
+
export { createDoc as default, languageIdOfExt };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
2
|
+
// src/utils/create-doc.ts
|
|
3
|
+
const languageIdOfExt = {
|
|
4
|
+
ts: "typescript",
|
|
5
|
+
tsx: "typescriptreact",
|
|
6
|
+
js: "javascript",
|
|
7
|
+
jsx: "javascriptreact",
|
|
8
|
+
css: "css",
|
|
9
|
+
scss: "scss",
|
|
10
|
+
less: "less",
|
|
11
|
+
html: "html",
|
|
12
|
+
json: "json",
|
|
13
|
+
vue: "vue",
|
|
14
|
+
svelte: "svelte",
|
|
15
|
+
astro: "astro"
|
|
16
|
+
};
|
|
17
|
+
function createDoc(ext, content) {
|
|
18
|
+
return TextDocument.create(`file:///abc.${ext}`, languageIdOfExt[ext], 0, content);
|
|
19
|
+
}
|
|
20
|
+
export { createDoc as default, languageIdOfExt };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TextDocument } from "vscode-languageserver-textdocument";
|
|
2
|
+
// src/utils/get-position.ts
|
|
3
|
+
function getPosition(searchString, text) {
|
|
4
|
+
const document = TextDocument.create("mockuri://test", "plaintext", 1, text);
|
|
5
|
+
const offset = text.indexOf(searchString);
|
|
6
|
+
return document.positionAt(offset);
|
|
7
|
+
}
|
|
8
|
+
export { getPosition as default };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/utils/get-range.ts
|
|
2
|
+
function getRange(searchString, doc) {
|
|
3
|
+
const text = doc.getText();
|
|
4
|
+
const regex = new RegExp(`(\\b(?:className|class)\\s*=\\s*(['"\`]))(.*?)\\2`, "gs");
|
|
5
|
+
let match;
|
|
6
|
+
while ((match = regex.exec(text)) !== null) {
|
|
7
|
+
match[0];
|
|
8
|
+
const attrStartIndex = match.index + match[1].length;
|
|
9
|
+
const relativeIndex = match[3].indexOf(searchString);
|
|
10
|
+
if (relativeIndex !== -1) {
|
|
11
|
+
const absoluteIndex = attrStartIndex + relativeIndex;
|
|
12
|
+
return {
|
|
13
|
+
start: doc.positionAt(absoluteIndex),
|
|
14
|
+
end: doc.positionAt(absoluteIndex + searchString.length)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
throw new Error(`Cannot find "${searchString}" in any class attribute.`);
|
|
19
|
+
}
|
|
20
|
+
export { getRange as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@master/css-language-service",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"engines": {
|
|
5
|
+
"node": "^24"
|
|
6
|
+
},
|
|
7
|
+
"description": "Master CSS Language Service",
|
|
8
|
+
"author": "Aoyue Design LLC.",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/master-co/css.git",
|
|
13
|
+
"directory": "packages/language-service"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@master/css-preset": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
17
|
+
"@master/css-schema": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
18
|
+
"@master/css-tooling": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
19
|
+
"colorjs.io": "^0.7.1",
|
|
20
|
+
"defu": "^6.1.7",
|
|
21
|
+
"js-beautify": "^2.0.3",
|
|
22
|
+
"minimatch": "^10.2.6",
|
|
23
|
+
"vscode-languageserver-protocol": "^3.18.5",
|
|
24
|
+
"vscode-languageserver-textdocument": "^1.0.16"
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"./src/*.css"
|
|
28
|
+
],
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./common": {
|
|
37
|
+
"types": "./dist/common.d.ts",
|
|
38
|
+
"import": "./dist/common.js",
|
|
39
|
+
"default": "./dist/common.js"
|
|
40
|
+
},
|
|
41
|
+
"./shiki": {
|
|
42
|
+
"types": "./dist/shiki.d.ts",
|
|
43
|
+
"import": "./dist/shiki.js",
|
|
44
|
+
"default": "./dist/shiki.js"
|
|
45
|
+
},
|
|
46
|
+
"./shiki.css": "./src/shiki.css",
|
|
47
|
+
"./syntaxes/master-css.tmLanguage.json": "./syntaxes/master-css.tmLanguage.json"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"src/*.css",
|
|
52
|
+
"syntaxes"
|
|
53
|
+
],
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public",
|
|
56
|
+
"provenance": true
|
|
57
|
+
},
|
|
58
|
+
"version": "0.0.0-site.1793659883.g69c9aebcf628",
|
|
59
|
+
"gitHead": "69c9aebcf628eb529001b9fa1b3536306f1b139e"
|
|
60
|
+
}
|