vscode-css-languageservice 5.4.2 → 6.0.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/lib/esm/cssLanguageService.d.ts +37 -37
  3. package/lib/esm/cssLanguageService.js +72 -75
  4. package/lib/esm/cssLanguageTypes.d.ts +238 -238
  5. package/lib/esm/cssLanguageTypes.js +42 -42
  6. package/lib/esm/data/webCustomData.js +21965 -21965
  7. package/lib/esm/languageFacts/builtinData.js +142 -142
  8. package/lib/esm/languageFacts/colors.js +469 -472
  9. package/lib/esm/languageFacts/dataManager.js +88 -92
  10. package/lib/esm/languageFacts/dataProvider.js +73 -79
  11. package/lib/esm/languageFacts/entry.js +137 -138
  12. package/lib/esm/languageFacts/facts.js +8 -8
  13. package/lib/esm/parser/cssErrors.js +48 -50
  14. package/lib/esm/parser/cssNodes.js +1502 -2019
  15. package/lib/esm/parser/cssParser.js +1534 -1563
  16. package/lib/esm/parser/cssScanner.js +592 -599
  17. package/lib/esm/parser/cssSymbolScope.js +311 -341
  18. package/lib/esm/parser/lessParser.js +714 -740
  19. package/lib/esm/parser/lessScanner.js +57 -78
  20. package/lib/esm/parser/scssErrors.js +18 -20
  21. package/lib/esm/parser/scssParser.js +796 -818
  22. package/lib/esm/parser/scssScanner.js +95 -116
  23. package/lib/esm/services/cssCodeActions.js +77 -81
  24. package/lib/esm/services/cssCompletion.js +1054 -1149
  25. package/lib/esm/services/cssFolding.js +190 -193
  26. package/lib/esm/services/cssFormatter.js +136 -136
  27. package/lib/esm/services/cssHover.js +148 -151
  28. package/lib/esm/services/cssNavigation.js +378 -470
  29. package/lib/esm/services/cssSelectionRange.js +47 -47
  30. package/lib/esm/services/cssValidation.js +41 -44
  31. package/lib/esm/services/lessCompletion.js +378 -397
  32. package/lib/esm/services/lint.js +518 -532
  33. package/lib/esm/services/lintRules.js +76 -83
  34. package/lib/esm/services/lintUtil.js +196 -205
  35. package/lib/esm/services/pathCompletion.js +157 -231
  36. package/lib/esm/services/scssCompletion.js +354 -378
  37. package/lib/esm/services/scssNavigation.js +82 -154
  38. package/lib/esm/services/selectorPrinting.js +492 -536
  39. package/lib/esm/utils/arrays.js +40 -46
  40. package/lib/esm/utils/objects.js +11 -11
  41. package/lib/esm/utils/resources.js +11 -24
  42. package/lib/esm/utils/strings.js +102 -104
  43. package/lib/umd/cssLanguageService.d.ts +37 -37
  44. package/lib/umd/cssLanguageService.js +99 -102
  45. package/lib/umd/cssLanguageTypes.d.ts +238 -238
  46. package/lib/umd/cssLanguageTypes.js +89 -88
  47. package/lib/umd/data/webCustomData.js +21978 -21978
  48. package/lib/umd/languageFacts/builtinData.js +154 -154
  49. package/lib/umd/languageFacts/colors.js +492 -495
  50. package/lib/umd/languageFacts/dataManager.js +101 -104
  51. package/lib/umd/languageFacts/dataProvider.js +86 -91
  52. package/lib/umd/languageFacts/entry.js +152 -153
  53. package/lib/umd/languageFacts/facts.js +29 -29
  54. package/lib/umd/parser/cssErrors.js +61 -62
  55. package/lib/umd/parser/cssNodes.js +1587 -2034
  56. package/lib/umd/parser/cssParser.js +1547 -1575
  57. package/lib/umd/parser/cssScanner.js +606 -611
  58. package/lib/umd/parser/cssSymbolScope.js +328 -353
  59. package/lib/umd/parser/lessParser.js +727 -752
  60. package/lib/umd/parser/lessScanner.js +70 -90
  61. package/lib/umd/parser/scssErrors.js +31 -32
  62. package/lib/umd/parser/scssParser.js +809 -830
  63. package/lib/umd/parser/scssScanner.js +108 -128
  64. package/lib/umd/services/cssCodeActions.js +90 -93
  65. package/lib/umd/services/cssCompletion.js +1067 -1161
  66. package/lib/umd/services/cssFolding.js +203 -206
  67. package/lib/umd/services/cssFormatter.js +150 -150
  68. package/lib/umd/services/cssHover.js +161 -163
  69. package/lib/umd/services/cssNavigation.js +391 -482
  70. package/lib/umd/services/cssSelectionRange.js +60 -60
  71. package/lib/umd/services/cssValidation.js +54 -56
  72. package/lib/umd/services/lessCompletion.js +391 -409
  73. package/lib/umd/services/lint.js +531 -544
  74. package/lib/umd/services/lintRules.js +91 -95
  75. package/lib/umd/services/lintUtil.js +210 -218
  76. package/lib/umd/services/pathCompletion.js +171 -244
  77. package/lib/umd/services/scssCompletion.js +367 -390
  78. package/lib/umd/services/scssNavigation.js +95 -166
  79. package/lib/umd/services/selectorPrinting.js +510 -550
  80. package/lib/umd/utils/arrays.js +55 -61
  81. package/lib/umd/utils/objects.js +25 -25
  82. package/lib/umd/utils/resources.js +26 -39
  83. package/lib/umd/utils/strings.js +120 -122
  84. package/package.json +10 -10
