mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-02 03:30:04 +00:00
refactor: load extensions dynamically according to the configuration file
This commit is contained in:
committed by
Alexander Brown
parent
ddbd26c062
commit
bb2c99749a
32
src/extensions/dispatch.ts
Normal file
32
src/extensions/dispatch.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import type {
|
||||
ComfyExtensionConfigs,
|
||||
ComfyExtensionEntrance,
|
||||
ComfyExtensionLoadContext
|
||||
} from './types'
|
||||
import { formatExtensions, shouldLoadExtension } from './utils'
|
||||
|
||||
const extLoadContext: ComfyExtensionLoadContext = {
|
||||
get isCloud() {
|
||||
return isCloud
|
||||
},
|
||||
get subscriptionRequired() {
|
||||
return !!window.__CONFIG__?.subscription_required
|
||||
}
|
||||
}
|
||||
|
||||
export async function dispatchComfyExtensions(options: {
|
||||
configs: ComfyExtensionConfigs
|
||||
entrance: ComfyExtensionEntrance
|
||||
}) {
|
||||
const { configs, entrance } = options
|
||||
const extensions = formatExtensions(entrance, configs)
|
||||
for (const extension of Object.values(extensions)) {
|
||||
if (shouldLoadExtension(extLoadContext, extension.config)) {
|
||||
const module = await extension.entry()
|
||||
console.log('✅ extension', extension.name, 'loaded', extension, module)
|
||||
} else {
|
||||
console.log('❌ extension', extension.name, 'disabled', extension.config)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user