@antv/g 6.3.1 → 6.3.3

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.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g
3
3
  * @description A core module for rendering engine implements DOM API.
4
- * @version 6.3.1
5
- * @date 12/24/2025, 11:55:39 AM
4
+ * @version 6.3.3
5
+ * @date 10/16/2026, 2:34:40 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -570,55 +570,31 @@ var Animation = /*#__PURE__*/function () {
570
570
  /**
571
571
  * https://github.com/gre/bezier-easing
572
572
  * BezierEasing - use bezier curve for transition easing function
573
- * by Gaëtan Renaudeau 2014 - 2015 – MIT License
573
+ * by Gaëtan Renaudeau 2014 - 2026 – MIT License
574
574
  */
575
575
 
576
- // These values are established by empiricism with tests (tradeoff: performance VS precision)
577
- var NEWTON_ITERATIONS = 4;
578
- var NEWTON_MIN_SLOPE = 0.001;
579
- var SUBDIVISION_PRECISION = 0.0000001;
580
- var SUBDIVISION_MAX_ITERATIONS = 10;
581
- var kSplineTableSize = 11;
582
- var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
583
- var float32ArraySupported = typeof Float32Array === 'function';
584
- var A = function A(aA1, aA2) {
585
- return 1.0 - 3.0 * aA2 + 3.0 * aA1;
586
- };
587
- var B = function B(aA1, aA2) {
588
- return 3.0 * aA2 - 6.0 * aA1;
589
- };
590
- var C = function C(aA1) {
591
- return 3.0 * aA1;
592
- };
593
-
594
- // Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
595
- var calcBezier = function calcBezier(aT, aA1, aA2) {
596
- return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT;
597
- };
598
-
599
- // Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
600
- var getSlope = function getSlope(aT, aA1, aA2) {
601
- return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1);
602
- };
603
- var binarySubdivide = function binarySubdivide(aX, aA, aB, mX1, mX2) {
604
- var currentX;
605
- var currentT;
606
- var i = 0;
607
- do {
608
- currentT = aA + (aB - aA) / 2.0;
609
- currentX = calcBezier(currentT, mX1, mX2) - aX;
610
- if (currentX > 0.0) aB = currentT;else aA = currentT;
611
- } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
612
- return currentT;
613
- };
614
- var newtonRaphsonIterate = function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
615
- for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
616
- var currentSlope = getSlope(aGuessT, mX1, mX2);
617
- if (currentSlope === 0.0) return aGuessT;
618
- var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
619
- aGuessT -= currentX / currentSlope;
576
+ // Solves x(t) = ((2a * t + 3b) * t + 3c) * t = x for t, with x in (0, 1):
577
+ // u = 1/t is the largest real root of x·u³ − 3c·u² − 3b·u − 2a = 0
578
+ var solveTForX = function solveTForX(x, a, b, c) {
579
+ var j = 1 / Math.max(c, Math.sqrt(x));
580
+ var k = x * j;
581
+ var l = k * j;
582
+ var s = c * j;
583
+ var q = b * l;
584
+ var m = s * s + q;
585
+ var h = -s * (s * s + 1.5 * q) - a * k * l;
586
+ var D = h * h - m * m * m;
587
+ var v;
588
+ if (m === 0 || D > 1e-12 * h * h) {
589
+ // one real root (Cardano)
590
+ var U = -Math.cbrt(h < 0 ? h - Math.sqrt(D) : h + Math.sqrt(D));
591
+ v = U + m / U || 0;
592
+ } else {
593
+ // three real roots, take the largest
594
+ var r = Math.sqrt(m);
595
+ v = 2 * r * Math.cos(Math.acos(Math.max(-1, Math.min(1, -h / (m * r)))) / 3);
620
596
  }
621
- return aGuessT;
597
+ return Math.min(1, k / (v + s));
622
598
  };
