@glissade/core 0.41.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/expr.js +14 -3
  2. package/package.json +1 -1
package/dist/expr.js CHANGED
@@ -37,7 +37,10 @@ const rand = (x) => {
37
37
  const CONSTS = {
38
38
  PI: Math.PI,
39
39
  TAU: Math.PI * 2,
40
- E: Math.E
40
+ E: Math.E,
41
+ pi: Math.PI,
42
+ tau: Math.PI * 2,
43
+ e: Math.E
41
44
  };
42
45
  const FNS = {
43
46
  sin: {
@@ -327,7 +330,11 @@ function compileExpr(source) {
327
330
  }
328
331
  /** The names available to an expression (for docs / a describe() surface). */
329
332
  const EXPR_FUNCTIONS = Object.keys(FNS);
330
- const EXPR_CONSTANTS = Object.keys(CONSTS);
333
+ const EXPR_CONSTANTS = [
334
+ "PI",
335
+ "TAU",
336
+ "E"
337
+ ];
331
338
  /**
332
339
  * A raw formula-driven numeric track — `exprTrack('circle/opacity', '0.5 +
333
340
  * 0.5*sin(t*3)')`. Sampled by evaluating the formula at the playhead `t` (no
@@ -338,7 +345,11 @@ function exprTrack(target, formula) {
338
345
  }
339
346
  setExprCompiler((src) => {
340
347
  const c = compileExpr(src);
341
- return (t) => c.eval({ t });
348
+ return (t) => {
349
+ const v = c.eval({ t });
350
+ if (!Number.isFinite(v)) throw new ExprError(`expr '${src}' evaluated to ${v} at t=${t} — a formula must produce a finite number (division by zero, sqrt of a negative, etc.)`);
351
+ return v;
352
+ };
342
353
  });
343
354
  //#endregion
344
355
  export { EXPR_CONSTANTS, EXPR_FUNCTIONS, ExprError, compileExpr, exprTrack };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/core",
3
- "version": "0.41.0",
3
+ "version": "0.41.1",
4
4
  "description": "glissade core: signals, tracks, timeline document, evaluation, easing, springs, seeded RNG. Zero DOM/Node dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {