@antv/g-lite 2.2.13 → 2.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /*!
2
2
  * @antv/g-lite
3
3
  * @description A core module for rendering engine implements DOM API.
4
- * @version 2.2.13
5
- * @date 12/27/2024, 4:20:45 AM
4
+ * @version 2.2.15
5
+ * @date 1/17/2025, 2:05:37 PM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -1592,8 +1592,31 @@ function combine(out, a, b, scale1, scale2) {
1592
1592
  */
1593
1593
 
1594
1594
  var CameraType = /*#__PURE__*/function (CameraType) {
1595
+ /**
1596
+ * Performs all the rotational operations with the focal point instead of the camera position.
1597
+ * This type of camera is useful in applications(like CAD) where 3D objects are being designed or explored.
1598
+ * Camera cannot orbits over the north & south poles.
1599
+ * @see http://voxelent.com/tutorial-cameras/
1600
+ *
1601
+ * In Three.js it's used in OrbitControls.
1602
+ * @see https://threejs.org/docs/#examples/zh/controls/OrbitControls
1603
+ */
1595
1604
  CameraType[CameraType["ORBITING"] = 0] = "ORBITING";
1605
+ /**
1606
+ * It's similar to the ORBITING camera, but it allows the camera to orbit over the north or south poles.
1607
+ *
1608
+ * In Three.js it's used in OrbitControls.
1609
+ * @see https://threejs.org/docs/#examples/en/controls/TrackballControls
1610
+ */
1596
1611
  CameraType[CameraType["EXPLORING"] = 1] = "EXPLORING";
1612
+ /**
1613
+ * Performs all the rotational operations with the camera position.
1614
+ * It's useful in first person shooting games.
1615
+ * Camera cannot orbits over the north & south poles.
1616
+ *
1617
+ * In Three.js it's used in FirstPersonControls.
1618
+ * @see https://threejs.org/docs/#examples/en/controls/FirstPersonControls
1619
+ */
1597
1620
  CameraType[CameraType["TRACKING"] = 2] = "TRACKING";
1598
1621
  return CameraType;
1599
1622
  }({});
