@master/css-language-service 2.0.0-rc.69 → 2.0.0-rc.70

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 (72) hide show
  1. package/README.md +57 -6
  2. package/dist/common.d.ts +1 -9
  3. package/dist/common.mjs +1 -48
  4. package/dist/core.d.ts +11 -10
  5. package/dist/core.mjs +70 -200
  6. package/dist/features/inspect-syntax.mjs +18 -32
  7. package/dist/features/render-semantic-tokens.d.ts +5 -0
  8. package/dist/features/render-semantic-tokens.mjs +10 -0
  9. package/dist/features/render-syntax-colors.mjs +23 -8
  10. package/dist/features/suggest-syntax.d.ts +2 -1
  11. package/dist/features/suggest-syntax.mjs +2 -2
  12. package/dist/index.mjs +1 -1
  13. package/dist/settings.d.ts +4 -7
  14. package/dist/settings.mjs +12 -41
  15. package/dist/utils/beautify-css.mjs +1 -1
  16. package/dist/utils/completion-index.d.ts +38 -0
  17. package/dist/utils/completion-index.mjs +268 -0
  18. package/dist/utils/convert-color-token.d.ts +1 -1
  19. package/dist/utils/convert-color-token.mjs +1 -1
  20. package/dist/utils/create-css-markdown-documentation.d.ts +5 -0
  21. package/dist/utils/create-css-markdown-documentation.mjs +15 -0
  22. package/dist/utils/get-class-completion-items.d.ts +4 -0
  23. package/dist/utils/get-class-completion-items.mjs +20 -0
  24. package/dist/utils/get-color-completion-items.d.ts +1 -1
  25. package/dist/utils/get-color-completion-items.mjs +6 -9
  26. package/dist/utils/get-pseudo-class-completion-items.d.ts +3 -2
  27. package/dist/utils/get-pseudo-class-completion-items.mjs +45 -42
  28. package/dist/utils/get-pseudo-element-completion-items.d.ts +3 -2
  29. package/dist/utils/get-pseudo-element-completion-items.mjs +17 -28
  30. package/dist/utils/get-query-completion-items.d.ts +3 -2
  31. package/dist/utils/get-query-completion-items.mjs +19 -32
  32. package/dist/utils/get-utility-info.d.ts +2 -5
  33. package/dist/utils/get-utility-info.mjs +4 -16
  34. package/dist/utils/get-value-completion-items.d.ts +3 -2
  35. package/dist/utils/get-value-completion-items.mjs +145 -123
  36. package/dist/utils/query-syntax-completions.d.ts +3 -2
  37. package/dist/utils/query-syntax-completions.mjs +25 -44
  38. package/package.json +1 -1
  39. package/dist/common.cjs +0 -57
  40. package/dist/core.cjs +0 -246
  41. package/dist/features/edit-syntax-colors.cjs +0 -19
  42. package/dist/features/inspect-syntax.cjs +0 -70
  43. package/dist/features/render-syntax-colors.cjs +0 -89
  44. package/dist/features/suggest-syntax.cjs +0 -20
  45. package/dist/index.cjs +0 -29
  46. package/dist/settings.cjs +0 -84
  47. package/dist/utils/beautify-css.cjs +0 -13
  48. package/dist/utils/convert-color-token.cjs +0 -60
  49. package/dist/utils/create-doc.cjs +0 -26
  50. package/dist/utils/css-data-provider.cjs +0 -9
  51. package/dist/utils/css-data-provider.d.ts +0 -3
  52. package/dist/utils/css-data-provider.mjs +0 -7
  53. package/dist/utils/find-matching-brackets.cjs +0 -29
  54. package/dist/utils/find-matching-brackets.d.ts +0 -1
  55. package/dist/utils/find-matching-brackets.mjs +0 -27
  56. package/dist/utils/get-color-completion-items.cjs +0 -29
  57. package/dist/utils/get-css-data-documentation.cjs +0 -88
  58. package/dist/utils/get-css-data-documentation.d.ts +0 -5
  59. package/dist/utils/get-css-data-documentation.mjs +0 -86
  60. package/dist/utils/get-main-completion-items.cjs +0 -106
  61. package/dist/utils/get-main-completion-items.d.ts +0 -3
  62. package/dist/utils/get-main-completion-items.mjs +0 -104
  63. package/dist/utils/get-position.cjs +0 -12
  64. package/dist/utils/get-pseudo-class-completion-items.cjs +0 -67
  65. package/dist/utils/get-pseudo-element-completion-items.cjs +0 -56
  66. package/dist/utils/get-query-completion-items.cjs +0 -92
  67. package/dist/utils/get-range.cjs +0 -23
  68. package/dist/utils/get-utility-info.cjs +0 -33
  69. package/dist/utils/get-value-completion-items.cjs +0 -183
  70. package/dist/utils/query-syntax-completions.cjs +0 -115
  71. package/dist/utils/regex.cjs +0 -5
  72. package/dist/utils/sort-completion-items.cjs +0 -13
