superfly-timeline
Version:
Resolver for defining objects with temporal boolean logic relationships on a timeline
132 lines • 5.62 kB
TypeScript
import { Content, TimelineObject } from './timeline';
import { InstanceId, Reference, Time } from './types';
/**
* The ResolvedTimeline contains all objects on the timeline, resolved.
* All references and all conflicts have been resolved.
* The absolute times of all objects can be found in objects[id].resolved.instances.
*
* To retrieve a state at a certain time, use getResolvedState(resolvedTimeline, time).
*
* Note: If `limitTime` was specified in the ResolveOptions,
* the ResolvedTimeline is only valid up until that time and
* needs to be re-resolved afterwards.
*/
export interface ResolvedTimeline<TContent extends Content = Content> {
/** The options used to resolve the timeline */
/** Map of all objects on timeline */
objects: ResolvedTimelineObjects<TContent>;
/** Map of all classes on timeline, maps className to object ids */
classes: {
[className: string]: string[];
};
/** Map of the object ids, per layer */
layers: {
[layer: string]: string[];
};
nextEvents: NextEvent[];
statistics: {
/** Number of timeline objects (including keyframes) in the timeline */
totalCount: number;
/** Number of resolved instances */
resolvedInstanceCount: number;
/** Number of resolved objects */
resolvedObjectCount: number;
/** Number of resolved groups */
resolvedGroupCount: number;
/** Number of resolved keyframes */
resolvedKeyframeCount: number;
/** How many objects (including keyframes) where actually resolved (is affected when using cache) */
resolvingObjectCount: number;
/**
* How many times the objects where resolved.
* If there are deep/recursive references in the timline,
* the resolver might resolve an object multiple times in order to fully resolve the timeline.
* (is affected when using cache)
*/
resolvingCount: number;
/** If traceResolving option is enabled, will contain a trace of the steps the resolver did while resolving */
resolveTrace: string[];
};
/** Is set if there was an error during Resolving and options.dontThrowOnError is set. */
error?: Error;
}
export interface ResolvedTimelineObjects<TContent extends Content = Content> {
[id: string]: ResolvedTimelineObject<TContent>;
}
export interface ResolvedTimelineObject<TContent extends Content = Content> extends TimelineObject<TContent> {
resolved: {
/** Instances of the object on the timeline */
instances: TimelineObjectInstance[];
/** A number that increases the more levels inside of a group the objects is. 0 = no parent */
levelDeep: number;
/** Id of the parent object (for children in groups or keyframes) */
parentId: string | undefined;
/** True if object is a keyframe */
isKeyframe: boolean;
/** Is set to true while object is being resolved (to prevent circular references) */
resolving: boolean;
/** Is set to true when object is resolved first time, and isn't reset thereafter */
firstResolved: boolean;
/** Is set to true when object's references has been resolved */
resolvedReferences: boolean;
/** Is set to true when object's conflicts has been resolved */
resolvedConflicts: boolean;
/** True if object is referencing itself (only directly, not indirectly via another object) */
isSelfReferencing: boolean;
/** Ids of all other objects that directly affects this object (ie through direct reference, classes, etc) */
directReferences: Reference[];
};
}
export interface InstanceBase {
/** The start time of the instance */
start: Time;
/** The end time of the instance (null = infinite) */
end: Time | null;
}
export interface TimelineObjectInstance extends InstanceBase {
/** id of the instance (unique) */
id: InstanceId;
/** if true, the instance starts from the beginning of time */
isFirst?: boolean;
/** The original start time of the instance (if an instance is split or capped, the original start time is retained in here).
* If undefined, fallback to .start
*/
originalStart?: Time;
/** The original end time of the instance (if an instance is split or capped, the original end time is retained in here)
* If undefined, fallback to .end
*/
originalEnd?: Time | null;
/** array of the id of the referenced objects */
references: Reference[];
/** If set, tells the cap of the parent. The instance will always be capped inside this. */
caps?: Cap[];
/** If the instance was generated from another instance, reference to the original */
fromInstanceId?: string;
}
export interface Cap {
id: InstanceId;
start: Time;
end: Time | null;
}
export interface NextEvent {
type: EventType;
time: Time;
objId: string;
}
export declare enum EventType {
START = 0,
END = 1,
KEYFRAME = 2
}
export interface AllStates<TContent extends Content = Content> {
[layer: string]: {
[time: string]: ResolvedTimelineObjectInstanceKeyframe<TContent>[] | null;
};
}
export interface ResolvedTimelineObjectInstanceKeyframe<TContent extends Content = Content> extends ResolvedTimelineObjectInstance<TContent> {
isKeyframe?: boolean;
}
export interface ResolvedTimelineObjectInstance<TContent extends Content = Content> extends ResolvedTimelineObject<TContent> {
instance: TimelineObjectInstance;
}
//# sourceMappingURL=resolvedTimeline.d.ts.map