blob: b79d4fa77cdee1e31bf6604e5e2a0f978c5fab3b [file] [log] [blame]
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02001import Feature from '../common/architecture/features/Feature';
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +02002import ScriptFilterListProvider from '../common/architecture/scripts/ScriptFilterListProvider';
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +02003import ExtraInfoFeature from './extraInfo/extraInfo.feature';
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02004
5export type ConcreteFeatureClass = { new (): Feature };
6
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +02007export default class Features extends ScriptFilterListProvider {
Adrià Vilanova Martínez58cc67c2024-04-21 16:43:01 +02008 private features: ConcreteFeatureClass[] = [
Adrià Vilanova Martínez66836fd2024-05-04 22:43:06 +02009 ExtraInfoFeature,
Adrià Vilanova Martínez58cc67c2024-04-21 16:43:01 +020010 ];
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020011 private initializedFeatures: Feature[];
12
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020013 protected getUnfilteredScriptsList() {
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020014 const features = this.getFeatures();
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020015 return features.map((feature) => feature.getScripts()).flat(1);
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020016 }
17
18 private getFeatures() {
19 if (this.initializedFeatures === undefined) {
20 this.initializedFeatures = this.features.map((feature) => new feature());
21 }
22 return this.initializedFeatures;
23 }
24}