Refactor manifests sorting
| @@ -38,6 +38,7 @@ export let modules = []; | ||
| 38 | 38 | let activeExtensions = new Set(); |
| 39 | 39 | |
| 40 | 40 | const getApiUrl = () => extension_settings.apiUrl; |
| 41 | +const sortManifests = (a, b) => a.loading_order - b.loading_order; | |
| 41 | 42 | let connectedToApi = false; |
| 42 | 43 | |
| 43 | 44 | /** |
| @@ -354,7 +355,7 @@ async function getManifests(names) { | ||
| 354 | 355 | * @returns {Promise<void>} |
| 355 | 356 | */ |
| 356 | 357 | async function activateExtensions() { |
| 357 | 358 | const extensions = Object.entries(manifests).sort((a, b) => sortManifests(a[1].loading_order -, b[1].loading_order)); |
| 358 | 359 | const promises = []; |
| 359 | 360 | |
| 360 | 361 | for (let entry of extensions) { |
| @@ -705,7 +706,7 @@ async function showExtensionsDetails() { | ||
| 705 | 706 | |
| 706 | 707 | htmlExternal.append(htmlLoading); |
| 707 | 708 | |
| 708 | 709 | const extensions = Object.entries(manifests).sort((a, b) => sortManifests(a[1].loading_order -, b[1].loading_order)).map(getExtensionData); |
| 709 | 710 | |
| 710 | 711 | extensions.forEach(value => { |
| 711 | 712 | const { isExternal, extensionHtml } = value; |
| @@ -1071,7 +1072,7 @@ function processVersionCheckQueue() { | ||
| 1071 | 1072 | */ |
| 1072 | 1073 | async function checkForUpdatesManual(abortSignal) { |
| 1073 | 1074 | const promises = []; |
| 1074 | 1075 | for (const id of Object.keys(manifests).filter(x => x.startsWith('third-party')).sort((a, b) => sortManifests(manifests[a], manifests[b]))) { |
| 1075 | 1076 | const externalId = id.replace('third-party', ''); |
| 1076 | 1077 | const promise = enqueueVersionCheck(async () => { |
| 1077 | 1078 | try { |
| @@ -1215,7 +1216,7 @@ export async function runGenerationInterceptors(chat, contextSize) { | ||
| 1215 | 1216 | exitImmediately = immediately; |
| 1216 | 1217 | }; |
| 1217 | 1218 | |
| 1218 | 1219 | for (const manifest of Object.values(manifests).filter(x => x.generate_interceptor).sort((a, b) => sortManifests(a.loading_order -, b.loading_order))) { |
| 1219 | 1220 | const interceptorKey = manifest.generate_interceptor; |
| 1220 | 1221 | if (typeof globalThis[interceptorKey] === 'function') { |
| 1221 | 1222 | try { |