|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690 |
- 'use strict';
-
- const keywordSets = {};
-
- keywordSets.nonLengthUnits = new Set([
- // Relative length units
- '%',
- // Time length units
- 's',
- 'ms',
- // Angle
- 'deg',
- 'grad',
- 'turn',
- 'rad',
- // Frequency
- 'Hz',
- 'kHz',
- // Resolution
- 'dpi',
- 'dpcm',
- 'dppx',
- ]);
-
- keywordSets.lengthUnits = new Set([
- // Relative length units
- 'em',
- 'ex',
- 'ch',
- 'rem',
- 'rlh',
- 'lh',
- // Viewport-percentage lengths
- 'vh',
- 'vw',
- 'vmin',
- 'vmax',
- 'vm',
- // Absolute length units
- 'px',
- 'mm',
- 'cm',
- 'in',
- 'pt',
- 'pc',
- 'q',
- 'mozmm',
- // Flexible length units
- 'fr',
- ]);
-
- keywordSets.units = uniteSets(keywordSets.nonLengthUnits, keywordSets.lengthUnits);
-
- keywordSets.colorFunctionNames = new Set(['rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'gray']);
-
- keywordSets.camelCaseFunctionNames = new Set([
- 'translateX',
- 'translateY',
- 'translateZ',
- 'scaleX',
- 'scaleY',
- 'scaleZ',
- 'rotateX',
- 'rotateY',
- 'rotateZ',
- 'skewX',
- 'skewY',
- ]);
-
- keywordSets.basicKeywords = new Set(['initial', 'inherit', 'unset']);
-
- keywordSets.systemFontValues = uniteSets(keywordSets.basicKeywords, [
- 'caption',
- 'icon',
- 'menu',
- 'message-box',
- 'small-caption',
- 'status-bar',
- ]);
-
- keywordSets.fontFamilyKeywords = uniteSets(keywordSets.basicKeywords, [
- 'serif',
- 'sans-serif',
- 'cursive',
- 'fantasy',
- 'monospace',
- 'system-ui',
- ]);
-
- keywordSets.fontWeightRelativeKeywords = new Set(['bolder', 'lighter']);
-
- keywordSets.fontWeightAbsoluteKeywords = new Set(['bold']);
-
- keywordSets.fontWeightNumericKeywords = new Set([
- '100',
- '200',
- '300',
- '400',
- '500',
- '600',
- '700',
- '800',
- '900',
- ]);
-
- keywordSets.fontWeightKeywords = uniteSets(
- keywordSets.basicKeywords,
- keywordSets.fontWeightRelativeKeywords,
- keywordSets.fontWeightAbsoluteKeywords,
- keywordSets.fontWeightNumericKeywords,
- );
-
- keywordSets.animationNameKeywords = uniteSets(keywordSets.basicKeywords, ['none']);
-
- keywordSets.animationTimingFunctionKeywords = uniteSets(keywordSets.basicKeywords, [
- 'linear',
- 'ease',
- 'ease-in',
- 'ease-in-out',
- 'ease-out',
- 'step-start',
- 'step-end',
- 'steps',
- 'cubic-bezier',
- ]);
-
- keywordSets.animationIterationCountKeywords = new Set(['infinite']);
-
- keywordSets.animationDirectionKeywords = uniteSets(keywordSets.basicKeywords, [
- 'normal',
- 'reverse',
- 'alternate',
- 'alternate-reverse',
- ]);
-
- keywordSets.animationFillModeKeywords = new Set(['none', 'forwards', 'backwards', 'both']);
-
- keywordSets.animationPlayStateKeywords = uniteSets(keywordSets.basicKeywords, [
- 'running',
- 'paused',
- ]);
-
- // cf. https://developer.mozilla.org/en-US/docs/Web/CSS/animation
- keywordSets.animationShorthandKeywords = uniteSets(
- keywordSets.basicKeywords,
- keywordSets.animationNameKeywords,
- keywordSets.animationTimingFunctionKeywords,
- keywordSets.animationIterationCountKeywords,
- keywordSets.animationDirectionKeywords,
- keywordSets.animationFillModeKeywords,
- keywordSets.animationPlayStateKeywords,
- );
-
- // These are the ones that can have single-colon notation
- keywordSets.levelOneAndTwoPseudoElements = new Set([
- 'before',
- 'after',
- 'first-line',
- 'first-letter',
- ]);
-
- // These are the ones that require double-colon notation
- keywordSets.levelThreeAndUpPseudoElements = new Set([
- 'before',
- 'after',
- 'first-line',
- 'first-letter',
- 'selection',
- 'spelling-error',
- 'grammar-error',
- 'backdrop',
- 'marker',
- 'placeholder',
- 'shadow',
- 'slotted',
- 'content',
- 'file-selector-button',
- ]);
-
- keywordSets.shadowTreePseudoElements = new Set(['part']);
-
- keywordSets.vendorSpecificPseudoElements = new Set([
- '-moz-progress-bar',
- '-moz-range-progress',
- '-moz-range-thumb',
- '-moz-range-track',
- '-ms-browse',
- '-ms-check',
- '-ms-clear',
- '-ms-expand',
- '-ms-fill',
- '-ms-fill-lower',
- '-ms-fill-upper',
- '-ms-reveal',
- '-ms-thumb',
- '-ms-ticks-after',
- '-ms-ticks-before',
- '-ms-tooltip',
- '-ms-track',
- '-ms-value',
- '-webkit-progress-bar',
- '-webkit-progress-value',
- '-webkit-slider-runnable-track',
- '-webkit-slider-thumb',
- ]);
-
- keywordSets.pseudoElements = uniteSets(
- keywordSets.levelOneAndTwoPseudoElements,
- keywordSets.levelThreeAndUpPseudoElements,
- keywordSets.vendorSpecificPseudoElements,
- keywordSets.shadowTreePseudoElements,
- );
-
- keywordSets.aNPlusBNotationPseudoClasses = new Set([
- 'nth-column',
- 'nth-last-column',
- 'nth-last-of-type',
- 'nth-of-type',
- ]);
-
- keywordSets.linguisticPseudoClasses = new Set(['dir', 'lang']);
-
- keywordSets.atRulePagePseudoClasses = new Set(['first', 'right', 'left', 'blank']);
-
- keywordSets.logicalCombinationsPseudoClasses = new Set(['has', 'is', 'matches', 'not', 'where']);
-
- keywordSets.aNPlusBOfSNotationPseudoClasses = new Set(['nth-child', 'nth-last-child']);
-
- keywordSets.otherPseudoClasses = new Set([
- 'active',
- 'any-link',
- 'autofill',
- 'blank',
- 'checked',
- /*
- https://www.w3.org/Style/CSS/Test/CSS3/Selectors/20011105/html/tests/css3-modsel-85.html
- https://www.w3.org/Style/CSS/Test/CSS3/Selectors/20011105/html/tests/css3-modsel-84.html
- */
- 'contains',
- 'current',
- 'default',
- 'defined',
- 'disabled',
- 'drop',
- 'empty',
- 'enabled',
- 'first-child',
- 'first-of-type',
- 'focus',
- 'focus-ring',
- 'focus-within',
- 'focus-visible',
- 'fullscreen',
- 'future',
- 'host',
- 'host-context',
- 'hover',
- 'indeterminate',
- 'in-range',
- 'invalid',
- 'last-child',
- 'last-of-type',
- 'link',
- 'only-child',
- 'only-of-type',
- 'optional',
- 'out-of-range',
- 'past',
- 'placeholder-shown',
- 'playing',
- 'paused',
- 'read-only',
- 'read-write',
- 'required',
- 'root',
- 'scope',
- 'state',
- 'target',
- 'user-error',
- 'user-invalid',
- 'valid',
- 'visited',
- ]);
-
- keywordSets.webkitProprietaryPseudoElements = new Set([
- 'scrollbar',
- 'scrollbar-button',
- 'scrollbar-track',
- 'scrollbar-track-piece',
- 'scrollbar-thumb',
- 'scrollbar-corner',
- 'resize',
- ]);
-
- keywordSets.webkitProprietaryPseudoClasses = new Set([
- 'horizontal',
- 'vertical',
- 'decrement',
- 'increment',
- 'start',
- 'end',
- 'double-button',
- 'single-button',
- 'no-button',
- 'corner-present',
- 'window-inactive',
- ]);
-
- keywordSets.pseudoClasses = uniteSets(
- keywordSets.aNPlusBNotationPseudoClasses,
- keywordSets.linguisticPseudoClasses,
- keywordSets.logicalCombinationsPseudoClasses,
- keywordSets.aNPlusBOfSNotationPseudoClasses,
- keywordSets.otherPseudoClasses,
- );
-
- keywordSets.shorthandTimeProperties = new Set(['transition', 'animation']);
-
- keywordSets.longhandTimeProperties = new Set([
- 'transition-duration',
- 'transition-delay',
- 'animation-duration',
- 'animation-delay',
- ]);
-
- keywordSets.timeProperties = uniteSets(
- keywordSets.shorthandTimeProperties,
- keywordSets.longhandTimeProperties,
- );
-
- keywordSets.camelCaseKeywords = new Set([
- 'optimizeSpeed',
- 'optimizeQuality',
- 'optimizeLegibility',
- 'geometricPrecision',
- 'currentColor',
- 'crispEdges',
- 'visiblePainted',
- 'visibleFill',
- 'visibleStroke',
- 'sRGB',
- 'linearRGB',
- ]);
-
- // https://developer.mozilla.org/docs/Web/CSS/counter-increment
- keywordSets.counterIncrementKeywords = uniteSets(keywordSets.basicKeywords, ['none']);
-
- keywordSets.counterResetKeywords = uniteSets(keywordSets.basicKeywords, ['none']);
-
- keywordSets.gridRowKeywords = uniteSets(keywordSets.basicKeywords, ['auto', 'span']);
-
- keywordSets.gridColumnKeywords = uniteSets(keywordSets.basicKeywords, ['auto', 'span']);
-
- keywordSets.gridAreaKeywords = uniteSets(keywordSets.basicKeywords, ['auto', 'span']);
-
- // https://developer.mozilla.org/ru/docs/Web/CSS/list-style-type
- keywordSets.listStyleTypeKeywords = uniteSets(keywordSets.basicKeywords, [
- 'none',
- 'disc',
- 'circle',
- 'square',
- 'decimal',
- 'cjk-decimal',
- 'decimal-leading-zero',
- 'lower-roman',
- 'upper-roman',
- 'lower-greek',
- 'lower-alpha',
- 'lower-latin',
- 'upper-alpha',
- 'upper-latin',
- 'arabic-indic',
- 'armenian',
- 'bengali',
- 'cambodian',
- 'cjk-earthly-branch',
- 'cjk-ideographic',
- 'devanagari',
- 'ethiopic-numeric',
- 'georgian',
- 'gujarati',
- 'gurmukhi',
- 'hebrew',
- 'hiragana',
- 'hiragana-iroha',
- 'japanese-formal',
- 'japanese-informal',
- 'kannada',
- 'katakana',
- 'katakana-iroha',
- 'khmer',
- 'korean-hangul-formal',
- 'korean-hanja-formal',
- 'korean-hanja-informal',
- 'lao',
- 'lower-armenian',
- 'malayalam',
- 'mongolian',
- 'myanmar',
- 'oriya',
- 'persian',
- 'simp-chinese-formal',
- 'simp-chinese-informal',
- 'tamil',
- 'telugu',
- 'thai',
- 'tibetan',
- 'trad-chinese-formal',
- 'trad-chinese-informal',
- 'upper-armenian',
- 'disclosure-open',
- 'disclosure-closed',
- // Non-standard extensions (without prefixe)
- 'ethiopic-halehame',
- 'ethiopic-halehame-am',
- 'ethiopic-halehame-ti-er',
- 'ethiopic-halehame-ti-et',
- 'hangul',
- 'hangul-consonant',
- 'urdu',
- ]);
-
- keywordSets.listStylePositionKeywords = uniteSets(keywordSets.basicKeywords, ['inside', 'outside']);
-
- keywordSets.listStyleImageKeywords = uniteSets(keywordSets.basicKeywords, ['none']);
-
- keywordSets.listStyleShorthandKeywords = uniteSets(
- keywordSets.basicKeywords,
- keywordSets.listStyleTypeKeywords,
- keywordSets.listStylePositionKeywords,
- keywordSets.listStyleImageKeywords,
- );
-
- keywordSets.fontStyleKeywords = uniteSets(keywordSets.basicKeywords, [
- 'normal',
- 'italic',
- 'oblique',
- ]);
-
- keywordSets.fontVariantKeywords = uniteSets(keywordSets.basicKeywords, [
- 'normal',
- 'none',
- 'historical-forms',
- 'none',
- 'common-ligatures',
- 'no-common-ligatures',
- 'discretionary-ligatures',
- 'no-discretionary-ligatures',
- 'historical-ligatures',
- 'no-historical-ligatures',
- 'contextual',
- 'no-contextual',
- 'small-caps',
- 'small-caps',
- 'all-small-caps',
- 'petite-caps',
- 'all-petite-caps',
- 'unicase',
- 'titling-caps',
- 'lining-nums',
- 'oldstyle-nums',
- 'proportional-nums',
- 'tabular-nums',
- 'diagonal-fractions',
- 'stacked-fractions',
- 'ordinal',
- 'slashed-zero',
- 'jis78',
- 'jis83',
- 'jis90',
- 'jis04',
- 'simplified',
- 'traditional',
- 'full-width',
- 'proportional-width',
- 'ruby',
- ]);
-
- keywordSets.fontStretchKeywords = uniteSets(keywordSets.basicKeywords, [
- 'semi-condensed',
- 'condensed',
- 'extra-condensed',
- 'ultra-condensed',
- 'semi-expanded',
- 'expanded',
- 'extra-expanded',
- 'ultra-expanded',
- ]);
-
- keywordSets.fontSizeKeywords = uniteSets(keywordSets.basicKeywords, [
- 'xx-small',
- 'x-small',
- 'small',
- 'medium',
- 'large',
- 'x-large',
- 'xx-large',
- 'larger',
- 'smaller',
- ]);
-
- keywordSets.lineHeightKeywords = uniteSets(keywordSets.basicKeywords, ['normal']);
-
- keywordSets.fontShorthandKeywords = uniteSets(
- keywordSets.basicKeywords,
- keywordSets.fontStyleKeywords,
- keywordSets.fontVariantKeywords,
- keywordSets.fontWeightKeywords,
- keywordSets.fontStretchKeywords,
- keywordSets.fontSizeKeywords,
- keywordSets.lineHeightKeywords,
- keywordSets.fontFamilyKeywords,
- );
-
- keywordSets.keyframeSelectorKeywords = new Set(['from', 'to']);
-
- // https://www.w3.org/TR/css-page-3/#syntax-page-selector
- keywordSets.pageMarginAtRules = new Set([
- 'top-left-corner',
- 'top-left',
- 'top-center',
- 'top-right',
- 'top-right-corner',
- 'bottom-left-corner',
- 'bottom-left',
- 'bottom-center',
- 'bottom-right',
- 'bottom-right-corner',
- 'left-top',
- 'left-middle',
- 'left-bottom',
- 'right-top',
- 'right-middle',
- 'right-bottom',
- ]);
-
- // https://developer.mozilla.org/en/docs/Web/CSS/At-rule
- keywordSets.atRules = uniteSets(keywordSets.pageMarginAtRules, [
- 'annotation',
- 'apply',
- 'character-variant',
- 'charset',
- 'counter-style',
- 'custom-media',
- 'custom-selector',
- 'document',
- 'font-face',
- 'font-feature-values',
- 'import',
- 'keyframes',
- 'media',
- 'namespace',
- 'nest',
- 'ornaments',
- 'page',
- 'property',
- 'styleset',
- 'stylistic',
- 'supports',
- 'swash',
- 'viewport',
- ]);
-
- // https://drafts.csswg.org/mediaqueries/#descdef-media-update
- keywordSets.deprecatedMediaFeatureNames = new Set([
- 'device-aspect-ratio',
- 'device-height',
- 'device-width',
- 'max-device-aspect-ratio',
- 'max-device-height',
- 'max-device-width',
- 'min-device-aspect-ratio',
- 'min-device-height',
- 'min-device-width',
- ]);
-
- // https://drafts.csswg.org/mediaqueries/#descdef-media-update
- keywordSets.mediaFeatureNames = uniteSets(keywordSets.deprecatedMediaFeatureNames, [
- 'any-hover',
- 'any-pointer',
- 'aspect-ratio',
- 'color',
- 'color-gamut',
- 'color-index',
- 'forced-colors',
- 'grid',
- 'height',
- 'hover',
- 'inverted-colors',
- 'light-level',
- 'max-aspect-ratio',
- 'max-color',
- 'max-color-index',
- 'max-height',
- 'max-monochrome',
- 'max-resolution',
- 'max-width',
- 'min-aspect-ratio',
- 'min-color',
- 'min-color-index',
- 'min-height',
- 'min-monochrome',
- 'min-resolution',
- 'min-width',
- 'monochrome',
- 'orientation',
- 'overflow-block',
- 'overflow-inline',
- 'pointer',
- 'prefers-color-scheme',
- 'prefers-reduced-motion',
- 'prefers-reduced-transparency',
- 'resolution',
- 'scan',
- 'scripting',
- 'update',
- 'width',
- ]);
-
- // https://www.w3.org/TR/CSS22/ui.html#system-colors
- keywordSets.systemColors = new Set([
- 'activeborder',
- 'activecaption',
- 'appworkspace',
- 'background',
- 'buttonface',
- 'buttonhighlight',
- 'buttonshadow',
- 'buttontext',
- 'captiontext',
- 'graytext',
- 'highlight',
- 'highlighttext',
- 'inactiveborder',
- 'inactivecaption',
- 'inactivecaptiontext',
- 'infobackground',
- 'infotext',
- 'menu',
- 'menutext',
- 'scrollbar',
- 'threeddarkshadow',
- 'threedface',
- 'threedhighlight',
- 'threedlightshadow',
- 'threedshadow',
- 'window',
- 'windowframe',
- 'windowtext',
- ]);
-
- // htmlTags includes only "standard" tags. So we augment it with older tags etc.
- keywordSets.nonStandardHtmlTags = new Set([
- 'acronym',
- 'applet',
- 'basefont',
- 'big',
- 'blink',
- 'center',
- 'content',
- 'dir',
- 'font',
- 'frame',
- 'frameset',
- 'hgroup',
- 'isindex',
- 'keygen',
- 'listing',
- 'marquee',
- 'nobr',
- 'noembed',
- 'plaintext',
- 'spacer',
- 'strike',
- 'tt',
- 'xmp',
- ]);
-
- /**
- * @param {(string[] | Set<string>)[]} args
- */
- function uniteSets(...args) {
- return new Set(
- [...args].reduce((/** @type {string[]} */ result, set) => {
- return result.concat([...set]);
- }, []),
- );
- }
-
- module.exports = keywordSets;
|