superfly-timeline
Version:
Resolver for defining objects with temporal boolean logic relationships on a timeline
112 lines • 5.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.onCloseCleanup = exports.validateExpression = exports.wrapInnerExpressions = exports.simplifyExpression = exports.interpretExpression = exports.applyKeyframeContent = exports.validateReferenceString = exports.validateKeyframe = exports.validateObject = exports.validateTimeline = exports.getResolvedState = exports.resolveTimeline = exports.ResolveError = void 0;
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./api"), exports);
var Error_1 = require("./resolver/lib/Error");
Object.defineProperty(exports, "ResolveError", { enumerable: true, get: function () { return Error_1.ResolveError; } });
const StateHandler_1 = require("./resolver/StateHandler");
const ExpressionHandler_1 = require("./resolver/ExpressionHandler");
const ResolverHandler_1 = require("./resolver/ResolverHandler");
const TimelineValidator_1 = require("./resolver/TimelineValidator");
/**
* Resolves a timeline, i.e. resolves the references between objects
* and calculates the absolute times for all objects in the timeline.
*/
function resolveTimeline(timeline, options) {
const resolverInstance = new ResolverHandler_1.ResolverHandler(options);
return resolverInstance.resolveTimeline(timeline);
}
exports.resolveTimeline = resolveTimeline;
/**
* Retrieve the state for a certain point in time.
* The state contains all objects that are active at that point in time.
* @param resolvedTimeline
* @param time
* @param eventLimit
*/
function getResolvedState(resolvedTimeline, time, eventLimit = 0) {
const stateHandler = new StateHandler_1.StateHandler();
return stateHandler.getState(resolvedTimeline, time, eventLimit);
}
exports.getResolvedState = getResolvedState;
/**
* Validates all objects in the timeline. Throws an error if something's wrong
* @param timeline The timeline to validate
* @param strict Set to true to enable some optional strict rules. Set this to true to increase future compatibility.
*/
function validateTimeline(timeline, strict) {
const validator = new TimelineValidator_1.TimelineValidator();
validator.validateTimeline(timeline, strict);
}
exports.validateTimeline = validateTimeline;
/**
* Validates a Timeline-object. Throws an error if something's wrong
* @param timeline The timeline to validate
* @param strict Set to true to enable some optional strict rules. Set this to true to increase future compatibility.
*/
function validateObject(obj, strict) {
const validator = new TimelineValidator_1.TimelineValidator();
validator.validateObject(obj, strict);
}
exports.validateObject = validateObject;
/**
* Validates a Timeline-keyframe. Throws an error if something's wrong
* @param timeline The timeline to validate
* @param strict Set to true to enable some optional strict rules. Set this to true to increase future compatibility.
*/
function validateKeyframe(keyframe, strict) {
const validator = new TimelineValidator_1.TimelineValidator();
validator.validateKeyframe(keyframe, strict);
}
exports.validateKeyframe = validateKeyframe;
/**
* Validates a string that is used in Timeline as a reference (an id, a class or layer)
* @param str The string to validate
* @param strict Set to true to enable some optional strict rules. Set this to true to increase future compatibility.
*/
function validateReferenceString(str, strict) {
TimelineValidator_1.TimelineValidator.validateReferenceString(str, strict);
}
exports.validateReferenceString = validateReferenceString;
/**
* Apply keyframe content onto its parent content.
* The keyframe content is deeply-applied onto the parent content.
* Note: This function mutates the parentContent.
*/
function applyKeyframeContent(parentContent, keyframeContent) {
StateHandler_1.StateHandler.applyKeyframeContent(parentContent, keyframeContent);
}
exports.applyKeyframeContent = applyKeyframeContent;
let expressionHandler = undefined;
function getExpressionHandler() {
if (!expressionHandler)
expressionHandler = new ExpressionHandler_1.ExpressionHandler(true);
return expressionHandler;
}
function interpretExpression(expression) {
return getExpressionHandler().interpretExpression(expression);
}
exports.interpretExpression = interpretExpression;
function simplifyExpression(expr0) {
return getExpressionHandler().simplifyExpression(expr0);
}
exports.simplifyExpression = simplifyExpression;
function wrapInnerExpressions(words) {
return getExpressionHandler().wrapInnerExpressions(words);
}
exports.wrapInnerExpressions = wrapInnerExpressions;
function validateExpression(operatorList, expr0, breadcrumbs) {
return getExpressionHandler().validateExpression(operatorList, expr0, breadcrumbs);
}
exports.validateExpression = validateExpression;
/**
* If you have called any of the manual expression-functions, such as interpretExpression(),
* you could call this to manually clean up an internal cache, to ensure your application quits cleanly.
*/
function onCloseCleanup() {
if (expressionHandler)
expressionHandler.clearCache();
}
exports.onCloseCleanup = onCloseCleanup;
//# sourceMappingURL=index.js.map