import { BaseLibrary , BaseLibraryOptions } from './baseLibrary' ; import regex from './replace/regex' ; export interface KeyframesLibraryOptions extends BaseLibraryOptions { origKeyframe ? : boolean ; } export class KeyframesLibrary extends BaseLibrary { constructor ( ) { super ( 'keyframe' ) ; } fillLibrary ( data ) { const code = data . toString ( ) ; const keyframes = code . match ( regex . keyframes ) ; if ( Array . isArray ( keyframes ) ) { this . set ( keyframes . map ( ( key ) => key . split ( /\s+/ ) [ 1 ] ) ) ; } } get ( selector , opts = { } ) { const defaultOptions = { origKeyframe : true , ... opts , } ; const options = { ... defaultOptions , isOriginalValue : defaultOptions . origKeyframe , } ; return super . get ( selector , options ) ; } get keyframes ( ) : { [ s ] : string ; } { return this . values ; } set keyframes ( keyframes ) { this . values = keyframes ; } get compressedKeyframes ( ) : { [ s ] : string ; } { return this . compressedValues ; } set compressedKeyframes ( compressedKeyframes ) { this . compressedValues = compressedKeyframes ; } } export default new KeyframesLibrary ( ) ;