Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

superfly-timeline

Package Overview
Dependencies
Maintainers
0
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superfly-timeline - npm Package Compare versions

Comparing version 9.0.0 to 9.0.1

5

dist/resolver/CacheHandler.d.ts

@@ -5,3 +5,3 @@ import { ResolvedTimelineObject, ResolverCache } from '../api';

private resolvedTimeline;
/** A Persistant store. This object contains data that is persisted between resolves. */
/** A Persistent store. This object contains data that is persisted between resolves. */
private cache;

@@ -13,5 +13,2 @@ private canUseIncomingCache;

persistData(): void;
private getAllReferencesThisObjectAffects;
/** Invalidate all changed objects, and recursively invalidate all objects that reference those objects */
private invalidateObjectsWithReference;
}

@@ -18,0 +15,0 @@ /** Return a "hash-string" which changes whenever anything that affects timing of a timeline-object has changed. */

182

dist/resolver/CacheHandler.js

@@ -36,9 +36,3 @@ "use strict";

const allNewObjects = {};
const changedReferences = {};
const addChangedObject = (obj) => {
const references = this.getAllReferencesThisObjectAffects(obj);
for (const ref of references) {
changedReferences[ref] = true;
}
};
const changedTracker = new ChangedTracker();
for (const obj of this.resolvedTimeline.objectsMap.values()) {

@@ -58,6 +52,6 @@ const oldHash = this.cache.objHashes[obj.id];

this.cache.objHashes[obj.id] = newHash;
addChangedObject(obj);
changedTracker.addChangedObject(obj);
const oldObj = this.cache.objects[obj.id];
if (oldObj)
addChangedObject(oldObj);
changedTracker.addChangedObject(oldObj);
}

