diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..70b329a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: node_js + +node_js: + - 'stable' diff --git a/index.d.ts b/index.d.ts index c550cb5..96ef91a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -349,7 +349,6 @@ export interface VendorLonghandProperties { MozAnimationTimingFunction?: AnimationTimingFunctionProperty; MozAppearance?: MozAppearanceProperty; MozBackfaceVisibility?: BackfaceVisibilityProperty; - MozBackgroundSize?: BackgroundSizeProperty; MozBinding?: MozBindingProperty; MozBorderBottomColors?: MozBorderBottomColorsProperty; MozBorderEndColor?: BorderInlineEndColorProperty; @@ -384,7 +383,6 @@ export interface VendorLonghandProperties { MozPaddingStart?: PaddingInlineStartProperty; MozPerspective?: PerspectiveProperty; MozPerspectiveOrigin?: PerspectiveOriginProperty; - MozResize?: ResizeProperty; MozStackSizing?: MozStackSizingProperty; MozTabSize?: TabSizeProperty; MozTextBlink?: MozTextBlinkProperty; @@ -628,6 +626,8 @@ export interface ObsoleteProperties { /** @deprecated */ MozBackgroundInlinePolicy?: BoxDecorationBreakProperty; /** @deprecated */ + MozBackgroundSize?: BackgroundSizeProperty; + /** @deprecated */ MozBorderRadius?: BorderRadiusProperty; /** @deprecated */ MozBorderRadiusTopright?: BorderTopRightRadiusProperty; @@ -652,6 +652,8 @@ export interface ObsoleteProperties { /** @deprecated */ MozOutlineWidth?: OutlineWidthProperty; /** @deprecated */ + MozResize?: ResizeProperty; + /** @deprecated */ MozTextAlignLast?: TextAlignLastProperty; /** @deprecated */ MozTextDecorationColor?: TextDecorationColorProperty; @@ -1123,7 +1125,6 @@ export interface VendorLonghandPropertiesHyphen { "-moz-animation-timing-function"?: AnimationTimingFunctionProperty; "-moz-appearance"?: MozAppearanceProperty; "-moz-backface-visibility"?: BackfaceVisibilityProperty; - "-moz-background-size"?: BackgroundSizeProperty; "-moz-binding"?: MozBindingProperty; "-moz-border-bottom-colors"?: MozBorderBottomColorsProperty; "-moz-border-end-color"?: BorderInlineEndColorProperty; @@ -1158,7 +1159,6 @@ export interface VendorLonghandPropertiesHyphen { "-moz-padding-start"?: PaddingInlineStartProperty; "-moz-perspective"?: PerspectiveProperty; "-moz-perspective-origin"?: PerspectiveOriginProperty; - "-moz-resize"?: ResizeProperty; "-moz-stack-sizing"?: MozStackSizingProperty; "-moz-tab-size"?: TabSizeProperty; "-moz-text-blink"?: MozTextBlinkProperty; @@ -1402,6 +1402,8 @@ export interface ObsoletePropertiesHyphen { /** @deprecated */ "-moz-background-inline-policy"?: BoxDecorationBreakProperty; /** @deprecated */ + "-moz-background-size"?: BackgroundSizeProperty; + /** @deprecated */ "-moz-border-radius"?: BorderRadiusProperty; /** @deprecated */ "-moz-border-radius-topright"?: BorderTopRightRadiusProperty; @@ -1426,6 +1428,8 @@ export interface ObsoletePropertiesHyphen { /** @deprecated */ "-moz-outline-width"?: OutlineWidthProperty; /** @deprecated */ + "-moz-resize"?: ResizeProperty; + /** @deprecated */ "-moz-text-align-last"?: TextAlignLastProperty; /** @deprecated */ "-moz-text-decoration-color"?: TextDecorationColorProperty; @@ -1901,7 +1905,6 @@ export interface VendorLonghandPropertiesFallback { MozAnimationTimingFunction?: AnimationTimingFunctionProperty | AnimationTimingFunctionProperty[]; MozAppearance?: MozAppearanceProperty | MozAppearanceProperty[]; MozBackfaceVisibility?: BackfaceVisibilityProperty | BackfaceVisibilityProperty[]; - MozBackgroundSize?: BackgroundSizeProperty | BackgroundSizeProperty[]; MozBinding?: MozBindingProperty | MozBindingProperty[]; MozBorderBottomColors?: MozBorderBottomColorsProperty | MozBorderBottomColorsProperty[]; MozBorderEndColor?: BorderInlineEndColorProperty | BorderInlineEndColorProperty[]; @@ -1936,7 +1939,6 @@ export interface VendorLonghandPropertiesFallback { MozPaddingStart?: PaddingInlineStartProperty | PaddingInlineStartProperty[]; MozPerspective?: PerspectiveProperty | PerspectiveProperty[]; MozPerspectiveOrigin?: PerspectiveOriginProperty | PerspectiveOriginProperty[]; - MozResize?: ResizeProperty | ResizeProperty[]; MozStackSizing?: MozStackSizingProperty | MozStackSizingProperty[]; MozTabSize?: TabSizeProperty | TabSizeProperty[]; MozTextBlink?: MozTextBlinkProperty | MozTextBlinkProperty[]; @@ -2180,6 +2182,8 @@ export interface ObsoletePropertiesFallback { /** @deprecated */ MozBackgroundInlinePolicy?: BoxDecorationBreakProperty | BoxDecorationBreakProperty[]; /** @deprecated */ + MozBackgroundSize?: BackgroundSizeProperty | BackgroundSizeProperty[]; + /** @deprecated */ MozBorderRadius?: BorderRadiusProperty | BorderRadiusProperty[]; /** @deprecated */ MozBorderRadiusTopright?: BorderTopRightRadiusProperty | BorderTopRightRadiusProperty[]; @@ -2204,6 +2208,8 @@ export interface ObsoletePropertiesFallback { /** @deprecated */ MozOutlineWidth?: OutlineWidthProperty | OutlineWidthProperty[]; /** @deprecated */ + MozResize?: ResizeProperty | ResizeProperty[]; + /** @deprecated */ MozTextAlignLast?: TextAlignLastProperty | TextAlignLastProperty[]; /** @deprecated */ MozTextDecorationColor?: TextDecorationColorProperty | TextDecorationColorProperty[]; @@ -2681,7 +2687,6 @@ export interface VendorLonghandPropertiesHyphenFallback { "-moz-animation-timing-function"?: AnimationTimingFunctionProperty | AnimationTimingFunctionProperty[]; "-moz-appearance"?: MozAppearanceProperty | MozAppearanceProperty[]; "-moz-backface-visibility"?: BackfaceVisibilityProperty | BackfaceVisibilityProperty[]; - "-moz-background-size"?: BackgroundSizeProperty | BackgroundSizeProperty[]; "-moz-binding"?: MozBindingProperty | MozBindingProperty[]; "-moz-border-bottom-colors"?: MozBorderBottomColorsProperty | MozBorderBottomColorsProperty[]; "-moz-border-end-color"?: BorderInlineEndColorProperty | BorderInlineEndColorProperty[]; @@ -2716,7 +2721,6 @@ export interface VendorLonghandPropertiesHyphenFallback { "-moz-padding-start"?: PaddingInlineStartProperty | PaddingInlineStartProperty[]; "-moz-perspective"?: PerspectiveProperty | PerspectiveProperty[]; "-moz-perspective-origin"?: PerspectiveOriginProperty | PerspectiveOriginProperty[]; - "-moz-resize"?: ResizeProperty | ResizeProperty[]; "-moz-stack-sizing"?: MozStackSizingProperty | MozStackSizingProperty[]; "-moz-tab-size"?: TabSizeProperty | TabSizeProperty[]; "-moz-text-blink"?: MozTextBlinkProperty | MozTextBlinkProperty[]; @@ -2960,6 +2964,8 @@ export interface ObsoletePropertiesHyphenFallback { /** @deprecated */ "-moz-background-inline-policy"?: BoxDecorationBreakProperty | BoxDecorationBreakProperty[]; /** @deprecated */ + "-moz-background-size"?: BackgroundSizeProperty | BackgroundSizeProperty[]; + /** @deprecated */ "-moz-border-radius"?: BorderRadiusProperty | BorderRadiusProperty[]; /** @deprecated */ "-moz-border-radius-topright"?: BorderTopRightRadiusProperty | BorderTopRightRadiusProperty[]; @@ -2984,6 +2990,8 @@ export interface ObsoletePropertiesHyphenFallback { /** @deprecated */ "-moz-outline-width"?: OutlineWidthProperty | OutlineWidthProperty[]; /** @deprecated */ + "-moz-resize"?: ResizeProperty | ResizeProperty[]; + /** @deprecated */ "-moz-text-align-last"?: TextAlignLastProperty | TextAlignLastProperty[]; /** @deprecated */ "-moz-text-decoration-color"?: TextDecorationColorProperty | TextDecorationColorProperty[]; @@ -3161,53 +3169,57 @@ export interface CounterStyleHyphenFallback { } export interface FontFace { + MozFontFeatureSettings?: FontFaceFontFeatureSettingsProperty; fontDisplay?: FontFaceFontDisplayProperty; fontFamily?: string; fontFeatureSettings?: FontFaceFontFeatureSettingsProperty; - fontVariationSettings?: FontFaceFontVariationSettingsProperty; fontStretch?: FontFaceFontStretchProperty; fontStyle?: FontFaceFontStyleProperty; - fontWeight?: FontFaceFontWeightProperty; fontVariant?: FontFaceFontVariantProperty; + fontVariationSettings?: FontFaceFontVariationSettingsProperty; + fontWeight?: FontFaceFontWeightProperty; src?: string; unicodeRange?: string; } export interface FontFaceHyphen { + "-moz-font-feature-settings"?: FontFaceFontFeatureSettingsProperty; "font-display"?: FontFaceFontDisplayProperty; "font-family"?: string; "font-feature-settings"?: FontFaceFontFeatureSettingsProperty; - "font-variation-settings"?: FontFaceFontVariationSettingsProperty; "font-stretch"?: FontFaceFontStretchProperty; "font-style"?: FontFaceFontStyleProperty; - "font-weight"?: FontFaceFontWeightProperty; "font-variant"?: FontFaceFontVariantProperty; + "font-variation-settings"?: FontFaceFontVariationSettingsProperty; + "font-weight"?: FontFaceFontWeightProperty; src?: string; "unicode-range"?: string; } export interface FontFaceFallback { + MozFontFeatureSettings?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[]; fontDisplay?: FontFaceFontDisplayProperty | FontFaceFontDisplayProperty[]; fontFamily?: string | string[]; fontFeatureSettings?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[]; - fontVariationSettings?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[]; fontStretch?: FontFaceFontStretchProperty | FontFaceFontStretchProperty[]; fontStyle?: FontFaceFontStyleProperty | FontFaceFontStyleProperty[]; - fontWeight?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[]; fontVariant?: FontFaceFontVariantProperty | FontFaceFontVariantProperty[]; + fontVariationSettings?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[]; + fontWeight?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[]; src?: string | string[]; unicodeRange?: string | string[]; } export interface FontFaceHyphenFallback { + "-moz-font-feature-settings"?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[]; "font-display"?: FontFaceFontDisplayProperty | FontFaceFontDisplayProperty[]; "font-family"?: string | string[]; "font-feature-settings"?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[]; - "font-variation-settings"?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[]; "font-stretch"?: FontFaceFontStretchProperty | FontFaceFontStretchProperty[]; "font-style"?: FontFaceFontStyleProperty | FontFaceFontStyleProperty[]; - "font-weight"?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[]; "font-variant"?: FontFaceFontVariantProperty | FontFaceFontVariantProperty[]; + "font-variation-settings"?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[]; + "font-weight"?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[]; src?: string | string[]; "unicode-range"?: string | string[]; } @@ -3233,6 +3245,15 @@ export interface PageHyphenFallback { } export interface Viewport { + msHeight?: ViewportHeightProperty; + msMaxHeight?: ViewportMaxHeightProperty; + msMaxWidth?: ViewportMaxWidthProperty; + msMinHeight?: ViewportMinHeightProperty; + msMinWidth?: ViewportMinWidthProperty; + msOrientation?: ViewportOrientationProperty; + msWidth?: ViewportWidthProperty; + msZoom?: ViewportZoomProperty; + OOrientation?: ViewportOrientationProperty; height?: ViewportHeightProperty; maxHeight?: ViewportMaxHeightProperty; maxWidth?: ViewportMaxWidthProperty; @@ -3247,6 +3268,15 @@ export interface Viewport { } export interface ViewportHyphen { + "-ms-height"?: ViewportHeightProperty; + "-ms-max-height"?: ViewportMaxHeightProperty; + "-ms-max-width"?: ViewportMaxWidthProperty; + "-ms-min-height"?: ViewportMinHeightProperty; + "-ms-min-width"?: ViewportMinWidthProperty; + "-ms-orientation"?: ViewportOrientationProperty; + "-ms-width"?: ViewportWidthProperty; + "-ms-zoom"?: ViewportZoomProperty; + "-o-orientation"?: ViewportOrientationProperty; height?: ViewportHeightProperty; "max-height"?: ViewportMaxHeightProperty; "max-width"?: ViewportMaxWidthProperty; @@ -3261,6 +3291,15 @@ export interface ViewportHyphen { } export interface ViewportFallback { + msHeight?: ViewportHeightProperty | ViewportHeightProperty[]; + msMaxHeight?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[]; + msMaxWidth?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[]; + msMinHeight?: ViewportMinHeightProperty | ViewportMinHeightProperty[]; + msMinWidth?: ViewportMinWidthProperty | ViewportMinWidthProperty[]; + msOrientation?: ViewportOrientationProperty | ViewportOrientationProperty[]; + msWidth?: ViewportWidthProperty | ViewportWidthProperty[]; + msZoom?: ViewportZoomProperty | ViewportZoomProperty[]; + OOrientation?: ViewportOrientationProperty | ViewportOrientationProperty[]; height?: ViewportHeightProperty | ViewportHeightProperty[]; maxHeight?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[]; maxWidth?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[]; @@ -3275,6 +3314,15 @@ export interface ViewportFallback { } export interface ViewportHyphenFallback { + "-ms-height"?: ViewportHeightProperty | ViewportHeightProperty[]; + "-ms-max-height"?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[]; + "-ms-max-width"?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[]; + "-ms-min-height"?: ViewportMinHeightProperty | ViewportMinHeightProperty[]; + "-ms-min-width"?: ViewportMinWidthProperty | ViewportMinWidthProperty[]; + "-ms-orientation"?: ViewportOrientationProperty | ViewportOrientationProperty[]; + "-ms-width"?: ViewportWidthProperty | ViewportWidthProperty[]; + "-ms-zoom"?: ViewportZoomProperty | ViewportZoomProperty[]; + "-o-orientation"?: ViewportOrientationProperty | ViewportOrientationProperty[]; height?: ViewportHeightProperty | ViewportHeightProperty[]; "max-height"?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[]; "max-width"?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[]; @@ -3302,20 +3350,42 @@ export type AtRules = | "@supports" | "@viewport"; -export type AdvancedPseudos = ":-moz-any" | ":-webkit-any" | "::cue" | ":dir" | ":lang" | ":not" | ":nth-child" | ":nth-last-child" | ":nth-last-of-type" | ":nth-of-type"; +export type AdvancedPseudos = + | ":-moz-any" + | ":-moz-dir" + | ":-webkit-any" + | "::cue" + | ":dir" + | ":lang" + | ":not" + | ":nth-child" + | ":nth-last-child" + | ":nth-last-of-type" + | ":nth-of-type"; export type SimplePseudos = + | ":-moz-any-link" + | ":-moz-full-screen" + | ":-moz-placeholder" + | ":-moz-read-only" + | ":-moz-read-write" + | ":-ms-fullscreen" + | ":-webkit-any-link" + | ":-webkit-full-screen" + | "::-moz-placeholder" | "::-moz-progress-bar" | "::-moz-range-progress" | "::-moz-range-thumb" | "::-moz-range-track" + | "::-moz-selection" + | "::-ms-backdrop" | "::-ms-browse" | "::-ms-check" | "::-ms-clear" - | "::-ms-clear" | "::-ms-fill" | "::-ms-fill-lower" | "::-ms-fill-upper" + | "::-ms-placeholder" | "::-ms-reveal" | "::-ms-thumb" | "::-ms-ticks-after" @@ -3323,6 +3393,8 @@ export type SimplePseudos = | "::-ms-tooltip" | "::-ms-track" | "::-ms-value" + | "::-webkit-backdrop" + | "::-webkit-placeholder" | "::-webkit-progress-bar" | "::-webkit-progress-inner-value" | "::-webkit-progress-value" @@ -3384,7 +3456,7 @@ export type SimplePseudos = export type Pseudos = AdvancedPseudos | SimplePseudos; -type Globals = "inherit" | "initial" | "revert" | "unset"; +type Globals = "-moz-initial" | "inherit" | "initial" | "revert" | "unset"; type GlobalsString = Globals | string; @@ -3894,15 +3966,15 @@ type OutlineStyleProperty = Globals | BrStyle | "auto"; type OutlineWidthProperty = Globals | BrWidth; -type OverflowProperty = Globals | "auto" | "hidden" | "scroll" | "visible"; +type OverflowProperty = Globals | "auto" | "clip" | "hidden" | "scroll" | "visible"; type OverflowClipBoxProperty = Globals | "content-box" | "padding-box"; type OverflowWrapProperty = Globals | "break-word" | "normal"; -type OverflowXProperty = Globals | "auto" | "hidden" | "scroll" | "visible"; +type OverflowXProperty = Globals | "auto" | "clip" | "hidden" | "scroll" | "visible"; -type OverflowYProperty = Globals | "auto" | "hidden" | "scroll" | "visible"; +type OverflowYProperty = Globals | "auto" | "clip" | "hidden" | "scroll" | "visible"; type OverscrollBehaviorProperty = Globals | "auto" | "contain" | "none" | string; @@ -4044,7 +4116,18 @@ type TransitionTimingFunctionProperty = Globals | SingleTimingFunction | string; type TranslateProperty = Globals | TLength | "none" | string; -type UnicodeBidiProperty = Globals | "-webkit-isolate" | "bidi-override" | "embed" | "isolate" | "isolate-override" | "normal" | "plaintext"; +type UnicodeBidiProperty = + | Globals + | "-moz-isolate" + | "-moz-isolate-override" + | "-moz-plaintext" + | "-webkit-isolate" + | "bidi-override" + | "embed" + | "isolate" + | "isolate-override" + | "normal" + | "plaintext"; type UserSelectProperty = Globals | "-webkit-contain" | "all" | "auto" | "contain" | "element" | "none" | "text"; @@ -4534,11 +4617,9 @@ type CounterStyleSpeakAsProperty = "auto" | "bullets" | "numbers" | "spell-out" type CounterStyleSystemProperty = "additive" | "alphabetic" | "cyclic" | "fixed" | "numeric" | "symbolic" | string; -type FontFaceFontDisplayProperty = "auto" | "block" | "fallback" | "optional" | "swap"; - type FontFaceFontFeatureSettingsProperty = "normal" | string; -type FontFaceFontVariationSettingsProperty = "normal"; +type FontFaceFontDisplayProperty = "auto" | "block" | "fallback" | "optional" | "swap"; type FontFaceFontStretchProperty = | "condensed" @@ -4553,8 +4634,6 @@ type FontFaceFontStretchProperty = type FontFaceFontStyleProperty = "italic" | "normal" | "oblique"; -type FontFaceFontWeightProperty = "bold" | "normal" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; - type FontFaceFontVariantProperty = | EastAsianVariantValues | "all-petite-caps" @@ -4587,6 +4666,10 @@ type FontFaceFontVariantProperty = | "unicase" | string; +type FontFaceFontVariationSettingsProperty = "normal"; + +type FontFaceFontWeightProperty = "bold" | "normal" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; + type PageBleedProperty = TLength | "auto"; type PageMarksProperty = "crop" | "cross" | "none" | string; @@ -4597,22 +4680,22 @@ type ViewportMaxHeightProperty = ViewportLength; type ViewportMaxWidthProperty = ViewportLength; -type ViewportMaxZoomProperty = "auto" | string | number; - type ViewportMinHeightProperty = ViewportLength; type ViewportMinWidthProperty = ViewportLength; -type ViewportMinZoomProperty = "auto" | string | number; - type ViewportOrientationProperty = "auto" | "landscape" | "portrait"; -type ViewportUserZoomProperty = "fixed" | "zoom"; - type ViewportWidthProperty = ViewportLength | string; type ViewportZoomProperty = "auto" | string | number; +type ViewportMaxZoomProperty = "auto" | string | number; + +type ViewportMinZoomProperty = "auto" | string | number; + +type ViewportUserZoomProperty = "fixed" | "zoom"; + type AbsoluteSize = "large" | "medium" | "small" | "x-large" | "x-small" | "xx-large" | "xx-small"; type AnimateableFeature = "contents" | "scroll-position" | string; diff --git a/index.js.flow b/index.js.flow index e6a3cf6..24be516 100644 --- a/index.js.flow +++ b/index.js.flow @@ -350,7 +350,6 @@ export type VendorLonghandProperties = { MozAnimationTimingFunction?: AnimationTimingFunctionProperty, MozAppearance?: MozAppearanceProperty, MozBackfaceVisibility?: BackfaceVisibilityProperty, - MozBackgroundSize?: BackgroundSizeProperty, MozBinding?: MozBindingProperty, MozBorderBottomColors?: MozBorderBottomColorsProperty, MozBorderEndColor?: BorderInlineEndColorProperty, @@ -385,7 +384,6 @@ export type VendorLonghandProperties = { MozPaddingStart?: PaddingInlineStartProperty, MozPerspective?: PerspectiveProperty, MozPerspectiveOrigin?: PerspectiveOriginProperty, - MozResize?: ResizeProperty, MozStackSizing?: MozStackSizingProperty, MozTabSize?: TabSizeProperty, MozTextBlink?: MozTextBlinkProperty, @@ -609,6 +607,7 @@ export type ObsoleteProperties = { KhtmlBoxOrient?: BoxOrientProperty, KhtmlBoxPack?: BoxPackProperty, MozBackgroundInlinePolicy?: BoxDecorationBreakProperty, + MozBackgroundSize?: BackgroundSizeProperty, MozBorderRadius?: BorderRadiusProperty, MozBorderRadiusTopright?: BorderTopRightRadiusProperty, MozBoxDirection?: BoxDirectionProperty, @@ -621,6 +620,7 @@ export type ObsoleteProperties = { MozOutlineColor?: OutlineColorProperty, MozOutlineStyle?: OutlineStyleProperty, MozOutlineWidth?: OutlineWidthProperty, + MozResize?: ResizeProperty, MozTextAlignLast?: TextAlignLastProperty, MozTextDecorationColor?: TextDecorationColorProperty, MozTextDecorationLine?: TextDecorationLineProperty, @@ -1066,7 +1066,6 @@ export type VendorLonghandPropertiesHyphen = { "-moz-animation-timing-function"?: AnimationTimingFunctionProperty, "-moz-appearance"?: MozAppearanceProperty, "-moz-backface-visibility"?: BackfaceVisibilityProperty, - "-moz-background-size"?: BackgroundSizeProperty, "-moz-binding"?: MozBindingProperty, "-moz-border-bottom-colors"?: MozBorderBottomColorsProperty, "-moz-border-end-color"?: BorderInlineEndColorProperty, @@ -1101,7 +1100,6 @@ export type VendorLonghandPropertiesHyphen = { "-moz-padding-start"?: PaddingInlineStartProperty, "-moz-perspective"?: PerspectiveProperty, "-moz-perspective-origin"?: PerspectiveOriginProperty, - "-moz-resize"?: ResizeProperty, "-moz-stack-sizing"?: MozStackSizingProperty, "-moz-tab-size"?: TabSizeProperty, "-moz-text-blink"?: MozTextBlinkProperty, @@ -1325,6 +1323,7 @@ export type ObsoletePropertiesHyphen = { "-khtml-box-orient"?: BoxOrientProperty, "-khtml-box-pack"?: BoxPackProperty, "-moz-background-inline-policy"?: BoxDecorationBreakProperty, + "-moz-background-size"?: BackgroundSizeProperty, "-moz-border-radius"?: BorderRadiusProperty, "-moz-border-radius-topright"?: BorderTopRightRadiusProperty, "-moz-box-direction"?: BoxDirectionProperty, @@ -1337,6 +1336,7 @@ export type ObsoletePropertiesHyphen = { "-moz-outline-color"?: OutlineColorProperty, "-moz-outline-style"?: OutlineStyleProperty, "-moz-outline-width"?: OutlineWidthProperty, + "-moz-resize"?: ResizeProperty, "-moz-text-align-last"?: TextAlignLastProperty, "-moz-text-decoration-color"?: TextDecorationColorProperty, "-moz-text-decoration-line"?: TextDecorationLineProperty, @@ -1785,7 +1785,6 @@ export type VendorLonghandPropertiesFallback = { MozAnimationTimingFunction?: AnimationTimingFunctionProperty | AnimationTimingFunctionProperty[], MozAppearance?: MozAppearanceProperty | MozAppearanceProperty[], MozBackfaceVisibility?: BackfaceVisibilityProperty | BackfaceVisibilityProperty[], - MozBackgroundSize?: BackgroundSizeProperty | BackgroundSizeProperty[], MozBinding?: MozBindingProperty | MozBindingProperty[], MozBorderBottomColors?: MozBorderBottomColorsProperty | MozBorderBottomColorsProperty[], MozBorderEndColor?: BorderInlineEndColorProperty | BorderInlineEndColorProperty[], @@ -1820,7 +1819,6 @@ export type VendorLonghandPropertiesFallback = { MozPaddingStart?: PaddingInlineStartProperty | PaddingInlineStartProperty[], MozPerspective?: PerspectiveProperty | PerspectiveProperty[], MozPerspectiveOrigin?: PerspectiveOriginProperty | PerspectiveOriginProperty[], - MozResize?: ResizeProperty | ResizeProperty[], MozStackSizing?: MozStackSizingProperty | MozStackSizingProperty[], MozTabSize?: TabSizeProperty | TabSizeProperty[], MozTextBlink?: MozTextBlinkProperty | MozTextBlinkProperty[], @@ -2044,6 +2042,7 @@ export type ObsoletePropertiesFallback = { KhtmlBoxOrient?: BoxOrientProperty | BoxOrientProperty[], KhtmlBoxPack?: BoxPackProperty | BoxPackProperty[], MozBackgroundInlinePolicy?: BoxDecorationBreakProperty | BoxDecorationBreakProperty[], + MozBackgroundSize?: BackgroundSizeProperty | BackgroundSizeProperty[], MozBorderRadius?: BorderRadiusProperty | BorderRadiusProperty[], MozBorderRadiusTopright?: BorderTopRightRadiusProperty | BorderTopRightRadiusProperty[], MozBoxDirection?: BoxDirectionProperty | BoxDirectionProperty[], @@ -2056,6 +2055,7 @@ export type ObsoletePropertiesFallback = { MozOutlineColor?: OutlineColorProperty | OutlineColorProperty[], MozOutlineStyle?: OutlineStyleProperty | OutlineStyleProperty[], MozOutlineWidth?: OutlineWidthProperty | OutlineWidthProperty[], + MozResize?: ResizeProperty | ResizeProperty[], MozTextAlignLast?: TextAlignLastProperty | TextAlignLastProperty[], MozTextDecorationColor?: TextDecorationColorProperty | TextDecorationColorProperty[], MozTextDecorationLine?: TextDecorationLineProperty | TextDecorationLineProperty[], @@ -2504,7 +2504,6 @@ export type VendorLonghandPropertiesHyphenFallback = { "-moz-animation-timing-function"?: AnimationTimingFunctionProperty | AnimationTimingFunctionProperty[], "-moz-appearance"?: MozAppearanceProperty | MozAppearanceProperty[], "-moz-backface-visibility"?: BackfaceVisibilityProperty | BackfaceVisibilityProperty[], - "-moz-background-size"?: BackgroundSizeProperty | BackgroundSizeProperty[], "-moz-binding"?: MozBindingProperty | MozBindingProperty[], "-moz-border-bottom-colors"?: MozBorderBottomColorsProperty | MozBorderBottomColorsProperty[], "-moz-border-end-color"?: BorderInlineEndColorProperty | BorderInlineEndColorProperty[], @@ -2539,7 +2538,6 @@ export type VendorLonghandPropertiesHyphenFallback = { "-moz-padding-start"?: PaddingInlineStartProperty | PaddingInlineStartProperty[], "-moz-perspective"?: PerspectiveProperty | PerspectiveProperty[], "-moz-perspective-origin"?: PerspectiveOriginProperty | PerspectiveOriginProperty[], - "-moz-resize"?: ResizeProperty | ResizeProperty[], "-moz-stack-sizing"?: MozStackSizingProperty | MozStackSizingProperty[], "-moz-tab-size"?: TabSizeProperty | TabSizeProperty[], "-moz-text-blink"?: MozTextBlinkProperty | MozTextBlinkProperty[], @@ -2763,6 +2761,7 @@ export type ObsoletePropertiesHyphenFallback = { "-khtml-box-orient"?: BoxOrientProperty | BoxOrientProperty[], "-khtml-box-pack"?: BoxPackProperty | BoxPackProperty[], "-moz-background-inline-policy"?: BoxDecorationBreakProperty | BoxDecorationBreakProperty[], + "-moz-background-size"?: BackgroundSizeProperty | BackgroundSizeProperty[], "-moz-border-radius"?: BorderRadiusProperty | BorderRadiusProperty[], "-moz-border-radius-topright"?: BorderTopRightRadiusProperty | BorderTopRightRadiusProperty[], "-moz-box-direction"?: BoxDirectionProperty | BoxDirectionProperty[], @@ -2775,6 +2774,7 @@ export type ObsoletePropertiesHyphenFallback = { "-moz-outline-color"?: OutlineColorProperty | OutlineColorProperty[], "-moz-outline-style"?: OutlineStyleProperty | OutlineStyleProperty[], "-moz-outline-width"?: OutlineWidthProperty | OutlineWidthProperty[], + "-moz-resize"?: ResizeProperty | ResizeProperty[], "-moz-text-align-last"?: TextAlignLastProperty | TextAlignLastProperty[], "-moz-text-decoration-color"?: TextDecorationColorProperty | TextDecorationColorProperty[], "-moz-text-decoration-line"?: TextDecorationLineProperty | TextDecorationLineProperty[], @@ -2925,53 +2925,57 @@ export type CounterStyleHyphenFallback = { }; export type FontFace = { + MozFontFeatureSettings?: FontFaceFontFeatureSettingsProperty, fontDisplay?: FontFaceFontDisplayProperty, fontFamily?: string, fontFeatureSettings?: FontFaceFontFeatureSettingsProperty, - fontVariationSettings?: FontFaceFontVariationSettingsProperty, fontStretch?: FontFaceFontStretchProperty, fontStyle?: FontFaceFontStyleProperty, - fontWeight?: FontFaceFontWeightProperty, fontVariant?: FontFaceFontVariantProperty, + fontVariationSettings?: FontFaceFontVariationSettingsProperty, + fontWeight?: FontFaceFontWeightProperty, src?: string, unicodeRange?: string, }; export type FontFaceHyphen = { + "-moz-font-feature-settings"?: FontFaceFontFeatureSettingsProperty, "font-display"?: FontFaceFontDisplayProperty, "font-family"?: string, "font-feature-settings"?: FontFaceFontFeatureSettingsProperty, - "font-variation-settings"?: FontFaceFontVariationSettingsProperty, "font-stretch"?: FontFaceFontStretchProperty, "font-style"?: FontFaceFontStyleProperty, - "font-weight"?: FontFaceFontWeightProperty, "font-variant"?: FontFaceFontVariantProperty, + "font-variation-settings"?: FontFaceFontVariationSettingsProperty, + "font-weight"?: FontFaceFontWeightProperty, src?: string, "unicode-range"?: string, }; export type FontFaceFallback = { + MozFontFeatureSettings?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[], fontDisplay?: FontFaceFontDisplayProperty | FontFaceFontDisplayProperty[], fontFamily?: string | string[], fontFeatureSettings?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[], - fontVariationSettings?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[], fontStretch?: FontFaceFontStretchProperty | FontFaceFontStretchProperty[], fontStyle?: FontFaceFontStyleProperty | FontFaceFontStyleProperty[], - fontWeight?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[], fontVariant?: FontFaceFontVariantProperty | FontFaceFontVariantProperty[], + fontVariationSettings?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[], + fontWeight?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[], src?: string | string[], unicodeRange?: string | string[], }; export type FontFaceHyphenFallback = { + "-moz-font-feature-settings"?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[], "font-display"?: FontFaceFontDisplayProperty | FontFaceFontDisplayProperty[], "font-family"?: string | string[], "font-feature-settings"?: FontFaceFontFeatureSettingsProperty | FontFaceFontFeatureSettingsProperty[], - "font-variation-settings"?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[], "font-stretch"?: FontFaceFontStretchProperty | FontFaceFontStretchProperty[], "font-style"?: FontFaceFontStyleProperty | FontFaceFontStyleProperty[], - "font-weight"?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[], "font-variant"?: FontFaceFontVariantProperty | FontFaceFontVariantProperty[], + "font-variation-settings"?: FontFaceFontVariationSettingsProperty | FontFaceFontVariationSettingsProperty[], + "font-weight"?: FontFaceFontWeightProperty | FontFaceFontWeightProperty[], src?: string | string[], "unicode-range"?: string | string[], }; @@ -2997,6 +3001,15 @@ export type PageHyphenFallback = { }; export type Viewport = { + msHeight?: ViewportHeightProperty, + msMaxHeight?: ViewportMaxHeightProperty, + msMaxWidth?: ViewportMaxWidthProperty, + msMinHeight?: ViewportMinHeightProperty, + msMinWidth?: ViewportMinWidthProperty, + msOrientation?: ViewportOrientationProperty, + msWidth?: ViewportWidthProperty, + msZoom?: ViewportZoomProperty, + OOrientation?: ViewportOrientationProperty, height?: ViewportHeightProperty, maxHeight?: ViewportMaxHeightProperty, maxWidth?: ViewportMaxWidthProperty, @@ -3011,6 +3024,15 @@ export type Viewport = { }; export type ViewportHyphen = { + "-ms-height"?: ViewportHeightProperty, + "-ms-max-height"?: ViewportMaxHeightProperty, + "-ms-max-width"?: ViewportMaxWidthProperty, + "-ms-min-height"?: ViewportMinHeightProperty, + "-ms-min-width"?: ViewportMinWidthProperty, + "-ms-orientation"?: ViewportOrientationProperty, + "-ms-width"?: ViewportWidthProperty, + "-ms-zoom"?: ViewportZoomProperty, + "-o-orientation"?: ViewportOrientationProperty, height?: ViewportHeightProperty, "max-height"?: ViewportMaxHeightProperty, "max-width"?: ViewportMaxWidthProperty, @@ -3025,6 +3047,15 @@ export type ViewportHyphen = { }; export type ViewportFallback = { + msHeight?: ViewportHeightProperty | ViewportHeightProperty[], + msMaxHeight?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[], + msMaxWidth?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[], + msMinHeight?: ViewportMinHeightProperty | ViewportMinHeightProperty[], + msMinWidth?: ViewportMinWidthProperty | ViewportMinWidthProperty[], + msOrientation?: ViewportOrientationProperty | ViewportOrientationProperty[], + msWidth?: ViewportWidthProperty | ViewportWidthProperty[], + msZoom?: ViewportZoomProperty | ViewportZoomProperty[], + OOrientation?: ViewportOrientationProperty | ViewportOrientationProperty[], height?: ViewportHeightProperty | ViewportHeightProperty[], maxHeight?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[], maxWidth?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[], @@ -3039,6 +3070,15 @@ export type ViewportFallback = { }; export type ViewportHyphenFallback = { + "-ms-height"?: ViewportHeightProperty | ViewportHeightProperty[], + "-ms-max-height"?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[], + "-ms-max-width"?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[], + "-ms-min-height"?: ViewportMinHeightProperty | ViewportMinHeightProperty[], + "-ms-min-width"?: ViewportMinWidthProperty | ViewportMinWidthProperty[], + "-ms-orientation"?: ViewportOrientationProperty | ViewportOrientationProperty[], + "-ms-width"?: ViewportWidthProperty | ViewportWidthProperty[], + "-ms-zoom"?: ViewportZoomProperty | ViewportZoomProperty[], + "-o-orientation"?: ViewportOrientationProperty | ViewportOrientationProperty[], height?: ViewportHeightProperty | ViewportHeightProperty[], "max-height"?: ViewportMaxHeightProperty | ViewportMaxHeightProperty[], "max-width"?: ViewportMaxWidthProperty | ViewportMaxWidthProperty[], @@ -3066,20 +3106,42 @@ export type AtRules = | "@supports" | "@viewport"; -export type AdvancedPseudos = ":-moz-any" | ":-webkit-any" | "::cue" | ":dir" | ":lang" | ":not" | ":nth-child" | ":nth-last-child" | ":nth-last-of-type" | ":nth-of-type"; +export type AdvancedPseudos = + | ":-moz-any" + | ":-moz-dir" + | ":-webkit-any" + | "::cue" + | ":dir" + | ":lang" + | ":not" + | ":nth-child" + | ":nth-last-child" + | ":nth-last-of-type" + | ":nth-of-type"; export type SimplePseudos = + | ":-moz-any-link" + | ":-moz-full-screen" + | ":-moz-placeholder" + | ":-moz-read-only" + | ":-moz-read-write" + | ":-ms-fullscreen" + | ":-webkit-any-link" + | ":-webkit-full-screen" + | "::-moz-placeholder" | "::-moz-progress-bar" | "::-moz-range-progress" | "::-moz-range-thumb" | "::-moz-range-track" + | "::-moz-selection" + | "::-ms-backdrop" | "::-ms-browse" | "::-ms-check" | "::-ms-clear" - | "::-ms-clear" | "::-ms-fill" | "::-ms-fill-lower" | "::-ms-fill-upper" + | "::-ms-placeholder" | "::-ms-reveal" | "::-ms-thumb" | "::-ms-ticks-after" @@ -3087,6 +3149,8 @@ export type SimplePseudos = | "::-ms-tooltip" | "::-ms-track" | "::-ms-value" + | "::-webkit-backdrop" + | "::-webkit-placeholder" | "::-webkit-progress-bar" | "::-webkit-progress-inner-value" | "::-webkit-progress-value" @@ -3148,7 +3212,7 @@ export type SimplePseudos = export type Pseudos = AdvancedPseudos | SimplePseudos; -type Globals = "inherit" | "initial" | "revert" | "unset"; +type Globals = "-moz-initial" | "inherit" | "initial" | "revert" | "unset"; type GlobalsString = Globals | string; @@ -3658,15 +3722,15 @@ type OutlineStyleProperty = Globals | BrStyle | "auto"; type OutlineWidthProperty = Globals | BrWidth; -type OverflowProperty = Globals | "auto" | "hidden" | "scroll" | "visible"; +type OverflowProperty = Globals | "auto" | "clip" | "hidden" | "scroll" | "visible"; type OverflowClipBoxProperty = Globals | "content-box" | "padding-box"; type OverflowWrapProperty = Globals | "break-word" | "normal"; -type OverflowXProperty = Globals | "auto" | "hidden" | "scroll" | "visible"; +type OverflowXProperty = Globals | "auto" | "clip" | "hidden" | "scroll" | "visible"; -type OverflowYProperty = Globals | "auto" | "hidden" | "scroll" | "visible"; +type OverflowYProperty = Globals | "auto" | "clip" | "hidden" | "scroll" | "visible"; type OverscrollBehaviorProperty = Globals | "auto" | "contain" | "none" | string; @@ -3808,7 +3872,18 @@ type TransitionTimingFunctionProperty = Globals | SingleTimingFunction | string; type TranslateProperty = Globals | TLength | "none" | string; -type UnicodeBidiProperty = Globals | "-webkit-isolate" | "bidi-override" | "embed" | "isolate" | "isolate-override" | "normal" | "plaintext"; +type UnicodeBidiProperty = + | Globals + | "-moz-isolate" + | "-moz-isolate-override" + | "-moz-plaintext" + | "-webkit-isolate" + | "bidi-override" + | "embed" + | "isolate" + | "isolate-override" + | "normal" + | "plaintext"; type UserSelectProperty = Globals | "-webkit-contain" | "all" | "auto" | "contain" | "element" | "none" | "text"; @@ -4298,11 +4373,9 @@ type CounterStyleSpeakAsProperty = "auto" | "bullets" | "numbers" | "spell-out" type CounterStyleSystemProperty = "additive" | "alphabetic" | "cyclic" | "fixed" | "numeric" | "symbolic" | string; -type FontFaceFontDisplayProperty = "auto" | "block" | "fallback" | "optional" | "swap"; - type FontFaceFontFeatureSettingsProperty = "normal" | string; -type FontFaceFontVariationSettingsProperty = "normal"; +type FontFaceFontDisplayProperty = "auto" | "block" | "fallback" | "optional" | "swap"; type FontFaceFontStretchProperty = | "condensed" @@ -4317,8 +4390,6 @@ type FontFaceFontStretchProperty = type FontFaceFontStyleProperty = "italic" | "normal" | "oblique"; -type FontFaceFontWeightProperty = "bold" | "normal" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; - type FontFaceFontVariantProperty = | EastAsianVariantValues | "all-petite-caps" @@ -4351,6 +4422,10 @@ type FontFaceFontVariantProperty = | "unicase" | string; +type FontFaceFontVariationSettingsProperty = "normal"; + +type FontFaceFontWeightProperty = "bold" | "normal" | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900; + type PageBleedProperty = TLength | "auto"; type PageMarksProperty = "crop" | "cross" | "none" | string; @@ -4361,22 +4436,22 @@ type ViewportMaxHeightProperty = ViewportLength; type ViewportMaxWidthProperty = ViewportLength; -type ViewportMaxZoomProperty = "auto" | string | number; - type ViewportMinHeightProperty = ViewportLength; type ViewportMinWidthProperty = ViewportLength; -type ViewportMinZoomProperty = "auto" | string | number; - type ViewportOrientationProperty = "auto" | "landscape" | "portrait"; -type ViewportUserZoomProperty = "fixed" | "zoom"; - type ViewportWidthProperty = ViewportLength | string; type ViewportZoomProperty = "auto" | string | number; +type ViewportMaxZoomProperty = "auto" | string | number; + +type ViewportMinZoomProperty = "auto" | string | number; + +type ViewportUserZoomProperty = "fixed" | "zoom"; + type AbsoluteSize = "large" | "medium" | "small" | "x-large" | "x-small" | "xx-large" | "xx-small"; type AnimateableFeature = "contents" | "scroll-position" | string; diff --git a/package.json b/package.json index e1c9409..f4b1c49 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "chokidar": "^2.0.0", "flow-bin": "^0.69.0", "jest": "^22.2.1", - "mdn-browser-compat-data": "0.0.30", - "mdn-data": "1.1.1", + "mdn-browser-compat-data": "git+https://github.com/mdn/browser-compat-data.git#3ab7b502352239d2131571d7463e098d2317532d", + "mdn-data": "git+https://github.com/mdn/data.git#af0369d9445c7e6f44f818d2034ccac16f328da9", "prettier": "^1.10.2", "ts-node": "^5.0.1", "tslint": "^5.9.1", @@ -32,7 +32,7 @@ "test": "jest --no-cache", "typecheck": "tsc typecheck.ts --noEmit --pretty & flow check typecheck.js", "prepublish": "tsc && npm run test && npm run build && npm run typecheck", - "rebase-build": "git rebase -s recursive -X theirs --exec \"yarn build && git commit -a --amend --no-verify --no-edit --allow-empty\"" + "rebase-build": "git rebase -s recursive -X theirs --exec \"yarn --ignore-scripts && yarn build && git commit -a --amend --no-verify --no-edit --allow-empty\"" }, "files": [ "index.d.ts", diff --git a/src/at-rules.ts b/src/at-rules.ts index 7d25c68..8cb99c6 100644 --- a/src/at-rules.ts +++ b/src/at-rules.ts @@ -1,28 +1,65 @@ import * as atRules from 'mdn-data/css/at-rules.json'; +import { compatNames, compatSyntax, getAtRuleData, getCompat, isAddedBySome } from './compat'; import { resolveDataTypes } from './data-types'; import parse from './parser'; import typing, { IStringLiteral, ResolvedType, Type } from './typer'; +interface IDescriptor { + name: string; + types: ResolvedType[]; +} + export interface IAtRuleDescriptors { - [descriptor: string]: ResolvedType[]; + [descriptor: string]: IDescriptor; } export const atRuleList: IStringLiteral[] = []; export const atRuleDescriptors: { [name: string]: IAtRuleDescriptors } = {}; -for (const name in atRules) { - const atRule = atRules[name]; +for (const atName in atRules) { + const atRule = atRules[atName]; + + // Without the `@` + const name = atName.slice(1); atRuleList.push({ type: Type.StringLiteral, - literal: name, + literal: atName, }); if ('descriptors' in atRule) { const descriptors: IAtRuleDescriptors = {}; + const compatibilityData = getAtRuleData(name); for (const descriptor in atRule.descriptors) { - descriptors[descriptor] = resolveDataTypes(typing(parse(atRule.descriptors[descriptor].syntax))); + let entities = parse(atRule.descriptors[descriptor].syntax); + let properties = [descriptor]; + + if (compatibilityData && descriptor in compatibilityData) { + const compat = getCompat(compatibilityData[descriptor]); + + if (!isAddedBySome(compat)) { + // The property needs to be added by some browsers + continue; + } + + entities = compatSyntax(compatibilityData, entities); + properties = properties.concat( + // We mix current and obsolete for now + compatNames(compat, descriptor) + .concat(compatNames(compat, descriptor, true)) + .filter(property => !(property in atRule.descriptors)), + ); + } + + const types = resolveDataTypes(typing(entities)); + + for (const property of properties) { + descriptors[property] = { + name: descriptor, + types, + }; + } } atRuleDescriptors[name] = descriptors; diff --git a/src/compat.ts b/src/compat.ts index 1bea1e0..eb8c502 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -2,70 +2,107 @@ import { Combinator, combinatorData, Component, componentData, componentGroupDat const importsCache: { [cssPath: string]: MDN.PropertiesCompat | null } = {}; -function getData(cssPath: string): MDN.PropertiesCompat | null { - if (cssPath in importsCache) { - return importsCache[cssPath]; - } +export function getCompat(data: { __compat: MDN.Compat }): MDN.Compat { + return data.__compat; +} - try { - return (importsCache[cssPath] = require(`mdn-browser-compat-data/css/${cssPath}.json`)); - } catch { - return (importsCache[cssPath] = null); +export function getSupport(support: MDN.Support | MDN.Support[]): MDN.Support[] { + return Array.isArray(support) ? support : [support]; +} + +export function getAtRuleData(name: string): MDN.CompatData | null { + const data = getData('at-rules/' + name); + + if (data) { + return data.css['at-rules'][name]; } + + return null; } -export function compatPropertyNames(name: string, onlyObsolete = false): string[] { +export function getPropertyData(name: string): MDN.CompatData | null { const data = getData('properties/' + name); - const properties = []; + if (data) { + return data.css.properties[name]; + } + + return null; +} + +export function getSelectorsData(name: string): MDN.CompatData | null { + const data = getData('selectors/' + name); if (data) { - const compat = data.css.properties[name].__compat; + return data.css.selectors[name]; + } - let browser: MDN.Browsers; - for (browser in compat.support) { - const support = compat.support[browser]; + return null; +} - for (const version of Array.isArray(support) ? support : [support]) { - // Assume that the version has the property implemented if `null` - const hasBeenAdded = !!version.version_added || version.version_added === null; - const isObsolete = isDeprecated(name) || !!version.version_removed; +export function getTypesData(name: string): MDN.CompatData | null { + const data = getData('types/' + name); - if (hasBeenAdded && isObsolete === onlyObsolete) { - const compatName = version.prefix ? version.prefix + name : version.alternative_name; + if (data) { + return data.css.types[name]; + } - if (compatName) { - properties.push(compatName); - } - } - } - } + return null; +} + +function getData(cssPath: string): any { + if (cssPath in importsCache) { + return importsCache[cssPath]; } - return properties; + try { + return (importsCache[cssPath] = require(`mdn-browser-compat-data/css/${cssPath}.json`)); + } catch { + return (importsCache[cssPath] = null); + } } -export function isDeprecated(name: string) { - const data = getData('properties/' + name); +export function compatNames(compat: MDN.Compat, name: string, onlyRemoved = false): string[] { + const properties: string[] = []; - if (data) { - const status = data.css.properties[name].__compat.status; + let browser: MDN.Browsers; + for (browser in compat.support) { + const support = compat.support[browser]; - // Assume not deprecated if is status i missing - return !!status && status.deprecated; + for (const version of getSupport(support)) { + // Assume that the version has the property implemented if `null` + const isAdded = !!version.version_added || version.version_added === null; + const isRemoved = !!version.version_removed; + + if (isAdded && isRemoved === onlyRemoved) { + if (version.prefix) { + properties.push(version.prefix + name); + } + if (version.alternative_name) { + properties.push(version.alternative_name); + } + } + } } - return null; + return properties; } -export function compatPropertySyntax(name: string, entities: EntityType[]): EntityType[] { +export function compatSyntax(data: MDN.CompatData, entities: EntityType[]): EntityType[] { const compatEntities: EntityType[] = []; for (const entity of entities) { if (entity.entity === Entity.Component) { switch (entity.component) { case Component.Keyword: { - const alternatives = alternativeKeywords(name, entity.value); + if (entity.value in data && !isAddedBySome(getCompat(data[entity.value]))) { + // The keyword needs to be added by some browsers so we remove previous + // combinator and skip this keyword + compatEntities.pop(); + continue; + } + + const alternatives = alternativeKeywords(data, entity.value); if (alternatives.length > 0) { const alternativeEntities: EntityType[] = [entity]; @@ -80,7 +117,7 @@ export function compatPropertySyntax(name: string, entities: EntityType[]): Enti break; } case Component.Group: { - compatEntities.push(componentGroupData(compatPropertySyntax(name, entity.entities), entity.multiplier)); + compatEntities.push(componentGroupData(compatSyntax(data, entity.entities), entity.multiplier)); continue; } } @@ -92,37 +129,88 @@ export function compatPropertySyntax(name: string, entities: EntityType[]): Enti return compatEntities; } -function alternativeKeywords(name: string, value: string): string[] { - const data = getData('properties/' + name); +function alternativeKeywords(data: MDN.CompatData, value: string): string[] { const alternatives: string[] = []; - if (data) { - const property = data.css.properties[name]; + if (value in data) { + const compat = getCompat(data[value]); + + let browser: MDN.Browsers; + for (browser in compat.support) { + const support = compat.support[browser]; + + for (const version of Array.isArray(support) ? support : [support]) { + const isCurrent = + // Assume that the version has the value implemented if `null` + !!version.version_added || version.version_added === null; + + if (isCurrent) { + if (version.prefix && !alternatives.includes(version.prefix + value)) { + alternatives.push(version.prefix + value); + } + if (version.alternative_name && !alternatives.includes(version.alternative_name)) { + alternatives.push(version.alternative_name); + } + } + } + } + } + + return alternatives; +} - if (value in property) { - const combat = property[value].__compat; +export function isDeprecated(compat: MDN.Compat) { + // Assume not deprecated if is status i missing + return !!compat.status && compat.status.deprecated; +} - let browser: MDN.Browsers; - for (browser in combat.support) { - const support = combat.support[browser]; +export function isAddedBySome(compat: MDN.Compat): boolean { + let browser: MDN.Browsers; + for (browser in compat.support) { + const support = compat.support[browser]; - for (const version of Array.isArray(support) ? support : [support]) { - const isCurrent = - // Assume that the version has the value implemented if `null` - (!!version.version_added || version.version_added === null) && - // Assume that the version hasn't removed value if `null` - !version.version_removed; + for (const version of getSupport(support)) { + // Assume that the version has the property implemented if `null` + if (!!version.version_added || version.version_added === null) { + return true; + } + } + } - if (isCurrent) { - const compatName = version.prefix ? version.prefix + value : version.alternative_name; + return false; +} - if (compatName) { - alternatives.push(compatName); - } +export function alternativeSelectors(selector: string): string[] { + const alternatives: string[] = []; + + // Pseudo without ':' + const colons = ':'.repeat(selector.lastIndexOf(':') + 1); + const name = selector.slice(colons.length); + const compatibilityData = getSelectorsData(name); + + if (compatibilityData) { + const compat = getCompat(compatibilityData); + + let browser: MDN.Browsers; + for (browser in compat.support) { + const support = compat.support[browser]; + + for (const version of getSupport(support)) { + // Assume that the version has the property implemented if `null` + const isAdded = !!version.version_added || version.version_added === null; + + if (isAdded) { + if (version.prefix) { + alternatives.push(colons + version.prefix + name); + } + if (version.alternative_name) { + alternatives.push(version.alternative_name); } } } } + + return alternatives; } return alternatives; diff --git a/src/declarator.ts b/src/declarator.ts index 238edc7..34f13ce 100644 --- a/src/declarator.ts +++ b/src/declarator.ts @@ -11,7 +11,7 @@ import { vendorPrefixedLonghandProperties, vendorPrefixedShorthandProperties, } from './properties'; -import { advancedPseudos, simplePseudos } from './pseudos'; +import { advancedPseudos, simplePseudos } from './selectors'; import { IDataType, Type, TypeType } from './typer'; export interface IAlias { @@ -254,12 +254,13 @@ for (const properties of [ const atRuleDefinitions: { [name: string]: PropertyType[] } = {}; const atRuleHyphenDefinitions: { [name: string]: PropertyType[] } = {}; -for (const name in atRuleDescriptors) { +for (const name of Object.keys(atRuleDescriptors).sort()) { atRuleDefinitions[name] = []; atRuleHyphenDefinitions[name] = []; - for (const property in atRuleDescriptors[name]) { - const types = atRuleDescriptors[name][property]; + for (const property of Object.keys(atRuleDescriptors[name]).sort()) { + const descriptor = atRuleDescriptors[name][property]; + const types = descriptor.types; const generics = lengthIn(types) ? [lengthGeneric] : []; if (onlyContainsString(types) || onlyContainsNumber(types)) { @@ -268,7 +269,7 @@ for (const name in atRuleDescriptors) { }; atRuleDefinitions[name].push({ - name: toCamelCase(property), + name: isVendorProperty(property) ? toVendorPrefixCase(property) : toCamelCase(property), type, obsolete: false, }); @@ -278,17 +279,23 @@ for (const name in atRuleDescriptors) { obsolete: false, }); } else { - const declaration: IDeclaration = { - name: toPascalCase(name.slice(1)) + toPropertyDeclarationName(property), - export: false, - types: declarable(types), - generics, - }; + // Some properties are prefixed and share the same type so we + // make sure to reuse the same declaration of that type + let declaration = declarations.get(types); + + if (!declaration) { + declaration = { + name: toPascalCase(name) + toPropertyDeclarationName(descriptor.name), + export: false, + types: declarable(types), + generics, + }; - declarations.set(types, declaration); + declarations.set(types, declaration); + } atRuleDefinitions[name].push({ - name: toCamelCase(property), + name: isVendorProperty(property) ? toVendorPrefixCase(property) : toCamelCase(property), generics, alias: aliasOf(declaration), obsolete: false, @@ -667,7 +674,7 @@ const atRuleInterfaces: Interface[] = []; // Loop in alphabetical order for (const name of Object.keys(atRuleDefinitions).sort()) { - const pascalName = toPascalCase(name.slice(1)); + const pascalName = toPascalCase(name); const generics = genericsOf(atRuleDefinitions[name].filter(isAliasProperty)); atRuleInterfaces.push( { diff --git a/src/properties.ts b/src/properties.ts index 6807de9..4218375 100644 --- a/src/properties.ts +++ b/src/properties.ts @@ -1,6 +1,14 @@ import * as properties from 'mdn-data/css/properties.json'; import * as syntaxes from 'mdn-data/css/syntaxes.json'; -import { compatPropertyNames, compatPropertySyntax, isDeprecated } from './compat'; +import { + compatNames, + compatSyntax, + getCompat, + getPropertyData, + getTypesData, + isAddedBySome, + isDeprecated, +} from './compat'; import { resolveDataTypes } from './data-types'; import { properties as rawSvgProperties, syntaxes as svgSyntaxes } from './data/svg'; import parse from './parser'; @@ -20,9 +28,16 @@ interface IProperty { types: ResolvedType[]; } +const globalCompatibilityData = getTypesData('global_keywords'); +if (!globalCompatibilityData) { + throw new Error('Compatibility data for CSS-wide keywords is missing or may have been moved'); +} + // The CSS-wide keywords are identical to the `all` property // https://www.w3.org/TR/2016/CR-css-cascade-4-20160114/#all-shorthand -export const globals: ResolvedType[] = resolveDataTypes(typing(parse(properties.all.syntax))); +export const globals: ResolvedType[] = resolveDataTypes( + typing(compatSyntax(globalCompatibilityData, parse(properties.all.syntax))), +); export const standardLonghandProperties: { [name: string]: IProperty } = {}; export const standardShorthandProperties: { [name: string]: IProperty } = { @@ -42,77 +57,96 @@ for (const originalName in properties) { continue; } + // Default values + let entities = parse(properties[originalName].syntax); + let currentNames: string[] = [originalName]; + let obsoleteNames: string[] = []; + + const compatibilityData = getPropertyData(originalName); + + if (compatibilityData) { + const compat = getCompat(compatibilityData); + + if (!isAddedBySome(compat)) { + // The property needs to be added by some browsers + continue; + } + + entities = compatSyntax(compatibilityData, entities); + currentNames = currentNames.concat(filterMissingProperties(compatNames(compat, originalName))); + obsoleteNames = obsoleteNames.concat(filterMissingProperties(compatNames(compat, originalName, true))); + + if (isDeprecated(compat)) { + // Move all property names to obsolete + obsoleteNames = obsoleteNames.concat(currentNames); + currentNames = []; + } + } + const property: IProperty = { name: originalName, - types: resolveDataTypes( - typing(compatPropertySyntax(originalName, parse(properties[originalName].syntax))), - createDataTypeResolver(originalName), - ), + types: resolveDataTypes(typing(entities), createDataTypeResolver(compatibilityData)), }; - if (!isDeprecated(originalName)) { - const currentPropertyNames = [originalName, ...filterMissingProperties(compatPropertyNames(originalName))]; - - for (const name of currentPropertyNames) { - const isShorthand = Array.isArray(properties[originalName].computed); + for (const name of currentNames) { + const isShorthand = Array.isArray(properties[originalName].computed); - if (isVendorProperty(name)) { - if (isShorthand) { - vendorPrefixedShorthandProperties[name] = property; - } else { - vendorPrefixedLonghandProperties[name] = property; - } + if (isVendorProperty(name)) { + if (isShorthand) { + vendorPrefixedShorthandProperties[name] = property; } else { - if (isShorthand) { - standardShorthandProperties[name] = property; - } else { - standardLonghandProperties[name] = property; - } + vendorPrefixedLonghandProperties[name] = property; + } + } else { + if (isShorthand) { + standardShorthandProperties[name] = property; + } else { + standardLonghandProperties[name] = property; } } - } else { - obsoleteProperties[originalName] = property; } - const obsoletePropertyNames = filterMissingProperties(compatPropertyNames(originalName, true)); - - for (const name of obsoletePropertyNames) { + for (const name of obsoleteNames) { obsoleteProperties[name] = property; } } for (const name in rawSvgProperties) { + const compatibilityData = getPropertyData(name); const syntax = rawSvgProperties[name].syntax; if (syntax) { svgProperties[name] = { name, - types: resolveDataTypes(typing(parse(syntax)), createSvgDataTypeResolver(name)), + types: resolveDataTypes(typing(parse(syntax)), createSvgDataTypeResolver(compatibilityData)), }; } } -export function createDataTypeResolver(propertyName: string) { - const resolver: (dataTypeName: string) => ResolvedType[] = dataTypeName => { - const data = syntaxes[dataTypeName] || properties[dataTypeName]; - return data - ? resolveDataTypes(typing(compatPropertySyntax(propertyName, parse(data.syntax))), resolver) - : [{ type: Type.String }]; - }; - - return resolver; -} - export function isVendorProperty(name: string) { return REGEX_VENDOR_PROPERTY.test(name); } -export function filterMissingProperties(propertyNames: string[]) { +function filterMissingProperties(names: string[]) { // Filter only those which isn't defined in MDN data - return propertyNames.filter(name => !(name in properties)); + return names.filter(name => !(name in properties)); +} + +export function createDataTypeResolver(data: MDN.CompatData | null) { + const resolver: (dataTypeName: string) => ResolvedType[] = dataTypeName => { + const syntax = syntaxes[dataTypeName] || properties[dataTypeName]; + return syntax + ? resolveDataTypes( + data ? typing(compatSyntax(data, parse(syntax.syntax))) : typing(parse(syntax.syntax)), + resolver, + ) + : [{ type: Type.String }]; + }; + + return resolver; } -function createSvgDataTypeResolver(propertyName: string) { - const resolver = createDataTypeResolver(propertyName); +function createSvgDataTypeResolver(data: MDN.CompatData | null) { + const resolver = createDataTypeResolver(data); const svgResolver: (dataTypeName: string) => ResolvedType[] = (dataTypeName: string) => dataTypeName in svgSyntaxes ? resolveDataTypes(typing(parse(svgSyntaxes[dataTypeName].syntax)), svgResolver) diff --git a/src/pseudos.ts b/src/pseudos.ts deleted file mode 100644 index 9654a0f..0000000 --- a/src/pseudos.ts +++ /dev/null @@ -1,18 +0,0 @@ -import * as selectors from 'mdn-data/css/selectors.json'; -import { IStringLiteral, Type } from './typer'; - -const REGEX_SIMPLE_PSEUDO_SELECTOR = /(?!:?:[\w-]+\()(:?:[\w-]+)/g; -const REGEX_ADVANCED_PSEUDO_SELECTOR = /(:?:[\w-]+)\(/g; - -export const simplePseudos: IStringLiteral[] = []; -export const advancedPseudos: IStringLiteral[] = []; - -for (const selector in selectors) { - let match: RegExpMatchArray | null = null; - while ((match = REGEX_SIMPLE_PSEUDO_SELECTOR.exec(selectors[selector].syntax))) { - simplePseudos.push({ type: Type.StringLiteral, literal: match[1] }); - } - while ((match = REGEX_ADVANCED_PSEUDO_SELECTOR.exec(selectors[selector].syntax))) { - advancedPseudos.push({ type: Type.StringLiteral, literal: match[1] }); - } -} diff --git a/src/selectors.ts b/src/selectors.ts new file mode 100644 index 0000000..4e0fc77 --- /dev/null +++ b/src/selectors.ts @@ -0,0 +1,27 @@ +import * as selectors from 'mdn-data/css/selectors.json'; +import { alternativeSelectors } from './compat'; +import { addType, ResolvedType, Type } from './typer'; + +const REGEX_SIMPLE_PSEUDO_SELECTOR = /(?!:?:[\w-]+\()(:?:[\w-]+)/g; +const REGEX_ADVANCED_PSEUDO_SELECTOR = /(:?:[\w-]+)\(/g; + +export let simplePseudos: ResolvedType[] = []; +export let advancedPseudos: ResolvedType[] = []; + +for (const selector in selectors) { + let match: RegExpMatchArray | null = null; + while ((match = REGEX_SIMPLE_PSEUDO_SELECTOR.exec(selectors[selector].syntax))) { + simplePseudos = addType(simplePseudos, { type: Type.StringLiteral, literal: match[1] }); + + for (const alternative of alternativeSelectors(match[1])) { + simplePseudos = addType(simplePseudos, { type: Type.StringLiteral, literal: alternative }); + } + } + while ((match = REGEX_ADVANCED_PSEUDO_SELECTOR.exec(selectors[selector].syntax))) { + advancedPseudos = addType(advancedPseudos, { type: Type.StringLiteral, literal: match[1] }); + + for (const alternative of alternativeSelectors(match[1])) { + advancedPseudos = addType(advancedPseudos, { type: Type.StringLiteral, literal: alternative }); + } + } +} diff --git a/typings/mdn-browser-compat-data.d.ts b/typings/mdn-browser-compat-data.d.ts index 1129591..965ecbf 100644 --- a/typings/mdn-browser-compat-data.d.ts +++ b/typings/mdn-browser-compat-data.d.ts @@ -38,18 +38,57 @@ declare namespace MDN { }; } - type PropertyCompat = { __compat: MDN.Compat } & { [value: string]: { __compat: MDN.Compat } }; + type CompatData = { __compat: MDN.Compat } & { [value: string]: { __compat: MDN.Compat } }; + + interface AtRulesCompat { + css: { + 'at-rules': { + [rule: string]: CompatData; + }; + }; + } interface PropertiesCompat { css: { properties: { - [property: string]: PropertyCompat; + [property: string]: CompatData; }; }; } + + interface SelectorsCompat { + css: { + selectors: { + [selector: string]: CompatData; + }; + }; + } + + interface TypesCompat { + css: { + types: { + [type: string]: CompatData; + }; + }; + } +} + +declare module 'browser-compat-data/css/at-rules/*.json' { + var atRules: MDN.AtRulesCompat; + export = atRules; } declare module 'browser-compat-data/css/properties/*.json' { var properties: MDN.PropertiesCompat; export = properties; } + +declare module 'browser-compat-data/css/selectors/*.json' { + var selectors: MDN.SelectorsCompat; + export = selectors; +} + +declare module 'browser-compat-data/css/types/*.json' { + var types: MDN.TypesCompat; + export = types; +} diff --git a/yarn.lock b/yarn.lock index 3969202..a563677 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2083,15 +2083,15 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -mdn-browser-compat-data@0.0.30: - version "0.0.30" - resolved "https://registry.yarnpkg.com/mdn-browser-compat-data/-/mdn-browser-compat-data-0.0.30.tgz#6cd9f14ff475dd503b45cac094b65524519dfae7" +"mdn-browser-compat-data@git+https://github.com/mdn/browser-compat-data.git#3ab7b502352239d2131571d7463e098d2317532d": + version "0.0.31" + resolved "git+https://github.com/mdn/browser-compat-data.git#3ab7b502352239d2131571d7463e098d2317532d" dependencies: extend "3.0.1" -mdn-data@1.1.1: +"mdn-data@git+https://github.com/mdn/data.git#af0369d9445c7e6f44f818d2034ccac16f328da9": version "1.1.1" - resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-1.1.1.tgz#79586c90321787e5a2e51eb6823bb448949bc1ab" + resolved "git+https://github.com/mdn/data.git#af0369d9445c7e6f44f818d2034ccac16f328da9" mem@^1.1.0: version "1.1.0"