diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..53c37a1 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..c1eabe0 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,12 @@ +{ + "env": { + "browser": true, + "worker": true, + "serviceworker": true, + "es6": true, + "node": true + }, + "globals": { "globalThis": true, "importScripts": true }, + "parserOptions": { "sourceType": "module", "ecmaVersion": "latest" }, + "extends": ["eslint:recommended"] +} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..53c37a1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1be4139..83dab4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "devDependencies": { "copy-webpack-plugin": "^11.0.0", "cross-env": "^7.0.3", - "eslint": "^8.8.0", + "eslint": "^8.28.0", "prettier": "^2.7.1", "terser-webpack-plugin": "^5.3.6", "webpack": "^5.74.0", @@ -39,9 +39,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz", - "integrity": "sha512-OhSY22oQQdw3zgPOOwdoj01l/Dzl1Z+xyUP33tkSN+aqyEhymJCcPHyXt+ylW8FSe0TfRC2VG+ROQOapD0aZSQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", + "integrity": "sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -62,29 +62,19 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz", - "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==", + "version": "0.11.7", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.7.tgz", + "integrity": "sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw==", "dev": true, "dependencies": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.4" + "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" } }, - "node_modules/@humanwhocodes/gitignore-to-minimatch": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", - "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", - "dev": true, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/nzakas" - } - }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -557,15 +547,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "node_modules/array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -987,15 +968,15 @@ } }, "node_modules/eslint": { - "version": "8.23.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.0.tgz", - "integrity": "sha512-pBG/XOn0MsJcKcTRLr27S5HpzQo4kLr+HjLQIyK4EiCsijDl/TB+h5uEuJU6bQ8Edvwz1XWOjpaP2qgnXGpTcA==", + "version": "8.28.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.28.0.tgz", + "integrity": "sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^1.3.1", - "@humanwhocodes/config-array": "^0.10.4", - "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@eslint/eslintrc": "^1.3.3", + "@humanwhocodes/config-array": "^0.11.6", "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -1011,15 +992,15 @@ "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "find-up": "^5.0.0", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", + "glob-parent": "^6.0.2", "globals": "^13.15.0", - "globby": "^11.1.0", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", @@ -1100,9 +1081,9 @@ } }, "node_modules/espree": { - "version": "9.4.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", - "integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==", + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", + "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", "dev": true, "dependencies": { "acorn": "^8.8.0", @@ -1301,12 +1282,6 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", - "dev": true - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -1346,9 +1321,9 @@ "dev": true }, "node_modules/globals": { - "version": "13.17.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", - "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", + "version": "13.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz", + "integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1360,26 +1335,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "dependencies": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/graceful-fs": { "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", @@ -1538,6 +1493,15 @@ "node": ">=0.12.0" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -1594,6 +1558,16 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/js-sdsl": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/js-sdsl" + } + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -2263,15 +2237,6 @@ "node": ">=8" } }, - "node_modules/slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -2708,9 +2673,9 @@ "dev": true }, "@eslint/eslintrc": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.1.tgz", - "integrity": "sha512-OhSY22oQQdw3zgPOOwdoj01l/Dzl1Z+xyUP33tkSN+aqyEhymJCcPHyXt+ylW8FSe0TfRC2VG+ROQOapD0aZSQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.3.3.tgz", + "integrity": "sha512-uj3pT6Mg+3t39fvLrj8iuCIJ38zKO9FpGtJ4BBJebJhEwjoT+KLVNCcHT5QC9NGRIEi7fZ0ZR8YRb884auB4Lg==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -2725,22 +2690,16 @@ } }, "@humanwhocodes/config-array": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.10.4.tgz", - "integrity": "sha512-mXAIHxZT3Vcpg83opl1wGlVZ9xydbfZO3r5YfRSH6Gpp2J/PfdBP0wbDa2sO6/qRbcalpoevVyW6A/fI6LfeMw==", + "version": "0.11.7", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.7.tgz", + "integrity": "sha512-kBbPWzN8oVMLb0hOUYXhmxggL/1cJE6ydvjDIGi9EnAGUyA7cLVKQg+d/Dsm+KZwx2czGHrCmMVLiyg8s5JPKw==", "dev": true, "requires": { "@humanwhocodes/object-schema": "^1.2.1", "debug": "^4.1.1", - "minimatch": "^3.0.4" + "minimatch": "^3.0.5" } }, - "@humanwhocodes/gitignore-to-minimatch": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/gitignore-to-minimatch/-/gitignore-to-minimatch-1.0.2.tgz", - "integrity": "sha512-rSqmMJDdLFUsyxR6FMtD00nfQKKLFb1kv+qBbOVKqErvloEIJLo5bDTJTQNTYgeyp78JsA7u/NPi5jT1GR/MuA==", - "dev": true - }, "@humanwhocodes/module-importer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", @@ -3140,12 +3099,6 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "array-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", - "dev": true - }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -3438,15 +3391,15 @@ "dev": true }, "eslint": { - "version": "8.23.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.23.0.tgz", - "integrity": "sha512-pBG/XOn0MsJcKcTRLr27S5HpzQo4kLr+HjLQIyK4EiCsijDl/TB+h5uEuJU6bQ8Edvwz1XWOjpaP2qgnXGpTcA==", + "version": "8.28.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.28.0.tgz", + "integrity": "sha512-S27Di+EVyMxcHiwDrFzk8dJYAaD+/5SoWKxL1ri/71CRHsnJnRDPNt2Kzj24+MT9FDupf4aqqyqPrvI8MvQ4VQ==", "dev": true, "requires": { - "@eslint/eslintrc": "^1.3.1", - "@humanwhocodes/config-array": "^0.10.4", - "@humanwhocodes/gitignore-to-minimatch": "^1.0.2", + "@eslint/eslintrc": "^1.3.3", + "@humanwhocodes/config-array": "^0.11.6", "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -3462,15 +3415,15 @@ "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", "find-up": "^5.0.0", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", + "glob-parent": "^6.0.2", "globals": "^13.15.0", - "globby": "^11.1.0", "grapheme-splitter": "^1.0.4", "ignore": "^5.2.0", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", + "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", @@ -3526,9 +3479,9 @@ } }, "espree": { - "version": "9.4.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.0.tgz", - "integrity": "sha512-DQmnRpLj7f6TgN/NYb0MTzJXL+vJF9h3pHy4JhCIs3zwcgez8xmGg3sXHcEO97BrmO2OSvCwMdfdlyl+E9KjOw==", + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", + "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", "dev": true, "requires": { "acorn": "^8.8.0", @@ -3684,12 +3637,6 @@ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", - "dev": true - }, "glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -3720,28 +3667,14 @@ "dev": true }, "globals": { - "version": "13.17.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.17.0.tgz", - "integrity": "sha512-1C+6nQRb1GwGMKm2dH/E7enFAMxGTmGI7/dEdhy/DNelv85w9B72t3uc5frtMNXIbzrarJJ/lTCjcaZwbLJmyw==", + "version": "13.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.18.0.tgz", + "integrity": "sha512-/mR4KI8Ps2spmoc0Ulu9L7agOF0du1CZNQ3dke8yItYlyKNmGrkONemBbd6V8UTc1Wgcqn21t3WYB7dbRmh6/A==", "dev": true, "requires": { "type-fest": "^0.20.2" } }, - "globby": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", - "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", - "dev": true, - "requires": { - "array-union": "^2.1.0", - "dir-glob": "^3.0.1", - "fast-glob": "^3.2.9", - "ignore": "^5.2.0", - "merge2": "^1.4.1", - "slash": "^3.0.0" - } - }, "graceful-fs": { "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", @@ -3858,6 +3791,12 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -3901,6 +3840,12 @@ } } }, + "js-sdsl": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", + "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", + "dev": true + }, "js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -4368,12 +4313,6 @@ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", diff --git a/package.json b/package.json index 10cf500..dc1a7ca 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "devDependencies": { "copy-webpack-plugin": "^11.0.0", "cross-env": "^7.0.3", - "eslint": "^8.8.0", + "eslint": "^8.28.0", "prettier": "^2.7.1", "terser-webpack-plugin": "^5.3.6", "webpack": "^5.74.0", diff --git a/src/client/dom/document.js b/src/client/dom/document.js index d9974ee..6c09c99 100644 --- a/src/client/dom/document.js +++ b/src/client/dom/document.js @@ -193,21 +193,6 @@ class DocumentHook extends EventEmitter { }, }); } - overrideReferrer() { - this.ctx.overrideDescriptor(this.docProto, 'referrer', { - get: (target, that) => { - const event = new HookEvent( - { value: target.call(that) }, - target, - that - ); - this.emit('referrer', event); - - if (event.intercepted) return event.returnValue; - return event.data.value; - }, - }); - } overrideCookie() { this.ctx.overrideDescriptor(this.docProto, 'cookie', { get: (target, that) => { diff --git a/src/client/dom/element.js b/src/client/dom/element.js index c33c98e..f366080 100644 --- a/src/client/dom/element.js +++ b/src/client/dom/element.js @@ -204,7 +204,7 @@ class ElementApi extends EventEmitter { ); } hookProperty(element, prop, handler) { - if (!element || !prop in element) return false; + if (!element || !(prop in element)) return false; if (this.ctx.nativeMethods.isArray(element)) { for (const elem of element) { diff --git a/src/client/index.js b/src/client/index.js index 8c26906..76f29cf 100644 --- a/src/client/index.js +++ b/src/client/index.js @@ -68,7 +68,7 @@ class UVClient extends EventEmitter { ); } override(obj, prop, wrapper, construct) { - if (!prop in obj) return false; + if (!(prop in obj)) return false; const wrapped = this.wrap(obj, prop, wrapper, construct); return (obj[prop] = wrapped); } @@ -92,7 +92,7 @@ class UVClient extends EventEmitter { }, }.attach; - if (!!construct) { + if (construct) { wrapped.prototype = fn.prototype; wrapped.prototype.constructor = wrapped; } diff --git a/src/client/location.js b/src/client/location.js index d7483e3..01451bc 100644 --- a/src/client/location.js +++ b/src/client/location.js @@ -37,7 +37,7 @@ class LocationApi extends EventEmitter { for (const key of this.keys) { this.ctx.overrideDescriptor(this.workerLocProto, key, { - get: (target, that) => { + get: () => { return parse(uv.href.get.call(this.location))[key]; }, }); @@ -78,9 +78,12 @@ class LocationApi extends EventEmitter { ); break; default: - const url = new URL(emulation.href); - url[key] = val; - that.location.href = wrap(url.href); + { + const url = new URL(emulation.href); + url[key] = val; + that.location.href = wrap(url.href); + } + break; } } : undefined, diff --git a/src/rewrite/cookie.js b/src/rewrite/cookie.js index f63a49d..7666bca 100644 --- a/src/rewrite/cookie.js +++ b/src/rewrite/cookie.js @@ -21,7 +21,7 @@ function validateCookie(cookie, meta, js = false) { async function db(openDB) { const db = await openDB('__op', 1, { - upgrade(db, oldVersion, newVersion, transaction) { + upgrade(db) { const store = db.createObjectStore('cookies', { keyPath: 'id', }); diff --git a/src/rewrite/html.js b/src/rewrite/html.js index 183cf42..3c86153 100644 --- a/src/rewrite/html.js +++ b/src/rewrite/html.js @@ -176,7 +176,7 @@ class P5Element extends EventEmitter { if (this.stream) return null; let str = ''; - iterate(this.node, (node) => { + this.iterate(this.node, (node) => { if (node.nodeName === '#text') str += node.value; }); diff --git a/src/rewrite/parsel.js b/src/rewrite/parsel.js index 9eff61c..01de2b4 100644 --- a/src/rewrite/parsel.js +++ b/src/rewrite/parsel.js @@ -365,7 +365,7 @@ export default (function (exports) { * Calculate specificity of a selector. * If the selector is a list, the max specificity is returned. */ - function specificity(selector, { format = 'array' } = {}) { + function specificity(selector) { let ast = typeof selector === 'object' ? selector diff --git a/src/rewrite/rewrite.html.js b/src/rewrite/rewrite.html.js index 24bcc1f..d1f33c6 100644 --- a/src/rewrite/rewrite.html.js +++ b/src/rewrite/rewrite.html.js @@ -1,5 +1,5 @@ function attributes(ctx, meta = ctx.meta) { - const { html, js, css, attributePrefix, handlerScript, bundleScript } = ctx; + const { html, js, attributePrefix } = ctx; const origPrefix = attributePrefix + '-attr-'; html.on('attr', (attr, type) => { @@ -68,8 +68,8 @@ function attributes(ctx, meta = ctx.meta) { }); } -function text(ctx, meta = ctx.meta) { - const { html, js, css, attributePrefix } = ctx; +function text(ctx) { + const { html, js, css } = ctx; html.on('text', (text, type) => { if (text.element.tagName === 'script') { @@ -181,8 +181,7 @@ function isEvent(name) { } function injectHead(ctx) { - const { html, js, css, attributePrefix } = ctx; - const origPrefix = attributePrefix + '-attr-'; + const { html } = ctx; html.on('element', (element, type) => { if (type !== 'rewrite') return false; if (element.tagName !== 'head') return false; diff --git a/src/rewrite/rewrite.script.js b/src/rewrite/rewrite.script.js index fb27c9c..699c162 100644 --- a/src/rewrite/rewrite.script.js +++ b/src/rewrite/rewrite.script.js @@ -261,54 +261,61 @@ function unwrap(ctx) { switch (node.callee.property.name) { case '$wrap': - if ( - !node.arguments || - node.parent.type !== Syntax.MemberExpression || - node.parent.property !== node - ) - return false; - const [property] = node.arguments; + { + if ( + !node.arguments || + node.parent.type !== Syntax.MemberExpression || + node.parent.property !== node + ) + return false; + const [property] = node.arguments; - data.changes.push({ - start: node.callee.start, - end: property.start, - }); - - node.iterateEnd = function () { data.changes.push({ - start: node.end - 2, - end: node.end, + start: node.callee.start, + end: property.start, }); - }; + + node.iterateEnd = function () { + data.changes.push({ + start: node.end - 2, + end: node.end, + }); + }; + } break; case '$get': case 'rewriteUrl': - const [arg] = node.arguments; + { + const [arg] = node.arguments; - data.changes.push({ - start: node.callee.start, - end: arg.start, - }); - - node.iterateEnd = function () { data.changes.push({ - start: node.end - 1, - end: node.end, + start: node.callee.start, + end: arg.start, }); - }; + + node.iterateEnd = function () { + data.changes.push({ + start: node.end - 1, + end: node.end, + }); + }; + } break; case 'rewrite': - const [script] = node.arguments; - data.changes.push({ - start: node.callee.start, - end: script.start, - }); - node.iterateEnd = function () { + { + const [script] = node.arguments; data.changes.push({ - start: node.end - 1, - end: node.end, + start: node.callee.start, + end: script.start, }); - }; + node.iterateEnd = function () { + data.changes.push({ + start: node.end - 1, + end: node.end, + }); + }; + } + break; } }); } diff --git a/src/sw.js b/src/sw.js index 647e3e3..4e397e3 100644 --- a/src/sw.js +++ b/src/sw.js @@ -1,3 +1,4 @@ +/*global UVServiceWorker*/ importScripts('/uv.bundle.js'); importScripts('/uv.config.js'); importScripts('/uv.sw.js'); diff --git a/src/uv.config.js b/src/uv.config.js index 6627583..dcf2c4a 100644 --- a/src/uv.config.js +++ b/src/uv.config.js @@ -1,3 +1,4 @@ +/*global Ultraviolet*/ self.__uv$config = { prefix: '/service/', bare: 'https://incog.dev/bare/', diff --git a/src/uv.handler.js b/src/uv.handler.js index 97fc092..1cf919a 100644 --- a/src/uv.handler.js +++ b/src/uv.handler.js @@ -481,7 +481,7 @@ function __uvHook(window, config = {}, bare = '/bare/') { }); client.overrideDescriptor(window, 'origin', { - get: (target, that) => { + get: () => { return __uv.location.origin; }, }); @@ -1318,20 +1318,13 @@ function __uvHook(window, config = {}, bare = '/bare/') { }); // Proper hash emulation. - if (!!window.window) { - __uv.addEventListener.call(window, 'hashchange', (event) => { - if (event.__uv$dispatched) return false; - event.stopImmediatePropagation(); - const hash = window.location.hash; - client.history.replaceState.call( - window.history, - '', - '', - event.oldURL - ); - __uv.location.hash = hash; - }); - } + __uv.addEventListener.call(window, 'hashchange', (event) => { + if (event.__uv$dispatched) return false; + event.stopImmediatePropagation(); + const hash = window.location.hash; + client.history.replaceState.call(window.history, '', '', event.oldURL); + __uv.location.hash = hash; + }); client.location.on('hashchange', (oldUrl, newUrl, ctx) => { if (ctx.HashChangeEvent && client.history.replaceState) { diff --git a/src/uv.sw.js b/src/uv.sw.js index 2ea1a6e..7a90ef2 100644 --- a/src/uv.sw.js +++ b/src/uv.sw.js @@ -1,3 +1,4 @@ +/*globals __uv$config*/ // Users must import the config (and bundle) prior to importing uv.sw.js // This is to allow us to produce a generic bundle with no hard-coded paths. @@ -29,7 +30,6 @@ const cspHeaders = [ 'x-xss-protection', ]; const emptyMethods = ['GET', 'HEAD']; -const emptyStatus = [204, 304]; class UVServiceWorker extends Ultraviolet.EventEmitter { constructor(config = __uv$config) { diff --git a/webpack.config.js b/webpack.config.js index d39bd07..4a1b8da 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,3 @@ -import webpack from 'webpack'; import { fileURLToPath } from 'url'; import TerserPlugin from 'terser-webpack-plugin'; import CopyPlugin from 'copy-webpack-plugin';