Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g-plugin-canvas-renderer

Package Overview
Dependencies
Maintainers
59
Versions
263
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-plugin-canvas-renderer - npm Package Compare versions

Comparing version 1.7.1 to 1.7.2

2

dist/index.umd.min.js

@@ -5,2 +5,2 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g")):"function"==typeof define&&define.amd?define(["exports","@antv/g"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.CanvasRenderer={}),e.window.G)}(this,(function(e,t){"use strict";function r(){

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
F=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new R(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var l=x(a,r);if(l){if(l===u)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var u={};function h(){}function d(){}function f(){}var p={};l(p,i,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(S([])));y&&y!==t&&r.call(y,i)&&(p=y);var g=f.prototype=h.prototype=Object.create(p);function m(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(i,o,a,l){var c=s(e[i],e,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,l)}),(function(e){n("throw",e,a,l)})):t.resolve(h).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,l)}))}l(c.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function x(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return d.prototype=f,l(g,"constructor",f),l(f,"constructor",d),d.displayName=l(f,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(w.prototype),l(w.prototype,o,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new w(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),l(g,a,"Generator"),l(g,i,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var l=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(l&&c){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(l){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}function D(e,t,r,n,i,o,a){try{var l=e[o](a),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,i)}function _(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){D(o,n,i,a,l,"next",e)}function l(e){D(o,n,i,a,l,"throw",e)}a(void 0)}))}}var V,Y,U=function(){function e(){this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=void 0}var r=e.prototype;return r.getImageSync=function(e,t){return this.imageCache[e]||this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]},r.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e,r.imageCache[e]=a)}))},r.getOrCreatePatternSync=function(e,r,n){var i=this.generatePatternKey(e);if(i&&this.patternCache[i])return this.patternCache[i];var o,a=e.image,l=e.repetition,c=(o=t.isString(a)?this.getImageSync(a,n):a)&&r.createPattern(o,l);return i&&c&&(this.patternCache[i]=c),c},r.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,l=e.height,c=e.cx,s=e.cy;if(this.gradientCache[n])return this.gradientCache[n];var u=null;if(i===t.GradientType.LinearGradient){var h=t.computeLinearGradient(a,l,e.angle);u=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(i===t.GradientType.RadialGradient){var d=t.computeRadialGradient(a,l,c,s),f=d.x,p=d.y;u=r.createRadialGradient(f,p,0,f,p,d.r)}return u&&(o.forEach((function(e){var t;null===(t=u)||void 0===t||t.addColorStop(e[0],e[1])})),this.gradientCache[n]=u),this.gradientCache[n]},r.generateGradientKey=function(e){return"gradient-"+e.type+"-"+(e.angle||0)+"-"+(e.cx||0)+"-"+(e.cy||0)+"-"+e.width+"-"+e.height+"-"+e.steps.map((function(e){return e.join("")})).join("-")},r.generatePatternKey=function(e){var r=e.image,n=e.repetition;if(t.isString(r))return"pattern-"+r+"-"+n},e}();c([t.inject(t.CanvasConfig),s("design:type",Object)],U.prototype,"canvasConfig",void 0),U=c([t.singleton()],U);var X=(V=function(){function e(){this.imagePool=void 0,this.renderingContext=void 0}return e.prototype.apply=function(e){var r=this,n=function(n){var i=n.target;if(i.nodeName===t.Shape.IMAGE){var o=i.attributes.img;t.isString(o)&&r.imagePool.getImageSync(o,(function(){i.renderable.dirty=!0,e.dirtify()}))}},i=function(n){var i=n.target,o=n.newValue;i.nodeName===t.Shape.IMAGE&&"img"===n.attrName&&t.isString(o)&&r.imagePool.getOrCreateImage(o).then((function(){i.renderable.dirty=!0,e.dirtify()}))};e.hooks.init.tapPromise(Y.tag,_(F().mark((function e(){return F().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,i);case 2:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Y.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,i)}))},e}(),V.tag="LoadImage",Y=V);c([t.inject(U),s("design:type",U)],X.prototype,"imagePool",void 0),c([t.inject(t.RenderingContext),s("design:type",Object)],X.prototype,"renderingContext",void 0),X=Y=c([t.singleton({contrib:t.RenderingPluginContribution})],X);t.Module((function(e){e(U),e(X)}));e.ImageRenderer=function(){function e(){this.imagePool=void 0}return e.prototype.render=function(e,r){var n,i=r.img,o=r.width.value,a=r.height.value;if(t.isString(i)?n=this.imagePool.getImageSync(i):(o||(o=i.width),a||(a=i.height),n=i),n)try{e.drawImage(n,0,0,o,a)}catch(e){}},e}(),c([t.inject(U),s("design:type",U)],e.ImageRenderer.prototype,"imagePool",void 0),e.ImageRenderer=c([t.singleton({token:G})],e.ImageRenderer),e.TextRenderer=function(){function e(){}var r=e.prototype;return r.render=function(e,r,n){var i=r.lineWidth,o=r.textAlign,a=r.textBaseline,l=r.lineJoin,c=r.miterLimit,s=r.letterSpacing,u=r.stroke,h=r.fill,d=r.fillOpacity,f=r.strokeOpacity,p=r.opacity,v=r.metrics,y=r.dx,g=r.dy,m=v.lines,w=v.height,x=v.lineHeight,b=v.lineMetrics;e.font=v.font,e.lineWidth=i.value,e.textAlign=o.value,e.textBaseline=a.value,e.lineJoin=l.value,t.isNil(c)||(e.miterLimit=c.value);var E=0;"middle"===a.value?E=-w/2-x/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?E=-w:"top"!==a.value&&"hanging"!==a.value||(E=-x);var R=0;y&&y.unit===t.UnitType.kPixels&&(R+=y.value),g&&g.unit===t.UnitType.kPixels&&(E+=g.value);for(var S=0;m.length>S;S++){var C=i.value/2+R;E+=x,!t.isNil(u)&&!u.isNone&&i&&i.value&&this.drawLetterSpacing(e,m[S],b[S],o.value,C,E,s.value,d.value,f.value,p.value,!0),t.isNil(h)||this.drawLetterSpacing(e,m[S],b[S],o.value,C,E,s.value,d.value,f.value,p.value)}},r.drawLetterSpacing=function(e,t,r,n,i,o,a,l,c,s,u){if(void 0===u&&(u=!1),0!==a){var h=e.textAlign;e.textAlign="left";var d=i;"center"===n?d=i-r.width/2:"right"!==n&&"end"!==n||(d=i-r.width);for(var f=Array.from(t),p=e.measureText(t).width,v=0,y=0;f.length>y;++y){var g=f[y];u?this.strokeText(e,g,d,o,c):this.fillText(e,g,d,o,l,s),d+=p-(v=e.measureText(t.substring(y+1)).width)+a,p=v}e.textAlign=h}else u?this.strokeText(e,t,i,o,c):this.fillText(e,t,i,o,l,s)},r.fillText=function(e,r,n,i,o,a){var l,c=!t.isNil(o)&&1!==o;c&&(l=e.globalAlpha,e.globalAlpha=o*a),e.fillText(r,n,i),c&&(e.globalAlpha=l)},r.strokeText=function(e,r,n,i,o){var a,l=!t.isNil(o)&&1!==o;l&&(a=e.globalAlpha,e.globalAlpha=o),e.strokeText(r,n,i),l&&(e.globalAlpha=a)},e}(),e.TextRenderer=c([t.singleton({token:I})],e.TextRenderer);var W=function(){function e(){this.imagePool=void 0}var r=e.prototype;return r.render=function(e,r,n,i){var o=r.fill,a=r.opacity,l=r.fillOpacity,c=r.stroke,s=r.strokeOpacity,u=r.lineWidth,h=r.lineCap,d=r.lineJoin,f=r.shadowType,p=r.shadowColor,v=r.shadowBlur,y=r.filter,g=r.miterLimit,m=!t.isNil(o)&&!o.isNone,w=!t.isNil(c)&&!c.isNone&&u&&u.value>0,x=0===o.alpha,b=!t.isNil(y),E=!t.isNil(p)&&(null==v?void 0:v.value)>0,R=n.nodeName,S="inner"===(null==f?void 0:f.value),C=w&&E&&(R===t.Shape.PATH||R===t.Shape.LINE||R===t.Shape.POLYLINE||x||S);m&&(e.globalAlpha=a.value*l.value,C||this.setShadowAndFilter(n,e,E),this.fill(e,n,o,i),C||this.clearShadowAndFilter(e,b,E)),w&&(e.globalAlpha=a.value*s.value,e.lineWidth=u.value,t.isNil(g)||(e.miterLimit=g.value),t.isNil(h)||(e.lineCap=h.value),t.isNil(d)||(e.lineJoin=d.value),C&&(S&&(e.globalCompositeOperation="source-atop"),this.setShadowAndFilter(n,e,!0),S&&(this.stroke(e,n,c,i),e.globalCompositeOperation="source-over",this.clearShadowAndFilter(e,b,!0))),this.stroke(e,n,c,i))},r.clearShadowAndFilter=function(e,r,n){if(n&&(e.shadowColor="transparent",e.shadowBlur=0),r){var i=e.filter;!t.isNil(i)&&i.indexOf("drop-shadow")>-1&&(e.filter=i.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},r.setShadowAndFilter=function(e,r,n){var i=e.parsedStyle,o=i.shadowColor,a=i.shadowBlur,l=i.shadowOffsetX,c=i.shadowOffsetY;t.isNil(i.filter)||(r.filter=e.style.filter),n&&(r.shadowColor=o.toString(),r.shadowBlur=a&&a.value||0,r.shadowOffsetX=l&&l.value||0,r.shadowOffsetY=c&&c.value||0)},r.fill=function(e,r,n,i){var o=this;Array.isArray(n)?n.forEach((function(t){e.fillStyle=o.getColor(t,r,e),e.fill()})):(t.isPattern(n)&&(e.fillStyle=this.getPattern(n,r,e,i)),e.fill())},r.stroke=function(e,r,n,i){var o=this;Array.isArray(n)?n.forEach((function(t){e.strokeStyle=o.getColor(t,r,e),e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=this.getPattern(n,r,e,i)),e.stroke())},r.getPattern=function(e,t,r,n){return this.imagePool.getOrCreatePatternSync(e,r,(function(){t.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(e,r,n){var i;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var a=r.getGeometryBounds();i=this.imagePool.getOrCreateGradient(o({type:e.type},e.value,{width:a&&2*a.halfExtents[0]||1,height:a&&2*a.halfExtents[1]||1}),n)}return i},e}();c([t.inject(U),s("design:type",U)],W.prototype,"imagePool",void 0),W=c([t.singleton()],W),e.RectRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.RectRenderer=c([t.singleton({token:T})],e.RectRenderer),e.CircleRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.CircleRenderer=c([t.singleton({token:k})],e.CircleRenderer),e.EllipseRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.EllipseRenderer=c([t.singleton({token:L})],e.EllipseRenderer),e.LineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.LineRenderer=c([t.singleton({token:A})],e.LineRenderer),e.PolylineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.PolylineRenderer=c([t.singleton({token:N})],e.PolylineRenderer),e.PolygonRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.PolygonRenderer=c([t.singleton({token:j})],e.PolygonRenderer),e.PathRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.PathRenderer=c([t.singleton({token:B})],e.PathRenderer);var Q,H,J=t.Syringe.defineToken("CanvasRendererPluginOptions"),K=(Q=function(){function e(){this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.styleRendererFactory=void 0,this.styleRendererFactoryCache={},this.displayObjectPool=void 0,this.canvasRendererPluginOptions=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=x(),this.dprMatrix=x(),this.tmpMat4=x(),this.tmpVec3=S()}var n=e.prototype;return n.apply=function(e){var n=this,o=this.renderingContext.root.ownerDocument.defaultView,a=function(e){var t=e.target.rBushNode;t.aabb&&n.removedRBushNodeAABBs.push(t.aabb)},l=function(e){var t=e.target.rBushNode;t.aabb&&n.removedRBushNodeAABBs.push(t.aabb)};e.hooks.init.tapPromise(H.tag,i(r().mark((function e(){var i,o,c,s,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,a),n.renderingContext.root.addEventListener(t.ElementEvent.CULLED,l),i=n.contextService.getDPR(),c=(o=n.canvasConfig).width,s=o.height,u=n.contextService.getContext(),n.clearRect(u,0,0,c*i,s*i),r=n.dprMatrix,h=C(i,i,1),r[0]=h[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=h[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=h[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1;case 7:case"end":return e.stop()}var r,h}),e)})))),e.hooks.destroy.tap(H.tag,(function(){n.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,a),n.renderingContext.root.removeEventListener(t.ElementEvent.CULLED,l)})),e.hooks.beginFrame.tap(H.tag,(function(){var t=n.contextService.getContext(),r=n.contextService.getDPR(),i=n.canvasConfig,o=i.width,a=i.height,l=n.canvasRendererPluginOptions,c=l.dirtyObjectNumThreshold,s=l.dirtyObjectRatioThreshold,u=e.getStats(),h=u.rendered,d=h/u.total;n.clearFullScreen=e.disableDirtyRectangleRendering()||h>c&&d>s,t&&(t.resetTransform(),n.clearFullScreen&&n.clearRect(t,0,0,o*r,a*r))}));var c=function t(r){r.isVisible()&&!r.isCulled()&&(n.renderDisplayObject(r,e),n.saveDirtyAABB(r)),r.sortable.sorted&&r.sortable.sorted.length&&r.sortable.sorted.forEach((function(e){t(e)}))};e.hooks.endFrame.tap(H.tag,(function(){var r=n.contextService.getContext();if(E(n.vpMatrix,n.dprMatrix,n.camera.getOrthoMatrix()),n.clearFullScreen)c(n.renderingContext.root);else{var i=n.safeMergeAABB.apply(n,[n.mergeDirtyAABBs(n.renderQueue)].concat(n.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,i=e.maxX,o=e.maxY,a=new t.AABB;return a.setMinMax(C(r,n,0),C(i,o,0)),a}))));if(n.removedRBushNodeAABBs=[],t.AABB.isEmpty(i))return void(n.renderQueue=[]);var a=n.convertAABB2Rect(i),l=a.x,s=a.y,u=a.width,h=a.height,d=O(n.tmpVec3,C(l,s,0),n.vpMatrix),f=O(S(),C(l+u,s+h,0),n.vpMatrix),p=Math.floor(d[0]),v=Math.floor(d[1]),y=Math.ceil(f[0]-d[0]),g=Math.ceil(f[1]-d[1]);r.save(),n.clearRect(r,p,v,y,g),r.beginPath(),r.rect(p,v,y,g),r.clip(),r.setTransform(n.vpMatrix[0],n.vpMatrix[1],n.vpMatrix[4],n.vpMatrix[5],n.vpMatrix[12],n.vpMatrix[13]),n.canvasConfig.renderer.getConfig().enableDirtyRectangleRenderingDebug&&o.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:a})),n.searchDirtyObjects(i).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&n.renderDisplayObject(t,e)})),r.restore(),n.renderQueue.forEach((function(e){n.saveDirtyAABB(e)})),n.renderQueue=[]}n.restoreStack.forEach((function(){r.restore()})),n.restoreStack=[]})),e.hooks.render.tap(H.tag,(function(e){n.clearFullScreen||n.renderQueue.push(e)}))},n.clearRect=function(e,t,r,n,i){e.clearRect(t,r,n,i);var o=this.canvasConfig.background;o&&(e.fillStyle=o,e.fillRect(t,r,n,i))},n.renderDisplayObject=function(e,r){var n=this.contextService.getContext(),i=e.nodeName,o=this.restoreStack[this.restoreStack.length-1];!o||e.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_CONTAINS||(n.restore(),this.restoreStack.pop()),void 0===this.styleRendererFactoryCache[i]&&(this.styleRendererFactoryCache[i]=this.styleRendererFactory(i));var a=this.styleRendererFactoryCache[i];void 0===this.pathGeneratorFactoryCache[i]&&(this.pathGeneratorFactoryCache[i]=this.pathGeneratorFactory(i));var l=this.pathGeneratorFactoryCache[i],c=e.parsedStyle.clipPath;if(c){this.applyWorldTransform(n,c,e.getWorldTransform()),void 0===this.pathGeneratorFactoryCache[c.nodeName]&&(this.pathGeneratorFactoryCache[c.nodeName]=this.pathGeneratorFactory(c.nodeName));var s=this.pathGeneratorFactoryCache[c.nodeName];s&&(n.save(),this.restoreStack.push(e),n.beginPath(),s(n,c.parsedStyle),n.closePath(),n.clip())}a&&(this.applyWorldTransform(n,e),n.save(),this.applyAttributesToContext(n,e)),l&&(n.beginPath(),l(n,e.parsedStyle),e.nodeName!==t.Shape.LINE&&e.nodeName!==t.Shape.PATH&&e.nodeName!==t.Shape.POLYLINE&&n.closePath()),a&&(a.render(n,e.parsedStyle,e,r),n.restore()),e.renderable.dirty=!1},n.convertAABB2Rect=function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},n.mergeDirtyAABBs=function(e){var r=new t.AABB;return e.forEach((function(e){var t=e.getRenderBounds();r.add(t);var n=e.renderable.dirtyRenderBounds;n&&r.add(n)})),r},n.searchDirtyObjects=function(e){var t=this,r=e.getMin(),n=r[0],i=r[1],o=e.getMax();return this.rBush.search({minX:n,minY:i,maxX:o[0],maxY:o[1]}).map((function(e){return t.displayObjectPool.getByEntity(e.id)}))},n.saveDirtyAABB=function(e){var r=e.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new t.AABB);var n=e.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},n.applyAttributesToContext=function(e,r){var n=r.parsedStyle,i=n.stroke,o=n.fill,a=n.opacity,l=n.lineDash,c=n.lineDashOffset;l&&Array.isArray(l)&&e.setLineDash(l.map((function(e){return e.value}))),t.isNil(c)||(e.lineDashOffset=c.value),t.isNil(a)||(e.globalAlpha*=a.value),t.isNil(i)||Array.isArray(i)||i.isNone||(e.strokeStyle=r.attributes.stroke),t.isNil(o)||Array.isArray(o)||o.isNone||(e.fillStyle=r.attributes.fill)},n.applyWorldTransform=function(e,t,r){var n=0,i=0,o=(t.parsedStyle||{}).anchor,a=o&&o[0].value||0,l=o&&o[1].value||0;if(0!==a||0!==l){var c=t.getGeometryBounds();n=-a*(c&&2*c.halfExtents[0]||0),i=-l*(c&&2*c.halfExtents[1]||0)}r?(b(this.tmpMat4,t.getLocalTransform()),this.tmpVec3[0]=n,this.tmpVec3[1]=i,this.tmpVec3[2]=0,R(this.tmpMat4,this.tmpMat4,this.tmpVec3),E(this.tmpMat4,r,this.tmpMat4),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(b(this.tmpMat4,t.getWorldTransform()),this.tmpVec3[0]=n,this.tmpVec3[1]=i,this.tmpVec3[2]=0,R(this.tmpMat4,this.tmpMat4,this.tmpVec3),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},n.safeMergeAABB=function(){for(var e=new t.AABB,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(t){e.add(t)})),e},e}(),Q.tag="CanvasRenderer",H=Q);c([t.inject(t.CanvasConfig),s("design:type",Object)],K.prototype,"canvasConfig",void 0),c([t.inject(t.DefaultCamera),s("design:type",t.Camera)],K.prototype,"camera",void 0),c([t.inject(t.ContextService),s("design:type",Object)],K.prototype,"contextService",void 0),c([t.inject(t.RenderingContext),s("design:type",Object)],K.prototype,"renderingContext",void 0),c([t.inject(u),s("design:type",Function)],K.prototype,"pathGeneratorFactory",void 0),c([t.inject(M),s("design:type",Function)],K.prototype,"styleRendererFactory",void 0),c([t.inject(t.DisplayObjectPool),s("design:type",t.DisplayObjectPool)],K.prototype,"displayObjectPool",void 0),c([t.inject(J),s("design:type",Object)],K.prototype,"canvasRendererPluginOptions",void 0),c([t.inject(t.RBushRoot),s("design:type",t.RBush)],K.prototype,"rBush",void 0),K=H=c([t.singleton({contrib:t.RenderingPluginContribution})],K);var Z=t.Module((function(r){var n;r(e.CircleRenderer),r(e.EllipseRenderer),r(e.RectRenderer),r(e.ImageRenderer),r(e.TextRenderer),r(e.LineRenderer),r(e.PolylineRenderer),r(e.PolygonRenderer),r(e.PathRenderer);var i=((n={})[t.Shape.CIRCLE]=k,n[t.Shape.ELLIPSE]=L,n[t.Shape.RECT]=T,n[t.Shape.IMAGE]=G,n[t.Shape.TEXT]=I,n[t.Shape.LINE]=A,n[t.Shape.POLYLINE]=N,n[t.Shape.POLYGON]=j,n[t.Shape.PATH]=B,n);r({token:M,useFactory:function(e){return function(t){var r=i[t];return r&&e.container.isBound(r)?e.container.get(r):null}}}),r(K)})),q=function(e){function t(t){var r;return void 0===t&&(t={}),(r=e.call(this)||this).options=void 0,r.name="canvas-renderer",r.options=t,r}a(t,e);var r=t.prototype;return r.init=function(){this.container.register(J,{useValue:o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options)}),this.container.load(Z,!0)},r.destroy=function(){this.container.unload(Z),this.container.remove(J)},t}(t.AbstractRendererPlugin);e.CircleRendererContribution=k,e.EllipseRendererContribution=L,e.ImageRendererContribution=G,e.LineRendererContribution=A,e.PathRendererContribution=B,e.Plugin=q,e.PolygonRendererContribution=j,e.PolylineRendererContribution=N,e.RectRendererContribution=T,e.StyleRendererFactory=M,e.TextRendererContribution=I,Object.defineProperty(e,"__esModule",{value:!0})}));
F=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var i=Object.create((t&&t.prototype instanceof h?t:h).prototype),o=new R(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return C()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var l=x(a,r);if(l){if(l===u)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,o),i}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var u={};function h(){}function d(){}function f(){}var p={};l(p,i,(function(){return this}));var v=Object.getPrototypeOf,y=v&&v(v(S([])));y&&y!==t&&r.call(y,i)&&(p=y);var g=f.prototype=h.prototype=Object.create(p);function m(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){function n(i,o,a,l){var c=s(e[i],e,o);if("throw"!==c.type){var u=c.arg,h=u.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,l)}),(function(e){n("throw",e,a,l)})):t.resolve(h).then((function(e){u.value=e,a(u)}),(function(e){return n("throw",e,a,l)}))}l(c.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function x(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method))return u;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,u;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,u):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,u)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:C}}function C(){return{value:void 0,done:!0}}return d.prototype=f,l(g,"constructor",f),l(f,"constructor",d),d.displayName=l(f,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,l(e,a,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(w.prototype),l(w.prototype,o,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new w(c(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),l(g,a,"Generator"),l(g,i,(function(){return this})),l(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=S,R.prototype={constructor:R,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(this.prev>=o.tryLoc){var l=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(l&&c){if(o.catchLoc>this.prev)return n(o.catchLoc,!0);if(o.finallyLoc>this.prev)return n(o.finallyLoc)}else if(l){if(o.catchLoc>this.prev)return n(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(o.finallyLoc>this.prev)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(this.prev>=i.tryLoc&&r.call(i,"finallyLoc")&&i.finallyLoc>this.prev){var o=i;break}}o&&("break"===e||"continue"===e)&&t>=o.tryLoc&&o.finallyLoc>=t&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,u):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),u},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),u}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:S(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},e}function D(e,t,r,n,i,o,a){try{var l=e[o](a),c=l.value}catch(e){return void r(e)}l.done?t(c):Promise.resolve(c).then(n,i)}function _(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){D(o,n,i,a,l,"next",e)}function l(e){D(o,n,i,a,l,"throw",e)}a(void 0)}))}}var V,Y,U=function(){function e(){this.imageCache={},this.gradientCache={},this.patternCache={},this.canvasConfig=void 0}var r=e.prototype;return r.getImageSync=function(e,t){return this.imageCache[e]?t&&t():this.getOrCreateImage(e).then((function(){t&&t()})),this.imageCache[e]},r.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e,r.imageCache[e]=a)}))},r.getOrCreatePatternSync=function(e,r,n){var i=this.generatePatternKey(e);if(i&&this.patternCache[i])return this.patternCache[i];var o,a=e.image,l=e.repetition,c=(o=t.isString(a)?this.getImageSync(a,n):a)&&r.createPattern(o,l);return i&&c&&(this.patternCache[i]=c),c},r.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.width,l=e.height,c=e.cx,s=e.cy;if(this.gradientCache[n])return this.gradientCache[n];var u=null;if(i===t.GradientType.LinearGradient){var h=t.computeLinearGradient(a,l,e.angle);u=r.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(i===t.GradientType.RadialGradient){var d=t.computeRadialGradient(a,l,c,s),f=d.x,p=d.y;u=r.createRadialGradient(f,p,0,f,p,d.r)}return u&&(o.forEach((function(e){var t;null===(t=u)||void 0===t||t.addColorStop(e[0],e[1])})),this.gradientCache[n]=u),this.gradientCache[n]},r.generateGradientKey=function(e){return"gradient-"+e.type+"-"+(e.angle||0)+"-"+(e.cx||0)+"-"+(e.cy||0)+"-"+e.width+"-"+e.height+"-"+e.steps.map((function(e){return e.join("")})).join("-")},r.generatePatternKey=function(e){var r=e.image,n=e.repetition;if(t.isString(r))return"pattern-"+r+"-"+n},e}();c([t.inject(t.CanvasConfig),s("design:type",Object)],U.prototype,"canvasConfig",void 0),U=c([t.singleton()],U);var X=(V=function(){function e(){this.imagePool=void 0,this.renderingContext=void 0}return e.prototype.apply=function(e){var r=this,n=function(n){var i=n.target;if(i.nodeName===t.Shape.IMAGE){var o=i.attributes.img;t.isString(o)&&r.imagePool.getImageSync(o,(function(){i.renderable.dirty=!0,e.dirtify()}))}},i=function(n){var i=n.target,o=n.newValue;i.nodeName===t.Shape.IMAGE&&"img"===n.attrName&&t.isString(o)&&r.imagePool.getOrCreateImage(o).then((function(){i.renderable.dirty=!0,e.dirtify()}))};e.hooks.init.tapPromise(Y.tag,_(F().mark((function e(){return F().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r.renderingContext.root.addEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.addEventListener(t.ElementEvent.ATTR_MODIFIED,i);case 2:case"end":return e.stop()}}),e)})))),e.hooks.destroy.tap(Y.tag,(function(){r.renderingContext.root.removeEventListener(t.ElementEvent.MOUNTED,n),r.renderingContext.root.removeEventListener(t.ElementEvent.ATTR_MODIFIED,i)}))},e}(),V.tag="LoadImage",Y=V);c([t.inject(U),s("design:type",U)],X.prototype,"imagePool",void 0),c([t.inject(t.RenderingContext),s("design:type",Object)],X.prototype,"renderingContext",void 0),X=Y=c([t.singleton({contrib:t.RenderingPluginContribution})],X);t.Module((function(e){e(U),e(X)}));e.ImageRenderer=function(){function e(){this.imagePool=void 0}return e.prototype.render=function(e,r){var n,i=r.img,o=r.width.value,a=r.height.value;if(t.isString(i)?n=this.imagePool.getImageSync(i):(o||(o=i.width),a||(a=i.height),n=i),n)try{e.drawImage(n,0,0,o,a)}catch(e){}},e}(),c([t.inject(U),s("design:type",U)],e.ImageRenderer.prototype,"imagePool",void 0),e.ImageRenderer=c([t.singleton({token:G})],e.ImageRenderer),e.TextRenderer=function(){function e(){}var r=e.prototype;return r.render=function(e,r,n){var i=r.lineWidth,o=r.textAlign,a=r.textBaseline,l=r.lineJoin,c=r.miterLimit,s=r.letterSpacing,u=r.stroke,h=r.fill,d=r.fillOpacity,f=r.strokeOpacity,p=r.opacity,v=r.metrics,y=r.dx,g=r.dy,m=v.lines,w=v.height,x=v.lineHeight,b=v.lineMetrics;e.font=v.font,e.lineWidth=i.value,e.textAlign=o.value,e.textBaseline=a.value,e.lineJoin=l.value,t.isNil(c)||(e.miterLimit=c.value);var E=0;"middle"===a.value?E=-w/2-x/2:"bottom"===a.value||"alphabetic"===a.value||"ideographic"===a.value?E=-w:"top"!==a.value&&"hanging"!==a.value||(E=-x);var R=0;y&&y.unit===t.UnitType.kPixels&&(R+=y.value),g&&g.unit===t.UnitType.kPixels&&(E+=g.value);for(var S=0;m.length>S;S++){var C=i.value/2+R;E+=x,!t.isNil(u)&&!u.isNone&&i&&i.value&&this.drawLetterSpacing(e,m[S],b[S],o.value,C,E,s.value,d.value,f.value,p.value,!0),t.isNil(h)||this.drawLetterSpacing(e,m[S],b[S],o.value,C,E,s.value,d.value,f.value,p.value)}},r.drawLetterSpacing=function(e,t,r,n,i,o,a,l,c,s,u){if(void 0===u&&(u=!1),0!==a){var h=e.textAlign;e.textAlign="left";var d=i;"center"===n?d=i-r.width/2:"right"!==n&&"end"!==n||(d=i-r.width);for(var f=Array.from(t),p=e.measureText(t).width,v=0,y=0;f.length>y;++y){var g=f[y];u?this.strokeText(e,g,d,o,c):this.fillText(e,g,d,o,l,s),d+=p-(v=e.measureText(t.substring(y+1)).width)+a,p=v}e.textAlign=h}else u?this.strokeText(e,t,i,o,c):this.fillText(e,t,i,o,l,s)},r.fillText=function(e,r,n,i,o,a){var l,c=!t.isNil(o)&&1!==o;c&&(l=e.globalAlpha,e.globalAlpha=o*a),e.fillText(r,n,i),c&&(e.globalAlpha=l)},r.strokeText=function(e,r,n,i,o){var a,l=!t.isNil(o)&&1!==o;l&&(a=e.globalAlpha,e.globalAlpha=o),e.strokeText(r,n,i),l&&(e.globalAlpha=a)},e}(),e.TextRenderer=c([t.singleton({token:I})],e.TextRenderer);var W=function(){function e(){this.imagePool=void 0}var r=e.prototype;return r.render=function(e,r,n,i){var o=r.fill,a=r.opacity,l=r.fillOpacity,c=r.stroke,s=r.strokeOpacity,u=r.lineWidth,h=r.lineCap,d=r.lineJoin,f=r.shadowType,p=r.shadowColor,v=r.shadowBlur,y=r.filter,g=r.miterLimit,m=!t.isNil(o)&&!o.isNone,w=!t.isNil(c)&&!c.isNone&&u&&u.value>0,x=0===o.alpha,b=!t.isNil(y),E=!t.isNil(p)&&(null==v?void 0:v.value)>0,R=n.nodeName,S="inner"===(null==f?void 0:f.value),C=w&&E&&(R===t.Shape.PATH||R===t.Shape.LINE||R===t.Shape.POLYLINE||x||S);m&&(e.globalAlpha=a.value*l.value,C||this.setShadowAndFilter(n,e,E),this.fill(e,n,o,i),C||this.clearShadowAndFilter(e,b,E)),w&&(e.globalAlpha=a.value*s.value,e.lineWidth=u.value,t.isNil(g)||(e.miterLimit=g.value),t.isNil(h)||(e.lineCap=h.value),t.isNil(d)||(e.lineJoin=d.value),C&&(S&&(e.globalCompositeOperation="source-atop"),this.setShadowAndFilter(n,e,!0),S&&(this.stroke(e,n,c,i),e.globalCompositeOperation="source-over",this.clearShadowAndFilter(e,b,!0))),this.stroke(e,n,c,i))},r.clearShadowAndFilter=function(e,r,n){if(n&&(e.shadowColor="transparent",e.shadowBlur=0),r){var i=e.filter;!t.isNil(i)&&i.indexOf("drop-shadow")>-1&&(e.filter=i.replace(/drop-shadow\([^)]*\)/,"").trim()||"none")}},r.setShadowAndFilter=function(e,r,n){var i=e.parsedStyle,o=i.shadowColor,a=i.shadowBlur,l=i.shadowOffsetX,c=i.shadowOffsetY;t.isNil(i.filter)||(r.filter=e.style.filter),n&&(r.shadowColor=o.toString(),r.shadowBlur=a&&a.value||0,r.shadowOffsetX=l&&l.value||0,r.shadowOffsetY=c&&c.value||0)},r.fill=function(e,r,n,i){var o=this;Array.isArray(n)?n.forEach((function(t){e.fillStyle=o.getColor(t,r,e),e.fill()})):(t.isPattern(n)&&(e.fillStyle=this.getPattern(n,r,e,i)),e.fill())},r.stroke=function(e,r,n,i){var o=this;Array.isArray(n)?n.forEach((function(t){e.strokeStyle=o.getColor(t,r,e),e.stroke()})):(t.isPattern(n)&&(e.strokeStyle=this.getPattern(n,r,e,i)),e.stroke())},r.getPattern=function(e,t,r,n){return this.imagePool.getOrCreatePatternSync(e,r,(function(){t.renderable.dirty=!0,n.dirtify()}))},r.getColor=function(e,r,n){var i;if(e.type===t.GradientType.LinearGradient||e.type===t.GradientType.RadialGradient){var a=r.getGeometryBounds();i=this.imagePool.getOrCreateGradient(o({type:e.type},e.value,{width:a&&2*a.halfExtents[0]||1,height:a&&2*a.halfExtents[1]||1}),n)}return i},e}();c([t.inject(U),s("design:type",U)],W.prototype,"imagePool",void 0),W=c([t.singleton()],W),e.RectRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.RectRenderer=c([t.singleton({token:T})],e.RectRenderer),e.CircleRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.CircleRenderer=c([t.singleton({token:k})],e.CircleRenderer),e.EllipseRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.EllipseRenderer=c([t.singleton({token:L})],e.EllipseRenderer),e.LineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.LineRenderer=c([t.singleton({token:A})],e.LineRenderer),e.PolylineRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.PolylineRenderer=c([t.singleton({token:N})],e.PolylineRenderer),e.PolygonRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.PolygonRenderer=c([t.singleton({token:j})],e.PolygonRenderer),e.PathRenderer=function(e){function t(){return e.apply(this,arguments)||this}return a(t,e),t}(W),e.PathRenderer=c([t.singleton({token:B})],e.PathRenderer);var Q,H,J=t.Syringe.defineToken("CanvasRendererPluginOptions"),K=(Q=function(){function e(){this.canvasConfig=void 0,this.camera=void 0,this.contextService=void 0,this.renderingContext=void 0,this.pathGeneratorFactory=void 0,this.pathGeneratorFactoryCache={},this.styleRendererFactory=void 0,this.styleRendererFactoryCache={},this.displayObjectPool=void 0,this.canvasRendererPluginOptions=void 0,this.rBush=void 0,this.removedRBushNodeAABBs=[],this.renderQueue=[],this.restoreStack=[],this.clearFullScreen=!1,this.vpMatrix=x(),this.dprMatrix=x(),this.tmpMat4=x(),this.tmpVec3=S()}var n=e.prototype;return n.apply=function(e){var n=this,o=this.renderingContext.root.ownerDocument.defaultView,a=function(e){var t=e.target.rBushNode;t.aabb&&n.removedRBushNodeAABBs.push(t.aabb)},l=function(e){var t=e.target.rBushNode;t.aabb&&n.removedRBushNodeAABBs.push(t.aabb)};e.hooks.init.tapPromise(H.tag,i(r().mark((function e(){var i,o,c,s,u;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n.renderingContext.root.addEventListener(t.ElementEvent.UNMOUNTED,a),n.renderingContext.root.addEventListener(t.ElementEvent.CULLED,l),i=n.contextService.getDPR(),c=(o=n.canvasConfig).width,s=o.height,u=n.contextService.getContext(),n.clearRect(u,0,0,c*i,s*i),r=n.dprMatrix,h=C(i,i,1),r[0]=h[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=h[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=h[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1;case 7:case"end":return e.stop()}var r,h}),e)})))),e.hooks.destroy.tap(H.tag,(function(){n.renderingContext.root.removeEventListener(t.ElementEvent.UNMOUNTED,a),n.renderingContext.root.removeEventListener(t.ElementEvent.CULLED,l)})),e.hooks.beginFrame.tap(H.tag,(function(){var t=n.contextService.getContext(),r=n.contextService.getDPR(),i=n.canvasConfig,o=i.width,a=i.height,l=n.canvasRendererPluginOptions,c=l.dirtyObjectNumThreshold,s=l.dirtyObjectRatioThreshold,u=e.getStats(),h=u.rendered,d=h/u.total;n.clearFullScreen=e.disableDirtyRectangleRendering()||h>c&&d>s,t&&(t.resetTransform(),n.clearFullScreen&&n.clearRect(t,0,0,o*r,a*r))}));var c=function t(r){r.isVisible()&&!r.isCulled()&&(n.renderDisplayObject(r,e),n.saveDirtyAABB(r)),r.sortable.sorted&&r.sortable.sorted.length&&r.sortable.sorted.forEach((function(e){t(e)}))};e.hooks.endFrame.tap(H.tag,(function(){var r=n.contextService.getContext();if(E(n.vpMatrix,n.dprMatrix,n.camera.getOrthoMatrix()),n.clearFullScreen)c(n.renderingContext.root);else{var i=n.safeMergeAABB.apply(n,[n.mergeDirtyAABBs(n.renderQueue)].concat(n.removedRBushNodeAABBs.map((function(e){var r=e.minX,n=e.minY,i=e.maxX,o=e.maxY,a=new t.AABB;return a.setMinMax(C(r,n,0),C(i,o,0)),a}))));if(n.removedRBushNodeAABBs=[],t.AABB.isEmpty(i))return void(n.renderQueue=[]);var a=n.convertAABB2Rect(i),l=a.x,s=a.y,u=a.width,h=a.height,d=O(n.tmpVec3,C(l,s,0),n.vpMatrix),f=O(S(),C(l+u,s+h,0),n.vpMatrix),p=Math.floor(d[0]),v=Math.floor(d[1]),y=Math.ceil(f[0]-d[0]),g=Math.ceil(f[1]-d[1]);r.save(),n.clearRect(r,p,v,y,g),r.beginPath(),r.rect(p,v,y,g),r.clip(),r.setTransform(n.vpMatrix[0],n.vpMatrix[1],n.vpMatrix[4],n.vpMatrix[5],n.vpMatrix[12],n.vpMatrix[13]),n.canvasConfig.renderer.getConfig().enableDirtyRectangleRenderingDebug&&o.dispatchEvent(new t.CustomEvent(t.CanvasEvent.DIRTY_RECTANGLE,{dirtyRect:a})),n.searchDirtyObjects(i).sort((function(e,t){return e.sortable.renderOrder-t.sortable.renderOrder})).forEach((function(t){t&&t.isVisible()&&!t.isCulled()&&n.renderDisplayObject(t,e)})),r.restore(),n.renderQueue.forEach((function(e){n.saveDirtyAABB(e)})),n.renderQueue=[]}n.restoreStack.forEach((function(){r.restore()})),n.restoreStack=[]})),e.hooks.render.tap(H.tag,(function(e){n.clearFullScreen||n.renderQueue.push(e)}))},n.clearRect=function(e,t,r,n,i){e.clearRect(t,r,n,i);var o=this.canvasConfig.background;o&&(e.fillStyle=o,e.fillRect(t,r,n,i))},n.renderDisplayObject=function(e,r){var n=this.contextService.getContext(),i=e.nodeName,o=this.restoreStack[this.restoreStack.length-1];!o||e.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_CONTAINS||(n.restore(),this.restoreStack.pop()),void 0===this.styleRendererFactoryCache[i]&&(this.styleRendererFactoryCache[i]=this.styleRendererFactory(i));var a=this.styleRendererFactoryCache[i];void 0===this.pathGeneratorFactoryCache[i]&&(this.pathGeneratorFactoryCache[i]=this.pathGeneratorFactory(i));var l=this.pathGeneratorFactoryCache[i],c=e.parsedStyle.clipPath;if(c){this.applyWorldTransform(n,c,e.getWorldTransform()),void 0===this.pathGeneratorFactoryCache[c.nodeName]&&(this.pathGeneratorFactoryCache[c.nodeName]=this.pathGeneratorFactory(c.nodeName));var s=this.pathGeneratorFactoryCache[c.nodeName];s&&(n.save(),this.restoreStack.push(e),n.beginPath(),s(n,c.parsedStyle),n.closePath(),n.clip())}a&&(this.applyWorldTransform(n,e),n.save(),this.applyAttributesToContext(n,e)),l&&(n.beginPath(),l(n,e.parsedStyle),e.nodeName!==t.Shape.LINE&&e.nodeName!==t.Shape.PATH&&e.nodeName!==t.Shape.POLYLINE&&n.closePath()),a&&(a.render(n,e.parsedStyle,e,r),n.restore()),e.renderable.dirty=!1},n.convertAABB2Rect=function(e){var t=e.getMin(),r=e.getMax(),n=Math.floor(t[0]),i=Math.floor(t[1]);return{x:n,y:i,width:Math.ceil(r[0])-n,height:Math.ceil(r[1])-i}},n.mergeDirtyAABBs=function(e){var r=new t.AABB;return e.forEach((function(e){var t=e.getRenderBounds();r.add(t);var n=e.renderable.dirtyRenderBounds;n&&r.add(n)})),r},n.searchDirtyObjects=function(e){var t=this,r=e.getMin(),n=r[0],i=r[1],o=e.getMax();return this.rBush.search({minX:n,minY:i,maxX:o[0],maxY:o[1]}).map((function(e){return t.displayObjectPool.getByEntity(e.id)}))},n.saveDirtyAABB=function(e){var r=e.renderable;r.dirtyRenderBounds||(r.dirtyRenderBounds=new t.AABB);var n=e.getRenderBounds();n&&r.dirtyRenderBounds.update(n.center,n.halfExtents)},n.applyAttributesToContext=function(e,r){var n=r.parsedStyle,i=n.stroke,o=n.fill,a=n.opacity,l=n.lineDash,c=n.lineDashOffset;l&&Array.isArray(l)&&e.setLineDash(l.map((function(e){return e.value}))),t.isNil(c)||(e.lineDashOffset=c.value),t.isNil(a)||(e.globalAlpha*=a.value),t.isNil(i)||Array.isArray(i)||i.isNone||(e.strokeStyle=r.attributes.stroke),t.isNil(o)||Array.isArray(o)||o.isNone||(e.fillStyle=r.attributes.fill)},n.applyWorldTransform=function(e,t,r){var n=0,i=0,o=(t.parsedStyle||{}).anchor,a=o&&o[0].value||0,l=o&&o[1].value||0;if(0!==a||0!==l){var c=t.getGeometryBounds();n=-a*(c&&2*c.halfExtents[0]||0),i=-l*(c&&2*c.halfExtents[1]||0)}r?(b(this.tmpMat4,t.getLocalTransform()),this.tmpVec3[0]=n,this.tmpVec3[1]=i,this.tmpVec3[2]=0,R(this.tmpMat4,this.tmpMat4,this.tmpVec3),E(this.tmpMat4,r,this.tmpMat4),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)):(b(this.tmpMat4,t.getWorldTransform()),this.tmpVec3[0]=n,this.tmpVec3[1]=i,this.tmpVec3[2]=0,R(this.tmpMat4,this.tmpMat4,this.tmpVec3),E(this.tmpMat4,this.vpMatrix,this.tmpMat4)),e.setTransform(this.tmpMat4[0],this.tmpMat4[1],this.tmpMat4[4],this.tmpMat4[5],this.tmpMat4[12],this.tmpMat4[13])},n.safeMergeAABB=function(){for(var e=new t.AABB,r=arguments.length,n=new Array(r),i=0;r>i;i++)n[i]=arguments[i];return n.forEach((function(t){e.add(t)})),e},e}(),Q.tag="CanvasRenderer",H=Q);c([t.inject(t.CanvasConfig),s("design:type",Object)],K.prototype,"canvasConfig",void 0),c([t.inject(t.DefaultCamera),s("design:type",t.Camera)],K.prototype,"camera",void 0),c([t.inject(t.ContextService),s("design:type",Object)],K.prototype,"contextService",void 0),c([t.inject(t.RenderingContext),s("design:type",Object)],K.prototype,"renderingContext",void 0),c([t.inject(u),s("design:type",Function)],K.prototype,"pathGeneratorFactory",void 0),c([t.inject(M),s("design:type",Function)],K.prototype,"styleRendererFactory",void 0),c([t.inject(t.DisplayObjectPool),s("design:type",t.DisplayObjectPool)],K.prototype,"displayObjectPool",void 0),c([t.inject(J),s("design:type",Object)],K.prototype,"canvasRendererPluginOptions",void 0),c([t.inject(t.RBushRoot),s("design:type",t.RBush)],K.prototype,"rBush",void 0),K=H=c([t.singleton({contrib:t.RenderingPluginContribution})],K);var Z=t.Module((function(r){var n;r(e.CircleRenderer),r(e.EllipseRenderer),r(e.RectRenderer),r(e.ImageRenderer),r(e.TextRenderer),r(e.LineRenderer),r(e.PolylineRenderer),r(e.PolygonRenderer),r(e.PathRenderer);var i=((n={})[t.Shape.CIRCLE]=k,n[t.Shape.ELLIPSE]=L,n[t.Shape.RECT]=T,n[t.Shape.IMAGE]=G,n[t.Shape.TEXT]=I,n[t.Shape.LINE]=A,n[t.Shape.POLYLINE]=N,n[t.Shape.POLYGON]=j,n[t.Shape.PATH]=B,n);r({token:M,useFactory:function(e){return function(t){var r=i[t];return r&&e.container.isBound(r)?e.container.get(r):null}}}),r(K)})),q=function(e){function t(t){var r;return void 0===t&&(t={}),(r=e.call(this)||this).options=void 0,r.name="canvas-renderer",r.options=t,r}a(t,e);var r=t.prototype;return r.init=function(){this.container.register(J,{useValue:o({dirtyObjectNumThreshold:500,dirtyObjectRatioThreshold:.8},this.options)}),this.container.load(Z,!0)},r.destroy=function(){this.container.unload(Z),this.container.remove(J)},t}(t.AbstractRendererPlugin);e.CircleRendererContribution=k,e.EllipseRendererContribution=L,e.ImageRendererContribution=G,e.LineRendererContribution=A,e.PathRendererContribution=B,e.Plugin=q,e.PolygonRendererContribution=j,e.PolylineRendererContribution=N,e.RectRendererContribution=T,e.StyleRendererFactory=M,e.TextRendererContribution=I,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@antv/g-plugin-canvas-renderer",
"version": "1.7.1",
"version": "1.7.2",
"description": "A G plugin of renderer implementation with Canvas2D API",

@@ -32,3 +32,3 @@ "keywords": [

"@antv/g-plugin-canvas-path-generator": "^1.1.0",
"@antv/g-plugin-image-loader": "^1.1.0",
"@antv/g-plugin-image-loader": "^1.1.1",
"tslib": "^2.3.1"

@@ -45,3 +45,3 @@ },

},
"gitHead": "8ce79c1d89b6331664ea34b811a9879d070fa590"
"gitHead": "4222974301960b6002ea7527d88f3b4d5547ad51"
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc