@vnejs/plugins.canvas.filter 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/const/const.js CHANGED
@@ -1 +1 @@
1
- export const ACTIONS = { SET: "set", UNSET: "unset" };
1
+ export const EXEC_ACTIONS = { SET: "set", UNSET: "unset" };
package/const/events.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export const SUBSCRIBE_EVENTS = {
2
- SET: "vne:layer_filter:show",
3
- UNSET: "vne:layer_filter:hide",
2
+ SET: "vne:layer_filter:set",
3
+ UNSET: "vne:layer_filter:unset",
4
4
  };
@@ -0,0 +1,8 @@
1
+ export const FILTERS = {
2
+ blur: (value = 0) => `blur(${value}px)`,
3
+ sunset: () => `opacity(95%) drop-shadow(0 0 0 #fad6a5) brightness(95%)`,
4
+ night: () => `opacity(90%) drop-shadow(0 0 0 #546bab) brightness(80%)`,
5
+ deepnight: () => `opacity(85%) drop-shadow(0 0 0 #2e4482) brightness(70%)`,
6
+ sunrise: () => `opacity(95%) drop-shadow(0 0 0 #fa7b62) brightness(95%)`,
7
+ grayscale: (value = 0) => `grayscale(${value})`,
8
+ };
package/index.js CHANGED
@@ -2,7 +2,8 @@ import { regPlugin } from "@vnejs/shared";
2
2
 
3
3
  import * as constants from "./const/const";
4
4
  import { SUBSCRIBE_EVENTS } from "./const/events";
5
+ import * as params from "./const/params";
5
6
 
6
7
  import { LayerFilter } from "./modules/filter";
7
8
 
8
- regPlugin("LAYER_FILTER", { constants, events: SUBSCRIBE_EVENTS }, [LayerFilter]);
9
+ regPlugin("LAYER_FILTER", { constants, events: SUBSCRIBE_EVENTS, params }, [LayerFilter]);
package/modules/filter.js CHANGED
@@ -11,10 +11,10 @@ export class LayerFilter extends Module {
11
11
  this.on(this.EVENTS.STATE.CLEAR, this.onStateClear);
12
12
  };
13
13
 
14
- onFilterSet = async ({ layer = "", name = "", duration = 0 } = {}) => {
15
- this.state[layer] = name;
14
+ onFilterSet = async ({ layer = "", name = "", value = "", duration = 0, args = [] } = {}) => {
15
+ this.state[layer] = value || this.PARAMS.LAYER_FILTER.FILTERS[name](...args);
16
16
 
17
- return this.emitLayerPropsUpdate(layer, name, duration);
17
+ return this.emitLayerPropsUpdate(layer, this.state[layer], duration);
18
18
  };
19
19
  onFilterUnset = async ({ layer = "", duration = 0 } = {}) => {
20
20
  delete this.state[layer];
@@ -24,7 +24,7 @@ export class LayerFilter extends Module {
24
24
 
25
25
  onStateSet = async ({ [this.name]: state = {} } = {}) => {
26
26
  await Promise.all(Object.keys(this.state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.UNSET, { layer, duration: 0 })));
27
- await Promise.all(Object.keys(state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.SET, { layer, name: state[layer], duration: 0 })));
27
+ await Promise.all(Object.keys(state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.SET, { layer, value: state[layer], duration: 0 })));
28
28
  };
29
29
  onStateClear = () => Promise.all(Object.keys(this.state).map((layer) => this.emit(this.EVENTS.LAYER_FILTER.UNSET, { layer, duration: 0 })));
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.canvas.filter",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",