forked from nullstack/nullstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugins.js
More file actions
36 lines (32 loc) · 875 Bytes
/
plugins.js
File metadata and controls
36 lines (32 loc) · 875 Bytes
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
33
34
35
36
import routable from '../plugins/routable';
import bindable from '../plugins/bindable';
import datable from '../plugins/datable';
import parameterizable from '../plugins/parameterizable';
import anchorable from '../plugins/anchorable';
import objectable from '../plugins/objectable';
let plugins = [
objectable,
parameterizable,
anchorable,
routable,
datable,
bindable
];
export function transformNodes(scope, node, depth) {
for(const plugin of plugins) {
plugin.transform({...scope.context, node, depth});
}
}
export function loadPlugins(scope) {
for(const plugin of plugins) {
plugin.load && plugin.load(scope.context)
}
return plugins;
}
export function usePlugins(environment) {
return async (...userPlugins) => {
plugins = [
...new Set([...userPlugins.flat(), ...plugins])
].filter((plugin) => plugin[environment])
}
}