lib/index.esm.js
function Plugin() {
    var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
        id = _ref.id,
        name = _ref.name,
        _ref$level = _ref.level,
        level = _ref$level === undefined ? 0 : _ref$level,
        _ref$operable = _ref.operable,
        operable = _ref$operable === undefined ? true : _ref$operable,
        beforeCreate = _ref.beforeCreate,
        create = _ref.create,
        init = _ref.init,
        inited = _ref.inited,
        destroy = _ref.destroy,
        _ref$events = _ref.events,
        events = _ref$events === undefined ? {} : _ref$events,
        _ref$data = _ref.data,
        data = _ref$data === undefined ? {} : _ref$data,
        _ref$computed = _ref.computed,
        computed = _ref$computed === undefined ? {} : _ref$computed,
        _ref$methods = _ref.methods,
        methods = _ref$methods === undefined ? {} : _ref$methods,
        el = _ref.el,
        _ref$penetrate = _ref.penetrate,
        penetrate = _ref$penetrate === undefined ? false : _ref$penetrate,
        _ref$inner = _ref.inner,
        inner = _ref$inner === undefined ? true : _ref$inner,
        autoFocus = _ref.autoFocus,
        className = _ref.className;

    var dispatcher = arguments[1];
    var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { name: name };

    _classCallCheck(this, Plugin);

    var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this));

    _this.destroyed = false;
    _this.VERSION = '0.11.0';
    _this.__operable = true;
    _this.__level = 0;

    if (isEmpty(dispatcher)) {
      /* istanbul ignore else  */
      Log.error('Dispatcher.plugin', 'lack of dispatcher. Do you forget to pass arguments to super in plugin?');
      throw new TypeError('lack of dispatcher');
    }
    if (!isString(id)) {
      throw new TypeError('id of PluginConfig must be string');
    }
    _this.__id = id;
    _this.__dispatcher = dispatcher;
    _this.$videoConfig = _this.__dispatcher.videoConfig;
    _this.__wrapAsVideo(_this.$videoConfig);
    _this.beforeCreate = _this.beforeCreate || beforeCreate;
    try {
      isFunction(_this.beforeCreate) && _this.beforeCreate({
        events: events,
        data: data,
        computed: computed,
        methods: methods
      }, option);
    } catch (error) {
      _this.$throwError(error);
    }
    // bind plugin methods into instance
    if (!isEmpty(methods) && isObject(methods)) {
      _Object$keys(methods).forEach(function (key) {
        var fn = methods[key];
        if (!isFunction(fn)) throw new TypeError('plugins methods must be Function');
        _Object$defineProperty(_this, key, {
          value: bind(fn, _this),
          writable: true,
          enumerable: false,
          configurable: true
        });
      });
    }
    // hook plugin events on bus
    if (!isEmpty(events) && isObject(events)) {
      _Object$keys(events).forEach(function (key) {
        if (!isFunction(events[key])) throw new TypeError('plugins events hook must bind with Function');
        _this.$on(key, events[key]);
      });
    }
    // bind data into plugin instance
    if (!isEmpty(data) && isObject(data)) {
      deepAssign(_this, data);
    }
    // set the computed member by getter and setter
    if (!isEmpty(computed) && isObject(computed)) {
      var props = _Object$keys(computed).reduce(function (props, key) {
        var val = computed[key];
        if (isFunction(val)) {
          props[key] = accessor({ get: val });
          return props;
        }
        if (isObject(val) && (isFunction(val.get) || isFunction(val.set))) {
          props[key] = accessor(val);
          return props;
        }
        /* istanbul ignore else  */
        Log.warn('Dispatcher.plugin', 'Wrong computed member \'' + key + '\' defination in Plugin ' + name);
        return props;
      }, {});
      applyDecorators(_this, props, { self: true });
    }
    /**
     * the create Function of plugin
     * @type {Function}
     */
    _this.create = _this.create || create;
    /**
     * this init Function of plugin
     * which will be called when we start to create the video player
     * the plugin can handle some config here
     * @type {Function}
     */
    _this.init = _this.init || init;
    /**
     * this inited Function of plugin
     * which will be called when we have created the video player
     * @type {Function}
     */
    _this.inited = _this.inited || inited;
    /**
     * the destroy Function of plugin
     * @type {Function}
     */
    _this.destroy = _this.destroy || destroy;
    /**
     * the dom node of whole plugin
     * @type {HTMLElement}
     */
    _this.$dom = _this.__dispatcher.dom.insertPlugin(_this.__id, el, { penetrate: penetrate, inner: inner, className: className });
    _this.$autoFocus = isBoolean(autoFocus) ? autoFocus : inner;
    // now we can frozen inner, autoFocus and penetrate
    _this.$inner = inner;
    _this.$penetrate = penetrate;
    applyDecorators(_this, {
      $inner: frozen,
      $penetrate: frozen
    }, { self: true });
    /**
     * to tell us if the plugin can be operable, can be dynamic change
     * @type {boolean}
     */
    _this.$operable = isBoolean(option.operable) ? option.operable : operable;
    _this.__level = isInteger$2(option.level) ? option.level : level;
    /**
     * pluginOption, so it's easy for plugin developer to check the config
     * @type {Object}
     */
    _this.$config = option;
    try {
      isFunction(_this.create) && _this.create();
    } catch (error) {
      _this.$throwError(error);
    }
    return _this;
  }
