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

path2d-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

path2d-polyfill - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

3

dist/index.esm.js

@@ -622,7 +622,4 @@ var ARG_LENGTH = {

};
var src_1 = src.path2dPolyfill;
var src_2 = src.parsePath;
export default src;
export { src_2 as parsePath, src_1 as path2dPolyfill };
//# sourceMappingURL=index.esm.js.map

2

dist/index.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).path2dPolyfill={})}(this,(function(e){"use strict";var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=/([astvzqmhlc])([^astvzqmhlc]*)/gi,a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;var r=function(e){var r=[],s=String(e).trim();return"M"!==s[0]&&"m"!==s[0]||s.replace(n,(function(e,n,s){var o=n.toLowerCase(),i=function(e){var t=e.match(a);return t?t.map(Number):[]}(s),l=n;if("m"===o&&i.length>2&&(r.push([l].concat(i.splice(0,2))),o="l",l="m"===l?"l":"L"),i.length<t[o])return"";for(r.push([l].concat(i.splice(0,t[o])));i.length>=t[o]&&i.length&&t[o];)r.push([l].concat(i.splice(0,t[o])));return""})),r};function s(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function l(e,t){var n=e.x*Math.cos(t)-e.y*Math.sin(t),a=e.y*Math.cos(t)+e.x*Math.sin(t);e.x=n,e.y=a}function c(e,t){e.x*=t,e.y*=t}var u=function(e){if(void 0!==e&&e.CanvasRenderingContext2D&&(!e.Path2D||!function(e){var t=e.document.createElement("canvas").getContext("2d"),n=new e.Path2D("M0 0 L1 1");return t.strokeStyle="red",t.lineWidth=1,t.stroke(n),255===t.getImageData(0,0,1,1).data[0]}(e))){var t=function(){function e(t){var n;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.segments=[],t&&t instanceof e)?(n=this.segments).push.apply(n,o(t.segments)):t&&(this.segments=r(t))}var t,n,a;return t=e,(n=[{key:"addPath",value:function(t){var n;t&&t instanceof e&&(n=this.segments).push.apply(n,o(t.segments))}},{key:"moveTo",value:function(e,t){this.segments.push(["M",e,t])}},{key:"lineTo",value:function(e,t){this.segments.push(["L",e,t])}},{key:"arc",value:function(e,t,n,a,r,s){this.segments.push(["AC",e,t,n,a,r,!!s])}},{key:"arcTo",value:function(e,t,n,a,r){this.segments.push(["AT",e,t,n,a,r])}},{key:"ellipse",value:function(e,t,n,a,r,s,o,i){this.segments.push(["E",e,t,n,a,r,s,o,!!i])}},{key:"closePath",value:function(){this.segments.push(["Z"])}},{key:"bezierCurveTo",value:function(e,t,n,a,r,s){this.segments.push(["C",e,t,n,a,r,s])}},{key:"quadraticCurveTo",value:function(e,t,n,a){this.segments.push(["Q",e,t,n,a])}},{key:"rect",value:function(e,t,n,a){this.segments.push(["R",e,t,n,a])}}])&&s(t.prototype,n),a&&s(t,a),e}(),n=e.CanvasRenderingContext2D.prototype.fill,a=e.CanvasRenderingContext2D.prototype.stroke;e.CanvasRenderingContext2D.prototype.fill=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];var r="nonzero";if(0===t.length||1===t.length&&"string"==typeof t[0])n.apply(this,t);else{2===arguments.length&&(r=t[1]);var s=t[0];i(this,s.segments),n.call(this,r)}},e.CanvasRenderingContext2D.prototype.stroke=function(e){e?(i(this,e.segments),a.call(this)):a.call(this)},e.Path2D=t}function i(e,t){var n,a,r,s,o,i,u,h,f,y,p,v,m,d,g,b,x,k,C,T,M,P,w,q,A,z,D,S,j,R={x:0,y:0},E={x:0,y:0};e.beginPath();for(var I=0;I<t.length;++I){var L=t[I];switch("S"!==(T=L[0])&&"s"!==T&&"C"!==T&&"c"!==T&&(P=null,w=null),"T"!==T&&"t"!==T&&"Q"!==T&&"q"!==T&&(q=null,A=null),T){case"m":case"M":"m"===T?(p+=L[1],m+=L[2]):(p=L[1],m=L[2]),"M"!==T&&R||(R={x:p,y:m}),e.moveTo(p,m);break;case"l":p+=L[1],m+=L[2],e.lineTo(p,m);break;case"L":p=L[1],m=L[2],e.lineTo(p,m);break;case"H":p=L[1],e.lineTo(p,m);break;case"h":p+=L[1],e.lineTo(p,m);break;case"V":m=L[1],e.lineTo(p,m);break;case"v":m+=L[1],e.lineTo(p,m);break;case"a":case"A":"a"===T?(p+=L[6],m+=L[7]):(p=L[6],m=L[7]),b=L[1],x=L[2],u=L[3]*Math.PI/180,r=!!L[4],s=!!L[5],o={x:p,y:m},l(i={x:(E.x-o.x)/2,y:(E.y-o.y)/2},-u),(h=i.x*i.x/(b*b)+i.y*i.y/(x*x))>1&&(b*=h=Math.sqrt(h),x*=h),f=b*b*x*x,y=b*b*i.y*i.y+x*x*i.x*i.x,c(M={x:b*i.y/x,y:-x*i.x/b},s!==r?Math.sqrt((f-y)/y)||0:-Math.sqrt((f-y)/y)||0),a=Math.atan2((i.y-M.y)/x,(i.x-M.x)/b),n=Math.atan2(-(i.y+M.y)/x,-(i.x+M.x)/b),l(M,u),D=M,S=(o.x+E.x)/2,j=(o.y+E.y)/2,D.x+=S,D.y+=j,e.save(),e.translate(M.x,M.y),e.rotate(u),e.scale(b,x),e.arc(0,0,1,a,n,!s),e.restore();break;case"C":P=L[3],w=L[4],p=L[5],m=L[6],e.bezierCurveTo(L[1],L[2],P,w,p,m);break;case"c":e.bezierCurveTo(L[1]+p,L[2]+m,L[3]+p,L[4]+m,L[5]+p,L[6]+m),P=L[3]+p,w=L[4]+m,p+=L[5],m+=L[6];break;case"S":null!==P&&null!==P||(P=p,w=m),e.bezierCurveTo(2*p-P,2*m-w,L[1],L[2],L[3],L[4]),P=L[1],w=L[2],p=L[3],m=L[4];break;case"s":null!==P&&null!==P||(P=p,w=m),e.bezierCurveTo(2*p-P,2*m-w,L[1]+p,L[2]+m,L[3]+p,L[4]+m),P=L[1]+p,w=L[2]+m,p+=L[3],m+=L[4];break;case"Q":q=L[1],A=L[2],p=L[3],m=L[4],e.quadraticCurveTo(q,A,p,m);break;case"q":q=L[1]+p,A=L[2]+m,p+=L[3],m+=L[4],e.quadraticCurveTo(q,A,p,m);break;case"T":null!==q&&null!==q||(q=p,A=m),q=2*p-q,A=2*m-A,p=L[1],m=L[2],e.quadraticCurveTo(q,A,p,m);break;case"t":null!==q&&null!==q||(q=p,A=m),q=2*p-q,A=2*m-A,p+=L[1],m+=L[2],e.quadraticCurveTo(q,A,p,m);break;case"z":case"Z":p=R.x,m=R.y,R=void 0,e.closePath();break;case"AC":p=L[1],m=L[2],g=L[3],a=L[4],n=L[5],z=L[6],e.arc(p,m,g,a,n,z);break;case"AT":v=L[1],d=L[2],p=L[3],m=L[4],g=L[5],e.arcTo(v,d,p,m,g);break;case"E":p=L[1],m=L[2],b=L[3],x=L[4],u=L[5],a=L[6],n=L[7],z=L[8],e.save(),e.translate(p,m),e.rotate(u),e.scale(b,x),e.arc(0,0,1,a,n,z),e.restore();break;case"R":p=L[1],m=L[2],k=L[3],C=L[4],R={x:p,y:m},e.rect(p,m,k,C)}E.x=p,E.y=m}}};"undefined"!=typeof window&&u(window);var h={path2dPolyfill:u,parsePath:r},f=h.path2dPolyfill,y=h.parsePath;e.default=h,e.parsePath=y,e.path2dPolyfill=f,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).path2dPolyfill={})}(this,(function(e){"use strict";var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=/([astvzqmhlc])([^astvzqmhlc]*)/gi,a=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;var r=function(e){var r=[],s=String(e).trim();return"M"!==s[0]&&"m"!==s[0]||s.replace(n,(function(e,n,s){var o=n.toLowerCase(),i=function(e){var t=e.match(a);return t?t.map(Number):[]}(s),l=n;if("m"===o&&i.length>2&&(r.push([l].concat(i.splice(0,2))),o="l",l="m"===l?"l":"L"),i.length<t[o])return"";for(r.push([l].concat(i.splice(0,t[o])));i.length>=t[o]&&i.length&&t[o];)r.push([l].concat(i.splice(0,t[o])));return""})),r};function s(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function l(e,t){var n=e.x*Math.cos(t)-e.y*Math.sin(t),a=e.y*Math.cos(t)+e.x*Math.sin(t);e.x=n,e.y=a}function c(e,t){e.x*=t,e.y*=t}var u=function(e){if(void 0!==e&&e.CanvasRenderingContext2D&&(!e.Path2D||!function(e){var t=e.document.createElement("canvas").getContext("2d"),n=new e.Path2D("M0 0 L1 1");return t.strokeStyle="red",t.lineWidth=1,t.stroke(n),255===t.getImageData(0,0,1,1).data[0]}(e))){var t=function(){function e(t){var n;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.segments=[],t&&t instanceof e)?(n=this.segments).push.apply(n,o(t.segments)):t&&(this.segments=r(t))}var t,n,a;return t=e,(n=[{key:"addPath",value:function(t){var n;t&&t instanceof e&&(n=this.segments).push.apply(n,o(t.segments))}},{key:"moveTo",value:function(e,t){this.segments.push(["M",e,t])}},{key:"lineTo",value:function(e,t){this.segments.push(["L",e,t])}},{key:"arc",value:function(e,t,n,a,r,s){this.segments.push(["AC",e,t,n,a,r,!!s])}},{key:"arcTo",value:function(e,t,n,a,r){this.segments.push(["AT",e,t,n,a,r])}},{key:"ellipse",value:function(e,t,n,a,r,s,o,i){this.segments.push(["E",e,t,n,a,r,s,o,!!i])}},{key:"closePath",value:function(){this.segments.push(["Z"])}},{key:"bezierCurveTo",value:function(e,t,n,a,r,s){this.segments.push(["C",e,t,n,a,r,s])}},{key:"quadraticCurveTo",value:function(e,t,n,a){this.segments.push(["Q",e,t,n,a])}},{key:"rect",value:function(e,t,n,a){this.segments.push(["R",e,t,n,a])}}])&&s(t.prototype,n),a&&s(t,a),e}(),n=e.CanvasRenderingContext2D.prototype.fill,a=e.CanvasRenderingContext2D.prototype.stroke;e.CanvasRenderingContext2D.prototype.fill=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];var r="nonzero";if(0===t.length||1===t.length&&"string"==typeof t[0])n.apply(this,t);else{2===arguments.length&&(r=t[1]);var s=t[0];i(this,s.segments),n.call(this,r)}},e.CanvasRenderingContext2D.prototype.stroke=function(e){e?(i(this,e.segments),a.call(this)):a.call(this)},e.Path2D=t}function i(e,t){var n,a,r,s,o,i,u,h,f,y,v,p,m,g,b,d,x,k,C,T,M,w,q,A,P,z,D,S,j,R={x:0,y:0},E={x:0,y:0};e.beginPath();for(var I=0;I<t.length;++I){var L=t[I];switch("S"!==(T=L[0])&&"s"!==T&&"C"!==T&&"c"!==T&&(w=null,q=null),"T"!==T&&"t"!==T&&"Q"!==T&&"q"!==T&&(A=null,P=null),T){case"m":case"M":"m"===T?(v+=L[1],m+=L[2]):(v=L[1],m=L[2]),"M"!==T&&R||(R={x:v,y:m}),e.moveTo(v,m);break;case"l":v+=L[1],m+=L[2],e.lineTo(v,m);break;case"L":v=L[1],m=L[2],e.lineTo(v,m);break;case"H":v=L[1],e.lineTo(v,m);break;case"h":v+=L[1],e.lineTo(v,m);break;case"V":m=L[1],e.lineTo(v,m);break;case"v":m+=L[1],e.lineTo(v,m);break;case"a":case"A":"a"===T?(v+=L[6],m+=L[7]):(v=L[6],m=L[7]),d=L[1],x=L[2],u=L[3]*Math.PI/180,r=!!L[4],s=!!L[5],o={x:v,y:m},l(i={x:(E.x-o.x)/2,y:(E.y-o.y)/2},-u),(h=i.x*i.x/(d*d)+i.y*i.y/(x*x))>1&&(d*=h=Math.sqrt(h),x*=h),f=d*d*x*x,y=d*d*i.y*i.y+x*x*i.x*i.x,c(M={x:d*i.y/x,y:-x*i.x/d},s!==r?Math.sqrt((f-y)/y)||0:-Math.sqrt((f-y)/y)||0),a=Math.atan2((i.y-M.y)/x,(i.x-M.x)/d),n=Math.atan2(-(i.y+M.y)/x,-(i.x+M.x)/d),l(M,u),D=M,S=(o.x+E.x)/2,j=(o.y+E.y)/2,D.x+=S,D.y+=j,e.save(),e.translate(M.x,M.y),e.rotate(u),e.scale(d,x),e.arc(0,0,1,a,n,!s),e.restore();break;case"C":w=L[3],q=L[4],v=L[5],m=L[6],e.bezierCurveTo(L[1],L[2],w,q,v,m);break;case"c":e.bezierCurveTo(L[1]+v,L[2]+m,L[3]+v,L[4]+m,L[5]+v,L[6]+m),w=L[3]+v,q=L[4]+m,v+=L[5],m+=L[6];break;case"S":null!==w&&null!==w||(w=v,q=m),e.bezierCurveTo(2*v-w,2*m-q,L[1],L[2],L[3],L[4]),w=L[1],q=L[2],v=L[3],m=L[4];break;case"s":null!==w&&null!==w||(w=v,q=m),e.bezierCurveTo(2*v-w,2*m-q,L[1]+v,L[2]+m,L[3]+v,L[4]+m),w=L[1]+v,q=L[2]+m,v+=L[3],m+=L[4];break;case"Q":A=L[1],P=L[2],v=L[3],m=L[4],e.quadraticCurveTo(A,P,v,m);break;case"q":A=L[1]+v,P=L[2]+m,v+=L[3],m+=L[4],e.quadraticCurveTo(A,P,v,m);break;case"T":null!==A&&null!==A||(A=v,P=m),A=2*v-A,P=2*m-P,v=L[1],m=L[2],e.quadraticCurveTo(A,P,v,m);break;case"t":null!==A&&null!==A||(A=v,P=m),A=2*v-A,P=2*m-P,v+=L[1],m+=L[2],e.quadraticCurveTo(A,P,v,m);break;case"z":case"Z":v=R.x,m=R.y,R=void 0,e.closePath();break;case"AC":v=L[1],m=L[2],b=L[3],a=L[4],n=L[5],z=L[6],e.arc(v,m,b,a,n,z);break;case"AT":p=L[1],g=L[2],v=L[3],m=L[4],b=L[5],e.arcTo(p,g,v,m,b);break;case"E":v=L[1],m=L[2],d=L[3],x=L[4],u=L[5],a=L[6],n=L[7],z=L[8],e.save(),e.translate(v,m),e.rotate(u),e.scale(d,x),e.arc(0,0,1,a,n,z),e.restore();break;case"R":v=L[1],m=L[2],k=L[3],C=L[4],R={x:v,y:m},e.rect(v,m,k,C)}E.x=v,E.y=m}}};"undefined"!=typeof window&&u(window);var h={path2dPolyfill:u,parsePath:r};e.default=h,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=index.js.map
{
"name": "path2d-polyfill",
"version": "1.0.0",
"version": "1.0.1",
"description": "Polyfills Path2D api for canvas rendering",

@@ -36,3 +36,3 @@ "scripts": {

"@rollup/plugin-babel": "^5.0.2",
"@rollup/plugin-commonjs": "^12.0.0",
"@rollup/plugin-commonjs": "^15.0.0",
"chai": "^4.2.0",

@@ -42,9 +42,9 @@ "eslint": "^7.1.0",

"eslint-plugin-prettier": "^3.1.3",
"mocha": "^7.2.0",
"mocha": "^8.1.2",
"nyc": "^15.0.1",
"prettier": "2.0.5",
"prettier": "^2.1.1",
"rollup": "^2.10.9",
"rollup-plugin-livereload": "^1.3.0",
"rollup-plugin-serve": "^1.0.1",
"rollup-plugin-terser": "6.1.0",
"rollup-plugin-terser": "7.0.0",
"sinon": "^9.0.2",

@@ -51,0 +51,0 @@ "sinon-chai": "^3.3.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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