@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.
Files changed (44) hide show
  1. package/README.md +131 -0
  2. package/dist/common.d.ts +2 -0
  3. package/dist/common.js +1 -0
  4. package/dist/core.d.ts +34 -0
  5. package/dist/core.js +81 -0
  6. package/dist/document-analysis.d.ts +16 -0
  7. package/dist/document-analysis.js +34 -0
  8. package/dist/features/edit-syntax-colors.d.ts +5 -0
  9. package/dist/features/edit-syntax-colors.js +36 -0
  10. package/dist/features/format-directives.d.ts +5 -0
  11. package/dist/features/format-directives.js +60 -0
  12. package/dist/features/inspect-syntax.d.ts +5 -0
  13. package/dist/features/inspect-syntax.js +48 -0
  14. package/dist/features/render-semantic-tokens.d.ts +6 -0
  15. package/dist/features/render-semantic-tokens.js +36 -0
  16. package/dist/features/render-syntax-colors.d.ts +5 -0
  17. package/dist/features/render-syntax-colors.js +47 -0
  18. package/dist/features/suggest-syntax.d.ts +5 -0
  19. package/dist/features/suggest-syntax.js +165 -0
  20. package/dist/index.d.ts +8 -0
  21. package/dist/index.js +8 -0
  22. package/dist/settings.d.ts +21 -0
  23. package/dist/settings.js +64 -0
  24. package/dist/shiki/hast.d.ts +13 -0
  25. package/dist/shiki/hast.js +174 -0
  26. package/dist/shiki/languages.d.ts +8 -0
  27. package/dist/shiki/languages.js +69 -0
  28. package/dist/shiki.d.ts +159 -0
  29. package/dist/shiki.js +522 -0
  30. package/dist/utils/beautify-css.d.ts +2 -0
  31. package/dist/utils/beautify-css.js +12 -0
  32. package/dist/utils/convert-color-token.d.ts +4 -0
  33. package/dist/utils/convert-color-token.js +31 -0
  34. package/dist/utils/create-css-markdown-documentation.d.ts +6 -0
  35. package/dist/utils/create-css-markdown-documentation.js +12 -0
  36. package/dist/utils/create-doc.d.ts +17 -0
  37. package/dist/utils/create-doc.js +20 -0
  38. package/dist/utils/get-position.d.ts +2 -0
  39. package/dist/utils/get-position.js +8 -0
  40. package/dist/utils/get-range.d.ts +3 -0
  41. package/dist/utils/get-range.js +20 -0
  42. package/package.json +60 -0
  43. package/src/shiki.css +7 -0
  44. 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,6 @@
1
+ interface CSSMarkdownDocumentation {
2
+ kind: 'markdown';
3
+ value: string;
4
+ }
5
+ declare function createCSSMarkdownDocumentation(css: string): CSSMarkdownDocumentation | undefined;
6
+ export { CSSMarkdownDocumentation, createCSSMarkdownDocumentation as default };
@@ -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,2 @@
1
+ declare function getPosition(searchString: string, text: string): import("vscode-languageserver-textdocument").Position;
2
+ export { getPosition as default };
@@ -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,3 @@
1
+ import { Range, TextDocument } from "vscode-languageserver-textdocument";
2
+ declare function getRange(searchString: string, doc: TextDocument): Range;
3
+ export { getRange 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
+ }
package/src/shiki.css ADDED
@@ -0,0 +1,7 @@
1
+ @media (hover: hover) {
2
+ @layer components {
3
+ .mcss-host-active-on-hover:not(:hover) :where(*) {
4
+ color: inherit !important;
5
+ }
6
+ }
7
+ }