1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 |
|
9 |
|
10 | class BasicEffectRulePlugin {
|
11 | constructor(ruleProperty, effectType) {
|
12 | this.ruleProperty = ruleProperty;
|
13 | this.effectType = effectType || ruleProperty;
|
14 | }
|
15 |
|
16 | |
17 |
|
18 |
|
19 |
|
20 | apply(ruleSetCompiler) {
|
21 | ruleSetCompiler.hooks.rule.tap(
|
22 | "BasicEffectRulePlugin",
|
23 | (path, rule, unhandledProperties, result, references) => {
|
24 | if (unhandledProperties.has(this.ruleProperty)) {
|
25 | unhandledProperties.delete(this.ruleProperty);
|
26 |
|
27 | const value = rule[this.ruleProperty];
|
28 |
|
29 | result.effects.push({
|
30 | type: this.effectType,
|
31 | value
|
32 | });
|
33 | }
|
34 | }
|
35 | );
|
36 | }
|
37 | }
|
38 |
|
39 | module.exports = BasicEffectRulePlugin;
|