refactor: use vite-plugin-wext-manifest plugin

This commit is contained in:
Abhijith Vijayan [FLUXON] 2025-06-24 04:41:38 +05:30
parent 78b2ed7ca7
commit ade445103d
5 changed files with 44 additions and 283 deletions

131
package-lock.json generated
View File

@ -10,15 +10,13 @@
"license": "MIT",
"dependencies": {
"advanced-css-reset": "2.1.3",
"find-up-simple": "1.0.1",
"load-json-file": "7.0.1",
"react": "19.1.0",
"react-dom": "19.1.0",
"read-pkg": "9.0.1",
"vite-plugin-wext-manifest": "^1.0.0",
"webextension-polyfill": "0.12.0"
},
"devDependencies": {
"@abhijithvijayan/tsconfig": "1.3.0",
"@abhijithvijayan/tsconfig": "^1.4.0",
"@types/react": "19.1.8",
"@types/react-dom": "19.1.6",
"@types/webextension-polyfill": "0.12.3",
@ -38,13 +36,13 @@
}
},
"node_modules/@abhijithvijayan/tsconfig": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@abhijithvijayan/tsconfig/-/tsconfig-1.3.0.tgz",
"integrity": "sha512-hE16KPLQdygY07f50Lnb4QS2XvUV1anoCNQxsr3rNW2iOAJ/JUhAqIpYqbX6z6UK44ErYHtwUOeW9lOCDjucAQ==",
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/@abhijithvijayan/tsconfig/-/tsconfig-1.4.0.tgz",
"integrity": "sha512-ymwC8mlDhWcZ1xZh+4z8AhdDotx2W+khq9n3D2ZOTP/Eyh1jxlrz0bog6tbGzKvTafWM6UZIF/UNgw1WWUsPVg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10.0.0"
"node": ">=18"
}
},
"node_modules/@ampproject/remapping": {
@ -338,7 +336,6 @@
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -355,7 +352,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -372,7 +368,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -389,7 +384,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -406,7 +400,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -423,7 +416,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -440,7 +432,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -457,7 +448,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -474,7 +464,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -491,7 +480,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -508,7 +496,6 @@
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -525,7 +512,6 @@
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -542,7 +528,6 @@
"cpu": [
"mips64el"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -559,7 +544,6 @@
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -576,7 +560,6 @@
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -593,7 +576,6 @@
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -610,7 +592,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -627,7 +608,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -644,7 +624,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -661,7 +640,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -678,7 +656,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -695,7 +672,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -712,7 +688,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -729,7 +704,6 @@
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -746,7 +720,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -813,7 +786,6 @@
"version": "2.5.1",
"resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz",
"integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
@ -853,7 +825,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -874,7 +845,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -895,7 +865,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -916,7 +885,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -937,7 +905,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -958,7 +925,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -979,7 +945,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1000,7 +965,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1021,7 +985,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1042,7 +1005,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1063,7 +1025,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1084,7 +1045,6 @@
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1105,7 +1065,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1169,7 +1128,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1183,7 +1141,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1197,7 +1154,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1211,7 +1167,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1225,7 +1180,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1239,7 +1193,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1253,7 +1206,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1267,7 +1219,6 @@
"cpu": [
"arm"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1281,7 +1232,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1295,7 +1245,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1309,7 +1258,6 @@
"cpu": [
"loong64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1323,7 +1271,6 @@
"cpu": [
"ppc64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1337,7 +1284,6 @@
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1351,7 +1297,6 @@
"cpu": [
"riscv64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1365,7 +1310,6 @@
"cpu": [
"s390x"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1379,7 +1323,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1393,7 +1336,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1407,7 +1349,6 @@
"cpu": [
"arm64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1421,7 +1362,6 @@
"cpu": [
"ia32"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1435,7 +1375,6 @@
"cpu": [
"x64"
],
"dev": true,
"license": "MIT",
"optional": true,
"os": [
@ -1491,7 +1430,6 @@
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/normalize-package-data": {
@ -1612,7 +1550,6 @@
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -1680,7 +1617,7 @@
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
"integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"readdirp": "^4.0.1"
@ -1769,7 +1706,6 @@
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==",
"dev": true,
"license": "Apache-2.0",
"optional": true,
"bin": {
@ -1790,7 +1726,6 @@
"version": "0.25.5",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz",
"integrity": "sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"bin": {
@ -1848,7 +1783,6 @@
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -1888,7 +1822,6 @@
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
@ -1948,7 +1881,7 @@
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/immutable/-/immutable-5.1.3.tgz",
"integrity": "sha512-+chQdDfvscSF1SJqv2gn4SRO2ZyS3xL3r7IW/wWEEzrzLisnOlKiQu5ytC/BVNcS15C39WT2Hg/bjKjDMcu+zg==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/index-to-position": {
@ -1974,7 +1907,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
@ -1985,7 +1917,6 @@
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -1999,7 +1930,6 @@
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
@ -2101,7 +2031,6 @@
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -2123,7 +2052,6 @@
"version": "3.3.11",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz",
"integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==",
"dev": true,
"funding": [
{
"type": "github",
@ -2142,7 +2070,6 @@
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz",
"integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==",
"dev": true,
"license": "MIT",
"optional": true
},
@ -2276,7 +2203,6 @@
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
@ -2290,7 +2216,6 @@
"version": "8.5.6",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz",
"integrity": "sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg==",
"dev": true,
"funding": [
{
"type": "opencollective",
@ -2399,7 +2324,7 @@
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
"dev": true,
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">= 14.18.0"
@ -2413,7 +2338,6 @@
"version": "4.44.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.44.0.tgz",
"integrity": "sha512-qHcdEzLCiktQIfwBq420pn2dP+30uzqYxv9ETm91wdt2R9AFcWfjNAmje4NWlnCIQ5RMTzVf0ZyisOKqHR6RwA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "1.0.8"
@ -2460,7 +2384,7 @@
"version": "1.89.2",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.89.2.tgz",
"integrity": "sha512-xCmtksBKd/jdJ9Bt9p7nPKiuqrlBMBuuGkQlkhZjjQk3Ty48lv93k5Dq6OPkKt4XwxDJ7tvlfrTa1MPA9bf+QA==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"chokidar": "^4.0.0",
@ -2527,7 +2451,6 @@
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
@ -2602,7 +2525,6 @@
"version": "0.2.14",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz",
"integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"fdir": "^6.4.4",
@ -2619,7 +2541,6 @@
"version": "6.4.6",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz",
"integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"picomatch": "^3 || ^4"
@ -2634,7 +2555,6 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
@ -2647,7 +2567,6 @@
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
@ -2747,7 +2666,6 @@
"version": "6.3.5",
"resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz",
"integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"esbuild": "^0.25.0",
@ -2904,6 +2822,24 @@
"vite": "^6.1.0"
}
},
"node_modules/vite-plugin-wext-manifest": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/vite-plugin-wext-manifest/-/vite-plugin-wext-manifest-1.0.0.tgz",
"integrity": "sha512-qtI7DWsvG8KN5mC5Vl1nO3Uitv4XWHEsMC3JSTzLYIOmbUuNdfoaEbooeD2wtRqIX378b/itJc/MYwXP0sMF9A==",
"license": "MIT",
"dependencies": {
"find-up-simple": "^1.0.1",
"load-json-file": "^7.0.1",
"read-pkg": "^9.0.1",
"wext-manifest-transformer": "^1.1.1"
},
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"vite": "^6.3.5"
}
},
"node_modules/vite-plugin-zip-pack": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/vite-plugin-zip-pack/-/vite-plugin-zip-pack-1.2.4.tgz",
@ -2921,7 +2857,6 @@
"version": "6.4.6",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.6.tgz",
"integrity": "sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"picomatch": "^3 || ^4"
@ -2936,7 +2871,6 @@
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
@ -2958,6 +2892,15 @@
"integrity": "sha512-97TBmpoWJEE+3nFBQ4VocyCdLKfw54rFaJ6EVQYLBCXqCIpLSZkwGgASpv4oPt9gdKCJ80RJlcmNzNn008Ag6Q==",
"license": "MPL-2.0"
},
"node_modules/wext-manifest-transformer": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/wext-manifest-transformer/-/wext-manifest-transformer-1.1.1.tgz",
"integrity": "sha512-GcoyZhpo+LeNuwdZlhBu21zLmtNoZRd8NYVzM8+SXlrses2c4ZOyUZC8YVjTY11onjw317KOU3XLIISPi0MtCA==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",

View File

@ -25,15 +25,13 @@
},
"dependencies": {
"advanced-css-reset": "2.1.3",
"find-up-simple": "1.0.1",
"load-json-file": "7.0.1",
"react": "19.1.0",
"react-dom": "19.1.0",
"read-pkg": "9.0.1",
"vite-plugin-wext-manifest": "^1.0.0",
"webextension-polyfill": "0.12.0"
},
"devDependencies": {
"@abhijithvijayan/tsconfig": "1.3.0",
"@abhijithvijayan/tsconfig": "^1.4.0",
"@types/react": "19.1.8",
"@types/react-dom": "19.1.6",
"@types/webextension-polyfill": "0.12.3",

View File

@ -2,7 +2,9 @@
"extends": "@abhijithvijayan/tsconfig",
"compilerOptions": {
"target": "es5", // ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'.
"module": "esnext", // Module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.
"module": "preserve",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"lib": [
"dom",
"dom.iterable",

View File

@ -1,181 +0,0 @@
import { Plugin, ResolvedConfig } from 'vite';
import path from 'node:path';
import {findUp} from 'find-up-simple';
import {readPackage} from 'read-pkg';
import {loadJsonFile} from 'load-json-file';
export const PLUGIN_NAME = 'vite-plugin-wext-manifest';
export const ENVKeys = {
DEV: 'dev',
PROD: 'prod',
} as const;
export const Browser = {
CHROME: 'chrome',
FIREFOX: 'firefox',
EDGE: 'edge',
BRAVE: 'brave',
OPERA: 'opera',
VIVALDI: 'vivaldi',
ARC: 'arc',
YANDEX: 'yandex',
} as const;
export type BrowserType = (typeof Browser)[keyof typeof Browser];
export const browserVendors: BrowserType[] = Object.values(Browser);
export const envVariables: string[] = [ENVKeys.DEV, ENVKeys.PROD];
// Refer: https://regex101.com/r/ddSEHh/1
export const CUSTOM_PREFIX_REGEX = new RegExp(
`^__((?:(?:${[...browserVendors, ...envVariables].join('|')})\\|?)+)__(.*)`
);
export const transformManifest = (
manifest: Record<string, string> | string | number | Awaited<ReturnType<typeof loadJsonFile>>,
selectedVendor: BrowserType,
nodeEnv: 'production' | 'development' | string
): any => {
if (Array.isArray(manifest)) {
return manifest.map((newManifest) => {
return transformManifest(newManifest, selectedVendor, nodeEnv);
});
}
if (typeof manifest === 'object') {
return Object.entries(manifest).reduce(
(newManifest: Record<string, string>, [key, value]) => {
// match with vendors regex
const vendorMatch: RegExpMatchArray | null =
key.match(CUSTOM_PREFIX_REGEX);
if (vendorMatch) {
// match[1] => 'opera|firefox|dev' => ['opera', 'firefox', 'dev']
const matches: string[] = vendorMatch[1].split('|');
const isProd: boolean = nodeEnv === 'production';
const hasCurrentVendor = matches.includes(selectedVendor);
const hasVendorKeys = matches.some((m) =>
browserVendors.includes(m as never)
);
const hasEnvKey = matches.some((m) =>
envVariables.includes(m as never)
);
const hasCurrentEnvKey =
hasEnvKey &&
// if production env key is found
((isProd && matches.includes(ENVKeys.PROD)) ||
// or if development env key is found
(!isProd && matches.includes(ENVKeys.DEV)));
// handles cases like
// 1. __dev__
// 2. __chrome__
// 3. __chrome|dev__
if (
// case: __chrome|dev__ (current vendor key and current env key)
(hasCurrentVendor && hasCurrentEnvKey) ||
// case: __dev__ (no vendor keys but current env key)
(!hasVendorKeys && hasCurrentEnvKey) ||
// case: __chrome__ (no env keys but current vendor key)
(!hasEnvKey && hasCurrentVendor)
) {
// Swap key with non prefixed name
// match[2] => will be the key
newManifest[vendorMatch[2]] = transformManifest(
value,
selectedVendor,
nodeEnv
);
}
} else {
newManifest[key] = transformManifest(value, selectedVendor, nodeEnv);
}
return newManifest;
},
{}
);
}
return manifest;
};
interface WextManifestOptions {
/**
* The path to the source manifest.json file, relative to the project root.
*/
manifestPath: string;
/**
* If true, updates manifest.json version field with package.json version. It is often useful for easy release of web-extension.
*/
usePackageJSONVersion?: boolean;
}
export default function vitePluginWextManifest(options: WextManifestOptions): Plugin {
let config: ResolvedConfig;
if (!options?.manifestPath) {
throw new Error(`${PLUGIN_NAME}: \`manifestPath\` option is required.`);
}
return {
name: PLUGIN_NAME,
configResolved(resolvedConfig) {
config = resolvedConfig;
},
async buildStart() {
const { mode, root } = config;
const targetBrowser = process.env.TARGET_BROWSER;
if (!targetBrowser) {
this.error('`TARGET_BROWSER` environment variable is not set.');
}
if (!browserVendors.includes(targetBrowser)) {
this.error(`Browser "${targetBrowser}" is not supported.`);
}
try {
const sourceManifestPath = path.resolve(root, options.manifestPath);
this.addWatchFile(sourceManifestPath);
// Read and parse manifest.json file
const manifestInput = await loadJsonFile(sourceManifestPath);
// 1. Transform the manifest
const transformed = transformManifest(manifestInput, targetBrowser, mode);
// 2. Inject version from package.json if option is enabled
const usePackageJSONVersion = !!options.usePackageJSONVersion;
if (usePackageJSONVersion) {
try {
// find the closest package.json file
const packageJsonPath = await findUp('package.json');
if (!packageJsonPath) {
throw new Error("Couldn't find a closest package.json")
}
this.addWatchFile(packageJsonPath);
const packageJson = await readPackage({...options, cwd: path.dirname(packageJsonPath)})
if (!!transformed.version) {
transformed.version = packageJson.version.replace('-beta.', '.'); // eg: replaces `2.0.0-beta.1` to `2.0.0.1`
}
} catch (err) {
this.error(`Failed to process package.json: ${err.message}`);
}
}
// 3. Emit the final manifest file
this.emitFile({
type: 'asset',
fileName: 'manifest.json',
source: JSON.stringify(transformed, null, 2),
});
} catch (err) {
this.error(`Failed to process manifest.json: ${err.message}`);
}
},
};
}

View File

@ -5,8 +5,7 @@ import process from "node:process";
import zipPack from "vite-plugin-zip-pack";
import checker from 'vite-plugin-checker';
import clean from 'vite-plugin-clean';
import vitePluginWextManifest from "./vite-plugin-wext-manifest";
import WextManifest from "vite-plugin-wext-manifest";
export default defineConfig(({ mode }) => {
const isDevelopment = mode !== "production";
@ -67,7 +66,7 @@ export default defineConfig(({ mode }) => {
}),
// Generate manifest.json for the browser
vitePluginWextManifest({
WextManifest({
manifestPath: "manifest.json",
usePackageJSONVersion: true,
}),