keywords.mjs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. import uniteSets from '../utils/uniteSets.mjs';
  2. /** @type {ReadonlySet<string>} */
  3. export const basicKeywords = new Set(['initial', 'inherit', 'revert', 'revert-layer', 'unset']);
  4. /** @type {ReadonlySet<string>} */
  5. export const systemFontKeywords = uniteSets(basicKeywords, [
  6. 'caption',
  7. 'icon',
  8. 'menu',
  9. 'message-box',
  10. 'small-caption',
  11. 'status-bar',
  12. ]);
  13. /** @type {ReadonlySet<string>} */
  14. export const fontFamilyKeywords = uniteSets(basicKeywords, [
  15. 'serif',
  16. 'sans-serif',
  17. 'cursive',
  18. 'fantasy',
  19. 'monospace',
  20. 'system-ui',
  21. 'ui-serif',
  22. 'ui-sans-serif',
  23. 'ui-monospace',
  24. 'ui-rounded',
  25. 'emoji',
  26. 'math',
  27. 'fangsong',
  28. ]);
  29. /** @type {ReadonlySet<string>} */
  30. const appleSystemFonts = new Set([
  31. '-apple-system',
  32. '-apple-system-headline',
  33. '-apple-system-body',
  34. '-apple-system-subheadline',
  35. '-apple-system-footnote',
  36. '-apple-system-caption1',
  37. '-apple-system-caption2',
  38. '-apple-system-short-headline',
  39. '-apple-system-short-body',
  40. '-apple-system-short-subheadline',
  41. '-apple-system-short-footnote',
  42. '-apple-system-short-caption1',
  43. '-apple-system-tall-body',
  44. '-apple-system-title0',
  45. '-apple-system-title1',
  46. '-apple-system-title2',
  47. '-apple-system-title3',
  48. '-apple-system-title4',
  49. ]);
  50. /** @type {ReadonlySet<string>} */
  51. const mozillaSystemFonts = new Set([
  52. '-moz-button',
  53. '-moz-desktop',
  54. '-moz-dialog',
  55. '-moz-document',
  56. '-moz-field',
  57. '-moz-fixed',
  58. '-moz-info',
  59. '-moz-list',
  60. '-moz-pull-down-menu',
  61. '-moz-window',
  62. '-moz-workspace',
  63. ]);
  64. /** @type {ReadonlySet<string>} */
  65. const webkitSystemFonts = new Set([
  66. '-webkit-body',
  67. '-webkit-control',
  68. '-webkit-mini-control',
  69. '-webkit-pictograph',
  70. '-webkit-small-control',
  71. '-webkit-standard',
  72. ]);
  73. /** @type {ReadonlySet<string>} */
  74. export const prefixedSystemFonts = uniteSets(
  75. appleSystemFonts,
  76. mozillaSystemFonts,
  77. webkitSystemFonts,
  78. );
  79. /** @type {ReadonlySet<string>} */
  80. export const fontWeightRelativeKeywords = new Set(['bolder', 'lighter']);
  81. /** @type {ReadonlySet<string>} */
  82. export const fontWeightAbsoluteKeywords = new Set(['normal', 'bold']);
  83. /** @type {ReadonlySet<string>} */
  84. export const fontWeightNonNumericKeywords = uniteSets(
  85. fontWeightRelativeKeywords,
  86. fontWeightAbsoluteKeywords,
  87. );
  88. /** @type {ReadonlySet<string>} */
  89. const fontWeightNumericKeywords = new Set([
  90. '100',
  91. '200',
  92. '300',
  93. '400',
  94. '500',
  95. '600',
  96. '700',
  97. '800',
  98. '900',
  99. ]);
  100. /** @type {ReadonlySet<string>} */
  101. export const fontWeightKeywords = uniteSets(
  102. basicKeywords,
  103. fontWeightNonNumericKeywords,
  104. fontWeightNumericKeywords,
  105. );
  106. /** @type {ReadonlySet<string>} */
  107. const fontStyleKeywords = uniteSets(basicKeywords, ['normal', 'italic', 'oblique']);
  108. /** @type {ReadonlySet<string>} */
  109. const fontVariantCSS2Keywords = uniteSets(basicKeywords, ['normal', 'none', 'small-caps']);
  110. /** @type {ReadonlySet<string>} */
  111. const fontStretchKeywords = uniteSets(basicKeywords, [
  112. 'semi-condensed',
  113. 'condensed',
  114. 'extra-condensed',
  115. 'ultra-condensed',
  116. 'semi-expanded',
  117. 'expanded',
  118. 'extra-expanded',
  119. 'ultra-expanded',
  120. ]);
  121. /** @type {ReadonlySet<string>} */
  122. export const fontSizeKeywords = uniteSets(basicKeywords, [
  123. 'xx-small',
  124. 'x-small',
  125. 'small',
  126. 'medium',
  127. 'large',
  128. 'x-large',
  129. 'xx-large',
  130. 'xxx-large',
  131. 'larger',
  132. 'smaller',
  133. 'math',
  134. '-konq-xxx-large',
  135. '-webkit-xxx-large',
  136. ]);
  137. /** @type {ReadonlySet<string>} */
  138. const lineHeightKeywords = uniteSets(basicKeywords, ['normal']);
  139. /** @type {ReadonlySet<string>} */
  140. export const fontShorthandKeywords = uniteSets(
  141. basicKeywords,
  142. fontStyleKeywords,
  143. fontVariantCSS2Keywords,
  144. fontWeightKeywords,
  145. fontStretchKeywords,
  146. fontSizeKeywords,
  147. lineHeightKeywords,
  148. fontFamilyKeywords,
  149. );
  150. /** @type {ReadonlySet<string>} */
  151. export const animationNameKeywords = uniteSets(basicKeywords, ['none']);
  152. /** @type {ReadonlySet<string>} */
  153. const animationTimingFunctionKeywords = uniteSets(basicKeywords, [
  154. 'linear',
  155. 'ease',
  156. 'ease-in',
  157. 'ease-in-out',
  158. 'ease-out',
  159. 'step-start',
  160. 'step-end',
  161. 'steps',
  162. 'cubic-bezier',
  163. ]);
  164. /** @type {ReadonlySet<string>} */
  165. const animationIterationCountKeywords = new Set(['infinite']);
  166. /** @type {ReadonlySet<string>} */
  167. const animationDirectionKeywords = uniteSets(basicKeywords, [
  168. 'normal',
  169. 'reverse',
  170. 'alternate',
  171. 'alternate-reverse',
  172. ]);
  173. /** @type {ReadonlySet<string>} */
  174. const animationFillModeKeywords = new Set(['none', 'forwards', 'backwards', 'both']);
  175. /** @type {ReadonlySet<string>} */
  176. const animationPlayStateKeywords = uniteSets(basicKeywords, ['running', 'paused']);
  177. /**
  178. * @see https://developer.mozilla.org/docs/Web/CSS/animation
  179. * @type {ReadonlySet<string>}
  180. */
  181. export const animationShorthandKeywords = uniteSets(
  182. basicKeywords,
  183. animationNameKeywords,
  184. animationTimingFunctionKeywords,
  185. animationIterationCountKeywords,
  186. animationDirectionKeywords,
  187. animationFillModeKeywords,
  188. animationPlayStateKeywords,
  189. );
  190. /** @type {ReadonlySet<string>} */
  191. export const gridRowKeywords = uniteSets(basicKeywords, ['auto', 'span']);
  192. /** @type {ReadonlySet<string>} */
  193. export const gridColumnKeywords = uniteSets(basicKeywords, ['auto', 'span']);
  194. /** @type {ReadonlySet<string>} */
  195. export const gridAreaKeywords = uniteSets(basicKeywords, ['auto', 'span']);
  196. /**
  197. * @see https://developer.mozilla.org/docs/Web/CSS/counter-increment
  198. * @type {ReadonlySet<string>}
  199. */
  200. export const counterIncrementKeywords = uniteSets(basicKeywords, ['none']);
  201. /** @type {ReadonlySet<string>} */
  202. export const counterResetKeywords = uniteSets(basicKeywords, ['none']);
  203. /**
  204. * @see https://developer.mozilla.org/docs/Web/CSS/list-style-type
  205. * @type {ReadonlySet<string>}
  206. */
  207. export const listStyleTypeKeywords = uniteSets(basicKeywords, [
  208. 'none',
  209. 'disc',
  210. 'circle',
  211. 'square',
  212. 'decimal',
  213. 'decimal-leading-zero',
  214. 'cjk-decimal',
  215. 'cjk-earthly-branch',
  216. 'cjk-heavenly-stem',
  217. 'cjk-ideographic',
  218. 'lower-alpha',
  219. 'upper-alpha',
  220. 'lower-armenian',
  221. 'upper-armenian',
  222. 'lower-greek',
  223. 'upper-greek',
  224. 'lower-hexadecimal',
  225. 'upper-hexadecimal',
  226. 'lower-latin',
  227. 'upper-latin',
  228. 'lower-norwegian',
  229. 'upper-norwegian',
  230. 'lower-roman',
  231. 'upper-roman',
  232. 'afar',
  233. 'amharic',
  234. 'amharic-abegede',
  235. 'arabic-indic',
  236. 'armenian',
  237. 'bengali',
  238. 'cambodian',
  239. 'devanagari',
  240. 'ethiopic-abegede',
  241. 'ethiopic-abegede-am-et',
  242. 'ethiopic-abegede-gez',
  243. 'ethiopic-abegede-ti-er',
  244. 'ethiopic-abegede-ti-et',
  245. 'ethiopic-halehame',
  246. 'ethiopic-halehame-aa-er',
  247. 'ethiopic-halehame-aa-et',
  248. 'ethiopic-halehame-am',
  249. 'ethiopic-halehame-am-et',
  250. 'ethiopic-halehame-gez',
  251. 'ethiopic-halehame-om-et',
  252. 'ethiopic-halehame-sid-et',
  253. 'ethiopic-halehame-so-et',
  254. 'ethiopic-halehame-ti-er',
  255. 'ethiopic-halehame-ti-et',
  256. 'ethiopic-halehame-tig',
  257. 'ethiopic-numeric',
  258. 'georgian',
  259. 'gujarati',
  260. 'gurmukhi',
  261. 'hangul',
  262. 'hangul-consonant',
  263. 'hebrew',
  264. 'hiragana',
  265. 'hiragana-iroha',
  266. 'japanese-formal',
  267. 'japanese-informal',
  268. 'kannada',
  269. 'katakana',
  270. 'katakana-iroha',
  271. 'khmer',
  272. 'korean-hangul-formal',
  273. 'korean-hanja-formal',
  274. 'korean-hanja-informal',
  275. 'lao',
  276. 'malayalam',
  277. 'mongolian',
  278. 'myanmar',
  279. 'oriya',
  280. 'oromo',
  281. 'persian',
  282. 'sidama',
  283. 'somali',
  284. 'simp-chinese-formal',
  285. 'simp-chinese-informal',
  286. 'tamil',
  287. 'telugu',
  288. 'thai',
  289. 'tibetan',
  290. 'tigre',
  291. 'tigrinya-er',
  292. 'tigrinya-er-abegede',
  293. 'tigrinya-et',
  294. 'tigrinya-et-abegede',
  295. 'trad-chinese-formal',
  296. 'trad-chinese-informal',
  297. 'urdu',
  298. 'disclosure-open',
  299. 'disclosure-closed',
  300. 'asterisks',
  301. 'binary',
  302. 'footnotes',
  303. 'octal',
  304. ]);
  305. /** @type {ReadonlySet<string>} */
  306. export const listStylePositionKeywords = uniteSets(basicKeywords, ['inside', 'outside']);
  307. /** @type {ReadonlySet<string>} */
  308. export const listStyleImageKeywords = uniteSets(basicKeywords, ['none']);
  309. /** @type {ReadonlySet<string>} */
  310. export const listStyleShorthandKeywords = uniteSets(
  311. basicKeywords,
  312. listStyleTypeKeywords,
  313. listStylePositionKeywords,
  314. listStyleImageKeywords,
  315. );
  316. /** @type {ReadonlySet<string>} */
  317. export const camelCaseKeywords = new Set([
  318. 'optimizeSpeed',
  319. 'optimizeQuality',
  320. 'optimizeLegibility',
  321. 'geometricPrecision',
  322. 'currentColor',
  323. 'crispEdges',
  324. 'visiblePainted',
  325. 'visibleFill',
  326. 'visibleStroke',
  327. 'sRGB',
  328. 'linearRGB',
  329. ]);
  330. /** @type {ReadonlySet<string>} */
  331. export const keyframeSelectorKeywords = new Set(['from', 'to']);
  332. /**
  333. * @see https://drafts.csswg.org/scroll-animations-1/#view-progress-timelines
  334. * @type {ReadonlySet<string>}
  335. */
  336. export const namedTimelineRangeKeywords = new Set([
  337. 'contain',
  338. 'cover',
  339. 'entry',
  340. 'entry-crossing',
  341. 'exit',
  342. 'exit-crossing',
  343. ]);
  344. /**
  345. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions#color_keywords
  346. * @type {ReadonlySet<string>}
  347. */
  348. const prefixedSystemColorKeywords = new Set([
  349. '-moz-buttondefault',
  350. '-moz-buttonhoverface',
  351. '-moz-buttonhovertext',
  352. '-moz-cellhighlight',
  353. '-moz-cellhighlighttext',
  354. '-moz-combobox',
  355. '-moz-comboboxtext',
  356. '-moz-dialog',
  357. '-moz-dialogtext',
  358. '-moz-dragtargetzone',
  359. '-moz-eventreerow',
  360. '-moz-field',
  361. '-moz-fieldtext',
  362. '-moz-html-cellhighlight',
  363. '-moz-html-cellhighlighttext',
  364. '-moz-mac-accentdarkestshadow',
  365. '-moz-mac-accentdarkshadow',
  366. '-moz-mac-accentface',
  367. '-moz-mac-accentlightesthighlight',
  368. '-moz-mac-accentlightshadow',
  369. '-moz-mac-accentregularhighlight',
  370. '-moz-mac-accentregularshadow',
  371. '-moz-mac-chrome-active',
  372. '-moz-mac-chrome-inactive',
  373. '-moz-mac-focusring',
  374. '-moz-mac-menuselect',
  375. '-moz-mac-menushadow',
  376. '-moz-mac-menutextselect',
  377. '-moz-menubarhovertext',
  378. '-moz-menubartext',
  379. '-moz-menuhover',
  380. '-moz-menuhovertext',
  381. '-moz-nativehyperlinktext',
  382. '-moz-oddtreerow',
  383. '-moz-win-accentcolor',
  384. '-moz-win-accentcolortext',
  385. '-moz-win-communicationstext',
  386. '-moz-win-mediatext',
  387. '-ms-hotlight',
  388. ]);
  389. /** @type {ReadonlySet<string>} */
  390. export const deprecatedSystemColorKeywords = new Set([
  391. 'activeborder',
  392. 'activecaption',
  393. 'appworkspace',
  394. 'background',
  395. 'buttonhighlight',
  396. 'buttonshadow',
  397. 'captiontext',
  398. 'inactiveborder',
  399. 'inactivecaption',
  400. 'inactivecaptiontext',
  401. 'infobackground',
  402. 'infotext',
  403. 'menu',
  404. 'menutext',
  405. 'scrollbar',
  406. 'threeddarkshadow',
  407. 'threedface',
  408. 'threedhighlight',
  409. 'threedlightshadow',
  410. 'threedshadow',
  411. 'window',
  412. 'windowframe',
  413. 'windowtext',
  414. ]);
  415. /** @type {ReadonlySet<string>} */
  416. export const systemColorsKeywords = uniteSets(
  417. prefixedSystemColorKeywords,
  418. deprecatedSystemColorKeywords,
  419. [
  420. // https://www.w3.org/TR/css-color-4/#css-system-colors
  421. 'accentcolor',
  422. 'accentcolortext',
  423. 'activetext',
  424. 'buttonborder',
  425. 'buttonface',
  426. 'buttontext',
  427. 'canvas',
  428. 'canvastext',
  429. 'field',
  430. 'fieldtext',
  431. 'graytext',
  432. 'highlight',
  433. 'highlighttext',
  434. 'linktext',
  435. 'mark',
  436. 'marktext',
  437. 'selecteditem',
  438. 'selecteditemtext',
  439. 'visitedtext',
  440. ],
  441. );
  442. /**
  443. * @see https://www.w3.org/TR/css-color-4/#named-colors
  444. * @type {ReadonlySet<string>}
  445. */
  446. export const namedColorsKeywords = new Set([
  447. 'aliceblue',
  448. 'antiquewhite',
  449. 'aqua',
  450. 'aquamarine',
  451. 'azure',
  452. 'beige',
  453. 'bisque',
  454. 'black',
  455. 'blanchedalmond',
  456. 'blue',
  457. 'blueviolet',
  458. 'brown',
  459. 'burlywood',
  460. 'cadetblue',
  461. 'chartreuse',
  462. 'chocolate',
  463. 'coral',
  464. 'cornflowerblue',
  465. 'cornsilk',
  466. 'crimson',
  467. 'cyan',
  468. 'darkblue',
  469. 'darkcyan',
  470. 'darkgoldenrod',
  471. 'darkgray',
  472. 'darkgreen',
  473. 'darkgrey',
  474. 'darkkhaki',
  475. 'darkmagenta',
  476. 'darkolivegreen',
  477. 'darkorange',
  478. 'darkorchid',
  479. 'darkred',
  480. 'darksalmon',
  481. 'darkseagreen',
  482. 'darkslateblue',
  483. 'darkslategray',
  484. 'darkslategrey',
  485. 'darkturquoise',
  486. 'darkviolet',
  487. 'deeppink',
  488. 'deepskyblue',
  489. 'dimgray',
  490. 'dimgrey',
  491. 'dodgerblue',
  492. 'firebrick',
  493. 'floralwhite',
  494. 'forestgreen',
  495. 'fuchsia',
  496. 'gainsboro',
  497. 'ghostwhite',
  498. 'gold',
  499. 'goldenrod',
  500. 'gray',
  501. 'green',
  502. 'greenyellow',
  503. 'grey',
  504. 'honeydew',
  505. 'hotpink',
  506. 'indianred',
  507. 'indigo',
  508. 'ivory',
  509. 'khaki',
  510. 'lavender',
  511. 'lavenderblush',
  512. 'lawngreen',
  513. 'lemonchiffon',
  514. 'lightblue',
  515. 'lightcoral',
  516. 'lightcyan',
  517. 'lightgoldenrodyellow',
  518. 'lightgray',
  519. 'lightgreen',
  520. 'lightgrey',
  521. 'lightpink',
  522. 'lightsalmon',
  523. 'lightseagreen',
  524. 'lightskyblue',
  525. 'lightslategray',
  526. 'lightslategrey',
  527. 'lightsteelblue',
  528. 'lightyellow',
  529. 'lime',
  530. 'limegreen',
  531. 'linen',
  532. 'magenta',
  533. 'maroon',
  534. 'mediumaquamarine',
  535. 'mediumblue',
  536. 'mediumorchid',
  537. 'mediumpurple',
  538. 'mediumseagreen',
  539. 'mediumslateblue',
  540. 'mediumspringgreen',
  541. 'mediumturquoise',
  542. 'mediumvioletred',
  543. 'midnightblue',
  544. 'mintcream',
  545. 'mistyrose',
  546. 'moccasin',
  547. 'navajowhite',
  548. 'navy',
  549. 'oldlace',
  550. 'olive',
  551. 'olivedrab',
  552. 'orange',
  553. 'orangered',
  554. 'orchid',
  555. 'palegoldenrod',
  556. 'palegreen',
  557. 'paleturquoise',
  558. 'palevioletred',
  559. 'papayawhip',
  560. 'peachpuff',
  561. 'peru',
  562. 'pink',
  563. 'plum',
  564. 'powderblue',
  565. 'purple',
  566. 'rebeccapurple',
  567. 'red',
  568. 'rosybrown',
  569. 'royalblue',
  570. 'saddlebrown',
  571. 'salmon',
  572. 'sandybrown',
  573. 'seagreen',
  574. 'seashell',
  575. 'sienna',
  576. 'silver',
  577. 'skyblue',
  578. 'slateblue',
  579. 'slategray',
  580. 'slategrey',
  581. 'snow',
  582. 'springgreen',
  583. 'steelblue',
  584. 'tan',
  585. 'teal',
  586. 'thistle',
  587. 'tomato',
  588. 'turquoise',
  589. 'violet',
  590. 'wheat',
  591. 'white',
  592. 'whitesmoke',
  593. 'yellow',
  594. 'yellowgreen',
  595. ]);