-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
32 lines (30 loc) · 1.07 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Plugin, KeyedStoreTrigger, Step } from "@shanzhai/interfaces";
import { MinifySvgStep } from "@shanzhai/minify-svg-step";
import { svgSourceStore } from "@shanzhai/svg-source-store";
import { minifiedSvgStore } from "@shanzhai/minified-svg-store";
import { DeleteFromKeyedStoreStep } from "@shanzhai/delete-from-keyed-store-step";
import { KeyedStoreGetInput } from "@shanzhai/keyed-store-get-input";
import { KeyedStoreSetOutput } from "@shanzhai/keyed-store-set-output";
const minifySvgPlugin: Plugin<{
readonly minifySvg: KeyedStoreTrigger;
}> = {
triggers: {
minifySvg: {
type: `keyedStore`,
keyedStore: svgSourceStore,
refreshAllWhenStoresChange: [],
down(key: string): Step {
return new DeleteFromKeyedStoreStep(minifiedSvgStore, key);
},
up(key: string): Step {
return new MinifySvgStep(
key,
new KeyedStoreGetInput(svgSourceStore, key),
new KeyedStoreSetOutput(minifiedSvgStore, key)
);
},
writesToStores: [minifiedSvgStore],
},
},
};
export = minifySvgPlugin;