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
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseBrowsersListVersion = parseBrowsersListVersion;
7
+ const STANDARD_TARGET_NAME_LIST = [{
8
+ browserslist: 'chrome',
9
+ mdn: 'chrome',
10
+ name: 'Chrome'
11
+ }, {
12
+ browserslist: 'and_chr',
13
+ mdn: 'chrome',
14
+ name: 'Android Chrome'
15
+ }, {
16
+ browserslist: 'edge',
17
+ mdn: 'edge',
18
+ name: 'Edge'
19
+ }, {
20
+ browserslist: 'firefox',
21
+ mdn: 'firefox',
22
+ name: 'Firefox'
23
+ }, {
24
+ browserslist: 'and_ff',
25
+ mdn: 'firefox_android',
26
+ name: 'Android Firefox'
27
+ }, {
28
+ browserslist: 'ie',
29
+ mdn: 'ie',
30
+ name: 'IE'
31
+ }, {
32
+ browserslist: 'node',
33
+ mdn: 'nodejs',
34
+ name: 'Node.js'
35
+ }, {
36
+ browserslist: 'opera',
37
+ mdn: 'opera',
38
+ name: 'Opera'
39
+ }, {
40
+ browserslist: 'op_mob',
41
+ mdn: 'opera_android',
42
+ name: 'Opera Android'
43
+ }, {
44
+ browserslist: 'safari',
45
+ mdn: 'safari',
46
+ name: 'Safari'
47
+ }, {
48
+ browserslist: 'ios_saf',
49
+ mdn: 'safari_ios',
50
+ name: 'iOS Safari'
51
+ }, {
52
+ browserslist: 'samsung',
53
+ mdn: 'samsunginternet_android',
54
+ name: 'Samsung Browser'
55
+ }, {
56
+ browserslist: 'android',
57
+ mdn: 'webview_android',
58
+ name: 'Android Webview'
59
+ }];
60
+ const STANDARD_TARGET_NAME_MAPPINGS = new Map(STANDARD_TARGET_NAME_LIST.map(info => [info.browserslist, info]));
61
+ /**
62
+ * MIT License Copyright (c) 2016 Amila Welihinda
63
+ * Forked from https://github.com/amilajack/eslint-plugin-compat/blob/4f00359c239aa4eb06a3bf2b23d13f517b666eee/src/helpers.ts#L219-L264
64
+ */
65
+
66
+ function parseBrowsersListVersion(targetslist) {
67
+ return (// Sort the targets by target name and then version number in ascending order
68
+ targetslist.map(rawString => {
69
+ const [targetName, versionString] = rawString.split(' ');
70
+
71
+ if (targetName === 'safari' && versionString === 'TP') {
72
+ return null;
73
+ }
74
+
75
+ const parsedVersion = (() => {
76
+ try {
77
+ if (targetName === 'op_mob' && versionString === '10') {
78
+ return 10.1;
79
+ }
80
+
81
+ if (versionString === 'all') {
82
+ return 0;
83
+ }
84
+
85
+ const [minVersionString] = versionString.split('-');
86
+
87
+ if (minVersionString == null) {
88
+ throw new Error(`"${rawString}" cannot parsed.`);
89
+ }
90
+
91
+ const parsedVersion = Number.parseFloat(minVersionString);
92
+
93
+ if (Number.isNaN(parsedVersion)) {
94
+ throw new Error(`"${rawString}" cannot parsed.`);
95
+ }
96
+
97
+ return parsedVersion;
98
+ } catch {
99
+ throw new Error(`"${rawString}" cannot parsed.`);
100
+ }
101
+ })();
102
+
103
+ const target = STANDARD_TARGET_NAME_MAPPINGS.get(targetName);
104
+
105
+ if (target == null) {
106
+ return null;
107
+ }
108
+
109
+ return {
110
+ target,
111
+ version: parsedVersion,
112
+ versionString
113
+ };
114
+ }).filter(v => v != null).sort( // Sort the targets by target name and then version number in descending order
115
+ // ex. [a@3, b@3, a@1] => [a@3, a@1, b@3]
116
+ (a, b) => {
117
+ if (b.target.browserslist === a.target.browserslist) {
118
+ return b.version - a.version;
119
+ }
120
+
121
+ return b.target.browserslist.localeCompare(a.target.browserslist);
122
+ }).filter( // First last target always has the latest version
123
+ (e, i, items) => {
124
+ var _items;
125
+
126
+ return (// Check if the current target is the last of its kind.
127
+ // If it is, then it's the most recent version.
128
+ i + 1 === items.length || e.target.browserslist !== ((_items = items[i + 1]) === null || _items === void 0 ? void 0 : _items.target.browserslist)
129
+ );
130
+ })
131
+ );
132
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ async function collectFeatures({
9
+ nodes,
10
+ parent
11
+ }) {
12
+ var _parent$raws$between;
13
+
14
+ if (parent.prop !== '-moz-orient') {
15
+ return [];
16
+ }
17
+
18
+ const features = [];
19
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
20
+
21
+ for (const node of nodes) {
22
+ if (node.type !== 'word') {
23
+ continue;
24
+ }
25
+
26
+ const index = offset + node.sourceIndex;
27
+ const endIndex = offset + node.sourceEndIndex;
28
+
29
+ if (node.value === 'auto') {
30
+ features.push({
31
+ endIndex,
32
+ id: `properties.-moz-orient.auto`,
33
+ index,
34
+ name: `"auto" value specified as -moz-orient`,
35
+ node: parent
36
+ });
37
+ }
38
+
39
+ if (node.value === 'inline') {
40
+ features.push({
41
+ endIndex,
42
+ id: `properties.-moz-orient.inline_and_block`,
43
+ index,
44
+ name: `"inline" value specified as -moz-orient`,
45
+ node: parent
46
+ });
47
+ }
48
+
49
+ if (node.value === 'block') {
50
+ features.push({
51
+ endIndex,
52
+ id: `properties.-moz-orient.inline_and_block`,
53
+ index,
54
+ name: `"block" value specified as -moz-orient`,
55
+ node: parent
56
+ });
57
+ }
58
+ }
59
+
60
+ return features;
61
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ async function collectFeatures({
9
+ nodes,
10
+ parent
11
+ }) {
12
+ var _parent$raws$between;
13
+
14
+ if (parent.prop !== '-moz-user-input') {
15
+ return [];
16
+ }
17
+
18
+ const features = [];
19
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
20
+
21
+ for (const node of nodes) {
22
+ if (node.type !== 'word') {
23
+ continue;
24
+ }
25
+
26
+ const index = offset + node.sourceIndex;
27
+ const endIndex = offset + node.sourceEndIndex;
28
+
29
+ if (node.value === 'auto') {
30
+ features.push({
31
+ endIndex,
32
+ id: `properties.-moz-user-input.auto`,
33
+ index,
34
+ name: `"auto" value specified as -moz-user-input`,
35
+ node: parent
36
+ });
37
+ }
38
+
39
+ if (node.value === 'none') {
40
+ features.push({
41
+ endIndex,
42
+ id: `properties.-moz-user-input.none`,
43
+ index,
44
+ name: `"none" value specified as -moz-user-input`,
45
+ node: parent
46
+ });
47
+ }
48
+
49
+ if (node.value === 'disabled') {
50
+ features.push({
51
+ endIndex,
52
+ id: `properties.-moz-user-input.disabled`,
53
+ index,
54
+ name: `"disabled" value specified as -moz-user-input`,
55
+ node: parent
56
+ });
57
+ }
58
+
59
+ if (node.value === 'enabled') {
60
+ features.push({
61
+ endIndex,
62
+ id: `properties.-moz-user-input.enabled`,
63
+ index,
64
+ name: `"enabled" value specified as -moz-user-input`,
65
+ node: parent
66
+ });
67
+ }
68
+ }
69
+
70
+ return features;
71
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ async function collectFeatures({
9
+ nodes,
10
+ parent
11
+ }) {
12
+ var _parent$raws$between;
13
+
14
+ const prop = parent.prop.replace(/^-(webkit|moz|ms|o)-/, '');
15
+
16
+ if (prop !== 'animation' && prop !== 'animation-direction') {
17
+ return [];
18
+ }
19
+
20
+ const features = [];
21
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
22
+
23
+ for (const node of nodes) {
24
+ if (node.type !== 'word') {
25
+ continue;
26
+ }
27
+
28
+ const index = offset + node.sourceIndex;
29
+ const endIndex = offset + node.sourceEndIndex;
30
+
31
+ if (node.value === 'reverse') {
32
+ features.push({
33
+ endIndex,
34
+ id: `properties.animation-direction.reverse`,
35
+ index,
36
+ name: `"reverse" value specified as animation-direction`,
37
+ node: parent
38
+ });
39
+ }
40
+
41
+ if (node.value === 'alternate-reverse') {
42
+ features.push({
43
+ endIndex,
44
+ id: `properties.animation-direction.alternate-reverse`,
45
+ index,
46
+ name: `"alternate-reverse" value specified as animation-direction`,
47
+ node: parent
48
+ });
49
+ }
50
+ }
51
+
52
+ return features;
53
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+ const JUMP_TERM_WORD_LIST = ['jump-start', 'jump-end', 'jump-none', 'jump-both'];
8
+
9
+ async function collectFeatures({
10
+ nodes,
11
+ parent
12
+ }) {
13
+ const prop = parent.prop.replace(/^-(webkit|moz|ms|o)-/, '');
14
+
15
+ if (prop !== 'animation' && prop !== 'animation-timing-function') {
16
+ return [];
17
+ }
18
+
19
+ const features = [];
20
+
21
+ for (const node of nodes) {
22
+ var _node$nodes$, _node$nodes$2, _node$nodes$3, _parent$raws$between;
23
+
24
+ if (node.type !== 'function' || node.value !== 'steps') {
25
+ continue;
26
+ }
27
+
28
+ if (((_node$nodes$ = node.nodes[0]) === null || _node$nodes$ === void 0 ? void 0 : _node$nodes$.type) !== 'word' || ((_node$nodes$2 = node.nodes[1]) === null || _node$nodes$2 === void 0 ? void 0 : _node$nodes$2.type) !== 'div' || ((_node$nodes$3 = node.nodes[2]) === null || _node$nodes$3 === void 0 ? void 0 : _node$nodes$3.type) !== 'word') {
29
+ continue;
30
+ }
31
+
32
+ const jumptermNode = node.nodes[2];
33
+
34
+ if (JUMP_TERM_WORD_LIST.includes(jumptermNode.value) === false) {
35
+ continue;
36
+ }
37
+
38
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
39
+ const index = offset + jumptermNode.sourceIndex;
40
+ const endIndex = offset + jumptermNode.sourceEndIndex;
41
+ features.push({
42
+ endIndex,
43
+ id: `properties.animation-timing-function.jump`,
44
+ index,
45
+ name: `"${jumptermNode.value}" keyword for steps() specified as animation-timing-function`,
46
+ node: parent
47
+ });
48
+ }
49
+
50
+ return features;
51
+ }
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+ const COMPAT_AUTO_VALUE_LIST = ['button', 'searchfield', 'textarea', 'push-button', 'slider-horizontal', 'checkbox', 'radio', 'square-button', 'menulist', 'listbox', 'meter', 'progress-bar'];
8
+
9
+ async function collectFeatures({
10
+ nodes,
11
+ parent
12
+ }) {
13
+ var _parent$raws$between;
14
+
15
+ const prop = parent.prop.replace(/^-(webkit|moz|ms|o)-/, '');
16
+
17
+ if (prop !== 'appearance') {
18
+ return [];
19
+ }
20
+
21
+ const features = [];
22
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
23
+
24
+ for (const node of nodes) {
25
+ if (node.type !== 'word') {
26
+ continue;
27
+ }
28
+
29
+ const index = offset + node.sourceIndex;
30
+ const endIndex = offset + node.sourceEndIndex;
31
+
32
+ if (COMPAT_AUTO_VALUE_LIST.includes(node.value)) {
33
+ features.push({
34
+ endIndex,
35
+ id: `properties.appearance.compat-auto`,
36
+ index,
37
+ name: `"${parent.value}" value specified as appearance`,
38
+ node: parent
39
+ });
40
+ } else if (node.value === 'auto') {
41
+ features.push({
42
+ endIndex,
43
+ id: `properties.appearance.auto`,
44
+ index,
45
+ name: `"auto" value specified as appearance`,
46
+ node: parent
47
+ });
48
+ } else if (node.value === 'none') {
49
+ features.push({
50
+ endIndex,
51
+ id: `properties.appearance.none`,
52
+ index,
53
+ name: `"none" value specified as appearance`,
54
+ node: parent
55
+ });
56
+ } else if (node.value === 'textfield') {
57
+ features.push({
58
+ endIndex,
59
+ id: `properties.appearance.textfield`,
60
+ index,
61
+ name: `"textfield" value specified as appearance`,
62
+ node: parent
63
+ });
64
+ } else if (node.value === 'menulist-button') {
65
+ features.push({
66
+ endIndex,
67
+ id: `properties.appearance.menulist-button`,
68
+ index,
69
+ name: `"menulist-button" value specified as appearance`,
70
+ node: parent
71
+ });
72
+ }
73
+ }
74
+
75
+ return features;
76
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ 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); }
9
+
10
+ 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; }
11
+
12
+ const BOX_VALUE_LIST = ['border-box', 'padding-box', 'content-box', 'text'];
13
+
14
+ async function collectFeatures({
15
+ bgLayerList,
16
+ parent
17
+ }) {
18
+ var _parent$raws$between;
19
+
20
+ const prop = parent.prop.replace(/^-(webkit|moz|ms|o)-/, '');
21
+
22
+ if (prop !== 'background') {
23
+ return [];
24
+ }
25
+
26
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
27
+ const promises = [];
28
+ const features = []; // background-origin / background-clip
29
+
30
+ for (const bgLayer of bgLayerList) {
31
+ const boxList = bgLayer.filter(node => BOX_VALUE_LIST.includes(node.value)); // https://drafts.csswg.org/css-backgrounds/#the-background
32
+ // If one <box> value is present then it sets both background-origin and background-clip to that value
33
+ // If two values are present, then the first sets background-origin and the second background-clip.
34
+
35
+ const backgroundClipNode = boxList[1] ?? boxList[0];
36
+
37
+ if (backgroundClipNode != null) {
38
+ const index = offset + backgroundClipNode.sourceIndex;
39
+ const endIndex = offset + backgroundClipNode.sourceEndIndex;
40
+ features.push({
41
+ endIndex,
42
+ id: `properties.background.background-clip`,
43
+ index,
44
+ name: `Values of background-clip specified as background`,
45
+ node: parent
46
+ });
47
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("../../background-clip/collect_features"))).then(({
48
+ collectFeatures
49
+ }) => {
50
+ return collectFeatures({
51
+ nodes: [backgroundClipNode],
52
+ parent
53
+ });
54
+ }));
55
+ }
56
+ }
57
+
58
+ return [...features, ...(await Promise.all(promises)).flat()];
59
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ 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); }
9
+
10
+ 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; }
11
+
12
+ const BOX_VALUE_LIST = ['border-box', 'padding-box', 'content-box', 'text'];
13
+
14
+ async function collectFeatures({
15
+ bgLayerList,
16
+ parent
17
+ }) {
18
+ var _parent$raws$between;
19
+
20
+ const prop = parent.prop.replace(/^-(webkit|moz|ms|o)-/, '');
21
+
22
+ if (prop !== 'background') {
23
+ return [];
24
+ }
25
+
26
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
27
+ const promises = [];
28
+ const features = []; // background-origin / background-clip
29
+
30
+ for (const bgLayer of bgLayerList) {
31
+ const boxList = bgLayer.filter(node => BOX_VALUE_LIST.includes(node.value)); // https://drafts.csswg.org/css-backgrounds/#the-background
32
+ // If one <box> value is present then it sets both background-origin and background-clip to that value
33
+ // If two values are present, then the first sets background-origin and the second background-clip.
34
+
35
+ const backgroundOriginNode = boxList[0];
36
+
37
+ if (backgroundOriginNode != null) {
38
+ const index = offset + backgroundOriginNode.sourceIndex;
39
+ const endIndex = offset + backgroundOriginNode.sourceEndIndex;
40
+ features.push({
41
+ endIndex,
42
+ id: `properties.background.background-origin`,
43
+ index,
44
+ name: `Values of background-origin specified as background`,
45
+ node: parent
46
+ });
47
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("../../background-origin/collect_features"))).then(({
48
+ collectFeatures
49
+ }) => {
50
+ return collectFeatures({
51
+ nodes: [backgroundOriginNode],
52
+ parent
53
+ });
54
+ }));
55
+ }
56
+ }
57
+
58
+ return [...features, ...(await Promise.all(promises)).flat()];
59
+ }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.collectFeatures = collectFeatures;
7
+
8
+ var _postcssValueParser = require("postcss-value-parser");
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
+ const BG_SIZE_SINGLE_KEYWORD_LIST = ['contain', 'cover'];
15
+
16
+ function isValidBgSizeValue(node) {
17
+ if (node == null) {
18
+ return false;
19
+ }
20
+
21
+ if (node.type === 'word') {
22
+ return node.value === 'auto' || (0, _postcssValueParser.unit)(node.value) !== false;
23
+ }
24
+
25
+ if (node.type === 'function') {
26
+ return node.value === 'calc';
27
+ }
28
+
29
+ return false;
30
+ }
31
+
32
+ async function collectFeatures({
33
+ bgLayerList,
34
+ parent
35
+ }) {
36
+ var _parent$raws$between;
37
+
38
+ const prop = parent.prop.replace(/^-(webkit|moz|ms|o)-/, '');
39
+
40
+ if (prop !== 'background') {
41
+ return [];
42
+ }
43
+
44
+ const offset = parent.prop.length + (((_parent$raws$between = parent.raws.between) === null || _parent$raws$between === void 0 ? void 0 : _parent$raws$between.length) ?? 0);
45
+ const promises = [];
46
+ const features = []; // background-size
47
+
48
+ for (const bgLayer of bgLayerList) {
49
+ const slashDivNodeIndex = bgLayer.findIndex(node => node.type === 'div' && node.value === '/');
50
+
51
+ if (slashDivNodeIndex === -1) {
52
+ continue;
53
+ }
54
+
55
+ const firstValueNode = bgLayer[slashDivNodeIndex + 1];
56
+ const secondValueNode = bgLayer[slashDivNodeIndex + 3];
57
+
58
+ if (firstValueNode == null) {
59
+ continue;
60
+ }
61
+
62
+ if (BG_SIZE_SINGLE_KEYWORD_LIST.includes(firstValueNode.value)) {
63
+ const index = offset + firstValueNode.sourceIndex;
64
+ const endIndex = offset + firstValueNode.sourceEndIndex;
65
+ features.push({
66
+ endIndex,
67
+ id: `properties.background.background-size`,
68
+ index,
69
+ name: `Values of background-size specified as background`,
70
+ node: parent
71
+ });
72
+ promises.push(Promise.resolve().then(() => _interopRequireWildcard(require("../../background-size/collect_features"))).then(({
73
+ collectFeatures
74
+ }) => {
75
+ return collectFeatures({
76
+ nodes: [firstValueNode],
77
+ parent
78
+ });
79
+ }));
80
+ } else if (isValidBgSizeValue(firstValueNode)) {
81
+ if (isValidBgSizeValue(secondValueNode)) {
82
+ const index = offset + firstValueNode.sourceIndex;
83
+ const endIndex = offset + secondValueNode.sourceEndIndex;
84
+ features.push({
85
+ endIndex,
86
+ id: `properties.background.background-size`,
87
+ index,
88
+ name: `Values of background-size specified as background`,
89
+ node: parent
90
+ });
91
+ } else {
92
+ const index = offset + firstValueNode.sourceIndex;
93
+ const endIndex = offset + firstValueNode.sourceEndIndex;
94
+ features.push({
95
+ endIndex,
96
+ id: `properties.background.background-size`,
97
+ index,
98
+ name: `Values of background-size specified as background`,
99
+ node: parent
100
+ });
101
+ }
102
+ }
103
+ }
104
+
105
+ return [...features, ...(await Promise.all(promises)).flat()];
106
+ }