diff --git a/package-lock.json b/package-lock.json
index 8b5156a..43bcf88 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10062,10 +10062,11 @@
}
},
"node_modules/tslib": {
- "version": "2.3.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
- "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
- "dev": true
+ "version": "2.8.1",
+ "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
+ "dev": true,
+ "license": "0BSD"
},
"node_modules/type-check": {
"version": "0.4.0",
@@ -18609,9 +18610,9 @@
}
},
"tslib": {
- "version": "2.3.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
- "integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
+ "version": "2.8.1",
+ "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"dev": true
},
"type-check": {
diff --git a/plugin/package-lock.json b/plugin/package-lock.json
index e3684c3..3d9e6c1 100644
--- a/plugin/package-lock.json
+++ b/plugin/package-lock.json
@@ -9,9 +9,381 @@
"iconv-lite": "^0.6.3",
"lodash": "^4.17.21",
"ses": "^0.15.15",
+ "sharp": "^0.33.5",
"tree-kill": "^1.2.2"
}
},
+ "node_modules/@emnapi/runtime": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmmirror.com/@emnapi/runtime/-/runtime-1.3.1.tgz",
+ "integrity": "sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==",
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "tslib": "^2.4.0"
+ }
+ },
+ "node_modules/@img/sharp-darwin-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz",
+ "integrity": "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-arm64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-darwin-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.5.tgz",
+ "integrity": "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==",
+ "cpu": [
+ "x64"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-x64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.4.tgz",
+ "integrity": "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==",
+ "cpu": [
+ "arm64"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.4.tgz",
+ "integrity": "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==",
+ "cpu": [
+ "x64"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.5.tgz",
+ "integrity": "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==",
+ "cpu": [
+ "arm"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.4.tgz",
+ "integrity": "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==",
+ "cpu": [
+ "arm64"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-s390x": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.4.tgz",
+ "integrity": "sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==",
+ "cpu": [
+ "s390x"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.4.tgz",
+ "integrity": "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==",
+ "cpu": [
+ "x64"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.4.tgz",
+ "integrity": "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==",
+ "cpu": [
+ "arm64"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.4.tgz",
+ "integrity": "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==",
+ "cpu": [
+ "x64"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.5.tgz",
+ "integrity": "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==",
+ "cpu": [
+ "arm"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm": "1.0.5"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.5.tgz",
+ "integrity": "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==",
+ "cpu": [
+ "arm64"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-s390x": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.5.tgz",
+ "integrity": "sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==",
+ "cpu": [
+ "s390x"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-s390x": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.5.tgz",
+ "integrity": "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==",
+ "cpu": [
+ "x64"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-x64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linuxmusl-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.5.tgz",
+ "integrity": "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==",
+ "cpu": [
+ "arm64"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-arm64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linuxmusl-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.5.tgz",
+ "integrity": "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==",
+ "cpu": [
+ "x64"
+ ],
+ "license": "Apache-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-x64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-wasm32": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-wasm32/-/sharp-wasm32-0.33.5.tgz",
+ "integrity": "sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==",
+ "cpu": [
+ "wasm32"
+ ],
+ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
+ "optional": true,
+ "dependencies": {
+ "@emnapi/runtime": "^1.2.0"
+ },
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-win32-ia32": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.5.tgz",
+ "integrity": "sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==",
+ "cpu": [
+ "ia32"
+ ],
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-win32-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.5.tgz",
+ "integrity": "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==",
+ "cpu": [
+ "x64"
+ ],
+ "license": "Apache-2.0 AND LGPL-3.0-or-later",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
"node_modules/axios": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
@@ -20,6 +392,56 @@
"follow-redirects": "^1.14.4"
}
},
+ "node_modules/color": {
+ "version": "4.2.3",
+ "resolved": "https://registry.npmmirror.com/color/-/color-4.2.3.tgz",
+ "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==",
+ "license": "MIT",
+ "dependencies": {
+ "color-convert": "^2.0.1",
+ "color-string": "^1.9.0"
+ },
+ "engines": {
+ "node": ">=12.5.0"
+ }
+ },
+ "node_modules/color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "license": "MIT",
+ "dependencies": {
+ "color-name": "~1.1.4"
+ },
+ "engines": {
+ "node": ">=7.0.0"
+ }
+ },
+ "node_modules/color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
+ "license": "MIT"
+ },
+ "node_modules/color-string": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmmirror.com/color-string/-/color-string-1.9.1.tgz",
+ "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==",
+ "license": "MIT",
+ "dependencies": {
+ "color-name": "^1.0.0",
+ "simple-swizzle": "^0.2.2"
+ }
+ },
+ "node_modules/detect-libc": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-2.0.3.tgz",
+ "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==",
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/follow-redirects": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
@@ -50,6 +472,12 @@
"node": ">=0.10.0"
}
},
+ "node_modules/is-arrayish": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmmirror.com/is-arrayish/-/is-arrayish-0.3.2.tgz",
+ "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==",
+ "license": "MIT"
+ },
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
@@ -60,11 +488,71 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
+ "node_modules/semver": {
+ "version": "7.6.3",
+ "resolved": "https://registry.npmmirror.com/semver/-/semver-7.6.3.tgz",
+ "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
"node_modules/ses": {
"version": "0.15.15",
"resolved": "https://registry.npmmirror.com/ses/-/ses-0.15.15.tgz",
"integrity": "sha512-sJM4HRlM3VouA3RhRmS7wG5MRQPqZZnc6O4BvAefU7yeM+qp8EUfGAWQ9iB/X5cNh3+m5N9lC7DEpyxQ+E4D+w=="
},
+ "node_modules/sharp": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/sharp/-/sharp-0.33.5.tgz",
+ "integrity": "sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==",
+ "hasInstallScript": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "color": "^4.2.3",
+ "detect-libc": "^2.0.3",
+ "semver": "^7.6.3"
+ },
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-darwin-arm64": "0.33.5",
+ "@img/sharp-darwin-x64": "0.33.5",
+ "@img/sharp-libvips-darwin-arm64": "1.0.4",
+ "@img/sharp-libvips-darwin-x64": "1.0.4",
+ "@img/sharp-libvips-linux-arm": "1.0.5",
+ "@img/sharp-libvips-linux-arm64": "1.0.4",
+ "@img/sharp-libvips-linux-s390x": "1.0.4",
+ "@img/sharp-libvips-linux-x64": "1.0.4",
+ "@img/sharp-libvips-linuxmusl-arm64": "1.0.4",
+ "@img/sharp-libvips-linuxmusl-x64": "1.0.4",
+ "@img/sharp-linux-arm": "0.33.5",
+ "@img/sharp-linux-arm64": "0.33.5",
+ "@img/sharp-linux-s390x": "0.33.5",
+ "@img/sharp-linux-x64": "0.33.5",
+ "@img/sharp-linuxmusl-arm64": "0.33.5",
+ "@img/sharp-linuxmusl-x64": "0.33.5",
+ "@img/sharp-wasm32": "0.33.5",
+ "@img/sharp-win32-ia32": "0.33.5",
+ "@img/sharp-win32-x64": "0.33.5"
+ }
+ },
+ "node_modules/simple-swizzle": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmmirror.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
+ "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==",
+ "license": "MIT",
+ "dependencies": {
+ "is-arrayish": "^0.3.1"
+ }
+ },
"node_modules/tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/tree-kill/-/tree-kill-1.2.2.tgz",
@@ -72,9 +560,166 @@
"bin": {
"tree-kill": "cli.js"
}
+ },
+ "node_modules/tslib": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
+ "license": "0BSD",
+ "optional": true
}
},
"dependencies": {
+ "@emnapi/runtime": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmmirror.com/@emnapi/runtime/-/runtime-1.3.1.tgz",
+ "integrity": "sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==",
+ "optional": true,
+ "requires": {
+ "tslib": "^2.4.0"
+ }
+ },
+ "@img/sharp-darwin-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz",
+ "integrity": "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-darwin-arm64": "1.0.4"
+ }
+ },
+ "@img/sharp-darwin-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.5.tgz",
+ "integrity": "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-darwin-x64": "1.0.4"
+ }
+ },
+ "@img/sharp-libvips-darwin-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.4.tgz",
+ "integrity": "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==",
+ "optional": true
+ },
+ "@img/sharp-libvips-darwin-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.4.tgz",
+ "integrity": "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==",
+ "optional": true
+ },
+ "@img/sharp-libvips-linux-arm": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.5.tgz",
+ "integrity": "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==",
+ "optional": true
+ },
+ "@img/sharp-libvips-linux-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.4.tgz",
+ "integrity": "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==",
+ "optional": true
+ },
+ "@img/sharp-libvips-linux-s390x": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.4.tgz",
+ "integrity": "sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==",
+ "optional": true
+ },
+ "@img/sharp-libvips-linux-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.4.tgz",
+ "integrity": "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==",
+ "optional": true
+ },
+ "@img/sharp-libvips-linuxmusl-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.4.tgz",
+ "integrity": "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==",
+ "optional": true
+ },
+ "@img/sharp-libvips-linuxmusl-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.4.tgz",
+ "integrity": "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==",
+ "optional": true
+ },
+ "@img/sharp-linux-arm": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.5.tgz",
+ "integrity": "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-linux-arm": "1.0.5"
+ }
+ },
+ "@img/sharp-linux-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.5.tgz",
+ "integrity": "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-linux-arm64": "1.0.4"
+ }
+ },
+ "@img/sharp-linux-s390x": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.5.tgz",
+ "integrity": "sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-linux-s390x": "1.0.4"
+ }
+ },
+ "@img/sharp-linux-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.5.tgz",
+ "integrity": "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-linux-x64": "1.0.4"
+ }
+ },
+ "@img/sharp-linuxmusl-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.5.tgz",
+ "integrity": "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-linuxmusl-arm64": "1.0.4"
+ }
+ },
+ "@img/sharp-linuxmusl-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.5.tgz",
+ "integrity": "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==",
+ "optional": true,
+ "requires": {
+ "@img/sharp-libvips-linuxmusl-x64": "1.0.4"
+ }
+ },
+ "@img/sharp-wasm32": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-wasm32/-/sharp-wasm32-0.33.5.tgz",
+ "integrity": "sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==",
+ "optional": true,
+ "requires": {
+ "@emnapi/runtime": "^1.2.0"
+ }
+ },
+ "@img/sharp-win32-ia32": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.5.tgz",
+ "integrity": "sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==",
+ "optional": true
+ },
+ "@img/sharp-win32-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.5.tgz",
+ "integrity": "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==",
+ "optional": true
+ },
"axios": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.24.0.tgz",
@@ -83,6 +728,42 @@
"follow-redirects": "^1.14.4"
}
},
+ "color": {
+ "version": "4.2.3",
+ "resolved": "https://registry.npmmirror.com/color/-/color-4.2.3.tgz",
+ "integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==",
+ "requires": {
+ "color-convert": "^2.0.1",
+ "color-string": "^1.9.0"
+ }
+ },
+ "color-convert": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
+ "requires": {
+ "color-name": "~1.1.4"
+ }
+ },
+ "color-name": {
+ "version": "1.1.4",
+ "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
+ },
+ "color-string": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmmirror.com/color-string/-/color-string-1.9.1.tgz",
+ "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==",
+ "requires": {
+ "color-name": "^1.0.0",
+ "simple-swizzle": "^0.2.2"
+ }
+ },
+ "detect-libc": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-2.0.3.tgz",
+ "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw=="
+ },
"follow-redirects": {
"version": "1.14.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz",
@@ -96,6 +777,11 @@
"safer-buffer": ">= 2.1.2 < 3.0.0"
}
},
+ "is-arrayish": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmmirror.com/is-arrayish/-/is-arrayish-0.3.2.tgz",
+ "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ=="
+ },
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
@@ -106,15 +792,63 @@
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
+ "semver": {
+ "version": "7.6.3",
+ "resolved": "https://registry.npmmirror.com/semver/-/semver-7.6.3.tgz",
+ "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A=="
+ },
"ses": {
"version": "0.15.15",
"resolved": "https://registry.npmmirror.com/ses/-/ses-0.15.15.tgz",
"integrity": "sha512-sJM4HRlM3VouA3RhRmS7wG5MRQPqZZnc6O4BvAefU7yeM+qp8EUfGAWQ9iB/X5cNh3+m5N9lC7DEpyxQ+E4D+w=="
},
+ "sharp": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmmirror.com/sharp/-/sharp-0.33.5.tgz",
+ "integrity": "sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==",
+ "requires": {
+ "@img/sharp-darwin-arm64": "0.33.5",
+ "@img/sharp-darwin-x64": "0.33.5",
+ "@img/sharp-libvips-darwin-arm64": "1.0.4",
+ "@img/sharp-libvips-darwin-x64": "1.0.4",
+ "@img/sharp-libvips-linux-arm": "1.0.5",
+ "@img/sharp-libvips-linux-arm64": "1.0.4",
+ "@img/sharp-libvips-linux-s390x": "1.0.4",
+ "@img/sharp-libvips-linux-x64": "1.0.4",
+ "@img/sharp-libvips-linuxmusl-arm64": "1.0.4",
+ "@img/sharp-libvips-linuxmusl-x64": "1.0.4",
+ "@img/sharp-linux-arm": "0.33.5",
+ "@img/sharp-linux-arm64": "0.33.5",
+ "@img/sharp-linux-s390x": "0.33.5",
+ "@img/sharp-linux-x64": "0.33.5",
+ "@img/sharp-linuxmusl-arm64": "0.33.5",
+ "@img/sharp-linuxmusl-x64": "0.33.5",
+ "@img/sharp-wasm32": "0.33.5",
+ "@img/sharp-win32-ia32": "0.33.5",
+ "@img/sharp-win32-x64": "0.33.5",
+ "color": "^4.2.3",
+ "detect-libc": "^2.0.3",
+ "semver": "^7.6.3"
+ }
+ },
+ "simple-swizzle": {
+ "version": "0.2.2",
+ "resolved": "https://registry.npmmirror.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
+ "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==",
+ "requires": {
+ "is-arrayish": "^0.3.1"
+ }
+ },
"tree-kill": {
"version": "1.2.2",
"resolved": "https://registry.npmmirror.com/tree-kill/-/tree-kill-1.2.2.tgz",
"integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A=="
+ },
+ "tslib": {
+ "version": "2.8.1",
+ "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
+ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
+ "optional": true
}
}
}
diff --git a/plugin/package.json b/plugin/package.json
index b867a2e..8ec873e 100644
--- a/plugin/package.json
+++ b/plugin/package.json
@@ -4,6 +4,7 @@
"iconv-lite": "^0.6.3",
"lodash": "^4.17.21",
"ses": "^0.15.15",
+ "sharp": "^0.33.5",
"tree-kill": "^1.2.2"
}
}
diff --git a/plugin/preload.js b/plugin/preload.js
index a61a00b..481d488 100644
--- a/plugin/preload.js
+++ b/plugin/preload.js
@@ -1,24 +1,25 @@
-utools.getAppVersion() < '2.6.1' && alert('请升级 uTools 至最新版本');
+utools.getAppVersion() < "2.6.1" && alert("请升级 uTools 至最新版本");
// -----------------------------------------------------------------
-const fs = require('fs');
-const os = require('os');
-const child_process = require("child_process")
-const iconv = require('iconv-lite')
-const electron = require('electron')
-const path = require("path")
-const axios = require('axios');
-const http = require('http');
-const url = require('url')
-const kill = require('tree-kill')
+const fs = require("fs");
+const os = require("os");
+const child_process = require("child_process");
+const iconv = require("iconv-lite");
+const electron = require("electron");
+const path = require("path");
+const axios = require("axios");
+const http = require("http");
+const url = require("url");
+const kill = require("tree-kill");
const crypto = require("crypto");
-require('ses')
+require("ses");
+const sharp = require("sharp");
const md5 = (input) => {
return crypto.createHash("md5").update(input, "utf8").digest("hex");
};
-window._ = require("lodash")
-window.getuToolsLite = require("./lib/utoolsLite")
+window._ = require("lodash");
+window.getuToolsLite = require("./lib/utoolsLite");
// window.yuQueClient = axios.create({
// baseURL: 'https://www.yuque.com/api/v2/',
// headers: {
@@ -40,29 +41,29 @@ window.getSharedQcById = async (id) => {
"verify-time": timeStamp,
},
});
- return JSON.stringify(data.data)
+ return JSON.stringify(data.data);
};
// 检测进程是否存在
-let isProcessExits = pid => {
- try {
- return process.kill(pid, 0)
- } catch (e) {
- return false
- }
-}
+let isProcessExits = (pid) => {
+ try {
+ return process.kill(pid, 0);
+ } catch (e) {
+ return false;
+ }
+};
window.isAppVersion4 = () => utools.getAppVersion() >= "4.0.0";
// 多开检测
window.multiProcessDetection = () => {
- let pids = JSON.parse(localStorage.getItem('processes')) || [];
- if (pids.length) pids = pids.filter(x => isProcessExits(x));
- pids.push(process.pid)
- localStorage.setItem('processes', JSON.stringify(pids))
- if (pids.length > 1) return true;
- return false;
-}
+ let pids = JSON.parse(localStorage.getItem("processes")) || [];
+ if (pids.length) pids = pids.filter((x) => isProcessExits(x));
+ pids.push(process.pid);
+ localStorage.setItem("processes", JSON.stringify(pids));
+ if (pids.length > 1) return true;
+ return false;
+};
// axios.defaults.adapter = require('axios/lib/adapters/http')
@@ -73,164 +74,172 @@ if (utools.isMacOS())
process.env.PATH = `/opt/homebrew/bin:/opt/homebrew/sbin:${process.env.PATH}`;
const shortCodes = [
+ (open = (path) => {
+ utools.shellOpenItem(path);
+ }),
+ (locate = (path) => {
+ utools.shellShowItemInFolder(path);
+ }),
+ (visit = (url) => {
+ utools.shellOpenExternal(url);
+ }),
+ (system = (cmd) => {
+ child_process.exec(cmd);
+ }),
+ (message = (msg) => {
+ utools.showNotification(msg);
+ }),
+ (keyTap = (key, ...modifier) => utools.simulateKeyboardTap(key, ...modifier)),
+ (copyTo = (text) => {
+ electron.clipboard.writeText(text);
+ }),
+ (send = (text) => {
+ copyTo(text);
+ quickcommand.simulatePaste();
+ }),
+];
- open = path => {
- utools.shellOpenItem(path)
- },
-
- locate = path => {
- utools.shellShowItemInFolder(path);
- },
-
- visit = url => {
- utools.shellOpenExternal(url);
- },
-
- system = cmd => {
- child_process.exec(cmd);
- },
-
- message = msg => {
- utools.showNotification(msg)
- },
-
- keyTap = (key, ...modifier) => utools.simulateKeyboardTap(key, ...modifier),
-
- copyTo = text => {
- electron.clipboard.writeText(text)
- },
-
- send = text => {
- copyTo(text);
- quickcommand.simulatePaste();
- }
-]
-
-const ctlKey = utools.isMacOs() ? 'command' : 'control'
+const ctlKey = utools.isMacOs() ? "command" : "control";
window.quickcommand = {
- // 模拟复制操作
- simulateCopy: function() {
- utools.simulateKeyboardTap('c', ctlKey);
- },
+ // 模拟复制操作
+ simulateCopy: function () {
+ utools.simulateKeyboardTap("c", ctlKey);
+ },
- // 模拟粘贴操作
- simulatePaste: function() {
- utools.simulateKeyboardTap('v', ctlKey);
- },
+ // 模拟粘贴操作
+ simulatePaste: function () {
+ utools.simulateKeyboardTap("v", ctlKey);
+ },
- // setTimout 不能在 vm2 中使用,同时在 electron 中有 bug
- sleep: function(ms) {
- var start = new Date().getTime()
- try {
- // node 16.13.1
- child_process.execSync(getSleepCodeByShell(ms), {
- timeout: ms,
- windowsHide: true
- })
- } catch (ex) {}
- var end = new Date().getTime()
- return (end - start)
- },
+ // setTimout 不能在 vm2 中使用,同时在 electron 中有 bug
+ sleep: function (ms) {
+ var start = new Date().getTime();
+ try {
+ // node 16.13.1
+ child_process.execSync(getSleepCodeByShell(ms), {
+ timeout: ms,
+ windowsHide: true,
+ });
+ } catch (ex) {}
+ var end = new Date().getTime();
+ return end - start;
+ },
- // 重写 setTimeout
- setTimeout: function(callback, ms) {
- var start = new Date().getTime()
- child_process.exec(getSleepCodeByShell(ms), {
- timeout: ms
- }, (err, stdout, stderr) => {
- var end = new Date().getTime()
- callback(end - start)
+ // 重写 setTimeout
+ setTimeout: function (callback, ms) {
+ var start = new Date().getTime();
+ child_process.exec(
+ getSleepCodeByShell(ms),
+ {
+ timeout: ms,
+ },
+ (err, stdout, stderr) => {
+ var end = new Date().getTime();
+ callback(end - start);
+ }
+ );
+ },
+
+ // 关闭进程
+ kill: function (pid, signal = "SIGTERM", cb) {
+ kill(pid, signal, cb);
+ },
+
+ // dom 解析
+ htmlParse: function (html) {
+ return new DOMParser().parseFromString(html, "text/html");
+ },
+
+ // 下载文件
+ downloadFile: function (url, file = {}) {
+ return new Promise((reslove, reject) => {
+ if (file instanceof Object)
+ file = utools.showSaveDialog(JSON.parse(JSON.stringify(file)));
+ axios({
+ method: "get",
+ url: url,
+ responseType: "arraybuffer",
+ })
+ .then((res) => {
+ var filebuffer = Buffer.from(res.data);
+ fs.writeFile(file, filebuffer, (err) => {
+ if (err) reject(err);
+ else reslove(filebuffer);
+ });
})
- },
+ .catch((err) => {
+ reject(err);
+ });
+ });
+ },
- // 关闭进程
- kill: function(pid, signal = 'SIGTERM', cb) {
- kill(pid, signal, cb)
- },
-
- // dom 解析
- htmlParse: function(html) {
- return new DOMParser().parseFromString(html, 'text/html')
- },
-
- // 下载文件
- downloadFile: function(url, file = {}) {
- return new Promise((reslove, reject) => {
- if (file instanceof Object) file = utools.showSaveDialog(JSON.parse(JSON.stringify(file)))
- axios({
- method: 'get',
- url: url,
- responseType: 'arraybuffer'
- }).then(res => {
- var filebuffer = Buffer.from(res.data)
- fs.writeFile(file, filebuffer, err => {
- if (err) reject(err)
- else reslove(filebuffer)
- })
- }).catch(err => {
- reject(err)
- })
+ // 上传文件
+ uploadFile: function (url, file = {}, name = "file", formData = {}) {
+ return new Promise((reslove, reject) => {
+ var objfile;
+ if (file instanceof File) {
+ objfile = file;
+ } else {
+ if (file instanceof Object)
+ file = utools.showOpenDialog(JSON.parse(JSON.stringify(file)))[0];
+ if (!fs.existsSync(file)) return reject("文件不存在");
+ var arraybuffer = fs.readFileSync(file).buffer;
+ var objfile = new File([arraybuffer], path.basename(file));
+ }
+ var form = new FormData();
+ form.append(name, objfile);
+ var keys = Object.keys(formData);
+ if (keys.length) keys.forEach((k) => form.append(k, formData[k]));
+ axios
+ .post(url, form, {
+ headers: {
+ accept: "application/json",
+ "Content-Type": `multipart/form-data; boundary=${formData._boundary}`,
+ },
})
- },
-
- // 上传文件
- uploadFile: function(url, file = {}, name = 'file', formData = {}) {
- return new Promise((reslove, reject) => {
- var objfile
- if (file instanceof File) {
- objfile = file
- } else {
- if (file instanceof Object) file = utools.showOpenDialog(JSON.parse(JSON.stringify(file)))[0]
- if (!fs.existsSync(file)) return reject('文件不存在')
- var arraybuffer = fs.readFileSync(file).buffer
- var objfile = new File([arraybuffer], path.basename(file))
- }
- var form = new FormData();
- form.append(name, objfile)
- var keys = Object.keys(formData)
- if (keys.length) keys.forEach(k => form.append(k, formData[k]))
- axios.post(url, form, {
- headers: {
- 'accept': 'application/json',
- 'Content-Type': `multipart/form-data; boundary=${formData._boundary}`,
- }
- }).then(res => {
- reslove(res)
- }).catch(err => {
- reject(err)
- })
+ .then((res) => {
+ reslove(res);
})
- },
+ .catch((err) => {
+ reject(err);
+ });
+ });
+ },
- // 载入在线资源
- loadRemoteScript: async function(url) {
- if (!/^((ht|f)tps?):\/\/([\w\-]+(\.[\w\-]+)*\/)*[\w\-]+(\.[\w\-]+)*\/?(\?([\w\-\.,@?^=%&:\/~\+#]*)+)?/.test(url)) throw 'url 不合法'
- let local = getQuickcommandTempFile('js')
- await this.downloadFile(url, local)
- let source = require(local)
- fs.unlinkSync(local)
- return source
- },
+ // 载入在线资源
+ loadRemoteScript: async function (url) {
+ if (
+ !/^((ht|f)tps?):\/\/([\w\-]+(\.[\w\-]+)*\/)*[\w\-]+(\.[\w\-]+)*\/?(\?([\w\-\.,@?^=%&:\/~\+#]*)+)?/.test(
+ url
+ )
+ )
+ throw "url 不合法";
+ let local = getQuickcommandTempFile("js");
+ await this.downloadFile(url, local);
+ let source = require(local);
+ fs.unlinkSync(local);
+ return source;
+ },
- // 唤醒 uTools
- wakeUtools: function() {
- let uToolsPath = utools.isMacOs() ?
- process.execPath.replace(/\/Frameworks\/.*/, "/MacOS/uTools") :
- process.execPath
- child_process.exec(uToolsPath, () => {})
- },
+ // 唤醒 uTools
+ wakeUtools: function () {
+ let uToolsPath = utools.isMacOs()
+ ? process.execPath.replace(/\/Frameworks\/.*/, "/MacOS/uTools")
+ : process.execPath;
+ child_process.exec(uToolsPath, () => {});
+ },
- readClipboard: function() {
- return electron.clipboard.readText()
- },
+ readClipboard: function () {
+ return electron.clipboard.readText();
+ },
- writeClipboard: function(text) {
- electron.clipboard.writeText(text.toString())
- }
-}
+ writeClipboard: function (text) {
+ electron.clipboard.writeText(text.toString());
+ },
+};
-if (process.platform === 'win32') {
+if (process.platform === "win32") {
// 运行vbs脚本
quickcommand.runVbs = function (script) {
return new Promise((reslove, reject) => {
@@ -267,12 +276,13 @@ if (process.platform === 'win32') {
};
}
-if (process.platform === 'darwin') {
+if (process.platform === "darwin") {
// 运行AppleScript脚本
quickcommand.runAppleScript = function (script) {
return new Promise((reslove, reject) => {
child_process.execFile(
- 'osascript', ['-e', script],
+ "osascript",
+ ["-e", script],
(err, stdout, stderr) => {
if (err) reject(stderr);
else reslove(stdout);
@@ -283,51 +293,55 @@ if (process.platform === 'darwin') {
}
// python -c
-window.runPythonCommand = py => {
- try {
- let result = child_process.execFileSync("python", ["-c", py], {
- windowsHide: true,
- encoding: 'buffer'
- })
- return iconv.decode(result, utools.isWindows() ? 'gbk' : 'utf8').trim()
- } catch (e) {
- alert(e)
- return ""
- }
-}
+window.runPythonCommand = (py) => {
+ try {
+ let result = child_process.execFileSync("python", ["-c", py], {
+ windowsHide: true,
+ encoding: "buffer",
+ });
+ return iconv.decode(result, utools.isWindows() ? "gbk" : "utf8").trim();
+ } catch (e) {
+ alert(e);
+ return "";
+ }
+};
// 在终端中执行
-if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline, dir) {
- let command = getCommandToLaunchTerminal(cmdline, dir)
- child_process.exec(command)
-}
+if (process.platform !== "linux")
+ quickcommand.runInTerminal = function (cmdline, dir) {
+ let command = getCommandToLaunchTerminal(cmdline, dir);
+ child_process.exec(command);
+ };
let getCommandToLaunchTerminal = (cmdline, dir) => {
- let cd, command;
- if (utools.isWindows()) {
- let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/');
- // 直接 existsSync wt.exe 无效
- if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
- cmdline = cmdline.replace(/"/g, `\\"`);
- cd = dir ? `-d "${dir.replace(/\\/g, '/')}"` : '';
- command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`;
- } else {
- cmdline = cmdline.replace(/"/g, `^"`);
- cd = dir ? `cd /d "${dir.replace(/\\/g, '/')}" &&` : '';
- command = `${cd} start "" cmd /k "${cmdline}"`;
- }
- } else if (utools.isMacOs()) {
- cmdline = cmdline.replace(/"/g, `\\"`);
- cd = dir ? `cd ${dir.replace(/ /g, '\\\\ ')} &&` : '';
- command = fs.existsSync('/Applications/iTerm.app') ?
- `osascript -e 'tell application "iTerm"
+ let cd, command;
+ if (utools.isWindows()) {
+ let appPath = path.join(
+ utools.getPath("home"),
+ "/AppData/Local/Microsoft/WindowsApps/"
+ );
+ // 直接 existsSync wt.exe 无效
+ if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes("wt.exe")) {
+ cmdline = cmdline.replace(/"/g, `\\"`);
+ cd = dir ? `-d "${dir.replace(/\\/g, "/")}"` : "";
+ command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"`;
+ } else {
+ cmdline = cmdline.replace(/"/g, `^"`);
+ cd = dir ? `cd /d "${dir.replace(/\\/g, "/")}" &&` : "";
+ command = `${cd} start "" cmd /k "${cmdline}"`;
+ }
+ } else if (utools.isMacOs()) {
+ cmdline = cmdline.replace(/"/g, `\\"`);
+ cd = dir ? `cd ${dir.replace(/ /g, "\\\\ ")} &&` : "";
+ command = fs.existsSync("/Applications/iTerm.app")
+ ? `osascript -e 'tell application "iTerm"
if application "iTerm" is running then
create window with default profile
end if
tell current session of first window to write text "clear && ${cd} ${cmdline}"
activate
- end tell'` :
- `osascript -e 'tell application "Terminal"
+ end tell'`
+ : `osascript -e 'tell application "Terminal"
if application "Terminal" is running then
do script "clear && ${cd} ${cmdline}"
else
@@ -335,150 +349,154 @@ let getCommandToLaunchTerminal = (cmdline, dir) => {
end if
activate
end tell'`;
- }
- return command;
-}
+ }
+ return command;
+};
window.pluginInfo = () => {
- return JSON.parse(fs.readFileSync(path.join(__dirname, 'plugin.json')))
-}
+ return JSON.parse(fs.readFileSync(path.join(__dirname, "plugin.json")));
+};
-let getSleepCodeByShell = ms => {
- var cmd, tempFilePath
- if (utools.isWindows()) {
- tempFilePath = getQuickcommandTempFile('vbs', 'SleepVBSScript')
- cmd = `echo set ws=CreateObject("Wscript.Shell") > ${tempFilePath} && echo Wscript.sleep ${ms} >> ${tempFilePath} && cscript /nologo ${tempFilePath}`
- } else {
- cmd = `sleep ${ms / 1000}`
- }
- return cmd
-}
+let getSleepCodeByShell = (ms) => {
+ var cmd, tempFilePath;
+ if (utools.isWindows()) {
+ tempFilePath = getQuickcommandTempFile("vbs", "SleepVBSScript");
+ cmd = `echo set ws=CreateObject("Wscript.Shell") > ${tempFilePath} && echo Wscript.sleep ${ms} >> ${tempFilePath} && cscript /nologo ${tempFilePath}`;
+ } else {
+ cmd = `sleep ${ms / 1000}`;
+ }
+ return cmd;
+};
window.htmlEncode = (value) => {
- let dom = quickcommand.htmlParse().querySelector('body')
- dom.innerText = value
- return dom.innerHTML
-}
+ let dom = quickcommand.htmlParse().querySelector("body");
+ dom.innerText = value;
+ return dom.innerHTML;
+};
-window.removeHtmlTags = value => {
- return quickcommand.htmlParse(value).querySelector('body').innerText
-}
+window.removeHtmlTags = (value) => {
+ return quickcommand.htmlParse(value).querySelector("body").innerText;
+};
-window.hexEncode = text => Buffer.from(text, 'utf8').toString('hex')
-window.hexDecode = text => Buffer.from(text, 'hex').toString('utf8')
-window.base64Decode = text => Buffer.from(text, 'base64').toString('utf8')
+window.hexEncode = (text) => Buffer.from(text, "utf8").toString("hex");
+window.hexDecode = (text) => Buffer.from(text, "hex").toString("utf8");
+window.base64Decode = (text) => Buffer.from(text, "base64").toString("utf8");
-window.processPlatform = process.platform
-window.joinPath = path.join
+window.processPlatform = process.platform;
+window.joinPath = path.join;
window.getUtoolsPlugins = () => {
- let root = utools.isMacOs() ?
- path.join(os.homedir(), 'Library/Application Support/uTools/plugins/') :
- (utools.isWindows() ?
- path.join(os.homedir(), 'AppData/Roaming/uTools/plugins') :
- path.join(os.homedir(), '.config/uTools/plugins'))
- let plugins = {};
- let files = fs.readdirSync(root);
- let deleted = path.join(root, "deleted");
- let deletedList = fs.existsSync(deleted) ?
- fs.readFileSync(path.join(root, "deleted"), "utf8").split("|") : [];
- files.forEach((file) => {
- if (/[a-zA-Z0-9\-]+\.asar$/.test(file) && !deletedList.includes(file)) {
- let pluginInfo = JSON.parse(
- fs.readFileSync(path.join(root, file, "plugin.json"))
- );
- pluginInfo.logoPath = path.join(root, file, pluginInfo.logo);
- let keyWordFeatures = [];
- pluginInfo.features.forEach((f) => {
- f.cmds.some((c) => {
- c.length && (keyWordFeatures.push(c));
- return true;
- });
- });
- if (!_.isEmpty(keyWordFeatures)) {
- pluginInfo["keyWordFeatures"] = keyWordFeatures
- plugins[pluginInfo.pluginName] = pluginInfo
- }
- }
- });
- return plugins;
-}
+ let root = utools.isMacOs()
+ ? path.join(os.homedir(), "Library/Application Support/uTools/plugins/")
+ : utools.isWindows()
+ ? path.join(os.homedir(), "AppData/Roaming/uTools/plugins")
+ : path.join(os.homedir(), ".config/uTools/plugins");
+ let plugins = {};
+ let files = fs.readdirSync(root);
+ let deleted = path.join(root, "deleted");
+ let deletedList = fs.existsSync(deleted)
+ ? fs.readFileSync(path.join(root, "deleted"), "utf8").split("|")
+ : [];
+ files.forEach((file) => {
+ if (/[a-zA-Z0-9\-]+\.asar$/.test(file) && !deletedList.includes(file)) {
+ let pluginInfo = JSON.parse(
+ fs.readFileSync(path.join(root, file, "plugin.json"))
+ );
+ pluginInfo.logoPath = path.join(root, file, pluginInfo.logo);
+ let keyWordFeatures = [];
+ pluginInfo.features.forEach((f) => {
+ f.cmds.some((c) => {
+ c.length && keyWordFeatures.push(c);
+ return true;
+ });
+ });
+ if (!_.isEmpty(keyWordFeatures)) {
+ pluginInfo["keyWordFeatures"] = keyWordFeatures;
+ plugins[pluginInfo.pluginName] = pluginInfo;
+ }
+ }
+ });
+ return plugins;
+};
-window.getQuickcommandTempFile = (ext, name, dir = 'quickcommandTempDir') => {
- if (!name) name = new Date().getTime() + (Math.random() * 10 ** 6).toFixed()
- let tempDir = path.join(os.tmpdir(), dir)
- if (!fs.existsSync(tempDir)) fs.mkdirSync(tempDir)
- return path.join(tempDir, `${name}.${ext}`)
-}
+window.getQuickcommandTempFile = (ext, name, dir = "quickcommandTempDir") => {
+ if (!name) name = new Date().getTime() + (Math.random() * 10 ** 6).toFixed();
+ let tempDir = path.join(os.tmpdir(), dir);
+ if (!fs.existsSync(tempDir)) fs.mkdirSync(tempDir);
+ return path.join(tempDir, `${name}.${ext}`);
+};
window.delTempFile = (...args) => {
- let tmpPath = path.join(os.tmpdir(), ...args)
- if (fs.existsSync(tmpPath)) fs.unlinkSync(tmpPath)
-}
+ let tmpPath = path.join(os.tmpdir(), ...args);
+ if (fs.existsSync(tmpPath)) fs.unlinkSync(tmpPath);
+};
-window.getBase64Ico = filepath => {
- let sourceImage, ext = path.extname(filepath).slice(1)
- if (['png', 'jpg', 'jpeg', 'bmp', 'ico', 'gif', 'svg'].includes(ext)) {
- if (ext == 'svg') ext = 'svg+xml'
- sourceImage = `data:image/${ext};base64,` + fs.readFileSync(filepath, 'base64')
- if (ext == 'png') return sourceImage
- } else {
- sourceImage = utools.getFileIcon(filepath)
- return sourceImage
- }
- return sourceImage
-}
+window.getBase64Ico = (filepath) => {
+ let sourceImage,
+ ext = path.extname(filepath).slice(1);
+ if (["png", "jpg", "jpeg", "bmp", "ico", "gif", "svg"].includes(ext)) {
+ if (ext == "svg") ext = "svg+xml";
+ sourceImage =
+ `data:image/${ext};base64,` + fs.readFileSync(filepath, "base64");
+ if (ext == "png") return sourceImage;
+ } else {
+ sourceImage = utools.getFileIcon(filepath);
+ return sourceImage;
+ }
+ return sourceImage;
+};
-window.getFileInfo = options => {
- var file
- if (options.type == 'file') {
- file = options.argvs
- } else if (options.type == 'dialog') {
- var dialog = utools.showOpenDialog(options.argvs);
- if (!dialog) return false
- file = dialog[0]
- } else {
- return false
- }
- var information = {
- name: path.basename(file),
- ext: path.extname(file),
- path: file
- }
- if (options.readfile) {
- var codec = (information.ext == '.bat' || information == '.ps1') ? 'gbk' : 'utf8'
- information.data = iconv.decode(fs.readFileSync(file), codec)
- }
- return information
-}
+window.getFileInfo = (options) => {
+ var file;
+ if (options.type == "file") {
+ file = options.argvs;
+ } else if (options.type == "dialog") {
+ var dialog = utools.showOpenDialog(options.argvs);
+ if (!dialog) return false;
+ file = dialog[0];
+ } else {
+ return false;
+ }
+ var information = {
+ name: path.basename(file),
+ ext: path.extname(file),
+ path: file,
+ };
+ if (options.readfile) {
+ var codec =
+ information.ext == ".bat" || information == ".ps1" ? "gbk" : "utf8";
+ information.data = iconv.decode(fs.readFileSync(file), codec);
+ }
+ return information;
+};
window.getCurrentFolderPathFix = () => {
- let pwd = utools.getCurrentFolderPath()
- let pwdFix = pwd ? pwd : path.join(utools.getPath('home'), 'desktop')
- return pwdFix.replace(/\\/g, '\\\\')
-}
+ let pwd = utools.getCurrentFolderPath();
+ let pwdFix = pwd ? pwd : path.join(utools.getPath("home"), "desktop");
+ return pwdFix.replace(/\\/g, "\\\\");
+};
window.saveFile = (content, file) => {
- if (file instanceof Object) file = utools.showSaveDialog(file)
- if (!file) return false
- try {
- fs.writeFileSync(file, content)
- return true
- } catch (error) {
- return false
- }
-}
+ if (file instanceof Object) file = utools.showSaveDialog(file);
+ if (!file) return false;
+ try {
+ fs.writeFileSync(file, content);
+ return true;
+ } catch (error) {
+ return false;
+ }
+};
-window.getSelectFile = hwnd => {
- if (utools.isWindows()) {
- var cmd = `powershell.exe -NoProfile "(New-Object -COM 'Shell.Application').Windows() | Where-Object { $_.HWND -eq ${hwnd} } | Select-Object -Expand Document | select @{ n='SelectItems'; e={$_.SelectedItems()} } | select -Expand SelectItems | select -Expand Path "`;
- let result = child_process.execSync(cmd, {
- encoding: "buffer",
- windowsHide: true
- })
- return iconv.decode(result, 'GBK').trim().replace(/\\/g, '/');
- } else {
- var cmd = `osascript -e 'tell application "Finder" to set selectedItems to selection as alias list
+window.getSelectFile = (hwnd) => {
+ if (utools.isWindows()) {
+ var cmd = `powershell.exe -NoProfile "(New-Object -COM 'Shell.Application').Windows() | Where-Object { $_.HWND -eq ${hwnd} } | Select-Object -Expand Document | select @{ n='SelectItems'; e={$_.SelectedItems()} } | select -Expand SelectItems | select -Expand Path "`;
+ let result = child_process.execSync(cmd, {
+ encoding: "buffer",
+ windowsHide: true,
+ });
+ return iconv.decode(result, "GBK").trim().replace(/\\/g, "/");
+ } else {
+ var cmd = `osascript -e 'tell application "Finder" to set selectedItems to selection as alias list
if selectedItems is {} then return
set parentPath to do shell script "dirname " & quoted form of POSIX path of (item 1 of selectedItems)
set pathData to ""
@@ -486,18 +504,20 @@ window.getSelectFile = hwnd => {
set pathData to pathData & POSIX path of theItem & linefeed
end repeat
'
- `
- let result = child_process.execSync(cmd, {
- encoding: "utf8",
- windowsHide: true
- })
- return result ? result.trim() : ""
- }
-}
+ `;
+ let result = child_process.execSync(cmd, {
+ encoding: "utf8",
+ windowsHide: true,
+ });
+ return result ? result.trim() : "";
+ }
+};
-let runUbrowser = path => {
- utools.ubrowser.goto(path)
- .css(`
+let runUbrowser = (path) => {
+ utools.ubrowser
+ .goto(path)
+ .css(
+ `
.ant-modal-content,
.ant-modal-mask,
[class*='index-module_contentWrapper'],
@@ -508,254 +528,294 @@ let runUbrowser = path => {
#header,
#footer {
display: none
- }`)
- .run({
- width: 980,
- height: 750
- });
-}
+ }`
+ )
+ .run({
+ width: 980,
+ height: 750,
+ });
+};
-const docsRepoUrl = 'https://www.yuque.com/fofolee/qcdocs3'
+const docsRepoUrl = "https://www.yuque.com/fofolee/qcdocs3";
window.showUb = {
- help: function(path = '') {
- runUbrowser(docsRepoUrl + '/bg31vl' + path)
- },
- docs: function(path = '') {
- runUbrowser(docsRepoUrl + '/pt589p' + path)
- },
- changelog: function(path = '') {
- runUbrowser(docsRepoUrl + '/ucnd2o' + path)
- },
-}
+ help: function (path = "") {
+ runUbrowser(docsRepoUrl + "/bg31vl" + path);
+ },
+ docs: function (path = "") {
+ runUbrowser(docsRepoUrl + "/pt589p" + path);
+ },
+ changelog: function (path = "") {
+ runUbrowser(docsRepoUrl + "/ucnd2o" + path);
+ },
+};
-window.clipboardReadText = () => electron.clipboard.readText()
+window.clipboardReadText = () => electron.clipboard.readText();
-window.convertFilePathToUtoolsPayload = files => files.map(file => {
- let isFile = fs.statSync(file).isFile()
+window.convertFilePathToUtoolsPayload = (files) =>
+ files.map((file) => {
+ let isFile = fs.statSync(file).isFile();
return {
- isFile: isFile,
- isDirectory: !isFile,
- name: path.basename(file),
- path: file
- }
-})
+ isFile: isFile,
+ isDirectory: !isFile,
+ name: path.basename(file),
+ path: file,
+ };
+ });
let getSandboxFuns = () => {
- var sandbox = {
- fetch: fetch.bind(window),
- utools: getuToolsLite(),
- electron,
- axios,
- Audio,
- _,
- AbortController,
- AbortSignal,
- Buffer,
- require,
- // 兼容老版本
- fs,
- path,
- os,
- child_process,
- }
- shortCodes.forEach(f => {
- sandbox[f.name] = f
- })
- return sandbox
-}
+ var sandbox = {
+ fetch: fetch.bind(window),
+ utools: getuToolsLite(),
+ electron,
+ axios,
+ Audio,
+ _,
+ AbortController,
+ AbortSignal,
+ Buffer,
+ require,
+ // 兼容老版本
+ fs,
+ path,
+ os,
+ child_process,
+ };
+ shortCodes.forEach((f) => {
+ sandbox[f.name] = f;
+ });
+ return sandbox;
+};
// 简化报错信息
-let liteErr = e => {
- if (!e) return
- return e.error ? e.error.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() : e.message
-}
+let liteErr = (e) => {
+ if (!e) return;
+ return e.error
+ ? e.error.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, "").trim()
+ : e.message;
+};
// vm 模块将无法在渲染进程中使用,改用 ses 来执行代码
window.evalCodeInSandbox = (code, addVars = {}) => {
- let sandboxWithAD = Object.assign(addVars, getSandboxFuns())
- sandboxWithAD.quickcommand = _.cloneDeep(quickcommand)
- try {
- return new Compartment(sandboxWithAD).evaluate(code);
- } catch (error) {
- throw liteErr(error)
- }
-}
+ let sandboxWithAD = Object.assign(addVars, getSandboxFuns());
+ sandboxWithAD.quickcommand = _.cloneDeep(quickcommand);
+ try {
+ return new Compartment(sandboxWithAD).evaluate(code);
+ } catch (error) {
+ throw liteErr(error);
+ }
+};
-let isWatchingError = false
+let isWatchingError = false;
window.runCodeInSandbox = (code, callback, addVars = {}) => {
- let sandbox = getSandboxFuns()
- sandbox.console = {
- log: (...stdout) => {
- console.log("Result:", stdout);
- callback(stdout, null)
- },
- error: (...stderr) => {
- callback(null, stderr)
- }
- }
- let sandboxWithAD = Object.assign(addVars, sandbox)
- sandboxWithAD.quickcommand = _.cloneDeep(quickcommand)
- if (addVars.enterData) {
- sandboxWithAD.quickcommand.enterData = addVars.enterData
- sandboxWithAD.quickcommand.payload = addVars.enterData.payload
- }
- try {
- new Compartment(sandboxWithAD).evaluate(code)
- } catch (e) {
- console.log('Error: ', e)
- callback(null, liteErr(e))
- }
- // 自动捕捉错误
- let cbUnhandledError = e => {
- removeAllListener()
- console.log('UnhandledError: ', e)
- callback(null, liteErr(e))
- }
+ let sandbox = getSandboxFuns();
+ sandbox.console = {
+ log: (...stdout) => {
+ console.log("Result:", stdout);
+ callback(stdout, null);
+ },
+ error: (...stderr) => {
+ callback(null, stderr);
+ },
+ };
+ let sandboxWithAD = Object.assign(addVars, sandbox);
+ sandboxWithAD.quickcommand = _.cloneDeep(quickcommand);
+ if (addVars.enterData) {
+ sandboxWithAD.quickcommand.enterData = addVars.enterData;
+ sandboxWithAD.quickcommand.payload = addVars.enterData.payload;
+ }
+ try {
+ new Compartment(sandboxWithAD).evaluate(code);
+ } catch (e) {
+ console.log("Error: ", e);
+ callback(null, liteErr(e));
+ }
+ // 自动捕捉错误
+ let cbUnhandledError = (e) => {
+ removeAllListener();
+ console.log("UnhandledError: ", e);
+ callback(null, liteErr(e));
+ };
- let cbUnhandledRejection = e => {
- removeAllListener()
- console.log('UnhandledRejection: ', e)
- callback(null, liteErr(e.reason))
- }
+ let cbUnhandledRejection = (e) => {
+ removeAllListener();
+ console.log("UnhandledRejection: ", e);
+ callback(null, liteErr(e.reason));
+ };
- let removeAllListener = () => {
- window.removeEventListener('error', cbUnhandledError)
- window.removeEventListener('unhandledrejection', cbUnhandledRejection)
- isWatchingError = false
- }
+ let removeAllListener = () => {
+ window.removeEventListener("error", cbUnhandledError);
+ window.removeEventListener("unhandledrejection", cbUnhandledRejection);
+ isWatchingError = false;
+ };
- if (!isWatchingError) {
- window.addEventListener('error', cbUnhandledError)
- window.addEventListener('unhandledrejection', cbUnhandledRejection)
- isWatchingError = true
- }
-}
+ if (!isWatchingError) {
+ window.addEventListener("error", cbUnhandledError);
+ window.addEventListener("unhandledrejection", cbUnhandledRejection);
+ isWatchingError = true;
+ }
+};
-window.runCodeFile = (cmd, option, terminal, callback, realTime=true) => {
- let {
- bin,
- argv,
- ext,
- charset,
- scptarg,
- envPath,
- alias
- } = option
- let script = getQuickcommandTempFile(ext, 'quickcommandTempScript');
- // 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
- if (charset.scriptCode) cmd = iconv.encode(cmd.replace(/\n/g, '\r\n'), charset.scriptCode);
- fs.writeFileSync(script, cmd);
- // var argvs = [script]
- // if (argv) {
- // argvs = argv.split(' ')
- // argvs.push(script);
- // }
- let child, cmdline;
- if (bin.slice(-7) == 'csc.exe') {
- cmdline = `${bin} ${argv} /out:"${script.slice(0, -2) + 'exe'}" "${script}" && "${script.slice(0, -2) + 'exe'}" ${scptarg}`
- } else if (bin == 'gcc') {
- var suffix = utools.isWindows() ? '.exe' : ''
- cmdline = `${bin} ${argv} "${script.slice(0, -2)}" "${script}" && "${script.slice(0, -2) + suffix}" ${scptarg}`
- } else if (utools.isWindows() && bin == 'bash') {
- cmdline = `${bin} ${argv} "${script.replace(/\\/g, '/').replace(/C:/i, '/mnt/c')}" ${scptarg}`
- } else {
- cmdline = `${bin} ${argv} "${script}" ${scptarg}`
- }
- let processEnv = _.cloneDeep(process.env);
- if (envPath) processEnv.PATH = envPath;
- if (alias) cmdline = alias + '\n' + cmdline;
- // 在终端中输出
- if (terminal) cmdline = getCommandToLaunchTerminal(cmdline)
- child = child_process.spawn(cmdline, {
- encoding: 'buffer',
- shell: true,
- env: processEnv
+window.runCodeFile = (cmd, option, terminal, callback, realTime = true) => {
+ let { bin, argv, ext, charset, scptarg, envPath, alias } = option;
+ let script = getQuickcommandTempFile(ext, "quickcommandTempScript");
+ // 批处理和 powershell 默认编码为 GBK, 解决批处理的换行问题
+ if (charset.scriptCode)
+ cmd = iconv.encode(cmd.replace(/\n/g, "\r\n"), charset.scriptCode);
+ fs.writeFileSync(script, cmd);
+ // var argvs = [script]
+ // if (argv) {
+ // argvs = argv.split(' ')
+ // argvs.push(script);
+ // }
+ let child, cmdline;
+ if (bin.slice(-7) == "csc.exe") {
+ cmdline = `${bin} ${argv} /out:"${
+ script.slice(0, -2) + "exe"
+ }" "${script}" && "${script.slice(0, -2) + "exe"}" ${scptarg}`;
+ } else if (bin == "gcc") {
+ var suffix = utools.isWindows() ? ".exe" : "";
+ cmdline = `${bin} ${argv} "${script.slice(0, -2)}" "${script}" && "${
+ script.slice(0, -2) + suffix
+ }" ${scptarg}`;
+ } else if (utools.isWindows() && bin == "bash") {
+ cmdline = `${bin} ${argv} "${script
+ .replace(/\\/g, "/")
+ .replace(/C:/i, "/mnt/c")}" ${scptarg}`;
+ } else {
+ cmdline = `${bin} ${argv} "${script}" ${scptarg}`;
+ }
+ let processEnv = _.cloneDeep(process.env);
+ if (envPath) processEnv.PATH = envPath;
+ if (alias) cmdline = alias + "\n" + cmdline;
+ // 在终端中输出
+ if (terminal) cmdline = getCommandToLaunchTerminal(cmdline);
+ child = child_process.spawn(cmdline, {
+ encoding: "buffer",
+ shell: true,
+ env: processEnv,
+ });
+ let chunks = [],
+ err_chunks = [];
+ console.log("Running: " + cmdline);
+ child.stdout.on("data", (chunk) => {
+ if (charset.outputCode) chunk = iconv.decode(chunk, charset.outputCode);
+ realTime ? callback(chunk.toString(), null) : chunks.push(chunk);
+ });
+ child.stderr.on("data", (err_chunk) => {
+ if (charset.outputCode)
+ err_chunk = iconv.decode(err_chunk, charset.outputCode);
+ realTime
+ ? callback(null, err_chunk.toString())
+ : err_chunks.push(err_chunk);
+ });
+ if (!realTime) {
+ child.on("close", (code) => {
+ let stdout = chunks.join("");
+ let stderr = err_chunks.join("");
+ callback(stdout, stderr);
});
- let chunks = [], err_chunks = [];
- console.log('Running: ' + cmdline);
- child.stdout.on('data', chunk => {
- if (charset.outputCode) chunk = iconv.decode(chunk, charset.outputCode);
- realTime
- ? callback(chunk.toString(), null)
- : chunks.push(chunk);
- });
- child.stderr.on("data", (err_chunk) => {
- if (charset.outputCode)
- err_chunk = iconv.decode(err_chunk, charset.outputCode);
- realTime
- ? callback(null, err_chunk.toString())
- : err_chunks.push(err_chunk);
- });
- if (!realTime) {
- child.on('close', code => {
- let stdout = chunks.join("");
- let stderr = err_chunks.join("");
- callback(stdout, stderr)
- })
- }
- return child
-}
+ }
+ return child;
+};
const dbStorage = utools.dbStorage;
let httpServer;
window.quickcommandHttpServer = () => {
- let run = (port = 33442) => {
- let httpResponse = (res, code, result) => {
- // 只收受一次 console.log,接收后就关闭连接
- if (res.finished) return
- res.writeHead(code, {
- 'Content-Type': 'text/html'
- });
- if (result) res.write(result);
- res.end();
- }
- let runUserCode = (res, userVars) => {
- let cmd = dbStorage.getItem('cfg_serverCode');
- // 不需要返回输出的提前关闭连接
- if (!cmd.includes('console.log')) httpResponse(res, 200);
- window.runCodeInSandbox(cmd, (stdout, stderr) => {
- // 错误返回 500
- if (stderr) return httpResponse(res, 500, stderr.join(" "));
- return httpResponse(res, 200, stdout.join(" "));
- }, userVars)
- }
- httpServer = http.createServer();
- httpServer.on('request', (req, res) => {
- if (req.method === 'GET') {
- let parsedParams = _.cloneDeep(url.parse(req.url, true).query);
- runUserCode(res, parsedParams);
- } else if (req.method === 'POST') {
- let data = [];
- req.on('data', (chunk) => {
- data.push(chunk);
- })
- req.on('end', () => {
- let parsedParams;
- let params = data.join("").toString();
- // 先尝试作为 json 解析
- try {
- parsedParams = JSON.parse(params);
- } catch (error) {
- parsedParams = _.cloneDeep(url.parse('?' + params, true).query);
- }
- runUserCode(res, parsedParams);
- })
- } else {
- httpResponse(res, 405);
- }
- })
- httpServer.listen(port, 'localhost');
- httpServer.on('error', err => {
- utools.showNotification('快捷命令服务:', err)
- })
+ let run = (port = 33442) => {
+ let httpResponse = (res, code, result) => {
+ // 只收受一次 console.log,接收后就关闭连接
+ if (res.finished) return;
+ res.writeHead(code, {
+ "Content-Type": "text/html",
+ });
+ if (result) res.write(result);
+ res.end();
+ };
+ let runUserCode = (res, userVars) => {
+ let cmd = dbStorage.getItem("cfg_serverCode");
+ // 不需要返回输出的提前关闭连接
+ if (!cmd.includes("console.log")) httpResponse(res, 200);
+ window.runCodeInSandbox(
+ cmd,
+ (stdout, stderr) => {
+ // 错误返回 500
+ if (stderr) return httpResponse(res, 500, stderr.join(" "));
+ return httpResponse(res, 200, stdout.join(" "));
+ },
+ userVars
+ );
+ };
+ httpServer = http.createServer();
+ httpServer.on("request", (req, res) => {
+ if (req.method === "GET") {
+ let parsedParams = _.cloneDeep(url.parse(req.url, true).query);
+ runUserCode(res, parsedParams);
+ } else if (req.method === "POST") {
+ let data = [];
+ req.on("data", (chunk) => {
+ data.push(chunk);
+ });
+ req.on("end", () => {
+ let parsedParams;
+ let params = data.join("").toString();
+ // 先尝试作为 json 解析
+ try {
+ parsedParams = JSON.parse(params);
+ } catch (error) {
+ parsedParams = _.cloneDeep(url.parse("?" + params, true).query);
+ }
+ runUserCode(res, parsedParams);
+ });
+ } else {
+ httpResponse(res, 405);
+ }
+ });
+ httpServer.listen(port, "localhost");
+ httpServer.on("error", (err) => {
+ utools.showNotification("快捷命令服务:", err);
+ });
+ };
+ let stop = () => {
+ if (!httpServer) return;
+ httpServer.close();
+ };
+ return {
+ run,
+ stop,
+ };
+};
+
+// 处理背景图片
+window.imageProcessor = async (imagePath) => {
+ try {
+ // 读取图片
+ let image = sharp(imagePath);
+ let metadata = await image.metadata();
+
+ // 设置固定目标尺寸
+ let targetWidth = 1280;
+ let targetHeight = 720;
+ const ratio = metadata.width / metadata.height;
+
+ if (ratio > 16 / 9) {
+ targetHeight = Math.min(720, Math.round(targetWidth / ratio));
+ } else {
+ targetWidth = Math.min(1280, Math.round(targetHeight * ratio));
}
- let stop = () => {
- if (!httpServer) return
- httpServer.close()
- }
- return {
- run,
- stop
- }
-}
+
+ // 调整大小并压缩
+ let processedBuffer = await image
+ .resize(targetWidth, targetHeight, {
+ fit: "contain",
+ background: { r: 0, g: 0, b: 0, alpha: 0 },
+ })
+ .jpeg({ quality: 80, progressive: true })
+ .toBuffer();
+
+ return `data:image/jpeg;base64,${processedBuffer.toString("base64")}`;
+ } catch (error) {
+ console.error("处理图片失败:", error);
+ return null;
+ }
+};
diff --git a/src/App.vue b/src/App.vue
index 79c617b..388ff57 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -15,7 +15,7 @@ import programmings from "./js/options/programs.js";
import defaultProfile from "./js/options/defaultProfile.js";
import Cron from "croner";
import QuickCommand from "components/quickcommandUI/QuickCommand";
-import autoDetach from "./js/autoDetach.js";
+// import autoDetach from "./js/autoDetach.js";
export default defineComponent({
components: { QuickCommand },
@@ -122,7 +122,7 @@ export default defineComponent({
this.enterData = enter;
// 自动分离目前还没有好的方案
// if (this.$root.profile.autoDetachFeatures?.includes(enter.code)) {
- // autoDetach.autoDetach();
+ // autoDetach.autoDetach();
// }
this.$router.push(enter.code);
},
@@ -240,5 +240,16 @@ export default defineComponent({
this.utools.setStorage("st_v300Inited", true);
},
},
+ watch: {
+ // 监听 glassEffect 值变化
+ 'profile.glassEffect': {
+ immediate: true,
+ handler(val) {
+ // 给 body 添加 glass-effect-menu 类和强度值
+ document.body.classList.toggle('glass-effect-menu', val > 0);
+ document.body.style.setProperty('--glass-effect-strength', val);
+ }
+ }
+ }
});
diff --git a/src/components/CommandCard.vue b/src/components/CommandCard.vue
index 19fb7c1..9bfbe3f 100644
--- a/src/components/CommandCard.vue
+++ b/src/components/CommandCard.vue
@@ -124,7 +124,7 @@
:class="{
featureIco: 1,
featureIcoHover: isWarpperHover,
- 'feature-disabled': !isCommandActivated
+ 'feature-disabled': !isCommandActivated,
}"
>
@@ -141,7 +141,7 @@
v-html="commandInfo.features.explain.trim() || '
'"
/>
-
+