blob: f3c9c98533707fac48db53363e41d38bd8011a6a [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ínez18d03c42024-04-21 16:43:01 +02003
4export type ConcreteFeatureClass = { new (): Feature };
5
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +02006export default class Features extends ScriptFilterListProvider {
Adrià Vilanova Martínezcb12c592024-11-09 20:46:03 +01007 private features: ConcreteFeatureClass[] = [];
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +02008 private initializedFeatures: Feature[];
9
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020010 protected getUnfilteredScriptsList() {
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020011 const features = this.getFeatures();
Adrià Vilanova Martínez2ba5d8d2024-05-04 21:17:16 +020012 return features.map((feature) => feature.getScripts()).flat(1);
Adrià Vilanova Martínez18d03c42024-04-21 16:43:01 +020013 }
14
15 private getFeatures() {
16 if (this.initializedFeatures === undefined) {
17 this.initializedFeatures = this.features.map((feature) => new feature());
18 }
19 return this.initializedFeatures;
20 }
21}