import { watchPublic } from '../util' ; import { publish , subscribe } from '../event' ; import { Movie } from '../movie' ; import { Visual } from '../layer/index' ; import BaseObject from '../object' ; /**
 * Modifies the visual contents of a layer.
 */ export class Base implements BaseObject { type : string ; publicExcludes : string [ ] ; propertyFilters : Record < string , < T > ( value : T ) => T > ; enabled : boolean ; private _target : Movie | Visual ; /**
     * The number of times this effect has been attached to a target minus the
     * number of times it's been detached. (Used for the target's array proxy with
     * `unshift`)
     */ private _occurrenceCount : number ; constructor ( ) { const newThis = watchPublic ( this ) as Base ; newThis . enabled = true ; newThis . _occurrenceCount = 0 ; newThis . _target = null ; subscribe ( newThis , 'effect.change.modify' , event => { if ( ! newThis . _target ) return ; const type = `${ newThis . _target . type }.change.effect.modify` ; publish ( newThis . _target , type , { ... event , target : newThis . _target , source : newThis , type } ) ; } ) ; return newThis ; } ignore tryAttach ( target ) { if ( this . _occurrenceCount === 0 ) this . attach ( target ) ; this . _occurrenceCount ++ ; } attach ( movie ) { this . _target = movie ; } ignore tryDetach ( ) { if ( this . _target === null ) throw new Error ( 'No movie to detach from' ) ; this . _occurrenceCount -- ; if ( this . _occurrenceCount === 0 ) this . detach ( ) ; } detach ( ) { this . _target = null ; } param target param reltime abstract apply ( target , reltime ) { } /**
     * The current time of the target
     */ get currentTime ( ) : number { return this . _target ? this . _target . currentTime : undefined ; } get parent ( ) : Movie | Visual { return this . _target ; } get movie ( ) : Movie { return this . _target ? this . _target . movie : undefined ; } getDefaultOptions ( ) { return { } ; } } Base . prototype . type = 'effect' ; Base . prototype . publicExcludes = [ ] ; Base . prototype . propertyFilters = { } ;