function Plugin() {
    var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
        id = _ref.id,
        name = _ref.name,
        _ref$level = _ref.level,
        level = _ref$level === undefined ? 0 : _ref$level,
        _ref$operable = _ref.operable,
        operable = _ref$operable === undefined ? true : _ref$operable,
        beforeCreate = _ref.beforeCreate,
        create = _ref.create,
        init = _ref.init,
        inited = _ref.inited,
        destroy = _ref.destroy,
        _ref$events = _ref.events,
        events = _ref$events === undefined ? {} : _ref$events,
        _ref$data = _ref.data,
        data = _ref$data === undefined ? {} : _ref$data,
        _ref$computed = _ref.computed,
        computed = _ref$computed === undefined ? {} : _ref$computed,
        _ref$methods = _ref.methods,
        methods = _ref$methods === undefined ? {} : _ref$methods,
        el = _ref.el,
        _ref$penetrate = _ref.penetrate,
        penetrate = _ref$penetrate === undefined ? false : _ref$penetrate,
        _ref$inner = _ref.inner,
        inner = _ref$inner === undefined ? true : _ref$inner,
        autoFocus = _ref.autoFocus,
        className = _ref.className;

    var dispatcher = arguments[1];
    var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { name: name };

    _classCallCheck(this, Plugin);

    var _this = _possibleConstructorReturn(this, (Plugin.__proto__ || _Object$getPrototypeOf(Plugin)).call(this));

    _this.destroyed = false;
    _this.VERSION = '0.11.0';
    _this.__operable = true;
    _this.__level = 0;

    if (isEmpty(dispatcher)) {
      /* istanbul ignore else  */
      Log.error('Dispatcher.plugin', 'lack of dispatcher. Do you forget to pass arguments to super in plugin?');
      throw new TypeError('lack of dispatcher');
    }
    if (!isString(id)) {
      throw new TypeError('id of PluginConfig must be string');
    }
    _this.__id = id;
    _this.__dispatcher = dispatcher;
    _this.$videoConfig = _this.__dispatcher.videoConfig;
    _this.__wrapAsVideo(_this.$videoConfig);
    _this.beforeCreate = _this.beforeCreate || beforeCreate;
    try {
      isFunction(_this.beforeCreate) && _this.beforeCreate({
        events: events,
        data: data,
        computed: computed,
        methods: methods
      }, option);
    } catch (error) {
      _this.$throwError(error);
    }
    // bind plugin methods into instance
    if (!isEmpty(methods) && isObject(methods)) {
      _Object$keys(methods).forEach(function (key) {
        var fn = methods[key];
        if (!isFunction(fn)) throw new TypeError('plugins methods must be Function');
        _Object$defineProperty(_this, key, {
          value: bind(fn, _this),
          writable: true,
          enumerable: false,
          configurable: true
        });
      });
    }
    // hook plugin events on bus
    if (!isEmpty(events) && isObject(events)) {
      _Object$keys(events).forEach(function (key) {
        if (!isFunction(events[key])) throw new TypeError('plugins events hook must bind with Function');
        _this.$on(key, events[key]);
      });
    }
    // bind data into plugin instance
    if (!isEmpty(data) && isObject(data)) {
      deepAssign(_this, data);
    }
    // set the computed member by getter and setter
    if (!isEmpty(computed) && isObject(computed)) {
      var props = _Object$keys(computed).reduce(function (props, key) {
        var val = computed[key];
        if (isFunction(val)) {
          props[key] = accessor({ get: val });
          return props;
        }
        if (isObject(val) && (isFunction(val.get) || isFunction(val.set))) {
          props[key] = accessor(val);
          return props;
        }
        /* istanbul ignore else  */
        Log.warn('Dispatcher.plugin', 'Wrong computed member \'' + key + '\' defination in Plugin ' + name);
        return props;
      }, {});
      applyDecorators(_this, props, { self: true });
    }
    /**
     * the create Function of plugin
     * @type {Function}
     */
    _this.create = _this.create || create;
    /**
     * this init Function of plugin
     * which will be called when we start to create the video player
     * the plugin can handle some config here
     * @type {Function}
     */
    _this.init = _this.init || init;
    /**
     * this inited Function of plugin
     * which will be called when we have created the video player
     * @type {Function}
     */
    _this.inited = _this.inited || inited;
    /**
     * the destroy Function of plugin
     * @type {Function}
     */
    _this.destroy = _this.destroy || destroy;
    /**
     * the dom node of whole plugin
     * @type {HTMLElement}
     */
    _this.$dom = _this.__dispatcher.dom.insertPlugin(_this.__id, el, { penetrate: penetrate, inner: inner, className: className });
    _this.$autoFocus = isBoolean(autoFocus) ? autoFocus : inner;
    // now we can frozen inner, autoFocus and penetrate
    _this.$inner = inner;
    _this.$penetrate = penetrate;
    applyDecorators(_this, {
      $inner: frozen,
      $penetrate: frozen
    }, { self: true });
    /**
     * to tell us if the plugin can be operable, can be dynamic change
     * @type {boolean}
     */
    _this.$operable = isBoolean(option.operable) ? option.operable : operable;
    _this.__level = isInteger$2(option.level) ? option.level : level;
    /**
     * pluginOption, so it's easy for plugin developer to check the config
     * @type {Object}
     */
    _this.$config = option;
    try {
      isFunction(_this.create) && _this.create();
    } catch (error) {
      _this.$throwError(error);
    }
    return _this;
  }