@@ -2487,20 +2510,57 @@ var EMPTY_PARSED_PATH = {
2487
2510
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
2488
2511
  */
2489
2512
  var PropertySyntax = /*#__PURE__*/function (PropertySyntax) {
2513
+ /**
2514
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
2515
+ */
2490
2516
  PropertySyntax["COORDINATE"] = "<coordinate>";
2517
+ /**
2518
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
2519
+ */
2491
2520
  PropertySyntax["COLOR"] = "<color>";
2521
+ /**
2522
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
2523
+ */
2492
2524
  PropertySyntax["PAINT"] = "<paint>";
2525
+ /**
2526
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
2527
+ */
2493
2528
  PropertySyntax["NUMBER"] = "<number>";
2529
+ /**
2530
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
2531
+ */
2494
2532
  PropertySyntax["ANGLE"] = "<angle>";
2533
+ /**
2534
+ * <number> with range 0..1
2535
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
2536
+ */
2495
2537
  PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
2538
+ /**
2539
+ * <number> with range 0..Infinity
2540
+ */
2496
2541
  PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
2542
+ /**
2543
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
2544
+ */
2497
2545
  PropertySyntax["LENGTH"] = "<length>";
2546
+ /**
2547
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
2548
+ */
2498
2549
  PropertySyntax["PERCENTAGE"] = "<percentage>";
2499
2550
  PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2500
2551
  PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2552
+ /**
2553
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2554
+ */
2501
2555
  PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2556
+ /**
2557
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2558
+ */
2502
2559
  PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2503
2560
  PropertySyntax["PATH"] = "<path>";
2561
+ /**
2562
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2563
+ */
2504
2564
  PropertySyntax["FILTER"] = "<filter>";
2505
2565
  PropertySyntax["Z_INDEX"] = "<z-index>";
2506
2566
  PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
@@ -2531,9 +2591,16 @@ function memoize(func, resolver) {
2531
2591
  return result;
2532
2592
  };
2533
2593
  _memoized.cache = new (memoize.Cache || Map)();
2594
+ memoize.cacheList.push(_memoized.cache);
2534
2595
  return _memoized;
2535
2596
  }
2536
2597
  memoize.Cache = Map;
2598
+ memoize.cacheList = [];
2599
+ memoize.clearCache = function () {
2600
+ memoize.cacheList.forEach(function (cache) {
2601
+ return cache.clear();
2602
+ });
2603
+ };
2537
2604
 
2538
2605
  // These units are iterated through, so be careful when adding or changing the
2539
2606
  // order.
@@ -2541,30 +2608,88 @@ var UnitType = /*#__PURE__*/function (UnitType) {
2541
2608
  UnitType[UnitType["kUnknown"] = 0] = "kUnknown";
2542
2609
  UnitType[UnitType["kNumber"] = 1] = "kNumber";
2543
2610
  UnitType[UnitType["kPercentage"] = 2] = "kPercentage";
2611
+ // Length units
2544
2612
  UnitType[UnitType["kEms"] = 3] = "kEms";
2613
+ // kExs,
2545
2614
  UnitType[UnitType["kPixels"] = 4] = "kPixels";
2615
+ // kCentimeters,
2616
+ // kMillimeters,
2617
+ // kInches,
2618
+ // kPoints,
2619
+ // kPicas,
2620
+ // kQuarterMillimeters,
2621
+ // https://drafts.csswg.org/css-values-4/#viewport-relative-lengths
2622
+ //
2623
+ // See also IsViewportPercentageLength.
2624
+ // kViewportWidth,
2625
+ // kViewportHeight,
2626
+ // kViewportInlineSize,
2627
+ // kViewportBlockSize,
2628
+ // kViewportMin,
2629
+ // kViewportMax,
2630
+ // kSmallViewportWidth,
2631
+ // kSmallViewportHeight,
2632
+ // kSmallViewportInlineSize,
2633
+ // kSmallViewportBlockSize,
2634
+ // kSmallViewportMin,
2635
+ // kSmallViewportMax,
2636
+ // kLargeViewportWidth,
2637
+ // kLargeViewportHeight,
2638
+ // kLargeViewportInlineSize,
2639
+ // kLargeViewportBlockSize,
2640
+ // kLargeViewportMin,
2641
+ // kLargeViewportMax,
2642
+ // kDynamicViewportWidth,
2643
+ // kDynamicViewportHeight,
2644
+ // kDynamicViewportInlineSize,
2645
+ // kDynamicViewportBlockSize,
2646
+ // kDynamicViewportMin,
2647
+ // kDynamicViewportMax,
2648
+ // https://drafts.csswg.org/css-contain-3/#container-lengths
2649
+ //
2650
+ // See also IsContainerPercentageLength.
2651
+ // kContainerWidth,
2652
+ // kContainerHeight,
2653
+ // kContainerInlineSize,
2654
+ // kContainerBlockSize,
2655
+ // kContainerMin,
2656
+ // kContainerMax,
2546
2657
  UnitType[UnitType["kRems"] = 5] = "kRems";
2658
+ // kChs,
2659
+ // kUserUnits, // The SVG term for unitless lengths
2660
+ // Angle units
2547
2661
  UnitType[UnitType["kDegrees"] = 6] = "kDegrees";
2548
2662
  UnitType[UnitType["kRadians"] = 7] = "kRadians";
2549
2663
  UnitType[UnitType["kGradians"] = 8] = "kGradians";
2550
2664
  UnitType[UnitType["kTurns"] = 9] = "kTurns";
2665
+ // Time units
2551
2666
  UnitType[UnitType["kMilliseconds"] = 10] = "kMilliseconds";
2552
2667
  UnitType[UnitType["kSeconds"] = 11] = "kSeconds";
2553
- UnitType[UnitType["kInteger"] = 12] = "kInteger";
2668
+ // kHertz,
2669
+ // kKilohertz,
2670
+ // Resolution
2671
+ // kDotsPerPixel,
2672
+ // kDotsPerInch,
2673
+ // kDotsPerCentimeter,
2674
+ // Other units
2675
+ // kFraction,
2676
+ UnitType[UnitType["kInteger"] = 12] = "kInteger"; // This value is used to handle quirky margins in reflow roots (body, td,
2677
+ // and th) like WinIE. The basic idea is that a stylesheet can use the value
2678
+ // __qem (for quirky em) instead of em. When the quirky value is used, if
2679
+ // you're in quirks mode, the margin will collapse away inside a table cell.
2680
+ // This quirk is specified in the HTML spec but our impl is different.
2681
+ // TODO: Remove this. crbug.com/443952
2682
+ // kQuirkyEms,
2554
2683
  return UnitType;
2555
- }({}); // This value is used to handle quirky margins in reflow roots (body, td,
2556
- // and th) like WinIE. The basic idea is that a stylesheet can use the value
2557
- // __qem (for quirky em) instead of em. When the quirky value is used, if
2558
- // you're in quirks mode, the margin will collapse away inside a table cell.
2559
- // This quirk is specified in the HTML spec but our impl is different.
2560
- // TODO: Remove this. crbug.com/443952
2561
- // kQuirkyEms,
2684
+ }({});
2562
2685
  var UnitCategory = /*#__PURE__*/function (UnitCategory) {
2563
2686
  UnitCategory[UnitCategory["kUNumber"] = 0] = "kUNumber";
2564
2687
  UnitCategory[UnitCategory["kUPercent"] = 1] = "kUPercent";
2565
2688
  UnitCategory[UnitCategory["kULength"] = 2] = "kULength";
2566
2689
  UnitCategory[UnitCategory["kUAngle"] = 3] = "kUAngle";
2567
2690
  UnitCategory[UnitCategory["kUTime"] = 4] = "kUTime";
2691
+ // kUFrequency,
2692
+ // kUResolution,
2568
2693
  UnitCategory[UnitCategory["kUOther"] = 5] = "kUOther";
2569
2694
  return UnitCategory;
2570
2695
  }({});
