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

fxsvg

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fxsvg - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

dist/fxsvg.js

@@ -1,1 +0,1 @@

!function(t){var e={};function r(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(n,a,function(e){return t[e]}.bind(null,a));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([,function(t,e,r){"use strict";r.r(e);const n=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_ROTATE:r}=t;return e===r},a=(t,{angle:e=0})=>{if(!n(t))return t;const{angle:r}=t;return t.setRotate(r+e,0,0),t},o=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_TRANSLATE:r}=t;return e===r},i=(t,{tx:e=0,ty:r=0})=>{if(!o(t))return t;const{e:n,f:a}=t.matrix;return t.setTranslate(n+e,a+r),t},s=t=>{const e=t.consolidate();return e?(t.initialize(e),t):t},m=({transform:{baseVal:t}})=>t;let c;const f=t=>(c=t,c),x=()=>(c||f(document.createElementNS("http://www.w3.org/2000/svg","svg")),c),u=(t=x())=>t.createSVGTransform(),l=(t=x())=>({angle:e=0,cx:r=0,cy:n=0}={})=>{const a=u(t);return a.setRotate(e,r,n),a},d=(t=x())=>({tx:e=0,ty:r=0}={})=>{const n=u(t);return n.setTranslate(e,r),n},y=(t=x())=>(e,{angle:r=0,cx:n=0,cy:a=0,index:o=0}={})=>{const i=m(e);i.insertItemBefore(d(t)({tx:-n,ty:-a}),o);const s=i.insertItemBefore(l(t)({angle:r}),o);return i.insertItemBefore(d(t)({tx:n,ty:a}),o),s},g=function*(){}();function h(t){return t&&t[Symbol.iterator]?t[Symbol.iterator]():g}var T=(t,e)=>t instanceof Promise?t.then(e):e(t);var S=Symbol.for("nop");function _(t,e,r){return e instanceof Promise?e.then(e=>r(t,e),e=>e==S?t:Promise.reject(e)):r(t,e)}function p(t){return(e,...r)=>r.length?t(e,...r):(...r)=>t(e,...r)}var b=p((function(t,e){if(t<1)return[];let r=[];return e=h(e),function n(){let a;for(;!(a=e.next()).done;){const e=a.value;if(e instanceof Promise)return e.then(e=>(r.push(e),r).length==t?r:n()).catch(t=>t==S?n():Promise.reject(t));if(r.push(e),r.length==t)return r}return r}()}));function V(t){return T(b(1,t),([t])=>t)}function I(t,e,r){return 1==arguments.length?(...e)=>I(t,...e):2==arguments.length?I(t,V(r=h(e)),r):(r=h(r),T(e,(function e(n){let a;for(;!(a=r.next()).done;)if((n=_(n,a.value,t))instanceof Promise)return n.then(e);return n})))}var v=(t,e)=>e(t);function G(...t){return I(v,t)}function*w(t=0,e=t,r=1){if(1===arguments.length&&(t=0),arguments.length<3&&t>e&&(r*=-1),t<e)for(;t<e;)yield t,t+=r;else for(;t>e;)yield t,t+=r}var M=p((function*(t,e){for(const r of h(e))yield T(r,t)}));var R=p((function(t,e){return function(t){return b(1/0,t)}(M(t,e))})),P=p((function(t,e){return R(e=>T(t(e),t=>e),e)}));const O=(t=x())=>(e,{index:r=1}={})=>{const a=m(e);if(!((t,{index:e})=>!(e>t.numberOfItems-2)&&G(w(3),M(t=>e-1+t),M(e=>t.getItem(e)),([t,e,r])=>o(t)&&n(e)&&o(r)&&0===e.matrix.e&&0===e.matrix.f&&1===t.matrix.a&&0===t.matrix.b&&0===t.matrix.c&&1===t.matrix.d&&1===r.matrix.a&&0===r.matrix.b&&0===r.matrix.c&&1===r.matrix.d&&t.matrix.e+r.matrix.e===0&&t.matrix.f+r.matrix.f===0))(a,{index:r}))return e;const{angle:i}=a.getItem(r),{e:s,f:c}=a.getItem(r-1).matrix;return P(()=>a.removeItem(r-1),w(3)),a.insertItemBefore(l(t)({angle:i,cx:s,cy:c}),r-1),e},B=(t,{angle:e=t.angle,cx:r=0,cy:a=0}={})=>n(t)?(t.setRotate(e,r,a),t):t;var A=p((function(t,e){return null==e||Number.isNaN(e)?t:e}));const N=(t=x())=>({sx:e=1,sy:r=1}={})=>{const n=u(t);return n.setScale(e,r),n},j=(t=x())=>(e,{sx:r=1,sy:n=1,cx:a=0,cy:o=0,index:i=0}={})=>{const s=m(e);s.insertItemBefore(d(t)({tx:-a,ty:-o}),i);const c=s.insertItemBefore(N(t)({sx:r,sy:n}),i);return s.insertItemBefore(d(t)({tx:a,ty:o}),i),c},E=(t=x())=>({a:e=1,b:r=0,c:n=0,d:a=1,e:o=0,f:i=0}={})=>{const s=t.createSVGMatrix();return s.a=e,s.b=r,s.c=n,s.d=a,s.e=o,s.f=i,s},L=(t=x())=>({matrix:e=E(t)()}={})=>{const r=u(t);return r.setMatrix(e),r},F=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_SCALE:r}=t;return e===r},$=(t,{index:e=0}={})=>e>0&&e+1<t.numberOfItems&&G(w(3),M(t=>e-1+t),M(e=>t.getItem(e)),([t,e,r])=>o(t)&&F(e)&&o(r)&&1===t.matrix.a&&0===t.matrix.b&&0===t.matrix.c&&1===t.matrix.d&&1===r.matrix.a&&0===r.matrix.b&&0===r.matrix.c&&1===r.matrix.d&&t.matrix.e+r.matrix.e===0&&t.matrix.f+r.matrix.f===0),C=(t=x())=>(e,{index:r=1}={})=>{const n=m(e);if(!$(n,{index:r}))return e;const a=G(w(3),M(t=>r-1+t),M(t=>n.getItem(t)),M(({matrix:t})=>t),I((t,e)=>t.multiply(e)),t=>({matrix:t}),L(t));return P(()=>n.removeItem(r-1),w(3)),n.insertItemBefore(a,r-1),e};var H=t=>t;function k(){}var z=p((function*(t,e){let r=null,n=!1;for(const a of h(e)){const e=n||T(a,t);if(e instanceof Promise?(e.catch(k),yield r=(r||Promise.resolve()).then(t=>e).then(t=>n?Promise.reject(S):(n=t,a)),r=r.catch(k)):(n=e,yield a),n)break}})),X=p((function(t,e){return G(M(t,e),z(H),I((t,e)=>t||e),(t=!1)=>t,Boolean)}));const q=new Set(["n","ne","e","se","s","sw","w","nw"]),D=(t,{index:e=1,x_name:r="x",y_name:n="y",width_name:a="width",height_name:o="height",direction:i}={})=>{const s=m(t);if(!$(s,{index:e})||!q.has(i))return t;const[{e:c,f:f},{a:x,d:u},{e:l,f:d}]=G(w(3),M(t=>e-1+t),M(t=>s.getItem(t)),M(({matrix:t})=>t)),[y,g,h,S]=G([r,n,a,o],M(e=>t.getAttributeNS(null,e)),M(parseFloat));return G([[y,x,l,c,h,["e","w"]],[g,u,d,f,S,["n","s"]]],M(([t,e,r,n,a,o])=>G(o,X(t=>i.includes(t)),o=>o?T((t+r)*e+n,t=>e<0?t+a*e:t):t)),([t,e])=>[[r,t],[n,e],[a,h*Math.abs(x)],[o,S*Math.abs(u)]],M(([t,e])=>[t,""+e]),P(([e,r])=>t.setAttributeNS(null,e,r))),P(()=>s.removeItem(e-1),w(3)),t},J=(t,{sx:e=t.matrix.a,sy:r=t.matrix.d}={})=>F(t)?(t.setScale(e,r),t):t,K=(t=x())=>(e,{tx:r=0,ty:n=0,index:a=0}={})=>m(e).insertItemBefore(d(t)({tx:r,ty:n}),a),Q=(t=x())=>(e,{index:r=0,x_name:n="x",y_name:a="y"}={})=>{const i=m(e);if(r>i.numberOfItems-1)return e;const s=i.getItem(r);if(!o(s))return e;const{e:c,f:f}=s.matrix;return G([{name:n,value:c},{name:a,value:f}],M(({name:t,value:r})=>({name:t,value:""+(parseFloat(e.getAttributeNS(null,t))+r)})),P(({name:t,value:r})=>e.setAttributeNS(null,t,r))),i.removeItem(r),G(w(i.numberOfItems),M(t=>i.getItem(t)),M(e=>[d(t)({tx:c,ty:f}),e,d(t)({tx:-c,ty:-f})]),P(([t,e,r])=>{const n=t.matrix.multiply(e.matrix).multiply(r.matrix);e.setMatrix(n)})),e},U=(t,{tx:e=t.matrix.e,ty:r=t.matrix.f}={})=>o(t)?(t.setTranslate(e,r),t):t,W=(t=x())=>({x:e=0,y:r=0}={})=>{const n=t.createSVGPoint();return n.x=e,n.y=r,n},Y=(t=x())=>e=>{e=e.trim(),t.innerHTML=e;const r=P(e=>t.removeChild(e),[...t.children]);return t.innerHTML="",r},Z=(t=x())=>e=>{const r=((t=x())=>e=>{const r=e.getBBox(),[n,a,o,i]=M(W(t),[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x,y:r.y+r.height},{x:r.x+r.width,y:r.y+r.height}]);return{top_left:n,top_right:a,bottom_left:o,bottom_right:i}})(t)(e),n=((t=x())=>(e,r)=>{const n=m(e),[a,o,i,s]=G([r.top_left,r.top_right,r.bottom_left,r.bottom_right],M(W(t)),M(t=>G(w(n.numberOfItems),M(t=>n.getItem(t)),M(({matrix:t})=>t),e=>I((t,e)=>t.matrixTransform(e),t,e))));return{top_left:a,top_right:o,bottom_left:i,bottom_right:s}})(t)(e,r);return{original:r,transformed:n,bounding:((t=x())=>(e,r)=>{const n=[r.top_left,r.top_right,r.bottom_left,r.bottom_right],[a,o]=T(R(({x:t})=>t,n),t=>[Math.min(...t),Math.max(...t)]),[i,s]=T(R(({y:t})=>t,n),t=>[Math.min(...t),Math.max(...t)]),[m,c]=M(W(t),[{x:a,y:i},{x:o,y:s}]);return{min:m,max:c}})(t)(e,n)}},tt=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_MATRIX:r}=t;return e===r},et={appendRotateTransform:a,appendTranslateTransform:i,consolidateTransformList:s,controlRotateTransform:(t=x())=>(e,{angle:r=0,cx:n=0,cy:o=0,index:i=0}={})=>{const c=y(t)(e,{angle:r,cx:n,cy:o,index:i}),f={update:({angle:t})=>(B(c,{angle:t,cx:0,cy:0}),f),append:({angle:t})=>(a(c,{angle:t}),f),end:()=>(O(t)(e,{index:i+1}),s(m(e)),e)};return{$el:e,transform:c,controller:f}},controlScaleTransform:(t=x())=>(e,{cx:r=0,cy:n=0,sx:a=1,sy:o=1,index:i=0,merge_type:c=1,x_name:f,y_name:x,width_name:u,height_name:l,direction:d})=>{const y=j(t)(e,{cx:r,cy:n,sx:a,sy:o,index:i}),g={update:({sx:t,sy:e})=>(J(y,{sx:t,sy:e}),g),end:({merge_type:r,x_name:n,y_name:a,width_name:o,height_name:y,direction:g})=>(2===A(c,r)?G([[f,n],[x,a],[u,o],[l,y],[d,g]],M(([t,e])=>A(t,e)),([t,e,r,n,a])=>({index:i+1,x_name:t,y_name:e,width_name:r,height_name:n,direction:a}),t=>D(e,t)):C(t)(e,{index:i+1}),s(m(e)),e)};return{$el:e,transform:y,controller:g}},controlTranslateTransform:(t=x())=>(e,{index:r=0,tx:n=0,ty:a=0,x_name:o,y_name:c}={})=>{const f=K(t)(e,{tx:n,ty:a,index:r}),x={update:({tx:t,ty:e})=>(U(f,{tx:t,ty:e}),x),append:({tx:t,ty:e})=>(i(f,{tx:t,ty:e}),x),end:()=>(o&&c&&Q(t)(e,{index:r,x_name:o,y_name:c}),s(m(e)),e)};return{$el:e,controller:x,transform:f}},createSVGMatrix:E,createSVGPoint:W,createSVGRect:(t=x())=>({x:e=0,y:r=0,width:n=0,height:a=0}={})=>{const o=t.createSVGRect();return o.x=e,o.y=r,o.width=n,o.height=a,o},createSVGTransform:u,createSVGTransformMatrix:L,createSVGTransformRotate:l,createSVGTransformScale:N,createSVGTransformTranslate:d,el:(t=x())=>e=>V(Y(t)(e)),els:Y,getAnimTransformList:({transform:{animVal:t}})=>t,getBaseTransformList:m,getBoxPoints:Z,getCenterPoint:(t=x())=>e=>G(Z(t)(e),({original:t,transformed:e})=>[t,e],M(((t=x())=>e=>{const r=[e.top_left,e.top_right,e.bottom_left,e.bottom_right],n=G(r,M(({x:t})=>t),I((t,e)=>t+e),t=>t/4),a=G(r,M(({y:t})=>t),I((t,e)=>t+e),t=>t/4);return W(t)({x:n,y:a})})(t)),([t,e])=>({original:t,transformed:e})),getSVG:x,setSVG:f,initMatrixTransform:(t=x())=>(e,{matrix:r=E()(),index:n=0}={})=>m(e).insertItemBefore(L(t)({matrix:r}),n),initRotateTransform:y,initScaleTransform:j,initTranslateTransform:K,isMatrixSVGTransform:tt,isRotateSVGTransform:n,isScaleSVGTransform:F,isTranslateSVGTransform:o,isValidFxScaleSVGTransformList:$,mergeRotateTransform:O,mergeScaleTransform:C,mergeScaleTransform2:D,mergeTranslateTransform:Q,updateMatrixTransform:(t,{matrix:e}={})=>tt(t)?(e&&t.setMatrix(e),t):t,updateRotateTransform:B,updateScaleTransform:J,updateTranslateTransform:U};window.$$=et}]);
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var a=e[n]={i:n,l:!1,exports:{}};return t[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)r.d(n,a,function(e){return t[e]}.bind(null,a));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=1)}([,function(t,e,r){"use strict";r.r(e);const n=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_ROTATE:r}=t;return e===r},a=(t,{angle:e=0})=>{if(!n(t))return t;const{angle:r}=t;return t.setRotate(r+e,0,0),t},o=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_TRANSLATE:r}=t;return e===r},i=(t,{tx:e=0,ty:r=0})=>{if(!o(t))return t;const{e:n,f:a}=t.matrix;return t.setTranslate(n+e,a+r),t},s=t=>{const e=t.consolidate();return e?(t.initialize(e),t):t},m=({transform:{baseVal:t}})=>t;let c;const f=t=>(c=t,c),x=()=>(c||f(document.createElementNS("http://www.w3.org/2000/svg","svg")),c),l=(t=x())=>t.createSVGTransform(),u=(t=x())=>({angle:e=0,cx:r=0,cy:n=0}={})=>{const a=l(t);return a.setRotate(e,r,n),a},d=(t=x())=>({tx:e=0,ty:r=0}={})=>{const n=l(t);return n.setTranslate(e,r),n},y=(t=x())=>(e,{angle:r=0,cx:n=0,cy:a=0,index:o=0}={})=>{const i=m(e);i.insertItemBefore(d(t)({tx:-n,ty:-a}),o);const s=i.insertItemBefore(u(t)({angle:r}),o);return i.insertItemBefore(d(t)({tx:n,ty:a}),o),s},g=function*(){}();function h(t){return t&&t[Symbol.iterator]?t[Symbol.iterator]():g}var T=(t,e)=>t instanceof Promise?t.then(e):e(t);var S=Symbol.for("nop");function _(t,e,r){return e instanceof Promise?e.then(e=>r(t,e),e=>e==S?t:Promise.reject(e)):r(t,e)}function p(t){return(e,...r)=>r.length?t(e,...r):(...r)=>t(e,...r)}var b=p((function(t,e){if(t<1)return[];let r=[];return e=h(e),function n(){let a;for(;!(a=e.next()).done;){const e=a.value;if(e instanceof Promise)return e.then(e=>(r.push(e),r).length==t?r:n()).catch(t=>t==S?n():Promise.reject(t));if(r.push(e),r.length==t)return r}return r}()}));function V(t){return T(b(1,t),([t])=>t)}function I(t,e,r){return 1==arguments.length?(...e)=>I(t,...e):2==arguments.length?I(t,V(r=h(e)),r):(r=h(r),T(e,(function e(n){let a;for(;!(a=r.next()).done;)if((n=_(n,a.value,t))instanceof Promise)return n.then(e);return n})))}var v=(t,e)=>e(t);function G(...t){return I(v,t)}function*w(t=0,e=t,r=1){if(1===arguments.length&&(t=0),arguments.length<3&&t>e&&(r*=-1),t<e)for(;t<e;)yield t,t+=r;else for(;t>e;)yield t,t+=r}var M=p((function*(t,e){for(const r of h(e))yield T(r,t)}));var R=p((function(t,e){return function(t){return b(1/0,t)}(M(t,e))})),P=p((function(t,e){return R(e=>T(t(e),t=>e),e)}));const O=(t=x())=>(e,{index:r=1}={})=>{const a=m(e);if(!((t,{index:e})=>!(e>t.numberOfItems-2)&&G(w(3),M(t=>e-1+t),M(e=>t.getItem(e)),([t,e,r])=>o(t)&&n(e)&&o(r)&&0===e.matrix.e&&0===e.matrix.f&&1===t.matrix.a&&0===t.matrix.b&&0===t.matrix.c&&1===t.matrix.d&&1===r.matrix.a&&0===r.matrix.b&&0===r.matrix.c&&1===r.matrix.d&&t.matrix.e+r.matrix.e===0&&t.matrix.f+r.matrix.f===0))(a,{index:r}))return e;const{angle:i}=a.getItem(r),{e:s,f:c}=a.getItem(r-1).matrix;return P(()=>a.removeItem(r-1),w(3)),a.insertItemBefore(u(t)({angle:i,cx:s,cy:c}),r-1),e},B=(t,{angle:e=t.angle,cx:r=0,cy:a=0}={})=>n(t)?(t.setRotate(e,r,a),t):t,A=(t=x())=>({sx:e=1,sy:r=1}={})=>{const n=l(t);return n.setScale(e,r),n},j=(t=x())=>(e,{sx:r=1,sy:n=1,cx:a=0,cy:o=0,index:i=0}={})=>{const s=m(e);s.insertItemBefore(d(t)({tx:-a,ty:-o}),i);const c=s.insertItemBefore(A(t)({sx:r,sy:n}),i);return s.insertItemBefore(d(t)({tx:a,ty:o}),i),c},N=(t=x())=>({a:e=1,b:r=0,c:n=0,d:a=1,e:o=0,f:i=0}={})=>{const s=t.createSVGMatrix();return s.a=e,s.b=r,s.c=n,s.d=a,s.e=o,s.f=i,s},E=(t=x())=>({matrix:e=N(t)()}={})=>{const r=l(t);return r.setMatrix(e),r},L=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_SCALE:r}=t;return e===r},F=(t,{index:e=0}={})=>e>0&&e+1<t.numberOfItems&&G(w(3),M(t=>e-1+t),M(e=>t.getItem(e)),([t,e,r])=>o(t)&&L(e)&&o(r)&&1===t.matrix.a&&0===t.matrix.b&&0===t.matrix.c&&1===t.matrix.d&&1===r.matrix.a&&0===r.matrix.b&&0===r.matrix.c&&1===r.matrix.d&&t.matrix.e+r.matrix.e===0&&t.matrix.f+r.matrix.f===0),$=(t=x())=>(e,{index:r=1}={})=>{const n=m(e);if(!F(n,{index:r}))return e;const a=G(w(3),M(t=>r-1+t),M(t=>n.getItem(t)),M(({matrix:t})=>t),I((t,e)=>t.multiply(e)),t=>({matrix:t}),E(t));return P(()=>n.removeItem(r-1),w(3)),n.insertItemBefore(a,r-1),e};var C=t=>t;function H(){}var k=p((function*(t,e){let r=null,n=!1;for(const a of h(e)){const e=n||T(a,t);if(e instanceof Promise?(e.catch(H),yield r=(r||Promise.resolve()).then(t=>e).then(t=>n?Promise.reject(S):(n=t,a)),r=r.catch(H)):(n=e,yield a),n)break}})),z=p((function(t,e){return G(M(t,e),k(C),I((t,e)=>t||e),(t=!1)=>t,Boolean)}));const X=new Set(["n","ne","e","se","s","sw","w","nw"]),q=(t,{index:e=1,x_name:r="x",y_name:n="y",width_name:a="width",height_name:o="height",direction:i}={})=>{const s=m(t);if(!F(s,{index:e})||!X.has(i))return t;const[{e:c,f:f},{a:x,d:l},{e:u,f:d}]=G(w(3),M(t=>e-1+t),M(t=>s.getItem(t)),M(({matrix:t})=>t)),[y,g,h,S]=G([r,n,a,o],M(e=>t.getAttributeNS(null,e)),M(parseFloat));return G([[y,x,u,c,h,["e","w"]],[g,l,d,f,S,["n","s"]]],M(([t,e,r,n,a,o])=>G(o,z(t=>i.includes(t)),o=>o?T((t+r)*e+n,t=>e<0?t+a*e:t):t)),([t,e])=>[[r,t],[n,e],[a,h*Math.abs(x)],[o,S*Math.abs(l)]],M(([t,e])=>[t,""+e]),P(([e,r])=>t.setAttributeNS(null,e,r))),P(()=>s.removeItem(e-1),w(3)),t},D=(t,{sx:e=t.matrix.a,sy:r=t.matrix.d}={})=>L(t)?(t.setScale(e,r),t):t,J=(t=x())=>(e,{tx:r=0,ty:n=0,index:a=0}={})=>m(e).insertItemBefore(d(t)({tx:r,ty:n}),a),K=(t=x())=>(e,{index:r=0,x_name:n="x",y_name:a="y"}={})=>{const i=m(e);if(r>i.numberOfItems-1)return e;const s=i.getItem(r);if(!o(s))return e;const{e:c,f:f}=s.matrix;return G([{name:n,value:c},{name:a,value:f}],M(({name:t,value:r})=>({name:t,value:""+(parseFloat(e.getAttributeNS(null,t))+r)})),P(({name:t,value:r})=>e.setAttributeNS(null,t,r))),i.removeItem(r),G(w(i.numberOfItems),M(t=>i.getItem(t)),M(e=>[d(t)({tx:c,ty:f}),e,d(t)({tx:-c,ty:-f})]),P(([t,e,r])=>{const n=t.matrix.multiply(e.matrix).multiply(r.matrix);e.setMatrix(n)})),e},Q=(t,{tx:e=t.matrix.e,ty:r=t.matrix.f}={})=>o(t)?(t.setTranslate(e,r),t):t,U=(t=x())=>({x:e=0,y:r=0}={})=>{const n=t.createSVGPoint();return n.x=e,n.y=r,n},W=(t=x())=>e=>{e=e.trim(),t.innerHTML=e;const r=P(e=>t.removeChild(e),[...t.children]);return t.innerHTML="",r},Y=(t=x())=>e=>{const r=((t=x())=>e=>{const r=e.getBBox(),[n,a,o,i]=M(U(t),[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x,y:r.y+r.height},{x:r.x+r.width,y:r.y+r.height}]);return{top_left:n,top_right:a,bottom_left:o,bottom_right:i}})(t)(e),n=((t=x())=>(e,r)=>{const n=m(e),[a,o,i,s]=G([r.top_left,r.top_right,r.bottom_left,r.bottom_right],M(U(t)),M(t=>G(w(n.numberOfItems),M(t=>n.getItem(t)),M(({matrix:t})=>t),e=>I((t,e)=>t.matrixTransform(e),t,e))));return{top_left:a,top_right:o,bottom_left:i,bottom_right:s}})(t)(e,r);return{original:r,transformed:n,bounding:((t=x())=>(e,r)=>{const n=[r.top_left,r.top_right,r.bottom_left,r.bottom_right],[a,o]=T(R(({x:t})=>t,n),t=>[Math.min(...t),Math.max(...t)]),[i,s]=T(R(({y:t})=>t,n),t=>[Math.min(...t),Math.max(...t)]),[m,c]=M(U(t),[{x:a,y:i},{x:o,y:s}]);return{min:m,max:c}})(t)(e,n)}},Z=t=>{if(!(t instanceof SVGTransform))throw new Error("It's not a SVGTransform.");const{type:e,SVG_TRANSFORM_MATRIX:r}=t;return e===r},tt={appendRotateTransform:a,appendTranslateTransform:i,consolidateTransformList:s,controlRotateTransform:(t=x())=>(e,{angle:r=0,cx:n=0,cy:o=0,index:i=0}={})=>{const c=y(t)(e,{angle:r,cx:n,cy:o,index:i}),f={update:({angle:t})=>(B(c,{angle:t,cx:0,cy:0}),f),append:({angle:t})=>(a(c,{angle:t}),f),end:()=>(O(t)(e,{index:i+1}),s(m(e)),e)};return{$el:e,transform:c,controller:f}},controlScaleTransform:(t=x())=>(e,{cx:r=0,cy:n=0,sx:a=1,sy:o=1,index:i=0,merge_type:c=1,x_name:f,y_name:x,width_name:l,height_name:u,direction:d}={})=>{const y=j(t)(e,{cx:r,cy:n,sx:a,sy:o,index:i}),g={update:({sx:t,sy:e}={})=>(D(y,{sx:t,sy:e}),g),end:({merge_type:r=c,x_name:n=f,y_name:a=x,width_name:o=l,height_name:y=u,direction:g=d}={})=>(2===r?q(e,{index:i+1,x_name:n,y_name:a,width_name:o,height_name:y,direction:g}):$(t)(e,{index:i+1}),s(m(e)),e)};return{$el:e,transform:y,controller:g}},controlTranslateTransform:(t=x())=>(e,{index:r=0,tx:n=0,ty:a=0,x_name:o,y_name:c}={})=>{const f=J(t)(e,{tx:n,ty:a,index:r}),x={update:({tx:t,ty:e})=>(Q(f,{tx:t,ty:e}),x),append:({tx:t,ty:e})=>(i(f,{tx:t,ty:e}),x),end:()=>(o&&c&&K(t)(e,{index:r,x_name:o,y_name:c}),s(m(e)),e)};return{$el:e,controller:x,transform:f}},createSVGMatrix:N,createSVGPoint:U,createSVGRect:(t=x())=>({x:e=0,y:r=0,width:n=0,height:a=0}={})=>{const o=t.createSVGRect();return o.x=e,o.y=r,o.width=n,o.height=a,o},createSVGTransform:l,createSVGTransformMatrix:E,createSVGTransformRotate:u,createSVGTransformScale:A,createSVGTransformTranslate:d,el:(t=x())=>e=>V(W(t)(e)),els:W,getAnimTransformList:({transform:{animVal:t}})=>t,getBaseTransformList:m,getBoxPoints:Y,getCenterPoint:(t=x())=>e=>G(Y(t)(e),({original:t,transformed:e})=>[t,e],M(((t=x())=>e=>{const r=[e.top_left,e.top_right,e.bottom_left,e.bottom_right],n=G(r,M(({x:t})=>t),I((t,e)=>t+e),t=>t/4),a=G(r,M(({y:t})=>t),I((t,e)=>t+e),t=>t/4);return U(t)({x:n,y:a})})(t)),([t,e])=>({original:t,transformed:e})),getSVG:x,setSVG:f,initMatrixTransform:(t=x())=>(e,{matrix:r=N()(),index:n=0}={})=>m(e).insertItemBefore(E(t)({matrix:r}),n),initRotateTransform:y,initScaleTransform:j,initTranslateTransform:J,isMatrixSVGTransform:Z,isRotateSVGTransform:n,isScaleSVGTransform:L,isTranslateSVGTransform:o,isValidFxScaleSVGTransformList:F,mergeRotateTransform:O,mergeScaleTransform:$,mergeScaleTransform2:q,mergeTranslateTransform:K,updateMatrixTransform:(t,{matrix:e}={})=>Z(t)?(e&&t.setMatrix(e),t):t,updateRotateTransform:B,updateScaleTransform:D,updateTranslateTransform:Q};window.$$=tt}]);
{
"name": "fxsvg",
"version": "0.2.4",
"version": "0.2.5",
"description": "Functional SVG Handling Library",

@@ -5,0 +5,0 @@ "type": "module",

@@ -1,2 +0,1 @@

import { defaultTo, go, mapL } from "fxjs2";
import { $$consolidateTransformList } from "../consolidateTransformList/consolidateTransformList.index.js";

@@ -24,3 +23,3 @@ import { $$getBaseTransformList } from "../getBaseTransformList/getBaseTransformList.index.js";

direction: _direction,
}
} = {}
) => {

@@ -36,3 +35,3 @@ const transform = $$initScaleTransform($svg)($el, {

const controller = {};
controller.update = ({ sx, sy }) => {
controller.update = ({ sx, sy } = {}) => {
$$updateScaleTransform(transform, { sx, sy });

@@ -42,29 +41,18 @@ return controller;

controller.end = ({
merge_type,
x_name,
y_name,
width_name,
height_name,
direction,
}) => {
defaultTo(_merge_type, merge_type) === 2
? go(
[
[_x_name, x_name],
[_y_name, y_name],
[_width_name, width_name],
[_height_name, height_name],
[_direction, direction],
],
mapL(([a, b]) => defaultTo(a, b)),
([x_name, y_name, width_name, height_name, direction]) => ({
index: index + 1,
x_name,
y_name,
width_name,
height_name,
direction,
}),
(config) => $$mergeScaleTransform2($el, config)
)
merge_type = _merge_type,
x_name = _x_name,
y_name = _y_name,
width_name = _width_name,
height_name = _height_name,
direction = _direction,
} = {}) => {
merge_type === 2
? $$mergeScaleTransform2($el, {
index: index + 1,
x_name,
y_name,
width_name,
height_name,
direction,
})
: $$mergeScaleTransform($svg)($el, { index: index + 1 });

@@ -71,0 +59,0 @@ $$consolidateTransformList($$getBaseTransformList($el));

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc