From 148ef1b343e4224fb9a071f68fabbde383687b61 Mon Sep 17 00:00:00 2001 From: double beep <38133098+double-beep@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:47:40 +0000 Subject: [PATCH] feat: add "Upload image" button --- .mocharc.json | 11 - dist/headers.js | 2 +- dist/legacy/index.min.user.js | 4 +- dist/legacy/index.user.js | 144 ++++-- dist/modern/index.min.user.js | 4 +- dist/modern/index.user.js | 83 +++- package-lock.json | 801 +--------------------------------- package.json | 8 +- scripts/headers.sh | 1 + src/index.ts | 124 ++++-- test/index.spec.mjs | 7 - tsconfig.json | 6 +- 12 files changed, 292 insertions(+), 903 deletions(-) delete mode 100644 .mocharc.json delete mode 100644 test/index.spec.mjs diff --git a/.mocharc.json b/.mocharc.json deleted file mode 100644 index c1f5e07..0000000 --- a/.mocharc.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/mocharc.json", - "extensions": [ - "js", - "ts", - "tsx" - ], - "spec": [ - "test/**/*.spec.*" - ] -} diff --git a/dist/headers.js b/dist/headers.js index 3790a41..8fe4705 100644 --- a/dist/headers.js +++ b/dist/headers.js @@ -25,7 +25,7 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* // @namespace userscripters -// @run-at document-start +// @run-at document-body // @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues // @version 0.1.0 diff --git a/dist/legacy/index.min.user.js b/dist/legacy/index.min.user.js index fedb85b..588555e 100644 --- a/dist/legacy/index.min.user.js +++ b/dist/legacy/index.min.user.js @@ -25,10 +25,10 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* // @namespace userscripters -// @run-at document-start +// @run-at document-body // @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues // @version 0.1.0 // ==/UserScript== -var __awaiter=this&&this.__awaiter||function(e,i,l,c){return new(l=l||Promise)(function(n,t){function r(e){try{o(c.next(e))}catch(e){t(e)}}function a(e){try{o(c.throw(e))}catch(e){t(e)}}function o(e){var t;e.done?n(e.value):((t=e.value)instanceof l?t:new l(function(e){e(t)})).then(r,a)}o((c=c.apply(e,i||[])).next())})},__generator=this&&this.__generator||function(r,a){var o,i,l,c={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]},s={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function e(n){return function(e){var t=[n,e];if(o)throw new TypeError("Generator is already executing.");for(;c=s&&t[s=0]?0:c;)try{if(o=1,i&&(l=2&t[0]?i.return:t[0]?i.throw||((l=i.return)&&l.call(i),0):i.next)&&!(l=l.call(i,t[1])).done)return l;switch(i=0,(t=l?[2&t[0],l.value]:t)[0]){case 0:case 1:l=t;break;case 4:return c.label++,{value:t[1],done:!1};case 5:c.label++,i=t[1],t=[0];continue;case 7:t=c.ops.pop(),c.trys.pop();continue;default:if(!(l=0<(l=c.trys).length&&l[l.length-1])&&(6===t[0]||2===t[0])){c=0;continue}if(3===t[0]&&(!l||t[1]>l[0]&&t[1]=a)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),r=t.selectionStart,a=t.selectionEnd,o="[Uploading ".concat(n.name,"...]()"),t.setRangeText(o,r,a,"start"),[4,uploadImage(n)];case 2:return l=e.sent(),console.log(l),i="enter image description here",t.setRangeText("[".concat(i,"](").concat(l,")"),r,r+o.length,"start"),t.setSelectionRange(r+1,r+1+i.length,"forward"),[3,4];case 3:return l=e.sent(),console.error(l),[3,4];case 4:return[2]}})})}window.addEventListener("paste",handleEvent),window.addEventListener("drop",handleEvent); \ No newline at end of file +var __awaiter=this&&this.__awaiter||function(e,o,c,l){return new(c=c||Promise)(function(n,t){function r(e){try{i(l.next(e))}catch(e){t(e)}}function a(e){try{i(l.throw(e))}catch(e){t(e)}}function i(e){var t;e.done?n(e.value):((t=e.value)instanceof c?t:new c(function(e){e(t)})).then(r,a)}i((l=l.apply(e,o||[])).next())})},__generator=this&&this.__generator||function(r,a){var i,o,c,l={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]},s={next:e(0),throw:e(1),return:e(2)};return"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function e(n){return function(e){var t=[n,e];if(i)throw new TypeError("Generator is already executing.");for(;l=s&&t[s=0]?0:l;)try{if(i=1,o&&(c=2&t[0]?o.return:t[0]?o.throw||((c=o.return)&&c.call(o),0):o.next)&&!(c=c.call(o,t[1])).done)return c;switch(o=0,(t=c?[2&t[0],c.value]:t)[0]){case 0:case 1:c=t;break;case 4:return l.label++,{value:t[1],done:!1};case 5:l.label++,o=t[1],t=[0];continue;case 7:t=l.ops.pop(),l.trys.pop();continue;default:if(!(c=0<(c=l.trys).length&&c[c.length-1])&&(6===t[0]||2===t[0])){l=0;continue}if(3===t[0]&&(!c||t[1]>c[0]&&t[1]=t))return e}}}}function insertText(i,o){return __awaiter(this,void 0,void 0,function(){var t,n,r,a;return __generator(this,function(e){switch(e.label){case 0:return t=o.selectionStart,r=o.selectionEnd,n="[Uploading ".concat(i.name,"...]()"),o.setRangeText(n,t,r,"start"),[4,uploadImage(i)];case 1:return r=e.sent(),a="enter image description here",o.setRangeText("[".concat(a,"](").concat(r,")"),t,t+n.length,"start"),o.setSelectionRange(t+1,t+1+a.length,"forward"),[2]}})})}function handleEvent(a){return __awaiter(this,void 0,void 0,function(){var t,n,r;return __generator(this,function(e){switch(e.label){case 0:if(!(t=a.target).matches("textarea.js-comment-text-input"))return[2];if(a.preventDefault(),!(n=findImage(a)))return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,insertText(n,t)];case 2:return e.sent(),[3,4];case 3:return r=e.sent(),console.error(r),[3,4];case 4:return[2]}})})}function appendButton(a){var e,t=this,i=document.createElement("input"),n=(i.type="file",i.addEventListener("change",function(){return __awaiter(t,void 0,void 0,function(){var t,n,r;return __generator(this,function(e){switch(e.label){case 0:if(r=null==(r=i.files)?void 0:r[0],t=a.querySelector("textarea.js-comment-text-input"),!r||!t)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,insertText(r,t)];case 2:return e.sent(),[3,4];case 3:return n=e.sent(),console.error(n),[3,4];case 4:return[2]}})})}),document.createElement("button")),r=(n.classList.add("s-btn","s-btn__link","ta-left","px2"),n.type="button",n.innerText="Upload image",n.addEventListener("click",function(){i.click()}),a.querySelector(".js-comment-help-link"));r&&(null!=(e=r.parentElement)&&e.classList.add("g4"),r.before(n))}window.addEventListener("paste",handleEvent),window.addEventListener("drop",handleEvent),document.querySelectorAll(".js-add-link").forEach(function(t){t.addEventListener("click",function(){setTimeout(function(){var e=t.closest(".post-layout--right");e&&appendButton(e)},200)})}); \ No newline at end of file diff --git a/dist/legacy/index.user.js b/dist/legacy/index.user.js index 544a63c..f463692 100644 --- a/dist/legacy/index.user.js +++ b/dist/legacy/index.user.js @@ -25,7 +25,7 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* // @namespace userscripters -// @run-at document-start +// @run-at document-body // @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues // @version 0.1.0 @@ -124,52 +124,71 @@ function uploadImage(file) { }); }); } +function findImage(event) { + var _a, _b, _c, _d; + var items = event instanceof ClipboardEvent + ? ((_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.items) || ((_b = event.clipboardData) === null || _b === void 0 ? void 0 : _b.files) + : ((_c = event.dataTransfer) === null || _c === void 0 ? void 0 : _c.items) || ((_d = event.dataTransfer) === null || _d === void 0 ? void 0 : _d.files); + if (!items) + return; + var image = __spreadArray([], __read(items), false).find(function (item) { return item.type.includes("image/"); }); + if (!image) + return; + var file = image instanceof File + ? image + : image.getAsFile(); + if (!file) { + return; + } + var maxFileSize = StackExchange.settings.image.maxImageUploadSizeInBytes; + if (file.size >= maxFileSize) { + return; + } + return file; +} +function insertText(file, textarea) { + return __awaiter(this, void 0, void 0, function () { + var start, end, replaceText, imageUrl, linkDescription; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + start = textarea.selectionStart; + end = textarea.selectionEnd; + replaceText = "[Uploading ".concat(file.name, "...]()"); + textarea.setRangeText(replaceText, start, end, "start"); + return [4, uploadImage(file)]; + case 1: + imageUrl = _a.sent(); + linkDescription = "enter image description here"; + textarea.setRangeText("[".concat(linkDescription, "](").concat(imageUrl, ")"), start, start + replaceText.length, "start"); + textarea.setSelectionRange(start + 1, start + 1 + linkDescription.length, "forward"); + return [2]; + } + }); + }); +} function handleEvent(event) { return __awaiter(this, void 0, void 0, function () { - var target, items, image, file, maxFileSize, start, end, replaceText, imageUrl, linkDescription, error_1; - var _a, _b, _c, _d; - return __generator(this, function (_e) { - switch (_e.label) { + var target, file, error_1; + return __generator(this, function (_a) { + switch (_a.label) { case 0: target = event.target; if (!target.matches("textarea.js-comment-text-input")) return [2]; event.preventDefault(); - items = event instanceof ClipboardEvent - ? ((_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.items) || ((_b = event.clipboardData) === null || _b === void 0 ? void 0 : _b.files) - : ((_c = event.dataTransfer) === null || _c === void 0 ? void 0 : _c.items) || ((_d = event.dataTransfer) === null || _d === void 0 ? void 0 : _d.files); - if (!items) - return [2]; - image = __spreadArray([], __read(items), false).find(function (item) { return item.type.includes("image/"); }); - if (!image) - return [2]; - file = image instanceof File - ? image - : image.getAsFile(); - if (!file) { + file = findImage(event); + if (!file) return [2]; - } - maxFileSize = StackExchange.settings.image.maxImageUploadSizeInBytes; - if (file.size >= maxFileSize) { - return [2]; - } - _e.label = 1; + _a.label = 1; case 1: - _e.trys.push([1, 3, , 4]); - start = target.selectionStart; - end = target.selectionEnd; - replaceText = "[Uploading ".concat(file.name, "...]()"); - target.setRangeText(replaceText, start, end, "start"); - return [4, uploadImage(file)]; + _a.trys.push([1, 3, , 4]); + return [4, insertText(file, target)]; case 2: - imageUrl = _e.sent(); - console.log(imageUrl); - linkDescription = "enter image description here"; - target.setRangeText("[".concat(linkDescription, "](").concat(imageUrl, ")"), start, start + replaceText.length, "start"); - target.setSelectionRange(start + 1, start + 1 + linkDescription.length, "forward"); + _a.sent(); return [3, 4]; case 3: - error_1 = _e.sent(); + error_1 = _a.sent(); console.error(error_1); return [3, 4]; case 4: return [2]; @@ -177,7 +196,62 @@ function handleEvent(event) { }); }); } +function appendButton(location) { + var _this = this; + var _a; + var input = document.createElement("input"); + input.type = "file"; + input.addEventListener("change", function () { return __awaiter(_this, void 0, void 0, function () { + var file, textarea, error_2; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + file = (_a = input.files) === null || _a === void 0 ? void 0 : _a[0]; + textarea = location.querySelector("textarea.js-comment-text-input"); + if (!file || !textarea) + return [2]; + _b.label = 1; + case 1: + _b.trys.push([1, 3, , 4]); + return [4, insertText(file, textarea)]; + case 2: + _b.sent(); + return [3, 4]; + case 3: + error_2 = _b.sent(); + console.error(error_2); + return [3, 4]; + case 4: return [2]; + } + }); + }); }); + var uploadButton = document.createElement("button"); + uploadButton.classList.add("s-btn", "s-btn__link", "ta-left", "px2"); + uploadButton.type = "button"; + uploadButton.innerText = "Upload image"; + uploadButton.addEventListener("click", function () { + input.click(); + }); + var helpLink = location.querySelector(".js-comment-help-link"); + if (!helpLink) + return; + (_a = helpLink.parentElement) === null || _a === void 0 ? void 0 : _a.classList.add("g4"); + helpLink.before(uploadButton); +} (function () { window.addEventListener("paste", handleEvent); window.addEventListener("drop", handleEvent); + document + .querySelectorAll(".js-add-link") + .forEach(function (link) { + link.addEventListener("click", function () { + setTimeout(function () { + var parent = link.closest(".post-layout--right"); + if (!parent) + return; + appendButton(parent); + }, 200); + }); + }); })(); diff --git a/dist/modern/index.min.user.js b/dist/modern/index.min.user.js index 04396c3..0abfe5b 100644 --- a/dist/modern/index.min.user.js +++ b/dist/modern/index.min.user.js @@ -25,10 +25,10 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* // @namespace userscripters -// @run-at document-start +// @run-at document-body // @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues // @version 0.1.0 // ==/UserScript== -async function uploadImage(e){var a=new FormData,e=(a.append("file",e),a.append("fkey",StackExchange.options.user.fkey),new URL(location.origin+"/upload/image")),a=await fetch(e,{method:"POST",body:a});if(!a.ok)throw new Error(`Request to ${e.toString()} failed.`);var{Success:e,UploadedImage:t}=await a.json();if(e)return t;throw console.error(a),new Error("Failed to upload image.")}async function handleEvent(e){var a=e.target;if(a.matches("textarea.js-comment-text-input")){e.preventDefault();e=e instanceof ClipboardEvent?(null==(t=e.clipboardData)?void 0:t.items)||(null==(t=e.clipboardData)?void 0:t.files):(null==(t=e.dataTransfer)?void 0:t.items)||(null==(t=e.dataTransfer)?void 0:t.files);if(e){var t=[...e].find(e=>e.type.includes("image/"));if(t){e=t instanceof File?t:t.getAsFile();if(e){t=StackExchange.settings.image.maxImageUploadSizeInBytes;if(!(e.size>=t))try{var n=a.selectionStart,i=a.selectionEnd,o=`[Uploading ${e.name}...]()`,r=(a.setRangeText(o,n,i,"start"),await uploadImage(e)),l=(console.log(r),"enter image description here");a.setRangeText(`[${l}](${r})`,n,n+o.length,"start"),a.setSelectionRange(n+1,n+1+l.length,"forward")}catch(e){console.error(e)}}}}}}window.addEventListener("paste",handleEvent),window.addEventListener("drop",handleEvent); \ No newline at end of file +async function uploadImage(e){var t=new FormData,e=(t.append("file",e),t.append("fkey",StackExchange.options.user.fkey),new URL(location.origin+"/upload/image")),t=await fetch(e,{method:"POST",body:t});if(!t.ok)throw new Error(`Request to ${e.toString()} failed.`);var{Success:e,UploadedImage:a}=await t.json();if(e)return a;throw console.error(t),new Error("Failed to upload image.")}function findImage(e){e=e instanceof ClipboardEvent?e.clipboardData?.items||e.clipboardData?.files:e.dataTransfer?.items||e.dataTransfer?.files;if(e){e=[...e].find(e=>e.type.includes("image/"));if(e){e=e instanceof File?e:e.getAsFile();if(e){var t=StackExchange.settings.image.maxImageUploadSizeInBytes;if(!(e.size>=t))return e}}}}async function insertText(e,t){var a=t.selectionStart,n=`[Uploading ${e.name}...]()`,e=(t.setRangeText(n,a,t.selectionEnd,"start"),await uploadImage(e)),i="enter image description here";t.setRangeText(`[${i}](${e})`,a,a+n.length,"start"),t.setSelectionRange(a+1,a+1+i.length,"forward")}async function handleEvent(e){var t=e.target;if(t.matches("textarea.js-comment-text-input")){e.preventDefault();e=findImage(e);if(e)try{await insertText(e,t)}catch(e){console.error(e)}}}function appendButton(a){let n=document.createElement("input");n.type="file",n.addEventListener("change",async()=>{var e=n.files?.[0],t=a.querySelector("textarea.js-comment-text-input");if(e&&t)try{await insertText(e,t)}catch(e){console.error(e)}});var e=document.createElement("button"),t=(e.classList.add("s-btn","s-btn__link","ta-left","px2"),e.type="button",e.innerText="Upload image",e.addEventListener("click",()=>{n.click()}),a.querySelector(".js-comment-help-link"));t&&(t.parentElement?.classList.add("g4"),t.before(e))}window.addEventListener("paste",handleEvent),window.addEventListener("drop",handleEvent),document.querySelectorAll(".js-add-link").forEach(t=>{t.addEventListener("click",()=>{setTimeout(()=>{var e=t.closest(".post-layout--right");e&&appendButton(e)},200)})}); \ No newline at end of file diff --git a/dist/modern/index.user.js b/dist/modern/index.user.js index e89df97..4bf1615 100644 --- a/dist/modern/index.user.js +++ b/dist/modern/index.user.js @@ -25,7 +25,7 @@ // @match https://ru.meta.stackoverflow.com/questions/* // @match https://es.meta.stackoverflow.com/questions/* // @namespace userscripters -// @run-at document-start +// @run-at document-body // @source git+https://github.com/userscripters/comment-image-upload.git // @supportURL https://github.com/userscripters/comment-image-upload/issues // @version 0.1.0 @@ -51,15 +51,10 @@ async function uploadImage(file) { } return image; } -async function handleEvent(event) { - var _a, _b, _c, _d; - const target = event.target; - if (!target.matches("textarea.js-comment-text-input")) - return; - event.preventDefault(); +function findImage(event) { const items = event instanceof ClipboardEvent - ? ((_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.items) || ((_b = event.clipboardData) === null || _b === void 0 ? void 0 : _b.files) - : ((_c = event.dataTransfer) === null || _c === void 0 ? void 0 : _c.items) || ((_d = event.dataTransfer) === null || _d === void 0 ? void 0 : _d.files); + ? event.clipboardData?.items || event.clipboardData?.files + : event.dataTransfer?.items || event.dataTransfer?.files; if (!items) return; const image = [...items].find(item => item.type.includes("image/")); @@ -75,22 +70,74 @@ async function handleEvent(event) { if (file.size >= maxFileSize) { return; } + return file; +} +async function insertText(file, textarea) { + const start = textarea.selectionStart; + const end = textarea.selectionEnd; + const replaceText = `[Uploading ${file.name}...]()`; + textarea.setRangeText(replaceText, start, end, "start"); + const imageUrl = await uploadImage(file); + const linkDescription = "enter image description here"; + textarea.setRangeText(`[${linkDescription}](${imageUrl})`, start, start + replaceText.length, "start"); + textarea.setSelectionRange(start + 1, start + 1 + linkDescription.length, "forward"); +} +async function handleEvent(event) { + const target = event.target; + if (!target.matches("textarea.js-comment-text-input")) + return; + event.preventDefault(); + const file = findImage(event); + if (!file) + return; try { - const start = target.selectionStart; - const end = target.selectionEnd; - const replaceText = `[Uploading ${file.name}...]()`; - target.setRangeText(replaceText, start, end, "start"); - const imageUrl = await uploadImage(file); - console.log(imageUrl); - const linkDescription = "enter image description here"; - target.setRangeText(`[${linkDescription}](${imageUrl})`, start, start + replaceText.length, "start"); - target.setSelectionRange(start + 1, start + 1 + linkDescription.length, "forward"); + await insertText(file, target); } catch (error) { console.error(error); } } +function appendButton(location) { + const input = document.createElement("input"); + input.type = "file"; + input.addEventListener("change", async () => { + const file = input.files?.[0]; + const textarea = location.querySelector("textarea.js-comment-text-input"); + if (!file || !textarea) + return; + try { + await insertText(file, textarea); + } + catch (error) { + console.error(error); + } + }); + const uploadButton = document.createElement("button"); + uploadButton.classList.add("s-btn", "s-btn__link", "ta-left", "px2"); + uploadButton.type = "button"; + uploadButton.innerText = "Upload image"; + uploadButton.addEventListener("click", () => { + input.click(); + }); + const helpLink = location.querySelector(".js-comment-help-link"); + if (!helpLink) + return; + helpLink.parentElement?.classList.add("g4"); + helpLink.before(uploadButton); +} (() => { window.addEventListener("paste", handleEvent); window.addEventListener("drop", handleEvent); + document + .querySelectorAll(".js-add-link") + .forEach((link) => { + link.addEventListener("click", () => { + setTimeout(() => { + const parent = link.closest(".post-layout--right"); + if (!parent) + return; + appendButton(parent); + }, 200); + }); + }); })(); diff --git a/package-lock.json b/package-lock.json index 50db24d..ef5c379 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,16 +11,10 @@ "devDependencies": { "@eslint/js": "^9.10.0", "@stylistic/eslint-plugin": "^2.7.2", - "@types/chai": "^4.3.19", - "@types/mocha": "^10.0.7", - "@types/node": "^22.5.4", "@types/tampermonkey": "^5.0.3", "@userscripters/generate-headers": "^3.4.1", "@userscripters/generate-readme": "^3.0.2", "@userscripters/stackexchange-global-types": "^2.8.2", - "chai": "^5.1.1", - "mocha": "^10.7.3", - "ts-node": "^10.9.2", "typescript": "^5.5.4", "typescript-eslint": "^8.4.0", "uglify-js": "^3.19.3" @@ -38,19 +32,6 @@ "is-potential-custom-element-name": "^1.0.1" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -258,34 +239,6 @@ "license": "BSD-3-Clause", "peer": true }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -400,41 +353,6 @@ "node": ">=14.16" } }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/chai": { - "version": "4.3.19", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.19.tgz", - "integrity": "sha512-2hHHvQBVE2FiSK4eN0Br6snX9MtolHaTo/batnLjlGRhoQzlCL61iVpxoqO7SfFyOw+P/pwv+0zNHzKoGWz9Cw==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/eslint": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz", @@ -477,23 +395,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/mocha": { - "version": "10.0.7", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.7.tgz", - "integrity": "sha512-GN8yJ1mNTcFcah/wKEFIJckJx9iJLoMSzWcfRRuxz/Jk+U6KQNnml+etbtxFK8lPjzOw3zp4Ha/kjSst9fsHYw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "22.5.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.4.tgz", - "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~6.19.2" - } - }, "node_modules/@types/sizzle": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.8.tgz", @@ -786,19 +687,6 @@ "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, - "node_modules/acorn-walk": { - "version": "8.3.3", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", - "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/agent-base": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", @@ -830,16 +718,6 @@ "url": "https://github.com/sponsors/epoberezkin" } }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -866,56 +744,13 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/anymatch/node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, - "license": "MIT" - }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true, - "license": "Python-2.0" - }, - "node_modules/assertion-error": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", - "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - } + "license": "Python-2.0", + "peer": true }, "node_modules/asynckit": { "version": "0.4.0", @@ -941,19 +776,6 @@ "require-from-string": "^2.0.2" } }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -977,13 +799,6 @@ "node": ">=8" } }, - "node_modules/browser-stdout": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", - "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", - "dev": true, - "license": "ISC" - }, "node_modules/cacheable-lookup": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz", @@ -1024,36 +839,6 @@ "node": ">=6" } }, - "node_modules/camelcase": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", - "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/chai": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.1.tgz", - "integrity": "sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==", - "dev": true, - "license": "MIT", - "dependencies": { - "assertion-error": "^2.0.1", - "check-error": "^2.1.1", - "deep-eql": "^5.0.1", - "loupe": "^3.1.0", - "pathval": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/chalk": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", @@ -1067,54 +852,6 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "node_modules/check-error": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", - "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 16" - } - }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/chokidar/node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -1171,13 +908,6 @@ "license": "MIT", "peer": true }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true, - "license": "MIT" - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -1260,19 +990,6 @@ } } }, - "node_modules/decamelize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", - "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/decimal.js": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz", @@ -1309,16 +1026,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/deep-eql": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", - "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -1347,16 +1054,6 @@ "node": ">=0.4.0" } }, - "node_modules/diff": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", - "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -1407,6 +1104,7 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=10" }, @@ -1785,6 +1483,7 @@ "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "locate-path": "^6.0.0", "path-exists": "^4.0.0" @@ -1796,16 +1495,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/flat": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", - "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true, - "license": "BSD-3-Clause", - "bin": { - "flat": "cli.js" - } - }, "node_modules/flat-cache": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", @@ -1860,22 +1549,8 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true, - "license": "ISC" - }, - "node_modules/fsevents": { - "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, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } + "license": "ISC", + "peer": true }, "node_modules/get-caller-file": { "version": "2.0.5", @@ -1887,16 +1562,6 @@ "node": "6.* || 8.* || >= 10.*" } }, - "node_modules/get-func-name": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", - "integrity": "sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "*" - } - }, "node_modules/get-stream": { "version": "9.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-9.0.1.tgz", @@ -1914,27 +1579,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "dev": true, - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -1949,19 +1593,6 @@ "node": ">=10.13.0" } }, - "node_modules/glob/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/globals": { "version": "13.24.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", @@ -2031,20 +1662,11 @@ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=8" } }, - "node_modules/he": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", - "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true, - "license": "MIT", - "bin": { - "he": "bin/he" - } - }, "node_modules/html-encoding-sniffer": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-4.0.0.tgz", @@ -2166,6 +1788,7 @@ "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, "license": "ISC", + "peer": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -2176,20 +1799,8 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true, - "license": "ISC" - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } + "license": "ISC", + "peer": true }, "node_modules/is-extglob": { "version": "2.1.1", @@ -2245,16 +1856,6 @@ "node": ">=8" } }, - "node_modules/is-plain-obj": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", - "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -2275,19 +1876,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -2302,6 +1890,7 @@ "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "argparse": "^2.0.1" }, @@ -2404,6 +1993,7 @@ "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "p-locate": "^5.0.0" }, @@ -2422,63 +2012,6 @@ "license": "MIT", "peer": true }, - "node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "license": "MIT", - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/log-symbols/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/log-symbols/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/loupe": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.1.tgz", - "integrity": "sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==", - "dev": true, - "license": "MIT", - "dependencies": { - "get-func-name": "^2.0.1" - } - }, "node_modules/lowercase-keys": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-3.0.0.tgz", @@ -2492,13 +2025,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, "node_modules/mdn-data": { "version": "2.0.30", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz", @@ -2595,86 +2121,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/mocha": { - "version": "10.7.3", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.3.tgz", - "integrity": "sha512-uQWxAu44wwiACGqjbPYmjo7Lg8sFrS3dQe7PP2FQI+woptP4vZXSMcfMyFL/e1yFEeEpV4RtyTpZROOKmxis+A==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-colors": "^4.1.3", - "browser-stdout": "^1.3.1", - "chokidar": "^3.5.3", - "debug": "^4.3.5", - "diff": "^5.2.0", - "escape-string-regexp": "^4.0.0", - "find-up": "^5.0.0", - "glob": "^8.1.0", - "he": "^1.2.0", - "js-yaml": "^4.1.0", - "log-symbols": "^4.1.0", - "minimatch": "^5.1.6", - "ms": "^2.1.3", - "serialize-javascript": "^6.0.2", - "strip-json-comments": "^3.1.1", - "supports-color": "^8.1.1", - "workerpool": "^6.5.1", - "yargs": "^16.2.0", - "yargs-parser": "^20.2.9", - "yargs-unparser": "^2.0.0" - }, - "bin": { - "_mocha": "bin/_mocha", - "mocha": "bin/mocha.js" - }, - "engines": { - "node": ">= 14.0.0" - } - }, - "node_modules/mocha/node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/mocha/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/mocha/node_modules/yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", - "dev": true, - "license": "MIT", - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.0", - "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -2689,16 +2135,6 @@ "dev": true, "license": "MIT" }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/normalize-url": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-8.0.1.tgz", @@ -2718,6 +2154,7 @@ "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "license": "ISC", + "peer": true, "dependencies": { "wrappy": "1" } @@ -2757,6 +2194,7 @@ "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "yocto-queue": "^0.1.0" }, @@ -2773,6 +2211,7 @@ "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "p-limit": "^3.0.2" }, @@ -2816,6 +2255,7 @@ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=8" } @@ -2842,16 +2282,6 @@ "node": ">=8" } }, - "node_modules/pathval": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", - "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 14.16" - } - }, "node_modules/picomatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", @@ -2934,42 +2364,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/readdirp/node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -3150,27 +2544,6 @@ "queue-microtask": "^1.2.2" } }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -3204,16 +2577,6 @@ "node": ">=10" } }, - "node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "dev": true, - "license": "BSD-3-Clause", - "dependencies": { - "randombytes": "^2.1.0" - } - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -3283,6 +2646,7 @@ "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=8" }, @@ -3290,22 +2654,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/supports-color": { - "version": "8.1.1", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", - "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/supports-color?sponsor=1" - } - }, "node_modules/symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", @@ -3376,60 +2724,6 @@ "typescript": ">=4.2.0" } }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, - "node_modules/ts-node/node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -3509,13 +2803,6 @@ "node": ">=0.8.0" } }, - "node_modules/undici-types": { - "version": "6.19.8", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", - "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true, - "license": "MIT" - }, "node_modules/universalify": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz", @@ -3548,13 +2835,6 @@ "requires-port": "^1.0.0" } }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, - "license": "MIT" - }, "node_modules/validator": { "version": "13.12.0", "resolved": "https://registry.npmjs.org/validator/-/validator-13.12.0.tgz", @@ -3653,13 +2933,6 @@ "node": ">=0.10.0" } }, - "node_modules/workerpool": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", - "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==", - "dev": true, - "license": "Apache-2.0" - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -3683,7 +2956,8 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true, - "license": "ISC" + "license": "ISC", + "peer": true }, "node_modules/ws": { "version": "8.18.0", @@ -3753,32 +3027,6 @@ "node": ">=12" } }, - "node_modules/yargs-parser": { - "version": "20.2.9", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", - "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", - "dev": true, - "license": "ISC", - "engines": { - "node": ">=10" - } - }, - "node_modules/yargs-unparser": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", - "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", - "dev": true, - "license": "MIT", - "dependencies": { - "camelcase": "^6.0.0", - "decamelize": "^4.0.0", - "flat": "^5.0.2", - "is-plain-obj": "^2.1.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/yargs/node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", @@ -3789,22 +3037,13 @@ "node": ">=12" } }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=10" }, diff --git a/package.json b/package.json index b2fa3b1..4e9ab8b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "description": "Userscript for uploading comment images", "scripts": { - "test": "mocha", + "test": "exit 0", "lint": "eslint src --fix", "clean": "rm -rf dist", "prebuild": "npm run lint && npm run clean", @@ -39,16 +39,10 @@ "devDependencies": { "@eslint/js": "^9.10.0", "@stylistic/eslint-plugin": "^2.7.2", - "@types/chai": "^4.3.19", - "@types/mocha": "^10.0.7", - "@types/node": "^22.5.4", "@types/tampermonkey": "^5.0.3", "@userscripters/generate-headers": "^3.4.1", "@userscripters/generate-readme": "^3.0.2", "@userscripters/stackexchange-global-types": "^2.8.2", - "chai": "^5.1.1", - "mocha": "^10.7.3", - "ts-node": "^10.9.2", "typescript": "^5.5.4", "typescript-eslint": "^8.4.0", "uglify-js": "^3.19.3" diff --git a/scripts/headers.sh b/scripts/headers.sh index dc24d8d..df189f5 100644 --- a/scripts/headers.sh +++ b/scripts/headers.sh @@ -5,6 +5,7 @@ output=$dist"/headers.js" generate-headers tampermonkey \ -o $output \ + -r "body" \ -m all meta "https://domain/questions/*" \ --pretty diff --git a/src/index.ts b/src/index.ts index 3b95554..33e936a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,14 +33,7 @@ async function uploadImage(file: File): Promise { return image; } -async function handleEvent(event: ClipboardEvent | DragEvent): Promise { - const target = event.target as HTMLTextAreaElement; - // image should be pasted in the comment box textarea - if (!target.matches("textarea.js-comment-text-input")) return; - - // https://dev.stackoverflow.com/content/js/wmd.en.js - event.preventDefault(); - +function findImage(event: ClipboardEvent | DragEvent): File | undefined { const items = event instanceof ClipboardEvent ? event.clipboardData?.items || event.clipboardData?.files : event.dataTransfer?.items || event.dataTransfer?.files; @@ -64,41 +57,102 @@ async function handleEvent(event: ClipboardEvent | DragEvent): Promise { // file size more than SE allows return; } + return file; +} + +async function insertText(file: File, textarea: HTMLTextAreaElement): Promise { + const start = textarea.selectionStart; + const end = textarea.selectionEnd; + + const replaceText = `[Uploading ${file.name}...]()`; + textarea.setRangeText( + replaceText, + start, + end, + "start", + ); + + const imageUrl = await uploadImage(file); + + const linkDescription = "enter image description here"; + textarea.setRangeText( + `[${linkDescription}](${imageUrl})`, + start, + start + replaceText.length, + "start", + ); + + textarea.setSelectionRange( + start + 1, // move past [ + start + 1 + linkDescription.length, + "forward", + ); +} + +async function handleEvent(event: ClipboardEvent | DragEvent): Promise { + const target = event.target as HTMLTextAreaElement; + // image should be pasted in the comment box textarea + if (!target.matches("textarea.js-comment-text-input")) return; + + // https://dev.stackoverflow.com/content/js/wmd.en.js + event.preventDefault(); + + const file = findImage(event); + if (!file) return; try { - const start = target.selectionStart; - const end = target.selectionEnd; - - const replaceText = `[Uploading ${file.name}...]()`; - target.setRangeText( - replaceText, - start, - end, - "start", - ); - - const imageUrl = await uploadImage(file); - console.log(imageUrl); - - const linkDescription = "enter image description here"; - target.setRangeText( - `[${linkDescription}](${imageUrl})`, - start, - start + replaceText.length, - "start", - ); - - target.setSelectionRange( - start + 1, // move past [ - start + 1 + linkDescription.length, - "forward", - ); + await insertText(file, target); } catch (error) { console.error(error); } } +function appendButton(location: HTMLElement): void { + const input = document.createElement("input"); + input.type = "file"; + + input.addEventListener("change", async () => { + const file = input.files?.[0]; + const textarea = location.querySelector("textarea.js-comment-text-input"); + + if (!file || !textarea) return; + + try { + await insertText(file, textarea as HTMLTextAreaElement); + } catch (error) { + console.error(error); + } + }); + + const uploadButton = document.createElement("button"); + uploadButton.classList.add("s-btn", "s-btn__link", "ta-left", "px2"); + uploadButton.type = "button"; + uploadButton.innerText = "Upload image"; + uploadButton.addEventListener("click", () => { + input.click(); + }); + + const helpLink = location.querySelector(".js-comment-help-link"); + if (!helpLink) return; + + helpLink.parentElement?.classList.add("g4"); // increase spacing + helpLink.before(uploadButton); +} + (() => { window.addEventListener("paste", handleEvent); window.addEventListener("drop", handleEvent); + + document + .querySelectorAll(".js-add-link") + .forEach((link) => { + link.addEventListener("click", () => { + setTimeout(() => { + const parent = link.closest(".post-layout--right"); + if (!parent) return; + + appendButton(parent); + }, 200); + }); + }); })(); diff --git a/test/index.spec.mjs b/test/index.spec.mjs deleted file mode 100644 index bde6859..0000000 --- a/test/index.spec.mjs +++ /dev/null @@ -1,7 +0,0 @@ -import { expect } from "chai"; - -describe("main", () => { - it('everything works ok', () => { - expect(true).to.be.true; - }); -}); \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index bf1a19d..c7695a5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,7 +5,7 @@ "allowJs": true, "checkJs": true, "lib": ["DOM", "DOM.Iterable", "ESNext"], - "target": "es2019", + "target": "es2023", "module": "CommonJS", "moduleResolution": "node", "noUnusedParameters": true, @@ -16,9 +16,7 @@ "outDir": "dist", "types": [ "@userscripters/stackexchange-global-types", - "jquery", - "tampermonkey", - "node" + "tampermonkey" ] }, "exclude": ["dist"],