@antv/g 5.15.9 → 5.15.11

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
@@ -7093,7 +7093,8 @@
7093
7093
  set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
7094
7094
  set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
7095
7095
  set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
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;/**
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';}function isSymbol(value){// @see https://github.com/lodash/lodash/blob/master/isSymbol.js
7097
+ return typeof value==='symbol';}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;/**
7097
7098
  * destroy existed canvas with the same id
7098
7099
  */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;
7099
7100
  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
@@ -8097,7 +8098,7 @@
8097
8098
  */;_proto.contain=function contain(other){return this.contains(other);};_proto.contains=function contains(other){// the node itself, one of its direct children
8098
8099
  var tmp=other;// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/contains
8099
8100
  while(tmp&&this!==tmp){tmp=tmp.parentNode;}return !!tmp;};_proto.getAncestor=function getAncestor(n){// eslint-disable-next-line @typescript-eslint/no-this-alias
8100
- var temp=this;while(n>0&&temp){temp=temp.parentNode;n--;}return temp;};_proto.forEach=function forEach(callback){if(!callback(this)){this.childNodes.forEach(function(child){child.forEach(callback);});}};_createClass(Node,[{key:"textContent",get:/**
8101
+ var temp=this;while(n>0&&temp){temp=temp.parentNode;n--;}return temp;};_proto.forEach=function forEach(callback,assigned){if(assigned===void 0){assigned=false;}if(!callback(this)){(assigned?this.childNodes.slice():this.childNodes).forEach(function(child){child.forEach(callback);});}};_createClass(Node,[{key:"textContent",get:/**
8101
8102
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/textContent
8102
8103
  */function get(){var out='';if(this.nodeName===exports.Shape.TEXT){// @ts-ignore
8103
8104
  out+=this.style.text;}for(var _iterator=_createForOfIteratorHelperLoose(this.childNodes),_step;!(_step=_iterator()).done;){var child=_step.value;if(child.nodeName===exports.Shape.TEXT){out+=child.nodeValue;}else {out+=child.textContent;}}return out;},set:function set(content){var _this2=this;// remove all children
@@ -8119,7 +8120,7 @@
8119
8120
  * @example const circle = document.createElement('circle', { style: { r: 10 } });
8120
8121
  */_proto.createElement=function createElement(tagName,options){// @observablehq/plot will create <svg>
8121
8122
  if(tagName==='svg'){return this.documentElement;}// d3 will use <tspan>
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){}}/**
8123
+ 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.childNodes.slice().forEach(function(child){child.forEach(function(object){object.destroy();},true);});this.timeline.destroy();}catch(e){}}/**
8123
8124
  * Picking 2D graphics with RBush based on BBox, fast but inaccurate.
8124
8125
  */;_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`
8125
8126
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
@@ -8247,7 +8248,8 @@
8247
8248
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames
8248
8249
  */_proto.getAttributeNames=function getAttributeNames(){return Object.keys(this.attributes);}/**
8249
8250
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttribute
8250
- */;_proto.getAttribute=function getAttribute(name){var value=this.attributes[name];if(value===undefined){var attributeName=formatAttributeName(name);value=this.attributes[attributeName];// if the given attribute does not exist, the value returned will either be null or ""
8251
+ */;_proto.getAttribute=function getAttribute(name){// @see https://github.com/antvis/G/issues/1267
8252
+ if(isSymbol(name)){return null;}var value=this.attributes[name];if(value===undefined){var attributeName=formatAttributeName(name);value=this.attributes[attributeName];// if the given attribute does not exist, the value returned will either be null or ""
8251
8253
  return isNil(value)?null:value;}else {return value;}}/**
8252
8254
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/hasAttribute
8253
8255
  */;_proto.hasAttribute=function hasAttribute(qualifiedName){return this.getAttributeNames().includes(qualifiedName);}/**
@@ -9203,18 +9205,18 @@
9203
9205
  */pickSync:new SyncWaterfallHook(['result']),/**
9204
9206
  * used in event system
9205
9207
  */pointerDown:new SyncHook(['event']),pointerUp:new SyncHook(['event']),pointerMove:new SyncHook(['event']),pointerOut:new SyncHook(['event']),pointerOver:new SyncHook(['event']),pointerWheel:new SyncHook(['event']),pointerCancel:new SyncHook(['event'])};this.globalRuntime=globalRuntime;this.context=context;}var _proto=RenderingService.prototype;_proto.init=/*#__PURE__*/function(){var _init=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var context;return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:context=_extends({},this.globalRuntime,this.context);// register rendering plugins
9206
- this.context.renderingPlugins.forEach(function(plugin){plugin.apply(context);});// await this.hooks.init.callPromise();
9208
+ this.context.renderingPlugins.forEach(function(plugin){plugin.apply(context,runtime);});// await this.hooks.init.callPromise();
9207
9209
  _context.next=4;return this.hooks.init.promise();case 4:this.inited=true;case 5:case"end":return _context.stop();}}},_callee,this);}));function init(){return _init.apply(this,arguments);}return init;}();_proto.getStats=function getStats(){return this.stats;}/**
9208
9210
  * Meet the following conditions:
9209
9211
  * * disable DirtyRectangleRendering
9210
9212
  * * camera changed
9211
- */;_proto.disableDirtyRectangleRendering=function disableDirtyRectangleRendering(){var renderer=this.context.config.renderer;var _renderer$getConfig=renderer.getConfig(),enableDirtyRectangleRendering=_renderer$getConfig.enableDirtyRectangleRendering;return !enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has(exports.RenderReason.CAMERA_CHANGED);};_proto.render=function render(canvasConfig){var _this=this;this.stats.total=0;this.stats.rendered=0;this.zIndexCounter=0;var renderingContext=this.context.renderingContext;this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);this.globalRuntime.sceneGraphService.triggerPendingEvents();if(renderingContext.renderReasons.size&&this.inited){this.renderDisplayObject(renderingContext.root,canvasConfig,renderingContext);this.hooks.beginFrame.call();renderingContext.renderListCurrentFrame.forEach(function(object){_this.hooks.beforeRender.call(object);_this.hooks.render.call(object);_this.hooks.afterRender.call(object);});this.hooks.endFrame.call();renderingContext.renderListCurrentFrame=[];renderingContext.renderReasons.clear();}// console.log('stats', this.stats);
9213
+ */;_proto.disableDirtyRectangleRendering=function disableDirtyRectangleRendering(){var renderer=this.context.config.renderer;var _renderer$getConfig=renderer.getConfig(),enableDirtyRectangleRendering=_renderer$getConfig.enableDirtyRectangleRendering;return !enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has(exports.RenderReason.CAMERA_CHANGED);};_proto.render=function render(canvasConfig,rerenderCallback){var _this=this;this.stats.total=0;this.stats.rendered=0;this.zIndexCounter=0;var renderingContext=this.context.renderingContext;this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);this.globalRuntime.sceneGraphService.triggerPendingEvents();if(renderingContext.renderReasons.size&&this.inited){this.renderDisplayObject(renderingContext.root,canvasConfig,renderingContext);this.hooks.beginFrame.call();renderingContext.renderListCurrentFrame.forEach(function(object){_this.hooks.beforeRender.call(object);_this.hooks.render.call(object);_this.hooks.afterRender.call(object);});this.hooks.endFrame.call();renderingContext.renderListCurrentFrame=[];renderingContext.renderReasons.clear();rerenderCallback();}// console.log('stats', this.stats);
9212
9214
  };_proto.renderDisplayObject=function renderDisplayObject(displayObject,canvasConfig,renderingContext){var _this2=this;var _canvasConfig$rendere=canvasConfig.renderer.getConfig(),enableDirtyCheck=_canvasConfig$rendere.enableDirtyCheck,enableCulling=_canvasConfig$rendere.enableCulling;// recalc style values
9213
9215
  this.globalRuntime.styleValueRegistry.recalc(displayObject);// TODO: relayout
9214
9216
  // dirtycheck first
9215
9217
  var objectChanged=enableDirtyCheck?this.hooks.dirtycheck.call(displayObject):displayObject;if(objectChanged){var objectToRender=enableCulling?this.hooks.cull.call(objectChanged,this.context.camera):objectChanged;if(objectToRender){this.stats.rendered++;renderingContext.renderListCurrentFrame.push(objectToRender);}}displayObject.renderable.dirty=false;displayObject.sortable.renderOrder=this.zIndexCounter++;this.stats.total++;// sort is very expensive, use cached result if posible
9216
9218
  var sortable=displayObject.sortable;var renderOrderChanged=false;if(sortable.dirty){sortable.sorted=displayObject.childNodes.slice().sort(sortByZIndex);renderOrderChanged=true;sortable.dirty=false;}// recursive rendering its children
9217
- (sortable.sorted||displayObject.childNodes).forEach(function(child){_this2.renderDisplayObject(child,canvasConfig,renderingContext);});if(renderOrderChanged){displayObject.forEach(function(child){_this2.renderOrderChangedEvent.target=child;_this2.renderOrderChangedEvent.detail={renderOrder:child.sortable.renderOrder};child.ownerDocument.defaultView.dispatchEvent(_this2.renderOrderChangedEvent,true);});}};_proto.destroy=function destroy(){this.inited=false;this.hooks.destroy.call();};_proto.dirtify=function dirtify(){// need re-render
9219
+ (sortable.sorted||displayObject.childNodes).forEach(function(child){_this2.renderDisplayObject(child,canvasConfig,renderingContext);});if(renderOrderChanged){displayObject.forEach(function(child){_this2.renderOrderChangedEvent.target=child;_this2.renderOrderChangedEvent.detail={renderOrder:child.sortable.renderOrder};child.ownerDocument.defaultView.dispatchEvent(_this2.renderOrderChangedEvent,true);});}};_proto.destroy=function destroy(){this.inited=false;this.hooks.destroy.call();this.globalRuntime.sceneGraphService.clearPendingEvents();};_proto.dirtify=function dirtify(){// need re-render
9218
9220
  this.context.renderingContext.renderReasons.add(exports.RenderReason.DISPLAY_OBJECT_CHANGED);};return RenderingService;}();var ATTRIBUTE_REGEXP=/\[\s*(.*)=(.*)\s*\]/;/**
9219
9221
  * support the following DOM API:
9220
9222
  * * getElementById
@@ -9286,7 +9288,7 @@
9286
9288
  *
9287
9289
  * 对应 g 原版的 translate 2D
9288
9290
  * @see https://github.com/antvis/g/blob/master/packages/g-base/src/abstract/element.ts#L665-L676
9289
- */;_proto.setLocalRotation=function setLocalRotation(element,rotation,y,z,w){if(typeof rotation==='number'){rotation=fromValues$4(rotation,y,z,w);}var transform=element.transformable;copy$3(transform.localRotation,rotation);this.dirtifyLocal(element,transform);};_proto.setLocalSkew=function setLocalSkew(element,skew,y){if(typeof skew==='number'){skew=fromValues$5(skew,y);}var transform=element.transformable;copy$4(transform.localSkew,skew);this.dirtifyLocal(element,transform);};_proto.dirtifyLocal=function dirtifyLocal(element,transform){if(!transform.localDirtyFlag){transform.localDirtyFlag=true;if(!transform.dirtyFlag){this.dirtifyWorld(element,transform);}}};_proto.dirtifyWorld=function dirtifyWorld(element,transform){if(!transform.dirtyFlag){this.unfreezeParentToRoot(element);}this.dirtifyWorldInternal(element,transform);this.dirtifyToRoot(element,true);};_proto.triggerPendingEvents=function triggerPendingEvents(){var _this2=this;var set=new Set();var trigger=function trigger(element,detail){if(element.isConnected&&!set.has(element.entity)){_this2.boundsChangedEvent.detail=detail;_this2.boundsChangedEvent.target=element;element.ownerDocument.defaultView.dispatchEvent(_this2.boundsChangedEvent,true);set.add(element.entity);}};this.pendingEvents.forEach(function(_ref){var element=_ref[0],detail=_ref[1];if(detail.affectChildren){element.forEach(function(e){trigger(e,detail);});}else {trigger(element,detail);}});this.pendingEvents=[];set.clear();};_proto.dirtifyToRoot=function dirtifyToRoot(element,affectChildren){if(affectChildren===void 0){affectChildren=false;}var p=element;// only need to re-render itself
9291
+ */;_proto.setLocalRotation=function setLocalRotation(element,rotation,y,z,w){if(typeof rotation==='number'){rotation=fromValues$4(rotation,y,z,w);}var transform=element.transformable;copy$3(transform.localRotation,rotation);this.dirtifyLocal(element,transform);};_proto.setLocalSkew=function setLocalSkew(element,skew,y){if(typeof skew==='number'){skew=fromValues$5(skew,y);}var transform=element.transformable;copy$4(transform.localSkew,skew);this.dirtifyLocal(element,transform);};_proto.dirtifyLocal=function dirtifyLocal(element,transform){if(!transform.localDirtyFlag){transform.localDirtyFlag=true;if(!transform.dirtyFlag){this.dirtifyWorld(element,transform);}}};_proto.dirtifyWorld=function dirtifyWorld(element,transform){if(!transform.dirtyFlag){this.unfreezeParentToRoot(element);}this.dirtifyWorldInternal(element,transform);this.dirtifyToRoot(element,true);};_proto.triggerPendingEvents=function triggerPendingEvents(){var _this2=this;var set=new Set();var trigger=function trigger(element,detail){if(element.isConnected&&!set.has(element.entity)){_this2.boundsChangedEvent.detail=detail;_this2.boundsChangedEvent.target=element;element.ownerDocument.defaultView.dispatchEvent(_this2.boundsChangedEvent,true);set.add(element.entity);}};this.pendingEvents.forEach(function(_ref){var element=_ref[0],detail=_ref[1];if(detail.affectChildren){element.forEach(function(e){trigger(e,detail);});}else {trigger(element,detail);}});this.clearPendingEvents();set.clear();};_proto.clearPendingEvents=function clearPendingEvents(){this.pendingEvents=[];};_proto.dirtifyToRoot=function dirtifyToRoot(element,affectChildren){if(affectChildren===void 0){affectChildren=false;}var p=element;// only need to re-render itself
9290
9292
  if(p.renderable){p.renderable.dirty=true;}while(p){markRenderableDirty(p);p=p.parentNode;}if(affectChildren){element.forEach(function(e){markRenderableDirty(e);});}// inform dependencies
9291
9293
  this.informDependentDisplayObjects(element);// reuse the same custom event
9292
9294
  this.pendingEvents.push([element,{affectChildren:affectChildren}]);};_proto.updateDisplayObjectDependency=function updateDisplayObjectDependency(name,oldPath,newPath,object){// clear ref to old clip path
@@ -9455,9 +9457,9 @@
9455
9457
  rBushNode.aabb={};}rBushNode.aabb.id=node.entity;rBushNode.aabb.minX=minX;rBushNode.aabb.minY=minY;rBushNode.aabb.maxX=maxX;rBushNode.aabb.maxY=maxY;}if(rBushNode.aabb){// TODO: NaN occurs when width/height of Rect is 0
9456
9458
  if(!isNaN(rBushNode.aabb.maxX)&&!isNaN(rBushNode.aabb.maxX)&&!isNaN(rBushNode.aabb.minX)&&!isNaN(rBushNode.aabb.minY)){bulk.push(rBushNode.aabb);}}});// use bulk inserting, which is ~2-3 times faster
9457
9459
  // @see https://github.com/mourner/rbush#bulk-inserting-data
9458
- this.rBush.load(bulk);bulk.length=0;this.toSync.clear();};return PrepareRendererPlugin;}();PrepareRendererPlugin.tag='Prepare';function isCanvas(value){return !!value.document;}(function(CanvasEvent){CanvasEvent["READY"]="ready";CanvasEvent["BEFORE_RENDER"]="beforerender";CanvasEvent["AFTER_RENDER"]="afterrender";CanvasEvent["BEFORE_DESTROY"]="beforedestroy";CanvasEvent["AFTER_DESTROY"]="afterdestroy";CanvasEvent["RESIZE"]="resize";CanvasEvent["DIRTY_RECTANGLE"]="dirtyrectangle";})(exports.CanvasEvent||(exports.CanvasEvent={}));var DEFAULT_CAMERA_Z=500;var DEFAULT_CAMERA_NEAR=0.1;var DEFAULT_CAMERA_FAR=1000;/**
9460
+ this.rBush.load(bulk);bulk.length=0;this.toSync.clear();};return PrepareRendererPlugin;}();PrepareRendererPlugin.tag='Prepare';function isCanvas(value){return !!value.document;}(function(CanvasEvent){CanvasEvent["READY"]="ready";CanvasEvent["BEFORE_RENDER"]="beforerender";CanvasEvent["RERENDER"]="rerender";CanvasEvent["AFTER_RENDER"]="afterrender";CanvasEvent["BEFORE_DESTROY"]="beforedestroy";CanvasEvent["AFTER_DESTROY"]="afterdestroy";CanvasEvent["RESIZE"]="resize";CanvasEvent["DIRTY_RECTANGLE"]="dirtyrectangle";})(exports.CanvasEvent||(exports.CanvasEvent={}));var DEFAULT_CAMERA_Z=500;var DEFAULT_CAMERA_NEAR=0.1;var DEFAULT_CAMERA_FAR=1000;/**
9459
9461
  * reuse custom event preventing from re-create them in every frame
9460
- */var mountedEvent=new CustomEvent(exports.ElementEvent.MOUNTED);var unmountedEvent=new CustomEvent(exports.ElementEvent.UNMOUNTED);var beforeRenderEvent=new CustomEvent(exports.CanvasEvent.BEFORE_RENDER);var afterRenderEvent=new CustomEvent(exports.CanvasEvent.AFTER_RENDER);/**
9462
+ */var mountedEvent=new CustomEvent(exports.ElementEvent.MOUNTED);var unmountedEvent=new CustomEvent(exports.ElementEvent.UNMOUNTED);var beforeRenderEvent=new CustomEvent(exports.CanvasEvent.BEFORE_RENDER);var rerenderEvent=new CustomEvent(exports.CanvasEvent.RERENDER);var afterRenderEvent=new CustomEvent(exports.CanvasEvent.AFTER_RENDER);/**
9461
9463
  * can be treated like Window in DOM
9462
9464
  * provide some extra methods like `window`, such as:
9463
9465
  * * `window.requestAnimationFrame`
@@ -9536,7 +9538,9 @@
9536
9538
  * Remove all children which can be appended to its original parent later again.
9537
9539
  */;_proto.removeChildren=function removeChildren(){this.document.documentElement.removeChildren();}/**
9538
9540
  * Recursively destroy all children which can not be appended to its original parent later again.
9539
- */;_proto.destroyChildren=function destroyChildren(){this.document.documentElement.destroyChildren();};_proto.render=function render(){this.dispatchEvent(beforeRenderEvent);var renderingService=this.getRenderingService();renderingService.render(this.getConfig());this.dispatchEvent(afterRenderEvent);};_proto.run=function run(){var _this3=this;var tick=function tick(){_this3.render();_this3.frameId=requestAnimationFrame(tick);};tick();};_proto.initRenderer=/*#__PURE__*/function(){var _initRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderer){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(renderer){_context2.next=2;break;}throw new Error('Renderer is required.');case 2:// reset
9541
+ */;_proto.destroyChildren=function destroyChildren(){this.document.documentElement.destroyChildren();};_proto.render=function render(){var _this3=this;this.dispatchEvent(beforeRenderEvent);var renderingService=this.getRenderingService();renderingService.render(this.getConfig(),function(){// trigger actual rerender event
9542
+ // @see https://github.com/antvis/G/issues/1268
9543
+ _this3.dispatchEvent(rerenderEvent);});this.dispatchEvent(afterRenderEvent);};_proto.run=function run(){var _this4=this;var tick=function tick(){_this4.render();_this4.frameId=requestAnimationFrame(tick);};tick();};_proto.initRenderer=/*#__PURE__*/function(){var _initRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderer){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(renderer){_context2.next=2;break;}throw new Error('Renderer is required.');case 2:// reset
9540
9544
  this.inited=false;this.readyPromise=undefined;// FIXME: should re-create here?
9541
9545
  this.context.rBushRoot=new rbush();// reset rendering plugins
9542
9546
  this.context.renderingPlugins=[];this.context.renderingPlugins.push(new EventPlugin(),new PrepareRendererPlugin(),new DirtyCheckPlugin(),new CullingPlugin([new FrustumCullingStrategy()]));//
@@ -9544,22 +9548,22 @@
9544
9548
  this.context.contextService=new this.context.ContextService(_extends({},runtime,this.context));// init rendering service
9545
9549
  this.context.renderingService=new RenderingService(runtime,this.context);// init event service
9546
9550
  this.context.eventService=new EventService(runtime,this.context);this.context.eventService.init();_context2.next=14;return this.context.contextService.init();case 14:_context2.next=16;return this.context.renderingService.init();case 16:this.inited=true;this.getRoot().forEach(function(node){var renderable=node.renderable;if(renderable){renderable.renderBoundsDirty=true;renderable.boundsDirty=true;renderable.dirty=true;}});// keep current scenegraph unchanged, just trigger mounted event
9547
- this.mountChildren(this.getRoot());if(renderer.getConfig().enableAutoRendering){this.run();}case 20:case"end":return _context2.stop();}}},_callee2,this);}));function initRenderer(_x){return _initRenderer.apply(this,arguments);}return initRenderer;}();_proto.loadRendererContainerModule=function loadRendererContainerModule(renderer){var _this4=this;// load other container modules provided by g-canvas/g-svg/g-webgl
9548
- var plugins=renderer.getPlugins();plugins.forEach(function(plugin){plugin.context=_this4.context;plugin.init();});};_proto.setRenderer=/*#__PURE__*/function(){var _setRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(renderer){var canvasConfig,oldRenderer;return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:// update canvas' config
9551
+ this.mountChildren(this.getRoot());if(renderer.getConfig().enableAutoRendering){this.run();}case 20:case"end":return _context2.stop();}}},_callee2,this);}));function initRenderer(_x){return _initRenderer.apply(this,arguments);}return initRenderer;}();_proto.loadRendererContainerModule=function loadRendererContainerModule(renderer){var _this5=this;// load other container modules provided by g-canvas/g-svg/g-webgl
9552
+ var plugins=renderer.getPlugins();plugins.forEach(function(plugin){plugin.context=_this5.context;plugin.init(runtime);});};_proto.setRenderer=/*#__PURE__*/function(){var _setRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(renderer){var canvasConfig,oldRenderer;return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:// update canvas' config
9549
9553
  canvasConfig=this.getConfig();if(!(canvasConfig.renderer===renderer)){_context3.next=3;break;}return _context3.abrupt("return");case 3:oldRenderer=canvasConfig.renderer;canvasConfig.renderer=renderer;// keep all children undestroyed
9550
9554
  this.destroy(false,true);// destroy all plugins, reverse will mutate origin array
9551
- [].concat(oldRenderer===null||oldRenderer===void 0?void 0:oldRenderer.getPlugins()).reverse().forEach(function(plugin){plugin.destroy();});_context3.next=9;return this.initRenderer(renderer);case 9:case"end":return _context3.stop();}}},_callee3,this);}));function setRenderer(_x2){return _setRenderer.apply(this,arguments);}return setRenderer;}();_proto.setCursor=function setCursor(cursor){var canvasConfig=this.getConfig();canvasConfig.cursor=cursor;this.getContextService().applyCursorStyle(cursor);};_proto.unmountChildren=function unmountChildren(parent){var _this5=this;// unmountChildren recursively
9552
- parent.childNodes.forEach(function(child){_this5.unmountChildren(child);});if(this.inited){if(parent.isMutationObserved){parent.dispatchEvent(unmountedEvent);}else {unmountedEvent.target=parent;this.dispatchEvent(unmountedEvent,true);}// skip document.documentElement
9555
+ [].concat(oldRenderer===null||oldRenderer===void 0?void 0:oldRenderer.getPlugins()).reverse().forEach(function(plugin){plugin.destroy(runtime);});_context3.next=9;return this.initRenderer(renderer);case 9:case"end":return _context3.stop();}}},_callee3,this);}));function setRenderer(_x2){return _setRenderer.apply(this,arguments);}return setRenderer;}();_proto.setCursor=function setCursor(cursor){var canvasConfig=this.getConfig();canvasConfig.cursor=cursor;this.getContextService().applyCursorStyle(cursor);};_proto.unmountChildren=function unmountChildren(parent){var _this6=this;// unmountChildren recursively
9556
+ parent.childNodes.forEach(function(child){_this6.unmountChildren(child);});if(this.inited){if(parent.isMutationObserved){parent.dispatchEvent(unmountedEvent);}else {unmountedEvent.target=parent;this.dispatchEvent(unmountedEvent,true);}// skip document.documentElement
9553
9557
  if(parent!==this.document.documentElement){parent.ownerDocument=null;}parent.isConnected=false;}// trigger after unmounted
9554
- if(parent.isCustomElement){if(parent.disconnectedCallback){parent.disconnectedCallback();}}};_proto.mountChildren=function mountChildren(parent){var _this6=this;if(this.inited){if(!parent.isConnected){parent.ownerDocument=this.document;parent.isConnected=true;if(parent.isMutationObserved){parent.dispatchEvent(mountedEvent);}else {mountedEvent.target=parent;this.dispatchEvent(mountedEvent,true);}}}else {console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.",'appended child: ',parent.nodeName);}// recursively mount children
9555
- parent.childNodes.forEach(function(child){_this6.mountChildren(child);});// trigger after mounted
9558
+ if(parent.isCustomElement){if(parent.disconnectedCallback){parent.disconnectedCallback();}}};_proto.mountChildren=function mountChildren(parent){var _this7=this;if(this.inited){if(!parent.isConnected){parent.ownerDocument=this.document;parent.isConnected=true;if(parent.isMutationObserved){parent.dispatchEvent(mountedEvent);}else {mountedEvent.target=parent;this.dispatchEvent(mountedEvent,true);}}}else {console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.",'appended child: ',parent.nodeName);}// recursively mount children
9559
+ parent.childNodes.forEach(function(child){_this7.mountChildren(child);});// trigger after mounted
9556
9560
  if(parent.isCustomElement){if(parent.connectedCallback){parent.connectedCallback();}}};_proto.client2Viewport=function client2Viewport(client){return this.getEventService().client2Viewport(client);};_proto.viewport2Client=function viewport2Client(canvas){return this.getEventService().viewport2Client(canvas);};_proto.viewport2Canvas=function viewport2Canvas(viewport){return this.getEventService().viewport2Canvas(viewport);};_proto.canvas2Viewport=function canvas2Viewport(canvas){return this.getEventService().canvas2Viewport(canvas);}/**
9557
9561
  * @deprecated
9558
9562
  * @alias client2Viewport
9559
9563
  */;_proto.getPointByClient=function getPointByClient(clientX,clientY){return this.client2Viewport({x:clientX,y:clientY});}/**
9560
9564
  * @deprecated
9561
9565
  * @alias viewport2Client
9562
- */;_proto.getClientByPoint=function getClientByPoint(x,y){return this.viewport2Client({x:x,y:y});};_createClass(Canvas,[{key:"ready",get:function get(){var _this7=this;if(!this.readyPromise){this.readyPromise=new Promise(function(resolve){_this7.resolveReadyPromise=function(){resolve(_this7);};});if(this.inited){this.resolveReadyPromise();}}return this.readyPromise;}}]);return Canvas;}(EventTarget);
9566
+ */;_proto.getClientByPoint=function getClientByPoint(x,y){return this.viewport2Client({x:x,y:y});};_createClass(Canvas,[{key:"ready",get:function get(){var _this8=this;if(!this.readyPromise){this.readyPromise=new Promise(function(resolve){_this8.resolveReadyPromise=function(){resolve(_this8);};});if(this.inited){this.resolveReadyPromise();}}return this.readyPromise;}}]);return Canvas;}(EventTarget);
9563
9567
 
9564
9568
  function _inheritsLoose$1(subClass, superClass) {
9565
9569
  subClass.prototype = Object.create(superClass.prototype);