diff --git a/public/script.js b/public/script.js index 6b80b330c..73314902d 100644 --- a/public/script.js +++ b/public/script.js @@ -145,7 +145,7 @@ import { Stopwatch, } from './scripts/utils.js'; -import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, processExtensionHelpers, registerExtensionHelper, renderExtensionTemplate, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js'; +import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, renderExtensionTemplate, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js'; import { COMMENT_NAME_DEFAULT, executeSlashCommands, getSlashCommandsHelp, processChatSlashCommands, registerSlashCommand } from './scripts/slash-commands.js'; import { tag_map, @@ -338,8 +338,6 @@ export const event_types = { export const eventSource = new EventEmitter(); -eventSource.on(event_types.MESSAGE_RECEIVED, processExtensionHelpers); -eventSource.on(event_types.MESSAGE_SENT, processExtensionHelpers); eventSource.on(event_types.CHAT_CHANGED, processChatSlashCommands); const characterGroupOverlay = new BulkEditOverlay(); @@ -7164,7 +7162,10 @@ window['SillyTavern'].getContext = function () { saveReply, registerSlashCommand: registerSlashCommand, executeSlashCommands: executeSlashCommands, - registerHelper: registerExtensionHelper, + /** + * @deprecated Handlebars for extensions are no longer supported. + */ + registerHelper: () => {}, registedDebugFunction: registerDebugFunction, renderExtensionTemplate: renderExtensionTemplate, callPopup: callPopup, diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js index 3ce240060..120791842 100644 --- a/public/scripts/extensions.js +++ b/public/scripts/extensions.js @@ -47,8 +47,6 @@ export function saveMetadataDebounced() { }, 1000); } -export const extensionsHandlebars = Handlebars.create(); - /** * Provides an ability for extensions to render HTML templates. * Templates sanitation and localization is forced. @@ -61,40 +59,6 @@ export function renderExtensionTemplate(extensionName, templateId, templateData return renderTemplate(`scripts/extensions/${extensionName}/${templateId}.html`, templateData, sanitize, localize, true); } -/** - * Registers a Handlebars helper for use in extensions. - * @param {string} name Handlebars helper name - * @param {function} helper Handlebars helper function - */ -export function registerExtensionHelper(name, helper) { - extensionsHandlebars.registerHelper(name, helper); -} - -/** - * Applies handlebars extension helpers to a message. - * @param {number} messageId Message index in the chat. - */ -export function processExtensionHelpers(messageId) { - const context = getContext(); - const message = context.chat[messageId]; - - if (!message?.mes || typeof message.mes !== 'string') { - return; - } - - // Don't waste time if there are no mustaches - if (!substituteParams(message.mes).includes('{{')) { - return; - } - - try { - const template = extensionsHandlebars.compile(substituteParams(message.mes), { noEscape: true }); - message.mes = template({}); - } catch { - // Ignore - } -} - // Disables parallel updates class ModuleWorkerWrapper { constructor(callback) {