@master/css-language-service 2.0.0-rc.6 → 2.0.0-rc.61

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 (94) hide show
  1. package/README.md +63 -0
  2. package/dist/common.cjs +57 -0
  3. package/dist/common.d.ts +9 -0
  4. package/dist/common.mjs +48 -0
  5. package/dist/core.cjs +246 -0
  6. package/dist/core.d.ts +29 -0
  7. package/dist/core.mjs +244 -0
  8. package/dist/features/edit-syntax-colors.cjs +19 -0
  9. package/dist/features/edit-syntax-colors.d.ts +4 -0
  10. package/dist/features/edit-syntax-colors.mjs +17 -0
  11. package/dist/features/inspect-syntax.cjs +70 -0
  12. package/dist/features/inspect-syntax.d.ts +4 -0
  13. package/dist/features/inspect-syntax.mjs +68 -0
  14. package/dist/features/render-syntax-colors.cjs +88 -0
  15. package/dist/features/render-syntax-colors.d.ts +4 -0
  16. package/dist/features/render-syntax-colors.mjs +86 -0
  17. package/dist/features/suggest-syntax.cjs +20 -0
  18. package/dist/features/suggest-syntax.d.ts +4 -0
  19. package/dist/features/suggest-syntax.mjs +18 -0
  20. package/dist/index.cjs +29 -0
  21. package/dist/index.d.ts +7 -5
  22. package/dist/index.mjs +7 -0
  23. package/dist/settings.cjs +84 -0
  24. package/dist/settings.d.ts +19 -9
  25. package/dist/settings.mjs +82 -0
  26. package/dist/utils/beautify-css.cjs +13 -0
  27. package/dist/utils/beautify-css.d.ts +1 -0
  28. package/dist/utils/beautify-css.mjs +11 -0
  29. package/dist/utils/convert-color-space.cjs +40 -0
  30. package/dist/utils/convert-color-space.d.ts +2 -0
  31. package/dist/utils/convert-color-space.mjs +38 -0
  32. package/dist/utils/convert-color-token.cjs +28 -0
  33. package/dist/utils/convert-color-token.d.ts +3 -0
  34. package/dist/utils/convert-color-token.mjs +26 -0
  35. package/dist/utils/create-doc.cjs +26 -0
  36. package/dist/utils/create-doc.d.ts +16 -0
  37. package/dist/utils/create-doc.mjs +21 -0
  38. package/dist/utils/css-data-provider.cjs +9 -0
  39. package/dist/utils/css-data-provider.d.ts +3 -0
  40. package/dist/utils/css-data-provider.mjs +7 -0
  41. package/dist/utils/find-matching-brackets.cjs +29 -0
  42. package/dist/utils/find-matching-brackets.d.ts +1 -0
  43. package/dist/utils/find-matching-brackets.mjs +27 -0
  44. package/dist/utils/get-color-completion-items.cjs +29 -0
  45. package/dist/utils/get-color-completion-items.d.ts +3 -0
  46. package/dist/utils/get-color-completion-items.mjs +27 -0
  47. package/dist/utils/get-css-data-documentation.cjs +90 -0
  48. package/dist/utils/get-css-data-documentation.d.ts +5 -0
  49. package/dist/utils/get-css-data-documentation.mjs +88 -0
  50. package/dist/utils/get-main-completion-items.cjs +106 -0
  51. package/dist/utils/get-main-completion-items.d.ts +3 -0
  52. package/dist/utils/get-main-completion-items.mjs +104 -0
  53. package/dist/utils/get-position.cjs +12 -0
  54. package/dist/utils/get-position.d.ts +1 -0
  55. package/dist/utils/get-position.mjs +10 -0
  56. package/dist/utils/get-pseudo-class-completion-items.cjs +65 -0
  57. package/dist/utils/get-pseudo-class-completion-items.d.ts +3 -0
  58. package/dist/utils/get-pseudo-class-completion-items.mjs +63 -0
  59. package/dist/utils/get-pseudo-element-completion-items.cjs +56 -0
  60. package/dist/utils/get-pseudo-element-completion-items.d.ts +3 -0
  61. package/dist/utils/get-pseudo-element-completion-items.mjs +54 -0
  62. package/dist/utils/get-query-completion-items.cjs +102 -0
  63. package/dist/utils/get-query-completion-items.d.ts +3 -0
  64. package/dist/utils/get-query-completion-items.mjs +100 -0
  65. package/dist/utils/get-range.cjs +21 -0
  66. package/dist/utils/get-range.d.ts +2 -0
  67. package/dist/utils/get-range.mjs +19 -0
  68. package/dist/utils/get-utility-info.cjs +32 -0
  69. package/dist/utils/get-utility-info.d.ts +7 -0
  70. package/dist/utils/get-utility-info.mjs +30 -0
  71. package/dist/utils/get-value-completion-items.cjs +184 -0
  72. package/dist/utils/get-value-completion-items.d.ts +3 -0
  73. package/dist/utils/get-value-completion-items.mjs +182 -0
  74. package/dist/utils/query-syntax-completions.cjs +115 -0
  75. package/dist/utils/query-syntax-completions.d.ts +3 -0
  76. package/dist/utils/query-syntax-completions.mjs +113 -0
  77. package/dist/utils/regex.cjs +5 -0
  78. package/dist/utils/regex.mjs +3 -0
  79. package/dist/utils/sort-completion-items.cjs +11 -0
  80. package/dist/utils/sort-completion-items.d.ts +2 -0
  81. package/dist/utils/sort-completion-items.mjs +9 -0
  82. package/package.json +1 -1
  83. package/dist/constant.d.ts +0 -33
  84. package/dist/index.bundle.js +0 -33
  85. package/dist/position-check.d.ts +0 -20
  86. package/dist/providers/color.d.ts +0 -5
  87. package/dist/providers/completion.d.ts +0 -14
  88. package/dist/providers/hover.d.ts +0 -2
  89. package/dist/settings.bundle.js +0 -1
  90. package/dist/utils/get-css-entry-markdown-description.d.ts +0 -1
  91. package/dist/utils/hex-to-rgb.d.ts +0 -2
  92. package/dist/utils/oklab-to-rgb.d.ts +0 -1
  93. package/dist/utils/oklch-to-oklab.d.ts +0 -1
  94. package/dist/utils/to-two-digit-hex.d.ts +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,29 @@
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
+ var common = require('./common.cjs');
8
+ var inspectSyntax = require('./features/inspect-syntax.cjs');
9
+ var renderSyntaxColors = require('./features/render-syntax-colors.cjs');
10
+ var editSyntaxColors = require('./features/edit-syntax-colors.cjs');
11
+ var suggestSyntax = require('./features/suggest-syntax.cjs');
12
+
13
+
14
+
15
+ exports.CSSLanguageService = core;
16
+ exports.default = core;
17
+ exports.settings = settings;
18
+ exports.AT_TRIGGER_CHARACTER = common.AT_TRIGGER_CHARACTER;
19
+ exports.DECLARATION_SEPARATOR_TRIGGER_CHARACTER = common.DECLARATION_SEPARATOR_TRIGGER_CHARACTER;
20
+ exports.GROUP_TRIGGER_CHARACTER = common.GROUP_TRIGGER_CHARACTER;
21
+ exports.INVOKED_TRIGGER_CHARACTERS = common.INVOKED_TRIGGER_CHARACTERS;
22
+ exports.QUERY_TRIGGER_CHARACTERS = common.QUERY_TRIGGER_CHARACTERS;
23
+ exports.SELECTOR_TRIGGER_CHARACTERS = common.SELECTOR_TRIGGER_CHARACTERS;
24
+ exports.SERVER_CAPABILITIES = common.SERVER_CAPABILITIES;
25
+ exports.VALUE_TRIGGER_CHARACTERS = common.VALUE_TRIGGER_CHARACTERS;
26
+ exports.inspectSyntax = inspectSyntax;
27
+ exports.renderSyntaxColors = renderSyntaxColors;
28
+ exports.editSyntaxColors = editSyntaxColors;
29
+ exports.suggestSyntax = suggestSyntax;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { getDocumentColors, getColorValue, getColorPresentation } from './providers/color';
2
- export { checkConfigColorsBlock, getLastInstance, getConfigColorsCompletionItem, getCompletionItem, getReturnItem } from './providers/completion';
3
- export { doHover } from './providers/hover';
4
- export { positionCheck } from './position-check';
5
- export { settings } from './settings';
1
+ export { default, default as CSSLanguageService } from './core';
2
+ export { default as settings, type Settings } from './settings';
3
+ export * from './common';
4
+ export { default as inspectSyntax } from './features/inspect-syntax';
5
+ export { default as renderSyntaxColors } from './features/render-syntax-colors';
6
+ export { default as editSyntaxColors } from './features/edit-syntax-colors';
7
+ export { default as suggestSyntax } from './features/suggest-syntax';
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ export { default as CSSLanguageService, default } from './core.mjs';
2
+ export { default as settings } from './settings.mjs';
3
+ export { AT_TRIGGER_CHARACTER, DECLARATION_SEPARATOR_TRIGGER_CHARACTER, GROUP_TRIGGER_CHARACTER, INVOKED_TRIGGER_CHARACTERS, QUERY_TRIGGER_CHARACTERS, SELECTOR_TRIGGER_CHARACTERS, SERVER_CAPABILITIES, VALUE_TRIGGER_CHARACTERS } from './common.mjs';
4
+ export { default as inspectSyntax } from './features/inspect-syntax.mjs';
5
+ export { default as renderSyntaxColors } from './features/render-syntax-colors.mjs';
6
+ export { default as editSyntaxColors } from './features/edit-syntax-colors.mjs';
7
+ export { default as suggestSyntax } from './features/suggest-syntax.mjs';
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ var css = require('@master/css');
4
+
5
+ /**
6
+ * @example styles https://regex101.com/r/HLPdsw/1
7
+ **/ const settings = {
8
+ includedLanguages: [
9
+ "html",
10
+ "php",
11
+ "javascript",
12
+ "typescript",
13
+ "javascriptreact",
14
+ "typescriptreact",
15
+ "vue",
16
+ "svelte",
17
+ "rust",
18
+ "astro",
19
+ "markdown",
20
+ "mdx",
21
+ "astro"
22
+ ],
23
+ /**
24
+ * @example <div class="a b">
25
+ * @example <div className="a b">
26
+ */ classAttributes: css.CLASS_ATTRIBUTES,
27
+ /**
28
+ * @example <div class={active ? 'a' : 'b'}>
29
+ * @example <div className={active ? 'a' : 'b'}>
30
+ */ classAttributeBindings: {
31
+ "className": [
32
+ "{",
33
+ "}"
34
+ ],
35
+ "class": [
36
+ "{",
37
+ "}"
38
+ ],
39
+ "class:list": [
40
+ "{",
41
+ "}"
42
+ ],
43
+ ":class": [
44
+ "\"",
45
+ "\""
46
+ ],
47
+ "v-bind:class": [
48
+ "\"",
49
+ "\""
50
+ ],
51
+ "[class]": [
52
+ "\"",
53
+ "\""
54
+ ],
55
+ "[className]": [
56
+ "\"",
57
+ "\""
58
+ ],
59
+ "[ngClass]": [
60
+ "\"",
61
+ "\""
62
+ ]
63
+ },
64
+ /**
65
+ * @example const components = 'a b'
66
+ * @example { components: { btn: 'a b' } }
67
+ */ classDeclarations: css.CLASS_DECLARATIONS,
68
+ /**
69
+ * @example clsx('a b')
70
+ * @example styled`a b`
71
+ * @example .classList.add('a')
72
+ */ classFunctions: css.CLASS_FUNCTIONS,
73
+ exclude: [
74
+ "**/.git/**",
75
+ "**/node_modules/**",
76
+ "**/.hg/**"
77
+ ],
78
+ suggestSyntax: true,
79
+ inspectSyntax: true,
80
+ renderSyntaxColors: true,
81
+ editSyntaxColors: true
82
+ };
83
+
84
+ module.exports = settings;
@@ -1,9 +1,19 @@
1
- export declare const settings: {
2
- languages: string[];
3
- classMatch: string[];
4
- exclude: string[];
5
- suggestions: boolean;
6
- inspect: boolean;
7
- previewColors: boolean;
8
- config: string;
9
- };
1
+ import { Config } from '@master/css';
2
+ /**
3
+ * @example styles https://regex101.com/r/HLPdsw/1
4
+ **/
5
+ declare const settings: Settings;
6
+ export default settings;
7
+ export declare interface Settings {
8
+ includedLanguages?: string[];
9
+ classAttributes?: string[];
10
+ classFunctions?: string[];
11
+ classDeclarations?: string[];
12
+ classAttributeBindings?: Record<string, [string, string] | false>;
13
+ exclude?: string[];
14
+ config?: Config;
15
+ suggestSyntax?: boolean;
16
+ inspectSyntax?: boolean;
17
+ renderSyntaxColors?: boolean;
18
+ editSyntaxColors?: boolean;
19
+ }
@@ -0,0 +1,82 @@
1
+ import { CLASS_FUNCTIONS, CLASS_DECLARATIONS, CLASS_ATTRIBUTES } from '@master/css';
2
+
3
+ /**
4
+ * @example styles https://regex101.com/r/HLPdsw/1
5
+ **/ const settings = {
6
+ includedLanguages: [
7
+ "html",
8
+ "php",
9
+ "javascript",
10
+ "typescript",
11
+ "javascriptreact",
12
+ "typescriptreact",
13
+ "vue",
14
+ "svelte",
15
+ "rust",
16
+ "astro",
17
+ "markdown",
18
+ "mdx",
19
+ "astro"
20
+ ],
21
+ /**
22
+ * @example <div class="a b">
23
+ * @example <div className="a b">
24
+ */ classAttributes: CLASS_ATTRIBUTES,
25
+ /**
26
+ * @example <div class={active ? 'a' : 'b'}>
27
+ * @example <div className={active ? 'a' : 'b'}>
28
+ */ classAttributeBindings: {
29
+ "className": [
30
+ "{",
31
+ "}"
32
+ ],
33
+ "class": [
34
+ "{",
35
+ "}"
36
+ ],
37
+ "class:list": [
38
+ "{",
39
+ "}"
40
+ ],
41
+ ":class": [
42
+ "\"",
43
+ "\""
44
+ ],
45
+ "v-bind:class": [
46
+ "\"",
47
+ "\""
48
+ ],
49
+ "[class]": [
50
+ "\"",
51
+ "\""
52
+ ],
53
+ "[className]": [
54
+ "\"",
55
+ "\""
56
+ ],
57
+ "[ngClass]": [
58
+ "\"",
59
+ "\""
60
+ ]
61
+ },
62
+ /**
63
+ * @example const components = 'a b'
64
+ * @example { components: { btn: 'a b' } }
65
+ */ classDeclarations: CLASS_DECLARATIONS,
66
+ /**
67
+ * @example clsx('a b')
68
+ * @example styled`a b`
69
+ * @example .classList.add('a')
70
+ */ classFunctions: CLASS_FUNCTIONS,
71
+ exclude: [
72
+ "**/.git/**",
73
+ "**/node_modules/**",
74
+ "**/.hg/**"
75
+ ],
76
+ suggestSyntax: true,
77
+ inspectSyntax: true,
78
+ renderSyntaxColors: true,
79
+ editSyntaxColors: true
80
+ };
81
+
82
+ export { settings as default };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var beautifyCss = require('js-beautify/js/lib/beautify-css');
4
+
5
+ // @ts-expect-error
6
+ function beautifyCSS(text) {
7
+ return beautifyCss.css_beautify(text, {
8
+ newline_between_rules: false,
9
+ indent_size: 2
10
+ });
11
+ }
12
+
13
+ module.exports = beautifyCSS;
@@ -0,0 +1 @@
1
+ export default function beautifyCSS(text: string): any;
@@ -0,0 +1,11 @@
1
+ import { css_beautify } from 'js-beautify/js/lib/beautify-css';
2
+
3
+ // @ts-expect-error
4
+ function beautifyCSS(text) {
5
+ return css_beautify(text, {
6
+ newline_between_rules: false,
7
+ indent_size: 2
8
+ });
9
+ }
10
+
11
+ export { beautifyCSS as default };
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ var culori = require('culori');
4
+
5
+ function convertColorSpace(rgb, targetSpace) {
6
+ const alphaUsed = rgb.alpha !== 1;
7
+ const alphaToken = alphaUsed ? `/${rgb.alpha}` : '';
8
+ if (rgb.r === 0 && rgb.g === 0 && rgb.b === 0) return 'black' + alphaToken;
9
+ if (rgb.r === 1 && rgb.g === 1 && rgb.b === 1) return 'white' + alphaToken;
10
+ switch(targetSpace){
11
+ case 'hex':
12
+ return alphaUsed ? culori.serializeHex8(rgb) : culori.serializeHex(rgb);
13
+ case 'rgba':
14
+ case 'rgb':
15
+ return `rgb(${Math.round(rgb.r * 255)}|${Math.round(rgb.g * 255)}|${Math.round(rgb.b * 255)}${alphaToken})`;
16
+ case 'hsla':
17
+ case 'hsl':
18
+ const hsl = culori.modeHsl.fromMode.rgb(rgb);
19
+ return `hsl(${Math.round(hsl.h || 0)}|${Math.round(hsl.s * 100)}%|${Math.round(hsl.l * 100)}%${alphaToken})`;
20
+ case 'hwb':
21
+ const hwb = culori.modeHwb.fromMode.rgb(rgb);
22
+ return `hwb(${Math.round(hwb.h || 0)}|${Math.round(hwb.w * 100)}%|${Math.round(hwb.b * 100)}%${alphaToken})`;
23
+ case 'lab':
24
+ const lab = culori.modeLab.fromMode.rgb(rgb);
25
+ return `lab(${Math.round(lab.l)}%|${Math.round(lab.a)}|${Math.round(lab.b || 0)}${alphaToken})`;
26
+ case 'lch':
27
+ const lch = culori.modeLch.fromMode.rgb(rgb);
28
+ return `lch(${Math.round(lch.l)}%|${Math.round(lch.c)}|${Math.round(lch.h || 0)}${alphaToken})`;
29
+ case 'oklab':
30
+ const oklab = culori.modeOklab.fromMode.rgb(rgb);
31
+ return `oklab(${Math.round(oklab.l * 100)}%|${oklab.a.toFixed(4)}|${oklab.b.toFixed(4)}${alphaToken})`;
32
+ case 'oklch':
33
+ const oklch = culori.modeOklch.fromMode.rgb(rgb);
34
+ return `oklch(${Math.round(oklch.l * 100)}%|${oklch.c.toFixed(4)}|${Math.round(oklch.h || 0)}${alphaToken})`;
35
+ }
36
+ // color()
37
+ return culori.formatCss(rgb).replace(' / ', '/').replace(' ', '|');
38
+ }
39
+
40
+ module.exports = convertColorSpace;
@@ -0,0 +1,2 @@
1
+ import { type Rgb } from 'culori';
2
+ export default function convertColorSpace(rgb: Rgb, targetSpace: any): string | undefined;
@@ -0,0 +1,38 @@
1
+ import { modeOklch, modeOklab, modeLch, modeLab, modeHwb, modeHsl, serializeHex8, serializeHex, formatCss } from 'culori';
2
+
3
+ function convertColorSpace(rgb, targetSpace) {
4
+ const alphaUsed = rgb.alpha !== 1;
5
+ const alphaToken = alphaUsed ? `/${rgb.alpha}` : '';
6
+ if (rgb.r === 0 && rgb.g === 0 && rgb.b === 0) return 'black' + alphaToken;
7
+ if (rgb.r === 1 && rgb.g === 1 && rgb.b === 1) return 'white' + alphaToken;
8
+ switch(targetSpace){
9
+ case 'hex':
10
+ return alphaUsed ? serializeHex8(rgb) : serializeHex(rgb);
11
+ case 'rgba':
12
+ case 'rgb':
13
+ return `rgb(${Math.round(rgb.r * 255)}|${Math.round(rgb.g * 255)}|${Math.round(rgb.b * 255)}${alphaToken})`;
14
+ case 'hsla':
15
+ case 'hsl':
16
+ const hsl = modeHsl.fromMode.rgb(rgb);
17
+ return `hsl(${Math.round(hsl.h || 0)}|${Math.round(hsl.s * 100)}%|${Math.round(hsl.l * 100)}%${alphaToken})`;
18
+ case 'hwb':
19
+ const hwb = modeHwb.fromMode.rgb(rgb);
20
+ return `hwb(${Math.round(hwb.h || 0)}|${Math.round(hwb.w * 100)}%|${Math.round(hwb.b * 100)}%${alphaToken})`;
21
+ case 'lab':
22
+ const lab = modeLab.fromMode.rgb(rgb);
23
+ return `lab(${Math.round(lab.l)}%|${Math.round(lab.a)}|${Math.round(lab.b || 0)}${alphaToken})`;
24
+ case 'lch':
25
+ const lch = modeLch.fromMode.rgb(rgb);
26
+ return `lch(${Math.round(lch.l)}%|${Math.round(lch.c)}|${Math.round(lch.h || 0)}${alphaToken})`;
27
+ case 'oklab':
28
+ const oklab = modeOklab.fromMode.rgb(rgb);
29
+ return `oklab(${Math.round(oklab.l * 100)}%|${oklab.a.toFixed(4)}|${oklab.b.toFixed(4)}${alphaToken})`;
30
+ case 'oklch':
31
+ const oklch = modeOklch.fromMode.rgb(rgb);
32
+ return `oklch(${Math.round(oklch.l * 100)}%|${oklch.c.toFixed(4)}|${Math.round(oklch.h || 0)}${alphaToken})`;
33
+ }
34
+ // color()
35
+ return formatCss(rgb).replace(' / ', '/').replace(' ', '|');
36
+ }
37
+
38
+ export { convertColorSpace as default };
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ var convertColorSpace = require('./convert-color-space.cjs');
4
+
5
+ function convertColorByToken(color, colorToken, css) {
6
+ const valueComponent = css.generate('color:' + colorToken)[0]?.valueComponents[0];
7
+ let outputColorSpace = 'hex';
8
+ switch(valueComponent?.type){
9
+ case 'function':
10
+ outputColorSpace = valueComponent.name;
11
+ break;
12
+ case 'variable':
13
+ outputColorSpace = valueComponent.variable?.space;
14
+ break;
15
+ case 'string':
16
+ outputColorSpace = 'hex';
17
+ break;
18
+ }
19
+ return convertColorSpace({
20
+ r: color.red,
21
+ g: color.green,
22
+ b: color.blue,
23
+ alpha: color.alpha,
24
+ mode: 'rgb'
25
+ }, outputColorSpace);
26
+ }
27
+
28
+ module.exports = convertColorByToken;
@@ -0,0 +1,3 @@
1
+ import type { MasterCSS } from '@master/css';
2
+ import type { ColorPresentationParams } from 'vscode-languageserver-protocol';
3
+ export default function convertColorByToken(color: ColorPresentationParams['color'], colorToken: string, css: MasterCSS): string | undefined;
@@ -0,0 +1,26 @@
1
+ import convertColorSpace from './convert-color-space.mjs';
2
+
3
+ function convertColorByToken(color, colorToken, css) {
4
+ const valueComponent = css.generate('color:' + colorToken)[0]?.valueComponents[0];
5
+ let outputColorSpace = 'hex';
6
+ switch(valueComponent?.type){
7
+ case 'function':
8
+ outputColorSpace = valueComponent.name;
9
+ break;
10
+ case 'variable':
11
+ outputColorSpace = valueComponent.variable?.space;
12
+ break;
13
+ case 'string':
14
+ outputColorSpace = 'hex';
15
+ break;
16
+ }
17
+ return convertColorSpace({
18
+ r: color.red,
19
+ g: color.green,
20
+ b: color.blue,
21
+ alpha: color.alpha,
22
+ mode: 'rgb'
23
+ }, outputColorSpace);
24
+ }
25
+
26
+ export { convertColorByToken as default };
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var vscodeLanguageserverTextdocument = require('vscode-languageserver-textdocument');
6
+
7
+ const languageIdOfExt = {
8
+ ts: 'typescript',
9
+ tsx: 'typescriptreact',
10
+ js: 'javascript',
11
+ jsx: 'javascriptreact',
12
+ css: 'css',
13
+ scss: 'scss',
14
+ less: 'less',
15
+ html: 'html',
16
+ json: 'json',
17
+ vue: 'vue',
18
+ svelte: 'svelte',
19
+ astro: 'astro'
20
+ };
21
+ function createDoc(ext, content) {
22
+ return vscodeLanguageserverTextdocument.TextDocument.create(`file:///abc.${ext}`, languageIdOfExt[ext], 0, content);
23
+ }
24
+
25
+ exports.default = createDoc;
26
+ exports.languageIdOfExt = languageIdOfExt;
@@ -0,0 +1,16 @@
1
+ import { TextDocument } from 'vscode-languageserver-textdocument';
2
+ export 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
+ export default function createDoc(ext: keyof typeof languageIdOfExt, content: string): TextDocument;
@@ -0,0 +1,21 @@
1
+ import { TextDocument } from 'vscode-languageserver-textdocument';
2
+
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
+
21
+ export { createDoc as default, languageIdOfExt };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var dataProvider = require('vscode-css-languageservice/lib/umd/languageFacts/dataProvider');
4
+ var webCustomData = require('vscode-css-languageservice/lib/umd/data/webCustomData');
5
+
6
+ // @ts-expect-error
7
+ const cssDataProvider = new dataProvider.CSSDataProvider(webCustomData.cssData);
8
+
9
+ module.exports = cssDataProvider;
@@ -0,0 +1,3 @@
1
+ import type { ICSSDataProvider } from 'vscode-css-languageservice/lib/umd/cssLanguageTypes';
2
+ declare const cssDataProvider: ICSSDataProvider;
3
+ export default cssDataProvider;
@@ -0,0 +1,7 @@
1
+ import { CSSDataProvider } from 'vscode-css-languageservice/lib/umd/languageFacts/dataProvider';
2
+ import { cssData } from 'vscode-css-languageservice/lib/umd/data/webCustomData';
3
+
4
+ // @ts-expect-error
5
+ const cssDataProvider = new CSSDataProvider(cssData);
6
+
7
+ export { cssDataProvider as default };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ function findMatchingPairs(input, startIndex, start, end) {
4
+ let endIndex;
5
+ // {} [] ()
6
+ if (start !== end) {
7
+ let count = 1;
8
+ for(let i = startIndex; i < input.length; i++){
9
+ if (input[i] === start) {
10
+ count++;
11
+ } else if (input[i] === end) {
12
+ count--;
13
+ if (count === 0) {
14
+ endIndex = i;
15
+ break;
16
+ }
17
+ }
18
+ }
19
+ } else {
20
+ for(let i = startIndex; i < input.length; i++){
21
+ if (input[i] === start && input[i - 1] !== '\\') {
22
+ return i;
23
+ }
24
+ }
25
+ }
26
+ return endIndex;
27
+ }
28
+
29
+ module.exports = findMatchingPairs;
@@ -0,0 +1 @@
1
+ export default function findMatchingPairs(input: string, startIndex: number, start: string, end: string): number | undefined;
@@ -0,0 +1,27 @@
1
+ function findMatchingPairs(input, startIndex, start, end) {
2
+ let endIndex;
3
+ // {} [] ()
4
+ if (start !== end) {
5
+ let count = 1;
6
+ for(let i = startIndex; i < input.length; i++){
7
+ if (input[i] === start) {
8
+ count++;
9
+ } else if (input[i] === end) {
10
+ count--;
11
+ if (count === 0) {
12
+ endIndex = i;
13
+ break;
14
+ }
15
+ }
16
+ }
17
+ } else {
18
+ for(let i = startIndex; i < input.length; i++){
19
+ if (input[i] === start && input[i - 1] !== '\\') {
20
+ return i;
21
+ }
22
+ }
23
+ }
24
+ return endIndex;
25
+ }
26
+
27
+ export { findMatchingPairs as default };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var css = require('@master/css');
4
+ var vscodeLanguageserverProtocol = require('vscode-languageserver-protocol');
5
+ var sortCompletionItems = require('./sort-completion-items.cjs');
6
+
7
+ function getColorCompletionItems(css$1 = new css.MasterCSS()) {
8
+ const completionItems = [];
9
+ css$1.variables.forEach((eachVariable, eachVariableName)=>{
10
+ if (eachVariable.type === 'color') {
11
+ // todo: packages/core should support getTextByVariable(variable)
12
+ const valueToken = eachVariable.space && eachVariable.value ? `${eachVariable.space}(${eachVariable.value})` : eachVariable.value;
13
+ completionItems.push({
14
+ label: eachVariableName,
15
+ // detail is shown in the detail pane
16
+ // todo: eachVariable.token should be recorded as original config variable
17
+ detail: valueToken,
18
+ // documentation is shown in the hover
19
+ // todo: should convert and space to rgba
20
+ documentation: eachVariable.space && eachVariable.value ? `${eachVariable.space}(${eachVariable.value.split(' ').join(',')})` : eachVariable.value,
21
+ kind: vscodeLanguageserverProtocol.CompletionItemKind.Color,
22
+ sortText: eachVariableName.replace(/(.+?)-(\d+)/, (match, prefix, num)=>prefix + '-' + ('00000' + num).slice(-5))
23
+ });
24
+ }
25
+ });
26
+ return sortCompletionItems(completionItems);
27
+ }
28
+
29
+ module.exports = getColorCompletionItems;
@@ -0,0 +1,3 @@
1
+ import { MasterCSS } from '@master/css';
2
+ import { type CompletionItem } from 'vscode-languageserver-protocol';
3
+ export default function getColorCompletionItems(css?: MasterCSS): CompletionItem[];
@@ -0,0 +1,27 @@
1
+ import { MasterCSS } from '@master/css';
2
+ import { CompletionItemKind } from 'vscode-languageserver-protocol';
3
+ import sortCompletionItems from './sort-completion-items.mjs';
4
+
5
+ function getColorCompletionItems(css = new MasterCSS()) {
6
+ const completionItems = [];
7
+ css.variables.forEach((eachVariable, eachVariableName)=>{
8
+ if (eachVariable.type === 'color') {
9
+ // todo: packages/core should support getTextByVariable(variable)
10
+ const valueToken = eachVariable.space && eachVariable.value ? `${eachVariable.space}(${eachVariable.value})` : eachVariable.value;
11
+ completionItems.push({
12
+ label: eachVariableName,
13
+ // detail is shown in the detail pane
14
+ // todo: eachVariable.token should be recorded as original config variable
15
+ detail: valueToken,
16
+ // documentation is shown in the hover
17
+ // todo: should convert and space to rgba
18
+ documentation: eachVariable.space && eachVariable.value ? `${eachVariable.space}(${eachVariable.value.split(' ').join(',')})` : eachVariable.value,
19
+ kind: CompletionItemKind.Color,
20
+ sortText: eachVariableName.replace(/(.+?)-(\d+)/, (match, prefix, num)=>prefix + '-' + ('00000' + num).slice(-5))
21
+ });
22
+ }
23
+ });
24
+ return sortCompletionItems(completionItems);
25
+ }
26
+
27
+ export { getColorCompletionItems as default };