mirror of
https://github.com/zadam/trilium.git
synced 2025-12-12 02:14:25 +01:00
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { t } from "./i18n";
|
|
import options from "./options";
|
|
|
|
interface ExperimentalFeature {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
}
|
|
|
|
export const experimentalFeatures = [
|
|
{
|
|
id: "new-layout",
|
|
name: t("experimental_features.new_layout_name"),
|
|
description: t("experimental_features.new_layout_description"),
|
|
}
|
|
] as const satisfies ExperimentalFeature[];
|
|
|
|
type ExperimentalFeatureId = typeof experimentalFeatures[number]["id"];
|
|
|
|
let enabledFeatures: Set<ExperimentalFeatureId> | null = null;
|
|
|
|
export function isExperimentalFeatureEnabled(featureId: ExperimentalFeatureId): boolean {
|
|
return getEnabledFeatures().has(featureId);
|
|
}
|
|
|
|
export function getEnabledExperimentalFeatureIds() {
|
|
return getEnabledFeatures().values();
|
|
}
|
|
|
|
function getEnabledFeatures() {
|
|
if (!enabledFeatures) {
|
|
let features: ExperimentalFeatureId[] = [];
|
|
try {
|
|
features = JSON.parse(options.get("experimentalFeatures")) as ExperimentalFeatureId[];
|
|
} catch (e) {
|
|
console.warn("Failed to parse experimental features from options:", e);
|
|
}
|
|
enabledFeatures = new Set(features);
|
|
}
|
|
return enabledFeatures;
|
|
}
|