@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.esm.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
  */
@@ -1571,8 +1571,31 @@ function combine(out, a, b, scale1, scale2) {
1571
1571
  */
1572
1572
 
1573
1573
  var CameraType = /*#__PURE__*/function (CameraType) {
1574
+ /**
1575
+ * Performs all the rotational operations with the focal point instead of the camera position.
1576
+ * This type of camera is useful in applications(like CAD) where 3D objects are being designed or explored.
1577
+ * Camera cannot orbits over the north & south poles.
1578
+ * @see http://voxelent.com/tutorial-cameras/
1579
+ *
1580
+ * In Three.js it's used in OrbitControls.
1581
+ * @see https://threejs.org/docs/#examples/zh/controls/OrbitControls
1582
+ */
1574
1583
  CameraType[CameraType["ORBITING"] = 0] = "ORBITING";
1584
+ /**
1585
+ * It's similar to the ORBITING camera, but it allows the camera to orbit over the north or south poles.
1586
+ *
1587
+ * In Three.js it's used in OrbitControls.
1588
+ * @see https://threejs.org/docs/#examples/en/controls/TrackballControls
1589
+ */
1575
1590
  CameraType[CameraType["EXPLORING"] = 1] = "EXPLORING";
1591
+ /**
1592
+ * Performs all the rotational operations with the camera position.
1593
+ * It's useful in first person shooting games.
1594
+ * Camera cannot orbits over the north & south poles.
1595
+ *
1596
+ * In Three.js it's used in FirstPersonControls.
1597
+ * @see https://threejs.org/docs/#examples/en/controls/FirstPersonControls
1598
+ */
1576
1599
  CameraType[CameraType["TRACKING"] = 2] = "TRACKING";
1577
1600
  return CameraType;
1578
1601
  }({});
@@ -2466,20 +2489,57 @@ var EMPTY_PARSED_PATH = {
2466
2489
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
2467
2490
  */
2468
2491
  var PropertySyntax = /*#__PURE__*/function (PropertySyntax) {
2492
+ /**
2493
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
2494
+ */
2469
2495
  PropertySyntax["COORDINATE"] = "<coordinate>";
2496
+ /**
2497
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
2498
+ */
2470
2499
  PropertySyntax["COLOR"] = "<color>";
2500
+ /**
2501
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
2502
+ */
2471
2503
  PropertySyntax["PAINT"] = "<paint>";
2504
+ /**
2505
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
2506
+ */
2472
2507
  PropertySyntax["NUMBER"] = "<number>";
2508
+ /**
2509
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
2510
+ */
2473
2511
  PropertySyntax["ANGLE"] = "<angle>";
2512
+ /**
2513
+ * <number> with range 0..1
2514
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
2515
+ */
2474
2516
  PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
2517
+ /**
2518
+ * <number> with range 0..Infinity
2519
+ */
2475
2520
  PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
2521
+ /**
2522
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
2523
+ */
2476
2524
  PropertySyntax["LENGTH"] = "<length>";
2525
+ /**
2526
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
2527
+ */
2477
2528
  PropertySyntax["PERCENTAGE"] = "<percentage>";
2478
2529
  PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2479
2530
  PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2531
+ /**
2532
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2533
+ */
2480
2534
  PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2535
+ /**
2536
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2537
+ */
2481
2538
  PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2482
2539
  PropertySyntax["PATH"] = "<path>";
2540
+ /**
2541
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2542
+ */
2483
2543
  PropertySyntax["FILTER"] = "<filter>";
2484
2544
  PropertySyntax["Z_INDEX"] = "<z-index>";
2485
2545
  PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
@@ -2510,9 +2570,16 @@ function memoize(func, resolver) {
2510
2570
  return result;
2511
2571
  };
2512
2572
  _memoized.cache = new (memoize.Cache || Map)();
2573
+ memoize.cacheList.push(_memoized.cache);
2513
2574
  return _memoized;
2514
2575
  }
2515
2576
  memoize.Cache = Map;
2577
+ memoize.cacheList = [];
2578
+ memoize.clearCache = function () {
2579
+ memoize.cacheList.forEach(function (cache) {
2580
+ return cache.clear();
2581
+ });
2582
+ };
2516
2583
 
2517
2584
  // These units are iterated through, so be careful when adding or changing the
2518
2585
  // order.
@@ -2520,30 +2587,88 @@ var UnitType = /*#__PURE__*/function (UnitType) {
2520
2587
  UnitType[UnitType["kUnknown"] = 0] = "kUnknown";
2521
2588
  UnitType[UnitType["kNumber"] = 1] = "kNumber";
2522
2589
  UnitType[UnitType["kPercentage"] = 2] = "kPercentage";
2590
+ // Length units
2523
2591
  UnitType[UnitType["kEms"] = 3] = "kEms";
2592
+ // kExs,
2524
2593
  UnitType[UnitType["kPixels"] = 4] = "kPixels";
2594
+ // kCentimeters,
2595
+ // kMillimeters,
2596
+ // kInches,
2597
+ // kPoints,
2598
+ // kPicas,
2599
+ // kQuarterMillimeters,
2600
+ // https://drafts.csswg.org/css-values-4/#viewport-relative-lengths
2601
+ //
2602
+ // See also IsViewportPercentageLength.
2603
+ // kViewportWidth,
2604
+ // kViewportHeight,
2605
+ // kViewportInlineSize,
2606
+ // kViewportBlockSize,
2607
+ // kViewportMin,
2608
+ // kViewportMax,
2609
+ // kSmallViewportWidth,
2610
+ // kSmallViewportHeight,
2611
+ // kSmallViewportInlineSize,
2612
+ // kSmallViewportBlockSize,
2613
+ // kSmallViewportMin,
2614
+ // kSmallViewportMax,
2615
+ // kLargeViewportWidth,
2616
+ // kLargeViewportHeight,
2617
+ // kLargeViewportInlineSize,
2618
+ // kLargeViewportBlockSize,
2619
+ // kLargeViewportMin,
2620
+ // kLargeViewportMax,
2621
+ // kDynamicViewportWidth,
2622
+ // kDynamicViewportHeight,
2623
+ // kDynamicViewportInlineSize,
2624
+ // kDynamicViewportBlockSize,
2625
+ // kDynamicViewportMin,
2626
+ // kDynamicViewportMax,
2627
+ // https://drafts.csswg.org/css-contain-3/#container-lengths
2628
+ //
2629
+ // See also IsContainerPercentageLength.
2630
+ // kContainerWidth,
2631
+ // kContainerHeight,
2632
+ // kContainerInlineSize,
2633
+ // kContainerBlockSize,
2634
+ // kContainerMin,
2635
+ // kContainerMax,
2525
2636
  UnitType[UnitType["kRems"] = 5] = "kRems";
2637
+ // kChs,
2638
+ // kUserUnits, // The SVG term for unitless lengths
2639
+ // Angle units
2526
2640
  UnitType[UnitType["kDegrees"] = 6] = "kDegrees";
2527
2641
  UnitType[UnitType["kRadians"] = 7] = "kRadians";
2528
2642
  UnitType[UnitType["kGradians"] = 8] = "kGradians";
2529
2643
  UnitType[UnitType["kTurns"] = 9] = "kTurns";
2644
+ // Time units
2530
2645
  UnitType[UnitType["kMilliseconds"] = 10] = "kMilliseconds";
2531
2646
  UnitType[UnitType["kSeconds"] = 11] = "kSeconds";
2532
- UnitType[UnitType["kInteger"] = 12] = "kInteger";
2647
+ // kHertz,
2648
+ // kKilohertz,
2649
+ // Resolution
2650
+ // kDotsPerPixel,
2651
+ // kDotsPerInch,
2652
+ // kDotsPerCentimeter,
2653
+ // Other units
2654
+ // kFraction,
2655
+ UnitType[UnitType["kInteger"] = 12] = "kInteger"; // This value is used to handle quirky margins in reflow roots (body, td,
2656
+ // and th) like WinIE. The basic idea is that a stylesheet can use the value
2657
+ // __qem (for quirky em) instead of em. When the quirky value is used, if
2658
+ // you're in quirks mode, the margin will collapse away inside a table cell.
2659
+ // This quirk is specified in the HTML spec but our impl is different.
2660
+ // TODO: Remove this. crbug.com/443952
2661
+ // kQuirkyEms,
2533
2662
  return UnitType;
2534
- }({}); // This value is used to handle quirky margins in reflow roots (body, td,
2535
- // and th) like WinIE. The basic idea is that a stylesheet can use the value
2536
- // __qem (for quirky em) instead of em. When the quirky value is used, if
2537
- // you're in quirks mode, the margin will collapse away inside a table cell.
2538
- // This quirk is specified in the HTML spec but our impl is different.
2539
- // TODO: Remove this. crbug.com/443952
2540
- // kQuirkyEms,
2663
+ }({});
2541
2664
  var UnitCategory = /*#__PURE__*/function (UnitCategory) {
2542
2665
  UnitCategory[UnitCategory["kUNumber"] = 0] = "kUNumber";
2543
2666
  UnitCategory[UnitCategory["kUPercent"] = 1] = "kUPercent";
2544
2667
  UnitCategory[UnitCategory["kULength"] = 2] = "kULength";
2545
2668
  UnitCategory[UnitCategory["kUAngle"] = 3] = "kUAngle";
2546
2669
  UnitCategory[UnitCategory["kUTime"] = 4] = "kUTime";
2670
+ // kUFrequency,
2671
+ // kUResolution,
2547
2672
  UnitCategory[UnitCategory["kUOther"] = 5] = "kUOther";
2548
2673
  return UnitCategory;
2549
2674
  }({});
@@ -2780,6 +2905,7 @@ var CSSStyleValueType = /*#__PURE__*/function (CSSStyleValueType) {
2780
2905
  CSSStyleValueType[CSSStyleValueType["kUnknownType"] = 0] = "kUnknownType";
2781
2906
  CSSStyleValueType[CSSStyleValueType["kUnparsedType"] = 1] = "kUnparsedType";
2782
2907
  CSSStyleValueType[CSSStyleValueType["kKeywordType"] = 2] = "kKeywordType";
2908
+ // Start of CSSNumericValue subclasses
2783
2909
  CSSStyleValueType[CSSStyleValueType["kUnitType"] = 3] = "kUnitType";
2784
2910
  CSSStyleValueType[CSSStyleValueType["kSumType"] = 4] = "kSumType";
2785
2911
  CSSStyleValueType[CSSStyleValueType["kProductType"] = 5] = "kProductType";
@@ -2788,6 +2914,7 @@ var CSSStyleValueType = /*#__PURE__*/function (CSSStyleValueType) {
2788
2914
  CSSStyleValueType[CSSStyleValueType["kMinType"] = 8] = "kMinType";
2789
2915
  CSSStyleValueType[CSSStyleValueType["kMaxType"] = 9] = "kMaxType";
2790
2916
  CSSStyleValueType[CSSStyleValueType["kClampType"] = 10] = "kClampType";
2917
+ // End of CSSNumericValue subclasses
2791
2918
  CSSStyleValueType[CSSStyleValueType["kTransformType"] = 11] = "kTransformType";
2792
2919
  CSSStyleValueType[CSSStyleValueType["kPositionType"] = 12] = "kPositionType";
2793
2920
  CSSStyleValueType[CSSStyleValueType["kURLImageType"] = 13] = "kURLImageType";
@@ -9658,8 +9785,7 @@ var EventService = /*#__PURE__*/function () {
9658
9785
  }, {
9659
9786
  key: "notifyTarget",
9660
9787
  value: function notifyTarget(e, type) {
9661
- var _type;
9662
- type = (_type = type) !== null && _type !== void 0 ? _type : e.type;
9788
+ type = type !== null && type !== void 0 ? type : e.type;
9663
9789
  var key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? "".concat(type, "capture") : type;
9664
9790
  this.notifyListeners(e, key);
9665
9791
  if (e.eventPhase === e.AT_TARGET) {
@@ -10203,11 +10329,30 @@ var DefaultSceneGraphSelector = /*#__PURE__*/function () {
10203
10329
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
10204
10330
  */
10205
10331
  var ElementEvent = /*#__PURE__*/function (ElementEvent) {
10332
+ // --- @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
10333
+ /**
10334
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
10335
+ */
10206
10336
  ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
10337
+ /**
10338
+ * it has been inserted
10339
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
10340
+ */
10207
10341
  ElementEvent["INSERTED"] = "DOMNodeInserted";
10342
+ /**
10343
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
10344
+ */
10208
10345
  ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
10346
+ /**
10347
+ * it is being removed
10348
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
10349
+ */
10209
10350
  ElementEvent["REMOVED"] = "removed";
10351
+ /**
10352
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
10353
+ */
10210
10354
  ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
10355
+ // ---
10211
10356
  ElementEvent["REPARENT"] = "reparent";
10212
10357
  ElementEvent["DESTROY"] = "destroy";
10213
10358
  ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
@@ -11483,6 +11628,7 @@ var TextService = /*#__PURE__*/function () {
11483
11628
  var lines = [];
11484
11629
  var currentLineIndex = 0;
11485
11630
  var currentLineWidth = 0;
11631
+ var prevLineLastCharIndex = 0;
11486
11632
  var cache = {};
11487
11633
  var calcWidth = function calcWidth(txt) {
11488
11634
  return _this2.getFromCache(txt, letterSpacing, cache, context);
@@ -11494,24 +11640,25 @@ var TextService = /*#__PURE__*/function () {
11494
11640
  *
11495
11641
  * @see https://github.com/antvis/G/issues/1833
11496
11642
  *
11497
- * @param txt - Current line of text
11498
- * @param textCharIndex - The index of the last character of the current line in the entire text
11643
+ * @param lineTxt - Current line of text
11644
+ * @param txtLastCharIndex - The index of the last character of the current line in the entire text
11645
+ * @param txtStartCharIndex - The index of the start character of the current line in the entire text
11499
11646
  */
11500
- function findCharIndexClosestWidthThreshold(txt, textCharIndex, widthThreshold) {
11501
- while (calcWidth(txt) < widthThreshold && textCharIndex < chars.length - 1) {
11502
- if (self.isNewline(chars[textCharIndex + 1])) {
11647
+ function findCharIndexClosestWidthThreshold(lineTxt, txtLastCharIndex, txtStartCharIndex, widthThreshold) {
11648
+ while (calcWidth(lineTxt) < widthThreshold && txtLastCharIndex < chars.length - 1) {
11649
+ if (self.isNewline(chars[txtLastCharIndex + 1])) {
11503
11650
  break;
11504
11651
  }
11505
- textCharIndex += 1;
11506
- txt += chars[textCharIndex];
11652
+ txtLastCharIndex += 1;
11653
+ lineTxt += chars[txtLastCharIndex];
11507
11654
  }
11508
- while (calcWidth(txt) > widthThreshold && textCharIndex > 0) {
11509
- textCharIndex -= 1;
11510
- txt = txt.slice(0, -1);
11655
+ while (calcWidth(lineTxt) > widthThreshold && txtLastCharIndex > txtStartCharIndex) {
11656
+ txtLastCharIndex -= 1;
11657
+ lineTxt = lineTxt.slice(0, -1);
11511
11658
  }
11512
11659
  return {
11513
- txt: txt,
11514
- textCharIndex: textCharIndex
11660
+ lineTxt: lineTxt,
11661
+ txtLastCharIndex: txtLastCharIndex
11515
11662
  };
11516
11663
  }
11517
11664
  function appendEllipsis(lineIndex, textCharIndex) {
@@ -11524,8 +11671,8 @@ var TextService = /*#__PURE__*/function () {
11524
11671
  lines[lineIndex] = ellipsis;
11525
11672
  return;
11526
11673
  }
11527
- var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, maxWidth - ellipsisWidth);
11528
- lines[lineIndex] = result.txt + ellipsis;
11674
+ var result = findCharIndexClosestWidthThreshold(lines[lineIndex], textCharIndex, prevLineLastCharIndex + 1, maxWidth - ellipsisWidth);
11675
+ lines[lineIndex] = result.lineTxt + ellipsis;
11529
11676
  }
11530
11677
  for (var i = 0; i < chars.length; i++) {
11531
11678
  var _char2 = chars[i];
@@ -11541,19 +11688,20 @@ var TextService = /*#__PURE__*/function () {
11541
11688
  }
11542
11689
  break;
11543
11690
  }
11691
+ prevLineLastCharIndex = i - 1;
11544
11692
  currentLineIndex += 1;
11545
11693
  currentLineWidth = 0;
11546
11694
  lines[currentLineIndex] = '';
11547
11695
  continue;
11548
11696
  }
11549
11697
  if (currentLineWidth > 0 && currentLineWidth + charWidth > maxWidth) {
11550
- var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, maxWidth);
11551
- if (result.textCharIndex !== i - 1) {
11552
- lines[currentLineIndex] = result.txt;
11553
- if (result.textCharIndex === chars.length - 1) {
11698
+ var result = findCharIndexClosestWidthThreshold(lines[currentLineIndex], i - 1, prevLineLastCharIndex + 1, maxWidth);
11699
+ if (result.txtLastCharIndex !== i - 1) {
11700
+ lines[currentLineIndex] = result.lineTxt;
11701
+ if (result.txtLastCharIndex === chars.length - 1) {
11554
11702
  break;
11555
11703
  }
11556
- i = result.textCharIndex + 1;
11704
+ i = result.txtLastCharIndex + 1;
11557
11705
  _char2 = chars[i];
11558
11706
  prevChar = chars[i - 1];
11559
11707
  nextChar = chars[i + 1];
@@ -11564,6 +11712,7 @@ var TextService = /*#__PURE__*/function () {
11564
11712
  appendEllipsis(currentLineIndex, i - 1);
11565
11713
  break;
11566
11714
  }
11715
+ prevLineLastCharIndex = i - 1;
11567
11716
  currentLineIndex += 1;
11568
11717
  currentLineWidth = 0;
11569
11718
  lines[currentLineIndex] = '';
@@ -15564,6 +15713,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
15564
15713
  value: function destroy() {
15565
15714
  var cleanUp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
15566
15715
  var skipTriggerEvent = arguments.length > 1 ? arguments[1] : undefined;
15716
+ memoize.clearCache();
15567
15717
  if (!skipTriggerEvent) {
15568
15718
  this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY));
15569
15719
  }