stylelint-browser-compat 1.0.0-beta.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.
Files changed (116) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -0
  3. package/lib/at-rules/at_rules_name_set.js +16 -0
  4. package/lib/at-rules/collect_features.js +145 -0
  5. package/lib/at-rules/counter-style/collect_features.js +41 -0
  6. package/lib/at-rules/counter-style/descriptor_name_set.js +16 -0
  7. package/lib/at-rules/document/collect_features.js +46 -0
  8. package/lib/at-rules/document/regexp/collect_features.js +30 -0
  9. package/lib/at-rules/font-face/__font_type/collect_features.js +79 -0
  10. package/lib/at-rules/font-face/collect_features.js +67 -0
  11. package/lib/at-rules/font-face/descriptor_name_set.js +16 -0
  12. package/lib/at-rules/font-feature-values/at_rules_name_set.js +16 -0
  13. package/lib/at-rules/font-feature-values/collect_features.js +30 -0
  14. package/lib/at-rules/keyframes/collect_features.js +29 -0
  15. package/lib/at-rules/media/collect_features.js +118 -0
  16. package/lib/at-rules/media/media_feature_name_map.js +8 -0
  17. package/lib/at-rules/page/collect_features.js +82 -0
  18. package/lib/at-rules/page/descriptor_name_set.js +16 -0
  19. package/lib/at-rules/page/size/collect_features.js +55 -0
  20. package/lib/at-rules/property/collect_features.js +60 -0
  21. package/lib/at-rules/property/descriptor_name_set.js +16 -0
  22. package/lib/at-rules/scroll-timeline/collect_features.js +60 -0
  23. package/lib/at-rules/scroll-timeline/descriptor_name_set.js +16 -0
  24. package/lib/collect_features.js +69 -0
  25. package/lib/index.js +5 -0
  26. package/lib/is_supported.js +75 -0
  27. package/lib/options.js +20 -0
  28. package/lib/parse_browserslist_version.js +132 -0
  29. package/lib/properties/-moz-orient/collect_features.js +61 -0
  30. package/lib/properties/-moz-user-input/collect_features.js +71 -0
  31. package/lib/properties/animation-direction/collect_features.js +53 -0
  32. package/lib/properties/animation-timing-function/collect_features.js +51 -0
  33. package/lib/properties/appearance/collect_features.js +76 -0
  34. package/lib/properties/background/background-clip/collect_features.js +59 -0
  35. package/lib/properties/background/background-origin/collect_features.js +59 -0
  36. package/lib/properties/background/background-size/collect_features.js +106 -0
  37. package/lib/properties/background/collect_features.js +104 -0
  38. package/lib/properties/background/multiple_backgrounds/collect_features.js +39 -0
  39. package/lib/properties/background-attachment/collect_features.js +70 -0
  40. package/lib/properties/background-clip/collect_features.js +55 -0
  41. package/lib/properties/background-image/collect_features.js +133 -0
  42. package/lib/properties/background-image/svg_images/collect_features.js +58 -0
  43. package/lib/properties/background-origin/collect_features.js +42 -0
  44. package/lib/properties/background-position/collect_features.js +117 -0
  45. package/lib/properties/background-position-x/collect_features.js +36 -0
  46. package/lib/properties/background-position-y/collect_features.js +36 -0
  47. package/lib/properties/background-repeat/collect_features.js +102 -0
  48. package/lib/properties/background-repeat/round_space/collect_features.js +54 -0
  49. package/lib/properties/background-size/collect_features.js +38 -0
  50. package/lib/properties/block-size/collect_features.js +77 -0
  51. package/lib/properties/border-bottom-left-radius/border-bottom-right-radius/collect_features.js +57 -0
  52. package/lib/properties/border-bottom-left-radius/collect_features.js +57 -0
  53. package/lib/properties/border-bottom-right-radius/collect_features.js +57 -0
  54. package/lib/properties/border-radius/collect_features.js +61 -0
  55. package/lib/properties/border-top-left-radius/collect_features.js +57 -0
  56. package/lib/properties/border-top-right-radius/collect_features.js +57 -0
  57. package/lib/properties/box-shadow/collect_features.js +92 -0
  58. package/lib/properties/box-sizing/collect_features.js +39 -0
  59. package/lib/properties/caption-side/collect_features.js +38 -0
  60. package/lib/properties/clear/collect_features.js +38 -0
  61. package/lib/properties/clip-path/collect_features.js +65 -0
  62. package/lib/properties/collect_features.js +452 -0
  63. package/lib/properties/color-scheme/collect_features.js +52 -0
  64. package/lib/properties/property_name_set.js +16 -0
  65. package/lib/properties/transition/collect_features.js +33 -0
  66. package/lib/properties/transition-property/collect_features.js +38 -0
  67. package/lib/rule.js +125 -0
  68. package/lib/selectors/__attributes/collect_features.js +44 -0
  69. package/lib/selectors/__classes/collect_features.js +23 -0
  70. package/lib/selectors/__combinators/collect_features.js +91 -0
  71. package/lib/selectors/__ids/collect_features.js +23 -0
  72. package/lib/selectors/__pseudos/collect_features.js +228 -0
  73. package/lib/selectors/__pseudos/pseudo_selector_name_set.js +18 -0
  74. package/lib/selectors/__tags/collect_features.js +48 -0
  75. package/lib/selectors/__universal/collect_features.js +37 -0
  76. package/lib/selectors/active/non_a_elements/collect_features.js +38 -0
  77. package/lib/selectors/after/animation_and_transition_support/collect_features.js +43 -0
  78. package/lib/selectors/backdrop/dialog/collect_features.js +38 -0
  79. package/lib/selectors/before/animation_and_transition_support/collect_features.js +43 -0
  80. package/lib/selectors/collect_features.js +120 -0
  81. package/lib/selectors/cue/selector_argument/collect_features.js +26 -0
  82. package/lib/selectors/hostfunction/collect_features.js +26 -0
  83. package/lib/selectors/hover/collect_features.js +61 -0
  84. package/lib/selectors/invalid/collect_features.js +39 -0
  85. package/lib/selectors/marker/animation_and_transition_support/collect_features.js +43 -0
  86. package/lib/selectors/not/selector_list/collect_features.js +31 -0
  87. package/lib/selectors/nth-child/of_syntax/collect_features.js +32 -0
  88. package/lib/selectors/nth-last-child/of_syntax/collect_features.js +32 -0
  89. package/lib/selectors/valid/collect_features.js +39 -0
  90. package/lib/types/__function/collect_features.js +187 -0
  91. package/lib/types/attr/collect_features.js +69 -0
  92. package/lib/types/attr/type_unit_name_map.js +8 -0
  93. package/lib/types/calc/collect_features.js +70 -0
  94. package/lib/types/collect_features.js +139 -0
  95. package/lib/types/color/__alpha_parameter/collect_features.js +37 -0
  96. package/lib/types/color/__float_values/collect_features.js +44 -0
  97. package/lib/types/color/__space_separated_parameters/collect_features.js +37 -0
  98. package/lib/types/color/rgb_hexadecimal_notation/collect_features.js +42 -0
  99. package/lib/types/easing-function/steps/jump/collect_features.js +37 -0
  100. package/lib/types/function_name_map.js +8 -0
  101. package/lib/types/image/gradient/__linear-gradient/collect_features.js +77 -0
  102. package/lib/types/image/gradient/__linear-gradient/doubleposition/collect_features.js +43 -0
  103. package/lib/types/image/gradient/__linear-gradient/interpolation_hints/collect_features.js +42 -0
  104. package/lib/types/image/gradient/__linear-gradient/to/collect_features.js +39 -0
  105. package/lib/types/image/gradient/__linear-gradient/unitless_0_angle/collect_features.js +40 -0
  106. package/lib/types/image/gradient/__radial-gradient/at/collect_features.js +44 -0
  107. package/lib/types/image/gradient/__radial-gradient/collect_features.js +68 -0
  108. package/lib/types/image/gradient/__radial-gradient/doubleposition/collect_features.js +47 -0
  109. package/lib/types/image/gradient/__radial-gradient/interpolation_hints/collect_features.js +42 -0
  110. package/lib/types/image/gradient/conic-gradient/collect_features.js +48 -0
  111. package/lib/types/image/gradient/conic-gradient/doubleposition/collect_features.js +43 -0
  112. package/lib/types/number/scientific_notation/collect_features.js +31 -0
  113. package/lib/types/unit_name_map.js +8 -0
  114. package/lib/types/value_name_map.js +8 -0
  115. package/lib/types.js +5 -0
  116. package/package.json +75 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2022 3846masa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the “Software”), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # stylelint-browser-compat
