@master/css-language-service 2.0.0-rc.26 → 2.0.0-rc.28

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 (111) hide show
  1. package/dist/common.cjs +57 -0
  2. package/dist/common.d.ts +9 -0
  3. package/dist/common.mjs +48 -0
  4. package/dist/core.cjs +188 -0
  5. package/dist/core.d.ts +30 -0
  6. package/dist/core.mjs +186 -0
  7. package/dist/features/edit-syntax-colors.cjs +19 -0
  8. package/dist/features/edit-syntax-colors.d.ts +4 -0
  9. package/dist/features/edit-syntax-colors.mjs +17 -0
  10. package/dist/features/inspect-syntax.cjs +70 -0
  11. package/dist/features/inspect-syntax.d.ts +4 -0
  12. package/dist/features/inspect-syntax.mjs +68 -0
  13. package/dist/features/render-syntax-colors.cjs +88 -0
  14. package/dist/features/render-syntax-colors.d.ts +4 -0
  15. package/dist/features/render-syntax-colors.mjs +86 -0
  16. package/dist/features/suggest-syntax.cjs +20 -0
  17. package/dist/features/suggest-syntax.d.ts +4 -0
  18. package/dist/features/suggest-syntax.mjs +18 -0
  19. package/dist/index.cjs +23 -15
  20. package/dist/index.d.ts +7 -5
  21. package/dist/index.mjs +7 -5
  22. package/dist/settings.cjs +130 -29
  23. package/dist/settings.d.ts +16 -8
  24. package/dist/settings.mjs +130 -29
  25. package/dist/utils/beautify-css.cjs +13 -0
  26. package/dist/utils/beautify-css.d.ts +1 -0
  27. package/dist/utils/beautify-css.mjs +11 -0
  28. package/dist/utils/convert-color-space.cjs +40 -0
  29. package/dist/utils/convert-color-space.d.ts +2 -0
  30. package/dist/utils/convert-color-space.mjs +38 -0
  31. package/dist/utils/convert-color-token.cjs +28 -0
  32. package/dist/utils/convert-color-token.d.ts +3 -0
  33. package/dist/utils/convert-color-token.mjs +26 -0
  34. package/dist/utils/create-doc.cjs +26 -0
  35. package/dist/utils/create-doc.d.ts +16 -0
  36. package/dist/utils/create-doc.mjs +21 -0
  37. package/dist/utils/css-data-provider.cjs +9 -0
  38. package/dist/utils/css-data-provider.d.ts +3 -0
  39. package/dist/utils/css-data-provider.mjs +7 -0
  40. package/dist/utils/find-matching-brackets.cjs +29 -0
  41. package/dist/utils/find-matching-brackets.d.ts +1 -0
  42. package/dist/utils/find-matching-brackets.mjs +27 -0
  43. package/dist/utils/get-color-completion-items.cjs +30 -0
  44. package/dist/utils/get-color-completion-items.d.ts +3 -0
  45. package/dist/utils/get-color-completion-items.mjs +28 -0
  46. package/dist/utils/get-css-data-documentation.cjs +90 -0
  47. package/dist/utils/get-css-data-documentation.d.ts +5 -0
  48. package/dist/utils/get-css-data-documentation.mjs +88 -0
  49. package/dist/utils/get-main-completion-items.cjs +105 -0
  50. package/dist/utils/get-main-completion-items.d.ts +3 -0
  51. package/dist/utils/get-main-completion-items.mjs +103 -0
  52. package/dist/utils/get-position.cjs +12 -0
  53. package/dist/utils/get-position.d.ts +1 -0
  54. package/dist/utils/get-position.mjs +10 -0
  55. package/dist/utils/get-pseudo-class-completion-items.cjs +65 -0
  56. package/dist/utils/get-pseudo-class-completion-items.d.ts +3 -0
  57. package/dist/utils/get-pseudo-class-completion-items.mjs +63 -0
  58. package/dist/utils/get-pseudo-element-completion-items.cjs +56 -0
  59. package/dist/utils/get-pseudo-element-completion-items.d.ts +3 -0
  60. package/dist/utils/get-pseudo-element-completion-items.mjs +54 -0
  61. package/dist/utils/get-query-completion-items.cjs +102 -0
  62. package/dist/utils/get-query-completion-items.d.ts +3 -0
  63. package/dist/utils/get-query-completion-items.mjs +100 -0
  64. package/dist/utils/get-range.cjs +21 -0
  65. package/dist/utils/get-range.d.ts +2 -0
  66. package/dist/utils/get-range.mjs +19 -0
  67. package/dist/utils/get-utility-info.cjs +32 -0
  68. package/dist/utils/get-utility-info.d.ts +7 -0
  69. package/dist/utils/get-utility-info.mjs +30 -0
  70. package/dist/utils/get-value-completion-items.cjs +185 -0
  71. package/dist/utils/get-value-completion-items.d.ts +3 -0
  72. package/dist/utils/get-value-completion-items.mjs +183 -0
  73. package/dist/utils/query-syntax-completions.cjs +115 -0
  74. package/dist/utils/query-syntax-completions.d.ts +3 -0
  75. package/dist/utils/query-syntax-completions.mjs +113 -0
  76. package/dist/utils/regex.cjs +1 -1
  77. package/dist/utils/regex.mjs +1 -1
  78. package/dist/utils/sort-completion-items.cjs +11 -0
  79. package/dist/utils/sort-completion-items.d.ts +2 -0
  80. package/dist/utils/sort-completion-items.mjs +9 -0
  81. package/package.json +1 -1
  82. package/dist/constant.cjs +0 -3064
  83. package/dist/constant.d.ts +0 -33
  84. package/dist/constant.mjs +0 -3055
  85. package/dist/position-check.cjs +0 -37
  86. package/dist/position-check.d.ts +0 -7
  87. package/dist/position-check.mjs +0 -35
  88. package/dist/providers/color.cjs +0 -319
  89. package/dist/providers/color.d.ts +0 -5
  90. package/dist/providers/color.mjs +0 -315
  91. package/dist/providers/completion.cjs +0 -309
  92. package/dist/providers/completion.d.ts +0 -14
  93. package/dist/providers/completion.mjs +0 -303
  94. package/dist/providers/hover.cjs +0 -65
  95. package/dist/providers/hover.d.ts +0 -2
  96. package/dist/providers/hover.mjs +0 -63
  97. package/dist/utils/get-css-entry-markdown-description.cjs +0 -77
  98. package/dist/utils/get-css-entry-markdown-description.d.ts +0 -1
  99. package/dist/utils/get-css-entry-markdown-description.mjs +0 -75
  100. package/dist/utils/hex-to-rgb.cjs +0 -13
  101. package/dist/utils/hex-to-rgb.d.ts +0 -2
  102. package/dist/utils/hex-to-rgb.mjs +0 -11
  103. package/dist/utils/oklab-to-rgb.cjs +0 -33
  104. package/dist/utils/oklab-to-rgb.d.ts +0 -1
  105. package/dist/utils/oklab-to-rgb.mjs +0 -31
  106. package/dist/utils/oklch-to-oklab.cjs +0 -11
  107. package/dist/utils/oklch-to-oklab.d.ts +0 -1
  108. package/dist/utils/oklch-to-oklab.mjs +0 -9
  109. package/dist/utils/to-two-digit-hex.cjs +0 -8
  110. package/dist/utils/to-two-digit-hex.d.ts +0 -1
  111. package/dist/utils/to-two-digit-hex.mjs +0 -6