function Plugin ( ) { var _ref = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } , id = _ref . id , name = _ref . name , _ref$level = _ref . level , level = _ref$level === undefined ? 0 : _ref$level , _ref$operable = _ref . operable , operable = _ref$operable === undefined ? true : _ref$operable , beforeCreate = _ref . beforeCreate , create = _ref . create , init = _ref . init , inited = _ref . inited , destroy = _ref . destroy , _ref$events = _ref . events , events = _ref$events === undefined ? { } : _ref$events , _ref$data = _ref . data , data = _ref$data === undefined ? { } : _ref$data , _ref$computed = _ref . computed , computed = _ref$computed === undefined ? { } : _ref$computed , _ref$methods = _ref . methods , methods = _ref$methods === undefined ? { } : _ref$methods , el = _ref . el , _ref$penetrate = _ref . penetrate , penetrate = _ref$penetrate === undefined ? false : _ref$penetrate , _ref$inner = _ref . inner , inner = _ref$inner === undefined ? true : _ref$inner , autoFocus = _ref . autoFocus , className = _ref . className ; var dispatcher = arguments [ 1 ] ; var option = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : { name : name } ; _classCallCheck ( this , Plugin ) ; var _this = _possibleConstructorReturn ( this , ( Plugin . __proto__ || _Object$getPrototypeOf ( Plugin ) ) . call ( this ) ) ; _this . destroyed = false ; _this . VERSION = '0.11.0' ; _this . __operable = true ; _this . __level = 0 ; if ( isEmpty ( dispatcher ) ) { /* istanbul ignore else  */ Log . error ( 'Dispatcher.plugin' , 'lack of dispatcher. Do you forget to pass arguments to super in plugin?' ) ; throw new TypeError ( 'lack of dispatcher' ) ; } if ( ! isString ( id ) ) { throw new TypeError ( 'id of PluginConfig must be string' ) ; } _this . __id = id ; _this . __dispatcher = dispatcher ; _this . $videoConfig = _this . __dispatcher . videoConfig ; _this . __wrapAsVideo ( _this . $videoConfig ) ; _this . beforeCreate = _this . beforeCreate || beforeCreate ; try { isFunction ( _this . beforeCreate ) && _this . beforeCreate ( { events : events , data : data , computed : computed , methods : methods } , option ) ; } catch ( error ) { _this . $throwError ( error ) ; } // bind plugin methods into instance if ( ! isEmpty ( methods ) && isObject ( methods ) ) { _Object$keys ( methods ) . forEach ( function ( key ) { var fn = methods [ key ] ; if ( ! isFunction ( fn ) ) throw new TypeError ( 'plugins methods must be Function' ) ; _Object$defineProperty ( _this , key , { value : bind ( fn , _this ) , writable : true , enumerable : false , configurable : true } ) ; } ) ; } // hook plugin events on bus if ( ! isEmpty ( events ) && isObject ( events ) ) { _Object$keys ( events ) . forEach ( function ( key ) { if ( ! isFunction ( events [ key ] ) ) throw new TypeError ( 'plugins events hook must bind with Function' ) ; _this . $on ( key , events [ key ] ) ; } ) ; } // bind data into plugin instance if ( ! isEmpty ( data ) && isObject ( data ) ) { deepAssign ( _this , data ) ; } // set the computed member by getter and setter if ( ! isEmpty ( computed ) && isObject ( computed ) ) { var props = _Object$keys ( computed ) . reduce ( function ( props , key ) { var val = computed [ key ] ; if ( isFunction ( val ) ) { props [ key ] = accessor ( { get : val } ) ; return props ; } if ( isObject ( val ) && ( isFunction ( val . get ) || isFunction ( val . set ) ) ) { props [ key ] = accessor ( val ) ; return props ; } /* istanbul ignore else  */ Log . warn ( 'Dispatcher.plugin' , 'Wrong computed member \'' + key + '\' defination in Plugin ' + name ) ; return props ; } , { } ) ; applyDecorators ( _this , props , { self : true } ) ; } /**
     * the create Function of plugin
     * @type {Function}
     */ _this . create = _this . create || create ; /**
     * this init Function of plugin
     * which will be called when we start to create the video player
     * the plugin can handle some config here
     * @type {Function}
     */ _this . init = _this . init || init ; /**
     * this inited Function of plugin
     * which will be called when we have created the video player
     * @type {Function}
     */ _this . inited = _this . inited || inited ; /**
     * the destroy Function of plugin
     * @type {Function}
     */ _this . destroy = _this . destroy || destroy ; /**
     * the dom node of whole plugin
     * @type {HTMLElement}
     */ _this . $dom = _this . __dispatcher . dom . insertPlugin ( _this . __id , el , { penetrate : penetrate , inner : inner , className : className } ) ; _this . $autoFocus = isBoolean ( autoFocus ) ? autoFocus : inner ; // now we can frozen inner, autoFocus and penetrate _this . $inner = inner ; _this . $penetrate = penetrate ; applyDecorators ( _this , { $inner : frozen , $penetrate : frozen } , { self : true } ) ; /**
     * to tell us if the plugin can be operable, can be dynamic change
     * @type {boolean}
     */ _this . $operable = isBoolean ( option . operable ) ? option . operable : operable ; _this . __level = isInteger$2 ( option . level ) ? option . level : level ; /**
     * pluginOption, so it's easy for plugin developer to check the config
     * @type {Object}
     */ _this . $config = option ; try { isFunction ( _this . create ) && _this . create ( ) ; } catch ( error ) { _this . $throwError ( error ) ; } return _this ; }
