Comparing version 1.0.2 to 1.0.3
/*! | ||
* DOMMatrix v1.0.2 (https://thednp.github.io/dommatrix/) | ||
* DOMMatrix v1.0.3 (https://thednp.github.io/dommatrix/) | ||
* Copyright 2022 © thednp | ||
@@ -505,3 +505,3 @@ * Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE) | ||
if (args && args.length) { | ||
if (args.length) { | ||
const ARGS = [16, 6].some((l) => l === args.length) ? args : args[0]; | ||
@@ -806,6 +806,4 @@ | ||
var version = "1.0.2"; | ||
var version = "1.0.3"; | ||
// @ts-ignore | ||
/** | ||
@@ -817,4 +815,6 @@ * A global namespace for library version. | ||
/** @typedef {import('../types/index')} */ | ||
Object.assign(CSSMatrix, { Version }); | ||
export { CSSMatrix as default }; |
@@ -1,2 +0,2 @@ | ||
// DOMMatrix v1.0.2 | thednp © 2022 | MIT-License | ||
function m(m){const t=new f,e=Array.from(m);if(!e.every(m=>!Number.isNaN(m)))throw TypeError(`CSSMatrix: "${m}" must only have numbers.`);if(16===e.length){const[m,r,n,s,i,o,a,c,l,u,f,h,y,d,w,M]=e;t.m11=m,t.a=m,t.m21=i,t.c=i,t.m31=l,t.m41=y,t.e=y,t.m12=r,t.b=r,t.m22=o,t.d=o,t.m32=u,t.m42=d,t.f=d,t.m13=n,t.m23=a,t.m33=f,t.m43=w,t.m14=s,t.m24=c,t.m34=h,t.m44=M}else{if(6!==e.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[m,r,n,s,i,o]=e;t.m11=m,t.a=m,t.m12=r,t.b=r,t.m21=n,t.c=n,t.m22=s,t.d=s,t.m41=i,t.e=i,t.m42=o,t.f=o}}return t}function t(t){const e=Object.keys(new f);if("object"==typeof t&&e.every(m=>m in t))return m([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(t)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)}function e(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let r=new f;const n=`CSSMatrix: invalid transform string "${t}"`;return e.split(")").filter(m=>m).forEach(t=>{const[e,s]=t.split("(");if(!s)throw TypeError(n);const i=s.split(",").map(m=>m.includes("rad")?parseFloat(m)*(180/Math.PI):parseFloat(m)),[o,a,c,l]=i,u=[o,a,c],f=[o,a,c,l];if("perspective"===e&&o&&[a,c].every(m=>void 0===m))r.m34=-1/o;else if(e.includes("matrix")&&[6,16].includes(i.length)&&i.every(m=>!Number.isNaN(+m))){const t=i.map(m=>Math.abs(m)<1e-6?0:m);r=r.multiply(m(t))}else if("translate3d"===e&&u.every(m=>!Number.isNaN(+m)))r=r.translate(o,a,c);else if("translate"===e&&o&&void 0===c)r=r.translate(o,a||0,0);else if("rotate3d"===e&&f.every(m=>!Number.isNaN(+m))&&l)r=r.rotateAxisAngle(o,a,c,l);else if("rotate"===e&&o&&[a,c].every(m=>void 0===m))r=r.rotate(0,0,o);else if("scale3d"===e&&u.every(m=>!Number.isNaN(+m))&&u.some(m=>1!==m))r=r.scale(o,a,c);else if("scale"!==e||Number.isNaN(o)||1===o||void 0!==c)if("skew"===e&&(o||!Number.isNaN(o)&&a)&&void 0===c)r=r.skew(o,a||0);else{if(!(/[XYZ]/.test(e)&&o&&[a,c].every(m=>void 0===m)&&["translate","rotate","scale","skew"].some(m=>e.includes(m))))throw TypeError(n);if(["skewX","skewY"].includes(e))r=r[e](o);else{const m=e.replace(/[XYZ]/,""),t=e.replace(m,""),n=["X","Y","Z"].indexOf(t),s="scale"===m?1:0,i=[0===n?o:s,1===n?o:s,2===n?o:s];r=r[m](...i)}}else{const m=Number.isNaN(+a)?o:a;r=r.scale(o,m,1)}}),r}function r(m,t){return t?[m.a,m.b,m.c,m.d,m.e,m.f]:[m.m11,m.m12,m.m13,m.m14,m.m21,m.m22,m.m23,m.m24,m.m31,m.m32,m.m33,m.m34,m.m41,m.m42,m.m43,m.m44]}function n(m,t,e){const r=new f;return r.m41=m,r.e=m,r.m42=t,r.f=t,r.m43=e,r}function s(m,t,e){const r=new f,n=Math.PI/180,s=m*n,i=t*n,o=e*n,a=Math.cos(s),c=-Math.sin(s),l=Math.cos(i),u=-Math.sin(i),h=Math.cos(o),y=-Math.sin(o),d=l*h,w=-l*y;r.m11=d,r.a=d,r.m12=w,r.b=w,r.m13=u;const M=c*u*h+a*y;r.m21=M,r.c=M;const p=a*h-c*u*y;return r.m22=p,r.d=p,r.m23=-c*l,r.m31=c*y-a*u*h,r.m32=c*h+a*u*y,r.m33=a*l,r}function i(m,t,e,r){const n=new f,s=Math.sqrt(m*m+t*t+e*e);if(0===s)return n;const i=m/s,o=t/s,a=e/s,c=r*(Math.PI/360),l=Math.sin(c),u=Math.cos(c),h=l*l,y=i*i,d=o*o,w=a*a,M=1-2*(d+w)*h;n.m11=M,n.a=M;const p=2*(i*o*h+a*l*u);n.m12=p,n.b=p,n.m13=2*(i*a*h-o*l*u);const N=2*(o*i*h-a*l*u);n.m21=N,n.c=N;const x=1-2*(w+y)*h;return n.m22=x,n.d=x,n.m23=2*(o*a*h+i*l*u),n.m31=2*(a*i*h+o*l*u),n.m32=2*(a*o*h-i*l*u),n.m33=1-2*(y+d)*h,n}function o(m,t,e){const r=new f;return r.m11=m,r.a=m,r.m22=t,r.d=t,r.m33=e,r}function a(m,t){const e=new f;if(m){const t=m*Math.PI/180,r=Math.tan(t);e.m21=r,e.c=r}if(t){const m=t*Math.PI/180,r=Math.tan(m);e.m12=r,e.b=r}return e}function c(m){return a(m,0)}function l(m){return a(0,m)}function u(t,e){return m([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}class f{constructor(...m){const t=this;if(t.a=1,t.b=0,t.c=0,t.d=1,t.e=0,t.f=0,t.m11=1,t.m12=0,t.m13=0,t.m14=0,t.m21=0,t.m22=1,t.m23=0,t.m24=0,t.m31=0,t.m32=0,t.m33=1,t.m34=0,t.m41=0,t.m42=0,t.m43=0,t.m44=1,m&&m.length){const e=[16,6].some(t=>t===m.length)?m:m[0];return t.setMatrixValue(e)}return t}get isIdentity(){const m=this;return 1===m.m11&&0===m.m12&&0===m.m13&&0===m.m14&&0===m.m21&&1===m.m22&&0===m.m23&&0===m.m24&&0===m.m31&&0===m.m32&&1===m.m33&&0===m.m34&&0===m.m41&&0===m.m42&&0===m.m43&&1===m.m44}get is2D(){const m=this;return 0===m.m31&&0===m.m32&&1===m.m33&&0===m.m34&&0===m.m43&&1===m.m44}setMatrixValue(r){return"string"==typeof r&&r.length&&"none"!==r?e(r):[Array,Float64Array,Float32Array].some(m=>r instanceof m)?m(r):[f,DOMMatrix,Object].some(m=>r instanceof m)?t(r):this}toFloat32Array(m){return Float32Array.from(r(this,m))}toFloat64Array(m){return Float64Array.from(r(this,m))}toString(){const{is2D:m}=this;return`${m?"matrix":"matrix3d"}(${this.toFloat64Array(m).join(", ")})`}toJSON(){const{is2D:m,isIdentity:t}=this;return{...this,is2D:m,isIdentity:t}}multiply(m){return u(this,m)}translate(m,t,e){let r=t,s=e;return void 0===r&&(r=0),void 0===s&&(s=0),u(this,n(m,r,s))}scale(m,t,e){let r=t,n=e;return void 0===r&&(r=m),void 0===n&&(n=1),u(this,o(m,r,n))}rotate(m,t,e){let r=m,n=t||0,i=e||0;return"number"==typeof m&&void 0===t&&void 0===e&&(i=r,r=0,n=0),u(this,s(r,n,i))}rotateAxisAngle(m,t,e,r){if([m,t,e,r].some(m=>Number.isNaN(+m)))throw new TypeError("CSSMatrix: expecting 4 values");return u(this,i(m,t,e,r))}skewX(m){return u(this,c(m))}skewY(m){return u(this,l(m))}skew(m,t){return u(this,a(m,t))}transformPoint(m){const t=this,e=t.m11*m.x+t.m21*m.y+t.m31*m.z+t.m41*m.w,r=t.m12*m.x+t.m22*m.y+t.m32*m.z+t.m42*m.w,n=t.m13*m.x+t.m23*m.y+t.m33*m.z+t.m43*m.w,s=t.m14*m.x+t.m24*m.y+t.m34*m.z+t.m44*m.w;return m instanceof DOMPoint?new DOMPoint(e,r,n,s):{x:e,y:r,z:n,w:s}}}Object.assign(f,{Translate:n,Rotate:s,RotateAxisAngle:i,Scale:o,SkewX:c,SkewY:l,Skew:a,Multiply:u,fromArray:m,fromMatrix:t,fromString:e,toArray:r});Object.assign(f,{Version:"1.0.2"});export{f as default}; | ||
// DOMMatrix v1.0.3 | thednp © 2022 | MIT-License | ||
function m(m){const t=new f,e=Array.from(m);if(!e.every(m=>!Number.isNaN(m)))throw TypeError(`CSSMatrix: "${m}" must only have numbers.`);if(16===e.length){const[m,r,n,s,i,o,a,c,l,u,f,h,y,d,w,M]=e;t.m11=m,t.a=m,t.m21=i,t.c=i,t.m31=l,t.m41=y,t.e=y,t.m12=r,t.b=r,t.m22=o,t.d=o,t.m32=u,t.m42=d,t.f=d,t.m13=n,t.m23=a,t.m33=f,t.m43=w,t.m14=s,t.m24=c,t.m34=h,t.m44=M}else{if(6!==e.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");{const[m,r,n,s,i,o]=e;t.m11=m,t.a=m,t.m12=r,t.b=r,t.m21=n,t.c=n,t.m22=s,t.d=s,t.m41=i,t.e=i,t.m42=o,t.f=o}}return t}function t(t){const e=Object.keys(new f);if("object"==typeof t&&e.every(m=>m in t))return m([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]);throw TypeError(`CSSMatrix: "${JSON.stringify(t)}" is not a DOMMatrix / CSSMatrix / JSON compatible object.`)}function e(t){if("string"!=typeof t)throw TypeError(`CSSMatrix: "${t}" is not a string.`);const e=String(t).replace(/\s/g,"");let r=new f;const n=`CSSMatrix: invalid transform string "${t}"`;return e.split(")").filter(m=>m).forEach(t=>{const[e,s]=t.split("(");if(!s)throw TypeError(n);const i=s.split(",").map(m=>m.includes("rad")?parseFloat(m)*(180/Math.PI):parseFloat(m)),[o,a,c,l]=i,u=[o,a,c],f=[o,a,c,l];if("perspective"===e&&o&&[a,c].every(m=>void 0===m))r.m34=-1/o;else if(e.includes("matrix")&&[6,16].includes(i.length)&&i.every(m=>!Number.isNaN(+m))){const t=i.map(m=>Math.abs(m)<1e-6?0:m);r=r.multiply(m(t))}else if("translate3d"===e&&u.every(m=>!Number.isNaN(+m)))r=r.translate(o,a,c);else if("translate"===e&&o&&void 0===c)r=r.translate(o,a||0,0);else if("rotate3d"===e&&f.every(m=>!Number.isNaN(+m))&&l)r=r.rotateAxisAngle(o,a,c,l);else if("rotate"===e&&o&&[a,c].every(m=>void 0===m))r=r.rotate(0,0,o);else if("scale3d"===e&&u.every(m=>!Number.isNaN(+m))&&u.some(m=>1!==m))r=r.scale(o,a,c);else if("scale"!==e||Number.isNaN(o)||1===o||void 0!==c)if("skew"===e&&(o||!Number.isNaN(o)&&a)&&void 0===c)r=r.skew(o,a||0);else{if(!(/[XYZ]/.test(e)&&o&&[a,c].every(m=>void 0===m)&&["translate","rotate","scale","skew"].some(m=>e.includes(m))))throw TypeError(n);if(["skewX","skewY"].includes(e))r=r[e](o);else{const m=e.replace(/[XYZ]/,""),t=e.replace(m,""),n=["X","Y","Z"].indexOf(t),s="scale"===m?1:0,i=[0===n?o:s,1===n?o:s,2===n?o:s];r=r[m](...i)}}else{const m=Number.isNaN(+a)?o:a;r=r.scale(o,m,1)}}),r}function r(m,t){return t?[m.a,m.b,m.c,m.d,m.e,m.f]:[m.m11,m.m12,m.m13,m.m14,m.m21,m.m22,m.m23,m.m24,m.m31,m.m32,m.m33,m.m34,m.m41,m.m42,m.m43,m.m44]}function n(m,t,e){const r=new f;return r.m41=m,r.e=m,r.m42=t,r.f=t,r.m43=e,r}function s(m,t,e){const r=new f,n=Math.PI/180,s=m*n,i=t*n,o=e*n,a=Math.cos(s),c=-Math.sin(s),l=Math.cos(i),u=-Math.sin(i),h=Math.cos(o),y=-Math.sin(o),d=l*h,w=-l*y;r.m11=d,r.a=d,r.m12=w,r.b=w,r.m13=u;const M=c*u*h+a*y;r.m21=M,r.c=M;const p=a*h-c*u*y;return r.m22=p,r.d=p,r.m23=-c*l,r.m31=c*y-a*u*h,r.m32=c*h+a*u*y,r.m33=a*l,r}function i(m,t,e,r){const n=new f,s=Math.sqrt(m*m+t*t+e*e);if(0===s)return n;const i=m/s,o=t/s,a=e/s,c=r*(Math.PI/360),l=Math.sin(c),u=Math.cos(c),h=l*l,y=i*i,d=o*o,w=a*a,M=1-2*(d+w)*h;n.m11=M,n.a=M;const p=2*(i*o*h+a*l*u);n.m12=p,n.b=p,n.m13=2*(i*a*h-o*l*u);const N=2*(o*i*h-a*l*u);n.m21=N,n.c=N;const x=1-2*(w+y)*h;return n.m22=x,n.d=x,n.m23=2*(o*a*h+i*l*u),n.m31=2*(a*i*h+o*l*u),n.m32=2*(a*o*h-i*l*u),n.m33=1-2*(y+d)*h,n}function o(m,t,e){const r=new f;return r.m11=m,r.a=m,r.m22=t,r.d=t,r.m33=e,r}function a(m,t){const e=new f;if(m){const t=m*Math.PI/180,r=Math.tan(t);e.m21=r,e.c=r}if(t){const m=t*Math.PI/180,r=Math.tan(m);e.m12=r,e.b=r}return e}function c(m){return a(m,0)}function l(m){return a(0,m)}function u(t,e){return m([e.m11*t.m11+e.m12*t.m21+e.m13*t.m31+e.m14*t.m41,e.m11*t.m12+e.m12*t.m22+e.m13*t.m32+e.m14*t.m42,e.m11*t.m13+e.m12*t.m23+e.m13*t.m33+e.m14*t.m43,e.m11*t.m14+e.m12*t.m24+e.m13*t.m34+e.m14*t.m44,e.m21*t.m11+e.m22*t.m21+e.m23*t.m31+e.m24*t.m41,e.m21*t.m12+e.m22*t.m22+e.m23*t.m32+e.m24*t.m42,e.m21*t.m13+e.m22*t.m23+e.m23*t.m33+e.m24*t.m43,e.m21*t.m14+e.m22*t.m24+e.m23*t.m34+e.m24*t.m44,e.m31*t.m11+e.m32*t.m21+e.m33*t.m31+e.m34*t.m41,e.m31*t.m12+e.m32*t.m22+e.m33*t.m32+e.m34*t.m42,e.m31*t.m13+e.m32*t.m23+e.m33*t.m33+e.m34*t.m43,e.m31*t.m14+e.m32*t.m24+e.m33*t.m34+e.m34*t.m44,e.m41*t.m11+e.m42*t.m21+e.m43*t.m31+e.m44*t.m41,e.m41*t.m12+e.m42*t.m22+e.m43*t.m32+e.m44*t.m42,e.m41*t.m13+e.m42*t.m23+e.m43*t.m33+e.m44*t.m43,e.m41*t.m14+e.m42*t.m24+e.m43*t.m34+e.m44*t.m44])}class f{constructor(...m){const t=this;if(t.a=1,t.b=0,t.c=0,t.d=1,t.e=0,t.f=0,t.m11=1,t.m12=0,t.m13=0,t.m14=0,t.m21=0,t.m22=1,t.m23=0,t.m24=0,t.m31=0,t.m32=0,t.m33=1,t.m34=0,t.m41=0,t.m42=0,t.m43=0,t.m44=1,m.length){const e=[16,6].some(t=>t===m.length)?m:m[0];return t.setMatrixValue(e)}return t}get isIdentity(){const m=this;return 1===m.m11&&0===m.m12&&0===m.m13&&0===m.m14&&0===m.m21&&1===m.m22&&0===m.m23&&0===m.m24&&0===m.m31&&0===m.m32&&1===m.m33&&0===m.m34&&0===m.m41&&0===m.m42&&0===m.m43&&1===m.m44}get is2D(){const m=this;return 0===m.m31&&0===m.m32&&1===m.m33&&0===m.m34&&0===m.m43&&1===m.m44}setMatrixValue(r){return"string"==typeof r&&r.length&&"none"!==r?e(r):[Array,Float64Array,Float32Array].some(m=>r instanceof m)?m(r):[f,DOMMatrix,Object].some(m=>r instanceof m)?t(r):this}toFloat32Array(m){return Float32Array.from(r(this,m))}toFloat64Array(m){return Float64Array.from(r(this,m))}toString(){const{is2D:m}=this;return`${m?"matrix":"matrix3d"}(${this.toFloat64Array(m).join(", ")})`}toJSON(){const{is2D:m,isIdentity:t}=this;return{...this,is2D:m,isIdentity:t}}multiply(m){return u(this,m)}translate(m,t,e){let r=t,s=e;return void 0===r&&(r=0),void 0===s&&(s=0),u(this,n(m,r,s))}scale(m,t,e){let r=t,n=e;return void 0===r&&(r=m),void 0===n&&(n=1),u(this,o(m,r,n))}rotate(m,t,e){let r=m,n=t||0,i=e||0;return"number"==typeof m&&void 0===t&&void 0===e&&(i=r,r=0,n=0),u(this,s(r,n,i))}rotateAxisAngle(m,t,e,r){if([m,t,e,r].some(m=>Number.isNaN(+m)))throw new TypeError("CSSMatrix: expecting 4 values");return u(this,i(m,t,e,r))}skewX(m){return u(this,c(m))}skewY(m){return u(this,l(m))}skew(m,t){return u(this,a(m,t))}transformPoint(m){const t=this,e=t.m11*m.x+t.m21*m.y+t.m31*m.z+t.m41*m.w,r=t.m12*m.x+t.m22*m.y+t.m32*m.z+t.m42*m.w,n=t.m13*m.x+t.m23*m.y+t.m33*m.z+t.m43*m.w,s=t.m14*m.x+t.m24*m.y+t.m34*m.z+t.m44*m.w;return m instanceof DOMPoint?new DOMPoint(e,r,n,s):{x:e,y:r,z:n,w:s}}}Object.assign(f,{Translate:n,Rotate:s,RotateAxisAngle:i,Scale:o,SkewX:c,SkewY:l,Skew:a,Multiply:u,fromArray:m,fromMatrix:t,fromString:e,toArray:r});Object.assign(f,{Version:"1.0.3"});export{f as default}; |
/*! | ||
* DOMMatrix v1.0.2 (https://thednp.github.io/dommatrix/) | ||
* DOMMatrix v1.0.3 (https://thednp.github.io/dommatrix/) | ||
* Copyright 2022 © thednp | ||
@@ -528,3 +528,3 @@ * Licensed under MIT (https://github.com/thednp/DOMMatrix/blob/master/LICENSE) | ||
if (args && args.length) { | ||
if (args.length) { | ||
var ARGS = [16, 6].some(function (l) { return l === args.length; }) ? args : args[0]; | ||
@@ -833,6 +833,4 @@ | ||
var version = "1.0.2"; | ||
var version = "1.0.3"; | ||
// @ts-ignore | ||
/** | ||
@@ -844,2 +842,4 @@ * A global namespace for library version. | ||
/** @typedef {import('../types/index')} */ | ||
Object.assign(CSSMatrix, { Version: Version }); | ||
@@ -846,0 +846,0 @@ |
@@ -1,2 +0,2 @@ | ||
// DOMMatrix v1.0.2 | thednp © 2022 | MIT-License | ||
!function(t,m){"object"==typeof exports&&"undefined"!=typeof module?module.exports=m():"function"==typeof define&&define.amd?define(m):(t="undefined"!=typeof globalThis?globalThis:t||self).CSSMatrix=m()}(this,(function(){"use strict";function t(t){var m=new l,r=Array.from(t);if(!r.every((function(t){return!Number.isNaN(t)})))throw TypeError('CSSMatrix: "'+t+'" must only have numbers.');if(16===r.length){var e=r[0],n=r[1],i=r[2],o=r[3],a=r[4],s=r[5],u=r[6],f=r[7],c=r[8],p=r[9],y=r[10],v=r[11],h=r[12],d=r[13],M=r[14],w=r[15];m.m11=e,m.a=e,m.m21=a,m.c=a,m.m31=c,m.m41=h,m.e=h,m.m12=n,m.b=n,m.m22=s,m.d=s,m.m32=p,m.m42=d,m.f=d,m.m13=i,m.m23=u,m.m33=y,m.m43=M,m.m14=o,m.m24=f,m.m34=v,m.m44=w}else{if(6!==r.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");var b=r[0],g=r[1],N=r[2],x=r[3],S=r[4],A=r[5];m.m11=b,m.a=b,m.m12=g,m.b=g,m.m21=N,m.c=N,m.m22=x,m.d=x,m.m41=S,m.e=S,m.m42=A,m.f=A}return m}function m(m){var r=Object.keys(new l);if("object"==typeof m&&r.every((function(t){return t in m})))return t([m.m11,m.m12,m.m13,m.m14,m.m21,m.m22,m.m23,m.m24,m.m31,m.m32,m.m33,m.m34,m.m41,m.m42,m.m43,m.m44]);throw TypeError('CSSMatrix: "'+JSON.stringify(m)+'" is not a DOMMatrix / CSSMatrix / JSON compatible object.')}function r(m){if("string"!=typeof m)throw TypeError('CSSMatrix: "'+m+'" is not a string.');var r=String(m).replace(/\s/g,""),e=new l,n='CSSMatrix: invalid transform string "'+m+'"';return r.split(")").filter((function(t){return t})).forEach((function(m){var r=m.split("("),i=r[0],o=r[1];if(!o)throw TypeError(n);var a=o.split(",").map((function(t){return t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)})),s=a[0],u=a[1],f=a[2],c=a[3],l=[s,u,f],p=[s,u,f,c];if("perspective"===i&&s&&[u,f].every((function(t){return void 0===t})))e.m34=-1/s;else if(i.includes("matrix")&&[6,16].includes(a.length)&&a.every((function(t){return!Number.isNaN(+t)}))){var y=a.map((function(t){return Math.abs(t)<1e-6?0:t}));e=e.multiply(t(y))}else if("translate3d"===i&&l.every((function(t){return!Number.isNaN(+t)})))e=e.translate(s,u,f);else if("translate"===i&&s&&void 0===f)e=e.translate(s,u||0,0);else if("rotate3d"===i&&p.every((function(t){return!Number.isNaN(+t)}))&&c)e=e.rotateAxisAngle(s,u,f,c);else if("rotate"===i&&s&&[u,f].every((function(t){return void 0===t})))e=e.rotate(0,0,s);else if("scale3d"===i&&l.every((function(t){return!Number.isNaN(+t)}))&&l.some((function(t){return 1!==t})))e=e.scale(s,u,f);else if("scale"!==i||Number.isNaN(s)||1===s||void 0!==f)if("skew"===i&&(s||!Number.isNaN(s)&&u)&&void 0===f)e=e.skew(s,u||0);else{if(!(/[XYZ]/.test(i)&&s&&[u,f].every((function(t){return void 0===t}))&&["translate","rotate","scale","skew"].some((function(t){return i.includes(t)}))))throw TypeError(n);if(["skewX","skewY"].includes(i))e=e[i](s);else{var v=i.replace(/[XYZ]/,""),h=i.replace(v,""),d=["X","Y","Z"].indexOf(h),M="scale"===v?1:0,w=[0===d?s:M,1===d?s:M,2===d?s:M];e=e[v].apply(e,w)}}else{var b=Number.isNaN(+u)?s:u;e=e.scale(s,b,1)}})),e}function e(t,m){return m?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]}function n(t,m,r){var e=new l;return e.m41=t,e.e=t,e.m42=m,e.f=m,e.m43=r,e}function i(t,m,r){var e=new l,n=Math.PI/180,i=t*n,o=m*n,a=r*n,s=Math.cos(i),u=-Math.sin(i),f=Math.cos(o),c=-Math.sin(o),p=Math.cos(a),y=-Math.sin(a),v=f*p,h=-f*y;e.m11=v,e.a=v,e.m12=h,e.b=h,e.m13=c;var d=u*c*p+s*y;e.m21=d,e.c=d;var M=s*p-u*c*y;return e.m22=M,e.d=M,e.m23=-u*f,e.m31=u*y-s*c*p,e.m32=u*p+s*c*y,e.m33=s*f,e}function o(t,m,r,e){var n=new l,i=Math.sqrt(t*t+m*m+r*r);if(0===i)return n;var o=t/i,a=m/i,s=r/i,u=e*(Math.PI/360),f=Math.sin(u),c=Math.cos(u),p=f*f,y=o*o,v=a*a,h=s*s,d=1-2*(v+h)*p;n.m11=d,n.a=d;var M=2*(o*a*p+s*f*c);n.m12=M,n.b=M,n.m13=2*(o*s*p-a*f*c);var w=2*(a*o*p-s*f*c);n.m21=w,n.c=w;var b=1-2*(h+y)*p;return n.m22=b,n.d=b,n.m23=2*(a*s*p+o*f*c),n.m31=2*(s*o*p+a*f*c),n.m32=2*(s*a*p-o*f*c),n.m33=1-2*(y+v)*p,n}function a(t,m,r){var e=new l;return e.m11=t,e.a=t,e.m22=m,e.d=m,e.m33=r,e}function s(t,m){var r=new l;if(t){var e=t*Math.PI/180,n=Math.tan(e);r.m21=n,r.c=n}if(m){var i=m*Math.PI/180,o=Math.tan(i);r.m12=o,r.b=o}return r}function u(t){return s(t,0)}function f(t){return s(0,t)}function c(m,r){return t([r.m11*m.m11+r.m12*m.m21+r.m13*m.m31+r.m14*m.m41,r.m11*m.m12+r.m12*m.m22+r.m13*m.m32+r.m14*m.m42,r.m11*m.m13+r.m12*m.m23+r.m13*m.m33+r.m14*m.m43,r.m11*m.m14+r.m12*m.m24+r.m13*m.m34+r.m14*m.m44,r.m21*m.m11+r.m22*m.m21+r.m23*m.m31+r.m24*m.m41,r.m21*m.m12+r.m22*m.m22+r.m23*m.m32+r.m24*m.m42,r.m21*m.m13+r.m22*m.m23+r.m23*m.m33+r.m24*m.m43,r.m21*m.m14+r.m22*m.m24+r.m23*m.m34+r.m24*m.m44,r.m31*m.m11+r.m32*m.m21+r.m33*m.m31+r.m34*m.m41,r.m31*m.m12+r.m32*m.m22+r.m33*m.m32+r.m34*m.m42,r.m31*m.m13+r.m32*m.m23+r.m33*m.m33+r.m34*m.m43,r.m31*m.m14+r.m32*m.m24+r.m33*m.m34+r.m34*m.m44,r.m41*m.m11+r.m42*m.m21+r.m43*m.m31+r.m44*m.m41,r.m41*m.m12+r.m42*m.m22+r.m43*m.m32+r.m44*m.m42,r.m41*m.m13+r.m42*m.m23+r.m43*m.m33+r.m44*m.m43,r.m41*m.m14+r.m42*m.m24+r.m43*m.m34+r.m44*m.m44])}var l=function(){for(var t=[],m=arguments.length;m--;)t[m]=arguments[m];var r=this;if(r.a=1,r.b=0,r.c=0,r.d=1,r.e=0,r.f=0,r.m11=1,r.m12=0,r.m13=0,r.m14=0,r.m21=0,r.m22=1,r.m23=0,r.m24=0,r.m31=0,r.m32=0,r.m33=1,r.m34=0,r.m41=0,r.m42=0,r.m43=0,r.m44=1,t&&t.length){var e=[16,6].some((function(m){return m===t.length}))?t:t[0];return r.setMatrixValue(e)}return r},p={isIdentity:{configurable:!0},is2D:{configurable:!0}};p.isIdentity.get=function(){var t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44},p.is2D.get=function(){var t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44},l.prototype.setMatrixValue=function(e){return"string"==typeof e&&e.length&&"none"!==e?r(e):[Array,Float64Array,Float32Array].some((function(t){return e instanceof t}))?t(e):[l,DOMMatrix,Object].some((function(t){return e instanceof t}))?m(e):this},l.prototype.toFloat32Array=function(t){return Float32Array.from(e(this,t))},l.prototype.toFloat64Array=function(t){return Float64Array.from(e(this,t))},l.prototype.toString=function(){var t=this.is2D;return(t?"matrix":"matrix3d")+"("+this.toFloat64Array(t).join(", ")+")"},l.prototype.toJSON=function(){var t=this,m=t.is2D,r=t.isIdentity;return Object.assign({},t,{is2D:m,isIdentity:r})},l.prototype.multiply=function(t){return c(this,t)},l.prototype.translate=function(t,m,r){var e=m,i=r;return void 0===e&&(e=0),void 0===i&&(i=0),c(this,n(t,e,i))},l.prototype.scale=function(t,m,r){var e=m,n=r;return void 0===e&&(e=t),void 0===n&&(n=1),c(this,a(t,e,n))},l.prototype.rotate=function(t,m,r){var e=t,n=m||0,o=r||0;return"number"==typeof t&&void 0===m&&void 0===r&&(o=e,e=0,n=0),c(this,i(e,n,o))},l.prototype.rotateAxisAngle=function(t,m,r,e){if([t,m,r,e].some((function(t){return Number.isNaN(+t)})))throw new TypeError("CSSMatrix: expecting 4 values");return c(this,o(t,m,r,e))},l.prototype.skewX=function(t){return c(this,u(t))},l.prototype.skewY=function(t){return c(this,f(t))},l.prototype.skew=function(t,m){return c(this,s(t,m))},l.prototype.transformPoint=function(t){var m=this,r=m.m11*t.x+m.m21*t.y+m.m31*t.z+m.m41*t.w,e=m.m12*t.x+m.m22*t.y+m.m32*t.z+m.m42*t.w,n=m.m13*t.x+m.m23*t.y+m.m33*t.z+m.m43*t.w,i=m.m14*t.x+m.m24*t.y+m.m34*t.z+m.m44*t.w;return t instanceof DOMPoint?new DOMPoint(r,e,n,i):{x:r,y:e,z:n,w:i}},Object.defineProperties(l.prototype,p),Object.assign(l,{Translate:n,Rotate:i,RotateAxisAngle:o,Scale:a,SkewX:u,SkewY:f,Skew:s,Multiply:c,fromArray:t,fromMatrix:m,fromString:r,toArray:e});return Object.assign(l,{Version:"1.0.2"}),l})); | ||
// DOMMatrix v1.0.3 | thednp © 2022 | MIT-License | ||
!function(t,m){"object"==typeof exports&&"undefined"!=typeof module?module.exports=m():"function"==typeof define&&define.amd?define(m):(t="undefined"!=typeof globalThis?globalThis:t||self).CSSMatrix=m()}(this,(function(){"use strict";function t(t){var m=new l,r=Array.from(t);if(!r.every((function(t){return!Number.isNaN(t)})))throw TypeError('CSSMatrix: "'+t+'" must only have numbers.');if(16===r.length){var e=r[0],n=r[1],i=r[2],o=r[3],a=r[4],s=r[5],u=r[6],f=r[7],c=r[8],p=r[9],y=r[10],v=r[11],h=r[12],d=r[13],M=r[14],w=r[15];m.m11=e,m.a=e,m.m21=a,m.c=a,m.m31=c,m.m41=h,m.e=h,m.m12=n,m.b=n,m.m22=s,m.d=s,m.m32=p,m.m42=d,m.f=d,m.m13=i,m.m23=u,m.m33=y,m.m43=M,m.m14=o,m.m24=f,m.m34=v,m.m44=w}else{if(6!==r.length)throw new TypeError("CSSMatrix: expecting an Array of 6/16 values.");var b=r[0],g=r[1],N=r[2],x=r[3],S=r[4],A=r[5];m.m11=b,m.a=b,m.m12=g,m.b=g,m.m21=N,m.c=N,m.m22=x,m.d=x,m.m41=S,m.e=S,m.m42=A,m.f=A}return m}function m(m){var r=Object.keys(new l);if("object"==typeof m&&r.every((function(t){return t in m})))return t([m.m11,m.m12,m.m13,m.m14,m.m21,m.m22,m.m23,m.m24,m.m31,m.m32,m.m33,m.m34,m.m41,m.m42,m.m43,m.m44]);throw TypeError('CSSMatrix: "'+JSON.stringify(m)+'" is not a DOMMatrix / CSSMatrix / JSON compatible object.')}function r(m){if("string"!=typeof m)throw TypeError('CSSMatrix: "'+m+'" is not a string.');var r=String(m).replace(/\s/g,""),e=new l,n='CSSMatrix: invalid transform string "'+m+'"';return r.split(")").filter((function(t){return t})).forEach((function(m){var r=m.split("("),i=r[0],o=r[1];if(!o)throw TypeError(n);var a=o.split(",").map((function(t){return t.includes("rad")?parseFloat(t)*(180/Math.PI):parseFloat(t)})),s=a[0],u=a[1],f=a[2],c=a[3],l=[s,u,f],p=[s,u,f,c];if("perspective"===i&&s&&[u,f].every((function(t){return void 0===t})))e.m34=-1/s;else if(i.includes("matrix")&&[6,16].includes(a.length)&&a.every((function(t){return!Number.isNaN(+t)}))){var y=a.map((function(t){return Math.abs(t)<1e-6?0:t}));e=e.multiply(t(y))}else if("translate3d"===i&&l.every((function(t){return!Number.isNaN(+t)})))e=e.translate(s,u,f);else if("translate"===i&&s&&void 0===f)e=e.translate(s,u||0,0);else if("rotate3d"===i&&p.every((function(t){return!Number.isNaN(+t)}))&&c)e=e.rotateAxisAngle(s,u,f,c);else if("rotate"===i&&s&&[u,f].every((function(t){return void 0===t})))e=e.rotate(0,0,s);else if("scale3d"===i&&l.every((function(t){return!Number.isNaN(+t)}))&&l.some((function(t){return 1!==t})))e=e.scale(s,u,f);else if("scale"!==i||Number.isNaN(s)||1===s||void 0!==f)if("skew"===i&&(s||!Number.isNaN(s)&&u)&&void 0===f)e=e.skew(s,u||0);else{if(!(/[XYZ]/.test(i)&&s&&[u,f].every((function(t){return void 0===t}))&&["translate","rotate","scale","skew"].some((function(t){return i.includes(t)}))))throw TypeError(n);if(["skewX","skewY"].includes(i))e=e[i](s);else{var v=i.replace(/[XYZ]/,""),h=i.replace(v,""),d=["X","Y","Z"].indexOf(h),M="scale"===v?1:0,w=[0===d?s:M,1===d?s:M,2===d?s:M];e=e[v].apply(e,w)}}else{var b=Number.isNaN(+u)?s:u;e=e.scale(s,b,1)}})),e}function e(t,m){return m?[t.a,t.b,t.c,t.d,t.e,t.f]:[t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44]}function n(t,m,r){var e=new l;return e.m41=t,e.e=t,e.m42=m,e.f=m,e.m43=r,e}function i(t,m,r){var e=new l,n=Math.PI/180,i=t*n,o=m*n,a=r*n,s=Math.cos(i),u=-Math.sin(i),f=Math.cos(o),c=-Math.sin(o),p=Math.cos(a),y=-Math.sin(a),v=f*p,h=-f*y;e.m11=v,e.a=v,e.m12=h,e.b=h,e.m13=c;var d=u*c*p+s*y;e.m21=d,e.c=d;var M=s*p-u*c*y;return e.m22=M,e.d=M,e.m23=-u*f,e.m31=u*y-s*c*p,e.m32=u*p+s*c*y,e.m33=s*f,e}function o(t,m,r,e){var n=new l,i=Math.sqrt(t*t+m*m+r*r);if(0===i)return n;var o=t/i,a=m/i,s=r/i,u=e*(Math.PI/360),f=Math.sin(u),c=Math.cos(u),p=f*f,y=o*o,v=a*a,h=s*s,d=1-2*(v+h)*p;n.m11=d,n.a=d;var M=2*(o*a*p+s*f*c);n.m12=M,n.b=M,n.m13=2*(o*s*p-a*f*c);var w=2*(a*o*p-s*f*c);n.m21=w,n.c=w;var b=1-2*(h+y)*p;return n.m22=b,n.d=b,n.m23=2*(a*s*p+o*f*c),n.m31=2*(s*o*p+a*f*c),n.m32=2*(s*a*p-o*f*c),n.m33=1-2*(y+v)*p,n}function a(t,m,r){var e=new l;return e.m11=t,e.a=t,e.m22=m,e.d=m,e.m33=r,e}function s(t,m){var r=new l;if(t){var e=t*Math.PI/180,n=Math.tan(e);r.m21=n,r.c=n}if(m){var i=m*Math.PI/180,o=Math.tan(i);r.m12=o,r.b=o}return r}function u(t){return s(t,0)}function f(t){return s(0,t)}function c(m,r){return t([r.m11*m.m11+r.m12*m.m21+r.m13*m.m31+r.m14*m.m41,r.m11*m.m12+r.m12*m.m22+r.m13*m.m32+r.m14*m.m42,r.m11*m.m13+r.m12*m.m23+r.m13*m.m33+r.m14*m.m43,r.m11*m.m14+r.m12*m.m24+r.m13*m.m34+r.m14*m.m44,r.m21*m.m11+r.m22*m.m21+r.m23*m.m31+r.m24*m.m41,r.m21*m.m12+r.m22*m.m22+r.m23*m.m32+r.m24*m.m42,r.m21*m.m13+r.m22*m.m23+r.m23*m.m33+r.m24*m.m43,r.m21*m.m14+r.m22*m.m24+r.m23*m.m34+r.m24*m.m44,r.m31*m.m11+r.m32*m.m21+r.m33*m.m31+r.m34*m.m41,r.m31*m.m12+r.m32*m.m22+r.m33*m.m32+r.m34*m.m42,r.m31*m.m13+r.m32*m.m23+r.m33*m.m33+r.m34*m.m43,r.m31*m.m14+r.m32*m.m24+r.m33*m.m34+r.m34*m.m44,r.m41*m.m11+r.m42*m.m21+r.m43*m.m31+r.m44*m.m41,r.m41*m.m12+r.m42*m.m22+r.m43*m.m32+r.m44*m.m42,r.m41*m.m13+r.m42*m.m23+r.m43*m.m33+r.m44*m.m43,r.m41*m.m14+r.m42*m.m24+r.m43*m.m34+r.m44*m.m44])}var l=function(){for(var t=[],m=arguments.length;m--;)t[m]=arguments[m];var r=this;if(r.a=1,r.b=0,r.c=0,r.d=1,r.e=0,r.f=0,r.m11=1,r.m12=0,r.m13=0,r.m14=0,r.m21=0,r.m22=1,r.m23=0,r.m24=0,r.m31=0,r.m32=0,r.m33=1,r.m34=0,r.m41=0,r.m42=0,r.m43=0,r.m44=1,t.length){var e=[16,6].some((function(m){return m===t.length}))?t:t[0];return r.setMatrixValue(e)}return r},p={isIdentity:{configurable:!0},is2D:{configurable:!0}};p.isIdentity.get=function(){var t=this;return 1===t.m11&&0===t.m12&&0===t.m13&&0===t.m14&&0===t.m21&&1===t.m22&&0===t.m23&&0===t.m24&&0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m41&&0===t.m42&&0===t.m43&&1===t.m44},p.is2D.get=function(){var t=this;return 0===t.m31&&0===t.m32&&1===t.m33&&0===t.m34&&0===t.m43&&1===t.m44},l.prototype.setMatrixValue=function(e){return"string"==typeof e&&e.length&&"none"!==e?r(e):[Array,Float64Array,Float32Array].some((function(t){return e instanceof t}))?t(e):[l,DOMMatrix,Object].some((function(t){return e instanceof t}))?m(e):this},l.prototype.toFloat32Array=function(t){return Float32Array.from(e(this,t))},l.prototype.toFloat64Array=function(t){return Float64Array.from(e(this,t))},l.prototype.toString=function(){var t=this.is2D;return(t?"matrix":"matrix3d")+"("+this.toFloat64Array(t).join(", ")+")"},l.prototype.toJSON=function(){var t=this,m=t.is2D,r=t.isIdentity;return Object.assign({},t,{is2D:m,isIdentity:r})},l.prototype.multiply=function(t){return c(this,t)},l.prototype.translate=function(t,m,r){var e=m,i=r;return void 0===e&&(e=0),void 0===i&&(i=0),c(this,n(t,e,i))},l.prototype.scale=function(t,m,r){var e=m,n=r;return void 0===e&&(e=t),void 0===n&&(n=1),c(this,a(t,e,n))},l.prototype.rotate=function(t,m,r){var e=t,n=m||0,o=r||0;return"number"==typeof t&&void 0===m&&void 0===r&&(o=e,e=0,n=0),c(this,i(e,n,o))},l.prototype.rotateAxisAngle=function(t,m,r,e){if([t,m,r,e].some((function(t){return Number.isNaN(+t)})))throw new TypeError("CSSMatrix: expecting 4 values");return c(this,o(t,m,r,e))},l.prototype.skewX=function(t){return c(this,u(t))},l.prototype.skewY=function(t){return c(this,f(t))},l.prototype.skew=function(t,m){return c(this,s(t,m))},l.prototype.transformPoint=function(t){var m=this,r=m.m11*t.x+m.m21*t.y+m.m31*t.z+m.m41*t.w,e=m.m12*t.x+m.m22*t.y+m.m32*t.z+m.m42*t.w,n=m.m13*t.x+m.m23*t.y+m.m33*t.z+m.m43*t.w,i=m.m14*t.x+m.m24*t.y+m.m34*t.z+m.m44*t.w;return t instanceof DOMPoint?new DOMPoint(r,e,n,i):{x:r,y:e,z:n,w:i}},Object.defineProperties(l.prototype,p),Object.assign(l,{Translate:n,Rotate:i,RotateAxisAngle:o,Scale:a,SkewX:u,SkewY:f,Skew:s,Multiply:c,fromArray:t,fromMatrix:m,fromString:r,toArray:e});return Object.assign(l,{Version:"1.0.3"}),l})); |
{ | ||
"name": "dommatrix", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "ES6+ shim for DOMMatrix", | ||
@@ -56,3 +56,3 @@ "main": "dist/dommatrix.js", | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"cypress": "^9.6.0", | ||
"cypress": "^9.6.1", | ||
"esbuild": "^0.14.30", | ||
@@ -59,0 +59,0 @@ "eslint": "^7.22.0", |
@@ -500,3 +500,3 @@ // DOMMatrix Static methods | ||
if (args && args.length) { | ||
if (args.length) { | ||
const ARGS = [16, 6].some((l) => l === args.length) ? args : args[0]; | ||
@@ -503,0 +503,0 @@ |
@@ -0,1 +1,2 @@ | ||
/** @typedef {import('../types/index')} */ | ||
import CSSMatrix from './dommatrix'; | ||
@@ -2,0 +3,0 @@ import Version from './version'; |
@@ -1,2 +0,1 @@ | ||
// @ts-ignore | ||
import { version } from '../package.json'; | ||
@@ -3,0 +2,0 @@ |
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
122160