detect-gpu-js
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
var e="1.0.4";const t=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function n(e){return e=e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const r=16384,o=4,a=35044,i=34962,c=5121,l=5126,s=6408,d=35632,f=35633,g="undefined"==typeof window,u=(()=>{if(g)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,r=/(iphone|ipod|ipad)/i.test(e),o="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:o,isMobile:/android/i.test(e)||r||o,isSafari12:/Version\/12.+Safari/.test(e)}})(),h=()=>{};function m(e,t,n){if(!n)return[t];const g=function(e){const t="\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n ",n="\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n ",g=e.createShader(f),u=e.createShader(d),h=e.createProgram();if(!(u&&g&&h))return;e.shaderSource(g,t),e.shaderSource(u,n),e.compileShader(g),e.compileShader(u),e.attachShader(h,g),e.attachShader(h,u),e.linkProgram(h),e.detachShader(h,g),e.detachShader(h,u),e.deleteShader(g),e.deleteShader(u),e.useProgram(h);const m=e.createBuffer();e.bindBuffer(i,m),e.bufferData(i,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),a);const p=e.getAttribLocation(h,"aPosition");e.vertexAttribPointer(p,3,l,!1,0,0),e.enableVertexAttribArray(p),e.clearColor(1,1,1,1),e.clear(r),e.viewport(0,0,1,1),e.drawArrays(o,0,3);const v=new Uint8Array(4);return e.readPixels(0,0,1,1,s,c,v),e.deleteProgram(h),e.deleteBuffer(m),v.join("")}(e),m="801621810",p="8016218135",v="80162181161",w=null!=u&&u.isIpad?[["a7",v,12],["a8",p,15],["a8x",p,15],["a9",p,15],["a9x",p,15],["a10",p,15],["a10x",p,15],["a12",m,15],["a12x",m,15],["a12z",m,15],["a14",m,15],["m1",m,15]]:[["a7",v,12],["a8",p,12],["a9",p,15],["a10",p,15],["a11",m,15],["a12",m,15],["a13",m,15],["a14",m,15]];let A;"80162181255"===g?A=w.filter((e=>{let[,,t]=e;return t>=14})):(A=w.filter((e=>{let[,t]=e;return t===g})),A.length||(A=w));const S=A.map((e=>{let[t]=e;return"apple ".concat(t," gpu")}));return h("iOS 12.2+ obfuscates its GPU type and version, using closest matches: ".concat(JSON.stringify(S))),S}class p extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const v=[],w=[];function A(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let r=e.length,o=t.length;for(;r>0&&e.charCodeAt(~-r)===t.charCodeAt(~-o);)r--,o--;let a,i=0;for(;i<r&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(r-=i,o-=i,0===r)return o;let c,l,s=0,d=0,f=0;for(;d<r;)w[d]=e.charCodeAt(i+d),v[d]=++d;for(;f<o;)for(a=t.charCodeAt(i+f),c=f++,s=f,d=0;d<r;d++)l=a===w[d]?c:c+1,c=v[d],s=v[d]=c>s?l>s?s+1:l:l>c?c+1:l;return s}function S(e){return null!=e}const P=async function(){let{mobileTiers:r=[0,15,30,60],desktopTiers:o=[0,15,30,60],override:a={},glContext:i,failIfMajorPerformanceCaveat:c=!1,benchmarksURL:l="https://unpkg.com/detect-gpu-js@".concat(e,"/dist/benchmarks")}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const s={};if(g)return{tier:0,type:"SSR"};const{isIpad:d=!(null==u||!u.isIpad),isMobile:f=!(null==u||!u.isMobile),screenSize:h=window.screen,loadBenchmarks:v=(async e=>{const t=await fetch("".concat(l,"/").concat(e)).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<1)throw new p("Detect GPU benchmark data is out of date. Please update to version 1x");return t})}=a;let{renderer:w}=a;const P=(e,t,n,r,o)=>({device:o,fps:r,gpu:n,isMobile:f,tier:e,type:t});let b,x="";if(w)w=n(w),b=[w];else{const e=i||function(e){const t={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:arguments.length>1&&void 0!==arguments[1]&&arguments[1],powerPreference:"high-performance",stencil:!1};e&&delete t.powerPreference;const n=window.document.createElement("canvas"),r=n.getContext("webgl",t)||n.getContext("experimental-webgl",t);return null!=r?r:void 0}(null==u?void 0:u.isSafari12,c);if(!e)return P(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(w=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),!w)return P(1,"FALLBACK");x=w,w=n(w),b=function(e,t,n){return"apple gpu"===t?m(e,t,n):[t]}(e,w,f)}const y=(await Promise.all(b.map((async function(e){var t;const n=(e=>{const t=f?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const r="".concat(f?"m":"d","-").concat(n).concat(d?"-ipad":"",".json"),o=s[r]=null!==(t=s[r])&&void 0!==t?t:v(r);let a;try{a=await o}catch(e){if(e instanceof p)throw e;return}const i=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let c=a.filter((e=>{let[,t]=e;return t===i}));"found ".concat(c.length," matching entries using version '").concat(i,"':"),c.map((e=>{let[t]=e;return t})),c.length||(c=a.filter((t=>{let[n]=t;return n.includes(e)})),"found ".concat(c.length," matching entries comparing model names"));const l=c.length;if(0===l)return;const g=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let[u,,,,m]=l>1?c.map((e=>[e,A(g,e[2])])).sort(((e,t)=>{let[,n]=e,[,r]=t;return n-r}))[0][0]:c[0];"".concat(e," matched closest to ").concat(u," with the following screen sizes"),JSON.stringify(m);let w,S=Number.MAX_VALUE;const{devicePixelRatio:P}=window,b=h.width*P*h.height*P;for(const e of m){const[t,n]=e,r=t*n,o=Math.abs(b-r);o<S&&(S=o,w=e)}if(!w)return;const[,,x,y]=w;return[S,x,u,y]})))).filter(S).sort(((e,t)=>{let[n=Number.MAX_VALUE,r]=e,[o=Number.MAX_VALUE,a]=t;return n===o?r-a:n-o}));if(!y.length){const e=t.find((e=>w.includes(e)));return e?P(0,"BLOCKLISTED",e):P(1,"FALLBACK","".concat(w," (").concat(x,")"))}const[,E,C,L]=y[0];if(-1===E)return P(0,"BLOCKLISTED",C,E,L);const M=f?r:o;let B=0;for(let e=0;e<M.length;e++)E>=M[e]&&(B=e);return P(B,"BENCHMARK",C,E,L)};export{P as getGPUTier}; | ||
var e="1.0.5",t={};const n=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function r(e){return e=e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const o=16384,a=4,i=35044,c=34962,l=5121,s=5126,d=6408,f=35632,g=35633,u="undefined"==typeof window,h=(()=>{if(u)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,r=/(iphone|ipod|ipad)/i.test(e),o="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:o,isMobile:/android/i.test(e)||r||o,isSafari12:/Version\/12.+Safari/.test(e)}})(),m=()=>{};function p(e,t,n){if(!n)return[t];const r=function(e){const t="\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n ",n="\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n ",r=e.createShader(g),u=e.createShader(f),h=e.createProgram();if(!(u&&r&&h))return;e.shaderSource(r,t),e.shaderSource(u,n),e.compileShader(r),e.compileShader(u),e.attachShader(h,r),e.attachShader(h,u),e.linkProgram(h),e.detachShader(h,r),e.detachShader(h,u),e.deleteShader(r),e.deleteShader(u),e.useProgram(h);const m=e.createBuffer();e.bindBuffer(c,m),e.bufferData(c,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),i);const p=e.getAttribLocation(h,"aPosition");e.vertexAttribPointer(p,3,s,!1,0,0),e.enableVertexAttribArray(p),e.clearColor(1,1,1,1),e.clear(o),e.viewport(0,0,1,1),e.drawArrays(a,0,3);const v=new Uint8Array(4);return e.readPixels(0,0,1,1,d,l,v),e.deleteProgram(h),e.deleteBuffer(m),v.join("")}(e),u="801621810",p="8016218135",v="80162181161",w=null!=h&&h.isIpad?[["a7",v,12],["a8",p,15],["a8x",p,15],["a9",p,15],["a9x",p,15],["a10",p,15],["a10x",p,15],["a12",u,15],["a12x",u,15],["a12z",u,15],["a14",u,15],["m1",u,15]]:[["a7",v,12],["a8",p,12],["a9",p,15],["a10",p,15],["a11",u,15],["a12",u,15],["a13",u,15],["a14",u,15]];let A;"80162181255"===r?A=w.filter((e=>{let[,,t]=e;return t>=14})):(A=w.filter((e=>{let[,t]=e;return t===r})),A.length||(A=w));const S=A.map((e=>{let[t]=e;return"apple ".concat(t," gpu")}));return m("iOS 12.2+ obfuscates its GPU type and version, using closest matches: ".concat(JSON.stringify(S))),S}class v extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const w=[],A=[];function S(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let r=e.length,o=t.length;for(;r>0&&e.charCodeAt(~-r)===t.charCodeAt(~-o);)r--,o--;let a,i=0;for(;i<r&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(r-=i,o-=i,0===r)return o;let c,l,s=0,d=0,f=0;for(;d<r;)A[d]=e.charCodeAt(i+d),w[d]=++d;for(;f<o;)for(a=t.charCodeAt(i+f),c=f++,s=f,d=0;d<r;d++)l=a===A[d]?c:c+1,c=w[d],s=w[d]=c>s?l>s?s+1:l:l>c?c+1:l;return s}function P(e){return null!=e}const b=async function(){let{mobileTiers:o=[0,15,30,60],desktopTiers:a=[0,15,30,60],override:i={},glContext:c,failIfMajorPerformanceCaveat:l=!1,benchmarksURL:s="https://unpkg.com/detect-gpu-js@".concat(e,"/dist/benchmarks")}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const d={};for(const e in t)d[e]=t[e].slice(1);if(u)return{tier:0,type:"SSR"};const{isIpad:f=!(null==h||!h.isIpad),isMobile:g=!(null==h||!h.isMobile),screenSize:m=window.screen,loadBenchmarks:w=(async e=>{const t=await fetch("".concat(s,"/").concat(e)).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<1)throw new v("Detect GPU benchmark data is out of date. Please update to version 1x");return t})}=i;let{renderer:A}=i;const b=(e,t,n,r,o)=>({device:o,fps:r,gpu:n,isMobile:g,tier:e,type:t});let x,y="";if(A)A=r(A),x=[A];else{const e=c||function(e){const t={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:arguments.length>1&&void 0!==arguments[1]&&arguments[1],powerPreference:"high-performance",stencil:!1};e&&delete t.powerPreference;const n=window.document.createElement("canvas"),r=n.getContext("webgl",t)||n.getContext("experimental-webgl",t);return null!=r?r:void 0}(null==h?void 0:h.isSafari12,l);if(!e)return b(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(A=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),!A)return b(1,"FALLBACK");y=A,A=r(A),x=function(e,t,n){return"apple gpu"===t?p(e,t,n):[t]}(e,A,g)}const E=(await Promise.all(x.map((async function(e){var t;const n=(e=>{const t=g?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const r="".concat(g?"m":"d","-").concat(n).concat(f?"-ipad":"",".json"),o=d[r]=null!==(t=d[r])&&void 0!==t?t:w(r);let a;try{a=await o}catch(e){if(e instanceof v)throw e;return}const i=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let c=a.filter((e=>{let[,t]=e;return t===i}));"found ".concat(c.length," matching entries using version '").concat(i,"':"),c.map((e=>{let[t]=e;return t})),c.length||(c=a.filter((t=>{let[n]=t;return n.includes(e)})),"found ".concat(c.length," matching entries comparing model names"));const l=c.length;if(0===l)return;const s=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let[u,,,,h]=l>1?c.map((e=>[e,S(s,e[2])])).sort(((e,t)=>{let[,n]=e,[,r]=t;return n-r}))[0][0]:c[0];"".concat(e," matched closest to ").concat(u," with the following screen sizes"),JSON.stringify(h);let p,A=Number.MAX_VALUE;const{devicePixelRatio:P}=window,b=m.width*P*m.height*P;for(const e of h){const[t,n]=e,r=t*n,o=Math.abs(b-r);o<A&&(A=o,p=e)}if(!p)return;const[,,x,y]=p;return[A,x,u,y]})))).filter(P).sort(((e,t)=>{let[n=Number.MAX_VALUE,r]=e,[o=Number.MAX_VALUE,a]=t;return n===o?r-a:n-o}));if(!E.length){const e=n.find((e=>A.includes(e)));return e?b(0,"BLOCKLISTED",e):b(1,"FALLBACK","".concat(A," (").concat(y,")"))}const[,C,L,M]=E[0];if(-1===C)return b(0,"BLOCKLISTED",L,C,M);const B=g?o:a;let R=0;for(let e=0;e<B.length;e++)C>=B[e]&&(R=e);return b(R,"BENCHMARK",L,C,M)};export{b as getGPUTier}; | ||
//# sourceMappingURL=detect-gpu.esm.js.map |
@@ -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="undefined"!=typeof globalThis?globalThis:e||self).DetectGPU={})}(this,(function(e){"use strict";var t="1.0.4";const n=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function r(e){return e=e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const o=16384,a=4,i=35044,c=34962,l=5121,s=5126,d=6408,f=35632,u=35633,g="undefined"==typeof window,h=(()=>{if(g)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,r=/(iphone|ipod|ipad)/i.test(e),o="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:o,isMobile:/android/i.test(e)||r||o,isSafari12:/Version\/12.+Safari/.test(e)}})(),m=()=>{};function p(e,t,n){if(!n)return[t];const r=function(e){const t="\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n ",n="\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n ",r=e.createShader(u),g=e.createShader(f),h=e.createProgram();if(!(g&&r&&h))return;e.shaderSource(r,t),e.shaderSource(g,n),e.compileShader(r),e.compileShader(g),e.attachShader(h,r),e.attachShader(h,g),e.linkProgram(h),e.detachShader(h,r),e.detachShader(h,g),e.deleteShader(r),e.deleteShader(g),e.useProgram(h);const m=e.createBuffer();e.bindBuffer(c,m),e.bufferData(c,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),i);const p=e.getAttribLocation(h,"aPosition");e.vertexAttribPointer(p,3,s,!1,0,0),e.enableVertexAttribArray(p),e.clearColor(1,1,1,1),e.clear(o),e.viewport(0,0,1,1),e.drawArrays(a,0,3);const v=new Uint8Array(4);return e.readPixels(0,0,1,1,d,l,v),e.deleteProgram(h),e.deleteBuffer(m),v.join("")}(e),g="801621810",p="8016218135",v="80162181161",w=null!=h&&h.isIpad?[["a7",v,12],["a8",p,15],["a8x",p,15],["a9",p,15],["a9x",p,15],["a10",p,15],["a10x",p,15],["a12",g,15],["a12x",g,15],["a12z",g,15],["a14",g,15],["m1",g,15]]:[["a7",v,12],["a8",p,12],["a9",p,15],["a10",p,15],["a11",g,15],["a12",g,15],["a13",g,15],["a14",g,15]];let b;"80162181255"===r?b=w.filter((e=>{let[,,t]=e;return t>=14})):(b=w.filter((e=>{let[,t]=e;return t===r})),b.length||(b=w));const P=b.map((e=>{let[t]=e;return"apple ".concat(t," gpu")}));return m("iOS 12.2+ obfuscates its GPU type and version, using closest matches: ".concat(JSON.stringify(P))),P}class v extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const w=[],b=[];function P(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let r=e.length,o=t.length;for(;r>0&&e.charCodeAt(~-r)===t.charCodeAt(~-o);)r--,o--;let a,i=0;for(;i<r&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(r-=i,o-=i,0===r)return o;let c,l,s=0,d=0,f=0;for(;d<r;)b[d]=e.charCodeAt(i+d),w[d]=++d;for(;f<o;)for(a=t.charCodeAt(i+f),c=f++,s=f,d=0;d<r;d++)l=a===b[d]?c:c+1,c=w[d],s=w[d]=c>s?l>s?s+1:l:l>c?c+1:l;return s}function x(e){return null!=e}e.getGPUTier=async function(){let{mobileTiers:e=[0,15,30,60],desktopTiers:o=[0,15,30,60],override:a={},glContext:i,failIfMajorPerformanceCaveat:c=!1,benchmarksURL:l="https://unpkg.com/detect-gpu-js@".concat(t,"/dist/benchmarks")}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const s={};if(g)return{tier:0,type:"SSR"};const{isIpad:d=!(null==h||!h.isIpad),isMobile:f=!(null==h||!h.isMobile),screenSize:u=window.screen,loadBenchmarks:m=(async e=>{const t=await fetch("".concat(l,"/").concat(e)).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<1)throw new v("Detect GPU benchmark data is out of date. Please update to version 1x");return t})}=a;let{renderer:w}=a;const b=(e,t,n,r,o)=>({device:o,fps:r,gpu:n,isMobile:f,tier:e,type:t});let A,S="";if(w)w=r(w),A=[w];else{const e=i||function(e){const t={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:arguments.length>1&&void 0!==arguments[1]&&arguments[1],powerPreference:"high-performance",stencil:!1};e&&delete t.powerPreference;const n=window.document.createElement("canvas"),r=n.getContext("webgl",t)||n.getContext("experimental-webgl",t);return null!=r?r:void 0}(null==h?void 0:h.isSafari12,c);if(!e)return b(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(w=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),!w)return b(1,"FALLBACK");S=w,w=r(w),A=function(e,t,n){return"apple gpu"===t?p(e,t,n):[t]}(e,w,f)}const y=(await Promise.all(A.map((async function(e){var t;const n=(e=>{const t=f?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const r="".concat(f?"m":"d","-").concat(n).concat(d?"-ipad":"",".json"),o=s[r]=null!==(t=s[r])&&void 0!==t?t:m(r);let a;try{a=await o}catch(e){if(e instanceof v)throw e;return}const i=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let c=a.filter((e=>{let[,t]=e;return t===i}));"found ".concat(c.length," matching entries using version '").concat(i,"':"),c.map((e=>{let[t]=e;return t})),c.length||(c=a.filter((t=>{let[n]=t;return n.includes(e)})),"found ".concat(c.length," matching entries comparing model names"));const l=c.length;if(0===l)return;const g=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let[h,,,,p]=l>1?c.map((e=>[e,P(g,e[2])])).sort(((e,t)=>{let[,n]=e,[,r]=t;return n-r}))[0][0]:c[0];"".concat(e," matched closest to ").concat(h," with the following screen sizes"),JSON.stringify(p);let w,b=Number.MAX_VALUE;const{devicePixelRatio:x}=window,A=u.width*x*u.height*x;for(const e of p){const[t,n]=e,r=t*n,o=Math.abs(A-r);o<b&&(b=o,w=e)}if(!w)return;const[,,S,y]=w;return[b,S,h,y]})))).filter(x).sort(((e,t)=>{let[n=Number.MAX_VALUE,r]=e,[o=Number.MAX_VALUE,a]=t;return n===o?r-a:n-o}));if(!y.length){const e=n.find((e=>w.includes(e)));return e?b(0,"BLOCKLISTED",e):b(1,"FALLBACK","".concat(w," (").concat(S,")"))}const[,E,C,L]=y[0];if(-1===E)return b(0,"BLOCKLISTED",C,E,L);const M=f?e:o;let B=0;for(let e=0;e<M.length;e++)E>=M[e]&&(B=e);return b(B,"BENCHMARK",C,E,L)}})); | ||
!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).DetectGPU={})}(this,(function(e){"use strict";var t="1.0.5",n={};const r=["geforce 320m","geforce 8600","geforce 8600m gt","geforce 8800 gs","geforce 8800 gt","geforce 9400","geforce 9400m g","geforce 9400m","geforce 9600m gt","geforce 9600m","geforce fx go5200","geforce gt 120","geforce gt 130","geforce gt 330m","geforce gtx 285","google swiftshader","intel g41","intel g45","intel gma 4500mhd","intel gma x3100","intel hd 3000","intel q45","legacy","mali-2","mali-3","mali-4","quadro fx 1500","quadro fx 4","quadro fx 5","radeon hd 2400","radeon hd 2600","radeon hd 4670","radeon hd 4850","radeon hd 4870","radeon hd 5670","radeon hd 5750","radeon hd 6290","radeon hd 6300","radeon hd 6310","radeon hd 6320","radeon hd 6490m","radeon hd 6630m","radeon hd 6750m","radeon hd 6770m","radeon hd 6970m","sgx 543","sgx543"];function o(e){return e=e.toLowerCase().replace(/.*angle ?\((.+)\)(?: on vulkan [0-9.]+)?$/i,"$1").replace(/\s(\d{1,2}gb|direct3d.+$)|\(r\)| \([^)]+\)$/g,"").replace(/(?:vulkan|opengl) \d+\.\d+(?:\.\d+)?(?: \((.*)\))?/,"$1")}const a=16384,i=4,c=35044,s=34962,l=5121,d=5126,f=6408,u=35632,g=35633,h="undefined"==typeof window,m=(()=>{if(h)return;const{userAgent:e,platform:t,maxTouchPoints:n}=window.navigator,r=/(iphone|ipod|ipad)/i.test(e),o="iPad"===t||"MacIntel"===t&&n>0&&!window.MSStream;return{isIpad:o,isMobile:/android/i.test(e)||r||o,isSafari12:/Version\/12.+Safari/.test(e)}})(),p=()=>{};function v(e,t,n){if(!n)return[t];const r=function(e){const t="\n precision highp float;\n attribute vec3 aPosition;\n varying float vvv;\n void main() {\n vvv = 0.31622776601683794;\n gl_Position = vec4(aPosition, 1.0);\n }\n ",n="\n precision highp float;\n varying float vvv;\n void main() {\n vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * vvv;\n enc = fract(enc);\n enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n gl_FragColor = enc;\n }\n ",r=e.createShader(g),o=e.createShader(u),h=e.createProgram();if(!(o&&r&&h))return;e.shaderSource(r,t),e.shaderSource(o,n),e.compileShader(r),e.compileShader(o),e.attachShader(h,r),e.attachShader(h,o),e.linkProgram(h),e.detachShader(h,r),e.detachShader(h,o),e.deleteShader(r),e.deleteShader(o),e.useProgram(h);const m=e.createBuffer();e.bindBuffer(s,m),e.bufferData(s,new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),c);const p=e.getAttribLocation(h,"aPosition");e.vertexAttribPointer(p,3,d,!1,0,0),e.enableVertexAttribArray(p),e.clearColor(1,1,1,1),e.clear(a),e.viewport(0,0,1,1),e.drawArrays(i,0,3);const v=new Uint8Array(4);return e.readPixels(0,0,1,1,f,l,v),e.deleteProgram(h),e.deleteBuffer(m),v.join("")}(e),o="801621810",h="8016218135",v="80162181161",w=null!=m&&m.isIpad?[["a7",v,12],["a8",h,15],["a8x",h,15],["a9",h,15],["a9x",h,15],["a10",h,15],["a10x",h,15],["a12",o,15],["a12x",o,15],["a12z",o,15],["a14",o,15],["m1",o,15]]:[["a7",v,12],["a8",h,12],["a9",h,15],["a10",h,15],["a11",o,15],["a12",o,15],["a13",o,15],["a14",o,15]];let b;"80162181255"===r?b=w.filter((e=>{let[,,t]=e;return t>=14})):(b=w.filter((e=>{let[,t]=e;return t===r})),b.length||(b=w));const P=b.map((e=>{let[t]=e;return"apple ".concat(t," gpu")}));return p("iOS 12.2+ obfuscates its GPU type and version, using closest matches: ".concat(JSON.stringify(P))),P}class w extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}const b=[],P=[];function x(e,t){if(e===t)return 0;const n=e;e.length>t.length&&(e=t,t=n);let r=e.length,o=t.length;for(;r>0&&e.charCodeAt(~-r)===t.charCodeAt(~-o);)r--,o--;let a,i=0;for(;i<r&&e.charCodeAt(i)===t.charCodeAt(i);)i++;if(r-=i,o-=i,0===r)return o;let c,s,l=0,d=0,f=0;for(;d<r;)P[d]=e.charCodeAt(i+d),b[d]=++d;for(;f<o;)for(a=t.charCodeAt(i+f),c=f++,l=f,d=0;d<r;d++)s=a===P[d]?c:c+1,c=b[d],l=b[d]=c>l?s>l?l+1:s:s>c?c+1:s;return l}function A(e){return null!=e}e.getGPUTier=async function(){let{mobileTiers:e=[0,15,30,60],desktopTiers:a=[0,15,30,60],override:i={},glContext:c,failIfMajorPerformanceCaveat:s=!1,benchmarksURL:l="https://unpkg.com/detect-gpu-js@".concat(t,"/dist/benchmarks")}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const d={};for(const e in n)d[e]=n[e].slice(1);if(h)return{tier:0,type:"SSR"};const{isIpad:f=!(null==m||!m.isIpad),isMobile:u=!(null==m||!m.isMobile),screenSize:g=window.screen,loadBenchmarks:p=(async e=>{const t=await fetch("".concat(l,"/").concat(e)).then((e=>e.json()));if(parseInt(t.shift().split(".")[0],10)<1)throw new w("Detect GPU benchmark data is out of date. Please update to version 1x");return t})}=i;let{renderer:b}=i;const P=(e,t,n,r,o)=>({device:o,fps:r,gpu:n,isMobile:u,tier:e,type:t});let S,y="";if(b)b=o(b),S=[b];else{const e=c||function(e){const t={alpha:!1,antialias:!1,depth:!1,failIfMajorPerformanceCaveat:arguments.length>1&&void 0!==arguments[1]&&arguments[1],powerPreference:"high-performance",stencil:!1};e&&delete t.powerPreference;const n=window.document.createElement("canvas"),r=n.getContext("webgl",t)||n.getContext("experimental-webgl",t);return null!=r?r:void 0}(null==m?void 0:m.isSafari12,s);if(!e)return P(0,"WEBGL_UNSUPPORTED");const t=e.getExtension("WEBGL_debug_renderer_info");if(b=t?e.getParameter(t.UNMASKED_RENDERER_WEBGL):e.getParameter(e.RENDERER),!b)return P(1,"FALLBACK");y=b,b=o(b),S=function(e,t,n){return"apple gpu"===t?v(e,t,n):[t]}(e,b,u)}const E=(await Promise.all(S.map((async function(e){var t;const n=(e=>{const t=u?["adreno","apple","mali-t","mali","nvidia","powervr","samsung"]:["intel","apple","amd","radeon","nvidia","geforce"];for(const n of t)if(e.includes(n))return n})(e);if(!n)return;const r="".concat(u?"m":"d","-").concat(n).concat(f?"-ipad":"",".json"),o=d[r]=null!==(t=d[r])&&void 0!==t?t:p(r);let a;try{a=await o}catch(e){if(e instanceof w)throw e;return}const i=function(e){var t;const n=(e=e.replace(/\([^)]+\)/,"")).match(/\d+/)||e.match(/(\W|^)([A-Za-z]{1,3})(\W|$)/g);return null!==(t=null==n?void 0:n.join("").replace(/\W|amd/g,""))&&void 0!==t?t:""}(e);let c=a.filter((e=>{let[,t]=e;return t===i}));"found ".concat(c.length," matching entries using version '").concat(i,"':"),c.map((e=>{let[t]=e;return t})),c.length||(c=a.filter((t=>{let[n]=t;return n.includes(e)})),"found ".concat(c.length," matching entries comparing model names"));const s=c.length;if(0===s)return;const l=e.split(/[.,()\[\]/\s]/g).sort().filter(((e,t,n)=>0===t||e!==n[t-1])).join(" ");let[h,,,,m]=s>1?c.map((e=>[e,x(l,e[2])])).sort(((e,t)=>{let[,n]=e,[,r]=t;return n-r}))[0][0]:c[0];"".concat(e," matched closest to ").concat(h," with the following screen sizes"),JSON.stringify(m);let v,b=Number.MAX_VALUE;const{devicePixelRatio:P}=window,A=g.width*P*g.height*P;for(const e of m){const[t,n]=e,r=t*n,o=Math.abs(A-r);o<b&&(b=o,v=e)}if(!v)return;const[,,S,y]=v;return[b,S,h,y]})))).filter(A).sort(((e,t)=>{let[n=Number.MAX_VALUE,r]=e,[o=Number.MAX_VALUE,a]=t;return n===o?r-a:n-o}));if(!E.length){const e=r.find((e=>b.includes(e)));return e?P(0,"BLOCKLISTED",e):P(1,"FALLBACK","".concat(b," (").concat(y,")"))}const[,C,L,M]=E[0];if(-1===C)return P(0,"BLOCKLISTED",L,C,M);const B=u?e:a;let U=0;for(let e=0;e<B.length;e++)C>=B[e]&&(U=e);return P(U,"BENCHMARK",L,C,M)}})); | ||
//# sourceMappingURL=detect-gpu.umd.js.map |
{ | ||
"name": "detect-gpu-js", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Detect and rate GPU based on its GFXBench scores", | ||
@@ -45,3 +45,3 @@ "author": "Soft8Soft", | ||
"parse-analytics": "node ./scripts/analytics_parser.js", | ||
"update-benchmarks": "rimraf benchmarks && mkdir -p benchmarks && mkdir -p benchmarks-min && node ./scripts/update_benchmarks.js && tar -czvf benchmarks.tar.gz benchmarks-min/*.json && rm -rf benchmarks-min" | ||
"update-benchmarks": "rimraf benchmarks && mkdir -p benchmarks && mkdir -p benchmarks-min && node ./scripts/update_benchmarks.js && tar -czvf benchmarks.tar.gz benchmarks-min/*.json && rm -rf benchmarks-min && node ./scripts/combine_benchmarks.js" | ||
}, | ||
@@ -68,2 +68,3 @@ "dependencies": { | ||
"rollup-plugin-filesize": "^10.0.0", | ||
"rollup-plugin-ignore": "^1.0.10", | ||
"rollup-plugin-livereload": "^2.0.5", | ||
@@ -70,0 +71,0 @@ "rollup-plugin-serve": "^2.0.2" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1404415
48.32%25
8.7%55777
2.18%19
5.56%