@@ -0,0 +1,88 @@
1
+ import beautifyCSS from './beautify-css.mjs';
2
+ import { OFFICIAL_URL } from '@master/css';
3
+
4
+ function getCSSDataDocumentation(data, additional) {
5
+ const values = [];
6
+ const references = data?.references ? [
7
+ ...data.references
8
+ ] : [];
9
+ if (data?.status) {
10
+ values.push(getEntryStatus(data.status));
11
+ }
12
+ if (additional?.generatedCSS) {
13
+ values.push('```css\n' + beautifyCSS(additional.generatedCSS) + '\n```');
14
+ }
15
+ if (data?.description) if (typeof data.description === 'string') {
16
+ values.push(textToMarkedString(data.description));
17
+ } else {
18
+ values.push(data.description.kind === 'markdown' ? data.description.value : textToMarkedString(data.description.value));
19
+ }
20
+ const browserLabel = getBrowserLabel(data?.browsers);
21
+ if (browserLabel) {
22
+ values.push('(' + textToMarkedString(browserLabel) + ')');
23
+ }
24
+ if (data && 'syntax' in data && data.syntax) {
25
+ values.push(`Syntax: ${textToMarkedString(data.syntax)}`);
26
+ }
27
+ // todo: can i use
28
+ if (additional?.docs) {
29
+ references.unshift({
30
+ name: 'Master CSS',
31
+ url: new URL(`/docs/${additional.docs}`, OFFICIAL_URL).href
32
+ });
33
+ }
34
+ if (references.length) {
35
+ values.push(references.map((r)=>{
36
+ return `[${r.name}](${r.url})`;
37
+ }).join(' | '));
38
+ }
39
+ return values?.length ? {
40
+ kind: 'markdown',
41
+ value: values.join('\n\n')
42
+ } : undefined;
43
+ }
44
+ const browserNames = {
45
+ E: 'Edge',
46
+ FF: 'Firefox',
47
+ S: 'Safari',
48
+ C: 'Chrome',
49
+ IE: 'IE',
50
+ O: 'Opera'
51
+ };
52
+ function getEntryStatus(status) {
53
+ switch(status){
54
+ case 'experimental':
55
+ return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
56
+ case 'nonstandard':
57
+ return '🚨️ Property is nonstandard. Avoid using it.\n\n';
58
+ case 'obsolete':
59
+ return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
60
+ default:
61
+ return '';
62
+ }
63
+ }
64
+ function textToMarkedString(text) {
65
+ text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&') // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
66
+ ;
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
+ export { getCSSDataDocumentation };
@@ -0,0 +1,105 @@
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 = new css.MasterCSS()) {
11
+ const completionItems = [];
12
+ const addedKeys = new Set();
13
+ for (const EachRule of css$1.Rules){
14
+ if (EachRule.definition.layer === css.Layer.Utility) {
15
+ const { data, detail, docs } = getUtilityInfo(EachRule, css$1);
16
+ const utilityName = EachRule.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 === EachRule.id);
31
+ const eachCompletionItem = {
32
+ kind: vscodeLanguageserverProtocol.CompletionItemKind.Property,
33
+ documentation: getCssDataDocumentation.getCSSDataDocumentation(nativeCSSPropertyData, {
34
+ docs: css.isCoreRule(EachRule.id) && EachRule.id
35
+ }),
36
+ detail: nativeCSSPropertyData?.syntax
37
+ };
38
+ EachRule.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 (EachRule.definition?.sign && EachRule.definition.includeAnimations) {
53
+ for(const animationName in css$1.animations){
54
+ completionItems.push({
55
+ ...eachCompletionItem,
56
+ label: EachRule.definition.sign + animationName + '|1s',
57
+ kind: vscodeLanguageserverProtocol.CompletionItemKind.Value
58
+ });
59
+ }
60
+ }
61
+ if (EachRule.definition?.ambiguousKeys?.length) {
62
+ for (const ambiguousKey of EachRule.definition.ambiguousKeys){
63
+ if (addedKeys.has(ambiguousKey)) {
64
+ continue;
65
+ }
66
+ addedKeys.add(ambiguousKey);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ addedKeys.forEach((ambiguousKey)=>{
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: ambiguousKey + ':',
79
+ sortText: ambiguousKey,
80
+ command: {
81
+ title: 'triggerSuggest',
82
+ command: 'editor.action.triggerSuggest'
83
+ }
84
+ });
85
+ });
86
+ if (css$1.config.styles) {
87
+ for(const styleName in css$1.config.styles){
88
+ const styleClasses = css$1.styles[styleName];
89
+ completionItems.push({
90
+ label: styleName,
91
+ kind: vscodeLanguageserverProtocol.CompletionItemKind.Value,
92
+ documentation: getCssDataDocumentation.getCSSDataDocumentation({}, {
93
+ generatedCSS: css.generateCSS([
94
+ styleName
95
+ ], css$1),
96
+ docs: 'styles'
97
+ }),
98
+ detail: styleClasses.join(' ') + ' (style)'
99
+ });
100
+ }
101
+ }
102
+ return sortCompletionItems(completionItems);
103
+ }
104
+
105
+ module.exports = getMainCompletionItems;
@@ -0,0 +1,3 @@
1
+ import { type CompletionItem } from 'vscode-languageserver-protocol';
2
+ import { MasterCSS } from '@master/css';
3
+ export default function getMainCompletionItems(css?: MasterCSS): CompletionItem[];
@@ -0,0 +1,103 @@
1
+ import { CompletionItemKind } from 'vscode-languageserver-protocol';
2
+ import { Layer, generateCSS, isCoreRule, MasterCSS } from '@master/css';
3
+ import { getCSSDataDocumentation } from './get-css-data-documentation.mjs';
4
+ import sortCompletionItems from './sort-completion-items.mjs';
5
+ import getUtilityInfo from './get-utility-info.mjs';
6
+ import cssDataProvider from './css-data-provider.mjs';
7
+
8
+ function getMainCompletionItems(css = new MasterCSS()) {
9
+ const completionItems = [];
10
+ const addedKeys = new Set();
11
+ for (const EachRule of css.Rules){
12
+ if (EachRule.definition.layer === Layer.Utility) {
13
+ const { data, detail, docs } = getUtilityInfo(EachRule, css);
14
+ const utilityName = EachRule.id.slice(1);
15
+ completionItems.push({
16
+ label: utilityName,
17
+ kind: CompletionItemKind.Value,
18
+ documentation: getCSSDataDocumentation(data, {
19
+ generatedCSS: generateCSS([
20
+ utilityName
21
+ ], css),
22
+ docs
23
+ }),
24
+ detail
25
+ });
26
+ } else {
27
+ const nativeProperties = cssDataProvider.provideProperties();
28
+ const nativeCSSPropertyData = nativeProperties.find(({ name })=>name === EachRule.id);
29
+ const eachCompletionItem = {
30
+ kind: CompletionItemKind.Property,
31
+ documentation: getCSSDataDocumentation(nativeCSSPropertyData, {
32
+ docs: isCoreRule(EachRule.id) && EachRule.id
33
+ }),
34
+ detail: nativeCSSPropertyData?.syntax
35
+ };
36
+ EachRule.keys.forEach((key)=>{
37
+ addedKeys.delete(key);
38
+ completionItems.push({
39
+ ...eachCompletionItem,
40
+ label: key + ':',
41
+ sortText: key,
42
+ command: {
43
+ title: 'triggerSuggest',
44
+ command: 'editor.action.triggerSuggest'
45
+ }
46
+ });
47
+ });
48
+ /**
49
+ * @example @ animation and ~ transition
50
+ */ if (EachRule.definition?.sign && EachRule.definition.includeAnimations) {
51
+ for(const animationName in css.animations){
52
+ completionItems.push({
53
+ ...eachCompletionItem,
54
+ label: EachRule.definition.sign + animationName + '|1s',
55
+ kind: CompletionItemKind.Value
56
+ });
57
+ }
58
+ }
59
+ if (EachRule.definition?.ambiguousKeys?.length) {
60
+ for (const ambiguousKey of EachRule.definition.ambiguousKeys){
61
+ if (addedKeys.has(ambiguousKey)) {
62
+ continue;
63
+ }
64
+ addedKeys.add(ambiguousKey);
65
+ }
66
+ }
67
+ }
68
+ }
69
+ addedKeys.forEach((ambiguousKey)=>{
70
+ /**
71
+ * Ambiguous keys are added to the completion list
72
+ * @example text: t:
73
+ */ completionItems.push({
74
+ kind: CompletionItemKind.Property,
75
+ detail: 'ambiguous key',
76
+ label: ambiguousKey + ':',
77
+ sortText: ambiguousKey,
78
+ command: {
79
+ title: 'triggerSuggest',
80
+ command: 'editor.action.triggerSuggest'
81
+ }
82
+ });
83
+ });
84
+ if (css.config.styles) {
85
+ for(const styleName in css.config.styles){
86
+ const styleClasses = css.styles[styleName];
87
+ completionItems.push({
88
+ label: styleName,
89
+ kind: CompletionItemKind.Value,
90
+ documentation: getCSSDataDocumentation({}, {
91
+ generatedCSS: generateCSS([
92
+ styleName
93
+ ], css),
94
+ docs: 'styles'
95
+ }),
96
+ detail: styleClasses.join(' ') + ' (style)'
97
+ });
98
+ }
99
+ }
100
+ return sortCompletionItems(completionItems);
101
+ }
102
+
103
+ export { getMainCompletionItems as default };
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var vscodeLanguageserverTextdocument = require('vscode-languageserver-textdocument');
4
+
5
+ function getPosition(searchString, text) {
6
+ const document = vscodeLanguageserverTextdocument.TextDocument.create('mockuri://test', 'plaintext', 1, text);
7
+ const offset = text.indexOf(searchString);
8
+ const position = document.positionAt(offset);
9
+ return position;
10
+ }
11
+
12
+ module.exports = getPosition;
@@ -0,0 +1 @@
1
+ export default function getPosition(searchString: string, text: string): import("vscode-languageserver-textdocument").Position;
@@ -0,0 +1,10 @@
1
+ import { TextDocument } from 'vscode-languageserver-textdocument';
2
+
3
+ function getPosition(searchString, text) {
4
+ const document = TextDocument.create('mockuri://test', 'plaintext', 1, text);
5
+ const offset = text.indexOf(searchString);
6
+ const position = document.positionAt(offset);
7
+ return position;
8
+ }
9
+
10
+ export { getPosition as default };
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ var css = require('@master/css');
4
+ var cssDataProvider = require('./css-data-provider.cjs');
5
+ var vscodeLanguageserverProtocol = require('vscode-languageserver-protocol');
6
+ var sortCompletionItems = require('./sort-completion-items.cjs');
7
+ var getCssDataDocumentation = require('./get-css-data-documentation.cjs');
8
+
9
+ const kind = vscodeLanguageserverProtocol.CompletionItemKind.Function;
10
+ function getPseudoClassCompletionItems(css$1 = new css.MasterCSS(), syntax) {
11
+ const pseudoClassDataList = cssDataProvider.providePseudoClasses().filter((data)=>{
12
+ // exclude @page pseudo-classes
13
+ if ([
14
+ ':first',
15
+ ':left',
16
+ ':right',
17
+ ':blank'
18
+ ].includes(data.name)) return false;
19
+ return true;
20
+ });
21
+ const completionItems = pseudoClassDataList.map((data)=>{
22
+ // fix https://github.com/microsoft/vscode-custom-data/issues/78
23
+ const name = /:(?:dir|has|is|nth-col|where)/.test(data.name) ? data.name + '()' : data.name;
24
+ let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
25
+ if (sortText.endsWith('()')) sortText = 'y' + sortText;
26
+ return {
27
+ label: name,
28
+ sortText,
29
+ documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
30
+ generatedCSS: css.generateCSS([
31
+ syntax + name.slice(1)
32
+ ], css$1),
33
+ docs: 'selectors'
34
+ }),
35
+ kind,
36
+ data
37
+ };
38
+ });
39
+ for(const selectorName in css$1.config.selectors){
40
+ if (selectorName.startsWith('::')) continue;
41
+ const selectorValue = css$1.config.selectors[selectorName];
42
+ const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
43
+ const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
44
+ const data = pseudoClassDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
45
+ let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
46
+ if (sortText.endsWith('()')) sortText = 'y' + sortText;
47
+ const completionItem = {
48
+ label: name,
49
+ documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
50
+ generatedCSS: css.generateCSS([
51
+ syntax + name.slice(1)
52
+ ], css$1),
53
+ docs: 'selectors'
54
+ }),
55
+ sortText,
56
+ kind,
57
+ detail: String(value),
58
+ data
59
+ };
60
+ completionItems.push(completionItem);
61
+ }
62
+ return sortCompletionItems(completionItems);
63
+ }
64
+
65
+ module.exports = getPseudoClassCompletionItems;
@@ -0,0 +1,3 @@
1
+ import { MasterCSS } from '@master/css';
2
+ import { type CompletionItem } from 'vscode-languageserver-protocol';
3
+ export default function getPseudoClassCompletionItems(css: MasterCSS | undefined, syntax: string): CompletionItem[];
@@ -0,0 +1,63 @@
1
+ import { generateCSS, MasterCSS } from '@master/css';
2
+ import cssDataProvider from './css-data-provider.mjs';
3
+ import { CompletionItemKind } from 'vscode-languageserver-protocol';
4
+ import sortCompletionItems from './sort-completion-items.mjs';
5
+ import { getCSSDataDocumentation } from './get-css-data-documentation.mjs';
6
+
7
+ const kind = CompletionItemKind.Function;
8
+ function getPseudoClassCompletionItems(css = new MasterCSS(), syntax) {
9
+ const pseudoClassDataList = cssDataProvider.providePseudoClasses().filter((data)=>{
10
+ // exclude @page pseudo-classes
11
+ if ([
12
+ ':first',
13
+ ':left',
14
+ ':right',
15
+ ':blank'
16
+ ].includes(data.name)) return false;
17
+ return true;
18
+ });
19
+ const completionItems = pseudoClassDataList.map((data)=>{
20
+ // fix https://github.com/microsoft/vscode-custom-data/issues/78
21
+ const name = /:(?:dir|has|is|nth-col|where)/.test(data.name) ? data.name + '()' : data.name;
22
+ let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
23
+ if (sortText.endsWith('()')) sortText = 'y' + sortText;
24
+ return {
25
+ label: name,
26
+ sortText,
27
+ documentation: getCSSDataDocumentation(data, {
28
+ generatedCSS: generateCSS([
29
+ syntax + name.slice(1)
30
+ ], css),
31
+ docs: 'selectors'
32
+ }),
33
+ kind,
34
+ data
35
+ };
36
+ });
37
+ for(const selectorName in css.config.selectors){
38
+ if (selectorName.startsWith('::')) continue;
39
+ const selectorValue = css.config.selectors[selectorName];
40
+ const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
41
+ const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
42
+ const data = pseudoClassDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
43
+ let sortText = name.startsWith(':-') ? 'yyyy' + name.slice(2) : 'yy' + name.replace(/^:/, '');
44
+ if (sortText.endsWith('()')) sortText = 'y' + sortText;
45
+ const completionItem = {
46
+ label: name,
47
+ documentation: getCSSDataDocumentation(data, {
48
+ generatedCSS: generateCSS([
49
+ syntax + name.slice(1)
50
+ ], css),
51
+ docs: 'selectors'
52
+ }),
53
+ sortText,
54
+ kind,
55
+ detail: String(value),
56
+ data
57
+ };
58
+ completionItems.push(completionItem);
59
+ }
60
+ return sortCompletionItems(completionItems);
61
+ }
62
+
63
+ export { getPseudoClassCompletionItems as default };
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ var css = require('@master/css');
4
+ var cssDataProvider = require('./css-data-provider.cjs');
5
+ var vscodeLanguageserverProtocol = require('vscode-languageserver-protocol');
6
+ var sortCompletionItems = require('./sort-completion-items.cjs');
7
+ var getCssDataDocumentation = require('./get-css-data-documentation.cjs');
8
+
9
+ const kind = vscodeLanguageserverProtocol.CompletionItemKind.Function;
10
+ function getPseudoElementCompletionItems(css$1 = new css.MasterCSS(), syntax) {
11
+ const pseudoElementDataList = cssDataProvider.providePseudoElements();
12
+ const completionItems = pseudoElementDataList.map((data)=>{
13
+ // fix https://github.com/microsoft/vscode-custom-data/issues/78
14
+ const name = /::(?:part|slotted)/.test(data.name) ? data.name + '()' : data.name;
15
+ let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
16
+ if (sortText.endsWith('()')) sortText = 'z' + sortText;
17
+ return {
18
+ label: name,
19
+ sortText,
20
+ documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
21
+ generatedCSS: css.generateCSS([
22
+ syntax + name.slice(2)
23
+ ], css$1),
24
+ docs: 'selectors'
25
+ }),
26
+ kind,
27
+ data
28
+ };
29
+ });
30
+ for(const selectorName in css$1.config.selectors){
31
+ if (!selectorName.startsWith('::')) continue;
32
+ const selectorValue = css$1.config.selectors[selectorName];
33
+ const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
34
+ const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
35
+ const data = pseudoElementDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
36
+ let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
37
+ if (sortText.endsWith('()')) sortText = 'z' + sortText;
38
+ const completionItem = {
39
+ label: name,
40
+ documentation: getCssDataDocumentation.getCSSDataDocumentation(data, {
41
+ generatedCSS: css.generateCSS([
42
+ syntax + name.slice(2)
43
+ ], css$1),
44
+ docs: 'selectors'
45
+ }),
46
+ sortText,
47
+ kind,
48
+ detail: String(value),
49
+ data
50
+ };
51
+ completionItems.push(completionItem);
52
+ }
53
+ return sortCompletionItems(completionItems);
54
+ }
55
+
56
+ module.exports = getPseudoElementCompletionItems;
@@ -0,0 +1,3 @@
1
+ import { MasterCSS } from '@master/css';
2
+ import { type CompletionItem } from 'vscode-languageserver-protocol';
3
+ export default function getPseudoElementCompletionItems(css: MasterCSS | undefined, syntax: string): CompletionItem[];
@@ -0,0 +1,54 @@
1
+ import { generateCSS, MasterCSS } from '@master/css';
2
+ import cssDataProvider from './css-data-provider.mjs';
3
+ import { CompletionItemKind } from 'vscode-languageserver-protocol';
4
+ import sortCompletionItems from './sort-completion-items.mjs';
5
+ import { getCSSDataDocumentation } from './get-css-data-documentation.mjs';
6
+
7
+ const kind = CompletionItemKind.Function;
8
+ function getPseudoElementCompletionItems(css = new MasterCSS(), syntax) {
9
+ const pseudoElementDataList = cssDataProvider.providePseudoElements();
10
+ const completionItems = pseudoElementDataList.map((data)=>{
11
+ // fix https://github.com/microsoft/vscode-custom-data/issues/78
12
+ const name = /::(?:part|slotted)/.test(data.name) ? data.name + '()' : data.name;
13
+ let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
14
+ if (sortText.endsWith('()')) sortText = 'z' + sortText;
15
+ return {
16
+ label: name,
17
+ sortText,
18
+ documentation: getCSSDataDocumentation(data, {
19
+ generatedCSS: generateCSS([
20
+ syntax + name.slice(2)
21
+ ], css),
22
+ docs: 'selectors'
23
+ }),
24
+ kind,
25
+ data
26
+ };
27
+ });
28
+ for(const selectorName in css.config.selectors){
29
+ if (!selectorName.startsWith('::')) continue;
30
+ const selectorValue = css.config.selectors[selectorName];
31
+ const name = selectorName.endsWith('(') ? selectorName + ')' : selectorName;
32
+ const value = typeof selectorValue === 'string' ? selectorValue.endsWith('(') ? selectorValue + ')' : selectorValue : selectorValue;
33
+ const data = pseudoElementDataList.find((data)=>typeof value === 'string' ? value.startsWith(data.name) : false);
34
+ let sortText = name.startsWith('::-') ? 'zzzz' + name.slice(3) : 'zz' + name.replace(/^::/, '');
35
+ if (sortText.endsWith('()')) sortText = 'z' + sortText;
36
+ const completionItem = {
37
+ label: name,
38
+ documentation: getCSSDataDocumentation(data, {
39
+ generatedCSS: generateCSS([
40
+ syntax + name.slice(2)
41
+ ], css),
42
+ docs: 'selectors'
43
+ }),
44
+ sortText,
45
+ kind,
46
+ detail: String(value),
47
+ data
48
+ };
49
+ completionItems.push(completionItem);
50
+ }
51
+ return sortCompletionItems(completionItems);
52
+ }
53
+
54
+ export { getPseudoElementCompletionItems as default };