Spaces:
Paused
Paused
Download packages/core/src/utils/feature.ts from f4b404/aiostreams: direct link, hf CLI and curl.
- Browser
- Download file 1.58 kB
-
https://huggingface.co/spaces/f4b404/aiostreams/resolve/main/packages/core/src/utils/feature.ts
- Command line
-
hf download hf://spaces/f4b404/aiostreams/packages/core/src/utils/feature.ts
-
curl -L -o feature.ts https://huggingface.co/spaces/f4b404/aiostreams/resolve/main/packages/core/src/utils/feature.ts
1.58 kB
| import { config } from '../config/index.js'; | |
| import { StreamType } from './constants.js'; | |
| const DEFAULT_REASON = 'Disabled by owner of the instance'; | |
| function parseReasonMap(input: Record<string, string>): Map<string, string> { | |
| const map = new Map<string, string>(); | |
| for (const [key, reason] of Object.entries(input)) { | |
| const trimmedKey = key.trim(); | |
| if (!trimmedKey) continue; | |
| map.set(trimmedKey, reason?.trim() || DEFAULT_REASON); | |
| } | |
| return map; | |
| } | |
| /** | |
| * Manages instance-level feature controls: | |
| * - Disabled hosts, addons, services, and stream types | |
| * - Regex filter access level | |
| * | |
| * All values are derived from the live runtime config snapshot, so changes via | |
| * the settings UI are picked up after a `settingsStore.refreshIfChanged()`. | |
| */ | |
| export class FeatureControl { | |
| public static get disabledHosts(): Map<string, string> { | |
| return parseReasonMap(config.userLimits.disabled.hosts); | |
| } | |
| public static get disabledAddons(): Map<string, string> { | |
| return parseReasonMap(config.userLimits.disabled.addons); | |
| } | |
| public static get removedAddons(): Map<string, string> { | |
| return parseReasonMap(config.userLimits.disabled.removedAddons); | |
| } | |
| public static get disabledServices(): Map<string, string> { | |
| return parseReasonMap(config.userLimits.disabled.services); | |
| } | |
| public static get disabledStreamTypes(): Set<StreamType> { | |
| return new Set(config.userLimits.disabled.streamTypes as StreamType[]); | |
| } | |
| public static get regexFilterAccess(): 'none' | 'trusted' | 'all' { | |
| return config.userLimits.regex.access; | |
| } | |
| } | |