@antv/g 5.16.31 → 5.16.33

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
@@ -7691,7 +7691,7 @@
7691
7691
  if(useStartOffset){return "M "+(params[1]-defX+startOffsetX)+","+(params[2]-defY+startOffsetY)+" L "+(params[1]-defX)+","+(params[2]-defY);}else {return "M "+(params[1]-defX)+","+(params[2]-defY);}case'L':return "L "+(params[1]-defX+(useEndOffset?endOffsetX:0))+","+(params[2]-defY+(useEndOffset?endOffsetY:0));case'Q':return "Q "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+(useEndOffset?" L "+(params[3]-defX+endOffsetX)+","+(params[4]-defY+endOffsetY):'');case'C':return "C "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+","+(params[5]-defX)+" "+(params[6]-defY)+(useEndOffset?" L "+(params[5]-defX+endOffsetX)+","+(params[6]-defY+endOffsetY):'');case'A':return "A "+params[1]+" "+params[2]+" "+params[3]+" "+params[4]+" "+params[5]+" "+(params[6]-defX)+" "+(params[7]-defY)+(useEndOffset?" L "+(params[6]-defX+endOffsetX)+","+(params[7]-defY+endOffsetY):'');case'Z':return 'Z';}}).join(' ');if(~newValue.indexOf('NaN')){return '';}return newValue;}function isFillOrStrokeAffected(pointerEvents,fill,stroke){// account for pointerEvents
7692
7692
  // @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
7693
7693
  var hasFill=false;var hasStroke=false;var isFillOtherThanNone=!!fill&&!fill.isNone;var isStrokeOtherThanNone=!!stroke&&!stroke.isNone;if(pointerEvents==='visiblepainted'||pointerEvents==='painted'||pointerEvents==='auto'){hasFill=isFillOtherThanNone;hasStroke=isStrokeOtherThanNone;}else if(pointerEvents==='visiblefill'||pointerEvents==='fill'){hasFill=true;}else if(pointerEvents==='visiblestroke'||pointerEvents==='stroke'){hasStroke=true;}else if(pointerEvents==='visible'||pointerEvents==='all'){// The values of the fill and stroke do not affect event processing.
7694
- hasFill=true;hasStroke=true;}return [hasFill,hasStroke];}var AsyncParallelHook=/*#__PURE__*/function(){function AsyncParallelHook(){this.callbacks=[];}var _proto=AsyncParallelHook.prototype;_proto.tapPromise=function tapPromise(options,fn){this.callbacks.push(fn);};_proto.promise=function promise(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}return Promise.all(this.callbacks.map(function(callback){return callback.apply(void 0,args);}));};return AsyncParallelHook;}();var AsyncSeriesWaterfallHook=/*#__PURE__*/function(){function AsyncSeriesWaterfallHook(){this.callbacks=[];}var _proto=AsyncSeriesWaterfallHook.prototype;_proto.tapPromise=function tapPromise(options,fn){this.callbacks.push(fn);};_proto.promise=/*#__PURE__*/function(){var _promise=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var _this$callbacks,result,i,callback,_args=arguments;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!this.callbacks.length){_context.next=14;break;}_context.next=3;return (_this$callbacks=this.callbacks)[0].apply(_this$callbacks,_args);case 3:result=_context.sent;i=0;case 5:if(!(i<this.callbacks.length-1)){_context.next=13;break;}callback=this.callbacks[i];// @ts-ignore
7694
+ hasFill=true;hasStroke=true;}return [hasFill,hasStroke];}var AsyncParallelHook=/*#__PURE__*/function(){function AsyncParallelHook(){this.callbacks=[];}var _proto=AsyncParallelHook.prototype;_proto.getCallbacksNum=function getCallbacksNum(){return this.callbacks.length;};_proto.tapPromise=function tapPromise(options,fn){this.callbacks.push(fn);};_proto.promise=function promise(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}return Promise.all(this.callbacks.map(function(callback){return callback.apply(void 0,args);}));};return AsyncParallelHook;}();var AsyncSeriesWaterfallHook=/*#__PURE__*/function(){function AsyncSeriesWaterfallHook(){this.callbacks=[];}var _proto=AsyncSeriesWaterfallHook.prototype;_proto.tapPromise=function tapPromise(options,fn){this.callbacks.push(fn);};_proto.promise=/*#__PURE__*/function(){var _promise=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){var _this$callbacks,result,i,callback,_args=arguments;return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:if(!this.callbacks.length){_context.next=14;break;}_context.next=3;return (_this$callbacks=this.callbacks)[0].apply(_this$callbacks,_args);case 3:result=_context.sent;i=0;case 5:if(!(i<this.callbacks.length-1)){_context.next=13;break;}callback=this.callbacks[i];// @ts-ignore
7695
7695
  _context.next=9;return callback(result);case 9:result=_context.sent;case 10:i++;_context.next=5;break;case 13:return _context.abrupt("return",result);case 14:return _context.abrupt("return",null);case 15:case"end":return _context.stop();}},_callee,this);}));function promise(){return _promise.apply(this,arguments);}return promise;}();return AsyncSeriesWaterfallHook;}();var SyncHook=/*#__PURE__*/function(){function SyncHook(){this.callbacks=[];}var _proto=SyncHook.prototype;_proto.tap=function tap(options,fn){this.callbacks.push(fn);};_proto.call=function call(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}this.callbacks.forEach(function(callback){callback.apply(void 0,args);});};return SyncHook;}();var SyncWaterfallHook=/*#__PURE__*/function(){function SyncWaterfallHook(){this.callbacks=[];}var _proto=SyncWaterfallHook.prototype;_proto.tap=function tap(options,fn){this.callbacks.push(fn);};_proto.call=function call(){if(this.callbacks.length){var _this$callbacks;var result=(_this$callbacks=this.callbacks)[0].apply(_this$callbacks,arguments);for(var i=0;i<this.callbacks.length-1;i++){var callback=this.callbacks[i];// @ts-ignore
7696
7696
  result=callback(result);}return result;}return null;};return SyncWaterfallHook;}();var genericFontFamilies=['serif','sans-serif','monospace','cursive','fantasy','system-ui'];var stringRegExp=/([\"\'])[^\'\"]+\1/;function toFontString(attributes){var fontSize=attributes.fontSize,fontFamily=attributes.fontFamily,fontStyle=attributes.fontStyle,fontVariant=attributes.fontVariant,fontWeight=attributes.fontWeight;// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
7697
7697
  // const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
@@ -9255,7 +9255,7 @@
9255
9255
  * number of display objects need to render in current frame
9256
9256
  */rendered:0};this.zIndexCounter=0;this.hooks={/**
9257
9257
  * called before any frame rendered
9258
- */init:new AsyncParallelHook(),/**
9258
+ */init:new SyncHook(),initAsync:new AsyncParallelHook(),/**
9259
9259
  * only dirty object which has sth changed will be rendered
9260
9260
  */dirtycheck:new SyncWaterfallHook(),/**
9261
9261
  * do culling
@@ -9273,19 +9273,18 @@
9273
9273
  * Unsafe but sync version of pick.
9274
9274
  */pickSync:new SyncWaterfallHook(),/**
9275
9275
  * used in event system
9276
- */pointerDown:new SyncHook(),pointerUp:new SyncHook(),pointerMove:new SyncHook(),pointerOut:new SyncHook(),pointerOver:new SyncHook(),pointerWheel:new SyncHook(),pointerCancel:new SyncHook(),click:new SyncHook()};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
9277
- this.context.renderingPlugins.forEach(function(plugin){plugin.apply(context,runtime);});// await this.hooks.init.callPromise();
9278
- _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;}/**
9276
+ */pointerDown:new SyncHook(),pointerUp:new SyncHook(),pointerMove:new SyncHook(),pointerOut:new SyncHook(),pointerOver:new SyncHook(),pointerWheel:new SyncHook(),pointerCancel:new SyncHook(),click:new SyncHook()};this.globalRuntime=globalRuntime;this.context=context;}var _proto=RenderingService.prototype;_proto.init=function init(callback){var _this=this;var context=_extends({},this.globalRuntime,this.context);// register rendering plugins
9277
+ this.context.renderingPlugins.forEach(function(plugin){plugin.apply(context,runtime);});this.hooks.init.call();if(this.hooks.initAsync.getCallbacksNum()===0){this.inited=true;callback();}else {this.hooks.initAsync.promise().then(function(){_this.inited=true;callback();});}};_proto.getStats=function getStats(){return this.stats;}/**
9279
9278
  * Meet the following conditions:
9280
9279
  * * disable DirtyRectangleRendering
9281
9280
  * * camera changed
9282
- */;_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);
9283
- };_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
9281
+ */;_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 _this2=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){_this2.hooks.beforeRender.call(object);_this2.hooks.render.call(object);_this2.hooks.afterRender.call(object);});this.hooks.endFrame.call();renderingContext.renderListCurrentFrame=[];renderingContext.renderReasons.clear();rerenderCallback();}// console.log('stats', this.stats);
9282
+ };_proto.renderDisplayObject=function renderDisplayObject(displayObject,canvasConfig,renderingContext){var _this3=this;var _canvasConfig$rendere=canvasConfig.renderer.getConfig(),enableDirtyCheck=_canvasConfig$rendere.enableDirtyCheck,enableCulling=_canvasConfig$rendere.enableCulling;// recalc style values
9284
9283
  if(this.globalRuntime.enableCSSParsing){this.globalRuntime.styleValueRegistry.recalc(displayObject);}// TODO: relayout
9285
9284
  // dirtycheck first
9286
9285
  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 possible
9287
9286
  var sortable=displayObject.sortable;if(sortable.dirty){this.sort(displayObject,sortable);sortable.dirty=false;sortable.dirtyChildren=[];sortable.dirtyReason=undefined;}// recursive rendering its children
9288
- (sortable.sorted||displayObject.childNodes).forEach(function(child){_this2.renderDisplayObject(child,canvasConfig,renderingContext);});};_proto.sort=function sort(displayObject,sortable){if(sortable.sorted&&sortable.dirtyReason!==exports.SortReason.Z_INDEX_CHANGED){// avoid re-sorting the whole children list
9287
+ (sortable.sorted||displayObject.childNodes).forEach(function(child){_this3.renderDisplayObject(child,canvasConfig,renderingContext);});};_proto.sort=function sort(displayObject,sortable){if(sortable.sorted&&sortable.dirtyReason!==exports.SortReason.Z_INDEX_CHANGED){// avoid re-sorting the whole children list
9289
9288
  sortable.dirtyChildren.forEach(function(child){var index=displayObject.childNodes.indexOf(child);if(index===-1){// remove from sorted list
9290
9289
  var _index=sortable.sorted.indexOf(child);if(_index>=0){sortable.sorted.splice(_index,1);}}else {if(sortable.sorted.length===0){sortable.sorted.push(child);}else {var _index2=sortedIndex(sortable.sorted,child);sortable.sorted.splice(_index2,0,child);}}});}else {sortable.sorted=displayObject.childNodes.slice().sort(sortByZIndex);}};_proto.destroy=function destroy(){this.inited=false;this.hooks.destroy.call();this.globalRuntime.sceneGraphService.clearPendingEvents();};_proto.dirtify=function dirtify(){// need re-render
9291
9290
  this.context.renderingContext.renderReasons.add(exports.RenderReason.DISPLAY_OBJECT_CHANGED);};return RenderingService;}();var ATTRIBUTE_REGEXP=/\[\s*(.*)=(.*)\s*\]/;/**
@@ -9403,7 +9402,7 @@
9403
9402
  if(regexCannotEnd.exec(nextChar)||regexCannotStart.exec(char)){return true;}}return false;};this.trimByKinsokuShorui=function(prev){var next=[].concat(prev);var prevLine=next[next.length-2];if(!prevLine){return prev;}var lastChar=prevLine[prevLine.length-1];next[next.length-2]=prevLine.slice(0,-1);next[next.length-1]=lastChar+next[next.length-1];return next;};this.runtime=runtime;}var _proto=TextService.prototype;/**
9404
9403
  * Calculates the ascent, descent and fontSize of a given font-style.
9405
9404
  */_proto.measureFont=function measureFont(font,offscreenCanvas){// as this method is used for preparing assets, don't recalculate things if we don't need to
9406
- if(this.fontMetricsCache[font]){return this.fontMetricsCache[font];}var properties={ascent:0,descent:0,fontSize:0};var canvas=this.runtime.offscreenCanvas.getOrCreateCanvas(offscreenCanvas);var context=this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);context.font=font;var metricsString=TEXT_METRICS.MetricsString+TEXT_METRICS.BaselineSymbol;var width=Math.ceil(context.measureText(metricsString).width);var baseline=Math.ceil(context.measureText(TEXT_METRICS.BaselineSymbol).width);var height=TEXT_METRICS.HeightMultiplier*baseline;baseline=baseline*TEXT_METRICS.BaselineMultiplier|0;// @ts-ignore
9405
+ if(this.fontMetricsCache[font]){return this.fontMetricsCache[font];}var properties={ascent:0,descent:0,fontSize:0};var canvas=this.runtime.offscreenCanvas.getOrCreateCanvas(offscreenCanvas);var context=this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas,{willReadFrequently:true});context.font=font;var metricsString=TEXT_METRICS.MetricsString+TEXT_METRICS.BaselineSymbol;var width=Math.ceil(context.measureText(metricsString).width);var baseline=Math.ceil(context.measureText(TEXT_METRICS.BaselineSymbol).width);var height=TEXT_METRICS.HeightMultiplier*baseline;baseline=baseline*TEXT_METRICS.BaselineMultiplier|0;// @ts-ignore
9407
9406
  canvas.width=width;// @ts-ignore
