@antv/g 5.15.14 → 5.15.17
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 +960 -980
- package/dist/index.umd.min.js +1 -1
- package/package.json +8 -8
package/dist/index.umd.js
CHANGED
|
@@ -2794,36 +2794,6 @@
|
|
|
2794
2794
|
out[2] = a[2] * b[2];
|
|
2795
2795
|
return out;
|
|
2796
2796
|
}
|
|
2797
|
-
/**
|
|
2798
|
-
* Returns the minimum of two vec3's
|
|
2799
|
-
*
|
|
2800
|
-
* @param {vec3} out the receiving vector
|
|
2801
|
-
* @param {ReadonlyVec3} a the first operand
|
|
2802
|
-
* @param {ReadonlyVec3} b the second operand
|
|
2803
|
-
* @returns {vec3} out
|
|
2804
|
-
*/
|
|
2805
|
-
|
|
2806
|
-
function min(out, a, b) {
|
|
2807
|
-
out[0] = Math.min(a[0], b[0]);
|
|
2808
|
-
out[1] = Math.min(a[1], b[1]);
|
|
2809
|
-
out[2] = Math.min(a[2], b[2]);
|
|
2810
|
-
return out;
|
|
2811
|
-
}
|
|
2812
|
-
/**
|
|
2813
|
-
* Returns the maximum of two vec3's
|
|
2814
|
-
*
|
|
2815
|
-
* @param {vec3} out the receiving vector
|
|
2816
|
-
* @param {ReadonlyVec3} a the first operand
|
|
2817
|
-
* @param {ReadonlyVec3} b the second operand
|
|
2818
|
-
* @returns {vec3} out
|
|
2819
|
-
*/
|
|
2820
|
-
|
|
2821
|
-
function max(out, a, b) {
|
|
2822
|
-
out[0] = Math.max(a[0], b[0]);
|
|
2823
|
-
out[1] = Math.max(a[1], b[1]);
|
|
2824
|
-
out[2] = Math.max(a[2], b[2]);
|
|
2825
|
-
return out;
|
|
2826
|
-
}
|
|
2827
2797
|
/**
|
|
2828
2798
|
* Scales a vec3 by a scalar number
|
|
2829
2799
|
*
|
|
@@ -3027,12 +2997,6 @@
|
|
|
3027
2997
|
b2 = b[2];
|
|
3028
2998
|
return Math.abs(a0 - b0) <= EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));
|
|
3029
2999
|
}
|
|
3030
|
-
/**
|
|
3031
|
-
* Alias for {@link vec3.subtract}
|
|
3032
|
-
* @function
|
|
3033
|
-
*/
|
|
3034
|
-
|
|
3035
|
-
var sub$1 = subtract$1;
|
|
3036
3000
|
/**
|
|
3037
3001
|
* Alias for {@link vec3.distance}
|
|
3038
3002
|
* @function
|
|
@@ -5353,7 +5317,7 @@
|
|
|
5353
5317
|
* // => 1250010
|
|
5354
5318
|
* // Math.max(...data) will encounter "Maximum call stack size exceeded" error
|
|
5355
5319
|
*/
|
|
5356
|
-
var max
|
|
5320
|
+
var max = (function (arr) {
|
|
5357
5321
|
if (!isArray(arr)) {
|
|
5358
5322
|
return undefined;
|
|
5359
5323
|
}
|
|
@@ -5379,7 +5343,7 @@
|
|
|
5379
5343
|
* // => 1250010
|
|
5380
5344
|
* // Math.min(...data) will encounter "Maximum call stack size exceeded" error
|
|
5381
5345
|
*/
|
|
5382
|
-
var min
|
|
5346
|
+
var min = (function (arr) {
|
|
5383
5347
|
if (!isArray(arr)) {
|
|
5384
5348
|
return undefined;
|
|
5385
5349
|
}
|
|
@@ -7071,34 +7035,7 @@
|
|
|
7071
7035
|
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
7072
7036
|
*/PropertySyntax["LIST_OF_POINTS"]="<list-of-points>";PropertySyntax["PATH"]="<path>";/**
|
|
7073
7037
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
7074
|
-
*/PropertySyntax["FILTER"]="<filter>";PropertySyntax["Z_INDEX"]="<z-index>";PropertySyntax["OFFSET_DISTANCE"]="<offset-distance>";PropertySyntax["DEFINED_PATH"]="<defined-path>";PropertySyntax["MARKER"]="<marker>";PropertySyntax["TRANSFORM"]="<transform>";PropertySyntax["TRANSFORM_ORIGIN"]="<transform-origin>";PropertySyntax["TEXT"]="<text>";PropertySyntax["TEXT_TRANSFORM"]="<text-transform>";})(exports.PropertySyntax||(exports.PropertySyntax={}));/**
|
|
7075
|
-
* Axis-Aligned Bounding Box
|
|
7076
|
-
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
7077
|
-
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
7078
|
-
*/var AABB=/*#__PURE__*/function(){AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};function AABB(center,halfExtents){if(center===void 0){center=[0,0,0];}if(halfExtents===void 0){halfExtents=[0,0,0];}this.center=create$2();this.halfExtents=create$2();this.min=create$2();this.max=create$2();this.update(center,halfExtents);}var _proto=AABB.prototype;_proto.update=function update(center,halfExtents){copy$1(this.center,center);copy$1(this.halfExtents,halfExtents);sub$1(this.min,this.center,this.halfExtents);add$1(this.max,this.center,this.halfExtents);};_proto.setMinMax=function setMinMax(min,max){add$1(this.center,max,min);scale$1(this.center,this.center,0.5);sub$1(this.halfExtents,max,min);scale$1(this.halfExtents,this.halfExtents,0.5);copy$1(this.min,min);copy$1(this.max,max);};_proto.getMin=function getMin(){return this.min;};_proto.getMax=function getMax(){return this.max;};_proto.add=function add(aabb){if(AABB.isEmpty(aabb)){return;}if(AABB.isEmpty(this)){this.setMinMax(aabb.getMin(),aabb.getMax());return;}var tc=this.center;var tcx=tc[0];var tcy=tc[1];var tcz=tc[2];var th=this.halfExtents;var thx=th[0];var thy=th[1];var thz=th[2];var tminx=tcx-thx;var tmaxx=tcx+thx;var tminy=tcy-thy;var tmaxy=tcy+thy;var tminz=tcz-thz;var tmaxz=tcz+thz;var oc=aabb.center;var ocx=oc[0];var ocy=oc[1];var ocz=oc[2];var oh=aabb.halfExtents;var ohx=oh[0];var ohy=oh[1];var ohz=oh[2];var ominx=ocx-ohx;var omaxx=ocx+ohx;var ominy=ocy-ohy;var omaxy=ocy+ohy;var ominz=ocz-ohz;var omaxz=ocz+ohz;if(ominx<tminx){tminx=ominx;}if(omaxx>tmaxx){tmaxx=omaxx;}if(ominy<tminy){tminy=ominy;}if(omaxy>tmaxy){tmaxy=omaxy;}if(ominz<tminz){tminz=ominz;}if(omaxz>tmaxz){tmaxz=omaxz;}tc[0]=(tminx+tmaxx)*0.5;tc[1]=(tminy+tmaxy)*0.5;tc[2]=(tminz+tmaxz)*0.5;th[0]=(tmaxx-tminx)*0.5;th[1]=(tmaxy-tminy)*0.5;th[2]=(tmaxz-tminz)*0.5;this.min[0]=tminx;this.min[1]=tminy;this.min[2]=tminz;this.max[0]=tmaxx;this.max[1]=tmaxy;this.max[2]=tmaxz;};_proto.setFromTransformedAABB=function setFromTransformedAABB(aabb,m){var bc=this.center;var br=this.halfExtents;var ac=aabb.center;var ar=aabb.halfExtents;var mx0=m[0];var mx1=m[4];var mx2=m[8];var my0=m[1];var my1=m[5];var my2=m[9];var mz0=m[2];var mz1=m[6];var mz2=m[10];var mx0a=Math.abs(mx0);var mx1a=Math.abs(mx1);var mx2a=Math.abs(mx2);var my0a=Math.abs(my0);var my1a=Math.abs(my1);var my2a=Math.abs(my2);var mz0a=Math.abs(mz0);var mz1a=Math.abs(mz1);var mz2a=Math.abs(mz2);set$1(bc,m[12]+mx0*ac[0]+mx1*ac[1]+mx2*ac[2],m[13]+my0*ac[0]+my1*ac[1]+my2*ac[2],m[14]+mz0*ac[0]+mz1*ac[1]+mz2*ac[2]);set$1(br,mx0a*ar[0]+mx1a*ar[1]+mx2a*ar[2],my0a*ar[0]+my1a*ar[1]+my2a*ar[2],mz0a*ar[0]+mz1a*ar[1]+mz2a*ar[2]);this.min=sub$1(this.min,bc,br);this.max=add$1(this.max,bc,br);};_proto.intersects=function intersects(aabb){var aMax=this.getMax();var aMin=this.getMin();var bMax=aabb.getMax();var bMin=aabb.getMin();return aMin[0]<=bMax[0]&&aMax[0]>=bMin[0]&&aMin[1]<=bMax[1]&&aMax[1]>=bMin[1]&&aMin[2]<=bMax[2]&&aMax[2]>=bMin[2];};_proto.intersection=function intersection(aabb){if(!this.intersects(aabb)){return null;}var intersection=new AABB();var min$1=max(create$2(),this.getMin(),aabb.getMin());var max$1=min(create$2(),this.getMax(),aabb.getMax());intersection.setMinMax(min$1,max$1);return intersection;};_proto.containsPoint=function containsPoint(point){var min=this.getMin();var max=this.getMax();return !(point[0]<min[0]||point[0]>max[0]||point[1]<min[1]||point[1]>max[1]||point[2]<min[2]||point[2]>max[2]);}/**
|
|
7079
|
-
* get n-vertex
|
|
7080
|
-
* @param plane plane of CullingVolume
|
|
7081
|
-
*/;_proto.getNegativeFarPoint=function getNegativeFarPoint(plane){if(plane.pnVertexFlag===0x111){return copy$1(create$2(),this.min);}else if(plane.pnVertexFlag===0x110){return fromValues$2(this.min[0],this.min[1],this.max[2]);}else if(plane.pnVertexFlag===0x101){return fromValues$2(this.min[0],this.max[1],this.min[2]);}else if(plane.pnVertexFlag===0x100){return fromValues$2(this.min[0],this.max[1],this.max[2]);}else if(plane.pnVertexFlag===0x011){return fromValues$2(this.max[0],this.min[1],this.min[2]);}else if(plane.pnVertexFlag===0x010){return fromValues$2(this.max[0],this.min[1],this.max[2]);}else if(plane.pnVertexFlag===0x001){return fromValues$2(this.max[0],this.max[1],this.min[2]);}else {return fromValues$2(this.max[0],this.max[1],this.max[2]);}}/**
|
|
7082
|
-
* get p-vertex
|
|
7083
|
-
* @param plane plane of CullingVolume
|
|
7084
|
-
*/;_proto.getPositiveFarPoint=function getPositiveFarPoint(plane){if(plane.pnVertexFlag===0x111){return copy$1(create$2(),this.max);}else if(plane.pnVertexFlag===0x110){return fromValues$2(this.max[0],this.max[1],this.min[2]);}else if(plane.pnVertexFlag===0x101){return fromValues$2(this.max[0],this.min[1],this.max[2]);}else if(plane.pnVertexFlag===0x100){return fromValues$2(this.max[0],this.min[1],this.min[2]);}else if(plane.pnVertexFlag===0x011){return fromValues$2(this.min[0],this.max[1],this.max[2]);}else if(plane.pnVertexFlag===0x010){return fromValues$2(this.min[0],this.max[1],this.min[2]);}else if(plane.pnVertexFlag===0x001){return fromValues$2(this.min[0],this.min[1],this.max[2]);}else {return fromValues$2(this.min[0],this.min[1],this.min[2]);}};return AABB;}();var Plane=/*#__PURE__*/function(){/**
|
|
7085
|
-
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
7086
|
-
*/function Plane(distance,normal){this.distance=void 0;this.normal=void 0;this.pnVertexFlag=void 0;this.distance=distance||0;this.normal=normal||fromValues$2(0,1,0);this.updatePNVertexFlag();}var _proto=Plane.prototype;_proto.updatePNVertexFlag=function updatePNVertexFlag(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0);};_proto.distanceToPoint=function distanceToPoint(point){return dot(point,this.normal)-this.distance;};_proto.normalize=function normalize(){var invLen=1/len(this.normal);scale$1(this.normal,this.normal,invLen);this.distance*=invLen;};_proto.intersectsLine=function intersectsLine(start,end,point){var d0=this.distanceToPoint(start);var d1=this.distanceToPoint(end);var t=d0/(d0-d1);var intersects=t>=0&&t<=1;if(intersects&&point){lerp(point,start,end,t);}return intersects;};return Plane;}();(function(Mask){Mask[Mask["OUTSIDE"]=4294967295]="OUTSIDE";Mask[Mask["INSIDE"]=0]="INSIDE";Mask[Mask["INDETERMINATE"]=2147483647]="INDETERMINATE";})(exports.Mask||(exports.Mask={}));var Frustum=/*#__PURE__*/function(){function Frustum(planes){this.planes=[];if(planes){this.planes=planes;}else {for(var i=0;i<6;i++){this.planes.push(new Plane());}}}/**
|
|
7087
|
-
* extract 6 planes from projectionMatrix
|
|
7088
|
-
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
7089
|
-
*/var _proto=Frustum.prototype;_proto.extractFromVPMatrix=function extractFromVPMatrix(projectionMatrix){// @ts-ignore
|
|
7090
|
-
var m0=projectionMatrix[0],m1=projectionMatrix[1],m2=projectionMatrix[2],m3=projectionMatrix[3],m4=projectionMatrix[4],m5=projectionMatrix[5],m6=projectionMatrix[6],m7=projectionMatrix[7],m8=projectionMatrix[8],m9=projectionMatrix[9],m10=projectionMatrix[10],m11=projectionMatrix[11],m12=projectionMatrix[12],m13=projectionMatrix[13],m14=projectionMatrix[14],m15=projectionMatrix[15];// right
|
|
7091
|
-
set$1(this.planes[0].normal,m3-m0,m7-m4,m11-m8);this.planes[0].distance=m15-m12;// left
|
|
7092
|
-
set$1(this.planes[1].normal,m3+m0,m7+m4,m11+m8);this.planes[1].distance=m15+m12;// bottom
|
|
7093
|
-
set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
|
|
7094
|
-
set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
|
|
7095
|
-
set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
|
|
7096
|
-
set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();(function(Shape){Shape["GROUP"]="g";Shape["CIRCLE"]="circle";Shape["ELLIPSE"]="ellipse";Shape["IMAGE"]="image";Shape["RECT"]="rect";Shape["LINE"]="line";Shape["POLYLINE"]="polyline";Shape["POLYGON"]="polygon";Shape["TEXT"]="text";Shape["PATH"]="path";Shape["HTML"]="html";Shape["MESH"]="mesh";})(exports.Shape||(exports.Shape={}));function memoize(func,resolver){if(typeof func!=='function'||resolver!=null&&typeof resolver!=='function'){throw new TypeError('Expected a function');}var memoized=function memoized(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var key=resolver?resolver.apply(this,args):args[0];var cache=memoized.cache;if(cache.has(key)){return cache.get(key);}var result=func.apply(this,args);memoized.cache=cache.set(key,result)||cache;return result;};memoized.cache=new(memoize.Cache||Map)();return memoized;}memoize.Cache=Map;var camelCase=memoize(function(str){if(str===void 0){str='';}return str.replace(/-([a-z])/g,function(g){return g[1].toUpperCase();});});function DCHECK(bool){if(!bool){throw new Error();}}function DCHECK_EQ(a,b){if(a!==b){throw new Error();}}function DCHECK_NE(a,b){if(a===b){throw new Error();}}function isFunction(func){return typeof func==='function';}function isSymbol(value){// @see https://github.com/lodash/lodash/blob/master/isSymbol.js
|
|
7097
|
-
return typeof value==='symbol';}var definedProps=function definedProps(obj){return Object.fromEntries(Object.entries(obj).filter(function(_ref){var v=_ref[1];return v!==undefined;}));};var FORMAT_ATTR_MAP={d:{alias:'path'},strokeDasharray:{alias:'lineDash'},strokeWidth:{alias:'lineWidth'},textAnchor:{alias:'textAlign'},src:{alias:'img'}};var formatAttributeName=memoize(function(name){var attributeName=camelCase(name);var map=FORMAT_ATTR_MAP[attributeName];attributeName=(map===null||map===void 0?void 0:map.alias)||attributeName;return attributeName;});var canvasMap={};var defaultCanvasIdCounter=0;/**
|
|
7098
|
-
* destroy existed canvas with the same id
|
|
7099
|
-
*/function cleanExistedCanvas(container,canvas){if(container){var id=typeof container==='string'?container:container.id||defaultCanvasIdCounter++;if(canvasMap[id]){canvasMap[id].destroy();}canvasMap[id]=canvas;}}var isBrowser=typeof window!=='undefined'&&typeof window.document!=='undefined';function sortByZIndex(o1,o2){var zIndex1=Number(o1.style.zIndex);var zIndex2=Number(o2.style.zIndex);if(zIndex1===zIndex2){// return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
|
|
7100
|
-
var parent=o1.parentNode;if(parent){var children=parent.childNodes||[];return children.indexOf(o1)-children.indexOf(o2);}}return zIndex1-zIndex2;}function findClosestClipPathTarget(object){var el=object;do{var _el$style;var clipPath=(_el$style=el.style)===null||_el$style===void 0?void 0:_el$style.clipPath;if(clipPath)return el;el=el.parentElement;}while(el!==null);return null;}var PX_SUFFIX='px';function setDOMSize($el,width,height){if(isBrowser&&$el.style){$el.style.width=width+PX_SUFFIX;$el.style.height=height+PX_SUFFIX;}}function getStyle($el,property){if(isBrowser){return document.defaultView.getComputedStyle($el,null).getPropertyValue(property);}}function getWidth($el){var width=getStyle($el,'width');if(width==='auto'){return $el.offsetWidth;}return parseFloat(width);}function getHeight($el){var height=getStyle($el,'height');if(height==='auto'){return $el.offsetHeight;}return parseFloat(height);}var ERROR_MSG_METHOD_NOT_IMPLEMENTED='Method not implemented.';var ERROR_MSG_USE_DOCUMENT_ELEMENT='Use document.documentElement instead.';var ERROR_MSG_APPEND_DESTROYED_ELEMENT='Cannot append a destroyed element.';// borrow from hammer.js
|
|
7101
|
-
var MOUSE_POINTER_ID=1;var TOUCH_TO_POINTER={touchstart:'pointerdown',touchend:'pointerup',touchendoutside:'pointerupoutside',touchmove:'pointermove',touchcancel:'pointercancel'};function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return exports;};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,defineProperty=Object.defineProperty||function(obj,key,desc){obj[key]=desc.value;},$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key];}try{define({},"");}catch(err){define=function define(obj,key,value){return obj[key]=value;};}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return defineProperty(generator,"_invoke",{value:makeInvokeMethod(innerFn,self,context)}),generator;}function tryCatch(fn,obj,arg){try{return {type:"normal",arg:fn.call(obj,arg)};}catch(err){return {type:"throw",arg:err};}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this;});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg);});});}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==typeof value&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject);},function(err){invoke("throw",err,resolve,reject);}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result);},function(error){return invoke("throw",error,resolve,reject);});}reject(record.arg);}var previousPromise;defineProperty(this,"_invoke",{value:function value(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject);});}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult();}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult;}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg);}else "return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return {value:record.arg,done:context.done};}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg);}};}function maybeInvokeDelegate(delegate,context){var methodName=context.method,method=delegate.iterator[methodName];if(undefined===method)return context.delegate=null,"throw"===methodName&&delegate.iterator.return&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method)||"return"!==methodName&&(context.method="throw",context.arg=new TypeError("The iterator does not provide a '"+methodName+"' method")),ContinueSentinel;var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel);}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry);}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record;}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0);}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;){if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;}return next.value=undefined,next.done=!0,next;};return next.next=next;}}return {next:doneResult};}function doneResult(){return {value:undefined,done:!0};}return GeneratorFunction.prototype=GeneratorFunctionPrototype,defineProperty(Gp,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),defineProperty(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return !!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name));},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun;},exports.awrap=function(arg){return {__await:arg};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this;}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next();});},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this;}),define(Gp,"toString",function(){return "[object Generator]";}),exports.keys=function(val){var object=Object(val),keys=[];for(var key in object){keys.push(key);}return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next;}return next.done=!0,next;};},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this){"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=undefined);}},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval;},dispatchException:function dispatchException(exception){if(this.done)throw exception;var context=this;function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=undefined),!!caught;}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}else if(hasCatch){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);}else {if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}}}},abrupt:function abrupt(type,arg){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break;}}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record);},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return "break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel;},finish:function finish(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel;}},catch:function _catch(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry);}return thrown;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel;}},exports;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _extends(){_extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return {};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _createForOfIteratorHelperLoose(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(it)return (it=it.call(o)).next.bind(it);if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;return function(){if(i>=o.length)return {done:true};return {done:false,value:o[i++]};};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return (hint==="string"?String:Number)(input);}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}// These units are iterated through, so be careful when adding or changing the
|
|
7038
|
+
*/PropertySyntax["FILTER"]="<filter>";PropertySyntax["Z_INDEX"]="<z-index>";PropertySyntax["OFFSET_DISTANCE"]="<offset-distance>";PropertySyntax["DEFINED_PATH"]="<defined-path>";PropertySyntax["MARKER"]="<marker>";PropertySyntax["TRANSFORM"]="<transform>";PropertySyntax["TRANSFORM_ORIGIN"]="<transform-origin>";PropertySyntax["TEXT"]="<text>";PropertySyntax["TEXT_TRANSFORM"]="<text-transform>";})(exports.PropertySyntax||(exports.PropertySyntax={}));function _regeneratorRuntime(){_regeneratorRuntime=function _regeneratorRuntime(){return exports;};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,defineProperty=Object.defineProperty||function(obj,key,desc){obj[key]=desc.value;},$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key];}try{define({},"");}catch(err){define=function define(obj,key,value){return obj[key]=value;};}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return defineProperty(generator,"_invoke",{value:makeInvokeMethod(innerFn,self,context)}),generator;}function tryCatch(fn,obj,arg){try{return {type:"normal",arg:fn.call(obj,arg)};}catch(err){return {type:"throw",arg:err};}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this;});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg);});});}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==typeof value&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject);},function(err){invoke("throw",err,resolve,reject);}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result);},function(error){return invoke("throw",error,resolve,reject);});}reject(record.arg);}var previousPromise;defineProperty(this,"_invoke",{value:function value(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject);});}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg();}});}function makeInvokeMethod(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult();}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult;}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg);}else "return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return {value:record.arg,done:context.done};}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg);}};}function maybeInvokeDelegate(delegate,context){var methodName=context.method,method=delegate.iterator[methodName];if(undefined===method)return context.delegate=null,"throw"===methodName&&delegate.iterator.return&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method)||"return"!==methodName&&(context.method="throw",context.arg=new TypeError("The iterator does not provide a '"+methodName+"' method")),ContinueSentinel;var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel);}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry);}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record;}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0);}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i<iterable.length;){if(hasOwn.call(iterable,i))return next.value=iterable[i],next.done=!1,next;}return next.value=undefined,next.done=!0,next;};return next.next=next;}}return {next:doneResult};}function doneResult(){return {value:undefined,done:!0};}return GeneratorFunction.prototype=GeneratorFunctionPrototype,defineProperty(Gp,"constructor",{value:GeneratorFunctionPrototype,configurable:!0}),defineProperty(GeneratorFunctionPrototype,"constructor",{value:GeneratorFunction,configurable:!0}),GeneratorFunction.displayName=define(GeneratorFunctionPrototype,toStringTagSymbol,"GeneratorFunction"),exports.isGeneratorFunction=function(genFun){var ctor="function"==typeof genFun&&genFun.constructor;return !!ctor&&(ctor===GeneratorFunction||"GeneratorFunction"===(ctor.displayName||ctor.name));},exports.mark=function(genFun){return Object.setPrototypeOf?Object.setPrototypeOf(genFun,GeneratorFunctionPrototype):(genFun.__proto__=GeneratorFunctionPrototype,define(genFun,toStringTagSymbol,"GeneratorFunction")),genFun.prototype=Object.create(Gp),genFun;},exports.awrap=function(arg){return {__await:arg};},defineIteratorMethods(AsyncIterator.prototype),define(AsyncIterator.prototype,asyncIteratorSymbol,function(){return this;}),exports.AsyncIterator=AsyncIterator,exports.async=function(innerFn,outerFn,self,tryLocsList,PromiseImpl){void 0===PromiseImpl&&(PromiseImpl=Promise);var iter=new AsyncIterator(wrap(innerFn,outerFn,self,tryLocsList),PromiseImpl);return exports.isGeneratorFunction(outerFn)?iter:iter.next().then(function(result){return result.done?result.value:iter.next();});},defineIteratorMethods(Gp),define(Gp,toStringTagSymbol,"Generator"),define(Gp,iteratorSymbol,function(){return this;}),define(Gp,"toString",function(){return "[object Generator]";}),exports.keys=function(val){var object=Object(val),keys=[];for(var key in object){keys.push(key);}return keys.reverse(),function next(){for(;keys.length;){var key=keys.pop();if(key in object)return next.value=key,next.done=!1,next;}return next.done=!0,next;};},exports.values=values,Context.prototype={constructor:Context,reset:function reset(skipTempReset){if(this.prev=0,this.next=0,this.sent=this._sent=undefined,this.done=!1,this.delegate=null,this.method="next",this.arg=undefined,this.tryEntries.forEach(resetTryEntry),!skipTempReset)for(var name in this){"t"===name.charAt(0)&&hasOwn.call(this,name)&&!isNaN(+name.slice(1))&&(this[name]=undefined);}},stop:function stop(){this.done=!0;var rootRecord=this.tryEntries[0].completion;if("throw"===rootRecord.type)throw rootRecord.arg;return this.rval;},dispatchException:function dispatchException(exception){if(this.done)throw exception;var context=this;function handle(loc,caught){return record.type="throw",record.arg=exception,context.next=loc,caught&&(context.method="next",context.arg=undefined),!!caught;}for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}else if(hasCatch){if(this.prev<entry.catchLoc)return handle(entry.catchLoc,!0);}else {if(!hasFinally)throw new Error("try statement without catch or finally");if(this.prev<entry.finallyLoc)return handle(entry.finallyLoc);}}}},abrupt:function abrupt(type,arg){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev<entry.finallyLoc){var finallyEntry=entry;break;}}finallyEntry&&("break"===type||"continue"===type)&&finallyEntry.tryLoc<=arg&&arg<=finallyEntry.finallyLoc&&(finallyEntry=null);var record=finallyEntry?finallyEntry.completion:{};return record.type=type,record.arg=arg,finallyEntry?(this.method="next",this.next=finallyEntry.finallyLoc,ContinueSentinel):this.complete(record);},complete:function complete(record,afterLoc){if("throw"===record.type)throw record.arg;return "break"===record.type||"continue"===record.type?this.next=record.arg:"return"===record.type?(this.rval=this.arg=record.arg,this.method="return",this.next="end"):"normal"===record.type&&afterLoc&&(this.next=afterLoc),ContinueSentinel;},finish:function finish(finallyLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel;}},catch:function _catch(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry);}return thrown;}}throw new Error("illegal catch attempt");},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel;}},exports;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else {Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,_toPropertyKey(descriptor.key),descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);Object.defineProperty(Constructor,"prototype",{writable:false});return Constructor;}function _extends(){_extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}function _inheritsLoose(subClass,superClass){subClass.prototype=Object.create(superClass.prototype);subClass.prototype.constructor=subClass;_setPrototypeOf(subClass,superClass);}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o;};return _setPrototypeOf(o,p);}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return {};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return self;}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _createForOfIteratorHelperLoose(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(it)return (it=it.call(o)).next.bind(it);if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;return function(){if(i>=o.length)return {done:true};return {done:false,value:o[i++]};};}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _toPrimitive(input,hint){if(typeof input!=="object"||input===null)return input;var prim=input[Symbol.toPrimitive];if(prim!==undefined){var res=prim.call(input,hint||"default");if(typeof res!=="object")return res;throw new TypeError("@@toPrimitive must return a primitive value.");}return (hint==="string"?String:Number)(input);}function _toPropertyKey(arg){var key=_toPrimitive(arg,"string");return typeof key==="symbol"?key:String(key);}// These units are iterated through, so be careful when adding or changing the
|
|
7102
7039
|
// order.
|
|
7103
7040
|
(function(UnitType){UnitType[UnitType["kUnknown"]=0]="kUnknown";UnitType[UnitType["kNumber"]=1]="kNumber";UnitType[UnitType["kPercentage"]=2]="kPercentage";// Length units
|
|
7104
7041
|
UnitType[UnitType["kEms"]=3]="kEms";// kExs,
|
|
@@ -7483,127 +7420,39 @@
|
|
|
7483
7420
|
* eg. 'initial'
|
|
7484
7421
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSKeywordValue
|
|
7485
7422
|
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_keyword_value.idl
|
|
7486
|
-
*/var CSSKeywordValue=/*#__PURE__*/function(_CSSStyleValue){_inheritsLoose(CSSKeywordValue,_CSSStyleValue);function CSSKeywordValue(value){var _this;_this=_CSSStyleValue.call(this)||this;_this.value=void 0;_this.value=value;return _this;}var _proto=CSSKeywordValue.prototype;_proto.clone=function clone(){return new CSSKeywordValue(this.value);};_proto.getType=function getType(){return CSSStyleValueType.kKeywordType;};_proto.buildCSSText=function buildCSSText(n,p,result){return result+this.value;};return CSSKeywordValue;}(CSSStyleValue);
|
|
7487
|
-
var
|
|
7488
|
-
|
|
7489
|
-
//
|
|
7490
|
-
//
|
|
7491
|
-
//
|
|
7492
|
-
//
|
|
7493
|
-
//
|
|
7494
|
-
//
|
|
7495
|
-
//
|
|
7496
|
-
//
|
|
7497
|
-
//
|
|
7498
|
-
//
|
|
7499
|
-
//
|
|
7500
|
-
//
|
|
7501
|
-
//
|
|
7502
|
-
//
|
|
7503
|
-
//
|
|
7504
|
-
//
|
|
7505
|
-
//
|
|
7506
|
-
|
|
7507
|
-
// case UnitType.kLargeViewportWidth:
|
|
7508
|
-
// case UnitType.kLargeViewportHeight:
|
|
7509
|
-
// case UnitType.kLargeViewportInlineSize:
|
|
7510
|
-
// case UnitType.kLargeViewportBlockSize:
|
|
7511
|
-
// case UnitType.kLargeViewportMin:
|
|
7512
|
-
// case UnitType.kLargeViewportMax:
|
|
7513
|
-
// case UnitType.kDynamicViewportWidth:
|
|
7514
|
-
// case UnitType.kDynamicViewportHeight:
|
|
7515
|
-
// case UnitType.kDynamicViewportInlineSize:
|
|
7516
|
-
// case UnitType.kDynamicViewportBlockSize:
|
|
7517
|
-
// case UnitType.kDynamicViewportMin:
|
|
7518
|
-
// case UnitType.kDynamicViewportMax:
|
|
7519
|
-
// case UnitType.kContainerWidth:
|
|
7520
|
-
// case UnitType.kContainerHeight:
|
|
7521
|
-
// case UnitType.kContainerInlineSize:
|
|
7522
|
-
// case UnitType.kContainerBlockSize:
|
|
7523
|
-
// case UnitType.kContainerMin:
|
|
7524
|
-
// case UnitType.kContainerMax:
|
|
7525
|
-
case exports.UnitType.kRems:// case UnitType.kChs:
|
|
7526
|
-
return BaseType.kLength;case exports.UnitType.kMilliseconds:case exports.UnitType.kSeconds:return BaseType.kTime;case exports.UnitType.kDegrees:case exports.UnitType.kRadians:case exports.UnitType.kGradians:case exports.UnitType.kTurns:return BaseType.kAngle;// case UnitType.kHertz:
|
|
7527
|
-
// case UnitType.kKilohertz:
|
|
7528
|
-
// return BaseType.kFrequency;
|
|
7529
|
-
// case UnitType.kDotsPerPixel:
|
|
7530
|
-
// case UnitType.kDotsPerInch:
|
|
7531
|
-
// case UnitType.kDotsPerCentimeter:
|
|
7532
|
-
// return BaseType.kResolution;
|
|
7533
|
-
// case UnitType.kFraction:
|
|
7534
|
-
// return BaseType.kFlex;
|
|
7535
|
-
case exports.UnitType.kPercentage:return BaseType.kPercent;default:return BaseType.kLength;}}function baseTypeToString(baseType){switch(baseType){case BaseType.kLength:return 'length';case BaseType.kAngle:return 'angle';case BaseType.kTime:return 'time';case BaseType.kFrequency:return 'frequency';case BaseType.kResolution:return 'resolution';case BaseType.kFlex:return 'flex';case BaseType.kPercent:return 'percent';}return '';}var CSSNumericValueType=/*#__PURE__*/function(){function CSSNumericValueType(unit,exponent){if(unit===void 0){unit=exports.UnitType.kNumber;}if(exponent===void 0){exponent=1;}this.exponents=[];this.numNonZeroEntries=0;this.percentHint=BaseType.kPercent;this.hasPercentHint=false;this.exponents=new Array(BaseType.kNumBaseTypes).fill(0);if(unit!==exports.UnitType.kNumber){this.setExponent(unitTypeToBaseType(unit),exponent);}}var _proto=CSSNumericValueType.prototype;_proto.applyPercentHint=function applyPercentHint(hint){DCHECK_NE(hint,BaseType.kPercent);this.setExponent(hint,this.exponent(hint)+this.exponent(BaseType.kPercent));this.setExponent(BaseType.kPercent,0);this.percentHint=hint;this.hasPercentHint=true;};_proto.hasNonZeroEntries=function hasNonZeroEntries(){return this.numNonZeroEntries>0;};_proto.isOnlyNonZeroEntry=function isOnlyNonZeroEntry(baseType,value){DCHECK_NE(value,0);return this.numNonZeroEntries===1&&this.exponent(baseType)===value;};_proto.exponent=function exponent(type){return this.exponents[type];};_proto.setExponent=function setExponent(type,newValue){var oldValue=this.exponents[type];if(oldValue==0&&newValue!==0){this.numNonZeroEntries++;}else if(oldValue!==0&&newValue==0){this.numNonZeroEntries--;}this.exponents[type]=newValue;};CSSNumericValueType.negateExponents=function negateExponents(type){type.exponents.forEach(function(v){return v*=-1;});return type;};_proto.matchesBaseType=function matchesBaseType(baseType){DCHECK_NE(baseType,BaseType.kPercent);return this.isOnlyNonZeroEntry(baseType,1)&&!this.hasPercentHint;};_proto.matchesPercentage=function matchesPercentage(){return this.isOnlyNonZeroEntry(BaseType.kPercent,1);};_proto.matchesBaseTypePercentage=function matchesBaseTypePercentage(baseType){DCHECK_NE(baseType,BaseType.kPercent);return this.isOnlyNonZeroEntry(baseType,1)||this.isOnlyNonZeroEntry(BaseType.kPercent,1);};_proto.matchesNumber=function matchesNumber(){return !this.hasNonZeroEntries()&&!this.hasPercentHint;};_proto.matchesNumberPercentage=function matchesNumberPercentage(){return !this.hasNonZeroEntries()||this.isOnlyNonZeroEntry(BaseType.kPercent,1);};CSSNumericValueType.add=function add(type1,type2,error){if(type1.hasPercentHint&&type2.hasPercentHint&&type1.percentHint!=type2.percentHint){return type1;}if(type1.hasPercentHint)type2.applyPercentHint(type1.percentHint);else if(type2.hasPercentHint)type1.applyPercentHint(type2.percentHint);DCHECK_EQ(type1.percentHint,type2.percentHint);// Match up base types. Try to use the percent hint to match up any
|
|
7536
|
-
// differences.
|
|
7537
|
-
for(var i=0;i<BaseType.kNumBaseTypes;++i){var base_type=i;if(type1.exponents[i]!==type2.exponents[i]){if(base_type!==BaseType.kPercent){type1.applyPercentHint(base_type);type2.applyPercentHint(base_type);}if(type1.exponents[i]!==type2.exponents[i]){return type1;}}}return type1;};CSSNumericValueType.multiply=function multiply(type1,type2,error){if(type1.hasPercentHint&&type2.hasPercentHint&&type1.percentHint!=type2.percentHint){return type1;}if(type1.hasPercentHint)type2.applyPercentHint(type1.percentHint);else if(type2.hasPercentHint)type1.applyPercentHint(type2.percentHint);for(var i=0;i<BaseType.kNumBaseTypes;++i){var base_type=i;type1.setExponent(base_type,type1.exponent(base_type)+type2.exponent(base_type));}return type1;};return CSSNumericValueType;}();var fromNumberish=function fromNumberish(value){if(typeof value==='number'){return new CSSUnitValue(value,exports.UnitType.kNumber);}return value;};/**
|
|
7423
|
+
*/var CSSKeywordValue=/*#__PURE__*/function(_CSSStyleValue){_inheritsLoose(CSSKeywordValue,_CSSStyleValue);function CSSKeywordValue(value){var _this;_this=_CSSStyleValue.call(this)||this;_this.value=void 0;_this.value=value;return _this;}var _proto=CSSKeywordValue.prototype;_proto.clone=function clone(){return new CSSKeywordValue(this.value);};_proto.getType=function getType(){return CSSStyleValueType.kKeywordType;};_proto.buildCSSText=function buildCSSText(n,p,result){return result+this.value;};return CSSKeywordValue;}(CSSStyleValue);function memoize(func,resolver){if(typeof func!=='function'||resolver!=null&&typeof resolver!=='function'){throw new TypeError('Expected a function');}var memoized=function memoized(){for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var key=resolver?resolver.apply(this,args):args[0];var cache=memoized.cache;if(cache.has(key)){return cache.get(key);}var result=func.apply(this,args);memoized.cache=cache.set(key,result)||cache;return result;};memoized.cache=new(memoize.Cache||Map)();return memoized;}memoize.Cache=Map;var camelCase=memoize(function(str){if(str===void 0){str='';}return str.replace(/-([a-z])/g,function(g){return g[1].toUpperCase();});});function DCHECK(bool){if(!bool){throw new Error();}}function isFunction(func){return typeof func==='function';}function isSymbol(value){// @see https://github.com/lodash/lodash/blob/master/isSymbol.js
|
|
7424
|
+
return typeof value==='symbol';}var definedProps=function definedProps(obj){return Object.fromEntries(Object.entries(obj).filter(function(_ref){var v=_ref[1];return v!==undefined;}));};var FORMAT_ATTR_MAP={d:{alias:'path'},strokeDasharray:{alias:'lineDash'},strokeWidth:{alias:'lineWidth'},textAnchor:{alias:'textAlign'},src:{alias:'img'}};var formatAttributeName=memoize(function(name){var attributeName=camelCase(name);var map=FORMAT_ATTR_MAP[attributeName];attributeName=(map===null||map===void 0?void 0:map.alias)||attributeName;return attributeName;});// type CSSNumericBaseType =
|
|
7425
|
+
// | 'length'
|
|
7426
|
+
// | 'angle'
|
|
7427
|
+
// | 'time'
|
|
7428
|
+
// | 'frequency'
|
|
7429
|
+
// | 'resolution'
|
|
7430
|
+
// | 'flex'
|
|
7431
|
+
// | 'percent';
|
|
7432
|
+
// https://drafts.css-houdini.org/css-typed-om/#dictdef-cssnumerictype
|
|
7433
|
+
// interface CSSNumericType {
|
|
7434
|
+
// length: number;
|
|
7435
|
+
// angle: number;
|
|
7436
|
+
// time: number;
|
|
7437
|
+
// frequency: number;
|
|
7438
|
+
// resolution: number;
|
|
7439
|
+
// flex: number;
|
|
7440
|
+
// percent: number;
|
|
7441
|
+
// percentHint: CSSNumericBaseType;
|
|
7442
|
+
// }
|
|
7443
|
+
var formatInfinityOrNaN=function formatInfinityOrNaN(number,suffix){if(suffix===void 0){suffix='';}var result='';if(!Number.isFinite(number)){if(number>0)result='infinity';else result='-infinity';}else {DCHECK(Number.isNaN(number));result='NaN';}return result+=suffix;};var toCanonicalUnit=function toCanonicalUnit(unit){return canonicalUnitTypeForCategory(unitTypeToUnitCategory(unit));};/**
|
|
7538
7444
|
* CSSNumericValue is the base class for numeric and length typed CSS Values.
|
|
7539
7445
|
* @see https://drafts.css-houdini.org/css-typed-om/#numeric-objects
|
|
7540
7446
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue
|
|
7541
7447
|
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.idl
|
|
7542
|
-
*/
|
|
7543
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#296
|
|
7544
|
-
*/ // static fromPercentish(value: CSSNumberish): CSSNumericValue {
|
|
7545
|
-
// if (typeof value === 'number') {
|
|
7546
|
-
// return new CSSUnitValue(value * 100, UnitType.kPercentage);
|
|
7547
|
-
// }
|
|
7548
|
-
// return value;
|
|
7549
|
-
// }
|
|
7550
|
-
function CSSNumericValue(type_){var _this;_this=_CSSStyleValue.call(this)||this;_this.type_=void 0;_this.type_=type_;return _this;}var _proto2=CSSNumericValue.prototype;_proto2.getType=function getType(){return CSSStyleValueType.kUnknownType;}// toCSSValue() {
|
|
7551
|
-
// return null;
|
|
7552
|
-
// }
|
|
7553
|
-
/**
|
|
7554
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/equals
|
|
7555
|
-
*/;_proto2.equals=function equals(){var _this2=this;for(var _len=arguments.length,numberishes=new Array(_len),_key=0;_key<_len;_key++){numberishes[_key]=arguments[_key];}var values=cssNumberishesToNumericValues(numberishes);return values.every(function(value){return _this2.equals(value);});}/**
|
|
7556
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#439
|
|
7557
|
-
*/;_proto2.add=function add(){for(var _len2=arguments.length,numberishes=new Array(_len2),_key2=0;_key2<_len2;_key2++){numberishes[_key2]=arguments[_key2];}var values=cssNumberishesToNumericValues(numberishes);prependValueForArithmetic(CSSStyleValueType.kSumType,values,this);// eg. 1px + 2px = 3px
|
|
7558
|
-
var unitValue=maybeSimplifyAsUnitValue(values,CSSMathOperator.kAdd);if(unitValue){return unitValue;}return CSSMathSum.create(values);}/**
|
|
7559
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#452
|
|
7560
|
-
*/;_proto2.sub=function sub(){for(var _len3=arguments.length,numberishes=new Array(_len3),_key3=0;_key3<_len3;_key3++){numberishes[_key3]=arguments[_key3];}var values=cssNumberishesToNumericValues(numberishes);values=values.map(function(value){return value.negate();});prependValueForArithmetic(CSSStyleValueType.kSumType,values,this);// eg. 3px - 2px = 1px
|
|
7561
|
-
var unitValue=maybeSimplifyAsUnitValue(values,CSSMathOperator.kAdd);if(unitValue){return unitValue;}return CSSMathSum.create(values);}/**
|
|
7562
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/mul
|
|
7563
|
-
*/;_proto2.mul=function mul(){for(var _len4=arguments.length,numberishes=new Array(_len4),_key4=0;_key4<_len4;_key4++){numberishes[_key4]=arguments[_key4];}var values=cssNumberishesToNumericValues(numberishes);prependValueForArithmetic(CSSStyleValueType.kProductType,values,this);var unitValue=maybeMultiplyAsUnitValue(values);if(unitValue){return unitValue;}return CSSMathProduct.create(values);}/**
|
|
7564
|
-
* eg. calc(24px / 4%)
|
|
7565
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/div
|
|
7566
|
-
*/;_proto2.div=function div(){for(var _len5=arguments.length,numberishes=new Array(_len5),_key5=0;_key5<_len5;_key5++){numberishes[_key5]=arguments[_key5];}var values=cssNumberishesToNumericValues(numberishes);values=values.map(function(value){return value.invert();});prependValueForArithmetic(CSSStyleValueType.kProductType,values,this);var unitValue=maybeMultiplyAsUnitValue(values);if(unitValue){return unitValue;}return CSSMathProduct.create(values);};_proto2.min=function min(){for(var _len6=arguments.length,numberishes=new Array(_len6),_key6=0;_key6<_len6;_key6++){numberishes[_key6]=arguments[_key6];}var values=cssNumberishesToNumericValues(numberishes);prependValueForArithmetic(CSSStyleValueType.kMinType,values,this);var unitValue=maybeSimplifyAsUnitValue(values,CSSMathOperator.kMin);if(unitValue){return unitValue;}return CSSMathMin.create(values);};_proto2.max=function max(){for(var _len7=arguments.length,numberishes=new Array(_len7),_key7=0;_key7<_len7;_key7++){numberishes[_key7]=arguments[_key7];}var values=cssNumberishesToNumericValues(numberishes);prependValueForArithmetic(CSSStyleValueType.kMaxType,values,this);var unitValue=maybeSimplifyAsUnitValue(values,CSSMathOperator.kMax);if(unitValue){return unitValue;}return CSSMathMax.create(values);}/**
|
|
7567
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/to
|
|
7568
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#331
|
|
7569
|
-
*/;_proto2.to=function to(unitOrName){var sum=this.sumValue();if(sum.length===0||sum.length!==1)return null;var value=cssNumericSumValueEntryToUnitValue(sum[0]);if(!value)return null;var unit;if(typeof unitOrName==='string'){unit=unitFromName(unitOrName);}else {unit=unitOrName;}return value.convertTo(unit);}/**
|
|
7570
|
-
* converts the object's value to a CSSMathSum object to values of the specified unit.
|
|
7571
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/toSum
|
|
7572
|
-
*/;_proto2.toSum=function toSum(){for(var _len8=arguments.length,unit_strings=new Array(_len8),_key8=0;_key8<_len8;_key8++){unit_strings[_key8]=arguments[_key8];}for(var _i=0,_unit_strings=unit_strings;_i<_unit_strings.length;_i++){var unit_string=_unit_strings[_i];if(!CSSNumericValue.isValidUnit(unitFromName(unit_string))){return null;}}var sum=this.sumValue();if(!sum.length){return null;}var values=[];for(var _iterator=_createForOfIteratorHelperLoose(sum),_step;!(_step=_iterator()).done;){var term=_step.value;var value=cssNumericSumValueEntryToUnitValue(term);if(!value){return null;}values.push(value);}if(unit_strings.length===0){values.sort(function(a,b){return a.unit-b.unit;});// We got 'values' from a sum value, so it must be a valid CSSMathSum.
|
|
7573
|
-
var _result=CSSMathSum.create(values);DCHECK(!!_result);return _result;}var result=[];var _loop=function _loop(){var unit_string=_unit_strings2[_i2];var target_unit=unitFromName(unit_string);DCHECK(CSSNumericValue.isValidUnit(target_unit));// Collect all the terms that are compatible with this unit.
|
|
7574
|
-
// We mark used terms as null so we don't use them again.
|
|
7575
|
-
var total_value=values.reduce(function(cur_sum,value,i){if(value){var unit_value=value;var converted_value=unit_value.convertTo(target_unit);if(converted_value){cur_sum+=converted_value.value;values[i]=null;}}return cur_sum;},0);result.push(new CSSUnitValue(total_value,target_unit));};for(var _i2=0,_unit_strings2=unit_strings;_i2<_unit_strings2.length;_i2++){_loop();}if(values.some(function(v){return !!v;})){throw new Error('There were leftover terms that were not converted');}return CSSMathSum.create(result);}/**
|
|
7576
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSNumericValue/type
|
|
7577
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_numeric_value.cc#414
|
|
7578
|
-
*/;_proto2.type=function type(){var type={length:0,angle:0,time:0,frequency:0,resolution:0,flex:0,percent:0,percentHint:'length'};var exponent=this.type_.exponent(BaseType.kLength);if(exponent){type.length=exponent;}exponent=this.type_.exponent(BaseType.kAngle);if(exponent){type.angle=exponent;}exponent=this.type_.exponent(BaseType.kTime);if(exponent){type.time=exponent;}exponent=this.type_.exponent(BaseType.kFrequency);if(exponent){type.frequency=exponent;}exponent=this.type_.exponent(BaseType.kResolution);if(exponent){type.resolution=exponent;}exponent=this.type_.exponent(BaseType.kFlex);if(exponent){type.flex=exponent;}exponent=this.type_.exponent(BaseType.kPercent);if(exponent){type.percent=exponent;}if(this.type_.hasPercentHint){type.percentHint=baseTypeToString(this.type_.percentHint);}return type;};CSSNumericValue.isValidUnit=function isValidUnit(unit){// if (unit === UnitType.kUserUnits) return false;
|
|
7579
|
-
if(unit===exports.UnitType.kNumber||unit==exports.UnitType.kPercentage||this.isLength(unit)||this.isAngle(unit)||this.isTime(unit)// this.isFrequency(unit) ||
|
|
7580
|
-
// this.isResolution(unit) ||
|
|
7581
|
-
// this.isFlex(unit)
|
|
7582
|
-
)return true;return false;};_proto2.negate=function negate(){return CSSMathNegate.create(this);};_proto2.invert=function invert(){return CSSMathInvert.create(this);};return CSSNumericValue;}(CSSStyleValue);function cssNumberishesToNumericValues(values){return values.map(fromNumberish);}function prependValueForArithmetic(type,values,value){DCHECK(!!value);if(value.getType()===type){values.unshift.apply(values,value.numericValues());}else {values.unshift(value);}}function cssNumericSumValueEntryToUnitValue(term){if(Object.keys(term.units).length===0){return new CSSUnitValue(term.value);}if(Object.keys(term.units).length===1&&term.units[Object.keys(term.units)[0]]===1){return new CSSUnitValue(term.value,Number(Object.keys(term.units)[0]));}return null;}function maybeSimplifyAsUnitValue(values,operator){DCHECK(!!values.length);var first_unit_value=values[0]instanceof CSSUnitValue?values[0]:null;if(!first_unit_value)return null;var final_value=first_unit_value.value;for(var i=1;i<values.length;i++){var unit_value=values[i]instanceof CSSUnitValue?values[i]:null;if(!unit_value||unit_value.unit!==first_unit_value.unit)return null;if(operator===CSSMathOperator.kAdd){final_value+=unit_value.value;}else if(operator===CSSMathOperator.kMax){final_value=Math.max(final_value,unit_value.value);}else if(operator===CSSMathOperator.kMin){final_value=Math.min(final_value,unit_value.value);}}return new CSSUnitValue(final_value,first_unit_value.unit);}function maybeMultiplyAsUnitValue(values){DCHECK(!!values.length);// We are allowed one unit value with type other than kNumber.
|
|
7583
|
-
var unit_other_than_number=exports.UnitType.kNumber;var final_value=1.0;for(var i=0;i<values.length;i++){var unit_value=values[i]instanceof CSSUnitValue?values[i]:null;if(!unit_value)return null;if(unit_value.unit!==exports.UnitType.kNumber){if(unit_other_than_number!==exports.UnitType.kNumber)return null;unit_other_than_number=unit_value.unit;}final_value*=unit_value.value;}return new CSSUnitValue(final_value,unit_other_than_number);}var toCanonicalUnit=function toCanonicalUnit(unit){return canonicalUnitTypeForCategory(unitTypeToUnitCategory(unit));};var formatInfinityOrNaN=function formatInfinityOrNaN(number,suffix){if(suffix===void 0){suffix='';}var result='';if(!Number.isFinite(number)){if(number>0)result='infinity';else result='-infinity';}else {DCHECK(Number.isNaN(number));result='NaN';}return result+=suffix;};var toCanonicalUnitIfPossible=function toCanonicalUnitIfPossible(unit){var canonical_unit=toCanonicalUnit(unit);if(canonical_unit===exports.UnitType.kUnknown)return unit;return canonical_unit;};/**
|
|
7448
|
+
*/ /**
|
|
7584
7449
|
* Represents numeric values that can be expressed as a single number plus a
|
|
7585
7450
|
* unit (or a naked number or percentage).
|
|
7586
7451
|
* @see https://drafts.css-houdini.org/css-typed-om/#cssunitvalue
|
|
7587
|
-
*/var CSSUnitValue=/*#__PURE__*/function(
|
|
7588
|
-
// let unit = value.type;
|
|
7589
|
-
// if (unit === UnitType.kInteger) unit = UnitType.kNumber;
|
|
7590
|
-
// if (!this.isValidUnit(unit)) return null;
|
|
7591
|
-
// return new CSSUnitValue(value.getDoubleValue(), unit);
|
|
7592
|
-
// }
|
|
7593
|
-
function CSSUnitValue(value,unitOrName){var _this3;if(unitOrName===void 0){unitOrName=exports.UnitType.kNumber;}var unit;if(typeof unitOrName==='string'){unit=unitFromName(unitOrName);}else {unit=unitOrName;}// DCHECK(CSSUnitValue.isValidUnit(unit));
|
|
7594
|
-
_this3=_CSSNumericValue.call(this,new CSSNumericValueType(unit))||this;_this3.unit=void 0;_this3.value=void 0;_this3.unit=unit;_this3.value=value;return _this3;}var _proto3=CSSUnitValue.prototype;_proto3.clone=function clone(){return new CSSUnitValue(this.value,this.unit);};_proto3.convertTo=function convertTo(target_unit){if(this.unit===target_unit){return new CSSUnitValue(this.value,this.unit);}// Instead of defining the scale factors for every unit to every other unit,
|
|
7452
|
+
*/var CSSUnitValue=/*#__PURE__*/function(_CSSStyleValue){_inheritsLoose(CSSUnitValue,_CSSStyleValue);function CSSUnitValue(value,unitOrName){var _this;if(unitOrName===void 0){unitOrName=exports.UnitType.kNumber;}_this=_CSSStyleValue.call(this)||this;_this.unit=void 0;_this.value=void 0;var unit;if(typeof unitOrName==='string'){unit=unitFromName(unitOrName);}else {unit=unitOrName;}_this.unit=unit;_this.value=value;return _this;}var _proto=CSSUnitValue.prototype;_proto.clone=function clone(){return new CSSUnitValue(this.value,this.unit);};_proto.equals=function equals(other){var other_unit_value=other;return this.value===other_unit_value.value&&this.unit===other_unit_value.unit;};_proto.getType=function getType(){return CSSStyleValueType.kUnitType;};_proto.convertTo=function convertTo(target_unit){if(this.unit===target_unit){return new CSSUnitValue(this.value,this.unit);}// Instead of defining the scale factors for every unit to every other unit,
|
|
7595
7453
|
// we simply convert to the canonical unit and back since we already have
|
|
7596
7454
|
// the scale factors for canonical units.
|
|
7597
|
-
var canonical_unit=toCanonicalUnit(this.unit);if(canonical_unit!==toCanonicalUnit(target_unit)||canonical_unit===exports.UnitType.kUnknown){return null;}var scale_factor=conversionToCanonicalUnitsScaleFactor(this.unit)/conversionToCanonicalUnitsScaleFactor(target_unit);return new CSSUnitValue(this.value*scale_factor,target_unit);};
|
|
7598
|
-
// return new CSSNumericLiteralValue(this.value, this.unit);
|
|
7599
|
-
// }
|
|
7600
|
-
// // const CSSPrimitiveValue* ToCSSValueWithProperty(CSSPropertyID) const final;
|
|
7601
|
-
// toCalcExpressionNode() {
|
|
7602
|
-
// return CSSMathExpressionNumericLiteral.create(
|
|
7603
|
-
// new CSSNumericLiteralValue(this.value, this.unit),
|
|
7604
|
-
// );
|
|
7605
|
-
// }
|
|
7606
|
-
;_proto3.sumValue=function sumValue(){var sum=[];var unit_map={};if(this.unit!==exports.UnitType.kNumber){unit_map[toCanonicalUnitIfPossible(this.unit)]=1;}sum.push({value:this.value*conversionToCanonicalUnitsScaleFactor(this.unit),units:unit_map});return sum;};_proto3.negate=function negate(){return new CSSUnitValue(-this.value,this.unit);};_proto3.invert=function invert(){if(this.unit===exports.UnitType.kNumber){if(this.value===0)return null;return new CSSUnitValue(1.0/this.value,this.unit);}return CSSMathInvert.create(this);};_proto3.buildCSSText=function buildCSSText(n,p,result){var text;switch(this.unit){case exports.UnitType.kUnknown:// FIXME
|
|
7455
|
+
var canonical_unit=toCanonicalUnit(this.unit);if(canonical_unit!==toCanonicalUnit(target_unit)||canonical_unit===exports.UnitType.kUnknown){return null;}var scale_factor=conversionToCanonicalUnitsScaleFactor(this.unit)/conversionToCanonicalUnitsScaleFactor(target_unit);return new CSSUnitValue(this.value*scale_factor,target_unit);};_proto.buildCSSText=function buildCSSText(n,p,result){var text;switch(this.unit){case exports.UnitType.kUnknown:// FIXME
|
|
7607
7456
|
break;case exports.UnitType.kInteger:text=Number(this.value).toFixed(0);break;case exports.UnitType.kNumber:case exports.UnitType.kPercentage:case exports.UnitType.kEms:// case UnitType.kQuirkyEms:
|
|
7608
7457
|
// case UnitType.kExs:
|
|
7609
7458
|
case exports.UnitType.kRems:// case UnitType.kChs:
|
|
@@ -7619,81 +7468,8 @@
|
|
|
7619
7468
|
// case UnitType.kUserUnits:
|
|
7620
7469
|
case exports.UnitType.kDegrees:case exports.UnitType.kRadians:case exports.UnitType.kGradians:case exports.UnitType.kMilliseconds:case exports.UnitType.kSeconds:// case UnitType.kHertz:
|
|
7621
7470
|
// case UnitType.kKilohertz:
|
|
7622
|
-
case exports.UnitType.kTurns:// case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
|
|
7623
|
-
|
|
7624
|
-
// case UnitType.kContainerHeight:
|
|
7625
|
-
// case UnitType.kContainerInlineSize:
|
|
7626
|
-
// case UnitType.kContainerBlockSize:
|
|
7627
|
-
// case UnitType.kContainerMin:
|
|
7628
|
-
// case UnitType.kContainerMax: {
|
|
7629
|
-
{var kMinInteger=-999999;var kMaxInteger=999999;var value=this.value;var unit=unitTypeToString(this.unit);if(value<kMinInteger||value>kMaxInteger){var _unit=unitTypeToString(this.unit);if(!Number.isFinite(value)||Number.isNaN(value)){text=formatInfinityOrNaN(value,_unit);}else {text=value+(_unit||'');}}else {text=""+value+unit;}}}result+=text;return result;};return CSSUnitValue;}(CSSNumericValue);/**
|
|
7630
|
-
* The CSSMathValue interface of the CSS_Object_Model a base class for classes representing complex numeric values.
|
|
7631
|
-
*
|
|
7632
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSSMathValue
|
|
7633
|
-
* @see https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/renderer/core/css/cssom/css_math_value.idl
|
|
7634
|
-
*/var CSSMathValue=/*#__PURE__*/function(_CSSNumericValue2){_inheritsLoose(CSSMathValue,_CSSNumericValue2);function CSSMathValue(){return _CSSNumericValue2.apply(this,arguments)||this;}var _proto4=CSSMathValue.prototype;// From CSSNumericValue
|
|
7635
|
-
_proto4.isUnitValue=function isUnitValue(){return false;};return CSSMathValue;}(CSSNumericValue);var CSSMathInvert=/*#__PURE__*/function(_CSSMathValue){_inheritsLoose(CSSMathInvert,_CSSMathValue);CSSMathInvert.create=function create(value){var type=CSSNumericValueType.negateExponents(value.type_);return new CSSMathInvert(value,type);};function CSSMathInvert(value,type){var _this4;_this4=_CSSMathValue.call(this,type)||this;_this4.value=void 0;_this4.operator='invert';_this4.value=value;return _this4;}var _proto5=CSSMathInvert.prototype;_proto5.clone=function clone(){return new CSSMathInvert(this.value,this.type_);};_proto5.getType=function getType(){return CSSStyleValueType.kInvertType;};_proto5.equals=function equals(other){if(other.getType()!==CSSStyleValueType.kInvertType){return false;}// We can safely cast here as we know 'other' has the same type as us.
|
|
7636
|
-
var other_invert=other;return this.value.equals(other_invert.value);};_proto5.sumValue=function sumValue(){var sum=this.value.sumValue();if(sum.length===0||sum.length!==1||sum[0].value===0){return null;}Object.keys(sum[0].units).forEach(function(key){sum[0].units[key]*=-1;});sum[0].value=1.0/sum[0].value;return sum;}// toCalcExpressionNode(): CSSMathExpressionNode {
|
|
7637
|
-
// const right_side = this.value.toCalcExpressionNode();
|
|
7638
|
-
// if (!right_side) {
|
|
7639
|
-
// return null;
|
|
7640
|
-
// }
|
|
7641
|
-
// // return CSSMathExpressionOperation::CreateArithmeticOperation(
|
|
7642
|
-
// // CSSMathExpressionNumericLiteral::Create(
|
|
7643
|
-
// // 1, UnitType.kNumber),
|
|
7644
|
-
// // right_side, CSSMathOperator.kDivide);
|
|
7645
|
-
// return null;
|
|
7646
|
-
// }
|
|
7647
|
-
;_proto5.buildCSSText=function buildCSSText(nested,paren_less,result){if(paren_less==ParenLess.kNo){result+=nested===Nested.kYes?'(':'calc(';}result+='1 / ';result=this.value.buildCSSText(Nested.kYes,ParenLess.kNo,result);if(paren_less===ParenLess.kNo){result+=')';}return result;};return CSSMathInvert;}(CSSMathValue);var CSSMathNegate=/*#__PURE__*/function(_CSSMathValue2){_inheritsLoose(CSSMathNegate,_CSSMathValue2);CSSMathNegate.create=function create(value){return new CSSMathNegate(value,value.type_);};function CSSMathNegate(value,type){var _this5;_this5=_CSSMathValue2.call(this,type)||this;_this5.value=void 0;_this5.operator='negate';_this5.value=value;return _this5;}var _proto6=CSSMathNegate.prototype;_proto6.clone=function clone(){return new CSSMathNegate(this.value,this.type_);};_proto6.getType=function getType(){return CSSStyleValueType.kNegateType;};_proto6.equals=function equals(other){if(other.getType()!==CSSStyleValueType.kNegateType){return false;}var other_invert=other;return this.value.equals(other_invert.value);};_proto6.sumValue=function sumValue(){var sum=this.value.sumValue();if(sum.length===0){return null;}sum.forEach(function(term){term.value*=-1;});return sum;}// toCalcExpressionNode(): CSSMathExpressionNode {
|
|
7648
|
-
// const right_side = this.value.toCalcExpressionNode();
|
|
7649
|
-
// if (!right_side) {
|
|
7650
|
-
// return null;
|
|
7651
|
-
// }
|
|
7652
|
-
// // return CSSMathExpressionOperation::CreateArithmeticOperationSimplified(
|
|
7653
|
-
// // CSSMathExpressionNumericLiteral::Create(
|
|
7654
|
-
// // -1, CSSPrimitiveValue::UnitType::kNumber),
|
|
7655
|
-
// // right_side, CSSMathOperator::kMultiply);
|
|
7656
|
-
// }
|
|
7657
|
-
;_proto6.buildCSSText=function buildCSSText(nested,paren_less,result){if(paren_less==ParenLess.kNo){result+=nested===Nested.kYes?'(':'calc(';}result+='-';result=this.value.buildCSSText(Nested.kYes,ParenLess.kNo,result);if(paren_less===ParenLess.kNo){result+=')';}return result;};return CSSMathNegate;}(CSSMathValue);function typeCheck(values,op,error){error=false;var final_type=values[0].type_;for(var i=1;i<values.length;i++){final_type=op(final_type,values[i].type_,error);if(error)return final_type;}return final_type;}// Represents an arithmetic operation with one or more CSSNumericValues.
|
|
7658
|
-
var CSSMathVariadic=/*#__PURE__*/function(_CSSMathValue3){_inheritsLoose(CSSMathVariadic,_CSSMathValue3);function CSSMathVariadic(values,type){var _this6;_this6=_CSSMathValue3.call(this,type)||this;_this6.values=void 0;_this6.values=values;return _this6;}var _proto7=CSSMathVariadic.prototype;_proto7.numericValues=function numericValues(){return this.values;};_proto7.equals=function equals(other){if(this.getType()!==other.getType()){return false;}return this.values.every(function(value,i){return value.equals(other.values[i]);});};return CSSMathVariadic;}(CSSMathValue);// Represents the minimum of one or more CSSNumericValues.
|
|
7659
|
-
// @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
7660
|
-
var CSSMathMin=/*#__PURE__*/function(_CSSMathVariadic){_inheritsLoose(CSSMathMin,_CSSMathVariadic);function CSSMathMin(){var _this7;for(var _len9=arguments.length,args=new Array(_len9),_key9=0;_key9<_len9;_key9++){args[_key9]=arguments[_key9];}_this7=_CSSMathVariadic.call.apply(_CSSMathVariadic,[this].concat(args))||this;_this7.operator='min';return _this7;}CSSMathMin.create=function create(values){var error=false;var final_type=typeCheck(values,CSSNumericValueType.add,error);return new CSSMathMin(values,final_type);};var _proto8=CSSMathMin.prototype;_proto8.clone=function clone(){return new CSSMathMin(this.values,this.type_);};_proto8.getType=function getType(){return CSSStyleValueType.kMinType;};_proto8.sumValue=function sumValue(){var cur_min=this.numericValues()[0].sumValue();if(!cur_min.length){return null;}for(var _iterator2=_createForOfIteratorHelperLoose(this.numericValues()),_step2;!(_step2=_iterator2()).done;){var value=_step2.value;var child_sum=value.sumValue();if(!child_sum.length||JSON.stringify(child_sum[0].units)!==JSON.stringify(cur_min[0].units)){return null;}if(child_sum[0].value<cur_min[0].value){cur_min=child_sum;}}return cur_min;}// toCalcExpressionNode() {
|
|
7661
|
-
// const operands: CSSMathExpressionOperation[] = [];
|
|
7662
|
-
// for (const value of this.numericValues()) {
|
|
7663
|
-
// const operand = value.toCalcExpressionNode();
|
|
7664
|
-
// if (!operand) {
|
|
7665
|
-
// continue;
|
|
7666
|
-
// }
|
|
7667
|
-
// operands.push(operand as CSSMathExpressionOperation);
|
|
7668
|
-
// }
|
|
7669
|
-
// return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMin);
|
|
7670
|
-
// }
|
|
7671
|
-
;_proto8.buildCSSText=function buildCSSText(nested,paren_less,result){result+='min(';var first_iteration=true;for(var _iterator3=_createForOfIteratorHelperLoose(this.numericValues()),_step3;!(_step3=_iterator3()).done;){var value=_step3.value;if(!first_iteration)result+=', ';first_iteration=false;result=value.buildCSSText(Nested.kYes,ParenLess.kYes,result);}result+=')';return result;};return CSSMathMin;}(CSSMathVariadic);// Represents the maximum of one or more CSSNumericValues.
|
|
7672
|
-
// @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
7673
|
-
var CSSMathMax=/*#__PURE__*/function(_CSSMathVariadic2){_inheritsLoose(CSSMathMax,_CSSMathVariadic2);function CSSMathMax(){var _this8;for(var _len10=arguments.length,args=new Array(_len10),_key10=0;_key10<_len10;_key10++){args[_key10]=arguments[_key10];}_this8=_CSSMathVariadic2.call.apply(_CSSMathVariadic2,[this].concat(args))||this;_this8.operator='max';return _this8;}CSSMathMax.create=function create(values){var error=false;var final_type=typeCheck(values,CSSNumericValueType.add,error);return new CSSMathMax(values,final_type);};var _proto9=CSSMathMax.prototype;_proto9.clone=function clone(){return new CSSMathMax(this.values,this.type_);};_proto9.getType=function getType(){return CSSStyleValueType.kMaxType;};_proto9.sumValue=function sumValue(){var cur_max=this.numericValues()[0].sumValue();if(!cur_max.length){return null;}for(var _iterator4=_createForOfIteratorHelperLoose(this.numericValues()),_step4;!(_step4=_iterator4()).done;){var value=_step4.value;var child_sum=value.sumValue();if(!child_sum.length||JSON.stringify(child_sum[0].units)!==JSON.stringify(cur_max[0].units)){return null;}if(child_sum[0].value<cur_max[0].value){cur_max=child_sum;}}return cur_max;}// toCalcExpressionNode() {
|
|
7674
|
-
// const operands: CSSMathExpressionOperation[] = [];
|
|
7675
|
-
// for (const value of this.numericValues()) {
|
|
7676
|
-
// const operand = value.toCalcExpressionNode();
|
|
7677
|
-
// if (!operand) {
|
|
7678
|
-
// continue;
|
|
7679
|
-
// }
|
|
7680
|
-
// operands.push(operand as CSSMathExpressionOperation);
|
|
7681
|
-
// }
|
|
7682
|
-
// return CSSMathExpressionOperation.createComparisonFunction(operands, CSSMathOperator.kMax);
|
|
7683
|
-
// }
|
|
7684
|
-
;_proto9.buildCSSText=function buildCSSText(nested,paren_less,result){result+='max(';var first_iteration=true;for(var _iterator5=_createForOfIteratorHelperLoose(this.numericValues()),_step5;!(_step5=_iterator5()).done;){var value=_step5.value;if(!first_iteration)result+=', ';first_iteration=false;result=value.buildCSSText(Nested.kYes,ParenLess.kYes,result);}result+=')';return result;};return CSSMathMax;}(CSSMathVariadic);/**
|
|
7685
|
-
* Represents the sum of one or more CSSNumericValues.
|
|
7686
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathsum
|
|
7687
|
-
*/var CSSMathSum=/*#__PURE__*/function(_CSSMathVariadic3){_inheritsLoose(CSSMathSum,_CSSMathVariadic3);function CSSMathSum(){var _this9;for(var _len11=arguments.length,args=new Array(_len11),_key11=0;_key11<_len11;_key11++){args[_key11]=arguments[_key11];}_this9=_CSSMathVariadic3.call.apply(_CSSMathVariadic3,[this].concat(args))||this;_this9.operator='sum';return _this9;}CSSMathSum.create=function create(values){var error=false;var finalType=typeCheck(values,CSSNumericValueType.add,error);return new CSSMathSum(values,finalType);};CSSMathSum.numericTypeFromUnitMap=function numericTypeFromUnitMap(units){var type=new CSSNumericValueType();Object.keys(units).forEach(function(key){var exp=units[key];var error=false;type=CSSNumericValueType.multiply(type,new CSSNumericValueType(Number(key),exp),error);DCHECK(!error);});return type;};CSSMathSum.canCreateNumericTypeFromSumValue=function canCreateNumericTypeFromSumValue(sum){var _this10=this;DCHECK(!!sum.length);var first_type=this.numericTypeFromUnitMap(sum[0].units);return sum.every(function(term){var error=false;CSSNumericValueType.add(first_type,_this10.numericTypeFromUnitMap(term.units),error);return !error;});};var _proto10=CSSMathSum.prototype;_proto10.clone=function clone(){return new CSSMathSum(this.values,this.type_);};_proto10.getType=function getType(){return CSSStyleValueType.kSumType;}// toCalcExpressionNode() {
|
|
7688
|
-
// return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kAdd);
|
|
7689
|
-
// }
|
|
7690
|
-
;_proto10.sumValue=function sumValue(){var sum=[];this.numericValues().forEach(function(value){var child_sum=value.sumValue();if(!child_sum.length){return null;}child_sum.forEach(function(term){var index=sum.findIndex(function(s){return JSON.stringify(s.units)===JSON.stringify(term.units);});if(index===-1){sum.push(_extends({},term));}else {sum[index].value+=term.value;}});});if(!CSSMathSum.canCreateNumericTypeFromSumValue(sum))return null;return sum;};_proto10.buildCSSText=function buildCSSText(nested,paren_less,result){if(paren_less==ParenLess.kNo){result+=nested===Nested.kYes?'(':'calc(';}var values=this.numericValues();result=values[0].buildCSSText(Nested.kYes,ParenLess.kNo,result);for(var i=1;i<values.length;i++){var arg=values[i];if(arg.getType()===CSSStyleValueType.kNegateType){result+=' - ';result=arg.value.buildCSSText(Nested.kYes,ParenLess.kNo,result);}else {result+=' + ';result=arg.buildCSSText(Nested.kYes,ParenLess.kNo,result);}}if(paren_less===ParenLess.kNo){result+=')';}return result;};return CSSMathSum;}(CSSMathVariadic);/**
|
|
7691
|
-
* Represents the product of one or more CSSNumericValues.
|
|
7692
|
-
* @see https://drafts.css-houdini.org/css-typed-om/#cssmathproduct
|
|
7693
|
-
*/var CSSMathProduct=/*#__PURE__*/function(_CSSMathVariadic4){_inheritsLoose(CSSMathProduct,_CSSMathVariadic4);function CSSMathProduct(){var _this11;for(var _len12=arguments.length,args=new Array(_len12),_key12=0;_key12<_len12;_key12++){args[_key12]=arguments[_key12];}_this11=_CSSMathVariadic4.call.apply(_CSSMathVariadic4,[this].concat(args))||this;_this11.operator='product';return _this11;}CSSMathProduct.create=function create(values){var error=false;var finalType=typeCheck(values,CSSNumericValueType.multiply,error);return new CSSMathProduct(values,finalType);};CSSMathProduct.multiplyUnitMaps=function multiplyUnitMaps(a,b){Object.keys(b).forEach(function(key){DCHECK_NE(b[key].value,0);var old_value=key in a?a[key].value:0;if(old_value+b[key].value===0){delete a[key];}else {a[key]=old_value+b[key].value;}});return a;};var _proto11=CSSMathProduct.prototype;_proto11.clone=function clone(){return new CSSMathProduct(this.values,this.type_);};_proto11.getType=function getType(){return CSSStyleValueType.kProductType;}// toCalcExpressionNode() {
|
|
7694
|
-
// return this.toCalcExporessionNodeForVariadic(CSSMathOperator.kMultiply);
|
|
7695
|
-
// }
|
|
7696
|
-
;_proto11.sumValue=function sumValue(){var sum=[{value:1,units:{}}];this.numericValues().forEach(function(value){var child_sum=value.sumValue();if(!child_sum.length){return null;}var new_sum=[];sum.forEach(function(a){child_sum.forEach(function(b){new_sum.push({value:a.value*b.value,units:CSSMathProduct.multiplyUnitMaps(a.units,b.units)});});});sum=new_sum;});return sum;};_proto11.buildCSSText=function buildCSSText(nested,paren_less,result){if(paren_less==ParenLess.kNo){result+=nested===Nested.kYes?'(':'calc(';}var values=this.numericValues();result=values[0].buildCSSText(Nested.kYes,ParenLess.kNo,result);for(var i=1;i<values.length;i++){var arg=values[i];if(arg.getType()===CSSStyleValueType.kInvertType){result+=' / ';result=arg.value.buildCSSText(Nested.kYes,ParenLess.kNo,result);}else {result+=' * ';result=arg.buildCSSText(Nested.kYes,ParenLess.kNo,result);}}if(paren_less===ParenLess.kNo){result+=')';}return result;};return CSSMathProduct;}(CSSMathVariadic);var Opx=new CSSUnitValue(0,'px');var Lpx=new CSSUnitValue(1,'px');var Odeg=new CSSUnitValue(0,'deg');/**
|
|
7471
|
+
case exports.UnitType.kTurns:// case UnitType.kContainerMax: { // case UnitType.kContainerMin: // case UnitType.kContainerBlockSize: // case UnitType.kContainerInlineSize: // case UnitType.kContainerHeight: // case UnitType.kContainerWidth: // case UnitType.kDynamicViewportMax: // case UnitType.kDynamicViewportMin: // case UnitType.kDynamicViewportBlockSize: // case UnitType.kDynamicViewportInlineSize: // case UnitType.kDynamicViewportHeight: // case UnitType.kDynamicViewportWidth: // case UnitType.kLargeViewportMax: // case UnitType.kLargeViewportMin: // case UnitType.kLargeViewportBlockSize: // case UnitType.kLargeViewportInlineSize: // case UnitType.kLargeViewportHeight: // case UnitType.kLargeViewportWidth: // case UnitType.kSmallViewportMax: // case UnitType.kSmallViewportMin: // case UnitType.kSmallViewportBlockSize: // case UnitType.kSmallViewportInlineSize: // case UnitType.kSmallViewportHeight: // case UnitType.kSmallViewportWidth: // case UnitType.kViewportMax: // case UnitType.kViewportMin: // case UnitType.kViewportBlockSize: // case UnitType.kViewportInlineSize: // case UnitType.kViewportHeight: // case UnitType.kViewportWidth: // case UnitType.kFraction:
|
|
7472
|
+
{var kMinInteger=-999999;var kMaxInteger=999999;var value=this.value;var unit=unitTypeToString(this.unit);if(value<kMinInteger||value>kMaxInteger){var _unit=unitTypeToString(this.unit);if(!Number.isFinite(value)||Number.isNaN(value)){text=formatInfinityOrNaN(value,_unit);}else {text=value+(_unit||'');}}else {text=""+value+unit;}}}result+=text;return result;};return CSSUnitValue;}(CSSStyleValue);var Opx=new CSSUnitValue(0,'px');var Lpx=new CSSUnitValue(1,'px');var Odeg=new CSSUnitValue(0,'deg');/**
|
|
7697
7473
|
* The CSSRGB class represents the CSS rgb()/rgba() functions.
|
|
7698
7474
|
*
|
|
7699
7475
|
* @see https://drafts.css-houdini.org/css-typed-om-1/#cssrgb
|
|
@@ -7744,198 +7520,564 @@
|
|
|
7744
7520
|
* CSSKeywordValue
|
|
7745
7521
|
*/var unsetKeywordValue=new CSSKeywordValue('unset');var initialKeywordValue=new CSSKeywordValue('initial');var inheritKeywordValue=new CSSKeywordValue('inherit');var keywordCache={'':unsetKeywordValue,unset:unsetKeywordValue,initial:initialKeywordValue,inherit:inheritKeywordValue};var getOrCreateKeyword=function getOrCreateKeyword(name){if(!keywordCache[name]){keywordCache[name]=new CSSKeywordValue(name);}return keywordCache[name];};/**
|
|
7746
7522
|
* CSSColor
|
|
7747
|
-
*/var noneColor=new CSSRGB(0,0,0,0,true);var transparentColor=new CSSRGB(0,0,0,0);var getOrCreateRGBA=memoize(function(r,g,b,a){return new CSSRGB(r,g,b,a);},function(r,g,b,a){return "rgba("+r+","+g+","+b+","+a+")";})
|
|
7748
|
-
|
|
7749
|
-
//
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
//
|
|
7753
|
-
//
|
|
7754
|
-
//
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
return
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
* @see https://
|
|
7768
|
-
*
|
|
7769
|
-
*/
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
//
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
//
|
|
7797
|
-
//
|
|
7798
|
-
|
|
7799
|
-
//
|
|
7800
|
-
//
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
//
|
|
7809
|
-
//
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
return
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
*
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
var
|
|
7825
|
-
var
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
return [];}var
|
|
7846
|
-
var
|
|
7847
|
-
|
|
7848
|
-
return
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
var
|
|
7869
|
-
|
|
7870
|
-
//
|
|
7871
|
-
//
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
if(
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
*
|
|
7912
|
-
*
|
|
7913
|
-
*
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7523
|
+
*/var noneColor=new CSSRGB(0,0,0,0,true);var transparentColor=new CSSRGB(0,0,0,0);var getOrCreateRGBA=memoize(function(r,g,b,a){return new CSSRGB(r,g,b,a);},function(r,g,b,a){return "rgba("+r+","+g+","+b+","+a+")";});// export const getOrCreateUnitValue = memoize(
|
|
7524
|
+
// (value: number, unitOrName: UnitType | string = UnitType.kNumber) => {
|
|
7525
|
+
// return new CSSUnitValue(value, unitOrName);
|
|
7526
|
+
// },
|
|
7527
|
+
// (value: number, unitOrName: UnitType | string = UnitType.kNumber) => {
|
|
7528
|
+
// return `${value}${unitOrName}`;
|
|
7529
|
+
// },
|
|
7530
|
+
// );
|
|
7531
|
+
var getOrCreateUnitValue=function getOrCreateUnitValue(value,unitOrName){if(unitOrName===void 0){unitOrName=exports.UnitType.kNumber;}return new CSSUnitValue(value,unitOrName);};var canvasMap={};var defaultCanvasIdCounter=0;/**
|
|
7532
|
+
* destroy existed canvas with the same id
|
|
7533
|
+
*/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;
|
|
7534
|
+
var parent=o1.parentNode;if(parent){var children=parent.childNodes||[];return children.indexOf(o1)-children.indexOf(o2);}}return zIndex1-zIndex2;}function findClosestClipPathTarget(object){var el=object;do{var _el$style;var clipPath=(_el$style=el.style)===null||_el$style===void 0?void 0:_el$style.clipPath;if(clipPath)return el;el=el.parentElement;}while(el!==null);return null;}var PX_SUFFIX='px';function setDOMSize($el,width,height){if(isBrowser&&$el.style){$el.style.width=width+PX_SUFFIX;$el.style.height=height+PX_SUFFIX;}}function getStyle($el,property){if(isBrowser){return document.defaultView.getComputedStyle($el,null).getPropertyValue(property);}}function getWidth($el){var width=getStyle($el,'width');if(width==='auto'){return $el.offsetWidth;}return parseFloat(width);}function getHeight($el){var height=getStyle($el,'height');if(height==='auto'){return $el.offsetHeight;}return parseFloat(height);}var ERROR_MSG_METHOD_NOT_IMPLEMENTED='Method not implemented.';var ERROR_MSG_USE_DOCUMENT_ELEMENT='Use document.documentElement instead.';var ERROR_MSG_APPEND_DESTROYED_ELEMENT='Cannot append a destroyed element.';// borrow from hammer.js
|
|
7535
|
+
var MOUSE_POINTER_ID=1;var TOUCH_TO_POINTER={touchstart:'pointerdown',touchend:'pointerup',touchendoutside:'pointerupoutside',touchmove:'pointermove',touchcancel:'pointercancel'};function copyVec3(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a;}function subVec3(o,a,b){o[0]=a[0]-b[0];o[1]=a[1]-b[1];o[2]=a[2]-b[2];return o;}function addVec3(o,a,b){o[0]=a[0]+b[0];o[1]=a[1]+b[1];o[2]=a[2]+b[2];return o;}function scaleVec3(o,a,b){o[0]=a[0]*b;o[1]=a[1]*b;o[2]=a[2]*b;return o;}function maxVec3(o,a,b){o[0]=Math.max(a[0],b[0]);o[1]=Math.max(a[1],b[1]);o[2]=Math.max(a[2],b[2]);return o;}function minVec3(o,a,b){o[0]=Math.min(a[0],b[0]);o[1]=Math.min(a[1],b[1]);o[2]=Math.min(a[2],b[2]);return o;}function getAngle$1(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
|
|
7536
|
+
// singularity at the north pole
|
|
7537
|
+
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
|
|
7538
|
+
// singularity at the south pole
|
|
7539
|
+
out[0]=-Math.PI/2;out[1]=2*Math.atan2(y,x);out[2]=0;}else {out[0]=Math.asin(2*(x*z-w*y));out[1]=Math.atan2(2*(x*w+y*z),1-2*(z2+w2));out[2]=Math.atan2(2*(x*y+z*w),1-2*(y2+z2));}// TODO: Return them as degrees and not as radians
|
|
7540
|
+
return out;}function getEulerFromMat4(out,m){var x;var z;var halfPi=Math.PI*0.5;var _mat4$getScaling=getScaling(create$2(),m),sx=_mat4$getScaling[0],sy=_mat4$getScaling[1],sz=_mat4$getScaling[2];var y=Math.asin(-m[2]/sx);if(y<halfPi){if(y>-halfPi){x=Math.atan2(m[6]/sy,m[10]/sz);z=Math.atan2(m[1]/sx,m[0]/sx);}else {// Not a unique solution
|
|
7541
|
+
z=0;x=-Math.atan2(m[4]/sy,m[5]/sy);}}else {// Not a unique solution
|
|
7542
|
+
z=0;x=Math.atan2(m[4]/sy,m[5]/sy);}out[0]=x;out[1]=y;out[2]=z;return out;}/**
|
|
7543
|
+
* @see https://github.com/toji/gl-matrix/issues/329
|
|
7544
|
+
* @see https://doc.babylonjs.com/divingDeeper/mesh/transforms/center_origin/rotation_conventions
|
|
7545
|
+
*/function getEuler(out,quat){if(quat.length===16){return getEulerFromMat4(out,quat);}else {return getEulerFromQuat(out,quat);}}function fromRotationTranslationScale$1(rotation,x,y,scaleX,scaleY){var cos=Math.cos(rotation);var sin=Math.sin(rotation);return fromValues(scaleX*cos,scaleY*sin,0,-scaleX*sin,scaleY*cos,0,x,y,1);}function makePerspective(out,left,right,top,bottom,near,far){var x=2*near/(right-left);var y=2*near/(top-bottom);var a=(right+left)/(right-left);var b=(top+bottom)/(top-bottom);var c=-(far+near)/(far-near);var d=-2*far*near/(far-near);out[0]=x;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=y;out[6]=0;out[7]=0;out[8]=a;out[9]=b;out[10]=c;out[11]=-1;out[12]=0;out[13]=0;out[14]=d;out[15]=0;return out;}function decompose(mat){var row0x=mat[0];var row0y=mat[1];var row1x=mat[3];var row1y=mat[4];// decompose 3x3 matrix
|
|
7546
|
+
// @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
|
|
7547
|
+
var scalingX=Math.sqrt(row0x*row0x+row0y*row0y);var scalingY=Math.sqrt(row1x*row1x+row1y*row1y);// If determinant is negative, one axis was flipped.
|
|
7548
|
+
var determinant=row0x*row1y-row0y*row1x;if(determinant<0){// Flip axis with minimum unit vector dot product.
|
|
7549
|
+
if(row0x<row1y){scalingX=-scalingX;}else {scalingY=-scalingY;}}// Renormalize matrix to remove scale.
|
|
7550
|
+
if(scalingX){row0x*=1/scalingX;row0y*=1/scalingX;}if(scalingY){row1x*=1/scalingY;row1y*=1/scalingY;}// Compute rotation and renormalize matrix.
|
|
7551
|
+
var rotation=Math.atan2(row0y,row0x);var angle=rad2deg(rotation);return [mat[6],mat[7],scalingX,scalingY,angle];}var tmp=create$1();var perspectiveMatrix=create$1();var tmpVec4=create$3();var row=[create$2(),create$2(),create$2()];var pdum3=create$2();/*
|
|
7552
|
+
Input: matrix ; a 4x4 matrix
|
|
7553
|
+
Output: translation ; a 3 component vector
|
|
7554
|
+
scale ; a 3 component vector
|
|
7555
|
+
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
|
|
7556
|
+
perspective ; a 4 component vector
|
|
7557
|
+
quaternion ; a 4 component vector
|
|
7558
|
+
Returns false if the matrix cannot be decomposed, true if it can
|
|
7559
|
+
|
|
7560
|
+
|
|
7561
|
+
References:
|
|
7562
|
+
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
|
|
7563
|
+
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
|
|
7564
|
+
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
|
|
7565
|
+
*/function decomposeMat4(matrix,translation,scale,skew,perspective,quaternion){//normalize, if not possible then bail out early
|
|
7566
|
+
if(!normalize$4(tmp,matrix))return false;// perspectiveMatrix is used to solve for perspective, but it also provides
|
|
7567
|
+
// an easy way to test for singularity of the upper 3x3 component.
|
|
7568
|
+
copy(perspectiveMatrix,tmp);perspectiveMatrix[3]=0;perspectiveMatrix[7]=0;perspectiveMatrix[11]=0;perspectiveMatrix[15]=1;// If the perspectiveMatrix is not invertible, we are also unable to
|
|
7569
|
+
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
|
|
7570
|
+
if(Math.abs(determinant(perspectiveMatrix))<1e-8)return false;var a03=tmp[3],a13=tmp[7],a23=tmp[11],a30=tmp[12],a31=tmp[13],a32=tmp[14],a33=tmp[15];// First, isolate perspective.
|
|
7571
|
+
if(a03!==0||a13!==0||a23!==0){tmpVec4[0]=a03;tmpVec4[1]=a13;tmpVec4[2]=a23;tmpVec4[3]=a33;// Solve the equation by inverting perspectiveMatrix and multiplying
|
|
7572
|
+
// rightHandSide by the inverse.
|
|
7573
|
+
// resuing the perspectiveMatrix here since it's no longer needed
|
|
7574
|
+
var ret=invert(perspectiveMatrix,perspectiveMatrix);if(!ret)return false;transpose(perspectiveMatrix,perspectiveMatrix);//multiply by transposed inverse perspective matrix, into perspective vec4
|
|
7575
|
+
transformMat4$1(perspective,tmpVec4,perspectiveMatrix);}else {//no perspective
|
|
7576
|
+
perspective[0]=perspective[1]=perspective[2]=0;perspective[3]=1;}// Next take care of translation
|
|
7577
|
+
translation[0]=a30;translation[1]=a31;translation[2]=a32;// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
|
|
7578
|
+
mat3from4(row,tmp);// Compute X scale factor and normalize first row.
|
|
7579
|
+
scale[0]=length(row[0]);normalize(row[0],row[0]);// Compute XY shear factor and make 2nd row orthogonal to 1st.
|
|
7580
|
+
skew[0]=dot(row[0],row[1]);combine(row[1],row[1],row[0],1.0,-skew[0]);// Now, compute Y scale and normalize 2nd row.
|
|
7581
|
+
scale[1]=length(row[1]);normalize(row[1],row[1]);skew[0]/=scale[1];// Compute XZ and YZ shears, orthogonalize 3rd row
|
|
7582
|
+
skew[1]=dot(row[0],row[2]);combine(row[2],row[2],row[0],1.0,-skew[1]);skew[2]=dot(row[1],row[2]);combine(row[2],row[2],row[1],1.0,-skew[2]);// Next, get Z scale and normalize 3rd row.
|
|
7583
|
+
scale[2]=length(row[2]);normalize(row[2],row[2]);skew[1]/=scale[2];skew[2]/=scale[2];// At this point, the matrix (in rows) is orthonormal.
|
|
7584
|
+
// Check for a coordinate system flip. If the determinant
|
|
7585
|
+
// is -1, then negate the matrix and the scaling factors.
|
|
7586
|
+
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
|
|
7587
|
+
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.
|
|
7588
|
+
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
|
|
7589
|
+
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;}var tmpMat4=create$1();function parsedTransformToMat4(transform,object){if(transform&&transform.length){var defX=0;var defY=0;if(object){defX=object.parsedStyle.defX||0;defY=object.parsedStyle.defY||0;// reset transform
|
|
7590
|
+
object.resetLocalTransform();object.setLocalPosition(defX,defY);}else {object=new DisplayObject({});}transform.forEach(function(parsed){var t=parsed.t,d=parsed.d;if(t==='scale'){// scale(1) scale(1, 1)
|
|
7591
|
+
var newScale=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1,1];object.scaleLocal(newScale[0],newScale[1],1);}else if(t==='scalex'){var _newScale=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(_newScale[0],1,1);}else if(t==='scaley'){var _newScale2=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(1,_newScale2[0],1);}else if(t==='scalez'){var _newScale3=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1];object.scaleLocal(1,1,_newScale3[0]);}else if(t==='scale3d'){var _newScale4=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[1,1,1];object.scaleLocal(_newScale4[0],_newScale4[1],_newScale4[2]);}else if(t==='translate'){var newTranslation=d||[Opx,Opx];object.translateLocal(newTranslation[0].value,newTranslation[1].value,0);}else if(t==='translatex'){var _newTranslation=d||[Opx];object.translateLocal(_newTranslation[0].value,0,0);}else if(t==='translatey'){var _newTranslation2=d||[Opx];object.translateLocal(0,_newTranslation2[0].value,0);}else if(t==='translatez'){var _newTranslation3=d||[Opx];object.translateLocal(0,0,_newTranslation3[0].value);}else if(t==='translate3d'){var _newTranslation4=d||[Opx,Opx,Opx];object.translateLocal(_newTranslation4[0].value,_newTranslation4[1].value,_newTranslation4[2].value);}else if(t==='rotate'){var newAngles=d||[Odeg];object.rotateLocal(0,0,convertAngleUnit(newAngles[0]));}else if(t==='rotatex'){var _newAngles=d||[Odeg];object.rotateLocal(convertAngleUnit(_newAngles[0]),0,0);}else if(t==='rotatey'){var _newAngles2=d||[Odeg];object.rotateLocal(0,convertAngleUnit(_newAngles2[0]),0);}else if(t==='rotatez'){var _newAngles3=d||[Odeg];object.rotateLocal(0,0,convertAngleUnit(_newAngles3[0]));}else if(t==='rotate3d');else if(t==='skew'){var newSkew=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0,0];object.setLocalSkew(deg2rad(newSkew[0]),deg2rad(newSkew[1]));}else if(t==='skewx'){var _newSkew=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0];object.setLocalSkew(deg2rad(_newSkew[0]),object.getLocalSkew()[1]);}else if(t==='skewy'){var _newSkew2=(d===null||d===void 0?void 0:d.map(function(s){return s.value;}))||[0];object.setLocalSkew(object.getLocalSkew()[0],deg2rad(_newSkew2[0]));}else if(t==='matrix'){var _d$map=d.map(function(s){return s.value;}),a=_d$map[0],b=_d$map[1],c=_d$map[2],dd=_d$map[3],tx=_d$map[4],ty=_d$map[5];object.setLocalTransform(set(tmpMat4,a,b,0,0,c,dd,0,0,0,0,1,0,tx+defX,ty+defY,0,1));}else if(t==='matrix3d'){// @ts-ignore
|
|
7592
|
+
set.apply(mat4,[tmpMat4].concat(d.map(function(s){return s.value;})));tmpMat4[12]+=defX;tmpMat4[13]+=defY;object.setLocalTransform(tmpMat4);}});}return object.getLocalTransform();}/**
|
|
7593
|
+
* borrow from gradient-parser, but we delete some browser compatible prefix such as `-webkit-`
|
|
7594
|
+
* @see https://github.com/rafaelcaricio/gradient-parser
|
|
7595
|
+
*/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,/**
|
|
7596
|
+
* @see https://projects.verou.me/conic-gradient/
|
|
7597
|
+
*/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
|
|
7598
|
+
radialType.at=matchAtPosition();}else {var extent=matchExtentKeyword();if(extent){radialType=extent;var positionAt=matchAtPosition();if(positionAt){// @ts-ignore
|
|
7599
|
+
radialType.at=positionAt;}}else {var defaultPosition=matchPositioning();if(defaultPosition){radialType={type:'default-radial',// @ts-ignore
|
|
7600
|
+
at:defaultPosition};}}}return radialType;}function matchCircle(){var circle=match('shape',/^(circle)/i,0);if(circle){// @ts-ignore
|
|
7601
|
+
circle.style=matchLength()||matchExtentKeyword();}return circle;}function matchEllipse(){var ellipse=match('shape',/^(ellipse)/i,0);if(ellipse){// @ts-ignore
|
|
7602
|
+
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
|
|
7603
|
+
// @see https://observablehq.com/@danburzo/css-gradient-line
|
|
7604
|
+
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'
|
|
7605
|
+
var x=cx.value;var y=cy.value;// TODO: 'em'
|
|
7606
|
+
// '%'
|
|
7607
|
+
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
|
|
7608
|
+
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
|
|
7609
|
+
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={}));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'
|
|
7610
|
+
for(var i=0;i<pathArray.length;i++){var params=pathArray[i];var cmd=params[0];if(cmd==='M'){// 遇到 'M' 判定是否是新数组,新数组中没有点
|
|
7611
|
+
if(points.length){// 如果存在点,则说明没有遇到 'Z',开始了一个新的多边形
|
|
7612
|
+
polylines.push(points);points=[];// 创建新的点
|
|
7613
|
+
}points.push([params[1],params[2]]);}else if(cmd==='Z'){if(points.length){// 存在点
|
|
7614
|
+
polygons.push(points);points=[];// 开始新的点集合
|
|
7615
|
+
}// 如果不存在点,同时 'Z',则说明是错误,不处理
|
|
7616
|
+
}else {points.push([params[1],params[2]]);}}// 说明 points 未放入 polygons 或者 polyline
|
|
7617
|
+
// 仅当只有一个 M,没有 Z 时会发生这种情况
|
|
7618
|
+
if(points.length>0){polylines.push(points);}return {polygons:polygons,polylines:polylines};}function isSamePoint(point1,point2){return point1[0]===point2[0]&&point1[1]===point2[1];}function getPathBBox(segments,lineWidth){var xArr=[];var yArr=[];var segmentsWithAngle=[];for(var i=0;i<segments.length;i++){var segment=segments[i];var currentPoint=segment.currentPoint,params=segment.params,prePoint=segment.prePoint;var box=void 0;switch(segment.command){case'Q':box=quadratic.box(prePoint[0],prePoint[1],params[1],params[2],params[3],params[4]);break;case'C':box=cubic.box(prePoint[0],prePoint[1],params[1],params[2],params[3],params[4],params[5],params[6]);break;case'A':var arcParams=segment.arcParams;box=arc.box(arcParams.cx,arcParams.cy,arcParams.rx,arcParams.ry,arcParams.xRotation,arcParams.startAngle,arcParams.endAngle);break;default:xArr.push(currentPoint[0]);yArr.push(currentPoint[1]);break;}if(box){segment.box=box;xArr.push(box.x,box.x+box.width);yArr.push(box.y,box.y+box.height);}if(lineWidth&&(segment.command==='L'||segment.command==='M')&&segment.prePoint&&segment.nextPoint){segmentsWithAngle.push(segment);}}// bbox calculation should ignore NaN for path attribute
|
|
7619
|
+
// ref: https://github.com/antvis/g/issues/210
|
|
7620
|
+
// ref: https://github.com/antvis/G2/issues/3109
|
|
7621
|
+
xArr=xArr.filter(function(item){return !Number.isNaN(item)&&item!==Infinity&&item!==-Infinity;});yArr=yArr.filter(function(item){return !Number.isNaN(item)&&item!==Infinity&&item!==-Infinity;});var minX=min(xArr);var minY=min(yArr);var maxX=max(xArr);var maxY=max(yArr);if(segmentsWithAngle.length===0){return {x:minX,y:minY,width:maxX-minX,height:maxY-minY};}for(var _i=0;_i<segmentsWithAngle.length;_i++){var _segment=segmentsWithAngle[_i];var _currentPoint=_segment.currentPoint;var extra=void 0;if(_currentPoint[0]===minX){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);minX=minX-extra.xExtra;}else if(_currentPoint[0]===maxX){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);maxX=maxX+extra.xExtra;}if(_currentPoint[1]===minY){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);minY=minY-extra.yExtra;}else if(_currentPoint[1]===maxY){extra=getExtraFromSegmentWithAngle(_segment,lineWidth);maxY=maxY+extra.yExtra;}}return {x:minX,y:minY,width:maxX-minX,height:maxY-minY};}function getExtraFromSegmentWithAngle(segment,lineWidth){var prePoint=segment.prePoint,currentPoint=segment.currentPoint,nextPoint=segment.nextPoint;var currentAndPre=Math.pow(currentPoint[0]-prePoint[0],2)+Math.pow(currentPoint[1]-prePoint[1],2);var currentAndNext=Math.pow(currentPoint[0]-nextPoint[0],2)+Math.pow(currentPoint[1]-nextPoint[1],2);var preAndNext=Math.pow(prePoint[0]-nextPoint[0],2)+Math.pow(prePoint[1]-nextPoint[1],2);// 以 currentPoint 为顶点的夹角
|
|
7622
|
+
var currentAngle=Math.acos((currentAndPre+currentAndNext-preAndNext)/(2*Math.sqrt(currentAndPre)*Math.sqrt(currentAndNext)));// 夹角为空、 0 或 PI 时,不需要计算夹角处的额外宽度
|
|
7623
|
+
// 注意: 由于计算精度问题,夹角为 0 的情况计算出来的角度可能是一个很小的值,还需要判断其与 0 是否近似相等
|
|
7624
|
+
if(!currentAngle||Math.sin(currentAngle)===0||isNumberEqual(currentAngle,0)){return {xExtra:0,yExtra:0};}var xAngle=Math.abs(Math.atan2(nextPoint[1]-currentPoint[1],nextPoint[0]-currentPoint[0]));var yAngle=Math.abs(Math.atan2(nextPoint[0]-currentPoint[0],nextPoint[1]-currentPoint[1]));// 将夹角转为锐角
|
|
7625
|
+
xAngle=xAngle>Math.PI/2?Math.PI-xAngle:xAngle;yAngle=yAngle>Math.PI/2?Math.PI-yAngle:yAngle;// 这里不考虑在水平和垂直方向的投影,直接使用最大差值
|
|
7626
|
+
// 由于上层统一加减了二分之一线宽,这里需要进行弥补
|
|
7627
|
+
var extra={// 水平方向投影
|
|
7628
|
+
xExtra:Math.cos(currentAngle/2-xAngle)*(lineWidth/2*(1/Math.sin(currentAngle/2)))-lineWidth/2||0,// 垂直方向投影
|
|
7629
|
+
yExtra:Math.cos(yAngle-currentAngle/2)*(lineWidth/2*(1/Math.sin(currentAngle/2)))-lineWidth/2||0};return extra;}// 点对称
|
|
7630
|
+
function toSymmetry(point,center){return [center[0]+(center[0]-point[0]),center[1]+(center[1]-point[1])];}var angleBetween$1=function angleBetween(v0,v1){var p=v0.x*v1.x+v0.y*v1.y;var n=Math.sqrt((Math.pow(v0.x,2)+Math.pow(v0.y,2))*(Math.pow(v1.x,2)+Math.pow(v1.y,2)));var sign=v0.x*v1.y-v0.y*v1.x<0?-1:1;var angle=sign*Math.acos(p/n);return angle;};/**
|
|
7631
|
+
* @see https://github.com/rveciana/svg-path-properties/blob/b6bd9a322966f6ef7a311872d80c56e3718de861/src/arc.ts#L121
|
|
7632
|
+
*/var pointOnEllipticalArc=function pointOnEllipticalArc(p0,rx,ry,xAxisRotation,largeArcFlag,sweepFlag,p1,t){// In accordance to: http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
|
|
7633
|
+
rx=Math.abs(rx);ry=Math.abs(ry);xAxisRotation=mod(xAxisRotation,360);var xAxisRotationRadians=deg2rad(xAxisRotation);// If the endpoints are identical, then this is equivalent to omitting the elliptical arc segment entirely.
|
|
7634
|
+
if(p0.x===p1.x&&p0.y===p1.y){return {x:p0.x,y:p0.y,ellipticalArcAngle:0};// Check if angle is correct
|
|
7635
|
+
}// If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
|
|
7636
|
+
if(rx===0||ry===0){//return this.pointOnLine(p0, p1, t);
|
|
7637
|
+
return {x:0,y:0,ellipticalArcAngle:0};// Check if angle is correct
|
|
7638
|
+
}// Following "Conversion from endpoint to center parameterization"
|
|
7639
|
+
// http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
|
|
7640
|
+
// Step #1: Compute transformedPoint
|
|
7641
|
+
var dx=(p0.x-p1.x)/2;var dy=(p0.y-p1.y)/2;var transformedPoint={x:Math.cos(xAxisRotationRadians)*dx+Math.sin(xAxisRotationRadians)*dy,y:-Math.sin(xAxisRotationRadians)*dx+Math.cos(xAxisRotationRadians)*dy};// Ensure radii are large enough
|
|
7642
|
+
var radiiCheck=Math.pow(transformedPoint.x,2)/Math.pow(rx,2)+Math.pow(transformedPoint.y,2)/Math.pow(ry,2);if(radiiCheck>1){rx=Math.sqrt(radiiCheck)*rx;ry=Math.sqrt(radiiCheck)*ry;}// Step #2: Compute transformedCenter
|
|
7643
|
+
var cSquareNumerator=Math.pow(rx,2)*Math.pow(ry,2)-Math.pow(rx,2)*Math.pow(transformedPoint.y,2)-Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cSquareRootDenom=Math.pow(rx,2)*Math.pow(transformedPoint.y,2)+Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cRadicand=cSquareNumerator/cSquareRootDenom;// Make sure this never drops below zero because of precision
|
|
7644
|
+
cRadicand=cRadicand<0?0:cRadicand;var cCoef=(largeArcFlag!==sweepFlag?1:-1)*Math.sqrt(cRadicand);var transformedCenter={x:cCoef*(rx*transformedPoint.y/ry),y:cCoef*(-(ry*transformedPoint.x)/rx)};// Step #3: Compute center
|
|
7645
|
+
var center={x:Math.cos(xAxisRotationRadians)*transformedCenter.x-Math.sin(xAxisRotationRadians)*transformedCenter.y+(p0.x+p1.x)/2,y:Math.sin(xAxisRotationRadians)*transformedCenter.x+Math.cos(xAxisRotationRadians)*transformedCenter.y+(p0.y+p1.y)/2};// Step #4: Compute start/sweep angles
|
|
7646
|
+
// Start angle of the elliptical arc prior to the stretch and rotate operations.
|
|
7647
|
+
// Difference between the start and end angles
|
|
7648
|
+
var startVector={x:(transformedPoint.x-transformedCenter.x)/rx,y:(transformedPoint.y-transformedCenter.y)/ry};var startAngle=angleBetween$1({x:1,y:0},startVector);var endVector={x:(-transformedPoint.x-transformedCenter.x)/rx,y:(-transformedPoint.y-transformedCenter.y)/ry};var sweepAngle=angleBetween$1(startVector,endVector);if(!sweepFlag&&sweepAngle>0){sweepAngle-=2*Math.PI;}else if(sweepFlag&&sweepAngle<0){sweepAngle+=2*Math.PI;}// We use % instead of `mod(..)` because we want it to be -360deg to 360deg(but actually in radians)
|
|
7649
|
+
sweepAngle%=2*Math.PI;// From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
|
|
7650
|
+
var angle=startAngle+sweepAngle*t;var ellipseComponentX=rx*Math.cos(angle);var ellipseComponentY=ry*Math.sin(angle);var point={x:Math.cos(xAxisRotationRadians)*ellipseComponentX-Math.sin(xAxisRotationRadians)*ellipseComponentY+center.x,y:Math.sin(xAxisRotationRadians)*ellipseComponentX+Math.cos(xAxisRotationRadians)*ellipseComponentY+center.y,ellipticalArcStartAngle:startAngle,ellipticalArcEndAngle:startAngle+sweepAngle,ellipticalArcAngle:angle,ellipticalArcCenter:center,resultantRx:rx,resultantRy:ry};return point;};function path2Segments(path){var segments=[];var currentPoint=null;// 当前图形
|
|
7651
|
+
var nextParams=null;// 下一节点的 path 参数
|
|
7652
|
+
var startMovePoint=null;// 开始 M 的点,可能会有多个
|
|
7653
|
+
var lastStartMovePointIndex=0;// 最近一个开始点 M 的索引
|
|
7654
|
+
var count=path.length;for(var i=0;i<count;i++){var params=path[i];nextParams=path[i+1];var command=params[0];// 数学定义上的参数,便于后面的计算
|
|
7655
|
+
var segment={command:command,prePoint:currentPoint,params:params,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(command){case'M':startMovePoint=[params[1],params[2]];lastStartMovePointIndex=i;break;case'A':var arcParams=getArcParams(currentPoint,params);segment.arcParams=arcParams;break;}if(command==='Z'){// 有了 Z 后,当前节点从开始 M 的点开始
|
|
7656
|
+
currentPoint=startMovePoint;// 如果当前点的命令为 Z,相当于当前点为最近一个 M 点,则下一个点直接指向最近一个 M 点的下一个点
|
|
7657
|
+
nextParams=path[lastStartMovePointIndex+1];}else {var len=params.length;currentPoint=[params[len-2],params[len-1]];}if(nextParams&&nextParams[0]==='Z'){// 如果下一个点的命令为 Z,则下一个点直接指向最近一个 M 点
|
|
7658
|
+
nextParams=path[lastStartMovePointIndex];if(segments[lastStartMovePointIndex]){// 如果下一个点的命令为 Z,则最近一个 M 点的前一个点为当前点
|
|
7659
|
+
segments[lastStartMovePointIndex].prePoint=currentPoint;}}segment.currentPoint=currentPoint;// 如果当前点与最近一个 M 点相同,则最近一个 M 点的前一个点为当前点的前一个点
|
|
7660
|
+
if(segments[lastStartMovePointIndex]&&isSamePoint(currentPoint,segments[lastStartMovePointIndex].currentPoint)){segments[lastStartMovePointIndex].prePoint=segment.prePoint;}var nextPoint=nextParams?[nextParams[nextParams.length-2],nextParams[nextParams.length-1]]:null;segment.nextPoint=nextPoint;// Add startTangent and endTangent
|
|
7661
|
+
var prePoint=segment.prePoint;if(['L','H','V'].includes(command)){segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}else if(command==='Q'){// 二次贝塞尔曲线只有一个控制点
|
|
7662
|
+
var cp=[params[1],params[2]];// 二次贝塞尔曲线的终点为 currentPoint
|
|
7663
|
+
segment.startTangent=[prePoint[0]-cp[0],prePoint[1]-cp[1]];segment.endTangent=[currentPoint[0]-cp[0],currentPoint[1]-cp[1]];}else if(command==='T'){var preSegment=segments[i-1];var _cp=toSymmetry(preSegment.currentPoint,prePoint);if(preSegment.command==='Q'){segment.command='Q';segment.startTangent=[prePoint[0]-_cp[0],prePoint[1]-_cp[1]];segment.endTangent=[currentPoint[0]-_cp[0],currentPoint[1]-_cp[1]];}else {// @ts-ignore
|
|
7664
|
+
segment.command='TL';segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}}else if(command==='C'){// 三次贝塞尔曲线有两个控制点
|
|
7665
|
+
var cp1=[params[1],params[2]];var cp2=[params[3],params[4]];segment.startTangent=[prePoint[0]-cp1[0],prePoint[1]-cp1[1]];segment.endTangent=[currentPoint[0]-cp2[0],currentPoint[1]-cp2[1]];// horizontal line, eg. ['C', 100, 100, 100, 100, 200, 200]
|
|
7666
|
+
if(segment.startTangent[0]===0&&segment.startTangent[1]===0){segment.startTangent=[cp1[0]-cp2[0],cp1[1]-cp2[1]];}if(segment.endTangent[0]===0&&segment.endTangent[1]===0){segment.endTangent=[cp2[0]-cp1[0],cp2[1]-cp1[1]];}}else if(command==='S'){var _preSegment=segments[i-1];var _cp2=toSymmetry(_preSegment.currentPoint,prePoint);var _cp3=[params[1],params[2]];if(_preSegment.command==='C'){segment.command='C';// 将 S 命令变换为 C 命令
|
|
7667
|
+
segment.startTangent=[prePoint[0]-_cp2[0],prePoint[1]-_cp2[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}else {// @ts-ignore
|
|
7668
|
+
segment.command='SQ';// 将 S 命令变换为 SQ 命令
|
|
7669
|
+
segment.startTangent=[prePoint[0]-_cp3[0],prePoint[1]-_cp3[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}}else if(command==='A'){var _getTangentAtRatio=getTangentAtRatio(segment,0),dx1=_getTangentAtRatio.x,dy1=_getTangentAtRatio.y;var _getTangentAtRatio2=getTangentAtRatio(segment,1,false),dx2=_getTangentAtRatio2.x,dy2=_getTangentAtRatio2.y;segment.startTangent=[dx1,dy1];segment.endTangent=[dx2,dy2];}segments.push(segment);}return segments;}/**
|
|
7670
|
+
* Use length instead of ratio
|
|
7671
|
+
*/function getTangentAtRatio(segment,ratio,sign){if(sign===void 0){sign=true;}var _segment$arcParams=segment.arcParams,_segment$arcParams$rx=_segment$arcParams.rx,rx=_segment$arcParams$rx===void 0?0:_segment$arcParams$rx,_segment$arcParams$ry=_segment$arcParams.ry,ry=_segment$arcParams$ry===void 0?0:_segment$arcParams$ry,xRotation=_segment$arcParams.xRotation,arcFlag=_segment$arcParams.arcFlag,sweepFlag=_segment$arcParams.sweepFlag;var p1=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},ratio);var p2=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},sign?ratio+0.005:ratio-0.005);var xDist=p2.x-p1.x;var yDist=p2.y-p1.y;var dist=Math.sqrt(xDist*xDist+yDist*yDist);return {x:-xDist/dist,y:-yDist/dist};}// 向量长度
|
|
7672
|
+
function vMag(v){return Math.sqrt(v[0]*v[0]+v[1]*v[1]);}// u.v/|u||v|,计算夹角的余弦值
|
|
7673
|
+
function vRatio(u,v){// 当存在一个向量的长度为 0 时,夹角也为 0,即夹角的余弦值为 1
|
|
7674
|
+
return vMag(u)*vMag(v)?(u[0]*v[0]+u[1]*v[1])/(vMag(u)*vMag(v)):1;}// 向量角度
|
|
7675
|
+
function vAngle(u,v){return (u[0]*v[1]<u[1]*v[0]?-1:1)*Math.acos(vRatio(u,v));}function getArcParams(startPoint,params){var rx=params[1];var ry=params[2];var xRotation=mod(deg2rad(params[3]),Math.PI*2);var arcFlag=params[4];var sweepFlag=params[5];// 弧形起点坐标
|
|
7676
|
+
var x1=startPoint[0];var y1=startPoint[1];// 弧形终点坐标
|
|
7677
|
+
var x2=params[6];var y2=params[7];var xp=Math.cos(xRotation)*(x1-x2)/2.0+Math.sin(xRotation)*(y1-y2)/2.0;var yp=-1*Math.sin(xRotation)*(x1-x2)/2.0+Math.cos(xRotation)*(y1-y2)/2.0;var lambda=xp*xp/(rx*rx)+yp*yp/(ry*ry);if(lambda>1){rx*=Math.sqrt(lambda);ry*=Math.sqrt(lambda);}var diff=rx*rx*(yp*yp)+ry*ry*(xp*xp);var f=diff?Math.sqrt((rx*rx*(ry*ry)-diff)/diff):1;if(arcFlag===sweepFlag){f*=-1;}if(isNaN(f)){f=0;}// 旋转前的起点坐标,且当长半轴和短半轴的长度为 0 时,坐标按 (0, 0) 处理
|
|
7678
|
+
var cxp=ry?f*rx*yp/ry:0;var cyp=rx?f*-ry*xp/rx:0;// 椭圆圆心坐标
|
|
7679
|
+
var cx=(x1+x2)/2.0+Math.cos(xRotation)*cxp-Math.sin(xRotation)*cyp;var cy=(y1+y2)/2.0+Math.sin(xRotation)*cxp+Math.cos(xRotation)*cyp;// 起始点的单位向量
|
|
7680
|
+
var u=[(xp-cxp)/rx,(yp-cyp)/ry];// 终止点的单位向量
|
|
7681
|
+
var v=[(-1*xp-cxp)/rx,(-1*yp-cyp)/ry];// 计算起始点和圆心的连线,与 x 轴正方向的夹角
|
|
7682
|
+
var theta=vAngle([1,0],u);// 计算圆弧起始点和终止点与椭圆圆心连线的夹角
|
|
7683
|
+
var dTheta=vAngle(u,v);if(vRatio(u,v)<=-1){dTheta=Math.PI;}if(vRatio(u,v)>=1){dTheta=0;}if(sweepFlag===0&&dTheta>0){dTheta=dTheta-2*Math.PI;}if(sweepFlag===1&&dTheta<0){dTheta=dTheta+2*Math.PI;}return {cx:cx,cy:cy,// 弧形的起点和终点相同时,长轴和短轴的长度按 0 处理
|
|
7684
|
+
rx:isSamePoint(startPoint,[x2,y2])?0:rx,ry:isSamePoint(startPoint,[x2,y2])?0:ry,startAngle:theta,endAngle:theta+dTheta,xRotation:xRotation,arcFlag:arcFlag,sweepFlag:sweepFlag};}function commandsToPathString(commands,object,transform){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;return commands.reduce(function(prev,cur){var path='';if(cur[0]==='M'||cur[0]==='L'){var p=fromValues$2(cur[1]-defX,cur[2]-defY,0);if(transform){transformMat4(p,p,transform);}path=""+cur[0]+p[0]+","+p[1];}else if(cur[0]==='Z'){path=cur[0];}else if(cur[0]==='C'){var p1=fromValues$2(cur[1]-defX,cur[2]-defY,0);var p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);var p3=fromValues$2(cur[5]-defX,cur[6]-defY,0);if(transform){transformMat4(p1,p1,transform);transformMat4(p2,p2,transform);transformMat4(p3,p3,transform);}path=""+cur[0]+p1[0]+","+p1[1]+","+p2[0]+","+p2[1]+","+p3[0]+","+p3[1];}else if(cur[0]==='A'){var c=fromValues$2(cur[6]-defX,cur[7]-defY,0);if(transform){transformMat4(c,c,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+","+cur[5]+","+c[0]+","+c[1];}else if(cur[0]==='Q'){var _p=fromValues$2(cur[1]-defX,cur[2]-defY,0);var _p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);if(transform){transformMat4(_p,_p,transform);transformMat4(_p2,_p2,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+"}";}return prev+=path;},'');}function lineToCommands(x1,y1,x2,y2){return [['M',x1,y1],['L',x2,y2]];}function ellipseToCommands(rx,ry,cx,cy){var factor=(-1+Math.sqrt(2))/3*4;var dx=rx*factor;var dy=ry*factor;var left=cx-rx;var right=cx+rx;var top=cy-ry;var bottom=cy+ry;return [['M',left,cy],['C',left,cy-dy,cx-dx,top,cx,top],['C',cx+dx,top,right,cy-dy,right,cy],['C',right,cy+dy,cx+dx,bottom,cx,bottom],['C',cx-dx,bottom,left,cy+dy,left,cy],['Z']];}function polygonToCommands(points,closed){var result=points.map(function(point,i){return [i===0?'M':'L',point[0],point[1]];});if(closed){result.push(['Z']);}return result;}function rectToCommands(width,height,x,y,radius){// @see https://gist.github.com/danielpquinn/dd966af424030d47e476
|
|
7685
|
+
if(radius){var tlr=radius[0],trr=radius[1],brr=radius[2],blr=radius[3];var signX=width>0?1:-1;var signY=height>0?1:-1;// sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
7686
|
+
var sweepFlag=signX+signY!==0?1:0;return [['M',signX*tlr+x,y],['L',width-signX*trr+x,y],trr?['A',trr,trr,0,0,sweepFlag,width+x,signY*trr+y]:null,['L',width+x,height-signY*brr+y],brr?['A',brr,brr,0,0,sweepFlag,width+x-signX*brr,height+y]:null,['L',x+signX*blr,height+y],blr?['A',blr,blr,0,0,sweepFlag,x,height+y-signY*blr]:null,['L',x,signY*tlr+y],tlr?['A',tlr,tlr,0,0,sweepFlag,signX*tlr+x,y]:null,['Z']].filter(function(command){return command;});}return [['M',x,y],['L',x+width,y],['L',x+width,y+height],['L',x,y+height],['Z']];}/**
|
|
7687
|
+
* convert object to path, should account for:
|
|
7688
|
+
* * transform & origin
|
|
7689
|
+
* * anchor
|
|
7690
|
+
* * lineWidth
|
|
7691
|
+
*/function convertToPath(object,transform){if(transform===void 0){transform=object.getLocalTransform();}var commands=[];switch(object.nodeName){case exports.Shape.LINE:var _object$parsedStyle2=object.parsedStyle,x1=_object$parsedStyle2.x1,y1=_object$parsedStyle2.y1,x2=_object$parsedStyle2.x2,y2=_object$parsedStyle2.y2;commands=lineToCommands(x1,y1,x2,y2);break;case exports.Shape.CIRCLE:{var _object$parsedStyle3=object.parsedStyle,r=_object$parsedStyle3.r,cx=_object$parsedStyle3.cx,cy=_object$parsedStyle3.cy;commands=ellipseToCommands(r,r,cx,cy);break;}case exports.Shape.ELLIPSE:{var _object$parsedStyle4=object.parsedStyle,rx=_object$parsedStyle4.rx,ry=_object$parsedStyle4.ry,_cx=_object$parsedStyle4.cx,_cy=_object$parsedStyle4.cy;commands=ellipseToCommands(rx,ry,_cx,_cy);break;}case exports.Shape.POLYLINE:case exports.Shape.POLYGON:var points=object.parsedStyle.points;commands=polygonToCommands(points.points,object.nodeName===exports.Shape.POLYGON);break;case exports.Shape.RECT:var _object$parsedStyle5=object.parsedStyle,width=_object$parsedStyle5.width,height=_object$parsedStyle5.height,x=_object$parsedStyle5.x,y=_object$parsedStyle5.y,radius=_object$parsedStyle5.radius;var hasRadius=radius&&radius.some(function(r){return r!==0;});commands=rectToCommands(width,height,x,y,hasRadius&&radius.map(function(r){return clamp(r,0,Math.min(Math.abs(width)/2,Math.abs(height)/2));}));break;case exports.Shape.PATH:var absolutePath=object.parsedStyle.path.absolutePath;commands=[].concat(absolutePath);break;}if(commands.length){return commandsToPathString(commands,object,transform);}}function translatePathToString(absolutePath,defX,defY,startOffsetX,startOffsetY,endOffsetX,endOffsetY){if(startOffsetX===void 0){startOffsetX=0;}if(startOffsetY===void 0){startOffsetY=0;}if(endOffsetX===void 0){endOffsetX=0;}if(endOffsetY===void 0){endOffsetY=0;}var newValue=absolutePath.map(function(params,i){var command=params[0];var nextSegment=absolutePath[i+1];var useStartOffset=i===0&&(startOffsetX!==0||startOffsetY!==0);var useEndOffset=(i===absolutePath.length-1||nextSegment&&(nextSegment[0]==='M'||nextSegment[0]==='Z'))&&endOffsetX!==0&&endOffsetY!==0;switch(command){case'M':// Use start marker offset
|
|
7692
|
+
if(useStartOffset){return "M "+(params[1]-defX+startOffsetX)+","+(params[2]-defY+startOffsetY)+" L "+(params[1]-defX)+","+(params[2]-defY);}else {return "M "+(params[1]-defX)+","+(params[2]-defY);}case'L':return "L "+(params[1]-defX+(useEndOffset?endOffsetX:0))+","+(params[2]-defY+(useEndOffset?endOffsetY:0));case'Q':return "Q "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+(useEndOffset?" L "+(params[3]-defX+endOffsetX)+","+(params[4]-defY+endOffsetY):'');case'C':return "C "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+","+(params[5]-defX)+" "+(params[6]-defY)+(useEndOffset?" L "+(params[5]-defX+endOffsetX)+","+(params[6]-defY+endOffsetY):'');case'A':return "A "+params[1]+" "+params[2]+" "+params[3]+" "+params[4]+" "+params[5]+" "+(params[6]-defX)+" "+(params[7]-defY)+(useEndOffset?" L "+(params[6]-defX+endOffsetX)+","+(params[7]-defY+endOffsetY):'');case'Z':return 'Z';}}).join(' ');if(~newValue.indexOf('NaN')){return '';}return newValue;}function isFillOrStrokeAffected(pointerEvents,fill,stroke){// account for pointerEvents
|
|
7693
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
7694
|
+
var hasFill=false;var hasStroke=false;var isFillOtherThanNone=!!fill&&!fill.isNone;var isStrokeOtherThanNone=!!stroke&&!stroke.isNone;if(pointerEvents==='visiblepainted'||pointerEvents==='painted'||pointerEvents==='auto'){hasFill=isFillOtherThanNone;hasStroke=isStrokeOtherThanNone;}else if(pointerEvents==='visiblefill'||pointerEvents==='fill'){hasFill=true;}else if(pointerEvents==='visiblestroke'||pointerEvents==='stroke'){hasStroke=true;}else if(pointerEvents==='visible'||pointerEvents==='all'){// The values of the fill and stroke do not affect event processing.
|
|
7695
|
+
hasFill=true;hasStroke=true;}return [hasFill,hasStroke];}// @ts-nocheck
|
|
7696
|
+
// interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
7697
|
+
// name?: string;
|
|
7698
|
+
// tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
|
|
7699
|
+
// call?: (...args: any[]) => void;
|
|
7700
|
+
// loop?: (...args: any[]) => void;
|
|
7701
|
+
// error?: (err: Error) => void;
|
|
7702
|
+
// result?: (result: R) => void;
|
|
7703
|
+
// done?: () => void;
|
|
7704
|
+
// register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
|
|
7705
|
+
// }
|
|
7706
|
+
// type ArgumentNames<T extends any[]> = FixedSizeArray<T['length'], string>;
|
|
7707
|
+
// export declare class AsyncHook<T, R, AdditionalOptions = UnsetAdditionalOptions> extends Hook<
|
|
7708
|
+
// T,
|
|
7709
|
+
// R,
|
|
7710
|
+
// AdditionalOptions
|
|
7711
|
+
// > {
|
|
7712
|
+
// tapAsync(
|
|
7713
|
+
// options: string | (Tap & IfSet<AdditionalOptions>),
|
|
7714
|
+
// fn: (...args: Append<AsArray<T>, InnerCallback<Error, R>>) => void,
|
|
7715
|
+
// ): void;
|
|
7716
|
+
// tapPromise(
|
|
7717
|
+
// options: string | (Tap & IfSet<AdditionalOptions>),
|
|
7718
|
+
// fn: (...args: AsArray<T>) => Promise<R>,
|
|
7719
|
+
// ): void;
|
|
7720
|
+
// }
|
|
7721
|
+
var CALL_DELEGATE=function CALL_DELEGATE(){this.call=this._createCall('sync');return this.call.apply(this,arguments);};var CALL_ASYNC_DELEGATE=function CALL_ASYNC_DELEGATE(){this.callAsync=this._createCall('async');return this.callAsync.apply(this,arguments);};var PROMISE_DELEGATE=function PROMISE_DELEGATE(){this.promise=this._createCall('promise');return this.promise.apply(this,arguments);};var Hook=/*#__PURE__*/function(){function Hook(args,name){if(args===void 0){args=[];}if(name===void 0){name=undefined;}this.name=void 0;this.taps=void 0;this.promise=void 0;this._promise=void 0;this._args=args;this.name=name;this.taps=[];this.interceptors=[];this._call=CALL_DELEGATE;this.call=CALL_DELEGATE;this._callAsync=CALL_ASYNC_DELEGATE;this.callAsync=CALL_ASYNC_DELEGATE;this._promise=PROMISE_DELEGATE;this.promise=PROMISE_DELEGATE;this._x=undefined;// this.compile = this.compile;
|
|
7722
|
+
// this.tap = this.tap;
|
|
7723
|
+
// this.tapAsync = this.tapAsync;
|
|
7724
|
+
// this.tapPromise = this.tapPromise;
|
|
7725
|
+
}var _proto=Hook.prototype;_proto.compile=function compile(options){throw new Error('Abstract: should be overridden');};_proto._createCall=function _createCall(type){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:type});};_proto._tap=function _tap(type,options,fn){if(typeof options==='string'){options={name:options.trim()};}else if(typeof options!=='object'||options===null){throw new Error('Invalid tap options');}if(typeof options.name!=='string'||options.name===''){throw new Error('Missing name for tap');}// if (typeof options.context !== "undefined") {
|
|
7726
|
+
// deprecateContext();
|
|
7727
|
+
// }
|
|
7728
|
+
options=Object.assign({type:type,fn:fn},options);options=this._runRegisterInterceptors(options);this._insert(options);};_proto.tap=function tap(options,fn){this._tap('sync',options,fn);};_proto.tapAsync=function tapAsync(options,fn){this._tap('async',options,fn);};_proto.tapPromise=function tapPromise(options,fn){this._tap('promise',options,fn);};_proto._runRegisterInterceptors=function _runRegisterInterceptors(options){for(var _iterator=_createForOfIteratorHelperLoose(this.interceptors),_step;!(_step=_iterator()).done;){var interceptor=_step.value;if(interceptor.register){var newOptions=interceptor.register(options);if(newOptions!==undefined){options=newOptions;}}}return options;};_proto.withOptions=function withOptions(options){var _this=this;var mergeOptions=function mergeOptions(opt){return Object.assign({},options,typeof opt==='string'?{name:opt}:opt);};return {name:this.name,tap:function tap(opt,fn){return _this.tap(mergeOptions(opt),fn);},tapAsync:function tapAsync(opt,fn){return _this.tapAsync(mergeOptions(opt),fn);},tapPromise:function tapPromise(opt,fn){return _this.tapPromise(mergeOptions(opt),fn);},// intercept: (interceptor) => this.intercept(interceptor),
|
|
7729
|
+
isUsed:function isUsed(){return _this.isUsed();},withOptions:function withOptions(opt){return _this.withOptions(mergeOptions(opt));}};};_proto.isUsed=function isUsed(){return this.taps.length>0||this.interceptors.length>0;}// intercept(interceptor: HookInterceptor<T, R, AdditionalOptions>) {
|
|
7730
|
+
// this._resetCompilation();
|
|
7731
|
+
// this.interceptors.push(Object.assign({}, interceptor));
|
|
7732
|
+
// if (interceptor.register) {
|
|
7733
|
+
// for (let i = 0; i < this.taps.length; i++) {
|
|
7734
|
+
// this.taps[i] = interceptor.register(this.taps[i]);
|
|
7735
|
+
// }
|
|
7736
|
+
// }
|
|
7737
|
+
// }
|
|
7738
|
+
;_proto._resetCompilation=function _resetCompilation(){this.call=this._call;this.callAsync=this._callAsync;this.promise=this._promise;};_proto._insert=function _insert(item){this._resetCompilation();var before;if(typeof item.before==='string'){before=new Set([item.before]);}else if(Array.isArray(item.before)){before=new Set(item.before);}var stage=0;if(typeof item.stage==='number'){stage=item.stage;}var i=this.taps.length;while(i>0){i--;var x=this.taps[i];this.taps[i+1]=x;var xStage=x.stage||0;if(before){if(before.has(x.name)){before.delete(x.name);continue;}if(before.size>0){continue;}}if(xStage>stage){continue;}i++;break;}this.taps[i]=item;};return Hook;}();// Object.setPrototypeOf(Hook.prototype, null);
|
|
7739
|
+
// @ts-nocheck
|
|
7740
|
+
var HookCodeFactory=/*#__PURE__*/function(){function HookCodeFactory(config){this.config=config;this.options=undefined;this._args=undefined;}var _proto=HookCodeFactory.prototype;_proto.create=function create(options){this.init(options);var fn;switch(this.options.type){case'sync':fn=new Function(this.args(),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "throw "+err+";\n";},onResult:function onResult(result){return "return "+result+";\n";},resultReturns:true,onDone:function onDone(){return '';},rethrowIfPossible:true}));break;case'async':fn=new Function(this.args({after:'_callback'}),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "_callback("+err+");\n";},onResult:function onResult(result){return "_callback(null, "+result+");\n";},onDone:function onDone(){return '_callback();\n';}}));break;case'promise':var errorHelperUsed=false;var content=this.contentWithInterceptors({onError:function onError(err){errorHelperUsed=true;return "_error("+err+");\n";},onResult:function onResult(result){return "_resolve("+result+");\n";},onDone:function onDone(){return '_resolve();\n';}});var code='';code+='"use strict";\n';code+=this.header();code+='return new Promise((function(_resolve, _reject) {\n';if(errorHelperUsed){code+='var _sync = true;\n';code+='function _error(_err) {\n';code+='if(_sync)\n';code+='_resolve(Promise.resolve().then((function() { throw _err; })));\n';code+='else\n';code+='_reject(_err);\n';code+='};\n';}code+=content;if(errorHelperUsed){code+='_sync = false;\n';}code+='}));\n';fn=new Function(this.args(),code);break;}this.deinit();return fn;};_proto.setup=function setup(instance,options){instance._x=options.taps.map(function(t){return t.fn;});}/**
|
|
7741
|
+
* @param {{ type: "sync" | "promise" | "async", taps: Array<Tap>, interceptors: Array<Interceptor> }} options
|
|
7742
|
+
*/;_proto.init=function init(options){this.options=options;this._args=options.args.slice();};_proto.deinit=function deinit(){this.options=undefined;this._args=undefined;};_proto.contentWithInterceptors=function contentWithInterceptors(options){var _this=this;if(this.options.interceptors.length>0){var onError=options.onError;var onResult=options.onResult;var onDone=options.onDone;var code='';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.call){code+=this.getInterceptor(i)+".call("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.content(Object.assign(options,{onError:onError&&function(err){var code='';for(var _i=0;_i<_this.options.interceptors.length;_i++){var _interceptor=_this.options.interceptors[_i];if(_interceptor.error){code+=_this.getInterceptor(_i)+".error("+err+");\n";}}code+=onError(err);return code;},onResult:onResult&&function(result){var code='';for(var _i2=0;_i2<_this.options.interceptors.length;_i2++){var _interceptor2=_this.options.interceptors[_i2];if(_interceptor2.result){code+=_this.getInterceptor(_i2)+".result("+result+");\n";}}code+=onResult(result);return code;},onDone:onDone&&function(){var code='';for(var _i3=0;_i3<_this.options.interceptors.length;_i3++){var _interceptor3=_this.options.interceptors[_i3];if(_interceptor3.done){code+=_this.getInterceptor(_i3)+".done();\n";}}code+=onDone();return code;}}));return code;}else {return this.content(options);}};_proto.header=function header(){var code='';if(this.needContext()){code+='var _context = {};\n';}else {code+='var _context;\n';}code+='var _x = this._x;\n';if(this.options.interceptors.length>0){code+='var _taps = this.taps;\n';code+='var _interceptors = this.interceptors;\n';}return code;};_proto.needContext=function needContext(){for(var _iterator=_createForOfIteratorHelperLoose(this.options.taps),_step;!(_step=_iterator()).done;){var tap=_step.value;if(tap.context)return true;}return false;};_proto.callTap=function callTap(tapIndex,_ref){var onError=_ref.onError,onResult=_ref.onResult,onDone=_ref.onDone,rethrowIfPossible=_ref.rethrowIfPossible;var code='';var hasTapCached=false;for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.tap){if(!hasTapCached){code+="var _tap"+tapIndex+" = "+this.getTap(tapIndex)+";\n";hasTapCached=true;}code+=this.getInterceptor(i)+".tap("+(interceptor.context?'_context, ':'')+"_tap"+tapIndex+");\n";}}code+="var _fn"+tapIndex+" = "+this.getTapFn(tapIndex)+";\n";var tap=this.options.taps[tapIndex];switch(tap.type){case'sync':if(!rethrowIfPossible){code+="var _hasError"+tapIndex+" = false;\n";code+='try {\n';}if(onResult){code+="var _result"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}else {code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}if(!rethrowIfPossible){code+='} catch(_err) {\n';code+="_hasError"+tapIndex+" = true;\n";code+=onError('_err');code+='}\n';code+="if(!_hasError"+tapIndex+") {\n";}if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}if(!rethrowIfPossible){code+='}\n';}break;case'async':var cbCode='';if(onResult)cbCode+="(function(_err"+tapIndex+", _result"+tapIndex+") {\n";else cbCode+="(function(_err"+tapIndex+") {\n";cbCode+="if(_err"+tapIndex+") {\n";cbCode+=onError("_err"+tapIndex);cbCode+='} else {\n';if(onResult){cbCode+=onResult("_result"+tapIndex);}if(onDone){cbCode+=onDone();}cbCode+='}\n';cbCode+='})';code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined,after:cbCode})+");\n";break;case'promise':code+="var _hasResult"+tapIndex+" = false;\n";code+="var _promise"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";code+="if (!_promise"+tapIndex+" || !_promise"+tapIndex+".then)\n";code+=" throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise"+tapIndex+" + ')');\n";code+="_promise"+tapIndex+".then((function(_result"+tapIndex+") {\n";code+="_hasResult"+tapIndex+" = true;\n";if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}code+="}), function(_err"+tapIndex+") {\n";code+="if(_hasResult"+tapIndex+") throw _err"+tapIndex+";\n";code+=onError("_err"+tapIndex);code+='});\n';break;}return code;};_proto.callTapsSeries=function callTapsSeries(_ref2){var _this2=this;var _onError=_ref2.onError,onResult=_ref2.onResult,resultReturns=_ref2.resultReturns,onDone=_ref2.onDone,doneReturns=_ref2.doneReturns,rethrowIfPossible=_ref2.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var firstAsync=this.options.taps.findIndex(function(t){return t.type!=='sync';});var somethingReturns=resultReturns||doneReturns;var code='';var current=onDone;var unrollCounter=0;var _loop=function _loop(j){var i=j;var unroll=current!==onDone&&(_this2.options.taps[i].type!=='sync'||unrollCounter++>20);if(unroll){unrollCounter=0;code+="function _next"+i+"() {\n";code+=current();code+="}\n";current=function current(){return (somethingReturns?'return ':'')+"_next"+i+"();\n";};}var done=current;var doneBreak=function doneBreak(skipDone){if(skipDone)return '';return onDone();};var content=_this2.callTap(i,{onError:function onError(error){return _onError(i,error,done,doneBreak);},onResult:onResult&&function(result){return onResult(i,result,done,doneBreak);},onDone:!onResult&&done,rethrowIfPossible:rethrowIfPossible&&(firstAsync<0||i<firstAsync)});current=function current(){return content;};};for(var j=this.options.taps.length-1;j>=0;j--){_loop(j);}code+=current();return code;};_proto.callTapsLooping=function callTapsLooping(_ref3){var onError=_ref3.onError,onDone=_ref3.onDone,rethrowIfPossible=_ref3.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var syncOnly=this.options.taps.every(function(t){return t.type==='sync';});var code='';if(!syncOnly){code+='var _looper = (function() {\n';code+='var _loopAsync = false;\n';}code+='var _loop;\n';code+='do {\n';code+='_loop = false;\n';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.loop){code+=this.getInterceptor(i)+".loop("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.callTapsSeries({onError:onError,onResult:function onResult(i,result,next,doneBreak){var code='';code+="if("+result+" !== undefined) {\n";code+='_loop = true;\n';if(!syncOnly)code+='if(_loopAsync) _looper();\n';code+=doneBreak(true);code+="} else {\n";code+=next();code+="}\n";return code;},onDone:onDone&&function(){var code='';code+='if(!_loop) {\n';code+=onDone();code+='}\n';return code;},rethrowIfPossible:rethrowIfPossible&&syncOnly});code+='} while(_loop);\n';if(!syncOnly){code+='_loopAsync = true;\n';code+='});\n';code+='_looper();\n';}return code;};_proto.callTapsParallel=function callTapsParallel(_ref4){var _this3=this;var _onError2=_ref4.onError,onResult=_ref4.onResult,onDone=_ref4.onDone,rethrowIfPossible=_ref4.rethrowIfPossible,_ref4$onTap=_ref4.onTap,onTap=_ref4$onTap===void 0?function(i,run){return run();}:_ref4$onTap;if(this.options.taps.length<=1){return this.callTapsSeries({onError:_onError2,onResult:onResult,onDone:onDone,rethrowIfPossible:rethrowIfPossible});}var code='';code+='do {\n';code+="var _counter = "+this.options.taps.length+";\n";if(onDone){code+='var _done = (function() {\n';code+=onDone();code+='});\n';}var _loop2=function _loop2(i){var done=function done(){if(onDone)return 'if(--_counter === 0) _done();\n';else return '--_counter;';};var doneBreak=function doneBreak(skipDone){if(skipDone||!onDone)return '_counter = 0;\n';else return '_counter = 0;\n_done();\n';};code+='if(_counter <= 0) break;\n';code+=onTap(i,function(){return _this3.callTap(i,{onError:function onError(error){var code='';code+='if(_counter > 0) {\n';code+=_onError2(i,error,done,doneBreak);code+='}\n';return code;},onResult:onResult&&function(result){var code='';code+='if(_counter > 0) {\n';code+=onResult(i,result,done,doneBreak);code+='}\n';return code;},onDone:!onResult&&function(){return done();},rethrowIfPossible:rethrowIfPossible});},done,doneBreak);};for(var i=0;i<this.options.taps.length;i++){_loop2(i);}code+='} while(false);\n';return code;};_proto.args=function args(_temp){var _ref5=_temp===void 0?{}:_temp,before=_ref5.before,after=_ref5.after;var allArgs=this._args;if(before)allArgs=[before].concat(allArgs);if(after)allArgs=allArgs.concat(after);if(allArgs.length===0){return '';}else {return allArgs.join(', ');}};_proto.getTapFn=function getTapFn(idx){return "_x["+idx+"]";};_proto.getTap=function getTap(idx){return "_taps["+idx+"]";};_proto.getInterceptor=function getInterceptor(idx){return "_interceptors["+idx+"]";};return HookCodeFactory;}();var AsyncParallelHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(AsyncParallelHookCodeFactory,_HookCodeFactory);function AsyncParallelHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=AsyncParallelHookCodeFactory.prototype;_proto.content=function content(_ref){var _onError=_ref.onError,onDone=_ref.onDone;return this.callTapsParallel({onError:function onError(i,err,done,doneBreak){return _onError(err)+doneBreak(true);},onDone:onDone});};return AsyncParallelHookCodeFactory;}(HookCodeFactory);var factory=new AsyncParallelHookCodeFactory();var COMPILE=function COMPILE(options){factory.setup(this,options);return factory.create(options);};var AsyncParallelHook=/*#__PURE__*/function(_Hook){_inheritsLoose(AsyncParallelHook,_Hook);function AsyncParallelHook(args,name){var _this;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this=_Hook.call(this,args,name)||this;_this.compile=COMPILE;_this._call=undefined;_this.call=undefined;return _this;}return AsyncParallelHook;}(Hook);// export function AsyncParallelHook(args = [], name = undefined) {
|
|
7743
|
+
// const hook = new Hook(args, name);
|
|
7744
|
+
// hook.constructor = AsyncParallelHook;
|
|
7745
|
+
// hook.compile = COMPILE;
|
|
7746
|
+
// hook._call = undefined;
|
|
7747
|
+
// hook.call = undefined;
|
|
7748
|
+
// return hook;
|
|
7749
|
+
// }
|
|
7750
|
+
// AsyncParallelHook.prototype = null;
|
|
7751
|
+
var AsyncSeriesWaterfallHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(AsyncSeriesWaterfallHookCodeFactory,_HookCodeFactory);function AsyncSeriesWaterfallHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=AsyncSeriesWaterfallHookCodeFactory.prototype;_proto.content=function content(_ref){var _this=this;var _onError=_ref.onError,onResult=_ref.onResult,onDone=_ref.onDone;return this.callTapsSeries({onError:function onError(i,err,next,doneBreak){return _onError(err)+doneBreak(true);},onResult:function onResult(i,result,next){var code='';code+="if("+result+" !== undefined) {\n";code+=_this._args[0]+" = "+result+";\n";code+="}\n";code+=next();return code;},onDone:function onDone(){return onResult(_this._args[0]);}});};return AsyncSeriesWaterfallHookCodeFactory;}(HookCodeFactory);var factory$1=new AsyncSeriesWaterfallHookCodeFactory();var COMPILE$1=function COMPILE(options){factory$1.setup(this,options);return factory$1.create(options);};// export function AsyncSeriesWaterfallHook(args = [], name = undefined) {
|
|
7752
|
+
// if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
|
|
7753
|
+
// const hook = new Hook(args, name);
|
|
7754
|
+
// hook.constructor = AsyncSeriesWaterfallHook;
|
|
7755
|
+
// hook.compile = COMPILE;
|
|
7756
|
+
// hook._call = undefined;
|
|
7757
|
+
// hook.call = undefined;
|
|
7758
|
+
// return hook;
|
|
7759
|
+
// }
|
|
7760
|
+
// AsyncSeriesWaterfallHook.prototype = null;
|
|
7761
|
+
var AsyncSeriesWaterfallHook=/*#__PURE__*/function(_Hook){_inheritsLoose(AsyncSeriesWaterfallHook,_Hook);function AsyncSeriesWaterfallHook(args,name){var _this2;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this2=_Hook.call(this,args,name)||this;_this2.compile=COMPILE$1;_this2._call=undefined;_this2.call=undefined;return _this2;}return AsyncSeriesWaterfallHook;}(Hook);var SyncHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(SyncHookCodeFactory,_HookCodeFactory);function SyncHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=SyncHookCodeFactory.prototype;_proto.content=function content(_ref){var _onError=_ref.onError,onDone=_ref.onDone,rethrowIfPossible=_ref.rethrowIfPossible;return this.callTapsSeries({onError:function onError(i,err){return _onError(err);},onDone:onDone,rethrowIfPossible:rethrowIfPossible});};return SyncHookCodeFactory;}(HookCodeFactory);var factory$2=new SyncHookCodeFactory();var TAP_ASYNC=function TAP_ASYNC(){throw new Error('tapAsync is not supported on a SyncHook');};var TAP_PROMISE=function TAP_PROMISE(){throw new Error('tapPromise is not supported on a SyncHook');};var COMPILE$2=function COMPILE(options){factory$2.setup(this,options);return factory$2.create(options);};var SyncHook=/*#__PURE__*/function(_Hook){_inheritsLoose(SyncHook,_Hook);function SyncHook(args,name){var _this;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this=_Hook.call(this,args,name)||this;_this.tapAsync=TAP_ASYNC;_this.tapPromise=TAP_PROMISE;_this.compile=COMPILE$2;return _this;}return SyncHook;}(Hook);// export function SyncHook(args = [], name = undefined) {
|
|
7762
|
+
// const hook = new Hook(args, name);
|
|
7763
|
+
// hook.constructor = SyncHook;
|
|
7764
|
+
// hook.tapAsync = TAP_ASYNC;
|
|
7765
|
+
// hook.tapPromise = TAP_PROMISE;
|
|
7766
|
+
// hook.compile = COMPILE;
|
|
7767
|
+
// return hook;
|
|
7768
|
+
// }
|
|
7769
|
+
// SyncHook.prototype = null;
|
|
7770
|
+
var SyncWaterfallHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(SyncWaterfallHookCodeFactory,_HookCodeFactory);function SyncWaterfallHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=SyncWaterfallHookCodeFactory.prototype;_proto.content=function content(_ref){var _this=this;var _onError=_ref.onError,onResult=_ref.onResult,resultReturns=_ref.resultReturns,rethrowIfPossible=_ref.rethrowIfPossible;return this.callTapsSeries({onError:function onError(i,err){return _onError(err);},onResult:function onResult(i,result,next){var code='';code+="if("+result+" !== undefined) {\n";code+=_this._args[0]+" = "+result+";\n";code+="}\n";code+=next();return code;},onDone:function onDone(){return onResult(_this._args[0]);},doneReturns:resultReturns,rethrowIfPossible:rethrowIfPossible});};return SyncWaterfallHookCodeFactory;}(HookCodeFactory);var factory$3=new SyncWaterfallHookCodeFactory();var TAP_ASYNC$1=function TAP_ASYNC(){throw new Error('tapAsync is not supported on a SyncWaterfallHook');};var TAP_PROMISE$1=function TAP_PROMISE(){throw new Error('tapPromise is not supported on a SyncWaterfallHook');};var COMPILE$3=function COMPILE(options){factory$3.setup(this,options);return factory$3.create(options);};var SyncWaterfallHook=/*#__PURE__*/function(_SyncHook){_inheritsLoose(SyncWaterfallHook,_SyncHook);function SyncWaterfallHook(args,name){var _this2;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this2=_SyncHook.call(this,args,name)||this;_this2.tapAsync=TAP_ASYNC$1;_this2.tapPromise=TAP_PROMISE$1;_this2.compile=COMPILE$3;return _this2;}return SyncWaterfallHook;}(SyncHook);// export function SyncWaterfallHook(args = [], name = undefined) {
|
|
7771
|
+
// if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
|
|
7772
|
+
// const hook = new Hook(args, name);
|
|
7773
|
+
// hook.constructor = SyncWaterfallHook;
|
|
7774
|
+
// hook.tapAsync = TAP_ASYNC;
|
|
7775
|
+
// hook.tapPromise = TAP_PROMISE;
|
|
7776
|
+
// hook.compile = COMPILE;
|
|
7777
|
+
// return hook;
|
|
7778
|
+
// }
|
|
7779
|
+
// SyncWaterfallHook.prototype = null;
|
|
7780
|
+
var genericFontFamilies=['serif','sans-serif','monospace','cursive','fantasy','system-ui'];var stringRegExp=/([\"\'])[^\'\"]+\1/;function toFontString(attributes){var fontSize=attributes.fontSize,fontFamily=attributes.fontFamily,fontStyle=attributes.fontStyle,fontVariant=attributes.fontVariant,fontWeight=attributes.fontWeight;// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
7781
|
+
// const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
|
|
7782
|
+
var fontSizeString=isNumber(fontSize)&&fontSize+"px"||'16px';// Clean-up fontFamily property by quoting each font name
|
|
7783
|
+
// this will support font names with spaces
|
|
7784
|
+
// @ts-ignore
|
|
7785
|
+
var fontFamilies=isString(fontFamily)?fontFamily.split(','):[fontFamily];for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
|
|
7786
|
+
var _fontFamily=fontFamilies[i].trim();// Check if font already contains strings
|
|
7787
|
+
if(!stringRegExp.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}/**
|
|
7788
|
+
* Thanks for following contributor of codes
|
|
7789
|
+
* https://gist.github.com/1866474
|
|
7790
|
+
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
|
7791
|
+
* http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
|
7792
|
+
* https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/requestAnimationFrame/polyfill.js
|
|
7793
|
+
**/var uId=1;var uniqueId=function uniqueId(){return uId++;};// We use `self` instead of `window` for `WebWorker` support.
|
|
7794
|
+
var root=typeof self==='object'&&self.self==self?self:// @ts-ignore
|
|
7795
|
+
typeof global==='object'&&global.global==global?// @ts-ignore
|
|
7796
|
+
global:{};var nowOffset=Date.now();// use performance api if exist, otherwise use Date.now.
|
|
7797
|
+
// Date.now polyfill required.
|
|
7798
|
+
var pnow=function pnow(){if(root.performance&&typeof root.performance.now==='function'){return root.performance.now();}// fallback
|
|
7799
|
+
return Date.now()-nowOffset;};var reservedCBs={};var lastTime=Date.now();var polyfillRaf=function polyfillRaf(callback){if(typeof callback!=='function'){throw new TypeError(callback+' is not a function');}var currentTime=Date.now();var gap=currentTime-lastTime;var delay=gap>16?0:16-gap;var id=uniqueId();reservedCBs[id]=callback;// keys(reservedCBs).length > 1 의미는 이미 setTimeout 이 걸려있는 경우.
|
|
7800
|
+
// 함께 callback 이 실행될 수 있게 reservedCBs 에만 추가해주고 return
|
|
7801
|
+
if(Object.keys(reservedCBs).length>1)return id;setTimeout(function(){lastTime=currentTime;var copied=reservedCBs;reservedCBs={};Object.keys(copied).forEach(function(key){return copied[key](pnow());});},delay);return id;};var polyfillCaf=function polyfillCaf(id){delete reservedCBs[id];};var vendorPrefixes=['','webkit','moz','ms','o'];var getRequestAnimationFrame=function getRequestAnimationFrame(vp){if(typeof vp!=='string')return polyfillRaf;if(vp==='')return root['requestAnimationFrame'];return root[vp+'RequestAnimationFrame'];};var getCancelAnimationFrame=function getCancelAnimationFrame(vp){if(typeof vp!=='string')return polyfillCaf;if(vp==='')return root['cancelAnimationFrame'];return root[vp+'CancelAnimationFrame']||root[vp+'CancelRequestAnimationFrame'];};var find=function find(arr,predicate){var i=0;while(arr[i]!==void 0){if(predicate(arr[i]))return arr[i];i=i+1;}};var vp=find(vendorPrefixes,function(vp){return !!getRequestAnimationFrame(vp);});var raf=getRequestAnimationFrame(vp);var caf=getCancelAnimationFrame(vp);root.requestAnimationFrame=raf;root.cancelAnimationFrame=caf;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'
|
|
7802
|
+
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.
|
|
7803
|
+
// different from CSS side(to top) @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient#values
|
|
7804
|
+
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
|
|
7805
|
+
return {offset:getOrCreateUnitValue(Number(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
|
|
7806
|
+
// TODO: repeating-linear-gradient & repeating-radial-gradient
|
|
7807
|
+
// } else if (type === 'repeating-linear-gradient') {
|
|
7808
|
+
// } else if (type === 'repeating-radial-gradient') {
|
|
7809
|
+
}});}// legacy format, should be deprecated later
|
|
7810
|
+
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
|
|
7811
|
+
repetition:repetition};}return null;}function isCSSGradientValue(object){return !!object.type&&!!object.value;}function isPattern(object){return isObject(object)&&!!object.image;}function isCSSRGB(object){return isObject(object)&&!isNil(object.r)&&!isNil(object.g)&&!isNil(object.b);}/**
|
|
7812
|
+
* @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
|
|
7813
|
+
*/var parseColor=memoize(function(colorStr){if(isPattern(colorStr)){return _extends({repetition:'repeat'},colorStr);}if(isNil(colorStr)){colorStr='';}if(colorStr==='transparent'){// transparent black
|
|
7814
|
+
return transparentColor;}else if(colorStr==='currentColor'){// @see https://github.com/adobe-webplatform/Snap.svg/issues/526
|
|
7815
|
+
colorStr='black';}// support CSS gradient syntax
|
|
7816
|
+
var g=parseGradient$1(colorStr);if(g){return g;}// constants
|
|
7817
|
+
var color$1=color(colorStr);var rgba=[0,0,0,0];if(color$1!==null){rgba[0]=color$1.r||0;rgba[1]=color$1.g||0;rgba[2]=color$1.b||0;rgba[3]=color$1.opacity;}// return new CSSRGB(...rgba);
|
|
7818
|
+
return getOrCreateRGBA.apply(void 0,rgba);});function mergeColors(left,right){// only support constant value, exclude gradient & pattern
|
|
7819
|
+
if(!isCSSRGB(left)||!isCSSRGB(right)){return;}return [[Number(left.r),Number(left.g),Number(left.b),Number(left.alpha)],[Number(right.r),Number(right.g),Number(right.b),Number(right.alpha)],function(color){var rgba=color.slice();if(rgba[3]){for(var i=0;i<3;i++){rgba[i]=Math.round(clamp(rgba[i],0,255));}}rgba[3]=clamp(rgba[3],0,1);return "rgba("+rgba.join(',')+")";}];}/**
|
|
7820
|
+
* Axis-Aligned Bounding Box
|
|
7821
|
+
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
7822
|
+
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
7823
|
+
*/var AABB=/*#__PURE__*/function(){AABB.isEmpty=function isEmpty(aabb){return !aabb||aabb.halfExtents[0]===0&&aabb.halfExtents[1]===0&&aabb.halfExtents[2]===0;};// center: vec3 = vec3.create();
|
|
7824
|
+
// halfExtents: vec3 = vec3.create();
|
|
7825
|
+
// min: vec3 = vec3.create();
|
|
7826
|
+
// max: vec3 = vec3.create();
|
|
7827
|
+
function AABB(center,halfExtents){if(center===void 0){center=[0,0,0];}if(halfExtents===void 0){halfExtents=[0,0,0];}this.center=[0,0,0];this.halfExtents=[0,0,0];this.min=[0,0,0];this.max=[0,0,0];this.update(center,halfExtents);}var _proto=AABB.prototype;_proto.update=function update(center,halfExtents){copyVec3(this.center,center);copyVec3(this.halfExtents,halfExtents);subVec3(this.min,this.center,this.halfExtents);addVec3(this.max,this.center,this.halfExtents);// vec3.copy(this.center, center);
|
|
7828
|
+
// vec3.copy(this.halfExtents, halfExtents);
|
|
7829
|
+
// vec3.sub(this.min, this.center, this.halfExtents);
|
|
7830
|
+
// vec3.add(this.max, this.center, this.halfExtents);
|
|
7831
|
+
};_proto.setMinMax=function setMinMax(min,max){// vec3.add(this.center, max, min);
|
|
7832
|
+
// vec3.scale(this.center, this.center, 0.5);
|
|
7833
|
+
// vec3.sub(this.halfExtents, max, min);
|
|
7834
|
+
// vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
7835
|
+
// vec3.copy(this.min, min);
|
|
7836
|
+
// vec3.copy(this.max, max);
|
|
7837
|
+
addVec3(this.center,max,min);scaleVec3(this.center,this.center,0.5);subVec3(this.halfExtents,max,min);scaleVec3(this.halfExtents,this.halfExtents,0.5);copyVec3(this.min,min);copyVec3(this.max,max);};_proto.getMin=function getMin(){return this.min;};_proto.getMax=function getMax(){return this.max;};_proto.add=function add(aabb){if(AABB.isEmpty(aabb)){return;}if(AABB.isEmpty(this)){this.setMinMax(aabb.getMin(),aabb.getMax());return;}var tc=this.center;var tcx=tc[0];var tcy=tc[1];var tcz=tc[2];var th=this.halfExtents;var thx=th[0];var thy=th[1];var thz=th[2];var tminx=tcx-thx;var tmaxx=tcx+thx;var tminy=tcy-thy;var tmaxy=tcy+thy;var tminz=tcz-thz;var tmaxz=tcz+thz;var oc=aabb.center;var ocx=oc[0];var ocy=oc[1];var ocz=oc[2];var oh=aabb.halfExtents;var ohx=oh[0];var ohy=oh[1];var ohz=oh[2];var ominx=ocx-ohx;var omaxx=ocx+ohx;var ominy=ocy-ohy;var omaxy=ocy+ohy;var ominz=ocz-ohz;var omaxz=ocz+ohz;if(ominx<tminx){tminx=ominx;}if(omaxx>tmaxx){tmaxx=omaxx;}if(ominy<tminy){tminy=ominy;}if(omaxy>tmaxy){tmaxy=omaxy;}if(ominz<tminz){tminz=ominz;}if(omaxz>tmaxz){tmaxz=omaxz;}tc[0]=(tminx+tmaxx)*0.5;tc[1]=(tminy+tmaxy)*0.5;tc[2]=(tminz+tmaxz)*0.5;th[0]=(tmaxx-tminx)*0.5;th[1]=(tmaxy-tminy)*0.5;th[2]=(tmaxz-tminz)*0.5;this.min[0]=tminx;this.min[1]=tminy;this.min[2]=tminz;this.max[0]=tmaxx;this.max[1]=tmaxy;this.max[2]=tmaxz;};_proto.setFromTransformedAABB=function setFromTransformedAABB(aabb,m){var bc=this.center;var br=this.halfExtents;var ac=aabb.center;var ar=aabb.halfExtents;var mx0=m[0];var mx1=m[4];var mx2=m[8];var my0=m[1];var my1=m[5];var my2=m[9];var mz0=m[2];var mz1=m[6];var mz2=m[10];var mx0a=Math.abs(mx0);var mx1a=Math.abs(mx1);var mx2a=Math.abs(mx2);var my0a=Math.abs(my0);var my1a=Math.abs(my1);var my2a=Math.abs(my2);var mz0a=Math.abs(mz0);var mz1a=Math.abs(mz1);var mz2a=Math.abs(mz2);bc[0]=m[12]+mx0*ac[0]+mx1*ac[1]+mx2*ac[2];bc[1]=m[13]+my0*ac[0]+my1*ac[1]+my2*ac[2];bc[2]=m[14]+mz0*ac[0]+mz1*ac[1]+mz2*ac[2];// vec3.set(
|
|
7838
|
+
// bc,
|
|
7839
|
+
// m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
|
|
7840
|
+
// m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
|
|
7841
|
+
// m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
|
|
7842
|
+
// );
|
|
7843
|
+
br[0]=mx0a*ar[0]+mx1a*ar[1]+mx2a*ar[2];br[1]=my0a*ar[0]+my1a*ar[1]+my2a*ar[2];br[2]=mz0a*ar[0]+mz1a*ar[1]+mz2a*ar[2];// vec3.set(
|
|
7844
|
+
// br,
|
|
7845
|
+
// mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
|
|
7846
|
+
// my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
|
|
7847
|
+
// mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
|
|
7848
|
+
// );
|
|
7849
|
+
// this.min = vec3.sub(this.min, bc, br);
|
|
7850
|
+
// this.max = vec3.add(this.max, bc, br);
|
|
7851
|
+
subVec3(this.min,bc,br);addVec3(this.max,bc,br);};_proto.intersects=function intersects(aabb){var aMax=this.getMax();var aMin=this.getMin();var bMax=aabb.getMax();var bMin=aabb.getMin();return aMin[0]<=bMax[0]&&aMax[0]>=bMin[0]&&aMin[1]<=bMax[1]&&aMax[1]>=bMin[1]&&aMin[2]<=bMax[2]&&aMax[2]>=bMin[2];};_proto.intersection=function intersection(aabb){if(!this.intersects(aabb)){return null;}var intersection=new AABB();// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
7852
|
+
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
7853
|
+
var min=maxVec3([0,0,0],this.getMin(),aabb.getMin());var max=minVec3([0,0,0],this.getMax(),aabb.getMax());intersection.setMinMax(min,max);return intersection;}// containsPoint(point: vec3) {
|
|
7854
|
+
// const min = this.getMin();
|
|
7855
|
+
// const max = this.getMax();
|
|
7856
|
+
// return !(
|
|
7857
|
+
// point[0] < min[0] ||
|
|
7858
|
+
// point[0] > max[0] ||
|
|
7859
|
+
// point[1] < min[1] ||
|
|
7860
|
+
// point[1] > max[1] ||
|
|
7861
|
+
// point[2] < min[2] ||
|
|
7862
|
+
// point[2] > max[2]
|
|
7863
|
+
// );
|
|
7864
|
+
// }
|
|
7865
|
+
/**
|
|
7866
|
+
* get n-vertex
|
|
7867
|
+
* @param plane plane of CullingVolume
|
|
7868
|
+
*/;_proto.getNegativeFarPoint=function getNegativeFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.min);// return vec3.copy(vec3.create(), this.min);
|
|
7869
|
+
}else if(plane.pnVertexFlag===0x110){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
7870
|
+
}else if(plane.pnVertexFlag===0x101){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
7871
|
+
}else if(plane.pnVertexFlag===0x100){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
7872
|
+
}else if(plane.pnVertexFlag===0x011){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
7873
|
+
}else if(plane.pnVertexFlag===0x010){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
7874
|
+
}else if(plane.pnVertexFlag===0x001){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
7875
|
+
}else {return [this.max[0],this.max[1],this.max[2]];// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
|
|
7876
|
+
}}/**
|
|
7877
|
+
* get p-vertex
|
|
7878
|
+
* @param plane plane of CullingVolume
|
|
7879
|
+
*/;_proto.getPositiveFarPoint=function getPositiveFarPoint(plane){if(plane.pnVertexFlag===0x111){return copyVec3([0,0,0],this.max);// return vec3.copy(vec3.create(), this.max);
|
|
7880
|
+
}else if(plane.pnVertexFlag===0x110){return [this.max[0],this.max[1],this.min[2]];// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
7881
|
+
}else if(plane.pnVertexFlag===0x101){return [this.max[0],this.min[1],this.max[2]];// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
7882
|
+
}else if(plane.pnVertexFlag===0x100){return [this.max[0],this.min[1],this.min[2]];// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
7883
|
+
}else if(plane.pnVertexFlag===0x011){return [this.min[0],this.max[1],this.max[2]];// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
7884
|
+
}else if(plane.pnVertexFlag===0x010){return [this.min[0],this.max[1],this.min[2]];// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
7885
|
+
}else if(plane.pnVertexFlag===0x001){return [this.min[0],this.min[1],this.max[2]];// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
7886
|
+
}else {return [this.min[0],this.min[1],this.min[2]];// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
7887
|
+
}};return AABB;}();var Plane=/*#__PURE__*/function(){/**
|
|
7888
|
+
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
7889
|
+
*/function Plane(distance,normal){this.distance=void 0;this.normal=void 0;this.pnVertexFlag=void 0;this.distance=distance||0;this.normal=normal||fromValues$2(0,1,0);this.updatePNVertexFlag();}var _proto=Plane.prototype;_proto.updatePNVertexFlag=function updatePNVertexFlag(){this.pnVertexFlag=(Number(this.normal[0]>=0)<<8)+(Number(this.normal[1]>=0)<<4)+Number(this.normal[2]>=0);};_proto.distanceToPoint=function distanceToPoint(point){return dot(point,this.normal)-this.distance;};_proto.normalize=function normalize(){var invLen=1/len(this.normal);scale$1(this.normal,this.normal,invLen);this.distance*=invLen;};_proto.intersectsLine=function intersectsLine(start,end,point){var d0=this.distanceToPoint(start);var d1=this.distanceToPoint(end);var t=d0/(d0-d1);var intersects=t>=0&&t<=1;if(intersects&&point){lerp(point,start,end,t);}return intersects;};return Plane;}();(function(Mask){Mask[Mask["OUTSIDE"]=4294967295]="OUTSIDE";Mask[Mask["INSIDE"]=0]="INSIDE";Mask[Mask["INDETERMINATE"]=2147483647]="INDETERMINATE";})(exports.Mask||(exports.Mask={}));var Frustum=/*#__PURE__*/function(){function Frustum(planes){this.planes=[];if(planes){this.planes=planes;}else {for(var i=0;i<6;i++){this.planes.push(new Plane());}}}/**
|
|
7890
|
+
* extract 6 planes from projectionMatrix
|
|
7891
|
+
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
7892
|
+
*/var _proto=Frustum.prototype;_proto.extractFromVPMatrix=function extractFromVPMatrix(projectionMatrix){// @ts-ignore
|
|
7893
|
+
var m0=projectionMatrix[0],m1=projectionMatrix[1],m2=projectionMatrix[2],m3=projectionMatrix[3],m4=projectionMatrix[4],m5=projectionMatrix[5],m6=projectionMatrix[6],m7=projectionMatrix[7],m8=projectionMatrix[8],m9=projectionMatrix[9],m10=projectionMatrix[10],m11=projectionMatrix[11],m12=projectionMatrix[12],m13=projectionMatrix[13],m14=projectionMatrix[14],m15=projectionMatrix[15];// right
|
|
7894
|
+
set$1(this.planes[0].normal,m3-m0,m7-m4,m11-m8);this.planes[0].distance=m15-m12;// left
|
|
7895
|
+
set$1(this.planes[1].normal,m3+m0,m7+m4,m11+m8);this.planes[1].distance=m15+m12;// bottom
|
|
7896
|
+
set$1(this.planes[2].normal,m3+m1,m7+m5,m11+m9);this.planes[2].distance=m15+m13;// top
|
|
7897
|
+
set$1(this.planes[3].normal,m3-m1,m7-m5,m11-m9);this.planes[3].distance=m15-m13;// far
|
|
7898
|
+
set$1(this.planes[4].normal,m3-m2,m7-m6,m11-m10);this.planes[4].distance=m15-m14;// near
|
|
7899
|
+
set$1(this.planes[5].normal,m3+m2,m7+m6,m11+m10);this.planes[5].distance=m15+m14;this.planes.forEach(function(plane){plane.normalize();plane.updatePNVertexFlag();});};return Frustum;}();var Point=/*#__PURE__*/function(){function Point(x,y){if(x===void 0){x=0;}if(y===void 0){y=0;}this.x=0;this.y=0;this.x=x;this.y=y;}var _proto=Point.prototype;_proto.clone=function clone(){return new Point(this.x,this.y);};_proto.copyFrom=function copyFrom(p){this.x=p.x;this.y=p.y;};return Point;}();var Rectangle=/*#__PURE__*/function(){function Rectangle(x,y,width,height){this.x=void 0;this.y=void 0;this.width=void 0;this.height=void 0;this.left=void 0;this.right=void 0;this.top=void 0;this.bottom=void 0;this.x=x;this.y=y;this.width=width;this.height=height;this.left=x;this.right=x+width;this.top=y;this.bottom=y+height;}var _proto=Rectangle.prototype;_proto.toJSON=function toJSON(){};return Rectangle;}();function parseDimension(unitRegExp,string){if(isNil(string)){return getOrCreateUnitValue(0,'px');}string=(""+string).trim().toLowerCase();if(isFinite(Number(string))){if('px'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'px');}else if('deg'.search(unitRegExp)>=0){return getOrCreateUnitValue(Number(string),'deg');}}var matchedUnits=[];string=string.replace(unitRegExp,function(match){matchedUnits.push(match);return 'U'+match;});var taggedUnitRegExp='U('+unitRegExp.source+')';return matchedUnits.map(function(unit){return getOrCreateUnitValue(Number(string.replace(new RegExp('U'+unit,'g'),'').replace(new RegExp(taggedUnitRegExp,'g'),'*0')),unit);})[0];}/**
|
|
7900
|
+
* <length>
|
|
7901
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
|
|
7902
|
+
* length with only absolute unit, eg. 1px
|
|
7903
|
+
*/var parseLength=memoize(function(css){return parseDimension(new RegExp('px','g'),css);});/**
|
|
7904
|
+
* <percentage>
|
|
7905
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
|
|
7906
|
+
*/var parserPercentage=memoize(function(css){return parseDimension(new RegExp('%','g'),css);});/**
|
|
7907
|
+
* length with absolute or relative unit,
|
|
7908
|
+
* eg. 1px, 0.7em, 50%, calc(100% - 200px);
|
|
7909
|
+
*
|
|
7910
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
|
|
7911
|
+
*/ // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
|
|
7912
|
+
// if (isNumber(css) || isFinite(Number(css))) {
|
|
7913
|
+
// return getOrCreateUnitValue(Number(css), 'px');
|
|
7914
|
+
// }
|
|
7915
|
+
// return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
|
|
7916
|
+
// });
|
|
7917
|
+
var parseLengthOrPercentage=function parseLengthOrPercentage(css){if(isNumber(css)||isFinite(Number(css))){return getOrCreateUnitValue(Number(css),'px');// return Number(css);
|
|
7918
|
+
}return parseDimension(new RegExp('px|%|em|rem','g'),css);};var parseAngle=memoize(function(css){return parseDimension(new RegExp('deg|rad|grad|turn','g'),css);});/**
|
|
7919
|
+
* merge CSSUnitValue
|
|
7920
|
+
*
|
|
7921
|
+
* @example
|
|
7922
|
+
* 10px + 20px = 30px
|
|
7923
|
+
* 10deg + 10rad
|
|
7924
|
+
* 10% + 20% = 30%
|
|
7925
|
+
*/function mergeDimensions(left,right,target,nonNegative,index){if(index===void 0){index=0;}var unit='';var leftValue=left.value||0;var rightValue=right.value||0;var canonicalUnit=toCanonicalUnit(left.unit);var leftCanonicalUnitValue=left.convertTo(canonicalUnit);var rightCanonicalUnitValue=right.convertTo(canonicalUnit);if(leftCanonicalUnitValue&&rightCanonicalUnitValue){leftValue=leftCanonicalUnitValue.value;rightValue=rightCanonicalUnitValue.value;unit=unitTypeToString(left.unit);}else {// format '%' to 'px'
|
|
7926
|
+
if(CSSUnitValue.isLength(left.unit)||CSSUnitValue.isLength(right.unit)){leftValue=convertPercentUnit(left,index,target);rightValue=convertPercentUnit(right,index,target);unit='px';}}// // format 'rad' 'turn' to 'deg'
|
|
7927
|
+
// if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
|
|
7928
|
+
// leftValue = convertAngleUnit(left);
|
|
7929
|
+
// rightValue = convertAngleUnit(right);
|
|
7930
|
+
// unit = 'deg';
|
|
7931
|
+
// }
|
|
7932
|
+
return [leftValue,rightValue,function(value){if(nonNegative){value=Math.max(value,0);}return value+unit;}];}function convertAngleUnit(value){var deg=0;if(value.unit===exports.UnitType.kDegrees){deg=value.value;}else if(value.unit===exports.UnitType.kRadians){deg=rad2deg(Number(value.value));}else if(value.unit===exports.UnitType.kTurns){deg=turn2deg(Number(value.value));}return deg;}function parseDimensionArrayFormat(string,size){var parsed;if(isString(string)){parsed=string.split(' ').map(function(segment){return Number(segment);});}else if(isNumber(string)){parsed=[string];}else {// [1, '2px', 3]
|
|
7933
|
+
parsed=string.map(function(segment){return Number(segment);});}if(size===2){if(parsed.length===1){return [parsed[0],parsed[0]];}else {return [parsed[0],parsed[1]];}}else {if(parsed.length===1){return [parsed[0],parsed[0],parsed[0],parsed[0]];}else if(parsed.length===2){return [parsed[0],parsed[1],parsed[0],parsed[1]];}else if(parsed.length===3){return [parsed[0],parsed[1],parsed[2],parsed[1]];}else {return [parsed[0],parsed[1],parsed[2],parsed[3]];}}}function parseDimensionArray(string){if(isString(string)){// "1px 2px 3px"
|
|
7934
|
+
return string.split(' ').map(function(segment){return parseLengthOrPercentage(segment);});}else {// [1, '2px', 3]
|
|
7935
|
+
return string.map(function(segment){return parseLengthOrPercentage(segment.toString());});}}// export function mergeDimensionList(
|
|
7936
|
+
// left: CSSUnitValue[],
|
|
7937
|
+
// right: CSSUnitValue[],
|
|
7938
|
+
// target: IElement | null,
|
|
7939
|
+
// ): [number[], number[], (list: number[]) => string] | undefined {
|
|
7940
|
+
// if (left.length !== right.length) {
|
|
7941
|
+
// return;
|
|
7942
|
+
// }
|
|
7943
|
+
// const unit = left[0].unit;
|
|
7944
|
+
// return [
|
|
7945
|
+
// left.map((l) => l.value),
|
|
7946
|
+
// right.map((l) => l.value),
|
|
7947
|
+
// (values: number[]) => {
|
|
7948
|
+
// return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
|
|
7949
|
+
// },
|
|
7950
|
+
// ];
|
|
7951
|
+
// }
|
|
7952
|
+
function convertPercentUnit(valueWithUnit,vec3Index,target){if(valueWithUnit.unit===exports.UnitType.kPixels){return Number(valueWithUnit.value);}else if(valueWithUnit.unit===exports.UnitType.kPercentage&&target){var bounds=target.nodeName===exports.Shape.GROUP?target.getLocalBounds():target.getGeometryBounds();var size=0;if(!AABB.isEmpty(bounds)){size=bounds.halfExtents[vec3Index]*2;}return Number(valueWithUnit.value)/100*size;}return 0;}var parseParam=function parseParam(css){return parseDimension(/deg|rad|grad|turn|px|%/g,css);};var supportedFilters=['blur','brightness','drop-shadow','contrast','grayscale','sepia','saturate','hue-rotate','invert'];function parseFilter(filterStr){if(filterStr===void 0){filterStr='';}filterStr=filterStr.toLowerCase().trim();if(filterStr==='none'){return [];}var filterRegExp=/\s*([\w-]+)\(([^)]*)\)/g;var result=[];var match;var prevLastIndex=0;while(match=filterRegExp.exec(filterStr)){if(match.index!==prevLastIndex){return [];}prevLastIndex=match.index+match[0].length;if(supportedFilters.indexOf(match[1])>-1){result.push({name:match[1],params:match[2].split(' ').map(function(p){return parseParam(p)||parseColor(p);})});}if(filterRegExp.lastIndex===filterStr.length){return result;}}return [];}function numberToString(x){// scale(0.00000001) -> scale(0)
|
|
7953
|
+
// return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
|
|
7954
|
+
return x.toString();}/**
|
|
7955
|
+
* parse string or number to CSSUnitValue(numeric)
|
|
7956
|
+
*
|
|
7957
|
+
* eg.
|
|
7958
|
+
* * 0 -> CSSUnitValue(0)
|
|
7959
|
+
* * '2' -> CSSUnitValue(2)
|
|
7960
|
+
*/var parseNumber=memoize(function(string){if(typeof string==='number'){return getOrCreateUnitValue(string);}if(/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)){return getOrCreateUnitValue(Number(string));}else {return getOrCreateUnitValue(0);}});/**
|
|
7961
|
+
* separate string to array
|
|
7962
|
+
* eg.
|
|
7963
|
+
* * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
|
|
7964
|
+
*/var parseNumberList=memoize(function(string){if(isString(string)){return string.split(' ').map(parseNumber);}else {return string.map(parseNumber);}});function mergeNumbers(left,right){return [left,right,numberToString];}function clampedMergeNumbers(min,max){return function(left,right){return [left,right,function(x){return numberToString(clamp(x,min,max));}];};}function mergeNumberLists(left,right){if(left.length!==right.length){return;}return [left,right,function(numberList){return numberList;}];}var internalParsePath=function internalParsePath(path){// empty path
|
|
7965
|
+
if(path===''||Array.isArray(path)&&path.length===0){return {absolutePath:[],hasArc:false,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:{x:0,y:0,width:0,height:0}};}var absolutePath;try{absolutePath=normalizePath(path);}catch(e){absolutePath=normalizePath('');console.error("[g]: Invalid SVG Path definition: "+path);}var hasArc=hasArcOrBezier(absolutePath);var _extractPolygons=extractPolygons(absolutePath),polygons=_extractPolygons.polygons,polylines=_extractPolygons.polylines;// for later use
|
|
7966
|
+
var segments=path2Segments(absolutePath);// Only calculate bbox here since we don't need length now.
|
|
7967
|
+
var _getPathBBox=getPathBBox(segments,0),x=_getPathBBox.x,y=_getPathBBox.y,width=_getPathBBox.width,height=_getPathBBox.height;return {absolutePath:absolutePath,hasArc:hasArc,segments:segments,polygons:polygons,polylines:polylines,// curve,
|
|
7968
|
+
// Delay the calculation of length.
|
|
7969
|
+
totalLength:0,rect:{x:Number.isFinite(x)?x:0,y:Number.isFinite(y)?y:0,width:Number.isFinite(width)?width:0,height:Number.isFinite(height)?height:0}};};var memoizedParsePath=memoize(internalParsePath);function parsePath(path,object){var result=isString(path)?memoizedParsePath(path):internalParsePath(path);if(object){object.parsedStyle.defX=result.rect.x;object.parsedStyle.defY=result.rect.y;}return result;}function mergePaths(left,right,object){var curve1=left.curve;var curve2=right.curve;if(!curve1||curve1.length===0){// convert to curves to do morphing & picking later
|
|
7970
|
+
// @see http://thednp.github.io/kute.js/svgCubicMorph.html
|
|
7971
|
+
curve1=path2Curve(left.absolutePath,false);left.curve=curve1;}if(!curve2||curve2.length===0){curve2=path2Curve(right.absolutePath,false);right.curve=curve2;}var curves=[curve1,curve2];if(curve1.length!==curve2.length){curves=equalizeSegments(curve1,curve2);}var curve0=getDrawDirection(curves[0])!==getDrawDirection(curves[1])?reverseCurve(curves[0]):clonePath(curves[0]);return [curve0,getRotatedCurve(curves[1],curve0),function(pathArray){// need converting to path string?
|
|
7972
|
+
return pathArray;}];}/**
|
|
7973
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
|
|
7974
|
+
*
|
|
7975
|
+
* @example
|
|
7976
|
+
* points="100,10 250,150 200,110"
|
|
7977
|
+
*/function parsePoints(pointsOrStr,object){var points;if(isString(pointsOrStr)){points=pointsOrStr.split(' ').map(function(pointStr){var _pointStr$split=pointStr.split(','),x=_pointStr$split[0],y=_pointStr$split[1];return [Number(x),Number(y)];});}else {points=pointsOrStr;}var segments=[];var tempLength=0;var segmentT;var segmentL;var totalLength=polyline.length(points);points.forEach(function(p,i){if(points[i+1]){segmentT=[0,0];segmentT[0]=tempLength/totalLength;segmentL=line.length(p[0],p[1],points[i+1][0],points[i+1][1]);tempLength+=segmentL;segmentT[1]=tempLength/totalLength;segments.push(segmentT);}});var minX=Math.min.apply(Math,points.map(function(point){return point[0];}));var minY=Math.min.apply(Math,points.map(function(point){return point[1];}));if(object){object.parsedStyle.defX=minX;object.parsedStyle.defY=minY;}return {points:points,totalLength:totalLength,segments:segments};}var _=null;function cast(pattern){return function(contents){var i=0;return pattern.map(function(x){return x===_?contents[i++]:x;});};}function id(x){return x;}// type: [argTypes, convertTo3D, convertTo2D]
|
|
7978
|
+
// In the argument types string, lowercase characters represent optional arguments
|
|
7979
|
+
var transformFunctions={// @ts-ignore
|
|
7980
|
+
matrix:['NNNNNN',[_,_,0,0,_,_,0,0,0,0,1,0,_,_,0,1],id],matrix3d:['NNNNNNNNNNNNNNNN',id],rotate:['A'],rotatex:['A'],rotatey:['A'],rotatez:['A'],rotate3d:['NNNA'],perspective:['L'],scale:['Nn',cast([_,_,new CSSUnitValue(1)]),id],scalex:['N',cast([_,new CSSUnitValue(1),new CSSUnitValue(1)]),cast([_,new CSSUnitValue(1)])],scaley:['N',cast([new CSSUnitValue(1),_,new CSSUnitValue(1)]),cast([new CSSUnitValue(1),_])],scalez:['N',cast([new CSSUnitValue(1),new CSSUnitValue(1),_])],scale3d:['NNN',id],skew:['Aa',null,id],skewx:['A',null,cast([_,Odeg])],skewy:['A',null,cast([Odeg,_])],translate:['Tt',cast([_,_,Opx]),id],translatex:['T',cast([_,Opx,Opx]),cast([_,Opx])],translatey:['T',cast([Opx,_,Opx]),cast([Opx,_])],translatez:['L',cast([Opx,Opx,_])],translate3d:['TTL',id]};/**
|
|
7981
|
+
* none
|
|
7982
|
+
* scale(1) scale(1, 2)
|
|
7983
|
+
* scaleX(1)
|
|
7984
|
+
*/function parseTransform(string){string=(string||'none').toLowerCase().trim();if(string==='none'){return [];}var transformRegExp=/\s*(\w+)\(([^)]*)\)/g;var result=[];var match;var prevLastIndex=0;while(match=transformRegExp.exec(string)){if(match.index!==prevLastIndex){return [];}prevLastIndex=match.index+match[0].length;var functionName=match[1];// scale
|
|
7985
|
+
var functionData=transformFunctions[functionName];// scale(1, 2)
|
|
7986
|
+
if(!functionData){// invalid, eg. scale()
|
|
7987
|
+
return [];}var args=match[2].split(',');// 1,2
|
|
7988
|
+
var argTypes=functionData[0];// Nn
|
|
7989
|
+
if(argTypes.length<args.length){// scale(N, n)
|
|
7990
|
+
return [];}var parsedArgs=[];for(var i=0;i<argTypes.length;i++){var arg=args[i];var type=argTypes[i];var parsedArg=void 0;if(!arg){// @ts-ignore
|
|
7991
|
+
parsedArg={a:Odeg,n:parsedArgs[0],t:Opx}[type];}else {// @ts-ignore
|
|
7992
|
+
parsedArg={A:function A(s){return s.trim()==='0'?Odeg:parseAngle(s);},N:parseNumber,T:parseLengthOrPercentage,L:parseLength}[type.toUpperCase()](arg);}if(parsedArg===undefined){return [];}parsedArgs.push(parsedArg);}result.push({t:functionName,d:parsedArgs});// { t: scale, d: [1, 2] }
|
|
7993
|
+
if(transformRegExp.lastIndex===string.length){return result;}}return [];}function convertItemToMatrix(item){var x;var y;var z;var angle;switch(item.t){case'rotatex':angle=deg2rad(convertAngleUnit(item.d[0]));return [1,0,0,0,0,Math.cos(angle),Math.sin(angle),0,0,-Math.sin(angle),Math.cos(angle),0,0,0,0,1];case'rotatey':angle=deg2rad(convertAngleUnit(item.d[0]));return [Math.cos(angle),0,-Math.sin(angle),0,0,1,0,0,Math.sin(angle),0,Math.cos(angle),0,0,0,0,1];case'rotate':case'rotatez':angle=deg2rad(convertAngleUnit(item.d[0]));return [Math.cos(angle),Math.sin(angle),0,0,-Math.sin(angle),Math.cos(angle),0,0,0,0,1,0,0,0,0,1];case'rotate3d':x=item.d[0].value;y=item.d[1].value;z=item.d[2].value;angle=deg2rad(convertAngleUnit(item.d[3]));var sqrLength=x*x+y*y+z*z;if(sqrLength===0){x=1;y=0;z=0;}else if(sqrLength!==1){var length=Math.sqrt(sqrLength);x/=length;y/=length;z/=length;}var s=Math.sin(angle/2);var sc=s*Math.cos(angle/2);var sq=s*s;return [1-2*(y*y+z*z)*sq,2*(x*y*sq+z*sc),2*(x*z*sq-y*sc),0,2*(x*y*sq-z*sc),1-2*(x*x+z*z)*sq,2*(y*z*sq+x*sc),0,2*(x*z*sq+y*sc),2*(y*z*sq-x*sc),1-2*(x*x+y*y)*sq,0,0,0,0,1];case'scale':return [item.d[0].value,0,0,0,0,item.d[1].value,0,0,0,0,1,0,0,0,0,1];case'scalex':return [item.d[0].value,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];case'scaley':return [1,0,0,0,0,item.d[0].value,0,0,0,0,1,0,0,0,0,1];case'scalez':return [1,0,0,0,0,1,0,0,0,0,item.d[0].value,0,0,0,0,1];case'scale3d':return [item.d[0].value,0,0,0,0,item.d[1].value,0,0,0,0,item.d[2].value,0,0,0,0,1];case'skew':var xAngle=deg2rad(convertAngleUnit(item.d[0]));var yAngle=deg2rad(convertAngleUnit(item.d[1]));return [1,Math.tan(yAngle),0,0,Math.tan(xAngle),1,0,0,0,0,1,0,0,0,0,1];case'skewx':angle=deg2rad(convertAngleUnit(item.d[0]));return [1,0,0,0,Math.tan(angle),1,0,0,0,0,1,0,0,0,0,1];case'skewy':angle=deg2rad(convertAngleUnit(item.d[0]));return [1,Math.tan(angle),0,0,0,1,0,0,0,0,1,0,0,0,0,1];case'translate':// TODO: pass target
|
|
7994
|
+
x=convertPercentUnit(item.d[0],0,null)||0;y=convertPercentUnit(item.d[1],0,null)||0;return [1,0,0,0,0,1,0,0,0,0,1,0,x,y,0,1];case'translatex':x=convertPercentUnit(item.d[0],0,null)||0;return [1,0,0,0,0,1,0,0,0,0,1,0,x,0,0,1];case'translatey':y=convertPercentUnit(item.d[0],0,null)||0;return [1,0,0,0,0,1,0,0,0,0,1,0,0,y,0,1];case'translatez':z=convertPercentUnit(item.d[0],0,null)||0;return [1,0,0,0,0,1,0,0,0,0,1,0,0,0,z,1];case'translate3d':x=convertPercentUnit(item.d[0],0,null)||0;y=convertPercentUnit(item.d[1],0,null)||0;z=convertPercentUnit(item.d[2],0,null)||0;return [1,0,0,0,0,1,0,0,0,0,1,0,x,y,z,1];case'perspective':var t=convertPercentUnit(item.d[0],0,null)||0;var p=t?-1/t:0;return [1,0,0,0,0,1,0,0,0,0,1,p,0,0,0,1];case'matrix':return [item.d[0].value,item.d[1].value,0,0,item.d[2].value,item.d[3].value,0,0,0,0,1,0,item.d[4].value,item.d[5].value,0,1];case'matrix3d':return item.d.map(function(d){return d.value;});}}function multiplyMatrices(a,b){return [a[0]*b[0]+a[4]*b[1]+a[8]*b[2]+a[12]*b[3],a[1]*b[0]+a[5]*b[1]+a[9]*b[2]+a[13]*b[3],a[2]*b[0]+a[6]*b[1]+a[10]*b[2]+a[14]*b[3],a[3]*b[0]+a[7]*b[1]+a[11]*b[2]+a[15]*b[3],a[0]*b[4]+a[4]*b[5]+a[8]*b[6]+a[12]*b[7],a[1]*b[4]+a[5]*b[5]+a[9]*b[6]+a[13]*b[7],a[2]*b[4]+a[6]*b[5]+a[10]*b[6]+a[14]*b[7],a[3]*b[4]+a[7]*b[5]+a[11]*b[6]+a[15]*b[7],a[0]*b[8]+a[4]*b[9]+a[8]*b[10]+a[12]*b[11],a[1]*b[8]+a[5]*b[9]+a[9]*b[10]+a[13]*b[11],a[2]*b[8]+a[6]*b[9]+a[10]*b[10]+a[14]*b[11],a[3]*b[8]+a[7]*b[9]+a[11]*b[10]+a[15]*b[11],a[0]*b[12]+a[4]*b[13]+a[8]*b[14]+a[12]*b[15],a[1]*b[12]+a[5]*b[13]+a[9]*b[14]+a[13]*b[15],a[2]*b[12]+a[6]*b[13]+a[10]*b[14]+a[14]*b[15],a[3]*b[12]+a[7]*b[13]+a[11]*b[14]+a[15]*b[15]];}function convertToMatrix(transformList){if(transformList.length===0){return [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];}return transformList.map(convertItemToMatrix).reduce(multiplyMatrices);}function makeMatrixDecomposition(transformList){var translate=[0,0,0];var scale=[1,1,1];var skew=[0,0,0];var perspective=[0,0,0,1];var quaternion=[0,0,0,1];// @ts-ignore
|
|
7995
|
+
decomposeMat4(convertToMatrix(transformList),translate,scale,skew,perspective,quaternion);return [[translate,scale,skew,quaternion,perspective]];}var composeMatrix=function(){function multiply(a,b){var result=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]];for(var i=0;i<4;i++){for(var j=0;j<4;j++){for(var k=0;k<4;k++){result[i][j]+=b[i][k]*a[k][j];}}}return result;}function is2D(m){return m[0][2]==0&&m[0][3]==0&&m[1][2]==0&&m[1][3]==0&&m[2][0]==0&&m[2][1]==0&&m[2][2]==1&&m[2][3]==0&&m[3][2]==0&&m[3][3]==1;}function composeMatrix(translate,scale,skew,quat,perspective){var matrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(var i=0;i<4;i++){matrix[i][3]=perspective[i];}for(var _i=0;_i<3;_i++){for(var j=0;j<3;j++){matrix[3][_i]+=translate[j]*matrix[j][_i];}}var x=quat[0],y=quat[1],z=quat[2],w=quat[3];var rotMatrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];rotMatrix[0][0]=1-2*(y*y+z*z);rotMatrix[0][1]=2*(x*y-z*w);rotMatrix[0][2]=2*(x*z+y*w);rotMatrix[1][0]=2*(x*y+z*w);rotMatrix[1][1]=1-2*(x*x+z*z);rotMatrix[1][2]=2*(y*z-x*w);rotMatrix[2][0]=2*(x*z-y*w);rotMatrix[2][1]=2*(y*z+x*w);rotMatrix[2][2]=1-2*(x*x+y*y);matrix=multiply(matrix,rotMatrix);var temp=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];if(skew[2]){temp[2][1]=skew[2];matrix=multiply(matrix,temp);}if(skew[1]){temp[2][1]=0;temp[2][0]=skew[0];matrix=multiply(matrix,temp);}if(skew[0]){temp[2][0]=0;temp[1][0]=skew[0];matrix=multiply(matrix,temp);}for(var _i2=0;_i2<3;_i2++){for(var _j=0;_j<3;_j++){matrix[_i2][_j]*=scale[_i2];}}if(is2D(matrix)){return [matrix[0][0],matrix[0][1],matrix[1][0],matrix[1][1],matrix[3][0],matrix[3][1]];}return matrix[0].concat(matrix[1],matrix[2],matrix[3]);}return composeMatrix;}();function numberToLongString(x){return x.toFixed(6).replace('.000000','');}function mergeMatrices(left,right){var leftArgs;var rightArgs;// @ts-ignore
|
|
7996
|
+
if(left.decompositionPair!==right){// @ts-ignore
|
|
7997
|
+
left.decompositionPair=right;// @ts-ignore
|
|
7998
|
+
leftArgs=makeMatrixDecomposition(left);}// @ts-ignore
|
|
7999
|
+
if(right.decompositionPair!==left){// @ts-ignore
|
|
8000
|
+
right.decompositionPair=left;// @ts-ignore
|
|
8001
|
+
rightArgs=makeMatrixDecomposition(right);}if(leftArgs[0]===null||rightArgs[0]===null)return [// @ts-ignore
|
|
8002
|
+
[false],// @ts-ignore
|
|
8003
|
+
[true],// @ts-ignore
|
|
8004
|
+
function(x){return x?right[0].d:left[0].d;}];leftArgs[0].push(0);rightArgs[0].push(1);return [leftArgs,rightArgs,// @ts-ignore
|
|
8005
|
+
function(list){// @ts-ignore
|
|
8006
|
+
var q=quat(leftArgs[0][3],rightArgs[0][3],list[5]);var mat=composeMatrix(list[0],list[1],list[2],q,list[4]);var stringifiedArgs=mat.map(numberToLongString).join(',');return stringifiedArgs;}];}function dot$2(v1,v2){var result=0;for(var i=0;i<v1.length;i++){result+=v1[i]*v2[i];}return result;}function quat(fromQ,toQ,f){var product=dot$2(fromQ,toQ);product=clamp(product,-1.0,1.0);var quat=[];if(product===1.0){quat=fromQ;}else {var theta=Math.acos(product);var w=Math.sin(f*theta)*1/Math.sqrt(1-product*product);for(var i=0;i<4;i++){quat.push(fromQ[i]*(Math.cos(f*theta)-product*w)+toQ[i]*w);}}return quat;}// scalex/y/z -> scale
|
|
8007
|
+
function typeTo2D(type){return type.replace(/[xy]/,'');}// scalex/y/z -> scale3d
|
|
8008
|
+
function typeTo3D(type){return type.replace(/(x|y|z|3d)?$/,'3d');}var isMatrixOrPerspective=function isMatrixOrPerspective(lt,rt){return lt==='perspective'&&rt==='perspective'||(lt==='matrix'||lt==='matrix3d')&&(rt==='matrix'||rt==='matrix3d');};function mergeTransforms(left,right,target){var flipResults=false;// padding empty transform, eg. merge 'scale(10)' with 'none' -> scale(1)
|
|
8009
|
+
if(!left.length||!right.length){if(!left.length){flipResults=true;left=right;right=[];}var _loop=function _loop(i){var _left$i=left[i],type=_left$i.t,args=_left$i.d;// none -> scale(1)/translateX(0)
|
|
8010
|
+
var defaultValue=type.substring(0,5)==='scale'?1:0;right.push({t:type,d:args.map(function(arg){if(typeof arg==='number'){return getOrCreateUnitValue(defaultValue);}return getOrCreateUnitValue(defaultValue,arg.unit);// {
|
|
8011
|
+
// unit: arg.unit,
|
|
8012
|
+
// value: defaultValue,
|
|
8013
|
+
// };
|
|
8014
|
+
})});};for(var i=0;i<left.length;i++){_loop(i);}}var leftResult=[];var rightResult=[];var types=[];// merge matrix() with matrix3d()
|
|
8015
|
+
if(left.length!==right.length){var merged=mergeMatrices(left,right);// @ts-ignore
|
|
8016
|
+
leftResult=[merged[0]];// @ts-ignore
|
|
8017
|
+
rightResult=[merged[1]];types=[['matrix',[merged[2]]]];}else {for(var _i3=0;_i3<left.length;_i3++){var leftType=left[_i3].t;var rightType=right[_i3].t;var leftArgs=left[_i3].d;var rightArgs=right[_i3].d;var leftFunctionData=transformFunctions[leftType];var rightFunctionData=transformFunctions[rightType];var type=void 0;if(isMatrixOrPerspective(leftType,rightType)){var _merged=mergeMatrices([left[_i3]],[right[_i3]]);// @ts-ignore
|
|
8018
|
+
leftResult.push(_merged[0]);// @ts-ignore
|
|
8019
|
+
rightResult.push(_merged[1]);types.push(['matrix',[_merged[2]]]);continue;}else if(leftType===rightType){type=leftType;}else if(leftFunctionData[2]&&rightFunctionData[2]&&typeTo2D(leftType)===typeTo2D(rightType)){type=typeTo2D(leftType);// @ts-ignore
|
|
8020
|
+
leftArgs=leftFunctionData[2](leftArgs);// @ts-ignore
|
|
8021
|
+
rightArgs=rightFunctionData[2](rightArgs);}else if(leftFunctionData[1]&&rightFunctionData[1]&&typeTo3D(leftType)===typeTo3D(rightType)){type=typeTo3D(leftType);// @ts-ignore
|
|
8022
|
+
leftArgs=leftFunctionData[1](leftArgs);// @ts-ignore
|
|
8023
|
+
rightArgs=rightFunctionData[1](rightArgs);}else {var _merged2=mergeMatrices(left,right);// @ts-ignore
|
|
8024
|
+
leftResult=[_merged2[0]];// @ts-ignore
|
|
8025
|
+
rightResult=[_merged2[1]];types=[['matrix',[_merged2[2]]]];break;}var leftArgsCopy=[];var rightArgsCopy=[];var stringConversions=[];for(var j=0;j<leftArgs.length;j++){// const merge = leftArgs[j].unit === UnitType.kNumber ? mergeDimensions : mergeDimensions;
|
|
8026
|
+
var _merged3=mergeDimensions(leftArgs[j],rightArgs[j],target,false,j);leftArgsCopy[j]=_merged3[0];rightArgsCopy[j]=_merged3[1];stringConversions.push(_merged3[2]);}leftResult.push(leftArgsCopy);rightResult.push(rightArgsCopy);types.push([type,stringConversions]);}}if(flipResults){var tmp=leftResult;leftResult=rightResult;rightResult=tmp;}return [leftResult,rightResult,function(list){return list.map(function(args,i){var stringifiedArgs=args.map(function(arg,j){return types[i][1][j](arg);}).join(',');if(types[i][0]==='matrix'&&stringifiedArgs.split(',').length===16){types[i][0]='matrix3d';}if(types[i][0]==='matrix3d'&&stringifiedArgs.split(',').length===6){types[i][0]='matrix';}return types[i][0]+'('+stringifiedArgs+')';}).join(' ');}];}/**
|
|
8027
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-origin
|
|
8028
|
+
* eg. 'center' 'top left' '50px 50px'
|
|
8029
|
+
*/var parseTransformOrigin=memoize(function(value){if(isString(value)){if(value==='text-anchor'){return [getOrCreateUnitValue(0,'px'),getOrCreateUnitValue(0,'px')];}var values=value.split(' ');if(values.length===1){if(values[0]==='top'||values[0]==='bottom'){// 'top' -> 'center top'
|
|
8030
|
+
values[1]=values[0];values[0]='center';}else {// '50px' -> '50px center'
|
|
8031
|
+
values[1]='center';}}if(values.length!==2){return null;}// eg. center bottom
|
|
8032
|
+
return [parseLengthOrPercentage(convertKeyword2Percent(values[0])),parseLengthOrPercentage(convertKeyword2Percent(values[1]))];}else {return [getOrCreateUnitValue(value[0]||0,'px'),getOrCreateUnitValue(value[1]||0,'px')];}});function convertKeyword2Percent(keyword){if(keyword==='center'){return '50%';}else if(keyword==='left'||keyword==='top'){return '0';}else if(keyword==='right'||keyword==='bottom'){return '100%';}return keyword;}var CSSPropertyAngle=/*#__PURE__*/function(){function CSSPropertyAngle(){this.parser=parseAngle;this.mixer=mergeNumbers;}var _proto=CSSPropertyAngle.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){return convertAngleUnit(parsed);};return CSSPropertyAngle;}();/**
|
|
8033
|
+
* clipPath / textPath / offsetPath
|
|
8034
|
+
*/var CSSPropertyClipPath=/*#__PURE__*/function(){function CSSPropertyClipPath(){}var _proto=CSSPropertyClipPath.prototype;_proto.calculator=function calculator(name,oldPath,newPath,object){// unset
|
|
8035
|
+
if(newPath instanceof CSSKeywordValue){newPath=null;}runtime.sceneGraphService.updateDisplayObjectDependency(name,oldPath,newPath,object);if(name==='clipPath'){// should affect children
|
|
8036
|
+
object.forEach(function(leaf){if(leaf.childNodes.length===0){runtime.sceneGraphService.dirtifyToRoot(leaf);}});}return newPath;};return CSSPropertyClipPath;}();var CSSPropertyColor=/*#__PURE__*/function(){function CSSPropertyColor(){this.parser=parseColor;this.mixer=mergeColors;}var _proto=CSSPropertyColor.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){// 'unset' 'none'
|
|
8037
|
+
return parsed.value==='none'?noneColor:transparentColor;}return parsed;};return CSSPropertyColor;}();var CSSPropertyFilter=/*#__PURE__*/function(){function CSSPropertyFilter(){this.parser=parseFilter;}var _proto=CSSPropertyFilter.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset or none
|
|
8038
|
+
if(parsed instanceof CSSKeywordValue){return [];}return parsed;};return CSSPropertyFilter;}();function getFontSize(object){var fontSize=object.parsedStyle.fontSize;return isNil(fontSize)?null:fontSize;}/**
|
|
8039
|
+
* <length> & <percentage>
|
|
8040
|
+
*/var CSSPropertyLengthOrPercentage=/*#__PURE__*/function(){function CSSPropertyLengthOrPercentage(){this.parser=parseLengthOrPercentage;this.mixer=mergeNumbers;}var _proto=CSSPropertyLengthOrPercentage.prototype;/**
|
|
8041
|
+
* according to parent's bounds
|
|
8042
|
+
*
|
|
8043
|
+
* @example
|
|
8044
|
+
* CSS.percent(50) -> CSS.px(0.5 * parent.width)
|
|
8045
|
+
*/_proto.calculator=function calculator(name,oldParsed,computed,object,registry){if(isNumber(computed)){return computed;}if(CSSUnitValue.isRelativeUnit(computed.unit)){if(computed.unit===exports.UnitType.kPercentage){// TODO: merge dimensions
|
|
8046
|
+
return 0;}else if(computed.unit===exports.UnitType.kEms){if(object.parentNode){var fontSize=getFontSize(object.parentNode);if(fontSize){fontSize*=computed.value;return fontSize;}else {registry.addUnresolveProperty(object,name);}}else {registry.addUnresolveProperty(object,name);}return 0;}else if(computed.unit===exports.UnitType.kRems){var _object$ownerDocument;if(object===null||object===void 0?void 0:(_object$ownerDocument=object.ownerDocument)===null||_object$ownerDocument===void 0?void 0:_object$ownerDocument.documentElement){var _fontSize=getFontSize(object.ownerDocument.documentElement);if(_fontSize){_fontSize*=computed.value;return _fontSize;}else {registry.addUnresolveProperty(object,name);}}else {registry.addUnresolveProperty(object,name);}return 0;}}else {// remove listener if exists
|
|
8047
|
+
// registry.unregisterParentGeometryBoundsChangedHandler(object, name);
|
|
8048
|
+
// return absolute value
|
|
8049
|
+
return computed.value;}};return CSSPropertyLengthOrPercentage;}();/**
|
|
8050
|
+
* format to Tuple2<CSSUnitValue>
|
|
8051
|
+
*
|
|
8052
|
+
* @example
|
|
8053
|
+
* rect.style.lineDash = 10;
|
|
8054
|
+
* rect.style.lineDash = [10, 10];
|
|
8055
|
+
* rect.style.lineDash = '10 10';
|
|
8056
|
+
*/var CSSPropertyLengthOrPercentage12=/*#__PURE__*/function(){function CSSPropertyLengthOrPercentage12(){this.mixer=mergeNumberLists;}var _proto=CSSPropertyLengthOrPercentage12.prototype;_proto.parser=function parser(radius){var parsed=parseDimensionArray(isNumber(radius)?[radius]:radius);var formatted;if(parsed.length===1){formatted=[parsed[0],parsed[0]];}else {formatted=[parsed[0],parsed[1]];}return formatted;};_proto.calculator=function calculator(name,oldParsed,computed){return computed.map(function(c){return c.value;});};return CSSPropertyLengthOrPercentage12;}();/**
|
|
8057
|
+
* used in rounded rect
|
|
8058
|
+
*
|
|
8059
|
+
* @example
|
|
8060
|
+
* rect.style.radius = 10;
|
|
8061
|
+
* rect.style.radius = '10 10';
|
|
8062
|
+
* rect.style.radius = '10 10 10 10';
|
|
8063
|
+
*/var CSSPropertyLengthOrPercentage14=/*#__PURE__*/function(){function CSSPropertyLengthOrPercentage14(){this.mixer=mergeNumberLists;}var _proto=CSSPropertyLengthOrPercentage14.prototype;_proto.parser=function parser(radius){var parsed=parseDimensionArray(isNumber(radius)?[radius]:radius);var formatted;// format to Tuple<CSSUnitValue>
|
|
8064
|
+
if(parsed.length===1){formatted=[parsed[0],parsed[0],parsed[0],parsed[0]];}else if(parsed.length===2){formatted=[parsed[0],parsed[1],parsed[0],parsed[1]];}else if(parsed.length===3){formatted=[parsed[0],parsed[1],parsed[2],parsed[1]];}else {formatted=[parsed[0],parsed[1],parsed[2],parsed[3]];}return formatted;};_proto.calculator=function calculator(name,oldParsed,computed){return computed.map(function(c){return c.value;});};return CSSPropertyLengthOrPercentage14;}();/**
|
|
8065
|
+
* local position
|
|
8066
|
+
*/var CSSPropertyLocalPosition=/*#__PURE__*/function(_CSSPropertyLengthOrP){_inheritsLoose(CSSPropertyLocalPosition,_CSSPropertyLengthOrP);function CSSPropertyLocalPosition(){return _CSSPropertyLengthOrP.apply(this,arguments)||this;}var _proto=CSSPropertyLocalPosition.prototype;/**
|
|
8067
|
+
* update local position
|
|
8068
|
+
*/_proto.postProcessor=function postProcessor(object,attributes){var x;var y;var z;switch(object.nodeName){case exports.Shape.CIRCLE:case exports.Shape.ELLIPSE:var _object$parsedStyle=object.parsedStyle,cx=_object$parsedStyle.cx,cy=_object$parsedStyle.cy;if(!isNil(cx)){x=cx;}if(!isNil(cy)){y=cy;}break;case exports.Shape.LINE:var _object$parsedStyle2=object.parsedStyle,x1=_object$parsedStyle2.x1,x2=_object$parsedStyle2.x2,y1=_object$parsedStyle2.y1,y2=_object$parsedStyle2.y2;var minX=Math.min(x1,x2);var minY=Math.min(y1,y2);x=minX;y=minY;z=0;break;case exports.Shape.RECT:case exports.Shape.IMAGE:case exports.Shape.GROUP:case exports.Shape.HTML:case exports.Shape.TEXT:case exports.Shape.MESH:if(!isNil(object.parsedStyle.x)){x=object.parsedStyle.x;}if(!isNil(object.parsedStyle.y)){y=object.parsedStyle.y;}break;}if(object.nodeName!==exports.Shape.PATH&&object.nodeName!==exports.Shape.POLYLINE&&object.nodeName!==exports.Shape.POLYGON){object.parsedStyle.defX=x||0;object.parsedStyle.defY=y||0;}var needResetLocalPosition=!isNil(x)||!isNil(y)||!isNil(z);// only if `transform` won't be processed later
|
|
8069
|
+
if(needResetLocalPosition&&attributes.indexOf('transform')===-1){// account for current transform if needed
|
|
8070
|
+
var transform=object.parsedStyle.transform;if(transform&&transform.length){parsedTransformToMat4(transform,object);}else {var _object$getLocalPosit=object.getLocalPosition(),ox=_object$getLocalPosit[0],oy=_object$getLocalPosit[1],oz=_object$getLocalPosit[2];object.setLocalPosition(isNil(x)?ox:x,isNil(y)?oy:y,isNil(z)?oz:z);}}};return CSSPropertyLocalPosition;}(CSSPropertyLengthOrPercentage);var CSSPropertyMarker=/*#__PURE__*/function(){function CSSPropertyMarker(){}var _proto=CSSPropertyMarker.prototype;_proto.calculator=function calculator(name,oldMarker,newMarker,object){var _newMarker;// unset
|
|
8071
|
+
if(newMarker instanceof CSSKeywordValue){newMarker=null;}var cloned=(_newMarker=newMarker)===null||_newMarker===void 0?void 0:_newMarker.cloneNode(true);if(cloned){// FIXME: SVG should not inherit parent's style, add a flag here
|
|
8072
|
+
cloned.style.isMarker=true;}return cloned;};return CSSPropertyMarker;}();var CSSPropertyNumber=/*#__PURE__*/function(){function CSSPropertyNumber(){this.mixer=mergeNumbers;this.parser=parseNumber;}var _proto=CSSPropertyNumber.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyNumber;}();var CSSPropertyOffsetDistance=/*#__PURE__*/function(){function CSSPropertyOffsetDistance(){this.parser=parseNumber;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOffsetDistance.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};_proto.postProcessor=function postProcessor(object){var _object$parsedStyle=object.parsedStyle,offsetPath=_object$parsedStyle.offsetPath,offsetDistance=_object$parsedStyle.offsetDistance;if(!offsetPath){return;}var nodeName=offsetPath.nodeName;if(nodeName===exports.Shape.LINE||nodeName===exports.Shape.PATH||nodeName===exports.Shape.POLYLINE){// set position in world space
|
|
8073
|
+
var point=offsetPath.getPoint(offsetDistance);if(point){object.parsedStyle.defX=point.x;object.parsedStyle.defY=point.y;object.setLocalPosition(point.x,point.y);}}};return CSSPropertyOffsetDistance;}();/**
|
|
7932
8074
|
* opacity
|
|
7933
8075
|
*/var CSSPropertyOpacity=/*#__PURE__*/function(){function CSSPropertyOpacity(){this.parser=parseNumber;this.mixer=clampedMergeNumbers(0,1);}var _proto=CSSPropertyOpacity.prototype;_proto.calculator=function calculator(name,oldParsed,computed){return computed.value;};return CSSPropertyOpacity;}();var CSSPropertyPath=/*#__PURE__*/function(){function CSSPropertyPath(){this.parser=parsePath;this.mixer=mergePaths;}var _proto=CSSPropertyPath.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset
|
|
7934
8076
|
if(parsed instanceof CSSKeywordValue&&parsed.value==='unset'){return {absolutePath:[],hasArc:false,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Rectangle(0,0,0,0)};}return parsed;};/**
|
|
7935
8077
|
* update local position
|
|
7936
|
-
*/_proto.postProcessor=function postProcessor(object){if(object.nodeName===exports.Shape.PATH){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;object.setLocalPosition(defX,defY);}};return CSSPropertyPath;}();var CSSPropertyPoints=/*#__PURE__*/function(){function CSSPropertyPoints(){this.parser=parsePoints;}var _proto=CSSPropertyPoints.prototype;/**
|
|
8078
|
+
*/_proto.postProcessor=function postProcessor(object,attributes){if(object.nodeName===exports.Shape.PATH&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;object.setLocalPosition(defX,defY);}};return CSSPropertyPath;}();var CSSPropertyPoints=/*#__PURE__*/function(){function CSSPropertyPoints(){this.parser=parsePoints;}var _proto=CSSPropertyPoints.prototype;/**
|
|
7937
8079
|
* update local position
|
|
7938
|
-
*/_proto.postProcessor=function postProcessor(object){if(object.nodeName===exports.Shape.POLYGON||object.nodeName===exports.Shape.POLYLINE){var _object$parsedStyle=object.parsedStyle,defX=_object$parsedStyle.defX,defY=_object$parsedStyle.defY;object.setLocalPosition(defX,defY);}};return CSSPropertyPoints;}();var CSSPropertyShadowBlur=/*#__PURE__*/function(_CSSPropertyLengthOrP){_inheritsLoose(CSSPropertyShadowBlur,_CSSPropertyLengthOrP);function CSSPropertyShadowBlur(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_CSSPropertyLengthOrP.call.apply(_CSSPropertyLengthOrP,[this].concat(args))||this;_this.mixer=clampedMergeNumbers(0,Infinity);return _this;}return CSSPropertyShadowBlur;}(CSSPropertyLengthOrPercentage);var CSSPropertyText=/*#__PURE__*/function(){function CSSPropertyText(){}var _proto=CSSPropertyText.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){if(parsed.value==='unset'){return '';}else {return parsed.value;}}// allow number as valid text content
|
|
8080
|
+
*/_proto.postProcessor=function postProcessor(object,attributes){if((object.nodeName===exports.Shape.POLYGON||object.nodeName===exports.Shape.POLYLINE)&&attributes.indexOf('transform')===-1){var _object$parsedStyle=object.parsedStyle,defX=_object$parsedStyle.defX,defY=_object$parsedStyle.defY;object.setLocalPosition(defX,defY);}};return CSSPropertyPoints;}();var CSSPropertyShadowBlur=/*#__PURE__*/function(_CSSPropertyLengthOrP){_inheritsLoose(CSSPropertyShadowBlur,_CSSPropertyLengthOrP);function CSSPropertyShadowBlur(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_CSSPropertyLengthOrP.call.apply(_CSSPropertyLengthOrP,[this].concat(args))||this;_this.mixer=clampedMergeNumbers(0,Infinity);return _this;}return CSSPropertyShadowBlur;}(CSSPropertyLengthOrPercentage);var CSSPropertyText=/*#__PURE__*/function(){function CSSPropertyText(){}var _proto=CSSPropertyText.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){if(parsed.value==='unset'){return '';}else {return parsed.value;}}// allow number as valid text content
|
|
7939
8081
|
return ""+parsed;};_proto.postProcessor=function postProcessor(object){object.nodeValue=""+object.parsedStyle.text||'';};return CSSPropertyText;}();/**
|
|
7940
8082
|
* it must transform after text get parsed
|
|
7941
8083
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/text-transform
|
|
@@ -8122,7 +8264,7 @@
|
|
|
8122
8264
|
* @example const circle = document.createElement('circle', { style: { r: 10 } });
|
|
8123
8265
|
*/_proto.createElement=function createElement(tagName,options){// @observablehq/plot will create <svg>
|
|
8124
8266
|
if(tagName==='svg'){return this.documentElement;}// d3 will use <tspan>
|
|
8125
|
-
var clazz=this.defaultView.customElements.get(tagName);if(!clazz){console.warn('Unsupported tagName: ',tagName);clazz=tagName==='tspan'?Text:Group;}var shape=new clazz(options);shape.ownerDocument=this;return shape;};_proto.createElementNS=function createElementNS(namespaceURI,tagName,options){return this.createElement(tagName,options);};_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.destroy=function destroy(){try{this.documentElement.
|
|
8267
|
+
var clazz=this.defaultView.customElements.get(tagName);if(!clazz){console.warn('Unsupported tagName: ',tagName);clazz=tagName==='tspan'?Text:Group;}var shape=new clazz(options);shape.ownerDocument=this;return shape;};_proto.createElementNS=function createElementNS(namespaceURI,tagName,options){return this.createElement(tagName,options);};_proto.cloneNode=function cloneNode(deep){throw new Error(ERROR_MSG_METHOD_NOT_IMPLEMENTED);};_proto.destroy=function destroy(){try{this.documentElement.destroyChildren();this.timeline.destroy();}catch(e){}}/**
|
|
8126
8268
|
* Picking 2D graphics with RBush based on BBox, fast but inaccurate.
|
|
8127
8269
|
*/;_proto.elementsFromBBox=function elementsFromBBox(minX,minY,maxX,maxY){var rBush=this.defaultView.context.rBushRoot;var rBushNodes=rBush.search({minX:minX,minY:minY,maxX:maxX,maxY:maxY});var hitTestList=[];rBushNodes.forEach(function(_ref2){var id=_ref2.id;var displayObject=runtime.displayObjectPool.getByEntity(id);var pointerEvents=displayObject.parsedStyle.pointerEvents;// account for `visibility`
|
|
8128
8270
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
@@ -8174,7 +8316,17 @@
|
|
|
8174
8316
|
* * Node insert/remove, eg. appendChild, removeChild, remove...
|
|
8175
8317
|
* * Query eg. querySelector getElementById...
|
|
8176
8318
|
* * Animation
|
|
8177
|
-
*/var Element=/*#__PURE__*/function(_Node){_inheritsLoose(Element,_Node);function Element(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_Node.call.apply(_Node,[this].concat(args))||this;_this.entity=entityCounter++;_this.renderable={bounds:undefined,boundsDirty:true,renderBounds:undefined,renderBoundsDirty:true,dirtyRenderBounds:undefined,dirty:false,proxyNodeName:undefined};_this.cullable={strategy:exports.Strategy.Standard,visibilityPlaneMask:-1,visible:true,enable:true};_this.transformable={dirtyFlag:false,localDirtyFlag:false,frozen:false
|
|
8319
|
+
*/var Element=/*#__PURE__*/function(_Node){_inheritsLoose(Element,_Node);function Element(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_Node.call.apply(_Node,[this].concat(args))||this;_this.entity=entityCounter++;_this.renderable={bounds:undefined,boundsDirty:true,renderBounds:undefined,renderBoundsDirty:true,dirtyRenderBounds:undefined,dirty:false,proxyNodeName:undefined};_this.cullable={strategy:exports.Strategy.Standard,visibilityPlaneMask:-1,visible:true,enable:true};_this.transformable={dirtyFlag:false,localDirtyFlag:false,frozen:false,// localPosition: vec3.fromValues(0, 0, 0),
|
|
8320
|
+
// localRotation: quat.fromValues(0, 0, 0, 1),
|
|
8321
|
+
// localScale: vec3.fromValues(1, 1, 1),
|
|
8322
|
+
// localTransform: mat4.create(),
|
|
8323
|
+
// localSkew: vec2.fromValues(0, 0),
|
|
8324
|
+
// position: vec3.fromValues(0, 0, 0),
|
|
8325
|
+
// rotation: quat.fromValues(0, 0, 0, 1),
|
|
8326
|
+
// scaling: vec3.fromValues(1, 1, 1),
|
|
8327
|
+
// worldTransform: mat4.create(),
|
|
8328
|
+
// origin: vec3.fromValues(0, 0, 0),
|
|
8329
|
+
localPosition:[0,0,0],localRotation:[0,0,0,1],localScale:[1,1,1],localTransform:create$1(),localSkew:[0,0],position:[0,0,0],rotation:[0,0,0,1],scaling:[1,1,1],worldTransform:create$1(),origin:[0,0,0]};_this.sortable={dirty:false,sorted:undefined,lastSortedIndex:undefined,renderOrder:0};_this.geometry={contentBounds:undefined,renderBounds:undefined};_this.rBushNode={aabb:undefined};_this.id=void 0;_this.name=void 0;_this.namespaceURI='g';_this.scrollLeft=0;_this.scrollTop=0;_this.clientTop=0;_this.clientLeft=0;_this.destroyed=false;_this.style={};_this.computedStyle=runtime.enableCSSParsing?{anchor:unsetKeywordValue,opacity:unsetKeywordValue,fillOpacity:unsetKeywordValue,strokeOpacity:unsetKeywordValue,fill:unsetKeywordValue,stroke:unsetKeywordValue,transform:unsetKeywordValue,transformOrigin:unsetKeywordValue,visibility:unsetKeywordValue,pointerEvents:unsetKeywordValue,lineWidth:unsetKeywordValue,lineCap:unsetKeywordValue,lineJoin:unsetKeywordValue,increasedLineWidthForHitTesting:unsetKeywordValue,fontSize:unsetKeywordValue,fontFamily:unsetKeywordValue,fontStyle:unsetKeywordValue,fontWeight:unsetKeywordValue,fontVariant:unsetKeywordValue,textAlign:unsetKeywordValue,textBaseline:unsetKeywordValue,textTransform:unsetKeywordValue,zIndex:unsetKeywordValue,filter:unsetKeywordValue,shadowType:unsetKeywordValue}:null;_this.parsedStyle={// opacity: '',
|
|
8178
8330
|
// fillOpacity: '',
|
|
8179
8331
|
// strokeOpacity: '',
|
|
8180
8332
|
// transformOrigin: '',
|
|
@@ -8198,9 +8350,9 @@
|
|
|
8198
8350
|
removedEvent.relatedNode=this;child.dispatchEvent(removedEvent);if((_child$ownerDocument=child.ownerDocument)===null||_child$ownerDocument===void 0?void 0:_child$ownerDocument.defaultView){child.ownerDocument.defaultView.unmountChildren(child);}// remove from scene graph
|
|
8199
8351
|
runtime.sceneGraphService.detach(child);return child;}/**
|
|
8200
8352
|
* Remove all children which can be appended to its original parent later again.
|
|
8201
|
-
*/;_proto.removeChildren=function removeChildren(){var
|
|
8353
|
+
*/;_proto.removeChildren=function removeChildren(){for(var i=this.childNodes.length-1;i>=0;i--){var child=this.childNodes[i];this.removeChild(child);}}/**
|
|
8202
8354
|
* Recursively destroy all children which can not be appended to its original parent later again.
|
|
8203
|
-
*/;_proto.destroyChildren=function destroyChildren(){this.childNodes.
|
|
8355
|
+
*/;_proto.destroyChildren=function destroyChildren(){for(var i=this.childNodes.length-1;i>=0;i--){var child=this.childNodes[i];if(child.childNodes.length){child.destroyChildren();}child.destroy();}}/**
|
|
8204
8356
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
|
|
8205
8357
|
*/;_proto.matches=function matches(selector){return runtime.sceneGraphService.matches(selector,this);};_proto.getElementById=function getElementById(id){return runtime.sceneGraphService.querySelector("#"+id,this);};_proto.getElementsByName=function getElementsByName(name){return runtime.sceneGraphService.querySelectorAll("[name=\""+name+"\"]",this);};_proto.getElementsByClassName=function getElementsByClassName(className){return runtime.sceneGraphService.querySelectorAll("."+className,this);};_proto.getElementsByTagName=function getElementsByTagName(tagName){return runtime.sceneGraphService.querySelectorAll(tagName,this);};_proto.querySelector=function querySelector(selectors){return runtime.sceneGraphService.querySelector(selectors,this);};_proto.querySelectorAll=function querySelectorAll(selectors){return runtime.sceneGraphService.querySelectorAll(selectors,this);}/**
|
|
8206
8358
|
* should traverses the element and its parents (heading toward the document root)
|
|
@@ -8209,17 +8361,17 @@
|
|
|
8209
8361
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#polyfill
|
|
8210
8362
|
*/;_proto.closest=function closest(selectors){var el=this;do{if(runtime.sceneGraphService.matches(selectors,el))return el;el=el.parentElement;}while(el!==null);return null;}/**
|
|
8211
8363
|
* search in scene group, but should not include itself
|
|
8212
|
-
*/;_proto.find=function find(filter){var
|
|
8364
|
+
*/;_proto.find=function find(filter){var _this2=this;var target=null;this.forEach(function(object){if(object!==_this2&&filter(object)){target=object;return true;}return false;});return target;};_proto.findAll=function findAll(filter){var _this3=this;var objects=[];this.forEach(function(object){if(object!==_this3&&filter(object)){objects.push(object);}});return objects;}/**
|
|
8213
8365
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/after
|
|
8214
|
-
*/;_proto.after=function after(){var
|
|
8366
|
+
*/;_proto.after=function after(){var _this4=this;if(this.parentNode){var index=this.parentNode.childNodes.indexOf(this);for(var _len2=arguments.length,nodes=new Array(_len2),_key2=0;_key2<_len2;_key2++){nodes[_key2]=arguments[_key2];}nodes.forEach(function(node,i){var _this4$parentNode;return (_this4$parentNode=_this4.parentNode)===null||_this4$parentNode===void 0?void 0:_this4$parentNode.appendChild(node,index+i+1);});}}/**
|
|
8215
8367
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/before
|
|
8216
8368
|
*/;_proto.before=function before(){if(this.parentNode){var index=this.parentNode.childNodes.indexOf(this);for(var _len3=arguments.length,nodes=new Array(_len3),_key3=0;_key3<_len3;_key3++){nodes[_key3]=arguments[_key3];}var first=nodes[0],rest=nodes.slice(1);this.parentNode.appendChild(first,index);first.after.apply(first,rest);}}/**
|
|
8217
8369
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceWith
|
|
8218
8370
|
*/;_proto.replaceWith=function replaceWith(){this.after.apply(this,arguments);this.remove();}/**
|
|
8219
8371
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/append
|
|
8220
|
-
*/;_proto.append=function append(){var
|
|
8372
|
+
*/;_proto.append=function append(){var _this5=this;for(var _len4=arguments.length,nodes=new Array(_len4),_key4=0;_key4<_len4;_key4++){nodes[_key4]=arguments[_key4];}nodes.forEach(function(node){return _this5.appendChild(node);});}/**
|
|
8221
8373
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/prepend
|
|
8222
|
-
*/;_proto.prepend=function prepend(){var
|
|
8374
|
+
*/;_proto.prepend=function prepend(){var _this6=this;for(var _len5=arguments.length,nodes=new Array(_len5),_key5=0;_key5<_len5;_key5++){nodes[_key5]=arguments[_key5];}nodes.forEach(function(node,i){return _this6.appendChild(node,i);});}/**
|
|
8223
8375
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/replaceChildren
|
|
8224
8376
|
*/;_proto.replaceChildren=function replaceChildren(){while(this.childNodes.length&&this.firstChild){this.removeChild(this.firstChild);}this.append.apply(this,arguments);}/**
|
|
8225
8377
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/remove
|
|
@@ -8293,7 +8445,8 @@
|
|
|
8293
8445
|
* which can lead to unintended consequences if an attempt is made to cache the entire event object.
|
|
8294
8446
|
*
|
|
8295
8447
|
* Therefore, while keeping the above performance considerations in mind, it is possible to provide a clone method that creates a new object when the user really wants to cache it, e.g.
|
|
8296
|
-
*/;_proto.clone=function clone(){return this.manager.clonePointerEvent(this);};return FederatedPointerEvent;}(FederatedMouseEvent);var FederatedWheelEvent=/*#__PURE__*/function(_FederatedMouseEvent){_inheritsLoose(FederatedWheelEvent,_FederatedMouseEvent);function FederatedWheelEvent(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_FederatedMouseEvent.call.apply(_FederatedMouseEvent,[this].concat(args))||this;_this.deltaMode=void 0;_this.deltaX=void 0;_this.deltaY=void 0;_this.deltaZ=void 0;_this.DOM_DELTA_LINE=0;_this.DOM_DELTA_PAGE=1;_this.DOM_DELTA_PIXEL=2;return _this;}var _proto=FederatedWheelEvent.prototype;_proto.clone=function clone(){return this.manager.cloneWheelEvent(this);};return FederatedWheelEvent;}(FederatedMouseEvent);function isDisplayObject(value){return !!(value===null||value===void 0?void 0:value.nodeName);}var mutationEvent=new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,null,null,null,null,MutationEvent.MODIFICATION,null,null);var DEFAULT_STYLE_PROPS={anchor:'',opacity:'',fillOpacity:'',strokeOpacity:'',fill:'',stroke:'',transform:'',transformOrigin:'',visibility:'',pointerEvents:'',lineWidth:'',lineCap:'',lineJoin:'',increasedLineWidthForHitTesting:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',zIndex:'',filter:'',shadowType:''};var DEFAULT_PARSED_STYLE_PROPS={anchor:[0,0],fill:noneColor,stroke:noneColor,transform:[],zIndex:0,filter:[],shadowType:'outer'};var
|
|
8448
|
+
*/;_proto.clone=function clone(){return this.manager.clonePointerEvent(this);};return FederatedPointerEvent;}(FederatedMouseEvent);var FederatedWheelEvent=/*#__PURE__*/function(_FederatedMouseEvent){_inheritsLoose(FederatedWheelEvent,_FederatedMouseEvent);function FederatedWheelEvent(){var _this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}_this=_FederatedMouseEvent.call.apply(_FederatedMouseEvent,[this].concat(args))||this;_this.deltaMode=void 0;_this.deltaX=void 0;_this.deltaY=void 0;_this.deltaZ=void 0;_this.DOM_DELTA_LINE=0;_this.DOM_DELTA_PAGE=1;_this.DOM_DELTA_PIXEL=2;return _this;}var _proto=FederatedWheelEvent.prototype;_proto.clone=function clone(){return this.manager.cloneWheelEvent(this);};return FederatedWheelEvent;}(FederatedMouseEvent);function isDisplayObject(value){return !!(value===null||value===void 0?void 0:value.nodeName);}var mutationEvent=new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,null,null,null,null,MutationEvent.MODIFICATION,null,null);var DEFAULT_STYLE_PROPS={anchor:'',opacity:'',fillOpacity:'',strokeOpacity:'',fill:'',stroke:'',transform:'',transformOrigin:'',visibility:'',pointerEvents:'',lineWidth:'',lineCap:'',lineJoin:'',increasedLineWidthForHitTesting:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',zIndex:'',filter:'',shadowType:''};var DEFAULT_PARSED_STYLE_PROPS={anchor:[0,0],fill:noneColor,stroke:noneColor,transform:[],zIndex:0,filter:[],shadowType:'outer'};var DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED=_extends({},DEFAULT_PARSED_STYLE_PROPS,{opacity:1,fillOpacity:1,strokeOpacity:1,visibility:'visible',pointerEvents:'auto',lineWidth:1,lineCap:'butt',lineJoin:'miter',increasedLineWidthForHitTesting:0,fillRule:'nonzero'// TODO: transformOrigin
|
|
8449
|
+
});var INHERITABLE_BASE_STYLE_PROPS=['opacity','fillOpacity','strokeOpacity','transformOrigin','visibility','pointerEvents','lineWidth','lineCap','lineJoin','increasedLineWidthForHitTesting'];var INHERITABLE_STYLE_PROPS=[].concat(INHERITABLE_BASE_STYLE_PROPS,['fontSize','fontFamily','fontStyle','fontWeight','fontVariant','textAlign','textBaseline','textTransform']);/**
|
|
8297
8450
|
* prototype chains: DisplayObject -> Element -> Node -> EventTarget
|
|
8298
8451
|
*
|
|
8299
8452
|
* mixins: Animatable, Transformable, Visible
|
|
@@ -8319,528 +8472,272 @@
|
|
|
8319
8472
|
_this.config=void 0;_this.isCustomElement=false;_this.isMutationObserved=false;_this.activeAnimations=[];_this.getClip=function(){return this.style.clipPath||null;};_this.config=config;// compatible with G 3.0
|
|
8320
8473
|
_this.config.interactive=(_this$config$capture=_this.config.capture)!==null&&_this$config$capture!==void 0?_this$config$capture:_this.config.interactive;// init scene graph node
|
|
8321
8474
|
_this.id=_this.config.id||'';_this.name=_this.config.name||'';if(_this.config.className||_this.config.class){_this.className=_this.config.className||_this.config.class;}_this.nodeName=_this.config.type||exports.Shape.GROUP;// compatible with G 3.0
|
|
8322
|
-
_this.config.style=
|
|
8323
|
-
|
|
8475
|
+
_this.config.style=_this.config.style||_this.config.attrs||{};Object.assign(_this.config.style,_this.config.attrs);// this.config.style = {
|
|
8476
|
+
// // ...DEFAULT_STYLE_PROPS,
|
|
8477
|
+
// ...this.config.style,
|
|
8478
|
+
// ...this.config.attrs,
|
|
8479
|
+
// };
|
|
8480
|
+
if(_this.config.visible!=null){_this.config.style.visibility=_this.config.visible===false?'hidden':'visible';}if(_this.config.interactive!=null){_this.config.style.pointerEvents=_this.config.interactive===false?'none':'auto';}// merge parsed value
|
|
8481
|
+
Object.assign(_this.parsedStyle,runtime.enableCSSParsing?DEFAULT_PARSED_STYLE_PROPS:DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,_this.config.initialParsedStyle);if(runtime.enableCSSParsing){Object.assign(_this.attributes,DEFAULT_STYLE_PROPS);}// start to process attributes
|
|
8324
8482
|
_this.initAttributes(_this.config.style);_this.style=new Proxy(// @ts-ignore
|
|
8325
8483
|
{// ...this.attributes,
|
|
8326
8484
|
setProperty:function setProperty(propertyName,value){_this.setAttribute(propertyName,value);},getPropertyValue:function getPropertyValue(propertyName){return _this.getAttribute(propertyName);},removeProperty:function removeProperty(propertyName){_this.removeAttribute(propertyName);},item:function item(){return '';}},{get:function get(target,name){if(target[name]!==undefined){// if (name in target) {
|
|
8327
8485
|
return target[name];}return _this.getAttribute(name);},set:function set(_,prop,value){_this.setAttribute(prop,value);return true;}});// insert this group into pool
|
|
8328
|
-
runtime.displayObjectPool.add(_this.entity,_assertThisInitialized(_this));return _this;}var _proto=DisplayObject.prototype;_proto.destroy=function destroy(){_Element.prototype.destroy.call(this);// remove from pool
|
|
8329
|
-
runtime.displayObjectPool.remove(this.entity);// stop all active animations
|
|
8330
|
-
this.getAnimations().forEach(function(animation){animation.cancel();});// FIXME
|
|
8331
|
-
// this.renderable = null;
|
|
8332
|
-
// this.cullable = null;
|
|
8333
|
-
// this.transformable = null;
|
|
8334
|
-
// this.rBushNode = null;
|
|
8335
|
-
// this.geometry = null;
|
|
8336
|
-
// this.sortable = null;
|
|
8337
|
-
};_proto.cloneNode=function cloneNode(deep,customCloneFunc){var clonedStyle=_extends({},this.attributes);for(var attributeName in clonedStyle){var attribute=clonedStyle[attributeName];// @see https://github.com/antvis/G/issues/1095
|
|
8338
|
-
if(isDisplayObject(attribute)&&// share the same clipPath if possible
|
|
8339
|
-
attributeName!=='clipPath'&&attributeName!=='offsetPath'&&attributeName!=='textPath'){clonedStyle[attributeName]=attribute.cloneNode(deep);}// TODO: clone other type
|
|
8340
|
-
if(customCloneFunc){clonedStyle[attributeName]=customCloneFunc(attributeName,attribute);}}var cloned=new this.constructor({// copy id & name
|
|
8341
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
|
|
8342
|
-
id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:clonedStyle});// apply transform
|
|
8343
|
-
cloned.setLocalTransform(this.getLocalTransform());if(deep){this.children.forEach(function(child){// skip marker
|
|
8344
|
-
if(!child.style.isMarker){var clonedChild=child.cloneNode(deep);cloned.appendChild(clonedChild);}});}return cloned;};_proto.initAttributes=function initAttributes(attributes){if(attributes===void 0){attributes={};}var renderable=this.renderable
|
|
8345
|
-
|
|
8346
|
-
//
|
|
8347
|
-
//
|
|
8348
|
-
//
|
|
8349
|
-
//
|
|
8350
|
-
}
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
* returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
|
|
8358
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
|
|
8359
|
-
*
|
|
8360
|
-
* FIXME: It is worth noting that getBBox responds to original untransformed values of a drawn object.
|
|
8361
|
-
* @see https://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#getBBox
|
|
8362
|
-
*/;_proto.getBBox=function getBBox(){var aabb=this.getBounds();var _aabb$getMin=aabb.getMin(),left=_aabb$getMin[0],top=_aabb$getMin[1];var _aabb$getMax=aabb.getMax(),right=_aabb$getMax[0],bottom=_aabb$getMax[1];return new Rectangle(left,top,right-left,bottom-top);};_proto.setOrigin=function setOrigin(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.setOrigin(this,createVec3(position,y,z));return this;};_proto.getOrigin=function getOrigin(){return runtime.sceneGraphService.getOrigin(this);}/**
|
|
8363
|
-
* set position in world space
|
|
8364
|
-
*/;_proto.setPosition=function setPosition(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.setPosition(this,createVec3(position,y,z));return this;}/**
|
|
8365
|
-
* set position in local space
|
|
8366
|
-
*/;_proto.setLocalPosition=function setLocalPosition(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.setLocalPosition(this,createVec3(position,y,z));return this;}/**
|
|
8367
|
-
* translate in world space
|
|
8368
|
-
*/;_proto.translate=function translate(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.translate(this,createVec3(position,y,z));return this;}/**
|
|
8369
|
-
* translate in local space
|
|
8370
|
-
*/;_proto.translateLocal=function translateLocal(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.translateLocal(this,createVec3(position,y,z));return this;};_proto.getPosition=function getPosition(){return runtime.sceneGraphService.getPosition(this);};_proto.getLocalPosition=function getLocalPosition(){return runtime.sceneGraphService.getLocalPosition(this);}/**
|
|
8371
|
-
* compatible with G 3.0
|
|
8372
|
-
*
|
|
8373
|
-
* scaling in local space
|
|
8374
|
-
* scale(10) = scale(10, 10, 10)
|
|
8375
|
-
*
|
|
8376
|
-
* we can't set scale in world space
|
|
8377
|
-
*/;_proto.scale=function scale(scaling,y,z){return this.scaleLocal(scaling,y,z);};_proto.scaleLocal=function scaleLocal(scaling,y,z){if(typeof scaling==='number'){y=y||scaling;z=z||scaling;scaling=createVec3(scaling,y,z);}runtime.sceneGraphService.scaleLocal(this,scaling);return this;}/**
|
|
8378
|
-
* set scaling in local space
|
|
8379
|
-
*/;_proto.setLocalScale=function setLocalScale(scaling,y,z){if(typeof scaling==='number'){y=y||scaling;z=z||scaling;scaling=createVec3(scaling,y,z);}runtime.sceneGraphService.setLocalScale(this,scaling);return this;}/**
|
|
8380
|
-
* get scaling in local space
|
|
8381
|
-
*/;_proto.getLocalScale=function getLocalScale(){return runtime.sceneGraphService.getLocalScale(this);}/**
|
|
8382
|
-
* get scaling in world space
|
|
8383
|
-
*/;_proto.getScale=function getScale(){return runtime.sceneGraphService.getScale(this);}/**
|
|
8384
|
-
* only return degrees of Z axis in world space
|
|
8385
|
-
*/;_proto.getEulerAngles=function getEulerAngles(){var _getEuler=getEuler(create$2(),runtime.sceneGraphService.getWorldTransform(this)),ez=_getEuler[2];return rad2deg(ez);}/**
|
|
8386
|
-
* only return degrees of Z axis in local space
|
|
8387
|
-
*/;_proto.getLocalEulerAngles=function getLocalEulerAngles(){var _getEuler2=getEuler(create$2(),runtime.sceneGraphService.getLocalRotation(this)),ez=_getEuler2[2];return rad2deg(ez);}/**
|
|
8388
|
-
* set euler angles(degrees) in world space
|
|
8389
|
-
*/;_proto.setEulerAngles=function setEulerAngles(z){runtime.sceneGraphService.setEulerAngles(this,0,0,z);return this;}/**
|
|
8390
|
-
* set euler angles(degrees) in local space
|
|
8391
|
-
*/;_proto.setLocalEulerAngles=function setLocalEulerAngles(z){runtime.sceneGraphService.setLocalEulerAngles(this,0,0,z);return this;};_proto.rotateLocal=function rotateLocal(x,y,z){if(isNil(y)&&isNil(z)){runtime.sceneGraphService.rotateLocal(this,0,0,x);}else {runtime.sceneGraphService.rotateLocal(this,x,y,z);}return this;};_proto.rotate=function rotate(x,y,z){if(isNil(y)&&isNil(z)){runtime.sceneGraphService.rotate(this,0,0,x);}else {runtime.sceneGraphService.rotate(this,x,y,z);}return this;};_proto.setRotation=function setRotation(rotation,y,z,w){runtime.sceneGraphService.setRotation(this,rotation,y,z,w);return this;};_proto.setLocalRotation=function setLocalRotation(rotation,y,z,w){runtime.sceneGraphService.setLocalRotation(this,rotation,y,z,w);return this;};_proto.setLocalSkew=function setLocalSkew(skew,y){runtime.sceneGraphService.setLocalSkew(this,skew,y);return this;};_proto.getRotation=function getRotation(){return runtime.sceneGraphService.getRotation(this);};_proto.getLocalRotation=function getLocalRotation(){return runtime.sceneGraphService.getLocalRotation(this);};_proto.getLocalSkew=function getLocalSkew(){return runtime.sceneGraphService.getLocalSkew(this);};_proto.getLocalTransform=function getLocalTransform(){return runtime.sceneGraphService.getLocalTransform(this);};_proto.getWorldTransform=function getWorldTransform(){return runtime.sceneGraphService.getWorldTransform(this);};_proto.setLocalTransform=function setLocalTransform(transform){runtime.sceneGraphService.setLocalTransform(this,transform);return this;};_proto.resetLocalTransform=function resetLocalTransform(){runtime.sceneGraphService.resetLocalTransform(this);}// #endregion transformable
|
|
8392
|
-
// #region animatable
|
|
8393
|
-
/**
|
|
8394
|
-
* returns an array of all Animation objects affecting this element
|
|
8395
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
|
|
8396
|
-
*/;_proto.getAnimations=function getAnimations(){return this.activeAnimations;}/**
|
|
8397
|
-
* create an animation with WAAPI
|
|
8398
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
|
|
8399
|
-
*/;_proto.animate=function animate(keyframes,options){var _this$ownerDocument;var timeline=(_this$ownerDocument=this.ownerDocument)===null||_this$ownerDocument===void 0?void 0:_this$ownerDocument.timeline;if(timeline){return timeline.play(this,keyframes,options);}return null;}// #endregion animatable
|
|
8400
|
-
// #region visible
|
|
8401
|
-
/**
|
|
8402
|
-
* shortcut for Used value of `visibility`
|
|
8403
|
-
*/;_proto.isVisible=function isVisible(){var _this$parsedStyle;return ((_this$parsedStyle=this.parsedStyle)===null||_this$parsedStyle===void 0?void 0:_this$parsedStyle.visibility)==='visible';};_proto.isInteractive=function isInteractive(){var _this$parsedStyle2;return ((_this$parsedStyle2=this.parsedStyle)===null||_this$parsedStyle2===void 0?void 0:_this$parsedStyle2.pointerEvents)!=='none';};_proto.isCulled=function isCulled(){return !!(this.cullable&&this.cullable.enable&&!this.cullable.visible);}/**
|
|
8404
|
-
* bring to front in current group
|
|
8405
|
-
*/;_proto.toFront=function toFront(){if(this.parentNode){this.style.zIndex=Math.max.apply(Math,this.parentNode.children.map(function(child){return Number(child.style.zIndex);}))+1;}return this;}/**
|
|
8406
|
-
* send to back in current group
|
|
8407
|
-
*/;_proto.toBack=function toBack(){if(this.parentNode){this.style.zIndex=Math.min.apply(Math,this.parentNode.children.map(function(child){return Number(child.style.zIndex);}))-1;}return this;}// #endregion visible
|
|
8408
|
-
// #region deprecated
|
|
8409
|
-
/**
|
|
8410
|
-
* compatible with G 3.0
|
|
8411
|
-
* @alias object.config
|
|
8412
|
-
* @deprecated
|
|
8413
|
-
*/;_proto.getConfig=function getConfig(){return this.config;};_proto.attr=function attr(){var _this2=this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var name=args[0],value=args[1];if(!name){return this.attributes;}if(isObject(name)){Object.keys(name).forEach(function(key){_this2.setAttribute(key,name[key]);});return this;}if(args.length===2){this.setAttribute(name,value);return this;}return this.attributes[name];}/**
|
|
8414
|
-
* return 3x3 matrix in world space
|
|
8415
|
-
* @deprecated
|
|
8416
|
-
*/;_proto.getMatrix=function getMatrix(transformMat4){var transform=transformMat4||this.getWorldTransform();var _mat4$getTranslation=getTranslation(create$2(),transform),tx=_mat4$getTranslation[0],ty=_mat4$getTranslation[1];var _mat4$getScaling=getScaling(create$2(),transform),sx=_mat4$getScaling[0],sy=_mat4$getScaling[1];var rotation=getRotation(create$4(),transform);var _getEuler3=getEuler(create$2(),rotation),eux=_getEuler3[0],euz=_getEuler3[2];// gimbal lock at 90 degrees
|
|
8417
|
-
return fromRotationTranslationScale$1(eux||euz,tx,ty,sx,sy);}/**
|
|
8418
|
-
* return 3x3 matrix in local space
|
|
8419
|
-
* @deprecated
|
|
8420
|
-
*/;_proto.getLocalMatrix=function getLocalMatrix(){return this.getMatrix(this.getLocalTransform());}/**
|
|
8421
|
-
* set 3x3 matrix in world space
|
|
8422
|
-
* @deprecated
|
|
8423
|
-
*/;_proto.setMatrix=function setMatrix(mat){var _decompose=decompose(mat),tx=_decompose[0],ty=_decompose[1],scalingX=_decompose[2],scalingY=_decompose[3],angle=_decompose[4];this.setEulerAngles(angle).setPosition(tx,ty).setLocalScale(scalingX,scalingY);}/**
|
|
8424
|
-
* set 3x3 matrix in local space
|
|
8425
|
-
* @deprecated
|
|
8426
|
-
*/;_proto.setLocalMatrix=function setLocalMatrix(mat){var _decompose2=decompose(mat),tx=_decompose2[0],ty=_decompose2[1],scalingX=_decompose2[2],scalingY=_decompose2[3],angle=_decompose2[4];this.setLocalEulerAngles(angle).setLocalPosition(tx,ty).setLocalScale(scalingX,scalingY);}/**
|
|
8427
|
-
* Use `visibility: visible` instead.
|
|
8428
|
-
* @deprecated
|
|
8429
|
-
*/;_proto.show=function show(){this.style.visibility='visible';}/**
|
|
8430
|
-
* Use `visibility: hidden` instead.
|
|
8431
|
-
* @deprecated
|
|
8432
|
-
*/;_proto.hide=function hide(){this.style.visibility='hidden';}/**
|
|
8433
|
-
* Use `childElementCount` instead.
|
|
8434
|
-
* @deprecated
|
|
8435
|
-
*/;_proto.getCount=function getCount(){return this.childElementCount;}/**
|
|
8436
|
-
* Use `parentElement` instead.
|
|
8437
|
-
* @deprecated
|
|
8438
|
-
*/;_proto.getParent=function getParent(){return this.parentElement;}/**
|
|
8439
|
-
* Use `children` instead.
|
|
8440
|
-
* @deprecated
|
|
8441
|
-
*/;_proto.getChildren=function getChildren(){return this.children;}/**
|
|
8442
|
-
* Use `firstElementChild` instead.
|
|
8443
|
-
* @deprecated
|
|
8444
|
-
*/;_proto.getFirst=function getFirst(){return this.firstElementChild;}/**
|
|
8445
|
-
* Use `lastElementChild` instead.
|
|
8446
|
-
* @deprecated
|
|
8447
|
-
*/;_proto.getLast=function getLast(){return this.lastElementChild;}/**
|
|
8448
|
-
* Use `this.children[index]` instead.
|
|
8449
|
-
* @deprecated
|
|
8450
|
-
*/;_proto.getChildByIndex=function getChildByIndex(index){return this.children[index]||null;}/**
|
|
8451
|
-
* Use `appendChild` instead.
|
|
8452
|
-
* @deprecated
|
|
8453
|
-
*/;_proto.add=function add(child,index){return this.appendChild(child,index);}/**
|
|
8454
|
-
* Use `this.style.clipPath` instead.
|
|
8455
|
-
* @deprecated
|
|
8456
|
-
*/;_proto.setClip=function setClip(clipPath){this.style.clipPath=clipPath;}/**
|
|
8457
|
-
* Use `this.style.clipPath` instead.
|
|
8458
|
-
* @deprecated
|
|
8459
|
-
*/;/**
|
|
8460
|
-
* @deprecated
|
|
8461
|
-
*/_proto.set=function set(name,value){// @ts-ignore
|
|
8462
|
-
this.config[name]=value;}/**
|
|
8463
|
-
* @deprecated
|
|
8464
|
-
*/;_proto.get=function get(name){return this.config[name];}/**
|
|
8465
|
-
* Use `setPosition` instead.
|
|
8466
|
-
* @deprecated
|
|
8467
|
-
*/;_proto.moveTo=function moveTo(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
|
|
8468
|
-
* Use `setPosition` instead.
|
|
8469
|
-
* @deprecated
|
|
8470
|
-
*/;_proto.move=function move(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
|
|
8471
|
-
* Use `this.style.zIndex` instead.
|
|
8472
|
-
* @deprecated
|
|
8473
|
-
*/;_proto.setZIndex=function setZIndex(zIndex){this.style.zIndex=zIndex;return this;};_createClass(DisplayObject,[{key:"interactive",get:function get(){return this.isInteractive();},set:function set(b){this.style.pointerEvents=b?'auto':'none';}}]);return DisplayObject;}(Element);var _excluded=["style"];var Circle=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Circle,_DisplayObject);function Circle(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded);return _DisplayObject.call(this,_extends({type:exports.Shape.CIRCLE,style:_extends({cx:'',cy:'',r:''},style),initialParsedStyle:{anchor:[0.5,0.5]}},rest))||this;}return Circle;}(DisplayObject);var _excluded$1=["style"];/**
|
|
8474
|
-
* shadow root
|
|
8475
|
-
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
8476
|
-
*/var CustomElement=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(CustomElement,_DisplayObject);// static get observedAttributes(): string[] {
|
|
8477
|
-
// return [];
|
|
8478
|
-
// }
|
|
8479
|
-
// private shadowNodes: DisplayObject[] = [];
|
|
8480
|
-
function CustomElement(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$1);_this=_DisplayObject.call(this,_extends({style:_extends({x:'',y:''},style)},rest))||this;_this.isCustomElement=true;return _this;}return CustomElement;}(DisplayObject);var pool={};var htmlPool=[];var DisplayObjectPool=/*#__PURE__*/function(){function DisplayObjectPool(){}var _proto=DisplayObjectPool.prototype;_proto.getByEntity=function getByEntity(entity){return pool[entity];};_proto.getAll=function getAll(){return Object.keys(pool).map(function(entity){return pool[entity];});};_proto.add=function add(entity,groupOrShape){pool[entity]=groupOrShape;if(groupOrShape.nodeName===exports.Shape.HTML){htmlPool.push(groupOrShape);}};_proto.remove=function remove(entity){var existed=pool[entity];if(existed){delete pool[entity];if(existed.nodeName===exports.Shape.HTML){var index=htmlPool.indexOf(existed);htmlPool.splice(index,1);}}};_proto.getHTMLs=function getHTMLs(){return htmlPool;};return DisplayObjectPool;}();var _excluded$2=["style"];var Ellipse=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Ellipse,_DisplayObject);function Ellipse(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$2);return _DisplayObject.call(this,_extends({type:exports.Shape.ELLIPSE,style:_extends({cx:'',cy:'',rx:'',ry:''},style),initialParsedStyle:{anchor:[0.5,0.5]}},rest))||this;}return Ellipse;}(DisplayObject);var _excluded$3=["style"];/**
|
|
8481
|
-
* its attributes are inherited by its children.
|
|
8482
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
|
|
8483
|
-
*
|
|
8484
|
-
* @example
|
|
8485
|
-
* <g fill="white" stroke="green" stroke-width="5">
|
|
8486
|
-
<circle cx="40" cy="40" r="25" />
|
|
8487
|
-
<circle cx="60" cy="60" r="25" />
|
|
8488
|
-
</g>
|
|
8489
|
-
*/var Group=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Group,_DisplayObject);function Group(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$3);return _DisplayObject.call(this,_extends({type:exports.Shape.GROUP,style:_extends({x:'',y:'',width:'',height:''},style)},rest))||this;}return Group;}(DisplayObject);var _excluded$4=["style"];/**
|
|
8490
|
-
* HTML container
|
|
8491
|
-
* @see https://github.com/pmndrs/drei#html
|
|
8492
|
-
*/var HTML=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(HTML,_DisplayObject);function HTML(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$4);_this=_DisplayObject.call(this,_extends({type:exports.Shape.HTML,style:_extends({x:'',y:'',width:'auto',height:'auto',innerHTML:''},style)},rest))||this;_this.cullable.enable=false;return _this;}/**
|
|
8493
|
-
* return wrapper HTMLElement
|
|
8494
|
-
* * <div> in g-webgl/canvas
|
|
8495
|
-
* * <foreignObject> in g-svg
|
|
8496
|
-
*/var _proto=HTML.prototype;_proto.getDomElement=function getDomElement(){return this.parsedStyle.$el;}/**
|
|
8497
|
-
* override with $el.getBoundingClientRect
|
|
8498
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
|
|
8499
|
-
*/;_proto.getBoundingClientRect=function getBoundingClientRect(){return this.parsedStyle.$el.getBoundingClientRect();};_proto.getClientRects=function getClientRects(){return [this.getBoundingClientRect()];};_proto.getBounds=function getBounds(){var _this$ownerDocument,_this$ownerDocument$d;var clientRect=this.getBoundingClientRect();// calc context's offset
|
|
8500
|
-
// @ts-ignore
|
|
8501
|
-
var canvasRect=(_this$ownerDocument=this.ownerDocument)===null||_this$ownerDocument===void 0?void 0:(_this$ownerDocument$d=_this$ownerDocument.defaultView)===null||_this$ownerDocument$d===void 0?void 0:_this$ownerDocument$d.getContextService().getBoundingClientRect();if(canvasRect){var minX=clientRect.left-canvasRect.left;var minY=clientRect.top-canvasRect.top;var aabb=new AABB();aabb.setMinMax(fromValues$2(minX,minY,0),fromValues$2(minX+clientRect.width,minY+clientRect.height,0));return aabb;}return null;};_proto.getLocalBounds=function getLocalBounds(){if(this.parentNode){var parentInvert=invert(create$1(),this.parentNode.getWorldTransform());var bounds=this.getBounds();if(!AABB.isEmpty(bounds)){var localBounds=new AABB();localBounds.setFromTransformedAABB(bounds,parentInvert);return localBounds;}}return this.getBounds();};return HTML;}(DisplayObject);var _excluded$5=["style"];var Image=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Image,_DisplayObject);function Image(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$5);return _DisplayObject.call(this,_extends({type:exports.Shape.IMAGE,style:_extends({x:'',y:'',img:'',width:'',height:''},style)},rest))||this;}return Image;}(DisplayObject);var _excluded$6=["style"];/**
|
|
8502
|
-
* Create a line connecting two points.
|
|
8503
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line
|
|
8504
|
-
*
|
|
8505
|
-
* Also support for using marker.
|
|
8506
|
-
*/var Line=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Line,_DisplayObject);function Line(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$6);_this=_DisplayObject.call(this,_extends({type:exports.Shape.LINE,style:_extends({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0,isBillboard:false},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Line.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='x1'||attrName==='y1'||attrName==='x2'||attrName==='y2'||attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
|
|
8507
|
-
if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,x1=_this$parsedStyle2.x1,x2=_this$parsedStyle2.x2,y1=_this$parsedStyle2.y1,y2=_this$parsedStyle2.y2,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){ox=x1-defX;oy=y1-defY;x=x2-x1;y=y2-y1;offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {ox=x2-defX;oy=y2-defY;x=x1-x2;y=y1-y2;offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
|
|
8508
|
-
marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}// TODO: account for z1/z2 in 3D line
|
|
8509
|
-
var _this$parsedStyle3=this.parsedStyle,x1=_this$parsedStyle3.x1,y1=_this$parsedStyle3.y1,x2=_this$parsedStyle3.x2,y2=_this$parsedStyle3.y2,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;var _LineUtil$pointAt=line.pointAt(x1,y1,x2,y2,ratio),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
|
|
8510
|
-
return new Point(transformed[0],transformed[1]);};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getTotalLength=function getTotalLength(){// TODO: account for z1/z2 in 3D line
|
|
8511
|
-
var _this$parsedStyle4=this.parsedStyle,x1=_this$parsedStyle4.x1,y1=_this$parsedStyle4.y1,x2=_this$parsedStyle4.x2,y2=_this$parsedStyle4.y2;return line.length(x1,y1,x2,y2);};return Line;}(DisplayObject);var _excluded$7=["style"];var Path=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Path,_DisplayObject);/**
|
|
8512
|
-
* markers placed at the mid
|
|
8513
|
-
*/function Path(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$7);_this=_DisplayObject.call(this,_extends({type:exports.Shape.PATH,style:_extends({path:'',miterLimit:''},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Path.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='path'){// recalc markers
|
|
8514
|
-
this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
|
|
8515
|
-
if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){var _this$getStartTangent=this.getStartTangent(),p1=_this$getStartTangent[0],p2=_this$getStartTangent[1];ox=p2[0]-defX;oy=p2[1]-defY;x=p1[0]-p2[0];y=p1[1]-p2[1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var _this$getEndTangent=this.getEndTangent(),_p=_this$getEndTangent[0],_p2=_this$getEndTangent[1];ox=_p2[0]-defX;oy=_p2[1]-defY;x=_p[0]-_p2[0];y=_p[1]-_p2[1];offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
|
|
8516
|
-
marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,segments=_this$parsedStyle3.path.segments,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
|
|
8517
|
-
this.markerMidList.forEach(function(marker){marker.remove();});if(marker&&isDisplayObject(marker)){for(var i=1;i<segments.length-1;i++){var _segments$i$currentPo=segments[i].currentPoint,ox=_segments$i$currentPo[0],oy=_segments$i$currentPo[1];var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox-defX,oy-defY);// TODO: orient of marker
|
|
8518
|
-
}}}/**
|
|
8519
|
-
* Returns the total length of the path.
|
|
8520
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getTotalLength
|
|
8521
|
-
*/;_proto.getTotalLength=function getTotalLength(){return getOrCalculatePathTotalLength(this);}/**
|
|
8522
|
-
* Returns the point at a given distance along the path.
|
|
8523
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getPointAtLength
|
|
8524
|
-
*/;_proto.getPointAtLength=function getPointAtLength$1(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle4=this.parsedStyle,defX=_this$parsedStyle4.defX,defY=_this$parsedStyle4.defY,absolutePath=_this$parsedStyle4.path.absolutePath;var _getPointAtLength2=getPointAtLength(absolutePath,distance),x=_getPointAtLength2.x,y=_getPointAtLength2.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
|
|
8525
|
-
return new Point(transformed[0],transformed[1]);}/**
|
|
8526
|
-
* Returns the point at a given ratio of the total length in path.
|
|
8527
|
-
*/;_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPointAtLength(ratio*getOrCalculatePathTotalLength(this),inWorldSpace);}/**
|
|
8528
|
-
* Get start tangent vector
|
|
8529
|
-
*/;_proto.getStartTangent=function getStartTangent(){var segments=this.parsedStyle.path.segments;var result=[];if(segments.length>1){var startPoint=segments[0].currentPoint;var endPoint=segments[1].currentPoint;var tangent=segments[1].startTangent;result=[];if(tangent){result.push([startPoint[0]-tangent[0],startPoint[1]-tangent[1]]);result.push([startPoint[0],startPoint[1]]);}else {result.push([endPoint[0],endPoint[1]]);result.push([startPoint[0],startPoint[1]]);}}return result;}/**
|
|
8530
|
-
* Get end tangent vector
|
|
8531
|
-
*/;_proto.getEndTangent=function getEndTangent(){var segments=this.parsedStyle.path.segments;var length=segments.length;var result=[];if(length>1){var startPoint=segments[length-2].currentPoint;var endPoint=segments[length-1].currentPoint;var tangent=segments[length-1].endTangent;result=[];if(tangent){result.push([endPoint[0]-tangent[0],endPoint[1]-tangent[1]]);result.push([endPoint[0],endPoint[1]]);}else {result.push([startPoint[0],startPoint[1]]);result.push([endPoint[0],endPoint[1]]);}}return result;};return Path;}(DisplayObject);var _excluded$8=["style"];var Polygon=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Polygon,_DisplayObject);/**
|
|
8532
|
-
* markers placed at the mid
|
|
8533
|
-
*/function Polygon(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$8);_this=_DisplayObject.call(this,_extends({type:exports.Shape.POLYGON,style:_extends({points:'',miterLimit:'',isClosed:true},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Polygon.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='points'){// recalc markers
|
|
8534
|
-
this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
|
|
8535
|
-
if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,points=_this$parsedStyle2.points.points,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;ox=points[0][0]-defX;oy=points[0][1]-defY;if(isStart){x=points[1][0]-points[0][0];y=points[1][1]-points[0][1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var length=points.length;if(!this.style.isClosed){ox=points[length-1][0]-defX;oy=points[length-1][1]-defY;x=points[length-2][0]-points[length-1][0];y=points[length-2][1]-points[length-1][1];}else {x=points[length-1][0]-points[0][0];y=points[length-1][1]-points[0][1];}offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
|
|
8536
|
-
marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,points=_this$parsedStyle3.points.points,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
|
|
8537
|
-
this.markerMidList.forEach(function(marker){marker.remove();});this.markerMidList=[];if(marker&&isDisplayObject(marker)){for(var i=1;i<(this.style.isClosed?points.length:points.length-1);i++){var ox=points[i][0]-defX;var oy=points[i][1]-defY;var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox,oy);// TODO: orient of marker
|
|
8538
|
-
}}};return Polygon;}(DisplayObject);var _excluded$9=["style"];/**
|
|
8539
|
-
* Polyline inherits the marker-related capabilities of Polygon.
|
|
8540
|
-
*/var Polyline=/*#__PURE__*/function(_Polygon){_inheritsLoose(Polyline,_Polygon);function Polyline(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$9);return _Polygon.call(this,_extends({type:exports.Shape.POLYLINE,style:_extends({points:'',miterLimit:'',isClosed:false},style)},rest))||this;}var _proto=Polyline.prototype;_proto.getTotalLength=function getTotalLength(){return this.parsedStyle.points.totalLength;};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle=this.parsedStyle,defX=_this$parsedStyle.defX,defY=_this$parsedStyle.defY,_this$parsedStyle$poi=_this$parsedStyle.points,points=_this$parsedStyle$poi.points,segments=_this$parsedStyle$poi.segments;var subt=0;var index=0;segments.forEach(function(v,i){if(ratio>=v[0]&&ratio<=v[1]){subt=(ratio-v[0])/(v[1]-v[0]);index=i;}});var _LineUtil$pointAt=line.pointAt(points[index][0],points[index][1],points[index+1][0],points[index+1][1],subt),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
|
|
8541
|
-
return new Point(transformed[0],transformed[1]);};_proto.getStartTangent=function getStartTangent(){var points=this.parsedStyle.points.points;var result=[];result.push([points[1][0],points[1][1]]);result.push([points[0][0],points[0][1]]);return result;};_proto.getEndTangent=function getEndTangent(){var points=this.parsedStyle.points.points;var l=points.length-1;var result=[];result.push([points[l-1][0],points[l-1][1]]);result.push([points[l][0],points[l][1]]);return result;};return Polyline;}(Polygon);var _excluded$a=["style"];var Rect=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Rect,_DisplayObject);function Rect(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$a);return _DisplayObject.call(this,_extends({type:exports.Shape.RECT,style:_extends({x:'',y:'',width:'',height:'',radius:''},style)},rest))||this;}return Rect;}(DisplayObject);var _excluded$b=["style"];/**
|
|
8542
|
-
* <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
|
|
8543
|
-
*/var Text=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Text,_DisplayObject);/**
|
|
8544
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
|
|
8545
|
-
*/ // LENGTHADJUST_SPACING: number = 1;
|
|
8546
|
-
// LENGTHADJUST_SPACINGANDGLYPHS: number = 2;
|
|
8547
|
-
// LENGTHADJUST_UNKNOWN: number = 0;
|
|
8548
|
-
function Text(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$b);return _DisplayObject.call(this,_extends({type:exports.Shape.TEXT,style:_extends({x:'',y:'',text:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',fill:'black',letterSpacing:'',lineHeight:'',miterLimit:'',// whiteSpace: 'pre',
|
|
8549
|
-
wordWrap:false,wordWrapWidth:0,leading:0,dx:'',dy:''},style)},rest))||this;}// lengthAdjust: SVGAnimatedEnumeration;
|
|
8550
|
-
// textLength: SVGAnimatedLength;
|
|
8551
|
-
// getCharNumAtPosition(point?: DOMPointInit): number {
|
|
8552
|
-
// throw new Error('Method not implemented.');
|
|
8553
|
-
// }
|
|
8486
|
+
runtime.displayObjectPool.add(_this.entity,_assertThisInitialized(_this));return _this;}var _proto=DisplayObject.prototype;_proto.destroy=function destroy(){_Element.prototype.destroy.call(this);// remove from pool
|
|
8487
|
+
runtime.displayObjectPool.remove(this.entity);// stop all active animations
|
|
8488
|
+
this.getAnimations().forEach(function(animation){animation.cancel();});// FIXME
|
|
8489
|
+
// this.renderable = null;
|
|
8490
|
+
// this.cullable = null;
|
|
8491
|
+
// this.transformable = null;
|
|
8492
|
+
// this.rBushNode = null;
|
|
8493
|
+
// this.geometry = null;
|
|
8494
|
+
// this.sortable = null;
|
|
8495
|
+
};_proto.cloneNode=function cloneNode(deep,customCloneFunc){var clonedStyle=_extends({},this.attributes);for(var attributeName in clonedStyle){var attribute=clonedStyle[attributeName];// @see https://github.com/antvis/G/issues/1095
|
|
8496
|
+
if(isDisplayObject(attribute)&&// share the same clipPath if possible
|
|
8497
|
+
attributeName!=='clipPath'&&attributeName!=='offsetPath'&&attributeName!=='textPath'){clonedStyle[attributeName]=attribute.cloneNode(deep);}// TODO: clone other type
|
|
8498
|
+
if(customCloneFunc){clonedStyle[attributeName]=customCloneFunc(attributeName,attribute);}}var cloned=new this.constructor({// copy id & name
|
|
8499
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
|
|
8500
|
+
id:this.id,name:this.name,className:this.name,interactive:this.interactive,style:clonedStyle});// apply transform
|
|
8501
|
+
cloned.setLocalTransform(this.getLocalTransform());if(deep){this.children.forEach(function(child){// skip marker
|
|
8502
|
+
if(!child.style.isMarker){var clonedChild=child.cloneNode(deep);cloned.appendChild(clonedChild);}});}return cloned;};_proto.initAttributes=function initAttributes(attributes){if(attributes===void 0){attributes={};}var renderable=this.renderable;var options={forceUpdateGeometry:true// usedAttributes:
|
|
8503
|
+
// // only Group / Text should account for text relative props
|
|
8504
|
+
// this.tagName === Shape.GROUP || this.tagName === Shape.TEXT
|
|
8505
|
+
// ? INHERITABLE_STYLE_PROPS
|
|
8506
|
+
// : INHERITABLE_BASE_STYLE_PROPS,
|
|
8507
|
+
};if(runtime.enableCSSParsing){// @ts-ignore
|
|
8508
|
+
options.usedAttributes=INHERITABLE_STYLE_PROPS;}// account for FCP, process properties as less as possible
|
|
8509
|
+
runtime.styleValueRegistry.processProperties(this,attributes,options);// redraw at next frame
|
|
8510
|
+
renderable.dirty=true;};_proto.setAttribute=function setAttribute(name,value,force){if(force===void 0){force=false;}var attributeName=formatAttributeName(name);// ignore undefined value
|
|
8511
|
+
if(isUndefined(value)){return;}if(force||value!==this.attributes[attributeName]){this.internalSetAttribute(attributeName,value);_Element.prototype.setAttribute.call(this,attributeName,value);}}/**
|
|
8512
|
+
* called when attributes get changed or initialized
|
|
8513
|
+
*/;_proto.internalSetAttribute=function internalSetAttribute(name,value,parseOptions){var _runtime$styleValueRe;if(parseOptions===void 0){parseOptions={};}var renderable=this.renderable;var oldValue=this.attributes[name];var oldParsedValue=this.parsedStyle[name];runtime.styleValueRegistry.processProperties(this,(_runtime$styleValueRe={},_runtime$styleValueRe[name]=value,_runtime$styleValueRe),parseOptions);// redraw at next frame
|
|
8514
|
+
renderable.dirty=true;var newParsedValue=this.parsedStyle[name];if(this.isConnected){mutationEvent.relatedNode=this;mutationEvent.prevValue=oldValue;mutationEvent.newValue=value;mutationEvent.attrName=name;mutationEvent.prevParsedValue=oldParsedValue;mutationEvent.newParsedValue=newParsedValue;if(this.isMutationObserved){this.dispatchEvent(mutationEvent);}else {mutationEvent.target=this;this.ownerDocument.defaultView.dispatchEvent(mutationEvent,true);}}if((this.isCustomElement&&this.isConnected||!this.isCustomElement)&&this.attributeChangedCallback){this.attributeChangedCallback(name,oldValue,value,oldParsedValue,newParsedValue);}}// #region transformable
|
|
8554
8515
|
/**
|
|
8555
|
-
*
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
* @see https://
|
|
8674
|
-
*/var
|
|
8675
|
-
|
|
8676
|
-
if(p0.x===p1.x&&p0.y===p1.y){return {x:p0.x,y:p0.y,ellipticalArcAngle:0};// Check if angle is correct
|
|
8677
|
-
}// If rx = 0 or ry = 0 then this arc is treated as a straight line segment joining the endpoints.
|
|
8678
|
-
if(rx===0||ry===0){//return this.pointOnLine(p0, p1, t);
|
|
8679
|
-
return {x:0,y:0,ellipticalArcAngle:0};// Check if angle is correct
|
|
8680
|
-
}// Following "Conversion from endpoint to center parameterization"
|
|
8681
|
-
// http://www.w3.org/TR/SVG/implnote.html#ArcConversionEndpointToCenter
|
|
8682
|
-
// Step #1: Compute transformedPoint
|
|
8683
|
-
var dx=(p0.x-p1.x)/2;var dy=(p0.y-p1.y)/2;var transformedPoint={x:Math.cos(xAxisRotationRadians)*dx+Math.sin(xAxisRotationRadians)*dy,y:-Math.sin(xAxisRotationRadians)*dx+Math.cos(xAxisRotationRadians)*dy};// Ensure radii are large enough
|
|
8684
|
-
var radiiCheck=Math.pow(transformedPoint.x,2)/Math.pow(rx,2)+Math.pow(transformedPoint.y,2)/Math.pow(ry,2);if(radiiCheck>1){rx=Math.sqrt(radiiCheck)*rx;ry=Math.sqrt(radiiCheck)*ry;}// Step #2: Compute transformedCenter
|
|
8685
|
-
var cSquareNumerator=Math.pow(rx,2)*Math.pow(ry,2)-Math.pow(rx,2)*Math.pow(transformedPoint.y,2)-Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cSquareRootDenom=Math.pow(rx,2)*Math.pow(transformedPoint.y,2)+Math.pow(ry,2)*Math.pow(transformedPoint.x,2);var cRadicand=cSquareNumerator/cSquareRootDenom;// Make sure this never drops below zero because of precision
|
|
8686
|
-
cRadicand=cRadicand<0?0:cRadicand;var cCoef=(largeArcFlag!==sweepFlag?1:-1)*Math.sqrt(cRadicand);var transformedCenter={x:cCoef*(rx*transformedPoint.y/ry),y:cCoef*(-(ry*transformedPoint.x)/rx)};// Step #3: Compute center
|
|
8687
|
-
var center={x:Math.cos(xAxisRotationRadians)*transformedCenter.x-Math.sin(xAxisRotationRadians)*transformedCenter.y+(p0.x+p1.x)/2,y:Math.sin(xAxisRotationRadians)*transformedCenter.x+Math.cos(xAxisRotationRadians)*transformedCenter.y+(p0.y+p1.y)/2};// Step #4: Compute start/sweep angles
|
|
8688
|
-
// Start angle of the elliptical arc prior to the stretch and rotate operations.
|
|
8689
|
-
// Difference between the start and end angles
|
|
8690
|
-
var startVector={x:(transformedPoint.x-transformedCenter.x)/rx,y:(transformedPoint.y-transformedCenter.y)/ry};var startAngle=angleBetween$1({x:1,y:0},startVector);var endVector={x:(-transformedPoint.x-transformedCenter.x)/rx,y:(-transformedPoint.y-transformedCenter.y)/ry};var sweepAngle=angleBetween$1(startVector,endVector);if(!sweepFlag&&sweepAngle>0){sweepAngle-=2*Math.PI;}else if(sweepFlag&&sweepAngle<0){sweepAngle+=2*Math.PI;}// We use % instead of `mod(..)` because we want it to be -360deg to 360deg(but actually in radians)
|
|
8691
|
-
sweepAngle%=2*Math.PI;// From http://www.w3.org/TR/SVG/implnote.html#ArcParameterizationAlternatives
|
|
8692
|
-
var angle=startAngle+sweepAngle*t;var ellipseComponentX=rx*Math.cos(angle);var ellipseComponentY=ry*Math.sin(angle);var point={x:Math.cos(xAxisRotationRadians)*ellipseComponentX-Math.sin(xAxisRotationRadians)*ellipseComponentY+center.x,y:Math.sin(xAxisRotationRadians)*ellipseComponentX+Math.cos(xAxisRotationRadians)*ellipseComponentY+center.y,ellipticalArcStartAngle:startAngle,ellipticalArcEndAngle:startAngle+sweepAngle,ellipticalArcAngle:angle,ellipticalArcCenter:center,resultantRx:rx,resultantRy:ry};return point;};function path2Segments(path){var segments=[];var currentPoint=null;// 当前图形
|
|
8693
|
-
var nextParams=null;// 下一节点的 path 参数
|
|
8694
|
-
var startMovePoint=null;// 开始 M 的点,可能会有多个
|
|
8695
|
-
var lastStartMovePointIndex=0;// 最近一个开始点 M 的索引
|
|
8696
|
-
var count=path.length;for(var i=0;i<count;i++){var params=path[i];nextParams=path[i+1];var command=params[0];// 数学定义上的参数,便于后面的计算
|
|
8697
|
-
var segment={command:command,prePoint:currentPoint,params:params,startTangent:null,endTangent:null,currentPoint:null,nextPoint:null,arcParams:null,box:null,cubicParams:null};switch(command){case'M':startMovePoint=[params[1],params[2]];lastStartMovePointIndex=i;break;case'A':var arcParams=getArcParams(currentPoint,params);segment.arcParams=arcParams;break;}if(command==='Z'){// 有了 Z 后,当前节点从开始 M 的点开始
|
|
8698
|
-
currentPoint=startMovePoint;// 如果当前点的命令为 Z,相当于当前点为最近一个 M 点,则下一个点直接指向最近一个 M 点的下一个点
|
|
8699
|
-
nextParams=path[lastStartMovePointIndex+1];}else {var len=params.length;currentPoint=[params[len-2],params[len-1]];}if(nextParams&&nextParams[0]==='Z'){// 如果下一个点的命令为 Z,则下一个点直接指向最近一个 M 点
|
|
8700
|
-
nextParams=path[lastStartMovePointIndex];if(segments[lastStartMovePointIndex]){// 如果下一个点的命令为 Z,则最近一个 M 点的前一个点为当前点
|
|
8701
|
-
segments[lastStartMovePointIndex].prePoint=currentPoint;}}segment.currentPoint=currentPoint;// 如果当前点与最近一个 M 点相同,则最近一个 M 点的前一个点为当前点的前一个点
|
|
8702
|
-
if(segments[lastStartMovePointIndex]&&isSamePoint(currentPoint,segments[lastStartMovePointIndex].currentPoint)){segments[lastStartMovePointIndex].prePoint=segment.prePoint;}var nextPoint=nextParams?[nextParams[nextParams.length-2],nextParams[nextParams.length-1]]:null;segment.nextPoint=nextPoint;// Add startTangent and endTangent
|
|
8703
|
-
var prePoint=segment.prePoint;if(['L','H','V'].includes(command)){segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}else if(command==='Q'){// 二次贝塞尔曲线只有一个控制点
|
|
8704
|
-
var cp=[params[1],params[2]];// 二次贝塞尔曲线的终点为 currentPoint
|
|
8705
|
-
segment.startTangent=[prePoint[0]-cp[0],prePoint[1]-cp[1]];segment.endTangent=[currentPoint[0]-cp[0],currentPoint[1]-cp[1]];}else if(command==='T'){var preSegment=segments[i-1];var _cp=toSymmetry(preSegment.currentPoint,prePoint);if(preSegment.command==='Q'){segment.command='Q';segment.startTangent=[prePoint[0]-_cp[0],prePoint[1]-_cp[1]];segment.endTangent=[currentPoint[0]-_cp[0],currentPoint[1]-_cp[1]];}else {// @ts-ignore
|
|
8706
|
-
segment.command='TL';segment.startTangent=[prePoint[0]-currentPoint[0],prePoint[1]-currentPoint[1]];segment.endTangent=[currentPoint[0]-prePoint[0],currentPoint[1]-prePoint[1]];}}else if(command==='C'){// 三次贝塞尔曲线有两个控制点
|
|
8707
|
-
var cp1=[params[1],params[2]];var cp2=[params[3],params[4]];segment.startTangent=[prePoint[0]-cp1[0],prePoint[1]-cp1[1]];segment.endTangent=[currentPoint[0]-cp2[0],currentPoint[1]-cp2[1]];// horizontal line, eg. ['C', 100, 100, 100, 100, 200, 200]
|
|
8708
|
-
if(segment.startTangent[0]===0&&segment.startTangent[1]===0){segment.startTangent=[cp1[0]-cp2[0],cp1[1]-cp2[1]];}if(segment.endTangent[0]===0&&segment.endTangent[1]===0){segment.endTangent=[cp2[0]-cp1[0],cp2[1]-cp1[1]];}}else if(command==='S'){var _preSegment=segments[i-1];var _cp2=toSymmetry(_preSegment.currentPoint,prePoint);var _cp3=[params[1],params[2]];if(_preSegment.command==='C'){segment.command='C';// 将 S 命令变换为 C 命令
|
|
8709
|
-
segment.startTangent=[prePoint[0]-_cp2[0],prePoint[1]-_cp2[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}else {// @ts-ignore
|
|
8710
|
-
segment.command='SQ';// 将 S 命令变换为 SQ 命令
|
|
8711
|
-
segment.startTangent=[prePoint[0]-_cp3[0],prePoint[1]-_cp3[1]];segment.endTangent=[currentPoint[0]-_cp3[0],currentPoint[1]-_cp3[1]];}}else if(command==='A'){var _getTangentAtRatio=getTangentAtRatio(segment,0),dx1=_getTangentAtRatio.x,dy1=_getTangentAtRatio.y;var _getTangentAtRatio2=getTangentAtRatio(segment,1,false),dx2=_getTangentAtRatio2.x,dy2=_getTangentAtRatio2.y;segment.startTangent=[dx1,dy1];segment.endTangent=[dx2,dy2];}segments.push(segment);}return segments;}/**
|
|
8712
|
-
* Use length instead of ratio
|
|
8713
|
-
*/function getTangentAtRatio(segment,ratio,sign){if(sign===void 0){sign=true;}var _segment$arcParams=segment.arcParams,_segment$arcParams$rx=_segment$arcParams.rx,rx=_segment$arcParams$rx===void 0?0:_segment$arcParams$rx,_segment$arcParams$ry=_segment$arcParams.ry,ry=_segment$arcParams$ry===void 0?0:_segment$arcParams$ry,xRotation=_segment$arcParams.xRotation,arcFlag=_segment$arcParams.arcFlag,sweepFlag=_segment$arcParams.sweepFlag;var p1=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},ratio);var p2=pointOnEllipticalArc({x:segment.prePoint[0],y:segment.prePoint[1]},rx,ry,xRotation,!!arcFlag,!!sweepFlag,{x:segment.currentPoint[0],y:segment.currentPoint[1]},sign?ratio+0.005:ratio-0.005);var xDist=p2.x-p1.x;var yDist=p2.y-p1.y;var dist=Math.sqrt(xDist*xDist+yDist*yDist);return {x:-xDist/dist,y:-yDist/dist};}// 向量长度
|
|
8714
|
-
function vMag(v){return Math.sqrt(v[0]*v[0]+v[1]*v[1]);}// u.v/|u||v|,计算夹角的余弦值
|
|
8715
|
-
function vRatio(u,v){// 当存在一个向量的长度为 0 时,夹角也为 0,即夹角的余弦值为 1
|
|
8716
|
-
return vMag(u)*vMag(v)?(u[0]*v[0]+u[1]*v[1])/(vMag(u)*vMag(v)):1;}// 向量角度
|
|
8717
|
-
function vAngle(u,v){return (u[0]*v[1]<u[1]*v[0]?-1:1)*Math.acos(vRatio(u,v));}function getArcParams(startPoint,params){var rx=params[1];var ry=params[2];var xRotation=mod(deg2rad(params[3]),Math.PI*2);var arcFlag=params[4];var sweepFlag=params[5];// 弧形起点坐标
|
|
8718
|
-
var x1=startPoint[0];var y1=startPoint[1];// 弧形终点坐标
|
|
8719
|
-
var x2=params[6];var y2=params[7];var xp=Math.cos(xRotation)*(x1-x2)/2.0+Math.sin(xRotation)*(y1-y2)/2.0;var yp=-1*Math.sin(xRotation)*(x1-x2)/2.0+Math.cos(xRotation)*(y1-y2)/2.0;var lambda=xp*xp/(rx*rx)+yp*yp/(ry*ry);if(lambda>1){rx*=Math.sqrt(lambda);ry*=Math.sqrt(lambda);}var diff=rx*rx*(yp*yp)+ry*ry*(xp*xp);var f=diff?Math.sqrt((rx*rx*(ry*ry)-diff)/diff):1;if(arcFlag===sweepFlag){f*=-1;}if(isNaN(f)){f=0;}// 旋转前的起点坐标,且当长半轴和短半轴的长度为 0 时,坐标按 (0, 0) 处理
|
|
8720
|
-
var cxp=ry?f*rx*yp/ry:0;var cyp=rx?f*-ry*xp/rx:0;// 椭圆圆心坐标
|
|
8721
|
-
var cx=(x1+x2)/2.0+Math.cos(xRotation)*cxp-Math.sin(xRotation)*cyp;var cy=(y1+y2)/2.0+Math.sin(xRotation)*cxp+Math.cos(xRotation)*cyp;// 起始点的单位向量
|
|
8722
|
-
var u=[(xp-cxp)/rx,(yp-cyp)/ry];// 终止点的单位向量
|
|
8723
|
-
var v=[(-1*xp-cxp)/rx,(-1*yp-cyp)/ry];// 计算起始点和圆心的连线,与 x 轴正方向的夹角
|
|
8724
|
-
var theta=vAngle([1,0],u);// 计算圆弧起始点和终止点与椭圆圆心连线的夹角
|
|
8725
|
-
var dTheta=vAngle(u,v);if(vRatio(u,v)<=-1){dTheta=Math.PI;}if(vRatio(u,v)>=1){dTheta=0;}if(sweepFlag===0&&dTheta>0){dTheta=dTheta-2*Math.PI;}if(sweepFlag===1&&dTheta<0){dTheta=dTheta+2*Math.PI;}return {cx:cx,cy:cy,// 弧形的起点和终点相同时,长轴和短轴的长度按 0 处理
|
|
8726
|
-
rx:isSamePoint(startPoint,[x2,y2])?0:rx,ry:isSamePoint(startPoint,[x2,y2])?0:ry,startAngle:theta,endAngle:theta+dTheta,xRotation:xRotation,arcFlag:arcFlag,sweepFlag:sweepFlag};}function commandsToPathString(commands,object,transform){var _object$parsedStyle=object.parsedStyle,_object$parsedStyle$d=_object$parsedStyle.defX,defX=_object$parsedStyle$d===void 0?0:_object$parsedStyle$d,_object$parsedStyle$d2=_object$parsedStyle.defY,defY=_object$parsedStyle$d2===void 0?0:_object$parsedStyle$d2;return commands.reduce(function(prev,cur){var path='';if(cur[0]==='M'||cur[0]==='L'){var p=fromValues$2(cur[1]-defX,cur[2]-defY,0);if(transform){transformMat4(p,p,transform);}path=""+cur[0]+p[0]+","+p[1];}else if(cur[0]==='Z'){path=cur[0];}else if(cur[0]==='C'){var p1=fromValues$2(cur[1]-defX,cur[2]-defY,0);var p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);var p3=fromValues$2(cur[5]-defX,cur[6]-defY,0);if(transform){transformMat4(p1,p1,transform);transformMat4(p2,p2,transform);transformMat4(p3,p3,transform);}path=""+cur[0]+p1[0]+","+p1[1]+","+p2[0]+","+p2[1]+","+p3[0]+","+p3[1];}else if(cur[0]==='A'){var c=fromValues$2(cur[6]-defX,cur[7]-defY,0);if(transform){transformMat4(c,c,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+","+cur[5]+","+c[0]+","+c[1];}else if(cur[0]==='Q'){var _p=fromValues$2(cur[1]-defX,cur[2]-defY,0);var _p2=fromValues$2(cur[3]-defX,cur[4]-defY,0);if(transform){transformMat4(_p,_p,transform);transformMat4(_p2,_p2,transform);}path=""+cur[0]+cur[1]+","+cur[2]+","+cur[3]+","+cur[4]+"}";}return prev+=path;},'');}function lineToCommands(x1,y1,x2,y2){return [['M',x1,y1],['L',x2,y2]];}function ellipseToCommands(rx,ry,cx,cy){var factor=(-1+Math.sqrt(2))/3*4;var dx=rx*factor;var dy=ry*factor;var left=cx-rx;var right=cx+rx;var top=cy-ry;var bottom=cy+ry;return [['M',left,cy],['C',left,cy-dy,cx-dx,top,cx,top],['C',cx+dx,top,right,cy-dy,right,cy],['C',right,cy+dy,cx+dx,bottom,cx,bottom],['C',cx-dx,bottom,left,cy+dy,left,cy],['Z']];}function polygonToCommands(points,closed){var result=points.map(function(point,i){return [i===0?'M':'L',point[0],point[1]];});if(closed){result.push(['Z']);}return result;}function rectToCommands(width,height,x,y,radius){// @see https://gist.github.com/danielpquinn/dd966af424030d47e476
|
|
8727
|
-
if(radius){var tlr=radius[0],trr=radius[1],brr=radius[2],blr=radius[3];var signX=width>0?1:-1;var signY=height>0?1:-1;// sweep-flag @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Tutorial/Paths#arcs
|
|
8728
|
-
var sweepFlag=signX+signY!==0?1:0;return [['M',signX*tlr+x,y],['L',width-signX*trr+x,y],trr?['A',trr,trr,0,0,sweepFlag,width+x,signY*trr+y]:null,['L',width+x,height-signY*brr+y],brr?['A',brr,brr,0,0,sweepFlag,width+x-signX*brr,height+y]:null,['L',x+signX*blr,height+y],blr?['A',blr,blr,0,0,sweepFlag,x,height+y-signY*blr]:null,['L',x,signY*tlr+y],tlr?['A',tlr,tlr,0,0,sweepFlag,signX*tlr+x,y]:null,['Z']].filter(function(command){return command;});}return [['M',x,y],['L',x+width,y],['L',x+width,y+height],['L',x,y+height],['Z']];}/**
|
|
8729
|
-
* convert object to path, should account for:
|
|
8730
|
-
* * transform & origin
|
|
8731
|
-
* * anchor
|
|
8732
|
-
* * lineWidth
|
|
8733
|
-
*/function convertToPath(object,transform){if(transform===void 0){transform=object.getLocalTransform();}var commands=[];switch(object.nodeName){case exports.Shape.LINE:var _object$parsedStyle2=object.parsedStyle,x1=_object$parsedStyle2.x1,y1=_object$parsedStyle2.y1,x2=_object$parsedStyle2.x2,y2=_object$parsedStyle2.y2;commands=lineToCommands(x1,y1,x2,y2);break;case exports.Shape.CIRCLE:{var _object$parsedStyle3=object.parsedStyle,r=_object$parsedStyle3.r,cx=_object$parsedStyle3.cx,cy=_object$parsedStyle3.cy;commands=ellipseToCommands(r,r,cx,cy);break;}case exports.Shape.ELLIPSE:{var _object$parsedStyle4=object.parsedStyle,rx=_object$parsedStyle4.rx,ry=_object$parsedStyle4.ry,_cx=_object$parsedStyle4.cx,_cy=_object$parsedStyle4.cy;commands=ellipseToCommands(rx,ry,_cx,_cy);break;}case exports.Shape.POLYLINE:case exports.Shape.POLYGON:var points=object.parsedStyle.points;commands=polygonToCommands(points.points,object.nodeName===exports.Shape.POLYGON);break;case exports.Shape.RECT:var _object$parsedStyle5=object.parsedStyle,width=_object$parsedStyle5.width,height=_object$parsedStyle5.height,x=_object$parsedStyle5.x,y=_object$parsedStyle5.y,radius=_object$parsedStyle5.radius;var hasRadius=radius&&radius.some(function(r){return r!==0;});commands=rectToCommands(width,height,x,y,hasRadius&&radius.map(function(r){return clamp(r,0,Math.min(Math.abs(width)/2,Math.abs(height)/2));}));break;case exports.Shape.PATH:var absolutePath=object.parsedStyle.path.absolutePath;commands=[].concat(absolutePath);break;}if(commands.length){return commandsToPathString(commands,object,transform);}}function translatePathToString(absolutePath,defX,defY,startOffsetX,startOffsetY,endOffsetX,endOffsetY){if(startOffsetX===void 0){startOffsetX=0;}if(startOffsetY===void 0){startOffsetY=0;}if(endOffsetX===void 0){endOffsetX=0;}if(endOffsetY===void 0){endOffsetY=0;}var newValue=absolutePath.map(function(params,i){var command=params[0];var nextSegment=absolutePath[i+1];var useStartOffset=i===0&&(startOffsetX!==0||startOffsetY!==0);var useEndOffset=(i===absolutePath.length-1||nextSegment&&(nextSegment[0]==='M'||nextSegment[0]==='Z'))&&endOffsetX!==0&&endOffsetY!==0;switch(command){case'M':// Use start marker offset
|
|
8734
|
-
if(useStartOffset){return "M "+(params[1]-defX+startOffsetX)+","+(params[2]-defY+startOffsetY)+" L "+(params[1]-defX)+","+(params[2]-defY);}else {return "M "+(params[1]-defX)+","+(params[2]-defY);}case'L':return "L "+(params[1]-defX+(useEndOffset?endOffsetX:0))+","+(params[2]-defY+(useEndOffset?endOffsetY:0));case'Q':return "Q "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+(useEndOffset?" L "+(params[3]-defX+endOffsetX)+","+(params[4]-defY+endOffsetY):'');case'C':return "C "+(params[1]-defX)+" "+(params[2]-defY)+","+(params[3]-defX)+" "+(params[4]-defY)+","+(params[5]-defX)+" "+(params[6]-defY)+(useEndOffset?" L "+(params[5]-defX+endOffsetX)+","+(params[6]-defY+endOffsetY):'');case'A':return "A "+params[1]+" "+params[2]+" "+params[3]+" "+params[4]+" "+params[5]+" "+(params[6]-defX)+" "+(params[7]-defY)+(useEndOffset?" L "+(params[6]-defX+endOffsetX)+","+(params[7]-defY+endOffsetY):'');case'Z':return 'Z';}}).join(' ');if(~newValue.indexOf('NaN')){return '';}return newValue;}function isFillOrStrokeAffected(pointerEvents,fill,stroke){// account for pointerEvents
|
|
8735
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
8736
|
-
var hasFill=false;var hasStroke=false;var isFillOtherThanNone=!!fill&&!fill.isNone;var isStrokeOtherThanNone=!!stroke&&!stroke.isNone;if(pointerEvents==='visiblepainted'||pointerEvents==='painted'||pointerEvents==='auto'){hasFill=isFillOtherThanNone;hasStroke=isStrokeOtherThanNone;}else if(pointerEvents==='visiblefill'||pointerEvents==='fill'){hasFill=true;}else if(pointerEvents==='visiblestroke'||pointerEvents==='stroke'){hasStroke=true;}else if(pointerEvents==='visible'||pointerEvents==='all'){// The values of the fill and stroke do not affect event processing.
|
|
8737
|
-
hasFill=true;hasStroke=true;}return [hasFill,hasStroke];}// @ts-nocheck
|
|
8738
|
-
// interface HookInterceptor<T, R, AdditionalOptions = UnsetAdditionalOptions> {
|
|
8739
|
-
// name?: string;
|
|
8740
|
-
// tap?: (tap: FullTap & IfSet<AdditionalOptions>) => void;
|
|
8741
|
-
// call?: (...args: any[]) => void;
|
|
8742
|
-
// loop?: (...args: any[]) => void;
|
|
8743
|
-
// error?: (err: Error) => void;
|
|
8744
|
-
// result?: (result: R) => void;
|
|
8745
|
-
// done?: () => void;
|
|
8746
|
-
// register?: (tap: FullTap & IfSet<AdditionalOptions>) => FullTap & IfSet<AdditionalOptions>;
|
|
8516
|
+
* returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
|
|
8517
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
|
|
8518
|
+
*
|
|
8519
|
+
* FIXME: It is worth noting that getBBox responds to original untransformed values of a drawn object.
|
|
8520
|
+
* @see https://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#getBBox
|
|
8521
|
+
*/;_proto.getBBox=function getBBox(){var aabb=this.getBounds();var _aabb$getMin=aabb.getMin(),left=_aabb$getMin[0],top=_aabb$getMin[1];var _aabb$getMax=aabb.getMax(),right=_aabb$getMax[0],bottom=_aabb$getMax[1];return new Rectangle(left,top,right-left,bottom-top);};_proto.setOrigin=function setOrigin(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.setOrigin(this,createVec3(position,y,z));return this;};_proto.getOrigin=function getOrigin(){return runtime.sceneGraphService.getOrigin(this);}/**
|
|
8522
|
+
* set position in world space
|
|
8523
|
+
*/;_proto.setPosition=function setPosition(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.setPosition(this,createVec3(position,y,z));return this;}/**
|
|
8524
|
+
* set position in local space
|
|
8525
|
+
*/;_proto.setLocalPosition=function setLocalPosition(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.setLocalPosition(this,createVec3(position,y,z));return this;}/**
|
|
8526
|
+
* translate in world space
|
|
8527
|
+
*/;_proto.translate=function translate(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.translate(this,createVec3(position,y,z));return this;}/**
|
|
8528
|
+
* translate in local space
|
|
8529
|
+
*/;_proto.translateLocal=function translateLocal(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}runtime.sceneGraphService.translateLocal(this,createVec3(position,y,z));return this;};_proto.getPosition=function getPosition(){return runtime.sceneGraphService.getPosition(this);};_proto.getLocalPosition=function getLocalPosition(){return runtime.sceneGraphService.getLocalPosition(this);}/**
|
|
8530
|
+
* compatible with G 3.0
|
|
8531
|
+
*
|
|
8532
|
+
* scaling in local space
|
|
8533
|
+
* scale(10) = scale(10, 10, 10)
|
|
8534
|
+
*
|
|
8535
|
+
* we can't set scale in world space
|
|
8536
|
+
*/;_proto.scale=function scale(scaling,y,z){return this.scaleLocal(scaling,y,z);};_proto.scaleLocal=function scaleLocal(scaling,y,z){if(typeof scaling==='number'){y=y||scaling;z=z||scaling;scaling=createVec3(scaling,y,z);}runtime.sceneGraphService.scaleLocal(this,scaling);return this;}/**
|
|
8537
|
+
* set scaling in local space
|
|
8538
|
+
*/;_proto.setLocalScale=function setLocalScale(scaling,y,z){if(typeof scaling==='number'){y=y||scaling;z=z||scaling;scaling=createVec3(scaling,y,z);}runtime.sceneGraphService.setLocalScale(this,scaling);return this;}/**
|
|
8539
|
+
* get scaling in local space
|
|
8540
|
+
*/;_proto.getLocalScale=function getLocalScale(){return runtime.sceneGraphService.getLocalScale(this);}/**
|
|
8541
|
+
* get scaling in world space
|
|
8542
|
+
*/;_proto.getScale=function getScale(){return runtime.sceneGraphService.getScale(this);}/**
|
|
8543
|
+
* only return degrees of Z axis in world space
|
|
8544
|
+
*/;_proto.getEulerAngles=function getEulerAngles(){var _getEuler=getEuler(create$2(),runtime.sceneGraphService.getWorldTransform(this)),ez=_getEuler[2];return rad2deg(ez);}/**
|
|
8545
|
+
* only return degrees of Z axis in local space
|
|
8546
|
+
*/;_proto.getLocalEulerAngles=function getLocalEulerAngles(){var _getEuler2=getEuler(create$2(),runtime.sceneGraphService.getLocalRotation(this)),ez=_getEuler2[2];return rad2deg(ez);}/**
|
|
8547
|
+
* set euler angles(degrees) in world space
|
|
8548
|
+
*/;_proto.setEulerAngles=function setEulerAngles(z){runtime.sceneGraphService.setEulerAngles(this,0,0,z);return this;}/**
|
|
8549
|
+
* set euler angles(degrees) in local space
|
|
8550
|
+
*/;_proto.setLocalEulerAngles=function setLocalEulerAngles(z){runtime.sceneGraphService.setLocalEulerAngles(this,0,0,z);return this;};_proto.rotateLocal=function rotateLocal(x,y,z){if(isNil(y)&&isNil(z)){runtime.sceneGraphService.rotateLocal(this,0,0,x);}else {runtime.sceneGraphService.rotateLocal(this,x,y,z);}return this;};_proto.rotate=function rotate(x,y,z){if(isNil(y)&&isNil(z)){runtime.sceneGraphService.rotate(this,0,0,x);}else {runtime.sceneGraphService.rotate(this,x,y,z);}return this;};_proto.setRotation=function setRotation(rotation,y,z,w){runtime.sceneGraphService.setRotation(this,rotation,y,z,w);return this;};_proto.setLocalRotation=function setLocalRotation(rotation,y,z,w){runtime.sceneGraphService.setLocalRotation(this,rotation,y,z,w);return this;};_proto.setLocalSkew=function setLocalSkew(skew,y){runtime.sceneGraphService.setLocalSkew(this,skew,y);return this;};_proto.getRotation=function getRotation(){return runtime.sceneGraphService.getRotation(this);};_proto.getLocalRotation=function getLocalRotation(){return runtime.sceneGraphService.getLocalRotation(this);};_proto.getLocalSkew=function getLocalSkew(){return runtime.sceneGraphService.getLocalSkew(this);};_proto.getLocalTransform=function getLocalTransform(){return runtime.sceneGraphService.getLocalTransform(this);};_proto.getWorldTransform=function getWorldTransform(){return runtime.sceneGraphService.getWorldTransform(this);};_proto.setLocalTransform=function setLocalTransform(transform){runtime.sceneGraphService.setLocalTransform(this,transform);return this;};_proto.resetLocalTransform=function resetLocalTransform(){runtime.sceneGraphService.resetLocalTransform(this);}// #endregion transformable
|
|
8551
|
+
// #region animatable
|
|
8552
|
+
/**
|
|
8553
|
+
* returns an array of all Animation objects affecting this element
|
|
8554
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
|
|
8555
|
+
*/;_proto.getAnimations=function getAnimations(){return this.activeAnimations;}/**
|
|
8556
|
+
* create an animation with WAAPI
|
|
8557
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
|
|
8558
|
+
*/;_proto.animate=function animate(keyframes,options){var _this$ownerDocument;var timeline=(_this$ownerDocument=this.ownerDocument)===null||_this$ownerDocument===void 0?void 0:_this$ownerDocument.timeline;if(timeline){return timeline.play(this,keyframes,options);}return null;}// #endregion animatable
|
|
8559
|
+
// #region visible
|
|
8560
|
+
/**
|
|
8561
|
+
* shortcut for Used value of `visibility`
|
|
8562
|
+
*/;_proto.isVisible=function isVisible(){var _this$parsedStyle;return ((_this$parsedStyle=this.parsedStyle)===null||_this$parsedStyle===void 0?void 0:_this$parsedStyle.visibility)==='visible';};_proto.isInteractive=function isInteractive(){var _this$parsedStyle2;return ((_this$parsedStyle2=this.parsedStyle)===null||_this$parsedStyle2===void 0?void 0:_this$parsedStyle2.pointerEvents)!=='none';};_proto.isCulled=function isCulled(){return !!(this.cullable&&this.cullable.enable&&!this.cullable.visible);}/**
|
|
8563
|
+
* bring to front in current group
|
|
8564
|
+
*/;_proto.toFront=function toFront(){if(this.parentNode){this.style.zIndex=Math.max.apply(Math,this.parentNode.children.map(function(child){return Number(child.style.zIndex);}))+1;}return this;}/**
|
|
8565
|
+
* send to back in current group
|
|
8566
|
+
*/;_proto.toBack=function toBack(){if(this.parentNode){this.style.zIndex=Math.min.apply(Math,this.parentNode.children.map(function(child){return Number(child.style.zIndex);}))-1;}return this;}// #endregion visible
|
|
8567
|
+
// #region deprecated
|
|
8568
|
+
/**
|
|
8569
|
+
* compatible with G 3.0
|
|
8570
|
+
* @alias object.config
|
|
8571
|
+
* @deprecated
|
|
8572
|
+
*/;_proto.getConfig=function getConfig(){return this.config;};_proto.attr=function attr(){var _this2=this;for(var _len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key];}var name=args[0],value=args[1];if(!name){return this.attributes;}if(isObject(name)){Object.keys(name).forEach(function(key){_this2.setAttribute(key,name[key]);});return this;}if(args.length===2){this.setAttribute(name,value);return this;}return this.attributes[name];}/**
|
|
8573
|
+
* return 3x3 matrix in world space
|
|
8574
|
+
* @deprecated
|
|
8575
|
+
*/;_proto.getMatrix=function getMatrix(transformMat4){var transform=transformMat4||this.getWorldTransform();var _mat4$getTranslation=getTranslation(create$2(),transform),tx=_mat4$getTranslation[0],ty=_mat4$getTranslation[1];var _mat4$getScaling=getScaling(create$2(),transform),sx=_mat4$getScaling[0],sy=_mat4$getScaling[1];var rotation=getRotation(create$4(),transform);var _getEuler3=getEuler(create$2(),rotation),eux=_getEuler3[0],euz=_getEuler3[2];// gimbal lock at 90 degrees
|
|
8576
|
+
return fromRotationTranslationScale$1(eux||euz,tx,ty,sx,sy);}/**
|
|
8577
|
+
* return 3x3 matrix in local space
|
|
8578
|
+
* @deprecated
|
|
8579
|
+
*/;_proto.getLocalMatrix=function getLocalMatrix(){return this.getMatrix(this.getLocalTransform());}/**
|
|
8580
|
+
* set 3x3 matrix in world space
|
|
8581
|
+
* @deprecated
|
|
8582
|
+
*/;_proto.setMatrix=function setMatrix(mat){var _decompose=decompose(mat),tx=_decompose[0],ty=_decompose[1],scalingX=_decompose[2],scalingY=_decompose[3],angle=_decompose[4];this.setEulerAngles(angle).setPosition(tx,ty).setLocalScale(scalingX,scalingY);}/**
|
|
8583
|
+
* set 3x3 matrix in local space
|
|
8584
|
+
* @deprecated
|
|
8585
|
+
*/;_proto.setLocalMatrix=function setLocalMatrix(mat){var _decompose2=decompose(mat),tx=_decompose2[0],ty=_decompose2[1],scalingX=_decompose2[2],scalingY=_decompose2[3],angle=_decompose2[4];this.setLocalEulerAngles(angle).setLocalPosition(tx,ty).setLocalScale(scalingX,scalingY);}/**
|
|
8586
|
+
* Use `visibility: visible` instead.
|
|
8587
|
+
* @deprecated
|
|
8588
|
+
*/;_proto.show=function show(){this.style.visibility='visible';}/**
|
|
8589
|
+
* Use `visibility: hidden` instead.
|
|
8590
|
+
* @deprecated
|
|
8591
|
+
*/;_proto.hide=function hide(){this.style.visibility='hidden';}/**
|
|
8592
|
+
* Use `childElementCount` instead.
|
|
8593
|
+
* @deprecated
|
|
8594
|
+
*/;_proto.getCount=function getCount(){return this.childElementCount;}/**
|
|
8595
|
+
* Use `parentElement` instead.
|
|
8596
|
+
* @deprecated
|
|
8597
|
+
*/;_proto.getParent=function getParent(){return this.parentElement;}/**
|
|
8598
|
+
* Use `children` instead.
|
|
8599
|
+
* @deprecated
|
|
8600
|
+
*/;_proto.getChildren=function getChildren(){return this.children;}/**
|
|
8601
|
+
* Use `firstElementChild` instead.
|
|
8602
|
+
* @deprecated
|
|
8603
|
+
*/;_proto.getFirst=function getFirst(){return this.firstElementChild;}/**
|
|
8604
|
+
* Use `lastElementChild` instead.
|
|
8605
|
+
* @deprecated
|
|
8606
|
+
*/;_proto.getLast=function getLast(){return this.lastElementChild;}/**
|
|
8607
|
+
* Use `this.children[index]` instead.
|
|
8608
|
+
* @deprecated
|
|
8609
|
+
*/;_proto.getChildByIndex=function getChildByIndex(index){return this.children[index]||null;}/**
|
|
8610
|
+
* Use `appendChild` instead.
|
|
8611
|
+
* @deprecated
|
|
8612
|
+
*/;_proto.add=function add(child,index){return this.appendChild(child,index);}/**
|
|
8613
|
+
* Use `this.style.clipPath` instead.
|
|
8614
|
+
* @deprecated
|
|
8615
|
+
*/;_proto.setClip=function setClip(clipPath){this.style.clipPath=clipPath;}/**
|
|
8616
|
+
* Use `this.style.clipPath` instead.
|
|
8617
|
+
* @deprecated
|
|
8618
|
+
*/;/**
|
|
8619
|
+
* @deprecated
|
|
8620
|
+
*/_proto.set=function set(name,value){// @ts-ignore
|
|
8621
|
+
this.config[name]=value;}/**
|
|
8622
|
+
* @deprecated
|
|
8623
|
+
*/;_proto.get=function get(name){return this.config[name];}/**
|
|
8624
|
+
* Use `setPosition` instead.
|
|
8625
|
+
* @deprecated
|
|
8626
|
+
*/;_proto.moveTo=function moveTo(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
|
|
8627
|
+
* Use `setPosition` instead.
|
|
8628
|
+
* @deprecated
|
|
8629
|
+
*/;_proto.move=function move(position,y,z){if(y===void 0){y=0;}if(z===void 0){z=0;}this.setPosition(position,y,z);return this;}/**
|
|
8630
|
+
* Use `this.style.zIndex` instead.
|
|
8631
|
+
* @deprecated
|
|
8632
|
+
*/;_proto.setZIndex=function setZIndex(zIndex){this.style.zIndex=zIndex;return this;};_createClass(DisplayObject,[{key:"interactive",get:function get(){return this.isInteractive();},set:function set(b){this.style.pointerEvents=b?'auto':'none';}}]);return DisplayObject;}(Element);var _excluded=["style"];var Circle=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Circle,_DisplayObject);function Circle(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded);return _DisplayObject.call(this,_extends({type:exports.Shape.CIRCLE,style:_extends({cx:'',cy:'',r:''},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[getOrCreateUnitValue(50,'%'),getOrCreateUnitValue(50,'%')]}},rest))||this;}return Circle;}(DisplayObject);var _excluded$1=["style"];/**
|
|
8633
|
+
* shadow root
|
|
8634
|
+
* @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
|
|
8635
|
+
*/var CustomElement=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(CustomElement,_DisplayObject);// static get observedAttributes(): string[] {
|
|
8636
|
+
// return [];
|
|
8747
8637
|
// }
|
|
8748
|
-
//
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8638
|
+
// private shadowNodes: DisplayObject[] = [];
|
|
8639
|
+
function CustomElement(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$1);_this=_DisplayObject.call(this,_extends({style:_extends({x:'',y:''},style)},rest))||this;_this.isCustomElement=true;return _this;}return CustomElement;}(DisplayObject);var pool={};var htmlPool=[];var DisplayObjectPool=/*#__PURE__*/function(){function DisplayObjectPool(){}var _proto=DisplayObjectPool.prototype;_proto.getByEntity=function getByEntity(entity){return pool[entity];};_proto.getAll=function getAll(){return Object.keys(pool).map(function(entity){return pool[entity];});};_proto.add=function add(entity,groupOrShape){pool[entity]=groupOrShape;if(groupOrShape.nodeName===exports.Shape.HTML){htmlPool.push(groupOrShape);}};_proto.remove=function remove(entity){var existed=pool[entity];if(existed){delete pool[entity];if(existed.nodeName===exports.Shape.HTML){var index=htmlPool.indexOf(existed);htmlPool.splice(index,1);}}};_proto.getHTMLs=function getHTMLs(){return htmlPool;};return DisplayObjectPool;}();var _excluded$2=["style"];var Ellipse=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Ellipse,_DisplayObject);function Ellipse(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$2);return _DisplayObject.call(this,_extends({type:exports.Shape.ELLIPSE,style:_extends({cx:'',cy:'',rx:'',ry:''},style),initialParsedStyle:{anchor:[0.5,0.5],transformOrigin:runtime.enableCSSParsing?null:[getOrCreateUnitValue(50,'%'),getOrCreateUnitValue(50,'%')]}},rest))||this;}return Ellipse;}(DisplayObject);var _excluded$3=["style"];/**
|
|
8640
|
+
* its attributes are inherited by its children.
|
|
8641
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
|
|
8642
|
+
*
|
|
8643
|
+
* @example
|
|
8644
|
+
* <g fill="white" stroke="green" stroke-width="5">
|
|
8645
|
+
<circle cx="40" cy="40" r="25" />
|
|
8646
|
+
<circle cx="60" cy="60" r="25" />
|
|
8647
|
+
</g>
|
|
8648
|
+
*/var Group=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Group,_DisplayObject);function Group(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$3);return _DisplayObject.call(this,_extends({type:exports.Shape.GROUP,style:_extends({x:'',y:'',width:'',height:''},style)},rest))||this;}return Group;}(DisplayObject);var _excluded$4=["style"];/**
|
|
8649
|
+
* HTML container
|
|
8650
|
+
* @see https://github.com/pmndrs/drei#html
|
|
8651
|
+
*/var HTML=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(HTML,_DisplayObject);function HTML(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$4);_this=_DisplayObject.call(this,_extends({type:exports.Shape.HTML,style:_extends({x:'',y:'',width:'auto',height:'auto',innerHTML:''},style)},rest))||this;_this.cullable.enable=false;return _this;}/**
|
|
8652
|
+
* return wrapper HTMLElement
|
|
8653
|
+
* * <div> in g-webgl/canvas
|
|
8654
|
+
* * <foreignObject> in g-svg
|
|
8655
|
+
*/var _proto=HTML.prototype;_proto.getDomElement=function getDomElement(){return this.parsedStyle.$el;}/**
|
|
8656
|
+
* override with $el.getBoundingClientRect
|
|
8657
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
|
|
8658
|
+
*/;_proto.getBoundingClientRect=function getBoundingClientRect(){return this.parsedStyle.$el.getBoundingClientRect();};_proto.getClientRects=function getClientRects(){return [this.getBoundingClientRect()];};_proto.getBounds=function getBounds(){var _this$ownerDocument,_this$ownerDocument$d;var clientRect=this.getBoundingClientRect();// calc context's offset
|
|
8659
|
+
// @ts-ignore
|
|
8660
|
+
var canvasRect=(_this$ownerDocument=this.ownerDocument)===null||_this$ownerDocument===void 0?void 0:(_this$ownerDocument$d=_this$ownerDocument.defaultView)===null||_this$ownerDocument$d===void 0?void 0:_this$ownerDocument$d.getContextService().getBoundingClientRect();if(canvasRect){var minX=clientRect.left-canvasRect.left;var minY=clientRect.top-canvasRect.top;var aabb=new AABB();// aabb.setMinMax(
|
|
8661
|
+
// vec3.fromValues(minX, minY, 0),
|
|
8662
|
+
// vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0),
|
|
8663
|
+
// );
|
|
8664
|
+
aabb.setMinMax([minX,minY,0],[minX+clientRect.width,minY+clientRect.height,0]);return aabb;}return null;};_proto.getLocalBounds=function getLocalBounds(){if(this.parentNode){var parentInvert=invert(create$1(),this.parentNode.getWorldTransform());var bounds=this.getBounds();if(!AABB.isEmpty(bounds)){var localBounds=new AABB();localBounds.setFromTransformedAABB(bounds,parentInvert);return localBounds;}}return this.getBounds();};return HTML;}(DisplayObject);var _excluded$5=["style"];var Image=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Image,_DisplayObject);function Image(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$5);return _DisplayObject.call(this,_extends({type:exports.Shape.IMAGE,style:_extends({x:'',y:'',img:'',width:'',height:''},style)},rest))||this;}return Image;}(DisplayObject);var _excluded$6=["style"];/**
|
|
8665
|
+
* Create a line connecting two points.
|
|
8666
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/line
|
|
8667
|
+
*
|
|
8668
|
+
* Also support for using marker.
|
|
8669
|
+
*/var Line=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Line,_DisplayObject);function Line(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$6);_this=_DisplayObject.call(this,_extends({type:exports.Shape.LINE,style:_extends({x1:0,y1:0,x2:0,y2:0,z1:0,z2:0,isBillboard:false},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Line.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='x1'||attrName==='y1'||attrName==='x2'||attrName==='y2'||attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
|
|
8670
|
+
if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,x1=_this$parsedStyle2.x1,x2=_this$parsedStyle2.x2,y1=_this$parsedStyle2.y1,y2=_this$parsedStyle2.y2,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){ox=x1-defX;oy=y1-defY;x=x2-x1;y=y2-y1;offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {ox=x2-defX;oy=y2-defY;x=x1-x2;y=y1-y2;offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
|
|
8671
|
+
marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}// TODO: account for z1/z2 in 3D line
|
|
8672
|
+
var _this$parsedStyle3=this.parsedStyle,x1=_this$parsedStyle3.x1,y1=_this$parsedStyle3.y1,x2=_this$parsedStyle3.x2,y2=_this$parsedStyle3.y2,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;var _LineUtil$pointAt=line.pointAt(x1,y1,x2,y2,ratio),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
|
|
8673
|
+
return new Point(transformed[0],transformed[1]);};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getTotalLength=function getTotalLength(){// TODO: account for z1/z2 in 3D line
|
|
8674
|
+
var _this$parsedStyle4=this.parsedStyle,x1=_this$parsedStyle4.x1,y1=_this$parsedStyle4.y1,x2=_this$parsedStyle4.x2,y2=_this$parsedStyle4.y2;return line.length(x1,y1,x2,y2);};return Line;}(DisplayObject);var _excluded$7=["style"];var EMPTY_PARSED_PATH={absolutePath:[],hasArc:false,segments:[],polygons:[],polylines:[],curve:null,totalLength:0,rect:new Rectangle(0,0,0,0)};var Path=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Path,_DisplayObject);/**
|
|
8675
|
+
* markers placed at the mid
|
|
8676
|
+
*/function Path(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$7);_this=_DisplayObject.call(this,_extends({type:exports.Shape.PATH,style:_extends({path:'',miterLimit:''},style),initialParsedStyle:runtime.enableCSSParsing?null:{path:_extends({},EMPTY_PARSED_PATH)}},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Path.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='path'){// recalc markers
|
|
8677
|
+
this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
|
|
8678
|
+
if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;if(isStart){var _this$getStartTangent=this.getStartTangent(),p1=_this$getStartTangent[0],p2=_this$getStartTangent[1];ox=p2[0]-defX;oy=p2[1]-defY;x=p1[0]-p2[0];y=p1[1]-p2[1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var _this$getEndTangent=this.getEndTangent(),_p=_this$getEndTangent[0],_p2=_this$getEndTangent[1];ox=_p2[0]-defX;oy=_p2[1]-defY;x=_p[0]-_p2[0];y=_p[1]-_p2[1];offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
|
|
8679
|
+
marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,segments=_this$parsedStyle3.path.segments,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
|
|
8680
|
+
this.markerMidList.forEach(function(marker){marker.remove();});if(marker&&isDisplayObject(marker)){for(var i=1;i<segments.length-1;i++){var _segments$i$currentPo=segments[i].currentPoint,ox=_segments$i$currentPo[0],oy=_segments$i$currentPo[1];var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox-defX,oy-defY);// TODO: orient of marker
|
|
8681
|
+
}}}/**
|
|
8682
|
+
* Returns the total length of the path.
|
|
8683
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getTotalLength
|
|
8684
|
+
*/;_proto.getTotalLength=function getTotalLength(){return getOrCalculatePathTotalLength(this);}/**
|
|
8685
|
+
* Returns the point at a given distance along the path.
|
|
8686
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGeometryElement/getPointAtLength
|
|
8687
|
+
*/;_proto.getPointAtLength=function getPointAtLength$1(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle4=this.parsedStyle,defX=_this$parsedStyle4.defX,defY=_this$parsedStyle4.defY,absolutePath=_this$parsedStyle4.path.absolutePath;var _getPointAtLength2=getPointAtLength(absolutePath,distance),x=_getPointAtLength2.x,y=_getPointAtLength2.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
|
|
8688
|
+
return new Point(transformed[0],transformed[1]);}/**
|
|
8689
|
+
* Returns the point at a given ratio of the total length in path.
|
|
8690
|
+
*/;_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPointAtLength(ratio*getOrCalculatePathTotalLength(this),inWorldSpace);}/**
|
|
8691
|
+
* Get start tangent vector
|
|
8692
|
+
*/;_proto.getStartTangent=function getStartTangent(){var segments=this.parsedStyle.path.segments;var result=[];if(segments.length>1){var startPoint=segments[0].currentPoint;var endPoint=segments[1].currentPoint;var tangent=segments[1].startTangent;result=[];if(tangent){result.push([startPoint[0]-tangent[0],startPoint[1]-tangent[1]]);result.push([startPoint[0],startPoint[1]]);}else {result.push([endPoint[0],endPoint[1]]);result.push([startPoint[0],startPoint[1]]);}}return result;}/**
|
|
8693
|
+
* Get end tangent vector
|
|
8694
|
+
*/;_proto.getEndTangent=function getEndTangent(){var segments=this.parsedStyle.path.segments;var length=segments.length;var result=[];if(length>1){var startPoint=segments[length-2].currentPoint;var endPoint=segments[length-1].currentPoint;var tangent=segments[length-1].endTangent;result=[];if(tangent){result.push([endPoint[0]-tangent[0],endPoint[1]-tangent[1]]);result.push([endPoint[0],endPoint[1]]);}else {result.push([startPoint[0],startPoint[1]]);result.push([endPoint[0],endPoint[1]]);}}return result;};return Path;}(DisplayObject);var _excluded$8=["style"];var Polygon=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Polygon,_DisplayObject);/**
|
|
8695
|
+
* markers placed at the mid
|
|
8696
|
+
*/function Polygon(_temp){var _this;var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$8);_this=_DisplayObject.call(this,_extends({type:exports.Shape.POLYGON,style:_extends({points:'',miterLimit:'',isClosed:true},style)},rest))||this;_this.markerStartAngle=0;_this.markerEndAngle=0;_this.markerMidList=[];var _this$parsedStyle=_this.parsedStyle,markerStart=_this$parsedStyle.markerStart,markerEnd=_this$parsedStyle.markerEnd,markerMid=_this$parsedStyle.markerMid;if(markerStart&&isDisplayObject(markerStart)){_this.markerStartAngle=markerStart.getLocalEulerAngles();_this.appendChild(markerStart);}if(markerMid&&isDisplayObject(markerMid)){_this.placeMarkerMid(markerMid);}if(markerEnd&&isDisplayObject(markerEnd)){_this.markerEndAngle=markerEnd.getLocalEulerAngles();_this.appendChild(markerEnd);}_this.transformMarker(true);_this.transformMarker(false);return _this;}var _proto=Polygon.prototype;_proto.attributeChangedCallback=function attributeChangedCallback(attrName,oldValue,newValue,prevParsedValue,newParsedValue){if(attrName==='points'){// recalc markers
|
|
8697
|
+
this.transformMarker(true);this.transformMarker(false);this.placeMarkerMid(this.parsedStyle.markerMid);}else if(attrName==='markerStartOffset'||attrName==='markerEndOffset'){this.transformMarker(true);this.transformMarker(false);}else if(attrName==='markerStart'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerStartAngle=0;prevParsedValue.remove();}// CSSKeyword 'unset'
|
|
8698
|
+
if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerStartAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(true);}}else if(attrName==='markerEnd'){if(prevParsedValue&&isDisplayObject(prevParsedValue)){this.markerEndAngle=0;prevParsedValue.remove();}if(newParsedValue&&isDisplayObject(newParsedValue)){this.markerEndAngle=newParsedValue.getLocalEulerAngles();this.appendChild(newParsedValue);this.transformMarker(false);}}else if(attrName==='markerMid'){this.placeMarkerMid(newParsedValue);}};_proto.transformMarker=function transformMarker(isStart){var _this$parsedStyle2=this.parsedStyle,markerStart=_this$parsedStyle2.markerStart,markerEnd=_this$parsedStyle2.markerEnd,markerStartOffset=_this$parsedStyle2.markerStartOffset,markerEndOffset=_this$parsedStyle2.markerEndOffset,points=_this$parsedStyle2.points.points,defX=_this$parsedStyle2.defX,defY=_this$parsedStyle2.defY;var marker=isStart?markerStart:markerEnd;if(!marker||!isDisplayObject(marker)){return;}var rad=0;var x;var y;var ox;var oy;var offset;var originalAngle;ox=points[0][0]-defX;oy=points[0][1]-defY;if(isStart){x=points[1][0]-points[0][0];y=points[1][1]-points[0][1];offset=markerStartOffset||0;originalAngle=this.markerStartAngle;}else {var length=points.length;if(!this.style.isClosed){ox=points[length-1][0]-defX;oy=points[length-1][1]-defY;x=points[length-2][0]-points[length-1][0];y=points[length-2][1]-points[length-1][1];}else {x=points[length-1][0]-points[0][0];y=points[length-1][1]-points[0][1];}offset=markerEndOffset||0;originalAngle=this.markerEndAngle;}rad=Math.atan2(y,x);// account for markerOffset
|
|
8699
|
+
marker.setLocalEulerAngles(rad*180/Math.PI+originalAngle);marker.setLocalPosition(ox+Math.cos(rad)*offset,oy+Math.sin(rad)*offset);};_proto.placeMarkerMid=function placeMarkerMid(marker){var _this$parsedStyle3=this.parsedStyle,points=_this$parsedStyle3.points.points,defX=_this$parsedStyle3.defX,defY=_this$parsedStyle3.defY;// clear all existed markers
|
|
8700
|
+
this.markerMidList.forEach(function(marker){marker.remove();});this.markerMidList=[];if(marker&&isDisplayObject(marker)){for(var i=1;i<(this.style.isClosed?points.length:points.length-1);i++){var ox=points[i][0]-defX;var oy=points[i][1]-defY;var cloned=i===1?marker:marker.cloneNode(true);this.markerMidList.push(cloned);this.appendChild(cloned);cloned.setLocalPosition(ox,oy);// TODO: orient of marker
|
|
8701
|
+
}}};return Polygon;}(DisplayObject);var _excluded$9=["style"];/**
|
|
8702
|
+
* Polyline inherits the marker-related capabilities of Polygon.
|
|
8703
|
+
*/var Polyline=/*#__PURE__*/function(_Polygon){_inheritsLoose(Polyline,_Polygon);function Polyline(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$9);return _Polygon.call(this,_extends({type:exports.Shape.POLYLINE,style:_extends({points:'',miterLimit:'',isClosed:false},style)},rest))||this;}var _proto=Polyline.prototype;_proto.getTotalLength=function getTotalLength(){return this.parsedStyle.points.totalLength;};_proto.getPointAtLength=function getPointAtLength(distance,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}return this.getPoint(distance/this.getTotalLength(),inWorldSpace);};_proto.getPoint=function getPoint(ratio,inWorldSpace){if(inWorldSpace===void 0){inWorldSpace=false;}var _this$parsedStyle=this.parsedStyle,defX=_this$parsedStyle.defX,defY=_this$parsedStyle.defY,_this$parsedStyle$poi=_this$parsedStyle.points,points=_this$parsedStyle$poi.points,segments=_this$parsedStyle$poi.segments;var subt=0;var index=0;segments.forEach(function(v,i){if(ratio>=v[0]&&ratio<=v[1]){subt=(ratio-v[0])/(v[1]-v[0]);index=i;}});var _LineUtil$pointAt=line.pointAt(points[index][0],points[index][1],points[index+1][0],points[index+1][1],subt),x=_LineUtil$pointAt.x,y=_LineUtil$pointAt.y;var transformed=transformMat4(create$2(),fromValues$2(x-defX,y-defY,0),inWorldSpace?this.getWorldTransform():this.getLocalTransform());// apply local transformation
|
|
8704
|
+
return new Point(transformed[0],transformed[1]);};_proto.getStartTangent=function getStartTangent(){var points=this.parsedStyle.points.points;var result=[];result.push([points[1][0],points[1][1]]);result.push([points[0][0],points[0][1]]);return result;};_proto.getEndTangent=function getEndTangent(){var points=this.parsedStyle.points.points;var l=points.length-1;var result=[];result.push([points[l-1][0],points[l-1][1]]);result.push([points[l][0],points[l][1]]);return result;};return Polyline;}(Polygon);var _excluded$a=["style"];var Rect=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Rect,_DisplayObject);function Rect(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$a);return _DisplayObject.call(this,_extends({type:exports.Shape.RECT,style:_extends({x:'',y:'',width:'',height:'',radius:''},style)},rest))||this;}return Rect;}(DisplayObject);var _excluded$b=["style"];/**
|
|
8705
|
+
* <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
|
|
8706
|
+
*/var Text=/*#__PURE__*/function(_DisplayObject){_inheritsLoose(Text,_DisplayObject);/**
|
|
8707
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
|
|
8708
|
+
*/ // LENGTHADJUST_SPACING: number = 1;
|
|
8709
|
+
// LENGTHADJUST_SPACINGANDGLYPHS: number = 2;
|
|
8710
|
+
// LENGTHADJUST_UNKNOWN: number = 0;
|
|
8711
|
+
function Text(_temp){var _ref=_temp===void 0?{}:_temp,style=_ref.style,rest=_objectWithoutPropertiesLoose(_ref,_excluded$b);return _DisplayObject.call(this,_extends({type:exports.Shape.TEXT,style:runtime.enableCSSParsing?_extends({x:'',y:'',text:'',fontSize:'',fontFamily:'',fontStyle:'',fontWeight:'',fontVariant:'',textAlign:'',textBaseline:'',textTransform:'',fill:'black',letterSpacing:'',lineHeight:'',miterLimit:'',// whiteSpace: 'pre',
|
|
8712
|
+
wordWrap:false,wordWrapWidth:0,leading:0,dx:'',dy:''},style):_extends({},style),initialParsedStyle:runtime.enableCSSParsing?{}:{fill:'black',fontSize:16,fontFamily:'sans-serif',fontStyle:'normal',fontWeight:'normal',fontVariant:'normal',lineHeight:0,letterSpacing:0,textBaseline:'alphabetic',textAlign:'start',miterLimit:10,wordWrap:false,wordWrapWidth:0,leading:0,dx:0,dy:0}},rest))||this;}// lengthAdjust: SVGAnimatedEnumeration;
|
|
8713
|
+
// textLength: SVGAnimatedLength;
|
|
8714
|
+
// getCharNumAtPosition(point?: DOMPointInit): number {
|
|
8715
|
+
// throw new Error('Method not implemented.');
|
|
8762
8716
|
// }
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
//
|
|
8767
|
-
}var _proto=Hook.prototype;_proto.compile=function compile(options){throw new Error('Abstract: should be overridden');};_proto._createCall=function _createCall(type){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:type});};_proto._tap=function _tap(type,options,fn){if(typeof options==='string'){options={name:options.trim()};}else if(typeof options!=='object'||options===null){throw new Error('Invalid tap options');}if(typeof options.name!=='string'||options.name===''){throw new Error('Missing name for tap');}// if (typeof options.context !== "undefined") {
|
|
8768
|
-
// deprecateContext();
|
|
8717
|
+
/**
|
|
8718
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
|
|
8719
|
+
*/var _proto=Text.prototype;_proto.getComputedTextLength=function getComputedTextLength(){var _this$parsedStyle$met;return ((_this$parsedStyle$met=this.parsedStyle.metrics)===null||_this$parsedStyle$met===void 0?void 0:_this$parsedStyle$met.maxLineWidth)||0;}// getEndPositionOfChar(charnum: number): DOMPoint {
|
|
8720
|
+
// throw new Error('Method not implemented.');
|
|
8769
8721
|
// }
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
// this._resetCompilation();
|
|
8773
|
-
// this.interceptors.push(Object.assign({}, interceptor));
|
|
8774
|
-
// if (interceptor.register) {
|
|
8775
|
-
// for (let i = 0; i < this.taps.length; i++) {
|
|
8776
|
-
// this.taps[i] = interceptor.register(this.taps[i]);
|
|
8777
|
-
// }
|
|
8778
|
-
// }
|
|
8722
|
+
// getExtentOfChar(charnum: number): DOMRect {
|
|
8723
|
+
// throw new Error('Method not implemented.');
|
|
8779
8724
|
// }
|
|
8780
|
-
|
|
8781
|
-
//
|
|
8782
|
-
var HookCodeFactory=/*#__PURE__*/function(){function HookCodeFactory(config){this.config=config;this.options=undefined;this._args=undefined;}var _proto=HookCodeFactory.prototype;_proto.create=function create(options){this.init(options);var fn;switch(this.options.type){case'sync':fn=new Function(this.args(),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "throw "+err+";\n";},onResult:function onResult(result){return "return "+result+";\n";},resultReturns:true,onDone:function onDone(){return '';},rethrowIfPossible:true}));break;case'async':fn=new Function(this.args({after:'_callback'}),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:function onError(err){return "_callback("+err+");\n";},onResult:function onResult(result){return "_callback(null, "+result+");\n";},onDone:function onDone(){return '_callback();\n';}}));break;case'promise':var errorHelperUsed=false;var content=this.contentWithInterceptors({onError:function onError(err){errorHelperUsed=true;return "_error("+err+");\n";},onResult:function onResult(result){return "_resolve("+result+");\n";},onDone:function onDone(){return '_resolve();\n';}});var code='';code+='"use strict";\n';code+=this.header();code+='return new Promise((function(_resolve, _reject) {\n';if(errorHelperUsed){code+='var _sync = true;\n';code+='function _error(_err) {\n';code+='if(_sync)\n';code+='_resolve(Promise.resolve().then((function() { throw _err; })));\n';code+='else\n';code+='_reject(_err);\n';code+='};\n';}code+=content;if(errorHelperUsed){code+='_sync = false;\n';}code+='}));\n';fn=new Function(this.args(),code);break;}this.deinit();return fn;};_proto.setup=function setup(instance,options){instance._x=options.taps.map(function(t){return t.fn;});}/**
|
|
8783
|
-
* @param {{ type: "sync" | "promise" | "async", taps: Array<Tap>, interceptors: Array<Interceptor> }} options
|
|
8784
|
-
*/;_proto.init=function init(options){this.options=options;this._args=options.args.slice();};_proto.deinit=function deinit(){this.options=undefined;this._args=undefined;};_proto.contentWithInterceptors=function contentWithInterceptors(options){var _this=this;if(this.options.interceptors.length>0){var onError=options.onError;var onResult=options.onResult;var onDone=options.onDone;var code='';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.call){code+=this.getInterceptor(i)+".call("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.content(Object.assign(options,{onError:onError&&function(err){var code='';for(var _i=0;_i<_this.options.interceptors.length;_i++){var _interceptor=_this.options.interceptors[_i];if(_interceptor.error){code+=_this.getInterceptor(_i)+".error("+err+");\n";}}code+=onError(err);return code;},onResult:onResult&&function(result){var code='';for(var _i2=0;_i2<_this.options.interceptors.length;_i2++){var _interceptor2=_this.options.interceptors[_i2];if(_interceptor2.result){code+=_this.getInterceptor(_i2)+".result("+result+");\n";}}code+=onResult(result);return code;},onDone:onDone&&function(){var code='';for(var _i3=0;_i3<_this.options.interceptors.length;_i3++){var _interceptor3=_this.options.interceptors[_i3];if(_interceptor3.done){code+=_this.getInterceptor(_i3)+".done();\n";}}code+=onDone();return code;}}));return code;}else {return this.content(options);}};_proto.header=function header(){var code='';if(this.needContext()){code+='var _context = {};\n';}else {code+='var _context;\n';}code+='var _x = this._x;\n';if(this.options.interceptors.length>0){code+='var _taps = this.taps;\n';code+='var _interceptors = this.interceptors;\n';}return code;};_proto.needContext=function needContext(){for(var _iterator=_createForOfIteratorHelperLoose(this.options.taps),_step;!(_step=_iterator()).done;){var tap=_step.value;if(tap.context)return true;}return false;};_proto.callTap=function callTap(tapIndex,_ref){var onError=_ref.onError,onResult=_ref.onResult,onDone=_ref.onDone,rethrowIfPossible=_ref.rethrowIfPossible;var code='';var hasTapCached=false;for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.tap){if(!hasTapCached){code+="var _tap"+tapIndex+" = "+this.getTap(tapIndex)+";\n";hasTapCached=true;}code+=this.getInterceptor(i)+".tap("+(interceptor.context?'_context, ':'')+"_tap"+tapIndex+");\n";}}code+="var _fn"+tapIndex+" = "+this.getTapFn(tapIndex)+";\n";var tap=this.options.taps[tapIndex];switch(tap.type){case'sync':if(!rethrowIfPossible){code+="var _hasError"+tapIndex+" = false;\n";code+='try {\n';}if(onResult){code+="var _result"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}else {code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";}if(!rethrowIfPossible){code+='} catch(_err) {\n';code+="_hasError"+tapIndex+" = true;\n";code+=onError('_err');code+='}\n';code+="if(!_hasError"+tapIndex+") {\n";}if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}if(!rethrowIfPossible){code+='}\n';}break;case'async':var cbCode='';if(onResult)cbCode+="(function(_err"+tapIndex+", _result"+tapIndex+") {\n";else cbCode+="(function(_err"+tapIndex+") {\n";cbCode+="if(_err"+tapIndex+") {\n";cbCode+=onError("_err"+tapIndex);cbCode+='} else {\n';if(onResult){cbCode+=onResult("_result"+tapIndex);}if(onDone){cbCode+=onDone();}cbCode+='}\n';cbCode+='})';code+="_fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined,after:cbCode})+");\n";break;case'promise':code+="var _hasResult"+tapIndex+" = false;\n";code+="var _promise"+tapIndex+" = _fn"+tapIndex+"("+this.args({before:tap.context?'_context':undefined})+");\n";code+="if (!_promise"+tapIndex+" || !_promise"+tapIndex+".then)\n";code+=" throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise"+tapIndex+" + ')');\n";code+="_promise"+tapIndex+".then((function(_result"+tapIndex+") {\n";code+="_hasResult"+tapIndex+" = true;\n";if(onResult){code+=onResult("_result"+tapIndex);}if(onDone){code+=onDone();}code+="}), function(_err"+tapIndex+") {\n";code+="if(_hasResult"+tapIndex+") throw _err"+tapIndex+";\n";code+=onError("_err"+tapIndex);code+='});\n';break;}return code;};_proto.callTapsSeries=function callTapsSeries(_ref2){var _this2=this;var _onError=_ref2.onError,onResult=_ref2.onResult,resultReturns=_ref2.resultReturns,onDone=_ref2.onDone,doneReturns=_ref2.doneReturns,rethrowIfPossible=_ref2.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var firstAsync=this.options.taps.findIndex(function(t){return t.type!=='sync';});var somethingReturns=resultReturns||doneReturns;var code='';var current=onDone;var unrollCounter=0;var _loop=function _loop(j){var i=j;var unroll=current!==onDone&&(_this2.options.taps[i].type!=='sync'||unrollCounter++>20);if(unroll){unrollCounter=0;code+="function _next"+i+"() {\n";code+=current();code+="}\n";current=function current(){return (somethingReturns?'return ':'')+"_next"+i+"();\n";};}var done=current;var doneBreak=function doneBreak(skipDone){if(skipDone)return '';return onDone();};var content=_this2.callTap(i,{onError:function onError(error){return _onError(i,error,done,doneBreak);},onResult:onResult&&function(result){return onResult(i,result,done,doneBreak);},onDone:!onResult&&done,rethrowIfPossible:rethrowIfPossible&&(firstAsync<0||i<firstAsync)});current=function current(){return content;};};for(var j=this.options.taps.length-1;j>=0;j--){_loop(j);}code+=current();return code;};_proto.callTapsLooping=function callTapsLooping(_ref3){var onError=_ref3.onError,onDone=_ref3.onDone,rethrowIfPossible=_ref3.rethrowIfPossible;if(this.options.taps.length===0)return onDone();var syncOnly=this.options.taps.every(function(t){return t.type==='sync';});var code='';if(!syncOnly){code+='var _looper = (function() {\n';code+='var _loopAsync = false;\n';}code+='var _loop;\n';code+='do {\n';code+='_loop = false;\n';for(var i=0;i<this.options.interceptors.length;i++){var interceptor=this.options.interceptors[i];if(interceptor.loop){code+=this.getInterceptor(i)+".loop("+this.args({before:interceptor.context?'_context':undefined})+");\n";}}code+=this.callTapsSeries({onError:onError,onResult:function onResult(i,result,next,doneBreak){var code='';code+="if("+result+" !== undefined) {\n";code+='_loop = true;\n';if(!syncOnly)code+='if(_loopAsync) _looper();\n';code+=doneBreak(true);code+="} else {\n";code+=next();code+="}\n";return code;},onDone:onDone&&function(){var code='';code+='if(!_loop) {\n';code+=onDone();code+='}\n';return code;},rethrowIfPossible:rethrowIfPossible&&syncOnly});code+='} while(_loop);\n';if(!syncOnly){code+='_loopAsync = true;\n';code+='});\n';code+='_looper();\n';}return code;};_proto.callTapsParallel=function callTapsParallel(_ref4){var _this3=this;var _onError2=_ref4.onError,onResult=_ref4.onResult,onDone=_ref4.onDone,rethrowIfPossible=_ref4.rethrowIfPossible,_ref4$onTap=_ref4.onTap,onTap=_ref4$onTap===void 0?function(i,run){return run();}:_ref4$onTap;if(this.options.taps.length<=1){return this.callTapsSeries({onError:_onError2,onResult:onResult,onDone:onDone,rethrowIfPossible:rethrowIfPossible});}var code='';code+='do {\n';code+="var _counter = "+this.options.taps.length+";\n";if(onDone){code+='var _done = (function() {\n';code+=onDone();code+='});\n';}var _loop2=function _loop2(i){var done=function done(){if(onDone)return 'if(--_counter === 0) _done();\n';else return '--_counter;';};var doneBreak=function doneBreak(skipDone){if(skipDone||!onDone)return '_counter = 0;\n';else return '_counter = 0;\n_done();\n';};code+='if(_counter <= 0) break;\n';code+=onTap(i,function(){return _this3.callTap(i,{onError:function onError(error){var code='';code+='if(_counter > 0) {\n';code+=_onError2(i,error,done,doneBreak);code+='}\n';return code;},onResult:onResult&&function(result){var code='';code+='if(_counter > 0) {\n';code+=onResult(i,result,done,doneBreak);code+='}\n';return code;},onDone:!onResult&&function(){return done();},rethrowIfPossible:rethrowIfPossible});},done,doneBreak);};for(var i=0;i<this.options.taps.length;i++){_loop2(i);}code+='} while(false);\n';return code;};_proto.args=function args(_temp){var _ref5=_temp===void 0?{}:_temp,before=_ref5.before,after=_ref5.after;var allArgs=this._args;if(before)allArgs=[before].concat(allArgs);if(after)allArgs=allArgs.concat(after);if(allArgs.length===0){return '';}else {return allArgs.join(', ');}};_proto.getTapFn=function getTapFn(idx){return "_x["+idx+"]";};_proto.getTap=function getTap(idx){return "_taps["+idx+"]";};_proto.getInterceptor=function getInterceptor(idx){return "_interceptors["+idx+"]";};return HookCodeFactory;}();var AsyncParallelHookCodeFactory=/*#__PURE__*/function(_HookCodeFactory){_inheritsLoose(AsyncParallelHookCodeFactory,_HookCodeFactory);function AsyncParallelHookCodeFactory(){return _HookCodeFactory.apply(this,arguments)||this;}var _proto=AsyncParallelHookCodeFactory.prototype;_proto.content=function content(_ref){var _onError=_ref.onError,onDone=_ref.onDone;return this.callTapsParallel({onError:function onError(i,err,done,doneBreak){return _onError(err)+doneBreak(true);},onDone:onDone});};return AsyncParallelHookCodeFactory;}(HookCodeFactory);var factory=new AsyncParallelHookCodeFactory();var COMPILE=function COMPILE(options){factory.setup(this,options);return factory.create(options);};var AsyncParallelHook=/*#__PURE__*/function(_Hook){_inheritsLoose(AsyncParallelHook,_Hook);function AsyncParallelHook(args,name){var _this;if(args===void 0){args=[];}if(name===void 0){name=undefined;}_this=_Hook.call(this,args,name)||this;_this.compile=COMPILE;_this._call=undefined;_this.call=undefined;return _this;}return AsyncParallelHook;}(Hook);// export function AsyncParallelHook(args = [], name = undefined) {
|
|
8785
|
-
// const hook = new Hook(args, name);
|
|
8786
|
-
// hook.constructor = AsyncParallelHook;
|
|
8787
|
-
// hook.compile = COMPILE;
|
|
8788
|
-
// hook._call = undefined;
|
|
8789
|
-
// hook.call = undefined;
|
|
8790
|
-
// return hook;
|
|
8725
|
+
// getNumberOfChars(): number {
|
|
8726
|
+
// throw new Error('Method not implemented.');
|
|
8791
8727
|
// }
|
|
8792
|
-
//
|
|
8793
|
-
|
|
8794
|
-
// if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
|
|
8795
|
-
// const hook = new Hook(args, name);
|
|
8796
|
-
// hook.constructor = AsyncSeriesWaterfallHook;
|
|
8797
|
-
// hook.compile = COMPILE;
|
|
8798
|
-
// hook._call = undefined;
|
|
8799
|
-
// hook.call = undefined;
|
|
8800
|
-
// return hook;
|
|
8728
|
+
// getRotationOfChar(charnum: number): number {
|
|
8729
|
+
// throw new Error('Method not implemented.');
|
|
8801
8730
|
// }
|
|
8802
|
-
//
|
|
8803
|
-
|
|
8804
|
-
// const hook = new Hook(args, name);
|
|
8805
|
-
// hook.constructor = SyncHook;
|
|
8806
|
-
// hook.tapAsync = TAP_ASYNC;
|
|
8807
|
-
// hook.tapPromise = TAP_PROMISE;
|
|
8808
|
-
// hook.compile = COMPILE;
|
|
8809
|
-
// return hook;
|
|
8731
|
+
// getStartPositionOfChar(charnum: number): DOMPoint {
|
|
8732
|
+
// throw new Error('Method not implemented.');
|
|
8810
8733
|
// }
|
|
8811
|
-
//
|
|
8812
|
-
|
|
8813
|
-
// if (args.length < 1) throw new Error('Waterfall hooks must have at least one argument');
|
|
8814
|
-
// const hook = new Hook(args, name);
|
|
8815
|
-
// hook.constructor = SyncWaterfallHook;
|
|
8816
|
-
// hook.tapAsync = TAP_ASYNC;
|
|
8817
|
-
// hook.tapPromise = TAP_PROMISE;
|
|
8818
|
-
// hook.compile = COMPILE;
|
|
8819
|
-
// return hook;
|
|
8734
|
+
// getSubStringLength(charnum: number, nchars: number): number {
|
|
8735
|
+
// throw new Error('Method not implemented.');
|
|
8820
8736
|
// }
|
|
8821
|
-
//
|
|
8822
|
-
|
|
8823
|
-
//
|
|
8824
|
-
var
|
|
8825
|
-
// this will support font names with spaces
|
|
8826
|
-
// @ts-ignore
|
|
8827
|
-
var fontFamilies=isString(fontFamily)?fontFamily.split(','):[fontFamily];for(var i=fontFamilies.length-1;i>=0;i--){// Trim any extra white-space
|
|
8828
|
-
var _fontFamily=fontFamilies[i].trim();// Check if font already contains strings
|
|
8829
|
-
if(!stringRegExp.test(_fontFamily)&&genericFontFamilies.indexOf(_fontFamily)<0){_fontFamily="\""+_fontFamily+"\"";}fontFamilies[i]=_fontFamily;}return fontStyle+" "+fontVariant+" "+fontWeight+" "+fontSizeString+" "+fontFamilies.join(',');}/**
|
|
8830
|
-
* Thanks for following contributor of codes
|
|
8831
|
-
* https://gist.github.com/1866474
|
|
8832
|
-
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
|
8833
|
-
* http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
|
8834
|
-
* https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/requestAnimationFrame/polyfill.js
|
|
8835
|
-
**/var uId=1;var uniqueId=function uniqueId(){return uId++;};// We use `self` instead of `window` for `WebWorker` support.
|
|
8836
|
-
var root=typeof self==='object'&&self.self==self?self:// @ts-ignore
|
|
8837
|
-
typeof global==='object'&&global.global==global?// @ts-ignore
|
|
8838
|
-
global:{};var nowOffset=Date.now();// use performance api if exist, otherwise use Date.now.
|
|
8839
|
-
// Date.now polyfill required.
|
|
8840
|
-
var pnow=function pnow(){if(root.performance&&typeof root.performance.now==='function'){return root.performance.now();}// fallback
|
|
8841
|
-
return Date.now()-nowOffset;};var reservedCBs={};var lastTime=Date.now();var polyfillRaf=function polyfillRaf(callback){if(typeof callback!=='function'){throw new TypeError(callback+' is not a function');}var currentTime=Date.now();var gap=currentTime-lastTime;var delay=gap>16?0:16-gap;var id=uniqueId();reservedCBs[id]=callback;// keys(reservedCBs).length > 1 의미는 이미 setTimeout 이 걸려있는 경우.
|
|
8842
|
-
// 함께 callback 이 실행될 수 있게 reservedCBs 에만 추가해주고 return
|
|
8843
|
-
if(Object.keys(reservedCBs).length>1)return id;setTimeout(function(){lastTime=currentTime;var copied=reservedCBs;reservedCBs={};Object.keys(copied).forEach(function(key){return copied[key](pnow());});},delay);return id;};var polyfillCaf=function polyfillCaf(id){delete reservedCBs[id];};var vendorPrefixes=['','webkit','moz','ms','o'];var getRequestAnimationFrame=function getRequestAnimationFrame(vp){if(typeof vp!=='string')return polyfillRaf;if(vp==='')return root['requestAnimationFrame'];return root[vp+'RequestAnimationFrame'];};var getCancelAnimationFrame=function getCancelAnimationFrame(vp){if(typeof vp!=='string')return polyfillCaf;if(vp==='')return root['cancelAnimationFrame'];return root[vp+'CancelAnimationFrame']||root[vp+'CancelRequestAnimationFrame'];};var find=function find(arr,predicate){var i=0;while(arr[i]!==void 0){if(predicate(arr[i]))return arr[i];i=i+1;}};var vp=find(vendorPrefixes,function(vp){return !!getRequestAnimationFrame(vp);});var raf=getRequestAnimationFrame(vp);var caf=getCancelAnimationFrame(vp);root.requestAnimationFrame=raf;root.cancelAnimationFrame=caf;/**
|
|
8737
|
+
// selectSubString(charnum: number, nchars: number): void {
|
|
8738
|
+
// throw new Error('Method not implemented.');
|
|
8739
|
+
// }
|
|
8740
|
+
;_proto.getLineBoundingRects=function getLineBoundingRects(){var _this$parsedStyle$met2;return ((_this$parsedStyle$met2=this.parsedStyle.metrics)===null||_this$parsedStyle$met2===void 0?void 0:_this$parsedStyle$met2.lineMetrics)||[];};_proto.isOverflowing=function isOverflowing(){return !!this.parsedStyle.isOverflowing;};return Text;}(DisplayObject);/**
|
|
8844
8741
|
* Blink used them in code generation(css_properties.json5)
|
|
8845
8742
|
*/var BUILT_IN_PROPERTIES=[{/**
|
|
8846
8743
|
* used in CSS Layout API
|
|
@@ -8890,7 +8787,10 @@
|
|
|
8890
8787
|
// l: true,
|
|
8891
8788
|
// },
|
|
8892
8789
|
{n:'markerStart',syntax:exports.PropertySyntax.MARKER},{n:'markerEnd',syntax:exports.PropertySyntax.MARKER},{n:'markerMid',syntax:exports.PropertySyntax.MARKER},{n:'markerStartOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'},{n:'markerEndOffset',syntax:exports.PropertySyntax.LENGTH,l:true,int:true,d:'0'}];var propertyMetadataCache={};var unresolvedProperties=new WeakMap();// const uniqueAttributeSet = new Set<string>();
|
|
8893
|
-
|
|
8790
|
+
// const tmpVec3a = vec3.create();
|
|
8791
|
+
// const tmpVec3b = vec3.create();
|
|
8792
|
+
// const tmpVec3c = vec3.create();
|
|
8793
|
+
var isPropertyResolved=function isPropertyResolved(object,name){var properties=unresolvedProperties.get(object);if(!properties||properties.length===0){return true;}return properties.includes(name);};var DefaultStyleValueRegistry=/*#__PURE__*/function(){/**
|
|
8894
8794
|
* need recalc later
|
|
8895
8795
|
*/ // dirty = false;
|
|
8896
8796
|
function DefaultStyleValueRegistry(){var _this=this;BUILT_IN_PROPERTIES.forEach(function(property){_this.registerMetadata(property);});}var _proto=DefaultStyleValueRegistry.prototype;_proto.registerMetadata=function registerMetadata(metadata){[metadata.n].concat(metadata.a||[]).forEach(function(name){propertyMetadataCache[name]=metadata;});};_proto.unregisterMetadata=function unregisterMetadata(name){delete propertyMetadataCache[name];};_proto.getPropertySyntax=function getPropertySyntax(syntax){return runtime.CSSPropertySyntaxFactory[syntax];}/**
|
|
@@ -8901,7 +8801,54 @@
|
|
|
8901
8801
|
*
|
|
8902
8802
|
* * calculate used value
|
|
8903
8803
|
* * post process
|
|
8904
|
-
*/;_proto.processProperties=function processProperties(object,attributes,options){var _this2=this;if(options===void 0){options={skipUpdateAttribute:false,skipParse:false,forceUpdateGeometry:false,usedAttributes:[]};}
|
|
8804
|
+
*/;_proto.processProperties=function processProperties(object,attributes,options){var _this2=this;if(options===void 0){options={skipUpdateAttribute:false,skipParse:false,forceUpdateGeometry:false,usedAttributes:[]};}if(!runtime.enableCSSParsing){// alias
|
|
8805
|
+
// @ts-ignore
|
|
8806
|
+
if(attributes.src){// @ts-ignore
|
|
8807
|
+
attributes.img=attributes.src;}// @ts-ignore
|
|
8808
|
+
if(attributes.d){// @ts-ignore
|
|
8809
|
+
attributes.path=attributes.d;}if(attributes.strokeDasharray){attributes.lineDash=attributes.strokeDasharray;}if(attributes.strokeWidth){attributes.lineWidth=attributes.strokeWidth;}// @ts-ignore
|
|
8810
|
+
if(attributes.textAnchor){// @ts-ignore
|
|
8811
|
+
attributes.textAlign=attributes.textAnchor;}Object.assign(object.attributes,attributes);var _attributeNames=Object.keys(attributes);// clipPath
|
|
8812
|
+
var oldClipPath=object.parsedStyle.clipPath;var oldOffsetPath=object.parsedStyle.offsetPath;object.parsedStyle=Object.assign(object.parsedStyle,attributes);if(attributes.fill){object.parsedStyle.fill=parseColor(attributes.fill);}if(attributes.stroke){object.parsedStyle.stroke=parseColor(attributes.stroke);}if(attributes.shadowColor){object.parsedStyle.shadowColor=parseColor(attributes.shadowColor);}if(attributes.filter){object.parsedStyle.filter=parseFilter(attributes.filter);}// Rect
|
|
8813
|
+
// @ts-ignore
|
|
8814
|
+
if(attributes.radius){// @ts-ignore
|
|
8815
|
+
object.parsedStyle.radius=parseDimensionArrayFormat(// @ts-ignore
|
|
8816
|
+
attributes.radius,4);}// Polyline
|
|
8817
|
+
if(attributes.lineDash){object.parsedStyle.lineDash=parseDimensionArrayFormat(attributes.lineDash,2);}// @ts-ignore
|
|
8818
|
+
if(attributes.points){// @ts-ignore
|
|
8819
|
+
object.parsedStyle.points=parsePoints(attributes.points,object);}// Path
|
|
8820
|
+
// @ts-ignore
|
|
8821
|
+
if(attributes.path===''){object.parsedStyle.path=_extends({},EMPTY_PARSED_PATH);}// @ts-ignore
|
|
8822
|
+
if(attributes.path){object.parsedStyle.path=parsePath(// @ts-ignore
|
|
8823
|
+
attributes.path,object);}// Text
|
|
8824
|
+
if(attributes.textTransform){runtime.CSSPropertySyntaxFactory['<text-transform>'].calculator(null,null,{value:attributes.textTransform},object,null);}if(attributes.clipPath){runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('clipPath',oldClipPath,attributes.clipPath,object,this);}if(attributes.offsetPath){runtime.CSSPropertySyntaxFactory['<defined-path>'].calculator('offsetPath',oldOffsetPath,attributes.offsetPath,object,this);}if(attributes.anchor){object.parsedStyle.anchor=parseDimensionArrayFormat(// @ts-ignorex
|
|
8825
|
+
attributes.anchor,2);}if(attributes.transform){object.parsedStyle.transform=parseTransform(attributes.transform);}if(attributes.transformOrigin){object.parsedStyle.transformOrigin=parseTransformOrigin(attributes.transformOrigin);}// Marker
|
|
8826
|
+
// @ts-ignore
|
|
8827
|
+
if(attributes.markerStart){// @ts-ignore
|
|
8828
|
+
object.parsedStyle.markerStart=runtime.CSSPropertySyntaxFactory['<marker>'].calculator(null,// @ts-ignore
|
|
8829
|
+
attributes.markerStart,// @ts-ignore
|
|
8830
|
+
attributes.markerStart,null,null);}// @ts-ignore
|
|
8831
|
+
if(attributes.markerEnd){// @ts-ignore
|
|
8832
|
+
object.parsedStyle.markerEnd=runtime.CSSPropertySyntaxFactory['<marker>'].calculator(null,// @ts-ignore
|
|
8833
|
+
attributes.markerEnd,// @ts-ignore
|
|
8834
|
+
attributes.markerEnd,null,null);}// @ts-ignore
|
|
8835
|
+
if(attributes.markerMid){// @ts-ignore
|
|
8836
|
+
object.parsedStyle.markerMid=runtime.CSSPropertySyntaxFactory['<marker>'].calculator('',// @ts-ignore
|
|
8837
|
+
attributes.markerMid,// @ts-ignore
|
|
8838
|
+
attributes.markerMid,null,null);}if(// @ts-ignore
|
|
8839
|
+
attributes.cx||// @ts-ignore
|
|
8840
|
+
attributes.cy||// @ts-ignore
|
|
8841
|
+
attributes.x||// @ts-ignore
|
|
8842
|
+
attributes.y||// @ts-ignore
|
|
8843
|
+
attributes.z||// @ts-ignore
|
|
8844
|
+
attributes.x1||// @ts-ignore
|
|
8845
|
+
attributes.y1||// @ts-ignore
|
|
8846
|
+
attributes.z1||// @ts-ignore
|
|
8847
|
+
attributes.x2||// @ts-ignore
|
|
8848
|
+
attributes.y2||// @ts-ignore
|
|
8849
|
+
attributes.z2){runtime.CSSPropertySyntaxFactory['<coordinate>'].postProcessor(object,_attributeNames);}if(attributes.zIndex){runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object,_attributeNames);}// @ts-ignore
|
|
8850
|
+
if(attributes.path){runtime.CSSPropertySyntaxFactory['<path>'].postProcessor(object,_attributeNames);}// @ts-ignore
|
|
8851
|
+
if(attributes.points){runtime.CSSPropertySyntaxFactory['<list-of-points>'].postProcessor(object,_attributeNames);}if(attributes.offsetDistance){runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object,_attributeNames);}if(attributes.transform){runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object,_attributeNames);}this.updateGeometry(object);return;}var _options=options,skipUpdateAttribute=_options.skipUpdateAttribute,skipParse=_options.skipParse,forceUpdateGeometry=_options.forceUpdateGeometry,usedAttributes=_options.usedAttributes;var needUpdateGeometry=forceUpdateGeometry;var attributeNames=Object.keys(attributes);attributeNames.forEach(function(attributeName){var _propertyMetadataCach;var name=formatAttributeName(attributeName);if(!skipUpdateAttribute){object.attributes[name]=attributes[attributeName];}if(!needUpdateGeometry&&((_propertyMetadataCach=propertyMetadataCache[name])===null||_propertyMetadataCach===void 0?void 0:_propertyMetadataCach.l)){needUpdateGeometry=true;}});if(!skipParse){attributeNames.forEach(function(name){object.computedStyle[name]=_this2.parseProperty(name,object.attributes[name],object);});}// let hasUnresolvedProperties = false;
|
|
8905
8852
|
// parse according to priority
|
|
8906
8853
|
// path 50
|
|
8907
8854
|
// points 50
|
|
@@ -8911,13 +8858,28 @@
|
|
|
8911
8858
|
// transform 100
|
|
8912
8859
|
// transformOrigin 100
|
|
8913
8860
|
if(usedAttributes===null||usedAttributes===void 0?void 0:usedAttributes.length){// uniqueAttributeSet.clear();
|
|
8914
|
-
attributeNames=Array.from(new Set(attributeNames.concat(usedAttributes)));}
|
|
8861
|
+
attributeNames=Array.from(new Set(attributeNames.concat(usedAttributes)));}// [
|
|
8862
|
+
// 'path',
|
|
8863
|
+
// 'points',
|
|
8864
|
+
// 'text',
|
|
8865
|
+
// 'textTransform',
|
|
8866
|
+
// 'anchor',
|
|
8867
|
+
// 'transform',
|
|
8868
|
+
// 'transformOrigin',
|
|
8869
|
+
// ].forEach((name) => {
|
|
8870
|
+
// const index = attributeNames.indexOf(name);
|
|
8871
|
+
// if (index > -1) {
|
|
8872
|
+
// attributeNames.splice(index, 1);
|
|
8873
|
+
// attributeNames.push(name);
|
|
8874
|
+
// }
|
|
8875
|
+
// });
|
|
8876
|
+
attributeNames.forEach(function(name){// some style props maybe deleted after parsing such as `anchor` in Text
|
|
8915
8877
|
if(name in object.computedStyle){object.parsedStyle[name]=_this2.computeProperty(name,object.computedStyle[name],object);}});// if (hasUnresolvedProperties) {
|
|
8916
8878
|
// this.dirty = true;
|
|
8917
8879
|
// return;
|
|
8918
8880
|
// }
|
|
8919
8881
|
// update geometry
|
|
8920
|
-
if(needUpdateGeometry){this.updateGeometry(object);}attributeNames.forEach(function(name){if(name in object.parsedStyle){_this2.postProcessProperty(name,object,attributeNames);}});if(object.children.length){attributeNames.forEach(function(name){if(name in object.parsedStyle&&_this2.isPropertyInheritable(name)){// update children's inheritable
|
|
8882
|
+
if(needUpdateGeometry){this.updateGeometry(object);}attributeNames.forEach(function(name){if(name in object.parsedStyle){_this2.postProcessProperty(name,object,attributeNames);}});if(runtime.enableCSSParsing&&object.children.length){attributeNames.forEach(function(name){if(name in object.parsedStyle&&_this2.isPropertyInheritable(name)){// update children's inheritable
|
|
8921
8883
|
object.children.forEach(function(child){child.internalSetAttribute(name,null,{skipUpdateAttribute:true,skipParse:true});});}});}}/**
|
|
8922
8884
|
* string -> parsed value
|
|
8923
8885
|
*/;_proto.parseProperty=function parseProperty(name,value,object){var metadata=propertyMetadataCache[name];var computed=value;if(value===''||isNil(value)){value='unset';}if(value==='unset'||value==='initial'||value==='inherit'){// computed = new CSSKeywordValue(value);
|
|
@@ -8953,9 +8915,21 @@
|
|
|
8953
8915
|
*/;_proto.updateGeometry=function updateGeometry(object){var geometryUpdater=runtime.geometryUpdaterFactory[object.nodeName];if(geometryUpdater){var geometry=object.geometry;if(!geometry.contentBounds){geometry.contentBounds=new AABB();}if(!geometry.renderBounds){geometry.renderBounds=new AABB();}var parsedStyle=object.parsedStyle;var _geometryUpdater$upda=geometryUpdater.update(parsedStyle,object),width=_geometryUpdater$upda.width,height=_geometryUpdater$upda.height,_geometryUpdater$upda2=_geometryUpdater$upda.depth,depth=_geometryUpdater$upda2===void 0?0:_geometryUpdater$upda2,_geometryUpdater$upda3=_geometryUpdater$upda.offsetX,offsetX=_geometryUpdater$upda3===void 0?0:_geometryUpdater$upda3,_geometryUpdater$upda4=_geometryUpdater$upda.offsetY,offsetY=_geometryUpdater$upda4===void 0?0:_geometryUpdater$upda4,_geometryUpdater$upda5=_geometryUpdater$upda.offsetZ,offsetZ=_geometryUpdater$upda5===void 0?0:_geometryUpdater$upda5;// account for negative width / height of Rect
|
|
8954
8916
|
// @see https://github.com/antvis/g/issues/957
|
|
8955
8917
|
var flipY=width<0;var flipX=height<0;// init with content box
|
|
8956
|
-
var halfExtents=
|
|
8918
|
+
var halfExtents=[Math.abs(width)/2,Math.abs(height)/2,depth/2];// const halfExtents = vec3.set(
|
|
8919
|
+
// tmpVec3a,
|
|
8920
|
+
// Math.abs(width) / 2,
|
|
8921
|
+
// Math.abs(height) / 2,
|
|
8922
|
+
// depth / 2,
|
|
8923
|
+
// );
|
|
8924
|
+
// anchor is center by default, don't account for lineWidth here
|
|
8957
8925
|
var stroke=parsedStyle.stroke,lineWidth=parsedStyle.lineWidth,increasedLineWidthForHitTesting=parsedStyle.increasedLineWidthForHitTesting,shadowType=parsedStyle.shadowType,shadowColor=parsedStyle.shadowColor,_parsedStyle$filter=parsedStyle.filter,filter=_parsedStyle$filter===void 0?[]:_parsedStyle$filter,transformOrigin=parsedStyle.transformOrigin;var anchor=parsedStyle.anchor;// <Text> use textAlign & textBaseline instead of anchor
|
|
8958
|
-
if(object.nodeName===exports.Shape.TEXT){delete parsedStyle.anchor;}var center=
|
|
8926
|
+
if(object.nodeName===exports.Shape.TEXT){delete parsedStyle.anchor;}var center=[(1-(anchor&&anchor[0]||0)*2)*width/2+offsetX,(1-(anchor&&anchor[1]||0)*2)*height/2+offsetY,(1-(anchor&&anchor[2]||0)*2)*halfExtents[2]+offsetZ];// const center = vec3.set(
|
|
8927
|
+
// tmpVec3b,
|
|
8928
|
+
// ((1 - ((anchor && anchor[0]) || 0) * 2) * width) / 2 + offsetX,
|
|
8929
|
+
// ((1 - ((anchor && anchor[1]) || 0) * 2) * height) / 2 + offsetY,
|
|
8930
|
+
// (1 - ((anchor && anchor[2]) || 0) * 2) * halfExtents[2] + offsetZ,
|
|
8931
|
+
// );
|
|
8932
|
+
// update geometry's AABB
|
|
8959
8933
|
geometry.contentBounds.update(center,halfExtents);// @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
|
|
8960
8934
|
var expansion=object.nodeName===exports.Shape.POLYLINE||object.nodeName===exports.Shape.POLYGON||object.nodeName===exports.Shape.PATH?Math.SQRT2:0.5;// if (lineCap?.value === 'square') {
|
|
8961
8935
|
// expansion = Math.SQRT1_2;
|
|
@@ -8966,10 +8940,15 @@
|
|
|
8966
8940
|
// append border only if stroke existed
|
|
8967
8941
|
var hasStroke=stroke&&!stroke.isNone;if(hasStroke){var halfLineWidth=((lineWidth||0)+(increasedLineWidthForHitTesting||0))*expansion;// halfExtents[0] += halfLineWidth[0];
|
|
8968
8942
|
// halfExtents[1] += halfLineWidth[1];
|
|
8969
|
-
|
|
8943
|
+
halfExtents[0]+=halfLineWidth;halfExtents[1]+=halfLineWidth;// vec3.add(
|
|
8944
|
+
// halfExtents,
|
|
8945
|
+
// halfExtents,
|
|
8946
|
+
// vec3.set(tmpVec3c, halfLineWidth, halfLineWidth, 0),
|
|
8947
|
+
// );
|
|
8948
|
+
}geometry.renderBounds.update(center,halfExtents);// account for shadow, only support constant value now
|
|
8970
8949
|
if(shadowColor&&shadowType&&shadowType!=='inner'){var _geometry$renderBound=geometry.renderBounds,min=_geometry$renderBound.min,max=_geometry$renderBound.max;var shadowBlur=parsedStyle.shadowBlur,shadowOffsetX=parsedStyle.shadowOffsetX,shadowOffsetY=parsedStyle.shadowOffsetY;var shadowBlurInPixels=shadowBlur||0;var shadowOffsetXInPixels=shadowOffsetX||0;var shadowOffsetYInPixels=shadowOffsetY||0;var shadowLeft=min[0]-shadowBlurInPixels+shadowOffsetXInPixels;var shadowRight=max[0]+shadowBlurInPixels+shadowOffsetXInPixels;var shadowTop=min[1]-shadowBlurInPixels+shadowOffsetYInPixels;var shadowBottom=max[1]+shadowBlurInPixels+shadowOffsetYInPixels;min[0]=Math.min(min[0],shadowLeft);max[0]=Math.max(max[0],shadowRight);min[1]=Math.min(min[1],shadowTop);max[1]=Math.max(max[1],shadowBottom);geometry.renderBounds.setMinMax(min,max);}// account for filter, eg. blur(5px), drop-shadow()
|
|
8971
|
-
filter.forEach(function(_ref){var name=_ref.name,params=_ref.params;if(name==='blur'){var blurRadius=params[0].value;geometry.renderBounds.update(geometry.renderBounds.center,
|
|
8972
|
-
var usedOriginXValue=(flipY?-1:1)*convertPercentUnit(transformOrigin[0],0,object);var usedOriginYValue=(flipX?-1:1)*convertPercentUnit(transformOrigin[1],1,object);usedOriginXValue=usedOriginXValue-(flipY?-1:1)*(anchor&&anchor[0]||0)*geometry.contentBounds.halfExtents[0]*2;usedOriginYValue=usedOriginYValue-(flipX?-1:1)*(anchor&&anchor[1]||0)*geometry.contentBounds.halfExtents[1]*2;object.setOrigin(usedOriginXValue,usedOriginYValue);runtime.sceneGraphService.dirtifyToRoot(object);}};_proto.isPropertyInheritable=function isPropertyInheritable(name){var metadata=propertyMetadataCache[name];if(!metadata){return false;}return metadata.inh;};return DefaultStyleValueRegistry;}();/**
|
|
8950
|
+
filter.forEach(function(_ref){var name=_ref.name,params=_ref.params;if(name==='blur'){var blurRadius=params[0].value;geometry.renderBounds.update(geometry.renderBounds.center,addVec3(geometry.renderBounds.halfExtents,geometry.renderBounds.halfExtents,[blurRadius,blurRadius,0]));}else if(name==='drop-shadow'){var _shadowOffsetX=params[0].value;var _shadowOffsetY=params[1].value;var _shadowBlur=params[2].value;var _geometry$renderBound2=geometry.renderBounds,_min=_geometry$renderBound2.min,_max=_geometry$renderBound2.max;var _shadowLeft=_min[0]-_shadowBlur+_shadowOffsetX;var _shadowRight=_max[0]+_shadowBlur+_shadowOffsetX;var _shadowTop=_min[1]-_shadowBlur+_shadowOffsetY;var _shadowBottom=_max[1]+_shadowBlur+_shadowOffsetY;_min[0]=Math.min(_min[0],_shadowLeft);_max[0]=Math.max(_max[0],_shadowRight);_min[1]=Math.min(_min[1],_shadowTop);_max[1]=Math.max(_max[1],_shadowBottom);geometry.renderBounds.setMinMax(_min,_max);}});anchor=parsedStyle.anchor;// set transform origin
|
|
8951
|
+
var usedOriginXValue=(flipY?-1:1)*(transformOrigin?convertPercentUnit(transformOrigin[0],0,object):0);var usedOriginYValue=(flipX?-1:1)*(transformOrigin?convertPercentUnit(transformOrigin[1],1,object):0);usedOriginXValue=usedOriginXValue-(flipY?-1:1)*(anchor&&anchor[0]||0)*geometry.contentBounds.halfExtents[0]*2;usedOriginYValue=usedOriginYValue-(flipX?-1:1)*(anchor&&anchor[1]||0)*geometry.contentBounds.halfExtents[1]*2;object.setOrigin(usedOriginXValue,usedOriginYValue);runtime.sceneGraphService.dirtifyToRoot(object);}};_proto.isPropertyInheritable=function isPropertyInheritable(name){var metadata=propertyMetadataCache[name];if(!metadata){return false;}return metadata.inh;};return DefaultStyleValueRegistry;}();/**
|
|
8973
8952
|
* Different type of cameras, eg. simple camera used in 2D scene or
|
|
8974
8953
|
* advanced camera which can do actions & switch between landmarks.
|
|
8975
8954
|
*/(function(CameraType){/**
|
|
@@ -9170,9 +9149,9 @@
|
|
|
9170
9149
|
* - g-plugin-device-renderer `ctx.createLinearGradient` and generate texture
|
|
9171
9150
|
*
|
|
9172
9151
|
* @see https://blog.scottlogic.com/2020/03/19/offscreen-canvas.html
|
|
9173
|
-
*/var OffscreenCanvasCreator=/*#__PURE__*/function(){function OffscreenCanvasCreator(){this.canvas=void 0;this.context=void 0;}var _proto=OffscreenCanvasCreator.prototype;_proto.getOrCreateCanvas=function getOrCreateCanvas(offscreenCanvas){if(this.canvas){return this.canvas;}// user-defined offscreen canvas
|
|
9174
|
-
if(offscreenCanvas){this.canvas=offscreenCanvas;this.context=this.canvas.getContext('2d');}else {try{// OffscreenCanvas2D measureText can be up to 40% faster.
|
|
9175
|
-
this.canvas=new window.OffscreenCanvas(0,0);this.context=this.canvas.getContext('2d');if(!this.context||!this.context.measureText){this.canvas=document.createElement('canvas');this.context=this.canvas.getContext('2d');}}catch(ex){this.canvas=document.createElement('canvas');this.context=this.canvas.getContext('2d');}}this.canvas.width=10;this.canvas.height=10;return this.canvas;};_proto.getOrCreateContext=function getOrCreateContext(offscreenCanvas){if(this.context){return this.context;}this.getOrCreateCanvas(offscreenCanvas);return this.context;};return OffscreenCanvasCreator;}();/**
|
|
9152
|
+
*/var OffscreenCanvasCreator=/*#__PURE__*/function(){function OffscreenCanvasCreator(){this.canvas=void 0;this.context=void 0;}var _proto=OffscreenCanvasCreator.prototype;_proto.getOrCreateCanvas=function getOrCreateCanvas(offscreenCanvas,contextAttributes){if(this.canvas){return this.canvas;}// user-defined offscreen canvas
|
|
9153
|
+
if(offscreenCanvas){this.canvas=offscreenCanvas;this.context=this.canvas.getContext('2d',contextAttributes);}else {try{// OffscreenCanvas2D measureText can be up to 40% faster.
|
|
9154
|
+
this.canvas=new window.OffscreenCanvas(0,0);this.context=this.canvas.getContext('2d',contextAttributes);if(!this.context||!this.context.measureText){this.canvas=document.createElement('canvas');this.context=this.canvas.getContext('2d');}}catch(ex){this.canvas=document.createElement('canvas');this.context=this.canvas.getContext('2d',contextAttributes);}}this.canvas.width=10;this.canvas.height=10;return this.canvas;};_proto.getOrCreateContext=function getOrCreateContext(offscreenCanvas,contextAttributes){if(this.context){return this.context;}this.getOrCreateCanvas(offscreenCanvas,contextAttributes);return this.context;};return OffscreenCanvasCreator;}();/**
|
|
9176
9155
|
* why we need re-render
|
|
9177
9156
|
*/(function(RenderReason){RenderReason[RenderReason["CAMERA_CHANGED"]=0]="CAMERA_CHANGED";RenderReason[RenderReason["DISPLAY_OBJECT_CHANGED"]=1]="DISPLAY_OBJECT_CHANGED";RenderReason[RenderReason["NONE"]=2]="NONE";})(exports.RenderReason||(exports.RenderReason={}));/**
|
|
9178
9157
|
* Use frame renderer implemented by `g-canvas/svg/webgl`, in every frame we do followings:
|
|
@@ -9214,7 +9193,7 @@
|
|
|
9214
9193
|
* * camera changed
|
|
9215
9194
|
*/;_proto.disableDirtyRectangleRendering=function disableDirtyRectangleRendering(){var renderer=this.context.config.renderer;var _renderer$getConfig=renderer.getConfig(),enableDirtyRectangleRendering=_renderer$getConfig.enableDirtyRectangleRendering;return !enableDirtyRectangleRendering||this.context.renderingContext.renderReasons.has(exports.RenderReason.CAMERA_CHANGED);};_proto.render=function render(canvasConfig,rerenderCallback){var _this=this;this.stats.total=0;this.stats.rendered=0;this.zIndexCounter=0;var renderingContext=this.context.renderingContext;this.globalRuntime.sceneGraphService.syncHierarchy(renderingContext.root);this.globalRuntime.sceneGraphService.triggerPendingEvents();if(renderingContext.renderReasons.size&&this.inited){this.renderDisplayObject(renderingContext.root,canvasConfig,renderingContext);this.hooks.beginFrame.call();renderingContext.renderListCurrentFrame.forEach(function(object){_this.hooks.beforeRender.call(object);_this.hooks.render.call(object);_this.hooks.afterRender.call(object);});this.hooks.endFrame.call();renderingContext.renderListCurrentFrame=[];renderingContext.renderReasons.clear();rerenderCallback();}// console.log('stats', this.stats);
|
|
9216
9195
|
};_proto.renderDisplayObject=function renderDisplayObject(displayObject,canvasConfig,renderingContext){var _this2=this;var _canvasConfig$rendere=canvasConfig.renderer.getConfig(),enableDirtyCheck=_canvasConfig$rendere.enableDirtyCheck,enableCulling=_canvasConfig$rendere.enableCulling;// recalc style values
|
|
9217
|
-
this.globalRuntime.styleValueRegistry.recalc(displayObject)
|
|
9196
|
+
if(this.globalRuntime.enableCSSParsing){this.globalRuntime.styleValueRegistry.recalc(displayObject);}// TODO: relayout
|
|
9218
9197
|
// dirtycheck first
|
|
9219
9198
|
var objectChanged=enableDirtyCheck?this.hooks.dirtycheck.call(displayObject):displayObject;if(objectChanged){var objectToRender=enableCulling?this.hooks.cull.call(objectChanged,this.context.camera):objectChanged;if(objectToRender){this.stats.rendered++;renderingContext.renderListCurrentFrame.push(objectToRender);}}displayObject.renderable.dirty=false;displayObject.sortable.renderOrder=this.zIndexCounter++;this.stats.total++;// sort is very expensive, use cached result if posible
|
|
9220
9199
|
var sortable=displayObject.sortable;var renderOrderChanged=false;if(sortable.dirty){sortable.sorted=displayObject.childNodes.slice().sort(sortByZIndex);renderOrderChanged=true;sortable.dirty=false;}// recursive rendering its children
|
|
@@ -9372,7 +9351,7 @@
|
|
|
9372
9351
|
* `g-camera-api` will provide an advanced implementation
|
|
9373
9352
|
*/runtime.CameraContribution=Camera;/**
|
|
9374
9353
|
* `g-web-animations-api` will provide an AnimationTimeline
|
|
9375
|
-
*/runtime.AnimationTimeline=null;runtime.EasingFunction=null;runtime.offscreenCanvas=new OffscreenCanvasCreator();runtime.displayObjectPool=new DisplayObjectPool();runtime.sceneGraphSelector=new DefaultSceneGraphSelector();runtime.sceneGraphService=new DefaultSceneGraphService(runtime);runtime.textService=new TextService(runtime);runtime.geometryUpdaterFactory=geometryUpdaterFactory;runtime.CSSPropertySyntaxFactory=CSSPropertySyntaxFactory;runtime.styleValueRegistry=new DefaultStyleValueRegistry();runtime.layoutRegistry=null;runtime.globalThis=getGlobalThis();var AbstractRendererPlugin=/*#__PURE__*/function(){function AbstractRendererPlugin(){this.context=void 0;this.plugins=[];}var _proto=AbstractRendererPlugin.prototype;_proto.addRenderingPlugin=function addRenderingPlugin(plugin){this.plugins.push(plugin);this.context.renderingPlugins.push(plugin);};_proto.removeAllRenderingPlugins=function removeAllRenderingPlugins(){var _this=this;this.plugins.forEach(function(plugin){var index=_this.context.renderingPlugins.indexOf(plugin);if(index>=0){_this.context.renderingPlugins.splice(index,1);}});};return AbstractRendererPlugin;}();var AbstractRenderer=/*#__PURE__*/function(){function AbstractRenderer(config){this.plugins=[];this.config=void 0;this.config=_extends({/**
|
|
9354
|
+
*/runtime.AnimationTimeline=null;runtime.EasingFunction=null;runtime.offscreenCanvas=new OffscreenCanvasCreator();runtime.displayObjectPool=new DisplayObjectPool();runtime.sceneGraphSelector=new DefaultSceneGraphSelector();runtime.sceneGraphService=new DefaultSceneGraphService(runtime);runtime.textService=new TextService(runtime);runtime.geometryUpdaterFactory=geometryUpdaterFactory;runtime.CSSPropertySyntaxFactory=CSSPropertySyntaxFactory;runtime.styleValueRegistry=new DefaultStyleValueRegistry();runtime.layoutRegistry=null;runtime.globalThis=getGlobalThis();runtime.enableCSSParsing=true;var AbstractRendererPlugin=/*#__PURE__*/function(){function AbstractRendererPlugin(){this.context=void 0;this.plugins=[];}var _proto=AbstractRendererPlugin.prototype;_proto.addRenderingPlugin=function addRenderingPlugin(plugin){this.plugins.push(plugin);this.context.renderingPlugins.push(plugin);};_proto.removeAllRenderingPlugins=function removeAllRenderingPlugins(){var _this=this;this.plugins.forEach(function(plugin){var index=_this.context.renderingPlugins.indexOf(plugin);if(index>=0){_this.context.renderingPlugins.splice(index,1);}});};return AbstractRendererPlugin;}();var AbstractRenderer=/*#__PURE__*/function(){function AbstractRenderer(config){this.plugins=[];this.config=void 0;this.config=_extends({/**
|
|
9376
9355
|
* only dirty object will cause re-render
|
|
9377
9356
|
*/enableDirtyCheck:true,enableCulling:false,/**
|
|
9378
9357
|
* enable auto rendering by default
|
|
@@ -9444,8 +9423,8 @@
|
|
|
9444
9423
|
var _planes$k=planes[k],normal=_planes$k.normal,distance=_planes$k.distance;if(dot(normal,aabb.getPositiveFarPoint(planes[k]))+distance<0){return exports.Mask.OUTSIDE;}if(dot(normal,aabb.getNegativeFarPoint(planes[k]))+distance<0){// 和当前面相交,对应位置为1,继续检测下一个面
|
|
9445
9424
|
mask|=flag;}}return mask;};return FrustumCullingStrategy;}();var PrepareRendererPlugin=/*#__PURE__*/function(){function PrepareRendererPlugin(){this.rBush=void 0;this.toSync=new Set();}var _proto=PrepareRendererPlugin.prototype;// private isFirstTimeRendering = true;
|
|
9446
9425
|
_proto.apply=function apply(context){var _this=this;var renderingService=context.renderingService,renderingContext=context.renderingContext,rBushRoot=context.rBushRoot;var canvas=renderingContext.root.ownerDocument.defaultView;this.rBush=rBushRoot;var handleAttributeChanged=function handleAttributeChanged(e){var object=e.target;object.renderable.dirty=true;renderingService.dirtify();};var handleBoundsChanged=function handleBoundsChanged(e){var affectChildren=e.detail.affectChildren;var object=e.target;if(affectChildren){object.forEach(function(node){_this.toSync.add(node);});}var p=object;while(p){if(p.renderable){_this.toSync.add(p);}p=p.parentElement;}// this.pushToSync(e.composedPath().slice(0, -2) as DisplayObject[]);
|
|
9447
|
-
renderingService.dirtify();};var handleMounted=function handleMounted(e){var object=e.target
|
|
9448
|
-
runtime.styleValueRegistry.recalc(object);runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};var handleUnmounted=function handleUnmounted(e){var object=e.target;var rBushNode=object.rBushNode;if(rBushNode.aabb){_this.rBush.remove(rBushNode.aabb);}_this.toSync.delete(object);runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};renderingService.hooks.init.tapPromise(PrepareRendererPlugin.tag,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:canvas.addEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.addEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.addEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.addEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);case 4:case"end":return _context.stop();}}},_callee);})));renderingService.hooks.destroy.tap(PrepareRendererPlugin.tag,function(){canvas.removeEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.removeEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.removeEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);});renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag,function(){// if (this.isFirstTimeRendering) {
|
|
9426
|
+
renderingService.dirtify();};var handleMounted=function handleMounted(e){var object=e.target;if(runtime.enableCSSParsing){// recalc style values
|
|
9427
|
+
runtime.styleValueRegistry.recalc(object);}runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};var handleUnmounted=function handleUnmounted(e){var object=e.target;var rBushNode=object.rBushNode;if(rBushNode.aabb){_this.rBush.remove(rBushNode.aabb);}_this.toSync.delete(object);runtime.sceneGraphService.dirtifyToRoot(object);renderingService.dirtify();};renderingService.hooks.init.tapPromise(PrepareRendererPlugin.tag,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(){return _regeneratorRuntime().wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:canvas.addEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.addEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.addEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.addEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);case 4:case"end":return _context.stop();}}},_callee);})));renderingService.hooks.destroy.tap(PrepareRendererPlugin.tag,function(){canvas.removeEventListener(exports.ElementEvent.MOUNTED,handleMounted);canvas.removeEventListener(exports.ElementEvent.UNMOUNTED,handleUnmounted);canvas.removeEventListener(exports.ElementEvent.ATTR_MODIFIED,handleAttributeChanged);canvas.removeEventListener(exports.ElementEvent.BOUNDS_CHANGED,handleBoundsChanged);_this.toSync.clear();});renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag,function(){// if (this.isFirstTimeRendering) {
|
|
9449
9428
|
// // @see https://github.com/antvis/G/issues/1117
|
|
9450
9429
|
// setTimeout(() => this.syncRTree());
|
|
9451
9430
|
// this.isFirstTimeRendering = false;
|
|
@@ -9520,14 +9499,13 @@
|
|
|
9520
9499
|
// getComputedStyle(node: DisplayObject) {
|
|
9521
9500
|
// return node.computedStyle;
|
|
9522
9501
|
// }
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
if(destroyScenegraph){// destroy Document
|
|
9502
|
+
;/**
|
|
9503
|
+
* `cleanUp` means clean all the internal services of Canvas which happens when calling `canvas.destroy()`.
|
|
9504
|
+
*/_proto.destroy=function destroy(cleanUp,skipTriggerEvent){if(cleanUp===void 0){cleanUp=true;}if(skipTriggerEvent===void 0){skipTriggerEvent=false;}if(!skipTriggerEvent){this.dispatchEvent(new CustomEvent(exports.CanvasEvent.BEFORE_DESTROY));}if(this.frameId){var cancelRAF=this.getConfig().cancelAnimationFrame||cancelAnimationFrame;cancelRAF(this.frameId);}// unmount all children
|
|
9505
|
+
var root=this.getRoot();this.unmountChildren(root);if(cleanUp){// destroy Document
|
|
9528
9506
|
this.document.destroy();this.getEventService().destroy();}// destroy services
|
|
9529
9507
|
this.getRenderingService().destroy();this.getContextService().destroy();// clear root after renderservice destroyed
|
|
9530
|
-
if(
|
|
9508
|
+
if(cleanUp&&this.context.rBushRoot){// clear rbush
|
|
9531
9509
|
this.context.rBushRoot.clear();this.context.rBushRoot=null;this.context.renderingContext.root=null;}if(!skipTriggerEvent){this.dispatchEvent(new CustomEvent(exports.CanvasEvent.AFTER_DESTROY));}}/**
|
|
9532
9510
|
* compatible with G 3.0
|
|
9533
9511
|
* @deprecated
|
|
@@ -9540,6 +9518,7 @@
|
|
|
9540
9518
|
* Remove all children which can be appended to its original parent later again.
|
|
9541
9519
|
*/;_proto.removeChildren=function removeChildren(){this.document.documentElement.removeChildren();}/**
|
|
9542
9520
|
* Recursively destroy all children which can not be appended to its original parent later again.
|
|
9521
|
+
* But the canvas remains running which means display objects can be appended later.
|
|
9543
9522
|
*/;_proto.destroyChildren=function destroyChildren(){this.document.documentElement.destroyChildren();};_proto.render=function render(){var _this3=this;this.dispatchEvent(beforeRenderEvent);var renderingService=this.getRenderingService();renderingService.render(this.getConfig(),function(){// trigger actual rerender event
|
|
9544
9523
|
// @see https://github.com/antvis/G/issues/1268
|
|
9545
9524
|
_this3.dispatchEvent(rerenderEvent);});this.dispatchEvent(afterRenderEvent);};_proto.run=function run(){var _this4=this;var tick=function tick(){_this4.render();_this4.frameId=requestAnimationFrame(tick);};tick();};_proto.initRenderer=/*#__PURE__*/function(){var _initRenderer=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderer){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(renderer){_context2.next=2;break;}throw new Error('Renderer is required.');case 2:// reset
|
|
@@ -13177,6 +13156,7 @@
|
|
|
13177
13156
|
exports.DisplayObject = DisplayObject;
|
|
13178
13157
|
exports.DisplayObjectPool = DisplayObjectPool;
|
|
13179
13158
|
exports.Document = Document;
|
|
13159
|
+
exports.EMPTY_PARSED_PATH = EMPTY_PARSED_PATH;
|
|
13180
13160
|
exports.ERROR_MSG_METHOD_NOT_IMPLEMENTED = ERROR_MSG_METHOD_NOT_IMPLEMENTED;
|
|
13181
13161
|
exports.Element = Element;
|
|
13182
13162
|
exports.Ellipse = Ellipse;
|