@thednp/dommatrix
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -7,2 +7,4 @@ /// <reference types="cypress" /> | ||
const roundTo4 = (x: number) => Math.round(x * 10000) / 10000 | ||
describe('DOMMatrix Class Test', () => { | ||
@@ -115,4 +117,10 @@ | ||
expect(m1.is2D).to.equal(d1.is2D); | ||
expect(m1.toFloat32Array()).to.deep.equal(d1.toFloat32Array()); | ||
expect(m1.toFloat64Array()).to.deep.equal(d1.toFloat64Array()); | ||
// for some reason DOMMatrix in | ||
// expect(m1.toFloat32Array()).to.deep.equal(d1.toFloat32Array()); | ||
// expect(m1.toFloat64Array()).to.deep.equal(d1.toFloat64Array()); | ||
expect(Array.from(m1.toFloat32Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d1.toFloat32Array()).map(roundTo4)); | ||
expect(Array.from(m1.toFloat64Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d1.toFloat64Array()).map(roundTo4)); | ||
}); | ||
@@ -132,4 +140,10 @@ | ||
expect(m2.is2D).to.equal(d2.is2D); | ||
expect(m2.toFloat32Array()).to.deep.equal(d2.toFloat32Array()); | ||
expect(m2.toFloat64Array()).to.deep.equal(d2.toFloat64Array()); | ||
// same here | ||
// expect(m2.toFloat32Array()).to.deep.equal(d2.toFloat32Array()); | ||
// expect(m2.toFloat64Array()).to.deep.equal(d2.toFloat64Array()); | ||
expect(Array.from(m2.toFloat32Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d2.toFloat32Array()).map(roundTo4)); | ||
expect(Array.from(m2.toFloat64Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d2.toFloat64Array()).map(roundTo4)); | ||
}); | ||
@@ -149,4 +163,8 @@ | ||
expect(m3.is2D).to.equal(d3.is2D); | ||
expect(m3.toFloat32Array()).to.deep.equal(d3.toFloat32Array()); | ||
expect(m3.toFloat64Array()).to.deep.equal(d3.toFloat64Array()); | ||
// expect(m3.toFloat32Array()).to.deep.equal(d3.toFloat32Array()); | ||
// expect(m3.toFloat64Array()).to.deep.equal(d3.toFloat64Array()); | ||
expect(Array.from(m3.toFloat32Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d3.toFloat32Array()).map(roundTo4)); | ||
expect(Array.from(m3.toFloat64Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d3.toFloat64Array()).map(roundTo4)); | ||
}); | ||
@@ -166,4 +184,8 @@ | ||
expect(m4.is2D).to.equal(d4.is2D); | ||
expect(m4.toFloat32Array()).to.deep.equal(d4.toFloat32Array()); | ||
expect(m4.toFloat64Array()).to.deep.equal(d4.toFloat64Array()); | ||
// expect(m4.toFloat32Array()).to.deep.equal(d4.toFloat32Array()); | ||
// expect(m4.toFloat64Array()).to.deep.equal(d4.toFloat64Array()); | ||
expect(Array.from(m4.toFloat32Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d4.toFloat32Array()).map(roundTo4)); | ||
expect(Array.from(m4.toFloat64Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d4.toFloat64Array()).map(roundTo4)); | ||
}); | ||
@@ -182,4 +204,8 @@ | ||
expect(m5.is2D).to.equal(d5.is2D); | ||
expect(m5.toFloat32Array()).to.deep.equal(d5.toFloat32Array()); | ||
expect(m5.toFloat64Array()).to.deep.equal(d5.toFloat64Array()); | ||
// expect(m5.toFloat32Array()).to.deep.equal(d5.toFloat32Array()); | ||
// expect(m5.toFloat64Array()).to.deep.equal(d5.toFloat64Array()); | ||
expect(Array.from(m5.toFloat32Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d5.toFloat32Array()).map(roundTo4)); | ||
expect(Array.from(m5.toFloat64Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d5.toFloat64Array()).map(roundTo4)); | ||
}); | ||
@@ -198,4 +224,8 @@ | ||
expect(m6.is2D).to.equal(d6.is2D); | ||
expect(m6.toFloat32Array()).to.deep.equal(d6.toFloat32Array()); | ||
expect(m6.toFloat64Array()).to.deep.equal(d6.toFloat64Array()); | ||
// expect(m6.toFloat32Array()).to.deep.equal(d6.toFloat32Array()); | ||
// expect(m6.toFloat64Array()).to.deep.equal(d6.toFloat64Array()); | ||
expect(Array.from(m6.toFloat32Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d6.toFloat32Array()).map(roundTo4)); | ||
expect(Array.from(m6.toFloat64Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(d6.toFloat64Array()).map(roundTo4)); | ||
}); | ||
@@ -293,6 +323,7 @@ | ||
}); | ||
cy.log('Due to the nature of the native DOMMatrix RegExp, for consistency reasons we\'re rounding numbers to 6 decimals in this test.') | ||
expect(Array.from(css.toFloat32Array()).map(x=> Math.floor(x * 10**6) / 10**6)) | ||
.to.deep.equal(Array.from(dom.toFloat32Array()).map(x=> Math.floor(x * 10**6) / 10**6)); | ||
expect(Array.from(css.toFloat32Array()).map(roundTo4)) | ||
.to.deep.equal(Array.from(dom.toFloat32Array()).map(roundTo4)); | ||
@@ -305,4 +336,2 @@ cy.wrap(css).as('css') | ||
}) | ||
}); | ||
}); |
@@ -104,9 +104,9 @@ /** A DOMMPoint compatible Tuple. */ | ||
static Skew: (angleX: number, angleY: number) => CSSMatrix; | ||
static Multiply: (m1: DOMMatrix | JSONMatrix | CSSMatrix, m2: DOMMatrix | JSONMatrix | CSSMatrix) => CSSMatrix; | ||
static Multiply: (m1: CSSMatrix | DOMMatrix | JSONMatrix, m2: CSSMatrix | DOMMatrix | JSONMatrix) => CSSMatrix; | ||
static fromArray: (array: any[] | Float32Array | Float64Array) => CSSMatrix; | ||
static fromMatrix: (m: DOMMatrix | JSONMatrix | CSSMatrix) => CSSMatrix; | ||
static fromMatrix: (m: CSSMatrix | DOMMatrix | JSONMatrix) => CSSMatrix; | ||
static fromString: (source: string) => CSSMatrix; | ||
static toArray: (m: DOMMatrix | JSONMatrix | CSSMatrix, is2D?: boolean | undefined) => Matrix | Matrix3d; | ||
static isCompatibleArray: (array?: unknown) => array is Float32Array | Float64Array | Matrix | Matrix3d; | ||
static isCompatibleObject: (object?: unknown) => object is DOMMatrix | JSONMatrix | CSSMatrix; | ||
static toArray: (m: CSSMatrix | DOMMatrix | JSONMatrix, is2D?: boolean) => Matrix | Matrix3d; | ||
static isCompatibleArray: (array?: unknown) => array is Matrix | Matrix3d | Float32Array | Float64Array; | ||
static isCompatibleObject: (object?: unknown) => object is CSSMatrix | DOMMatrix | JSONMatrix; | ||
/** | ||
@@ -113,0 +113,0 @@ * @constructor |
@@ -1,2 +0,2 @@ | ||
var CSSMatrix=function(){"use strict";var z=Object.defineProperty;var S=(v,N,g)=>N in v?z(v,N,{enumerable:!0,configurable:!0,writable:!0,value:g}):v[N]=g;var p=(v,N,g)=>(S(v,typeof N!="symbol"?N+"":N,g),g);const v={a:1,b:0,c:0,d:1,e:0,f:0,m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:0,m42:0,m43:0,m44:1,is2D:!0,isIdentity:!0},N=s=>(s instanceof Float64Array||s instanceof Float32Array||Array.isArray(s)&&s.every(t=>typeof t=="number"))&&[6,16].some(t=>s.length===t),g=s=>s instanceof DOMMatrix||s instanceof f||typeof s=="object"&&Object.keys(v).every(t=>s&&t in s),k=s=>{const t=new f,e=Array.from(s);if(!N(e))throw TypeError(`CSSMatrix: "${e.join(",")}" must be an array with 6/16 numbers.`);if(e.length===16){const[n,i,r,a,l,m,h,c,y,u,w,o,d,A,M,x]=e;t.m11=n,t.a=n,t.m21=l,t.c=l,t.m31=y,t.m41=d,t.e=d,t.m12=i,t.b=i,t.m22=m,t.d=m,t.m32=u,t.m42=A,t.f=A,t.m13=r,t.m23=h,t.m33=w,t.m43=M,t.m14=a,t.m24=c,t.m34=o,t.m44=x}else if(e.length===6){const[n,i,r,a,l,m]=e;t.m11=n,t.a=n,t.m12=i,t.b=i,t.m21=r,t.c=r,t.m22=a,t.d=a,t.m41=l,t.e=l,t.m42=m,t.f=m}return t},Y=s=>{if(g(s))return k([s.m11,s.m12,s.m13,s.m14,s.m21,s.m22,s.m23,s.m24,s.m31,s.m32,s.m33,s.m34,s.m41,s.m42,s.m43,s.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)},F=s=>{if(typeof s!="string")throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a string.`);const t=String(s).replace(/\s/g,"");let e=new f;const n=`CSSMatrix: invalid transform string "${s}"`;return t.split(")").filter(i=>i).forEach(i=>{const[r,a]=i.split("(");if(!a)throw TypeError(n);const l=a.split(",").map(o=>o.includes("rad")?parseFloat(o)*(180/Math.PI):parseFloat(o)),[m,h,c,y]=l,u=[m,h,c],w=[m,h,c,y];if(r==="perspective"&&m&&[h,c].every(o=>o===void 0))e.m34=-1/m;else if(r.includes("matrix")&&[6,16].includes(l.length)&&l.every(o=>!Number.isNaN(+o))){const o=l.map(d=>Math.abs(d)<1e-6?0:d);e=e.multiply(k(o))}else if(r==="translate3d"&&u.every(o=>!Number.isNaN(+o)))e=e.translate(m,h,c);else if(r==="translate"&&m&&c===void 0)e=e.translate(m,h||0,0);else if(r==="rotate3d"&&w.every(o=>!Number.isNaN(+o))&&y)e=e.rotateAxisAngle(m,h,c,y);else if(r==="rotate"&&m&&[h,c].every(o=>o===void 0))e=e.rotate(0,0,m);else if(r==="scale3d"&&u.every(o=>!Number.isNaN(+o))&&u.some(o=>o!==1))e=e.scale(m,h,c);else if(r==="scale"&&!Number.isNaN(m)&&m!==1&&c===void 0){const d=Number.isNaN(+h)?m:h;e=e.scale(m,d,1)}else if(r==="skew"&&(m||!Number.isNaN(m)&&h)&&c===void 0)e=e.skew(m,h||0);else if(["translate","rotate","scale","skew"].some(o=>r.includes(o))&&/[XYZ]/.test(r)&&m&&[h,c].every(o=>o===void 0))if(r==="skewX"||r==="skewY")e=e[r](m);else{const o=r.replace(/[XYZ]/,""),d=r.replace(o,""),A=["X","Y","Z"].indexOf(d),M=o==="scale"?1:0,x=[A===0?m:M,A===1?m:M,A===2?m:M];e=e[o](...x)}else throw TypeError(n)}),e},O=(s,t)=>t?[s.a,s.b,s.c,s.d,s.e,s.f]:[s.m11,s.m12,s.m13,s.m14,s.m21,s.m22,s.m23,s.m24,s.m31,s.m32,s.m33,s.m34,s.m41,s.m42,s.m43,s.m44],T=(s,t,e)=>{const n=new f;return n.m41=s,n.e=s,n.m42=t,n.f=t,n.m43=e,n},I=(s,t,e)=>{const n=new f,i=Math.PI/180,r=s*i,a=t*i,l=e*i,m=Math.cos(r),h=-Math.sin(r),c=Math.cos(a),y=-Math.sin(a),u=Math.cos(l),w=-Math.sin(l),o=c*u,d=-c*w;n.m11=o,n.a=o,n.m12=d,n.b=d,n.m13=y;const A=h*y*u+m*w;n.m21=A,n.c=A;const M=m*u-h*y*w;return n.m22=M,n.d=M,n.m23=-h*c,n.m31=h*w-m*y*u,n.m32=h*u+m*y*w,n.m33=m*c,n},R=(s,t,e,n)=>{const i=new f,r=Math.sqrt(s*s+t*t+e*e);if(r===0)return i;const a=s/r,l=t/r,m=e/r,h=n*(Math.PI/360),c=Math.sin(h),y=Math.cos(h),u=c*c,w=a*a,o=l*l,d=m*m,A=1-2*(o+d)*u;i.m11=A,i.a=A;const M=2*(a*l*u+m*c*y);i.m12=M,i.b=M,i.m13=2*(a*m*u-l*c*y);const x=2*(l*a*u-m*c*y);i.m21=x,i.c=x;const Z=1-2*(d+w)*u;return i.m22=Z,i.d=Z,i.m23=2*(l*m*u+a*c*y),i.m31=2*(m*a*u+l*c*y),i.m32=2*(m*l*u-a*c*y),i.m33=1-2*(w+o)*u,i},D=(s,t,e)=>{const n=new f;return n.m11=s,n.a=s,n.m22=t,n.d=t,n.m33=e,n},X=(s,t)=>{const e=new f;if(s){const n=s*Math.PI/180,i=Math.tan(n);e.m21=i,e.c=i}if(t){const n=t*Math.PI/180,i=Math.tan(n);e.m12=i,e.b=i}return e},E=s=>X(s,0),P=s=>X(0,s),b=(s,t)=>{const e=t.m11*s.m11+t.m12*s.m21+t.m13*s.m31+t.m14*s.m41,n=t.m11*s.m12+t.m12*s.m22+t.m13*s.m32+t.m14*s.m42,i=t.m11*s.m13+t.m12*s.m23+t.m13*s.m33+t.m14*s.m43,r=t.m11*s.m14+t.m12*s.m24+t.m13*s.m34+t.m14*s.m44,a=t.m21*s.m11+t.m22*s.m21+t.m23*s.m31+t.m24*s.m41,l=t.m21*s.m12+t.m22*s.m22+t.m23*s.m32+t.m24*s.m42,m=t.m21*s.m13+t.m22*s.m23+t.m23*s.m33+t.m24*s.m43,h=t.m21*s.m14+t.m22*s.m24+t.m23*s.m34+t.m24*s.m44,c=t.m31*s.m11+t.m32*s.m21+t.m33*s.m31+t.m34*s.m41,y=t.m31*s.m12+t.m32*s.m22+t.m33*s.m32+t.m34*s.m42,u=t.m31*s.m13+t.m32*s.m23+t.m33*s.m33+t.m34*s.m43,w=t.m31*s.m14+t.m32*s.m24+t.m33*s.m34+t.m34*s.m44,o=t.m41*s.m11+t.m42*s.m21+t.m43*s.m31+t.m44*s.m41,d=t.m41*s.m12+t.m42*s.m22+t.m43*s.m32+t.m44*s.m42,A=t.m41*s.m13+t.m42*s.m23+t.m43*s.m33+t.m44*s.m43,M=t.m41*s.m14+t.m42*s.m24+t.m43*s.m34+t.m44*s.m44;return k([e,n,i,r,a,l,m,h,c,y,u,w,o,d,A,M])};class f{constructor(t){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,t?this.setMatrixValue(t):this}get isIdentity(){return this.m11===1&&this.m12===0&&this.m13===0&&this.m14===0&&this.m21===0&&this.m22===1&&this.m23===0&&this.m24===0&&this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m41===0&&this.m42===0&&this.m43===0&&this.m44===1}get is2D(){return this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m43===0&&this.m44===1}setMatrixValue(t){return typeof t=="string"&&t.length&&t!=="none"?F(t):Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array?k(t):typeof t=="object"?Y(t):this}toFloat32Array(t){return Float32Array.from(O(this,t))}toFloat64Array(t){return Float64Array.from(O(this,t))}toString(){const{is2D:t}=this,e=this.toFloat64Array(t).join(", ");return`${t?"matrix":"matrix3d"}(${e})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return b(this,t)}translate(t,e,n){const i=t;let r=e,a=n;return typeof r>"u"&&(r=0),typeof a>"u"&&(a=0),b(this,T(i,r,a))}scale(t,e,n){const i=t;let r=e,a=n;return typeof r>"u"&&(r=t),typeof a>"u"&&(a=1),b(this,D(i,r,a))}rotate(t,e,n){let i=t,r=e||0,a=n||0;return typeof t=="number"&&typeof e>"u"&&typeof n>"u"&&(a=i,i=0,r=0),b(this,I(i,r,a))}rotateAxisAngle(t,e,n,i){if([t,e,n,i].some(r=>Number.isNaN(+r)))throw new TypeError("CSSMatrix: expecting 4 values");return b(this,R(t,e,n,i))}skewX(t){return b(this,E(t))}skewY(t){return b(this,P(t))}skew(t,e){return b(this,X(t,e))}transformPoint(t){const e=this.m11*t.x+this.m21*t.y+this.m31*t.z+this.m41*t.w,n=this.m12*t.x+this.m22*t.y+this.m32*t.z+this.m42*t.w,i=this.m13*t.x+this.m23*t.y+this.m33*t.z+this.m43*t.w,r=this.m14*t.x+this.m24*t.y+this.m34*t.z+this.m44*t.w;return t instanceof DOMPoint?new DOMPoint(e,n,i,r):{x:e,y:n,z:i,w:r}}}return p(f,"Translate",T),p(f,"Rotate",I),p(f,"RotateAxisAngle",R),p(f,"Scale",D),p(f,"SkewX",E),p(f,"SkewY",P),p(f,"Skew",X),p(f,"Multiply",b),p(f,"fromArray",k),p(f,"fromMatrix",Y),p(f,"fromString",F),p(f,"toArray",O),p(f,"isCompatibleArray",N),p(f,"isCompatibleObject",g),f}(); | ||
var CSSMatrix=function(){"use strict";var z=Object.defineProperty;var S=(g,N,v)=>N in g?z(g,N,{enumerable:!0,configurable:!0,writable:!0,value:v}):g[N]=v;var p=(g,N,v)=>S(g,typeof N!="symbol"?N+"":N,v);const g={a:1,b:0,c:0,d:1,e:0,f:0,m11:1,m12:0,m13:0,m14:0,m21:0,m22:1,m23:0,m24:0,m31:0,m32:0,m33:1,m34:0,m41:0,m42:0,m43:0,m44:1,is2D:!0,isIdentity:!0},N=s=>(s instanceof Float64Array||s instanceof Float32Array||Array.isArray(s)&&s.every(t=>typeof t=="number"))&&[6,16].some(t=>s.length===t),v=s=>s instanceof DOMMatrix||s instanceof f||typeof s=="object"&&Object.keys(g).every(t=>s&&t in s),k=s=>{const t=new f,e=Array.from(s);if(!N(e))throw TypeError(`CSSMatrix: "${e.join(",")}" must be an array with 6/16 numbers.`);if(e.length===16){const[n,i,r,a,l,m,h,c,y,u,w,o,d,A,M,x]=e;t.m11=n,t.a=n,t.m21=l,t.c=l,t.m31=y,t.m41=d,t.e=d,t.m12=i,t.b=i,t.m22=m,t.d=m,t.m32=u,t.m42=A,t.f=A,t.m13=r,t.m23=h,t.m33=w,t.m43=M,t.m14=a,t.m24=c,t.m34=o,t.m44=x}else if(e.length===6){const[n,i,r,a,l,m]=e;t.m11=n,t.a=n,t.m12=i,t.b=i,t.m21=r,t.c=r,t.m22=a,t.d=a,t.m41=l,t.e=l,t.m42=m,t.f=m}return t},Y=s=>{if(v(s))return k([s.m11,s.m12,s.m13,s.m14,s.m21,s.m22,s.m23,s.m24,s.m31,s.m32,s.m33,s.m34,s.m41,s.m42,s.m43,s.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)},F=s=>{if(typeof s!="string")throw TypeError(`CSSMatrix: "${JSON.stringify(s)}" is not a string.`);const t=String(s).replace(/\s/g,"");let e=new f;const n=`CSSMatrix: invalid transform string "${s}"`;return t.split(")").filter(i=>i).forEach(i=>{const[r,a]=i.split("(");if(!a)throw TypeError(n);const l=a.split(",").map(o=>o.includes("rad")?parseFloat(o)*(180/Math.PI):parseFloat(o)),[m,h,c,y]=l,u=[m,h,c],w=[m,h,c,y];if(r==="perspective"&&m&&[h,c].every(o=>o===void 0))e.m34=-1/m;else if(r.includes("matrix")&&[6,16].includes(l.length)&&l.every(o=>!Number.isNaN(+o))){const o=l.map(d=>Math.abs(d)<1e-6?0:d);e=e.multiply(k(o))}else if(r==="translate3d"&&u.every(o=>!Number.isNaN(+o)))e=e.translate(m,h,c);else if(r==="translate"&&m&&c===void 0)e=e.translate(m,h||0,0);else if(r==="rotate3d"&&w.every(o=>!Number.isNaN(+o))&&y)e=e.rotateAxisAngle(m,h,c,y);else if(r==="rotate"&&m&&[h,c].every(o=>o===void 0))e=e.rotate(0,0,m);else if(r==="scale3d"&&u.every(o=>!Number.isNaN(+o))&&u.some(o=>o!==1))e=e.scale(m,h,c);else if(r==="scale"&&!Number.isNaN(m)&&m!==1&&c===void 0){const d=Number.isNaN(+h)?m:h;e=e.scale(m,d,1)}else if(r==="skew"&&(m||!Number.isNaN(m)&&h)&&c===void 0)e=e.skew(m,h||0);else if(["translate","rotate","scale","skew"].some(o=>r.includes(o))&&/[XYZ]/.test(r)&&m&&[h,c].every(o=>o===void 0))if(r==="skewX"||r==="skewY")e=e[r](m);else{const o=r.replace(/[XYZ]/,""),d=r.replace(o,""),A=["X","Y","Z"].indexOf(d),M=o==="scale"?1:0,x=[A===0?m:M,A===1?m:M,A===2?m:M];e=e[o](...x)}else throw TypeError(n)}),e},O=(s,t)=>t?[s.a,s.b,s.c,s.d,s.e,s.f]:[s.m11,s.m12,s.m13,s.m14,s.m21,s.m22,s.m23,s.m24,s.m31,s.m32,s.m33,s.m34,s.m41,s.m42,s.m43,s.m44],T=(s,t,e)=>{const n=new f;return n.m41=s,n.e=s,n.m42=t,n.f=t,n.m43=e,n},I=(s,t,e)=>{const n=new f,i=Math.PI/180,r=s*i,a=t*i,l=e*i,m=Math.cos(r),h=-Math.sin(r),c=Math.cos(a),y=-Math.sin(a),u=Math.cos(l),w=-Math.sin(l),o=c*u,d=-c*w;n.m11=o,n.a=o,n.m12=d,n.b=d,n.m13=y;const A=h*y*u+m*w;n.m21=A,n.c=A;const M=m*u-h*y*w;return n.m22=M,n.d=M,n.m23=-h*c,n.m31=h*w-m*y*u,n.m32=h*u+m*y*w,n.m33=m*c,n},R=(s,t,e,n)=>{const i=new f,r=Math.sqrt(s*s+t*t+e*e);if(r===0)return i;const a=s/r,l=t/r,m=e/r,h=n*(Math.PI/360),c=Math.sin(h),y=Math.cos(h),u=c*c,w=a*a,o=l*l,d=m*m,A=1-2*(o+d)*u;i.m11=A,i.a=A;const M=2*(a*l*u+m*c*y);i.m12=M,i.b=M,i.m13=2*(a*m*u-l*c*y);const x=2*(l*a*u-m*c*y);i.m21=x,i.c=x;const Z=1-2*(d+w)*u;return i.m22=Z,i.d=Z,i.m23=2*(l*m*u+a*c*y),i.m31=2*(m*a*u+l*c*y),i.m32=2*(m*l*u-a*c*y),i.m33=1-2*(w+o)*u,i},D=(s,t,e)=>{const n=new f;return n.m11=s,n.a=s,n.m22=t,n.d=t,n.m33=e,n},X=(s,t)=>{const e=new f;if(s){const n=s*Math.PI/180,i=Math.tan(n);e.m21=i,e.c=i}if(t){const n=t*Math.PI/180,i=Math.tan(n);e.m12=i,e.b=i}return e},E=s=>X(s,0),P=s=>X(0,s),b=(s,t)=>{const e=t.m11*s.m11+t.m12*s.m21+t.m13*s.m31+t.m14*s.m41,n=t.m11*s.m12+t.m12*s.m22+t.m13*s.m32+t.m14*s.m42,i=t.m11*s.m13+t.m12*s.m23+t.m13*s.m33+t.m14*s.m43,r=t.m11*s.m14+t.m12*s.m24+t.m13*s.m34+t.m14*s.m44,a=t.m21*s.m11+t.m22*s.m21+t.m23*s.m31+t.m24*s.m41,l=t.m21*s.m12+t.m22*s.m22+t.m23*s.m32+t.m24*s.m42,m=t.m21*s.m13+t.m22*s.m23+t.m23*s.m33+t.m24*s.m43,h=t.m21*s.m14+t.m22*s.m24+t.m23*s.m34+t.m24*s.m44,c=t.m31*s.m11+t.m32*s.m21+t.m33*s.m31+t.m34*s.m41,y=t.m31*s.m12+t.m32*s.m22+t.m33*s.m32+t.m34*s.m42,u=t.m31*s.m13+t.m32*s.m23+t.m33*s.m33+t.m34*s.m43,w=t.m31*s.m14+t.m32*s.m24+t.m33*s.m34+t.m34*s.m44,o=t.m41*s.m11+t.m42*s.m21+t.m43*s.m31+t.m44*s.m41,d=t.m41*s.m12+t.m42*s.m22+t.m43*s.m32+t.m44*s.m42,A=t.m41*s.m13+t.m42*s.m23+t.m43*s.m33+t.m44*s.m43,M=t.m41*s.m14+t.m42*s.m24+t.m43*s.m34+t.m44*s.m44;return k([e,n,i,r,a,l,m,h,c,y,u,w,o,d,A,M])};class f{constructor(t){return this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,this.m11=1,this.m12=0,this.m13=0,this.m14=0,this.m21=0,this.m22=1,this.m23=0,this.m24=0,this.m31=0,this.m32=0,this.m33=1,this.m34=0,this.m41=0,this.m42=0,this.m43=0,this.m44=1,t?this.setMatrixValue(t):this}get isIdentity(){return this.m11===1&&this.m12===0&&this.m13===0&&this.m14===0&&this.m21===0&&this.m22===1&&this.m23===0&&this.m24===0&&this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m41===0&&this.m42===0&&this.m43===0&&this.m44===1}get is2D(){return this.m31===0&&this.m32===0&&this.m33===1&&this.m34===0&&this.m43===0&&this.m44===1}setMatrixValue(t){return typeof t=="string"&&t.length&&t!=="none"?F(t):Array.isArray(t)||t instanceof Float64Array||t instanceof Float32Array?k(t):typeof t=="object"?Y(t):this}toFloat32Array(t){return Float32Array.from(O(this,t))}toFloat64Array(t){return Float64Array.from(O(this,t))}toString(){const{is2D:t}=this,e=this.toFloat64Array(t).join(", ");return`${t?"matrix":"matrix3d"}(${e})`}toJSON(){const{is2D:t,isIdentity:e}=this;return{...this,is2D:t,isIdentity:e}}multiply(t){return b(this,t)}translate(t,e,n){const i=t;let r=e,a=n;return typeof r>"u"&&(r=0),typeof a>"u"&&(a=0),b(this,T(i,r,a))}scale(t,e,n){const i=t;let r=e,a=n;return typeof r>"u"&&(r=t),typeof a>"u"&&(a=1),b(this,D(i,r,a))}rotate(t,e,n){let i=t,r=e||0,a=n||0;return typeof t=="number"&&typeof e>"u"&&typeof n>"u"&&(a=i,i=0,r=0),b(this,I(i,r,a))}rotateAxisAngle(t,e,n,i){if([t,e,n,i].some(r=>Number.isNaN(+r)))throw new TypeError("CSSMatrix: expecting 4 values");return b(this,R(t,e,n,i))}skewX(t){return b(this,E(t))}skewY(t){return b(this,P(t))}skew(t,e){return b(this,X(t,e))}transformPoint(t){const e=this.m11*t.x+this.m21*t.y+this.m31*t.z+this.m41*t.w,n=this.m12*t.x+this.m22*t.y+this.m32*t.z+this.m42*t.w,i=this.m13*t.x+this.m23*t.y+this.m33*t.z+this.m43*t.w,r=this.m14*t.x+this.m24*t.y+this.m34*t.z+this.m44*t.w;return t instanceof DOMPoint?new DOMPoint(e,n,i,r):{x:e,y:n,z:i,w:r}}}return p(f,"Translate",T),p(f,"Rotate",I),p(f,"RotateAxisAngle",R),p(f,"Scale",D),p(f,"SkewX",E),p(f,"SkewY",P),p(f,"Skew",X),p(f,"Multiply",b),p(f,"fromArray",k),p(f,"fromMatrix",Y),p(f,"fromString",F),p(f,"toArray",O),p(f,"isCompatibleArray",N),p(f,"isCompatibleObject",v),f}(); | ||
//# sourceMappingURL=dommatrix.js.map |
{ | ||
"name": "@thednp/dommatrix", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "TypeScript shim for DOMMatrix", | ||
@@ -24,2 +24,3 @@ "homepage": "https://thednp.github.io/dommatrix/", | ||
"coverage:report": "nyc report --reporter=lcov --reporter=json --reporter=text --reporter=json-summary", | ||
"badges": "npx -p dependency-version-badge update-badge eslint typescript cypress eslint prettier vite", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
@@ -30,3 +31,4 @@ "lint:ts": "eslint -c .eslintrc.cjs --ext .ts src", | ||
"dts": "dts-bundle-generator --config ./dts.config.ts", | ||
"docs": "ncp dist/dommatrix.js docs/dommatrix.js && ncp dist/dommatrix.js.map docs/dommatrix.js.map" | ||
"docs": "ncp dist/dommatrix.js docs/dommatrix.js && ncp dist/dommatrix.js.map docs/dommatrix.js.map", | ||
"prepublishOnly": "npm update && npm run format && npm run lint:ts && npm run build && npm run badges" | ||
}, | ||
@@ -61,4 +63,4 @@ "repository": { | ||
"@typescript-eslint/parser": "^5.61.0", | ||
"cypress": "^12.16.0", | ||
"dts-bundle-generator": "^8.0.1", | ||
"cypress": "^13.13.1", | ||
"dts-bundle-generator": "^8.1.2", | ||
"eslint": "^8.44.0", | ||
@@ -74,5 +76,5 @@ "eslint-plugin-jsdoc": "^46.4.3", | ||
"rimraf": "^5.0.1", | ||
"typescript": "^5.1.6", | ||
"vite": "^4.3.9" | ||
"typescript": "^5.5.4", | ||
"vite": "^5.3.5" | ||
} | ||
} |
@@ -7,6 +7,6 @@ # DOMMatrix | ||
[![jsDeliver](https://data.jsdelivr.com/v1/package/npm/@thednp/dommatrix/badge)](https://www.jsdelivr.com/package/npm/@thednp/dommatrix) | ||
[![typescript version](https://img.shields.io/badge/typescript-5.1.6-brightgreen)](https://www.typescriptlang.org/) | ||
[![cypress version](https://img.shields.io/badge/cypress-12.16.0-brightgreen)](https://www.cypress.io/) | ||
[![typescript version](https://img.shields.io/badge/typescript-5.5.4-brightgreen)](https://www.typescriptlang.org/) | ||
[![cypress version](https://img.shields.io/badge/cypress-13.13.1-brightgreen)](https://www.cypress.io/) | ||
[![eslint version](https://img.shields.io/badge/eslint-8.44.0-brightgreen)](https://github.com/eslint) | ||
[![vite version](https://img.shields.io/badge/vite-4.3.9-brightgreen)](https://vitejs.dev/) | ||
[![vite version](https://img.shields.io/badge/vite-5.3.5-brightgreen)](https://vitejs.dev/) | ||
[![prettier version](https://img.shields.io/badge/prettier-2.8.8-brightgreen)](https://prettier.io/) | ||
@@ -13,0 +13,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"lib": ["DOM", "ESNext", "DOM.Iterable"], | ||
"types": ["vite", "vite/client", "cypress"], | ||
// "types": ["vite", "vite/client", "cypress"], | ||
"rootDir": "./src", | ||
@@ -11,3 +11,3 @@ "baseUrl": "./", | ||
"target": "ESNext", | ||
"moduleResolution": "Node", | ||
"moduleResolution": "Bundler", | ||
"allowJs": true, | ||
@@ -30,3 +30,3 @@ "forceConsistentCasingInFileNames": true, | ||
"include": ["src/*"], | ||
"exclude": ["node_modules", "experiments", "coverage"], | ||
"exclude": ["node_modules", "experiments", "coverage"] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
236875
2392