@antv/g-canvas 1.9.3 → 1.9.5

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.umd.js CHANGED
@@ -424,17 +424,34 @@
424
424
 
425
425
  function __param(paramIndex, decorator) {
426
426
  return function (target, key) { decorator(target, key, paramIndex); }
427
- }
428
-
429
- /** @deprecated */
430
- function __spreadArrays() {
431
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
432
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
433
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
434
- r[k] = a[j];
435
- return r;
436
427
  }
437
428
 
429
+ var toString = {}.toString;
430
+ var isType = function (value, type) { return toString.call(value) === '[object ' + type + ']'; };
431
+
432
+ // isFinite,
433
+ var isNil = function (value) {
434
+ /**
435
+ * isNil(null) => true
436
+ * isNil() => true
437
+ */
438
+ return value === null || value === undefined;
439
+ };
440
+
441
+ var isString = (function (str) {
442
+ return isType(str, 'String');
443
+ });
444
+
445
+ var clamp = function (a, min, max) {
446
+ if (a < min) {
447
+ return min;
448
+ }
449
+ else if (a > max) {
450
+ return max;
451
+ }
452
+ return a;
453
+ };
454
+
438
455
  function _inheritsLoose$1(subClass, superClass) {
439
456
  subClass.prototype = Object.create(superClass.prototype);
440
457
  subClass.prototype.constructor = subClass;
@@ -691,158 +708,6 @@
691
708
  context.lineTo(x2 + endOffsetX, y2 + endOffsetY);
692
709
  }
693
710
 
694
- var toString = {}.toString;
695
-
696
- var isType = function isType(value, type) {
697
- return toString.call(value) === '[object ' + type + ']';
698
- };
699
- /**
700
- * 是否为函数
701
- * @param {*} fn 对象
702
- * @return {Boolean} 是否函数
703
- */
704
-
705
-
706
- var isFunction = function isFunction(value) {
707
- return isType(value, 'Function');
708
- };
709
-
710
- var isArray = function isArray(value) {
711
- return Array.isArray ? Array.isArray(value) : isType(value, 'Array');
712
- };
713
-
714
- var isObject = function isObject(value) {
715
- /**
716
- * isObject({}) => true
717
- * isObject([1, 2, 3]) => true
718
- * isObject(Function) => true
719
- * isObject(null) => false
720
- */
721
- var type = typeof value;
722
- return value !== null && type === 'object' || type === 'function';
723
- };
724
-
725
- function each(elements, func) {
726
- if (!elements) {
727
- return;
728
- }
729
-
730
- var rst;
731
-
732
- if (isArray(elements)) {
733
- for (var i = 0, len = elements.length; i < len; i++) {
734
- rst = func(elements[i], i);
735
-
736
- if (rst === false) {
737
- break;
738
- }
739
- }
740
- } else if (isObject(elements)) {
741
- for (var k in elements) {
742
- if (elements.hasOwnProperty(k)) {
743
- rst = func(elements[k], k);
744
-
745
- if (rst === false) {
746
- break;
747
- }
748
- }
749
- }
750
- }
751
- }
752
-
753
- var isString = function isString(str) {
754
- return isType(str, 'String');
755
- };
756
-
757
- var clamp = function clamp(a, min, max) {
758
- if (a < min) {
759
- return min;
760
- } else if (a > max) {
761
- return max;
762
- }
763
-
764
- return a;
765
- }; // @ts-ignore
766
-
767
-
768
- var values = Object.values ? function (obj) {
769
- return Object.values(obj);
770
- } : function (obj) {
771
- var result = [];
772
- each(obj, function (value, key) {
773
- if (!(isFunction(obj) && key === 'prototype')) {
774
- result.push(value);
775
- }
776
- });
777
- return result;
778
- };
779
- /**
780
- * _.memoize(calColor);
781
- * _.memoize(calColor, (...args) => args[0]);
782
- * @param f
783
- * @param resolver
784
- */
785
-
786
- var memoize = function memoize(f, resolver) {
787
- if (!isFunction(f)) {
788
- throw new TypeError('Expected a function');
789
- }
790
-
791
- var memoized = function memoized() {
792
- var args = [];
793
-
794
- for (var _i = 0; _i < arguments.length; _i++) {
795
- args[_i] = arguments[_i];
796
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
797
-
798
-
799
- var key = resolver ? resolver.apply(this, args) : args[0];
800
- var cache = memoized.cache;
801
-
802
- if (cache.has(key)) {
803
- return cache.get(key);
804
- }
805
-
806
- var result = f.apply(this, args); // 缓存起来
807
-
808
- cache.set(key, result);
809
- return result;
810
- };
811
-
812
- memoized.cache = new Map();
813
- return memoized;
814
- };
815
-
816
- var ctx;
817
- /**
818
- * 计算文本的宽度
819
- */
820
-
821
- memoize(function (text, font) {
822
- if (font === void 0) {
823
- font = {};
824
- }
825
-
826
- var fontSize = font.fontSize,
827
- fontFamily = font.fontFamily,
828
- fontWeight = font.fontWeight,
829
- fontStyle = font.fontStyle,
830
- fontVariant = font.fontVariant;
831
-
832
- if (!ctx) {
833
- ctx = document.createElement('canvas').getContext('2d');
834
- }
835
-
836
- ctx.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
837
- return ctx.measureText(isString(text) ? text : '').width;
838
- }, function (text, font) {
839
- if (font === void 0) {
840
- font = {};
841
- }
842
-
843
- return __spreadArrays([text], values(font)).join('');
844
- });
845
-
846
711
  function generatePath$6(context, parsedStyle) {
847
712
  var radius = parsedStyle.radius,
848
713
  width = parsedStyle.width,
@@ -998,16 +863,6 @@
998
863
  Plugin: Plugin
999
864
  });
1000
865
 
1001
- var clamp$1 = function (a, min, max) {
1002
- if (a < min) {
1003
- return min;
1004
- }
1005
- else if (a > max) {
1006
- return max;
1007
- }
1008
- return a;
1009
- };
1010
-
1011
866
  function _regeneratorRuntime$1() {
1012
867
  /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1013
868
  _regeneratorRuntime$1 = function _regeneratorRuntime() {
@@ -1864,14 +1719,12 @@
1864
1719
  */
1865
1720
 
1866
1721
  var CanvasPickerPlugin = CanvasPickerPlugin_1 = (_class = /*#__PURE__*/function () {
1867
- function CanvasPickerPlugin(displayObjectPool, renderingContext, canvasConfig, offscreenCanvas, rBush, pathGeneratorFactory, pointInPathPickerFactory) {
1722
+ function CanvasPickerPlugin(renderingContext, canvasConfig, offscreenCanvas, pathGeneratorFactory, pointInPathPickerFactory) {
1868
1723
  var _this = this;
1869
1724
 
1870
- this.displayObjectPool = void 0;
1871
1725
  this.renderingContext = void 0;
1872
1726
  this.canvasConfig = void 0;
1873
1727
  this.offscreenCanvas = void 0;
1874
- this.rBush = void 0;
1875
1728
  this.pathGeneratorFactory = void 0;
1876
1729
  this.pointInPathPickerFactory = void 0;
1877
1730
  this.pathGeneratorFactoryCache = {};
@@ -1919,11 +1772,9 @@
1919
1772
  return context.isPointInPath(position.x, position.y);
1920
1773
  };
1921
1774
 
1922
- this.displayObjectPool = displayObjectPool;
1923
1775
  this.renderingContext = renderingContext;
1924
1776
  this.canvasConfig = canvasConfig;
1925
1777
  this.offscreenCanvas = offscreenCanvas;
1926
- this.rBush = rBush;
1927
1778
  this.pathGeneratorFactory = pathGeneratorFactory;
1928
1779
  this.pointInPathPickerFactory = pointInPathPickerFactory;
1929
1780
  }
@@ -1937,127 +1788,13 @@
1937
1788
  var document = (_this$renderingContex = this.renderingContext.root) === null || _this$renderingContex === void 0 ? void 0 : _this$renderingContex.ownerDocument;
1938
1789
  renderingService.hooks.pick.tapPromise(CanvasPickerPlugin_1.tag, /*#__PURE__*/function () {
1939
1790
  var _ref = _asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee(result) {
1940
- var topmost, _result$position, x, y, position, hitTestList, pickedDisplayObjects, _iterator, _step, displayObject, worldTransform, isHitOriginShape, clipped, clipPath, isHitClipPath;
1941
-
1942
1791
  return _regeneratorRuntime$1().wrap(function _callee$(_context) {
1943
1792
  while (1) {
1944
1793
  switch (_context.prev = _context.next) {
1945
1794
  case 0:
1946
- topmost = result.topmost, _result$position = result.position, x = _result$position.x, y = _result$position.y; // position in world space
1947
-
1948
- position = set(tmpVec3a, x, y, 0); // query by AABB first with spatial index(r-tree)
1949
-
1950
- hitTestList = document.elementsFromBBox(position[0], position[1], position[0], position[1]); // const rBushNodes = this.rBush.search({
1951
- // minX: position[0],
1952
- // minY: position[1],
1953
- // maxX: position[0],
1954
- // maxY: position[1],
1955
- // });
1956
- // const queriedIds = rBushNodes.map((node) => node.id);
1957
- // const hitTestList: DisplayObject[] = [];
1958
- // rBushNodes.forEach(({ id }) => {
1959
- // const displayObject = this.displayObjectPool.getByEntity(id);
1960
- // const { pointerEvents } = displayObject.parsedStyle as ParsedBaseStyleProps;
1961
- // // account for `visibility`
1962
- // // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
1963
- // const isVisibilityAffected = [
1964
- // 'auto',
1965
- // 'visiblepainted',
1966
- // 'visiblefill',
1967
- // 'visiblestroke',
1968
- // 'visible',
1969
- // ].includes(pointerEvents);
1970
- // if (
1971
- // (!isVisibilityAffected || (isVisibilityAffected && displayObject.isVisible())) &&
1972
- // !displayObject.isCulled() &&
1973
- // displayObject.isInteractive()
1974
- // ) {
1975
- // // parent is not included, eg. parent is clipped
1976
- // if (
1977
- // displayObject.parentNode &&
1978
- // queriedIds.indexOf((displayObject.parentNode as Element).entity) === -1
1979
- // ) {
1980
- // return;
1981
- // }
1982
- // hitTestList.push(displayObject);
1983
- // }
1984
- // });
1985
- // // find group with max z-index
1986
- // hitTestList.sort((a, b) => b.sortable.renderOrder - a.sortable.renderOrder);
1987
- // test with clip path & origin shape
1988
- // @see https://github.com/antvis/g/issues/1064
1989
-
1990
- pickedDisplayObjects = [];
1991
- _iterator = _createForOfIteratorHelperLoose(hitTestList);
1992
-
1993
- case 5:
1994
- if ((_step = _iterator()).done) {
1995
- _context.next = 32;
1996
- break;
1997
- }
1998
-
1999
- displayObject = _step.value;
2000
- worldTransform = displayObject.getWorldTransform();
2001
- isHitOriginShape = _this2.isHit(displayObject, position, worldTransform);
2002
-
2003
- if (!isHitOriginShape) {
2004
- _context.next = 30;
2005
- break;
2006
- } // should look up in the ancestor node
2007
-
2008
-
2009
- clipped = gLite.findClosestClipPathTarget(displayObject);
2010
-
2011
- if (!clipped) {
2012
- _context.next = 24;
2013
- break;
2014
- }
2015
-
2016
- clipPath = clipped.style.clipPath;
2017
- worldTransform = multiply(tmpMat4, clipped === displayObject ? worldTransform : clipped.getWorldTransform(), clipPath.getLocalTransform());
2018
- isHitClipPath = _this2.isHit(clipPath, position, worldTransform);
2019
-
2020
- if (!isHitClipPath) {
2021
- _context.next = 22;
2022
- break;
2023
- }
2024
-
2025
- if (!topmost) {
2026
- _context.next = 21;
2027
- break;
2028
- }
2029
-
2030
- result.picked = [displayObject];
2031
- return _context.abrupt("return", result);
2032
-
2033
- case 21:
2034
- pickedDisplayObjects.push(displayObject);
1795
+ return _context.abrupt("return", _this2.pick(document, result));
2035
1796
 
2036
- case 22:
2037
- _context.next = 30;
2038
- break;
2039
-
2040
- case 24:
2041
- if (!topmost) {
2042
- _context.next = 29;
2043
- break;
2044
- }
2045
-
2046
- result.picked = [displayObject];
2047
- return _context.abrupt("return", result);
2048
-
2049
- case 29:
2050
- pickedDisplayObjects.push(displayObject);
2051
-
2052
- case 30:
2053
- _context.next = 5;
2054
- break;
2055
-
2056
- case 32:
2057
- result.picked = pickedDisplayObjects;
2058
- return _context.abrupt("return", result);
2059
-
2060
- case 34:
1797
+ case 1:
2061
1798
  case "end":
2062
1799
  return _context.stop();
2063
1800
  }
@@ -2069,27 +1806,103 @@
2069
1806
  return _ref.apply(this, arguments);
2070
1807
  };
2071
1808
  }());
1809
+ renderingService.hooks.pickSync.tap(CanvasPickerPlugin_1.tag, function (result) {
1810
+ return _this2.pick(document, result);
1811
+ });
2072
1812
  };
2073
1813
 
2074
- _proto.findClosestClipPath = function findClosestClipPath(object) {
2075
- var el = object;
2076
-
2077
- do {
2078
- var _el$style;
2079
-
2080
- var clipPath = (_el$style = el.style) === null || _el$style === void 0 ? void 0 : _el$style.clipPath;
2081
- if (clipPath) return el;
2082
- el = el.parentElement;
2083
- } while (el !== null);
1814
+ _proto.pick = function pick(document, result) {
1815
+ var topmost = result.topmost,
1816
+ _result$position = result.position,
1817
+ x = _result$position.x,
1818
+ y = _result$position.y; // position in world space
1819
+
1820
+ var position = set(tmpVec3a, x, y, 0); // query by AABB first with spatial index(r-tree)
1821
+
1822
+ var hitTestList = document.elementsFromBBox(position[0], position[1], position[0], position[1]); // const rBushNodes = this.rBush.search({
1823
+ // minX: position[0],
1824
+ // minY: position[1],
1825
+ // maxX: position[0],
1826
+ // maxY: position[1],
1827
+ // });
1828
+ // const queriedIds = rBushNodes.map((node) => node.id);
1829
+ // const hitTestList: DisplayObject[] = [];
1830
+ // rBushNodes.forEach(({ id }) => {
1831
+ // const displayObject = this.displayObjectPool.getByEntity(id);
1832
+ // const { pointerEvents } = displayObject.parsedStyle as ParsedBaseStyleProps;
1833
+ // // account for `visibility`
1834
+ // // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
1835
+ // const isVisibilityAffected = [
1836
+ // 'auto',
1837
+ // 'visiblepainted',
1838
+ // 'visiblefill',
1839
+ // 'visiblestroke',
1840
+ // 'visible',
1841
+ // ].includes(pointerEvents);
1842
+ // if (
1843
+ // (!isVisibilityAffected || (isVisibilityAffected && displayObject.isVisible())) &&
1844
+ // !displayObject.isCulled() &&
1845
+ // displayObject.isInteractive()
1846
+ // ) {
1847
+ // // parent is not included, eg. parent is clipped
1848
+ // if (
1849
+ // displayObject.parentNode &&
1850
+ // queriedIds.indexOf((displayObject.parentNode as Element).entity) === -1
1851
+ // ) {
1852
+ // return;
1853
+ // }
1854
+ // hitTestList.push(displayObject);
1855
+ // }
1856
+ // });
1857
+ // // find group with max z-index
1858
+ // hitTestList.sort((a, b) => b.sortable.renderOrder - a.sortable.renderOrder);
1859
+ // test with clip path & origin shape
1860
+ // @see https://github.com/antvis/g/issues/1064
1861
+
1862
+ var pickedDisplayObjects = [];
1863
+
1864
+ for (var _iterator = _createForOfIteratorHelperLoose(hitTestList), _step; !(_step = _iterator()).done;) {
1865
+ var displayObject = _step.value;
1866
+ var worldTransform = displayObject.getWorldTransform();
1867
+ var isHitOriginShape = this.isHit(displayObject, position, worldTransform);
1868
+
1869
+ if (isHitOriginShape) {
1870
+ // should look up in the ancestor node
1871
+ var clipped = gLite.findClosestClipPathTarget(displayObject);
1872
+
1873
+ if (clipped) {
1874
+ var clipPath = clipped.style.clipPath;
1875
+ worldTransform = multiply(tmpMat4, clipped === displayObject ? worldTransform : clipped.getWorldTransform(), clipPath.getLocalTransform());
1876
+ var isHitClipPath = this.isHit(clipPath, position, worldTransform);
1877
+
1878
+ if (isHitClipPath) {
1879
+ if (topmost) {
1880
+ result.picked = [displayObject];
1881
+ return result;
1882
+ } else {
1883
+ pickedDisplayObjects.push(displayObject);
1884
+ }
1885
+ }
1886
+ } else {
1887
+ if (topmost) {
1888
+ result.picked = [displayObject];
1889
+ return result;
1890
+ } else {
1891
+ pickedDisplayObjects.push(displayObject);
1892
+ }
1893
+ }
1894
+ }
1895
+ }
2084
1896
 
2085
- return null;
1897
+ result.picked = pickedDisplayObjects;
1898
+ return result;
2086
1899
  };
2087
1900
 
2088
1901
  return CanvasPickerPlugin;
2089
1902
  }(), _class.tag = 'CanvasPicker', _class);
2090
1903
  CanvasPickerPlugin = CanvasPickerPlugin_1 = __decorate([gLite.singleton({
2091
1904
  contrib: gLite.RenderingPluginContribution
2092
- }), __param(0, gLite.inject(gLite.DisplayObjectPool)), __param(1, gLite.inject(gLite.RenderingContext)), __param(2, gLite.inject(gLite.CanvasConfig)), __param(3, gLite.inject(gLite.OffscreenCanvasCreator)), __param(4, gLite.inject(gLite.RBushRoot)), __param(5, gLite.inject(PathGeneratorFactory)), __param(6, gLite.inject(PointInPathPickerFactory))], CanvasPickerPlugin);
1905
+ }), __param(0, gLite.inject(gLite.RenderingContext)), __param(1, gLite.inject(gLite.CanvasConfig)), __param(2, gLite.inject(gLite.OffscreenCanvasCreator)), __param(3, gLite.inject(PathGeneratorFactory)), __param(4, gLite.inject(PointInPathPickerFactory))], CanvasPickerPlugin);
2093
1906
  /**
2094
1907
  * 两点之间的距离
2095
1908
  * @param {number} x1 起始点 x
@@ -2898,7 +2711,7 @@
2898
2711
 
2899
2712
  if (hasStroke || isClipPath) {
2900
2713
  isHit = inRectWithRadius(0, 0, width, height, radius.map(function (r) {
2901
- return clamp$1(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
2714
+ return clamp(r, 0, Math.min(Math.abs(width) / 2, Math.abs(height) / 2));
2902
2715
  }), lineWidthForHitTesting, position.x, position.y);
2903
2716
  } // 仅填充时带有圆角的矩形直接通过图形拾取
2904
2717
  // 以后可以改成纯数学的近似拾取,将圆弧切割成多边形
@@ -3389,148 +3202,6 @@
3389
3202
  return _setPrototypeOf$3(o, p);
3390
3203
  }
3391
3204
 
3392
- var toString$1 = {}.toString;
3393
-
3394
- var isType$1 = function isType(value, type) {
3395
- return toString$1.call(value) === '[object ' + type + ']';
3396
- };
3397
- /**
3398
- * 是否为函数
3399
- * @param {*} fn 对象
3400
- * @return {Boolean} 是否函数
3401
- */
3402
-
3403
-
3404
- var isFunction$1 = function isFunction(value) {
3405
- return isType$1(value, 'Function');
3406
- };
3407
-
3408
- var isArray$1 = function isArray(value) {
3409
- return Array.isArray ? Array.isArray(value) : isType$1(value, 'Array');
3410
- };
3411
-
3412
- var isObject$1 = function isObject(value) {
3413
- /**
3414
- * isObject({}) => true
3415
- * isObject([1, 2, 3]) => true
3416
- * isObject(Function) => true
3417
- * isObject(null) => false
3418
- */
3419
- var type = typeof value;
3420
- return value !== null && type === 'object' || type === 'function';
3421
- };
3422
-
3423
- function each$1(elements, func) {
3424
- if (!elements) {
3425
- return;
3426
- }
3427
-
3428
- var rst;
3429
-
3430
- if (isArray$1(elements)) {
3431
- for (var i = 0, len = elements.length; i < len; i++) {
3432
- rst = func(elements[i], i);
3433
-
3434
- if (rst === false) {
3435
- break;
3436
- }
3437
- }
3438
- } else if (isObject$1(elements)) {
3439
- for (var k in elements) {
3440
- if (elements.hasOwnProperty(k)) {
3441
- rst = func(elements[k], k);
3442
-
3443
- if (rst === false) {
3444
- break;
3445
- }
3446
- }
3447
- }
3448
- }
3449
- }
3450
-
3451
- var isString$1 = function isString(str) {
3452
- return isType$1(str, 'String');
3453
- }; // @ts-ignore
3454
-
3455
-
3456
- var values$1 = Object.values ? function (obj) {
3457
- return Object.values(obj);
3458
- } : function (obj) {
3459
- var result = [];
3460
- each$1(obj, function (value, key) {
3461
- if (!(isFunction$1(obj) && key === 'prototype')) {
3462
- result.push(value);
3463
- }
3464
- });
3465
- return result;
3466
- };
3467
- /**
3468
- * _.memoize(calColor);
3469
- * _.memoize(calColor, (...args) => args[0]);
3470
- * @param f
3471
- * @param resolver
3472
- */
3473
-
3474
- var memoize$1 = function memoize(f, resolver) {
3475
- if (!isFunction$1(f)) {
3476
- throw new TypeError('Expected a function');
3477
- }
3478
-
3479
- var memoized = function memoized() {
3480
- var args = [];
3481
-
3482
- for (var _i = 0; _i < arguments.length; _i++) {
3483
- args[_i] = arguments[_i];
3484
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
3485
-
3486
-
3487
- var key = resolver ? resolver.apply(this, args) : args[0];
3488
- var cache = memoized.cache;
3489
-
3490
- if (cache.has(key)) {
3491
- return cache.get(key);
3492
- }
3493
-
3494
- var result = f.apply(this, args); // 缓存起来
3495
-
3496
- cache.set(key, result);
3497
- return result;
3498
- };
3499
-
3500
- memoized.cache = new Map();
3501
- return memoized;
3502
- };
3503
-
3504
- var ctx$1;
3505
- /**
3506
- * 计算文本的宽度
3507
- */
3508
-
3509
- memoize$1(function (text, font) {
3510
- if (font === void 0) {
3511
- font = {};
3512
- }
3513
-
3514
- var fontSize = font.fontSize,
3515
- fontFamily = font.fontFamily,
3516
- fontWeight = font.fontWeight,
3517
- fontStyle = font.fontStyle,
3518
- fontVariant = font.fontVariant;
3519
-
3520
- if (!ctx$1) {
3521
- ctx$1 = document.createElement('canvas').getContext('2d');
3522
- }
3523
-
3524
- ctx$1.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
3525
- return ctx$1.measureText(isString$1(text) ? text : '').width;
3526
- }, function (text, font) {
3527
- if (font === void 0) {
3528
- font = {};
3529
- }
3530
-
3531
- return __spreadArrays([text], values$1(font)).join('');
3532
- });
3533
-
3534
3205
  var ImagePool = /*#__PURE__*/function () {
3535
3206
  function ImagePool(canvasConfig) {
3536
3207
  this.canvasConfig = void 0;
@@ -3603,7 +3274,7 @@
3603
3274
  repetition = pattern.repetition;
3604
3275
  var src; // Image URL
3605
3276
 
3606
- if (isString$1(image)) {
3277
+ if (isString(image)) {
3607
3278
  src = this.getImageSync(image, callback);
3608
3279
  } else {
3609
3280
  src = image;
@@ -3687,7 +3358,7 @@
3687
3358
  var image = pattern.image,
3688
3359
  repetition = pattern.repetition; // only generate cache for Image
3689
3360
 
3690
- if (isString$1(image)) {
3361
+ if (isString(image)) {
3691
3362
  return "pattern-" + image + "-" + repetition;
3692
3363
  }
3693
3364
  };
@@ -3721,7 +3392,7 @@
3721
3392
  if (nodeName === gLite.Shape.IMAGE) {
3722
3393
  var img = attributes.img;
3723
3394
 
3724
- if (isString$1(img)) {
3395
+ if (isString(img)) {
3725
3396
  _this.imagePool.getImageSync(img, function () {
3726
3397
  // set dirty rectangle flag
3727
3398
  object.renderable.dirty = true;
@@ -3738,7 +3409,7 @@
3738
3409
 
3739
3410
  if (object.nodeName === gLite.Shape.IMAGE) {
3740
3411
  if (attrName === 'img') {
3741
- if (isString$1(newValue)) {
3412
+ if (isString(newValue)) {
3742
3413
  _this.imagePool.getOrCreateImage(newValue).then(function () {
3743
3414
  // set dirty rectangle flag
3744
3415
  object.renderable.dirty = true;
@@ -4233,162 +3904,12 @@
4233
3904
  };
4234
3905
  return _setPrototypeOf$4(o, p);
4235
3906
  }
4236
-
4237
- var toString$2 = {}.toString;
4238
-
4239
- var isType$2 = function isType(value, type) {
4240
- return toString$2.call(value) === '[object ' + type + ']';
4241
- };
4242
- /**
4243
- * 是否为函数
4244
- * @param {*} fn 对象
4245
- * @return {Boolean} 是否函数
4246
- */
4247
-
4248
-
4249
- var isFunction$2 = function isFunction(value) {
4250
- return isType$2(value, 'Function');
4251
- }; // isFinite,
4252
-
4253
-
4254
- var isNil = function isNil(value) {
4255
- /**
4256
- * isNil(null) => true
4257
- * isNil() => true
4258
- */
4259
- return value === null || value === undefined;
4260
- };
4261
-
4262
- var isArray$2 = function isArray(value) {
4263
- return Array.isArray ? Array.isArray(value) : isType$2(value, 'Array');
4264
- };
4265
-
4266
- var isObject$2 = function isObject(value) {
4267
- /**
4268
- * isObject({}) => true
4269
- * isObject([1, 2, 3]) => true
4270
- * isObject(Function) => true
4271
- * isObject(null) => false
4272
- */
4273
- var type = typeof value;
4274
- return value !== null && type === 'object' || type === 'function';
4275
- };
4276
-
4277
- function each$2(elements, func) {
4278
- if (!elements) {
4279
- return;
4280
- }
4281
-
4282
- var rst;
4283
-
4284
- if (isArray$2(elements)) {
4285
- for (var i = 0, len = elements.length; i < len; i++) {
4286
- rst = func(elements[i], i);
4287
-
4288
- if (rst === false) {
4289
- break;
4290
- }
4291
- }
4292
- } else if (isObject$2(elements)) {
4293
- for (var k in elements) {
4294
- if (elements.hasOwnProperty(k)) {
4295
- rst = func(elements[k], k);
4296
-
4297
- if (rst === false) {
4298
- break;
4299
- }
4300
- }
4301
- }
4302
- }
4303
- }
4304
-
4305
- var isString$2 = function isString(str) {
4306
- return isType$2(str, 'String');
4307
- }; // @ts-ignore
4308
-
4309
-
4310
- var values$2 = Object.values ? function (obj) {
4311
- return Object.values(obj);
4312
- } : function (obj) {
4313
- var result = [];
4314
- each$2(obj, function (value, key) {
4315
- if (!(isFunction$2(obj) && key === 'prototype')) {
4316
- result.push(value);
4317
- }
4318
- });
4319
- return result;
4320
- };
4321
- /**
4322
- * _.memoize(calColor);
4323
- * _.memoize(calColor, (...args) => args[0]);
4324
- * @param f
4325
- * @param resolver
4326
- */
4327
-
4328
- var memoize$2 = function memoize(f, resolver) {
4329
- if (!isFunction$2(f)) {
4330
- throw new TypeError('Expected a function');
4331
- }
4332
-
4333
- var memoized = function memoized() {
4334
- var args = [];
4335
-
4336
- for (var _i = 0; _i < arguments.length; _i++) {
4337
- args[_i] = arguments[_i];
4338
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
4339
-
4340
-
4341
- var key = resolver ? resolver.apply(this, args) : args[0];
4342
- var cache = memoized.cache;
4343
-
4344
- if (cache.has(key)) {
4345
- return cache.get(key);
4346
- }
4347
-
4348
- var result = f.apply(this, args); // 缓存起来
4349
-
4350
- cache.set(key, result);
4351
- return result;
4352
- };
4353
-
4354
- memoized.cache = new Map();
4355
- return memoized;
4356
- };
4357
-
4358
- var ctx$2;
4359
- /**
4360
- * 计算文本的宽度
4361
- */
4362
-
4363
- memoize$2(function (text, font) {
4364
- if (font === void 0) {
4365
- font = {};
4366
- }
4367
-
4368
- var fontSize = font.fontSize,
4369
- fontFamily = font.fontFamily,
4370
- fontWeight = font.fontWeight,
4371
- fontStyle = font.fontStyle,
4372
- fontVariant = font.fontVariant;
4373
-
4374
- if (!ctx$2) {
4375
- ctx$2 = document.createElement('canvas').getContext('2d');
4376
- }
4377
-
4378
- ctx$2.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
4379
- return ctx$2.measureText(isString$2(text) ? text : '').width;
4380
- }, function (text, font) {
4381
- if (font === void 0) {
4382
- font = {};
4383
- }
4384
-
4385
- return __spreadArrays([text], values$2(font)).join('');
4386
- });
4387
3907
  /**
4388
3908
  * Common utilities
4389
3909
  * @module glMatrix
4390
3910
  */
4391
3911
 
3912
+
4392
3913
  var ARRAY_TYPE$1 = typeof Float32Array !== 'undefined' ? Float32Array : Array;
4393
3914
  if (!Math.hypot) Math.hypot = function () {
4394
3915
  var y = 0,
@@ -4954,7 +4475,7 @@
4954
4475
  var iw = width;
4955
4476
  var ih = height;
4956
4477
 
4957
- if (isString$2(img)) {
4478
+ if (isString(img)) {
4958
4479
  // image has been loaded in `mounted` hook
4959
4480
  image = this.imagePool.getImageSync(img);
4960
4481
  } else {
@@ -6860,148 +6381,6 @@
6860
6381
  return _setPrototypeOf$6(o, p);
6861
6382
  }
6862
6383
 
6863
- var toString$3 = {}.toString;
6864
-
6865
- var isType$3 = function isType(value, type) {
6866
- return toString$3.call(value) === '[object ' + type + ']';
6867
- };
6868
- /**
6869
- * 是否为函数
6870
- * @param {*} fn 对象
6871
- * @return {Boolean} 是否函数
6872
- */
6873
-
6874
-
6875
- var isFunction$3 = function isFunction(value) {
6876
- return isType$3(value, 'Function');
6877
- };
6878
-
6879
- var isArray$3 = function isArray(value) {
6880
- return Array.isArray ? Array.isArray(value) : isType$3(value, 'Array');
6881
- };
6882
-
6883
- var isObject$3 = function isObject(value) {
6884
- /**
6885
- * isObject({}) => true
6886
- * isObject([1, 2, 3]) => true
6887
- * isObject(Function) => true
6888
- * isObject(null) => false
6889
- */
6890
- var type = typeof value;
6891
- return value !== null && type === 'object' || type === 'function';
6892
- };
6893
-
6894
- function each$3(elements, func) {
6895
- if (!elements) {
6896
- return;
6897
- }
6898
-
6899
- var rst;
6900
-
6901
- if (isArray$3(elements)) {
6902
- for (var i = 0, len = elements.length; i < len; i++) {
6903
- rst = func(elements[i], i);
6904
-
6905
- if (rst === false) {
6906
- break;
6907
- }
6908
- }
6909
- } else if (isObject$3(elements)) {
6910
- for (var k in elements) {
6911
- if (elements.hasOwnProperty(k)) {
6912
- rst = func(elements[k], k);
6913
-
6914
- if (rst === false) {
6915
- break;
6916
- }
6917
- }
6918
- }
6919
- }
6920
- }
6921
-
6922
- var isString$3 = function isString(str) {
6923
- return isType$3(str, 'String');
6924
- }; // @ts-ignore
6925
-
6926
-
6927
- var values$3 = Object.values ? function (obj) {
6928
- return Object.values(obj);
6929
- } : function (obj) {
6930
- var result = [];
6931
- each$3(obj, function (value, key) {
6932
- if (!(isFunction$3(obj) && key === 'prototype')) {
6933
- result.push(value);
6934
- }
6935
- });
6936
- return result;
6937
- };
6938
- /**
6939
- * _.memoize(calColor);
6940
- * _.memoize(calColor, (...args) => args[0]);
6941
- * @param f
6942
- * @param resolver
6943
- */
6944
-
6945
- var memoize$3 = function memoize(f, resolver) {
6946
- if (!isFunction$3(f)) {
6947
- throw new TypeError('Expected a function');
6948
- }
6949
-
6950
- var memoized = function memoized() {
6951
- var args = [];
6952
-
6953
- for (var _i = 0; _i < arguments.length; _i++) {
6954
- args[_i] = arguments[_i];
6955
- } // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
6956
-
6957
-
6958
- var key = resolver ? resolver.apply(this, args) : args[0];
6959
- var cache = memoized.cache;
6960
-
6961
- if (cache.has(key)) {
6962
- return cache.get(key);
6963
- }
6964
-
6965
- var result = f.apply(this, args); // 缓存起来
6966
-
6967
- cache.set(key, result);
6968
- return result;
6969
- };
6970
-
6971
- memoized.cache = new Map();
6972
- return memoized;
6973
- };
6974
-
6975
- var ctx$3;
6976
- /**
6977
- * 计算文本的宽度
6978
- */
6979
-
6980
- memoize$3(function (text, font) {
6981
- if (font === void 0) {
6982
- font = {};
6983
- }
6984
-
6985
- var fontSize = font.fontSize,
6986
- fontFamily = font.fontFamily,
6987
- fontWeight = font.fontWeight,
6988
- fontStyle = font.fontStyle,
6989
- fontVariant = font.fontVariant;
6990
-
6991
- if (!ctx$3) {
6992
- ctx$3 = document.createElement('canvas').getContext('2d');
6993
- }
6994
-
6995
- ctx$3.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
6996
- return ctx$3.measureText(isString$3(text) ? text : '').width;
6997
- }, function (text, font) {
6998
- if (font === void 0) {
6999
- font = {};
7000
- }
7001
-
7002
- return __spreadArrays([text], values$3(font)).join('');
7003
- });
7004
-
7005
6384
  var _class$4;
7006
6385
 
7007
6386
  var HTMLRenderingPlugin_1;
@@ -7164,7 +6543,7 @@
7164
6543
  case 'innerHTML':
7165
6544
  var innerHTML = object.parsedStyle.innerHTML;
7166
6545
 
7167
- if (isString$3(innerHTML)) {
6546
+ if (isString(innerHTML)) {
7168
6547
  $el.innerHTML = innerHTML;
7169
6548
  } else {
7170
6549
  $el.innerHTML = '';
@@ -7301,122 +6680,6 @@
7301
6680
  Plugin: Plugin$5
7302
6681
  });
7303
6682
 
7304
- var toString$4 = {}.toString;
7305
- var isType$4 = function (value, type) { return toString$4.call(value) === '[object ' + type + ']'; };
7306
-
7307
- /**
7308
- * 是否为函数
7309
- * @param {*} fn 对象
7310
- * @return {Boolean} 是否函数
7311
- */
7312
- var isFunction$4 = (function (value) {
7313
- return isType$4(value, 'Function');
7314
- });
7315
-
7316
- var isArray$4 = (function (value) {
7317
- return Array.isArray ?
7318
- Array.isArray(value) :
7319
- isType$4(value, 'Array');
7320
- });
7321
-
7322
- var isObject$4 = (function (value) {
7323
- /**
7324
- * isObject({}) => true
7325
- * isObject([1, 2, 3]) => true
7326
- * isObject(Function) => true
7327
- * isObject(null) => false
7328
- */
7329
- var type = typeof value;
7330
- return value !== null && type === 'object' || type === 'function';
7331
- });
7332
-
7333
- function each$4(elements, func) {
7334
- if (!elements) {
7335
- return;
7336
- }
7337
- var rst;
7338
- if (isArray$4(elements)) {
7339
- for (var i = 0, len = elements.length; i < len; i++) {
7340
- rst = func(elements[i], i);
7341
- if (rst === false) {
7342
- break;
7343
- }
7344
- }
7345
- }
7346
- else if (isObject$4(elements)) {
7347
- for (var k in elements) {
7348
- if (elements.hasOwnProperty(k)) {
7349
- rst = func(elements[k], k);
7350
- if (rst === false) {
7351
- break;
7352
- }
7353
- }
7354
- }
7355
- }
7356
- }
7357
-
7358
- var isString$4 = (function (str) {
7359
- return isType$4(str, 'String');
7360
- });
7361
-
7362
- // @ts-ignore
7363
- var values$4 = Object.values ? function (obj) { return Object.values(obj); } : function (obj) {
7364
- var result = [];
7365
- each$4(obj, function (value, key) {
7366
- if (!(isFunction$4(obj) && key === 'prototype')) {
7367
- result.push(value);
7368
- }
7369
- });
7370
- return result;
7371
- };
7372
-
7373
- /**
7374
- * _.memoize(calColor);
7375
- * _.memoize(calColor, (...args) => args[0]);
7376
- * @param f
7377
- * @param resolver
7378
- */
7379
- var memoize$4 = (function (f, resolver) {
7380
- if (!isFunction$4(f)) {
7381
- throw new TypeError('Expected a function');
7382
- }
7383
- var memoized = function () {
7384
- var args = [];
7385
- for (var _i = 0; _i < arguments.length; _i++) {
7386
- args[_i] = arguments[_i];
7387
- }
7388
- // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
7389
- var key = resolver ? resolver.apply(this, args) : args[0];
7390
- var cache = memoized.cache;
7391
- if (cache.has(key)) {
7392
- return cache.get(key);
7393
- }
7394
- var result = f.apply(this, args);
7395
- // 缓存起来
7396
- cache.set(key, result);
7397
- return result;
7398
- };
7399
- memoized.cache = new Map();
7400
- return memoized;
7401
- });
7402
-
7403
- var ctx$4;
7404
- /**
7405
- * 计算文本的宽度
7406
- */
7407
- memoize$4(function (text, font) {
7408
- if (font === void 0) { font = {}; }
7409
- var fontSize = font.fontSize, fontFamily = font.fontFamily, fontWeight = font.fontWeight, fontStyle = font.fontStyle, fontVariant = font.fontVariant;
7410
- if (!ctx$4) {
7411
- ctx$4 = document.createElement('canvas').getContext('2d');
7412
- }
7413
- ctx$4.font = [fontStyle, fontVariant, fontWeight, fontSize + "px", fontFamily].join(' ');
7414
- return ctx$4.measureText(isString$4(text) ? text : '').width;
7415
- }, function (text, font) {
7416
- if (font === void 0) { font = {}; }
7417
- return __spreadArrays([text], values$4(font)).join('');
7418
- });
7419
-
7420
6683
  var Canvas2DContextService = /*#__PURE__*/function () {
7421
6684
  function Canvas2DContextService(canvasConfig) {
7422
6685
  this.canvasConfig = void 0;
@@ -7450,7 +6713,7 @@
7450
6713
  this.canvasConfig.container = this.$container;
7451
6714
  } else if (container) {
7452
6715
  // create container
7453
- this.$container = isString$4(container) ? document.getElementById(container) : container;
6716
+ this.$container = isString(container) ? document.getElementById(container) : container;
7454
6717
 
7455
6718
  if (this.$container) {
7456
6719
  // create canvas