@@ -2801,6 +2926,7 @@ var CSSStyleValueType = /*#__PURE__*/function (CSSStyleValueType) {
2801
2926
  CSSStyleValueType[CSSStyleValueType["kUnknownType"] = 0] = "kUnknownType";
2802
2927
  CSSStyleValueType[CSSStyleValueType["kUnparsedType"] = 1] = "kUnparsedType";
2803
2928
  CSSStyleValueType[CSSStyleValueType["kKeywordType"] = 2] = "kKeywordType";
2929
+ // Start of CSSNumericValue subclasses
2804
2930
  CSSStyleValueType[CSSStyleValueType["kUnitType"] = 3] = "kUnitType";
2805
2931
  CSSStyleValueType[CSSStyleValueType["kSumType"] = 4] = "kSumType";
2806
2932
  CSSStyleValueType[CSSStyleValueType["kProductType"] = 5] = "kProductType";
@@ -2809,6 +2935,7 @@ var CSSStyleValueType = /*#__PURE__*/function (CSSStyleValueType) {
2809
2935
  CSSStyleValueType[CSSStyleValueType["kMinType"] = 8] = "kMinType";
2810
2936
  CSSStyleValueType[CSSStyleValueType["kMaxType"] = 9] = "kMaxType";
2811
2937
  CSSStyleValueType[CSSStyleValueType["kClampType"] = 10] = "kClampType";
2938
+ // End of CSSNumericValue subclasses
2812
2939
  CSSStyleValueType[CSSStyleValueType["kTransformType"] = 11] = "kTransformType";
2813
2940
  CSSStyleValueType[CSSStyleValueType["kPositionType"] = 12] = "kPositionType";
2814
2941
  CSSStyleValueType[CSSStyleValueType["kURLImageType"] = 13] = "kURLImageType";
@@ -9679,8 +9806,7 @@ var EventService = /*#__PURE__*/function () {
9679
9806
  }, {
9680
9807
  key: "notifyTarget",
9681
9808
  value: function notifyTarget(e, type) {
9682
- var _type;
9683
- type = (_type = type) !== null && _type !== void 0 ? _type : e.type;
9809
+ type = type !== null && type !== void 0 ? type : e.type;
9684
9810
  var key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? "".concat(type, "capture") : type;
9685
9811
  this.notifyListeners(e, key);
9686
9812
  if (e.eventPhase === e.AT_TARGET) {
@@ -10224,11 +10350,30 @@ var DefaultSceneGraphSelector = /*#__PURE__*/function () {
10224
10350
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
10225
10351
  */
10226
10352
  var ElementEvent = /*#__PURE__*/function (ElementEvent) {
10353
+ // --- @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
10354
+ /**
10355
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
10356
+ */
10227
10357
  ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
10358
+ /**
10359
+ * it has been inserted
10360
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
10361
+ */
10228
10362
  ElementEvent["INSERTED"] = "DOMNodeInserted";
10363
+ /**
10364
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
10365
+ */
10229
10366
  ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
10367
+ /**
10368
+ * it is being removed
10369
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
10370
+ */
10230
10371
  ElementEvent["REMOVED"] = "removed";
10372
+ /**
10373
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
10374
+ */
10231
10375
  ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
10376
+ // ---
10232
10377
  ElementEvent["REPARENT"] = "reparent";
10233
10378
  ElementEvent["DESTROY"] = "destroy";
10234
10379
  ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
@@ -11504,6 +11649,7 @@ var TextService = /*#__PURE__*/function () {
11504
11649
  var lines = [];
11505
11650
  var currentLineIndex = 0;
11506
11651
  var currentLineWidth = 0;
11652
+ var prevLineLastCharIndex = 0;
11507
11653
  var cache = {};
11508
11654
  var calcWidth = function calcWidth(txt) {
11509
11655
  return _this2.getFromCache(txt, letterSpacing, cache, context);
@@ -11515,24 +11661,25 @@ var TextService = /*#__PURE__*/function () {
11515
11661
  *
11516
11662
  * @see https://github.com/antvis/G/issues/1833
11517
11663
  *
11518
- * @param txt - Current line of text
11519
- * @param textCharIndex - The index of the last character of the current line in the entire text
11664
+ * @param lineTxt - Current line of text
11665
+ * @param txtLastCharIndex - The index of the last character of the current line in the entire text
11666
+ * @param txtStartCharIndex - The index of the start character of the current line in the entire text
11520
11667
  */
11521
- function findCharIndexClosestWidthThreshold(txt, textCharIndex, widthThreshold) {
11522
- while (calcWidth(txt) < widthThreshold && textCharIndex < chars.length - 1) {
11523
- if (self.isNewline(chars[textCharIndex + 1])) {
11668
+ function findCharIndexClosestWidthThreshold(lineTxt, txtLastCharIndex, txtStartCharIndex, widthThreshold) {
11669
+ while (calcWidth(lineTxt) < widthThreshold && txtLastCharIndex < chars.length - 1) {
11670
+ if (self.isNewline(chars[txtLastCharIndex + 1])) {
11524
11671
  break;
11525
11672
  }
11526
- textCharIndex += 1;
11527
- txt += chars[textCharIndex];
11673
+ txtLastCharIndex += 1;
11674
+ lineTxt += chars[txtLastCharIndex];
11528
11675
  }
11529
- while (calcWidth(txt) > widthThreshold && textCharIndex > 0) {
11530
- textCharIndex -= 1;
11531
- txt = txt.slice(0, -1);
11676
+ while (calcWidth(lineTxt) > widthThreshold && txtLastCharIndex > txtStartCharIndex) {
11677
+ txtLastCharIndex -= 1;
11678
+ lineTxt = lineTxt.slice(0, -1);
11532
11679
  }
11533
11680
  return {
11534
- txt: txt,
11535
- textCharIndex: textCharIndex
11681
+ lineTxt: lineTxt,
11682
+ txtLastCharIndex: txtLastCharIndex
11536
11683
  };
11537
11684
  }
11538
11685
  function appendEllipsis(lineIndex, textCharIndex) {
@@ -11545,8 +11692,8 @@ var TextService = /*#__PURE__*/function () {
11545
11692
  lines[lineIndex] = ellipsis;
11546
11693
  return;
11547
11694
  }
11548
- var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, maxWidth - ellipsisWidth);
11549
- lines[lineIndex] = result.txt + ellipsis;
11695
+ var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, prevLineLastCharIndex + 1, maxWidth - ellipsisWidth);
11696
+ lines[lineIndex] = result.lineTxt + ellipsis;
11550
11697
  }
11551
11698
  for (var i = 0; i < chars.length; i++) {
11552
11699
  var _char2 = chars[i];
@@ -11562,19 +11709,20 @@ var TextService = /*#__PURE__*/function () {
11562
11709
  }
11563
11710
  break;
11564
11711
  }
11712
+ prevLineLastCharIndex = i - 1;
11565
11713
  currentLineIndex += 1;
11566
11714
  currentLineWidth = 0;
11567
11715
  lines[currentLineIndex] = '';
11568
11716
  continue;
11569
11717
  }
11570
11718
  if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
11571
- var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, maxWidth);
11572
- if (result.textCharIndex !== i - 1) {
11573
- lines[currentLineIndex] = result.txt;
11574
- if (result.textCharIndex === chars.length - 1) {
11719
+ var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, prevLineLastCharIndex + 1, maxWidth);
11720
+ if (result.txtLastCharIndex !== i - 1) {
11721
+ lines[currentLineIndex] = result.lineTxt;
11722
+ if (result.txtLastCharIndex === chars.length - 1) {
11575
11723
  break;
11576
11724
  }
11577
- i = result.textCharIndex + 1;
11725
+ i = result.txtLastCharIndex + 1;
11578
11726
  _char2 = chars[i];
11579
11727
  prevChar = chars[i - 1];
11580
11728
  nextChar = chars[i + 1];
@@ -11585,6 +11733,7 @@ var TextService = /*#__PURE__*/function () {
11585
11733
  appendEllipsis(currentLineIndex, i - 1);
11586
11734
  break;
11587
11735
  }
11736
+ prevLineLastCharIndex = i - 1;
11588
11737
  currentLineIndex += 1;
11589
11738
  currentLineWidth = 0;
11590
11739
  lines[currentLineIndex] = '';
@@ -15585,6 +15734,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
15585
15734
  value: function destroy() {
15586
15735
  var cleanUp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
15587
15736
  var skipTriggerEvent = arguments.length > 1 ? arguments[1] : undefined;
15737
+ memoize.clearCache();
15588
15738
  if (!skipTriggerEvent) {
15589
15739
  this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY));
15590
15740
  }