@pixodesk/svg-animator-vue 1.0.26 → 1.0.27
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 +844 -601
- 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,22 @@ ${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
|
+
range: PxScrollRangeSchema.optional()
|
|
57943
|
+
}));
|
|
57460
57944
|
var PxAnimatorConfigSchema = implementsInterface()(px.object({
|
|
57461
57945
|
mode: px.enum([PxAnimatorMode.auto, PxAnimatorMode.waapi, PxAnimatorMode.frames]).optional(),
|
|
57462
57946
|
duration: px.number().optional(),
|
|
@@ -57472,6 +57956,7 @@ ${codeFrame}` : message);
|
|
|
57472
57956
|
definitions: PxDefsSchema.optional(),
|
|
57473
57957
|
animateById: px.record(PxElementAnimationSchema).optional(),
|
|
57474
57958
|
timelineSource: px.string().optional(),
|
|
57959
|
+
scroll: PxScrollSchema.optional(),
|
|
57475
57960
|
debugInstName: px.string().optional()
|
|
57476
57961
|
}));
|
|
57477
57962
|
var PxBindingSchema = implementsInterface()(px.object({
|
|
@@ -57551,528 +58036,114 @@ ${codeFrame}` : message);
|
|
|
57551
58036
|
sourceId: px.string().optional(),
|
|
57552
58037
|
retime: PxRetimeEffectSchema.optional()
|
|
57553
58038
|
}));
|
|
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'
|
|
58039
|
+
var PxGradientStopSchema = implementsInterface()(px.object({
|
|
58040
|
+
offset: px.number(),
|
|
58041
|
+
color: px.string()
|
|
58042
|
+
}));
|
|
58043
|
+
var PxAnimatableGradientStopsSchema = px.union([
|
|
58044
|
+
px.array(PxGradientStopSchema),
|
|
58045
|
+
px.object({ value: px.array(PxGradientStopSchema) }),
|
|
58046
|
+
PxPropertyAnimationSchema
|
|
57974
58047
|
]);
|
|
57975
|
-
|
|
57976
|
-
|
|
57977
|
-
|
|
57978
|
-
|
|
57979
|
-
|
|
57980
|
-
|
|
57981
|
-
|
|
57982
|
-
|
|
57983
|
-
|
|
57984
|
-
|
|
57985
|
-
|
|
57986
|
-
|
|
57987
|
-
|
|
57988
|
-
|
|
57989
|
-
|
|
57990
|
-
|
|
57991
|
-
|
|
57992
|
-
|
|
57993
|
-
|
|
57994
|
-
|
|
57995
|
-
|
|
57996
|
-
|
|
57997
|
-
}
|
|
57998
|
-
var
|
|
57999
|
-
|
|
58000
|
-
|
|
58001
|
-
|
|
58002
|
-
|
|
58003
|
-
|
|
58004
|
-
|
|
58005
|
-
|
|
58006
|
-
|
|
58007
|
-
|
|
58008
|
-
|
|
58009
|
-
|
|
58010
|
-
|
|
58011
|
-
|
|
58012
|
-
|
|
58013
|
-
|
|
58014
|
-
|
|
58015
|
-
|
|
58016
|
-
|
|
58017
|
-
|
|
58018
|
-
|
|
58019
|
-
|
|
58020
|
-
|
|
58021
|
-
|
|
58022
|
-
|
|
58023
|
-
|
|
58024
|
-
|
|
58025
|
-
|
|
58026
|
-
|
|
58027
|
-
|
|
58028
|
-
|
|
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);
|
|
58048
|
+
var PxFillGradientEffectSchema = implementsInterface()(px.object({
|
|
58049
|
+
// Contextual kind — the `type` convention, see `PxNodeBase.type`.
|
|
58050
|
+
type: px.enum([PxGradientType.linear, PxGradientType.radial]),
|
|
58051
|
+
p1: PxAnimatableVec2Schema.optional(),
|
|
58052
|
+
p2: PxAnimatableVec2Schema.optional(),
|
|
58053
|
+
c: PxAnimatableVec2Schema.optional(),
|
|
58054
|
+
r: PxAnimatableNumberSchema.optional(),
|
|
58055
|
+
fp: PxAnimatableVec2Schema.optional(),
|
|
58056
|
+
stops: PxAnimatableGradientStopsSchema.optional(),
|
|
58057
|
+
gradientUnits: px.enum([PxGradientUnits.userSpaceOnUse, PxGradientUnits.objectBoundingBox]).optional(),
|
|
58058
|
+
spreadMethod: px.enum([PxGradientSpreadMethod.pad, PxGradientSpreadMethod.reflect, PxGradientSpreadMethod.repeat]).optional(),
|
|
58059
|
+
gradientTransform: px.string().optional()
|
|
58060
|
+
}));
|
|
58061
|
+
var PxStrokeGradientEffectSchema = PxFillGradientEffectSchema;
|
|
58062
|
+
var PxTextPathEffectSchema = implementsInterface()(px.object({
|
|
58063
|
+
path: px.string(),
|
|
58064
|
+
pathOverflow: px.enum([PxPathOverflow.clip, PxPathOverflow.extend]).optional(),
|
|
58065
|
+
lengthAdjust: px.enum([PxLengthAdjust.spacing, PxLengthAdjust.spacingAndGlyphs]).optional(),
|
|
58066
|
+
method: px.enum([PxTextPathMethod.align, PxTextPathMethod.stretch]).optional(),
|
|
58067
|
+
spacing: px.enum([PxTextPathSpacing.auto, PxTextPathSpacing.exact]).optional(),
|
|
58068
|
+
startOffset: PxAnimatableNumberSchema.optional(),
|
|
58069
|
+
textLength: PxAnimatableNumberSchema.optional()
|
|
58070
|
+
}));
|
|
58071
|
+
var PxTextEffectSchema = implementsInterface()(px.object({
|
|
58072
|
+
useGlyphs: px.boolean().optional()
|
|
58073
|
+
}));
|
|
58074
|
+
var PxEffectsSchema = implementsInterface()(px.object({
|
|
58075
|
+
transformBy: PxTransformByEffectSchema.optional(),
|
|
58076
|
+
repeater: PxRepeaterEffectSchema.optional(),
|
|
58077
|
+
maskedBy: PxMaskedByEffectSchema.optional(),
|
|
58078
|
+
clipPath: PxClipPathEffectSchema.optional(),
|
|
58079
|
+
trimPath: PxTrimPathEffectSchema.optional(),
|
|
58080
|
+
clone: PxCloneEffectSchema.optional(),
|
|
58081
|
+
fillGradient: PxFillGradientEffectSchema.optional(),
|
|
58082
|
+
strokeGradient: PxStrokeGradientEffectSchema.optional(),
|
|
58083
|
+
textPath: PxTextPathEffectSchema.optional(),
|
|
58084
|
+
text: PxTextEffectSchema.optional()
|
|
58085
|
+
}));
|
|
58086
|
+
function validateNodeEffects(root, opts) {
|
|
58087
|
+
const warnings = [];
|
|
58088
|
+
const walk = (node, path) => {
|
|
58089
|
+
if (node && node.effects) {
|
|
58090
|
+
const ctx = { errors: [], warnings: [], strict: !!(opts == null ? void 0 : opts.strict) };
|
|
58091
|
+
const ok = PxEffectsSchema.isValid(node.effects, ctx, [path + ".effects"]);
|
|
58092
|
+
if (!ok) {
|
|
58093
|
+
for (const err of ctx.errors) warnings.push(err);
|
|
58094
|
+
}
|
|
58095
|
+
}
|
|
58096
|
+
if (node && Array.isArray(node.children)) {
|
|
58097
|
+
node.children.forEach((c, i) => walk(c, path + ".children[" + i + "]"));
|
|
58098
|
+
}
|
|
58099
|
+
};
|
|
58100
|
+
walk(root, "root");
|
|
58101
|
+
return warnings;
|
|
58075
58102
|
}
|
|
58103
|
+
var PxNodeBase = px.openObject({
|
|
58104
|
+
// CONVENTION (SCHEMA-DESIGN R1 / issues N4): `type` is the ONE word for "what
|
|
58105
|
+
// kind of thing is this", discriminated by its CARRIER — here the node TAG
|
|
58106
|
+
// (`rect`, `text`), and inside a sub-object that object's kind (`clone.type`,
|
|
58107
|
+
// `fillGradient.type`, editor `preset.type`). Each sits in its own object, so
|
|
58108
|
+
// the carrier disambiguates completely; synonyms (`cloneKind`, `presetShape`)
|
|
58109
|
+
// would add words that all mean "type" and still need the carrier to read.
|
|
58110
|
+
// Guarding a `type` SLOT against a wrong VALUE is the job of strict enums
|
|
58111
|
+
// (issues V3), never of distinct key names.
|
|
58112
|
+
type: px.string(),
|
|
58113
|
+
id: px.string().optional(),
|
|
58114
|
+
meta: px.any().optional(),
|
|
58115
|
+
// Player-effects bucket emitted by the Editor's lightweight design format.
|
|
58116
|
+
// Consumed and removed by `applyPlayerEffects` before any other normalisation
|
|
58117
|
+
// (see `createAnimatorImpl`), so downstream code never sees it.
|
|
58118
|
+
effects: PxEffectsSchema.optional(),
|
|
58119
|
+
// `PxElementAnimation` (not just `PxAnimationDefinition`) — accepts
|
|
58120
|
+
// string ref / array of refs / inline definition / mixed array; mirrors
|
|
58121
|
+
// `animator.animateById` map values and what `processNode` resolves at runtime.
|
|
58122
|
+
animate: PxElementAnimationSchema.optional(),
|
|
58123
|
+
style: px.union([px.string(), px.record(px.union([px.string(), px.number()]))]).optional()
|
|
58124
|
+
}, PxAttrValueSchema);
|
|
58125
|
+
var PxNodeSchema = px.openObject(__spreadProps2(__spreadValues2({}, PxNodeBase._shape), {
|
|
58126
|
+
children: px.lazy(() => px.array(PxNodeSchema), []).optional()
|
|
58127
|
+
}), PxAttrValueSchema);
|
|
58128
|
+
var PxSvgNodeExtra = px.object({
|
|
58129
|
+
// `"100%"` and other SVG length strings are legal here — a number-only slot rejected
|
|
58130
|
+
// real documents (e.g. apple-store-look-14-main.json) at the root <svg>.
|
|
58131
|
+
width: px.union([px.number(), px.string()]).optional(),
|
|
58132
|
+
height: px.union([px.number(), px.string()]).optional(),
|
|
58133
|
+
viewBox: px.string().optional(),
|
|
58134
|
+
animator: PxAnimatorConfigSchema.optional()
|
|
58135
|
+
});
|
|
58136
|
+
var PxAnimatedSvgDocumentSchema = px.openObject(__spreadProps2(__spreadValues2(__spreadValues2({}, PxNodeBase._shape), PxSvgNodeExtra._shape), {
|
|
58137
|
+
type: px.literal("svg"),
|
|
58138
|
+
// override string → literal to require 'svg'
|
|
58139
|
+
children: px.array(PxNodeSchema).optional()
|
|
58140
|
+
}), PxAttrValueSchema);
|
|
58141
|
+
var PxBezierPathSchema = implementsInterface()(px.object({
|
|
58142
|
+
v: px.array(px.array(px.number())),
|
|
58143
|
+
i: px.array(px.array(px.number())).optional(),
|
|
58144
|
+
o: px.array(px.array(px.number())).optional(),
|
|
58145
|
+
c: px.boolean().optional()
|
|
58146
|
+
}));
|
|
58076
58147
|
var _idCounter = 0;
|
|
58077
58148
|
function generateUniqueId() {
|
|
58078
58149
|
const timestamp = Date.now().toString(36);
|
|
@@ -62428,7 +62499,13 @@ ${codeFrame}` : message);
|
|
|
62428
62499
|
const api = __spreadProps(__spreadValues({}, basicApi), {
|
|
62429
62500
|
"getRootElement": () => rootElement || null
|
|
62430
62501
|
});
|
|
62431
|
-
if (config.trigger)
|
|
62502
|
+
if (config.trigger) {
|
|
62503
|
+
if (isScrollTimeline(config)) {
|
|
62504
|
+
console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
|
|
62505
|
+
} else {
|
|
62506
|
+
setupAnimationTriggers(api, config.trigger);
|
|
62507
|
+
}
|
|
62508
|
+
}
|
|
62432
62509
|
return api;
|
|
62433
62510
|
}
|
|
62434
62511
|
function createDomAdapter(rootElement) {
|
|
@@ -62554,7 +62631,7 @@ ${codeFrame}` : message);
|
|
|
62554
62631
|
}
|
|
62555
62632
|
return result;
|
|
62556
62633
|
}
|
|
62557
|
-
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs) {
|
|
62634
|
+
function createWebApiAnimator(doc, callbacks, rootElement, forceEvenIfHasUnsupportedAttrs, scrollTimeline) {
|
|
62558
62635
|
var _a;
|
|
62559
62636
|
const config = getAnimatorConfig(doc) || {};
|
|
62560
62637
|
if (!rootElement) {
|
|
@@ -62613,7 +62690,12 @@ ${codeFrame}` : message);
|
|
|
62613
62690
|
if (keyframes.length > 0) {
|
|
62614
62691
|
try {
|
|
62615
62692
|
const effect = new KeyframeEffect(element, keyframes, effectOptions);
|
|
62616
|
-
const anim = new Animation(effect, document.timeline);
|
|
62693
|
+
const anim = new Animation(effect, scrollTimeline ? scrollTimeline.timeline : document.timeline);
|
|
62694
|
+
if (scrollTimeline) {
|
|
62695
|
+
const a = anim;
|
|
62696
|
+
if (scrollTimeline.rangeStart) a.rangeStart = scrollTimeline.rangeStart;
|
|
62697
|
+
if (scrollTimeline.rangeEnd) a.rangeEnd = scrollTimeline.rangeEnd;
|
|
62698
|
+
}
|
|
62617
62699
|
if (callbacks == null ? void 0 : callbacks.onFinish) anim.onfinish = () => {
|
|
62618
62700
|
var _a2;
|
|
62619
62701
|
if (finishNotified) return;
|
|
@@ -62707,10 +62789,133 @@ ${codeFrame}` : message);
|
|
|
62707
62789
|
}
|
|
62708
62790
|
};
|
|
62709
62791
|
if (config.trigger) {
|
|
62710
|
-
|
|
62792
|
+
if (config.timelineSource === "scroll") {
|
|
62793
|
+
console.warn("scroll timeline: `animator.trigger` is ignored (triggers do not apply to scroll-driven playback)");
|
|
62794
|
+
} else {
|
|
62795
|
+
setupAnimationTriggers(api, config.trigger);
|
|
62796
|
+
}
|
|
62797
|
+
}
|
|
62798
|
+
if (scrollTimeline) {
|
|
62799
|
+
animations.forEach((a) => a.play());
|
|
62711
62800
|
}
|
|
62712
62801
|
return api;
|
|
62713
62802
|
}
|
|
62803
|
+
function nativeRangeOffset(point, defaultFraction, view) {
|
|
62804
|
+
var _a, _b, _c;
|
|
62805
|
+
const fraction = typeof (point == null ? void 0 : point.fraction) === "number" ? point.fraction : defaultFraction;
|
|
62806
|
+
const pct = (_b = (_a = globalThis.CSS) == null ? void 0 : _a.percent) == null ? void 0 : _b.call(_a, fraction * 100);
|
|
62807
|
+
if (pct === void 0) return void 0;
|
|
62808
|
+
return view ? { rangeName: (_c = point == null ? void 0 : point.phase) != null ? _c : "cover", offset: pct } : { offset: pct };
|
|
62809
|
+
}
|
|
62810
|
+
function createNativeScrollTimeline(subject, config) {
|
|
62811
|
+
var _a, _b, _c, _d;
|
|
62812
|
+
if (!config || !isScrollTimeline(config)) return null;
|
|
62813
|
+
const scroll = config.scroll || {};
|
|
62814
|
+
const kind = (_a = scroll.kind) != null ? _a : "view";
|
|
62815
|
+
const g = globalThis;
|
|
62816
|
+
const view = kind === "view";
|
|
62817
|
+
const Ctor = view ? g.ViewTimeline : g.ScrollTimeline;
|
|
62818
|
+
if (typeof Ctor !== "function") return null;
|
|
62819
|
+
const axis = (_b = scroll.axis) != null ? _b : "block";
|
|
62820
|
+
let timeline;
|
|
62821
|
+
try {
|
|
62822
|
+
if (view) {
|
|
62823
|
+
timeline = new Ctor({ subject, axis });
|
|
62824
|
+
} else {
|
|
62825
|
+
const source = scroll.source === "root" ? documentScroller() : findNearestScroller(subject, "y") || findNearestScroller(subject, "x") || documentScroller();
|
|
62826
|
+
timeline = new Ctor({ source, axis });
|
|
62827
|
+
}
|
|
62828
|
+
} catch (e) {
|
|
62829
|
+
console.warn("scroll timeline: native timeline construction failed \u2014 falling back to the custom driver", e);
|
|
62830
|
+
return null;
|
|
62831
|
+
}
|
|
62832
|
+
return {
|
|
62833
|
+
timeline,
|
|
62834
|
+
rangeStart: nativeRangeOffset((_c = scroll.range) == null ? void 0 : _c.start, 0, view),
|
|
62835
|
+
rangeEnd: nativeRangeOffset((_d = scroll.range) == null ? void 0 : _d.end, 1, view)
|
|
62836
|
+
};
|
|
62837
|
+
}
|
|
62838
|
+
function findNearestScroller(el, axis) {
|
|
62839
|
+
for (let p = el.parentElement; p; p = p.parentElement) {
|
|
62840
|
+
const style = getComputedStyle(p);
|
|
62841
|
+
const overflow = axis === "y" ? style.overflowY : style.overflowX;
|
|
62842
|
+
if (overflow === "auto" || overflow === "scroll" || overflow === "hidden" || overflow === "overlay") {
|
|
62843
|
+
return p;
|
|
62844
|
+
}
|
|
62845
|
+
}
|
|
62846
|
+
return null;
|
|
62847
|
+
}
|
|
62848
|
+
function documentScroller() {
|
|
62849
|
+
return document.scrollingElement || document.documentElement;
|
|
62850
|
+
}
|
|
62851
|
+
function createScrollDriver(subject, config, onProgress) {
|
|
62852
|
+
var _a;
|
|
62853
|
+
if (!config || !isScrollTimeline(config)) return null;
|
|
62854
|
+
const scroll = config.scroll || {};
|
|
62855
|
+
const kind = (_a = scroll.kind) != null ? _a : "view";
|
|
62856
|
+
const nearest = findNearestScroller(subject, "y") || findNearestScroller(subject, "x");
|
|
62857
|
+
const scroller = kind === "scroll" && scroll.source === "root" ? documentScroller() : nearest || documentScroller();
|
|
62858
|
+
const isRootScroller = scroller === documentScroller();
|
|
62859
|
+
const axis = scrollResolveAxis(scroll.axis, getComputedStyle(scroller).writingMode);
|
|
62860
|
+
const compute = () => {
|
|
62861
|
+
if (kind === "scroll") {
|
|
62862
|
+
const offset = axis === "y" ? scroller.scrollTop : scroller.scrollLeft;
|
|
62863
|
+
const maxOffset = axis === "y" ? scroller.scrollHeight - scroller.clientHeight : scroller.scrollWidth - scroller.clientWidth;
|
|
62864
|
+
return scrollOffsetProgress(offset, maxOffset, scroll.range);
|
|
62865
|
+
}
|
|
62866
|
+
const subjectRect = subject.getBoundingClientRect();
|
|
62867
|
+
let portStart, portSize;
|
|
62868
|
+
if (isRootScroller) {
|
|
62869
|
+
portStart = 0;
|
|
62870
|
+
portSize = axis === "y" ? document.documentElement.clientHeight : document.documentElement.clientWidth;
|
|
62871
|
+
} else {
|
|
62872
|
+
const portRect = scroller.getBoundingClientRect();
|
|
62873
|
+
portStart = axis === "y" ? portRect.top : portRect.left;
|
|
62874
|
+
portSize = axis === "y" ? scroller.clientHeight : scroller.clientWidth;
|
|
62875
|
+
}
|
|
62876
|
+
const subjectStart = (axis === "y" ? subjectRect.top : subjectRect.left) - portStart;
|
|
62877
|
+
const subjectSize = axis === "y" ? subjectRect.height : subjectRect.width;
|
|
62878
|
+
return scrollViewProgress(subjectStart, subjectSize, portSize, scroll.range);
|
|
62879
|
+
};
|
|
62880
|
+
let rafId = null;
|
|
62881
|
+
let destroyed = false;
|
|
62882
|
+
const tick = () => {
|
|
62883
|
+
rafId = null;
|
|
62884
|
+
if (destroyed) return;
|
|
62885
|
+
onProgress(compute());
|
|
62886
|
+
};
|
|
62887
|
+
const schedule = () => {
|
|
62888
|
+
if (destroyed || rafId !== null) return;
|
|
62889
|
+
rafId = requestAnimationFrame(tick);
|
|
62890
|
+
};
|
|
62891
|
+
const scrollTarget = isRootScroller ? window : scroller;
|
|
62892
|
+
scrollTarget.addEventListener("scroll", schedule, { passive: true });
|
|
62893
|
+
window.addEventListener("resize", schedule, { passive: true });
|
|
62894
|
+
let resizeObserver;
|
|
62895
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
62896
|
+
resizeObserver = new ResizeObserver(schedule);
|
|
62897
|
+
resizeObserver.observe(subject);
|
|
62898
|
+
if (!isRootScroller) resizeObserver.observe(scroller);
|
|
62899
|
+
}
|
|
62900
|
+
const driver = {
|
|
62901
|
+
destroy: () => {
|
|
62902
|
+
if (destroyed) return;
|
|
62903
|
+
destroyed = true;
|
|
62904
|
+
scrollTarget.removeEventListener("scroll", schedule);
|
|
62905
|
+
window.removeEventListener("resize", schedule);
|
|
62906
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
62907
|
+
if (rafId !== null) {
|
|
62908
|
+
cancelAnimationFrame(rafId);
|
|
62909
|
+
rafId = null;
|
|
62910
|
+
}
|
|
62911
|
+
},
|
|
62912
|
+
refresh: () => {
|
|
62913
|
+
if (!destroyed) onProgress(compute());
|
|
62914
|
+
}
|
|
62915
|
+
};
|
|
62916
|
+
driver.refresh();
|
|
62917
|
+
return driver;
|
|
62918
|
+
}
|
|
62714
62919
|
function finaliseAnimator(animatorConfig, callbacks, make) {
|
|
62715
62920
|
let apiRef;
|
|
62716
62921
|
let effectiveCallbacks = callbacks;
|
|
@@ -62732,6 +62937,44 @@ ${codeFrame}` : message);
|
|
|
62732
62937
|
}
|
|
62733
62938
|
function bindWithEngineChoice(doc, adapter, callbacks, rootElement) {
|
|
62734
62939
|
const animatorConfig = getAnimatorConfig(doc) || {};
|
|
62940
|
+
if (isScrollTimeline(animatorConfig)) {
|
|
62941
|
+
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
62942
|
+
var _a, _b;
|
|
62943
|
+
if (animatorConfig.mode !== PxAnimatorMode.frames && ((_a = animatorConfig.scroll) == null ? void 0 : _a.driver) === "native" && rootElement) {
|
|
62944
|
+
const native = createNativeScrollTimeline(rootElement, animatorConfig);
|
|
62945
|
+
if (native) {
|
|
62946
|
+
const api2 = createWebApiAnimator(
|
|
62947
|
+
doc,
|
|
62948
|
+
cb,
|
|
62949
|
+
rootElement,
|
|
62950
|
+
animatorConfig.mode === PxAnimatorMode.waapi,
|
|
62951
|
+
native
|
|
62952
|
+
);
|
|
62953
|
+
if (api2) return api2;
|
|
62954
|
+
}
|
|
62955
|
+
}
|
|
62956
|
+
const api = (animatorConfig.mode !== PxAnimatorMode.frames ? createWebApiAnimator(doc, cb, rootElement, animatorConfig.mode === PxAnimatorMode.waapi) : null) || createFrameLoopAnimator(doc, adapter, cb, rootElement);
|
|
62957
|
+
const subject = ((_b = api.getRootElement) == null ? void 0 : _b.call(api)) || rootElement;
|
|
62958
|
+
if (subject) {
|
|
62959
|
+
const totalMs = scrollTotalDurationMs(animatorConfig);
|
|
62960
|
+
const driver = createScrollDriver(
|
|
62961
|
+
subject,
|
|
62962
|
+
animatorConfig,
|
|
62963
|
+
(progress) => api.setCurrentTime(progress * totalMs)
|
|
62964
|
+
);
|
|
62965
|
+
if (driver) {
|
|
62966
|
+
const destroy = api.destroy.bind(api);
|
|
62967
|
+
api.destroy = () => {
|
|
62968
|
+
driver.destroy();
|
|
62969
|
+
destroy();
|
|
62970
|
+
};
|
|
62971
|
+
}
|
|
62972
|
+
} else {
|
|
62973
|
+
console.warn("scroll timeline: no root element to observe \u2014 animation will stay at frame 0");
|
|
62974
|
+
}
|
|
62975
|
+
return api;
|
|
62976
|
+
});
|
|
62977
|
+
}
|
|
62735
62978
|
return finaliseAnimator(animatorConfig, callbacks, (cb) => {
|
|
62736
62979
|
if (animatorConfig.mode === PxAnimatorMode.frames) {
|
|
62737
62980
|
return createFrameLoopAnimator(doc, adapter, cb, rootElement);
|