UNPKG

superfly-timeline

Version:

Resolver for defining objects with temporal boolean logic relationships on a timeline

127 lines 5.43 kB
import { ResolvedTimeline, ResolvedTimelineObject, TimelineObjectInstance } from '../api/resolvedTimeline'; import { Content, TimelineKeyframe, TimelineObject } from '../api/timeline'; import { InstanceId, ResolveOptions, ResolverCache } from '../api'; import { CacheHandler } from './CacheHandler'; /** * A ResolvedTimelineHandler instance is short-lived and used to resolve a timeline. * Intended usage: * 1. const resolver = new ResolvedTimelineHandler(options) * 2. timelineObjects.forEach(obj => resolver.addTimelineObject(obj)) * 3. resolver.resolveAllTimelineObjs() */ export declare class ResolvedTimelineHandler<TContent extends Content = Content> { options: ResolveOptions; /** Maps object id to object */ objectsMap: Map<string, ResolvedTimelineObject<TContent>>; /** Maps className to a list of object ids */ classesMap: Map<string, string[]>; /** Maps layer to a list of object ids */ layersMap: Map<string, string[]>; private expression; private reference; private instance; /** * Maps an array of object ids to an object id (objects that directly reference an reference). */ private directReferenceMap; private cache?; /** How many objects that was actually resolved (is affected when using cache) */ private statisticResolvingObjectCount; /** How many times an object where resolved. (is affected when using cache) */ private statisticResolvingCount; private debug; private _resolveTrace; /** * A Map of strings (instance hashes) that is used to determine if an objects instances have changed. * Maps objectId -> instancesHash */ private resolvedObjInstancesHash; /** * List of explanations fow why an object changed during a resolve iteration. * Used for debugging and Errors */ private changedObjIdsExplanations; /** * A Map that contains the objects that needs to resolve again. * Object are added into this after this.resolveConflictsForLayer() */ private objectsToReResolve; /** Counter that increases during resolving, for every object that might need re-resolving*/ private objectResolveCount; /** Error message, is set when an error is encountered and this.options.dontThrowOnError is set */ private _resolveError; readonly traceResolving: boolean; constructor(options: ResolveOptions); get resolveError(): Error | undefined; /** Populate ResolvedTimelineHandler with a timeline-object. */ addTimelineObject(obj: TimelineObject<TContent>): void; /** Resolve the timeline. */ resolveAllTimelineObjs(): void; /** * Resolve a timeline-object. * The Resolve algorithm works like this: * 1. Go through the .enable expression(s) and look up all referenced objects. * 1.5 For each referenced object, recursively resolve it first if not already resolved. * 2. Collect the resolved instances and calculate the resulting list of resulting instances. */ resolveTimelineObj(obj: ResolvedTimelineObject): void; getStatistics(): ResolvedTimeline['statistics']; initializeCache(cacheObj: Partial<ResolverCache>): CacheHandler; /** * Returns an object. * type-wise, assumes you know what object you're looking for */ getObject(objId: string): ResolvedTimelineObject; /** * Returns object ids on a layer * type-wise, assumes you know what layer you're looking for */ getLayerObjects(layer: string): string[]; /** * Returns object ids on a layer * type-wise, assumes you know what className you're looking for */ getClassObjects(className: string): string[]; capInstancesToParentInstances(arg: { instances: TimelineObjectInstance[]; parentInstances: TimelineObjectInstance[] | null; }): TimelineObjectInstance[]; addResolveTrace(message: string): void; getResolvedTimeline(): ResolvedTimeline<TContent>; private getNextEvents; private updateDirectReferenceMap; private getLayersForObjects; /** Cache of all layers, sorted by object count ASC */ private allObjectLayersCache; /** * Returns a list of all object's layers, sorted by object count ASC * Note: The order of the layers is important from a performance perspective. * By feeding layers with a low object count first into this.resolveConflictsForLayer(), * there is a higher likelihood that a conflict from a low-count layer will affect an object on * a high-count layer, so it can be skipped in this iteration. */ private getAllObjectLayers; /** Look up an expression, update references and return it. */ private lookupExpression; /** * Add timelineObject or keyframe */ private _addTimelineObject; /** * Resolve conflicts for all layers of the provided objects */ private resolveConflictsForObjs; /** * Resolve conflicts for a layer * @returns A list of objects on that layer */ private resolveConflictsForLayer; private _idCount; /** Returns the next unique instance id */ getInstanceId(): InstanceId; private updateObjectsToReResolve; private markObjectToBeReResolved; } export interface TimelineObjectKeyframe<TContent extends Content = Content> extends TimelineObject<TContent>, TimelineKeyframe<TContent> { } //# sourceMappingURL=ResolvedTimelineHandler.d.ts.map