@glissade/lottie 0.57.1-pre.0 → 0.58.0-pre.0
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/index.js +36 -11
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Circle, Group, ImageNode, Path, Rect, Text, breakLines, createScene, meshRasterSize, rasterizeMesh } from "@glissade/scene";
|
|
2
2
|
import { compileTimeline, cubicBezier, formatColor, parseColor, sampleTrack, track } from "@glissade/core";
|
|
3
3
|
import { Camera, cameraLayerMatrix, shakenSpec } from "@glissade/scene/motion";
|
|
4
|
+
import { densifyStops } from "@glissade/scene/gradient";
|
|
4
5
|
import "@glissade/core/expr";
|
|
5
6
|
//#region src/spec.ts
|
|
6
7
|
var LottieImportError = class extends Error {
|
|
@@ -2485,8 +2486,9 @@ function buildFill(ctx, node, tracks, ind) {
|
|
|
2485
2486
|
ctx.warn(`${describe(node)}: a mesh fill has no Lottie gradient ramp (MVP: solid / linear / radial) — dropped`);
|
|
2486
2487
|
return;
|
|
2487
2488
|
}
|
|
2488
|
-
|
|
2489
|
-
|
|
2489
|
+
const stops = exportStops(fill);
|
|
2490
|
+
warnGradientInterpolation(ctx, node, fill, stops);
|
|
2491
|
+
return gradientFillItem(fill, localBounds(node), stops);
|
|
2490
2492
|
}
|
|
2491
2493
|
/**
|
|
2492
2494
|
* Rasterize a STATIC (or first-key-flattened) mesh Paint to a PNG and emit it as a
|
|
@@ -2630,16 +2632,38 @@ function gradientStopArray(stops) {
|
|
|
2630
2632
|
}
|
|
2631
2633
|
return anyAlpha ? [...colors, ...alphas] : colors;
|
|
2632
2634
|
}
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
+
/**
|
|
2636
|
+
* Densify a gradient's stops for export exactly as the render path does: `smooth`/
|
|
2637
|
+
* `gaussian` → a GRADIENT_RAMP_STEPS-stop oklab ramp; `linear`/undefined → the input
|
|
2638
|
+
* unchanged (byte-identical). Pure + deterministic (no RNG), so export stays reproducible.
|
|
2639
|
+
*/
|
|
2640
|
+
function exportStops(g) {
|
|
2641
|
+
return g.interpolation ? densifyStops(g.stops, g.interpolation) : g.stops;
|
|
2635
2642
|
}
|
|
2636
|
-
/**
|
|
2637
|
-
|
|
2643
|
+
/**
|
|
2644
|
+
* NEVER-SILENT guard for a non-linear gradient. The `gf` has no smooth/gaussian mode, so
|
|
2645
|
+
* we honor it by densifying the ramp into a GRADIENT_RAMP_STEPS-stop oklab approximation
|
|
2646
|
+
* (see exportStops) — the same ramp the render path uses, round-tripping at perceptual
|
|
2647
|
+
* parity (SSIM ~1.0). When densification APPLIES, the mode is faithfully honored, so we
|
|
2648
|
+
* stay SILENT — a warn there would be spurious noise firing on a mode we actually respected
|
|
2649
|
+
* (a stale warn is its own never-silent-adjacent bug). We warn ONLY on the genuine fallback:
|
|
2650
|
+
* a degenerate gradient (<2 stops or a non-positive offset span) the densifier can't resample,
|
|
2651
|
+
* which really does emit a hard linear ramp — that divergence must not be silent.
|
|
2652
|
+
*/
|
|
2653
|
+
function warnGradientInterpolation(ctx, node, g, resolved) {
|
|
2654
|
+
const mode = g.interpolation;
|
|
2655
|
+
if (mode === void 0 || mode === "linear") return;
|
|
2656
|
+
if (resolved.length > g.stops.length) return;
|
|
2657
|
+
ctx.warn(`${describe(node)}: '${mode}' gradient interpolation could not be densified (needs ≥2 stops over a positive offset span) — emitted as a hard linear ramp; mid-stop banding may differ`);
|
|
2658
|
+
}
|
|
2659
|
+
/** A static linear/radial gradient → a `gf` shape item (geometry from `bounds`). Stops are
|
|
2660
|
+
* already resolved (densified for smooth/gaussian) by the caller. */
|
|
2661
|
+
function gradientFillItem(g, bounds, stops) {
|
|
2638
2662
|
const gk = {
|
|
2639
|
-
p:
|
|
2663
|
+
p: stops.length,
|
|
2640
2664
|
k: {
|
|
2641
2665
|
a: 0,
|
|
2642
|
-
k: gradientStopArray(
|
|
2666
|
+
k: gradientStopArray(stops)
|
|
2643
2667
|
}
|
|
2644
2668
|
};
|
|
2645
2669
|
const s = gradientStart(g, bounds);
|
|
@@ -2719,11 +2743,12 @@ function buildAnimatedGradientFill(ctx, node, tr, ind) {
|
|
|
2719
2743
|
color: "#000000"
|
|
2720
2744
|
}]
|
|
2721
2745
|
};
|
|
2722
|
-
|
|
2723
|
-
|
|
2746
|
+
const firstStops = exportStops(first);
|
|
2747
|
+
warnGradientInterpolation(ctx, node, first, firstStops);
|
|
2748
|
+
const p = firstStops.length;
|
|
2724
2749
|
const sMap = (v) => gradientStart(asGradient(v), bounds);
|
|
2725
2750
|
const eMap = (v) => gradientEnd(asGradient(v), bounds);
|
|
2726
|
-
const gMap = (v) => gradientStopArray(asGradient(v)
|
|
2751
|
+
const gMap = (v) => gradientStopArray(exportStops(asGradient(v)));
|
|
2727
2752
|
let sK;
|
|
2728
2753
|
let eK;
|
|
2729
2754
|
let gK;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glissade/lottie",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0-pre.0",
|
|
4
4
|
"description": "glissade Lottie import (S1 MVP): pure .json (Lottie/bodymovin) → node specs + a v1 Timeline. Fail-fast feature audit; no DOM/Node dependencies.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"engines": {
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@glissade/core": "0.
|
|
22
|
-
"@glissade/scene": "0.
|
|
21
|
+
"@glissade/core": "0.58.0-pre.0",
|
|
22
|
+
"@glissade/scene": "0.58.0-pre.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@glissade/backend-skia": "0.
|
|
25
|
+
"@glissade/backend-skia": "0.58.0-pre.0"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|