@pixodesk/svg-animator-react 1.0.26 → 1.0.28
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.umd.js +1046 -676
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -1815,114 +1815,582 @@ var PixodeskAnimatorReact = (() => {
|
|
|
1815
1815
|
return a;
|
|
1816
1816
|
};
|
|
1817
1817
|
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
1818
|
-
function
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1818
|
+
function bezierToSvgPath(path, forceCurves = false) {
|
|
1819
|
+
var _a, _b, _c, _d;
|
|
1820
|
+
const v = path.v;
|
|
1821
|
+
const i = path.i;
|
|
1822
|
+
const o = path.o;
|
|
1823
|
+
const c = path.c;
|
|
1824
|
+
if (!v.length) return "";
|
|
1825
|
+
const d = [];
|
|
1826
|
+
const len = v.length;
|
|
1827
|
+
d.push("M" + v[0][0] + "," + v[0][1]);
|
|
1828
|
+
for (let idx = 1; idx < len; idx++) {
|
|
1829
|
+
const prevV = v[idx - 1];
|
|
1830
|
+
const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
|
|
1831
|
+
const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
|
|
1832
|
+
const currV = v[idx];
|
|
1833
|
+
const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
|
|
1834
|
+
if (isLine) {
|
|
1835
|
+
d.push("L" + currV[0] + "," + currV[1]);
|
|
1836
|
+
} else {
|
|
1837
|
+
d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
|
|
1838
|
+
}
|
|
1830
1839
|
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1840
|
+
if (c && len > 0) {
|
|
1841
|
+
const lastV = v[len - 1];
|
|
1842
|
+
const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
|
|
1843
|
+
const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
|
|
1844
|
+
const firstV = v[0];
|
|
1845
|
+
const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
|
|
1846
|
+
if (!isLine) {
|
|
1847
|
+
d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
|
|
1848
|
+
}
|
|
1849
|
+
d.push("z");
|
|
1833
1850
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1851
|
+
return d.join("");
|
|
1852
|
+
}
|
|
1853
|
+
function interpolateNum(a, b, t) {
|
|
1854
|
+
return a + (b - a) * t;
|
|
1855
|
+
}
|
|
1856
|
+
function interpolateVec(a, b, t) {
|
|
1857
|
+
const res = [];
|
|
1858
|
+
const count = Math.max(a.length, b.length);
|
|
1859
|
+
for (let i = 0; i < count; i++) {
|
|
1860
|
+
res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
|
|
1840
1861
|
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1862
|
+
return res;
|
|
1863
|
+
}
|
|
1864
|
+
function interpolateColor(a, b, t) {
|
|
1865
|
+
return [
|
|
1866
|
+
interpolateNum(a[0] || 0, b[0] || 0, t),
|
|
1867
|
+
interpolateNum(a[1] || 0, b[1] || 0, t),
|
|
1868
|
+
interpolateNum(a[2] || 0, b[2] || 0, t),
|
|
1869
|
+
interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
|
|
1870
|
+
];
|
|
1871
|
+
}
|
|
1872
|
+
function interpolateBeziers(paths1, paths2, progress) {
|
|
1873
|
+
const count = Math.max(paths1.length, paths2.length);
|
|
1874
|
+
const res = [];
|
|
1875
|
+
for (let i = 0; i < count; i++) {
|
|
1876
|
+
res.push(interpolateBezier(paths1[i], paths2[i], progress));
|
|
1844
1877
|
}
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1878
|
+
return res;
|
|
1879
|
+
}
|
|
1880
|
+
function interpolateBezier(path1, path2, progress) {
|
|
1881
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1882
|
+
if (!path1 || !path2) return path1 || path2 || { v: [] };
|
|
1883
|
+
const t = Math.min(Math.max(progress, 0), 1);
|
|
1884
|
+
const len = Math.min(path1.v.length, path2.v.length);
|
|
1885
|
+
const v = [];
|
|
1886
|
+
const i = [];
|
|
1887
|
+
const o = [];
|
|
1888
|
+
for (let idx = 0; idx < len; idx++) {
|
|
1889
|
+
const v1 = path1.v[idx];
|
|
1890
|
+
const v2 = path2.v[idx];
|
|
1891
|
+
v.push(interpolateVec(v1, v2, t));
|
|
1892
|
+
const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
|
|
1893
|
+
const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
|
|
1894
|
+
i.push(interpolateVec(i1, i2, t));
|
|
1895
|
+
const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
|
|
1896
|
+
const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
|
|
1897
|
+
o.push(interpolateVec(o1, o2, t));
|
|
1848
1898
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1899
|
+
return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
|
|
1900
|
+
}
|
|
1901
|
+
function remap(value, inMin, inMax, outMin, outMax) {
|
|
1902
|
+
if (inMax === inMin) return outMin;
|
|
1903
|
+
const t = (value - inMin) / (inMax - inMin);
|
|
1904
|
+
return outMin + t * (outMax - outMin);
|
|
1905
|
+
}
|
|
1906
|
+
function solveCubicBezierX(p1x, p2x, x) {
|
|
1907
|
+
if (x <= 0) return 0;
|
|
1908
|
+
if (x >= 1) return 1;
|
|
1909
|
+
const cx = 3 * p1x;
|
|
1910
|
+
const bx = 3 * (p2x - p1x) - cx;
|
|
1911
|
+
const ax = 1 - cx - bx;
|
|
1912
|
+
function sampleX(t) {
|
|
1913
|
+
return ((ax * t + bx) * t + cx) * t;
|
|
1851
1914
|
}
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
constructor(_default = "") {
|
|
1855
|
-
super();
|
|
1856
|
-
this._default = _default;
|
|
1915
|
+
function sampleDX(t) {
|
|
1916
|
+
return (3 * ax * t + 2 * bx) * t + cx;
|
|
1857
1917
|
}
|
|
1858
|
-
|
|
1859
|
-
|
|
1918
|
+
let t2 = x;
|
|
1919
|
+
let t0 = 0;
|
|
1920
|
+
let t1 = 1;
|
|
1921
|
+
for (let i = 0; i < 8; i++) {
|
|
1922
|
+
const x2 = sampleX(t2) - x;
|
|
1923
|
+
if (Math.abs(x2) < 1e-6) return t2;
|
|
1924
|
+
const d2 = sampleDX(t2);
|
|
1925
|
+
if (Math.abs(d2) < 1e-6) break;
|
|
1926
|
+
t2 -= x2 / d2;
|
|
1860
1927
|
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
return
|
|
1928
|
+
t2 = x;
|
|
1929
|
+
while (t0 < t1) {
|
|
1930
|
+
const x2 = sampleX(t2);
|
|
1931
|
+
if (Math.abs(x2 - x) < 1e-6) return t2;
|
|
1932
|
+
if (x > x2) t0 = t2;
|
|
1933
|
+
else t1 = t2;
|
|
1934
|
+
t2 = (t1 + t0) / 2;
|
|
1865
1935
|
}
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1936
|
+
return t2;
|
|
1937
|
+
}
|
|
1938
|
+
function cubicBezier(easing) {
|
|
1939
|
+
const [p1x, p1y, p2x, p2y] = easing;
|
|
1940
|
+
const cy = 3 * p1y;
|
|
1941
|
+
const by = 3 * (p2y - p1y) - cy;
|
|
1942
|
+
const ay = 1 - cy - by;
|
|
1943
|
+
function sampleCurveY(t) {
|
|
1944
|
+
return ((ay * t + by) * t + cy) * t;
|
|
1871
1945
|
}
|
|
1872
|
-
|
|
1873
|
-
return
|
|
1946
|
+
return function(x) {
|
|
1947
|
+
return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1950
|
+
function lerp2(a, b, t) {
|
|
1951
|
+
return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
1952
|
+
}
|
|
1953
|
+
function subdivideCubicBezier(p0, p1, p2, p3, t) {
|
|
1954
|
+
const q0 = lerp2(p0, p1, t);
|
|
1955
|
+
const q1 = lerp2(p1, p2, t);
|
|
1956
|
+
const q2 = lerp2(p2, p3, t);
|
|
1957
|
+
const r0 = lerp2(q0, q1, t);
|
|
1958
|
+
const r1 = lerp2(q1, q2, t);
|
|
1959
|
+
const s = lerp2(r0, r1, t);
|
|
1960
|
+
return {
|
|
1961
|
+
left: [p0, q0, r0, s],
|
|
1962
|
+
right: [s, r1, q2, p3]
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
function splitEasing(easing, xFraction) {
|
|
1966
|
+
if (!easing) return { left: void 0, right: void 0 };
|
|
1967
|
+
if (xFraction <= 0) return { left: void 0, right: easing };
|
|
1968
|
+
if (xFraction >= 1) return { left: easing, right: void 0 };
|
|
1969
|
+
const [x1, y1, x2, y2] = easing;
|
|
1970
|
+
const t = solveCubicBezierX(x1, x2, xFraction);
|
|
1971
|
+
const p0 = [0, 0];
|
|
1972
|
+
const p1 = [x1, y1];
|
|
1973
|
+
const p2 = [x2, y2];
|
|
1974
|
+
const p3 = [1, 1];
|
|
1975
|
+
const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
|
|
1976
|
+
const sx = left[3][0];
|
|
1977
|
+
const sy = left[3][1];
|
|
1978
|
+
let leftEasing;
|
|
1979
|
+
if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
|
|
1980
|
+
leftEasing = [
|
|
1981
|
+
left[1][0] / sx,
|
|
1982
|
+
left[1][1] / sy,
|
|
1983
|
+
left[2][0] / sx,
|
|
1984
|
+
left[2][1] / sy
|
|
1985
|
+
];
|
|
1874
1986
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1987
|
+
let rightEasing;
|
|
1988
|
+
const rx = 1 - sx;
|
|
1989
|
+
const ry = 1 - sy;
|
|
1990
|
+
if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
|
|
1991
|
+
rightEasing = [
|
|
1992
|
+
(right[1][0] - sx) / rx,
|
|
1993
|
+
(right[1][1] - sy) / ry,
|
|
1994
|
+
(right[2][0] - sx) / rx,
|
|
1995
|
+
(right[2][1] - sy) / ry
|
|
1996
|
+
];
|
|
1879
1997
|
}
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1998
|
+
return { left: leftEasing, right: rightEasing };
|
|
1999
|
+
}
|
|
2000
|
+
function reverseEasing(easing) {
|
|
2001
|
+
if (!easing) return void 0;
|
|
2002
|
+
return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
|
|
2003
|
+
}
|
|
2004
|
+
function toRGBA(color) {
|
|
2005
|
+
const r = Math.round(color[0] * 255);
|
|
2006
|
+
const g = Math.round(color[1] * 255);
|
|
2007
|
+
const b = Math.round(color[2] * 255);
|
|
2008
|
+
return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
|
|
2009
|
+
}
|
|
2010
|
+
function parseRgba(s) {
|
|
2011
|
+
var _a;
|
|
2012
|
+
const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
|
|
2013
|
+
if (!inner) throw new Error("Invalid rgb/rgba format");
|
|
2014
|
+
const parts = inner.split(",").map((v) => +v.trim());
|
|
2015
|
+
return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
|
|
2016
|
+
}
|
|
2017
|
+
function parseHex(s) {
|
|
2018
|
+
const hex = s.slice(1);
|
|
2019
|
+
const isShort = hex.length <= 4;
|
|
2020
|
+
const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
|
|
2021
|
+
const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
|
|
2022
|
+
const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
|
|
2023
|
+
const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
|
|
2024
|
+
const result = [
|
|
2025
|
+
parseInt(r, 16) / 255,
|
|
2026
|
+
parseInt(g, 16) / 255,
|
|
2027
|
+
parseInt(b, 16) / 255
|
|
2028
|
+
];
|
|
2029
|
+
if (a !== null) {
|
|
2030
|
+
result.push(parseInt(a, 16) / 255);
|
|
1885
2031
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
2032
|
+
return result;
|
|
2033
|
+
}
|
|
2034
|
+
function parseColor(s) {
|
|
2035
|
+
if (!s) return void 0;
|
|
2036
|
+
if (Array.isArray(s)) return s;
|
|
2037
|
+
if (typeof s !== "string") return void 0;
|
|
2038
|
+
if (s.startsWith("#")) {
|
|
2039
|
+
return parseHex(s);
|
|
2040
|
+
} else if (s.startsWith("rgb")) {
|
|
2041
|
+
return parseRgba(s);
|
|
2042
|
+
} else {
|
|
2043
|
+
console.warn("Unsupported color format: " + s);
|
|
1888
2044
|
}
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
2045
|
+
return void 0;
|
|
2046
|
+
}
|
|
2047
|
+
var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
2048
|
+
var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
2049
|
+
var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
2050
|
+
function composeTransformParts(parts, opts) {
|
|
2051
|
+
var _a;
|
|
2052
|
+
if (!parts) return "";
|
|
2053
|
+
const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
|
|
2054
|
+
const segs = [];
|
|
2055
|
+
const t = parts.translate;
|
|
2056
|
+
const o = parts.origin;
|
|
2057
|
+
const r = parts.rotate;
|
|
2058
|
+
const k = parts.skew;
|
|
2059
|
+
const s = parts.scale;
|
|
2060
|
+
const tu = withUnits ? "px" : "";
|
|
2061
|
+
const ru = withUnits ? "deg" : "";
|
|
2062
|
+
if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
|
|
2063
|
+
if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
|
|
2064
|
+
if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
|
|
2065
|
+
if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
|
|
2066
|
+
if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
|
|
2067
|
+
if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
|
|
2068
|
+
return segs.join("");
|
|
2069
|
+
}
|
|
2070
|
+
var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
2071
|
+
var DEFAULT_DURATION_MS = 1e3;
|
|
2072
|
+
function kebabToCamelCaseWord(kebab) {
|
|
2073
|
+
return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
|
|
2074
|
+
}
|
|
2075
|
+
function isCamelCaseWord(word) {
|
|
2076
|
+
return !word.includes("-") && /[a-z][A-Z]/.test(word);
|
|
2077
|
+
}
|
|
2078
|
+
var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
|
|
2079
|
+
// Transform/positioning
|
|
2080
|
+
"viewBox",
|
|
2081
|
+
"preserveAspectRatio",
|
|
2082
|
+
// Gradient
|
|
2083
|
+
"gradientUnits",
|
|
2084
|
+
"gradientTransform",
|
|
2085
|
+
"spreadMethod",
|
|
2086
|
+
// Pattern
|
|
2087
|
+
"patternUnits",
|
|
2088
|
+
"patternContentUnits",
|
|
2089
|
+
"patternTransform",
|
|
2090
|
+
// Clipping/masking
|
|
2091
|
+
"clipPathUnits",
|
|
2092
|
+
"maskUnits",
|
|
2093
|
+
"maskContentUnits",
|
|
2094
|
+
// Marker (SVG spec keeps these camelCase, like viewBox)
|
|
2095
|
+
"markerUnits",
|
|
2096
|
+
"markerWidth",
|
|
2097
|
+
"markerHeight",
|
|
2098
|
+
"refX",
|
|
2099
|
+
"refY",
|
|
2100
|
+
// Text
|
|
2101
|
+
"textLength",
|
|
2102
|
+
"lengthAdjust",
|
|
2103
|
+
"startOffset",
|
|
2104
|
+
// Filter
|
|
2105
|
+
"filterUnits",
|
|
2106
|
+
"primitiveUnits",
|
|
2107
|
+
"tableValues",
|
|
2108
|
+
// feFuncR/G/B/A transfer table (type="table")
|
|
2109
|
+
"stdDeviation",
|
|
2110
|
+
"baseFrequency",
|
|
2111
|
+
"numOctaves",
|
|
2112
|
+
"surfaceScale",
|
|
2113
|
+
"diffuseConstant",
|
|
2114
|
+
"specularConstant",
|
|
2115
|
+
"specularExponent",
|
|
2116
|
+
"kernelMatrix",
|
|
2117
|
+
"kernelUnitLength",
|
|
2118
|
+
"edgeMode",
|
|
2119
|
+
"preserveAlpha",
|
|
2120
|
+
"targetX",
|
|
2121
|
+
"targetY"
|
|
2122
|
+
// // Animation
|
|
2123
|
+
// 'attributeName',
|
|
2124
|
+
// 'attributeType',
|
|
2125
|
+
// 'calcMode',
|
|
2126
|
+
// 'keyTimes',
|
|
2127
|
+
// 'keySplines',
|
|
2128
|
+
// 'repeatCount',
|
|
2129
|
+
// 'repeatDur'
|
|
2130
|
+
]);
|
|
2131
|
+
function camelCaseToKebabWordIfNeeded(camel) {
|
|
2132
|
+
return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2133
|
+
}
|
|
2134
|
+
function clamp(value, min, max) {
|
|
2135
|
+
return Math.max(min, Math.min(value, max));
|
|
2136
|
+
}
|
|
2137
|
+
function bezier2D_pointAt(P0, P1, P2, P3, t) {
|
|
2138
|
+
if (t <= 0) return [P0[0], P0[1]];
|
|
2139
|
+
if (t >= 1) return [P3[0], P3[1]];
|
|
2140
|
+
const u = 1 - t;
|
|
2141
|
+
const u2 = u * u;
|
|
2142
|
+
const u3 = u2 * u;
|
|
2143
|
+
const t2 = t * t;
|
|
2144
|
+
const t3 = t2 * t;
|
|
2145
|
+
const w0 = u3;
|
|
2146
|
+
const w1 = 3 * t * u2;
|
|
2147
|
+
const w2 = 3 * t2 * u;
|
|
2148
|
+
const w3 = t3;
|
|
2149
|
+
return [
|
|
2150
|
+
w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
|
|
2151
|
+
w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
|
|
2152
|
+
];
|
|
2153
|
+
}
|
|
2154
|
+
var BEZIER_T_NUDGE = 1e-4;
|
|
2155
|
+
function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
|
|
2156
|
+
const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
|
|
2157
|
+
if (result[0] === 0 && result[1] === 0) {
|
|
2158
|
+
const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
|
|
2159
|
+
return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
|
|
2160
|
+
}
|
|
2161
|
+
return result;
|
|
2162
|
+
}
|
|
2163
|
+
function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
|
|
2164
|
+
const u = 1 - t;
|
|
2165
|
+
const a = 3 * u * u;
|
|
2166
|
+
const b = 6 * t * u;
|
|
2167
|
+
const c = 3 * t * t;
|
|
2168
|
+
return [
|
|
2169
|
+
a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
|
|
2170
|
+
a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
|
|
2171
|
+
];
|
|
2172
|
+
}
|
|
2173
|
+
function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
|
|
2174
|
+
const n = steps + 1;
|
|
2175
|
+
const ts = new Float64Array(n);
|
|
2176
|
+
const ds = new Float64Array(n);
|
|
2177
|
+
let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
|
|
2178
|
+
ts[0] = 0;
|
|
2179
|
+
ds[0] = 0;
|
|
2180
|
+
let cum = 0;
|
|
2181
|
+
for (let i = 1; i < n; i++) {
|
|
2182
|
+
const t = i / steps;
|
|
2183
|
+
const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
|
|
2184
|
+
const dx = cur[0] - prev[0];
|
|
2185
|
+
const dy = cur[1] - prev[1];
|
|
2186
|
+
cum += Math.sqrt(dx * dx + dy * dy);
|
|
2187
|
+
ts[i] = t;
|
|
2188
|
+
ds[i] = cum;
|
|
2189
|
+
prev = cur;
|
|
2190
|
+
}
|
|
2191
|
+
return { ts, ds };
|
|
2192
|
+
}
|
|
2193
|
+
function bezier2D_tForDistance(lut, distance) {
|
|
2194
|
+
const { ts, ds } = lut;
|
|
2195
|
+
const last = ds.length - 1;
|
|
2196
|
+
if (distance <= 0) return ts[0];
|
|
2197
|
+
if (distance >= ds[last]) return ts[last];
|
|
2198
|
+
let lo = 1;
|
|
2199
|
+
let hi = last;
|
|
2200
|
+
while (lo < hi) {
|
|
2201
|
+
const mid = lo + hi >>> 1;
|
|
2202
|
+
if (ds[mid] < distance) lo = mid + 1;
|
|
2203
|
+
else hi = mid;
|
|
2204
|
+
}
|
|
2205
|
+
const dPrev = ds[hi - 1];
|
|
2206
|
+
const dCur = ds[hi];
|
|
2207
|
+
const span = dCur - dPrev;
|
|
2208
|
+
const frac = span > 0 ? (distance - dPrev) / span : 0;
|
|
2209
|
+
return ts[hi - 1] + frac * (ts[hi] - ts[hi - 1]);
|
|
2210
|
+
}
|
|
2211
|
+
function bezier2D_arcAtT(lut, t) {
|
|
2212
|
+
const { ts, ds } = lut;
|
|
2213
|
+
const last = ts.length - 1;
|
|
2214
|
+
if (t <= ts[0]) return ds[0];
|
|
2215
|
+
if (t >= ts[last]) return ds[last];
|
|
2216
|
+
let lo = 1, hi = last;
|
|
2217
|
+
while (lo < hi) {
|
|
2218
|
+
const mid = lo + hi >>> 1;
|
|
2219
|
+
if (ts[mid] < t) lo = mid + 1;
|
|
2220
|
+
else hi = mid;
|
|
2221
|
+
}
|
|
2222
|
+
const tPrev = ts[hi - 1];
|
|
2223
|
+
const span = ts[hi] - tPrev;
|
|
2224
|
+
const frac = span > 0 ? (t - tPrev) / span : 0;
|
|
2225
|
+
return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
|
|
2226
|
+
}
|
|
2227
|
+
function invertEasing(easing) {
|
|
2228
|
+
if (!easing) return (y) => y;
|
|
2229
|
+
const flipped = [easing[1], easing[0], easing[3], easing[2]];
|
|
2230
|
+
return cubicBezier(flipped);
|
|
2231
|
+
}
|
|
2232
|
+
function isScrollTimeline(config) {
|
|
2233
|
+
return (config == null ? void 0 : config.timelineSource) === "scroll";
|
|
2234
|
+
}
|
|
2235
|
+
function scrollTotalDurationMs(config) {
|
|
2236
|
+
const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : DEFAULT_DURATION_MS;
|
|
2237
|
+
const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
|
|
2238
|
+
return duration * iterations;
|
|
2239
|
+
}
|
|
2240
|
+
function scrollPhaseInterval(phase, subjectSize, scrollportSize) {
|
|
2241
|
+
const s = subjectSize, vp = scrollportSize;
|
|
2242
|
+
switch (phase) {
|
|
2243
|
+
case "cover":
|
|
2244
|
+
return [0, s + vp];
|
|
2245
|
+
case "entry":
|
|
2246
|
+
return [0, Math.min(s, vp)];
|
|
2247
|
+
case "contain":
|
|
2248
|
+
return [Math.min(s, vp), Math.max(s, vp)];
|
|
2249
|
+
case "exit":
|
|
2250
|
+
return [Math.max(s, vp), s + vp];
|
|
2251
|
+
case "entry-crossing":
|
|
2252
|
+
return [0, s];
|
|
2253
|
+
case "exit-crossing":
|
|
2254
|
+
return [vp, s + vp];
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
var DEFAULT_PHASE = "cover";
|
|
2258
|
+
function resolveRangePointU(point, defaultFraction, subjectSize, scrollportSize) {
|
|
2259
|
+
var _a;
|
|
2260
|
+
const [u0, u1] = scrollPhaseInterval((_a = point == null ? void 0 : point.phase) != null ? _a : DEFAULT_PHASE, subjectSize, scrollportSize);
|
|
2261
|
+
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
2262
|
+
return u0 + fraction * (u1 - u0);
|
|
2263
|
+
}
|
|
2264
|
+
function scrollViewProgress(subjectStart, subjectSize, scrollportSize, range) {
|
|
2265
|
+
const u = scrollportSize - subjectStart;
|
|
2266
|
+
const uStart = resolveRangePointU(range == null ? void 0 : range.start, 0, subjectSize, scrollportSize);
|
|
2267
|
+
const uEnd = resolveRangePointU(range == null ? void 0 : range.end, 1, subjectSize, scrollportSize);
|
|
2268
|
+
if (uEnd <= uStart) return u >= uEnd ? 1 : 0;
|
|
2269
|
+
return clamp((u - uStart) / (uEnd - uStart), 0, 1);
|
|
2270
|
+
}
|
|
2271
|
+
function scrollOffsetProgress(offset, maxOffset, range) {
|
|
2272
|
+
var _a, _b;
|
|
2273
|
+
const raw = maxOffset > 0 ? clamp(offset / maxOffset, 0, 1) : 1;
|
|
2274
|
+
const start = typeof ((_a = range == null ? void 0 : range.start) == null ? void 0 : _a.fraction) === "number" ? range.start.fraction : 0;
|
|
2275
|
+
const end = typeof ((_b = range == null ? void 0 : range.end) == null ? void 0 : _b.fraction) === "number" ? range.end.fraction : 1;
|
|
2276
|
+
if (end <= start) return raw >= end ? 1 : 0;
|
|
2277
|
+
return clamp((raw - start) / (end - start), 0, 1);
|
|
2278
|
+
}
|
|
2279
|
+
function scrollResolveAxis(axis, writingMode) {
|
|
2280
|
+
const a = axis != null ? axis : "block";
|
|
2281
|
+
if (a === "x" || a === "y") return a;
|
|
2282
|
+
const vertical = !!writingMode && writingMode.startsWith("vertical");
|
|
2283
|
+
if (a === "inline") return vertical ? "y" : "x";
|
|
2284
|
+
return vertical ? "x" : "y";
|
|
2285
|
+
}
|
|
2286
|
+
function pathStr(path) {
|
|
2287
|
+
if (!path.length) return ".";
|
|
2288
|
+
let result = "";
|
|
2289
|
+
for (const seg of path) {
|
|
2290
|
+
if (seg.startsWith("[")) result += seg;
|
|
2291
|
+
else result += (result ? "." : "") + seg;
|
|
2292
|
+
}
|
|
2293
|
+
return result;
|
|
2294
|
+
}
|
|
2295
|
+
var Base = class {
|
|
2296
|
+
_canSanitize(raw) {
|
|
2297
|
+
return this.isValid(raw);
|
|
2298
|
+
}
|
|
2299
|
+
optional() {
|
|
2300
|
+
return new Optional(this);
|
|
1893
2301
|
}
|
|
1894
2302
|
};
|
|
1895
|
-
var
|
|
1896
|
-
constructor(
|
|
2303
|
+
var Optional = class extends Base {
|
|
2304
|
+
constructor(inner) {
|
|
1897
2305
|
super();
|
|
1898
|
-
this.
|
|
1899
|
-
this._default =
|
|
2306
|
+
this.inner = inner;
|
|
2307
|
+
this._default = void 0;
|
|
1900
2308
|
}
|
|
1901
2309
|
sanitize(raw) {
|
|
1902
|
-
|
|
2310
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
2311
|
+
return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
|
|
1903
2312
|
}
|
|
1904
2313
|
isValid(raw, ctx, path) {
|
|
1905
|
-
if (raw ===
|
|
1906
|
-
|
|
1907
|
-
|
|
2314
|
+
if (raw === void 0 || raw === null) return true;
|
|
2315
|
+
return this.inner.isValid(raw, ctx, path);
|
|
2316
|
+
}
|
|
2317
|
+
_canSanitize(raw) {
|
|
2318
|
+
return raw === void 0 || raw === null || this.inner._canSanitize(raw);
|
|
1908
2319
|
}
|
|
1909
2320
|
};
|
|
1910
|
-
var
|
|
1911
|
-
constructor(
|
|
2321
|
+
var Str = class extends Base {
|
|
2322
|
+
constructor(_default = "") {
|
|
1912
2323
|
super();
|
|
1913
|
-
this.
|
|
1914
|
-
this._default = defaultVal != null ? defaultVal : values[0];
|
|
2324
|
+
this._default = _default;
|
|
1915
2325
|
}
|
|
1916
2326
|
sanitize(raw) {
|
|
1917
|
-
return
|
|
2327
|
+
return typeof raw === "string" ? raw : this._default;
|
|
1918
2328
|
}
|
|
1919
2329
|
isValid(raw, ctx, path) {
|
|
1920
|
-
if (
|
|
1921
|
-
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected
|
|
2330
|
+
if (typeof raw === "string") return true;
|
|
2331
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected string, got " + typeof raw);
|
|
1922
2332
|
return false;
|
|
1923
2333
|
}
|
|
1924
2334
|
};
|
|
1925
|
-
var
|
|
2335
|
+
var Num = class extends Base {
|
|
2336
|
+
constructor(_default = 0) {
|
|
2337
|
+
super();
|
|
2338
|
+
this._default = _default;
|
|
2339
|
+
}
|
|
2340
|
+
sanitize(raw) {
|
|
2341
|
+
return typeof raw === "number" && isFinite(raw) ? raw : this._default;
|
|
2342
|
+
}
|
|
2343
|
+
isValid(raw, ctx, path) {
|
|
2344
|
+
if (typeof raw === "number" && isFinite(raw)) return true;
|
|
2345
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected finite number, got " + JSON.stringify(raw));
|
|
2346
|
+
return false;
|
|
2347
|
+
}
|
|
2348
|
+
};
|
|
2349
|
+
var Bool = class extends Base {
|
|
2350
|
+
constructor(_default = false) {
|
|
2351
|
+
super();
|
|
2352
|
+
this._default = _default;
|
|
2353
|
+
}
|
|
2354
|
+
sanitize(raw) {
|
|
2355
|
+
return typeof raw === "boolean" ? raw : this._default;
|
|
2356
|
+
}
|
|
2357
|
+
isValid(raw, ctx, path) {
|
|
2358
|
+
if (typeof raw === "boolean") return true;
|
|
2359
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected boolean, got " + typeof raw);
|
|
2360
|
+
return false;
|
|
2361
|
+
}
|
|
2362
|
+
};
|
|
2363
|
+
var Literal = class extends Base {
|
|
2364
|
+
constructor(value) {
|
|
2365
|
+
super();
|
|
2366
|
+
this.value = value;
|
|
2367
|
+
this._default = value;
|
|
2368
|
+
}
|
|
2369
|
+
sanitize(raw) {
|
|
2370
|
+
return raw === this.value ? this.value : this._default;
|
|
2371
|
+
}
|
|
2372
|
+
isValid(raw, ctx, path) {
|
|
2373
|
+
if (raw === this.value) return true;
|
|
2374
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected " + JSON.stringify(this.value) + ", got " + JSON.stringify(raw));
|
|
2375
|
+
return false;
|
|
2376
|
+
}
|
|
2377
|
+
};
|
|
2378
|
+
var Enum = class extends Base {
|
|
2379
|
+
constructor(values, defaultVal) {
|
|
2380
|
+
super();
|
|
2381
|
+
this.values = values;
|
|
2382
|
+
this._default = defaultVal != null ? defaultVal : values[0];
|
|
2383
|
+
}
|
|
2384
|
+
sanitize(raw) {
|
|
2385
|
+
return this.values.includes(raw) ? raw : this._default;
|
|
2386
|
+
}
|
|
2387
|
+
isValid(raw, ctx, path) {
|
|
2388
|
+
if (this.values.includes(raw)) return true;
|
|
2389
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected one of " + this.values.map((v) => JSON.stringify(v)).join(" | ") + ", got " + JSON.stringify(raw));
|
|
2390
|
+
return false;
|
|
2391
|
+
}
|
|
2392
|
+
};
|
|
2393
|
+
var Union = class extends Base {
|
|
1926
2394
|
constructor(schemas, defaultVal) {
|
|
1927
2395
|
super();
|
|
1928
2396
|
this.schemas = schemas;
|
|
@@ -2459,6 +2927,28 @@ var PixodeskAnimatorReact = (() => {
|
|
|
2459
2927
|
styles: px.record(px.any()).optional(),
|
|
2460
2928
|
glyphs: px.record(PxGlyphFontSchema).optional()
|
|
2461
2929
|
}));
|
|
2930
|
+
var PX_SCROLL_PHASES = ["cover", "contain", "entry", "exit", "entry-crossing", "exit-crossing"];
|
|
2931
|
+
var PxScrollRangePointSchema = implementsInterface()(px.object({
|
|
2932
|
+
phase: px.enum(PX_SCROLL_PHASES).optional(),
|
|
2933
|
+
fraction: px.number().optional()
|
|
2934
|
+
}));
|
|
2935
|
+
var PxScrollRangeSchema = px.object({
|
|
2936
|
+
start: PxScrollRangePointSchema.optional(),
|
|
2937
|
+
end: PxScrollRangePointSchema.optional()
|
|
2938
|
+
});
|
|
2939
|
+
var PxScrollSchema = implementsInterface()(px.object({
|
|
2940
|
+
driver: px.enum(["custom", "native"]).optional(),
|
|
2941
|
+
kind: px.enum(["view", "scroll"]).optional(),
|
|
2942
|
+
axis: px.enum(["block", "inline", "x", "y"]).optional(),
|
|
2943
|
+
source: px.enum(["nearest", "root"]).optional(),
|
|
2944
|
+
// Free-form: the two keywords `parent`/`scroller` plus any CSS selector.
|
|
2945
|
+
subject: px.string().optional(),
|
|
2946
|
+
smoothing: px.number().optional(),
|
|
2947
|
+
pin: px.boolean().optional(),
|
|
2948
|
+
pinTop: px.number().optional(),
|
|
2949
|
+
pinDistance: px.number().optional(),
|
|
2950
|
+
range: PxScrollRangeSchema.optional()
|
|
2951
|
+
}));
|
|
2462
2952
|
var PxAnimatorConfigSchema = implementsInterface()(px.object({
|
|
2463
2953
|
mode: px.enum([PxAnimatorMode.auto, PxAnimatorMode.waapi, PxAnimatorMode.frames]).optional(),
|
|
2464
2954
|
duration: px.number().optional(),
|
|
@@ -2474,607 +2964,194 @@ var PixodeskAnimatorReact = (() => {
|
|
|
2474
2964
|
definitions: PxDefsSchema.optional(),
|
|
2475
2965
|
animateById: px.record(PxElementAnimationSchema).optional(),
|
|
2476
2966
|
timelineSource: px.string().optional(),
|
|
2967
|
+
scroll: PxScrollSchema.optional(),
|
|
2477
2968
|
debugInstName: px.string().optional()
|
|
2478
2969
|
}));
|
|
2479
2970
|
var PxBindingSchema = implementsInterface()(px.object({
|
|
2480
2971
|
id: px.string(),
|
|
2481
2972
|
animate: PxElementAnimationSchema
|
|
2482
|
-
}));
|
|
2483
|
-
var PxAttrValueSchema = px.union([
|
|
2484
|
-
px.string(),
|
|
2485
|
-
px.number(),
|
|
2486
|
-
px.array(px.number()),
|
|
2487
|
-
// Structured static — `{value: …}` (read-accepted transitional spelling, S1).
|
|
2488
|
-
// `defined`, not `any`: the KEY's presence is what identifies this branch (V6).
|
|
2489
|
-
px.object({ value: px.defined() }),
|
|
2490
|
-
// Bare transform parts record — the canonical static `transform` on the wire (T2).
|
|
2491
|
-
PxTransformPartsSchema
|
|
2492
|
-
]);
|
|
2493
|
-
var PxAnimatableNumberSchema = px.union([
|
|
2494
|
-
px.number(),
|
|
2495
|
-
px.object({ value: px.number() }),
|
|
2496
|
-
PxPropertyAnimationSchema
|
|
2497
|
-
]);
|
|
2498
|
-
var PxAnimatableVec2Schema = px.union([
|
|
2499
|
-
px.tuple([px.number(), px.number()]),
|
|
2500
|
-
px.object({ value: px.tuple([px.number(), px.number()]) }),
|
|
2501
|
-
PxPropertyAnimationSchema
|
|
2502
|
-
]);
|
|
2503
|
-
var PxAnimatableStringSchema = px.union([
|
|
2504
|
-
px.string(),
|
|
2505
|
-
px.object({ value: px.string() }),
|
|
2506
|
-
PxPropertyAnimationSchema
|
|
2507
|
-
]);
|
|
2508
|
-
var PxTransformByEffectSchema = implementsInterface()(px.object({
|
|
2509
|
-
translate: PxAnimatableVec2Schema.optional(),
|
|
2510
|
-
rotate: PxAnimatableNumberSchema.optional(),
|
|
2511
|
-
scale: PxAnimatableVec2Schema.optional(),
|
|
2512
|
-
skew: PxAnimatableNumberSchema.optional(),
|
|
2513
|
-
origin: PxAnimatableVec2Schema.optional()
|
|
2514
|
-
}));
|
|
2515
|
-
var PxRepeaterEffectSchema = implementsInterface()(px.object({
|
|
2516
|
-
// STATIC config, not a channel (V2/SCHEMA-DESIGN R5): the copy COUNT is read
|
|
2517
|
-
// once at expansion time and never sampled — plain number, no `keyframes`.
|
|
2518
|
-
copies: px.number().optional(),
|
|
2519
|
-
translate: PxAnimatableVec2Schema.optional(),
|
|
2520
|
-
rotate: PxAnimatableNumberSchema.optional(),
|
|
2521
|
-
skew: PxAnimatableNumberSchema.optional(),
|
|
2522
|
-
scale: PxAnimatableVec2Schema.optional(),
|
|
2523
|
-
origin: PxAnimatableVec2Schema.optional()
|
|
2524
|
-
}));
|
|
2525
|
-
var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
2526
|
-
sourceId: px.string().optional(),
|
|
2527
|
-
maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
|
|
2528
|
-
maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
2529
|
-
maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
2530
|
-
x: px.number().optional(),
|
|
2531
|
-
y: px.number().optional(),
|
|
2532
|
-
width: px.number().optional(),
|
|
2533
|
-
height: px.number().optional()
|
|
2534
|
-
}));
|
|
2535
|
-
var PxClipPathEffectSchema = implementsInterface()(px.object({
|
|
2536
|
-
d: PxAnimatableStringSchema.optional(),
|
|
2537
|
-
animate: PxPropertyAnimationSchema.optional()
|
|
2538
|
-
}));
|
|
2539
|
-
var PxTrimPathEffectSchema = implementsInterface()(px.object({
|
|
2540
|
-
offset: PxAnimatableNumberSchema.optional(),
|
|
2541
|
-
range: PxAnimatableVec2Schema.optional(),
|
|
2542
|
-
subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
|
|
2543
|
-
}));
|
|
2544
|
-
var PxRetimeEffectSchema = implementsInterface()(px.object({
|
|
2545
|
-
sourceId: px.string().optional(),
|
|
2546
|
-
start: px.number().optional(),
|
|
2547
|
-
stretch: px.number().optional(),
|
|
2548
|
-
timeCrop: px.tuple([px.number(), px.number()]).optional()
|
|
2549
|
-
}));
|
|
2550
|
-
var PxCloneEffectSchema = implementsInterface()(px.object({
|
|
2551
|
-
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
2552
|
-
type: px.enum([PxCloneType.content]).optional(),
|
|
2553
|
-
sourceId: px.string().optional(),
|
|
2554
|
-
retime: PxRetimeEffectSchema.optional()
|
|
2555
|
-
}));
|
|
2556
|
-
var PxGradientStopSchema = implementsInterface()(px.object({
|
|
2557
|
-
offset: px.number(),
|
|
2558
|
-
color: px.string()
|
|
2559
|
-
}));
|
|
2560
|
-
var PxAnimatableGradientStopsSchema = px.union([
|
|
2561
|
-
px.array(PxGradientStopSchema),
|
|
2562
|
-
px.object({ value: px.array(PxGradientStopSchema) }),
|
|
2563
|
-
PxPropertyAnimationSchema
|
|
2564
|
-
]);
|
|
2565
|
-
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
2566
|
-
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
2567
|
-
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
2568
|
-
p1: PxAnimatableVec2Schema.optional(),
|
|
2569
|
-
p2: PxAnimatableVec2Schema.optional(),
|
|
2570
|
-
c: PxAnimatableVec2Schema.optional(),
|
|
2571
|
-
r: PxAnimatableNumberSchema.optional(),
|
|
2572
|
-
fp: PxAnimatableVec2Schema.optional(),
|
|
2573
|
-
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
2574
|
-
gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
|
|
2575
|
-
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
|
|
2576
|
-
gradientTransform: px.string().optional()
|
|
2577
|
-
}));
|
|
2578
|
-
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
2579
|
-
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
2580
|
-
path: px.string(),
|
|
2581
|
-
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
|
|
2582
|
-
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
|
|
2583
|
-
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
|
|
2584
|
-
spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
|
|
2585
|
-
startOffset: PxAnimatableNumberSchema.optional(),
|
|
2586
|
-
textLength: PxAnimatableNumberSchema.optional()
|
|
2587
|
-
}));
|
|
2588
|
-
var PxTextEffectSchema = implementsInterface()(px.object({
|
|
2589
|
-
useGlyphs: px.boolean().optional()
|
|
2590
|
-
}));
|
|
2591
|
-
var PxEffectsSchema = implementsInterface()(px.object({
|
|
2592
|
-
transformBy: PxTransformByEffectSchema.optional(),
|
|
2593
|
-
repeater: PxRepeaterEffectSchema.optional(),
|
|
2594
|
-
maskedBy: PxMaskedByEffectSchema.optional(),
|
|
2595
|
-
clipPath: PxClipPathEffectSchema.optional(),
|
|
2596
|
-
trimPath: PxTrimPathEffectSchema.optional(),
|
|
2597
|
-
clone: PxCloneEffectSchema.optional(),
|
|
2598
|
-
fillGradient: PxFillGradientEffectSchema.optional(),
|
|
2599
|
-
strokeGradient: PxStrokeGradientEffectSchema.optional(),
|
|
2600
|
-
textPath: PxTextPathEffectSchema.optional(),
|
|
2601
|
-
text: PxTextEffectSchema.optional()
|
|
2602
|
-
}));
|
|
2603
|
-
function validateNodeEffects(root, opts) {
|
|
2604
|
-
const warnings = [];
|
|
2605
|
-
const walk = (node, path) => {
|
|
2606
|
-
if (node && node.effects) {
|
|
2607
|
-
const ctx = { errors: [], warnings: [], strict: !!(opts == null ? void 0 : opts.strict) };
|
|
2608
|
-
const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
|
|
2609
|
-
if (!ok) {
|
|
2610
|
-
for (const err of ctx.errors) warnings.push(err);
|
|
2611
|
-
}
|
|
2612
|
-
}
|
|
2613
|
-
if (node && Array.isArray(node.children)) {
|
|
2614
|
-
node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]"));
|
|
2615
|
-
}
|
|
2616
|
-
};
|
|
2617
|
-
walk(root, "root");
|
|
2618
|
-
return warnings;
|
|
2619
|
-
}
|
|
2620
|
-
var PxNodeBase = px.openObject({
|
|
2621
|
-
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
2622
|
-
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
2623
|
-
// (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
|
|
2624
|
-
// `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
|
|
2625
|
-
// the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
|
|
2626
|
-
// would add words that all mean "type" and still need the carrier to read.
|
|
2627
|
-
// Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
|
|
2628
|
-
// (issues V3), never of distinct key names.
|
|
2629
|
-
type: px.string(),
|
|
2630
|
-
id: px.string().optional(),
|
|
2631
|
-
meta: px.any().optional(),
|
|
2632
|
-
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
2633
|
-
// Consumed and removed by `applyPlayerEffects` before any other normalisation
|
|
2634
|
-
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
2635
|
-
effects: PxEffectsSchema.optional(),
|
|
2636
|
-
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
2637
|
-
// string ref / array of refs / inline definition / mixed array; mirrors
|
|
2638
|
-
// `animator.animateById` map values and what `processNode` resolves at runtime.
|
|
2639
|
-
animate: PxElementAnimationSchema.optional(),
|
|
2640
|
-
style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
|
|
2641
|
-
}, PxAttrValueSchema);
|
|
2642
|
-
var PxNodeSchema = px.openObject(__spreadProps2(__spreadValues2({}, PxNodeBase._shape), {
|
|
2643
|
-
children: px.lazy(() => px.array(PxNodeSchema), []).optional()
|
|
2644
|
-
}), PxAttrValueSchema);
|
|
2645
|
-
var PxSvgNodeExtra = px.object({
|
|
2646
|
-
// `"100%"` and other SVG length strings are legal here — a number-only slot rejected
|
|
2647
|
-
// real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
|
|
2648
|
-
width: px.union([px.number(), px.string()]).optional(),
|
|
2649
|
-
height: px.union([px.number(), px.string()]).optional(),
|
|
2650
|
-
viewBox: px.string().optional(),
|
|
2651
|
-
animator: PxAnimatorConfigSchema.optional()
|
|
2652
|
-
});
|
|
2653
|
-
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps2(__spreadValues2(__spreadValues2({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
|
|
2654
|
-
type: px.literal("svg"),
|
|
2655
|
-
// override string → literal to require 'svg'
|
|
2656
|
-
children: px.array(PxNodeSchema).optional()
|
|
2657
|
-
}), PxAttrValueSchema);
|
|
2658
|
-
var PxBezierPathSchema = implementsInterface()(px.object({
|
|
2659
|
-
v: px.array(px.array(px.number())),
|
|
2660
|
-
i: px.array(px.array(px.number())).optional(),
|
|
2661
|
-
o: px.array(px.array(px.number())).optional(),
|
|
2662
|
-
c: px.boolean().optional()
|
|
2663
|
-
}));
|
|
2664
|
-
function bezierToSvgPath(path, forceCurves = false) {
|
|
2665
|
-
var _a, _b, _c, _d;
|
|
2666
|
-
const v = path.v;
|
|
2667
|
-
const i = path.i;
|
|
2668
|
-
const o = path.o;
|
|
2669
|
-
const c = path.c;
|
|
2670
|
-
if (!v.length) return "";
|
|
2671
|
-
const d = [];
|
|
2672
|
-
const len = v.length;
|
|
2673
|
-
d.push("M" + v[0][0] + "," + v[0][1]);
|
|
2674
|
-
for (let idx = 1; idx < len; idx++) {
|
|
2675
|
-
const prevV = v[idx - 1];
|
|
2676
|
-
const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
|
|
2677
|
-
const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
|
|
2678
|
-
const currV = v[idx];
|
|
2679
|
-
const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
|
|
2680
|
-
if (isLine) {
|
|
2681
|
-
d.push("L" + currV[0] + "," + currV[1]);
|
|
2682
|
-
} else {
|
|
2683
|
-
d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
|
|
2684
|
-
}
|
|
2685
|
-
}
|
|
2686
|
-
if (c && len > 0) {
|
|
2687
|
-
const lastV = v[len - 1];
|
|
2688
|
-
const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
|
|
2689
|
-
const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
|
|
2690
|
-
const firstV = v[0];
|
|
2691
|
-
const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
|
|
2692
|
-
if (!isLine) {
|
|
2693
|
-
d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
|
|
2694
|
-
}
|
|
2695
|
-
d.push("z");
|
|
2696
|
-
}
|
|
2697
|
-
return d.join("");
|
|
2698
|
-
}
|
|
2699
|
-
function interpolateNum(a, b, t) {
|
|
2700
|
-
return a + (b - a) * t;
|
|
2701
|
-
}
|
|
2702
|
-
function interpolateVec(a, b, t) {
|
|
2703
|
-
const res = [];
|
|
2704
|
-
const count = Math.max(a.length, b.length);
|
|
2705
|
-
for (let i = 0; i < count; i++) {
|
|
2706
|
-
res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
|
|
2707
|
-
}
|
|
2708
|
-
return res;
|
|
2709
|
-
}
|
|
2710
|
-
function interpolateColor(a, b, t) {
|
|
2711
|
-
return [
|
|
2712
|
-
interpolateNum(a[0] || 0, b[0] || 0, t),
|
|
2713
|
-
interpolateNum(a[1] || 0, b[1] || 0, t),
|
|
2714
|
-
interpolateNum(a[2] || 0, b[2] || 0, t),
|
|
2715
|
-
interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
|
|
2716
|
-
];
|
|
2717
|
-
}
|
|
2718
|
-
function interpolateBeziers(paths1, paths2, progress) {
|
|
2719
|
-
const count = Math.max(paths1.length, paths2.length);
|
|
2720
|
-
const res = [];
|
|
2721
|
-
for (let i = 0; i < count; i++) {
|
|
2722
|
-
res.push(interpolateBezier(paths1[i], paths2[i], progress));
|
|
2723
|
-
}
|
|
2724
|
-
return res;
|
|
2725
|
-
}
|
|
2726
|
-
function interpolateBezier(path1, path2, progress) {
|
|
2727
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2728
|
-
if (!path1 || !path2) return path1 || path2 || { v: [] };
|
|
2729
|
-
const t = Math.min(Math.max(progress, 0), 1);
|
|
2730
|
-
const len = Math.min(path1.v.length, path2.v.length);
|
|
2731
|
-
const v = [];
|
|
2732
|
-
const i = [];
|
|
2733
|
-
const o = [];
|
|
2734
|
-
for (let idx = 0; idx < len; idx++) {
|
|
2735
|
-
const v1 = path1.v[idx];
|
|
2736
|
-
const v2 = path2.v[idx];
|
|
2737
|
-
v.push(interpolateVec(v1, v2, t));
|
|
2738
|
-
const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
|
|
2739
|
-
const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
|
|
2740
|
-
i.push(interpolateVec(i1, i2, t));
|
|
2741
|
-
const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
|
|
2742
|
-
const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
|
|
2743
|
-
o.push(interpolateVec(o1, o2, t));
|
|
2744
|
-
}
|
|
2745
|
-
return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
|
|
2746
|
-
}
|
|
2747
|
-
function remap(value, inMin, inMax, outMin, outMax) {
|
|
2748
|
-
if (inMax === inMin) return outMin;
|
|
2749
|
-
const t = (value - inMin) / (inMax - inMin);
|
|
2750
|
-
return outMin + t * (outMax - outMin);
|
|
2751
|
-
}
|
|
2752
|
-
function solveCubicBezierX(p1x, p2x, x) {
|
|
2753
|
-
if (x <= 0) return 0;
|
|
2754
|
-
if (x >= 1) return 1;
|
|
2755
|
-
const cx = 3 * p1x;
|
|
2756
|
-
const bx = 3 * (p2x - p1x) - cx;
|
|
2757
|
-
const ax = 1 - cx - bx;
|
|
2758
|
-
function sampleX(t) {
|
|
2759
|
-
return ((ax * t + bx) * t + cx) * t;
|
|
2760
|
-
}
|
|
2761
|
-
function sampleDX(t) {
|
|
2762
|
-
return (3 * ax * t + 2 * bx) * t + cx;
|
|
2763
|
-
}
|
|
2764
|
-
let t2 = x;
|
|
2765
|
-
let t0 = 0;
|
|
2766
|
-
let t1 = 1;
|
|
2767
|
-
for (let i = 0; i < 8; i++) {
|
|
2768
|
-
const x2 = sampleX(t2) - x;
|
|
2769
|
-
if (Math.abs(x2) < 1e-6) return t2;
|
|
2770
|
-
const d2 = sampleDX(t2);
|
|
2771
|
-
if (Math.abs(d2) < 1e-6) break;
|
|
2772
|
-
t2 -= x2 / d2;
|
|
2773
|
-
}
|
|
2774
|
-
t2 = x;
|
|
2775
|
-
while (t0 < t1) {
|
|
2776
|
-
const x2 = sampleX(t2);
|
|
2777
|
-
if (Math.abs(x2 - x) < 1e-6) return t2;
|
|
2778
|
-
if (x > x2) t0 = t2;
|
|
2779
|
-
else t1 = t2;
|
|
2780
|
-
t2 = (t1 + t0) / 2;
|
|
2781
|
-
}
|
|
2782
|
-
return t2;
|
|
2783
|
-
}
|
|
2784
|
-
function cubicBezier(easing) {
|
|
2785
|
-
const [p1x, p1y, p2x, p2y] = easing;
|
|
2786
|
-
const cy = 3 * p1y;
|
|
2787
|
-
const by = 3 * (p2y - p1y) - cy;
|
|
2788
|
-
const ay = 1 - cy - by;
|
|
2789
|
-
function sampleCurveY(t) {
|
|
2790
|
-
return ((ay * t + by) * t + cy) * t;
|
|
2791
|
-
}
|
|
2792
|
-
return function(x) {
|
|
2793
|
-
return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
|
|
2794
|
-
};
|
|
2795
|
-
}
|
|
2796
|
-
function lerp2(a, b, t) {
|
|
2797
|
-
return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
2798
|
-
}
|
|
2799
|
-
function subdivideCubicBezier(p0, p1, p2, p3, t) {
|
|
2800
|
-
const q0 = lerp2(p0, p1, t);
|
|
2801
|
-
const q1 = lerp2(p1, p2, t);
|
|
2802
|
-
const q2 = lerp2(p2, p3, t);
|
|
2803
|
-
const r0 = lerp2(q0, q1, t);
|
|
2804
|
-
const r1 = lerp2(q1, q2, t);
|
|
2805
|
-
const s = lerp2(r0, r1, t);
|
|
2806
|
-
return {
|
|
2807
|
-
left: [p0, q0, r0, s],
|
|
2808
|
-
right: [s, r1, q2, p3]
|
|
2809
|
-
};
|
|
2810
|
-
}
|
|
2811
|
-
function splitEasing(easing, xFraction) {
|
|
2812
|
-
if (!easing) return { left: void 0, right: void 0 };
|
|
2813
|
-
if (xFraction <= 0) return { left: void 0, right: easing };
|
|
2814
|
-
if (xFraction >= 1) return { left: easing, right: void 0 };
|
|
2815
|
-
const [x1, y1, x2, y2] = easing;
|
|
2816
|
-
const t = solveCubicBezierX(x1, x2, xFraction);
|
|
2817
|
-
const p0 = [0, 0];
|
|
2818
|
-
const p1 = [x1, y1];
|
|
2819
|
-
const p2 = [x2, y2];
|
|
2820
|
-
const p3 = [1, 1];
|
|
2821
|
-
const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
|
|
2822
|
-
const sx = left[3][0];
|
|
2823
|
-
const sy = left[3][1];
|
|
2824
|
-
let leftEasing;
|
|
2825
|
-
if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
|
|
2826
|
-
leftEasing = [
|
|
2827
|
-
left[1][0] / sx,
|
|
2828
|
-
left[1][1] / sy,
|
|
2829
|
-
left[2][0] / sx,
|
|
2830
|
-
left[2][1] / sy
|
|
2831
|
-
];
|
|
2832
|
-
}
|
|
2833
|
-
let rightEasing;
|
|
2834
|
-
const rx = 1 - sx;
|
|
2835
|
-
const ry = 1 - sy;
|
|
2836
|
-
if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
|
|
2837
|
-
rightEasing = [
|
|
2838
|
-
(right[1][0] - sx) / rx,
|
|
2839
|
-
(right[1][1] - sy) / ry,
|
|
2840
|
-
(right[2][0] - sx) / rx,
|
|
2841
|
-
(right[2][1] - sy) / ry
|
|
2842
|
-
];
|
|
2843
|
-
}
|
|
2844
|
-
return { left: leftEasing, right: rightEasing };
|
|
2845
|
-
}
|
|
2846
|
-
function reverseEasing(easing) {
|
|
2847
|
-
if (!easing) return void 0;
|
|
2848
|
-
return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
|
|
2849
|
-
}
|
|
2850
|
-
function toRGBA(color) {
|
|
2851
|
-
const r = Math.round(color[0] * 255);
|
|
2852
|
-
const g = Math.round(color[1] * 255);
|
|
2853
|
-
const b = Math.round(color[2] * 255);
|
|
2854
|
-
return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
|
|
2855
|
-
}
|
|
2856
|
-
function parseRgba(s) {
|
|
2857
|
-
var _a;
|
|
2858
|
-
const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
|
|
2859
|
-
if (!inner) throw new Error("Invalid rgb/rgba format");
|
|
2860
|
-
const parts = inner.split(",").map((v) => +v.trim());
|
|
2861
|
-
return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
|
|
2862
|
-
}
|
|
2863
|
-
function parseHex(s) {
|
|
2864
|
-
const hex = s.slice(1);
|
|
2865
|
-
const isShort = hex.length <= 4;
|
|
2866
|
-
const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
|
|
2867
|
-
const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
|
|
2868
|
-
const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
|
|
2869
|
-
const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
|
|
2870
|
-
const result = [
|
|
2871
|
-
parseInt(r, 16) / 255,
|
|
2872
|
-
parseInt(g, 16) / 255,
|
|
2873
|
-
parseInt(b, 16) / 255
|
|
2874
|
-
];
|
|
2875
|
-
if (a !== null) {
|
|
2876
|
-
result.push(parseInt(a, 16) / 255);
|
|
2877
|
-
}
|
|
2878
|
-
return result;
|
|
2879
|
-
}
|
|
2880
|
-
function parseColor(s) {
|
|
2881
|
-
if (!s) return void 0;
|
|
2882
|
-
if (Array.isArray(s)) return s;
|
|
2883
|
-
if (typeof s !== "string") return void 0;
|
|
2884
|
-
if (s.startsWith("#")) {
|
|
2885
|
-
return parseHex(s);
|
|
2886
|
-
} else if (s.startsWith("rgb")) {
|
|
2887
|
-
return parseRgba(s);
|
|
2888
|
-
} else {
|
|
2889
|
-
console.warn("Unsupported color format: " + s);
|
|
2890
|
-
}
|
|
2891
|
-
return void 0;
|
|
2892
|
-
}
|
|
2893
|
-
var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
2894
|
-
var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
2895
|
-
var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
2896
|
-
function composeTransformParts(parts, opts) {
|
|
2897
|
-
var _a;
|
|
2898
|
-
if (!parts) return "";
|
|
2899
|
-
const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
|
|
2900
|
-
const segs = [];
|
|
2901
|
-
const t = parts.translate;
|
|
2902
|
-
const o = parts.origin;
|
|
2903
|
-
const r = parts.rotate;
|
|
2904
|
-
const k = parts.skew;
|
|
2905
|
-
const s = parts.scale;
|
|
2906
|
-
const tu = withUnits ? "px" : "";
|
|
2907
|
-
const ru = withUnits ? "deg" : "";
|
|
2908
|
-
if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
|
|
2909
|
-
if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
|
|
2910
|
-
if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
|
|
2911
|
-
if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
|
|
2912
|
-
if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
|
|
2913
|
-
if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
|
|
2914
|
-
return segs.join("");
|
|
2915
|
-
}
|
|
2916
|
-
var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
2917
|
-
var DEFAULT_DURATION_MS = 1e3;
|
|
2918
|
-
function kebabToCamelCaseWord(kebab) {
|
|
2919
|
-
return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
|
|
2920
|
-
}
|
|
2921
|
-
function isCamelCaseWord(word) {
|
|
2922
|
-
return !word.includes("-") && /[a-z][A-Z]/.test(word);
|
|
2923
|
-
}
|
|
2924
|
-
var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
|
|
2925
|
-
// Transform/positioning
|
|
2926
|
-
"viewBox",
|
|
2927
|
-
"preserveAspectRatio",
|
|
2928
|
-
// Gradient
|
|
2929
|
-
"gradientUnits",
|
|
2930
|
-
"gradientTransform",
|
|
2931
|
-
"spreadMethod",
|
|
2932
|
-
// Pattern
|
|
2933
|
-
"patternUnits",
|
|
2934
|
-
"patternContentUnits",
|
|
2935
|
-
"patternTransform",
|
|
2936
|
-
// Clipping/masking
|
|
2937
|
-
"clipPathUnits",
|
|
2938
|
-
"maskUnits",
|
|
2939
|
-
"maskContentUnits",
|
|
2940
|
-
// Marker (SVG spec keeps these camelCase, like viewBox)
|
|
2941
|
-
"markerUnits",
|
|
2942
|
-
"markerWidth",
|
|
2943
|
-
"markerHeight",
|
|
2944
|
-
"refX",
|
|
2945
|
-
"refY",
|
|
2946
|
-
// Text
|
|
2947
|
-
"textLength",
|
|
2948
|
-
"lengthAdjust",
|
|
2949
|
-
"startOffset",
|
|
2950
|
-
// Filter
|
|
2951
|
-
"filterUnits",
|
|
2952
|
-
"primitiveUnits",
|
|
2953
|
-
"tableValues",
|
|
2954
|
-
// feFuncR/G/B/A transfer table (type="table")
|
|
2955
|
-
"stdDeviation",
|
|
2956
|
-
"baseFrequency",
|
|
2957
|
-
"numOctaves",
|
|
2958
|
-
"surfaceScale",
|
|
2959
|
-
"diffuseConstant",
|
|
2960
|
-
"specularConstant",
|
|
2961
|
-
"specularExponent",
|
|
2962
|
-
"kernelMatrix",
|
|
2963
|
-
"kernelUnitLength",
|
|
2964
|
-
"edgeMode",
|
|
2965
|
-
"preserveAlpha",
|
|
2966
|
-
"targetX",
|
|
2967
|
-
"targetY"
|
|
2968
|
-
// // Animation
|
|
2969
|
-
// 'attributeName',
|
|
2970
|
-
// 'attributeType',
|
|
2971
|
-
// 'calcMode',
|
|
2972
|
-
// 'keyTimes',
|
|
2973
|
-
// 'keySplines',
|
|
2974
|
-
// 'repeatCount',
|
|
2975
|
-
// 'repeatDur'
|
|
2976
|
-
]);
|
|
2977
|
-
function camelCaseToKebabWordIfNeeded(camel) {
|
|
2978
|
-
return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
2979
|
-
}
|
|
2980
|
-
function clamp(value, min, max) {
|
|
2981
|
-
return Math.max(min, Math.min(value, max));
|
|
2982
|
-
}
|
|
2983
|
-
function bezier2D_pointAt(P0, P1, P2, P3, t) {
|
|
2984
|
-
if (t <= 0) return [P0[0], P0[1]];
|
|
2985
|
-
if (t >= 1) return [P3[0], P3[1]];
|
|
2986
|
-
const u = 1 - t;
|
|
2987
|
-
const u2 = u * u;
|
|
2988
|
-
const u3 = u2 * u;
|
|
2989
|
-
const t2 = t * t;
|
|
2990
|
-
const t3 = t2 * t;
|
|
2991
|
-
const w0 = u3;
|
|
2992
|
-
const w1 = 3 * t * u2;
|
|
2993
|
-
const w2 = 3 * t2 * u;
|
|
2994
|
-
const w3 = t3;
|
|
2995
|
-
return [
|
|
2996
|
-
w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
|
|
2997
|
-
w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
|
|
2998
|
-
];
|
|
2999
|
-
}
|
|
3000
|
-
var BEZIER_T_NUDGE = 1e-4;
|
|
3001
|
-
function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
|
|
3002
|
-
const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
|
|
3003
|
-
if (result[0] === 0 && result[1] === 0) {
|
|
3004
|
-
const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
|
|
3005
|
-
return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
|
|
3006
|
-
}
|
|
3007
|
-
return result;
|
|
3008
|
-
}
|
|
3009
|
-
function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
|
|
3010
|
-
const u = 1 - t;
|
|
3011
|
-
const a = 3 * u * u;
|
|
3012
|
-
const b = 6 * t * u;
|
|
3013
|
-
const c = 3 * t * t;
|
|
3014
|
-
return [
|
|
3015
|
-
a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
|
|
3016
|
-
a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
|
|
3017
|
-
];
|
|
3018
|
-
}
|
|
3019
|
-
function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
|
|
3020
|
-
const n = steps + 1;
|
|
3021
|
-
const ts = new Float64Array(n);
|
|
3022
|
-
const ds = new Float64Array(n);
|
|
3023
|
-
let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
|
|
3024
|
-
ts[0] = 0;
|
|
3025
|
-
ds[0] = 0;
|
|
3026
|
-
let cum = 0;
|
|
3027
|
-
for (let i = 1; i < n; i++) {
|
|
3028
|
-
const t = i / steps;
|
|
3029
|
-
const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
|
|
3030
|
-
const dx = cur[0] - prev[0];
|
|
3031
|
-
const dy = cur[1] - prev[1];
|
|
3032
|
-
cum += Math.sqrt(dx * dx + dy * dy);
|
|
3033
|
-
ts[i] = t;
|
|
3034
|
-
ds[i] = cum;
|
|
3035
|
-
prev = cur;
|
|
3036
|
-
}
|
|
3037
|
-
return { ts, ds };
|
|
3038
|
-
}
|
|
3039
|
-
function bezier2D_tForDistance(lut, distance) {
|
|
3040
|
-
const { ts, ds } = lut;
|
|
3041
|
-
const last = ds.length - 1;
|
|
3042
|
-
if (distance <= 0) return ts[0];
|
|
3043
|
-
if (distance >= ds[last]) return ts[last];
|
|
3044
|
-
let lo = 1;
|
|
3045
|
-
let hi = last;
|
|
3046
|
-
while (lo < hi) {
|
|
3047
|
-
const mid = lo + hi >>> 1;
|
|
3048
|
-
if (ds[mid] < distance) lo = mid + 1;
|
|
3049
|
-
else hi = mid;
|
|
3050
|
-
}
|
|
3051
|
-
const dPrev = ds[hi - 1];
|
|
3052
|
-
const dCur = ds[hi];
|
|
3053
|
-
const span = dCur - dPrev;
|
|
3054
|
-
const frac = span > 0 ? (distance - dPrev) / span : 0;
|
|
3055
|
-
return ts[hi - 1] + frac * (ts[hi] - ts[hi - 1]);
|
|
3056
|
-
}
|
|
3057
|
-
function bezier2D_arcAtT(lut, t) {
|
|
3058
|
-
const { ts, ds } = lut;
|
|
3059
|
-
const last = ts.length - 1;
|
|
3060
|
-
if (t <= ts[0]) return ds[0];
|
|
3061
|
-
if (t >= ts[last]) return ds[last];
|
|
3062
|
-
let lo = 1, hi = last;
|
|
3063
|
-
while (lo < hi) {
|
|
3064
|
-
const mid = lo + hi >>> 1;
|
|
3065
|
-
if (ts[mid] < t) lo = mid + 1;
|
|
3066
|
-
else hi = mid;
|
|
3067
|
-
}
|
|
3068
|
-
const tPrev = ts[hi - 1];
|
|
3069
|
-
const span = ts[hi] - tPrev;
|
|
3070
|
-
const frac = span > 0 ? (t - tPrev) / span : 0;
|
|
3071
|
-
return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
|
|
3072
|
-
}
|
|
3073
|
-
function invertEasing(easing) {
|
|
3074
|
-
if (!easing) return (y) => y;
|
|
3075
|
-
const flipped = [easing[1], easing[0], easing[3], easing[2]];
|
|
3076
|
-
return cubicBezier(flipped);
|
|
2973
|
+
}));
|
|
2974
|
+
var PxAttrValueSchema = px.union([
|
|
2975
|
+
px.string(),
|
|
2976
|
+
px.number(),
|
|
2977
|
+
px.array(px.number()),
|
|
2978
|
+
// Structured static — `{value: …}` (read-accepted transitional spelling, S1).
|
|
2979
|
+
// `defined`, not `any`: the KEY's presence is what identifies this branch (V6).
|
|
2980
|
+
px.object({ value: px.defined() }),
|
|
2981
|
+
// Bare transform parts record — the canonical static `transform` on the wire (T2).
|
|
2982
|
+
PxTransformPartsSchema
|
|
2983
|
+
]);
|
|
2984
|
+
var PxAnimatableNumberSchema = px.union([
|
|
2985
|
+
px.number(),
|
|
2986
|
+
px.object({ value: px.number() }),
|
|
2987
|
+
PxPropertyAnimationSchema
|
|
2988
|
+
]);
|
|
2989
|
+
var PxAnimatableVec2Schema = px.union([
|
|
2990
|
+
px.tuple([px.number(), px.number()]),
|
|
2991
|
+
px.object({ value: px.tuple([px.number(), px.number()]) }),
|
|
2992
|
+
PxPropertyAnimationSchema
|
|
2993
|
+
]);
|
|
2994
|
+
var PxAnimatableStringSchema = px.union([
|
|
2995
|
+
px.string(),
|
|
2996
|
+
px.object({ value: px.string() }),
|
|
2997
|
+
PxPropertyAnimationSchema
|
|
2998
|
+
]);
|
|
2999
|
+
var PxTransformByEffectSchema = implementsInterface()(px.object({
|
|
3000
|
+
translate: PxAnimatableVec2Schema.optional(),
|
|
3001
|
+
rotate: PxAnimatableNumberSchema.optional(),
|
|
3002
|
+
scale: PxAnimatableVec2Schema.optional(),
|
|
3003
|
+
skew: PxAnimatableNumberSchema.optional(),
|
|
3004
|
+
origin: PxAnimatableVec2Schema.optional()
|
|
3005
|
+
}));
|
|
3006
|
+
var PxRepeaterEffectSchema = implementsInterface()(px.object({
|
|
3007
|
+
// STATIC config, not a channel (V2/SCHEMA-DESIGN R5): the copy COUNT is read
|
|
3008
|
+
// once at expansion time and never sampled — plain number, no `keyframes`.
|
|
3009
|
+
copies: px.number().optional(),
|
|
3010
|
+
translate: PxAnimatableVec2Schema.optional(),
|
|
3011
|
+
rotate: PxAnimatableNumberSchema.optional(),
|
|
3012
|
+
skew: PxAnimatableNumberSchema.optional(),
|
|
3013
|
+
scale: PxAnimatableVec2Schema.optional(),
|
|
3014
|
+
origin: PxAnimatableVec2Schema.optional()
|
|
3015
|
+
}));
|
|
3016
|
+
var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
3017
|
+
sourceId: px.string().optional(),
|
|
3018
|
+
maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
|
|
3019
|
+
maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
3020
|
+
maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
3021
|
+
x: px.number().optional(),
|
|
3022
|
+
y: px.number().optional(),
|
|
3023
|
+
width: px.number().optional(),
|
|
3024
|
+
height: px.number().optional()
|
|
3025
|
+
}));
|
|
3026
|
+
var PxClipPathEffectSchema = implementsInterface()(px.object({
|
|
3027
|
+
d: PxAnimatableStringSchema.optional(),
|
|
3028
|
+
animate: PxPropertyAnimationSchema.optional()
|
|
3029
|
+
}));
|
|
3030
|
+
var PxTrimPathEffectSchema = implementsInterface()(px.object({
|
|
3031
|
+
offset: PxAnimatableNumberSchema.optional(),
|
|
3032
|
+
range: PxAnimatableVec2Schema.optional(),
|
|
3033
|
+
subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
|
|
3034
|
+
}));
|
|
3035
|
+
var PxRetimeEffectSchema = implementsInterface()(px.object({
|
|
3036
|
+
sourceId: px.string().optional(),
|
|
3037
|
+
start: px.number().optional(),
|
|
3038
|
+
stretch: px.number().optional(),
|
|
3039
|
+
timeCrop: px.tuple([px.number(), px.number()]).optional()
|
|
3040
|
+
}));
|
|
3041
|
+
var PxCloneEffectSchema = implementsInterface()(px.object({
|
|
3042
|
+
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
3043
|
+
type: px.enum([PxCloneType.content]).optional(),
|
|
3044
|
+
sourceId: px.string().optional(),
|
|
3045
|
+
retime: PxRetimeEffectSchema.optional()
|
|
3046
|
+
}));
|
|
3047
|
+
var PxGradientStopSchema = implementsInterface()(px.object({
|
|
3048
|
+
offset: px.number(),
|
|
3049
|
+
color: px.string()
|
|
3050
|
+
}));
|
|
3051
|
+
var PxAnimatableGradientStopsSchema = px.union([
|
|
3052
|
+
px.array(PxGradientStopSchema),
|
|
3053
|
+
px.object({ value: px.array(PxGradientStopSchema) }),
|
|
3054
|
+
PxPropertyAnimationSchema
|
|
3055
|
+
]);
|
|
3056
|
+
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
3057
|
+
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
3058
|
+
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
3059
|
+
p1: PxAnimatableVec2Schema.optional(),
|
|
3060
|
+
p2: PxAnimatableVec2Schema.optional(),
|
|
3061
|
+
c: PxAnimatableVec2Schema.optional(),
|
|
3062
|
+
r: PxAnimatableNumberSchema.optional(),
|
|
3063
|
+
fp: PxAnimatableVec2Schema.optional(),
|
|
3064
|
+
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
3065
|
+
gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
|
|
3066
|
+
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
|
|
3067
|
+
gradientTransform: px.string().optional()
|
|
3068
|
+
}));
|
|
3069
|
+
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
3070
|
+
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
3071
|
+
path: px.string(),
|
|
3072
|
+
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
|
|
3073
|
+
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
|
|
3074
|
+
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
|
|
3075
|
+
spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
|
|
3076
|
+
startOffset: PxAnimatableNumberSchema.optional(),
|
|
3077
|
+
textLength: PxAnimatableNumberSchema.optional()
|
|
3078
|
+
}));
|
|
3079
|
+
var PxTextEffectSchema = implementsInterface()(px.object({
|
|
3080
|
+
useGlyphs: px.boolean().optional()
|
|
3081
|
+
}));
|
|
3082
|
+
var PxEffectsSchema = implementsInterface()(px.object({
|
|
3083
|
+
transformBy: PxTransformByEffectSchema.optional(),
|
|
3084
|
+
repeater: PxRepeaterEffectSchema.optional(),
|
|
3085
|
+
maskedBy: PxMaskedByEffectSchema.optional(),
|
|
3086
|
+
clipPath: PxClipPathEffectSchema.optional(),
|
|
3087
|
+
trimPath: PxTrimPathEffectSchema.optional(),
|
|
3088
|
+
clone: PxCloneEffectSchema.optional(),
|
|
3089
|
+
fillGradient: PxFillGradientEffectSchema.optional(),
|
|
3090
|
+
strokeGradient: PxStrokeGradientEffectSchema.optional(),
|
|
3091
|
+
textPath: PxTextPathEffectSchema.optional(),
|
|
3092
|
+
text: PxTextEffectSchema.optional()
|
|
3093
|
+
}));
|
|
3094
|
+
function validateNodeEffects(root, opts) {
|
|
3095
|
+
const warnings = [];
|
|
3096
|
+
const walk = (node, path) => {
|
|
3097
|
+
if (node && node.effects) {
|
|
3098
|
+
const ctx = { errors: [], warnings: [], strict: !!(opts == null ? void 0 : opts.strict) };
|
|
3099
|
+
const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
|
|
3100
|
+
if (!ok) {
|
|
3101
|
+
for (const err of ctx.errors) warnings.push(err);
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
if (node && Array.isArray(node.children)) {
|
|
3105
|
+
node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]"));
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
walk(root, "root");
|
|
3109
|
+
return warnings;
|
|
3077
3110
|
}
|
|
3111
|
+
var PxNodeBase = px.openObject({
|
|
3112
|
+
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
3113
|
+
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
3114
|
+
// (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
|
|
3115
|
+
// `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
|
|
3116
|
+
// the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
|
|
3117
|
+
// would add words that all mean "type" and still need the carrier to read.
|
|
3118
|
+
// Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
|
|
3119
|
+
// (issues V3), never of distinct key names.
|
|
3120
|
+
type: px.string(),
|
|
3121
|
+
id: px.string().optional(),
|
|
3122
|
+
meta: px.any().optional(),
|
|
3123
|
+
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
3124
|
+
// Consumed and removed by `applyPlayerEffects` before any other normalisation
|
|
3125
|
+
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
3126
|
+
effects: PxEffectsSchema.optional(),
|
|
3127
|
+
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
3128
|
+
// string ref / array of refs / inline definition / mixed array; mirrors
|
|
3129
|
+
// `animator.animateById` map values and what `processNode` resolves at runtime.
|
|
3130
|
+
animate: PxElementAnimationSchema.optional(),
|
|
3131
|
+
style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
|
|
3132
|
+
}, PxAttrValueSchema);
|
|
3133
|
+
var PxNodeSchema = px.openObject(__spreadProps2(__spreadValues2({}, PxNodeBase._shape), {
|
|
3134
|
+
children: px.lazy(() => px.array(PxNodeSchema), []).optional()
|
|
3135
|
+
}), PxAttrValueSchema);
|
|
3136
|
+
var PxSvgNodeExtra = px.object({
|
|
3137
|
+
// `"100%"` and other SVG length strings are legal here — a number-only slot rejected
|
|
3138
|
+
// real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
|
|
3139
|
+
width: px.union([px.number(), px.string()]).optional(),
|
|
3140
|
+
height: px.union([px.number(), px.string()]).optional(),
|
|
3141
|
+
viewBox: px.string().optional(),
|
|
3142
|
+
animator: PxAnimatorConfigSchema.optional()
|
|
3143
|
+
});
|
|
3144
|
+
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps2(__spreadValues2(__spreadValues2({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
|
|
3145
|
+
type: px.literal("svg"),
|
|
3146
|
+
// override string → literal to require 'svg'
|
|
3147
|
+
children: px.array(PxNodeSchema).optional()
|
|
3148
|
+
}), PxAttrValueSchema);
|
|
3149
|
+
var PxBezierPathSchema = implementsInterface()(px.object({
|
|
3150
|
+
v: px.array(px.array(px.number())),
|
|
3151
|
+
i: px.array(px.array(px.number())).optional(),
|
|
3152
|
+
o: px.array(px.array(px.number())).optional(),
|
|
3153
|
+
c: px.boolean().optional()
|
|
3154
|
+
}));
|
|
3078
3155
|
var _idCounter = 0;
|
|
3079
3156
|
function generateUniqueId() {
|
|
3080
3157
|
const timestamp = Date.now().toString(36);
|
|
@@ -7430,7 +7507,13 @@ var PixodeskAnimatorReact = (() => {
|
|
|
7430
7507
|
const api = __spreadProps(__spreadValues({}, basicApi), {
|
|
7431
7508
|
"getRootElement": () => rootElement || null
|
|
7432
7509
|
});
|
|
7433
|
-
if (config.trigger)
|
|
7510
|
+
if (config.trigger) {
|
|
7511
|
+
if (isScrollTimeline(config)) {
|
|
7512
|
+
console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
|
|
7513
|
+
} else {
|
|
7514
|
+
setupAnimationTriggers(api, config.trigger);
|
|
7515
|
+
}
|
|
7516
|
+
}
|
|
7434
7517
|
return api;
|
|
7435
7518
|
}
|
|
7436
7519
|
function createDomAdapter(rootElement) {
|
|
@@ -7556,7 +7639,7 @@ var PixodeskAnimatorReact = (() => {
|
|
|
7556
7639
|
}
|
|
7557
7640
|
return result;
|
|
7558
7641
|
}
|
|
7559
|
-
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs) {
|
|
7642
|
+
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs, scrollTimeline) {
|
|
7560
7643
|
var _a;
|
|
7561
7644
|
const config = getAnimatorConfig(doc) || {};
|
|
7562
7645
|
if (!rootElement) {
|
|
@@ -7615,7 +7698,12 @@ var PixodeskAnimatorReact = (() => {
|
|
|
7615
7698
|
if (keyframes.length > 0) {
|
|
7616
7699
|
try {
|
|
7617
7700
|
const effect = new KeyframeEffect(element, keyframes, effectOptions);
|
|
7618
|
-
const anim = new Animation(effect, document.timeline);
|
|
7701
|
+
const anim = new Animation(effect, scrollTimeline ? scrollTimeline.timeline : document.timeline);
|
|
7702
|
+
if (scrollTimeline) {
|
|
7703
|
+
const a = anim;
|
|
7704
|
+
if (scrollTimeline.rangeStart) a.rangeStart = scrollTimeline.rangeStart;
|
|
7705
|
+
if (scrollTimeline.rangeEnd) a.rangeEnd = scrollTimeline.rangeEnd;
|
|
7706
|
+
}
|
|
7619
7707
|
if (callbacks == null ? void 0 : callbacks.onFinish) anim.onfinish = () => {
|
|
7620
7708
|
var _a2;
|
|
7621
7709
|
if (finishNotified) return;
|
|
@@ -7709,10 +7797,239 @@ var PixodeskAnimatorReact = (() => {
|
|
|
7709
7797
|
}
|
|
7710
7798
|
};
|
|
7711
7799
|
if (config.trigger) {
|
|
7712
|
-
|
|
7800
|
+
if (config.timelineSource === "scroll") {
|
|
7801
|
+
console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
|
|
7802
|
+
} else {
|
|
7803
|
+
setupAnimationTriggers(api, config.trigger);
|
|
7804
|
+
}
|
|
7805
|
+
}
|
|
7806
|
+
if (scrollTimeline) {
|
|
7807
|
+
animations.forEach((a) => a.play());
|
|
7713
7808
|
}
|
|
7714
7809
|
return api;
|
|
7715
7810
|
}
|
|
7811
|
+
function nativeRangeOffset(point, defaultFraction, view) {
|
|
7812
|
+
var _a, _b, _c;
|
|
7813
|
+
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
7814
|
+
const pct = (_b = (_a = globalThis.CSS) == null ? void 0 : _a.percent) == null ? void 0 : _b.call(_a, fraction * 100);
|
|
7815
|
+
if (pct === void 0) return void 0;
|
|
7816
|
+
return view ? { rangeName: (_c = point == null ? void 0 : point.phase) != null ? _c : "cover", offset: pct } : { offset: pct };
|
|
7817
|
+
}
|
|
7818
|
+
function createNativeScrollTimeline(subject, config) {
|
|
7819
|
+
var _a, _b, _c, _d;
|
|
7820
|
+
if (!config || !isScrollTimeline(config)) return null;
|
|
7821
|
+
const scroll = config.scroll || {};
|
|
7822
|
+
const kind = (_a = scroll.kind) != null ? _a : "view";
|
|
7823
|
+
if (scroll.smoothing) {
|
|
7824
|
+
console.warn('scroll timeline: `smoothing` needs the built-in driver \u2014 ignoring `driver: "native"`');
|
|
7825
|
+
return null;
|
|
7826
|
+
}
|
|
7827
|
+
const g = globalThis;
|
|
7828
|
+
const view = kind === "view";
|
|
7829
|
+
const Ctor = view ? g.ViewTimeline : g.ScrollTimeline;
|
|
7830
|
+
if (typeof Ctor !== "function") return null;
|
|
7831
|
+
const axis = (_b = scroll.axis) != null ? _b : "block";
|
|
7832
|
+
let timeline;
|
|
7833
|
+
try {
|
|
7834
|
+
if (view) {
|
|
7835
|
+
timeline = new Ctor({ subject: resolveScrollSubject(subject, scroll.subject), axis });
|
|
7836
|
+
} else {
|
|
7837
|
+
const source = scroll.source === "root" ? documentScroller() : findNearestScroller(subject, "y") || findNearestScroller(subject, "x") || documentScroller();
|
|
7838
|
+
timeline = new Ctor({ source, axis });
|
|
7839
|
+
}
|
|
7840
|
+
} catch (e) {
|
|
7841
|
+
console.warn("scroll timeline: native timeline construction failed \u2014 falling back to the custom driver", e);
|
|
7842
|
+
return null;
|
|
7843
|
+
}
|
|
7844
|
+
return {
|
|
7845
|
+
timeline,
|
|
7846
|
+
rangeStart: nativeRangeOffset((_c = scroll.range) == null ? void 0 : _c.start, 0, view),
|
|
7847
|
+
rangeEnd: nativeRangeOffset((_d = scroll.range) == null ? void 0 : _d.end, 1, view)
|
|
7848
|
+
};
|
|
7849
|
+
}
|
|
7850
|
+
function findNearestScroller(el, axis) {
|
|
7851
|
+
const body = document.body;
|
|
7852
|
+
const root = document.documentElement;
|
|
7853
|
+
for (let p = el.parentElement; p; p = p.parentElement) {
|
|
7854
|
+
if (p === body || p === root) return null;
|
|
7855
|
+
const style = getComputedStyle(p);
|
|
7856
|
+
const overflow = axis === "y" ? style.overflowY : style.overflowX;
|
|
7857
|
+
if (overflow === "auto" || overflow === "scroll" || overflow === "hidden" || overflow === "overlay") {
|
|
7858
|
+
return p;
|
|
7859
|
+
}
|
|
7860
|
+
}
|
|
7861
|
+
return null;
|
|
7862
|
+
}
|
|
7863
|
+
function documentScroller() {
|
|
7864
|
+
return document.scrollingElement || document.documentElement;
|
|
7865
|
+
}
|
|
7866
|
+
var SUBJECT_PARENT = "parent";
|
|
7867
|
+
var SUBJECT_SCROLLER = "scroller";
|
|
7868
|
+
function resolveScrollSubject(svgRoot, subject) {
|
|
7869
|
+
var _a, _b;
|
|
7870
|
+
const spec = subject == null ? void 0 : subject.trim();
|
|
7871
|
+
if (!spec) return svgRoot;
|
|
7872
|
+
if (spec === SUBJECT_PARENT) {
|
|
7873
|
+
let outermostPinned = null;
|
|
7874
|
+
for (let p = svgRoot.parentElement; p && p !== document.body; p = p.parentElement) {
|
|
7875
|
+
const position = getComputedStyle(p).position;
|
|
7876
|
+
if (position === "sticky" || position === "fixed") outermostPinned = p;
|
|
7877
|
+
}
|
|
7878
|
+
return (_b = (_a = outermostPinned == null ? void 0 : outermostPinned.parentElement) != null ? _a : svgRoot.parentElement) != null ? _b : svgRoot;
|
|
7879
|
+
}
|
|
7880
|
+
if (spec === SUBJECT_SCROLLER) {
|
|
7881
|
+
return findNearestScroller(svgRoot, "y") || findNearestScroller(svgRoot, "x") || documentScroller();
|
|
7882
|
+
}
|
|
7883
|
+
let found = null;
|
|
7884
|
+
try {
|
|
7885
|
+
found = document.querySelector(spec);
|
|
7886
|
+
} catch (e) {
|
|
7887
|
+
console.warn('scroll timeline: subject "' + spec + '" is not a valid selector \u2014 measuring the SVG itself');
|
|
7888
|
+
return svgRoot;
|
|
7889
|
+
}
|
|
7890
|
+
if (!found) {
|
|
7891
|
+
console.warn('scroll timeline: subject "' + spec + '" matched no element \u2014 measuring the SVG itself');
|
|
7892
|
+
return svgRoot;
|
|
7893
|
+
}
|
|
7894
|
+
return found;
|
|
7895
|
+
}
|
|
7896
|
+
function createScrollDriver(subject, config, onProgress) {
|
|
7897
|
+
var _a, _b;
|
|
7898
|
+
if (!config || !isScrollTimeline(config)) return null;
|
|
7899
|
+
const scroll = config.scroll || {};
|
|
7900
|
+
const kind = (_a = scroll.kind) != null ? _a : "view";
|
|
7901
|
+
const measured = resolveScrollSubject(subject, scroll.subject);
|
|
7902
|
+
const nearest = findNearestScroller(subject, "y") || findNearestScroller(subject, "x");
|
|
7903
|
+
const scroller = kind === "scroll" && scroll.source === "root" ? documentScroller() : nearest || documentScroller();
|
|
7904
|
+
const isRootScroller = scroller === documentScroller();
|
|
7905
|
+
const axis = scrollResolveAxis(scroll.axis, getComputedStyle(scroller).writingMode);
|
|
7906
|
+
const compute = () => {
|
|
7907
|
+
if (kind === "scroll") {
|
|
7908
|
+
const offset = axis === "y" ? scroller.scrollTop : scroller.scrollLeft;
|
|
7909
|
+
const maxOffset = axis === "y" ? scroller.scrollHeight - scroller.clientHeight : scroller.scrollWidth - scroller.clientWidth;
|
|
7910
|
+
return scrollOffsetProgress(offset, maxOffset, scroll.range);
|
|
7911
|
+
}
|
|
7912
|
+
const subjectRect = measured.getBoundingClientRect();
|
|
7913
|
+
let portStart, portSize;
|
|
7914
|
+
if (isRootScroller) {
|
|
7915
|
+
portStart = 0;
|
|
7916
|
+
portSize = axis === "y" ? document.documentElement.clientHeight : document.documentElement.clientWidth;
|
|
7917
|
+
} else {
|
|
7918
|
+
const portRect = scroller.getBoundingClientRect();
|
|
7919
|
+
portStart = axis === "y" ? portRect.top : portRect.left;
|
|
7920
|
+
portSize = axis === "y" ? scroller.clientHeight : scroller.clientWidth;
|
|
7921
|
+
}
|
|
7922
|
+
const subjectStart = (axis === "y" ? subjectRect.top : subjectRect.left) - portStart;
|
|
7923
|
+
const subjectSize = axis === "y" ? subjectRect.height : subjectRect.width;
|
|
7924
|
+
return scrollViewProgress(subjectStart, subjectSize, portSize, scroll.range);
|
|
7925
|
+
};
|
|
7926
|
+
const smoothingSec = Math.max(0, (_b = scroll.smoothing) != null ? _b : 0) / 1e3;
|
|
7927
|
+
const SETTLE_EPSILON = 1e-3;
|
|
7928
|
+
let destroyed = false;
|
|
7929
|
+
let smoothed = null;
|
|
7930
|
+
let smoothRaf = null;
|
|
7931
|
+
let lastFrameMs = 0;
|
|
7932
|
+
const emit = (target) => {
|
|
7933
|
+
if (!smoothingSec) {
|
|
7934
|
+
onProgress(target);
|
|
7935
|
+
return;
|
|
7936
|
+
}
|
|
7937
|
+
if (smoothed === null) {
|
|
7938
|
+
smoothed = target;
|
|
7939
|
+
onProgress(target);
|
|
7940
|
+
return;
|
|
7941
|
+
}
|
|
7942
|
+
if (smoothRaf !== null) return;
|
|
7943
|
+
lastFrameMs = 0;
|
|
7944
|
+
const step = (nowMs) => {
|
|
7945
|
+
smoothRaf = null;
|
|
7946
|
+
if (destroyed) return;
|
|
7947
|
+
const dtSec = lastFrameMs ? Math.min(0.1, (nowMs - lastFrameMs) / 1e3) : 1 / 60;
|
|
7948
|
+
lastFrameMs = nowMs;
|
|
7949
|
+
const goal = compute();
|
|
7950
|
+
const k = 1 - Math.exp(-dtSec / smoothingSec);
|
|
7951
|
+
smoothed = smoothed + (goal - smoothed) * k;
|
|
7952
|
+
if (Math.abs(goal - smoothed) < SETTLE_EPSILON) smoothed = goal;
|
|
7953
|
+
onProgress(smoothed);
|
|
7954
|
+
if (smoothed !== goal) smoothRaf = requestAnimationFrame(step);
|
|
7955
|
+
};
|
|
7956
|
+
smoothRaf = requestAnimationFrame(step);
|
|
7957
|
+
};
|
|
7958
|
+
let rafId = null;
|
|
7959
|
+
const tick = () => {
|
|
7960
|
+
rafId = null;
|
|
7961
|
+
if (destroyed) return;
|
|
7962
|
+
emit(compute());
|
|
7963
|
+
};
|
|
7964
|
+
const schedule = () => {
|
|
7965
|
+
if (destroyed || rafId !== null) return;
|
|
7966
|
+
rafId = requestAnimationFrame(tick);
|
|
7967
|
+
};
|
|
7968
|
+
const scrollTarget = isRootScroller ? window : scroller;
|
|
7969
|
+
scrollTarget.addEventListener("scroll", schedule, { passive: true });
|
|
7970
|
+
window.addEventListener("resize", schedule, { passive: true });
|
|
7971
|
+
let resizeObserver;
|
|
7972
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
7973
|
+
resizeObserver = new ResizeObserver(schedule);
|
|
7974
|
+
resizeObserver.observe(measured);
|
|
7975
|
+
if (measured !== subject) resizeObserver.observe(subject);
|
|
7976
|
+
if (!isRootScroller) resizeObserver.observe(scroller);
|
|
7977
|
+
}
|
|
7978
|
+
const driver = {
|
|
7979
|
+
destroy: () => {
|
|
7980
|
+
if (destroyed) return;
|
|
7981
|
+
destroyed = true;
|
|
7982
|
+
scrollTarget.removeEventListener("scroll", schedule);
|
|
7983
|
+
window.removeEventListener("resize", schedule);
|
|
7984
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
7985
|
+
if (rafId !== null) {
|
|
7986
|
+
cancelAnimationFrame(rafId);
|
|
7987
|
+
rafId = null;
|
|
7988
|
+
}
|
|
7989
|
+
if (smoothRaf !== null) {
|
|
7990
|
+
cancelAnimationFrame(smoothRaf);
|
|
7991
|
+
smoothRaf = null;
|
|
7992
|
+
}
|
|
7993
|
+
},
|
|
7994
|
+
// `refresh` is a deliberate JUMP (attach, host relayout) — never eased.
|
|
7995
|
+
refresh: () => {
|
|
7996
|
+
if (!destroyed) {
|
|
7997
|
+
smoothed = compute();
|
|
7998
|
+
onProgress(smoothed);
|
|
7999
|
+
}
|
|
8000
|
+
}
|
|
8001
|
+
};
|
|
8002
|
+
driver.refresh();
|
|
8003
|
+
return driver;
|
|
8004
|
+
}
|
|
8005
|
+
function applyScrollPin(svgRoot, scroll) {
|
|
8006
|
+
var _a;
|
|
8007
|
+
const styled = svgRoot;
|
|
8008
|
+
if (!(scroll == null ? void 0 : scroll.pin) || !styled.style) return () => {
|
|
8009
|
+
};
|
|
8010
|
+
const style = styled.style;
|
|
8011
|
+
const prevPosition = style.position;
|
|
8012
|
+
const prevTop = style.top;
|
|
8013
|
+
style.position = "sticky";
|
|
8014
|
+
style.top = ((_a = scroll.pinTop) != null ? _a : 0) + "px";
|
|
8015
|
+
let wrapper = null;
|
|
8016
|
+
const parent = svgRoot.parentElement;
|
|
8017
|
+
if (scroll.pinDistance && scroll.pinDistance > 0 && parent) {
|
|
8018
|
+
wrapper = document.createElement("div");
|
|
8019
|
+
wrapper.setAttribute("data-px-pin", "");
|
|
8020
|
+
wrapper.style.height = scroll.pinDistance * 100 + "vh";
|
|
8021
|
+
parent.insertBefore(wrapper, svgRoot);
|
|
8022
|
+
wrapper.appendChild(svgRoot);
|
|
8023
|
+
}
|
|
8024
|
+
return () => {
|
|
8025
|
+
style.position = prevPosition;
|
|
8026
|
+
style.top = prevTop;
|
|
8027
|
+
if (wrapper == null ? void 0 : wrapper.parentElement) {
|
|
8028
|
+
wrapper.parentElement.insertBefore(svgRoot, wrapper);
|
|
8029
|
+
wrapper.remove();
|
|
8030
|
+
}
|
|
8031
|
+
};
|
|
8032
|
+
}
|
|
7716
8033
|
function finaliseAnimator(animatorConfig, callbacks, make) {
|
|
7717
8034
|
let apiRef;
|
|
7718
8035
|
let effectiveCallbacks = callbacks;
|
|
@@ -7734,6 +8051,59 @@ var PixodeskAnimatorReact = (() => {
|
|
|
7734
8051
|
}
|
|
7735
8052
|
function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
7736
8053
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
8054
|
+
if (isScrollTimeline(animatorConfig)) {
|
|
8055
|
+
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
8056
|
+
var _a, _b;
|
|
8057
|
+
let unpin = () => {
|
|
8058
|
+
};
|
|
8059
|
+
if (animatorConfig.mode !== PxAnimatorMode.frames && ((_a = animatorConfig.scroll) == null ? void 0 : _a.driver) === "native" && rootElement) {
|
|
8060
|
+
unpin = applyScrollPin(rootElement, animatorConfig.scroll);
|
|
8061
|
+
const native = createNativeScrollTimeline(rootElement, animatorConfig);
|
|
8062
|
+
if (native) {
|
|
8063
|
+
const api2 = createWebApiAnimator(
|
|
8064
|
+
doc,
|
|
8065
|
+
cb,
|
|
8066
|
+
rootElement,
|
|
8067
|
+
animatorConfig.mode === PxAnimatorMode.waapi,
|
|
8068
|
+
native
|
|
8069
|
+
);
|
|
8070
|
+
if (api2) {
|
|
8071
|
+
const destroyNative = api2.destroy.bind(api2);
|
|
8072
|
+
api2.destroy = () => {
|
|
8073
|
+
unpin();
|
|
8074
|
+
destroyNative();
|
|
8075
|
+
};
|
|
8076
|
+
return api2;
|
|
8077
|
+
}
|
|
8078
|
+
}
|
|
8079
|
+
unpin();
|
|
8080
|
+
unpin = () => {
|
|
8081
|
+
};
|
|
8082
|
+
}
|
|
8083
|
+
const api = (animatorConfig.mode !== PxAnimatorMode.frames ? createWebApiAnimator(doc, cb, rootElement, animatorConfig.mode === PxAnimatorMode.waapi) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
8084
|
+
const subject = ((_b = api.getRootElement) == null ? void 0 : _b.call(api)) || rootElement;
|
|
8085
|
+
if (subject) {
|
|
8086
|
+
unpin = applyScrollPin(subject, animatorConfig.scroll);
|
|
8087
|
+
const totalMs = scrollTotalDurationMs(animatorConfig);
|
|
8088
|
+
const driver = createScrollDriver(
|
|
8089
|
+
subject,
|
|
8090
|
+
animatorConfig,
|
|
8091
|
+
(progress) => api.setCurrentTime(progress * totalMs)
|
|
8092
|
+
);
|
|
8093
|
+
if (driver) {
|
|
8094
|
+
const destroy = api.destroy.bind(api);
|
|
8095
|
+
api.destroy = () => {
|
|
8096
|
+
driver.destroy();
|
|
8097
|
+
unpin();
|
|
8098
|
+
destroy();
|
|
8099
|
+
};
|
|
8100
|
+
}
|
|
8101
|
+
} else {
|
|
8102
|
+
console.warn("scroll timeline: no root element to observe \u2014 animation will stay at frame 0");
|
|
8103
|
+
}
|
|
8104
|
+
return api;
|
|
8105
|
+
});
|
|
8106
|
+
}
|
|
7737
8107
|
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
7738
8108
|
if (animatorConfig.mode === PxAnimatorMode.frames) {
|
|
7739
8109
|
return createFrameLoopAnimator(doc, adapter, cb, rootElement);
|