Refactor manifests sorting

62be0939d01c1144bedb5ee9f98aedf5157fe5f0

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +5 -4Ignore whitespace
public/scripts/extensions.js+5 -4
@@ -38,6 +38,7 @@ export let modules = [];
3838let activeExtensions = new Set();
3939
4040const getApiUrl = () => extension_settings.apiUrl;
41+const sortManifests = (a, b) => a.loading_order - b.loading_order;
4142let connectedToApi = false;
4243
4344/**
@@ -354,7 +355,7 @@ async function getManifests(names) {
354355 * @returns {Promise<void>}
355356 */
356357async function activateExtensions() {
357358 const extensions = Object.entries(manifests).sort((a, b) => sortManifests(a[1].loading_order -, b[1].loading_order));
358359 const promises = [];
359360
360361 for (let entry of extensions) {
@@ -705,7 +706,7 @@ async function showExtensionsDetails() {
705706
706707 htmlExternal.append(htmlLoading);
707708
708709 const extensions = Object.entries(manifests).sort((a, b) => sortManifests(a[1].loading_order -, b[1].loading_order)).map(getExtensionData);
709710
710711 extensions.forEach(value => {
711712 const { isExternal, extensionHtml } = value;
@@ -1071,7 +1072,7 @@ function processVersionCheckQueue() {
10711072 */
10721073async function checkForUpdatesManual(abortSignal) {
10731074 const promises = [];
10741075 for (const id of Object.keys(manifests).filter(x => x.startsWith('third-party')).sort((a, b) => sortManifests(manifests[a], manifests[b]))) {
10751076 const externalId = id.replace('third-party', '');
10761077 const promise = enqueueVersionCheck(async () => {
10771078 try {
@@ -1215,7 +1216,7 @@ export async function runGenerationInterceptors(chat, contextSize) {
12151216 exitImmediately = immediately;
12161217 };
12171218
12181219 for (const manifest of Object.values(manifests).filter(x => x.generate_interceptor).sort((a, b) => sortManifests(a.loading_order -, b.loading_order))) {
12191220 const interceptorKey = manifest.generate_interceptor;
12201221 if (typeof globalThis[interceptorKey] === 'function') {
12211222 try {