9408
9407
  canvas.height=height;context.fillStyle='#f00';context.fillRect(0,0,width,height);context.font=font;context.textBaseline='alphabetic';context.fillStyle='#000';context.fillText(metricsString,0,baseline);var imagedata=context.getImageData(0,0,width||1,height||1).data;var pixels=imagedata.length;var line=width*4;var i=0;var idx=0;var stop=false;// ascent. scan from top to bottom until we find a non red pixel
9409
9408
  for(i=0;i<baseline;++i){for(var j=0;j<line;j+=4){if(imagedata[idx+j]!==255){stop=true;break;}}if(!stop){idx+=line;}else {break;}}properties.ascent=baseline-i;idx=pixels-line;stop=false;// descent. scan from bottom to top until we find a non red pixel
@@ -9535,7 +9534,7 @@
9535
9534
  // private syncing = false;
9536
9535
  _proto.apply=function apply(context){var _this=this;var renderingService=context.renderingService,renderingContext=context.renderingContext,rBushRoot=context.rBushRoot;var canvas=renderingContext.root.ownerDocument.defaultView;this.rBush=rBushRoot;var handleAttributeChanged=function handleAttributeChanged(e){var object=e.target;object.renderable.dirty=true;renderingService.dirtify();};var handleBoundsChanged=function handleBoundsChanged(e){var affectChildren=e.detail.affectChildren;var object=e.target;if(affectChildren){object.forEach(function(node){_this.toSync.add(node);});}var p=object;while(p){if(p.renderable){_this.toSync.add(p);}p=p.parentElement;}// this.pushToSync(e.composedPath().slice(0, -2) as DisplayObject[]);
9537
9536
  renderingService.dirtify();};var handleMounted=function handleMounted(e){var object=e.target;if(runtime.enableCSSParsing){// recalc style values
9538
- runtime.styleValueRegistry.recalc(object);}runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};var handleUnmounted=function handleUnmounted(e){var object=e.target;var rBushNode=object.rBushNode;if(rBushNode.aabb){_this.rBush.remove(rBushNode.aabb);}_this.toSync.delete(object);runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};renderingService.hooks.init.tapPromise(PrepareRendererPlugin.tag,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:canvas.addEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.addEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.addEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.addEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);case 4:case"end":return _context.stop();}},_callee);})));renderingService.hooks.destroy.tap(PrepareRendererPlugin.tag,function(){canvas.removeEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.removeEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.removeEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);_this.toSync.clear();});renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag,function(){// if (this.isFirstTimeRendering) {
9537
+ runtime.styleValueRegistry.recalc(object);}runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};var handleUnmounted=function handleUnmounted(e){var object=e.target;var rBushNode=object.rBushNode;if(rBushNode.aabb){_this.rBush.remove(rBushNode.aabb);}_this.toSync.delete(object);runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};renderingService.hooks.init.tap(PrepareRendererPlugin.tag,function(){canvas.addEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.addEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.addEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.addEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);});renderingService.hooks.destroy.tap(PrepareRendererPlugin.tag,function(){canvas.removeEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.removeEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.removeEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);_this.toSync.clear();});renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag,function(){// if (this.isFirstTimeRendering) {
9539
9538
  // this.isFirstTimeRendering = false;
9540
9539
  // this.syncing = true;
9541
9540
  // // @see https://github.com/antvis/G/issues/1117
@@ -9556,7 +9555,7 @@
9556
9555
  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
9557
9556
  // @see https://github.com/mourner/rbush#bulk-inserting-data
9558
9557
  this.rBush.load(bulk);bulk.length=0;this.toSync.clear();// this.syncing = false;
9559
- };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;/**
9558
+ };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";CanvasEvent["RENDERER_CHANGED"]="rendererchanged";})(exports.CanvasEvent||(exports.CanvasEvent={}));var DEFAULT_CAMERA_Z=500;var DEFAULT_CAMERA_NEAR=0.1;var DEFAULT_CAMERA_FAR=1000;/**
9560
9559
  * reuse custom event preventing from re-create them in every frame
9561
9560
  */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);/**
9562
9561
  * can be treated like Window in DOM
@@ -9599,7 +9598,7 @@
9599
9598
  * limits query
9600
9599
  */ // the following feature-detect from hammer.js
