@glissade/core 0.12.0-pre.0 → 0.12.0-pre.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.
- package/dist/clips.js +24 -2
- package/package.json +1 -1
package/dist/clips.js
CHANGED
|
@@ -18,6 +18,28 @@ var ClipError = class extends Error {
|
|
|
18
18
|
this.name = "ClipError";
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Guard a clip override VALUE against the channel's resolved type. `compileChannel`
|
|
23
|
+
* infers the channel type from the ORIGINAL first key, then substitutes the
|
|
24
|
+
* override `from`/`to`. `validateTrack` only checks key TIMES, never value shapes,
|
|
25
|
+
* so a mismatched override (e.g. a number on a `vec2` channel) would otherwise
|
|
26
|
+
* sample to NaN through evaluate() into both backends with no warning. This asserts
|
|
27
|
+
* the override value's inferred type matches the channel — the only place a clip
|
|
28
|
+
* can introduce a wrong-shaped value. `color`/`string` are treated as one family:
|
|
29
|
+
* `inferValueType` can't tell a plain string from a color string, so we never
|
|
30
|
+
* reject a string override on a string-shaped channel.
|
|
31
|
+
*/
|
|
32
|
+
function assertOverrideType(target, resolvedType, value) {
|
|
33
|
+
let got;
|
|
34
|
+
try {
|
|
35
|
+
got = inferValueType(value);
|
|
36
|
+
} catch {
|
|
37
|
+
throw new ClipError(`clip override for '${target}' has an un-typeable value ${JSON.stringify(value)} (channel type '${resolvedType}')`);
|
|
38
|
+
}
|
|
39
|
+
const stringFamily = (t) => t === "color" || t === "string";
|
|
40
|
+
if (!(got === resolvedType || stringFamily(got) && stringFamily(resolvedType))) throw new ClipError(`clip override for '${target}' is a '${got}' value but the channel is '${resolvedType}' (${JSON.stringify(value)}); a mismatched override samples to NaN`);
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
21
43
|
function channelDuration(ch) {
|
|
22
44
|
return ch.keys.length === 0 ? 0 : ch.keys[ch.keys.length - 1].t;
|
|
23
45
|
}
|
|
@@ -47,8 +69,8 @@ function compileChannel(target, ch, startSec, speed, override) {
|
|
|
47
69
|
return track(target, type, ch.keys.map((k, i) => {
|
|
48
70
|
let value = k.value;
|
|
49
71
|
if (override) {
|
|
50
|
-
if (i === 0 && override.from !== void 0) value = override.from;
|
|
51
|
-
if (i === lastIdx && override.to !== void 0) value = override.to;
|
|
72
|
+
if (i === 0 && override.from !== void 0) value = assertOverrideType(target, type, override.from);
|
|
73
|
+
if (i === lastIdx && override.to !== void 0) value = assertOverrideType(target, type, override.to);
|
|
52
74
|
}
|
|
53
75
|
const out = {
|
|
54
76
|
t: startSec + k.t / speed,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissade/core",
|
|
3
|
-
"version": "0.12.0-pre.
|
|
3
|
+
"version": "0.12.0-pre.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": {
|