@pixodesk/svg-animator-vue 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 +1047 -677
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.umd.js
CHANGED
|
@@ -56813,114 +56813,582 @@ ${codeFrame}` : message);
|
|
|
56813
56813
|
return a;
|
|
56814
56814
|
};
|
|
56815
56815
|
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
56816
|
-
function
|
|
56817
|
-
|
|
56818
|
-
|
|
56819
|
-
|
|
56820
|
-
|
|
56821
|
-
|
|
56822
|
-
|
|
56823
|
-
|
|
56824
|
-
|
|
56825
|
-
|
|
56826
|
-
|
|
56827
|
-
|
|
56816
|
+
function bezierToSvgPath(path, forceCurves = false) {
|
|
56817
|
+
var _a, _b, _c, _d;
|
|
56818
|
+
const v = path.v;
|
|
56819
|
+
const i = path.i;
|
|
56820
|
+
const o = path.o;
|
|
56821
|
+
const c = path.c;
|
|
56822
|
+
if (!v.length) return "";
|
|
56823
|
+
const d = [];
|
|
56824
|
+
const len = v.length;
|
|
56825
|
+
d.push("M" + v[0][0] + "," + v[0][1]);
|
|
56826
|
+
for (let idx = 1; idx < len; idx++) {
|
|
56827
|
+
const prevV = v[idx - 1];
|
|
56828
|
+
const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
|
|
56829
|
+
const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
|
|
56830
|
+
const currV = v[idx];
|
|
56831
|
+
const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
|
|
56832
|
+
if (isLine) {
|
|
56833
|
+
d.push("L" + currV[0] + "," + currV[1]);
|
|
56834
|
+
} else {
|
|
56835
|
+
d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
|
|
56836
|
+
}
|
|
56828
56837
|
}
|
|
56829
|
-
|
|
56830
|
-
|
|
56838
|
+
if (c && len > 0) {
|
|
56839
|
+
const lastV = v[len - 1];
|
|
56840
|
+
const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
|
|
56841
|
+
const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
|
|
56842
|
+
const firstV = v[0];
|
|
56843
|
+
const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
|
|
56844
|
+
if (!isLine) {
|
|
56845
|
+
d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
|
|
56846
|
+
}
|
|
56847
|
+
d.push("z");
|
|
56831
56848
|
}
|
|
56832
|
-
|
|
56833
|
-
|
|
56834
|
-
|
|
56835
|
-
|
|
56836
|
-
|
|
56837
|
-
|
|
56849
|
+
return d.join("");
|
|
56850
|
+
}
|
|
56851
|
+
function interpolateNum(a, b, t) {
|
|
56852
|
+
return a + (b - a) * t;
|
|
56853
|
+
}
|
|
56854
|
+
function interpolateVec(a, b, t) {
|
|
56855
|
+
const res = [];
|
|
56856
|
+
const count = Math.max(a.length, b.length);
|
|
56857
|
+
for (let i = 0; i < count; i++) {
|
|
56858
|
+
res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
|
|
56838
56859
|
}
|
|
56839
|
-
|
|
56840
|
-
|
|
56841
|
-
|
|
56860
|
+
return res;
|
|
56861
|
+
}
|
|
56862
|
+
function interpolateColor(a, b, t) {
|
|
56863
|
+
return [
|
|
56864
|
+
interpolateNum(a[0] || 0, b[0] || 0, t),
|
|
56865
|
+
interpolateNum(a[1] || 0, b[1] || 0, t),
|
|
56866
|
+
interpolateNum(a[2] || 0, b[2] || 0, t),
|
|
56867
|
+
interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
|
|
56868
|
+
];
|
|
56869
|
+
}
|
|
56870
|
+
function interpolateBeziers(paths1, paths2, progress) {
|
|
56871
|
+
const count = Math.max(paths1.length, paths2.length);
|
|
56872
|
+
const res = [];
|
|
56873
|
+
for (let i = 0; i < count; i++) {
|
|
56874
|
+
res.push(interpolateBezier(paths1[i], paths2[i], progress));
|
|
56842
56875
|
}
|
|
56843
|
-
|
|
56844
|
-
|
|
56845
|
-
|
|
56876
|
+
return res;
|
|
56877
|
+
}
|
|
56878
|
+
function interpolateBezier(path1, path2, progress) {
|
|
56879
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
56880
|
+
if (!path1 || !path2) return path1 || path2 || { v: [] };
|
|
56881
|
+
const t = Math.min(Math.max(progress, 0), 1);
|
|
56882
|
+
const len = Math.min(path1.v.length, path2.v.length);
|
|
56883
|
+
const v = [];
|
|
56884
|
+
const i = [];
|
|
56885
|
+
const o = [];
|
|
56886
|
+
for (let idx = 0; idx < len; idx++) {
|
|
56887
|
+
const v1 = path1.v[idx];
|
|
56888
|
+
const v2 = path2.v[idx];
|
|
56889
|
+
v.push(interpolateVec(v1, v2, t));
|
|
56890
|
+
const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
|
|
56891
|
+
const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
|
|
56892
|
+
i.push(interpolateVec(i1, i2, t));
|
|
56893
|
+
const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
|
|
56894
|
+
const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
|
|
56895
|
+
o.push(interpolateVec(o1, o2, t));
|
|
56846
56896
|
}
|
|
56847
|
-
|
|
56848
|
-
|
|
56897
|
+
return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
|
|
56898
|
+
}
|
|
56899
|
+
function remap(value, inMin, inMax, outMin, outMax) {
|
|
56900
|
+
if (inMax === inMin) return outMin;
|
|
56901
|
+
const t = (value - inMin) / (inMax - inMin);
|
|
56902
|
+
return outMin + t * (outMax - outMin);
|
|
56903
|
+
}
|
|
56904
|
+
function solveCubicBezierX(p1x, p2x, x) {
|
|
56905
|
+
if (x <= 0) return 0;
|
|
56906
|
+
if (x >= 1) return 1;
|
|
56907
|
+
const cx = 3 * p1x;
|
|
56908
|
+
const bx = 3 * (p2x - p1x) - cx;
|
|
56909
|
+
const ax = 1 - cx - bx;
|
|
56910
|
+
function sampleX(t) {
|
|
56911
|
+
return ((ax * t + bx) * t + cx) * t;
|
|
56849
56912
|
}
|
|
56850
|
-
|
|
56851
|
-
|
|
56852
|
-
constructor(_default = "") {
|
|
56853
|
-
super();
|
|
56854
|
-
this._default = _default;
|
|
56913
|
+
function sampleDX(t) {
|
|
56914
|
+
return (3 * ax * t + 2 * bx) * t + cx;
|
|
56855
56915
|
}
|
|
56856
|
-
|
|
56857
|
-
|
|
56916
|
+
let t2 = x;
|
|
56917
|
+
let t0 = 0;
|
|
56918
|
+
let t1 = 1;
|
|
56919
|
+
for (let i = 0; i < 8; i++) {
|
|
56920
|
+
const x2 = sampleX(t2) - x;
|
|
56921
|
+
if (Math.abs(x2) < 1e-6) return t2;
|
|
56922
|
+
const d2 = sampleDX(t2);
|
|
56923
|
+
if (Math.abs(d2) < 1e-6) break;
|
|
56924
|
+
t2 -= x2 / d2;
|
|
56858
56925
|
}
|
|
56859
|
-
|
|
56860
|
-
|
|
56861
|
-
|
|
56862
|
-
return
|
|
56926
|
+
t2 = x;
|
|
56927
|
+
while (t0 < t1) {
|
|
56928
|
+
const x2 = sampleX(t2);
|
|
56929
|
+
if (Math.abs(x2 - x) < 1e-6) return t2;
|
|
56930
|
+
if (x > x2) t0 = t2;
|
|
56931
|
+
else t1 = t2;
|
|
56932
|
+
t2 = (t1 + t0) / 2;
|
|
56863
56933
|
}
|
|
56864
|
-
|
|
56865
|
-
|
|
56866
|
-
|
|
56867
|
-
|
|
56868
|
-
|
|
56934
|
+
return t2;
|
|
56935
|
+
}
|
|
56936
|
+
function cubicBezier(easing) {
|
|
56937
|
+
const [p1x, p1y, p2x, p2y] = easing;
|
|
56938
|
+
const cy = 3 * p1y;
|
|
56939
|
+
const by = 3 * (p2y - p1y) - cy;
|
|
56940
|
+
const ay = 1 - cy - by;
|
|
56941
|
+
function sampleCurveY(t) {
|
|
56942
|
+
return ((ay * t + by) * t + cy) * t;
|
|
56869
56943
|
}
|
|
56870
|
-
|
|
56871
|
-
return
|
|
56944
|
+
return function(x) {
|
|
56945
|
+
return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
|
|
56946
|
+
};
|
|
56947
|
+
}
|
|
56948
|
+
function lerp2(a, b, t) {
|
|
56949
|
+
return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
56950
|
+
}
|
|
56951
|
+
function subdivideCubicBezier(p0, p1, p2, p3, t) {
|
|
56952
|
+
const q0 = lerp2(p0, p1, t);
|
|
56953
|
+
const q1 = lerp2(p1, p2, t);
|
|
56954
|
+
const q2 = lerp2(p2, p3, t);
|
|
56955
|
+
const r0 = lerp2(q0, q1, t);
|
|
56956
|
+
const r1 = lerp2(q1, q2, t);
|
|
56957
|
+
const s = lerp2(r0, r1, t);
|
|
56958
|
+
return {
|
|
56959
|
+
left: [p0, q0, r0, s],
|
|
56960
|
+
right: [s, r1, q2, p3]
|
|
56961
|
+
};
|
|
56962
|
+
}
|
|
56963
|
+
function splitEasing(easing, xFraction) {
|
|
56964
|
+
if (!easing) return { left: void 0, right: void 0 };
|
|
56965
|
+
if (xFraction <= 0) return { left: void 0, right: easing };
|
|
56966
|
+
if (xFraction >= 1) return { left: easing, right: void 0 };
|
|
56967
|
+
const [x1, y1, x2, y2] = easing;
|
|
56968
|
+
const t = solveCubicBezierX(x1, x2, xFraction);
|
|
56969
|
+
const p0 = [0, 0];
|
|
56970
|
+
const p1 = [x1, y1];
|
|
56971
|
+
const p2 = [x2, y2];
|
|
56972
|
+
const p3 = [1, 1];
|
|
56973
|
+
const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
|
|
56974
|
+
const sx = left[3][0];
|
|
56975
|
+
const sy = left[3][1];
|
|
56976
|
+
let leftEasing;
|
|
56977
|
+
if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
|
|
56978
|
+
leftEasing = [
|
|
56979
|
+
left[1][0] / sx,
|
|
56980
|
+
left[1][1] / sy,
|
|
56981
|
+
left[2][0] / sx,
|
|
56982
|
+
left[2][1] / sy
|
|
56983
|
+
];
|
|
56872
56984
|
}
|
|
56873
|
-
|
|
56874
|
-
|
|
56875
|
-
|
|
56876
|
-
|
|
56985
|
+
let rightEasing;
|
|
56986
|
+
const rx = 1 - sx;
|
|
56987
|
+
const ry = 1 - sy;
|
|
56988
|
+
if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
|
|
56989
|
+
rightEasing = [
|
|
56990
|
+
(right[1][0] - sx) / rx,
|
|
56991
|
+
(right[1][1] - sy) / ry,
|
|
56992
|
+
(right[2][0] - sx) / rx,
|
|
56993
|
+
(right[2][1] - sy) / ry
|
|
56994
|
+
];
|
|
56877
56995
|
}
|
|
56878
|
-
|
|
56879
|
-
|
|
56880
|
-
|
|
56881
|
-
|
|
56882
|
-
|
|
56996
|
+
return { left: leftEasing, right: rightEasing };
|
|
56997
|
+
}
|
|
56998
|
+
function reverseEasing(easing) {
|
|
56999
|
+
if (!easing) return void 0;
|
|
57000
|
+
return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
|
|
57001
|
+
}
|
|
57002
|
+
function toRGBA(color) {
|
|
57003
|
+
const r = Math.round(color[0] * 255);
|
|
57004
|
+
const g = Math.round(color[1] * 255);
|
|
57005
|
+
const b = Math.round(color[2] * 255);
|
|
57006
|
+
return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
|
|
57007
|
+
}
|
|
57008
|
+
function parseRgba(s) {
|
|
57009
|
+
var _a;
|
|
57010
|
+
const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
|
|
57011
|
+
if (!inner) throw new Error("Invalid rgb/rgba format");
|
|
57012
|
+
const parts = inner.split(",").map((v) => +v.trim());
|
|
57013
|
+
return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
|
|
57014
|
+
}
|
|
57015
|
+
function parseHex(s) {
|
|
57016
|
+
const hex = s.slice(1);
|
|
57017
|
+
const isShort = hex.length <= 4;
|
|
57018
|
+
const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
|
|
57019
|
+
const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
|
|
57020
|
+
const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
|
|
57021
|
+
const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
|
|
57022
|
+
const result = [
|
|
57023
|
+
parseInt(r, 16) / 255,
|
|
57024
|
+
parseInt(g, 16) / 255,
|
|
57025
|
+
parseInt(b, 16) / 255
|
|
57026
|
+
];
|
|
57027
|
+
if (a !== null) {
|
|
57028
|
+
result.push(parseInt(a, 16) / 255);
|
|
56883
57029
|
}
|
|
56884
|
-
|
|
56885
|
-
|
|
57030
|
+
return result;
|
|
57031
|
+
}
|
|
57032
|
+
function parseColor(s) {
|
|
57033
|
+
if (!s) return void 0;
|
|
57034
|
+
if (Array.isArray(s)) return s;
|
|
57035
|
+
if (typeof s !== "string") return void 0;
|
|
57036
|
+
if (s.startsWith("#")) {
|
|
57037
|
+
return parseHex(s);
|
|
57038
|
+
} else if (s.startsWith("rgb")) {
|
|
57039
|
+
return parseRgba(s);
|
|
57040
|
+
} else {
|
|
57041
|
+
console.warn("Unsupported color format: " + s);
|
|
56886
57042
|
}
|
|
56887
|
-
|
|
56888
|
-
|
|
56889
|
-
|
|
56890
|
-
|
|
57043
|
+
return void 0;
|
|
57044
|
+
}
|
|
57045
|
+
var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
57046
|
+
var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
57047
|
+
var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
57048
|
+
function composeTransformParts(parts, opts) {
|
|
57049
|
+
var _a;
|
|
57050
|
+
if (!parts) return "";
|
|
57051
|
+
const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
|
|
57052
|
+
const segs = [];
|
|
57053
|
+
const t = parts.translate;
|
|
57054
|
+
const o = parts.origin;
|
|
57055
|
+
const r = parts.rotate;
|
|
57056
|
+
const k = parts.skew;
|
|
57057
|
+
const s = parts.scale;
|
|
57058
|
+
const tu = withUnits ? "px" : "";
|
|
57059
|
+
const ru = withUnits ? "deg" : "";
|
|
57060
|
+
if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
|
|
57061
|
+
if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
|
|
57062
|
+
if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
|
|
57063
|
+
if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
|
|
57064
|
+
if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
|
|
57065
|
+
if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
|
|
57066
|
+
return segs.join("");
|
|
57067
|
+
}
|
|
57068
|
+
var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
57069
|
+
var DEFAULT_DURATION_MS = 1e3;
|
|
57070
|
+
function kebabToCamelCaseWord(kebab) {
|
|
57071
|
+
return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
|
|
57072
|
+
}
|
|
57073
|
+
function isCamelCaseWord(word) {
|
|
57074
|
+
return !word.includes("-") && /[a-z][A-Z]/.test(word);
|
|
57075
|
+
}
|
|
57076
|
+
var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
|
|
57077
|
+
// Transform/positioning
|
|
57078
|
+
"viewBox",
|
|
57079
|
+
"preserveAspectRatio",
|
|
57080
|
+
// Gradient
|
|
57081
|
+
"gradientUnits",
|
|
57082
|
+
"gradientTransform",
|
|
57083
|
+
"spreadMethod",
|
|
57084
|
+
// Pattern
|
|
57085
|
+
"patternUnits",
|
|
57086
|
+
"patternContentUnits",
|
|
57087
|
+
"patternTransform",
|
|
57088
|
+
// Clipping/masking
|
|
57089
|
+
"clipPathUnits",
|
|
57090
|
+
"maskUnits",
|
|
57091
|
+
"maskContentUnits",
|
|
57092
|
+
// Marker (SVG spec keeps these camelCase, like viewBox)
|
|
57093
|
+
"markerUnits",
|
|
57094
|
+
"markerWidth",
|
|
57095
|
+
"markerHeight",
|
|
57096
|
+
"refX",
|
|
57097
|
+
"refY",
|
|
57098
|
+
// Text
|
|
57099
|
+
"textLength",
|
|
57100
|
+
"lengthAdjust",
|
|
57101
|
+
"startOffset",
|
|
57102
|
+
// Filter
|
|
57103
|
+
"filterUnits",
|
|
57104
|
+
"primitiveUnits",
|
|
57105
|
+
"tableValues",
|
|
57106
|
+
// feFuncR/G/B/A transfer table (type="table")
|
|
57107
|
+
"stdDeviation",
|
|
57108
|
+
"baseFrequency",
|
|
57109
|
+
"numOctaves",
|
|
57110
|
+
"surfaceScale",
|
|
57111
|
+
"diffuseConstant",
|
|
57112
|
+
"specularConstant",
|
|
57113
|
+
"specularExponent",
|
|
57114
|
+
"kernelMatrix",
|
|
57115
|
+
"kernelUnitLength",
|
|
57116
|
+
"edgeMode",
|
|
57117
|
+
"preserveAlpha",
|
|
57118
|
+
"targetX",
|
|
57119
|
+
"targetY"
|
|
57120
|
+
// // Animation
|
|
57121
|
+
// 'attributeName',
|
|
57122
|
+
// 'attributeType',
|
|
57123
|
+
// 'calcMode',
|
|
57124
|
+
// 'keyTimes',
|
|
57125
|
+
// 'keySplines',
|
|
57126
|
+
// 'repeatCount',
|
|
57127
|
+
// 'repeatDur'
|
|
57128
|
+
]);
|
|
57129
|
+
function camelCaseToKebabWordIfNeeded(camel) {
|
|
57130
|
+
return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
57131
|
+
}
|
|
57132
|
+
function clamp(value, min, max) {
|
|
57133
|
+
return Math.max(min, Math.min(value, max));
|
|
57134
|
+
}
|
|
57135
|
+
function bezier2D_pointAt(P0, P1, P2, P3, t) {
|
|
57136
|
+
if (t <= 0) return [P0[0], P0[1]];
|
|
57137
|
+
if (t >= 1) return [P3[0], P3[1]];
|
|
57138
|
+
const u = 1 - t;
|
|
57139
|
+
const u2 = u * u;
|
|
57140
|
+
const u3 = u2 * u;
|
|
57141
|
+
const t2 = t * t;
|
|
57142
|
+
const t3 = t2 * t;
|
|
57143
|
+
const w0 = u3;
|
|
57144
|
+
const w1 = 3 * t * u2;
|
|
57145
|
+
const w2 = 3 * t2 * u;
|
|
57146
|
+
const w3 = t3;
|
|
57147
|
+
return [
|
|
57148
|
+
w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
|
|
57149
|
+
w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
|
|
57150
|
+
];
|
|
57151
|
+
}
|
|
57152
|
+
var BEZIER_T_NUDGE = 1e-4;
|
|
57153
|
+
function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
|
|
57154
|
+
const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
|
|
57155
|
+
if (result[0] === 0 && result[1] === 0) {
|
|
57156
|
+
const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
|
|
57157
|
+
return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
|
|
57158
|
+
}
|
|
57159
|
+
return result;
|
|
57160
|
+
}
|
|
57161
|
+
function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
|
|
57162
|
+
const u = 1 - t;
|
|
57163
|
+
const a = 3 * u * u;
|
|
57164
|
+
const b = 6 * t * u;
|
|
57165
|
+
const c = 3 * t * t;
|
|
57166
|
+
return [
|
|
57167
|
+
a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
|
|
57168
|
+
a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
|
|
57169
|
+
];
|
|
57170
|
+
}
|
|
57171
|
+
function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
|
|
57172
|
+
const n = steps + 1;
|
|
57173
|
+
const ts = new Float64Array(n);
|
|
57174
|
+
const ds = new Float64Array(n);
|
|
57175
|
+
let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
|
|
57176
|
+
ts[0] = 0;
|
|
57177
|
+
ds[0] = 0;
|
|
57178
|
+
let cum = 0;
|
|
57179
|
+
for (let i = 1; i < n; i++) {
|
|
57180
|
+
const t = i / steps;
|
|
57181
|
+
const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
|
|
57182
|
+
const dx = cur[0] - prev[0];
|
|
57183
|
+
const dy = cur[1] - prev[1];
|
|
57184
|
+
cum += Math.sqrt(dx * dx + dy * dy);
|
|
57185
|
+
ts[i] = t;
|
|
57186
|
+
ds[i] = cum;
|
|
57187
|
+
prev = cur;
|
|
57188
|
+
}
|
|
57189
|
+
return { ts, ds };
|
|
57190
|
+
}
|
|
57191
|
+
function bezier2D_tForDistance(lut, distance) {
|
|
57192
|
+
const { ts, ds } = lut;
|
|
57193
|
+
const last = ds.length - 1;
|
|
57194
|
+
if (distance <= 0) return ts[0];
|
|
57195
|
+
if (distance >= ds[last]) return ts[last];
|
|
57196
|
+
let lo = 1;
|
|
57197
|
+
let hi = last;
|
|
57198
|
+
while (lo < hi) {
|
|
57199
|
+
const mid = lo + hi >>> 1;
|
|
57200
|
+
if (ds[mid] < distance) lo = mid + 1;
|
|
57201
|
+
else hi = mid;
|
|
57202
|
+
}
|
|
57203
|
+
const dPrev = ds[hi - 1];
|
|
57204
|
+
const dCur = ds[hi];
|
|
57205
|
+
const span = dCur - dPrev;
|
|
57206
|
+
const frac = span > 0 ? (distance - dPrev) / span : 0;
|
|
57207
|
+
return ts[hi - 1] + frac * (ts[hi] - ts[hi - 1]);
|
|
57208
|
+
}
|
|
57209
|
+
function bezier2D_arcAtT(lut, t) {
|
|
57210
|
+
const { ts, ds } = lut;
|
|
57211
|
+
const last = ts.length - 1;
|
|
57212
|
+
if (t <= ts[0]) return ds[0];
|
|
57213
|
+
if (t >= ts[last]) return ds[last];
|
|
57214
|
+
let lo = 1, hi = last;
|
|
57215
|
+
while (lo < hi) {
|
|
57216
|
+
const mid = lo + hi >>> 1;
|
|
57217
|
+
if (ts[mid] < t) lo = mid + 1;
|
|
57218
|
+
else hi = mid;
|
|
57219
|
+
}
|
|
57220
|
+
const tPrev = ts[hi - 1];
|
|
57221
|
+
const span = ts[hi] - tPrev;
|
|
57222
|
+
const frac = span > 0 ? (t - tPrev) / span : 0;
|
|
57223
|
+
return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
|
|
57224
|
+
}
|
|
57225
|
+
function invertEasing(easing) {
|
|
57226
|
+
if (!easing) return (y) => y;
|
|
57227
|
+
const flipped = [easing[1], easing[0], easing[3], easing[2]];
|
|
57228
|
+
return cubicBezier(flipped);
|
|
57229
|
+
}
|
|
57230
|
+
function isScrollTimeline(config) {
|
|
57231
|
+
return (config == null ? void 0 : config.timelineSource) === "scroll";
|
|
57232
|
+
}
|
|
57233
|
+
function scrollTotalDurationMs(config) {
|
|
57234
|
+
const duration = typeof (config == null ? void 0 : config.duration) === "number" && config.duration > 0 ? config.duration : DEFAULT_DURATION_MS;
|
|
57235
|
+
const iterations = typeof (config == null ? void 0 : config.iterations) === "number" && config.iterations > 0 ? config.iterations : 1;
|
|
57236
|
+
return duration * iterations;
|
|
57237
|
+
}
|
|
57238
|
+
function scrollPhaseInterval(phase, subjectSize, scrollportSize) {
|
|
57239
|
+
const s = subjectSize, vp = scrollportSize;
|
|
57240
|
+
switch (phase) {
|
|
57241
|
+
case "cover":
|
|
57242
|
+
return [0, s + vp];
|
|
57243
|
+
case "entry":
|
|
57244
|
+
return [0, Math.min(s, vp)];
|
|
57245
|
+
case "contain":
|
|
57246
|
+
return [Math.min(s, vp), Math.max(s, vp)];
|
|
57247
|
+
case "exit":
|
|
57248
|
+
return [Math.max(s, vp), s + vp];
|
|
57249
|
+
case "entry-crossing":
|
|
57250
|
+
return [0, s];
|
|
57251
|
+
case "exit-crossing":
|
|
57252
|
+
return [vp, s + vp];
|
|
57253
|
+
}
|
|
57254
|
+
}
|
|
57255
|
+
var DEFAULT_PHASE = "cover";
|
|
57256
|
+
function resolveRangePointU(point, defaultFraction, subjectSize, scrollportSize) {
|
|
57257
|
+
var _a;
|
|
57258
|
+
const [u0, u1] = scrollPhaseInterval((_a = point == null ? void 0 : point.phase) != null ? _a : DEFAULT_PHASE, subjectSize, scrollportSize);
|
|
57259
|
+
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
57260
|
+
return u0 + fraction * (u1 - u0);
|
|
57261
|
+
}
|
|
57262
|
+
function scrollViewProgress(subjectStart, subjectSize, scrollportSize, range) {
|
|
57263
|
+
const u = scrollportSize - subjectStart;
|
|
57264
|
+
const uStart = resolveRangePointU(range == null ? void 0 : range.start, 0, subjectSize, scrollportSize);
|
|
57265
|
+
const uEnd = resolveRangePointU(range == null ? void 0 : range.end, 1, subjectSize, scrollportSize);
|
|
57266
|
+
if (uEnd <= uStart) return u >= uEnd ? 1 : 0;
|
|
57267
|
+
return clamp((u - uStart) / (uEnd - uStart), 0, 1);
|
|
57268
|
+
}
|
|
57269
|
+
function scrollOffsetProgress(offset, maxOffset, range) {
|
|
57270
|
+
var _a, _b;
|
|
57271
|
+
const raw = maxOffset > 0 ? clamp(offset / maxOffset, 0, 1) : 1;
|
|
57272
|
+
const start = typeof ((_a = range == null ? void 0 : range.start) == null ? void 0 : _a.fraction) === "number" ? range.start.fraction : 0;
|
|
57273
|
+
const end = typeof ((_b = range == null ? void 0 : range.end) == null ? void 0 : _b.fraction) === "number" ? range.end.fraction : 1;
|
|
57274
|
+
if (end <= start) return raw >= end ? 1 : 0;
|
|
57275
|
+
return clamp((raw - start) / (end - start), 0, 1);
|
|
57276
|
+
}
|
|
57277
|
+
function scrollResolveAxis(axis, writingMode) {
|
|
57278
|
+
const a = axis != null ? axis : "block";
|
|
57279
|
+
if (a === "x" || a === "y") return a;
|
|
57280
|
+
const vertical = !!writingMode && writingMode.startsWith("vertical");
|
|
57281
|
+
if (a === "inline") return vertical ? "y" : "x";
|
|
57282
|
+
return vertical ? "x" : "y";
|
|
57283
|
+
}
|
|
57284
|
+
function pathStr(path) {
|
|
57285
|
+
if (!path.length) return ".";
|
|
57286
|
+
let result = "";
|
|
57287
|
+
for (const seg of path) {
|
|
57288
|
+
if (seg.startsWith("[")) result += seg;
|
|
57289
|
+
else result += (result ? "." : "") + seg;
|
|
57290
|
+
}
|
|
57291
|
+
return result;
|
|
57292
|
+
}
|
|
57293
|
+
var Base = class {
|
|
57294
|
+
_canSanitize(raw) {
|
|
57295
|
+
return this.isValid(raw);
|
|
57296
|
+
}
|
|
57297
|
+
optional() {
|
|
57298
|
+
return new Optional(this);
|
|
56891
57299
|
}
|
|
56892
57300
|
};
|
|
56893
|
-
var
|
|
56894
|
-
constructor(
|
|
57301
|
+
var Optional = class extends Base {
|
|
57302
|
+
constructor(inner) {
|
|
56895
57303
|
super();
|
|
56896
|
-
this.
|
|
56897
|
-
this._default =
|
|
57304
|
+
this.inner = inner;
|
|
57305
|
+
this._default = void 0;
|
|
56898
57306
|
}
|
|
56899
57307
|
sanitize(raw) {
|
|
56900
|
-
|
|
57308
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
57309
|
+
return this.inner._canSanitize(raw) ? this.inner.sanitize(raw) : void 0;
|
|
56901
57310
|
}
|
|
56902
57311
|
isValid(raw, ctx, path) {
|
|
56903
|
-
if (raw ===
|
|
56904
|
-
|
|
56905
|
-
|
|
57312
|
+
if (raw === void 0 || raw === null) return true;
|
|
57313
|
+
return this.inner.isValid(raw, ctx, path);
|
|
57314
|
+
}
|
|
57315
|
+
_canSanitize(raw) {
|
|
57316
|
+
return raw === void 0 || raw === null || this.inner._canSanitize(raw);
|
|
56906
57317
|
}
|
|
56907
57318
|
};
|
|
56908
|
-
var
|
|
56909
|
-
constructor(
|
|
57319
|
+
var Str = class extends Base {
|
|
57320
|
+
constructor(_default = "") {
|
|
56910
57321
|
super();
|
|
56911
|
-
this.
|
|
56912
|
-
this._default = defaultVal != null ? defaultVal : values[0];
|
|
57322
|
+
this._default = _default;
|
|
56913
57323
|
}
|
|
56914
57324
|
sanitize(raw) {
|
|
56915
|
-
return
|
|
57325
|
+
return typeof raw === "string" ? raw : this._default;
|
|
56916
57326
|
}
|
|
56917
57327
|
isValid(raw, ctx, path) {
|
|
56918
|
-
if (
|
|
56919
|
-
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected
|
|
57328
|
+
if (typeof raw === "string") return true;
|
|
57329
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected string, got " + typeof raw);
|
|
56920
57330
|
return false;
|
|
56921
57331
|
}
|
|
56922
57332
|
};
|
|
56923
|
-
var
|
|
57333
|
+
var Num = class extends Base {
|
|
57334
|
+
constructor(_default = 0) {
|
|
57335
|
+
super();
|
|
57336
|
+
this._default = _default;
|
|
57337
|
+
}
|
|
57338
|
+
sanitize(raw) {
|
|
57339
|
+
return typeof raw === "number" && isFinite(raw) ? raw : this._default;
|
|
57340
|
+
}
|
|
57341
|
+
isValid(raw, ctx, path) {
|
|
57342
|
+
if (typeof raw === "number" && isFinite(raw)) return true;
|
|
57343
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected finite number, got " + JSON.stringify(raw));
|
|
57344
|
+
return false;
|
|
57345
|
+
}
|
|
57346
|
+
};
|
|
57347
|
+
var Bool = class extends Base {
|
|
57348
|
+
constructor(_default = false) {
|
|
57349
|
+
super();
|
|
57350
|
+
this._default = _default;
|
|
57351
|
+
}
|
|
57352
|
+
sanitize(raw) {
|
|
57353
|
+
return typeof raw === "boolean" ? raw : this._default;
|
|
57354
|
+
}
|
|
57355
|
+
isValid(raw, ctx, path) {
|
|
57356
|
+
if (typeof raw === "boolean") return true;
|
|
57357
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected boolean, got " + typeof raw);
|
|
57358
|
+
return false;
|
|
57359
|
+
}
|
|
57360
|
+
};
|
|
57361
|
+
var Literal = class extends Base {
|
|
57362
|
+
constructor(value) {
|
|
57363
|
+
super();
|
|
57364
|
+
this.value = value;
|
|
57365
|
+
this._default = value;
|
|
57366
|
+
}
|
|
57367
|
+
sanitize(raw) {
|
|
57368
|
+
return raw === this.value ? this.value : this._default;
|
|
57369
|
+
}
|
|
57370
|
+
isValid(raw, ctx, path) {
|
|
57371
|
+
if (raw === this.value) return true;
|
|
57372
|
+
ctx == null ? void 0 : ctx.errors.push(pathStr(path != null ? path : []) + ": expected " + JSON.stringify(this.value) + ", got " + JSON.stringify(raw));
|
|
57373
|
+
return false;
|
|
57374
|
+
}
|
|
57375
|
+
};
|
|
57376
|
+
var Enum = class extends Base {
|
|
57377
|
+
constructor(values, defaultVal) {
|
|
57378
|
+
super();
|
|
57379
|
+
this.values = values;
|
|
57380
|
+
this._default = defaultVal != null ? defaultVal : values[0];
|
|
57381
|
+
}
|
|
57382
|
+
sanitize(raw) {
|
|
57383
|
+
return this.values.includes(raw) ? raw : this._default;
|
|
57384
|
+
}
|
|
57385
|
+
isValid(raw, ctx, path) {
|
|
57386
|
+
if (this.values.includes(raw)) return true;
|
|
57387
|
+
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));
|
|
57388
|
+
return false;
|
|
57389
|
+
}
|
|
57390
|
+
};
|
|
57391
|
+
var Union = class extends Base {
|
|
56924
57392
|
constructor(schemas, defaultVal) {
|
|
56925
57393
|
super();
|
|
56926
57394
|
this.schemas = schemas;
|
|
@@ -57457,6 +57925,28 @@ ${codeFrame}` : message);
|
|
|
57457
57925
|
styles: px.record(px.any()).optional(),
|
|
57458
57926
|
glyphs: px.record(PxGlyphFontSchema).optional()
|
|
57459
57927
|
}));
|
|
57928
|
+
var PX_SCROLL_PHASES = ["cover", "contain", "entry", "exit", "entry-crossing", "exit-crossing"];
|
|
57929
|
+
var PxScrollRangePointSchema = implementsInterface()(px.object({
|
|
57930
|
+
phase: px.enum(PX_SCROLL_PHASES).optional(),
|
|
57931
|
+
fraction: px.number().optional()
|
|
57932
|
+
}));
|
|
57933
|
+
var PxScrollRangeSchema = px.object({
|
|
57934
|
+
start: PxScrollRangePointSchema.optional(),
|
|
57935
|
+
end: PxScrollRangePointSchema.optional()
|
|
57936
|
+
});
|
|
57937
|
+
var PxScrollSchema = implementsInterface()(px.object({
|
|
57938
|
+
driver: px.enum(["custom", "native"]).optional(),
|
|
57939
|
+
kind: px.enum(["view", "scroll"]).optional(),
|
|
57940
|
+
axis: px.enum(["block", "inline", "x", "y"]).optional(),
|
|
57941
|
+
source: px.enum(["nearest", "root"]).optional(),
|
|
57942
|
+
// Free-form: the two keywords `parent`/`scroller` plus any CSS selector.
|
|
57943
|
+
subject: px.string().optional(),
|
|
57944
|
+
smoothing: px.number().optional(),
|
|
57945
|
+
pin: px.boolean().optional(),
|
|
57946
|
+
pinTop: px.number().optional(),
|
|
57947
|
+
pinDistance: px.number().optional(),
|
|
57948
|
+
range: PxScrollRangeSchema.optional()
|
|
57949
|
+
}));
|
|
57460
57950
|
var PxAnimatorConfigSchema = implementsInterface()(px.object({
|
|
57461
57951
|
mode: px.enum([PxAnimatorMode.auto, PxAnimatorMode.waapi, PxAnimatorMode.frames]).optional(),
|
|
57462
57952
|
duration: px.number().optional(),
|
|
@@ -57472,607 +57962,194 @@ ${codeFrame}` : message);
|
|
|
57472
57962
|
definitions: PxDefsSchema.optional(),
|
|
57473
57963
|
animateById: px.record(PxElementAnimationSchema).optional(),
|
|
57474
57964
|
timelineSource: px.string().optional(),
|
|
57965
|
+
scroll: PxScrollSchema.optional(),
|
|
57475
57966
|
debugInstName: px.string().optional()
|
|
57476
57967
|
}));
|
|
57477
57968
|
var PxBindingSchema = implementsInterface()(px.object({
|
|
57478
57969
|
id: px.string(),
|
|
57479
|
-
animate: PxElementAnimationSchema
|
|
57480
|
-
}));
|
|
57481
|
-
var PxAttrValueSchema = px.union([
|
|
57482
|
-
px.string(),
|
|
57483
|
-
px.number(),
|
|
57484
|
-
px.array(px.number()),
|
|
57485
|
-
// Structured static — `{value: …}` (read-accepted transitional spelling, S1).
|
|
57486
|
-
// `defined`, not `any`: the KEY's presence is what identifies this branch (V6).
|
|
57487
|
-
px.object({ value: px.defined() }),
|
|
57488
|
-
// Bare transform parts record — the canonical static `transform` on the wire (T2).
|
|
57489
|
-
PxTransformPartsSchema
|
|
57490
|
-
]);
|
|
57491
|
-
var PxAnimatableNumberSchema = px.union([
|
|
57492
|
-
px.number(),
|
|
57493
|
-
px.object({ value: px.number() }),
|
|
57494
|
-
PxPropertyAnimationSchema
|
|
57495
|
-
]);
|
|
57496
|
-
var PxAnimatableVec2Schema = px.union([
|
|
57497
|
-
px.tuple([px.number(), px.number()]),
|
|
57498
|
-
px.object({ value: px.tuple([px.number(), px.number()]) }),
|
|
57499
|
-
PxPropertyAnimationSchema
|
|
57500
|
-
]);
|
|
57501
|
-
var PxAnimatableStringSchema = px.union([
|
|
57502
|
-
px.string(),
|
|
57503
|
-
px.object({ value: px.string() }),
|
|
57504
|
-
PxPropertyAnimationSchema
|
|
57505
|
-
]);
|
|
57506
|
-
var PxTransformByEffectSchema = implementsInterface()(px.object({
|
|
57507
|
-
translate: PxAnimatableVec2Schema.optional(),
|
|
57508
|
-
rotate: PxAnimatableNumberSchema.optional(),
|
|
57509
|
-
scale: PxAnimatableVec2Schema.optional(),
|
|
57510
|
-
skew: PxAnimatableNumberSchema.optional(),
|
|
57511
|
-
origin: PxAnimatableVec2Schema.optional()
|
|
57512
|
-
}));
|
|
57513
|
-
var PxRepeaterEffectSchema = implementsInterface()(px.object({
|
|
57514
|
-
// STATIC config, not a channel (V2/SCHEMA-DESIGN R5): the copy COUNT is read
|
|
57515
|
-
// once at expansion time and never sampled — plain number, no `keyframes`.
|
|
57516
|
-
copies: px.number().optional(),
|
|
57517
|
-
translate: PxAnimatableVec2Schema.optional(),
|
|
57518
|
-
rotate: PxAnimatableNumberSchema.optional(),
|
|
57519
|
-
skew: PxAnimatableNumberSchema.optional(),
|
|
57520
|
-
scale: PxAnimatableVec2Schema.optional(),
|
|
57521
|
-
origin: PxAnimatableVec2Schema.optional()
|
|
57522
|
-
}));
|
|
57523
|
-
var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
57524
|
-
sourceId: px.string().optional(),
|
|
57525
|
-
maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
|
|
57526
|
-
maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
57527
|
-
maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
57528
|
-
x: px.number().optional(),
|
|
57529
|
-
y: px.number().optional(),
|
|
57530
|
-
width: px.number().optional(),
|
|
57531
|
-
height: px.number().optional()
|
|
57532
|
-
}));
|
|
57533
|
-
var PxClipPathEffectSchema = implementsInterface()(px.object({
|
|
57534
|
-
d: PxAnimatableStringSchema.optional(),
|
|
57535
|
-
animate: PxPropertyAnimationSchema.optional()
|
|
57536
|
-
}));
|
|
57537
|
-
var PxTrimPathEffectSchema = implementsInterface()(px.object({
|
|
57538
|
-
offset: PxAnimatableNumberSchema.optional(),
|
|
57539
|
-
range: PxAnimatableVec2Schema.optional(),
|
|
57540
|
-
subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
|
|
57541
|
-
}));
|
|
57542
|
-
var PxRetimeEffectSchema = implementsInterface()(px.object({
|
|
57543
|
-
sourceId: px.string().optional(),
|
|
57544
|
-
start: px.number().optional(),
|
|
57545
|
-
stretch: px.number().optional(),
|
|
57546
|
-
timeCrop: px.tuple([px.number(), px.number()]).optional()
|
|
57547
|
-
}));
|
|
57548
|
-
var PxCloneEffectSchema = implementsInterface()(px.object({
|
|
57549
|
-
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
57550
|
-
type: px.enum([PxCloneType.content]).optional(),
|
|
57551
|
-
sourceId: px.string().optional(),
|
|
57552
|
-
retime: PxRetimeEffectSchema.optional()
|
|
57553
|
-
}));
|
|
57554
|
-
var PxGradientStopSchema = implementsInterface()(px.object({
|
|
57555
|
-
offset: px.number(),
|
|
57556
|
-
color: px.string()
|
|
57557
|
-
}));
|
|
57558
|
-
var PxAnimatableGradientStopsSchema = px.union([
|
|
57559
|
-
px.array(PxGradientStopSchema),
|
|
57560
|
-
px.object({ value: px.array(PxGradientStopSchema) }),
|
|
57561
|
-
PxPropertyAnimationSchema
|
|
57562
|
-
]);
|
|
57563
|
-
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
57564
|
-
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
57565
|
-
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
57566
|
-
p1: PxAnimatableVec2Schema.optional(),
|
|
57567
|
-
p2: PxAnimatableVec2Schema.optional(),
|
|
57568
|
-
c: PxAnimatableVec2Schema.optional(),
|
|
57569
|
-
r: PxAnimatableNumberSchema.optional(),
|
|
57570
|
-
fp: PxAnimatableVec2Schema.optional(),
|
|
57571
|
-
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
57572
|
-
gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
|
|
57573
|
-
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
|
|
57574
|
-
gradientTransform: px.string().optional()
|
|
57575
|
-
}));
|
|
57576
|
-
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
57577
|
-
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
57578
|
-
path: px.string(),
|
|
57579
|
-
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
|
|
57580
|
-
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
|
|
57581
|
-
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
|
|
57582
|
-
spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
|
|
57583
|
-
startOffset: PxAnimatableNumberSchema.optional(),
|
|
57584
|
-
textLength: PxAnimatableNumberSchema.optional()
|
|
57585
|
-
}));
|
|
57586
|
-
var PxTextEffectSchema = implementsInterface()(px.object({
|
|
57587
|
-
useGlyphs: px.boolean().optional()
|
|
57588
|
-
}));
|
|
57589
|
-
var PxEffectsSchema = implementsInterface()(px.object({
|
|
57590
|
-
transformBy: PxTransformByEffectSchema.optional(),
|
|
57591
|
-
repeater: PxRepeaterEffectSchema.optional(),
|
|
57592
|
-
maskedBy: PxMaskedByEffectSchema.optional(),
|
|
57593
|
-
clipPath: PxClipPathEffectSchema.optional(),
|
|
57594
|
-
trimPath: PxTrimPathEffectSchema.optional(),
|
|
57595
|
-
clone: PxCloneEffectSchema.optional(),
|
|
57596
|
-
fillGradient: PxFillGradientEffectSchema.optional(),
|
|
57597
|
-
strokeGradient: PxStrokeGradientEffectSchema.optional(),
|
|
57598
|
-
textPath: PxTextPathEffectSchema.optional(),
|
|
57599
|
-
text: PxTextEffectSchema.optional()
|
|
57600
|
-
}));
|
|
57601
|
-
function validateNodeEffects(root, opts) {
|
|
57602
|
-
const warnings = [];
|
|
57603
|
-
const walk = (node, path) => {
|
|
57604
|
-
if (node && node.effects) {
|
|
57605
|
-
const ctx = { errors: [], warnings: [], strict: !!(opts == null ? void 0 : opts.strict) };
|
|
57606
|
-
const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
|
|
57607
|
-
if (!ok) {
|
|
57608
|
-
for (const err of ctx.errors) warnings.push(err);
|
|
57609
|
-
}
|
|
57610
|
-
}
|
|
57611
|
-
if (node && Array.isArray(node.children)) {
|
|
57612
|
-
node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]"));
|
|
57613
|
-
}
|
|
57614
|
-
};
|
|
57615
|
-
walk(root, "root");
|
|
57616
|
-
return warnings;
|
|
57617
|
-
}
|
|
57618
|
-
var PxNodeBase = px.openObject({
|
|
57619
|
-
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
57620
|
-
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
57621
|
-
// (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
|
|
57622
|
-
// `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
|
|
57623
|
-
// the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
|
|
57624
|
-
// would add words that all mean "type" and still need the carrier to read.
|
|
57625
|
-
// Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
|
|
57626
|
-
// (issues V3), never of distinct key names.
|
|
57627
|
-
type: px.string(),
|
|
57628
|
-
id: px.string().optional(),
|
|
57629
|
-
meta: px.any().optional(),
|
|
57630
|
-
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
57631
|
-
// Consumed and removed by `applyPlayerEffects` before any other normalisation
|
|
57632
|
-
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
57633
|
-
effects: PxEffectsSchema.optional(),
|
|
57634
|
-
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
57635
|
-
// string ref / array of refs / inline definition / mixed array; mirrors
|
|
57636
|
-
// `animator.animateById` map values and what `processNode` resolves at runtime.
|
|
57637
|
-
animate: PxElementAnimationSchema.optional(),
|
|
57638
|
-
style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
|
|
57639
|
-
}, PxAttrValueSchema);
|
|
57640
|
-
var PxNodeSchema = px.openObject(__spreadProps2(__spreadValues2({}, PxNodeBase._shape), {
|
|
57641
|
-
children: px.lazy(() => px.array(PxNodeSchema), []).optional()
|
|
57642
|
-
}), PxAttrValueSchema);
|
|
57643
|
-
var PxSvgNodeExtra = px.object({
|
|
57644
|
-
// `"100%"` and other SVG length strings are legal here — a number-only slot rejected
|
|
57645
|
-
// real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
|
|
57646
|
-
width: px.union([px.number(), px.string()]).optional(),
|
|
57647
|
-
height: px.union([px.number(), px.string()]).optional(),
|
|
57648
|
-
viewBox: px.string().optional(),
|
|
57649
|
-
animator: PxAnimatorConfigSchema.optional()
|
|
57650
|
-
});
|
|
57651
|
-
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps2(__spreadValues2(__spreadValues2({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
|
|
57652
|
-
type: px.literal("svg"),
|
|
57653
|
-
// override string → literal to require 'svg'
|
|
57654
|
-
children: px.array(PxNodeSchema).optional()
|
|
57655
|
-
}), PxAttrValueSchema);
|
|
57656
|
-
var PxBezierPathSchema = implementsInterface()(px.object({
|
|
57657
|
-
v: px.array(px.array(px.number())),
|
|
57658
|
-
i: px.array(px.array(px.number())).optional(),
|
|
57659
|
-
o: px.array(px.array(px.number())).optional(),
|
|
57660
|
-
c: px.boolean().optional()
|
|
57661
|
-
}));
|
|
57662
|
-
function bezierToSvgPath(path, forceCurves = false) {
|
|
57663
|
-
var _a, _b, _c, _d;
|
|
57664
|
-
const v = path.v;
|
|
57665
|
-
const i = path.i;
|
|
57666
|
-
const o = path.o;
|
|
57667
|
-
const c = path.c;
|
|
57668
|
-
if (!v.length) return "";
|
|
57669
|
-
const d = [];
|
|
57670
|
-
const len = v.length;
|
|
57671
|
-
d.push("M" + v[0][0] + "," + v[0][1]);
|
|
57672
|
-
for (let idx = 1; idx < len; idx++) {
|
|
57673
|
-
const prevV = v[idx - 1];
|
|
57674
|
-
const prevO = (_a = o == null ? void 0 : o[idx - 1]) != null ? _a : prevV;
|
|
57675
|
-
const currI = (_b = i == null ? void 0 : i[idx]) != null ? _b : v[idx];
|
|
57676
|
-
const currV = v[idx];
|
|
57677
|
-
const isLine = !forceCurves && (prevO[0] === prevV[0] && prevO[1] === prevV[1]) && (currI[0] === currV[0] && currI[1] === currV[1]);
|
|
57678
|
-
if (isLine) {
|
|
57679
|
-
d.push("L" + currV[0] + "," + currV[1]);
|
|
57680
|
-
} else {
|
|
57681
|
-
d.push("C" + prevO[0] + "," + prevO[1] + "," + currI[0] + "," + currI[1] + "," + currV[0] + "," + currV[1]);
|
|
57682
|
-
}
|
|
57683
|
-
}
|
|
57684
|
-
if (c && len > 0) {
|
|
57685
|
-
const lastV = v[len - 1];
|
|
57686
|
-
const lastO = (_c = o == null ? void 0 : o[len - 1]) != null ? _c : lastV;
|
|
57687
|
-
const firstI = (_d = i == null ? void 0 : i[0]) != null ? _d : v[0];
|
|
57688
|
-
const firstV = v[0];
|
|
57689
|
-
const isLine = !forceCurves && (lastO[0] === lastV[0] && lastO[1] === lastV[1]) && (firstI[0] === firstV[0] && firstI[1] === firstV[1]);
|
|
57690
|
-
if (!isLine) {
|
|
57691
|
-
d.push("C" + lastO[0] + "," + lastO[1] + "," + firstI[0] + "," + firstI[1] + "," + firstV[0] + "," + firstV[1]);
|
|
57692
|
-
}
|
|
57693
|
-
d.push("z");
|
|
57694
|
-
}
|
|
57695
|
-
return d.join("");
|
|
57696
|
-
}
|
|
57697
|
-
function interpolateNum(a, b, t) {
|
|
57698
|
-
return a + (b - a) * t;
|
|
57699
|
-
}
|
|
57700
|
-
function interpolateVec(a, b, t) {
|
|
57701
|
-
const res = [];
|
|
57702
|
-
const count = Math.max(a.length, b.length);
|
|
57703
|
-
for (let i = 0; i < count; i++) {
|
|
57704
|
-
res[i] = interpolateNum(a[i] || 0, b[i] || 0, t);
|
|
57705
|
-
}
|
|
57706
|
-
return res;
|
|
57707
|
-
}
|
|
57708
|
-
function interpolateColor(a, b, t) {
|
|
57709
|
-
return [
|
|
57710
|
-
interpolateNum(a[0] || 0, b[0] || 0, t),
|
|
57711
|
-
interpolateNum(a[1] || 0, b[1] || 0, t),
|
|
57712
|
-
interpolateNum(a[2] || 0, b[2] || 0, t),
|
|
57713
|
-
interpolateNum(a[3] === void 0 ? 1 : a[3], b[3] === void 0 ? 1 : b[3], t)
|
|
57714
|
-
];
|
|
57715
|
-
}
|
|
57716
|
-
function interpolateBeziers(paths1, paths2, progress) {
|
|
57717
|
-
const count = Math.max(paths1.length, paths2.length);
|
|
57718
|
-
const res = [];
|
|
57719
|
-
for (let i = 0; i < count; i++) {
|
|
57720
|
-
res.push(interpolateBezier(paths1[i], paths2[i], progress));
|
|
57721
|
-
}
|
|
57722
|
-
return res;
|
|
57723
|
-
}
|
|
57724
|
-
function interpolateBezier(path1, path2, progress) {
|
|
57725
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
57726
|
-
if (!path1 || !path2) return path1 || path2 || { v: [] };
|
|
57727
|
-
const t = Math.min(Math.max(progress, 0), 1);
|
|
57728
|
-
const len = Math.min(path1.v.length, path2.v.length);
|
|
57729
|
-
const v = [];
|
|
57730
|
-
const i = [];
|
|
57731
|
-
const o = [];
|
|
57732
|
-
for (let idx = 0; idx < len; idx++) {
|
|
57733
|
-
const v1 = path1.v[idx];
|
|
57734
|
-
const v2 = path2.v[idx];
|
|
57735
|
-
v.push(interpolateVec(v1, v2, t));
|
|
57736
|
-
const i1 = (_b = (_a = path1.i) == null ? void 0 : _a[idx]) != null ? _b : v1;
|
|
57737
|
-
const i2 = (_d = (_c = path2.i) == null ? void 0 : _c[idx]) != null ? _d : v2;
|
|
57738
|
-
i.push(interpolateVec(i1, i2, t));
|
|
57739
|
-
const o1 = (_f = (_e = path1.o) == null ? void 0 : _e[idx]) != null ? _f : v1;
|
|
57740
|
-
const o2 = (_h = (_g = path2.o) == null ? void 0 : _g[idx]) != null ? _h : v2;
|
|
57741
|
-
o.push(interpolateVec(o1, o2, t));
|
|
57742
|
-
}
|
|
57743
|
-
return { v, i: i.length ? i : void 0, o: o.length ? o : void 0, c: (_i = path1.c) != null ? _i : path2.c };
|
|
57744
|
-
}
|
|
57745
|
-
function remap(value, inMin, inMax, outMin, outMax) {
|
|
57746
|
-
if (inMax === inMin) return outMin;
|
|
57747
|
-
const t = (value - inMin) / (inMax - inMin);
|
|
57748
|
-
return outMin + t * (outMax - outMin);
|
|
57749
|
-
}
|
|
57750
|
-
function solveCubicBezierX(p1x, p2x, x) {
|
|
57751
|
-
if (x <= 0) return 0;
|
|
57752
|
-
if (x >= 1) return 1;
|
|
57753
|
-
const cx = 3 * p1x;
|
|
57754
|
-
const bx = 3 * (p2x - p1x) - cx;
|
|
57755
|
-
const ax = 1 - cx - bx;
|
|
57756
|
-
function sampleX(t) {
|
|
57757
|
-
return ((ax * t + bx) * t + cx) * t;
|
|
57758
|
-
}
|
|
57759
|
-
function sampleDX(t) {
|
|
57760
|
-
return (3 * ax * t + 2 * bx) * t + cx;
|
|
57761
|
-
}
|
|
57762
|
-
let t2 = x;
|
|
57763
|
-
let t0 = 0;
|
|
57764
|
-
let t1 = 1;
|
|
57765
|
-
for (let i = 0; i < 8; i++) {
|
|
57766
|
-
const x2 = sampleX(t2) - x;
|
|
57767
|
-
if (Math.abs(x2) < 1e-6) return t2;
|
|
57768
|
-
const d2 = sampleDX(t2);
|
|
57769
|
-
if (Math.abs(d2) < 1e-6) break;
|
|
57770
|
-
t2 -= x2 / d2;
|
|
57771
|
-
}
|
|
57772
|
-
t2 = x;
|
|
57773
|
-
while (t0 < t1) {
|
|
57774
|
-
const x2 = sampleX(t2);
|
|
57775
|
-
if (Math.abs(x2 - x) < 1e-6) return t2;
|
|
57776
|
-
if (x > x2) t0 = t2;
|
|
57777
|
-
else t1 = t2;
|
|
57778
|
-
t2 = (t1 + t0) / 2;
|
|
57779
|
-
}
|
|
57780
|
-
return t2;
|
|
57781
|
-
}
|
|
57782
|
-
function cubicBezier(easing) {
|
|
57783
|
-
const [p1x, p1y, p2x, p2y] = easing;
|
|
57784
|
-
const cy = 3 * p1y;
|
|
57785
|
-
const by = 3 * (p2y - p1y) - cy;
|
|
57786
|
-
const ay = 1 - cy - by;
|
|
57787
|
-
function sampleCurveY(t) {
|
|
57788
|
-
return ((ay * t + by) * t + cy) * t;
|
|
57789
|
-
}
|
|
57790
|
-
return function(x) {
|
|
57791
|
-
return sampleCurveY(solveCubicBezierX(p1x, p2x, x));
|
|
57792
|
-
};
|
|
57793
|
-
}
|
|
57794
|
-
function lerp2(a, b, t) {
|
|
57795
|
-
return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
|
57796
|
-
}
|
|
57797
|
-
function subdivideCubicBezier(p0, p1, p2, p3, t) {
|
|
57798
|
-
const q0 = lerp2(p0, p1, t);
|
|
57799
|
-
const q1 = lerp2(p1, p2, t);
|
|
57800
|
-
const q2 = lerp2(p2, p3, t);
|
|
57801
|
-
const r0 = lerp2(q0, q1, t);
|
|
57802
|
-
const r1 = lerp2(q1, q2, t);
|
|
57803
|
-
const s = lerp2(r0, r1, t);
|
|
57804
|
-
return {
|
|
57805
|
-
left: [p0, q0, r0, s],
|
|
57806
|
-
right: [s, r1, q2, p3]
|
|
57807
|
-
};
|
|
57808
|
-
}
|
|
57809
|
-
function splitEasing(easing, xFraction) {
|
|
57810
|
-
if (!easing) return { left: void 0, right: void 0 };
|
|
57811
|
-
if (xFraction <= 0) return { left: void 0, right: easing };
|
|
57812
|
-
if (xFraction >= 1) return { left: easing, right: void 0 };
|
|
57813
|
-
const [x1, y1, x2, y2] = easing;
|
|
57814
|
-
const t = solveCubicBezierX(x1, x2, xFraction);
|
|
57815
|
-
const p0 = [0, 0];
|
|
57816
|
-
const p1 = [x1, y1];
|
|
57817
|
-
const p2 = [x2, y2];
|
|
57818
|
-
const p3 = [1, 1];
|
|
57819
|
-
const { left, right } = subdivideCubicBezier(p0, p1, p2, p3, t);
|
|
57820
|
-
const sx = left[3][0];
|
|
57821
|
-
const sy = left[3][1];
|
|
57822
|
-
let leftEasing;
|
|
57823
|
-
if (sx > 1e-9 && Math.abs(sy) > 1e-9) {
|
|
57824
|
-
leftEasing = [
|
|
57825
|
-
left[1][0] / sx,
|
|
57826
|
-
left[1][1] / sy,
|
|
57827
|
-
left[2][0] / sx,
|
|
57828
|
-
left[2][1] / sy
|
|
57829
|
-
];
|
|
57830
|
-
}
|
|
57831
|
-
let rightEasing;
|
|
57832
|
-
const rx = 1 - sx;
|
|
57833
|
-
const ry = 1 - sy;
|
|
57834
|
-
if (rx > 1e-9 && Math.abs(ry) > 1e-9) {
|
|
57835
|
-
rightEasing = [
|
|
57836
|
-
(right[1][0] - sx) / rx,
|
|
57837
|
-
(right[1][1] - sy) / ry,
|
|
57838
|
-
(right[2][0] - sx) / rx,
|
|
57839
|
-
(right[2][1] - sy) / ry
|
|
57840
|
-
];
|
|
57841
|
-
}
|
|
57842
|
-
return { left: leftEasing, right: rightEasing };
|
|
57843
|
-
}
|
|
57844
|
-
function reverseEasing(easing) {
|
|
57845
|
-
if (!easing) return void 0;
|
|
57846
|
-
return [1 - easing[2], 1 - easing[3], 1 - easing[0], 1 - easing[1]];
|
|
57847
|
-
}
|
|
57848
|
-
function toRGBA(color) {
|
|
57849
|
-
const r = Math.round(color[0] * 255);
|
|
57850
|
-
const g = Math.round(color[1] * 255);
|
|
57851
|
-
const b = Math.round(color[2] * 255);
|
|
57852
|
-
return color.length === 4 ? "rgba(" + r + "," + g + "," + b + "," + color[3] + ")" : "rgb(" + r + "," + g + "," + b + ")";
|
|
57853
|
-
}
|
|
57854
|
-
function parseRgba(s) {
|
|
57855
|
-
var _a;
|
|
57856
|
-
const inner = (_a = s.match(/rgba?\((.*)\)/)) == null ? void 0 : _a[1];
|
|
57857
|
-
if (!inner) throw new Error("Invalid rgb/rgba format");
|
|
57858
|
-
const parts = inner.split(",").map((v) => +v.trim());
|
|
57859
|
-
return [parts[0] / 255, parts[1] / 255, parts[2] / 255, ...parts[3] !== void 0 ? [parts[3]] : []];
|
|
57860
|
-
}
|
|
57861
|
-
function parseHex(s) {
|
|
57862
|
-
const hex = s.slice(1);
|
|
57863
|
-
const isShort = hex.length <= 4;
|
|
57864
|
-
const r = isShort ? hex[0] + hex[0] : hex.slice(0, 2);
|
|
57865
|
-
const g = isShort ? hex[1] + hex[1] : hex.slice(2, 4);
|
|
57866
|
-
const b = isShort ? hex[2] + hex[2] : hex.slice(4, 6);
|
|
57867
|
-
const a = hex.length === 4 ? hex[3] + hex[3] : hex.length === 8 ? hex.slice(6, 8) : null;
|
|
57868
|
-
const result = [
|
|
57869
|
-
parseInt(r, 16) / 255,
|
|
57870
|
-
parseInt(g, 16) / 255,
|
|
57871
|
-
parseInt(b, 16) / 255
|
|
57872
|
-
];
|
|
57873
|
-
if (a !== null) {
|
|
57874
|
-
result.push(parseInt(a, 16) / 255);
|
|
57875
|
-
}
|
|
57876
|
-
return result;
|
|
57877
|
-
}
|
|
57878
|
-
function parseColor(s) {
|
|
57879
|
-
if (!s) return void 0;
|
|
57880
|
-
if (Array.isArray(s)) return s;
|
|
57881
|
-
if (typeof s !== "string") return void 0;
|
|
57882
|
-
if (s.startsWith("#")) {
|
|
57883
|
-
return parseHex(s);
|
|
57884
|
-
} else if (s.startsWith("rgb")) {
|
|
57885
|
-
return parseRgba(s);
|
|
57886
|
-
} else {
|
|
57887
|
-
console.warn("Unsupported color format: " + s);
|
|
57888
|
-
}
|
|
57889
|
-
return void 0;
|
|
57890
|
-
}
|
|
57891
|
-
var COLOUR_ATTR_NAMES = /* @__PURE__ */ new Set(["color", "fill", "flood-color", "lighting-color", "stop-color", "stroke"]);
|
|
57892
|
-
var TRANSFORM_FN_NAMES = /* @__PURE__ */ new Set(["translate", "rotate", "scale", "skew"]);
|
|
57893
|
-
var PCT_BASED_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
57894
|
-
function composeTransformParts(parts, opts) {
|
|
57895
|
-
var _a;
|
|
57896
|
-
if (!parts) return "";
|
|
57897
|
-
const withUnits = (_a = opts == null ? void 0 : opts.withUnits) != null ? _a : true;
|
|
57898
|
-
const segs = [];
|
|
57899
|
-
const t = parts.translate;
|
|
57900
|
-
const o = parts.origin;
|
|
57901
|
-
const r = parts.rotate;
|
|
57902
|
-
const k = parts.skew;
|
|
57903
|
-
const s = parts.scale;
|
|
57904
|
-
const tu = withUnits ? "px" : "";
|
|
57905
|
-
const ru = withUnits ? "deg" : "";
|
|
57906
|
-
if (t) segs.push("translate(" + t[0] + tu + "," + t[1] + tu + ")");
|
|
57907
|
-
if (o) segs.push("translate(" + o[0] + tu + "," + o[1] + tu + ")");
|
|
57908
|
-
if (r !== void 0 && r !== null) segs.push("rotate(" + r + ru + ")");
|
|
57909
|
-
if (k !== void 0 && k !== null) segs.push("skewX(" + k + ru + ")");
|
|
57910
|
-
if (s) segs.push("scale(" + s[0] + "," + s[1] + ")");
|
|
57911
|
-
if (o) segs.push("translate(" + -o[0] + tu + "," + -o[1] + tu + ")");
|
|
57912
|
-
return segs.join("");
|
|
57913
|
-
}
|
|
57914
|
-
var STYLE_ATTR_NAMES = /* @__PURE__ */ new Set(["offset-distance", "offsetDistance"]);
|
|
57915
|
-
var DEFAULT_DURATION_MS = 1e3;
|
|
57916
|
-
function kebabToCamelCaseWord(kebab) {
|
|
57917
|
-
return kebab.includes("-") ? kebab.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase()) : kebab;
|
|
57918
|
-
}
|
|
57919
|
-
function isCamelCaseWord(word) {
|
|
57920
|
-
return !word.includes("-") && /[a-z][A-Z]/.test(word);
|
|
57921
|
-
}
|
|
57922
|
-
var SVG_CAMEL_CASE_ATTRS = /* @__PURE__ */ new Set([
|
|
57923
|
-
// Transform/positioning
|
|
57924
|
-
"viewBox",
|
|
57925
|
-
"preserveAspectRatio",
|
|
57926
|
-
// Gradient
|
|
57927
|
-
"gradientUnits",
|
|
57928
|
-
"gradientTransform",
|
|
57929
|
-
"spreadMethod",
|
|
57930
|
-
// Pattern
|
|
57931
|
-
"patternUnits",
|
|
57932
|
-
"patternContentUnits",
|
|
57933
|
-
"patternTransform",
|
|
57934
|
-
// Clipping/masking
|
|
57935
|
-
"clipPathUnits",
|
|
57936
|
-
"maskUnits",
|
|
57937
|
-
"maskContentUnits",
|
|
57938
|
-
// Marker (SVG spec keeps these camelCase, like viewBox)
|
|
57939
|
-
"markerUnits",
|
|
57940
|
-
"markerWidth",
|
|
57941
|
-
"markerHeight",
|
|
57942
|
-
"refX",
|
|
57943
|
-
"refY",
|
|
57944
|
-
// Text
|
|
57945
|
-
"textLength",
|
|
57946
|
-
"lengthAdjust",
|
|
57947
|
-
"startOffset",
|
|
57948
|
-
// Filter
|
|
57949
|
-
"filterUnits",
|
|
57950
|
-
"primitiveUnits",
|
|
57951
|
-
"tableValues",
|
|
57952
|
-
// feFuncR/G/B/A transfer table (type="table")
|
|
57953
|
-
"stdDeviation",
|
|
57954
|
-
"baseFrequency",
|
|
57955
|
-
"numOctaves",
|
|
57956
|
-
"surfaceScale",
|
|
57957
|
-
"diffuseConstant",
|
|
57958
|
-
"specularConstant",
|
|
57959
|
-
"specularExponent",
|
|
57960
|
-
"kernelMatrix",
|
|
57961
|
-
"kernelUnitLength",
|
|
57962
|
-
"edgeMode",
|
|
57963
|
-
"preserveAlpha",
|
|
57964
|
-
"targetX",
|
|
57965
|
-
"targetY"
|
|
57966
|
-
// // Animation
|
|
57967
|
-
// 'attributeName',
|
|
57968
|
-
// 'attributeType',
|
|
57969
|
-
// 'calcMode',
|
|
57970
|
-
// 'keyTimes',
|
|
57971
|
-
// 'keySplines',
|
|
57972
|
-
// 'repeatCount',
|
|
57973
|
-
// 'repeatDur'
|
|
57974
|
-
]);
|
|
57975
|
-
function camelCaseToKebabWordIfNeeded(camel) {
|
|
57976
|
-
return SVG_CAMEL_CASE_ATTRS.has(camel) ? camel : camel.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
57977
|
-
}
|
|
57978
|
-
function clamp(value, min, max) {
|
|
57979
|
-
return Math.max(min, Math.min(value, max));
|
|
57980
|
-
}
|
|
57981
|
-
function bezier2D_pointAt(P0, P1, P2, P3, t) {
|
|
57982
|
-
if (t <= 0) return [P0[0], P0[1]];
|
|
57983
|
-
if (t >= 1) return [P3[0], P3[1]];
|
|
57984
|
-
const u = 1 - t;
|
|
57985
|
-
const u2 = u * u;
|
|
57986
|
-
const u3 = u2 * u;
|
|
57987
|
-
const t2 = t * t;
|
|
57988
|
-
const t3 = t2 * t;
|
|
57989
|
-
const w0 = u3;
|
|
57990
|
-
const w1 = 3 * t * u2;
|
|
57991
|
-
const w2 = 3 * t2 * u;
|
|
57992
|
-
const w3 = t3;
|
|
57993
|
-
return [
|
|
57994
|
-
w0 * P0[0] + w1 * P1[0] + w2 * P2[0] + w3 * P3[0],
|
|
57995
|
-
w0 * P0[1] + w1 * P1[1] + w2 * P2[1] + w3 * P3[1]
|
|
57996
|
-
];
|
|
57997
|
-
}
|
|
57998
|
-
var BEZIER_T_NUDGE = 1e-4;
|
|
57999
|
-
function bezier2D_derivativeAt(P0, P1, P2, P3, t) {
|
|
58000
|
-
const result = _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t);
|
|
58001
|
-
if (result[0] === 0 && result[1] === 0) {
|
|
58002
|
-
const nudgedT = t < 0.5 ? t + BEZIER_T_NUDGE : t - BEZIER_T_NUDGE;
|
|
58003
|
-
return _bezier2D_derivativeAtRaw(P0, P1, P2, P3, nudgedT);
|
|
58004
|
-
}
|
|
58005
|
-
return result;
|
|
58006
|
-
}
|
|
58007
|
-
function _bezier2D_derivativeAtRaw(P0, P1, P2, P3, t) {
|
|
58008
|
-
const u = 1 - t;
|
|
58009
|
-
const a = 3 * u * u;
|
|
58010
|
-
const b = 6 * t * u;
|
|
58011
|
-
const c = 3 * t * t;
|
|
58012
|
-
return [
|
|
58013
|
-
a * (P1[0] - P0[0]) + b * (P2[0] - P1[0]) + c * (P3[0] - P2[0]),
|
|
58014
|
-
a * (P1[1] - P0[1]) + b * (P2[1] - P1[1]) + c * (P3[1] - P2[1])
|
|
58015
|
-
];
|
|
58016
|
-
}
|
|
58017
|
-
function bezier2D_arcLengthLUT(P0, P1, P2, P3, steps = 100) {
|
|
58018
|
-
const n = steps + 1;
|
|
58019
|
-
const ts = new Float64Array(n);
|
|
58020
|
-
const ds = new Float64Array(n);
|
|
58021
|
-
let prev = bezier2D_pointAt(P0, P1, P2, P3, 0);
|
|
58022
|
-
ts[0] = 0;
|
|
58023
|
-
ds[0] = 0;
|
|
58024
|
-
let cum = 0;
|
|
58025
|
-
for (let i = 1; i < n; i++) {
|
|
58026
|
-
const t = i / steps;
|
|
58027
|
-
const cur = bezier2D_pointAt(P0, P1, P2, P3, t);
|
|
58028
|
-
const dx = cur[0] - prev[0];
|
|
58029
|
-
const dy = cur[1] - prev[1];
|
|
58030
|
-
cum += Math.sqrt(dx * dx + dy * dy);
|
|
58031
|
-
ts[i] = t;
|
|
58032
|
-
ds[i] = cum;
|
|
58033
|
-
prev = cur;
|
|
58034
|
-
}
|
|
58035
|
-
return { ts, ds };
|
|
58036
|
-
}
|
|
58037
|
-
function bezier2D_tForDistance(lut, distance) {
|
|
58038
|
-
const { ts, ds } = lut;
|
|
58039
|
-
const last = ds.length - 1;
|
|
58040
|
-
if (distance <= 0) return ts[0];
|
|
58041
|
-
if (distance >= ds[last]) return ts[last];
|
|
58042
|
-
let lo = 1;
|
|
58043
|
-
let hi = last;
|
|
58044
|
-
while (lo < hi) {
|
|
58045
|
-
const mid = lo + hi >>> 1;
|
|
58046
|
-
if (ds[mid] < distance) lo = mid + 1;
|
|
58047
|
-
else hi = mid;
|
|
58048
|
-
}
|
|
58049
|
-
const dPrev = ds[hi - 1];
|
|
58050
|
-
const dCur = ds[hi];
|
|
58051
|
-
const span = dCur - dPrev;
|
|
58052
|
-
const frac = span > 0 ? (distance - dPrev) / span : 0;
|
|
58053
|
-
return ts[hi - 1] + frac * (ts[hi] - ts[hi - 1]);
|
|
58054
|
-
}
|
|
58055
|
-
function bezier2D_arcAtT(lut, t) {
|
|
58056
|
-
const { ts, ds } = lut;
|
|
58057
|
-
const last = ts.length - 1;
|
|
58058
|
-
if (t <= ts[0]) return ds[0];
|
|
58059
|
-
if (t >= ts[last]) return ds[last];
|
|
58060
|
-
let lo = 1, hi = last;
|
|
58061
|
-
while (lo < hi) {
|
|
58062
|
-
const mid = lo + hi >>> 1;
|
|
58063
|
-
if (ts[mid] < t) lo = mid + 1;
|
|
58064
|
-
else hi = mid;
|
|
58065
|
-
}
|
|
58066
|
-
const tPrev = ts[hi - 1];
|
|
58067
|
-
const span = ts[hi] - tPrev;
|
|
58068
|
-
const frac = span > 0 ? (t - tPrev) / span : 0;
|
|
58069
|
-
return ds[hi - 1] + frac * (ds[hi] - ds[hi - 1]);
|
|
58070
|
-
}
|
|
58071
|
-
function invertEasing(easing) {
|
|
58072
|
-
if (!easing) return (y) => y;
|
|
58073
|
-
const flipped = [easing[1], easing[0], easing[3], easing[2]];
|
|
58074
|
-
return cubicBezier(flipped);
|
|
57970
|
+
animate: PxElementAnimationSchema
|
|
57971
|
+
}));
|
|
57972
|
+
var PxAttrValueSchema = px.union([
|
|
57973
|
+
px.string(),
|
|
57974
|
+
px.number(),
|
|
57975
|
+
px.array(px.number()),
|
|
57976
|
+
// Structured static — `{value: …}` (read-accepted transitional spelling, S1).
|
|
57977
|
+
// `defined`, not `any`: the KEY's presence is what identifies this branch (V6).
|
|
57978
|
+
px.object({ value: px.defined() }),
|
|
57979
|
+
// Bare transform parts record — the canonical static `transform` on the wire (T2).
|
|
57980
|
+
PxTransformPartsSchema
|
|
57981
|
+
]);
|
|
57982
|
+
var PxAnimatableNumberSchema = px.union([
|
|
57983
|
+
px.number(),
|
|
57984
|
+
px.object({ value: px.number() }),
|
|
57985
|
+
PxPropertyAnimationSchema
|
|
57986
|
+
]);
|
|
57987
|
+
var PxAnimatableVec2Schema = px.union([
|
|
57988
|
+
px.tuple([px.number(), px.number()]),
|
|
57989
|
+
px.object({ value: px.tuple([px.number(), px.number()]) }),
|
|
57990
|
+
PxPropertyAnimationSchema
|
|
57991
|
+
]);
|
|
57992
|
+
var PxAnimatableStringSchema = px.union([
|
|
57993
|
+
px.string(),
|
|
57994
|
+
px.object({ value: px.string() }),
|
|
57995
|
+
PxPropertyAnimationSchema
|
|
57996
|
+
]);
|
|
57997
|
+
var PxTransformByEffectSchema = implementsInterface()(px.object({
|
|
57998
|
+
translate: PxAnimatableVec2Schema.optional(),
|
|
57999
|
+
rotate: PxAnimatableNumberSchema.optional(),
|
|
58000
|
+
scale: PxAnimatableVec2Schema.optional(),
|
|
58001
|
+
skew: PxAnimatableNumberSchema.optional(),
|
|
58002
|
+
origin: PxAnimatableVec2Schema.optional()
|
|
58003
|
+
}));
|
|
58004
|
+
var PxRepeaterEffectSchema = implementsInterface()(px.object({
|
|
58005
|
+
// STATIC config, not a channel (V2/SCHEMA-DESIGN R5): the copy COUNT is read
|
|
58006
|
+
// once at expansion time and never sampled — plain number, no `keyframes`.
|
|
58007
|
+
copies: px.number().optional(),
|
|
58008
|
+
translate: PxAnimatableVec2Schema.optional(),
|
|
58009
|
+
rotate: PxAnimatableNumberSchema.optional(),
|
|
58010
|
+
skew: PxAnimatableNumberSchema.optional(),
|
|
58011
|
+
scale: PxAnimatableVec2Schema.optional(),
|
|
58012
|
+
origin: PxAnimatableVec2Schema.optional()
|
|
58013
|
+
}));
|
|
58014
|
+
var PxMaskedByEffectSchema = implementsInterface()(px.object({
|
|
58015
|
+
sourceId: px.string().optional(),
|
|
58016
|
+
maskType: px.enum([PxMaskType.luminance, PxMaskType.alpha]).optional(),
|
|
58017
|
+
maskUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
58018
|
+
maskContentUnits: px.enum([PxUnits.userSpaceOnUse, PxUnits.objectBoundingBox]).optional(),
|
|
58019
|
+
x: px.number().optional(),
|
|
58020
|
+
y: px.number().optional(),
|
|
58021
|
+
width: px.number().optional(),
|
|
58022
|
+
height: px.number().optional()
|
|
58023
|
+
}));
|
|
58024
|
+
var PxClipPathEffectSchema = implementsInterface()(px.object({
|
|
58025
|
+
d: PxAnimatableStringSchema.optional(),
|
|
58026
|
+
animate: PxPropertyAnimationSchema.optional()
|
|
58027
|
+
}));
|
|
58028
|
+
var PxTrimPathEffectSchema = implementsInterface()(px.object({
|
|
58029
|
+
offset: PxAnimatableNumberSchema.optional(),
|
|
58030
|
+
range: PxAnimatableVec2Schema.optional(),
|
|
58031
|
+
subPaths: px.enum([PxTrimSubPaths.separate, PxTrimSubPaths.combined]).optional()
|
|
58032
|
+
}));
|
|
58033
|
+
var PxRetimeEffectSchema = implementsInterface()(px.object({
|
|
58034
|
+
sourceId: px.string().optional(),
|
|
58035
|
+
start: px.number().optional(),
|
|
58036
|
+
stretch: px.number().optional(),
|
|
58037
|
+
timeCrop: px.tuple([px.number(), px.number()]).optional()
|
|
58038
|
+
}));
|
|
58039
|
+
var PxCloneEffectSchema = implementsInterface()(px.object({
|
|
58040
|
+
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
58041
|
+
type: px.enum([PxCloneType.content]).optional(),
|
|
58042
|
+
sourceId: px.string().optional(),
|
|
58043
|
+
retime: PxRetimeEffectSchema.optional()
|
|
58044
|
+
}));
|
|
58045
|
+
var PxGradientStopSchema = implementsInterface()(px.object({
|
|
58046
|
+
offset: px.number(),
|
|
58047
|
+
color: px.string()
|
|
58048
|
+
}));
|
|
58049
|
+
var PxAnimatableGradientStopsSchema = px.union([
|
|
58050
|
+
px.array(PxGradientStopSchema),
|
|
58051
|
+
px.object({ value: px.array(PxGradientStopSchema) }),
|
|
58052
|
+
PxPropertyAnimationSchema
|
|
58053
|
+
]);
|
|
58054
|
+
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
58055
|
+
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
58056
|
+
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
58057
|
+
p1: PxAnimatableVec2Schema.optional(),
|
|
58058
|
+
p2: PxAnimatableVec2Schema.optional(),
|
|
58059
|
+
c: PxAnimatableVec2Schema.optional(),
|
|
58060
|
+
r: PxAnimatableNumberSchema.optional(),
|
|
58061
|
+
fp: PxAnimatableVec2Schema.optional(),
|
|
58062
|
+
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
58063
|
+
gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
|
|
58064
|
+
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
|
|
58065
|
+
gradientTransform: px.string().optional()
|
|
58066
|
+
}));
|
|
58067
|
+
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
58068
|
+
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
58069
|
+
path: px.string(),
|
|
58070
|
+
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
|
|
58071
|
+
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
|
|
58072
|
+
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
|
|
58073
|
+
spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
|
|
58074
|
+
startOffset: PxAnimatableNumberSchema.optional(),
|
|
58075
|
+
textLength: PxAnimatableNumberSchema.optional()
|
|
58076
|
+
}));
|
|
58077
|
+
var PxTextEffectSchema = implementsInterface()(px.object({
|
|
58078
|
+
useGlyphs: px.boolean().optional()
|
|
58079
|
+
}));
|
|
58080
|
+
var PxEffectsSchema = implementsInterface()(px.object({
|
|
58081
|
+
transformBy: PxTransformByEffectSchema.optional(),
|
|
58082
|
+
repeater: PxRepeaterEffectSchema.optional(),
|
|
58083
|
+
maskedBy: PxMaskedByEffectSchema.optional(),
|
|
58084
|
+
clipPath: PxClipPathEffectSchema.optional(),
|
|
58085
|
+
trimPath: PxTrimPathEffectSchema.optional(),
|
|
58086
|
+
clone: PxCloneEffectSchema.optional(),
|
|
58087
|
+
fillGradient: PxFillGradientEffectSchema.optional(),
|
|
58088
|
+
strokeGradient: PxStrokeGradientEffectSchema.optional(),
|
|
58089
|
+
textPath: PxTextPathEffectSchema.optional(),
|
|
58090
|
+
text: PxTextEffectSchema.optional()
|
|
58091
|
+
}));
|
|
58092
|
+
function validateNodeEffects(root, opts) {
|
|
58093
|
+
const warnings = [];
|
|
58094
|
+
const walk = (node, path) => {
|
|
58095
|
+
if (node && node.effects) {
|
|
58096
|
+
const ctx = { errors: [], warnings: [], strict: !!(opts == null ? void 0 : opts.strict) };
|
|
58097
|
+
const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
|
|
58098
|
+
if (!ok) {
|
|
58099
|
+
for (const err of ctx.errors) warnings.push(err);
|
|
58100
|
+
}
|
|
58101
|
+
}
|
|
58102
|
+
if (node && Array.isArray(node.children)) {
|
|
58103
|
+
node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]"));
|
|
58104
|
+
}
|
|
58105
|
+
};
|
|
58106
|
+
walk(root, "root");
|
|
58107
|
+
return warnings;
|
|
58075
58108
|
}
|
|
58109
|
+
var PxNodeBase = px.openObject({
|
|
58110
|
+
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
58111
|
+
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
58112
|
+
// (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
|
|
58113
|
+
// `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
|
|
58114
|
+
// the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
|
|
58115
|
+
// would add words that all mean "type" and still need the carrier to read.
|
|
58116
|
+
// Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
|
|
58117
|
+
// (issues V3), never of distinct key names.
|
|
58118
|
+
type: px.string(),
|
|
58119
|
+
id: px.string().optional(),
|
|
58120
|
+
meta: px.any().optional(),
|
|
58121
|
+
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
58122
|
+
// Consumed and removed by `applyPlayerEffects` before any other normalisation
|
|
58123
|
+
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
58124
|
+
effects: PxEffectsSchema.optional(),
|
|
58125
|
+
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
58126
|
+
// string ref / array of refs / inline definition / mixed array; mirrors
|
|
58127
|
+
// `animator.animateById` map values and what `processNode` resolves at runtime.
|
|
58128
|
+
animate: PxElementAnimationSchema.optional(),
|
|
58129
|
+
style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
|
|
58130
|
+
}, PxAttrValueSchema);
|
|
58131
|
+
var PxNodeSchema = px.openObject(__spreadProps2(__spreadValues2({}, PxNodeBase._shape), {
|
|
58132
|
+
children: px.lazy(() => px.array(PxNodeSchema), []).optional()
|
|
58133
|
+
}), PxAttrValueSchema);
|
|
58134
|
+
var PxSvgNodeExtra = px.object({
|
|
58135
|
+
// `"100%"` and other SVG length strings are legal here — a number-only slot rejected
|
|
58136
|
+
// real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
|
|
58137
|
+
width: px.union([px.number(), px.string()]).optional(),
|
|
58138
|
+
height: px.union([px.number(), px.string()]).optional(),
|
|
58139
|
+
viewBox: px.string().optional(),
|
|
58140
|
+
animator: PxAnimatorConfigSchema.optional()
|
|
58141
|
+
});
|
|
58142
|
+
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps2(__spreadValues2(__spreadValues2({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
|
|
58143
|
+
type: px.literal("svg"),
|
|
58144
|
+
// override string → literal to require 'svg'
|
|
58145
|
+
children: px.array(PxNodeSchema).optional()
|
|
58146
|
+
}), PxAttrValueSchema);
|
|
58147
|
+
var PxBezierPathSchema = implementsInterface()(px.object({
|
|
58148
|
+
v: px.array(px.array(px.number())),
|
|
58149
|
+
i: px.array(px.array(px.number())).optional(),
|
|
58150
|
+
o: px.array(px.array(px.number())).optional(),
|
|
58151
|
+
c: px.boolean().optional()
|
|
58152
|
+
}));
|
|
58076
58153
|
var _idCounter = 0;
|
|
58077
58154
|
function generateUniqueId() {
|
|
58078
58155
|
const timestamp = Date.now().toString(36);
|
|
@@ -62428,7 +62505,13 @@ ${codeFrame}` : message);
|
|
|
62428
62505
|
const api = __spreadProps(__spreadValues({}, basicApi), {
|
|
62429
62506
|
"getRootElement": () => rootElement || null
|
|
62430
62507
|
});
|
|
62431
|
-
if (config.trigger)
|
|
62508
|
+
if (config.trigger) {
|
|
62509
|
+
if (isScrollTimeline(config)) {
|
|
62510
|
+
console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
|
|
62511
|
+
} else {
|
|
62512
|
+
setupAnimationTriggers(api, config.trigger);
|
|
62513
|
+
}
|
|
62514
|
+
}
|
|
62432
62515
|
return api;
|
|
62433
62516
|
}
|
|
62434
62517
|
function createDomAdapter(rootElement) {
|
|
@@ -62554,7 +62637,7 @@ ${codeFrame}` : message);
|
|
|
62554
62637
|
}
|
|
62555
62638
|
return result;
|
|
62556
62639
|
}
|
|
62557
|
-
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs) {
|
|
62640
|
+
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs, scrollTimeline) {
|
|
62558
62641
|
var _a;
|
|
62559
62642
|
const config = getAnimatorConfig(doc) || {};
|
|
62560
62643
|
if (!rootElement) {
|
|
@@ -62613,7 +62696,12 @@ ${codeFrame}` : message);
|
|
|
62613
62696
|
if (keyframes.length > 0) {
|
|
62614
62697
|
try {
|
|
62615
62698
|
const effect = new KeyframeEffect(element, keyframes, effectOptions);
|
|
62616
|
-
const anim = new Animation(effect, document.timeline);
|
|
62699
|
+
const anim = new Animation(effect, scrollTimeline ? scrollTimeline.timeline : document.timeline);
|
|
62700
|
+
if (scrollTimeline) {
|
|
62701
|
+
const a = anim;
|
|
62702
|
+
if (scrollTimeline.rangeStart) a.rangeStart = scrollTimeline.rangeStart;
|
|
62703
|
+
if (scrollTimeline.rangeEnd) a.rangeEnd = scrollTimeline.rangeEnd;
|
|
62704
|
+
}
|
|
62617
62705
|
if (callbacks == null ? void 0 : callbacks.onFinish) anim.onfinish = () => {
|
|
62618
62706
|
var _a2;
|
|
62619
62707
|
if (finishNotified) return;
|
|
@@ -62707,10 +62795,239 @@ ${codeFrame}` : message);
|
|
|
62707
62795
|
}
|
|
62708
62796
|
};
|
|
62709
62797
|
if (config.trigger) {
|
|
62710
|
-
|
|
62798
|
+
if (config.timelineSource === "scroll") {
|
|
62799
|
+
console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
|
|
62800
|
+
} else {
|
|
62801
|
+
setupAnimationTriggers(api, config.trigger);
|
|
62802
|
+
}
|
|
62803
|
+
}
|
|
62804
|
+
if (scrollTimeline) {
|
|
62805
|
+
animations.forEach((a) => a.play());
|
|
62711
62806
|
}
|
|
62712
62807
|
return api;
|
|
62713
62808
|
}
|
|
62809
|
+
function nativeRangeOffset(point, defaultFraction, view) {
|
|
62810
|
+
var _a, _b, _c;
|
|
62811
|
+
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
62812
|
+
const pct = (_b = (_a = globalThis.CSS) == null ? void 0 : _a.percent) == null ? void 0 : _b.call(_a, fraction * 100);
|
|
62813
|
+
if (pct === void 0) return void 0;
|
|
62814
|
+
return view ? { rangeName: (_c = point == null ? void 0 : point.phase) != null ? _c : "cover", offset: pct } : { offset: pct };
|
|
62815
|
+
}
|
|
62816
|
+
function createNativeScrollTimeline(subject, config) {
|
|
62817
|
+
var _a, _b, _c, _d;
|
|
62818
|
+
if (!config || !isScrollTimeline(config)) return null;
|
|
62819
|
+
const scroll = config.scroll || {};
|
|
62820
|
+
const kind = (_a = scroll.kind) != null ? _a : "view";
|
|
62821
|
+
if (scroll.smoothing) {
|
|
62822
|
+
console.warn('scroll timeline: `smoothing` needs the built-in driver \u2014 ignoring `driver: "native"`');
|
|
62823
|
+
return null;
|
|
62824
|
+
}
|
|
62825
|
+
const g = globalThis;
|
|
62826
|
+
const view = kind === "view";
|
|
62827
|
+
const Ctor = view ? g.ViewTimeline : g.ScrollTimeline;
|
|
62828
|
+
if (typeof Ctor !== "function") return null;
|
|
62829
|
+
const axis = (_b = scroll.axis) != null ? _b : "block";
|
|
62830
|
+
let timeline;
|
|
62831
|
+
try {
|
|
62832
|
+
if (view) {
|
|
62833
|
+
timeline = new Ctor({ subject: resolveScrollSubject(subject, scroll.subject), axis });
|
|
62834
|
+
} else {
|
|
62835
|
+
const source = scroll.source === "root" ? documentScroller() : findNearestScroller(subject, "y") || findNearestScroller(subject, "x") || documentScroller();
|
|
62836
|
+
timeline = new Ctor({ source, axis });
|
|
62837
|
+
}
|
|
62838
|
+
} catch (e) {
|
|
62839
|
+
console.warn("scroll timeline: native timeline construction failed \u2014 falling back to the custom driver", e);
|
|
62840
|
+
return null;
|
|
62841
|
+
}
|
|
62842
|
+
return {
|
|
62843
|
+
timeline,
|
|
62844
|
+
rangeStart: nativeRangeOffset((_c = scroll.range) == null ? void 0 : _c.start, 0, view),
|
|
62845
|
+
rangeEnd: nativeRangeOffset((_d = scroll.range) == null ? void 0 : _d.end, 1, view)
|
|
62846
|
+
};
|
|
62847
|
+
}
|
|
62848
|
+
function findNearestScroller(el, axis) {
|
|
62849
|
+
const body = document.body;
|
|
62850
|
+
const root = document.documentElement;
|
|
62851
|
+
for (let p = el.parentElement; p; p = p.parentElement) {
|
|
62852
|
+
if (p === body || p === root) return null;
|
|
62853
|
+
const style = getComputedStyle(p);
|
|
62854
|
+
const overflow = axis === "y" ? style.overflowY : style.overflowX;
|
|
62855
|
+
if (overflow === "auto" || overflow === "scroll" || overflow === "hidden" || overflow === "overlay") {
|
|
62856
|
+
return p;
|
|
62857
|
+
}
|
|
62858
|
+
}
|
|
62859
|
+
return null;
|
|
62860
|
+
}
|
|
62861
|
+
function documentScroller() {
|
|
62862
|
+
return document.scrollingElement || document.documentElement;
|
|
62863
|
+
}
|
|
62864
|
+
var SUBJECT_PARENT = "parent";
|
|
62865
|
+
var SUBJECT_SCROLLER = "scroller";
|
|
62866
|
+
function resolveScrollSubject(svgRoot, subject) {
|
|
62867
|
+
var _a, _b;
|
|
62868
|
+
const spec = subject == null ? void 0 : subject.trim();
|
|
62869
|
+
if (!spec) return svgRoot;
|
|
62870
|
+
if (spec === SUBJECT_PARENT) {
|
|
62871
|
+
let outermostPinned = null;
|
|
62872
|
+
for (let p = svgRoot.parentElement; p && p !== document.body; p = p.parentElement) {
|
|
62873
|
+
const position = getComputedStyle(p).position;
|
|
62874
|
+
if (position === "sticky" || position === "fixed") outermostPinned = p;
|
|
62875
|
+
}
|
|
62876
|
+
return (_b = (_a = outermostPinned == null ? void 0 : outermostPinned.parentElement) != null ? _a : svgRoot.parentElement) != null ? _b : svgRoot;
|
|
62877
|
+
}
|
|
62878
|
+
if (spec === SUBJECT_SCROLLER) {
|
|
62879
|
+
return findNearestScroller(svgRoot, "y") || findNearestScroller(svgRoot, "x") || documentScroller();
|
|
62880
|
+
}
|
|
62881
|
+
let found = null;
|
|
62882
|
+
try {
|
|
62883
|
+
found = document.querySelector(spec);
|
|
62884
|
+
} catch (e) {
|
|
62885
|
+
console.warn('scroll timeline: subject "' + spec + '" is not a valid selector \u2014 measuring the SVG itself');
|
|
62886
|
+
return svgRoot;
|
|
62887
|
+
}
|
|
62888
|
+
if (!found) {
|
|
62889
|
+
console.warn('scroll timeline: subject "' + spec + '" matched no element \u2014 measuring the SVG itself');
|
|
62890
|
+
return svgRoot;
|
|
62891
|
+
}
|
|
62892
|
+
return found;
|
|
62893
|
+
}
|
|
62894
|
+
function createScrollDriver(subject, config, onProgress) {
|
|
62895
|
+
var _a, _b;
|
|
62896
|
+
if (!config || !isScrollTimeline(config)) return null;
|
|
62897
|
+
const scroll = config.scroll || {};
|
|
62898
|
+
const kind = (_a = scroll.kind) != null ? _a : "view";
|
|
62899
|
+
const measured = resolveScrollSubject(subject, scroll.subject);
|
|
62900
|
+
const nearest = findNearestScroller(subject, "y") || findNearestScroller(subject, "x");
|
|
62901
|
+
const scroller = kind === "scroll" && scroll.source === "root" ? documentScroller() : nearest || documentScroller();
|
|
62902
|
+
const isRootScroller = scroller === documentScroller();
|
|
62903
|
+
const axis = scrollResolveAxis(scroll.axis, getComputedStyle(scroller).writingMode);
|
|
62904
|
+
const compute = () => {
|
|
62905
|
+
if (kind === "scroll") {
|
|
62906
|
+
const offset = axis === "y" ? scroller.scrollTop : scroller.scrollLeft;
|
|
62907
|
+
const maxOffset = axis === "y" ? scroller.scrollHeight - scroller.clientHeight : scroller.scrollWidth - scroller.clientWidth;
|
|
62908
|
+
return scrollOffsetProgress(offset, maxOffset, scroll.range);
|
|
62909
|
+
}
|
|
62910
|
+
const subjectRect = measured.getBoundingClientRect();
|
|
62911
|
+
let portStart, portSize;
|
|
62912
|
+
if (isRootScroller) {
|
|
62913
|
+
portStart = 0;
|
|
62914
|
+
portSize = axis === "y" ? document.documentElement.clientHeight : document.documentElement.clientWidth;
|
|
62915
|
+
} else {
|
|
62916
|
+
const portRect = scroller.getBoundingClientRect();
|
|
62917
|
+
portStart = axis === "y" ? portRect.top : portRect.left;
|
|
62918
|
+
portSize = axis === "y" ? scroller.clientHeight : scroller.clientWidth;
|
|
62919
|
+
}
|
|
62920
|
+
const subjectStart = (axis === "y" ? subjectRect.top : subjectRect.left) - portStart;
|
|
62921
|
+
const subjectSize = axis === "y" ? subjectRect.height : subjectRect.width;
|
|
62922
|
+
return scrollViewProgress(subjectStart, subjectSize, portSize, scroll.range);
|
|
62923
|
+
};
|
|
62924
|
+
const smoothingSec = Math.max(0, (_b = scroll.smoothing) != null ? _b : 0) / 1e3;
|
|
62925
|
+
const SETTLE_EPSILON = 1e-3;
|
|
62926
|
+
let destroyed = false;
|
|
62927
|
+
let smoothed = null;
|
|
62928
|
+
let smoothRaf = null;
|
|
62929
|
+
let lastFrameMs = 0;
|
|
62930
|
+
const emit = (target) => {
|
|
62931
|
+
if (!smoothingSec) {
|
|
62932
|
+
onProgress(target);
|
|
62933
|
+
return;
|
|
62934
|
+
}
|
|
62935
|
+
if (smoothed === null) {
|
|
62936
|
+
smoothed = target;
|
|
62937
|
+
onProgress(target);
|
|
62938
|
+
return;
|
|
62939
|
+
}
|
|
62940
|
+
if (smoothRaf !== null) return;
|
|
62941
|
+
lastFrameMs = 0;
|
|
62942
|
+
const step = (nowMs) => {
|
|
62943
|
+
smoothRaf = null;
|
|
62944
|
+
if (destroyed) return;
|
|
62945
|
+
const dtSec = lastFrameMs ? Math.min(0.1, (nowMs - lastFrameMs) / 1e3) : 1 / 60;
|
|
62946
|
+
lastFrameMs = nowMs;
|
|
62947
|
+
const goal = compute();
|
|
62948
|
+
const k = 1 - Math.exp(-dtSec / smoothingSec);
|
|
62949
|
+
smoothed = smoothed + (goal - smoothed) * k;
|
|
62950
|
+
if (Math.abs(goal - smoothed) < SETTLE_EPSILON) smoothed = goal;
|
|
62951
|
+
onProgress(smoothed);
|
|
62952
|
+
if (smoothed !== goal) smoothRaf = requestAnimationFrame(step);
|
|
62953
|
+
};
|
|
62954
|
+
smoothRaf = requestAnimationFrame(step);
|
|
62955
|
+
};
|
|
62956
|
+
let rafId = null;
|
|
62957
|
+
const tick = () => {
|
|
62958
|
+
rafId = null;
|
|
62959
|
+
if (destroyed) return;
|
|
62960
|
+
emit(compute());
|
|
62961
|
+
};
|
|
62962
|
+
const schedule = () => {
|
|
62963
|
+
if (destroyed || rafId !== null) return;
|
|
62964
|
+
rafId = requestAnimationFrame(tick);
|
|
62965
|
+
};
|
|
62966
|
+
const scrollTarget = isRootScroller ? window : scroller;
|
|
62967
|
+
scrollTarget.addEventListener("scroll", schedule, { passive: true });
|
|
62968
|
+
window.addEventListener("resize", schedule, { passive: true });
|
|
62969
|
+
let resizeObserver;
|
|
62970
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
62971
|
+
resizeObserver = new ResizeObserver(schedule);
|
|
62972
|
+
resizeObserver.observe(measured);
|
|
62973
|
+
if (measured !== subject) resizeObserver.observe(subject);
|
|
62974
|
+
if (!isRootScroller) resizeObserver.observe(scroller);
|
|
62975
|
+
}
|
|
62976
|
+
const driver = {
|
|
62977
|
+
destroy: () => {
|
|
62978
|
+
if (destroyed) return;
|
|
62979
|
+
destroyed = true;
|
|
62980
|
+
scrollTarget.removeEventListener("scroll", schedule);
|
|
62981
|
+
window.removeEventListener("resize", schedule);
|
|
62982
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
62983
|
+
if (rafId !== null) {
|
|
62984
|
+
cancelAnimationFrame(rafId);
|
|
62985
|
+
rafId = null;
|
|
62986
|
+
}
|
|
62987
|
+
if (smoothRaf !== null) {
|
|
62988
|
+
cancelAnimationFrame(smoothRaf);
|
|
62989
|
+
smoothRaf = null;
|
|
62990
|
+
}
|
|
62991
|
+
},
|
|
62992
|
+
// `refresh` is a deliberate JUMP (attach, host relayout) — never eased.
|
|
62993
|
+
refresh: () => {
|
|
62994
|
+
if (!destroyed) {
|
|
62995
|
+
smoothed = compute();
|
|
62996
|
+
onProgress(smoothed);
|
|
62997
|
+
}
|
|
62998
|
+
}
|
|
62999
|
+
};
|
|
63000
|
+
driver.refresh();
|
|
63001
|
+
return driver;
|
|
63002
|
+
}
|
|
63003
|
+
function applyScrollPin(svgRoot, scroll) {
|
|
63004
|
+
var _a;
|
|
63005
|
+
const styled = svgRoot;
|
|
63006
|
+
if (!(scroll == null ? void 0 : scroll.pin) || !styled.style) return () => {
|
|
63007
|
+
};
|
|
63008
|
+
const style = styled.style;
|
|
63009
|
+
const prevPosition = style.position;
|
|
63010
|
+
const prevTop = style.top;
|
|
63011
|
+
style.position = "sticky";
|
|
63012
|
+
style.top = ((_a = scroll.pinTop) != null ? _a : 0) + "px";
|
|
63013
|
+
let wrapper = null;
|
|
63014
|
+
const parent = svgRoot.parentElement;
|
|
63015
|
+
if (scroll.pinDistance && scroll.pinDistance > 0 && parent) {
|
|
63016
|
+
wrapper = document.createElement("div");
|
|
63017
|
+
wrapper.setAttribute("data-px-pin", "");
|
|
63018
|
+
wrapper.style.height = scroll.pinDistance * 100 + "vh";
|
|
63019
|
+
parent.insertBefore(wrapper, svgRoot);
|
|
63020
|
+
wrapper.appendChild(svgRoot);
|
|
63021
|
+
}
|
|
63022
|
+
return () => {
|
|
63023
|
+
style.position = prevPosition;
|
|
63024
|
+
style.top = prevTop;
|
|
63025
|
+
if (wrapper == null ? void 0 : wrapper.parentElement) {
|
|
63026
|
+
wrapper.parentElement.insertBefore(svgRoot, wrapper);
|
|
63027
|
+
wrapper.remove();
|
|
63028
|
+
}
|
|
63029
|
+
};
|
|
63030
|
+
}
|
|
62714
63031
|
function finaliseAnimator(animatorConfig, callbacks, make) {
|
|
62715
63032
|
let apiRef;
|
|
62716
63033
|
let effectiveCallbacks = callbacks;
|
|
@@ -62732,6 +63049,59 @@ ${codeFrame}` : message);
|
|
|
62732
63049
|
}
|
|
62733
63050
|
function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
62734
63051
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
63052
|
+
if (isScrollTimeline(animatorConfig)) {
|
|
63053
|
+
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
63054
|
+
var _a, _b;
|
|
63055
|
+
let unpin = () => {
|
|
63056
|
+
};
|
|
63057
|
+
if (animatorConfig.mode !== PxAnimatorMode.frames && ((_a = animatorConfig.scroll) == null ? void 0 : _a.driver) === "native" && rootElement) {
|
|
63058
|
+
unpin = applyScrollPin(rootElement, animatorConfig.scroll);
|
|
63059
|
+
const native = createNativeScrollTimeline(rootElement, animatorConfig);
|
|
63060
|
+
if (native) {
|
|
63061
|
+
const api2 = createWebApiAnimator(
|
|
63062
|
+
doc,
|
|
63063
|
+
cb,
|
|
63064
|
+
rootElement,
|
|
63065
|
+
animatorConfig.mode === PxAnimatorMode.waapi,
|
|
63066
|
+
native
|
|
63067
|
+
);
|
|
63068
|
+
if (api2) {
|
|
63069
|
+
const destroyNative = api2.destroy.bind(api2);
|
|
63070
|
+
api2.destroy = () => {
|
|
63071
|
+
unpin();
|
|
63072
|
+
destroyNative();
|
|
63073
|
+
};
|
|
63074
|
+
return api2;
|
|
63075
|
+
}
|
|
63076
|
+
}
|
|
63077
|
+
unpin();
|
|
63078
|
+
unpin = () => {
|
|
63079
|
+
};
|
|
63080
|
+
}
|
|
63081
|
+
const api = (animatorConfig.mode !== PxAnimatorMode.frames ? createWebApiAnimator(doc, cb, rootElement, animatorConfig.mode === PxAnimatorMode.waapi) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
63082
|
+
const subject = ((_b = api.getRootElement) == null ? void 0 : _b.call(api)) || rootElement;
|
|
63083
|
+
if (subject) {
|
|
63084
|
+
unpin = applyScrollPin(subject, animatorConfig.scroll);
|
|
63085
|
+
const totalMs = scrollTotalDurationMs(animatorConfig);
|
|
63086
|
+
const driver = createScrollDriver(
|
|
63087
|
+
subject,
|
|
63088
|
+
animatorConfig,
|
|
63089
|
+
(progress) => api.setCurrentTime(progress * totalMs)
|
|
63090
|
+
);
|
|
63091
|
+
if (driver) {
|
|
63092
|
+
const destroy = api.destroy.bind(api);
|
|
63093
|
+
api.destroy = () => {
|
|
63094
|
+
driver.destroy();
|
|
63095
|
+
unpin();
|
|
63096
|
+
destroy();
|
|
63097
|
+
};
|
|
63098
|
+
}
|
|
63099
|
+
} else {
|
|
63100
|
+
console.warn("scroll timeline: no root element to observe \u2014 animation will stay at frame 0");
|
|
63101
|
+
}
|
|
63102
|
+
return api;
|
|
63103
|
+
});
|
|
63104
|
+
}
|
|
62735
63105
|
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
62736
63106
|
if (animatorConfig.mode === PxAnimatorMode.frames) {
|
|
62737
63107
|
return createFrameLoopAnimator(doc, adapter, cb, rootElement);
|