package/dist/index.cjs DELETED
@@ -1,29 +0,0 @@
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/settings.cjs DELETED
@@ -1,84 +0,0 @@
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,13 +0,0 @@
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.replace(/@(media|container|supports|layer)\(/g, '@$1 ('), {
8
- newline_between_rules: false,
9
- indent_size: 2
10
- });
11
- }
12
-
13
- module.exports = beautifyCSS;
@@ -1,60 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var Color = require('colorjs.io');
6
-
7
- function convertColorByToken(color, colorToken, css) {
8
- const valueComponent = css.generate('color:' + colorToken)[0]?.valueComponents[0];
9
- let outputSpace = 'srgb';
10
- switch(valueComponent?.type){
11
- case 'function':
12
- outputSpace = valueComponent.name;
13
- break;
14
- case 'variable':
15
- outputSpace = valueComponent.variable?.space;
16
- break;
17
- case 'string':
18
- outputSpace = 'srgb';
19
- break;
20
- }
21
- outputSpace = normalizeCSSColorFunctionName(outputSpace);
22
- if (!outputSpace) {
23
- return;
24
- }
25
- return new Color({
26
- space: 'srgb',
27
- coords: [
28
- color.red,
29
- color.green,
30
- color.blue
31
- ],
32
- alpha: color.alpha
33
- }).to(outputSpace).toString({
34
- format: 'css',
35
- precision: 4,
36
- inGamut: false
37
- }).replace(' / ', '/').replaceAll(' ', '|');
38
- }
39
- function normalizeCSSColorFunctionName(fn) {
40
- switch(fn){
41
- case 'rgb':
42
- case 'rgba':
43
- return 'srgb';
44
- case 'hsla':
45
- return 'hsl';
46
- case 'display-p3':
47
- case 'p3':
48
- return 'p3';
49
- case 'rec2020':
50
- case 'rec.2020':
51
- return 'rec2020';
52
- case 'color':
53
- return '';
54
- default:
55
- return fn;
56
- }
57
- }
58
-
59
- exports.default = convertColorByToken;
60
- exports.normalizeCSSColorFunctionName = normalizeCSSColorFunctionName;
@@ -1,26 +0,0 @@
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;
@@ -1,9 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- import type { ICSSDataProvider } from 'vscode-css-languageservice/lib/umd/cssLanguageTypes';
2
- declare const cssDataProvider: ICSSDataProvider;
3
- export default cssDataProvider;
@@ -1,7 +0,0 @@
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 };
@@ -1,29 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export default function findMatchingPairs(input: string, startIndex: number, start: string, end: string): number | undefined;
@@ -1,27 +0,0 @@
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 };
@@ -1,29 +0,0 @@
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 = css.createCSS()) {
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;
@@ -1,88 +0,0 @@
1
- 'use strict';
2
-
3
- var beautifyCss = require('./beautify-css.cjs');
4
-
5
- function getCSSDataDocumentation(data, additional) {
6
- const values = [];
7
- const references = data?.references ? [
8
- ...data.references
9
- ] : [];
10
- if (data?.status) {
11
- values.push(getEntryStatus(data.status));
12
- }
13
- if (additional?.generatedCSS) {
14
- values.push('```css\n' + beautifyCss(additional.generatedCSS).split('\n').slice(1).join('\n') + '\n```');
15
- }
16
- if (data?.description) if (typeof data.description === 'string') {
17
- values.push(textToMarkedString(data.description));
18
- } else {
19
- values.push(data.description.kind === 'markdown' ? data.description.value : textToMarkedString(data.description.value));
20
- }
21
- const browserLabel = getBrowserLabel(data?.browsers);
22
- if (browserLabel) {
23
- values.push('(' + textToMarkedString(browserLabel) + ')');
24
- }
25
- if (data && 'syntax' in data && data.syntax) {
26
- values.push(`Syntax: ${textToMarkedString(data.syntax)}`);
27
- }
28
- // todo: can i use
29
- if (additional?.docs) {
30
- references.unshift({
31
- name: 'Master CSS',
32
- url: new URL(additional.docs, 'https://rc.css.master.co').href
33
- });
34
- }
35
- if (references.length) {
36
- values.push(references.map((r)=>{
37
- return `[${r.name}](${r.url})`;
38
- }).join(' | '));
39
- }
40
- return values?.length ? {
41
- kind: 'markdown',
42
- value: values.join('\n\n')
43
- } : undefined;
44
- }
45
- const browserNames = {
46
- E: 'Edge',
47
- FF: 'Firefox',
48
- S: 'Safari',
49
- C: 'Chrome',
50
- IE: 'IE',
51
- O: 'Opera'
52
- };
53
- function getEntryStatus(status) {
54
- switch(status){
55
- case 'experimental':
56
- return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
57
- case 'nonstandard':
58
- return '🚨️ Property is nonstandard. Avoid using it.\n\n';
59
- case 'obsolete':
60
- return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
61
- default:
62
- return '';
63
- }
64
- }
65
- function textToMarkedString(text) {
66
- text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
67
- return text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
68
- }
69
- function getBrowserLabel(browsers = []) {
70
- if (browsers.length === 0) {
71
- return null;
72
- }
73
- return browsers.map((b)=>{
74
- let value = '';
75
- const matches = b.match(/([A-Z]+)(\d+)?/) ?? '';
76
- const name = matches[1];
77
- const version = matches[2];
78
- if (name in browserNames) {
79
- value += browserNames[name];
80
- }
81
- if (version) {
82
- value += ' ' + version;
83
- }
84
- return value;
85
- }).join(', ');
86
- }
87
-
88
- exports.getCSSDataDocumentation = getCSSDataDocumentation;
@@ -1,5 +0,0 @@
1
- import type { IPropertyData, IValueData, MarkupContent } from 'vscode-css-languageservice';
2
- export declare function getCSSDataDocumentation(data?: IPropertyData | IValueData, additional?: {
3
- generatedCSS?: string;
4
- docs?: string | false;
5
- }): MarkupContent | undefined;
@@ -1,86 +0,0 @@
1
- import beautifyCSS from './beautify-css.mjs';
2
-
3
- function getCSSDataDocumentation(data, additional) {
4
- const values = [];
5
- const references = data?.references ? [
6
- ...data.references
7
- ] : [];
8
- if (data?.status) {
9
- values.push(getEntryStatus(data.status));
10
- }
11
- if (additional?.generatedCSS) {
12
- values.push('```css\n' + beautifyCSS(additional.generatedCSS).split('\n').slice(1).join('\n') + '\n```');
13
- }
14
- if (data?.description) if (typeof data.description === 'string') {
15
- values.push(textToMarkedString(data.description));
16
- } else {
17
- values.push(data.description.kind === 'markdown' ? data.description.value : textToMarkedString(data.description.value));
18
- }
19
- const browserLabel = getBrowserLabel(data?.browsers);
20
- if (browserLabel) {
21
- values.push('(' + textToMarkedString(browserLabel) + ')');
22
- }
23
- if (data && 'syntax' in data && data.syntax) {
24
- values.push(`Syntax: ${textToMarkedString(data.syntax)}`);
25
- }
26
- // todo: can i use
27
- if (additional?.docs) {
28
- references.unshift({
29
- name: 'Master CSS',
30
- url: new URL(additional.docs, 'https://rc.css.master.co').href
31
- });
32
- }
33
- if (references.length) {
34
- values.push(references.map((r)=>{
35
- return `[${r.name}](${r.url})`;
36
- }).join(' | '));
37
- }
38
- return values?.length ? {
39
- kind: 'markdown',
40
- value: values.join('\n\n')
41
- } : undefined;
42
- }
43
- const browserNames = {
44
- E: 'Edge',
45
- FF: 'Firefox',
46
- S: 'Safari',
47
- C: 'Chrome',
48
- IE: 'IE',
49
- O: 'Opera'
50
- };
51
- function getEntryStatus(status) {
52
- switch(status){
53
- case 'experimental':
54
- return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
55
- case 'nonstandard':
56
- return '🚨️ Property is nonstandard. Avoid using it.\n\n';
57
- case 'obsolete':
58
- return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
59
- default:
60
- return '';
61
- }
62
- }
63
- function textToMarkedString(text) {
64
- text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
65
- return text.replace(/</g, '&lt;').replace(/>/g, '&gt;');
66
- }
67
- function getBrowserLabel(browsers = []) {
68
- if (browsers.length === 0) {
69
- return null;
70
- }
71
- return browsers.map((b)=>{
72
- let value = '';
73
- const matches = b.match(/([A-Z]+)(\d+)?/) ?? '';
74
- const name = matches[1];
75
- const version = matches[2];
76
- if (name in browserNames) {
77
- value += browserNames[name];
78
- }
79
- if (version) {
80
- value += ' ' + version;
81
- }
82
- return value;
83
- }).join(', ');
84
- }
85
-
86
- export { getCSSDataDocumentation };
@@ -1,106 +0,0 @@
1
- 'use strict';
2
-
3
- var vscodeLanguageserverProtocol = require('vscode-languageserver-protocol');
4
- var css = require('@master/css');
5
- var getCssDataDocumentation = require('./get-css-data-documentation.cjs');
6
- var sortCompletionItems = require('./sort-completion-items.cjs');
7
- var getUtilityInfo = require('./get-utility-info.cjs');
8
- var cssDataProvider = require('./css-data-provider.cjs');
9
-
10
- function getMainCompletionItems(css$1 = css.createCSS()) {
11
- const completionItems = [];
12
- const addedKeys = new Set();
13
- for (const eachDefinedRule of css$1.definedRules){
14
- if (eachDefinedRule.definition.type === css.SyntaxRuleType.Utility) {
15
- const { data, detail, docs } = getUtilityInfo(eachDefinedRule, css$1);
16
- const utilityName = eachDefinedRule.id.slice(1);
17
- completionItems.push({
18
- label: utilityName,
19
- kind: vscodeLanguageserverProtocol.CompletionItemKind.Value,
20
- documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
21
- generatedCSS: css.generateCSS([
22
- utilityName
23
- ], css$1),
24
- docs
25
- }),
26
- detail
27
- });
28
- } else {
29
- const nativeProperties = cssDataProvider.provideProperties();
30
- const nativeCSSPropertyData = nativeProperties.find(({ name })=>name === eachDefinedRule.id);
31
- const eachCompletionItem = {
32
- kind: vscodeLanguageserverProtocol.CompletionItemKind.Property,
33
- documentation: getCssDataDocumentation.getCSSDataDocumentation(nativeCSSPropertyData, {
34
- docs: '/reference/' + css.isCoreRule(eachDefinedRule.id) && eachDefinedRule.id
35
- }),
36
- detail: nativeCSSPropertyData?.syntax
37
- };
38
- eachDefinedRule.keys.forEach((key)=>{
39
- addedKeys.delete(key);
40
- completionItems.push({
41
- ...eachCompletionItem,
42
- label: key + ':',
43
- sortText: key,
44
- command: {
45
- title: 'triggerSuggest',
46
- command: 'editor.action.triggerSuggest'
47
- }
48
- });
49
- });
50
- /**
51
- * @example @ animation and ~ transition
52
- */ if (eachDefinedRule.definition?.sign && eachDefinedRule.definition.includeAnimations) {
53
- css$1.animations.forEach((animation, animationName)=>{
54
- completionItems.push({
55
- ...eachCompletionItem,
56
- label: eachDefinedRule.definition.sign + animationName + '|1s',
57
- kind: vscodeLanguageserverProtocol.CompletionItemKind.Value
58
- });
59
- });
60
- }
61
- if (eachDefinedRule.definition?.aliasGroups?.length) {
62
- for (const aliasGroup of eachDefinedRule.definition.aliasGroups){
63
- if (addedKeys.has(aliasGroup)) {
64
- continue;
65
- }
66
- addedKeys.add(aliasGroup);
67
- }
68
- }
69
- }
70
- }
71
- addedKeys.forEach((aliasGroup)=>{
72
- /**
73
- * Ambiguous keys are added to the completion list
74
- * @example text: t:
75
- */ completionItems.push({
76
- kind: vscodeLanguageserverProtocol.CompletionItemKind.Property,
77
- detail: 'ambiguous key',
78
- label: aliasGroup + ':',
79
- sortText: aliasGroup,
80
- command: {
81
- title: 'triggerSuggest',
82
- command: 'editor.action.triggerSuggest'
83
- }
84
- });
85
- });
86
- if (css$1.config.components) {
87
- for(const componentClass in css$1.config.components){
88
- const componentTokens = css$1.components.get(componentClass);
89
- if (!componentTokens) continue;
90
- completionItems.push({
91
- label: componentClass,
92
- kind: vscodeLanguageserverProtocol.CompletionItemKind.Value,
93
- documentation: getCssDataDocumentation.getCSSDataDocumentation({}, {
94
- generatedCSS: css.generateCSS([
95
- componentClass
96
- ], css$1),
97
- docs: '/guide/components'
98
- }),
99
- detail: componentTokens.join(' ') + ' (style)'
100
- });
101
- }
102
- }
103
- return sortCompletionItems(completionItems);
104
- }
105
-
106
- module.exports = getMainCompletionItems;
@@ -1,3 +0,0 @@
1
- import { type CompletionItem } from 'vscode-languageserver-protocol';
2
- import { MasterCSS } from '@master/css';
3
- export default function getMainCompletionItems(css?: MasterCSS): CompletionItem[];