2
+
3
+ ![](./assets/ogp.png)
4
+
5
+ [![npm](https://flat.badgen.net/npm/v/stylelint-browser-compat)](https://www.npmjs.com/package/stylelint-browser-compat)
6
+ [![license](https://flat.badgen.net/badge/license/MIT/blue)](LICENSE)
7
+ [![standard-readme compliant](https://flat.badgen.net/badge/readme%20style/standard/green)](https://github.com/RichardLitt/standard-readme)
8
+
9
+ Yet another linter rule to detect compatibility of CSS features.
10
+
11
+ This plugin checks if the CSS you're using is supported by the browsers you're targeting.
12
+ It uses [@mdn/browser-compat-data](https://github.com/mdn/browser-compat-data) to detect browser support.
13
+
14
+ **:warning: This plugin is beta. USE AT YOUR OWN RISK.**
15
+
16
+ ## Table of Contents
17
+
18
+ - [Background](#background)
19
+ - [Install](#install)
20
+ - [Usage](#usage)
21
+ - [Contributing](#contributing)
22
+ - [License](#license)
23
+
24
+ ## Background
25
+
26
+ `stylelint-no-unsupported-browser-features` (using `doiuse`) are available to detect compatibility of CSS features.
27
+
28
+ However, `doiuse` have not been maintained for a long time.
29
+
30
+ This library provides another alternative to detect compatibility of CSS features.
31
+
32
+ Although `doiuse` detects compatibility from `caniuse` data, this library uses `@mdn/browser-compat-data` to do so.
33
+
34
+ ## Install
35
+
36
+ ```bash
37
+ $ npm install --dev browserslist stylelint stylelint-browser-compat
38
+ ```
39
+
40
+ ```bash
41
+ $ yarn add --dev browserslist stylelint stylelint-browser-compat
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ```js
47
+ module.exports = {
48
+ plugins: ['stylelint-browser-compat'],
49
+ rules: {
50
+ 'plugin/browser-compat': [
51
+ true,
52
+ {
53
+ allow: {
54
+ features: ['at-rules.supports'],
55
+ flagged: false,
56
+ partialImplementation: false,
57
+ prefix: true,
58
+ },
59
+ browserslist: ['last 2 versions'],
60
+ },
61
+ ],
62
+ },
63
+ };
64
+ ```
65
+
66
+ ### Options
67
+
68
+ - `browserslist` (string or array, optional)
69
+ - Accepts [browserslist queries](https://github.com/browserslist/browserslist#queries) for target browsers.
70
+ - By default, browserslist automatically loads the configuration file (e.g. `package.json`, `.browserslistrc`).
71
+ - `allow.features` (array, optional)
72
+ - Accepts an array of features to allow.
73
+ - Feature names are from [@mdn/browser-compat-data](https://github.com/mdn/browser-compat-data).
74
+ - For example, if you want to use `@supports` at-rules, pass `at-rules.supports`.
75
+ - `allow.flagged` (boolean, optional)
76
+ - Allows features that are available when the browser's feature flags is enabled.
77
+ - `false` by default
78
+ - `allow.partialImplementation` (boolean, optional)
79
+ - Allows features that are partial implementations.
80
+ - `false` by default
81
+ - `allow.prefix` (boolean, optional)
82
+ - Allows features with vendor prefix.
83
+ - `true` by default
84
+
85
+ ## Contributing
86
+
87
+ PRs accepted.
88
+
89
+ ## License
90
+
91
+ [MIT (c) 3846masa](./LICENSE)
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.atRulesNameSet = void 0;
7
+
8
+ var _browserCompatData = _interopRequireDefault(require("@mdn/browser-compat-data"));
9
+
10
+ var _dotProp = _interopRequireDefault(require("dot-prop"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const IGNORE_KEYS = new Set([]);
15
+ const atRulesNameSet = new Set(Array.from(Object.keys(_dotProp.default.get(_browserCompatData.default.css, 'at-rules') ?? {})).filter(k => !IGNORE_KEYS.has(k)));
16
+ exports.atRulesNameSet = atRulesNameSet;
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ var _at_rules_name_set = require("./at_rules_name_set");
9
+
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+
14
+ async function collectFeatures({
15
+ ignoreFeatures,
16
+ node
17
+ }) {
18
+ const promises = [];
19
+
20
+ if (_at_rules_name_set.atRulesNameSet.has(node.name)) {
21
+ promises.push(Promise.resolve([{
22
+ endIndex: `@${node.name}`.length,
23
+ id: `at-rules.${node.name}`,
24
+ index: 0,
25
+ name: `"@${node.name}" at rules`,
26
+ node
27
+ }]));
28
+ }
29
+
30
+ switch (node.name) {
31
+ case 'counter-style':
32
+ {
33
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./counter-style/collect_features"))).then(({
34
+ collectFeatures
35
+ }) => {
36
+ return collectFeatures({
37
+ node
38
+ });
39
+ }));
40
+ break;
41
+ }
42
+
43
+ case 'document':
44
+ {
45
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./document/collect_features"))).then(({
46
+ collectFeatures
47
+ }) => {
48
+ return collectFeatures({
49
+ ignoreFeatures,
50
+ node
51
+ });
52
+ }));
53
+ break;
54
+ }
55
+
56
+ case 'font-face':
57
+ {
58
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./font-face/collect_features"))).then(({
59
+ collectFeatures
60
+ }) => {
61
+ return collectFeatures({
62
+ node
63
+ });
64
+ }));
65
+ break;
66
+ }
67
+
68
+ case 'font-feature-values':
69
+ {
70
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./font-feature-values/collect_features"))).then(({
71
+ collectFeatures
72
+ }) => {
73
+ return collectFeatures({
74
+ node
75
+ });
76
+ }));
77
+ break;
78
+ }
79
+
80
+ case 'keyframes':
81
+ {
82
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./keyframes/collect_features"))).then(({
83
+ collectFeatures
84
+ }) => {
85
+ return collectFeatures({
86
+ node
87
+ });
88
+ }));
89
+ break;
90
+ }
91
+
92
+ case 'media':
93
+ {
94
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./media/collect_features"))).then(({
95
+ collectFeatures
96
+ }) => {
97
+ return collectFeatures({
98
+ ignoreFeatures,
99
+ node
100
+ });
101
+ }));
102
+ break;
103
+ }
104
+
105
+ case 'page':
106
+ {
107
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./page/collect_features"))).then(({
108
+ collectFeatures
109
+ }) => {
110
+ return collectFeatures({
111
+ ignoreFeatures,
112
+ node
113
+ });
114
+ }));
115
+ break;
116
+ }
117
+
118
+ case 'property':
119
+ {
120
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./property/collect_features"))).then(({
121
+ collectFeatures
122
+ }) => {
123
+ return collectFeatures({
124
+ node
125
+ });
126
+ }));
127
+ break;
128
+ }
129
+
130
+ case 'scroll-timeline':
131
+ {
132
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./scroll-timeline/collect_features"))).then(({
133
+ collectFeatures
134
+ }) => {
135
+ return collectFeatures({
136
+ node
137
+ });
138
+ }));
139
+ break;
140
+ }
141
+ }
142
+
143
+ const features = (await Promise.all(promises)).flat();
144
+ return features;
145
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ var _descriptor_name_set = require("./descriptor_name_set");
9
+
10
+ async function collectFeatures({
11
+ node
12
+ }) {
13
+ const features = [];
14
+ node.walkDecls(delc => {
15
+ const [vendorPrefix] = /^-(webkit|moz|ms|o)-/.exec(delc.prop) ?? [];
16
+
17
+ if (_descriptor_name_set.descriptorNameSet.has(delc.prop)) {
18
+ features.push({
19
+ endIndex: delc.prop.length,
20
+ id: `at-rules.counter-style.${delc.prop}`,
21
+ index: 0,
22
+ name: `"${delc.prop}" descriptor of the @counter-style`,
23
+ node: delc
24
+ });
25
+ } else if (vendorPrefix != null) {
26
+ const name = delc.prop.replace(vendorPrefix, '');
27
+
28
+ if (_descriptor_name_set.descriptorNameSet.has(name)) {
29
+ features.push({
30
+ endIndex: delc.prop.length,
31
+ id: `at-rules.counter-style.${name}`,
32
+ index: 0,
33
+ name: `"${name}" descriptor of the @counter-style`,
34
+ node: delc,
35
+ prefix: vendorPrefix
36
+ });
37
+ }
38
+ }
39
+ });
40
+ return features;
41
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.descriptorNameSet = void 0;
7
+
8
+ var _browserCompatData = _interopRequireDefault(require("@mdn/browser-compat-data"));
9
+
10
+ var _dotProp = _interopRequireDefault(require("dot-prop"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const IGNORE_KEYS = new Set([]);
15
+ const descriptorNameSet = new Set(Array.from(Object.keys(_dotProp.default.get(_browserCompatData.default.css, 'at-rules.counter-style') ?? {})).filter(k => !IGNORE_KEYS.has(k)));
16
+ exports.descriptorNameSet = descriptorNameSet;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
+
14
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
+
16
+ async function collectFeatures({
17
+ ignoreFeatures,
18
+ node
19
+ }) {
20
+ const promises = [];
21
+ const valueRoot = (0, _postcssValueParser.default)(node.params);
22
+
23
+ for (const valueNode of valueRoot.nodes) {
24
+ if (valueNode.type === 'function' && valueNode.value === 'regexp') {
25
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./regexp/collect_features"))).then(({
26
+ collectFeatures
27
+ }) => {
28
+ return collectFeatures({
29
+ node: valueNode,
30
+ parent: node
31
+ });
32
+ }));
33
+ }
34
+ }
35
+
36
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("../../collect_features"))).then(({
37
+ collectFeatures
38
+ }) => {
39
+ return collectFeatures({
40
+ container: node,
41
+ ignoreFeatures
42
+ });
43
+ }));
44
+ const features = (await Promise.all(promises)).flat();
45
+ return features;
46
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ async function collectFeatures({
9
+ node,
10
+ parent
11
+ }) {
12
+ const features = [];
13
+
14
+ if (node.type === 'function' && node.value === 'regexp') {
15
+ var _parent$raws$afterNam;
16
+
17
+ const offset = `@${parent.name}`.length + (((_parent$raws$afterNam = parent.raws.afterName) === null || _parent$raws$afterNam === void 0 ? void 0 : _parent$raws$afterNam.length) ?? 0);
18
+ const index = offset + node.sourceIndex;
19
+ const endIndex = offset + node.sourceEndIndex;
20
+ features.push({
21
+ endIndex,
22
+ id: `at-rules.document.regexp`,
23
+ index,
24
+ name: `"regexp()" function of the @document`,
25
+ node: parent
26
+ });
27
+ }
28
+
29
+ return features;
30
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ var _nodePath = _interopRequireDefault(require("node:path"));
9
+
10
+ var _tsResults = require("ts-results");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ async function collectFeatures({
15
+ node,
16
+ parent
17
+ }) {
18
+ var _parent$raws$between;
19
+
20
+ const features = [];
21
+
22
+ if (node.type !== 'function' || node.value !== 'url' || node.nodes.length !== 1 || node.nodes[0] == null) {
23
+ return features;
24
+ }
25
+
26
+ const urlPathNode = node.nodes[0];
27
+
28
+ const url = _tsResults.Result.wrap(() => new URL(urlPathNode.value, 'https://example.com/')).unwrapOr(null);
29
+
30
+ if (url == null || url.protocol !== 'http:' && url.protocol !== 'https:') {
31
+ return features;
32
+ }
33
+
34
+ const extension = _nodePath.default.extname(url.pathname);
35
+
36
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
37
+ const index = offset + urlPathNode.sourceIndex;
38
+ const endIndex = offset + urlPathNode.sourceEndIndex;
39
+
40
+ switch (extension.toLowerCase()) {
41
+ case '.svg':
42
+ {
43
+ features.push({
44
+ endIndex,
45
+ id: `at-rules.font-face.SVG_fonts`,
46
+ index,
47
+ name: `SVG fonts`,
48
+ node: parent
49
+ });
50
+ break;
51
+ }
52
+
53
+ case '.woff':
54
+ {
55
+ features.push({
56
+ endIndex,
57
+ id: `at-rules.font-face.WOFF`,
58
+ index,
59
+ name: `WOFF`,
60
+ node: parent
61
+ });
62
+ break;
63
+ }
64
+
65
+ case '.woff2':
66
+ {
67
+ features.push({
68
+ endIndex,
69
+ id: `at-rules.font-face.WOFF_2`,
70
+ index,
71
+ name: `WOFF2`,
72
+ node: parent
73
+ });
74
+ break;
75
+ }
76
+ }
77
+
78
+ return features;
79
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
9
+
10
+ var _descriptor_name_set = require("./descriptor_name_set");
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ async function collectFeatures({
19
+ node
20
+ }) {
21
+ const promises = [];
22
+ node.walkDecls(delc => {
23
+ const [vendorPrefix] = /^-(webkit|moz|ms|o)-/.exec(delc.prop) ?? [];
24
+
25
+ if (_descriptor_name_set.descriptorNameSet.has(delc.prop)) {
26
+ promises.push(Promise.resolve([{
27
+ endIndex: delc.prop.length,
28
+ id: `at-rules.font-face.${delc.prop}`,
29
+ index: 0,
30
+ name: `"${delc.prop}" descriptor of the @font-face`,
31
+ node: delc
32
+ }]));
33
+ } else if (vendorPrefix != null) {
34
+ const name = delc.prop.replace(vendorPrefix, '');
35
+
36
+ if (_descriptor_name_set.descriptorNameSet.has(name)) {
37
+ promises.push(Promise.resolve([{
38
+ endIndex: delc.prop.length,
39
+ id: `at-rules.font-face.${name}`,
40
+ index: 0,
41
+ name: `"${name}" descriptor of the @font-face`,
42
+ node: delc,
43
+ prefix: vendorPrefix
44
+ }]));
45
+ }
46
+ }
47
+
48
+ const valueRoot = (0, _postcssValueParser.default)(delc.value);
49
+
50
+ if (delc.prop === 'src') {
51
+ for (const valueNode of valueRoot.nodes) {
52
+ if (valueNode.type === 'function' && valueNode.value === 'url') {
53
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("./__font_type/collect_features"))).then(({
54
+ collectFeatures
55
+ }) => {
56
+ return collectFeatures({
57
+ node: valueNode,
58
+ parent: delc
59
+ });
60
+ }));
61
+ }
62
+ }
63
+ }
64
+ });
65
+ const features = (await Promise.all(promises)).flat();
66
+ return features;
67
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.descriptorNameSet = void 0;
7
+
8
+ var _browserCompatData = _interopRequireDefault(require("@mdn/browser-compat-data"));
9
+
10
+ var _dotProp = _interopRequireDefault(require("dot-prop"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const IGNORE_KEYS = new Set(['SVG_fonts', 'WOFF', 'WOFF_2']);
15
+ const descriptorNameSet = new Set(Array.from(Object.keys(_dotProp.default.get(_browserCompatData.default.css, 'at-rules.font-face') ?? {})).filter(k => !IGNORE_KEYS.has(k)));
16
+ exports.descriptorNameSet = descriptorNameSet;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.atRulesNameSet = void 0;
7
+
8
+ var _browserCompatData = _interopRequireDefault(require("@mdn/browser-compat-data"));
9
+
10
+ var _dotProp = _interopRequireDefault(require("dot-prop"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const IGNORE_KEYS = new Set([]);
15
+ const atRulesNameSet = new Set(Array.from(Object.keys(_dotProp.default.get(_browserCompatData.default.css, 'at-rules.font-feature-values') ?? {})).filter(k => !IGNORE_KEYS.has(k)));
16
+ exports.atRulesNameSet = atRulesNameSet;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ var _at_rules_name_set = require("./at_rules_name_set");
9
+
10
+ async function collectFeatures({
11
+ node
12
+ }) {
13
+ const features = [];
14
+ node.each(node => {
15
+ if (node.type !== 'atrule') {
16
+ return;
17
+ }
18
+
19
+ if (_at_rules_name_set.atRulesNameSet.has(node.name)) {
20
+ features.push({
21
+ endIndex: `@${node.name}`.length,
22
+ id: `at-rules.font-feature-values.${node.name}`,
23
+ index: 0,
24
+ name: `"@${node.name}" at rules of the @font-feature-values`,
25
+ node
26
+ });
27
+ }
28
+ });
29
+ return features;
30
+ }
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ async function collectFeatures({
9
+ node
10
+ }) {
11
+ const features = [];
12
+ node.walkDecls(delc => {
13
+ const prop = delc.prop.replace(/^-(webkit|moz|ms|o)-/, '');
14
+
15
+ switch (prop) {
16
+ case 'clip-path':
17
+ {
18
+ features.push({
19
+ endIndex: delc.prop.length,
20
+ id: `properties.clip-path.animations`,
21
+ index: 0,
22
+ name: `CSS animation for clip-path`,
23
+ node: delc
24
+ });
25
+ }
26
+ }
27
+ });
28
+ return features;
29
+ }