feat: add getExtensionManifest() to extensions.js and expose via getContext() (#5442) Returns a structuredClone of the loaded manifest for the given extension name. Accepts either the short name or full internal key (third-party/...). Returns null if the extension is not registered.

a7f144f28b43490cac66b3e618d557d8bc991358

Wolfsblvt <wolfsblvt@gmail.com>

Signed
2 files changed, +17 -0Ignore whitespace
public/scripts/extensions.js+15 -0
@@ -474,6 +474,21 @@ export function findExtension(name) {
474}474}
475475
476/**476/**
477 * Returns a deep clone of the manifest for the given extension name.
478 * Accepts either the short name (e.g. `SillyTavern-MyExtension`) or the full internal key
479 * (e.g. `third-party/SillyTavern-MyExtension`). Returns null if the extension is not found.
480 * @param {string} name - Extension name or internal key
481 * @returns {object|null} Cloned manifest object, or null if not found
482 */
483export function getExtensionManifest(name) {
484 const found = extensionNames.find(extName =>
485 equalsIgnoreCaseAndAccents(extName, name) || equalsIgnoreCaseAndAccents(extName, `third-party/${name}`),
486 );
487 const manifest = found ? manifests[found] : null;
488 return manifest ? structuredClone(manifest) : null;
489}
490
491/**
477 * Loads manifest.json files for extensions.492 * Loads manifest.json files for extensions.
478 * @param {string[]} names Array of extension names493 * @param {string[]} names Array of extension names
479 * @returns {Promise<Record<string, object>>} Object with extension names as keys and their manifests as values494 * @returns {Promise<Record<string, object>>} Object with extension names as keys and their manifests as values
public/scripts/st-context.js+2 -0
@@ -71,6 +71,7 @@ import {
71} from '../script.js';71} from '../script.js';
72import {72import {
73 extension_settings,73 extension_settings,
74 getExtensionManifest,
74 ModuleWorkerWrapper,75 ModuleWorkerWrapper,
75 openThirdPartyExtensionMenu,76 openThirdPartyExtensionMenu,
76 renderExtensionTemplate,77 renderExtensionTemplate,
@@ -290,6 +291,7 @@ export function getContext() {
290 getReasoningTemplateByName,291 getReasoningTemplateByName,
291 unshallowCharacter,292 unshallowCharacter,
292 unshallowGroupMembers,293 unshallowGroupMembers,
294 getExtensionManifest,
293 openThirdPartyExtensionMenu,295 openThirdPartyExtensionMenu,
294 symbols: {296 symbols: {
295 ignore: IGNORE_SYMBOL,297 ignore: IGNORE_SYMBOL,