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

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
@@ -1,37 +0,0 @@
1
- 'use strict';
2
-
3
- var regex = require('./utils/regex.cjs');
4
-
5
- function positionCheck(text, positionIndex, startIndex, RegExpList) {
6
- let result;
7
- let instanceMatch;
8
- let classMatch;
9
- for (const classRegexString of RegExpList){
10
- const classPattern = new RegExp(classRegexString, 'g');
11
- while((classMatch = classPattern.exec(text)) !== null){
12
- if ((classMatch.index <= positionIndex - startIndex && classMatch.index + classMatch[0].length >= positionIndex - startIndex) == true) {
13
- const classContentStartIndex = classMatch.index + classMatch[1].length;
14
- regex.instancePattern.lastIndex = 0;
15
- while((instanceMatch = regex.instancePattern.exec(classMatch[2])) !== null){
16
- const instanceStartIndex = classContentStartIndex + instanceMatch.index;
17
- const instanceEndIndex = classContentStartIndex + instanceMatch.index + instanceMatch[0].length;
18
- if (instanceStartIndex <= positionIndex - startIndex && instanceEndIndex >= positionIndex - startIndex) {
19
- result = {
20
- index: {
21
- start: instanceStartIndex,
22
- end: instanceEndIndex
23
- },
24
- instanceContent: instanceMatch[0]
25
- };
26
- return result;
27
- }
28
- }
29
- } else if (classMatch.index > positionIndex - startIndex) {
30
- break;
31
- }
32
- }
33
- }
34
- return null;
35
- }
36
-
37
- exports.positionCheck = positionCheck;
@@ -1,7 +0,0 @@
1
- export declare function positionCheck(text: string, positionIndex: number, startIndex: number, RegExpList: string[]): {
2
- index: {
3
- start: number;
4
- end: number;
5
- };
6
- instanceContent: string;
7
- } | null;
@@ -1,35 +0,0 @@
1
- import { instancePattern } from './utils/regex.mjs';
2
-
3
- function positionCheck(text, positionIndex, startIndex, RegExpList) {
4
- let result;
5
- let instanceMatch;
6
- let classMatch;
7
- for (const classRegexString of RegExpList){
8
- const classPattern = new RegExp(classRegexString, 'g');
9
- while((classMatch = classPattern.exec(text)) !== null){
10
- if ((classMatch.index <= positionIndex - startIndex && classMatch.index + classMatch[0].length >= positionIndex - startIndex) == true) {
11
- const classContentStartIndex = classMatch.index + classMatch[1].length;
12
- instancePattern.lastIndex = 0;
13
- while((instanceMatch = instancePattern.exec(classMatch[2])) !== null){
14
- const instanceStartIndex = classContentStartIndex + instanceMatch.index;
15
- const instanceEndIndex = classContentStartIndex + instanceMatch.index + instanceMatch[0].length;
16
- if (instanceStartIndex <= positionIndex - startIndex && instanceEndIndex >= positionIndex - startIndex) {
17
- result = {
18
- index: {
19
- start: instanceStartIndex,
20
- end: instanceEndIndex
21
- },
22
- instanceContent: instanceMatch[0]
23
- };
24
- return result;
25
- }
26
- }
27
- } else if (classMatch.index > positionIndex - startIndex) {
28
- break;
29
- }
30
- }
31
- }
32
- return null;
33
- }
34
-
35
- export { positionCheck };
@@ -1,319 +0,0 @@
1
- 'use strict';
2
-
3
- var css = require('@master/css');
4
- var hexToRgb = require('../utils/hex-to-rgb.cjs');
5
- var regex = require('../utils/regex.cjs');
6
- var toTwoDigitHex = require('../utils/to-two-digit-hex.cjs');
7
- var colorConvert = require('color-convert');
8
- var oklabToRgb = require('../utils/oklab-to-rgb.cjs');
9
- var oklchToOklab = require('../utils/oklch-to-oklab.cjs');
10
-
11
- async function getDocumentColors(text, css$1 = new css.MasterCSS()) {
12
- const colors = [];
13
- let instanceMatch;
14
- while((instanceMatch = regex.instancePattern.exec(text)) !== null){
15
- const instanceStartIndex = instanceMatch.index;
16
- // todo: refactor theme
17
- // const theme = css.themeNames.find(x => instanceMatch?.[0]?.endsWith(`@${x}`)) ?? ''
18
- const theme = '';
19
- const colorPattern = /(?<=[|:\s"'`]|^)(?:#?[\w-]+(?:-[\d]{1,2})?(?:\/.?[\d]*)?(?:\([^\s)]+\))?(?![:]))/g;
20
- let colorMatch;
21
- //check color
22
- while((colorMatch = colorPattern.exec(instanceMatch[0])) !== null){
23
- const colorValue = parseColorString(colorMatch[0], theme, css$1);
24
- if (colorValue) {
25
- const colorIndex = {
26
- index: {
27
- start: instanceStartIndex + colorMatch.index,
28
- end: instanceStartIndex + colorMatch.index + colorMatch[0].length
29
- },
30
- color: colorValue
31
- };
32
- colors.push(colorIndex);
33
- }
34
- }
35
- }
36
- return colors;
37
- }
38
- function percentageConverter(value, max = 1) {
39
- if (value === 'none') {
40
- return 0;
41
- } else if (value.endsWith('%')) {
42
- return max * Number(value.replace('%', '')) / 100;
43
- } else {
44
- return Number(value);
45
- }
46
- }
47
- function degConverter(value) {
48
- if (value === 'none') {
49
- return 0;
50
- } else if (value.endsWith('turn')) {
51
- return Number(value.replace('turn', '')) * 360;
52
- } else if (value.endsWith('grad')) {
53
- return Number(value.replace('grad', '')) * 0.9;
54
- } else if (value.endsWith('rad')) {
55
- return Number(value.replace('rad', '')) * 57.2957795;
56
- } else if (value.endsWith('deg')) {
57
- return Number(value.replace('deg', ''));
58
- } else {
59
- return Number(value);
60
- }
61
- }
62
- function parseColorString(colorString, theme, css$1 = new css.MasterCSS()) {
63
- const rgbaColorPattern = /rgb(?:a)?\(([\d.]+)[,|]([\d.]+)[,|]([\d.]+)(?:[,/]([\d.]+(?:%)?))?\)/g;
64
- const hslaColorPattern = /hsl(?:a)?\(([\d.]+(?:deg|turn|grad|rad)?|none)[,|]([\d.]+%|none)[,|]([\d.]+%|none)(?:[,/]([\d.]+(?:%)?))?\)/g;
65
- const hwbColorPattern = /hwb\(([\d.]+(?:deg|turn|grad|rad)?|none)[|]([\d.]+%|none)[|]([\d.]+%|none)(?:[/]([\d.]+(?:%)?))?\)/g;
66
- const oklchColorPattern = /oklch\(([\d.]+(?:%)?|none)[|]([\d.]+(?:%)?|none)[|]([\d.]+(?:deg|turn|grad|rad)?|none)(?:[/]([\d.]+(?:%)?))?\)/g;
67
- const lchColorPattern = /lch\(([\d.]+(?:%)?|none)[|]([\d.]+(?:%)?|none)[|]([\d.]+(?:deg|turn|grad|rad)?|none)(?:[/]([\d.]+(?:%)?))?\)/g;
68
- const oklabColorPattern = /oklab\(([\d.]+(?:%)?|none)[|](-?[\d.]+(?:%)?|none)[|](-?[\d.]+(?:%)?|none)(?:[/]([\d.]+(?:%)?))?\)/g;
69
- const labColorPattern = /lab\(([\d.]+(?:%)?|none)[|](-?[\d.]+(?:%)?|none)[|](-?[\d.]+(?:%)?|none)(?:[/]([\d.]+(?:%)?))?\)/g;
70
- const cmykColorPattern = /device-cmyk\(([\d.]+(?:%)?|none)[|]([\d.]+(?:%)?|none)[|]([\d.]+(?:%)?|none)[|]([\d.]+(?:%)?|none)(?:[/]([\d.]+(?:%)?))?(?:,\w+\(.*\))?\)/g;
71
- const hexColorPattern = /#([0-9a-fA-F]{6,8})/g;
72
- const colorFunctionPattern = /color?\((?:srgb|srgb-linear|display-p3|a98-rgb|prophoto-rgb|rec2020|xyz|xyz-d50|xyz-d65)[|]([\d.]+)[|]([\d.]+)[|]([\d.]+)(?:[/]([\d.]+(?:%)?))?\)/g;
73
- let colorMatch2;
74
- //#region for rgb、hls
75
- if (colorMatch2 = rgbaColorPattern.exec(colorString)) {
76
- return getColorValue({
77
- red: Number(colorMatch2[1]),
78
- green: Number(colorMatch2[2]),
79
- blue: Number(colorMatch2[3]),
80
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
81
- });
82
- } else if (colorMatch2 = hslaColorPattern.exec(colorString)) {
83
- const rgb = colorConvert.hsl.rgb([
84
- degConverter(colorMatch2[1]),
85
- percentageConverter(colorMatch2[2], 100),
86
- percentageConverter(colorMatch2[3], 100)
87
- ]);
88
- return getColorValue({
89
- red: rgb[0],
90
- green: rgb[1],
91
- blue: rgb[2],
92
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
93
- });
94
- } else if (colorMatch2 = hwbColorPattern.exec(colorString)) {
95
- const rgb = colorConvert.hwb.rgb([
96
- degConverter(colorMatch2[1]),
97
- percentageConverter(colorMatch2[2], 100),
98
- percentageConverter(colorMatch2[3], 100)
99
- ]);
100
- return getColorValue({
101
- red: rgb[0],
102
- green: rgb[1],
103
- blue: rgb[2],
104
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
105
- });
106
- } else if (colorMatch2 = oklchColorPattern.exec(colorString)) {
107
- const oklab = oklchToOklab.oklchToOklab([
108
- percentageConverter(colorMatch2[1]),
109
- percentageConverter(colorMatch2[2], 0.4),
110
- degConverter(colorMatch2[3])
111
- ]);
112
- const rgb = oklabToRgb.oklabToRgb(oklab);
113
- return getColorValue({
114
- red: rgb[0],
115
- green: rgb[1],
116
- blue: rgb[2],
117
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
118
- });
119
- } else if (colorMatch2 = lchColorPattern.exec(colorString)) {
120
- const rgb = colorConvert.lch.rgb([
121
- percentageConverter(colorMatch2[1], 100),
122
- percentageConverter(colorMatch2[2], 150),
123
- degConverter(colorMatch2[3])
124
- ]);
125
- return getColorValue({
126
- red: rgb[0],
127
- green: rgb[1],
128
- blue: rgb[2],
129
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
130
- });
131
- } else if (colorMatch2 = oklabColorPattern.exec(colorString)) {
132
- const rgb = oklabToRgb.oklabToRgb([
133
- percentageConverter(colorMatch2[1]),
134
- percentageConverter(colorMatch2[2], 0.4),
135
- percentageConverter(colorMatch2[3], 0.4)
136
- ]);
137
- return getColorValue({
138
- red: rgb[0],
139
- green: rgb[1],
140
- blue: rgb[2],
141
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
142
- });
143
- } else if (colorMatch2 = labColorPattern.exec(colorString)) {
144
- const rgb = colorConvert.lab.rgb([
145
- percentageConverter(colorMatch2[1], 100),
146
- percentageConverter(colorMatch2[2], 125),
147
- percentageConverter(colorMatch2[3], 125)
148
- ]);
149
- return getColorValue({
150
- red: rgb[0],
151
- green: rgb[1],
152
- blue: rgb[2],
153
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
154
- });
155
- } else if (colorMatch2 = cmykColorPattern.exec(colorString)) {
156
- const rgb = colorConvert.cmyk.rgb([
157
- percentageConverter(colorMatch2[1], 100),
158
- percentageConverter(colorMatch2[2], 100),
159
- percentageConverter(colorMatch2[3], 100),
160
- percentageConverter(colorMatch2[4], 100)
161
- ]);
162
- return getColorValue({
163
- red: rgb[0],
164
- green: rgb[1],
165
- blue: rgb[2],
166
- alpha: colorMatch2[5] == undefined ? 1 : percentageConverter(colorMatch2[5])
167
- });
168
- } else if (colorMatch2 = hexColorPattern.exec(colorString)) {
169
- return getColorValue(hexToRgb.hexToRgb(colorMatch2[1]));
170
- } else if (colorMatch2 = colorFunctionPattern.exec(colorString)) {
171
- return getColorValue({
172
- red: Number(colorMatch2[1]) * 255,
173
- green: Number(colorMatch2[2]) * 255,
174
- blue: Number(colorMatch2[3]) * 255,
175
- alpha: colorMatch2[4] == undefined ? 1 : percentageConverter(colorMatch2[4])
176
- });
177
- }
178
- //#endregion for rgb、hls
179
- //#region for mastercss color
180
- let colorAlpha = 1;
181
- let colorName = colorString;
182
- const allCSSColorNames = [];
183
- // todo: refactor css.variables
184
- for(const eachVariableName in css$1.variables){
185
- const eachVariable = css$1.variables[eachVariableName];
186
- if (eachVariable.type === 'color') allCSSColorNames.push(eachVariableName);
187
- }
188
- if (colorString.split('/').length == 2) {
189
- colorAlpha = Number('0' + colorString.split('/')[1]);
190
- }
191
- if (colorString.split('-').length == 1) {
192
- colorName = colorString.split('/')[0];
193
- colorName = colorName.endsWith('_') ? colorName.replace('_', '') : colorName;
194
- }
195
- if (allCSSColorNames.find((x)=>x == colorName)) {
196
- return getColorsRGBA(colorName, colorAlpha, theme, css$1);
197
- }
198
- //#endregion for mastercss color
199
- }
200
- function getColorsRGBA(colorName, colorAlpha = 1, theme = '', css$1 = new css.MasterCSS()) {
201
- try {
202
- // todo: refactor colorNumberMap
203
- const colorNumberMap = css$1.variables[colorName];
204
- const levelRgb = hexToRgb.hexToRgb(colorNumberMap[theme] ?? colorNumberMap[''] ?? Object.values(colorNumberMap)[0]);
205
- return {
206
- red: levelRgb.red / 255,
207
- green: levelRgb.green / 255,
208
- blue: levelRgb.blue / 255,
209
- alpha: colorAlpha
210
- };
211
- } catch (ex) {
212
- return {
213
- red: 0,
214
- green: 0,
215
- blue: 0,
216
- alpha: 1
217
- };
218
- }
219
- }
220
- function getColorValue(color) {
221
- return {
222
- red: color.red / 255.0,
223
- green: color.green / 255.0,
224
- blue: color.blue / 255.0,
225
- alpha: color.alpha
226
- };
227
- }
228
- function getColorPresentation(params, isColorRender = false) {
229
- const result = [];
230
- const color = params.color;
231
- const range = params.range;
232
- const red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
233
- let label;
234
- if (isColorRender) {
235
- if (color.alpha === 1) {
236
- label = `'#${toTwoDigitHex.toTwoDigitHex(red256)}${toTwoDigitHex.toTwoDigitHex(green256)}${toTwoDigitHex.toTwoDigitHex(blue256)}`;
237
- } else {
238
- label = `'#${toTwoDigitHex.toTwoDigitHex(red256)}${toTwoDigitHex.toTwoDigitHex(green256)}${toTwoDigitHex.toTwoDigitHex(blue256)}${toTwoDigitHex.toTwoDigitHex(Math.round(color.alpha * 255))}`;
239
- }
240
- result.push({
241
- label: label,
242
- textEdit: {
243
- range: range,
244
- newText: label
245
- }
246
- });
247
- return result;
248
- }
249
- if (color.alpha === 1) {
250
- label = `rgb(${red256},${green256},${blue256})`;
251
- } else {
252
- label = `rgba(${red256},${green256},${blue256},${color.alpha})`;
253
- }
254
- result.push({
255
- label: label,
256
- textEdit: {
257
- range: range,
258
- newText: label
259
- }
260
- });
261
- if (color.alpha === 1) {
262
- label = `#${toTwoDigitHex.toTwoDigitHex(red256)}${toTwoDigitHex.toTwoDigitHex(green256)}${toTwoDigitHex.toTwoDigitHex(blue256)}`;
263
- } else {
264
- label = `#${toTwoDigitHex.toTwoDigitHex(red256)}${toTwoDigitHex.toTwoDigitHex(green256)}${toTwoDigitHex.toTwoDigitHex(blue256)}${toTwoDigitHex.toTwoDigitHex(Math.round(color.alpha * 255))}`;
265
- }
266
- result.push({
267
- label: label,
268
- textEdit: {
269
- range: range,
270
- newText: label
271
- }
272
- });
273
- const hsl = colorConvert.rgb.hsl(red256, green256, blue256);
274
- if (color.alpha === 1) {
275
- label = `hsl(${hsl[0]},${Math.round(hsl[1])}%,${Math.round(hsl[2])}%)`;
276
- } else {
277
- label = `hsla(${hsl[0]},${Math.round(hsl[1])}%,${Math.round(hsl[2])}%,${color.alpha})`;
278
- }
279
- result.push({
280
- label: label,
281
- textEdit: {
282
- range: range,
283
- newText: label
284
- }
285
- });
286
- // const hwb = rgb.hwb(red256, green256, blue256)
287
- // if (color.alpha === 1) {
288
- // label = `hwb(${hwb[0]}|${hwb[1]}%|${hwb[2]}%)`
289
- // } else {
290
- // label = `hwb(${hwb[0]}|${hwb[1]}%|${hwb[2]}%/${color.alpha})`
291
- // }
292
- // result.push({ label: label, textEdit: { range: range, newText: label } })
293
- // const lab = rgb.lab(red256, green256, blue256)
294
- // if (color.alpha === 1) {
295
- // label = `lab(${lab[0]}%|${lab[1]}|${lab[2]})`
296
- // } else {
297
- // label = `lab(${lab[0]}%|${lab[1]}|${lab[2]}/${color.alpha})`
298
- // }
299
- // result.push({ label: label, textEdit: { range: range, newText: label } })
300
- // const lch = rgb.lch(red256, green256, blue256)
301
- // if (color.alpha === 1) {
302
- // label = `lch(${lch[0]}%|${lch[1]}|${lch[2]})`
303
- // } else {
304
- // label = `lch(${lch[0]}%|${lch[1]}|${lch[2]}/${color.alpha})`
305
- // }
306
- // result.push({ label: label, textEdit: { range: range, newText: label } })
307
- // const cmyk = rgb.cmyk(red256, green256, blue256)
308
- // if (color.alpha === 1) {
309
- // label = `device-cmyk(${cmyk[0]}%|${cmyk[1]}%|${cmyk[2]}%|${cmyk[3]}%)`
310
- // } else {
311
- // label = `device-cmyk(${cmyk[0]}%|${cmyk[1]}%|${cmyk[2]}%|${cmyk[3]}%/${color.alpha})`
312
- // }
313
- // result.push({ label: label, textEdit: { range: range, newText: label } })
314
- return result;
315
- }
316
-
317
- exports.getColorPresentation = getColorPresentation;
318
- exports.getColorValue = getColorValue;
319
- exports.getDocumentColors = getDocumentColors;
@@ -1,5 +0,0 @@
1
- import type { Color, ColorPresentation } from 'vscode-languageserver-types';
2
- import { MasterCSS } from '@master/css';
3
- export declare function getDocumentColors(text: string, css?: MasterCSS): Promise<any[]>;
4
- export declare function getColorValue(color: Color): Color;
5
- export declare function getColorPresentation(params: any, isColorRender?: boolean): ColorPresentation[];