This commit is contained in:
RossAscends
2023-07-14 01:46:26 +09:00
6 changed files with 42 additions and 121 deletions

90
package-lock.json generated
View File

@@ -38,7 +38,6 @@
"png-chunks-encode": "^1.0.0", "png-chunks-encode": "^1.0.0",
"png-chunks-extract": "^1.0.0", "png-chunks-extract": "^1.0.0",
"response-time": "^2.3.2", "response-time": "^2.3.2",
"rimraf": "^3.0.2",
"sanitize-filename": "^1.6.3", "sanitize-filename": "^1.6.3",
"sentencepiece-js": "^1.1.0", "sentencepiece-js": "^1.1.0",
"simple-git": "^3.19.1", "simple-git": "^3.19.1",
@@ -786,11 +785,6 @@
"proxy-from-env": "^1.1.0" "proxy-from-env": "^1.1.0"
} }
}, },
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
"node_modules/base64-js": { "node_modules/base64-js": {
"version": "1.5.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -871,15 +865,6 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/braces": { "node_modules/braces": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
@@ -1062,11 +1047,6 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
},
"node_modules/concat-stream": { "node_modules/concat-stream": {
"version": "1.6.2", "version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
@@ -1572,11 +1552,6 @@
"node": ">=10" "node": ">=10"
} }
}, },
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
@@ -1619,25 +1594,6 @@
"integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==",
"dev": true "dev": true
}, },
"node_modules/glob": {
"version": "7.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.1.1",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": "*"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/glob-parent": { "node_modules/glob-parent": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
@@ -1841,15 +1797,6 @@
"@types/node": "16.9.1" "@types/node": "16.9.1"
} }
}, },
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"node_modules/inherits": { "node_modules/inherits": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
@@ -2165,17 +2112,6 @@
"dom-walk": "^0.1.0" "dom-walk": "^0.1.0"
} }
}, },
"node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/minimist": { "node_modules/minimist": {
"version": "1.2.8", "version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
@@ -2398,6 +2334,7 @@
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"dev": true,
"dependencies": { "dependencies": {
"wrappy": "1" "wrappy": "1"
} }
@@ -2476,14 +2413,6 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/path-parse": { "node_modules/path-parse": {
"version": "1.0.7", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
@@ -3015,20 +2944,6 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"dependencies": {
"glob": "^7.1.3"
},
"bin": {
"rimraf": "bin.js"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/run-parallel": { "node_modules/run-parallel": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
@@ -3605,7 +3520,8 @@
"node_modules/wrappy": { "node_modules/wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true
}, },
"node_modules/ws": { "node_modules/ws": {
"version": "8.13.0", "version": "8.13.0",

View File

@@ -29,7 +29,6 @@
"png-chunks-encode": "^1.0.0", "png-chunks-encode": "^1.0.0",
"png-chunks-extract": "^1.0.0", "png-chunks-extract": "^1.0.0",
"response-time": "^2.3.2", "response-time": "^2.3.2",
"rimraf": "^3.0.2",
"sanitize-filename": "^1.6.3", "sanitize-filename": "^1.6.3",
"sentencepiece-js": "^1.1.0", "sentencepiece-js": "^1.1.0",
"simple-git": "^3.19.1", "simple-git": "^3.19.1",

View File

@@ -2868,9 +2868,9 @@
<div class="tags rm_tag_filter"></div> <div class="tags rm_tag_filter"></div>
</div> </div>
<!-- a div containing a dynamically updated count of characters currently displayed --> <!-- a div containing a dynamically updated count of characters currently displayed -->
<div class="flex-container"> <div class="flex-container alignitemscenter">
<div id="rm_character_count"></div> <div id="rm_character_count"></div>
<i id="charListGridToggle" class="fa-solid fa-table-cells-large menu_button"></i> <i id="charListGridToggle" class="fa-solid fa-table-cells-large menu_button" title="Toggle character grid view"></i>
</div> </div>
<hr> <hr>
</div> </div>
@@ -3681,4 +3681,4 @@
</script> </script>
</body> </body>
</html> </html>

View File

@@ -7132,9 +7132,11 @@ $(document).ready(function () {
" -- Name: " + " -- Name: " +
characters[this_chid].name characters[this_chid].name
); );
const delete_chats = !!$("#del_char_checkbox").prop("checked");
const avatar = characters[this_chid].avatar; const avatar = characters[this_chid].avatar;
const name = characters[this_chid].name; const name = characters[this_chid].name;
var msg = jQuery("#form_create").serialize(); // ID form const msg = new FormData($("#form_create").get(0)); // ID form
msg.append("delete_chats", delete_chats);
jQuery.ajax({ jQuery.ajax({
method: "POST", method: "POST",
url: "/deletecharacter", url: "/deletecharacter",
@@ -7142,6 +7144,8 @@ $(document).ready(function () {
}, },
data: msg, data: msg,
cache: false, cache: false,
contentType: false,
processData: false,
success: async function (html) { success: async function (html) {
//RossAscends: New handling of character deletion that avoids page refreshes and should have //RossAscends: New handling of character deletion that avoids page refreshes and should have
// fixed char corruption due to cache problems. // fixed char corruption due to cache problems.
@@ -7259,8 +7263,10 @@ $(document).ready(function () {
callPopup(` callPopup(`
<h3>Delete the character?</h3> <h3>Delete the character?</h3>
<b>THIS IS PERMANENT!<br><br> <b>THIS IS PERMANENT!<br><br>
THIS WILL ALSO DELETE ALL<br> <label for="del_char_checkbox" class="checkbox_label justifyCenter">
OF THE CHARACTER'S CHAT FILES.<br><br></b>` <input type="checkbox" id="del_char_checkbox" checked />
<span>Also delete the chat files</span>
</label><br></b>`
); );
}); });

View File

@@ -1197,6 +1197,7 @@ input[type="file"] {
flex-grow: 1; flex-grow: 1;
display: flex; display: flex;
/* row-gap: 5px; */ /* row-gap: 5px; */
justify-content: space-between;
} }
#rm_ch_create_block { #rm_ch_create_block {
@@ -5274,4 +5275,4 @@ body.waifuMode .zoomed_avatar {
background-color: var(--SmartThemeBlurTintColor); background-color: var(--SmartThemeBlurTintColor);
text-align: center; text-align: center;
line-height: 14px; line-height: 14px;
} }

View File

@@ -43,7 +43,6 @@ const fs = require('fs');
const readline = require('readline'); const readline = require('readline');
const open = require('open'); const open = require('open');
const rimraf = require("rimraf");
const multer = require("multer"); const multer = require("multer");
const http = require("http"); const http = require("http");
const https = require('https'); const https = require('https');
@@ -1078,7 +1077,7 @@ app.post("/editcharacterattribute", jsonParser, async function (request, respons
} }
}); });
app.post("/deletecharacter", urlencodedParser, function (request, response) { app.post("/deletecharacter", urlencodedParser, async function (request, response) {
if (!request.body || !request.body.avatar_url) { if (!request.body || !request.body.avatar_url) {
return response.sendStatus(400); return response.sendStatus(400);
} }
@@ -1102,16 +1101,16 @@ app.post("/deletecharacter", urlencodedParser, function (request, response) {
return response.sendStatus(403); return response.sendStatus(403);
} }
rimraf(path.join(chatsPath, sanitize(dir_name)), (err) => { if (request.body.delete_chats == 'true') {
if (err) { try {
response.send(err); await fs.promises.rm(path.join(chatsPath, sanitize(dir_name)), { recursive: true, force: true })
return console.log(err); } catch (err) {
} else { console.error(err);
//response.redirect("/"); return response.sendStatus(500);
response.send('ok');
} }
}); }
return response.sendStatus(200);
}); });
async function charaWrite(img_url, data, target_img, response = undefined, mes = 'ok', crop = undefined) { async function charaWrite(img_url, data, target_img, response = undefined, mes = 'ok', crop = undefined) {
@@ -2768,7 +2767,7 @@ app.post('/poe_suggest', jsonParser, async function (request, response) {
* If the folder is called third-party, search for subfolders instead * If the folder is called third-party, search for subfolders instead
*/ */
app.get('/discover_extensions', jsonParser, function (_, response) { app.get('/discover_extensions', jsonParser, function (_, response) {
// get all folders in the extensions folder, except third-party // get all folders in the extensions folder, except third-party
const extensions = fs const extensions = fs
.readdirSync(directories.extensions) .readdirSync(directories.extensions)
@@ -4444,7 +4443,7 @@ async function getImageBuffers(zipFilePath) {
/** /**
* This function extracts the extension information from the manifest file. * This function extracts the extension information from the manifest file.
* @param {string} extensionPath - The path of the extension folder * @param {string} extensionPath - The path of the extension folder
* @returns {Object} - Returns the manifest data as an object * @returns {Object} - Returns the manifest data as an object
@@ -4473,7 +4472,7 @@ async function checkIfRepoIsUpToDate(extensionPath) {
// Fetch remote repository information // Fetch remote repository information
const remotes = await git.cwd(extensionPath).getRemotes(true); const remotes = await git.cwd(extensionPath).getRemotes(true);
return { return {
isUpToDate: log.total === 0, isUpToDate: log.total === 0,
remoteUrl: remotes[0].refs.fetch, // URL of the remote repository remoteUrl: remotes[0].refs.fetch, // URL of the remote repository
@@ -4488,7 +4487,7 @@ async function checkIfRepoIsUpToDate(extensionPath) {
* *
* @param {Object} request - HTTP Request object, expects a JSON body with a 'url' property. * @param {Object} request - HTTP Request object, expects a JSON body with a 'url' property.
* @param {Object} response - HTTP Response object used to respond to the HTTP request. * @param {Object} response - HTTP Response object used to respond to the HTTP request.
* *
* @returns {void} * @returns {void}
*/ */
app.post('/get_extension', jsonParser, async (request, response) => { app.post('/get_extension', jsonParser, async (request, response) => {
@@ -4526,14 +4525,14 @@ app.post('/get_extension', jsonParser, async (request, response) => {
}); });
/** /**
* HTTP POST handler function to pull the latest updates from a git repository * HTTP POST handler function to pull the latest updates from a git repository
* based on the extension name provided in the request body. It returns the latest commit hash, * based on the extension name provided in the request body. It returns the latest commit hash,
* the path of the extension, the status of the repository (whether it's up-to-date or not), * the path of the extension, the status of the repository (whether it's up-to-date or not),
* and the remote URL of the repository. * and the remote URL of the repository.
* *
* @param {Object} request - HTTP Request object, expects a JSON body with an 'extensionName' property. * @param {Object} request - HTTP Request object, expects a JSON body with an 'extensionName' property.
* @param {Object} response - HTTP Response object used to respond to the HTTP request. * @param {Object} response - HTTP Response object used to respond to the HTTP request.
* *
* @returns {void} * @returns {void}
*/ */
app.post('/update_extension', jsonParser, async (request, response) => { app.post('/update_extension', jsonParser, async (request, response) => {
@@ -4578,7 +4577,7 @@ app.post('/update_extension', jsonParser, async (request, response) => {
* *
* @param {Object} request - HTTP Request object, expects a JSON body with an 'extensionName' property. * @param {Object} request - HTTP Request object, expects a JSON body with an 'extensionName' property.
* @param {Object} response - HTTP Response object used to respond to the HTTP request. * @param {Object} response - HTTP Response object used to respond to the HTTP request.
* *
* @returns {void} * @returns {void}
*/ */
app.post('/get_extension_version', jsonParser, async (request, response) => { app.post('/get_extension_version', jsonParser, async (request, response) => {
@@ -4586,17 +4585,17 @@ app.post('/get_extension_version', jsonParser, async (request, response) => {
if (!request.body.extensionName) { if (!request.body.extensionName) {
return response.status(400).send('Bad Request: extensionName is required in the request body.'); return response.status(400).send('Bad Request: extensionName is required in the request body.');
} }
try { try {
const extensionName = request.body.extensionName; const extensionName = request.body.extensionName;
const extensionPath = path.join(directories.extensions, 'third-party', extensionName); const extensionPath = path.join(directories.extensions, 'third-party', extensionName);
if (!fs.existsSync(extensionPath)) { if (!fs.existsSync(extensionPath)) {
return response.status(404).send(`Directory does not exist at ${extensionPath}`); return response.status(404).send(`Directory does not exist at ${extensionPath}`);
} }
const currentBranch = await git.cwd(extensionPath).branch(); const currentBranch = await git.cwd(extensionPath).branch();
// get only the working branch // get only the working branch
const currentBranchName = currentBranch.current; const currentBranchName = currentBranch.current;
await git.cwd(extensionPath).fetch('origin'); await git.cwd(extensionPath).fetch('origin');
const currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']); const currentCommitHash = await git.cwd(extensionPath).revparse(['HEAD']);
@@ -4604,7 +4603,7 @@ app.post('/get_extension_version', jsonParser, async (request, response) => {
const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath); const { isUpToDate, remoteUrl } = await checkIfRepoIsUpToDate(extensionPath);
return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl }); return response.send({ currentBranchName, currentCommitHash, isUpToDate, remoteUrl });
} catch (error) { } catch (error) {
console.log('Getting extension version failed', error); console.log('Getting extension version failed', error);
return response.status(500).send(`Server Error: ${error.message}`); return response.status(500).send(`Server Error: ${error.message}`);
@@ -4617,7 +4616,7 @@ app.post('/get_extension_version', jsonParser, async (request, response) => {
* *
* @param {Object} request - HTTP Request object, expects a JSON body with a 'url' property. * @param {Object} request - HTTP Request object, expects a JSON body with a 'url' property.
* @param {Object} response - HTTP Response object used to respond to the HTTP request. * @param {Object} response - HTTP Response object used to respond to the HTTP request.
* *
* @returns {void} * @returns {void}
*/ */
app.post('/delete_extension', jsonParser, async (request, response) => { app.post('/delete_extension', jsonParser, async (request, response) => {