canvas-context
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -6,3 +6,5 @@ const contextTypeList = [ | ||
"webgl2", | ||
"bitmaprenderer" | ||
"webgl2-compute", | ||
"bitmaprenderer", | ||
"gpupresent" | ||
]; | ||
@@ -9,0 +11,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){_defineProperty(e,t,n[t])})}return e}const contextTypeList=["2d","webgl","experimental-webgl","webgl2","bitmaprenderer"];function createCanvasContext(e="2d",t={}){const{width:n,height:r,offscreen:o=!1,contextAttributes:c={},worker:a=!1}=_objectSpread({},t);if(!a&&!contextTypeList.includes(e))throw new TypeError(`Unknown contextType: "${e}"`);if("undefined"==typeof window&&!t.canvas)return null;const i=t.canvas||document.createElement("canvas"),l=(o||a)&&"OffscreenCanvas"in window?i.transferControlToOffscreen():i;if(Number.isInteger(n)&&n>=0&&(l.width=n),Number.isInteger(r)&&r>=0&&(l.height=r),a)return{canvas:l};let s;try{s=l.getContext(e,c)||("webgl"===e?l.getContext("experimental-webgl",c):null)}catch(e){s=null}return{canvas:l,context:s}}module.exports=createCanvasContext; | ||
"use strict";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}const r=["2d","webgl","experimental-webgl","webgl2","webgl2-compute","bitmaprenderer","gpupresent"];module.exports=function(n="2d",o={}){const{width:c,height:i,offscreen:u=!1,contextAttributes:s={},worker:l=!1}=function(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}({},o);if(!l&&!r.includes(n))throw new TypeError(`Unknown contextType: "${n}"`);if("undefined"==typeof window&&!o.canvas)return null;const a=o.canvas||document.createElement("canvas"),b=(u||l)&&"OffscreenCanvas"in window?a.transferControlToOffscreen():a;if(Number.isInteger(c)&&c>=0&&(b.width=c),Number.isInteger(i)&&i>=0&&(b.height=i),l)return{canvas:b};let f;try{f=b.getContext(n,s)||("webgl"===n?b.getContext("experimental-webgl",s):null)}catch(e){f=null}return{canvas:b,context:f}}; |
@@ -1,1 +0,1 @@ | ||
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n=["2d","webgl","experimental-webgl","webgl2","bitmaprenderer"];export default function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2d",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(n){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){e(n,t,r[t])})}return n}({},r),i=o.width,c=o.height,a=o.offscreen,l=void 0!==a&&a,u=o.contextAttributes,f=void 0===u?{}:u,b=o.worker,w=void 0!==b&&b;if(!w&&!n.includes(t))throw new TypeError('Unknown contextType: "'.concat(t,'"'));if("undefined"==typeof window&&!r.canvas)return null;var d,g=r.canvas||document.createElement("canvas"),s=(l||w)&&"OffscreenCanvas"in window?g.transferControlToOffscreen():g;if(Number.isInteger(i)&&i>=0&&(s.width=i),Number.isInteger(c)&&c>=0&&(s.height=c),w)return{canvas:s};try{d=s.getContext(t,f)||("webgl"===t?s.getContext("experimental-webgl",f):null)}catch(e){d=null}return{canvas:s,context: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}var n=["2d","webgl","experimental-webgl","webgl2","webgl2-compute","bitmaprenderer","gpupresent"];export default function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2d",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r({},t),c=o.width,i=o.height,a=o.offscreen,l=void 0!==a&&a,u=o.contextAttributes,f=void 0===u?{}:u,b=o.worker,p=void 0!==b&&b;if(!p&&!n.includes(e))throw new TypeError('Unknown contextType: "'.concat(e,'"'));if("undefined"==typeof window&&!t.canvas)return null;var s,g=t.canvas||document.createElement("canvas"),w=(l||p)&&"OffscreenCanvas"in window?g.transferControlToOffscreen():g;if(Number.isInteger(c)&&c>=0&&(w.width=c),Number.isInteger(i)&&i>=0&&(w.height=i),p)return{canvas:w};try{s=w.getContext(e,f)||("webgl"===e?w.getContext("experimental-webgl",f):null)}catch(e){s=null}return{canvas:w,context:s}} |
@@ -1,1 +0,1 @@ | ||
var createCanvasContext=function(){"use strict";function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n=["2d","webgl","experimental-webgl","webgl2","bitmaprenderer"];return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2d",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(n){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){e(n,t,r[t])})}return n}({},r),c=o.width,i=o.height,a=o.offscreen,l=void 0!==a&&a,u=o.contextAttributes,f=void 0===u?{}:u,s=o.worker,b=void 0!==s&&s;if(!b&&!n.includes(t))throw new TypeError('Unknown contextType: "'.concat(t,'"'));if("undefined"==typeof window&&!r.canvas)return null;var v,w=r.canvas||document.createElement("canvas"),g=(l||b)&&"OffscreenCanvas"in window?w.transferControlToOffscreen():w;if(Number.isInteger(c)&&c>=0&&(g.width=c),Number.isInteger(i)&&i>=0&&(g.height=i),b)return{canvas:g};try{v=g.getContext(t,f)||("webgl"===t?g.getContext("experimental-webgl",f):null)}catch(e){v=null}return{canvas:g,context:v}}}(); | ||
var createCanvasContext=function(){"use strict";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}var n=["2d","webgl","experimental-webgl","webgl2","webgl2-compute","bitmaprenderer","gpupresent"];return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2d",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r({},t),c=o.width,i=o.height,a=o.offscreen,u=void 0!==a&&a,l=o.contextAttributes,f=void 0===l?{}:l,s=o.worker,b=void 0!==s&&s;if(!b&&!n.includes(e))throw new TypeError('Unknown contextType: "'.concat(e,'"'));if("undefined"==typeof window&&!t.canvas)return null;var p,g=t.canvas||document.createElement("canvas"),w=(u||b)&&"OffscreenCanvas"in window?g.transferControlToOffscreen():g;if(Number.isInteger(c)&&c>=0&&(w.width=c),Number.isInteger(i)&&i>=0&&(w.height=i),b)return{canvas:w};try{p=w.getContext(e,f)||("webgl"===e?w.getContext("experimental-webgl",f):null)}catch(e){p=null}return{canvas:w,context:p}}}(); |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).createCanvasContext=n()}(this,function(){"use strict";function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var n=["2d","webgl","experimental-webgl","webgl2","bitmaprenderer"];return function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2d",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=function(n){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){e(n,t,r[t])})}return n}({},r),i=o.width,c=o.height,a=o.offscreen,f=void 0!==a&&a,u=o.contextAttributes,l=void 0===u?{}:u,d=o.worker,s=void 0!==d&&d;if(!s&&!n.includes(t))throw new TypeError('Unknown contextType: "'.concat(t,'"'));if("undefined"==typeof window&&!r.canvas)return null;var b,w=r.canvas||document.createElement("canvas"),g=(f||s)&&"OffscreenCanvas"in window?w.transferControlToOffscreen():w;if(Number.isInteger(i)&&i>=0&&(g.width=i),Number.isInteger(c)&&c>=0&&(g.height=c),s)return{canvas:g};try{b=g.getContext(t,l)||("webgl"===t?g.getContext("experimental-webgl",l):null)}catch(e){b=null}return{canvas:g,context:b}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).createCanvasContext=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}var r=["2d","webgl","experimental-webgl","webgl2","webgl2-compute","bitmaprenderer","gpupresent"];return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"2d",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=n({},t),i=o.width,c=o.height,f=o.offscreen,u=void 0!==f&&f,a=o.contextAttributes,l=void 0===a?{}:a,s=o.worker,p=void 0!==s&&s;if(!p&&!r.includes(e))throw new TypeError('Unknown contextType: "'.concat(e,'"'));if("undefined"==typeof window&&!t.canvas)return null;var b,d=t.canvas||document.createElement("canvas"),g=(u||p)&&"OffscreenCanvas"in window?d.transferControlToOffscreen():d;if(Number.isInteger(i)&&i>=0&&(g.width=i),Number.isInteger(c)&&c>=0&&(g.height=c),p)return{canvas:g};try{b=g.getContext(e,l)||("webgl"===e?g.getContext("experimental-webgl",l):null)}catch(e){b=null}return{canvas:g,context:b}}})); |
{ | ||
"name": "canvas-context", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Create a RenderingContext (2d, webgl, webgl2, bitmaprenderer), optionally offscreen for possible use in a Worker.", | ||
@@ -23,11 +23,11 @@ "main": "lib/canvas-context.cjs.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.2.2", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.3.1", | ||
"@babel/preset-env": "^7.3.1", | ||
"rollup": "^1.1.2", | ||
"rollup-plugin-babel": "^4.3.2", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-resolve": "^4.0.0", | ||
"@babel/core": "^7.8.7", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.8.3", | ||
"@babel/preset-env": "^7.8.7", | ||
"rollup": "^2.0.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-serve": "^1.0.1", | ||
"rollup-plugin-terser": "^4.0.3" | ||
"rollup-plugin-terser": "^5.2.0" | ||
}, | ||
@@ -34,0 +34,0 @@ "keywords": [ |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
81
0
13180
8