@antv/g 5.9.1 → 5.10.0
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 +35 -22
- package/dist/index.umd.min.js +2 -2
- package/package.json +9 -9
package/dist/index.umd.js
CHANGED
|
@@ -11278,19 +11278,7 @@
|
|
|
11278
11278
|
* destroy existed canvas with the same id
|
|
11279
11279
|
*/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;
|
|
11280
11280
|
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.';// borrow from hammer.js
|
|
11281
|
-
var MOUSE_POINTER_ID=1;var TOUCH_TO_POINTER={touchstart:'pointerdown',touchend:'pointerup',touchendoutside:'pointerupoutside',touchmove:'pointermove',touchcancel:'pointercancel'}
|
|
11282
|
-
* borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
|
|
11283
|
-
* @see https://github.com/rafaelcaricio/gradient-parser
|
|
11284
|
-
*/function colorStopToString(colorStop){var type=colorStop.type,value=colorStop.value;if(type==='hex'){return "#"+value;}else if(type==='literal'){return value;}else if(type==='rgb'){return "rgb("+value.join(',')+")";}else {return "rgba("+value.join(',')+")";}}var parseGradient=function(){var tokens={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,/**
|
|
11285
|
-
* @see https://projects.verou.me/conic-gradient/
|
|
11286
|
-
*/conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/};var input='';function error(msg){throw new Error(input+': '+msg);}function getAST(){var ast=matchListDefinitions();if(input.length>0){error('Invalid input not EOF');}return ast;}function matchListDefinitions(){return matchListing(matchDefinition);}function matchDefinition(){return matchGradient('linear-gradient',tokens.linearGradient,matchLinearOrientation)||matchGradient('repeating-linear-gradient',tokens.repeatingLinearGradient,matchLinearOrientation)||matchGradient('radial-gradient',tokens.radialGradient,matchListRadialOrientations)||matchGradient('repeating-radial-gradient',tokens.repeatingRadialGradient,matchListRadialOrientations)||matchGradient('conic-gradient',tokens.conicGradient,matchListRadialOrientations);}function matchGradient(gradientType,pattern,orientationMatcher){return matchCall(pattern,function(captures){var orientation=orientationMatcher();if(orientation){if(!scan(tokens.comma)){error('Missing comma before color stops');}}return {type:gradientType,orientation:orientation,colorStops:matchListing(matchColorStop)};});}function matchCall(pattern,callback){var captures=scan(pattern);if(captures){if(!scan(tokens.startCall)){error('Missing (');}var result=callback(captures);if(!scan(tokens.endCall)){error('Missing )');}return result;}}function matchLinearOrientation(){return matchSideOrCorner()||matchAngle();}function matchSideOrCorner(){return match('directional',tokens.sideOrCorner,1);}function matchAngle(){return match('angular',tokens.angleValue,1);}function matchListRadialOrientations(){var radialOrientations,radialOrientation=matchRadialOrientation(),lookaheadCache;if(radialOrientation){radialOrientations=[];radialOrientations.push(radialOrientation);lookaheadCache=input;if(scan(tokens.comma)){radialOrientation=matchRadialOrientation();if(radialOrientation){radialOrientations.push(radialOrientation);}else {input=lookaheadCache;}}}return radialOrientations;}function matchRadialOrientation(){var radialType=matchCircle()||matchEllipse();if(radialType){// @ts-ignore
|
|
11287
|
-
radialType.at=matchAtPosition();}else {var extent=matchExtentKeyword();if(extent){radialType=extent;var positionAt=matchAtPosition();if(positionAt){// @ts-ignore
|
|
11288
|
-
radialType.at=positionAt;}}else {var defaultPosition=matchPositioning();if(defaultPosition){radialType={type:'default-radial',// @ts-ignore
|
|
11289
|
-
at:defaultPosition};}}}return radialType;}function matchCircle(){var circle=match('shape',/^(circle)/i,0);if(circle){// @ts-ignore
|
|
11290
|
-
circle.style=matchLength()||matchExtentKeyword();}return circle;}function matchEllipse(){var ellipse=match('shape',/^(ellipse)/i,0);if(ellipse){// @ts-ignore
|
|
11291
|
-
ellipse.style=matchDistance()||matchExtentKeyword();}return ellipse;}function matchExtentKeyword(){return match('extent-keyword',tokens.extentKeywords,1);}function matchAtPosition(){if(match('position',/^at/,0)){var positioning=matchPositioning();if(!positioning){error('Missing positioning value');}return positioning;}}function matchPositioning(){var location=matchCoordinates();if(location.x||location.y){return {type:'position',value:location};}}function matchCoordinates(){return {x:matchDistance(),y:matchDistance()};}function matchListing(matcher){var captures=matcher();var result=[];if(captures){result.push(captures);while(scan(tokens.comma)){captures=matcher();if(captures){result.push(captures);}else {error('One extra comma');}}}return result;}function matchColorStop(){var color=matchColor();if(!color){error('Expected color definition');}color.length=matchDistance();return color;}function matchColor(){return matchHexColor()||matchRGBAColor()||matchRGBColor()||matchLiteralColor();}function matchLiteralColor(){return match('literal',tokens.literalColor,0);}function matchHexColor(){return match('hex',tokens.hexColor,1);}function matchRGBColor(){return matchCall(tokens.rgbColor,function(){return {type:'rgb',value:matchListing(matchNumber)};});}function matchRGBAColor(){return matchCall(tokens.rgbaColor,function(){return {type:'rgba',value:matchListing(matchNumber)};});}function matchNumber(){return scan(tokens.number)[1];}function matchDistance(){return match('%',tokens.percentageValue,1)||matchPositionKeyword()||matchLength();}function matchPositionKeyword(){return match('position-keyword',tokens.positionKeywords,1);}function matchLength(){return match('px',tokens.pixelValue,1)||match('em',tokens.emValue,1);}function match(type,pattern,captureIndex){var captures=scan(pattern);if(captures){return {type:type,value:captures[captureIndex]};}}function scan(regexp){var blankCaptures=/^[\n\r\t\s]+/.exec(input);if(blankCaptures){consume(blankCaptures[0].length);}var captures=regexp.exec(input);if(captures){consume(captures[0].length);}return captures;}function consume(size){input=input.substring(size);}return function(code){input=code;return getAST();};}();function computeLinearGradient(width,height,angle){var rad=angle*Math.PI/180;var rx=0;var ry=0;var rcx=rx+width/2;var rcy=ry+height/2;// get the length of gradient line
|
|
11292
|
-
// @see https://observablehq.com/@danburzo/css-gradient-line
|
|
11293
|
-
var length=Math.abs(width*Math.cos(rad))+Math.abs(height*Math.sin(rad));var x1=rcx-Math.cos(rad)*length/2;var y1=rcy-Math.sin(rad)*length/2;var x2=rcx+Math.cos(rad)*length/2;var y2=rcy+Math.sin(rad)*length/2;return {x1:x1,y1:y1,x2:x2,y2:y2};}function computeRadialGradient(width,height,cx,cy){var r=Math.sqrt(width*width+height*height)/2;return {x:cx*width,y:cy*height,r:r};}function getAngle(angle){if(angle===undefined){return 0;}else if(angle>360||angle<-360){return angle%360;}return angle;}function createVec3(x,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(isNumber(x)){return fromValues$2(x,y,z);}if(Array.isArray(x)&&x.length===3){return clone$1(x);}return fromValues$2(x[0],x[1]||y,x[2]||z);}function deg2rad(deg){return deg*(Math.PI/180);}function rad2deg(rad){return rad*(180/Math.PI);}function grad2deg(grads){grads=grads%400;if(grads<0){grads+=400;}return grads/400*360;}function deg2turn(deg){return deg/360;}function turn2deg(turn){return 360*turn;}function getEulerFromQuat(out,quat){var x=quat[0];var y=quat[1];var z=quat[2];var w=quat[3];var x2=x*x;var y2=y*y;var z2=z*z;var w2=w*w;var unit=x2+y2+z2+w2;var test=x*w-y*z;if(test>0.499995*unit){// TODO: Use glmatrix.EPSILON
|
|
11281
|
+
var MOUSE_POINTER_ID=1;var TOUCH_TO_POINTER={touchstart:'pointerdown',touchend:'pointerup',touchendoutside:'pointerupoutside',touchmove:'pointermove',touchcancel:'pointercancel'};function getAngle(angle){if(angle===undefined){return 0;}else if(angle>360||angle<-360){return angle%360;}return angle;}function createVec3(x,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}if(isNumber(x)){return fromValues$2(x,y,z);}if(Array.isArray(x)&&x.length===3){return clone$1(x);}return fromValues$2(x[0],x[1]||y,x[2]||z);}function deg2rad(deg){return deg*(Math.PI/180);}function rad2deg(rad){return rad*(180/Math.PI);}function grad2deg(grads){grads=grads%400;if(grads<0){grads+=400;}return grads/400*360;}function deg2turn(deg){return deg/360;}function turn2deg(turn){return 360*turn;}function getEulerFromQuat(out,quat){var x=quat[0];var y=quat[1];var z=quat[2];var w=quat[3];var x2=x*x;var y2=y*y;var z2=z*z;var w2=w*w;var unit=x2+y2+z2+w2;var test=x*w-y*z;if(test>0.499995*unit){// TODO: Use glmatrix.EPSILON
|
|
11294
11282
|
// singularity at the north pole
|
|
11295
11283
|
out[0]=Math.PI/2;out[1]=2*Math.atan2(y,x);out[2]=0;}else if(test<-0.499995*unit){//TODO: Use glmatrix.EPSILON
|
|
11296
11284
|
// singularity at the south pole
|
|
@@ -11344,7 +11332,24 @@
|
|
|
11344
11332
|
cross(pdum3,row[1],row[2]);if(dot(row[0],pdum3)<0){for(var i=0;i<3;i++){scale[i]*=-1;row[i][0]*=-1;row[i][1]*=-1;row[i][2]*=-1;}}// Now, get the rotations out
|
|
11345
11333
|
quaternion[0]=0.5*Math.sqrt(Math.max(1+row[0][0]-row[1][1]-row[2][2],0));quaternion[1]=0.5*Math.sqrt(Math.max(1-row[0][0]+row[1][1]-row[2][2],0));quaternion[2]=0.5*Math.sqrt(Math.max(1-row[0][0]-row[1][1]+row[2][2],0));quaternion[3]=0.5*Math.sqrt(Math.max(1+row[0][0]+row[1][1]+row[2][2],0));if(row[2][1]>row[1][2])quaternion[0]=-quaternion[0];if(row[0][2]>row[2][0])quaternion[1]=-quaternion[1];if(row[1][0]>row[0][1])quaternion[2]=-quaternion[2];return true;}function normalize$4(out,mat){var m44=mat[15];// Cannot normalize.
|
|
11346
11334
|
if(m44===0)return false;var scale=1/m44;for(var i=0;i<16;i++){out[i]=mat[i]*scale;}return true;}//gets upper-left of a 4x4 matrix into a 3x3 of vectors
|
|
11347
|
-
function mat3from4(out,mat4x4){out[0][0]=mat4x4[0];out[0][1]=mat4x4[1];out[0][2]=mat4x4[2];out[1][0]=mat4x4[4];out[1][1]=mat4x4[5];out[1][2]=mat4x4[6];out[2][0]=mat4x4[8];out[2][1]=mat4x4[9];out[2][2]=mat4x4[10];}function combine(out,a,b,scale1,scale2){out[0]=a[0]*scale1+b[0]*scale2;out[1]=a[1]*scale1+b[1]*scale2;out[2]=a[2]*scale1+b[2]*scale2;}
|
|
11335
|
+
function mat3from4(out,mat4x4){out[0][0]=mat4x4[0];out[0][1]=mat4x4[1];out[0][2]=mat4x4[2];out[1][0]=mat4x4[4];out[1][1]=mat4x4[5];out[1][2]=mat4x4[6];out[2][0]=mat4x4[8];out[2][1]=mat4x4[9];out[2][2]=mat4x4[10];}function combine(out,a,b,scale1,scale2){out[0]=a[0]*scale1+b[0]*scale2;out[1]=a[1]*scale1+b[1]*scale2;out[2]=a[2]*scale1+b[2]*scale2;}/**
|
|
11336
|
+
* borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
|
|
11337
|
+
* @see https://github.com/rafaelcaricio/gradient-parser
|
|
11338
|
+
*/function colorStopToString(colorStop){var type=colorStop.type,value=colorStop.value;if(type==='hex'){return "#"+value;}else if(type==='literal'){return value;}else if(type==='rgb'){return "rgb("+value.join(',')+")";}else {return "rgba("+value.join(',')+")";}}var parseGradient=function(){var tokens={linearGradient:/^(linear\-gradient)/i,repeatingLinearGradient:/^(repeating\-linear\-gradient)/i,radialGradient:/^(radial\-gradient)/i,repeatingRadialGradient:/^(repeating\-radial\-gradient)/i,/**
|
|
11339
|
+
* @see https://projects.verou.me/conic-gradient/
|
|
11340
|
+
*/conicGradient:/^(conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^\#([0-9a-fA-F]+)/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/};var input='';function error(msg){throw new Error(input+': '+msg);}function getAST(){var ast=matchListDefinitions();if(input.length>0){error('Invalid input not EOF');}return ast;}function matchListDefinitions(){return matchListing(matchDefinition);}function matchDefinition(){return matchGradient('linear-gradient',tokens.linearGradient,matchLinearOrientation)||matchGradient('repeating-linear-gradient',tokens.repeatingLinearGradient,matchLinearOrientation)||matchGradient('radial-gradient',tokens.radialGradient,matchListRadialOrientations)||matchGradient('repeating-radial-gradient',tokens.repeatingRadialGradient,matchListRadialOrientations)||matchGradient('conic-gradient',tokens.conicGradient,matchListRadialOrientations);}function matchGradient(gradientType,pattern,orientationMatcher){return matchCall(pattern,function(captures){var orientation=orientationMatcher();if(orientation){if(!scan(tokens.comma)){error('Missing comma before color stops');}}return {type:gradientType,orientation:orientation,colorStops:matchListing(matchColorStop)};});}function matchCall(pattern,callback){var captures=scan(pattern);if(captures){if(!scan(tokens.startCall)){error('Missing (');}var result=callback(captures);if(!scan(tokens.endCall)){error('Missing )');}return result;}}function matchLinearOrientation(){return matchSideOrCorner()||matchAngle();}function matchSideOrCorner(){return match('directional',tokens.sideOrCorner,1);}function matchAngle(){return match('angular',tokens.angleValue,1);}function matchListRadialOrientations(){var radialOrientations,radialOrientation=matchRadialOrientation(),lookaheadCache;if(radialOrientation){radialOrientations=[];radialOrientations.push(radialOrientation);lookaheadCache=input;if(scan(tokens.comma)){radialOrientation=matchRadialOrientation();if(radialOrientation){radialOrientations.push(radialOrientation);}else {input=lookaheadCache;}}}return radialOrientations;}function matchRadialOrientation(){var radialType=matchCircle()||matchEllipse();if(radialType){// @ts-ignore
|
|
11341
|
+
radialType.at=matchAtPosition();}else {var extent=matchExtentKeyword();if(extent){radialType=extent;var positionAt=matchAtPosition();if(positionAt){// @ts-ignore
|
|
11342
|
+
radialType.at=positionAt;}}else {var defaultPosition=matchPositioning();if(defaultPosition){radialType={type:'default-radial',// @ts-ignore
|
|
11343
|
+
at:defaultPosition};}}}return radialType;}function matchCircle(){var circle=match('shape',/^(circle)/i,0);if(circle){// @ts-ignore
|
|
11344
|
+
circle.style=matchLength()||matchExtentKeyword();}return circle;}function matchEllipse(){var ellipse=match('shape',/^(ellipse)/i,0);if(ellipse){// @ts-ignore
|
|
11345
|
+
ellipse.style=matchDistance()||matchExtentKeyword();}return ellipse;}function matchExtentKeyword(){return match('extent-keyword',tokens.extentKeywords,1);}function matchAtPosition(){if(match('position',/^at/,0)){var positioning=matchPositioning();if(!positioning){error('Missing positioning value');}return positioning;}}function matchPositioning(){var location=matchCoordinates();if(location.x||location.y){return {type:'position',value:location};}}function matchCoordinates(){return {x:matchDistance(),y:matchDistance()};}function matchListing(matcher){var captures=matcher();var result=[];if(captures){result.push(captures);while(scan(tokens.comma)){captures=matcher();if(captures){result.push(captures);}else {error('One extra comma');}}}return result;}function matchColorStop(){var color=matchColor();if(!color){error('Expected color definition');}color.length=matchDistance();return color;}function matchColor(){return matchHexColor()||matchRGBAColor()||matchRGBColor()||matchLiteralColor();}function matchLiteralColor(){return match('literal',tokens.literalColor,0);}function matchHexColor(){return match('hex',tokens.hexColor,1);}function matchRGBColor(){return matchCall(tokens.rgbColor,function(){return {type:'rgb',value:matchListing(matchNumber)};});}function matchRGBAColor(){return matchCall(tokens.rgbaColor,function(){return {type:'rgba',value:matchListing(matchNumber)};});}function matchNumber(){return scan(tokens.number)[1];}function matchDistance(){return match('%',tokens.percentageValue,1)||matchPositionKeyword()||matchLength();}function matchPositionKeyword(){return match('position-keyword',tokens.positionKeywords,1);}function matchLength(){return match('px',tokens.pixelValue,1)||match('em',tokens.emValue,1);}function match(type,pattern,captureIndex){var captures=scan(pattern);if(captures){return {type:type,value:captures[captureIndex]};}}function scan(regexp){var blankCaptures=/^[\n\r\t\s]+/.exec(input);if(blankCaptures){consume(blankCaptures[0].length);}var captures=regexp.exec(input);if(captures){consume(captures[0].length);}return captures;}function consume(size){input=input.substring(size);}return function(code){input=code;return getAST();};}();function computeLinearGradient(width,height,angle){var rad=deg2rad(angle.value);var rx=0;var ry=0;var rcx=rx+width/2;var rcy=ry+height/2;// get the length of gradient line
|
|
11346
|
+
// @see https://observablehq.com/@danburzo/css-gradient-line
|
|
11347
|
+
var length=Math.abs(width*Math.cos(rad))+Math.abs(height*Math.sin(rad));var x1=rcx-Math.cos(rad)*length/2;var y1=rcy-Math.sin(rad)*length/2;var x2=rcx+Math.cos(rad)*length/2;var y2=rcy+Math.sin(rad)*length/2;return {x1:x1,y1:y1,x2:x2,y2:y2};}function computeRadialGradient(width,height,cx,cy,size){// 'px'
|
|
11348
|
+
var x=cx.value;var y=cy.value;// TODO: 'em'
|
|
11349
|
+
// '%'
|
|
11350
|
+
if(cx.unit===exports.UnitType.kPercentage){x=cx.value/100*width;}if(cy.unit===exports.UnitType.kPercentage){y=cy.value/100*height;}// default to farthest-side
|
|
11351
|
+
var r=Math.max(distanceSquareRoot([0,0],[x,y]),distanceSquareRoot([0,height],[x,y]),distanceSquareRoot([width,height],[x,y]),distanceSquareRoot([width,0],[x,y]));if(size){if(size instanceof CSSUnitValue){r=size.value;}else if(size instanceof CSSKeywordValue){// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/CSS_Images/Using_CSS_gradients#example_closest-side_for_circles
|
|
11352
|
+
if(size.value==='closest-side'){r=Math.min(x,width-x,y,height-y);}else if(size.value==='farthest-side'){r=Math.max(x,width-x,y,height-y);}else if(size.value==='closest-corner'){r=Math.min(distanceSquareRoot([0,0],[x,y]),distanceSquareRoot([0,height],[x,y]),distanceSquareRoot([width,height],[x,y]),distanceSquareRoot([width,0],[x,y]));}}}return {x:x,y:y,r:r};}(function(Shape){Shape["GROUP"]="g";Shape["CIRCLE"]="circle";Shape["ELLIPSE"]="ellipse";Shape["IMAGE"]="image";Shape["RECT"]="rect";Shape["LINE"]="line";Shape["POLYLINE"]="polyline";Shape["POLYGON"]="polygon";Shape["TEXT"]="text";Shape["PATH"]="path";Shape["HTML"]="html";Shape["MESH"]="mesh";})(exports.Shape||(exports.Shape={}));var CanvasConfig=exports.Syringe.defineToken('');/**
|
|
11348
11353
|
* Web Animations API
|
|
11349
11354
|
*/var AnimationTimelineToken=exports.Syringe.defineToken('');var ParseEasingFunction=exports.Syringe.defineToken('');function getOrCalculatePathTotalLength(path){if(path.parsedStyle.path.totalLength===0){path.parsedStyle.path.totalLength=getTotalLength(path.parsedStyle.path.absolutePath);}return path.parsedStyle.path.totalLength;}function hasArcOrBezier(path){var hasArc=false;var count=path.length;for(var i=0;i<count;i++){var params=path[i];var cmd=params[0];if(cmd==='C'||cmd==='A'||cmd==='Q'){hasArc=true;break;}}return hasArc;}function extractPolygons(pathArray){var polygons=[];var polylines=[];var points=[];// 防止第一个命令不是 'M'
|
|
11350
11355
|
for(var i=0;i<pathArray.length;i++){var params=pathArray[i];var cmd=params[0];if(cmd==='M'){// 遇到 'M' 判定是否是新数组,新数组中没有点
|
|
@@ -11470,13 +11475,16 @@
|
|
|
11470
11475
|
// @ts-ignore
|
|
11471
11476
|
var fontFamilies=isString(fontFamily)?fontFamily.split(','):[fontFamily];for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
|
|
11472
11477
|
var _fontFamily=fontFamilies[i].trim();// Check if font already contains strings
|
|
11473
|
-
if(!/([\"\'])[^\'\"]+\1/.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}var regexLG=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;var regexRG=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;var regexPR=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;var regexColorStop=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;function spaceColorStops(colorStops){var _colorStops$length;var length=colorStops.length;colorStops[length-1].length=(_colorStops$length=colorStops[length-1].length)!==null&&_colorStops$length!==void 0?_colorStops$length:{type:'%',value:'100'};if(length>1){var _colorStops$0$length;colorStops[0].length=(_colorStops$0$length=colorStops[0].length)!==null&&_colorStops$0$length!==void 0?_colorStops$0$length:{type:'%',value:'0'};}var previousIndex=0;var previousOffset=Number(colorStops[0].length.value);for(var i=1;i<length;i++){var _colorStops$i$length
|
|
11478
|
+
if(!/([\"\'])[^\'\"]+\1/.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}var regexLG=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;var regexRG=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;var regexPR=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;var regexColorStop=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;function spaceColorStops(colorStops){var _colorStops$length;var length=colorStops.length;colorStops[length-1].length=(_colorStops$length=colorStops[length-1].length)!==null&&_colorStops$length!==void 0?_colorStops$length:{type:'%',value:'100'};if(length>1){var _colorStops$0$length;colorStops[0].length=(_colorStops$0$length=colorStops[0].length)!==null&&_colorStops$0$length!==void 0?_colorStops$0$length:{type:'%',value:'0'};}var previousIndex=0;var previousOffset=Number(colorStops[0].length.value);for(var i=1;i<length;i++){var _colorStops$i$length;// support '%' & 'px'
|
|
11479
|
+
var offset=(_colorStops$i$length=colorStops[i].length)===null||_colorStops$i$length===void 0?void 0:_colorStops$i$length.value;if(!isNil(offset)&&!isNil(previousOffset)){for(var j=1;j<i-previousIndex;j++){colorStops[previousIndex+j].length={type:'%',value:""+(previousOffset+(Number(offset)-previousOffset)*j/(i-previousIndex))};}previousIndex=i;previousOffset=Number(offset);}}}// The position of the gradient line's starting point.
|
|
11474
11480
|
// different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
|
|
11475
|
-
var SideOrCornerToDegMap={left:270-90,top:0-90,bottom:180-90,right:90-90,'left top':315-90,'top left':315-90,'left bottom':225-90,'bottom left':225-90,'right top':45-90,'top right':45-90,'right bottom':135-90,'bottom right':135-90};var angleToDeg=memoize(function(orientation){var angle;if(orientation.type==='angular'){angle=Number(orientation.value);}else {angle=SideOrCornerToDegMap[orientation.value]||0;}return angle;});var
|
|
11476
|
-
return
|
|
11481
|
+
var SideOrCornerToDegMap={left:270-90,top:0-90,bottom:180-90,right:90-90,'left top':315-90,'top left':315-90,'left bottom':225-90,'bottom left':225-90,'right top':45-90,'top right':45-90,'right bottom':135-90,'bottom right':135-90};var angleToDeg=memoize(function(orientation){var angle;if(orientation.type==='angular'){angle=Number(orientation.value);}else {angle=SideOrCornerToDegMap[orientation.value]||0;}return getOrCreateUnitValue(angle,'deg');});var positonToCSSUnitValue=memoize(function(position){var cx=50;var cy=50;var unitX='%';var unitY='%';if((position===null||position===void 0?void 0:position.type)==='position'){var _position$value=position.value,x=_position$value.x,y=_position$value.y;if((x===null||x===void 0?void 0:x.type)==='position-keyword'){if(x.value==='left'){cx=0;}else if(x.value==='center'){cx=50;}else if(x.value==='right'){cx=100;}else if(x.value==='top'){cy=0;}else if(x.value==='bottom'){cy=100;}}if((y===null||y===void 0?void 0:y.type)==='position-keyword'){if(y.value==='left'){cx=0;}else if(y.value==='center'){cy=50;}else if(y.value==='right'){cx=100;}else if(y.value==='top'){cy=0;}else if(y.value==='bottom'){cy=100;}}if((x===null||x===void 0?void 0:x.type)==='px'||(x===null||x===void 0?void 0:x.type)==='%'||(x===null||x===void 0?void 0:x.type)==='em'){unitX=x===null||x===void 0?void 0:x.type;cx=Number(x.value);}if((y===null||y===void 0?void 0:y.type)==='px'||(y===null||y===void 0?void 0:y.type)==='%'||(y===null||y===void 0?void 0:y.type)==='em'){unitY=y===null||y===void 0?void 0:y.type;cy=Number(y.value);}}return {cx:getOrCreateUnitValue(cx,unitX),cy:getOrCreateUnitValue(cy,unitY)};});var parseGradient$1=memoize(function(colorStr){if(colorStr.indexOf('linear')>-1||colorStr.indexOf('radial')>-1){var ast=parseGradient(colorStr);return ast.map(function(_ref){var type=_ref.type,orientation=_ref.orientation,colorStops=_ref.colorStops;spaceColorStops(colorStops);var steps=colorStops.map(function(colorStop){// TODO: only support % for now, should calc percentage of axis length when using px/em
|
|
11482
|
+
return {offset:getOrCreateUnitValue(colorStop.length.value,'%'),color:colorStopToString(colorStop)};});if(type==='linear-gradient'){return new CSSGradientValue(exports.GradientType.LinearGradient,{angle:orientation?angleToDeg(orientation):Odeg,steps:steps});}else if(type==='radial-gradient'){if(!orientation){orientation=[{type:'shape',value:'circle'}];}if(orientation[0].type==='shape'&&orientation[0].value==='circle'){var _positonToCSSUnitValu=positonToCSSUnitValue(orientation[0].at),cx=_positonToCSSUnitValu.cx,cy=_positonToCSSUnitValu.cy;var size;if(orientation[0].style){var _orientation$0$style=orientation[0].style,_type=_orientation$0$style.type,value=_orientation$0$style.value;if(_type==='extent-keyword'){size=getOrCreateKeyword(value);}else {size=getOrCreateUnitValue(value,_type);}}return new CSSGradientValue(exports.GradientType.RadialGradient,{cx:cx,cy:cy,size:size,steps:steps});}// TODO: support ellipse shape
|
|
11483
|
+
// TODO: repeating-linear-gradient & repeating-radial-gradient
|
|
11484
|
+
// } else if (type === 'repeating-linear-gradient') {
|
|
11477
11485
|
// } else if (type === 'repeating-radial-gradient') {
|
|
11478
11486
|
}});}// legacy format, should be deprecated later
|
|
11479
|
-
var type=colorStr[0];if(colorStr[1]==='('||colorStr[2]==='('){if(type==='l'){var arr=regexLG.exec(colorStr);if(arr){var _arr$2$match;var steps=((_arr$2$match=arr[2].match(regexColorStop))===null||_arr$2$match===void 0?void 0:_arr$2$match.map(function(stop){return stop.split(':');}))||[];return [new CSSGradientValue(exports.GradientType.LinearGradient,{angle:parseFloat(arr[1]),steps:steps.map(function(_ref2){var offset=_ref2[0],color=_ref2[1];return
|
|
11487
|
+
var type=colorStr[0];if(colorStr[1]==='('||colorStr[2]==='('){if(type==='l'){var arr=regexLG.exec(colorStr);if(arr){var _arr$2$match;var steps=((_arr$2$match=arr[2].match(regexColorStop))===null||_arr$2$match===void 0?void 0:_arr$2$match.map(function(stop){return stop.split(':');}))||[];return [new CSSGradientValue(exports.GradientType.LinearGradient,{angle:getOrCreateUnitValue(parseFloat(arr[1]),'deg'),steps:steps.map(function(_ref2){var offset=_ref2[0],color=_ref2[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})})];}}else if(type==='r'){var parsedRadialGradient=parseRadialGradient(colorStr);if(parsedRadialGradient){if(isString(parsedRadialGradient)){colorStr=parsedRadialGradient;}else {return [new CSSGradientValue(exports.GradientType.RadialGradient,parsedRadialGradient)];}}}else if(type==='p'){return parsePattern(colorStr);}}});function parseRadialGradient(gradientStr){var arr=regexRG.exec(gradientStr);if(arr){var _arr$4$match;var steps=((_arr$4$match=arr[4].match(regexColorStop))===null||_arr$4$match===void 0?void 0:_arr$4$match.map(function(stop){return stop.split(':');}))||[];return {cx:getOrCreateUnitValue(50,'%'),cy:getOrCreateUnitValue(50,'%'),steps:steps.map(function(_ref3){var offset=_ref3[0],color=_ref3[1];return {offset:getOrCreateUnitValue(Number(offset)*100,'%'),color:color};})};}return null;}function parsePattern(patternStr){var arr=regexPR.exec(patternStr);if(arr){var repetition=arr[1];var src=arr[2];switch(repetition){case'a':repetition='repeat';break;case'x':repetition='repeat-x';break;case'y':repetition='repeat-y';break;case'n':repetition='no-repeat';break;default:repetition='no-repeat';}return {image:src,// @ts-ignore
|
|
11480
11488
|
repetition:repetition};}return null;}function isPattern(object){return isObject(object)&&!!object.image;}/**
|
|
11481
11489
|
* @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
|
|
11482
11490
|
*/var parseColor=memoize(function(colorStr){if(isPattern(colorStr)){return _extends({repetition:'repeat'},colorStr);}if(isNil(colorStr)){colorStr='';}if(colorStr==='transparent'){// transparent black
|
|
@@ -11889,7 +11897,7 @@
|
|
|
11889
11897
|
*/ElementEvent["UNMOUNTED"]="DOMNodeRemovedFromDocument";ElementEvent["BOUNDS_CHANGED"]="bounds-changed";// GEOMETRY_BOUNDS_CHANGED = 'geometry-bounds-changed',
|
|
11890
11898
|
/**
|
|
11891
11899
|
* trigger when z-index changed
|
|
11892
|
-
*/ElementEvent["RENDER_ORDER_CHANGED"]="render-order-changed";ElementEvent["CULLED"]="culled";})(exports.ElementEvent||(exports.ElementEvent={}));var MutationEvent=/*#__PURE__*/function(_FederatedEvent){_inheritsLoose(MutationEvent,_FederatedEvent);function MutationEvent(typeArg,relatedNode,prevValue,newValue,attrName,attrChange,prevParsedValue,newParsedValue){var _this;_this=_FederatedEvent.call(this,null)||this;_this.relatedNode=void 0;_this.prevValue=void 0;_this.newValue=void 0;_this.attrName=void 0;_this.attrChange=void 0;_this.prevParsedValue=void 0;_this.newParsedValue=void 0;_this.relatedNode=relatedNode;_this.prevValue=prevValue;_this.newValue=newValue;_this.attrName=attrName;_this.attrChange=attrChange;_this.prevParsedValue=prevParsedValue;_this.newParsedValue=newParsedValue;_this.type=typeArg;return _this;}return MutationEvent;}(FederatedEvent);MutationEvent.ADDITION=2;MutationEvent.MODIFICATION=1;MutationEvent.REMOVAL=3;var entityCounter=0
|
|
11900
|
+
*/ElementEvent["RENDER_ORDER_CHANGED"]="render-order-changed";ElementEvent["CULLED"]="culled";})(exports.ElementEvent||(exports.ElementEvent={}));var MutationEvent=/*#__PURE__*/function(_FederatedEvent){_inheritsLoose(MutationEvent,_FederatedEvent);function MutationEvent(typeArg,relatedNode,prevValue,newValue,attrName,attrChange,prevParsedValue,newParsedValue){var _this;_this=_FederatedEvent.call(this,null)||this;_this.relatedNode=void 0;_this.prevValue=void 0;_this.newValue=void 0;_this.attrName=void 0;_this.attrChange=void 0;_this.prevParsedValue=void 0;_this.newParsedValue=void 0;_this.relatedNode=relatedNode;_this.prevValue=prevValue;_this.newValue=newValue;_this.attrName=attrName;_this.attrChange=attrChange;_this.prevParsedValue=prevParsedValue;_this.newParsedValue=newParsedValue;_this.type=typeArg;return _this;}return MutationEvent;}(FederatedEvent);MutationEvent.ADDITION=2;MutationEvent.MODIFICATION=1;MutationEvent.REMOVAL=3;var entityCounter=0;function resetEntityCounter(){entityCounter=0;}// let this.sceneGraphService: SceneGraphService;
|
|
11893
11901
|
var childInsertedEvent=new CustomEvent(exports.ElementEvent.CHILD_INSERTED,{child:null});var insertedEvent=new MutationEvent(exports.ElementEvent.INSERTED,null,'','','',0,'','');var removedEvent=new MutationEvent(exports.ElementEvent.REMOVED,null,'','','',0,'','');var destroyEvent=new CustomEvent(exports.ElementEvent.DESTROY);var childRemovedEvent=new CustomEvent(exports.ElementEvent.CHILD_REMOVED,{child:null});/**
|
|
11894
11902
|
* Has following capabilities:
|
|
11895
11903
|
* * Node insert/remove, eg. appendChild, removeChild, remove...
|
|
@@ -12847,7 +12855,11 @@
|
|
|
12847
12855
|
});case 2:_yield$_this2$renderi=_context.sent;picked=_yield$_this2$renderi.picked;return _context.abrupt("return",picked[0]||null);case 5:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());renderingService.hooks.pointerWheel.tap(EventPlugin_1.tag,function(nativeEvent){var wheelEvent=_this2.normalizeWheelEvent(nativeEvent);_this2.eventService.mapEvent(wheelEvent);});renderingService.hooks.pointerDown.tap(EventPlugin_1.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;var events=_this2.normalizeToPointerEvent(nativeEvent,canvas);if(_this2.autoPreventDefault&&events[0].isNormalized){var cancelable=nativeEvent.cancelable||!('cancelable'in nativeEvent);if(cancelable){nativeEvent.preventDefault();}}for(var _iterator2=_createForOfIteratorHelperLoose(events),_step2;!(_step2=_iterator2()).done;){var event=_step2.value;var federatedEvent=_this2.bootstrapEvent(_this2.rootPointerEvent,event,canvas);_this2.eventService.mapEvent(federatedEvent);}_this2.setCursor(_this2.eventService.cursor);});renderingService.hooks.pointerUp.tap(EventPlugin_1.tag,function(nativeEvent){if(canvas.supportsTouchEvents&&nativeEvent.pointerType==='touch')return;// account for element in SVG
|
|
12848
12856
|
var $element=_this2.contextService.getDomElement();var outside=$element&&nativeEvent.target&&nativeEvent.target!==$element&&// @ts-ignore
|
|
12849
12857
|
$element.contains&&// @ts-ignore
|
|
12850
|
-
!$element.contains(nativeEvent.target)?'outside':'';var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator3=_createForOfIteratorHelperLoose(normalizedEvents),_step3;!(_step3=_iterator3()).done;){var normalizedEvent=_step3.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas);event.type+=outside;_this2.eventService.mapEvent(event);}_this2.setCursor(_this2.eventService.cursor);});renderingService.hooks.pointerMove.tap(EventPlugin_1.tag,this.onPointerMove);renderingService.hooks.pointerOver.tap(EventPlugin_1.tag,this.onPointerMove);renderingService.hooks.pointerOut.tap(EventPlugin_1.tag,this.onPointerMove);};_proto.
|
|
12858
|
+
!$element.contains(nativeEvent.target)?'outside':'';var normalizedEvents=_this2.normalizeToPointerEvent(nativeEvent,canvas);for(var _iterator3=_createForOfIteratorHelperLoose(normalizedEvents),_step3;!(_step3=_iterator3()).done;){var normalizedEvent=_step3.value;var event=_this2.bootstrapEvent(_this2.rootPointerEvent,normalizedEvent,canvas);event.type+=outside;_this2.eventService.mapEvent(event);}_this2.setCursor(_this2.eventService.cursor);});renderingService.hooks.pointerMove.tap(EventPlugin_1.tag,this.onPointerMove);renderingService.hooks.pointerOver.tap(EventPlugin_1.tag,this.onPointerMove);renderingService.hooks.pointerOut.tap(EventPlugin_1.tag,this.onPointerMove);};_proto.getViewportXY=function getViewportXY(nativeEvent){var x;var y;/**
|
|
12859
|
+
* Should account for CSS Transform applied on container.
|
|
12860
|
+
* @see https://github.com/antvis/G/issues/1161
|
|
12861
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/MouseEvent/offsetX
|
|
12862
|
+
*/var offsetX=nativeEvent.offsetX,offsetY=nativeEvent.offsetY,clientX=nativeEvent.clientX,clientY=nativeEvent.clientY;if(this.canvasConfig.supportsCSSTransform&&!isNil(offsetX)&&!isNil(offsetY)){x=offsetX;y=offsetY;}else {var point=this.eventService.client2Viewport(new Point(clientX,clientY));x=point.x;y=point.y;}return {x:x,y:y};};_proto.bootstrapEvent=function bootstrapEvent(event,nativeEvent,view){event.view=view;event.originalEvent=null;event.nativeEvent=nativeEvent;event.pointerId=nativeEvent.pointerId;event.width=nativeEvent.width;event.height=nativeEvent.height;event.isPrimary=nativeEvent.isPrimary;event.pointerType=nativeEvent.pointerType;event.pressure=nativeEvent.pressure;event.tangentialPressure=nativeEvent.tangentialPressure;event.tiltX=nativeEvent.tiltX;event.tiltY=nativeEvent.tiltY;event.twist=nativeEvent.twist;this.transferMouseData(event,nativeEvent);var _this$getViewportXY=this.getViewportXY(nativeEvent),x=_this$getViewportXY.x,y=_this$getViewportXY.y;event.viewport.x=x;event.viewport.y=y;var _this$eventService$vi=this.eventService.viewport2Canvas(event.viewport),canvasX=_this$eventService$vi.x,canvasY=_this$eventService$vi.y;event.canvas.x=canvasX;event.canvas.y=canvasY;event.global.copyFrom(event.canvas);event.offset.copyFrom(event.canvas);event.isTrusted=nativeEvent.isTrusted;if(event.type==='pointerleave'){event.type='pointerout';}if(event.type.startsWith('mouse')){event.type=event.type.replace('mouse','pointer');}if(event.type.startsWith('touch')){event.type=TOUCH_TO_POINTER[event.type]||event.type;}return event;};_proto.normalizeWheelEvent=function normalizeWheelEvent(nativeEvent){var event=this.rootWheelEvent;this.transferMouseData(event,nativeEvent);event.deltaMode=nativeEvent.deltaMode;event.deltaX=nativeEvent.deltaX;event.deltaY=nativeEvent.deltaY;event.deltaZ=nativeEvent.deltaZ;var _this$getViewportXY2=this.getViewportXY(nativeEvent),x=_this$getViewportXY2.x,y=_this$getViewportXY2.y;event.viewport.x=x;event.viewport.y=y;var _this$eventService$vi2=this.eventService.viewport2Canvas(event.viewport),canvasX=_this$eventService$vi2.x,canvasY=_this$eventService$vi2.y;event.canvas.x=canvasX;event.canvas.y=canvasY;event.global.copyFrom(event.canvas);event.offset.copyFrom(event.canvas);event.nativeEvent=nativeEvent;event.type=nativeEvent.type;return event;}/**
|
|
12851
12863
|
* Transfers base & mouse event data from the nativeEvent to the federated event.
|
|
12852
12864
|
*/;_proto.transferMouseData=function transferMouseData(event,nativeEvent){event.isTrusted=nativeEvent.isTrusted;event.srcElement=nativeEvent.srcElement;event.timeStamp=performance.now();event.type=nativeEvent.type;event.altKey=nativeEvent.altKey;event.metaKey=nativeEvent.metaKey;event.shiftKey=nativeEvent.shiftKey;event.ctrlKey=nativeEvent.ctrlKey;event.button=nativeEvent.button;event.buttons=nativeEvent.buttons;event.client.x=nativeEvent.clientX;event.client.y=nativeEvent.clientY;event.movement.x=nativeEvent.movementX;event.movement.y=nativeEvent.movementY;event.page.x=nativeEvent.pageX;event.page.y=nativeEvent.pageY;event.screen.x=nativeEvent.screenX;event.screen.y=nativeEvent.screenY;event.relatedTarget=null;};_proto.setCursor=function setCursor(cursor){this.contextService.applyCursorStyle(cursor||this.canvasConfig.cursor||'default');};_proto.normalizeToPointerEvent=function normalizeToPointerEvent(event,canvas){var normalizedEvents=[];if(canvas.isTouchEvent(event)){for(var i=0;i<event.changedTouches.length;i++){var touch=event.changedTouches[i];// use changedTouches instead of touches since touchend has no touches
|
|
12853
12865
|
// @see https://stackoverflow.com/a/10079076
|
|
@@ -12939,7 +12951,7 @@
|
|
|
12939
12951
|
* reuse custom event preventing from re-create them in every frame
|
|
12940
12952
|
*/function Canvas(config){var _this;_this=_EventTarget.call(this)||this;// create document
|
|
12941
12953
|
_this.container=GlobalContainer$1.createChild();_this.document=void 0;_this.customElements=void 0;_this.requestAnimationFrame=void 0;_this.cancelAnimationFrame=void 0;_this.devicePixelRatio=void 0;_this.supportsPointerEvents=void 0;_this.supportsTouchEvents=void 0;_this.isTouchEvent=void 0;_this.isMouseEvent=void 0;_this.Element=DisplayObject;_this.frameId=void 0;_this.eventService=void 0;_this.renderingService=void 0;_this.inited=false;_this.readyPromise=void 0;_this.resolveReadyPromise=void 0;_this.mountEvent=new CustomEvent(exports.ElementEvent.MOUNTED);_this.unmountEvent=new CustomEvent(exports.ElementEvent.UNMOUNTED);_this.beforeRenderEvent=new CustomEvent(exports.CanvasEvent.BEFORE_RENDER);_this.afterRenderEvent=new CustomEvent(exports.CanvasEvent.AFTER_RENDER);_this.document=new Document();_this.document.defaultView=_assertThisInitialized(_this);// create registry of custom elements
|
|
12942
|
-
_this.customElements=new CustomElementRegistry();var container=config.container,canvas=config.canvas,offscreenCanvas=config.offscreenCanvas,width=config.width,height=config.height,devicePixelRatio=config.devicePixelRatio,renderer=config.renderer,background=config.background,cursor=config.cursor,document=config.document,requestAnimationFrame=config.requestAnimationFrame,cancelAnimationFrame=config.cancelAnimationFrame,createImage=config.createImage,supportsPointerEvents=config.supportsPointerEvents,supportsTouchEvents=config.supportsTouchEvents,isTouchEvent=config.isTouchEvent,isMouseEvent=config.isMouseEvent;cleanExistedCanvas(container,_assertThisInitialized(_this));var canvasWidth=width;var canvasHeight=height;var dpr=devicePixelRatio;// use user-defined <canvas> or OffscreenCanvas
|
|
12954
|
+
_this.customElements=new CustomElementRegistry();var container=config.container,canvas=config.canvas,offscreenCanvas=config.offscreenCanvas,width=config.width,height=config.height,devicePixelRatio=config.devicePixelRatio,renderer=config.renderer,background=config.background,cursor=config.cursor,document=config.document,requestAnimationFrame=config.requestAnimationFrame,cancelAnimationFrame=config.cancelAnimationFrame,createImage=config.createImage,supportsPointerEvents=config.supportsPointerEvents,supportsTouchEvents=config.supportsTouchEvents,supportsCSSTransform=config.supportsCSSTransform,isTouchEvent=config.isTouchEvent,isMouseEvent=config.isMouseEvent;cleanExistedCanvas(container,_assertThisInitialized(_this));var canvasWidth=width;var canvasHeight=height;var dpr=devicePixelRatio;// use user-defined <canvas> or OffscreenCanvas
|
|
12943
12955
|
if(canvas){// infer width & height with dpr
|
|
12944
12956
|
dpr=devicePixelRatio||isBrowser&&window.devicePixelRatio||1;dpr=dpr>=1?Math.ceil(dpr):1;canvasWidth=width||getWidth(canvas)||canvas.width/dpr;canvasHeight=height||getHeight(canvas)||canvas.height/dpr;}/**
|
|
12945
12957
|
* implements `Window` interface
|
|
@@ -12947,7 +12959,7 @@
|
|
|
12947
12959
|
* limits query
|
|
12948
12960
|
*/ // the following feature-detect from hammer.js
|
|
12949
12961
|
// @see https://github.com/hammerjs/hammer.js/blob/master/src/inputjs/input-consts.js#L5
|
|
12950
|
-
_this.supportsTouchEvents=supportsTouchEvents!==null&&supportsTouchEvents!==void 0?supportsTouchEvents:'ontouchstart'in globalThis;_this.supportsPointerEvents=supportsPointerEvents!==null&&supportsPointerEvents!==void 0?supportsPointerEvents:!!globalThis.PointerEvent;_this.isTouchEvent=isTouchEvent!==null&&isTouchEvent!==void 0?isTouchEvent:function(event){return _this.supportsTouchEvents&&event instanceof globalThis.TouchEvent;};_this.isMouseEvent=isMouseEvent!==null&&isMouseEvent!==void 0?isMouseEvent:function(event){return !globalThis.MouseEvent||event instanceof globalThis.MouseEvent&&(!_this.supportsPointerEvents||!(event instanceof 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});_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){var _this2=this;this.container.register({token:CanvasConfig,useValue:mergedConfig});// bind rendering context, shared by all renderers
|
|
12962
|
+
_this.supportsTouchEvents=supportsTouchEvents!==null&&supportsTouchEvents!==void 0?supportsTouchEvents:'ontouchstart'in globalThis;_this.supportsPointerEvents=supportsPointerEvents!==null&&supportsPointerEvents!==void 0?supportsPointerEvents:!!globalThis.PointerEvent;_this.isTouchEvent=isTouchEvent!==null&&isTouchEvent!==void 0?isTouchEvent:function(event){return _this.supportsTouchEvents&&event instanceof globalThis.TouchEvent;};_this.isMouseEvent=isMouseEvent!==null&&isMouseEvent!==void 0?isMouseEvent:function(event){return !globalThis.MouseEvent||event instanceof globalThis.MouseEvent&&(!_this.supportsPointerEvents||!(event instanceof 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});_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){var _this2=this;this.container.register({token:CanvasConfig,useValue:mergedConfig});// bind rendering context, shared by all renderers
|
|
12951
12963
|
this.container.register({token:RenderingContext,useValue:{/**
|
|
12952
12964
|
* the root node in scene graph
|
|
12953
12965
|
*/root:this.document.documentElement,renderListCurrentFrame:[],unculledEntities:[],renderReasons:new Set(),force:false,dirty:false}});this.document.documentElement.addEventListener(exports.ElementEvent.CHILD_INSERTED,function(e){_this2.mountChildren(e.detail.child);});this.document.documentElement.addEventListener(exports.ElementEvent.CHILD_REMOVED,function(e){_this2.unmountChildren(e.detail.child);});};_proto.initDefaultCamera=function initDefaultCamera(width,height){// set a default ortho camera
|
|
@@ -18462,6 +18474,7 @@
|
|
|
18462
18474
|
exports.parsePath = parsePath;
|
|
18463
18475
|
exports.propertyMetadataCache = propertyMetadataCache;
|
|
18464
18476
|
exports.rad2deg = rad2deg;
|
|
18477
|
+
exports.resetEntityCounter = resetEntityCounter;
|
|
18465
18478
|
exports.setDOMSize = setDOMSize;
|
|
18466
18479
|
exports.singleton = singleton;
|
|
18467
18480
|
exports.styleValueRegistry = styleValueRegistry;
|