@antv/g 5.15.3 → 5.15.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
@@ -5309,13 +5309,6 @@
5309
5309
  return result[0].length === result[1].length ? result : equalizeSegments(result[0], result[1], tl);
5310
5310
  }
5311
5311
 
5312
- /**
5313
- * @see https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_isfunction
5314
- */
5315
- var isFunction = (function (value) {
5316
- return typeof value === 'function';
5317
- });
5318
-
5319
5312
  // isFinite,
5320
5313
  var isNil = function (value) {
5321
5314
  /**
@@ -5441,36 +5434,6 @@
5441
5434
  return value === undefined;
5442
5435
  };
5443
5436
 
5444
- /**
5445
- * _.memoize(calColor);
5446
- * _.memoize(calColor, (...args) => args[0]);
5447
- * @param f
5448
- * @param resolver
5449
- */
5450
- var memoize = (function (f, resolver) {
5451
- if (!isFunction(f)) {
5452
- throw new TypeError('Expected a function');
5453
- }
5454
- var memoized = function () {
5455
- var args = [];
5456
- for (var _i = 0; _i < arguments.length; _i++) {
5457
- args[_i] = arguments[_i];
5458
- }
5459
- // 使用方法构造 key,如果不存在 resolver,则直接取第一个参数作为 key
5460
- var key = resolver ? resolver.apply(this, args) : args[0];
5461
- var cache = memoized.cache;
5462
- if (cache.has(key)) {
5463
- return cache.get(key);
5464
- }
5465
- var result = f.apply(this, args);
5466
- // 缓存起来
5467
- cache.set(key, result);
5468
- return result;
5469
- };
5470
- memoized.cache = new Map();
5471
- return memoized;
5472
- });
5473
-
5474
5437
  function define(constructor, factory, prototype) {
5475
5438
  constructor.prototype = factory.prototype = prototype;
5476
5439
  prototype.constructor = constructor;
@@ -5883,6 +5846,7 @@
5883
5846
  function piMod(angle) {
5884
5847
  return (angle + Math.PI * 2) % (Math.PI * 2);
5885
5848
  }
5849
+
5886
5850
  var line = {
5887
5851
  /**
5888
5852
  * 计算线段的包围盒
@@ -5977,6 +5941,7 @@
5977
5941
  return Math.atan2(y2 - y1, x2 - x1);
5978
5942
  }
5979
5943
  };
5944
+
5980
5945
  var EPSILON$1 = 0.0001;
5981
5946
  /**
5982
5947
  * 使用牛顿切割法求最近的点
@@ -6146,6 +6111,7 @@
6146
6111
  return piMod(angle);
6147
6112
  }
6148
6113
  };
6114
+
6149
6115
  function cubicAt(p0, p1, p2, p3, t) {
6150
6116
  var onet = 1 - t; // t * t * t 的性能大概是 Math.pow(t, 3) 的三倍
6151
6117
  return onet * onet * onet * p0 + 3 * p1 * t * onet * onet + 3 * p2 * t * t * onet + p3 * t * t * t;
@@ -6577,6 +6543,7 @@
6577
6543
  return piMod(Math.atan2(dy, dx));
6578
6544
  }
6579
6545
  };
6546
+
6580
6547
  function analyzePoints(points) {
6581
6548
  // 计算每段的长度和总的长度
6582
6549
  var totalLength = 0;
@@ -6689,6 +6656,7 @@
6689
6656
  }
6690
6657
  return minDistance;
6691
6658
  }
6659
+
6692
6660
  var polyline = {
6693
6661
  /**
6694
6662
  * 计算多折线的包围盒
@@ -7130,7 +7098,7 @@
7130
7098
  set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
7131
7099
  set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
7132
7100
  set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
7133
- set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();(function(Shape){Shape["GROUP"]="g";Shape["CIRCLE"]="circle";Shape["ELLIPSE"]="ellipse";Shape["IMAGE"]="image";Shape["RECT"]="rect";Shape["LINE"]="line";Shape["POLYLINE"]="polyline";Shape["POLYGON"]="polygon";Shape["TEXT"]="text";Shape["PATH"]="path";Shape["HTML"]="html";Shape["MESH"]="mesh";})(exports.Shape||(exports.Shape={}));var camelCase=memoize(function(str){if(str===void 0){str='';}return str.replace(/-([a-z])/g,function(g){return g[1].toUpperCase();});});function DCHECK(bool){if(!bool){throw new Error();}}function DCHECK_EQ(a,b){if(a!==b){throw new Error();}}function DCHECK_NE(a,b){if(a===b){throw new Error();}}function isFunction$1(func){return typeof func==='function';}var definedProps=function definedProps(obj){return Object.fromEntries(Object.entries(obj).filter(function(_ref){var v=_ref[1];return v!==undefined;}));};var FORMAT_ATTR_MAP={d:{alias:'path'},strokeDasharray:{alias:'lineDash'},strokeWidth:{alias:'lineWidth'},textAnchor:{alias:'textAlign'},src:{alias:'img'}};var formatAttributeName=memoize(function(name){var attributeName=camelCase(name);var map=FORMAT_ATTR_MAP[attributeName];attributeName=(map===null||map===void 0?void 0:map.alias)||attributeName;return attributeName;});var canvasMap={};var defaultCanvasIdCounter=0;/**
7101
+ set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();(function(Shape){Shape["GROUP"]="g";Shape["CIRCLE"]="circle";Shape["ELLIPSE"]="ellipse";Shape["IMAGE"]="image";Shape["RECT"]="rect";Shape["LINE"]="line";Shape["POLYLINE"]="polyline";Shape["POLYGON"]="polygon";Shape["TEXT"]="text";Shape["PATH"]="path";Shape["HTML"]="html";Shape["MESH"]="mesh";})(exports.Shape||(exports.Shape={}));function memoize(func,resolver){if(typeof func!=='function'||resolver!=null&&typeof resolver!=='function'){throw new TypeError('Expected a function');}var memoized=function memoized(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var key=resolver?resolver.apply(this,args):args[0];var cache=memoized.cache;if(cache.has(key)){return cache.get(key);}var result=func.apply(this,args);memoized.cache=cache.set(key,result)||cache;return result;};memoized.cache=new(memoize.Cache||Map)();return memoized;}memoize.Cache=Map;var camelCase=memoize(function(str){if(str===void 0){str='';}return str.replace(/-([a-z])/g,function(g){return g[1].toUpperCase();});});function DCHECK(bool){if(!bool){throw new Error();}}function DCHECK_EQ(a,b){if(a!==b){throw new Error();}}function DCHECK_NE(a,b){if(a===b){throw new Error();}}function isFunction(func){return typeof func==='function';}var definedProps=function definedProps(obj){return Object.fromEntries(Object.entries(obj).filter(function(_ref){var v=_ref[1];return v!==undefined;}));};var FORMAT_ATTR_MAP={d:{alias:'path'},strokeDasharray:{alias:'lineDash'},strokeWidth:{alias:'lineWidth'},textAnchor:{alias:'textAlign'},src:{alias:'img'}};var formatAttributeName=memoize(function(name){var attributeName=camelCase(name);var map=FORMAT_ATTR_MAP[attributeName];attributeName=(map===null||map===void 0?void 0:map.alias)||attributeName;return attributeName;});var canvasMap={};var defaultCanvasIdCounter=0;/**
7134
7102
  * destroy existed canvas with the same id
7135
7103
  */function cleanExistedCanvas(container,canvas){if(container){var id=typeof container==='string'?container:container.id||defaultCanvasIdCounter++;if(canvasMap[id]){canvasMap[id].destroy();}canvasMap[id]=canvas;}}var isBrowser=typeof window!=='undefined'&&typeof window.document!=='undefined';function sortByZIndex(o1,o2){var zIndex1=Number(o1.style.zIndex);var zIndex2=Number(o2.style.zIndex);if(zIndex1===zIndex2){// return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
7136
7104
  var parent=o1.parentNode;if(parent){var children=parent.childNodes||[];return children.indexOf(o1)-children.indexOf(o2);}}return zIndex1-zIndex2;}function findClosestClipPathTarget(object){var el=object;do{var _el$style;var clipPath=(_el$style=el.style)===null||_el$style===void 0?void 0:_el$style.clipPath;if(clipPath)return el;el=el.parentElement;}while(el!==null);return null;}var PX_SUFFIX='px';function setDOMSize($el,width,height){if(isBrowser&&$el.style){$el.style.width=width+PX_SUFFIX;$el.style.height=height+PX_SUFFIX;}}function getStyle($el,property){if(isBrowser){return document.defaultView.getComputedStyle($el,null).getPropertyValue(property);}}function getWidth($el){var width=getStyle($el,'width');if(width==='auto'){return $el.offsetWidth;}return parseFloat(width);}function getHeight($el){var height=getStyle($el,'height');if(height==='auto'){return $el.offsetHeight;}return parseFloat(height);}var ERROR_MSG_METHOD_NOT_IMPLEMENTED='Method not implemented.';var ERROR_MSG_USE_DOCUMENT_ELEMENT='Use document.documentElement instead.';var ERROR_MSG_APPEND_DESTROYED_ELEMENT='Cannot append a destroyed element.';// borrow from hammer.js
@@ -8083,15 +8051,15 @@
8083
8051
  */_proto.on=function on(type,listener,options){this.addEventListener(type,listener,options);return this;}/**
8084
8052
  * support `capture` & `once` in options
8085
8053
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
8086
- */;_proto.addEventListener=function addEventListener(type,listener,options){var capture=isBoolean(options)&&options||isObject(options)&&options.capture;var once=isObject(options)&&options.once;var context=isFunction$1(listener)?undefined:listener;// compatible with G 3.0
8054
+ */;_proto.addEventListener=function addEventListener(type,listener,options){var capture=isBoolean(options)&&options||isObject(options)&&options.capture;var once=isObject(options)&&options.once;var context=isFunction(listener)?undefined:listener;// compatible with G 3.0
8087
8055
  // support using delegate name in event type, eg. 'node:click'
8088
- var useDelegatedName=false;var delegatedName='';if(type.indexOf(DELEGATION_SPLITTER)>-1){var _type$split=type.split(DELEGATION_SPLITTER),name=_type$split[0],eventType=_type$split[1];type=eventType;delegatedName=name;useDelegatedName=true;}type=capture?type+"capture":type;listener=isFunction$1(listener)?listener:listener.handleEvent;// compatible with G 3.0
8056
+ var useDelegatedName=false;var delegatedName='';if(type.indexOf(DELEGATION_SPLITTER)>-1){var _type$split=type.split(DELEGATION_SPLITTER),name=_type$split[0],eventType=_type$split[1];type=eventType;delegatedName=name;useDelegatedName=true;}type=capture?type+"capture":type;listener=isFunction(listener)?listener:listener.handleEvent;// compatible with G 3.0
8089
8057
  if(useDelegatedName){var originListener=listener;listener=function listener(){var _args$0$target;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}if(((_args$0$target=args[0].target)===null||_args$0$target===void 0?void 0:_args$0$target.name)!==delegatedName){return;}// @ts-ignore
8090
8058
  originListener.apply(void 0,args);};}if(once){this.emitter.once(type,listener,context);}else {this.emitter.on(type,listener,context);}return this;}/**
8091
8059
  * @deprecated
8092
8060
  * @alias removeEventListener
8093
8061
  */;_proto.off=function off(type,listener,options){if(type){this.removeEventListener(type,listener,options);}else {// remove all listeners
8094
- this.removeAllEventListeners();}return this;};_proto.removeAllEventListeners=function removeAllEventListeners(){this.emitter.removeAllListeners();};_proto.removeEventListener=function removeEventListener(type,listener,options){var _listener;var capture=isBoolean(options)&&options||isObject(options)&&options.capture;var context=isFunction$1(listener)?undefined:listener;type=capture?type+"capture":type;listener=isFunction$1(listener)?listener:(_listener=listener)===null||_listener===void 0?void 0:_listener.handleEvent;this.emitter.off(type,listener,context);return this;}/**
8062
+ this.removeAllEventListeners();}return this;};_proto.removeAllEventListeners=function removeAllEventListeners(){this.emitter.removeAllListeners();};_proto.removeEventListener=function removeEventListener(type,listener,options){var _listener;var capture=isBoolean(options)&&options||isObject(options)&&options.capture;var context=isFunction(listener)?undefined:listener;type=capture?type+"capture":type;listener=isFunction(listener)?listener:(_listener=listener)===null||_listener===void 0?void 0:_listener.handleEvent;this.emitter.off(type,listener,context);return this;}/**
8095
8063
  * @deprecated
8096
8064
  * @alias dispatchEvent
8097
8065
  */ // eslint-disable-next-line @typescript-eslint/ban-types
@@ -8151,12 +8119,12 @@
8151
8119
  * for inherited properties, the initial value is used on the root element only,
8152
8120
  * as long as no specified value is supplied.
8153
8121
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial_value
8154
- */var initialStyle={};BUILT_IN_PROPERTIES.forEach(function(_ref){var n=_ref.n,inh=_ref.inh,d=_ref.d;if(inh&&d){initialStyle[n]=isFunction$1(d)?d(exports.Shape.GROUP):d;}});// like <html> in DOM tree
8122
+ */var initialStyle={};BUILT_IN_PROPERTIES.forEach(function(_ref){var n=_ref.n,inh=_ref.inh,d=_ref.d;if(inh&&d){initialStyle[n]=isFunction(d)?d(exports.Shape.GROUP):d;}});// like <html> in DOM tree
8155
8123
  _this.documentElement=new Group({id:'g-root',style:initialStyle});_this.documentElement.ownerDocument=_assertThisInitialized(_this);_this.documentElement.parentNode=_assertThisInitialized(_this);_this.childNodes=[_this.documentElement];return _this;}var _proto=Document.prototype;/**
8156
8124
  * @example const circle = document.createElement('circle', { style: { r: 10 } });
8157
8125
  */_proto.createElement=function createElement(tagName,options){// @observablehq/plot will create <svg>
8158
8126
  if(tagName==='svg'){return this.documentElement;}// d3 will use <tspan>
8159
- var clazz=this.defaultView.customElements.get(tagName);if(!clazz){console.warn('Unsupported tagName: ',tagName);clazz=tagName==='tspan'?Text:Group;}var shape=new clazz(options);shape.ownerDocument=this;return shape;};_proto.createElementNS=function createElementNS(namespaceURI,tagName,options){return this.createElement(tagName,options);};_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.destroy=function destroy(){try{this.documentElement.destroy();this.timeline.destroy();}catch(e){}}/**
8127
+ var clazz=this.defaultView.customElements.get(tagName);if(!clazz){console.warn('Unsupported tagName: ',tagName);clazz=tagName==='tspan'?Text:Group;}var shape=new clazz(options);shape.ownerDocument=this;return shape;};_proto.createElementNS=function createElementNS(namespaceURI,tagName,options){return this.createElement(tagName,options);};_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.destroy=function destroy(){try{[].concat(this.documentElement.childNodes).forEach(function(child,i){child.forEach(function(object){object.destroy();});});this.timeline.destroy();}catch(e){}}/**
8160
8128
  * Picking 2D graphics with RBush based on BBox, fast but inaccurate.
8161
8129
  */;_proto.elementsFromBBox=function elementsFromBBox(minX,minY,maxX,maxY){var rBush=this.defaultView.context.rBushRoot;var rBushNodes=rBush.search({minX:minX,minY:minY,maxX:maxX,maxY:maxY});var hitTestList=[];rBushNodes.forEach(function(_ref2){var id=_ref2.id;var displayObject=runtime.displayObjectPool.getByEntity(id);var pointerEvents=displayObject.parsedStyle.pointerEvents;// account for `visibility`
8162
8130
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
@@ -8360,7 +8328,7 @@
8360
8328
  return target[name];}return _this.getAttribute(name);},set:function set(_,prop,value){_this.setAttribute(prop,value);return true;}});// insert this group into pool
8361
8329
  runtime.displayObjectPool.add(_this.entity,_assertThisInitialized(_this));return _this;}var _proto=DisplayObject.prototype;_proto.destroy=function destroy(){_Element.prototype.destroy.call(this);// remove from pool
8362
8330
  runtime.displayObjectPool.remove(this.entity);// stop all active animations
8363
- this.getAnimations().forEach(function(animation){animation.cancel();});};_proto.cloneNode=function cloneNode(deep,customCloneFunc){var clonedStyle=_extends({},this.attributes);for(var attributeName in clonedStyle){var attribute=clonedStyle[attributeName];// @see https://github.com/antvis/G/issues/1095
8331
+ this.getAnimations().forEach(function(animation){animation.cancel();});this.renderable=null;this.cullable=null;this.transformable=null;this.rBushNode=null;this.geometry=null;this.sortable=null;};_proto.cloneNode=function cloneNode(deep,customCloneFunc){var clonedStyle=_extends({},this.attributes);for(var attributeName in clonedStyle){var attribute=clonedStyle[attributeName];// @see https://github.com/antvis/G/issues/1095
8364
8332
  if(attribute instanceof DisplayObject&&// share the same clipPath if possible
8365
8333
  attributeName!=='clipPath'&&attributeName!=='offsetPath'&&attributeName!=='textPath'){clonedStyle[attributeName]=attribute.cloneNode(deep);}// TODO: clone other type
8366
8334
  if(customCloneFunc){clonedStyle[attributeName]=customCloneFunc(attributeName,attribute);}}var cloned=new this.constructor({// copy id & name
@@ -8368,8 +8336,12 @@
8368
8336
  id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:clonedStyle});// apply transform
8369
8337
  cloned.setLocalTransform(this.getLocalTransform());if(deep){this.children.forEach(function(child){// skip marker
8370
8338
  if(!child.style.isMarker){var clonedChild=child.cloneNode(deep);cloned.appendChild(clonedChild);}});}return cloned;};_proto.initAttributes=function initAttributes(attributes){if(attributes===void 0){attributes={};}var renderable=this.renderable;// account for FCP, process properties as less as possible
8371
- runtime.styleValueRegistry.processProperties(this,attributes,{forceUpdateGeometry:true,usedAttributes:// only Group / Text should account for text relative props
8372
- this.tagName===exports.Shape.GROUP||this.tagName===exports.Shape.TEXT?INHERITABLE_STYLE_PROPS:INHERITABLE_BASE_STYLE_PROPS});// redraw at next frame
8339
+ runtime.styleValueRegistry.processProperties(this,attributes,{forceUpdateGeometry:true,usedAttributes:INHERITABLE_STYLE_PROPS// usedAttributes:
8340
+ // // only Group / Text should account for text relative props
8341
+ // this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
8342
+ // ? INHERITABLE_STYLE_PROPS
8343
+ // : INHERITABLE_BASE_STYLE_PROPS,
8344
+ });// redraw at next frame
8373
8345
  renderable.dirty=true;};_proto.setAttribute=function setAttribute(name,value,force){if(force===void 0){force=false;}var attributeName=formatAttributeName(name);// ignore undefined value
8374
8346
  if(isUndefined(value)){return;}if(force||value!==this.attributes[attributeName]){this.internalSetAttribute(attributeName,value);_Element.prototype.setAttribute.call(this,attributeName,value);}}/**
8375
8347
  * called when attributes get changed or initialized
@@ -8911,10 +8883,11 @@
8911
8883
  // n: 'whiteSpace',
8912
8884
  // l: true,
8913
8885
  // },
8914
- {n:'markerStart',syntax:exports.PropertySyntax.MARKER},{n:'markerEnd',syntax:exports.PropertySyntax.MARKER},{n:'markerMid',syntax:exports.PropertySyntax.MARKER},{n:'markerStartOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'},{n:'markerEndOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'}];var propertyMetadataCache={};var unresolvedProperties=new WeakMap();var priorityMap={};var sortAttributeNames=memoize(function(attributeNames){return attributeNames.sort(function(a,b){return priorityMap[a]-priorityMap[b];});});var tmpVec3a=create$2();var tmpVec3b=create$2();var tmpVec3c=create$2();var isPropertyResolved=function isPropertyResolved(object,name){var properties=unresolvedProperties.get(object);if(!properties||properties.length===0){return true;}return properties.includes(name);};var DefaultStyleValueRegistry=/*#__PURE__*/function(){/**
8886
+ {n:'markerStart',syntax:exports.PropertySyntax.MARKER},{n:'markerEnd',syntax:exports.PropertySyntax.MARKER},{n:'markerMid',syntax:exports.PropertySyntax.MARKER},{n:'markerStartOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'},{n:'markerEndOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'}];var propertyMetadataCache={};var unresolvedProperties=new WeakMap();// const uniqueAttributeSet = new Set<string>();
8887
+ var tmpVec3a=create$2();var tmpVec3b=create$2();var tmpVec3c=create$2();var isPropertyResolved=function isPropertyResolved(object,name){var properties=unresolvedProperties.get(object);if(!properties||properties.length===0){return true;}return properties.includes(name);};var DefaultStyleValueRegistry=/*#__PURE__*/function(){/**
8915
8888
  * need recalc later
8916
8889
  */ // dirty = false;
8917
- function DefaultStyleValueRegistry(){var _this=this;BUILT_IN_PROPERTIES.forEach(function(property){_this.registerMetadata(property);});}var _proto=DefaultStyleValueRegistry.prototype;_proto.registerMetadata=function registerMetadata(metadata){[metadata.n].concat(metadata.a||[]).forEach(function(name){propertyMetadataCache[name]=metadata;priorityMap[name]=metadata.p||0;});};_proto.unregisterMetadata=function unregisterMetadata(name){delete propertyMetadataCache[name];};_proto.getPropertySyntax=function getPropertySyntax(syntax){return runtime.CSSPropertySyntaxFactory[syntax];}/**
8890
+ function DefaultStyleValueRegistry(){var _this=this;BUILT_IN_PROPERTIES.forEach(function(property){_this.registerMetadata(property);});}var _proto=DefaultStyleValueRegistry.prototype;_proto.registerMetadata=function registerMetadata(metadata){[metadata.n].concat(metadata.a||[]).forEach(function(name){propertyMetadataCache[name]=metadata;});};_proto.unregisterMetadata=function unregisterMetadata(name){delete propertyMetadataCache[name];};_proto.getPropertySyntax=function getPropertySyntax(syntax){return runtime.CSSPropertySyntaxFactory[syntax];}/**
8918
8891
  * * parse value, eg.
8919
8892
  * fill: 'red' => CSSRGB
8920
8893
  * translateX: '10px' => CSSUnitValue { unit: 'px', value: 10 }
@@ -8924,8 +8897,15 @@
8924
8897
  * * post process
8925
8898
  */;_proto.processProperties=function processProperties(object,attributes,options){var _this2=this;if(options===void 0){options={skipUpdateAttribute:false,skipParse:false,forceUpdateGeometry:false,usedAttributes:[]};}var _options=options,skipUpdateAttribute=_options.skipUpdateAttribute,skipParse=_options.skipParse,forceUpdateGeometry=_options.forceUpdateGeometry,usedAttributes=_options.usedAttributes;var needUpdateGeometry=forceUpdateGeometry;var attributeNames=Object.keys(attributes);attributeNames.forEach(function(attributeName){var _propertyMetadataCach;var name=formatAttributeName(attributeName);if(!skipUpdateAttribute){object.attributes[name]=attributes[attributeName];}if(!needUpdateGeometry&&((_propertyMetadataCach=propertyMetadataCache[name])===null||_propertyMetadataCach===void 0?void 0:_propertyMetadataCach.l)){needUpdateGeometry=true;}});if(!skipParse){attributeNames.forEach(function(name){object.computedStyle[name]=_this2.parseProperty(name,object.attributes[name],object);});}// let hasUnresolvedProperties = false;
8926
8899
  // parse according to priority
8927
- attributeNames=sortAttributeNames((usedAttributes===null||usedAttributes===void 0?void 0:usedAttributes.length)?Array.from(new Set(attributeNames.concat(usedAttributes))):attributeNames);// attributeNames.sort((a, b) => priorityMap[a] - priorityMap[b]);
8928
- attributeNames.forEach(function(name){// some style props maybe deleted after parsing such as `anchor` in Text
8900
+ // path 50
8901
+ // points 50
8902
+ // text 50
8903
+ // textTransform 51
8904
+ // anchor 99
8905
+ // transform 100
8906
+ // transformOrigin 100
8907
+ if(usedAttributes===null||usedAttributes===void 0?void 0:usedAttributes.length){// uniqueAttributeSet.clear();
8908
+ attributeNames=Array.from(new Set(attributeNames.concat(usedAttributes)));}['path','points','text','textTransform','anchor','transform','transformOrigin'].forEach(function(name){var index=attributeNames.indexOf(name);if(index>-1){attributeNames.splice(index,1);attributeNames.push(name);}});attributeNames.forEach(function(name){// some style props maybe deleted after parsing such as `anchor` in Text
8929
8909
  if(name in object.computedStyle){object.parsedStyle[name]=_this2.computeProperty(name,object.computedStyle[name],object);}});// if (hasUnresolvedProperties) {
8930
8910
  // this.dirty = true;
8931
8911
  // return;
@@ -8944,7 +8924,7 @@
8944
8924
  var used=computed;if(metadata){var syntax=metadata.syntax,inherited=metadata.inh,defaultValue=metadata.d;if(computed instanceof CSSKeywordValue){var value=computed.value;/**
8945
8925
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/unset
8946
8926
  */if(value==='unset'){if(inherited&&!isDocumentElement){value='inherit';}else {value='initial';}}if(value==='initial'){// @see https://developer.mozilla.org/en-US/docs/Web/CSS/initial
8947
- if(!isNil(defaultValue)){computed=this.parseProperty(name,isFunction$1(defaultValue)?defaultValue(object.nodeName):defaultValue,object);}}else if(value==='inherit'){// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
8927
+ if(!isNil(defaultValue)){computed=this.parseProperty(name,isFunction(defaultValue)?defaultValue(object.nodeName):defaultValue,object);}}else if(value==='inherit'){// @see https://developer.mozilla.org/en-US/docs/Web/CSS/inherit
8948
8928
  // behave like `inherit`
8949
8929
  var resolved=this.tryToResolveProperty(object,name,{inherited:true});if(!isNil(resolved)){// object.parsedStyle[name] = resolved;
8950
8930
  // return false;
@@ -9120,7 +9100,7 @@
9120
9100
  enterEvent=_this.clonePointerEvent(e,'pointerenter');enterEvent.eventPhase=enterEvent.AT_TARGET;while(enterEvent.target&&enterEvent.target!==(Node.isNode(_this.rootTarget)&&_this.rootTarget.parentNode)){enterEvent.currentTarget=enterEvent.target;_this.notifyTarget(enterEvent);if(isMouse){// mouseenter should not bubble
9121
9101
  // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event#usage_notes
9122
9102
  _this.notifyTarget(enterEvent,'mouseenter');}if(Node.isNode(enterEvent.target)){enterEvent.target=enterEvent.target.parentNode;}}trackingData.overTargets=e.composedPath();_this.freeEvent(e);_this.freeEvent(enterEvent);case 16:case"end":return _context5.stop();}}},_callee5);}));return function(_x5){return _ref5.apply(this,arguments);};}();this.onPointerUpOutside=/*#__PURE__*/function(){var _ref6=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(from){var trackingData,pressTarget,e,currentTarget;return _regeneratorRuntime().wrap(function _callee6$(_context6){while(1){switch(_context6.prev=_context6.next){case 0:if(from instanceof FederatedPointerEvent){_context6.next=2;break;}return _context6.abrupt("return");case 2:trackingData=_this.trackingData(from.pointerId);pressTarget=_this.findMountedTarget(trackingData.pressTargetsByButton[from.button]);_context6.next=6;return _this.createPointerEvent(from);case 6:e=_context6.sent;if(pressTarget){currentTarget=pressTarget;while(currentTarget){e.currentTarget=currentTarget;_this.notifyTarget(e,'pointerupoutside');if(e.pointerType==='touch');else if(e.pointerType==='mouse'||e.pointerType==='pen'){_this.notifyTarget(e,e.button===2?'rightupoutside':'mouseupoutside');}if(Node.isNode(currentTarget)){currentTarget=currentTarget.parentNode;}}delete trackingData.pressTargetsByButton[from.button];}_this.freeEvent(e);case 9:case"end":return _context6.stop();}}},_callee6);}));return function(_x6){return _ref6.apply(this,arguments);};}();this.onWheel=/*#__PURE__*/function(){var _ref7=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(from){var wheelEvent;return _regeneratorRuntime().wrap(function _callee7$(_context7){while(1){switch(_context7.prev=_context7.next){case 0:if(from instanceof FederatedWheelEvent){_context7.next=2;break;}return _context7.abrupt("return");case 2:_context7.next=4;return _this.createWheelEvent(from);case 4:wheelEvent=_context7.sent;_this.dispatchEvent(wheelEvent);_this.freeEvent(wheelEvent);case 7:case"end":return _context7.stop();}}},_callee7);}));return function(_x7){return _ref7.apply(this,arguments);};}();this.globalRuntime=globalRuntime;this.context=context;}var _proto=EventService.prototype;_proto.init=function init(){this.rootTarget=this.context.renderingContext.root.parentNode;// document
9123
- this.addEventMapping('pointerdown',this.onPointerDown);this.addEventMapping('pointerup',this.onPointerUp);this.addEventMapping('pointermove',this.onPointerMove);this.addEventMapping('pointerout',this.onPointerOut);this.addEventMapping('pointerleave',this.onPointerOut);this.addEventMapping('pointerover',this.onPointerOver);this.addEventMapping('pointerupoutside',this.onPointerUpOutside);this.addEventMapping('wheel',this.onWheel);};_proto.client2Viewport=function client2Viewport(client){var bbox=this.context.contextService.getBoundingClientRect();return new Point(client.x-((bbox===null||bbox===void 0?void 0:bbox.left)||0),client.y-((bbox===null||bbox===void 0?void 0:bbox.top)||0));};_proto.viewport2Client=function viewport2Client(canvas){var bbox=this.context.contextService.getBoundingClientRect();return new Point(canvas.x+((bbox===null||bbox===void 0?void 0:bbox.left)||0),canvas.y+((bbox===null||bbox===void 0?void 0:bbox.top)||0));};_proto.viewport2Canvas=function viewport2Canvas(_ref8){var x=_ref8.x,y=_ref8.y;var canvas=this.rootTarget.defaultView;var camera=canvas.getCamera();var _this$context$config=this.context.config,width=_this$context$config.width,height=_this$context$config.height;var projectionMatrixInverse=camera.getPerspectiveInverse();var worldMatrix=camera.getWorldTransform();var vpMatrix=multiply(this.tmpMatrix,worldMatrix,projectionMatrixInverse);var viewport=set$1(this.tmpVec3,x/width*2-1,(1-y/height)*2-1,0);transformMat4(viewport,viewport,vpMatrix);return new Point(viewport[0],viewport[1]);};_proto.canvas2Viewport=function canvas2Viewport(canvasP){var canvas=this.rootTarget.defaultView;var camera=canvas.getCamera();// World -> Clip
9103
+ this.addEventMapping('pointerdown',this.onPointerDown);this.addEventMapping('pointerup',this.onPointerUp);this.addEventMapping('pointermove',this.onPointerMove);this.addEventMapping('pointerout',this.onPointerOut);this.addEventMapping('pointerleave',this.onPointerOut);this.addEventMapping('pointerover',this.onPointerOver);this.addEventMapping('pointerupoutside',this.onPointerUpOutside);this.addEventMapping('wheel',this.onWheel);};_proto.destroy=function destroy(){this.emitter.removeAllListeners();this.mappingTable={};this.mappingState={};this.eventPool.clear();};_proto.client2Viewport=function client2Viewport(client){var bbox=this.context.contextService.getBoundingClientRect();return new Point(client.x-((bbox===null||bbox===void 0?void 0:bbox.left)||0),client.y-((bbox===null||bbox===void 0?void 0:bbox.top)||0));};_proto.viewport2Client=function viewport2Client(canvas){var bbox=this.context.contextService.getBoundingClientRect();return new Point(canvas.x+((bbox===null||bbox===void 0?void 0:bbox.left)||0),canvas.y+((bbox===null||bbox===void 0?void 0:bbox.top)||0));};_proto.viewport2Canvas=function viewport2Canvas(_ref8){var x=_ref8.x,y=_ref8.y;var canvas=this.rootTarget.defaultView;var camera=canvas.getCamera();var _this$context$config=this.context.config,width=_this$context$config.width,height=_this$context$config.height;var projectionMatrixInverse=camera.getPerspectiveInverse();var worldMatrix=camera.getWorldTransform();var vpMatrix=multiply(this.tmpMatrix,worldMatrix,projectionMatrixInverse);var viewport=set$1(this.tmpVec3,x/width*2-1,(1-y/height)*2-1,0);transformMat4(viewport,viewport,vpMatrix);return new Point(viewport[0],viewport[1]);};_proto.canvas2Viewport=function canvas2Viewport(canvasP){var canvas=this.rootTarget.defaultView;var camera=canvas.getCamera();// World -> Clip
9124
9104
  var projectionMatrix=camera.getPerspective();var viewMatrix=camera.getViewTransform();var vpMatrix=multiply(this.tmpMatrix,projectionMatrix,viewMatrix);var clip=set$1(this.tmpVec3,canvasP.x,canvasP.y,0);transformMat4(this.tmpVec3,this.tmpVec3,vpMatrix);// Clip -> NDC -> Viewport, flip Y
9125
9105
  var _this$context$config2=this.context.config,width=_this$context$config2.width,height=_this$context$config2.height;return new Point((clip[0]+1)/2*width,(1-(clip[1]+1)/2)*height);};_proto.setPickHandler=function setPickHandler(pickHandler){this.pickHandler=pickHandler;};_proto.addEventMapping=function addEventMapping(type,fn){if(!this.mappingTable[type]){this.mappingTable[type]=[];}this.mappingTable[type].push({fn:fn,priority:0});this.mappingTable[type].sort(function(a,b){return a.priority-b.priority;});};_proto.mapEvent=function mapEvent(e){if(!this.rootTarget){return;}var mappers=this.mappingTable[e.type];if(mappers){for(var i=0,j=mappers.length;i<j;i++){mappers[i].fn(e);}}else {console.warn("[EventService]: Event mapping not defined for "+e.type);}};_proto.dispatchEvent=function dispatchEvent(e,type,skipPropagate){// Canvas should skip
9126
9106
  if(!skipPropagate){e.propagationStopped=false;e.propagationImmediatelyStopped=false;this.propagate(e,type);}else {// target phase
@@ -9319,7 +9299,8 @@
9319
9299
  // (toDataURI, getImageData functions)
9320
9300
  if(fontProperties.fontSize===0){fontProperties.fontSize=fontSize;fontProperties.ascent=fontSize;}var context=this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);context.font=font;// no overflowing by default
9321
9301
  parsedStyle.isOverflowing=false;var outputText=wordWrap?this.wordWrap(text,parsedStyle,offscreenCanvas):text;var lines=outputText.split(/(?:\r\n|\r|\n)/);var lineWidths=new Array(lines.length);var maxLineWidth=0;// account for textPath
9322
- if(textPath){var totalPathLength=textPath.getTotalLength();var startingPoint=textPath.getPoint(0);for(var i=0;i<lines.length;i++){var width=context.measureText(lines[i]).width+(lines[i].length-1)*letterSpacing;// for (
9302
+ if(textPath){var totalPathLength=textPath.getTotalLength();// const startingPoint = textPath.getPoint(0);
9303
+ for(var i=0;i<lines.length;i++){var width=context.measureText(lines[i]).width+(lines[i].length-1)*letterSpacing;// for (
9323
9304
  // let i = reverse ? lines[0].length - 1 : 0;
9324
9305
  // reverse ? i >= 0 : i < lines[0].length;
9325
9306
  // reverse ? i-- : i++
@@ -9513,7 +9494,8 @@
9513
9494
  // this.unmountChildren(child);
9514
9495
  // });
9515
9496
  if(destroyScenegraph){// destroy Document
9516
- this.document.destroy();}// destroy services
9497
+ this.document.destroy();this.getEventService().destroy();// clear rbush
9498
+ this.context.rBushRoot.clear();this.context.rBushRoot=null;this.context.renderingContext.root=null;}// destroy services
9517
9499
  this.getRenderingService().destroy();this.getContextService().destroy();if(!skipTriggerEvent){this.dispatchEvent(new CustomEvent(exports.CanvasEvent.AFTER_DESTROY));}}/**
9518
9500
  * compatible with G 3.0
9519
9501
  * @deprecated