@antv/g-lite 2.2.14 → 2.2.16

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.14
5
- * @date 1/2/2025, 2:54:20 AM
4
+ * @version 2.2.16
5
+ * @date 1/23/2025, 8:31:51 AM
6
6
  * @author AntVis
7
7
  * @docs https://g.antv.antgroup.com/
8
8
  */
@@ -19,7 +19,6 @@ import '@babel/runtime/helpers/readOnlyError';
19
19
  import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isUndefined, isArray, isBoolean, isFunction, isObject, getPointAtLength } from '@antv/util';
20
20
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
21
21
  import _superPropGet from '@babel/runtime/helpers/superPropGet';
22
- import * as d3 from 'd3-color';
23
22
  import { polylineLength, arcBox, cubicBox, quadBox, linePointAt, lineLength } from '@antv/g-math';
24
23
  import _regeneratorRuntime from '@babel/runtime/helpers/regeneratorRuntime';
25
24
  import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
@@ -1571,8 +1570,31 @@ function combine(out, a, b, scale1, scale2) {
1571
1570
  */
1572
1571
 
1573
1572
  var CameraType = /*#__PURE__*/function (CameraType) {
1573
+ /**
1574
+ * Performs all the rotational operations with the focal point instead of the camera position.
1575
+ * This type of camera is useful in applications(like CAD) where 3D objects are being designed or explored.
1576
+ * Camera cannot orbits over the north & south poles.
1577
+ * @see http://voxelent.com/tutorial-cameras/
1578
+ *
1579
+ * In Three.js it's used in OrbitControls.
1580
+ * @see https://threejs.org/docs/#examples/zh/controls/OrbitControls
1581
+ */
1574
1582
  CameraType[CameraType["ORBITING"] = 0] = "ORBITING";
1583
+ /**
1584
+ * It's similar to the ORBITING camera, but it allows the camera to orbit over the north or south poles.
1585
+ *
1586
+ * In Three.js it's used in OrbitControls.
1587
+ * @see https://threejs.org/docs/#examples/en/controls/TrackballControls
1588
+ */
1575
1589
  CameraType[CameraType["EXPLORING"] = 1] = "EXPLORING";
1590
+ /**
1591
+ * Performs all the rotational operations with the camera position.
1592
+ * It's useful in first person shooting games.
1593
+ * Camera cannot orbits over the north & south poles.
1594
+ *
1595
+ * In Three.js it's used in FirstPersonControls.
1596
+ * @see https://threejs.org/docs/#examples/en/controls/FirstPersonControls
1597
+ */
1576
1598
  CameraType[CameraType["TRACKING"] = 2] = "TRACKING";
1577
1599
  return CameraType;
1578
1600
  }({});
@@ -2466,20 +2488,57 @@ var EMPTY_PARSED_PATH = {
2466
2488
  * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type
2467
2489
  */
2468
2490
  var PropertySyntax = /*#__PURE__*/function (PropertySyntax) {
2491
+ /**
2492
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#coordinate
2493
+ */
2469
2494
  PropertySyntax["COORDINATE"] = "<coordinate>";
2495
+ /**
2496
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#color
2497
+ */
2470
2498
  PropertySyntax["COLOR"] = "<color>";
2499
+ /**
2500
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#paint
2501
+ */
2471
2502
  PropertySyntax["PAINT"] = "<paint>";
2503
+ /**
2504
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#number
2505
+ */
2472
2506
  PropertySyntax["NUMBER"] = "<number>";
2507
+ /**
2508
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/angle
2509
+ */
2473
2510
  PropertySyntax["ANGLE"] = "<angle>";
2511
+ /**
2512
+ * <number> with range 0..1
2513
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#opacity_value
2514
+ */
2474
2515
  PropertySyntax["OPACITY_VALUE"] = "<opacity-value>";
2516
+ /**
2517
+ * <number> with range 0..Infinity
2518
+ */
2475
2519
  PropertySyntax["SHADOW_BLUR"] = "<shadow-blur>";
2520
+ /**
2521
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length
2522
+ */
2476
2523
  PropertySyntax["LENGTH"] = "<length>";
2524
+ /**
2525
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage
2526
+ */
2477
2527
  PropertySyntax["PERCENTAGE"] = "<percentage>";
2478
2528
  PropertySyntax["LENGTH_PERCENTAGE"] = "<length> | <percentage>";
2479
2529
  PropertySyntax["LENGTH_PERCENTAGE_12"] = "[<length> | <percentage>]{1,2}";
2530
+ /**
2531
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/margin#formal_syntax
2532
+ */
2480
2533
  PropertySyntax["LENGTH_PERCENTAGE_14"] = "[<length> | <percentage>]{1,4}";
2534
+ /**
2535
+ * @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
2536
+ */
2481
2537
  PropertySyntax["LIST_OF_POINTS"] = "<list-of-points>";
2482
2538
  PropertySyntax["PATH"] = "<path>";
2539
+ /**
2540
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
2541
+ */
2483
2542
  PropertySyntax["FILTER"] = "<filter>";
2484
2543
  PropertySyntax["Z_INDEX"] = "<z-index>";
2485
2544
  PropertySyntax["OFFSET_DISTANCE"] = "<offset-distance>";
@@ -2492,6 +2551,412 @@ var PropertySyntax = /*#__PURE__*/function (PropertySyntax) {
2492
2551
  return PropertySyntax;
2493
2552
  }({});
2494
2553
 
2554
+ function define(constructor, factory, prototype) {
2555
+ constructor.prototype = factory.prototype = prototype;
2556
+ prototype.constructor = constructor;
2557
+ }
2558
+
2559
+ function extend(parent, definition) {
2560
+ var prototype = Object.create(parent.prototype);
2561
+ for (var key in definition) prototype[key] = definition[key];
2562
+ return prototype;
2563
+ }
2564
+
2565
+ function Color() {}
2566
+
2567
+ var darker = 0.7;
2568
+ var brighter = 1 / darker;
2569
+
2570
+ var reI = "\\s*([+-]?\\d+)\\s*",
2571
+ reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",
2572
+ reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
2573
+ reHex = /^#([0-9a-f]{3,8})$/,
2574
+ reRgbInteger = new RegExp(`^rgb\\(${reI},${reI},${reI}\\)$`),
2575
+ reRgbPercent = new RegExp(`^rgb\\(${reP},${reP},${reP}\\)$`),
2576
+ reRgbaInteger = new RegExp(`^rgba\\(${reI},${reI},${reI},${reN}\\)$`),
2577
+ reRgbaPercent = new RegExp(`^rgba\\(${reP},${reP},${reP},${reN}\\)$`),
2578
+ reHslPercent = new RegExp(`^hsl\\(${reN},${reP},${reP}\\)$`),
2579
+ reHslaPercent = new RegExp(`^hsla\\(${reN},${reP},${reP},${reN}\\)$`);
2580
+
2581
+ var named = {
2582
+ aliceblue: 0xf0f8ff,
2583
+ antiquewhite: 0xfaebd7,
2584
+ aqua: 0x00ffff,
2585
+ aquamarine: 0x7fffd4,
2586
+ azure: 0xf0ffff,
2587
+ beige: 0xf5f5dc,
2588
+ bisque: 0xffe4c4,
2589
+ black: 0x000000,
2590
+ blanchedalmond: 0xffebcd,
2591
+ blue: 0x0000ff,
2592
+ blueviolet: 0x8a2be2,
2593
+ brown: 0xa52a2a,
2594
+ burlywood: 0xdeb887,
2595
+ cadetblue: 0x5f9ea0,
2596
+ chartreuse: 0x7fff00,
2597
+ chocolate: 0xd2691e,
2598
+ coral: 0xff7f50,
2599
+ cornflowerblue: 0x6495ed,
2600
+ cornsilk: 0xfff8dc,
2601
+ crimson: 0xdc143c,
2602
+ cyan: 0x00ffff,
2603
+ darkblue: 0x00008b,
2604
+ darkcyan: 0x008b8b,
2605
+ darkgoldenrod: 0xb8860b,
2606
+ darkgray: 0xa9a9a9,
2607
+ darkgreen: 0x006400,
2608
+ darkgrey: 0xa9a9a9,
2609
+ darkkhaki: 0xbdb76b,
2610
+ darkmagenta: 0x8b008b,
2611
+ darkolivegreen: 0x556b2f,
2612
+ darkorange: 0xff8c00,
2613
+ darkorchid: 0x9932cc,
2614
+ darkred: 0x8b0000,
2615
+ darksalmon: 0xe9967a,
2616
+ darkseagreen: 0x8fbc8f,
2617
+ darkslateblue: 0x483d8b,
2618
+ darkslategray: 0x2f4f4f,
2619
+ darkslategrey: 0x2f4f4f,
2620
+ darkturquoise: 0x00ced1,
2621
+ darkviolet: 0x9400d3,
2622
+ deeppink: 0xff1493,
2623
+ deepskyblue: 0x00bfff,
2624
+ dimgray: 0x696969,
2625
+ dimgrey: 0x696969,
2626
+ dodgerblue: 0x1e90ff,
2627
+ firebrick: 0xb22222,
2628
+ floralwhite: 0xfffaf0,
2629
+ forestgreen: 0x228b22,
2630
+ fuchsia: 0xff00ff,
2631
+ gainsboro: 0xdcdcdc,
2632
+ ghostwhite: 0xf8f8ff,
2633
+ gold: 0xffd700,
2634
+ goldenrod: 0xdaa520,
2635
+ gray: 0x808080,
2636
+ green: 0x008000,
2637
+ greenyellow: 0xadff2f,
2638
+ grey: 0x808080,
2639
+ honeydew: 0xf0fff0,
2640
+ hotpink: 0xff69b4,
2641
+ indianred: 0xcd5c5c,
2642
+ indigo: 0x4b0082,
2643
+ ivory: 0xfffff0,
2644
+ khaki: 0xf0e68c,
2645
+ lavender: 0xe6e6fa,
2646
+ lavenderblush: 0xfff0f5,
2647
+ lawngreen: 0x7cfc00,
2648
+ lemonchiffon: 0xfffacd,
2649
+ lightblue: 0xadd8e6,
2650
+ lightcoral: 0xf08080,
2651
+ lightcyan: 0xe0ffff,
2652
+ lightgoldenrodyellow: 0xfafad2,
2653
+ lightgray: 0xd3d3d3,
2654
+ lightgreen: 0x90ee90,
2655
+ lightgrey: 0xd3d3d3,
2656
+ lightpink: 0xffb6c1,
2657
+ lightsalmon: 0xffa07a,
2658
+ lightseagreen: 0x20b2aa,
2659
+ lightskyblue: 0x87cefa,
2660
+ lightslategray: 0x778899,
2661
+ lightslategrey: 0x778899,
2662
+ lightsteelblue: 0xb0c4de,
2663
+ lightyellow: 0xffffe0,
2664
+ lime: 0x00ff00,
2665
+ limegreen: 0x32cd32,
2666
+ linen: 0xfaf0e6,
2667
+ magenta: 0xff00ff,
2668
+ maroon: 0x800000,
2669
+ mediumaquamarine: 0x66cdaa,
2670
+ mediumblue: 0x0000cd,
2671
+ mediumorchid: 0xba55d3,
2672
+ mediumpurple: 0x9370db,
2673
+ mediumseagreen: 0x3cb371,
2674
+ mediumslateblue: 0x7b68ee,
2675
+ mediumspringgreen: 0x00fa9a,
2676
+ mediumturquoise: 0x48d1cc,
2677
+ mediumvioletred: 0xc71585,
2678
+ midnightblue: 0x191970,
2679
+ mintcream: 0xf5fffa,
2680
+ mistyrose: 0xffe4e1,
2681
+ moccasin: 0xffe4b5,
2682
+ navajowhite: 0xffdead,
2683
+ navy: 0x000080,
2684
+ oldlace: 0xfdf5e6,
2685
+ olive: 0x808000,
2686
+ olivedrab: 0x6b8e23,
2687
+ orange: 0xffa500,
2688
+ orangered: 0xff4500,
2689
+ orchid: 0xda70d6,
2690
+ palegoldenrod: 0xeee8aa,
2691
+ palegreen: 0x98fb98,
2692
+ paleturquoise: 0xafeeee,
2693
+ palevioletred: 0xdb7093,
2694
+ papayawhip: 0xffefd5,
2695
+ peachpuff: 0xffdab9,
2696
+ peru: 0xcd853f,
2697
+ pink: 0xffc0cb,
2698
+ plum: 0xdda0dd,
2699
+ powderblue: 0xb0e0e6,
2700
+ purple: 0x800080,
2701
+ rebeccapurple: 0x663399,
2702
+ red: 0xff0000,
2703
+ rosybrown: 0xbc8f8f,
2704
+ royalblue: 0x4169e1,
2705
+ saddlebrown: 0x8b4513,
2706
+ salmon: 0xfa8072,
2707
+ sandybrown: 0xf4a460,
2708
+ seagreen: 0x2e8b57,
2709
+ seashell: 0xfff5ee,
2710
+ sienna: 0xa0522d,
2711
+ silver: 0xc0c0c0,
2712
+ skyblue: 0x87ceeb,
2713
+ slateblue: 0x6a5acd,
2714
+ slategray: 0x708090,
2715
+ slategrey: 0x708090,
2716
+ snow: 0xfffafa,
2717
+ springgreen: 0x00ff7f,
2718
+ steelblue: 0x4682b4,
2719
+ tan: 0xd2b48c,
2720
+ teal: 0x008080,
2721
+ thistle: 0xd8bfd8,
2722
+ tomato: 0xff6347,
2723
+ turquoise: 0x40e0d0,
2724
+ violet: 0xee82ee,
2725
+ wheat: 0xf5deb3,
2726
+ white: 0xffffff,
2727
+ whitesmoke: 0xf5f5f5,
2728
+ yellow: 0xffff00,
2729
+ yellowgreen: 0x9acd32
2730
+ };
2731
+
2732
+ define(Color, color, {
2733
+ copy(channels) {
2734
+ return Object.assign(new this.constructor, this, channels);
2735
+ },
2736
+ displayable() {
2737
+ return this.rgb().displayable();
2738
+ },
2739
+ hex: color_formatHex, // Deprecated! Use color.formatHex.
2740
+ formatHex: color_formatHex,
2741
+ formatHex8: color_formatHex8,
2742
+ formatHsl: color_formatHsl,
2743
+ formatRgb: color_formatRgb,
2744
+ toString: color_formatRgb
2745
+ });
2746
+
2747
+ function color_formatHex() {
2748
+ return this.rgb().formatHex();
2749
+ }
2750
+
2751
+ function color_formatHex8() {
2752
+ return this.rgb().formatHex8();
2753
+ }
2754
+
2755
+ function color_formatHsl() {
2756
+ return hslConvert(this).formatHsl();
2757
+ }
2758
+
2759
+ function color_formatRgb() {
2760
+ return this.rgb().formatRgb();
2761
+ }
2762
+
2763
+ function color(format) {
2764
+ var m, l;
2765
+ format = (format + "").trim().toLowerCase();
2766
+ return (m = reHex.exec(format)) ? (l = m[1].length, m = parseInt(m[1], 16), l === 6 ? rgbn(m) // #ff0000
2767
+ : l === 3 ? new Rgb((m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), ((m & 0xf) << 4) | (m & 0xf), 1) // #f00
2768
+ : l === 8 ? rgba(m >> 24 & 0xff, m >> 16 & 0xff, m >> 8 & 0xff, (m & 0xff) / 0xff) // #ff000000
2769
+ : l === 4 ? rgba((m >> 12 & 0xf) | (m >> 8 & 0xf0), (m >> 8 & 0xf) | (m >> 4 & 0xf0), (m >> 4 & 0xf) | (m & 0xf0), (((m & 0xf) << 4) | (m & 0xf)) / 0xff) // #f000
2770
+ : null) // invalid hex
2771
+ : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
2772
+ : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
2773
+ : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
2774
+ : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
2775
+ : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
2776
+ : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
2777
+ : named.hasOwnProperty(format) ? rgbn(named[format]) // eslint-disable-line no-prototype-builtins
2778
+ : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0)
2779
+ : null;
2780
+ }
2781
+
2782
+ function rgbn(n) {
2783
+ return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
2784
+ }
2785
+
2786
+ function rgba(r, g, b, a) {
2787
+ if (a <= 0) r = g = b = NaN;
2788
+ return new Rgb(r, g, b, a);
2789
+ }
2790
+
2791
+ function rgbConvert(o) {
2792
+ if (!(o instanceof Color)) o = color(o);
2793
+ if (!o) return new Rgb;
2794
+ o = o.rgb();
2795
+ return new Rgb(o.r, o.g, o.b, o.opacity);
2796
+ }
2797
+
2798
+ function rgb(r, g, b, opacity) {
2799
+ return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
2800
+ }
2801
+
2802
+ function Rgb(r, g, b, opacity) {
2803
+ this.r = +r;
2804
+ this.g = +g;
2805
+ this.b = +b;
2806
+ this.opacity = +opacity;
2807
+ }
2808
+
2809
+ define(Rgb, rgb, extend(Color, {
2810
+ brighter(k) {
2811
+ k = k == null ? brighter : Math.pow(brighter, k);
2812
+ return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2813
+ },
2814
+ darker(k) {
2815
+ k = k == null ? darker : Math.pow(darker, k);
2816
+ return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2817
+ },
2818
+ rgb() {
2819
+ return this;
2820
+ },
2821
+ clamp() {
2822
+ return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
2823
+ },
2824
+ displayable() {
2825
+ return (-0.5 <= this.r && this.r < 255.5)
2826
+ && (-0.5 <= this.g && this.g < 255.5)
2827
+ && (-0.5 <= this.b && this.b < 255.5)
2828
+ && (0 <= this.opacity && this.opacity <= 1);
2829
+ },
2830
+ hex: rgb_formatHex, // Deprecated! Use color.formatHex.
2831
+ formatHex: rgb_formatHex,
2832
+ formatHex8: rgb_formatHex8,
2833
+ formatRgb: rgb_formatRgb,
2834
+ toString: rgb_formatRgb
2835
+ }));
2836
+
2837
+ function rgb_formatHex() {
2838
+ return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}`;
2839
+ }
2840
+
2841
+ function rgb_formatHex8() {
2842
+ return `#${hex(this.r)}${hex(this.g)}${hex(this.b)}${hex((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
2843
+ }
2844
+
2845
+ function rgb_formatRgb() {
2846
+ const a = clampa(this.opacity);
2847
+ return `${a === 1 ? "rgb(" : "rgba("}${clampi(this.r)}, ${clampi(this.g)}, ${clampi(this.b)}${a === 1 ? ")" : `, ${a})`}`;
2848
+ }
2849
+
2850
+ function clampa(opacity) {
2851
+ return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
2852
+ }
2853
+
2854
+ function clampi(value) {
2855
+ return Math.max(0, Math.min(255, Math.round(value) || 0));
2856
+ }
2857
+
2858
+ function hex(value) {
2859
+ value = clampi(value);
2860
+ return (value < 16 ? "0" : "") + value.toString(16);
2861
+ }
2862
+
2863
+ function hsla(h, s, l, a) {
2864
+ if (a <= 0) h = s = l = NaN;
2865
+ else if (l <= 0 || l >= 1) h = s = NaN;
2866
+ else if (s <= 0) h = NaN;
2867
+ return new Hsl(h, s, l, a);
2868
+ }
2869
+
2870
+ function hslConvert(o) {
2871
+ if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
2872
+ if (!(o instanceof Color)) o = color(o);
2873
+ if (!o) return new Hsl;
2874
+ if (o instanceof Hsl) return o;
2875
+ o = o.rgb();
2876
+ var r = o.r / 255,
2877
+ g = o.g / 255,
2878
+ b = o.b / 255,
2879
+ min = Math.min(r, g, b),
2880
+ max = Math.max(r, g, b),
2881
+ h = NaN,
2882
+ s = max - min,
2883
+ l = (max + min) / 2;
2884
+ if (s) {
2885
+ if (r === max) h = (g - b) / s + (g < b) * 6;
2886
+ else if (g === max) h = (b - r) / s + 2;
2887
+ else h = (r - g) / s + 4;
2888
+ s /= l < 0.5 ? max + min : 2 - max - min;
2889
+ h *= 60;
2890
+ } else {
2891
+ s = l > 0 && l < 1 ? 0 : h;
2892
+ }
2893
+ return new Hsl(h, s, l, o.opacity);
2894
+ }
2895
+
2896
+ function hsl(h, s, l, opacity) {
2897
+ return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
2898
+ }
2899
+
2900
+ function Hsl(h, s, l, opacity) {
2901
+ this.h = +h;
2902
+ this.s = +s;
2903
+ this.l = +l;
2904
+ this.opacity = +opacity;
2905
+ }
2906
+
2907
+ define(Hsl, hsl, extend(Color, {
2908
+ brighter(k) {
2909
+ k = k == null ? brighter : Math.pow(brighter, k);
2910
+ return new Hsl(this.h, this.s, this.l * k, this.opacity);
2911
+ },
2912
+ darker(k) {
2913
+ k = k == null ? darker : Math.pow(darker, k);
2914
+ return new Hsl(this.h, this.s, this.l * k, this.opacity);
2915
+ },
2916
+ rgb() {
2917
+ var h = this.h % 360 + (this.h < 0) * 360,
2918
+ s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
2919
+ l = this.l,
2920
+ m2 = l + (l < 0.5 ? l : 1 - l) * s,
2921
+ m1 = 2 * l - m2;
2922
+ return new Rgb(
2923
+ hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2),
2924
+ hsl2rgb(h, m1, m2),
2925
+ hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2),
2926
+ this.opacity
2927
+ );
2928
+ },
2929
+ clamp() {
2930
+ return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
2931
+ },
2932
+ displayable() {
2933
+ return (0 <= this.s && this.s <= 1 || isNaN(this.s))
2934
+ && (0 <= this.l && this.l <= 1)
2935
+ && (0 <= this.opacity && this.opacity <= 1);
2936
+ },
2937
+ formatHsl() {
2938
+ const a = clampa(this.opacity);
2939
+ return `${a === 1 ? "hsl(" : "hsla("}${clamph(this.h)}, ${clampt(this.s) * 100}%, ${clampt(this.l) * 100}%${a === 1 ? ")" : `, ${a})`}`;
2940
+ }
2941
+ }));
2942
+
2943
+ function clamph(value) {
2944
+ value = (value || 0) % 360;
2945
+ return value < 0 ? value + 360 : value;
2946
+ }
2947
+
2948
+ function clampt(value) {
2949
+ return Math.max(0, Math.min(1, value || 0));
2950
+ }
2951
+
2952
+ /* From FvD 13.37, CSS Color Module Level 3 */
2953
+ function hsl2rgb(h, m1, m2) {
2954
+ return (h < 60 ? m1 + (m2 - m1) * h / 60
2955
+ : h < 180 ? m2
2956
+ : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60
2957
+ : m1) * 255;
2958
+ }
2959
+
2495
2960
  function memoize(func, resolver) {
2496
2961
  if (typeof func !== 'function' || resolver != null && typeof resolver !== 'function') {
2497
2962
  throw new TypeError('Expected a function');
@@ -2510,9 +2975,16 @@ function memoize(func, resolver) {
2510
2975
  return result;
2511
2976
  };
2512
2977
  _memoized.cache = new (memoize.Cache || Map)();
2978
+ memoize.cacheList.push(_memoized.cache);
2513
2979
  return _memoized;
2514
2980
  }
2515
2981
  memoize.Cache = Map;
2982
+ memoize.cacheList = [];
2983
+ memoize.clearCache = function () {
2984
+ memoize.cacheList.forEach(function (cache) {
2985
+ return cache.clear();
2986
+ });
2987
+ };
2516
2988
 
2517
2989
  // These units are iterated through, so be careful when adding or changing the
2518
2990
  // order.
@@ -2520,30 +2992,88 @@ var UnitType = /*#__PURE__*/function (UnitType) {
2520
2992
  UnitType[UnitType["kUnknown"] = 0] = "kUnknown";
2521
2993
  UnitType[UnitType["kNumber"] = 1] = "kNumber";
2522
2994
  UnitType[UnitType["kPercentage"] = 2] = "kPercentage";
2995
+ // Length units
2523
2996
  UnitType[UnitType["kEms"] = 3] = "kEms";
2997
+ // kExs,
2524
2998
  UnitType[UnitType["kPixels"] = 4] = "kPixels";
2999
+ // kCentimeters,
3000
+ // kMillimeters,
3001
+ // kInches,
3002
+ // kPoints,
3003
+ // kPicas,
3004
+ // kQuarterMillimeters,
3005
+ // https://drafts.csswg.org/css-values-4/#viewport-relative-lengths
3006
+ //
3007
+ // See also IsViewportPercentageLength.
3008
+ // kViewportWidth,
3009
+ // kViewportHeight,
3010
+ // kViewportInlineSize,
3011
+ // kViewportBlockSize,
3012
+ // kViewportMin,
3013
+ // kViewportMax,
3014
+ // kSmallViewportWidth,
3015
+ // kSmallViewportHeight,
3016
+ // kSmallViewportInlineSize,
3017
+ // kSmallViewportBlockSize,
3018
+ // kSmallViewportMin,
3019
+ // kSmallViewportMax,
3020
+ // kLargeViewportWidth,
3021
+ // kLargeViewportHeight,
3022
+ // kLargeViewportInlineSize,
3023
+ // kLargeViewportBlockSize,
3024
+ // kLargeViewportMin,
3025
+ // kLargeViewportMax,
3026
+ // kDynamicViewportWidth,
3027
+ // kDynamicViewportHeight,
3028
+ // kDynamicViewportInlineSize,
3029
+ // kDynamicViewportBlockSize,
3030
+ // kDynamicViewportMin,
3031
+ // kDynamicViewportMax,
3032
+ // https://drafts.csswg.org/css-contain-3/#container-lengths
3033
+ //
3034
+ // See also IsContainerPercentageLength.
3035
+ // kContainerWidth,
3036
+ // kContainerHeight,
3037
+ // kContainerInlineSize,
3038
+ // kContainerBlockSize,
3039
+ // kContainerMin,
3040
+ // kContainerMax,
2525
3041
  UnitType[UnitType["kRems"] = 5] = "kRems";
3042
+ // kChs,
3043
+ // kUserUnits, // The SVG term for unitless lengths
3044
+ // Angle units
2526
3045
  UnitType[UnitType["kDegrees"] = 6] = "kDegrees";
2527
3046
  UnitType[UnitType["kRadians"] = 7] = "kRadians";
2528
3047
  UnitType[UnitType["kGradians"] = 8] = "kGradians";
2529
3048
  UnitType[UnitType["kTurns"] = 9] = "kTurns";
3049
+ // Time units
2530
3050
  UnitType[UnitType["kMilliseconds"] = 10] = "kMilliseconds";
2531
3051
  UnitType[UnitType["kSeconds"] = 11] = "kSeconds";
2532
- UnitType[UnitType["kInteger"] = 12] = "kInteger";
3052
+ // kHertz,
3053
+ // kKilohertz,
3054
+ // Resolution
3055
+ // kDotsPerPixel,
3056
+ // kDotsPerInch,
3057
+ // kDotsPerCentimeter,
3058
+ // Other units
3059
+ // kFraction,
3060
+ UnitType[UnitType["kInteger"] = 12] = "kInteger"; // This value is used to handle quirky margins in reflow roots (body, td,
3061
+ // and th) like WinIE. The basic idea is that a stylesheet can use the value
3062
+ // __qem (for quirky em) instead of em. When the quirky value is used, if
3063
+ // you're in quirks mode, the margin will collapse away inside a table cell.
3064
+ // This quirk is specified in the HTML spec but our impl is different.
3065
+ // TODO: Remove this. crbug.com/443952
3066
+ // kQuirkyEms,
2533
3067
  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,
3068
+ }({});
2541
3069
  var UnitCategory = /*#__PURE__*/function (UnitCategory) {
2542
3070
  UnitCategory[UnitCategory["kUNumber"] = 0] = "kUNumber";
2543
3071
  UnitCategory[UnitCategory["kUPercent"] = 1] = "kUPercent";
2544
3072
  UnitCategory[UnitCategory["kULength"] = 2] = "kULength";
2545
3073
  UnitCategory[UnitCategory["kUAngle"] = 3] = "kUAngle";
2546
3074
  UnitCategory[UnitCategory["kUTime"] = 4] = "kUTime";
3075
+ // kUFrequency,
3076
+ // kUResolution,
2547
3077
  UnitCategory[UnitCategory["kUOther"] = 5] = "kUOther";
2548
3078
  return UnitCategory;
2549
3079
  }({});
@@ -2780,6 +3310,7 @@ var CSSStyleValueType = /*#__PURE__*/function (CSSStyleValueType) {
2780
3310
  CSSStyleValueType[CSSStyleValueType["kUnknownType"] = 0] = "kUnknownType";
2781
3311
  CSSStyleValueType[CSSStyleValueType["kUnparsedType"] = 1] = "kUnparsedType";
2782
3312
  CSSStyleValueType[CSSStyleValueType["kKeywordType"] = 2] = "kKeywordType";
3313
+ // Start of CSSNumericValue subclasses
2783
3314
  CSSStyleValueType[CSSStyleValueType["kUnitType"] = 3] = "kUnitType";
2784
3315
  CSSStyleValueType[CSSStyleValueType["kSumType"] = 4] = "kSumType";
2785
3316
  CSSStyleValueType[CSSStyleValueType["kProductType"] = 5] = "kProductType";
@@ -2788,6 +3319,7 @@ var CSSStyleValueType = /*#__PURE__*/function (CSSStyleValueType) {
2788
3319
  CSSStyleValueType[CSSStyleValueType["kMinType"] = 8] = "kMinType";
2789
3320
  CSSStyleValueType[CSSStyleValueType["kMaxType"] = 9] = "kMaxType";
2790
3321
  CSSStyleValueType[CSSStyleValueType["kClampType"] = 10] = "kClampType";
3322
+ // End of CSSNumericValue subclasses
2791
3323
  CSSStyleValueType[CSSStyleValueType["kTransformType"] = 11] = "kTransformType";
2792
3324
  CSSStyleValueType[CSSStyleValueType["kPositionType"] = 12] = "kPositionType";
2793
3325
  CSSStyleValueType[CSSStyleValueType["kURLImageType"] = 13] = "kURLImageType";
@@ -4035,13 +4567,13 @@ var parseColor = memoize(function (colorStr) {
4035
4567
  }
4036
4568
 
4037
4569
  // constants
4038
- var color = d3.color(colorStr);
4570
+ var color$1 = color(colorStr);
4039
4571
  var rgba = [0, 0, 0, 0];
4040
- if (color !== null) {
4041
- rgba[0] = color.r || 0;
4042
- rgba[1] = color.g || 0;
4043
- rgba[2] = color.b || 0;
4044
- rgba[3] = color.opacity;
4572
+ if (color$1 !== null) {
4573
+ rgba[0] = color$1.r || 0;
4574
+ rgba[1] = color$1.g || 0;
4575
+ rgba[2] = color$1.b || 0;
4576
+ rgba[3] = color$1.opacity;
4045
4577
  }
4046
4578
 
4047
4579
  // return new CSSRGB(...rgba);
@@ -9658,8 +10190,7 @@ var EventService = /*#__PURE__*/function () {
9658
10190
  }, {
9659
10191
  key: "notifyTarget",
9660
10192
  value: function notifyTarget(e, type) {
9661
- var _type;
9662
- type = (_type = type) !== null && _type !== void 0 ? _type : e.type;
10193
+ type = type !== null && type !== void 0 ? type : e.type;
9663
10194
  var key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? "".concat(type, "capture") : type;
9664
10195
  this.notifyListeners(e, key);
9665
10196
  if (e.eventPhase === e.AT_TARGET) {
@@ -10203,11 +10734,30 @@ var DefaultSceneGraphSelector = /*#__PURE__*/function () {
10203
10734
  * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
10204
10735
  */
10205
10736
  var ElementEvent = /*#__PURE__*/function (ElementEvent) {
10737
+ // --- @see https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent
10738
+ /**
10739
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMAttrModified
10740
+ */
10206
10741
  ElementEvent["ATTR_MODIFIED"] = "DOMAttrModified";
10742
+ /**
10743
+ * it has been inserted
10744
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeInserted
10745
+ */
10207
10746
  ElementEvent["INSERTED"] = "DOMNodeInserted";
10747
+ /**
10748
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnodeinsertedintodocument
10749
+ */
10208
10750
  ElementEvent["MOUNTED"] = "DOMNodeInsertedIntoDocument";
10751
+ /**
10752
+ * it is being removed
10753
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#event-type-DOMNodeRemoved
10754
+ */
10209
10755
  ElementEvent["REMOVED"] = "removed";
10756
+ /**
10757
+ * @see https://www.w3.org/TR/DOM-Level-3-Events/#domnoderemovedfromdocument
10758
+ */
10210
10759
  ElementEvent["UNMOUNTED"] = "DOMNodeRemovedFromDocument";
10760
+ // ---
10211
10761
  ElementEvent["REPARENT"] = "reparent";
10212
10762
  ElementEvent["DESTROY"] = "destroy";
10213
10763
  ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
@@ -11576,7 +12126,7 @@ var TextService = /*#__PURE__*/function () {
11576
12126
  }
11577
12127
  if (!this.canBreakInLastChar(_char2)) {
11578
12128
  lines = this.trimToBreakable(lines);
11579
- currentLineWidth = this.sumTextWidthByCache(lines[currentLineIndex] || '', cache);
12129
+ currentLineWidth = this.sumTextWidthByCache(lines[currentLineIndex] || '', calcWidth);
11580
12130
  }
11581
12131
  if (this.shouldBreakByKinsokuShorui(_char2, nextChar)) {
11582
12132
  lines = this.trimByKinsokuShorui(lines);
@@ -11627,10 +12177,9 @@ var TextService = /*#__PURE__*/function () {
11627
12177
  }
11628
12178
  }, {
11629
12179
  key: "sumTextWidthByCache",
11630
- value: function sumTextWidthByCache(text, cache) {
12180
+ value: function sumTextWidthByCache(text, calcWidthWithCache) {
11631
12181
  return text.split('').reduce(function (sum, c) {
11632
- if (!cache[c]) throw Error('cannot count the word without cache');
11633
- return sum + cache[c];
12182
+ return sum + calcWidthWithCache(c);
11634
12183
  }, 0);
11635
12184
  }
11636
12185
  }, {
@@ -15568,6 +16117,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
15568
16117
  value: function destroy() {
15569
16118
  var cleanUp = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
15570
16119
  var skipTriggerEvent = arguments.length > 1 ? arguments[1] : undefined;
16120
+ memoize.clearCache();
15571
16121
  if (!skipTriggerEvent) {
15572
16122
  this.dispatchEvent(new CustomEvent(CanvasEvent.BEFORE_DESTROY));
15573
16123
  }