623
599
  var bezier = function bezier(mX1, mY1, mX2, mY2) {
624
600
  if (!(mX1 >= 0 && mX1 <= 1 && mX2 >= 0 && mX2 <= 1)) throw new Error('bezier x values must be in [0, 1] range');
@@ -626,30 +602,19 @@ var bezier = function bezier(mX1, mY1, mX2, mY2) {
626
602
  return t;
627
603
  };
628
604
 
629
- // Precompute samples table
630
- var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
631
- for (var i = 0; i < kSplineTableSize; ++i) {
632
- sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
633
- }
634
- var getTForX = function getTForX(aX) {
635
- var intervalStart = 0.0;
636
- var currentSample = 1;
637
- var lastSample = kSplineTableSize - 1;
638
- for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) intervalStart += kSampleStepSize;
639
- --currentSample;
640
-
641
- // Interpolate to provide an initial guess for t
642
- var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
643
- var guessForT = intervalStart + dist * kSampleStepSize;
644
- var initialSlope = getSlope(guessForT, mX1, mX2);
645
- if (initialSlope >= NEWTON_MIN_SLOPE) return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
646
- if (initialSlope === 0.0) return guessForT;
647
- return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
648
- };
605
+ // x(t) = ((2a * t + 3b) * t + 3c) * t, y(t) = ((ay * t + by) * t + cy) * t
606
+ var a = (3 * mX1 - 3 * mX2 + 1) / 2;
607
+ var b = mX2 - 2 * mX1;
608
+ var c = mX1;
609
+ var ay = 3 * mY1 - 3 * mY2 + 1;
610
+ var by = 3 * (mY2 - 2 * mY1);
611
+ var cy = 3 * mY1;
649
612
  return function (t) {
650
- // Because JavaScript number are imprecise, we should guarantee the extremes are right.
651
- if (t === 0 || t === 1) return t;
652
- return calcBezier(getTForX(t), mY1, mY2);
613
+ // t outside (0, 1) saturates to 0 / 1
614
+ if (t <= 0) return 0;
615
+ if (t >= 1) return 1;
616
+ var u = solveTForX(t, a, b, c);
617
+ return ((ay * u + by) * u + cy) * u;
653
618
  };
654
619
  };
655
620
 
@@ -1657,9 +1622,13 @@ var AnimationTimeline = /*#__PURE__*/function () {
1657
1622
  if (t < Number(_this.currentTime)) t = Number(_this.currentTime);
1658
1623
  _this.animations.sort(compareAnimations);
1659
1624
  _this.animations = _this.tick(t, true, _this.animations)[0];
1625
+ // Once per frame rather than around each callback: there is one callback per started
1626
+ // animation, and each update goes over every animation with promises.
1627
+ _this.updateAnimationsPromises();
1660
1628
  processing.forEach(function (entry) {
1661
1629
  entry[1](t);
1662
1630
  });
1631
+ _this.updateAnimationsPromises();
1663
1632
  _this.applyPendingEffects();
1664
1633
  };
1665
1634
  this.document = document;
@@ -1773,17 +1742,12 @@ var AnimationTimeline = /*#__PURE__*/function () {
1773
1742
  }, {
1774
1743
  key: "requestAnimationFrame",
1775
1744
  value: function requestAnimationFrame(f) {
1776
- var _this3 = this;
1777
- return this.rAF(function (x) {
1778
- _this3.updateAnimationsPromises();
1779
- f(x);
1780
- _this3.updateAnimationsPromises();
1781
- });
1745
+ return this.rAF(f);
1782
1746
  }
1783
1747
  }, {
1784
1748
  key: "tick",
1785
1749
  value: function tick(t, isAnimationFrame, updatingAnimations) {
1786
- var _this4 = this,
1750
+ var _this3 = this,
1787
1751
  _this$pendingEffects,
1788
1752
  _this$pendingEffects2;
1789
1753
  this.inTick = true;
@@ -1803,7 +1767,7 @@ var AnimationTimeline = /*#__PURE__*/function () {
1803
1767
  newPendingEffects.push(animation.effect);
1804
1768
  animation.markTarget();
1805
1769
  }
1806
- if (animation._needsTick) _this4.ticking = true;
1770
+ if (animation._needsTick) _this3.ticking = true;
1807
1771
  var alive = animation._inEffect || animation._needsTick;
1808
1772
  animation._inTimeline = alive;
1809
1773
  if (alive) {