Adrià Vilanova MartÃnez | 18d03c4 | 2024-04-21 16:43:01 +0200 | [diff] [blame] | 1 | import Script, { ConcreteScript } from '../scripts/Script'; |
| 2 | |
| 3 | export default abstract class Feature { |
| 4 | /** |
| 5 | * Internal codename used for the feature. |
| 6 | * |
| 7 | * It will be used for i18n translations, shown in log messages, etc. |
| 8 | */ |
| 9 | abstract readonly codename: string; |
| 10 | |
| 11 | /** |
| 12 | * Options which control the behavior of this feature. |
| 13 | */ |
| 14 | abstract readonly relatedOptions: string[]; |
| 15 | |
| 16 | /** |
| 17 | * Uninitialized scripts which are associated with the feature. |
| 18 | */ |
| 19 | abstract readonly scripts: ConcreteScript[]; |
| 20 | |
| 21 | private initializedScripts: Script[]; |
| 22 | |
| 23 | public getScripts() { |
| 24 | if (this.initializedScripts === undefined) { |
| 25 | this.initializedScripts = this.scripts.map((script) => new script()); |
| 26 | } |
| 27 | return this.initializedScripts; |
| 28 | } |
| 29 | } |