2025-12-09 22:58:16 +02:00
|
|
|
import { t } from "./i18n";
|
2025-12-09 19:42:37 +02:00
|
|
|
import options from "./options";
|
|
|
|
|
|
2025-12-09 19:34:03 +02:00
|
|
|
interface ExperimentalFeature {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
description: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-09 20:48:54 +02:00
|
|
|
export const experimentalFeatures = [
|
2025-12-09 19:34:03 +02:00
|
|
|
{
|
2025-12-09 19:42:37 +02:00
|
|
|
id: "new-layout",
|
2025-12-09 22:58:16 +02:00
|
|
|
name: t("experimental_features.new_layout_name"),
|
|
|
|
|
description: t("experimental_features.new_layout_description"),
|
2025-12-09 19:34:03 +02:00
|
|
|
}
|
2025-12-09 20:48:54 +02:00
|
|
|
] as const satisfies ExperimentalFeature[];
|
2025-12-09 19:42:37 +02:00
|
|
|
|
|
|
|
|
type ExperimentalFeatureId = typeof experimentalFeatures[number]["id"];
|
|
|
|
|
|
|
|
|
|
let enabledFeatures: Set<ExperimentalFeatureId> | null = null;
|
|
|
|
|
|
|
|
|
|
export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId): boolean {
|
2025-12-09 19:51:53 +02:00
|
|
|
return getEnabledFeatures().has(featureId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getEnabledExperimentalFeatureIds() {
|
|
|
|
|
return getEnabledFeatures().values();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getEnabledFeatures() {
|
2025-12-09 19:42:37 +02:00
|
|
|
if (!enabledFeatures) {
|
2025-12-09 22:43:39 +02:00
|
|
|
let features: ExperimentalFeatureId[] = [];
|
|
|
|
|
try {
|
|
|
|
|
features = JSON.parse(options.get("experimentalFeatures")) as ExperimentalFeatureId[];
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.warn("Failed to parse experimental features from options:", e);
|
|
|
|
|
}
|
2025-12-09 19:42:37 +02:00
|
|
|
enabledFeatures = new Set(features);
|
|
|
|
|
}
|
2025-12-09 19:51:53 +02:00
|
|
|
return enabledFeatures;
|
2025-12-09 19:42:37 +02:00
|
|
|
}
|