Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 1 | import Feature from '../common/architecture/features/Feature'; |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 2 | import ScriptFilterListProvider from '../common/architecture/scripts/ScriptFilterListProvider'; |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 3 | |
| 4 | export type ConcreteFeatureClass = { new (): Feature }; |
| 5 | |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 6 | export default class Features extends ScriptFilterListProvider { |
Adrià Vilanova Martínez | cb12c59 | 2024-11-09 20:46:03 +0100 | [diff] [blame] | 7 | private features: ConcreteFeatureClass[] = []; |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 8 | private initializedFeatures: Feature[]; |
| 9 | |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 10 | protected getUnfilteredScriptsList() { |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 11 | const features = this.getFeatures(); |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 12 | return features.map((feature) => feature.getScripts()).flat(1); |
Adrià Vilanova Martínez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 13 | } |
| 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 | } |