@@ -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
- var CSSDataManager = /** @class */ (function () {
10
- function CSSDataManager(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 === null || options === void 0 ? void 0 : options.useDefaultDataProvider) !== false, (options === null || options === void 0 ? void 0 : options.customDataProviders) || []);
21
- }
22
- CSSDataManager.prototype.setDataProviders = function (builtIn, providers) {
23
- var _a;
24
- this.dataProviders = [];
25
- if (builtIn) {
26
- this.dataProviders.push(new CSSDataProvider(cssData));
27
- }
28
- (_a = this.dataProviders).push.apply(_a, providers);
29
- this.collectData();
30
- };
31
- /**
32
- * Collect all data & handle duplicates
33
- */
34
- CSSDataManager.prototype.collectData = function () {
35
- var _this = this;
36
- this._propertySet = {};
37
- this._atDirectiveSet = {};
38
- this._pseudoClassSet = {};
39
- this._pseudoElementSet = {};
40
- this.dataProviders.forEach(function (provider) {
41
- provider.provideProperties().forEach(function (p) {
42
- if (!_this._propertySet[p.name]) {
43
- _this._propertySet[p.name] = p;
44
- }
45
- });
46
- provider.provideAtDirectives().forEach(function (p) {
47
- if (!_this._atDirectiveSet[p.name]) {
48
- _this._atDirectiveSet[p.name] = p;
49
- }
50
- });
51
- provider.providePseudoClasses().forEach(function (p) {
52
- if (!_this._pseudoClassSet[p.name]) {
53
- _this._pseudoClassSet[p.name] = p;
54
- }
55
- });
56
- provider.providePseudoElements().forEach(function (p) {
57
- if (!_this._pseudoElementSet[p.name]) {
58
- _this._pseudoElementSet[p.name] = p;
59
- }
60
- });
61
- });
62
- this._properties = objects.values(this._propertySet);
63
- this._atDirectives = objects.values(this._atDirectiveSet);
64
- this._pseudoClasses = objects.values(this._pseudoClassSet);
65
- this._pseudoElements = objects.values(this._pseudoElementSet);
66
- };
67
- CSSDataManager.prototype.getProperty = function (name) { return this._propertySet[name]; };
68
- CSSDataManager.prototype.getAtDirective = function (name) { return this._atDirectiveSet[name]; };
69
- CSSDataManager.prototype.getPseudoClass = function (name) { return this._pseudoClassSet[name]; };
70
- CSSDataManager.prototype.getPseudoElement = function (name) { return this._pseudoElementSet[name]; };
71
- CSSDataManager.prototype.getProperties = function () {
72
- return this._properties;
73
- };
74
- CSSDataManager.prototype.getAtDirectives = function () {
75
- return this._atDirectives;
76
- };
77
- CSSDataManager.prototype.getPseudoClasses = function () {
78
- return this._pseudoClasses;
79
- };
80
- CSSDataManager.prototype.getPseudoElements = function () {
81
- return this._pseudoElements;
82
- };
83
- CSSDataManager.prototype.isKnownProperty = function (name) {
84
- return name.toLowerCase() in this._propertySet;
85
- };
86
- CSSDataManager.prototype.isStandardProperty = function (name) {
87
- return this.isKnownProperty(name) &&
88
- (!this._propertySet[name.toLowerCase()].status || this._propertySet[name.toLowerCase()].status === 'standard');
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
- var CSSDataProvider = /** @class */ (function () {
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
- function CSSDataProvider(data) {
13
- this._properties = [];
14
- this._atDirectives = [];
15
- this._pseudoClasses = [];
16
- this._pseudoElements = [];
17
- this.addData(data);
18
- }
19
- CSSDataProvider.prototype.provideProperties = function () {
20
- return this._properties;
21
- };
22
- CSSDataProvider.prototype.provideAtDirectives = function () {
23
- return this._atDirectives;
24
- };
25
- CSSDataProvider.prototype.providePseudoClasses = function () {
26
- return this._pseudoClasses;
27
- };
28
- CSSDataProvider.prototype.providePseudoElements = function () {
29
- return this._pseudoElements;
30
- };
31
- CSSDataProvider.prototype.addData = function (data) {
32
- if (Array.isArray(data.properties)) {
33
- for (var _i = 0, _a = data.properties; _i < _a.length; _i++) {
34
- var prop = _a[_i];
35
- if (isPropertyData(prop)) {
36
- this._properties.push(prop);
37
- }
38
- }
39
- }
40
- if (Array.isArray(data.atDirectives)) {
41
- for (var _b = 0, _c = data.atDirectives; _b < _c.length; _b++) {
42
- var prop = _c[_b];
43
- if (isAtDirective(prop)) {
44
- this._atDirectives.push(prop);
45
- }
46
- }
47
- }
48
- if (Array.isArray(data.pseudoClasses)) {
49
- for (var _d = 0, _e = data.pseudoClasses; _d < _e.length; _d++) {
50
- var prop = _e[_d];
51
- if (isPseudoClassData(prop)) {
52
- this._pseudoClasses.push(prop);
53
- }
54
- }
55
- }
56
- if (Array.isArray(data.pseudoElements)) {
57
- for (var _f = 0, _g = data.pseudoElements; _f < _g.length; _f++) {
58
- var prop = _g[_f];
59
- if (isPseudoElementData(prop)) {
60
- this._pseudoElements.push(prop);
61
- }
62
- }
63
- }
64
- };
65
- return CSSDataProvider;
66
- }());
67
- export { CSSDataProvider };
68
- function isPropertyData(d) {
69
- return typeof d.name === 'string';
70
- }
71
- function isAtDirective(d) {
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 var 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
- var 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, '&lt;').replace(/>/g, '&gt;');
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
- var result = '';
58
- if ((settings === null || settings === void 0 ? void 0 : settings.documentation) !== false) {
59
- if (entry.status) {
60
- result += getEntryStatus(entry.status);
61
- }
62
- result += entry.description;
63
- var browserLabel = getBrowserLabel(entry.browsers);
64
- if (browserLabel) {
65
- result += '\n(' + browserLabel + ')';
66
- }
67
- if ('syntax' in entry) {
68
- result += "\n\nSyntax: ".concat(entry.syntax);
69
- }
70
- }
71
- if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
72
- if (result.length > 0) {
73
- result += '\n\n';
74
- }
75
- result += entry.references.map(function (r) {
76
- return "".concat(r.name, ": ").concat(r.url);
77
- }).join(' | ');
78
- }
79
- return result;
80
- }
81
- function getEntryMarkdownDescription(entry, settings) {
82
- if (!entry.description || entry.description === '') {
83
- return '';
84
- }
85
- var result = '';
86
- if ((settings === null || settings === void 0 ? void 0 : 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
- var 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: ".concat(textToMarkedString(entry.syntax));
102
- }
103
- }
104
- if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
105
- if (result.length > 0) {
106
- result += '\n\n';
107
- }
108
- result += entry.references.map(function (r) {
109
- return "[".concat(r.name, "](").concat(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 === void 0) { browsers = []; }
120
- if (browsers.length === 0) {
121
- return null;
122
- }
123
- return browsers
124
- .map(function (b) {
125
- var result = '';
126
- var matches = b.match(/([A-Z]+)(\d+)?/);
127
- var name = matches[1];
128
- var version = matches[2];
129
- if (name in browserNames) {
130
- result += browserNames[name];
131
- }
132
- if (version) {
133
- result += ' ' + version;
134
- }
135
- return result;
136
- })
137
- .join(', ');
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, '&lt;').replace(/>/g, '&gt;');
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';