vscode-css-languageservice 5.4.1 → 6.0.1
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 +5 -1
- package/README.md +1 -0
- package/lib/esm/beautify/beautify-css.js +50 -8
- package/lib/esm/cssLanguageService.d.ts +37 -37
- package/lib/esm/cssLanguageService.js +72 -75
- package/lib/esm/cssLanguageTypes.d.ts +238 -238
- package/lib/esm/cssLanguageTypes.js +42 -42
- package/lib/esm/data/webCustomData.js +21959 -21965
- package/lib/esm/languageFacts/builtinData.js +142 -142
- package/lib/esm/languageFacts/colors.js +469 -472
- package/lib/esm/languageFacts/dataManager.js +88 -92
- package/lib/esm/languageFacts/dataProvider.js +73 -79
- package/lib/esm/languageFacts/entry.js +137 -138
- package/lib/esm/languageFacts/facts.js +8 -8
- package/lib/esm/parser/cssErrors.js +48 -50
- package/lib/esm/parser/cssNodes.js +1502 -2019
- package/lib/esm/parser/cssParser.js +1534 -1566
- package/lib/esm/parser/cssScanner.js +592 -599
- package/lib/esm/parser/cssSymbolScope.js +311 -341
- package/lib/esm/parser/lessParser.js +714 -740
- package/lib/esm/parser/lessScanner.js +57 -78
- package/lib/esm/parser/scssErrors.js +18 -20
- package/lib/esm/parser/scssParser.js +796 -818
- package/lib/esm/parser/scssScanner.js +95 -116
- package/lib/esm/services/cssCodeActions.js +77 -81
- package/lib/esm/services/cssCompletion.js +1054 -1149
- package/lib/esm/services/cssFolding.js +190 -193
- package/lib/esm/services/cssFormatter.js +136 -136
- package/lib/esm/services/cssHover.js +148 -151
- package/lib/esm/services/cssNavigation.js +378 -470
- package/lib/esm/services/cssSelectionRange.js +47 -47
- package/lib/esm/services/cssValidation.js +41 -44
- package/lib/esm/services/lessCompletion.js +378 -397
- package/lib/esm/services/lint.js +518 -532
- package/lib/esm/services/lintRules.js +76 -83
- package/lib/esm/services/lintUtil.js +196 -205
- package/lib/esm/services/pathCompletion.js +157 -231
- package/lib/esm/services/scssCompletion.js +354 -378
- package/lib/esm/services/scssNavigation.js +82 -154
- package/lib/esm/services/selectorPrinting.js +492 -536
- package/lib/esm/utils/arrays.js +40 -46
- package/lib/esm/utils/objects.js +11 -11
- package/lib/esm/utils/resources.js +11 -24
- package/lib/esm/utils/strings.js +102 -104
- package/lib/umd/beautify/beautify-css.js +50 -8
- package/lib/umd/cssLanguageService.d.ts +37 -37
- package/lib/umd/cssLanguageService.js +99 -102
- package/lib/umd/cssLanguageTypes.d.ts +238 -238
- package/lib/umd/cssLanguageTypes.js +89 -88
- package/lib/umd/data/webCustomData.js +21972 -21978
- package/lib/umd/languageFacts/builtinData.js +154 -154
- package/lib/umd/languageFacts/colors.js +492 -495
- package/lib/umd/languageFacts/dataManager.js +101 -104
- package/lib/umd/languageFacts/dataProvider.js +86 -91
- package/lib/umd/languageFacts/entry.js +152 -153
- package/lib/umd/languageFacts/facts.js +29 -29
- package/lib/umd/parser/cssErrors.js +61 -62
- package/lib/umd/parser/cssNodes.js +1587 -2034
- package/lib/umd/parser/cssParser.js +1547 -1578
- package/lib/umd/parser/cssScanner.js +606 -611
- package/lib/umd/parser/cssSymbolScope.js +328 -353
- package/lib/umd/parser/lessParser.js +727 -752
- package/lib/umd/parser/lessScanner.js +70 -90
- package/lib/umd/parser/scssErrors.js +31 -32
- package/lib/umd/parser/scssParser.js +809 -830
- package/lib/umd/parser/scssScanner.js +108 -128
- package/lib/umd/services/cssCodeActions.js +90 -93
- package/lib/umd/services/cssCompletion.js +1067 -1161
- package/lib/umd/services/cssFolding.js +203 -206
- package/lib/umd/services/cssFormatter.js +150 -150
- package/lib/umd/services/cssHover.js +161 -163
- package/lib/umd/services/cssNavigation.js +391 -482
- package/lib/umd/services/cssSelectionRange.js +60 -60
- package/lib/umd/services/cssValidation.js +54 -56
- package/lib/umd/services/lessCompletion.js +391 -409
- package/lib/umd/services/lint.js +531 -544
- package/lib/umd/services/lintRules.js +91 -95
- package/lib/umd/services/lintUtil.js +210 -218
- package/lib/umd/services/pathCompletion.js +171 -244
- package/lib/umd/services/scssCompletion.js +367 -390
- package/lib/umd/services/scssNavigation.js +95 -166
- package/lib/umd/services/selectorPrinting.js +510 -550
- package/lib/umd/utils/arrays.js +55 -61
- package/lib/umd/utils/objects.js +25 -25
- package/lib/umd/utils/resources.js +26 -39
- package/lib/umd/utils/strings.js +120 -122
- package/package.json +11 -11
|
@@ -1,92 +1,88 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
'use strict';
|
|
6
|
-
import * as objects from '../utils/objects';
|
|
7
|
-
import { cssData } from '../data/webCustomData';
|
|
8
|
-
import { CSSDataProvider } from './dataProvider';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.dataProviders = [];
|
|
12
|
-
this._propertySet = {};
|
|
13
|
-
this._atDirectiveSet = {};
|
|
14
|
-
this._pseudoClassSet = {};
|
|
15
|
-
this._pseudoElementSet = {};
|
|
16
|
-
this._properties = [];
|
|
17
|
-
this._atDirectives = [];
|
|
18
|
-
this._pseudoClasses = [];
|
|
19
|
-
this._pseudoElements = [];
|
|
20
|
-
this.setDataProviders(
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
return CSSDataManager;
|
|
91
|
-
}());
|
|
92
|
-
export { CSSDataManager };
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
'use strict';
|
|
6
|
+
import * as objects from '../utils/objects';
|
|
7
|
+
import { cssData } from '../data/webCustomData';
|
|
8
|
+
import { CSSDataProvider } from './dataProvider';
|
|
9
|
+
export class CSSDataManager {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.dataProviders = [];
|
|
12
|
+
this._propertySet = {};
|
|
13
|
+
this._atDirectiveSet = {};
|
|
14
|
+
this._pseudoClassSet = {};
|
|
15
|
+
this._pseudoElementSet = {};
|
|
16
|
+
this._properties = [];
|
|
17
|
+
this._atDirectives = [];
|
|
18
|
+
this._pseudoClasses = [];
|
|
19
|
+
this._pseudoElements = [];
|
|
20
|
+
this.setDataProviders(options?.useDefaultDataProvider !== false, options?.customDataProviders || []);
|
|
21
|
+
}
|
|
22
|
+
setDataProviders(builtIn, providers) {
|
|
23
|
+
this.dataProviders = [];
|
|
24
|
+
if (builtIn) {
|
|
25
|
+
this.dataProviders.push(new CSSDataProvider(cssData));
|
|
26
|
+
}
|
|
27
|
+
this.dataProviders.push(...providers);
|
|
28
|
+
this.collectData();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Collect all data & handle duplicates
|
|
32
|
+
*/
|
|
33
|
+
collectData() {
|
|
34
|
+
this._propertySet = {};
|
|
35
|
+
this._atDirectiveSet = {};
|
|
36
|
+
this._pseudoClassSet = {};
|
|
37
|
+
this._pseudoElementSet = {};
|
|
38
|
+
this.dataProviders.forEach(provider => {
|
|
39
|
+
provider.provideProperties().forEach(p => {
|
|
40
|
+
if (!this._propertySet[p.name]) {
|
|
41
|
+
this._propertySet[p.name] = p;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
provider.provideAtDirectives().forEach(p => {
|
|
45
|
+
if (!this._atDirectiveSet[p.name]) {
|
|
46
|
+
this._atDirectiveSet[p.name] = p;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
provider.providePseudoClasses().forEach(p => {
|
|
50
|
+
if (!this._pseudoClassSet[p.name]) {
|
|
51
|
+
this._pseudoClassSet[p.name] = p;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
provider.providePseudoElements().forEach(p => {
|
|
55
|
+
if (!this._pseudoElementSet[p.name]) {
|
|
56
|
+
this._pseudoElementSet[p.name] = p;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
this._properties = objects.values(this._propertySet);
|
|
61
|
+
this._atDirectives = objects.values(this._atDirectiveSet);
|
|
62
|
+
this._pseudoClasses = objects.values(this._pseudoClassSet);
|
|
63
|
+
this._pseudoElements = objects.values(this._pseudoElementSet);
|
|
64
|
+
}
|
|
65
|
+
getProperty(name) { return this._propertySet[name]; }
|
|
66
|
+
getAtDirective(name) { return this._atDirectiveSet[name]; }
|
|
67
|
+
getPseudoClass(name) { return this._pseudoClassSet[name]; }
|
|
68
|
+
getPseudoElement(name) { return this._pseudoElementSet[name]; }
|
|
69
|
+
getProperties() {
|
|
70
|
+
return this._properties;
|
|
71
|
+
}
|
|
72
|
+
getAtDirectives() {
|
|
73
|
+
return this._atDirectives;
|
|
74
|
+
}
|
|
75
|
+
getPseudoClasses() {
|
|
76
|
+
return this._pseudoClasses;
|
|
77
|
+
}
|
|
78
|
+
getPseudoElements() {
|
|
79
|
+
return this._pseudoElements;
|
|
80
|
+
}
|
|
81
|
+
isKnownProperty(name) {
|
|
82
|
+
return name.toLowerCase() in this._propertySet;
|
|
83
|
+
}
|
|
84
|
+
isStandardProperty(name) {
|
|
85
|
+
return this.isKnownProperty(name) &&
|
|
86
|
+
(!this._propertySet[name.toLowerCase()].status || this._propertySet[name.toLowerCase()].status === 'standard');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -1,79 +1,73 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
'use strict';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Currently, unversioned data uses the V1 implementation
|
|
9
|
-
* In the future when the provider handles multiple versions of HTML custom data,
|
|
10
|
-
* use the latest implementation for unversioned data
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
this._properties = [];
|
|
14
|
-
this._atDirectives = [];
|
|
15
|
-
this._pseudoClasses = [];
|
|
16
|
-
this._pseudoElements = [];
|
|
17
|
-
this.addData(data);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return this._properties;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return this._atDirectives;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return this._pseudoClasses;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return this._pseudoElements;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (Array.isArray(data.properties)) {
|
|
33
|
-
for (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
function
|
|
69
|
-
return typeof d.name === 'string';
|
|
70
|
-
}
|
|
71
|
-
function
|
|
72
|
-
return typeof d.name === 'string';
|
|
73
|
-
}
|
|
74
|
-
function isPseudoClassData(d) {
|
|
75
|
-
return typeof d.name === 'string';
|
|
76
|
-
}
|
|
77
|
-
function isPseudoElementData(d) {
|
|
78
|
-
return typeof d.name === 'string';
|
|
79
|
-
}
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
'use strict';
|
|
6
|
+
export class CSSDataProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Currently, unversioned data uses the V1 implementation
|
|
9
|
+
* In the future when the provider handles multiple versions of HTML custom data,
|
|
10
|
+
* use the latest implementation for unversioned data
|
|
11
|
+
*/
|
|
12
|
+
constructor(data) {
|
|
13
|
+
this._properties = [];
|
|
14
|
+
this._atDirectives = [];
|
|
15
|
+
this._pseudoClasses = [];
|
|
16
|
+
this._pseudoElements = [];
|
|
17
|
+
this.addData(data);
|
|
18
|
+
}
|
|
19
|
+
provideProperties() {
|
|
20
|
+
return this._properties;
|
|
21
|
+
}
|
|
22
|
+
provideAtDirectives() {
|
|
23
|
+
return this._atDirectives;
|
|
24
|
+
}
|
|
25
|
+
providePseudoClasses() {
|
|
26
|
+
return this._pseudoClasses;
|
|
27
|
+
}
|
|
28
|
+
providePseudoElements() {
|
|
29
|
+
return this._pseudoElements;
|
|
30
|
+
}
|
|
31
|
+
addData(data) {
|
|
32
|
+
if (Array.isArray(data.properties)) {
|
|
33
|
+
for (const prop of data.properties) {
|
|
34
|
+
if (isPropertyData(prop)) {
|
|
35
|
+
this._properties.push(prop);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(data.atDirectives)) {
|
|
40
|
+
for (const prop of data.atDirectives) {
|
|
41
|
+
if (isAtDirective(prop)) {
|
|
42
|
+
this._atDirectives.push(prop);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(data.pseudoClasses)) {
|
|
47
|
+
for (const prop of data.pseudoClasses) {
|
|
48
|
+
if (isPseudoClassData(prop)) {
|
|
49
|
+
this._pseudoClasses.push(prop);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(data.pseudoElements)) {
|
|
54
|
+
for (const prop of data.pseudoElements) {
|
|
55
|
+
if (isPseudoElementData(prop)) {
|
|
56
|
+
this._pseudoElements.push(prop);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function isPropertyData(d) {
|
|
63
|
+
return typeof d.name === 'string';
|
|
64
|
+
}
|
|
65
|
+
function isAtDirective(d) {
|
|
66
|
+
return typeof d.name === 'string';
|
|
67
|
+
}
|
|
68
|
+
function isPseudoClassData(d) {
|
|
69
|
+
return typeof d.name === 'string';
|
|
70
|
+
}
|
|
71
|
+
function isPseudoElementData(d) {
|
|
72
|
+
return typeof d.name === 'string';
|
|
73
|
+
}
|
|
@@ -1,138 +1,137 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
'use strict';
|
|
6
|
-
import { MarkupKind } from '../cssLanguageTypes';
|
|
7
|
-
export
|
|
8
|
-
E: 'Edge',
|
|
9
|
-
FF: 'Firefox',
|
|
10
|
-
S: 'Safari',
|
|
11
|
-
C: 'Chrome',
|
|
12
|
-
IE: 'IE',
|
|
13
|
-
O: 'Opera'
|
|
14
|
-
};
|
|
15
|
-
function getEntryStatus(status) {
|
|
16
|
-
switch (status) {
|
|
17
|
-
case 'experimental':
|
|
18
|
-
return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
|
|
19
|
-
case 'nonstandard':
|
|
20
|
-
return '🚨️ Property is nonstandard. Avoid using it.\n\n';
|
|
21
|
-
case 'obsolete':
|
|
22
|
-
return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
|
|
23
|
-
default:
|
|
24
|
-
return '';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export function getEntryDescription(entry, doesSupportMarkdown, settings) {
|
|
28
|
-
|
|
29
|
-
if (doesSupportMarkdown) {
|
|
30
|
-
result = {
|
|
31
|
-
kind: 'markdown',
|
|
32
|
-
value: getEntryMarkdownDescription(entry, settings)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
result = {
|
|
37
|
-
kind: 'plaintext',
|
|
38
|
-
value: getEntryStringDescription(entry, settings)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
if (result.value === '') {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
46
|
-
export function textToMarkedString(text) {
|
|
47
|
-
text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
|
48
|
-
return text.replace(/</g, '<').replace(/>/g, '>');
|
|
49
|
-
}
|
|
50
|
-
function getEntryStringDescription(entry, settings) {
|
|
51
|
-
if (!entry.description || entry.description === '') {
|
|
52
|
-
return '';
|
|
53
|
-
}
|
|
54
|
-
if (typeof entry.description !== 'string') {
|
|
55
|
-
return entry.description.value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (
|
|
59
|
-
if (entry.status) {
|
|
60
|
-
result += getEntryStatus(entry.status);
|
|
61
|
-
}
|
|
62
|
-
result += entry.description;
|
|
63
|
-
|
|
64
|
-
if (browserLabel) {
|
|
65
|
-
result += '\n(' + browserLabel + ')';
|
|
66
|
-
}
|
|
67
|
-
if ('syntax' in entry) {
|
|
68
|
-
result +=
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (entry.references && entry.references.length > 0 &&
|
|
72
|
-
if (result.length > 0) {
|
|
73
|
-
result += '\n\n';
|
|
74
|
-
}
|
|
75
|
-
result += entry.references.map(
|
|
76
|
-
return
|
|
77
|
-
}).join(' | ');
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
function getEntryMarkdownDescription(entry, settings) {
|
|
82
|
-
if (!entry.description || entry.description === '') {
|
|
83
|
-
return '';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
if (entry.status) {
|
|
88
|
-
result += getEntryStatus(entry.status);
|
|
89
|
-
}
|
|
90
|
-
if (typeof entry.description === 'string') {
|
|
91
|
-
result += textToMarkedString(entry.description);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
result += entry.description.kind === MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (browserLabel) {
|
|
98
|
-
result += '\n\n(' + textToMarkedString(browserLabel) + ')';
|
|
99
|
-
}
|
|
100
|
-
if ('syntax' in entry && entry.syntax) {
|
|
101
|
-
result +=
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
if (entry.references && entry.references.length > 0 &&
|
|
105
|
-
if (result.length > 0) {
|
|
106
|
-
result += '\n\n';
|
|
107
|
-
}
|
|
108
|
-
result += entry.references.map(
|
|
109
|
-
return
|
|
110
|
-
}).join(' | ');
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Input is like `["E12","FF49","C47","IE","O"]`
|
|
116
|
-
* Output is like `Edge 12, Firefox 49, Chrome 47, IE, Opera`
|
|
117
|
-
*/
|
|
118
|
-
export function getBrowserLabel(browsers) {
|
|
119
|
-
if (browsers ===
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
'use strict';
|
|
6
|
+
import { MarkupKind } from '../cssLanguageTypes';
|
|
7
|
+
export const browserNames = {
|
|
8
|
+
E: 'Edge',
|
|
9
|
+
FF: 'Firefox',
|
|
10
|
+
S: 'Safari',
|
|
11
|
+
C: 'Chrome',
|
|
12
|
+
IE: 'IE',
|
|
13
|
+
O: 'Opera'
|
|
14
|
+
};
|
|
15
|
+
function getEntryStatus(status) {
|
|
16
|
+
switch (status) {
|
|
17
|
+
case 'experimental':
|
|
18
|
+
return '⚠️ Property is experimental. Be cautious when using it.️\n\n';
|
|
19
|
+
case 'nonstandard':
|
|
20
|
+
return '🚨️ Property is nonstandard. Avoid using it.\n\n';
|
|
21
|
+
case 'obsolete':
|
|
22
|
+
return '🚨️️️ Property is obsolete. Avoid using it.\n\n';
|
|
23
|
+
default:
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function getEntryDescription(entry, doesSupportMarkdown, settings) {
|
|
28
|
+
let result;
|
|
29
|
+
if (doesSupportMarkdown) {
|
|
30
|
+
result = {
|
|
31
|
+
kind: 'markdown',
|
|
32
|
+
value: getEntryMarkdownDescription(entry, settings)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result = {
|
|
37
|
+
kind: 'plaintext',
|
|
38
|
+
value: getEntryStringDescription(entry, settings)
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (result.value === '') {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
export function textToMarkedString(text) {
|
|
47
|
+
text = text.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
|
48
|
+
return text.replace(/</g, '<').replace(/>/g, '>');
|
|
49
|
+
}
|
|
50
|
+
function getEntryStringDescription(entry, settings) {
|
|
51
|
+
if (!entry.description || entry.description === '') {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
if (typeof entry.description !== 'string') {
|
|
55
|
+
return entry.description.value;
|
|
56
|
+
}
|
|
57
|
+
let result = '';
|
|
58
|
+
if (settings?.documentation !== false) {
|
|
59
|
+
if (entry.status) {
|
|
60
|
+
result += getEntryStatus(entry.status);
|
|
61
|
+
}
|
|
62
|
+
result += entry.description;
|
|
63
|
+
const browserLabel = getBrowserLabel(entry.browsers);
|
|
64
|
+
if (browserLabel) {
|
|
65
|
+
result += '\n(' + browserLabel + ')';
|
|
66
|
+
}
|
|
67
|
+
if ('syntax' in entry) {
|
|
68
|
+
result += `\n\nSyntax: ${entry.syntax}`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (entry.references && entry.references.length > 0 && settings?.references !== false) {
|
|
72
|
+
if (result.length > 0) {
|
|
73
|
+
result += '\n\n';
|
|
74
|
+
}
|
|
75
|
+
result += entry.references.map(r => {
|
|
76
|
+
return `${r.name}: ${r.url}`;
|
|
77
|
+
}).join(' | ');
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
function getEntryMarkdownDescription(entry, settings) {
|
|
82
|
+
if (!entry.description || entry.description === '') {
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
let result = '';
|
|
86
|
+
if (settings?.documentation !== false) {
|
|
87
|
+
if (entry.status) {
|
|
88
|
+
result += getEntryStatus(entry.status);
|
|
89
|
+
}
|
|
90
|
+
if (typeof entry.description === 'string') {
|
|
91
|
+
result += textToMarkedString(entry.description);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
result += entry.description.kind === MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
|
|
95
|
+
}
|
|
96
|
+
const browserLabel = getBrowserLabel(entry.browsers);
|
|
97
|
+
if (browserLabel) {
|
|
98
|
+
result += '\n\n(' + textToMarkedString(browserLabel) + ')';
|
|
99
|
+
}
|
|
100
|
+
if ('syntax' in entry && entry.syntax) {
|
|
101
|
+
result += `\n\nSyntax: ${textToMarkedString(entry.syntax)}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (entry.references && entry.references.length > 0 && settings?.references !== false) {
|
|
105
|
+
if (result.length > 0) {
|
|
106
|
+
result += '\n\n';
|
|
107
|
+
}
|
|
108
|
+
result += entry.references.map(r => {
|
|
109
|
+
return `[${r.name}](${r.url})`;
|
|
110
|
+
}).join(' | ');
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Input is like `["E12","FF49","C47","IE","O"]`
|
|
116
|
+
* Output is like `Edge 12, Firefox 49, Chrome 47, IE, Opera`
|
|
117
|
+
*/
|
|
118
|
+
export function getBrowserLabel(browsers = []) {
|
|
119
|
+
if (browsers.length === 0) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return browsers
|
|
123
|
+
.map(b => {
|
|
124
|
+
let result = '';
|
|
125
|
+
const matches = b.match(/([A-Z]+)(\d+)?/);
|
|
126
|
+
const name = matches[1];
|
|
127
|
+
const version = matches[2];
|
|
128
|
+
if (name in browserNames) {
|
|
129
|
+
result += browserNames[name];
|
|
130
|
+
}
|
|
131
|
+
if (version) {
|
|
132
|
+
result += ' ' + version;
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
})
|
|
136
|
+
.join(', ');
|
|
137
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
'use strict';
|
|
6
|
-
export * from './entry';
|
|
7
|
-
export * from './colors';
|
|
8
|
-
export * from './builtinData';
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
'use strict';
|
|
6
|
+
export * from './entry';
|
|
7
|
+
export * from './colors';
|
|
8
|
+
export * from './builtinData';
|