9601
9600
  // @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
9602
- _this.supportsTouchEvents=supportsTouchEvents!==null&&supportsTouchEvents!==void 0?supportsTouchEvents:'ontouchstart'in runtime.globalThis;_this.supportsPointerEvents=supportsPointerEvents!==null&&supportsPointerEvents!==void 0?supportsPointerEvents:!!runtime.globalThis.PointerEvent;_this.isTouchEvent=isTouchEvent!==null&&isTouchEvent!==void 0?isTouchEvent:function(event){return _this.supportsTouchEvents&&event instanceof runtime.globalThis.TouchEvent;};_this.isMouseEvent=isMouseEvent!==null&&isMouseEvent!==void 0?isMouseEvent:function(event){return !runtime.globalThis.MouseEvent||event instanceof runtime.globalThis.MouseEvent&&(!_this.supportsPointerEvents||!(event instanceof runtime.globalThis.PointerEvent));};_this.initRenderingContext({container:container,canvas:canvas,width:canvasWidth,height:canvasHeight,renderer:renderer,offscreenCanvas:offscreenCanvas,devicePixelRatio:dpr,cursor:cursor||'default',background:background||'transparent',createImage:createImage,document:document,supportsCSSTransform:supportsCSSTransform,useNativeClickEvent:useNativeClickEvent,alwaysTriggerPointerEventOnCanvas:alwaysTriggerPointerEventOnCanvas});_this.initDefaultCamera(canvasWidth,canvasHeight);_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.next=2;return _this.initRenderer(renderer);case 2:_this.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));if(_this.readyPromise){_this.resolveReadyPromise();}case 4:case"end":return _context.stop();}},_callee);}))();return _this;}var _proto=Canvas.prototype;_proto.initRenderingContext=function initRenderingContext(mergedConfig){this.context.config=mergedConfig;// bind rendering context, shared by all renderers
9601
+ _this.supportsTouchEvents=supportsTouchEvents!==null&&supportsTouchEvents!==void 0?supportsTouchEvents:'ontouchstart'in runtime.globalThis;_this.supportsPointerEvents=supportsPointerEvents!==null&&supportsPointerEvents!==void 0?supportsPointerEvents:!!runtime.globalThis.PointerEvent;_this.isTouchEvent=isTouchEvent!==null&&isTouchEvent!==void 0?isTouchEvent:function(event){return _this.supportsTouchEvents&&event instanceof runtime.globalThis.TouchEvent;};_this.isMouseEvent=isMouseEvent!==null&&isMouseEvent!==void 0?isMouseEvent:function(event){return !runtime.globalThis.MouseEvent||event instanceof runtime.globalThis.MouseEvent&&(!_this.supportsPointerEvents||!(event instanceof runtime.globalThis.PointerEvent));};_this.initRenderingContext({container:container,canvas:canvas,width:canvasWidth,height:canvasHeight,renderer:renderer,offscreenCanvas:offscreenCanvas,devicePixelRatio:dpr,cursor:cursor||'default',background:background||'transparent',createImage:createImage,document:document,supportsCSSTransform:supportsCSSTransform,useNativeClickEvent:useNativeClickEvent,alwaysTriggerPointerEventOnCanvas:alwaysTriggerPointerEventOnCanvas});_this.initDefaultCamera(canvasWidth,canvasHeight);_this.initRenderer(renderer,true);return _this;}var _proto=Canvas.prototype;_proto.initRenderingContext=function initRenderingContext(mergedConfig){this.context.config=mergedConfig;// bind rendering context, shared by all renderers
9603
9602
  this.context.renderingContext={/**
9604
9603
  * the root node in scene graph
9605
9604
  */root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set(),force:false,dirty:false};};_proto.initDefaultCamera=function initDefaultCamera(width,height){var _this2=this;// set a default ortho camera
@@ -9639,30 +9638,30 @@
9639
9638
  * But the canvas remains running which means display objects can be appended later.
9640
9639
  */;_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
9641
9640
  // @see https://github.com/antvis/G/issues/1268
9642
- _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
9641
+ _this3.dispatchEvent(rerenderEvent);});this.dispatchEvent(afterRenderEvent);};_proto.run=function run(){var _this4=this;var tick=function tick(){_this4.render();_this4.frameId=_this4.requestAnimationFrame(tick);};tick();};_proto.initRenderer=function initRenderer(renderer,firstContentfullPaint){var _this5=this;if(firstContentfullPaint===void 0){firstContentfullPaint=false;}if(!renderer){throw new Error('Renderer is required.');}// reset
9643
9642
  this.inited=false;this.readyPromise=undefined;// FIXME: should re-create here?
9644
9643
  this.context.rBushRoot=new rbush();// reset rendering plugins
9645
9644
  this.context.renderingPlugins=[];this.context.renderingPlugins.push(new EventPlugin(),new PrepareRendererPlugin(),new DirtyCheckPlugin(),new CullingPlugin([new FrustumCullingStrategy()]));//
9646
9645
  this.loadRendererContainerModule(renderer);// init context service
9647
9646
  this.context.contextService=new this.context.ContextService(_extends({},runtime,this.context));// init rendering service
9648
9647
  this.context.renderingService=new RenderingService(runtime,this.context);// init event service
9649
- 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
9650
- 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
9651
- 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
9652
- 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
9648
+ this.context.eventService=new EventService(runtime,this.context);this.context.eventService.init();if(this.context.contextService.init){this.context.contextService.init();this.initRenderingService(renderer,firstContentfullPaint,true);}else {this.context.contextService.initAsync().then(function(){_this5.initRenderingService(renderer,firstContentfullPaint);});}};_proto.initRenderingService=function initRenderingService(renderer,firstContentfullPaint,async){var _this6=this;if(firstContentfullPaint===void 0){firstContentfullPaint=false;}if(async===void 0){async=false;}this.context.renderingService.init(function(){_this6.inited=true;if(firstContentfullPaint){if(async){_this6.requestAnimationFrame(function(){_this6.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));});}else {_this6.dispatchEvent(new CustomEvent(exports.CanvasEvent.READY));}if(_this6.readyPromise){_this6.resolveReadyPromise();}}else {_this6.dispatchEvent(new CustomEvent(exports.CanvasEvent.RENDERER_CHANGED));}if(!firstContentfullPaint){_this6.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
9649
+ _this6.mountChildren(_this6.getRoot());if(renderer.getConfig().enableAutoRendering){_this6.run();}});};_proto.loadRendererContainerModule=function loadRendererContainerModule(renderer){var _this7=this;// load other container modules provided by g-canvas/g-svg/g-webgl
9650
+ var plugins=renderer.getPlugins();plugins.forEach(function(plugin){plugin.context=_this7.context;plugin.init(runtime);});};_proto.setRenderer=function setRenderer(renderer){// update canvas' config
9651
+ var canvasConfig=this.getConfig();if(canvasConfig.renderer===renderer){return;}var oldRenderer=canvasConfig.renderer;canvasConfig.renderer=renderer;// keep all children undestroyed
9653
9652
  this.destroy(false,true);// destroy all plugins, reverse will mutate origin array
9654
- [].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
9655
- 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
9653
+ [].concat(oldRenderer===null||oldRenderer===void 0?void 0:oldRenderer.getPlugins()).reverse().forEach(function(plugin){plugin.destroy(runtime);});this.initRenderer(renderer);};_proto.setCursor=function setCursor(cursor){var canvasConfig=this.getConfig();canvasConfig.cursor=cursor;this.getContextService().applyCursorStyle(cursor);};_proto.unmountChildren=function unmountChildren(parent){var _this8=this;// unmountChildren recursively
9654
+ parent.childNodes.forEach(function(child){_this8.unmountChildren(child);});if(this.inited){if(parent.isMutationObserved){parent.dispatchEvent(unmountedEvent);}else {unmountedEvent.target=parent;this.dispatchEvent(unmountedEvent,true);}// skip document.documentElement
9656
9655
  if(parent!==this.document.documentElement){parent.ownerDocument=null;}parent.isConnected=false;}// trigger after unmounted
9657
- 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
9658
- parent.childNodes.forEach(function(child){_this7.mountChildren(child);});// trigger after mounted
9656
+ if(parent.isCustomElement){if(parent.disconnectedCallback){parent.disconnectedCallback();}}};_proto.mountChildren=function mountChildren(parent){var _this9=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
9657
+ parent.childNodes.forEach(function(child){_this9.mountChildren(child);});// trigger after mounted
9659
9658
  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);}/**
9660
9659
  * @deprecated
9661
9660
  * @alias client2Viewport
9662
9661
  */;_proto.getPointByClient=function getPointByClient(clientX,clientY){return this.client2Viewport({x:clientX,y:clientY});}/**
9663
9662
  * @deprecated
9664
9663
  * @alias viewport2Client
9665
- */;_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);
9664
+ */;_proto.getClientByPoint=function getClientByPoint(x,y){return this.viewport2Client({x:x,y:y});};_createClass(Canvas,[{key:"ready",get:function get(){var _this10=this;if(!this.readyPromise){this.readyPromise=new Promise(function(resolve){_this10.resolveReadyPromise=function(){resolve(_this10);};});if(this.inited){this.resolveReadyPromise();}}return this.readyPromise;}}]);return Canvas;}(EventTarget);
9666
9665
 
9667
9666
  function _inheritsLoose$1(subClass, superClass) {
9668
9667
  subClass.prototype = Object.create(superClass.prototype);