<pre>
to create a plugin, we need three parameter
1. the config of a plugin
2. the dispatcher
3. this option for plugin to read
this is the plugin base class, which you can get on Chimee
You can just extends it and then install
But in that way you must remember to pass the arguments to super()
</pre>
@param  {string}  PluginConfig.id        camelize from plugin's name or class name.
@param  {string}  PluginConfig.name      plugin's name or class name
@param  {Number}  PluginConfig.level     the level of z-index
@param  {Boolean} PluginConfig.operable  to tell if the plugin can be operable, if not, we will add pointer-events: none on it.
@param  {Function}  PluginConfig.create  the create function which we will called when plugin is used. sth like constructor in object style.
@param  {Function}  PluginConfig.destroy   function to be called when we destroy a plugin
@param  {Object}  PluginConfig.events    You can set some events handler in this object, we will bind it once you use the plugin.
@param  {Object}  PluginConfig.data      dataset we will bind on data in object style
@param  {Object<{get: Function, set: Function}}  PluginConfig.computed  dataset we will handle by getter and setter
@param  {Object<Function>}  PluginConfig.methods   some function we will bind on plugin
@param  {string|HTMLElment}  PluginConfig.el  can be string or HTMLElement, we will use this to create the dom for plugin
@param  {boolean} PluginConfig.penetrate boolean to let us do we need to forward the dom events for this plugin.
@param  {Dispatcher}  dispatcher referrence of dispatcher
@param  {Object}  option  PluginOption that will pass to the plugin
@return {Plugin}  plugin instance
<pre > to create a plugin we need three parameter 1 . the config of a plugin 2 . the dispatcher 3 . this option for plugin to read this is the plugin base class which you can get on Chimee You can just extends it and then install But in that way you must remember to pass the arguments to super () < / pre >