Always show extension panel in settings dialog (#2002)

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chenlei Hu
2024-12-20 16:30:11 -08:00
committed by GitHub
parent ca9627cada
commit 72f7c3101d
9 changed files with 23 additions and 30 deletions

View File

@@ -9,6 +9,16 @@ import { useMenuItemStore } from './menuItemStore'
import { useBottomPanelStore } from './workspace/bottomPanelStore'
import { useWidgetStore } from './widgetStore'
/**
* These extensions are always active, even if they are disabled in the setting.
* TODO(https://github.com/Comfy-Org/ComfyUI_frontend/issues/1996):
* Migrate logic to out of extensions/core, as features provided
* by these extensions are now essential to core.
*/
export const ALWAYS_ENABLED_EXTENSIONS: readonly string[] = [
'Comfy.ColorPalette'
]
export const useExtensionStore = defineStore('extension', () => {
// For legacy reasons, the name uniquely identifies an extension
const extensionByName = ref<Record<string, ComfyExtension>>({})
@@ -32,6 +42,10 @@ export const useExtensionStore = defineStore('extension', () => {
return extensions.value.filter((ext) => isExtensionEnabled(ext.name))
})
function isExtensionAlwaysEnabled(name: string) {
return ALWAYS_ENABLED_EXTENSIONS.includes(name)
}
function registerExtension(extension: ComfyExtension) {
if (!extension.name) {
throw new Error("Extensions must have a 'name' property.")
@@ -80,6 +94,10 @@ export const useExtensionStore = defineStore('extension', () => {
// allowed since v1.3.12.
// https://github.com/Comfy-Org/ComfyUI_frontend/issues/1176
disabledExtensionNames.value.add('pysssss.SnapToGrid')
for (const name of ALWAYS_ENABLED_EXTENSIONS) {
disabledExtensionNames.value.delete(name)
}
}
// Some core extensions are registered before the store is initialized, e.g.
@@ -95,6 +113,7 @@ export const useExtensionStore = defineStore('extension', () => {
enabledExtensions,
inactiveDisabledExtensionNames,
isExtensionEnabled,
isExtensionAlwaysEnabled,
registerExtension,
loadDisabledExtensionNames
}