vscode-css-languageservice 5.4.2 → 6.1.0
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.
- package/CHANGELOG.md +7 -1
- package/SECURITY.md +41 -0
- package/lib/esm/beautify/beautify-css.js +11 -4
- package/lib/esm/cssLanguageService.d.ts +2 -1
- package/lib/esm/cssLanguageService.js +15 -17
- package/lib/esm/cssLanguageTypes.js +2 -2
- package/lib/esm/data/webCustomData.js +356 -232
- package/lib/esm/languageFacts/builtinData.js +15 -15
- package/lib/esm/languageFacts/colors.js +66 -69
- package/lib/esm/languageFacts/dataManager.js +38 -42
- package/lib/esm/languageFacts/dataProvider.js +17 -23
- package/lib/esm/languageFacts/entry.js +22 -23
- package/lib/esm/parser/cssErrors.js +5 -7
- package/lib/esm/parser/cssNodes.js +869 -1377
- package/lib/esm/parser/cssParser.js +419 -376
- package/lib/esm/parser/cssScanner.js +168 -175
- package/lib/esm/parser/cssSymbolScope.js +107 -137
- package/lib/esm/parser/lessParser.js +177 -202
- package/lib/esm/parser/lessScanner.js +22 -43
- package/lib/esm/parser/scssErrors.js +5 -7
- package/lib/esm/parser/scssParser.js +196 -208
- package/lib/esm/parser/scssScanner.js +33 -54
- package/lib/esm/services/cssCodeActions.js +36 -40
- package/lib/esm/services/cssCompletion.js +300 -395
- package/lib/esm/services/cssFolding.js +32 -35
- package/lib/esm/services/cssFormatter.js +22 -22
- package/lib/esm/services/cssHover.js +30 -33
- package/lib/esm/services/cssNavigation.js +260 -289
- package/lib/esm/services/cssSelectionRange.js +6 -6
- package/lib/esm/services/cssValidation.js +13 -16
- package/lib/esm/services/lessCompletion.js +351 -370
- package/lib/esm/services/lint.js +161 -175
- package/lib/esm/services/lintRules.js +20 -27
- package/lib/esm/services/lintUtil.js +19 -28
- package/lib/esm/services/pathCompletion.js +84 -158
- package/lib/esm/services/scssCompletion.js +283 -307
- package/lib/esm/services/scssNavigation.js +65 -137
- package/lib/esm/services/selectorPrinting.js +131 -175
- package/lib/esm/utils/arrays.js +6 -12
- package/lib/esm/utils/objects.js +1 -1
- package/lib/esm/utils/resources.js +3 -16
- package/lib/esm/utils/strings.js +10 -12
- package/lib/umd/beautify/beautify-css.js +11 -4
- package/lib/umd/cssLanguageService.d.ts +2 -1
- package/lib/umd/cssLanguageService.js +34 -32
- package/lib/umd/cssLanguageTypes.js +4 -3
- package/lib/umd/data/webCustomData.js +355 -231
- package/lib/umd/languageFacts/colors.js +65 -68
- package/lib/umd/languageFacts/dataManager.js +41 -44
- package/lib/umd/languageFacts/dataProvider.js +17 -22
- package/lib/umd/languageFacts/entry.js +22 -23
- package/lib/umd/languageFacts/facts.js +5 -1
- package/lib/umd/parser/cssErrors.js +5 -6
- package/lib/umd/parser/cssNodes.js +870 -1307
- package/lib/umd/parser/cssParser.js +424 -380
- package/lib/umd/parser/cssScanner.js +168 -173
- package/lib/umd/parser/cssSymbolScope.js +109 -134
- package/lib/umd/parser/lessParser.js +182 -206
- package/lib/umd/parser/lessScanner.js +22 -42
- package/lib/umd/parser/scssErrors.js +5 -6
- package/lib/umd/parser/scssParser.js +202 -213
- package/lib/umd/parser/scssScanner.js +25 -45
- package/lib/umd/services/cssCodeActions.js +41 -44
- package/lib/umd/services/cssCompletion.js +308 -402
- package/lib/umd/services/cssFolding.js +35 -38
- package/lib/umd/services/cssFormatter.js +25 -25
- package/lib/umd/services/cssHover.js +36 -38
- package/lib/umd/services/cssNavigation.js +267 -295
- package/lib/umd/services/cssSelectionRange.js +8 -8
- package/lib/umd/services/cssValidation.js +17 -19
- package/lib/umd/services/lessCompletion.js +354 -372
- package/lib/umd/services/lint.js +167 -180
- package/lib/umd/services/lintRules.js +20 -24
- package/lib/umd/services/lintUtil.js +20 -28
- package/lib/umd/services/pathCompletion.js +87 -160
- package/lib/umd/services/scssCompletion.js +287 -310
- package/lib/umd/services/scssNavigation.js +69 -140
- package/lib/umd/services/selectorPrinting.js +134 -174
- package/lib/umd/utils/arrays.js +6 -12
- package/lib/umd/utils/objects.js +1 -1
- package/lib/umd/utils/resources.js +4 -17
- package/lib/umd/utils/strings.js +10 -12
- package/package.json +16 -15
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"use strict";
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.getColorValue = exports.hwbFromColor = exports.colorFromHWB = exports.hslFromColor = exports.colorFromHSL = exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = exports.isColorValue = exports.isColorConstructor = exports.colorKeywords = exports.colors = exports.colorFunctions = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const nodes = require("../parser/cssNodes");
|
|
18
|
+
const nls = require("vscode-nls");
|
|
19
|
+
const localize = nls.loadMessageBundle();
|
|
20
20
|
exports.colorFunctions = [
|
|
21
21
|
{ func: 'rgb($red, $green, $blue)', desc: localize('css.builtin.rgb', 'Creates a Color from red, green, and blue values.') },
|
|
22
22
|
{ func: 'rgba($red, $green, $blue, $alpha)', desc: localize('css.builtin.rgba', 'Creates a Color from red, green, blue, and alpha values.') },
|
|
@@ -179,13 +179,13 @@
|
|
|
179
179
|
'transparent': 'Fully transparent. This keyword can be considered a shorthand for rgba(0,0,0,0) which is its computed value.',
|
|
180
180
|
};
|
|
181
181
|
function getNumericValue(node, factor) {
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
const val = node.getText();
|
|
183
|
+
const m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(%?)$/);
|
|
184
184
|
if (m) {
|
|
185
185
|
if (m[2]) {
|
|
186
186
|
factor = 100.0;
|
|
187
187
|
}
|
|
188
|
-
|
|
188
|
+
const result = parseFloat(m[1]) / factor;
|
|
189
189
|
if (result >= 0 && result <= 1) {
|
|
190
190
|
return result;
|
|
191
191
|
}
|
|
@@ -193,8 +193,8 @@
|
|
|
193
193
|
throw new Error();
|
|
194
194
|
}
|
|
195
195
|
function getAngle(node) {
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
const val = node.getText();
|
|
197
|
+
const m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg|rad|grad|turn)?$/);
|
|
198
198
|
if (m) {
|
|
199
199
|
switch (m[2]) {
|
|
200
200
|
case 'deg':
|
|
@@ -214,7 +214,7 @@
|
|
|
214
214
|
throw new Error();
|
|
215
215
|
}
|
|
216
216
|
function isColorConstructor(node) {
|
|
217
|
-
|
|
217
|
+
const name = node.getName();
|
|
218
218
|
if (!name) {
|
|
219
219
|
return false;
|
|
220
220
|
}
|
|
@@ -237,7 +237,7 @@
|
|
|
237
237
|
if (node.parent && node.parent.type !== nodes.NodeType.Term) {
|
|
238
238
|
return false;
|
|
239
239
|
}
|
|
240
|
-
|
|
240
|
+
const candidateColor = node.getText().toLowerCase();
|
|
241
241
|
if (candidateColor === 'none') {
|
|
242
242
|
return false;
|
|
243
243
|
}
|
|
@@ -248,12 +248,12 @@
|
|
|
248
248
|
return false;
|
|
249
249
|
}
|
|
250
250
|
exports.isColorValue = isColorValue;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
251
|
+
const Digit0 = 48;
|
|
252
|
+
const Digit9 = 57;
|
|
253
|
+
const A = 65;
|
|
254
|
+
const F = 70;
|
|
255
|
+
const a = 97;
|
|
256
|
+
const f = 102;
|
|
257
257
|
function hexDigit(charCode) {
|
|
258
258
|
if (charCode < Digit0) {
|
|
259
259
|
return 0;
|
|
@@ -307,24 +307,22 @@
|
|
|
307
307
|
return null;
|
|
308
308
|
}
|
|
309
309
|
exports.colorFromHex = colorFromHex;
|
|
310
|
-
function colorFrom256RGB(red, green, blue, alpha) {
|
|
311
|
-
if (alpha === void 0) { alpha = 1.0; }
|
|
310
|
+
function colorFrom256RGB(red, green, blue, alpha = 1.0) {
|
|
312
311
|
return {
|
|
313
312
|
red: red / 255.0,
|
|
314
313
|
green: green / 255.0,
|
|
315
314
|
blue: blue / 255.0,
|
|
316
|
-
alpha
|
|
315
|
+
alpha
|
|
317
316
|
};
|
|
318
317
|
}
|
|
319
318
|
exports.colorFrom256RGB = colorFrom256RGB;
|
|
320
|
-
function colorFromHSL(hue, sat, light, alpha) {
|
|
321
|
-
if (alpha === void 0) { alpha = 1.0; }
|
|
319
|
+
function colorFromHSL(hue, sat, light, alpha = 1.0) {
|
|
322
320
|
hue = hue / 60.0;
|
|
323
321
|
if (sat === 0) {
|
|
324
|
-
return { red: light, green: light, blue: light, alpha
|
|
322
|
+
return { red: light, green: light, blue: light, alpha };
|
|
325
323
|
}
|
|
326
324
|
else {
|
|
327
|
-
|
|
325
|
+
const hueToRgb = (t1, t2, hue) => {
|
|
328
326
|
while (hue < 0) {
|
|
329
327
|
hue += 6;
|
|
330
328
|
}
|
|
@@ -342,23 +340,23 @@
|
|
|
342
340
|
}
|
|
343
341
|
return t1;
|
|
344
342
|
};
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
return { red: hueToRgb(t1, t2, hue + 2), green: hueToRgb(t1, t2, hue), blue: hueToRgb(t1, t2, hue - 2), alpha
|
|
343
|
+
const t2 = light <= 0.5 ? (light * (sat + 1)) : (light + sat - (light * sat));
|
|
344
|
+
const t1 = light * 2 - t2;
|
|
345
|
+
return { red: hueToRgb(t1, t2, hue + 2), green: hueToRgb(t1, t2, hue), blue: hueToRgb(t1, t2, hue - 2), alpha };
|
|
348
346
|
}
|
|
349
347
|
}
|
|
350
348
|
exports.colorFromHSL = colorFromHSL;
|
|
351
349
|
function hslFromColor(rgba) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
350
|
+
const r = rgba.red;
|
|
351
|
+
const g = rgba.green;
|
|
352
|
+
const b = rgba.blue;
|
|
353
|
+
const a = rgba.alpha;
|
|
354
|
+
const max = Math.max(r, g, b);
|
|
355
|
+
const min = Math.min(r, g, b);
|
|
356
|
+
let h = 0;
|
|
357
|
+
let s = 0;
|
|
358
|
+
const l = (min + max) / 2;
|
|
359
|
+
const chroma = max - min;
|
|
362
360
|
if (chroma > 0) {
|
|
363
361
|
s = Math.min((l <= 0.5 ? chroma / (2 * l) : chroma / (2 - (2 * l))), 1);
|
|
364
362
|
switch (max) {
|
|
@@ -375,37 +373,36 @@
|
|
|
375
373
|
h *= 60;
|
|
376
374
|
h = Math.round(h);
|
|
377
375
|
}
|
|
378
|
-
return { h
|
|
376
|
+
return { h, s, l, a };
|
|
379
377
|
}
|
|
380
378
|
exports.hslFromColor = hslFromColor;
|
|
381
|
-
function colorFromHWB(hue, white, black, alpha) {
|
|
382
|
-
if (alpha === void 0) { alpha = 1.0; }
|
|
379
|
+
function colorFromHWB(hue, white, black, alpha = 1.0) {
|
|
383
380
|
if (white + black >= 1) {
|
|
384
|
-
|
|
385
|
-
return { red: gray, green: gray, blue: gray, alpha
|
|
381
|
+
const gray = white / (white + black);
|
|
382
|
+
return { red: gray, green: gray, blue: gray, alpha };
|
|
386
383
|
}
|
|
387
|
-
|
|
388
|
-
|
|
384
|
+
const rgb = colorFromHSL(hue, 1, 0.5, alpha);
|
|
385
|
+
let red = rgb.red;
|
|
389
386
|
red *= (1 - white - black);
|
|
390
387
|
red += white;
|
|
391
|
-
|
|
388
|
+
let green = rgb.green;
|
|
392
389
|
green *= (1 - white - black);
|
|
393
390
|
green += white;
|
|
394
|
-
|
|
391
|
+
let blue = rgb.blue;
|
|
395
392
|
blue *= (1 - white - black);
|
|
396
393
|
blue += white;
|
|
397
394
|
return {
|
|
398
395
|
red: red,
|
|
399
396
|
green: green,
|
|
400
397
|
blue: blue,
|
|
401
|
-
alpha
|
|
398
|
+
alpha
|
|
402
399
|
};
|
|
403
400
|
}
|
|
404
401
|
exports.colorFromHWB = colorFromHWB;
|
|
405
402
|
function hwbFromColor(rgba) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
403
|
+
const hsl = hslFromColor(rgba);
|
|
404
|
+
const white = Math.min(rgba.red, rgba.green, rgba.blue);
|
|
405
|
+
const black = 1 - Math.max(rgba.red, rgba.green, rgba.blue);
|
|
409
406
|
return {
|
|
410
407
|
h: hsl.h,
|
|
411
408
|
w: white,
|
|
@@ -416,21 +413,21 @@
|
|
|
416
413
|
exports.hwbFromColor = hwbFromColor;
|
|
417
414
|
function getColorValue(node) {
|
|
418
415
|
if (node.type === nodes.NodeType.HexColorValue) {
|
|
419
|
-
|
|
416
|
+
const text = node.getText();
|
|
420
417
|
return colorFromHex(text);
|
|
421
418
|
}
|
|
422
419
|
else if (node.type === nodes.NodeType.Function) {
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
420
|
+
const functionNode = node;
|
|
421
|
+
const name = functionNode.getName();
|
|
422
|
+
let colorValues = functionNode.getArguments().getChildren();
|
|
426
423
|
if (colorValues.length === 1) {
|
|
427
|
-
|
|
424
|
+
const functionArg = colorValues[0].getChildren();
|
|
428
425
|
if (functionArg.length === 1 && functionArg[0].type === nodes.NodeType.Expression) {
|
|
429
426
|
colorValues = functionArg[0].getChildren();
|
|
430
427
|
if (colorValues.length === 3) {
|
|
431
|
-
|
|
428
|
+
const lastValue = colorValues[2];
|
|
432
429
|
if (lastValue instanceof nodes.BinaryExpression) {
|
|
433
|
-
|
|
430
|
+
const left = lastValue.getLeft(), right = lastValue.getRight(), operator = lastValue.getOperator();
|
|
434
431
|
if (left && right && operator && operator.matches('/')) {
|
|
435
432
|
colorValues = [colorValues[0], colorValues[1], left, right];
|
|
436
433
|
}
|
|
@@ -442,25 +439,25 @@
|
|
|
442
439
|
return null;
|
|
443
440
|
}
|
|
444
441
|
try {
|
|
445
|
-
|
|
442
|
+
const alpha = colorValues.length === 4 ? getNumericValue(colorValues[3], 1) : 1;
|
|
446
443
|
if (name === 'rgb' || name === 'rgba') {
|
|
447
444
|
return {
|
|
448
445
|
red: getNumericValue(colorValues[0], 255.0),
|
|
449
446
|
green: getNumericValue(colorValues[1], 255.0),
|
|
450
447
|
blue: getNumericValue(colorValues[2], 255.0),
|
|
451
|
-
alpha
|
|
448
|
+
alpha
|
|
452
449
|
};
|
|
453
450
|
}
|
|
454
451
|
else if (name === 'hsl' || name === 'hsla') {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
452
|
+
const h = getAngle(colorValues[0]);
|
|
453
|
+
const s = getNumericValue(colorValues[1], 100.0);
|
|
454
|
+
const l = getNumericValue(colorValues[2], 100.0);
|
|
458
455
|
return colorFromHSL(h, s, l, alpha);
|
|
459
456
|
}
|
|
460
457
|
else if (name === 'hwb') {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
458
|
+
const h = getAngle(colorValues[0]);
|
|
459
|
+
const w = getNumericValue(colorValues[1], 100.0);
|
|
460
|
+
const b = getNumericValue(colorValues[2], 100.0);
|
|
464
461
|
return colorFromHWB(h, w, b, alpha);
|
|
465
462
|
}
|
|
466
463
|
}
|
|
@@ -473,18 +470,18 @@
|
|
|
473
470
|
if (node.parent && node.parent.type !== nodes.NodeType.Term) {
|
|
474
471
|
return null;
|
|
475
472
|
}
|
|
476
|
-
|
|
473
|
+
const term = node.parent;
|
|
477
474
|
if (term && term.parent && term.parent.type === nodes.NodeType.BinaryExpression) {
|
|
478
|
-
|
|
475
|
+
const expression = term.parent;
|
|
479
476
|
if (expression.parent && expression.parent.type === nodes.NodeType.ListEntry && expression.parent.key === expression) {
|
|
480
477
|
return null;
|
|
481
478
|
}
|
|
482
479
|
}
|
|
483
|
-
|
|
480
|
+
const candidateColor = node.getText().toLowerCase();
|
|
484
481
|
if (candidateColor === 'none') {
|
|
485
482
|
return null;
|
|
486
483
|
}
|
|
487
|
-
|
|
484
|
+
const colorHex = exports.colors[candidateColor];
|
|
488
485
|
if (colorHex) {
|
|
489
486
|
return colorFromHex(colorHex);
|
|
490
487
|
}
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.CSSDataManager = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const objects = require("../utils/objects");
|
|
18
|
+
const webCustomData_1 = require("../data/webCustomData");
|
|
19
|
+
const dataProvider_1 = require("./dataProvider");
|
|
20
|
+
class CSSDataManager {
|
|
21
|
+
constructor(options) {
|
|
22
22
|
this.dataProviders = [];
|
|
23
23
|
this._propertySet = {};
|
|
24
24
|
this._atDirectiveSet = {};
|
|
@@ -28,45 +28,43 @@
|
|
|
28
28
|
this._atDirectives = [];
|
|
29
29
|
this._pseudoClasses = [];
|
|
30
30
|
this._pseudoElements = [];
|
|
31
|
-
this.setDataProviders(
|
|
31
|
+
this.setDataProviders(options?.useDefaultDataProvider !== false, options?.customDataProviders || []);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
var _a;
|
|
33
|
+
setDataProviders(builtIn, providers) {
|
|
35
34
|
this.dataProviders = [];
|
|
36
35
|
if (builtIn) {
|
|
37
36
|
this.dataProviders.push(new dataProvider_1.CSSDataProvider(webCustomData_1.cssData));
|
|
38
37
|
}
|
|
39
|
-
|
|
38
|
+
this.dataProviders.push(...providers);
|
|
40
39
|
this.collectData();
|
|
41
|
-
}
|
|
40
|
+
}
|
|
42
41
|
/**
|
|
43
42
|
* Collect all data & handle duplicates
|
|
44
43
|
*/
|
|
45
|
-
|
|
46
|
-
var _this = this;
|
|
44
|
+
collectData() {
|
|
47
45
|
this._propertySet = {};
|
|
48
46
|
this._atDirectiveSet = {};
|
|
49
47
|
this._pseudoClassSet = {};
|
|
50
48
|
this._pseudoElementSet = {};
|
|
51
|
-
this.dataProviders.forEach(
|
|
52
|
-
provider.provideProperties().forEach(
|
|
53
|
-
if (!
|
|
54
|
-
|
|
49
|
+
this.dataProviders.forEach(provider => {
|
|
50
|
+
provider.provideProperties().forEach(p => {
|
|
51
|
+
if (!this._propertySet[p.name]) {
|
|
52
|
+
this._propertySet[p.name] = p;
|
|
55
53
|
}
|
|
56
54
|
});
|
|
57
|
-
provider.provideAtDirectives().forEach(
|
|
58
|
-
if (!
|
|
59
|
-
|
|
55
|
+
provider.provideAtDirectives().forEach(p => {
|
|
56
|
+
if (!this._atDirectiveSet[p.name]) {
|
|
57
|
+
this._atDirectiveSet[p.name] = p;
|
|
60
58
|
}
|
|
61
59
|
});
|
|
62
|
-
provider.providePseudoClasses().forEach(
|
|
63
|
-
if (!
|
|
64
|
-
|
|
60
|
+
provider.providePseudoClasses().forEach(p => {
|
|
61
|
+
if (!this._pseudoClassSet[p.name]) {
|
|
62
|
+
this._pseudoClassSet[p.name] = p;
|
|
65
63
|
}
|
|
66
64
|
});
|
|
67
|
-
provider.providePseudoElements().forEach(
|
|
68
|
-
if (!
|
|
69
|
-
|
|
65
|
+
provider.providePseudoElements().forEach(p => {
|
|
66
|
+
if (!this._pseudoElementSet[p.name]) {
|
|
67
|
+
this._pseudoElementSet[p.name] = p;
|
|
70
68
|
}
|
|
71
69
|
});
|
|
72
70
|
});
|
|
@@ -74,31 +72,30 @@
|
|
|
74
72
|
this._atDirectives = objects.values(this._atDirectiveSet);
|
|
75
73
|
this._pseudoClasses = objects.values(this._pseudoClassSet);
|
|
76
74
|
this._pseudoElements = objects.values(this._pseudoElementSet);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
}
|
|
76
|
+
getProperty(name) { return this._propertySet[name]; }
|
|
77
|
+
getAtDirective(name) { return this._atDirectiveSet[name]; }
|
|
78
|
+
getPseudoClass(name) { return this._pseudoClassSet[name]; }
|
|
79
|
+
getPseudoElement(name) { return this._pseudoElementSet[name]; }
|
|
80
|
+
getProperties() {
|
|
83
81
|
return this._properties;
|
|
84
|
-
}
|
|
85
|
-
|
|
82
|
+
}
|
|
83
|
+
getAtDirectives() {
|
|
86
84
|
return this._atDirectives;
|
|
87
|
-
}
|
|
88
|
-
|
|
85
|
+
}
|
|
86
|
+
getPseudoClasses() {
|
|
89
87
|
return this._pseudoClasses;
|
|
90
|
-
}
|
|
91
|
-
|
|
88
|
+
}
|
|
89
|
+
getPseudoElements() {
|
|
92
90
|
return this._pseudoElements;
|
|
93
|
-
}
|
|
94
|
-
|
|
91
|
+
}
|
|
92
|
+
isKnownProperty(name) {
|
|
95
93
|
return name.toLowerCase() in this._propertySet;
|
|
96
|
-
}
|
|
97
|
-
|
|
94
|
+
}
|
|
95
|
+
isStandardProperty(name) {
|
|
98
96
|
return this.isKnownProperty(name) &&
|
|
99
97
|
(!this._propertySet[name.toLowerCase()].status || this._propertySet[name.toLowerCase()].status === 'standard');
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
}());
|
|
98
|
+
}
|
|
99
|
+
}
|
|
103
100
|
exports.CSSDataManager = CSSDataManager;
|
|
104
101
|
});
|
|
@@ -14,67 +14,62 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.CSSDataProvider = void 0;
|
|
17
|
-
|
|
17
|
+
class CSSDataProvider {
|
|
18
18
|
/**
|
|
19
19
|
* Currently, unversioned data uses the V1 implementation
|
|
20
20
|
* In the future when the provider handles multiple versions of HTML custom data,
|
|
21
21
|
* use the latest implementation for unversioned data
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
constructor(data) {
|
|
24
24
|
this._properties = [];
|
|
25
25
|
this._atDirectives = [];
|
|
26
26
|
this._pseudoClasses = [];
|
|
27
27
|
this._pseudoElements = [];
|
|
28
28
|
this.addData(data);
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
provideProperties() {
|
|
31
31
|
return this._properties;
|
|
32
|
-
}
|
|
33
|
-
|
|
32
|
+
}
|
|
33
|
+
provideAtDirectives() {
|
|
34
34
|
return this._atDirectives;
|
|
35
|
-
}
|
|
36
|
-
|
|
35
|
+
}
|
|
36
|
+
providePseudoClasses() {
|
|
37
37
|
return this._pseudoClasses;
|
|
38
|
-
}
|
|
39
|
-
|
|
38
|
+
}
|
|
39
|
+
providePseudoElements() {
|
|
40
40
|
return this._pseudoElements;
|
|
41
|
-
}
|
|
42
|
-
|
|
41
|
+
}
|
|
42
|
+
addData(data) {
|
|
43
43
|
if (Array.isArray(data.properties)) {
|
|
44
|
-
for (
|
|
45
|
-
var prop = _a[_i];
|
|
44
|
+
for (const prop of data.properties) {
|
|
46
45
|
if (isPropertyData(prop)) {
|
|
47
46
|
this._properties.push(prop);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
if (Array.isArray(data.atDirectives)) {
|
|
52
|
-
for (
|
|
53
|
-
var prop = _c[_b];
|
|
51
|
+
for (const prop of data.atDirectives) {
|
|
54
52
|
if (isAtDirective(prop)) {
|
|
55
53
|
this._atDirectives.push(prop);
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
if (Array.isArray(data.pseudoClasses)) {
|
|
60
|
-
for (
|
|
61
|
-
var prop = _e[_d];
|
|
58
|
+
for (const prop of data.pseudoClasses) {
|
|
62
59
|
if (isPseudoClassData(prop)) {
|
|
63
60
|
this._pseudoClasses.push(prop);
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
if (Array.isArray(data.pseudoElements)) {
|
|
68
|
-
for (
|
|
69
|
-
var prop = _g[_f];
|
|
65
|
+
for (const prop of data.pseudoElements) {
|
|
70
66
|
if (isPseudoElementData(prop)) {
|
|
71
67
|
this._pseudoElements.push(prop);
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
}());
|
|
71
|
+
}
|
|
72
|
+
}
|
|
78
73
|
exports.CSSDataProvider = CSSDataProvider;
|
|
79
74
|
function isPropertyData(d) {
|
|
80
75
|
return typeof d.name === 'string';
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.getBrowserLabel = exports.textToMarkedString = exports.getEntryDescription = exports.browserNames = void 0;
|
|
17
|
-
|
|
17
|
+
const cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
18
18
|
exports.browserNames = {
|
|
19
19
|
E: 'Edge',
|
|
20
20
|
FF: 'Firefox',
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
function getEntryDescription(entry, doesSupportMarkdown, settings) {
|
|
39
|
-
|
|
39
|
+
let result;
|
|
40
40
|
if (doesSupportMarkdown) {
|
|
41
41
|
result = {
|
|
42
42
|
kind: 'markdown',
|
|
@@ -67,26 +67,26 @@
|
|
|
67
67
|
if (typeof entry.description !== 'string') {
|
|
68
68
|
return entry.description.value;
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
if (
|
|
70
|
+
let result = '';
|
|
71
|
+
if (settings?.documentation !== false) {
|
|
72
72
|
if (entry.status) {
|
|
73
73
|
result += getEntryStatus(entry.status);
|
|
74
74
|
}
|
|
75
75
|
result += entry.description;
|
|
76
|
-
|
|
76
|
+
const browserLabel = getBrowserLabel(entry.browsers);
|
|
77
77
|
if (browserLabel) {
|
|
78
78
|
result += '\n(' + browserLabel + ')';
|
|
79
79
|
}
|
|
80
80
|
if ('syntax' in entry) {
|
|
81
|
-
result +=
|
|
81
|
+
result += `\n\nSyntax: ${entry.syntax}`;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
if (entry.references && entry.references.length > 0 &&
|
|
84
|
+
if (entry.references && entry.references.length > 0 && settings?.references !== false) {
|
|
85
85
|
if (result.length > 0) {
|
|
86
86
|
result += '\n\n';
|
|
87
87
|
}
|
|
88
|
-
result += entry.references.map(
|
|
89
|
-
return
|
|
88
|
+
result += entry.references.map(r => {
|
|
89
|
+
return `${r.name}: ${r.url}`;
|
|
90
90
|
}).join(' | ');
|
|
91
91
|
}
|
|
92
92
|
return result;
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
if (!entry.description || entry.description === '') {
|
|
96
96
|
return '';
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
if (
|
|
98
|
+
let result = '';
|
|
99
|
+
if (settings?.documentation !== false) {
|
|
100
100
|
if (entry.status) {
|
|
101
101
|
result += getEntryStatus(entry.status);
|
|
102
102
|
}
|
|
@@ -106,20 +106,20 @@
|
|
|
106
106
|
else {
|
|
107
107
|
result += entry.description.kind === cssLanguageTypes_1.MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
const browserLabel = getBrowserLabel(entry.browsers);
|
|
110
110
|
if (browserLabel) {
|
|
111
111
|
result += '\n\n(' + textToMarkedString(browserLabel) + ')';
|
|
112
112
|
}
|
|
113
113
|
if ('syntax' in entry && entry.syntax) {
|
|
114
|
-
result +=
|
|
114
|
+
result += `\n\nSyntax: ${textToMarkedString(entry.syntax)}`;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
if (entry.references && entry.references.length > 0 &&
|
|
117
|
+
if (entry.references && entry.references.length > 0 && settings?.references !== false) {
|
|
118
118
|
if (result.length > 0) {
|
|
119
119
|
result += '\n\n';
|
|
120
120
|
}
|
|
121
|
-
result += entry.references.map(
|
|
122
|
-
return
|
|
121
|
+
result += entry.references.map(r => {
|
|
122
|
+
return `[${r.name}](${r.url})`;
|
|
123
123
|
}).join(' | ');
|
|
124
124
|
}
|
|
125
125
|
return result;
|
|
@@ -128,17 +128,16 @@
|
|
|
128
128
|
* Input is like `["E12","FF49","C47","IE","O"]`
|
|
129
129
|
* Output is like `Edge 12, Firefox 49, Chrome 47, IE, Opera`
|
|
130
130
|
*/
|
|
131
|
-
function getBrowserLabel(browsers) {
|
|
132
|
-
if (browsers === void 0) { browsers = []; }
|
|
131
|
+
function getBrowserLabel(browsers = []) {
|
|
133
132
|
if (browsers.length === 0) {
|
|
134
133
|
return null;
|
|
135
134
|
}
|
|
136
135
|
return browsers
|
|
137
|
-
.map(
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
.map(b => {
|
|
137
|
+
let result = '';
|
|
138
|
+
const matches = b.match(/([A-Z]+)(\d+)?/);
|
|
139
|
+
const name = matches[1];
|
|
140
|
+
const version = matches[2];
|
|
142
141
|
if (name in exports.browserNames) {
|
|
143
142
|
result += exports.browserNames[name];
|
|
144
143
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
2
|
if (k2 === undefined) k2 = k;
|
|
3
|
-
Object.
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
4
8
|
}) : (function(o, m, k, k2) {
|
|
5
9
|
if (k2 === undefined) k2 = k;
|
|
6
10
|
o[k2] = m[k];
|
|
@@ -14,15 +14,14 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.ParseError = exports.CSSIssueType = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const nls = require("vscode-nls");
|
|
18
|
+
const localize = nls.loadMessageBundle();
|
|
19
|
+
class CSSIssueType {
|
|
20
|
+
constructor(id, message) {
|
|
21
21
|
this.id = id;
|
|
22
22
|
this.message = message;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
}());
|
|
24
|
+
}
|
|
26
25
|
exports.CSSIssueType = CSSIssueType;
|
|
27
26
|
exports.ParseError = {
|
|
28
27
|
NumberExpected: new CSSIssueType('css-numberexpected', localize('expected.number', "number expected")),
|