superfly-timeline
Advanced tools
Comparing version 8.2.8 to 8.3.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [8.3.0](https://github.com/SuperFlyTV/supertimeline/compare/8.2.8...8.3.0) (2022-10-05) | ||
### Features | ||
* add validateIdString() function, used to ensure that id, classes and layers doesn't contain any invalid characters ([ecd0ae7](https://github.com/SuperFlyTV/supertimeline/commit/ecd0ae76565af89c744fd38981b75f50a8e82260)) | ||
### Bug Fixes | ||
* validate ids, classes and layer string, to avoid possible crashes when resolving the timeline ([e7b9114](https://github.com/SuperFlyTV/supertimeline/commit/e7b911450869bb2d4726a338f5ce5ea613237cf5)) | ||
### [8.2.8](https://github.com/SuperFlyTV/supertimeline/compare/8.2.3...8.2.8) (2022-06-13) | ||
@@ -7,0 +19,0 @@ |
export * from './api/enums'; | ||
export * from './api/api'; | ||
export { Resolver } from './resolver/resolver'; | ||
export { validateTimeline, validateObject, validateKeyframe } from './resolver/validate'; | ||
export { validateTimeline, validateObject, validateKeyframe, validateIdString } from './resolver/validate'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateKeyframe = exports.validateObject = exports.validateTimeline = exports.Resolver = void 0; | ||
exports.validateIdString = exports.validateKeyframe = exports.validateObject = exports.validateTimeline = exports.Resolver = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -13,2 +13,3 @@ (0, tslib_1.__exportStar)(require("./api/enums"), exports); | ||
Object.defineProperty(exports, "validateKeyframe", { enumerable: true, get: function () { return validate_1.validateKeyframe; } }); | ||
Object.defineProperty(exports, "validateIdString", { enumerable: true, get: function () { return validate_1.validateIdString; } }); | ||
//# sourceMappingURL=index.js.map |
import { Expression, ExpressionObj } from '../api/api'; | ||
export declare const OPERATORS: string[]; | ||
export declare const REGEXP_OPERATORS: RegExp; | ||
export declare function interpretExpression(expression: null): null; | ||
@@ -4,0 +5,0 @@ export declare function interpretExpression(expression: number): number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateExpression = exports.wrapInnerExpressions = exports.simplifyExpression = exports.interpretExpression = exports.OPERATORS = void 0; | ||
exports.validateExpression = exports.wrapInnerExpressions = exports.simplifyExpression = exports.interpretExpression = exports.REGEXP_OPERATORS = exports.OPERATORS = void 0; | ||
const _ = require("underscore"); | ||
const lib_1 = require("../lib"); | ||
exports.OPERATORS = ['&', '|', '+', '-', '*', '/', '%', '!']; | ||
const REGEXP_OPERATORS = _.map(exports.OPERATORS, (o) => '\\' + o).join(''); | ||
exports.REGEXP_OPERATORS = new RegExp('([' + _.map(exports.OPERATORS, (o) => '\\' + o).join('') + '\\(\\)])', 'g'); | ||
function interpretExpression(expression) { | ||
@@ -15,3 +15,3 @@ if ((0, lib_1.isNumeric)(expression)) { | ||
return (0, lib_1.cacheResult)(expressionString, () => { | ||
const expr = expressionString.replace(new RegExp('([' + REGEXP_OPERATORS + '\\(\\)])', 'g'), ' $1 '); // Make sure there's a space between every operator & operand | ||
const expr = expressionString.replace(exports.REGEXP_OPERATORS, ' $1 '); // Make sure there's a space between every operator & operand | ||
const words = _.compact(expr.split(' ')); | ||
@@ -18,0 +18,0 @@ if (words.length === 0) |
@@ -20,2 +20,8 @@ import { TimelineObject, TimelineKeyframe } from '../api/api'; | ||
export declare function validateKeyframe(keyframe: TimelineKeyframe, strict?: boolean): void; | ||
/** | ||
* 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 strict rules (rules that can possibly be ignored) | ||
*/ | ||
export declare function validateIdString(str: string, strict?: boolean): void; | ||
//# sourceMappingURL=validate.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateKeyframe = exports.validateObject = exports.validateTimeline = void 0; | ||
exports.validateIdString = exports.validateKeyframe = exports.validateObject = exports.validateTimeline = void 0; | ||
const _ = require("underscore"); | ||
const expression_1 = require("./expression"); | ||
function validateObject0(obj, strict, uniqueIds) { | ||
@@ -16,2 +17,8 @@ if (!uniqueIds) | ||
throw new Error(`Object "id" attribute is not a string: "${obj.id}"`); | ||
try { | ||
validateIdString(obj.id, strict); | ||
} | ||
catch (err) { | ||
throw new Error(`Object "id" attribute: ${err}`); | ||
} | ||
if (uniqueIds[obj.id]) | ||
@@ -22,2 +29,8 @@ throw new Error(`Object id "${obj.id}" is not unique`); | ||
throw new Error(`Object "${obj.id}": "layer" attribute is undefined`); | ||
try { | ||
validateIdString(obj.layer + '', strict); | ||
} | ||
catch (err) { | ||
throw new Error(`Object "${obj.id}": "layer" attribute: ${err}`); | ||
} | ||
if (!obj.content) | ||
@@ -61,2 +74,8 @@ throw new Error(`Object "${obj.id}": "content" attribute must be set`); | ||
throw new Error(`Object "${obj.id}": "classes[${i}]" is not a string`); | ||
try { | ||
validateIdString(className, strict); | ||
} | ||
catch (err) { | ||
throw new Error(`Object "${obj.id}": "classes[${i}]": ${err}`); | ||
} | ||
} | ||
@@ -157,2 +176,37 @@ } | ||
exports.validateKeyframe = validateKeyframe; | ||
/** These characters are reserved and cannot be used in ids, etc */ | ||
const RESERVED_CHARACTERS = /[#.$]/; | ||
/** These characters are reserved for possible future use and cannot be used in ids, etc */ | ||
const FUTURE_RESERVED_CHARACTERS = /[=?@{}[\]^§]/; | ||
/** | ||
* 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 strict rules (rules that can possibly be ignored) | ||
*/ | ||
function validateIdString(str, strict) { | ||
if (!str) | ||
return; | ||
{ | ||
const m = str.match(expression_1.REGEXP_OPERATORS); | ||
if (m) { | ||
throw new Error(`The string "${str}" contains a character ("${m[1]}") which isn't allowed in Timeline (is an operator)`); | ||
} | ||
} | ||
{ | ||
const m = str.match(RESERVED_CHARACTERS); | ||
if (m) { | ||
throw new Error(`The string "${str}" contains a character ("${m[1]}") which isn't allowed in Timeline (is a reserved character)`); | ||
} | ||
} | ||
if (strict) { | ||
// Also check a few characters that are technically allowed today, but *might* become used in future versions of Timeline: | ||
{ | ||
const m = str.match(FUTURE_RESERVED_CHARACTERS); | ||
if (m) { | ||
throw new Error(`The string "${str}" contains a character ("${m[0]}") which isn't allowed in Timeline (is an reserved character and might be used in the future)`); | ||
} | ||
} | ||
} | ||
} | ||
exports.validateIdString = validateIdString; | ||
//# sourceMappingURL=validate.js.map |
{ | ||
"name": "superfly-timeline", | ||
"version": "8.2.8", | ||
"version": "8.3.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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
309386
2953