diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..89c5273 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +test/mocha.js +test/js/twgl-full.module.js +webgl-memory.js + + + diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..6d52412 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,97 @@ +/* global module */ +module.exports = { + "env": { + "browser": true, + "es6": true, + }, + "globals": { + "chroma": true, + "importScripts": true, + "SharedArrayBuffer": true, + "twgl": true, + }, + "parserOptions": { + "sourceType": "module", + "ecmaVersion": 2019, + }, + "plugins": [ + "eslint-plugin-html", + "eslint-plugin-optional-comma-spacing", + "eslint-plugin-one-variable-per-var", + "eslint-plugin-require-trailing-comma", + ], + "extends": "eslint:recommended", + "rules": { + "no-alert": 2, + "no-array-constructor": 2, + "no-caller": 2, + "no-catch-shadow": 2, + "no-const-assign": 2, + "no-eval": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-implied-eval": 2, + "no-iterator": 2, + "no-label-var": 2, + "no-labels": 2, + "no-lone-blocks": 2, + "no-loop-func": 2, + "no-multi-str": 2, + "no-native-reassign": 2, + "no-new": 2, + "no-new-func": 2, + "no-new-object": 2, + "no-new-wrappers": 2, + "no-octal-escape": 2, + "no-process-exit": 2, + "no-proto": 2, + "no-return-assign": 2, + "no-script-url": 2, + "no-sequences": 2, + "no-shadow-restricted-names": 2, + "no-spaced-func": 2, + "no-trailing-spaces": 2, + "no-undef-init": 2, + "no-underscore-dangle": 2, + "no-unused-expressions": 2, + "no-use-before-define": 0, + "no-with": 2, + "consistent-return": 2, + "curly": [2, "all"], + "no-extra-parens": [2, "functions"], + "eqeqeq": 2, + "new-cap": 2, + "new-parens": 2, + "semi-spacing": [2, {"before": false, "after": true}], + "space-infix-ops": 2, + "space-unary-ops": [2, { "words": true, "nonwords": false }], + "strict": [2, "function"], + "yoda": [2, "never"], + "prefer-const": 2, + "no-var": 2, + + "brace-style": [2, "1tbs", { "allowSingleLine": false }], + "camelcase": [0], + "comma-spacing": 0, + "comma-dangle": 0, + "comma-style": [2, "last"], + "dot-notation": 0, + "eol-last": [0], + "global-strict": [0], + "key-spacing": [0], + "no-comma-dangle": [0], + "no-irregular-whitespace": 2, + "no-multi-spaces": [0], + "no-obj-calls": 2, + "no-shadow": [0], + "no-undef": 2, + "no-unreachable": 2, + "one-variable-per-var/one-variable-per-var": [2], + "optional-comma-spacing/optional-comma-spacing": [2, {"after": true}], + "quotes": [0, "single"], + "require-trailing-comma/require-trailing-comma": [2], + "semi": [2, "always"], + "space-before-function-paren": [2, "never"], + "keyword-spacing": [1, {"before": true, "after": true, "overrides": {}} ], + }, +}; diff --git a/package-lock.json b/package-lock.json index 71272c8..695123b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,12 @@ "version": "1.0.15", "license": "MIT", "devDependencies": { + "@rollup/plugin-node-resolve": "^15.0.1", "eslint": "^7.5.0", - "eslint-plugin-html": "^6.0.2", - "eslint-plugin-optional-comma-spacing": "0.0.4", - "eslint-plugin-require-trailing-comma": "0.0.1", + "eslint-plugin-html": "^6.2.0", + "eslint-plugin-one-variable-per-var": "^0.0.3", + "eslint-plugin-optional-comma-spacing": "^0.0.4", + "eslint-plugin-require-trailing-comma": "^0.0.1", "express": "^4.18.2", "puppeteer": "^19.3.0", "rollup": "^2.23.0", @@ -114,6 +116,71 @@ "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", "dev": true }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.1.tgz", + "integrity": "sha512-ReY88T7JhJjeRVbfCyNj+NXAG3IIsVMsX9b5/9jC98dRP8/yxlZdz7mHZbHk5zHr24wZZICS5AcXsFZAXYUQEg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.0", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve/node_modules/@rollup/pluginutils": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", + "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve/node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, + "node_modules/@rollup/plugin-node-resolve/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "node_modules/@types/estree": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", + "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", + "dev": true + }, "node_modules/@types/node": { "version": "16.9.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", @@ -381,9 +448,9 @@ } }, "node_modules/builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true, "engines": { "node": ">=6" @@ -618,6 +685,15 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "node_modules/deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -656,9 +732,9 @@ } }, "node_modules/dom-serializer": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", - "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", "dev": true, "dependencies": { "domelementtype": "^2.0.1", @@ -669,10 +745,19 @@ "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" } }, - "node_modules/domelementtype": { + "node_modules/dom-serializer/node_modules/entities": { "version": "2.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", "dev": true, "funding": [ { @@ -682,9 +767,9 @@ ] }, "node_modules/domhandler": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", - "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", "dev": true, "dependencies": { "domelementtype": "^2.2.0" @@ -753,10 +838,13 @@ } }, "node_modules/entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-3.0.1.tgz", + "integrity": "sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==", "dev": true, + "engines": { + "node": ">=0.12" + }, "funding": { "url": "https://github.com/fb55/entities?sponsor=1" } @@ -846,18 +934,27 @@ } }, "node_modules/eslint-plugin-html": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-6.1.2.tgz", - "integrity": "sha512-bhBIRyZFqI4EoF12lGDHAmgfff8eLXx6R52/K3ESQhsxzCzIE6hdebS7Py651f7U3RBotqroUnC3L29bR7qJWQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-6.2.0.tgz", + "integrity": "sha512-vi3NW0E8AJombTvt8beMwkL1R/fdRWl4QSNRNMhVQKWm36/X0KF0unGNAY4mqUF06mnwVWZcIcerrCnfn9025g==", "dev": true, "dependencies": { - "htmlparser2": "^6.0.1" + "htmlparser2": "^7.1.2" + } + }, + "node_modules/eslint-plugin-one-variable-per-var": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-one-variable-per-var/-/eslint-plugin-one-variable-per-var-0.0.3.tgz", + "integrity": "sha512-gdqNqxyuGNjiJFIbOFMV5rs+cAR8TwQmldwsHINFNtgsm7/D5ogFmplibJL4UzQpINb5RwiXdOY0Ixed71PtIQ==", + "dev": true, + "peerDependencies": { + "eslint": ">=0.8.0" } }, "node_modules/eslint-plugin-optional-comma-spacing": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/eslint-plugin-optional-comma-spacing/-/eslint-plugin-optional-comma-spacing-0.0.4.tgz", - "integrity": "sha1-OaAMpQ5fyRhCb/o/Z21auUoZ8uw=", + "integrity": "sha512-VXTJW7LgMxjJngnCrPl/oLxw74aJvDoNLYYXjOedqq4qIuEb9JBqFJolAIHQFSqWPY0teQEkl8HKxfphu3eczg==", "dev": true, "peerDependencies": { "eslint": ">=0.8.0" @@ -866,7 +963,7 @@ "node_modules/eslint-plugin-require-trailing-comma": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/eslint-plugin-require-trailing-comma/-/eslint-plugin-require-trailing-comma-0.0.1.tgz", - "integrity": "sha1-Aa/LZX1v1DpgetKWfN4HuLrw1WI=", + "integrity": "sha512-PFNp10AQZsFUbbt70esqj2WW6wd0mJbZaKZMSdWsvTqRPjOdzQd9Cn1xx7i8YCrAGYZCZpJIO8O7/22sQvuCTA==", "dev": true, "peerDependencies": { "eslint": ">=0.8.0" @@ -1363,9 +1460,9 @@ } }, "node_modules/htmlparser2": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", - "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-7.2.0.tgz", + "integrity": "sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog==", "dev": true, "funding": [ "https://github.com/fb55/htmlparser2?sponsor=1", @@ -1376,9 +1473,9 @@ ], "dependencies": { "domelementtype": "^2.0.1", - "domhandler": "^4.0.0", - "domutils": "^2.5.2", - "entities": "^2.0.0" + "domhandler": "^4.2.2", + "domutils": "^2.8.0", + "entities": "^3.0.1" } }, "node_modules/http-errors": { @@ -1507,10 +1604,25 @@ "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, + "node_modules/is-builtin-module": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.0.tgz", + "integrity": "sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-core-module": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", - "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", "dev": true, "dependencies": { "has": "^1.0.3" @@ -1894,6 +2006,18 @@ "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -2064,13 +2188,17 @@ } }, "node_modules/resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dev": true, "dependencies": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -2101,9 +2229,9 @@ } }, "node_modules/rollup": { - "version": "2.56.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.3.tgz", - "integrity": "sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg==", + "version": "2.79.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", + "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -2407,6 +2535,18 @@ "node": ">=4" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/table": { "version": "6.7.1", "resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz", @@ -2769,6 +2909,51 @@ "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", "dev": true }, + "@rollup/plugin-node-resolve": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.0.1.tgz", + "integrity": "sha512-ReY88T7JhJjeRVbfCyNj+NXAG3IIsVMsX9b5/9jC98dRP8/yxlZdz7mHZbHk5zHr24wZZICS5AcXsFZAXYUQEg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.0", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", + "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", + "dev": true, + "requires": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + } + }, + "@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + } + } + }, + "@types/estree": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", + "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", + "dev": true + }, "@types/node": { "version": "16.9.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", @@ -2973,9 +3158,9 @@ "dev": true }, "builtin-modules": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", - "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", "dev": true }, "bytes": { @@ -3153,6 +3338,12 @@ "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, "depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -3181,26 +3372,34 @@ } }, "dom-serializer": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.3.2.tgz", - "integrity": "sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", + "integrity": "sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==", "dev": true, "requires": { "domelementtype": "^2.0.1", "domhandler": "^4.2.0", "entities": "^2.0.0" + }, + "dependencies": { + "entities": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "dev": true + } } }, "domelementtype": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.2.0.tgz", - "integrity": "sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", "dev": true }, "domhandler": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.2.2.tgz", - "integrity": "sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.3.1.tgz", + "integrity": "sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==", "dev": true, "requires": { "domelementtype": "^2.2.0" @@ -3254,9 +3453,9 @@ } }, "entities": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/entities/-/entities-3.0.1.tgz", + "integrity": "sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==", "dev": true }, "error-ex": { @@ -3329,25 +3528,32 @@ } }, "eslint-plugin-html": { - "version": "6.1.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-6.1.2.tgz", - "integrity": "sha512-bhBIRyZFqI4EoF12lGDHAmgfff8eLXx6R52/K3ESQhsxzCzIE6hdebS7Py651f7U3RBotqroUnC3L29bR7qJWQ==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-html/-/eslint-plugin-html-6.2.0.tgz", + "integrity": "sha512-vi3NW0E8AJombTvt8beMwkL1R/fdRWl4QSNRNMhVQKWm36/X0KF0unGNAY4mqUF06mnwVWZcIcerrCnfn9025g==", "dev": true, "requires": { - "htmlparser2": "^6.0.1" + "htmlparser2": "^7.1.2" } }, + "eslint-plugin-one-variable-per-var": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-one-variable-per-var/-/eslint-plugin-one-variable-per-var-0.0.3.tgz", + "integrity": "sha512-gdqNqxyuGNjiJFIbOFMV5rs+cAR8TwQmldwsHINFNtgsm7/D5ogFmplibJL4UzQpINb5RwiXdOY0Ixed71PtIQ==", + "dev": true, + "requires": {} + }, "eslint-plugin-optional-comma-spacing": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/eslint-plugin-optional-comma-spacing/-/eslint-plugin-optional-comma-spacing-0.0.4.tgz", - "integrity": "sha1-OaAMpQ5fyRhCb/o/Z21auUoZ8uw=", + "integrity": "sha512-VXTJW7LgMxjJngnCrPl/oLxw74aJvDoNLYYXjOedqq4qIuEb9JBqFJolAIHQFSqWPY0teQEkl8HKxfphu3eczg==", "dev": true, "requires": {} }, "eslint-plugin-require-trailing-comma": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/eslint-plugin-require-trailing-comma/-/eslint-plugin-require-trailing-comma-0.0.1.tgz", - "integrity": "sha1-Aa/LZX1v1DpgetKWfN4HuLrw1WI=", + "integrity": "sha512-PFNp10AQZsFUbbt70esqj2WW6wd0mJbZaKZMSdWsvTqRPjOdzQd9Cn1xx7i8YCrAGYZCZpJIO8O7/22sQvuCTA==", "dev": true, "requires": {} }, @@ -3736,15 +3942,15 @@ "dev": true }, "htmlparser2": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", - "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-7.2.0.tgz", + "integrity": "sha512-H7MImA4MS6cw7nbyURtLPO1Tms7C5H602LRETv95z1MxO/7CP7rDVROehUYeYBUYEON94NXXDEPmZuq+hX4sog==", "dev": true, "requires": { "domelementtype": "^2.0.1", - "domhandler": "^4.0.0", - "domutils": "^2.5.2", - "entities": "^2.0.0" + "domhandler": "^4.2.2", + "domutils": "^2.8.0", + "entities": "^3.0.1" } }, "http-errors": { @@ -3835,10 +4041,19 @@ "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, + "is-builtin-module": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.0.tgz", + "integrity": "sha512-phDA4oSGt7vl1n5tJvTWooWWAsXLY+2xCnxNqvKhGEzujg+A43wPlPOyDg3C8XQHN+6k/JTQWJ/j0dQh/qr+Hw==", + "dev": true, + "requires": { + "builtin-modules": "^3.3.0" + } + }, "is-core-module": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", - "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", "dev": true, "requires": { "has": "^1.0.3" @@ -4136,6 +4351,12 @@ "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "dev": true }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -4263,13 +4484,14 @@ "dev": true }, "resolve": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", - "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dev": true, "requires": { - "is-core-module": "^2.2.0", - "path-parse": "^1.0.6" + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" } }, "resolve-from": { @@ -4288,9 +4510,9 @@ } }, "rollup": { - "version": "2.56.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.3.tgz", - "integrity": "sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg==", + "version": "2.79.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", + "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", "dev": true, "requires": { "fsevents": "~2.3.2" @@ -4522,6 +4744,12 @@ "has-flag": "^3.0.0" } }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, "table": { "version": "6.7.1", "resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz", diff --git a/package.json b/package.json index c0b6b2c..c49d9b6 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,12 @@ ], "homepage": "https://github.com/greggman/webgl-memory#readme", "devDependencies": { + "@rollup/plugin-node-resolve": "^15.0.1", "eslint": "^7.5.0", - "eslint-plugin-html": "^6.0.2", - "eslint-plugin-optional-comma-spacing": "0.0.4", - "eslint-plugin-require-trailing-comma": "0.0.1", + "eslint-plugin-html": "^6.2.0", + "eslint-plugin-one-variable-per-var": "^0.0.3", + "eslint-plugin-optional-comma-spacing": "^0.0.4", + "eslint-plugin-require-trailing-comma": "^0.0.1", "express": "^4.18.2", "puppeteer": "^19.3.0", "rollup": "^2.23.0", diff --git a/rollup.config.js b/rollup.config.js index 0cba961..a0bc425 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,4 +1,4 @@ -import resolve from 'rollup-plugin-node-resolve'; +import resolve from '@rollup/plugin-node-resolve'; import fs from 'fs'; const pkg = JSON.parse(fs.readFileSync('package.json', {encoding: 'utf8'})); diff --git a/src/augment-api.js b/src/augment-api.js index 2e0850e..9bff352 100644 --- a/src/augment-api.js +++ b/src/augment-api.js @@ -31,10 +31,6 @@ import { isNumber, } from './utils.js'; -/* global console */ -/* global WebGL2RenderingContext */ -/* global WebGLUniformLocation */ - //------------ [ from https://github.com/KhronosGroup/WebGLDeveloperTools ] /* @@ -70,6 +66,7 @@ const augmentedSet = new Set(); * @param {WebGLRenderingContext|Extension} ctx The webgl context to wrap. * @param {string} nameOfClass (eg, webgl, webgl2, OES_texture_float) */ +// eslint-disable-next-line consistent-return export function augmentAPI(ctx, nameOfClass, options = {}) { if (augmentedSet.has(ctx)) { @@ -95,10 +92,10 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { ...memory, drawingbuffer, total: drawingbuffer + memory.buffer + memory.texture + memory.renderbuffer, - }, + }, resources: { ...resources, - } + }, }; }, }, @@ -127,7 +124,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { sharedState.webglObjectToMemory.set(sharedState.defaultVertexArray, {}); sharedState.currentVertexArray = sharedState.defaultVertexArray; [sharedState.resources, sharedState.memory].forEach(function(obj) { - for (let prop in obj) { + for (const prop in obj) { obj[prop] = 0; } }); @@ -138,7 +135,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { // * all resources are lost. // Solution: handled by resetSharedState // * all functions are no-op - // Solutions: + // Solutions: // * swap all functions for noop // (not so easy because some functions return values) // * wrap all functions is a isContextLost check forwarder @@ -157,7 +154,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { if (!unRestorableAPIs.has(name) && origFuncs) { augmentedSet.delete(ctx); for (const [funcName, origFn] of Object.entries(origFuncs)) { - ctx[funcName] = origFn + ctx[funcName] = origFn; } delete apis[name]; } @@ -182,9 +179,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { const { apis, - baseContext, bindings, - config, memory, resources, webglObjectToMemory, @@ -198,12 +193,12 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { function makeCreateWrapper(ctx, typeName, _funcName) { const funcName = _funcName || `create${typeName[0].toUpperCase()}${typeName.substr(1)}`; if (!ctx[funcName]) { - return; + return null; } resources[typeName] = 0; return function(ctx, funcName, args, webglObj) { if (sharedState.isContextLost) { - return null; + return; } ++resources[typeName]; webglObjectToMemory.set(webglObj, { @@ -215,7 +210,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { function makeDeleteWrapper(typeName, fn = noop, _funcName) { const funcName = _funcName || `delete${typeName[0].toUpperCase()}${typeName.substr(1)}`; if (!ctx[funcName]) { - return; + return null; } return function(ctx, funcName, args) { if (sharedState.isContextLost) { @@ -304,7 +299,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { info.mips = info.mips || []; info.mips[level] = info.mips[level] || []; - const mipFaceInfo = info.mips[level][faceNdx] || {} + const mipFaceInfo = info.mips[level][faceNdx] || {}; info.size -= mipFaceInfo.size || 0; mipFaceInfo.size = newMipSize; @@ -324,7 +319,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { function updateTexStorage(target, levels, internalFormat, width, height, depth) { const info = getTextureInfo(target); const numFaces = target === TEXTURE_CUBE_MAP ? 6 : 1; - const baseFaceTarget = target === TEXTURE_CUBE_MAP ? TEXTURE_CUBE_MAP_POSITIVE_X : target;; + const baseFaceTarget = target === TEXTURE_CUBE_MAP ? TEXTURE_CUBE_MAP_POSITIVE_X : target; for (let level = 0; level < levels; ++level) { for (let face = 0; face < numFaces; ++face) { updateMipLevel(info, baseFaceTarget + face, level, internalFormat, width, height, depth); @@ -348,10 +343,11 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { return; } switch (target) { - case ELEMENT_ARRAY_BUFFER: - const info = webglObjectToMemory.get(sharedState.currentVertexArray); - info.elementArrayBuffer = obj; - break; + case ELEMENT_ARRAY_BUFFER: { + const info = webglObjectToMemory.get(sharedState.currentVertexArray); + info.elementArrayBuffer = obj; + break; + } default: bindings.set(target, obj); break; @@ -370,7 +366,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { if (sharedState.isContextLost) { return; } - const [target, src, /* usage */, srcOffset = 0, length = undefined] = args; + const [target, src, /* usage */, /*srcOffset = 0*/, length = undefined] = args; let obj; switch (target) { case ELEMENT_ARRAY_BUFFER: @@ -416,12 +412,12 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { }, bindBufferBase(gl, funcName, args) { - const [target, ndx, obj] = args; + const [target, /*ndx*/, obj] = args; handleBufferBinding(target, obj); }, bindBufferRange(gl, funcName, args) { - const [target, ndx, obj, offset, size] = args; + const [target, /*ndx*/, obj, /*offset*/, /*size*/] = args; handleBufferBinding(target, obj); }, @@ -446,7 +442,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { if (sharedState.isContextLost) { return; } - const [target, level, internalFormat, x, y, width, height, border] = args; + const [target, level, internalFormat, /*x*/, /*y*/, width, height, /*border*/] = args; const info = getTextureInfo(target); updateMipLevel(info, target, level, internalFormat, width, height, 1, UNSIGNED_BYTE); }, @@ -514,10 +510,10 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { fenceSync: function(ctx) { if (sharedState.isContextLost) { - return; + return undefined; } if (!ctx.fenceSync) { - return; + return undefined; } resources.sync = 0; return function(ctx, funcName, args, webglObj) { @@ -537,11 +533,13 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { const info = getTextureInfo(target); const baseMipNdx = info.parameters ? info.parameters.get(TEXTURE_BASE_LEVEL) || 0 : 0; const maxMipNdx = info.parameters ? info.parameters.get(TEXTURE_MAX_LEVEL) || 1024 : 1024; - let {width, height, depth, internalFormat, type} = info.mips[baseMipNdx][0]; + const mipInfo = info.mips[baseMipNdx][0]; + let {width, height, depth} = mipInfo; + const {internalFormat, type} = mipInfo; let level = baseMipNdx + 1; const numFaces = target === TEXTURE_CUBE_MAP ? 6 : 1; - const baseFaceTarget = target === TEXTURE_CUBE_MAP ? TEXTURE_CUBE_MAP_POSITIVE_X : target;; + const baseFaceTarget = target === TEXTURE_CUBE_MAP ? TEXTURE_CUBE_MAP_POSITIVE_X : target; while (level <= maxMipNdx && !(width === 1 && height === 1 && (depth === 1 || target === TEXTURE_2D_ARRAY))) { width = Math.ceil(Math.max(width / 2, 1)); height = Math.ceil(Math.max(height / 2, 1)); @@ -598,11 +596,11 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { // void gl.texImage2D(target, level, internalformat, width, height, border, format, type, ImageBitmap source); // void gl.texImage2D(target, level, internalformat, width, height, border, format, type, ImageData source); // void gl.texImage2D(target, level, internalformat, width, height, border, format, type, ArrayBufferView srcData, srcOffset); - let [target, level, internalFormat] = args; + const [target, level, internalFormat] = args; let width; let height; let type; - if (args.length == 6) { + if (args.length === 6) { const src = args[5]; width = src.width; height = src.height; @@ -631,7 +629,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { if (sharedState.isContextLost) { return; } - let [target, level, internalFormat, width, height, depth, border, format, type] = args; + const [target, level, internalFormat, width, height, depth, /*border*/, /*format*/, type] = args; const info = getTextureInfo(target); updateMipLevel(info, target, level, internalFormat, width, height, depth, type); }, @@ -640,7 +638,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { if (sharedState.isContextLost) { return; } - let [target, pname, value] = args; + const [target, pname, value] = args; const info = getTextureInfo(target); info.parameters = info.parameters || new Map(); info.parameters.set(pname, value); @@ -648,13 +646,13 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { // void gl.texStorage2D(target, levels, internalformat, width, height); texStorage2D(ctx, funcName, args) { - let [target, levels, internalFormat, width, height] = args; + const [target, levels, internalFormat, width, height] = args; updateTexStorage(target, levels, internalFormat, width, height, 1); }, // void gl.texStorage3D(target, levels, internalformat, width, height, depth); texStorage3D(ctx, funcName, args) { - let [target, levels, internalFormat, width, height, depth] = args; + const [target, levels, internalFormat, width, height, depth] = args; updateTexStorage(target, levels, internalFormat, width, height, depth); }, }; @@ -662,7 +660,7 @@ export function augmentAPI(ctx, nameOfClass, options = {}) { const extraWrappers = { getExtension(ctx, propertyName) { if (sharedState.isContextLost) { - return null; + return; } const origFn = ctx[propertyName]; ctx[propertyName] = function(...args) { diff --git a/src/texture-utils.js b/src/texture-utils.js index 39ea960..9a6691a 100644 --- a/src/texture-utils.js +++ b/src/texture-utils.js @@ -65,11 +65,11 @@ const DEPTH32F_STENCIL8 = 0x8CAD; const DEPTH24_STENCIL8 = 0x88F0; /* DataType */ -const BYTE = 0x1400; +// const BYTE = 0x1400; const UNSIGNED_BYTE = 0x1401; -const SHORT = 0x1402; +// const SHORT = 0x1402; const UNSIGNED_SHORT = 0x1403; -const INT = 0x1404; +// const INT = 0x1404; const UNSIGNED_INT = 0x1405; const FLOAT = 0x1406; const UNSIGNED_SHORT_4_4_4_4 = 0x8033; @@ -77,11 +77,11 @@ const UNSIGNED_SHORT_5_5_5_1 = 0x8034; const UNSIGNED_SHORT_5_6_5 = 0x8363; const HALF_FLOAT = 0x140B; const HALF_FLOAT_OES = 0x8D61; // Thanks Khronos for making this different >:( -const UNSIGNED_INT_2_10_10_10_REV = 0x8368; -const UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B; -const UNSIGNED_INT_5_9_9_9_REV = 0x8C3E; -const FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD; -const UNSIGNED_INT_24_8 = 0x84FA; +// const UNSIGNED_INT_2_10_10_10_REV = 0x8368; +// const UNSIGNED_INT_10F_11F_11F_REV = 0x8C3B; +// const UNSIGNED_INT_5_9_9_9_REV = 0x8C3E; +// const FLOAT_32_UNSIGNED_INT_24_8_REV = 0x8DAD; +// const UNSIGNED_INT_24_8 = 0x84FA; const RG = 0x8227; const RG_INTEGER = 0x8228; @@ -207,14 +207,14 @@ function makeComputeBlockRectSizeFunction(blockWidth, blockHeight, bytesPerBlock const blocksAcross = (width + blockWidth - 1) / blockWidth | 0; const blocksDown = (height + blockHeight - 1) / blockHeight | 0; return blocksAcross * blocksDown * bytesPerBlock * depth; - } -} + }; +} function makeComputePaddedRectSizeFunction(minWidth, minHeight, divisor) { return function(width, height, depth) { return (Math.max(width, minWidth) * Math.max(height, minHeight) / divisor | 0) * depth; - } -} + }; +} // WEBGL_compressed_texture_s3tc const COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0; @@ -384,4 +384,4 @@ function getBytesForMipUncompressed(internalFormat, width, height, depth, type) export function getBytesForMip(internalFormat, width, height, depth, type) { const fn = compressedTextureFunctions.get(internalFormat); return fn ? fn(width, height, depth) : getBytesForMipUncompressed(internalFormat, width, height, depth, type); -}; +} diff --git a/src/utils.js b/src/utils.js index 282fb4e..4263e8f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -105,7 +105,7 @@ export function getDrawingbufferInfo(gl) { } function computeDepthStencilSize(drawingBufferInfo) { - const {depthBits, stencilBits} = drawingBufferInfo + const {depthBits, stencilBits} = drawingBufferInfo; const depthSize = (depthBits + stencilBits + 7) / 8 | 0; return depthSize === 3 ? 4 : depthSize; } diff --git a/src/wrap.js b/src/wrap.js index 4d0b891..f924aaf 100644 --- a/src/wrap.js +++ b/src/wrap.js @@ -23,11 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import {augmentAPI} from './augment-api.js'; -/* global console */ -/* global document */ -/* global HTMLCanvasElement */ -/* global OffscreenCanvas */ - function wrapGetContext(Ctor) { const oldFn = Ctor.prototype.getContext; Ctor.prototype.getContext = function(type, ...args) { @@ -37,7 +32,7 @@ function wrapGetContext(Ctor) { if (ctx && ctx.bindTexture) { const config = {}; augmentAPI(ctx, type, config); - const ext = ctx.getExtension('GMAN_webgl_memory'); + ctx.getExtension('GMAN_webgl_memory'); } return ctx; }; diff --git a/test/assert.js b/test/assert.js index 188e1e6..95a5acf 100644 --- a/test/assert.js +++ b/test/assert.js @@ -1,5 +1,3 @@ -/* global console */ - export const config = {}; export function setConfig(options) { diff --git a/test/index.js b/test/index.js index a15f2f2..b785442 100644 --- a/test/index.js +++ b/test/index.js @@ -1,6 +1,4 @@ /* global mocha */ -/* global URLSearchParams */ -/* global window */ import './tests/buffer-tests.js'; import './tests/contextloss-tests.js'; diff --git a/test/mocha-support.js b/test/mocha-support.js index 351db8a..7e251b7 100644 --- a/test/mocha-support.js +++ b/test/mocha-support.js @@ -1,5 +1,3 @@ -/* global window */ - export const describe = window.describe; export const it = window.it; export const before = window.before; diff --git a/test/puppeteer.js b/test/puppeteer.js index 3e68610..adfc4c0 100755 --- a/test/puppeteer.js +++ b/test/puppeteer.js @@ -4,7 +4,6 @@ const puppeteer = require('puppeteer'); const path = require('path'); -const fs = require('fs'); const express = require('express'); const app = express(); const port = 3000; diff --git a/test/tests/buffer-tests.js b/test/tests/buffer-tests.js index b51aa1b..c0b99c8 100644 --- a/test/tests/buffer-tests.js +++ b/test/tests/buffer-tests.js @@ -180,7 +180,7 @@ describe('buffer tests', () => { tracker.deleteObjectAndMemory(size2); }); - it ('test bindBufferBase/bindBufferRange', () => { + it('test bindBufferBase/bindBufferRange', () => { const {gl} = createContext2(); if (!gl) { return; @@ -203,7 +203,7 @@ describe('buffer tests', () => { tracker.addObjects(1); const data2 = new Float32Array(55); - gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buf2, 0, data2.byteLength); + gl.bindBufferRange(gl.TRANSFORM_FEEDBACK_BUFFER, 0, buf2, 0, data2.byteLength); gl.bufferData(gl.TRANSFORM_FEEDBACK_BUFFER, data2, gl.STATIC_DRAW); tracker.addMemory(data2.byteLength); diff --git a/test/tests/contextloss-tests.js b/test/tests/contextloss-tests.js index 6545762..656f280 100644 --- a/test/tests/contextloss-tests.js +++ b/test/tests/contextloss-tests.js @@ -1,4 +1,4 @@ -import assert, { assertEqual, assertFalsy } from '../assert.js'; +import { assertEqual, assertFalsy } from '../assert.js'; import {describe, it} from '../mocha-support.js'; import {createContext} from '../webgl.js'; import {MemInfoTracker} from './test-utils.js'; @@ -25,7 +25,7 @@ describe('webgl context lost tests', () => { e.preventDefault(); contextLostExposedPromise.resolve(); }; - const handleContextRestored = _ => { + const handleContextRestored = () => { contextRestoredExposedPromise.resolve(); }; @@ -106,12 +106,12 @@ describe('webgl context lost tests', () => { assertEqual(memExt.getMemoryInfo().resources.vertexArray, 1); } - it('test context loss', async () => { + it('test context loss', async() => { const {gl} = createContext(); await testContextLost(gl); }); - it('test context loss OffscreenCanvas', async () => { + it('test context loss OffscreenCanvas', async() => { if (typeof OffscreenCanvas === 'undefined') { return; } diff --git a/test/tests/info-tests.js b/test/tests/info-tests.js index 3c7212a..a1b9382 100644 --- a/test/tests/info-tests.js +++ b/test/tests/info-tests.js @@ -1,5 +1,5 @@ import { computeDrawingbufferSize, getDrawingbufferInfo } from '../../src/utils.js'; -import assert, {assertEqual, assertNotEqual, assertTruthy} from '../assert.js'; +import {assertEqual, assertNotEqual, assertTruthy} from '../assert.js'; import {describe, it} from '../mocha-support.js'; import {createContext, createContext2} from '../webgl.js'; @@ -87,7 +87,7 @@ describe('info tests', () => { const {memory} = info; assertEqual(memory.drawingbuffer, newDrawingbufferSize); assertEqual(memory.total, newDrawingbufferSize); - assertNotEqual(drawingbufferSize, newDrawingbufferSize) + assertNotEqual(drawingbufferSize, newDrawingbufferSize); } }); diff --git a/test/tests/renderbuffer-tests.js b/test/tests/renderbuffer-tests.js index aac5139..f2417ae 100644 --- a/test/tests/renderbuffer-tests.js +++ b/test/tests/renderbuffer-tests.js @@ -1,5 +1,3 @@ -import * as twgl from '../js/twgl-full.module.js'; -import {assertThrowsWith} from '../assert.js'; import {describe, it} from '../mocha-support.js'; import {createContext, createContext2} from '../webgl.js'; import {MemInfoTracker} from './test-utils.js'; diff --git a/test/tests/test-utils.js b/test/tests/test-utils.js index b5107c8..a3253d2 100644 --- a/test/tests/test-utils.js +++ b/test/tests/test-utils.js @@ -35,4 +35,4 @@ export class MemInfoTracker { this.numObjects -= deltaObjects; this.check(); } -}; +} diff --git a/test/tests/texture-tests.js b/test/tests/texture-tests.js index 5595829..3ce3bd7 100644 --- a/test/tests/texture-tests.js +++ b/test/tests/texture-tests.js @@ -1,4 +1,3 @@ -import {assertThrowsWith} from '../assert.js'; import {describe, it} from '../mocha-support.js'; import {createContext, createContext2} from '../webgl.js'; import {MemInfoTracker} from './test-utils.js'; @@ -259,7 +258,7 @@ describe('tex-image tests', () => { const texSize = 4 * ( 16 * 8 + // level1 8 * 4 + // level2 - 4 * 2) // level3 + 4 * 2); // level3 tracker.addMemory(texSize - mip1Size); gl.deleteTexture(tex1); diff --git a/test/webgl.js b/test/webgl.js index 4e5e5d2..3f5ba04 100644 --- a/test/webgl.js +++ b/test/webgl.js @@ -1,4 +1,3 @@ -/* global document */ import { computeDrawingbufferSize, getDrawingbufferInfo,