import * as LruCache from 'lru-cache' ; export * from './consts' ; export * from './dom-query' ; export * from './pure-view' ; import { injectGlobal } from 'emotion' ; import * as Hydux from 'hydux' ; injectGlobal `
  body {
    padding: 0;
    margin: 0;
    background-color: rgb(32, 31, 31);
    font-family: sans-serif;
  }
    /* width */
  *::-webkit-scrollbar {
      width: 6px;
      height: 6px;
  }

  /* Track */
  *::-webkit-scrollbar-track {
      background: #333;
  }

  /* Handle */
  *::-webkit-scrollbar-thumb {
      background: #555;
      border-radius: 3px;
  }

  /* Handle on hover */
  *::-webkit-scrollbar-thumb:hover {
      background: #888;
  }
` ; export function slug ( key ) { key = key . replace ( /([A-Z])/g , ( _ , c ) => `-${ c . toLowerCase ( ) }` ) ; if ( /^webkit|moz|ms/ . test ( key ) ) { key = '-' + key ; } return key ; } export function deslug ( key ) { return key . replace ( /-([a-z])/g , ( _ , c ) => c . toUpperCase ( ) ) ; } export const lruCache = new LruCache < string , any > ( { max : 500 } ) ; export function svg2dataUrl ( svg ) { let dataUrl = lruCache . get ( svg ) ; if ( ! dataUrl ) { dataUrl = `data:image/svg+xml;utf8,${ ( ( svg . replace ( /(<\?.*?\?>|\<\!--.*?--\>)/g , '' ) ) ) }` ; lruCache . set ( svg , dataUrl ) ; } return dataUrl ; } export function overrideAction < S , A , PS , PA , A1 > ( parentActions , getter , wrapper ? ) ; export function overrideAction < S , A , PS , PA , A1 , A2 > ( parentActions , getter , wrapper ? ) ; param action param wrapper param parentState param parentActions export function overrideAction < S , A , PS , PA > ( parentActions , getter , wrapper ? ) { if ( ! wrapper ) { return parentActions ; } let action = getter ( parentActions ) ; const wrappedAction = ( ... args ) => ( state , actions , parentState , parentActions ) => { const normalAction = ( ... args ) => Hydux . runAction ( action ( ... args ) , state , actions ) ; return wrapper ( ... args ) ( normalAction , parentState , parentActions , state , actions ) ; } ; let keys = ( getter . toString ( ) . match ( /((?:[\w_$]+\.)+[\w_$]+)/ ) || [ ] ) [ 1 ] . split ( '.' ) . slice ( 1 ) ; let cursor = parentActions ; let replaced = false ; for ( let i = 0 ; i < keys . length ; i ++ ) { const key = keys [ i ] ; if ( cursor [ key ] === action ) { cursor [ key ] = wrappedAction ; replaced = true ; break ; } cursor = cursor [ key ] = { ... cursor [ key ] } ; } if ( ! replaced ) { console . error ( new Error ( `Cannot find action in parentActions` ) , parentActions , getter , parentActions ) ; } return parentActions ; } let counter = 1 ; export function uid ( label = '' ) { return `uid_${ label }_${ counter ++ }` ; } export function defaults < T > ( a , defaults ) { return typeof a === 'undefined' ? defaults : a ; } export const sleep = ( ms ) => new Promise ( res => setTimeout ( res , ms ) ) ; export const log = ( ... args ) => __DEV__ && console . log ( ... args ) ; export const time = ( ... args ) => __DEV__ && console . time ( ... args ) ; export const timeEnd = ( ... args ) => __DEV__ && console . timeEnd ( ... args ) ;