Socket
Socket
Sign inDemoInstall

canvas-size

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.2.3

6

CHANGELOG.md
# Change Log
## 1.2.3
*2021-03-03*
- Fix handling of floating point sizes in Webkit-based browsers (e.g. Safari)
## 1.2.2

@@ -4,0 +10,0 @@

6

dist/canvas-size.esm.js
/*!
* canvas-size
* v1.2.2
* v1.2.3
* https://github.com/jhildenbiddle/canvas-size

@@ -150,4 +150,4 @@ * (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com>

var size = settings.sizes.shift();
var width = size[0];
var height = size[1];
var width = Math.max(Math.ceil(size[0]), 1);
var height = Math.max(Math.ceil(size[1]), 1);
var fill = [ width - 1, height - 1, 1, 1 ];

@@ -154,0 +154,0 @@ var job = Date.now();

/*!
* canvas-size
* v1.2.2
* v1.2.3
* https://github.com/jhildenbiddle/canvas-size

@@ -8,3 +8,3 @@ * (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com>

*/
function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function n(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return r}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||a(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 a(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e){var t,r,n=e.sizes.shift(),o=n[0],i=n[1],a=[o-1,i-1,1,1],s=Date.now(),u="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;u?(t=new OffscreenCanvas(1,1),r=new OffscreenCanvas(o,i)):((t=document.createElement("canvas")).width=1,t.height=1,(r=document.createElement("canvas")).width=o,r.height=i);var f=t.getContext("2d"),l=r.getContext("2d");l&&(l.fillRect.apply(l,a),f.drawImage(r,o-1,i-1,1,1,0,0,1,1));var h=f&&0!==f.getImageData(0,0,1,1).data[3],p=Date.now()-s;return u?(postMessage({width:o,height:i,benchmark:p,isTestPass:h}),!h&&e.sizes.length&&c(e)):h?e.onSuccess(o,i,p):(e.onError(o,i,p),e.sizes.length&&c(e)),h}var u=[16384,14188,11402,10836,11180,8192,4096,1],f=[8388607,65535,32767,16384,8192,4096,1],l=[4194303,65535,32767,16384,8192,4096,1],h={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},p={};function m(e){var t=e.width===e.height,r=1===e.height,n=1===e.width,o=[];if(e.width&&e.height)for(var i=e.min||h.min,a=e.step||h.step,s=Math.max(e.width,e.height);s>=i;){var c=t||r?s:1,u=t||n?s:1;o.push([c,u]),s-=a}else e.sizes.forEach((function(e){var i=t||r?e:1,a=t||n?e:1;o.push([i,a])}));return o}function d(e){var t=window&&"HTMLCanvasElement"in window,i=window&&"OffscreenCanvas"in window,a=Date.now(),s=e.onError,u=e.onSuccess,f=n(e,["onError","onSuccess"]),l=null;if(!t)return!1;if(e.useWorker&&i){var h="\n var canvasTest = ".concat(c.toString(),";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "),m=new Blob([h],{type:"application/javascript"}),d=URL.createObjectURL(m);l=new Worker(d),URL.revokeObjectURL(d),l.onmessage=function(e){var t=e.data,r=t.width,n=t.height,o=t.benchmark;t.isTestPass?(p[a].onSuccess(r,n,o),delete p[a]):p[a].onError(r,n,o)}}return e.usePromise?new Promise((function(t,n){var i=r(r({},e),{},{onError:function(t,r,i){var a;if(0===e.sizes.length)a=!0;else{var c=o(e.sizes.slice(-1),1),u=o(c[0],2),f=u[0],l=u[1];a=t===f&&r===l}s(t,r,i),a&&n({width:t,height:r,benchmark:i})},onSuccess:function(e,r,n){u(e,r,n),t({width:e,height:r,benchmark:n})}});if(l){var h=i.onError,m=i.onSuccess;p[a]={onError:h,onSuccess:m},l.postMessage(f)}else c(i)})):l?(p[a]={onError:s,onSuccess:u},void l.postMessage(f)):c(e)}var v={maxArea:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=m({width:e.max,height:e.max,min:e.min,step:e.step,sizes:i(u)}),n=r(r(r({},h),e),{},{sizes:t});return d(n)},maxHeight:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=m({width:1,height:e.max,min:e.min,step:e.step,sizes:i(f)}),n=r(r(r({},h),e),{},{sizes:t});return d(n)},maxWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=m({width:e.max,height:1,min:e.min,step:e.step,sizes:i(l)}),n=r(r(r({},h),e),{},{sizes:t});return d(n)},test:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r(r({},h),e);return t.sizes=i(t.sizes),t.width&&t.height&&(t.sizes=[[t.width,t.height]]),d(t)}};export default v;
function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function r(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){e(r,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}function n(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){o=!0,i=e}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return r}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||a(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 a(e,t){if(e){if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function c(e){var t,r,n=e.sizes.shift(),o=Math.max(Math.ceil(n[0]),1),i=Math.max(Math.ceil(n[1]),1),a=[o-1,i-1,1,1],s=Date.now(),u="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;u?(t=new OffscreenCanvas(1,1),r=new OffscreenCanvas(o,i)):((t=document.createElement("canvas")).width=1,t.height=1,(r=document.createElement("canvas")).width=o,r.height=i);var f=t.getContext("2d"),h=r.getContext("2d");h&&(h.fillRect.apply(h,a),f.drawImage(r,o-1,i-1,1,1,0,0,1,1));var l=f&&0!==f.getImageData(0,0,1,1).data[3],p=Date.now()-s;return u?(postMessage({width:o,height:i,benchmark:p,isTestPass:l}),!l&&e.sizes.length&&c(e)):l?e.onSuccess(o,i,p):(e.onError(o,i,p),e.sizes.length&&c(e)),l}var u=[16384,14188,11402,10836,11180,8192,4096,1],f=[8388607,65535,32767,16384,8192,4096,1],h=[4194303,65535,32767,16384,8192,4096,1],l={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},p={};function m(e){var t=e.width===e.height,r=1===e.height,n=1===e.width,o=[];if(e.width&&e.height)for(var i=e.min||l.min,a=e.step||l.step,s=Math.max(e.width,e.height);s>=i;){var c=t||r?s:1,u=t||n?s:1;o.push([c,u]),s-=a}else e.sizes.forEach((function(e){var i=t||r?e:1,a=t||n?e:1;o.push([i,a])}));return o}function d(e){var t=window&&"HTMLCanvasElement"in window,i=window&&"OffscreenCanvas"in window,a=Date.now(),s=e.onError,u=e.onSuccess,f=n(e,["onError","onSuccess"]),h=null;if(!t)return!1;if(e.useWorker&&i){var l="\n var canvasTest = ".concat(c.toString(),";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "),m=new Blob([l],{type:"application/javascript"}),d=URL.createObjectURL(m);h=new Worker(d),URL.revokeObjectURL(d),h.onmessage=function(e){var t=e.data,r=t.width,n=t.height,o=t.benchmark;t.isTestPass?(p[a].onSuccess(r,n,o),delete p[a]):p[a].onError(r,n,o)}}return e.usePromise?new Promise((function(t,n){var i=r(r({},e),{},{onError:function(t,r,i){var a;if(0===e.sizes.length)a=!0;else{var c=o(e.sizes.slice(-1),1),u=o(c[0],2),f=u[0],h=u[1];a=t===f&&r===h}s(t,r,i),a&&n({width:t,height:r,benchmark:i})},onSuccess:function(e,r,n){u(e,r,n),t({width:e,height:r,benchmark:n})}});if(h){var l=i.onError,m=i.onSuccess;p[a]={onError:l,onSuccess:m},h.postMessage(f)}else c(i)})):h?(p[a]={onError:s,onSuccess:u},void h.postMessage(f)):c(e)}var v={maxArea:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=m({width:e.max,height:e.max,min:e.min,step:e.step,sizes:i(u)}),n=r(r(r({},l),e),{},{sizes:t});return d(n)},maxHeight:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=m({width:1,height:e.max,min:e.min,step:e.step,sizes:i(f)}),n=r(r(r({},l),e),{},{sizes:t});return d(n)},maxWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=m({width:e.max,height:1,min:e.min,step:e.step,sizes:i(h)}),n=r(r(r({},l),e),{},{sizes:t});return d(n)},test:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r(r({},l),e);return t.sizes=i(t.sizes),t.width&&t.height&&(t.sizes=[[t.width,t.height]]),d(t)}};export default v;
//# sourceMappingURL=canvas-size.esm.min.js.map
/*!
* canvas-size
* v1.2.2
* v1.2.3
* https://github.com/jhildenbiddle/canvas-size

@@ -140,4 +140,4 @@ * (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com>

var size = settings.sizes.shift();
var width = size[0];
var height = size[1];
var width = Math.max(Math.ceil(size[0]), 1);
var height = Math.max(Math.ceil(size[1]), 1);
var fill = [ width - 1, height - 1, 1, 1 ];

@@ -144,0 +144,0 @@ var job = Date.now();

/*!
* canvas-size
* v1.2.2
* v1.2.3
* https://github.com/jhildenbiddle/canvas-size

@@ -8,3 +8,3 @@ * (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com>

*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).canvasSize=t()}(this,(function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(n){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(Object(o),!0).forEach((function(t){e(n,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}function r(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var s,a=e[Symbol.iterator]();!(r=(s=a.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==a.return||a.return()}finally{if(o)throw i}}return n}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||s(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 s(e,t){if(e){if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?a(e,t):void 0}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e){var t,n,r=e.sizes.shift(),o=r[0],i=r[1],s=[o-1,i-1,1,1],a=Date.now(),u="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;u?(t=new OffscreenCanvas(1,1),n=new OffscreenCanvas(o,i)):((t=document.createElement("canvas")).width=1,t.height=1,(n=document.createElement("canvas")).width=o,n.height=i);var f=t.getContext("2d"),l=n.getContext("2d");l&&(l.fillRect.apply(l,s),f.drawImage(n,o-1,i-1,1,1,0,0,1,1));var h=f&&0!==f.getImageData(0,0,1,1).data[3],p=Date.now()-a;return u?(postMessage({width:o,height:i,benchmark:p,isTestPass:h}),!h&&e.sizes.length&&c(e)):h?e.onSuccess(o,i,p):(e.onError(o,i,p),e.sizes.length&&c(e)),h}var u=[16384,14188,11402,10836,11180,8192,4096,1],f=[8388607,65535,32767,16384,8192,4096,1],l=[4194303,65535,32767,16384,8192,4096,1],h={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},p={};function d(e){var t=e.width===e.height,n=1===e.height,r=1===e.width,o=[];if(e.width&&e.height)for(var i=e.min||h.min,s=e.step||h.step,a=Math.max(e.width,e.height);a>=i;){var c=t||n?a:1,u=t||r?a:1;o.push([c,u]),a-=s}else e.sizes.forEach((function(e){var i=t||n?e:1,s=t||r?e:1;o.push([i,s])}));return o}function m(e){var t=window&&"HTMLCanvasElement"in window,i=window&&"OffscreenCanvas"in window,s=Date.now(),a=e.onError,u=e.onSuccess,f=r(e,["onError","onSuccess"]),l=null;if(!t)return!1;if(e.useWorker&&i){var h="\n var canvasTest = ".concat(c.toString(),";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "),d=new Blob([h],{type:"application/javascript"}),m=URL.createObjectURL(d);l=new Worker(m),URL.revokeObjectURL(m),l.onmessage=function(e){var t=e.data,n=t.width,r=t.height,o=t.benchmark;t.isTestPass?(p[s].onSuccess(n,r,o),delete p[s]):p[s].onError(n,r,o)}}return e.usePromise?new Promise((function(t,r){var i=n(n({},e),{},{onError:function(t,n,i){var s;if(0===e.sizes.length)s=!0;else{var c=o(e.sizes.slice(-1),1),u=o(c[0],2),f=u[0],l=u[1];s=t===f&&n===l}a(t,n,i),s&&r({width:t,height:n,benchmark:i})},onSuccess:function(e,n,r){u(e,n,r),t({width:e,height:n,benchmark:r})}});if(l){var h=i.onError,d=i.onSuccess;p[s]={onError:h,onSuccess:d},l.postMessage(f)}else c(i)})):l?(p[s]={onError:a,onSuccess:u},void l.postMessage(f)):c(e)}return{maxArea:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({width:e.max,height:e.max,min:e.min,step:e.step,sizes:i(u)}),r=n(n(n({},h),e),{},{sizes:t});return m(r)},maxHeight:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({width:1,height:e.max,min:e.min,step:e.step,sizes:i(f)}),r=n(n(n({},h),e),{},{sizes:t});return m(r)},maxWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({width:e.max,height:1,min:e.min,step:e.step,sizes:i(l)}),r=n(n(n({},h),e),{},{sizes:t});return m(r)},test:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n(n({},h),e);return t.sizes=i(t.sizes),t.width&&t.height&&(t.sizes=[[t.width,t.height]]),m(t)}}}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).canvasSize=t()}(this,(function(){"use strict";function e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function n(n){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(Object(o),!0).forEach((function(t){e(n,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}))}return n}function r(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return n}(e,t)||a(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||a(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 a(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e){var t,n,r=e.sizes.shift(),o=Math.max(Math.ceil(r[0]),1),i=Math.max(Math.ceil(r[1]),1),a=[o-1,i-1,1,1],s=Date.now(),u="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;u?(t=new OffscreenCanvas(1,1),n=new OffscreenCanvas(o,i)):((t=document.createElement("canvas")).width=1,t.height=1,(n=document.createElement("canvas")).width=o,n.height=i);var f=t.getContext("2d"),l=n.getContext("2d");l&&(l.fillRect.apply(l,a),f.drawImage(n,o-1,i-1,1,1,0,0,1,1));var h=f&&0!==f.getImageData(0,0,1,1).data[3],p=Date.now()-s;return u?(postMessage({width:o,height:i,benchmark:p,isTestPass:h}),!h&&e.sizes.length&&c(e)):h?e.onSuccess(o,i,p):(e.onError(o,i,p),e.sizes.length&&c(e)),h}var u=[16384,14188,11402,10836,11180,8192,4096,1],f=[8388607,65535,32767,16384,8192,4096,1],l=[4194303,65535,32767,16384,8192,4096,1],h={max:null,min:1,sizes:[],step:1024,usePromise:!1,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},p={};function d(e){var t=e.width===e.height,n=1===e.height,r=1===e.width,o=[];if(e.width&&e.height)for(var i=e.min||h.min,a=e.step||h.step,s=Math.max(e.width,e.height);s>=i;){var c=t||n?s:1,u=t||r?s:1;o.push([c,u]),s-=a}else e.sizes.forEach((function(e){var i=t||n?e:1,a=t||r?e:1;o.push([i,a])}));return o}function m(e){var t=window&&"HTMLCanvasElement"in window,i=window&&"OffscreenCanvas"in window,a=Date.now(),s=e.onError,u=e.onSuccess,f=r(e,["onError","onSuccess"]),l=null;if(!t)return!1;if(e.useWorker&&i){var h="\n var canvasTest = ".concat(c.toString(),";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "),d=new Blob([h],{type:"application/javascript"}),m=URL.createObjectURL(d);l=new Worker(m),URL.revokeObjectURL(m),l.onmessage=function(e){var t=e.data,n=t.width,r=t.height,o=t.benchmark;t.isTestPass?(p[a].onSuccess(n,r,o),delete p[a]):p[a].onError(n,r,o)}}return e.usePromise?new Promise((function(t,r){var i=n(n({},e),{},{onError:function(t,n,i){var a;if(0===e.sizes.length)a=!0;else{var c=o(e.sizes.slice(-1),1),u=o(c[0],2),f=u[0],l=u[1];a=t===f&&n===l}s(t,n,i),a&&r({width:t,height:n,benchmark:i})},onSuccess:function(e,n,r){u(e,n,r),t({width:e,height:n,benchmark:r})}});if(l){var h=i.onError,d=i.onSuccess;p[a]={onError:h,onSuccess:d},l.postMessage(f)}else c(i)})):l?(p[a]={onError:s,onSuccess:u},void l.postMessage(f)):c(e)}return{maxArea:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({width:e.max,height:e.max,min:e.min,step:e.step,sizes:i(u)}),r=n(n(n({},h),e),{},{sizes:t});return m(r)},maxHeight:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({width:1,height:e.max,min:e.min,step:e.step,sizes:i(f)}),r=n(n(n({},h),e),{},{sizes:t});return m(r)},maxWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=d({width:e.max,height:1,min:e.min,step:e.step,sizes:i(l)}),r=n(n(n({},h),e),{},{sizes:t});return m(r)},test:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n(n({},h),e);return t.sizes=i(t.sizes),t.width&&t.height&&(t.sizes=[[t.width,t.height]]),m(t)}}}));
//# sourceMappingURL=canvas-size.min.js.map
{
"name": "canvas-size",
"version": "1.2.2",
"version": "1.2.3",
"description": "Determine the maximum size of an HTML canvas element and test support for custom canvas dimensions.",

@@ -5,0 +5,0 @@ "author": "John Hildenbiddle <http://hildenbiddle.com>",

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc