{"name":"detect-gpu","version":"5.0.57","keywords":["gpu","detect","webgl","webgl2","three.js","babylonjs","three","babylon","3d","typescript","javascript"],"author":{"name":"Tim van Scherpenzeel"},"license":"MIT","_id":"detect-gpu@5.0.57","maintainers":[{"name":"drcmda","email":"drcmda@gmail.com"},{"name":"timvanscherpenzeel","email":"timvanscherpenzeel@gmail.com"}],"homepage":"https://github.com/pmndrs/detect-gpu#readme","bugs":{"url":"https://github.com/pmndrs/detect-gpu/issues"},"dist":{"shasum":"b032977b2cbddc464e592bd7af64684cc966aa35","tarball":"http://registry-npm.ywwl.com/detect-gpu/download/detect-gpu-5.0.57.tgz","fileCount":38,"integrity":"sha512-iHfsCCAyxYTE0S4ULs52/DhV2W4l+VT9sTnnYLMwgdNlXKks6PSZleZRDmTCLvPXS4Lt30JI/M5QjhUPwwnZfQ==","signatures":[{"sig":"MEQCIEtniPb24Uu7DFcGzuVpwNsLCs+1vATaJat1o16ZkglWAiBx7tSq4Zycf1VhTDGAoyaeR6r90KOvv3cMiceYPeTAQA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":975266,"size":126155,"noattachment":false,"key":"/detect-gpu/-/detect-gpu-5.0.57.tgz"},"jest":{"preset":"ts-jest","testMatch":["**/test/**/*.test.ts"],"transform":{"^.+\\.tsx?$":["ts-jest",{"tsconfig":"tsconfig.json"}]},"moduleFileExtensions":["js","ts"],"testEnvironmentOptions":{"url":"http://localhost"},"testPathIgnorePatterns":["<rootDir>/test/data.ts"]},"main":"dist/detect-gpu.umd.js","types":"dist/src/index.d.ts","module":"dist/detect-gpu.esm.js","gitHead":"9c5464dea3eefed16f87f702d61176741aea3cd4","scripts":{"lint":"eslint \"src/**/*.ts\" \"test/**/*.ts\" \"test/**/*.test.ts\" \"rollup/**/*.ts\" \"scripts/**/*.ts\" \"scripts/**/*.js\" --fix --cache --cache-location ~/.eslintcache/eslintcache","test":"jest --verbose=false","build":"rollup -c rollup/config.lib.ts --configPlugin rollup-plugin-typescript2","start":"rollup -c rollup/config.lib.ts -w --configPlugin rollup-plugin-typescript2","example":"rollup -w -c rollup/config.dev.ts --configPlugin rollup-plugin-typescript2","prebuild":"rimraf dist","test:debug":"node --inspect-brk ./node_modules/jest/bin/jest --runInBand --no-cache --watch","test:watch":"jest --watch","test:coverage":"jest --coverage","parse-analytics":"node ./scripts/analytics_parser.js","update-benchmarks":"rimraf benchmarks && mkdir -p benchmarks && mkdir -p benchmarks-min && ts-node -O '{\"module\":\"commonjs\"}' ./scripts/update_benchmarks.ts && tar -czvf benchmarks.tar.gz benchmarks-min/*.json && rm -rf benchmarks-min"},"_npmUser":{"name":"timvanscherpenzeel","email":"timvanscherpenzeel@gmail.com"},"repository":{"url":"git+https://github.com/pmndrs/detect-gpu.git","type":"git"},"_npmVersion":"10.7.0","description":"Classify GPU's based on their benchmark score in order to provide an adaptive experience.","directories":{},"_nodeVersion":"18.20.4","dependencies":{"webgl-constants":"^1.1.1"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.6.2","eslint":"^8.4.1","moment":"^2.29.1","rimraf":"^5.0.1","rollup":"^3.28.0","ts-jest":"^29.1.1","ts-node":"^10.0.0","prettier":"^3.0.1","csvtojson":"^2.0.10","puppeteer":"^13.0.0","typescript":"^5.1.6","@types/jest":"^29.5.3","rollup-plugin-copy":"^3.4.0","@rollup/plugin-json":"^6.0.0","rollup-plugin-serve":"^2.0.2","rollup-plugin-terser":"^7.0.2","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","jest-environment-jsdom":"^29.6.2","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-filesize":"^10.0.0","rollup-plugin-livereload":"^2.0.0","rollup-plugin-sourcemaps":"^0.6.3","@typescript-eslint/parser":"^6.4.0","rollup-plugin-typescript2":"^0.31.1","@rollup/plugin-node-resolve":"^15.1.0","@typescript-eslint/eslint-plugin":"^6.4.0"},"_npmOperationalInternal":{"tmp":"tmp/detect-gpu_5.0.57_1731805937514_0.8156548684459453","host":"s3://npm-registry-packages"},"readme":"# Detect GPU\n\n[![npm version](https://badge.fury.io/js/detect-gpu.svg)](https://badge.fury.io/js/detect-gpu)\n[![gzip size](https://img.badgesize.io/https:/unpkg.com/detect-gpu/dist/detect-gpu.esm.js?compression=gzip)](https://unpkg.com/detect-gpu)\n[![install size](https://packagephobia.now.sh/badge?p=detect-gpu)](https://packagephobia.now.sh/result?p=detect-gpu)\n\nClassifies GPUs based on their 3D rendering benchmark score allowing the developer to provide sensible default settings for graphically intensive applications. Think of it like a user-agent detection for the GPU but more powerful.\n\n## Demo\n\n[Live demo](https://pmndrs.github.io/detect-gpu/)\n\n## Installation\n\nBy default we use the [UNPKG](https://unpkg.com) CDN to host the benchmark data. If you would like to serve the benchmark data yourself download the required benchmarking data from [benchmarks.tar.gz](https://github.com/pmndrs/detect-gpu/raw/master/benchmarks.tar.gz) and serve it from a public directory.\n\nMake sure you have [Node.js](http://nodejs.org/) installed.\n\n```sh\n $ npm install detect-gpu\n```\n\n## Usage\n\n```ts\nimport { getGPUTier } from 'detect-gpu';\n\n(async () => {\n  const gpuTier = await getGPUTier();\n\n  // Example output:\n  // {\n  //   \"tier\": 1,\n  //   \"isMobile\": false,\n  //   \"type\": \"BENCHMARK\",\n  //   \"fps\": 21,\n  //   \"gpu\": \"intel iris graphics 6100\"\n  // }\n})();\n```\n\n`detect-gpu` uses rendering benchmark scores (framerate, normalized by resolution) in order to determine what tier should be assigned to the user's GPU. If no `WebGLContext` can be created, the GPU is blocklisted or the GPU has reported to render on less than `15 fps` `tier: 0` is assigned. One should provide a fallback to a non-WebGL experience.\n\nBased on the reported `fps` the GPU is then classified into either `tier: 1 (>= 15 fps)`, `tier: 2 (>= 30 fps)` or `tier: 3 (>= 60 fps)`. The higher the tier the more graphically intensive workload you can offer to the user.\n\n## API\n\n```ts\ngetGPUTier({\n  /**\n   * URL of directory where benchmark data is hosted.\n   *\n   * @default https://unpkg.com/detect-gpu@{version}/dist/benchmarks\n   */\n  benchmarksURL?: string;\n  /**\n   * Optionally pass in a WebGL context to avoid creating a temporary one\n   * internally.\n   */\n  glContext?: WebGLRenderingContext | WebGL2RenderingContext;\n  /**\n   * Whether to fail if the system performance is low or if no hardware GPU is\n   * available.\n   *\n   * @default false\n   */\n  failIfMajorPerformanceCaveat?: boolean;\n  /**\n   * Framerate per tier for mobile devices.\n   *\n   * @defaultValue [0, 15, 30, 60]\n   */\n  mobileTiers?: number[];\n  /**\n   * Framerate per tier for desktop devices.\n   *\n   * @defaultValue [0, 15, 30, 60]\n   */\n  desktopTiers?: number[];\n  /**\n   * Optionally override specific parameters. Used mainly for testing.\n   */\n  override?: {\n    renderer?: string;\n    /**\n     * Override whether device is an iPad.\n     */\n    isIpad?: boolean;\n    /**\n     * Override whether device is a mobile device.\n     */\n    isMobile?: boolean;\n    /**\n     * Override device screen size.\n     */\n    screenSize?: { width: number; height: number };\n    /**\n     * Override how benchmark data is loaded\n     */\n    loadBenchmarks?: (file: string) => Promise<ModelEntry[]>;\n  };\n})\n```\n\n## Support\n\nSpecial care has been taken to make sure all browsers that support `WebGL` are also supported by `detect-gpu` including `IE 11`.\n\n## Changelog\n\n[Changelog](CHANGELOG.md)\n\n## Licence\n\nMy work is released under the [MIT license](https://raw.githubusercontent.com/pmndrs/detect-gpu/master/LICENSE).\n\n`detect-gpu` uses both mobile and desktop benchmarking scores from [https://gfxbench.com](https://gfxbench.com).\n","publish_time":1731805937694,"_cnpm_publish_time":1731805937694,"dist-tags":{"latest":"5.0.70","next":"2.0.2-rc1"}}