superfly-timeline
Advanced tools
Comparing version 9.0.0-nightly-wip-big-rewrite-20230707-073157-387a67a.0 to 9.0.0-nightly-wip-big-rewrite-20230707-094049-a13df02.0
@@ -1,5 +0,3 @@ | ||
import { InstanceId } from '../resolver/lib/instance'; | ||
import { Reference } from '../resolver/lib/reference'; | ||
import { TimelineObject } from './timeline'; | ||
import { Time } from './types'; | ||
import { Content, TimelineObject } from './timeline'; | ||
import { InstanceId, Reference, Time } from './types'; | ||
/** | ||
@@ -16,6 +14,6 @@ * The ResolvedTimeline contains all objects on the timeline, resolved. | ||
*/ | ||
export interface ResolvedTimeline { | ||
export interface ResolvedTimeline<TContent extends Content = Content> { | ||
/** The options used to resolve the timeline */ | ||
/** Map of all objects on timeline */ | ||
objects: ResolvedTimelineObjects; | ||
objects: ResolvedTimelineObjects<TContent>; | ||
/** Map of all classes on timeline, maps className to object ids */ | ||
@@ -47,6 +45,6 @@ classes: { | ||
} | ||
export interface ResolvedTimelineObjects { | ||
[id: string]: ResolvedTimelineObject; | ||
export interface ResolvedTimelineObjects<TContent extends Content = Content> { | ||
[id: string]: ResolvedTimelineObject<TContent>; | ||
} | ||
export interface ResolvedTimelineObject extends TimelineObject { | ||
export interface ResolvedTimelineObject<TContent extends Content = Content> extends TimelineObject<TContent> { | ||
resolved: { | ||
@@ -116,13 +114,13 @@ /** Instances of the object on the timeline */ | ||
} | ||
export interface AllStates { | ||
export interface AllStates<TContent extends Content = Content> { | ||
[layer: string]: { | ||
[time: string]: ResolvedTimelineObjectInstanceKeyframe[] | null; | ||
[time: string]: ResolvedTimelineObjectInstanceKeyframe<TContent>[] | null; | ||
}; | ||
} | ||
export interface ResolvedTimelineObjectInstanceKeyframe extends ResolvedTimelineObjectInstance { | ||
export interface ResolvedTimelineObjectInstanceKeyframe<TContent extends Content = Content> extends ResolvedTimelineObjectInstance<TContent> { | ||
isKeyframe?: boolean; | ||
} | ||
export interface ResolvedTimelineObjectInstance extends ResolvedTimelineObject { | ||
export interface ResolvedTimelineObjectInstance<TContent extends Content = Content> extends ResolvedTimelineObject<TContent> { | ||
instance: TimelineObjectInstance; | ||
} | ||
//# sourceMappingURL=resolvedTimeline.d.ts.map |
import { ResolvedTimelineObjects } from './resolvedTimeline'; | ||
import { Content } from './timeline'; | ||
import { Time } from './types'; | ||
@@ -43,9 +44,9 @@ export interface ResolveOptions { | ||
} | ||
export interface ResolverCache { | ||
export interface ResolverCache<TContent extends Content = Content> { | ||
objHashes: { | ||
[id: string]: string; | ||
}; | ||
objects: ResolvedTimelineObjects; | ||
objects: ResolvedTimelineObjects<TContent>; | ||
hasOldData?: boolean; | ||
} | ||
//# sourceMappingURL=resolver.d.ts.map |
import { NextEvent, ResolvedTimelineObjectInstance } from './resolvedTimeline'; | ||
import { Content } from './timeline'; | ||
import { Time } from './types'; | ||
@@ -8,7 +9,7 @@ /** | ||
*/ | ||
export interface TimelineState { | ||
export interface TimelineState<TContent extends Content = Content> { | ||
/** The timestamp for this state */ | ||
time: Time; | ||
/** All objects that are active on each respective layer */ | ||
layers: StateInTime; | ||
layers: StateInTime<TContent>; | ||
/** | ||
@@ -20,5 +21,5 @@ * A sorted list of the points in time where the next thing will happen on the timeline. | ||
} | ||
export interface StateInTime { | ||
[layer: string]: ResolvedTimelineObjectInstance; | ||
export interface StateInTime<TContent extends Content = Content> { | ||
[layer: string]: ResolvedTimelineObjectInstance<TContent>; | ||
} | ||
//# sourceMappingURL=state.d.ts.map |
import { Expression } from './expression'; | ||
import { ObjectId } from './types'; | ||
export interface TimelineObject { | ||
export interface TimelineObject<TContent extends Content = Content> { | ||
/** ID of the object. Must be unique! */ | ||
@@ -18,3 +18,3 @@ id: ObjectId; | ||
*/ | ||
children?: TimelineObject[]; | ||
children?: TimelineObject<Content>[]; | ||
isGroup?: boolean; | ||
@@ -25,3 +25,3 @@ /** | ||
*/ | ||
keyframes?: Array<TimelineKeyframe>; | ||
keyframes?: TimelineKeyframe<Partial<TContent>>[]; | ||
/** | ||
@@ -46,3 +46,3 @@ * A list of classes on this Timeline-object. classes can be referenced by other objects using the syntax: ".className" | ||
/** The payload of the timeline-object. Can be anything you want. */ | ||
content: Content; | ||
content: TContent; | ||
} | ||
@@ -74,3 +74,3 @@ export type Content = { | ||
} | ||
export interface TimelineKeyframe { | ||
export interface TimelineKeyframe<TContent extends Content = Content> { | ||
/** | ||
@@ -96,4 +96,4 @@ * ID of the Timeline-object. | ||
*/ | ||
content: Content; | ||
content: TContent; | ||
} | ||
//# sourceMappingURL=timeline.d.ts.map |
@@ -7,2 +7,8 @@ /** Point in time, (timestamp) */ | ||
export type ObjectId = string; | ||
export type InstanceId = `@${string}`; | ||
export type ObjectReference = `#${string}`; | ||
export type ClassReference = `.${string}`; | ||
export type LayerReference = `$${string}`; | ||
export type InstanceReference = `@${InstanceId}`; | ||
export type Reference = ObjectReference | ClassReference | LayerReference | InstanceReference; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -53,2 +53,3 @@ "use strict"; | ||
// No timing-affecting changes detected | ||
/* istanbul ignore if */ | ||
if (!oldHash) | ||
@@ -59,6 +60,7 @@ this.debug(`Cache: Object "${obj.id}" is similar`); | ||
const oldObj = this.cache.objects[obj.id]; | ||
/* istanbul ignore if */ | ||
if (!oldObj) { | ||
console.error('oldHash', oldHash); | ||
console.error('ids', Object.keys(this.cache.objects)); | ||
throw new Error(`Internal Error: obj "${obj.id}" not found in cache`); | ||
throw new Error(`Internal Error: obj "${obj.id}" not found in cache, even though hashes match!`); | ||
} | ||
@@ -135,2 +137,3 @@ this.cache.objects[obj.id] = { | ||
if (!this.cache.objects[obj.id]) | ||
/* istanbul ignore next */ | ||
throw new Error(`Something went wrong: "${obj.id}" does not exist in cache.resolvedTimeline.objects`); | ||
@@ -137,0 +140,0 @@ this.resolvedTimeline.objectsMap.set(obj.id, this.cache.objects[obj.id]); |
@@ -136,2 +136,3 @@ "use strict"; | ||
words2Expression(operatorList, words) { | ||
/* istanbul ignore if */ | ||
if (!words?.length) | ||
@@ -138,0 +139,0 @@ throw new Error('words2Expression: syntax error: unbalanced expression'); |
@@ -224,2 +224,3 @@ "use strict"; | ||
return -1; | ||
/* istanbul ignore next */ | ||
return 0; | ||
@@ -265,2 +266,3 @@ }; | ||
return -1; | ||
/* istanbul ignore next */ | ||
return 0; | ||
@@ -293,8 +295,11 @@ }; | ||
return -1; | ||
/* istanbul ignore next */ | ||
if (a.instance.id > b.instance.id) | ||
return 1; | ||
/* istanbul ignore next */ | ||
if (a.instance.id < b.instance.id) | ||
return -1; | ||
/* istanbul ignore next */ | ||
return 0; | ||
}; | ||
//# sourceMappingURL=LayerStateHandler.js.map |
@@ -8,3 +8,3 @@ export declare class Cache { | ||
/** Cache the result of function for a limited time */ | ||
cacheResult<T>(key: string, fcn: () => T, limitTime?: number): T; | ||
cacheResult<T>(key: string, fcn: () => T, limitTime: number): T; | ||
cleanUp(): void; | ||
@@ -11,0 +11,0 @@ clear(): void; |
@@ -14,3 +14,3 @@ "use strict"; | ||
/** Cache the result of function for a limited time */ | ||
cacheResult(key, fcn, limitTime = 10000) { | ||
cacheResult(key, fcn, limitTime) { | ||
const cache = this.cache.get(key); | ||
@@ -25,2 +25,3 @@ if (!cache || cache.ttl < Date.now()) { | ||
this.timeToCueNewCleanup = false; | ||
/* istanbul ignore next */ | ||
this.clearTimeout = setTimeout(() => { | ||
@@ -38,2 +39,3 @@ this.clearTimeout = undefined; | ||
} | ||
/* istanbul ignore next */ | ||
cleanUp() { | ||
@@ -40,0 +42,0 @@ const now = Date.now(); |
@@ -1,3 +0,2 @@ | ||
import { Time, TimelineObjectInstance } from '../../api'; | ||
import { Reference } from './reference'; | ||
import { Time, TimelineObjectInstance, Reference } from '../../api'; | ||
export interface InstanceEvent<T = any> { | ||
@@ -4,0 +3,0 @@ time: Time; |
@@ -1,7 +0,10 @@ | ||
import { Time, InstanceBase, TimelineObjectInstance } from '../../api'; | ||
export type InstanceId = `@${string}`; | ||
import { Time, InstanceBase, TimelineObjectInstance, InstanceId } from '../../api'; | ||
export declare function isInstanceId(str: string): str is InstanceId; | ||
export declare function instanceIsActive(instance: InstanceBase, time: Time): boolean; | ||
export declare function getInstanceUnion(a: InstanceBase, b: InstanceBase): null | InstanceBase; | ||
/** | ||
* Returns the intersection of two instances. | ||
* Example: for (10-20) and (15-30), the intersection is (15-20). | ||
*/ | ||
export declare function getInstanceIntersection(a: InstanceBase, b: InstanceBase): null | InstanceBase; | ||
/** | ||
* Convenience function to splice an array of instances | ||
@@ -15,3 +18,3 @@ * @param instances The array of instances to splice | ||
*/ | ||
export declare function spliceInstances(instances: TimelineObjectInstance[], fcn: (instance: TimelineObjectInstance) => TimelineObjectInstance[] | TimelineObjectInstance | undefined): void; | ||
export declare function spliceInstances<I extends InstanceBase>(instances: I[], fcn: (instance: I) => I[] | I | undefined): void; | ||
export declare function baseInstances(instances: TimelineObjectInstance[]): InstanceBase[]; | ||
@@ -18,0 +21,0 @@ export declare function baseInstance(instance: TimelineObjectInstance): InstanceBase; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getInstanceHash = exports.getInstancesHash = exports.baseInstance = exports.baseInstances = exports.spliceInstances = exports.getInstanceUnion = exports.instanceIsActive = exports.isInstanceId = void 0; | ||
exports.getInstanceHash = exports.getInstancesHash = exports.baseInstance = exports.baseInstances = exports.spliceInstances = exports.getInstanceIntersection = exports.instanceIsActive = exports.isInstanceId = void 0; | ||
const lib_1 = require("./lib"); | ||
@@ -13,3 +13,7 @@ function isInstanceId(str) { | ||
exports.instanceIsActive = instanceIsActive; | ||
function getInstanceUnion(a, b) { | ||
/** | ||
* Returns the intersection of two instances. | ||
* Example: for (10-20) and (15-30), the intersection is (15-20). | ||
*/ | ||
function getInstanceIntersection(a, b) { | ||
if (a.start < (b.end ?? Infinity) && (a.end ?? Infinity) > b.start) { | ||
@@ -25,3 +29,3 @@ const start = Math.max(a.start, b.start); | ||
} | ||
exports.getInstanceUnion = getInstanceUnion; | ||
exports.getInstanceIntersection = getInstanceIntersection; | ||
/** | ||
@@ -28,0 +32,0 @@ * Convenience function to splice an array of instances |
@@ -1,17 +0,11 @@ | ||
import { TimelineObjectInstance } from '../../api'; | ||
import { ClassReference, InstanceId, InstanceReference, LayerReference, ObjectReference, Reference, TimelineObjectInstance } from '../../api'; | ||
import { ValueWithReference } from '../ReferenceHandler'; | ||
import { InstanceId } from './instance'; | ||
export type ObjectReference = `#${string}`; | ||
export declare function isObjectReference(ref: Reference): ref is ObjectReference; | ||
export declare function getRefObjectId(ref: ObjectReference): string; | ||
export type ClassReference = `.${string}`; | ||
export declare function isClassReference(ref: Reference): ref is ClassReference; | ||
export declare function getRefClass(ref: ClassReference): string; | ||
export type LayerReference = `$${string}`; | ||
export declare function isLayerReference(ref: Reference): ref is LayerReference; | ||
export declare function getRefLayer(ref: LayerReference): string; | ||
export type InstanceReference = `@${InstanceId}`; | ||
export declare function isInstanceReference(ref: Reference): ref is InstanceReference; | ||
export declare function getRefInstanceId(ref: InstanceReference): InstanceId; | ||
export type Reference = ObjectReference | ClassReference | LayerReference | InstanceReference; | ||
/** Add / join references Arrays. Returns a sorted list of unique references */ | ||
@@ -18,0 +12,0 @@ export declare function joinReferences(references: Reference[], ...addReferences: Array<Reference[] | Reference>): Reference[]; |
@@ -5,2 +5,6 @@ "use strict"; | ||
const performance_1 = require("./performance"); | ||
/* | ||
* References are strings that are added to instances, | ||
* to indicate what objects, layers or classes they are derived from. | ||
*/ | ||
function isObjectReference(ref) { | ||
@@ -93,2 +97,3 @@ return ref.startsWith('#'); | ||
return -1; | ||
/* istanbul ignore next */ | ||
return 0; | ||
@@ -95,0 +100,0 @@ }); |
import { Expression } from '../api/expression'; | ||
import { ResolvedTimelineObject, TimelineObjectInstance } from '../api/resolvedTimeline'; | ||
import { Reference } from '../api/types'; | ||
import { ResolvedTimelineHandler } from './ResolvedTimelineHandler'; | ||
import { InstanceHandler } from './InstanceHandler'; | ||
import { Reference } from './lib/reference'; | ||
type ObjectRefType = 'start' | 'end' | 'duration'; | ||
@@ -7,0 +7,0 @@ export interface ValueWithReference { |
@@ -187,4 +187,6 @@ "use strict"; | ||
} | ||
else | ||
throw Error(`Unknown ref: "${ref}"`); | ||
else { | ||
/* istanbul ignore next */ | ||
(0, lib_1.assertNever)(ref); | ||
} | ||
for (let i = 0; i < referencedObjs.length; i++) { | ||
@@ -191,0 +193,0 @@ const referencedObj = referencedObjs[i]; |
import { ResolvedTimeline, ResolvedTimelineObject, TimelineObjectInstance } from '../api/resolvedTimeline'; | ||
import { TimelineKeyframe, TimelineObject } from '../api/timeline'; | ||
import { ResolveOptions, ResolverCache } from '../api'; | ||
import { InstanceId } from './lib/instance'; | ||
import { InstanceId, ResolveOptions, ResolverCache } from '../api'; | ||
import { CacheHandler } from './CacheHandler'; | ||
@@ -16,3 +15,3 @@ /** | ||
/** Maps object id to object */ | ||
objectsMap: Map<string, ResolvedTimelineObject>; | ||
objectsMap: Map<string, ResolvedTimelineObject<import("../api").Content>>; | ||
/** Maps className to a list of object ids */ | ||
@@ -19,0 +18,0 @@ classesMap: Map<string, string[]>; |
@@ -100,2 +100,3 @@ "use strict"; | ||
} | ||
/* istanbul ignore if */ | ||
if (this.debug) { | ||
@@ -188,2 +189,3 @@ this.debugTrace(`---------------------------------`); | ||
// Not supported at the moment, perhaps this could be supported in the future. | ||
/* istanbul ignore next */ | ||
throw new Error(`lookupExpression should never return an array for .duration lookup`); | ||
@@ -324,3 +326,4 @@ } | ||
// This is unsupported at the moment, but could possibly be added in the future. | ||
throw new Error(`lookupExpression should never return an array for .duration lookup`); | ||
/* istanbul ignore next */ | ||
throw new Error(`lookedupDuration should never return an array for .duration lookup`); | ||
} | ||
@@ -673,6 +676,9 @@ else if (lookedupDuration !== null) { | ||
} | ||
else if ((0, reference_1.isInstanceReference)(ref)) { | ||
// ignore | ||
else if ( | ||
/* istanbul ignore next */ | ||
(0, reference_1.isInstanceReference)(ref)) { | ||
// do nothing | ||
} | ||
else { | ||
/* istanbul ignore next */ | ||
(0, lib_1.assertNever)(ref); | ||
@@ -716,2 +722,3 @@ } | ||
if (this.objectsMap.has(obj.id)) { | ||
/* istanbul ignore next */ | ||
throw Error(`All timelineObjects must be unique! (duplicate: "${obj.id}")`); | ||
@@ -718,0 +725,0 @@ } |
@@ -32,2 +32,3 @@ "use strict"; | ||
const toc = (0, performance_1.tic)('resolveTimeline'); | ||
/* istanbul ignore if */ | ||
if (this.hasRun) | ||
@@ -97,2 +98,3 @@ throw new Error(`Resolver.resolveTimeline can only run once per instance! | ||
if (parentObj) { | ||
/* istanbul ignore if */ | ||
if (!(0, timeline_1.objHasLayer)(parentObj)) | ||
@@ -99,0 +101,0 @@ continue; // Keyframes of transparent objects are omitted in NextEvents |
@@ -29,2 +29,3 @@ "use strict"; | ||
}; | ||
/* istanbul ignore if */ | ||
if (state.layers[`${obj.layer}`]) { | ||
@@ -65,2 +66,3 @@ // There is already an object on this layer! | ||
return 1; | ||
/* istanbul ignore next */ | ||
return 0; | ||
@@ -67,0 +69,0 @@ }); |
{ | ||
"name": "superfly-timeline", | ||
"version": "9.0.0-nightly-wip-big-rewrite-20230707-073157-387a67a.0", | ||
"version": "9.0.0-nightly-wip-big-rewrite-20230707-094049-a13df02.0", | ||
"description": "A collection of rules as well as a resolver for placing objects on a virtual timeline.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
409260
4304
0