@@ -90,19 +84,18 @@ else {

delete this.cache.objHashes[objId];
addChangedObject(obj);
changedTracker.addChangedObject(obj);
}
}
// Invalidate objects, by gradually removing the invalidated ones from validObjects
// Prepare validObjects:
const validObjects = {};
// At this point, all directly changed objects have been marked as changed.
// Next step is to invalidate any indirectly affected objects, by gradually removing the invalidated ones from validObjects
// Prepare the invalidator, ie populate it with the objects that are still valid:
const invalidator = new Invalidator();
for (const obj of this.resolvedTimeline.objectsMap.values()) {
validObjects[obj.id] = obj;
invalidator.addValidObject(obj);
}
/** All references that depend on another reference (ie objects, classs or layers): */
const affectReferenceMap = {};
for (const obj of this.resolvedTimeline.objectsMap.values()) {
// Add everything that this object affects:
const cachedObj = this.cache.objects[obj.id];
let affectedReferences = this.getAllReferencesThisObjectAffects(obj);
let affectedReferences = getAllReferencesThisObjectAffects(obj);
if (cachedObj) {
affectedReferences = (0, reference_1.joinReferences)(affectedReferences, this.getAllReferencesThisObjectAffects(cachedObj));
affectedReferences = (0, reference_1.joinReferences)(affectedReferences, getAllReferencesThisObjectAffects(cachedObj));
}

@@ -113,13 +106,12 @@ for (let i = 0; i < affectedReferences.length; i++) {

if (ref !== objRef) {
if (!affectReferenceMap[objRef])
affectReferenceMap[objRef] = [];
affectReferenceMap[objRef].push(ref);
invalidator.addAffectedReference(objRef, ref);
}
}
// Add everything that this object is affected by:
if (changedReferences[`#${obj.id}`]) {
// The object is directly said to be invalid, no need to add it to referencingObjects,
// since it'll be easily invalidated anyway later
if (changedTracker.isChanged(`#${obj.id}`)) {
// The object is directly said to have changed.
}
else {
// The object is not directly said to have changed.
// But if might have been affected by other objects that have changed.
// Note: we only have to check for the OLD object, since if the old and the new object differs,

@@ -132,7 +124,9 @@ // that would mean it'll be directly invalidated anyway.

const dependOnReferences = cachedObj.resolved.directReferences;
// Build up objectLayerMap:
if ((0, timeline_1.objHasLayer)(cachedObj)) {
invalidator.addObjectOnLayer(`${cachedObj.layer}`, obj);
}
for (let i = 0; i < dependOnReferences.length; i++) {
const ref = dependOnReferences[i];
if (!affectReferenceMap[ref])
affectReferenceMap[ref] = [];
affectReferenceMap[ref].push(`#${obj.id}`);
invalidator.addAffectedReference(ref, `#${obj.id}`);
}

@@ -143,9 +137,8 @@ }

// Invalidate all changed objects, and recursively invalidate all objects that reference those objects:
const handledReferences = {};
for (const reference of Object.keys(changedReferences)) {
this.invalidateObjectsWithReference(handledReferences, reference, affectReferenceMap, validObjects);
for (const reference of changedTracker.listChanged()) {
invalidator.invalidateObjectsWithReference(reference);
}
// The objects that are left in validObjects at this point are still valid.
// At this point, the objects that are left in validObjects are still valid (ie has not changed or is affected by any others).
// We can reuse the old resolving for those:
for (const obj of Object.values(validObjects)) {
for (const obj of invalidator.getValidObjects()) {
if (!this.cache.objects[obj.id])

@@ -173,35 +166,105 @@ /* istanbul ignore next */

}
getAllReferencesThisObjectAffects(newObj) {
const references = [`#${newObj.id}`];
if (newObj.classes) {
for (const className of newObj.classes) {
references.push(`.${className}`);
}
}
exports.CacheHandler = CacheHandler;
/** Return a "hash-string" which changes whenever anything that affects timing of a timeline-object has changed. */
function hashTimelineObject(obj) {
/*
Note: The following properties are ignored, as they don't affect timing or resolving:
* id
* children
* keyframes
* isGroup
* content
*/
return `${JSON.stringify(obj.enable)},${+!!obj.disabled},${obj.priority}',${obj.resolved.parentId},${+obj.resolved
.isKeyframe},${obj.classes ? obj.classes.join('.') : ''},${obj.layer},${+!!obj.seamless}`;
}
exports.hashTimelineObject = hashTimelineObject;
function getAllReferencesThisObjectAffects(newObj) {
const references = [`#${newObj.id}`];
if (newObj.classes) {
for (const className of newObj.classes) {
references.push(`.${className}`);
}
if ((0, timeline_1.objHasLayer)(newObj))
references.push(`$${newObj.layer}`);
if (newObj.children) {
for (const child of newObj.children) {
references.push(`#${child.id}`);
}
}
if ((0, timeline_1.objHasLayer)(newObj))
references.push(`$${newObj.layer}`);
if (newObj.children) {
for (const child of newObj.children) {
references.push(`#${child.id}`);
}
return references;
}
return references;
}
class ChangedTracker {
constructor() {
this.changedReferences = new Set();
}
addChangedObject(obj) {
const references = getAllReferencesThisObjectAffects(obj);
for (const ref of references) {
this.changedReferences.add(ref);
}
if ((0, timeline_1.objHasLayer)(obj)) {
this.changedReferences.add(`$${obj.layer}`);
}
}
isChanged(ref) {
return this.changedReferences.has(ref);
}
listChanged() {
return this.changedReferences.keys();
}
}
/** The Invalidator */
class Invalidator {
constructor() {
this.handledReferences = {};
/** All references that depend on another reference (ie objects, class or layers): */
this.affectReferenceMap = {};
this.validObjects = {};
/** Map of which objects can be affected by any other object, per layer */
this.objectLayerMap = {};
}
addValidObject(obj) {
this.validObjects[obj.id] = obj;
}
getValidObjects() {
return Object.values(this.validObjects);
}
addObjectOnLayer(layer, obj) {
if (!this.objectLayerMap[layer])
this.objectLayerMap[layer] = [];
this.objectLayerMap[layer].push(obj.id);
}
addAffectedReference(objRef, ref) {
if (!this.affectReferenceMap[objRef])
this.affectReferenceMap[objRef] = [];
this.affectReferenceMap[objRef].push(ref);
}
/** Invalidate all changed objects, and recursively invalidate all objects that reference those objects */
invalidateObjectsWithReference(handledReferences, reference, affectReferenceMap, validObjects) {
if (handledReferences[reference])
invalidateObjectsWithReference(reference) {
if (this.handledReferences[reference])
return; // to avoid infinite loops
handledReferences[reference] = true;
this.handledReferences[reference] = true;
if ((0, reference_1.isObjectReference)(reference)) {
const objId = (0, reference_1.getRefObjectId)(reference);
if (validObjects[objId]) {
delete validObjects[objId];
if (this.validObjects[objId]) {
delete this.validObjects[objId];
}
}
if ((0, reference_1.isLayerReference)(reference)) {
const layer = (0, reference_1.getRefLayer)(reference);
if (this.objectLayerMap[layer]) {
for (const affectedObjId of this.objectLayerMap[layer]) {
this.invalidateObjectsWithReference(`#${affectedObjId}`);
}
}
}
// Invalidate all objects that depend on any of the references that this reference affects:
const affectedReferences = affectReferenceMap[reference];
const affectedReferences = this.affectReferenceMap[reference];
if (affectedReferences) {
for (let i = 0; i < affectedReferences.length; i++) {
const referencingReference = affectedReferences[i];
this.invalidateObjectsWithReference(handledReferences, referencingReference, affectReferenceMap, validObjects);
this.invalidateObjectsWithReference(referencingReference);
}

@@ -211,17 +274,2 @@ }

}
exports.CacheHandler = CacheHandler;
/** Return a "hash-string" which changes whenever anything that affects timing of a timeline-object has changed. */
function hashTimelineObject(obj) {
/*
Note: The following properties are ignored, as they don't affect timing or resolving:
* id
* children
* keyframes
* isGroup
* content
*/
return `${JSON.stringify(obj.enable)},${+!!obj.disabled},${obj.priority}',${obj.resolved.parentId},${+obj.resolved
.isKeyframe},${obj.classes ? obj.classes.join('.') : ''},${obj.layer},${+!!obj.seamless}`;
}
exports.hashTimelineObject = hashTimelineObject;
//# sourceMappingURL=CacheHandler.js.map

@@ -7,3 +7,5 @@ import { TimelineObject } from '../../api';

*/
export declare function objHasLayer(obj: TimelineObject): boolean;
export declare function objHasLayer(obj: TimelineObject): obj is TimelineObject & {
layer: TimelineObject['layer'];
};
//# sourceMappingURL=timeline.d.ts.map

@@ -186,3 +186,3 @@ "use strict";

else {
// Loop up references to the parent:
// Look up references to the parent:
let parentInstances = null;

@@ -189,0 +189,0 @@ let hasParent = false;

{
"name": "superfly-timeline",
"version": "9.0.0",
"version": "9.0.1",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc