[feat] Add reactive feature flags foundation (#4817)

This commit is contained in:
Christian Byrne
2025-08-07 13:06:29 -07:00
committed by Jin Yi
parent 808adc06ac
commit b7f778bfc8
3 changed files with 162 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import axios from 'axios'
import get from 'lodash/get'
import defaultClientFeatureFlags from '@/config/clientFeatureFlags.json'
import type {
@@ -1082,21 +1083,21 @@ export class ComfyApi extends EventTarget {
/**
* Checks if the server supports a specific feature.
* @param featureName The name of the feature to check
* @param featureName The name of the feature to check (supports dot notation for nested values)
* @returns true if the feature is supported, false otherwise
*/
serverSupportsFeature(featureName: string): boolean {
return this.serverFeatureFlags[featureName] === true
return get(this.serverFeatureFlags, featureName) === true
}
/**
* Gets a server feature flag value.
* @param featureName The name of the feature to get
* @param featureName The name of the feature to get (supports dot notation for nested values)
* @param defaultValue The default value if the feature is not found
* @returns The feature value or default
*/
getServerFeature<T = unknown>(featureName: string, defaultValue?: T): T {
return (this.serverFeatureFlags[featureName] ?? defaultValue) as T
return get(this.serverFeatureFlags, featureName, defaultValue) as T
}
/**