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