import { error , warn } from '../utils' ; import { Callback , CallbackOptions , Data } from './models' ; public export interface SpriteSpinPlugin extends CallbackOptions { [ key ] : Callback | string ; name ? : string ; } const plugins = { } ; remarks public param name param plugin export function registerPlugin ( name , plugin ) { if ( plugins [ name ] ) { error ( `Plugin name "${ name }" is already taken` ) ; return ; } plugin = plugin || { } ; plugins [ name ] = plugin ; return plugin ; } public deprecated Use  registerPlugin instead
 *  param name param plugin export function registerModule ( name , plugin ) { warn ( '"registerModule" is deprecated, use "registerPlugin" instead' ) ; registerPlugin ( name , plugin ) ; } internal param name export function getPlugin ( name ) { return plugins [ name ] ; } internal export function applyPlugins ( data ) { fixPlugins ( data ) ; for ( let i = 0 ; i < data . plugins . length ; i += 1 ) { const name = data . plugins [ i ] ; if ( typeof name !== 'string' ) { continue ; } const plugin = getPlugin ( name ) ; if ( ! plugin ) { error ( 'No plugin found with name ' + name ) ; continue ; } data . plugins [ i ] = plugin ; } } function fixPlugins ( data ) { if ( data [ 'mods' ] ) { warn ( '"mods" option is deprecated, use "plugins" instead' ) ; data . plugins = data [ 'mods' ] ; delete data [ 'mods' ] ; } if ( data [ 'behavior' ] ) { warn ( '"behavior" option is deprecated, use "plugins" instead' ) ; data . plugins . push ( data [ 'behavior' ] ) ; delete data [ 'behavior' ] ; } if ( data [ 'module' ] ) { warn ( '"module" option is deprecated, use "plugins" instead' ) ; data . plugins . push ( data [ 'module' ] ) ; delete data [ 'module' ] ; } }