@antv/g 5.15.3 → 5.15.4

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;
@@ -7130,7 +7093,7 @@
7130
7093
  set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
7131
7094
  set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
7132
7095
  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;/**
7096
+ 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
7097
  * destroy existed canvas with the same id
7135
7098
  */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
7099
  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 +8046,15 @@
8083
8046
  */_proto.on=function on(type,listener,options){this.addEventListener(type,listener,options);return this;}/**
8084
8047
  * support `capture` & `once` in options
8085
8048
  * @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
8049
+ */;_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
8050
  // 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
8051
+ 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
8052
  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
8053
  originListener.apply(void 0,args);};}if(once){this.emitter.once(type,listener,context);}else {this.emitter.on(type,listener,context);}return this;}/**
8091
8054
  * @deprecated
8092
8055
  * @alias removeEventListener
8093
8056
  */;_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;}/**
8057
+ 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
8058
  * @deprecated
8096
8059
  * @alias dispatchEvent
8097
8060
  */ // eslint-disable-next-line @typescript-eslint/ban-types
@@ -8151,12 +8114,12 @@
8151
8114
  * for inherited properties, the initial value is used on the root element only,
8152
8115
  * as long as no specified value is supplied.
8153
8116
  * @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
8117
+ */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
8118
  _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
8119
  * @example const circle = document.createElement('circle', { style: { r: 10 } });
8157
8120
  */_proto.createElement=function createElement(tagName,options){// @observablehq/plot will create <svg>
8158
8121
  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){}}/**
8122
+ 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
8123
  * Picking 2D graphics with RBush based on BBox, fast but inaccurate.
8161
8124
  */;_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
8125
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
@@ -8360,7 +8323,7 @@
8360
8323
  return target[name];}return _this.getAttribute(name);},set:function set(_,prop,value){_this.setAttribute(prop,value);return true;}});// insert this group into pool
8361
8324
  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
8325
  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
8326
+ 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
8327
  if(attribute instanceof DisplayObject&&// share the same clipPath if possible
8365
8328
  attributeName!=='clipPath'&&attributeName!=='offsetPath'&&attributeName!=='textPath'){clonedStyle[attributeName]=attribute.cloneNode(deep);}// TODO: clone other type
8366
8329
  if(customCloneFunc){clonedStyle[attributeName]=customCloneFunc(attributeName,attribute);}}var cloned=new this.constructor({// copy id & name
@@ -8368,8 +8331,12 @@
8368
8331
  id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:clonedStyle});// apply transform
8369
8332
  cloned.setLocalTransform(this.getLocalTransform());if(deep){this.children.forEach(function(child){// skip marker
8370
8333
  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
8334
+ runtime.styleValueRegistry.processProperties(this,attributes,{forceUpdateGeometry:true,usedAttributes:INHERITABLE_STYLE_PROPS// usedAttributes:
8335
+ // // only Group / Text should account for text relative props
8336
+ // this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
8337
+ // ? INHERITABLE_STYLE_PROPS
8338
+ // : INHERITABLE_BASE_STYLE_PROPS,
8339
+ });// redraw at next frame
8373
8340
  renderable.dirty=true;};_proto.setAttribute=function setAttribute(name,value,force){if(force===void 0){force=false;}var attributeName=formatAttributeName(name);// ignore undefined value
8374
8341
  if(isUndefined(value)){return;}if(force||value!==this.attributes[attributeName]){this.internalSetAttribute(attributeName,value);_Element.prototype.setAttribute.call(this,attributeName,value);}}/**
8375
8342
  * called when attributes get changed or initialized
@@ -8911,10 +8878,11 @@
8911
8878
  // n: 'whiteSpace',
8912
8879
  // l: true,
8913
8880
  // },
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(){/**
8881
+ {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>();
8882
+ 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
8883
  * need recalc later
8916
8884
  */ // 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];}/**
8885
+ 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
8886
  * * parse value, eg.
8919
8887
  * fill: 'red' => CSSRGB
8920
8888
  * translateX: '10px' => CSSUnitValue { unit: 'px', value: 10 }
@@ -8924,8 +8892,15 @@
8924
8892
  * * post process
8925
8893
  */;_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
8894
  // 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
8895
+ // path 50
8896
+ // points 50
8897
+ // text 50
8898
+ // textTransform 51
8899
+ // anchor 99
8900
+ // transform 100
8901
+ // transformOrigin 100
8902
+ if(usedAttributes===null||usedAttributes===void 0?void 0:usedAttributes.length){// uniqueAttributeSet.clear();
8903
+ 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
8904
  if(name in object.computedStyle){object.parsedStyle[name]=_this2.computeProperty(name,object.computedStyle[name],object);}});// if (hasUnresolvedProperties) {
8930
8905
  // this.dirty = true;
8931
8906
  // return;
@@ -8944,7 +8919,7 @@
8944
8919
  var used=computed;if(metadata){var syntax=metadata.syntax,inherited=metadata.inh,defaultValue=metadata.d;if(computed instanceof CSSKeywordValue){var value=computed.value;/**
8945
8920
  * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/unset
8946
8921
  */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
8922
+ 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
8923
  // behave like `inherit`
8949
8924
  var resolved=this.tryToResolveProperty(object,name,{inherited:true});if(!isNil(resolved)){// object.parsedStyle[name] = resolved;
8950
8925
  // return false;
@@ -9120,7 +9095,7 @@
9120
9095
  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
9096
  // @see https://developer.mozilla.org/en-US/docs/Web/API/Element/mouseenter_event#usage_notes
9122
9097
  _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
9098
+ 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
9099
  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
9100
  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
9101
  if(!skipPropagate){e.propagationStopped=false;e.propagationImmediatelyStopped=false;this.propagate(e,type);}else {// target phase
@@ -9319,7 +9294,8 @@
9319
9294
  // (toDataURI, getImageData functions)
9320
9295
  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
9296
  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 (
9297
+ if(textPath){var totalPathLength=textPath.getTotalLength();// const startingPoint = textPath.getPoint(0);
9298
+ for(var i=0;i<lines.length;i++){var width=context.measureText(lines[i]).width+(lines[i].length-1)*letterSpacing;// for (
9323
9299
  // let i = reverse ? lines[0].length - 1 : 0;
9324
9300
  // reverse ? i >= 0 : i < lines[0].length;
9325
9301
  // reverse ? i-- : i++
@@ -9513,7 +9489,8 @@
9513
9489
  // this.unmountChildren(child);
9514
9490
  // });
9515
9491
  if(destroyScenegraph){// destroy Document
9516
- this.document.destroy();}// destroy services
9492
+ this.document.destroy();this.getEventService().destroy();// clear rbush
9493
+ this.context.rBushRoot.clear();this.context.rBushRoot=null;this.context.renderingContext.root=null;}// destroy services
9517
9494
  this.getRenderingService().destroy();this.getContextService().destroy();if(!skipTriggerEvent){this.dispatchEvent(new CustomEvent(exports.CanvasEvent.AFTER_DESTROY));}}/**
9518
9495
  * compatible with G 3.0
9519
9496
  * @deprecated