isAutoprefixable.cjs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const vendor = require('./vendor.cjs');
  5. /**
  6. * Extract each list using the internal API of Autoprefixer 10.2.5.
  7. *
  8. * @see https://github.com/postcss/autoprefixer/tree/10.2.5
  9. *
  10. * @example
  11. * const autoprefixer = require('autoprefixer');
  12. * const Browsers = require('autoprefixer/lib/browsers');
  13. * const Prefixes = require('autoprefixer/lib/prefixes');
  14. * const utils = require('autoprefixer/lib/utils');
  15. *
  16. * const prefixes = new Prefixes(autoprefixer.data.prefixes, new Browsers(autoprefixer.data.browsers, []));
  17. */
  18. /**
  19. * @example
  20. * Object.keys(prefixes.remove).filter((s) => s.startsWith('@'));
  21. */
  22. const AT_RULES = new Set([
  23. '@-moz-keyframes',
  24. '@-moz-document',
  25. '@-ms-keyframes',
  26. '@-ms-viewport',
  27. '@-o-keyframes',
  28. '@-o-viewport',
  29. '@-webkit-keyframes',
  30. '@-webkit-viewport',
  31. ]);
  32. /**
  33. * @example
  34. * prefixes.remove.selectors.map((s) => s.prefixed);
  35. */
  36. const SELECTORS = new Set([
  37. ':-moz-any-link',
  38. ':-moz-full-screen',
  39. ':-moz-placeholder',
  40. ':-moz-placeholder-shown',
  41. ':-moz-read-only',
  42. ':-moz-read-write',
  43. ':-ms-fullscreen',
  44. ':-ms-input-placeholder',
  45. ':-webkit-any-link',
  46. ':-webkit-full-screen',
  47. '::-moz-placeholder',
  48. '::-moz-selection',
  49. '::-ms-input-placeholder',
  50. '::-webkit-backdrop',
  51. '::-webkit-input-placeholder',
  52. ]);
  53. /**
  54. * @example
  55. * Object.entries(autoprefixer.data.prefixes)
  56. * .filter(([key, value]) => !value.selector && !value.props && !key.startsWith('@'))
  57. * .map(([key, value]) => key);
  58. */
  59. const PROPERTIES = new Set([
  60. 'align-content',
  61. 'align-items',
  62. 'align-self',
  63. 'animation',
  64. 'animation-delay',
  65. 'animation-direction',
  66. 'animation-duration',
  67. 'animation-fill-mode',
  68. 'animation-iteration-count',
  69. 'animation-name',
  70. 'animation-play-state',
  71. 'animation-timing-function',
  72. 'appearance',
  73. 'backdrop-filter',
  74. 'backface-visibility',
  75. 'background-clip',
  76. 'background-origin',
  77. 'background-size',
  78. 'border-block-end',
  79. 'border-block-start',
  80. 'border-bottom-left-radius',
  81. 'border-bottom-right-radius',
  82. 'border-image',
  83. 'border-inline-end',
  84. 'border-inline-start',
  85. 'border-radius',
  86. 'border-top-left-radius',
  87. 'border-top-right-radius',
  88. 'box-decoration-break',
  89. 'box-shadow',
  90. 'box-sizing',
  91. 'break-after',
  92. 'break-before',
  93. 'break-inside',
  94. 'clip-path',
  95. 'color-adjust',
  96. 'column-count',
  97. 'column-fill',
  98. 'column-gap',
  99. 'column-rule',
  100. 'column-rule-color',
  101. 'column-rule-style',
  102. 'column-rule-width',
  103. 'column-span',
  104. 'column-width',
  105. 'columns',
  106. 'filter',
  107. 'flex',
  108. 'flex-basis',
  109. 'flex-direction',
  110. 'flex-flow',
  111. 'flex-grow',
  112. 'flex-shrink',
  113. 'flex-wrap',
  114. 'flow-from',
  115. 'flow-into',
  116. 'font-feature-settings',
  117. 'font-kerning',
  118. 'font-language-override',
  119. 'font-variant-ligatures',
  120. 'grid-area',
  121. 'grid-column',
  122. 'grid-column-align',
  123. 'grid-column-end',
  124. 'grid-column-start',
  125. 'grid-row',
  126. 'grid-row-align',
  127. 'grid-row-end',
  128. 'grid-row-start',
  129. 'grid-template',
  130. 'grid-template-areas',
  131. 'grid-template-columns',
  132. 'grid-template-rows',
  133. 'hyphens',
  134. 'image-rendering',
  135. 'justify-content',
  136. 'margin-block-end',
  137. 'margin-block-start',
  138. 'margin-inline-end',
  139. 'margin-inline-start',
  140. 'mask',
  141. 'mask-border',
  142. 'mask-border-outset',
  143. 'mask-border-repeat',
  144. 'mask-border-slice',
  145. 'mask-border-source',
  146. 'mask-border-width',
  147. 'mask-clip',
  148. 'mask-composite',
  149. 'mask-image',
  150. 'mask-origin',
  151. 'mask-position',
  152. 'mask-repeat',
  153. 'mask-size',
  154. 'object-fit',
  155. 'object-position',
  156. 'order',
  157. 'overscroll-behavior',
  158. 'padding-block-end',
  159. 'padding-block-start',
  160. 'padding-inline-end',
  161. 'padding-inline-start',
  162. 'perspective',
  163. 'perspective-origin',
  164. 'place-self',
  165. 'region-fragment',
  166. 'scroll-snap-coordinate',
  167. 'scroll-snap-destination',
  168. 'scroll-snap-points-x',
  169. 'scroll-snap-points-y',
  170. 'scroll-snap-type',
  171. 'shape-image-threshold',
  172. 'shape-margin',
  173. 'shape-outside',
  174. 'tab-size',
  175. 'text-align-last',
  176. 'text-decoration',
  177. 'text-decoration-color',
  178. 'text-decoration-line',
  179. 'text-decoration-skip',
  180. 'text-decoration-skip-ink',
  181. 'text-decoration-style',
  182. 'text-emphasis',
  183. 'text-emphasis-color',
  184. 'text-emphasis-position',
  185. 'text-emphasis-style',
  186. 'text-orientation',
  187. 'text-overflow',
  188. 'text-size-adjust',
  189. 'text-spacing',
  190. 'touch-action',
  191. 'transform',
  192. 'transform-origin',
  193. 'transform-style',
  194. 'transition',
  195. 'transition-delay',
  196. 'transition-duration',
  197. 'transition-property',
  198. 'transition-timing-function',
  199. 'user-select',
  200. 'writing-mode',
  201. ]);
  202. /**
  203. * This list is currently being used to compile all the prefixed values that can safely be unprefixed.
  204. * i.e. value-no-vendor-prefix autofix ought to be able to handle it appropriately
  205. * It was initially populated using the following example:
  206. * @example
  207. * Object.values(prefixes.remove)
  208. * .filter((p) => Array.isArray(p.values))
  209. * .flatMap((p) => p.values)
  210. * .map((p) => utils.removeNote(p.prefixed)) // normalize '-webkit- old'
  211. * .filter((p) => !p.endsWith('-')); // remove '-webkit-' only
  212. *
  213. * @see https://github.com/stylelint/stylelint/pull/5312/files#r636018013
  214. */
  215. const PROPERTY_VALUES = new Set([
  216. '-moz-all',
  217. '-moz-calc',
  218. '-moz-crisp-edges',
  219. '-moz-element',
  220. '-moz-fit-content',
  221. '-moz-grab',
  222. '-moz-grabbing',
  223. '-moz-initial',
  224. '-moz-isolate',
  225. '-moz-isolate-override',
  226. '-moz-linear-gradient',
  227. '-moz-max-content',
  228. '-moz-min-content',
  229. '-moz-pre-wrap',
  230. '-moz-plaintext',
  231. '-moz-radial-gradient',
  232. '-moz-repeating-linear-gradient',
  233. '-moz-repeating-radial-gradient',
  234. '-moz-zoom-in',
  235. '-moz-zoom-out',
  236. '-ms-flexbox',
  237. '-ms-grid',
  238. '-ms-inline-grid',
  239. '-ms-linear-gradient',
  240. '-ms-radial-gradient',
  241. '-ms-repeating-linear-gradient',
  242. '-ms-repeating-radial-gradient',
  243. '-o-crisp-edges',
  244. '-o-linear-gradient',
  245. '-o-pre-wrap',
  246. '-o-radial-gradient',
  247. '-o-repeating-linear-gradient',
  248. '-o-repeating-radial-gradient',
  249. '-webkit-calc',
  250. '-webkit-cross-fade',
  251. '-webkit-filter',
  252. '-webkit-fit-content',
  253. '-webkit-flex',
  254. '-webkit-grab',
  255. '-webkit-grabbing',
  256. '-webkit-image-set',
  257. '-webkit-inline-flex',
  258. '-webkit-isolate',
  259. '-webkit-linear-gradient',
  260. '-webkit-max-content',
  261. '-webkit-min-content',
  262. '-webkit-plaintext',
  263. '-webkit-radial-gradient',
  264. '-webkit-repeating-linear-gradient',
  265. '-webkit-repeating-radial-gradient',
  266. '-webkit-sticky',
  267. '-webkit-zoom-in',
  268. '-webkit-zoom-out',
  269. '-xv-digits',
  270. '-xv-literal-punctuation',
  271. '-xv-no-punctuation',
  272. // Firefox does not support
  273. // ethiopic-halehame, ethiopic-halehame-am, ethiopic-halehame-ti-er and ethiopic-halehame-ti-et
  274. // without a -moz- prefix
  275. // see https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type
  276. '-moz-arabic-indic',
  277. '-moz-bengali',
  278. '-moz-cjk-earthly-branch',
  279. '-moz-cjk-heavenly-stem',
  280. '-moz-devanagari',
  281. '-moz-ethiopic-numeric',
  282. '-moz-gujarati',
  283. '-moz-gurmukhi',
  284. '-moz-hangul',
  285. '-moz-hangul-consonant',
  286. '-moz-japanese-formal',
  287. '-moz-japanese-informal',
  288. '-moz-kannada',
  289. '-moz-khmer',
  290. '-moz-lao',
  291. '-moz-malayalam',
  292. '-moz-myanmar',
  293. '-moz-oriya',
  294. '-moz-persian',
  295. '-moz-simp-chinese-formal',
  296. '-moz-simp-chinese-informal',
  297. '-moz-tamil',
  298. '-moz-telugu',
  299. '-moz-thai',
  300. '-moz-trad-chinese-formal',
  301. '-moz-trad-chinese-informal',
  302. ]);
  303. /**
  304. * Most identifier types have to be looked up in a unique way,
  305. * so we're exposing special functions for each.
  306. */
  307. const isAutoprefixable = {
  308. /**
  309. * @param {string} identifier
  310. * @returns {boolean}
  311. */
  312. atRuleName(identifier) {
  313. return AT_RULES.has(`@${identifier.toLowerCase()}`);
  314. },
  315. /**
  316. * @param {string} identifier
  317. * @returns {boolean}
  318. */
  319. selector(identifier) {
  320. return SELECTORS.has(identifier.toLowerCase());
  321. },
  322. /**
  323. * @param {string} identifier
  324. * @returns {boolean}
  325. */
  326. mediaFeatureName(identifier) {
  327. return identifier.toLowerCase().includes('device-pixel-ratio');
  328. },
  329. /**
  330. * @param {string} identifier
  331. * @returns {boolean}
  332. */
  333. property(identifier) {
  334. const ident = identifier.toLowerCase();
  335. if (vendor.prefix(ident).length === 0) {
  336. return false;
  337. }
  338. return PROPERTIES.has(vendor.unprefixed(ident));
  339. },
  340. /**
  341. * @param {string} value
  342. * @returns {boolean}
  343. */
  344. propertyValue(value) {
  345. return PROPERTY_VALUES.has(value.toLowerCase());
  346. },
  347. /**
  348. * @param {string} value
  349. * @returns {string}
  350. */
  351. unprefix(value) {
  352. return value.replace(/-\w+-/, '');
  353. },
  354. };
  355. module.exports = isAutoprefixable;