canvas-size
Advanced tools
Comparing version 1.2.1 to 1.2.2
# Change Log | ||
## 1.2.2 | ||
*2021-01-28* | ||
- Fix reference error after minification (#5, #6) | ||
## 1.2.1 | ||
@@ -4,0 +10,0 @@ |
/*! | ||
* canvas-size | ||
* v1.2.1 | ||
* v1.2.2 | ||
* https://github.com/jhildenbiddle/canvas-size | ||
* (c) 2015-2020 John Hildenbiddle <http://hildenbiddle.com> | ||
* (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com> | ||
* MIT license | ||
@@ -250,3 +250,3 @@ */ | ||
if (settings.useWorker && hasOffscreenCanvasSupport) { | ||
var js = "\n ".concat(canvasTest.toString(), "\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "); | ||
var js = "\n var canvasTest = ".concat(canvasTest.toString(), ";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "); | ||
var blob = new Blob([ js ], { | ||
@@ -253,0 +253,0 @@ type: "application/javascript" |
/*! | ||
* canvas-size | ||
* v1.2.1 | ||
* v1.2.2 | ||
* https://github.com/jhildenbiddle/canvas-size | ||
* (c) 2015-2020 John Hildenbiddle <http://hildenbiddle.com> | ||
* (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com> | ||
* MIT license | ||
*/ | ||
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 canvasTest(e){var t,r,n=e.sizes.shift(),o=n[0],i=n[1],a=[o-1,i-1,1,1],s=Date.now(),c="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;c?(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 u=t.getContext("2d"),f=r.getContext("2d");f&&(f.fillRect.apply(f,a),u.drawImage(r,o-1,i-1,1,1,0,0,1,1));var l=u&&0!==u.getImageData(0,0,1,1).data[3],h=Date.now()-s;return c?(postMessage({width:o,height:i,benchmark:h,isTestPass:l}),!l&&e.sizes.length&&canvasTest(e)):l?e.onSuccess(o,i,h):(e.onError(o,i,h),e.sizes.length&&canvasTest(e)),l}var c=[16384,14188,11402,10836,11180,8192,4096,1],u=[8388607,65535,32767,16384,8192,4096,1],f=[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},h={};function p(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 m(e){var t=window&&"HTMLCanvasElement"in window,i=window&&"OffscreenCanvas"in window,a=Date.now(),s=e.onError,c=e.onSuccess,u=n(e,["onError","onSuccess"]),f=null;if(!t)return!1;if(e.useWorker&&i){var l="\n ".concat(canvasTest.toString(),"\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "),p=new Blob([l],{type:"application/javascript"}),m=URL.createObjectURL(p);f=new Worker(m),URL.revokeObjectURL(m),f.onmessage=function(e){var t=e.data,r=t.width,n=t.height,o=t.benchmark;t.isTestPass?(h[a].onSuccess(r,n,o),delete h[a]):h[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){c(e,r,n),t({width:e,height:r,benchmark:n})}});if(f){var l=i.onError,p=i.onSuccess;h[a]={onError:l,onSuccess:p},f.postMessage(u)}else canvasTest(i)})):f?(h[a]={onError:s,onSuccess:c},void f.postMessage(u)):canvasTest(e)}var d={maxArea:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p({width:e.max,height:e.max,min:e.min,step:e.step,sizes:i(c)}),n=r(r(r({},l),e),{},{sizes:t});return m(n)},maxHeight:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p({width:1,height:e.max,min:e.min,step:e.step,sizes:i(u)}),n=r(r(r({},l),e),{},{sizes:t});return m(n)},maxWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p({width:e.max,height:1,min:e.min,step:e.step,sizes:i(f)}),n=r(r(r({},l),e),{},{sizes:t});return m(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]]),m(t)}};export default d; | ||
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; | ||
//# sourceMappingURL=canvas-size.esm.min.js.map |
/*! | ||
* canvas-size | ||
* v1.2.1 | ||
* v1.2.2 | ||
* https://github.com/jhildenbiddle/canvas-size | ||
* (c) 2015-2020 John Hildenbiddle <http://hildenbiddle.com> | ||
* (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com> | ||
* MIT license | ||
@@ -235,3 +235,3 @@ */ | ||
if (settings.useWorker && hasOffscreenCanvasSupport) { | ||
var js = "\n ".concat(canvasTest.toString(), "\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "); | ||
var js = "\n var canvasTest = ".concat(canvasTest.toString(), ";\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "); | ||
var blob = new Blob([ js ], { | ||
@@ -238,0 +238,0 @@ type: "application/javascript" |
/*! | ||
* canvas-size | ||
* v1.2.1 | ||
* v1.2.2 | ||
* https://github.com/jhildenbiddle/canvas-size | ||
* (c) 2015-2020 John Hildenbiddle <http://hildenbiddle.com> | ||
* (c) 2015-2021 John Hildenbiddle <http://hildenbiddle.com> | ||
* MIT license | ||
*/ | ||
!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 canvasTest(e){var t,n,r=e.sizes.shift(),o=r[0],i=r[1],s=[o-1,i-1,1,1],a=Date.now(),c="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;c?(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 u=t.getContext("2d"),f=n.getContext("2d");f&&(f.fillRect.apply(f,s),u.drawImage(n,o-1,i-1,1,1,0,0,1,1));var l=u&&0!==u.getImageData(0,0,1,1).data[3],h=Date.now()-a;return c?(postMessage({width:o,height:i,benchmark:h,isTestPass:l}),!l&&e.sizes.length&&canvasTest(e)):l?e.onSuccess(o,i,h):(e.onError(o,i,h),e.sizes.length&&canvasTest(e)),l}var c=[16384,14188,11402,10836,11180,8192,4096,1],u=[8388607,65535,32767,16384,8192,4096,1],f=[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},h={};function p(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||l.min,s=e.step||l.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 d(e){var t=window&&"HTMLCanvasElement"in window,i=window&&"OffscreenCanvas"in window,s=Date.now(),a=e.onError,c=e.onSuccess,u=r(e,["onError","onSuccess"]),f=null;if(!t)return!1;if(e.useWorker&&i){var l="\n ".concat(canvasTest.toString(),"\n onmessage = function(e) {\n canvasTest(e.data);\n };\n "),p=new Blob([l],{type:"application/javascript"}),d=URL.createObjectURL(p);f=new Worker(d),URL.revokeObjectURL(d),f.onmessage=function(e){var t=e.data,n=t.width,r=t.height,o=t.benchmark;t.isTestPass?(h[s].onSuccess(n,r,o),delete h[s]):h[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){c(e,n,r),t({width:e,height:n,benchmark:r})}});if(f){var l=i.onError,p=i.onSuccess;h[s]={onError:l,onSuccess:p},f.postMessage(u)}else canvasTest(i)})):f?(h[s]={onError:a,onSuccess:c},void f.postMessage(u)):canvasTest(e)}return{maxArea:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p({width:e.max,height:e.max,min:e.min,step:e.step,sizes:i(c)}),r=n(n(n({},l),e),{},{sizes:t});return d(r)},maxHeight:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p({width:1,height:e.max,min:e.min,step:e.step,sizes:i(u)}),r=n(n(n({},l),e),{},{sizes:t});return d(r)},maxWidth:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=p({width:e.max,height:1,min:e.min,step:e.step,sizes:i(f)}),r=n(n(n({},l),e),{},{sizes:t});return d(r)},test:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n(n({},l),e);return t.sizes=i(t.sizes),t.width&&t.height&&(t.sizes=[[t.width,t.height]]),d(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 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)}}})); | ||
//# sourceMappingURL=canvas-size.min.js.map |
{ | ||
"name": "canvas-size", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Determine the maximum size of an HTML canvas element and test support for custom canvas dimensions.", | ||
@@ -50,9 +50,9 @@ "author": "John Hildenbiddle <http://hildenbiddle.com>", | ||
"devDependencies": { | ||
"@babel/core": "^7.12.3", | ||
"@babel/core": "^7.12.10", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.12.1", | ||
"@babel/preset-env": "^7.12.1", | ||
"babel-loader": "^8.1.0", | ||
"@babel/preset-env": "^7.12.11", | ||
"babel-loader": "^8.2.2", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.12.1", | ||
"eslint": "^7.18.0", | ||
"eslint-plugin-chai-expect": "^2.2.0", | ||
@@ -74,3 +74,3 @@ "eslint-plugin-mocha": "^8.0.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.33.1", | ||
"rollup": "^2.38.0", | ||
"rollup-plugin-babel": "^4.4.0", | ||
@@ -82,5 +82,4 @@ "rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"webpack": "^4.44.2" | ||
}, | ||
"dependencies": {} | ||
"webpack": "^4.46.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141302