![img1]()
diff --git a/public/script.js b/public/script.js
index 35faf6c58..80b6b7c5d 100644
--- a/public/script.js
+++ b/public/script.js
@@ -784,6 +784,15 @@ function messageFormating(mes, ch_name, isSystem, forceAvatar) {
return mes;
}
+function getMessageFromTemplate(mesId, characterName, isUser, avatarImg, bias) {
+ const mes = $('#message_template .mes').clone();
+ mes.attr({ 'mesid': mesId, 'ch_name': characterName, 'is_user': isUser });
+ mes.find('.avatar img').attr('src', avatarImg);
+ mes.find('.ch_name .name_text').text(characterName);
+ mes.find('.mes_bias').html(bias);
+ return mes;
+}
+
function appendImageToMessage(mes, messageElement) {
if (mes.extra?.image) {
const image = document.createElement("img");
@@ -830,34 +839,7 @@ function addOneMessage(mes, type = "normal") {
);
const bias = messageFormating(mes.extra?.bias ?? "");
- var HTMLForEachMes =
- '
' +
- '
' +
- '
' +
- '
' +
- '

' +
- '
' +
- '
' +
- '

' +
- '
' +
- '
' +
- '
' +
- characterName +
- '
' +
- '
' +
- '

' +
- '
' +
- '
' +
- '

' +
- '
' +
- '
' +
- '
' +
- '
' +
- '
' + bias + '
' +
- '
' +
- '

' +
- '
' +
- '
';
+ var HTMLForEachMes = getMessageFromTemplate(count_view_mes, characterName, mes.is_user, avatarImg, bias);
if (type !== 'swipe') {
$("#chat").append(HTMLForEachMes);
diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js
index 81116e450..82a6f043a 100644
--- a/public/scripts/extensions.js
+++ b/public/scripts/extensions.js
@@ -5,20 +5,8 @@ export {
defaultRequestArgs,
};
-import * as captionManifest from "./extensions/caption/manifest.json" assert {type: 'json'};
-import * as diceManifest from "./extensions/dice/manifest.json" assert {type: 'json'};
-import * as expressionsManifest from "./extensions/expressions/manifest.json" assert {type: 'json'};
-import * as floatingPromptManifest from "./extensions/floating-prompt/manifest.json" assert {type: 'json'};
-import * as memoryManifest from "./extensions/memory/manifest.json" assert {type: 'json'};
-
-const manifests = {
- 'floating-prompt': floatingPromptManifest.default,
- 'dice': diceManifest.default,
- 'caption': captionManifest.default,
- 'expressions': expressionsManifest.default,
- 'memory': memoryManifest.default,
-};
-
+const extensionNames = ['caption', 'dice', 'expressions', 'floating-prompt', 'memory'];
+const manifests = await getManifests(extensionNames);
const extensions_urlKey = 'extensions_url';
const extensions_autoConnectKey = 'extensions_autoconnect';
let modules = [];
@@ -30,6 +18,19 @@ const defaultUrl = "http://localhost:5100";
const defaultRequestArgs = { method: 'GET', headers: { 'Bypass-Tunnel-Reminder': 'bypass' } };
let connectedToApi = false;
+async function getManifests(names) {
+ const obj = {};
+ for (const name of names) {
+ const response = await fetch(`/scripts/extensions/${name}/manifest.json`);
+
+ if (response.ok) {
+ const json = await response.json();
+ obj[name] = json;
+ }
+ }
+ return obj;
+}
+
async function activateExtensions() {
const extensions = Object.entries(manifests).sort((a, b) => a[1].loading_order - b[1].loading_order);
diff --git a/public/style.css b/public/style.css
index bc326c7b4..320792711 100644
--- a/public/style.css
+++ b/public/style.css
@@ -363,6 +363,10 @@ code {
}
+#message_template {
+ display: none !important;
+}
+
.mes {
display: grid;