divhunt 2.0.11 → 2.0.12
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/addons/core/commands/front/directives/run.js +77 -75
- package/addons/core/commands/front/directives/submit.js +111 -111
- package/addons/render/pages/front/items/directives/change.js +37 -34
- package/addons/render/transforms/front/js/items/directives/transform.js +36 -33
- package/package.json +1 -1
|
@@ -1,90 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
divhunt.AddonReady('directives', function()
|
|
2
|
+
{
|
|
3
|
+
directives.ItemAdd({
|
|
4
|
+
id: 'dh-command',
|
|
5
|
+
icon: 'terminal',
|
|
6
|
+
name: 'Command',
|
|
7
|
+
description: 'Execute a command instantly on render',
|
|
8
|
+
category: 'data',
|
|
9
|
+
trigger: 'node',
|
|
10
|
+
order: 664,
|
|
11
|
+
strict: false,
|
|
12
|
+
tag: 'dh-command',
|
|
13
|
+
attributes: {
|
|
14
|
+
'command': ['string', null, true],
|
|
15
|
+
'bind': ['string', 'command'],
|
|
16
|
+
'_success': ['function'],
|
|
17
|
+
'_error': ['function'],
|
|
18
|
+
'data': ['object', {}],
|
|
19
|
+
'api': ['boolean', false]
|
|
20
|
+
},
|
|
21
|
+
code: function(data, item, compile, node, identifier)
|
|
22
22
|
{
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const config = {};
|
|
27
|
-
const methods = {};
|
|
28
|
-
|
|
29
|
-
methods.init = () =>
|
|
30
|
-
{
|
|
31
|
-
methods.config();
|
|
32
|
-
|
|
33
|
-
if(compile.data[config.bind] !== undefined)
|
|
23
|
+
if(node.tagName.toLowerCase() !== 'dh-command')
|
|
34
24
|
{
|
|
35
25
|
return;
|
|
36
26
|
}
|
|
37
27
|
|
|
38
|
-
|
|
39
|
-
methods
|
|
40
|
-
};
|
|
28
|
+
const config = {};
|
|
29
|
+
const methods = {};
|
|
41
30
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
config.bind = data['bind'].value;
|
|
46
|
-
config.onSuccess = data['_success'].value;
|
|
47
|
-
config.onError = data['_error'].value;
|
|
48
|
-
config.data = data['data'].value;
|
|
49
|
-
config.api = data['api'].value;
|
|
50
|
-
};
|
|
31
|
+
methods.init = () =>
|
|
32
|
+
{
|
|
33
|
+
methods.config();
|
|
51
34
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
if(compile.data[config.bind] !== undefined)
|
|
36
|
+
{
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
compile.data[config.bind] = null;
|
|
41
|
+
methods.run();
|
|
58
42
|
};
|
|
59
43
|
|
|
60
|
-
|
|
44
|
+
methods.config = () =>
|
|
61
45
|
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
46
|
+
config.command = data['command'].value;
|
|
47
|
+
config.bind = data['bind'].value;
|
|
48
|
+
config.onSuccess = data['_success'].value;
|
|
49
|
+
config.onError = data['_error'].value;
|
|
50
|
+
config.data = data['data'].value;
|
|
51
|
+
config.api = data['api'].value;
|
|
52
|
+
};
|
|
69
53
|
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
catch(error)
|
|
54
|
+
methods.run = async () =>
|
|
73
55
|
{
|
|
74
|
-
state
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
const state = {
|
|
57
|
+
response: null,
|
|
58
|
+
error: null,
|
|
59
|
+
loading: true
|
|
60
|
+
};
|
|
77
61
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
compile.data[config.bind] = state;
|
|
84
|
-
compile.data.Update();
|
|
85
|
-
}
|
|
86
|
-
};
|
|
62
|
+
try
|
|
63
|
+
{
|
|
64
|
+
const result = config.api
|
|
65
|
+
? await commands.Fn('api', config.command, config.data)
|
|
66
|
+
: await commands.Fn('run', config.command, config.data);
|
|
87
67
|
|
|
88
|
-
|
|
89
|
-
|
|
68
|
+
state.response = result;
|
|
69
|
+
state.error = null;
|
|
70
|
+
state.loading = false;
|
|
71
|
+
|
|
72
|
+
config.onSuccess && config.onSuccess(state);
|
|
73
|
+
}
|
|
74
|
+
catch(error)
|
|
75
|
+
{
|
|
76
|
+
state.response = null;
|
|
77
|
+
state.error = error.message;
|
|
78
|
+
state.loading = false;
|
|
79
|
+
|
|
80
|
+
config.onError && config.onError(state);
|
|
81
|
+
}
|
|
82
|
+
finally
|
|
83
|
+
{
|
|
84
|
+
compile.data[config.bind] = state;
|
|
85
|
+
compile.data.Update();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
methods.init();
|
|
90
|
+
}
|
|
91
|
+
});
|
|
90
92
|
});
|
|
@@ -1,139 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const methods = {};
|
|
25
|
-
|
|
26
|
-
methods.init = () =>
|
|
1
|
+
divhunt.AddonReady('directives', function()
|
|
2
|
+
{
|
|
3
|
+
directives.ItemAdd({
|
|
4
|
+
id: 'dh-command-submit',
|
|
5
|
+
icon: 'terminal',
|
|
6
|
+
name: 'Command Submit',
|
|
7
|
+
description: 'Submit form data to a command via commands.Fn',
|
|
8
|
+
category: 'data',
|
|
9
|
+
trigger: 'node',
|
|
10
|
+
order: 665,
|
|
11
|
+
strict: false,
|
|
12
|
+
tag: 'dh-command-submit',
|
|
13
|
+
attributes: {
|
|
14
|
+
'command': ['string', null, true],
|
|
15
|
+
'bind': ['string', 'command'],
|
|
16
|
+
'_success': ['function'],
|
|
17
|
+
'_error': ['function'],
|
|
18
|
+
'reset': ['boolean', false],
|
|
19
|
+
'stop': ['boolean', false],
|
|
20
|
+
'data': ['object', {}],
|
|
21
|
+
'api': ['boolean', false]
|
|
22
|
+
},
|
|
23
|
+
code: function(data, item, compile, node, identifier)
|
|
27
24
|
{
|
|
28
|
-
|
|
29
|
-
methods
|
|
30
|
-
methods.element();
|
|
31
|
-
methods.handler();
|
|
32
|
-
};
|
|
25
|
+
const config = {};
|
|
26
|
+
const methods = {};
|
|
33
27
|
|
|
34
|
-
|
|
35
|
-
{
|
|
36
|
-
if(!compile.data[config.bind])
|
|
28
|
+
methods.init = () =>
|
|
37
29
|
{
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
methods.config = () =>
|
|
47
|
-
{
|
|
48
|
-
config.command = data['command'].value;
|
|
49
|
-
config.bind = data['bind'].value;
|
|
50
|
-
config.onSuccess = data['_success'].value;
|
|
51
|
-
config.onError = data['_error'].value;
|
|
52
|
-
config.reset = data['reset'].value;
|
|
53
|
-
config.stop = data['stop'].value;
|
|
54
|
-
config.data = data['data'].value;
|
|
55
|
-
config.api = data['api'].value;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
methods.element = () =>
|
|
59
|
-
{
|
|
60
|
-
config.form = document.createElement('form');
|
|
61
|
-
config.form.setAttribute('autocomplete', 'off');
|
|
30
|
+
methods.config();
|
|
31
|
+
methods.state();
|
|
32
|
+
methods.element();
|
|
33
|
+
methods.handler();
|
|
34
|
+
};
|
|
62
35
|
|
|
63
|
-
|
|
36
|
+
methods.state = () =>
|
|
64
37
|
{
|
|
65
|
-
config.
|
|
66
|
-
|
|
38
|
+
if(!compile.data[config.bind])
|
|
39
|
+
{
|
|
40
|
+
compile.data[config.bind] = {
|
|
41
|
+
response: null,
|
|
42
|
+
error: null,
|
|
43
|
+
loading: false
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
67
47
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
48
|
+
methods.config = () =>
|
|
49
|
+
{
|
|
50
|
+
config.command = data['command'].value;
|
|
51
|
+
config.bind = data['bind'].value;
|
|
52
|
+
config.onSuccess = data['_success'].value;
|
|
53
|
+
config.onError = data['_error'].value;
|
|
54
|
+
config.reset = data['reset'].value;
|
|
55
|
+
config.stop = data['stop'].value;
|
|
56
|
+
config.data = data['data'].value;
|
|
57
|
+
config.api = data['api'].value;
|
|
58
|
+
};
|
|
71
59
|
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
config.form.dhCommandSubmit = async (event) =>
|
|
60
|
+
methods.element = () =>
|
|
75
61
|
{
|
|
76
|
-
|
|
62
|
+
config.form = document.createElement('form');
|
|
63
|
+
config.form.setAttribute('autocomplete', 'off');
|
|
77
64
|
|
|
78
|
-
|
|
65
|
+
while(node.firstChild)
|
|
79
66
|
{
|
|
80
|
-
|
|
67
|
+
config.form.appendChild(node.firstChild);
|
|
81
68
|
}
|
|
82
69
|
|
|
83
|
-
|
|
70
|
+
node.appendChild(config.form);
|
|
71
|
+
divhunt.FormSet(config.form, config.data);
|
|
84
72
|
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
methods.submit = async () =>
|
|
88
|
-
{
|
|
89
|
-
compile.data[config.bind];
|
|
90
73
|
|
|
91
|
-
|
|
74
|
+
methods.handler = () =>
|
|
92
75
|
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
compile.data[config.bind].loading = true;
|
|
97
|
-
compile.data[config.bind].error = null;
|
|
76
|
+
config.form.dhCommandSubmit = async (event) =>
|
|
77
|
+
{
|
|
78
|
+
event.preventDefault();
|
|
98
79
|
|
|
99
|
-
|
|
80
|
+
if(config.stop)
|
|
81
|
+
{
|
|
82
|
+
event.stopPropagation();
|
|
83
|
+
}
|
|
100
84
|
|
|
101
|
-
|
|
85
|
+
await methods.submit();
|
|
86
|
+
};
|
|
87
|
+
};
|
|
102
88
|
|
|
103
|
-
|
|
89
|
+
methods.submit = async () =>
|
|
104
90
|
{
|
|
105
|
-
|
|
106
|
-
const result = config.api
|
|
107
|
-
? await commands.Fn('api', config.command, formData)
|
|
108
|
-
: await commands.Fn('run', config.command, formData);
|
|
91
|
+
compile.data[config.bind];
|
|
109
92
|
|
|
110
|
-
compile.data[config.bind].
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
if(compile.data[config.bind].loading)
|
|
94
|
+
{
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
113
97
|
|
|
114
|
-
config.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
{
|
|
119
|
-
compile.data[config.bind].response = null;
|
|
120
|
-
compile.data[config.bind].error = error.message;
|
|
121
|
-
compile.data[config.bind].loading = false;
|
|
98
|
+
compile.data[config.bind].loading = true;
|
|
99
|
+
compile.data[config.bind].error = null;
|
|
100
|
+
|
|
101
|
+
console.log(compile.data[config.bind]);
|
|
122
102
|
|
|
123
|
-
config.onError && config.onError(compile.data[config.bind]);
|
|
124
|
-
}
|
|
125
|
-
finally
|
|
126
|
-
{
|
|
127
103
|
compile.data.Update();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
104
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
105
|
+
try
|
|
106
|
+
{
|
|
107
|
+
const formData = divhunt.FormGet(config.form);
|
|
108
|
+
const result = config.api
|
|
109
|
+
? await commands.Fn('api', config.command, formData)
|
|
110
|
+
: await commands.Fn('run', config.command, formData);
|
|
111
|
+
|
|
112
|
+
compile.data[config.bind].response = result;
|
|
113
|
+
compile.data[config.bind].error = null;
|
|
114
|
+
compile.data[config.bind].loading = false;
|
|
115
|
+
|
|
116
|
+
config.reset && config.form.reset();
|
|
117
|
+
config.onSuccess && config.onSuccess(compile.data[config.bind]);
|
|
118
|
+
}
|
|
119
|
+
catch(error)
|
|
120
|
+
{
|
|
121
|
+
compile.data[config.bind].response = null;
|
|
122
|
+
compile.data[config.bind].error = error.message;
|
|
123
|
+
compile.data[config.bind].loading = false;
|
|
124
|
+
|
|
125
|
+
config.onError && config.onError(compile.data[config.bind]);
|
|
126
|
+
}
|
|
127
|
+
finally
|
|
128
|
+
{
|
|
129
|
+
compile.data.Update();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
methods.init();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
134
136
|
|
|
135
|
-
divhunt.AddonReady('directives', function()
|
|
136
|
-
{
|
|
137
137
|
document.addEventListener('submit', function(event)
|
|
138
138
|
{
|
|
139
139
|
let node = event.target;
|
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const parameters = data['parameters'].value;
|
|
21
|
-
const push = data['history'].value;
|
|
22
|
-
const timeout = data['timeout'].value;
|
|
23
|
-
|
|
24
|
-
const change = () =>
|
|
1
|
+
divhunt.AddonReady('directives', function()
|
|
2
|
+
{
|
|
3
|
+
directives.ItemAdd({
|
|
4
|
+
id: 'dh-page',
|
|
5
|
+
icon: 'file',
|
|
6
|
+
name: 'Page',
|
|
7
|
+
description: 'Navigate to a page on render',
|
|
8
|
+
category: 'navigation',
|
|
9
|
+
trigger: 'node',
|
|
10
|
+
order: 666,
|
|
11
|
+
strict: false,
|
|
12
|
+
tag: 'dh-page',
|
|
13
|
+
attributes: {
|
|
14
|
+
'route': ['string', null, true],
|
|
15
|
+
'parameters': ['object', {}],
|
|
16
|
+
'history': ['boolean', true],
|
|
17
|
+
'timeout': ['number', 0]
|
|
18
|
+
},
|
|
19
|
+
code: function(data, item, compile, node, identifier)
|
|
25
20
|
{
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const route = data['route'].value;
|
|
22
|
+
const parameters = data['parameters'].value;
|
|
23
|
+
const push = data['history'].value;
|
|
24
|
+
const timeout = data['timeout'].value;
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const change = () =>
|
|
27
|
+
{
|
|
28
|
+
pages.Fn('change', route, parameters, { path: true, push });
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if(timeout > 0)
|
|
32
|
+
{
|
|
33
|
+
setTimeout(change, timeout);
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
{
|
|
37
|
+
change();
|
|
38
|
+
}
|
|
36
39
|
}
|
|
37
|
-
}
|
|
40
|
+
});
|
|
38
41
|
});
|
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if(!transformer)
|
|
1
|
+
divhunt.AddonReady('directives', function()
|
|
2
|
+
{
|
|
3
|
+
directives.ItemAdd({
|
|
4
|
+
id: 'dh-transform',
|
|
5
|
+
icon: 'auto_fix_high',
|
|
6
|
+
name: 'Transform',
|
|
7
|
+
description: 'Apply transform functions to elements for advanced functionality. Enables custom element behaviors and third-party integrations.',
|
|
8
|
+
trigger: 'node',
|
|
9
|
+
order: 1100,
|
|
10
|
+
type: '1',
|
|
11
|
+
code: async function(data, item, compile, node, identifier)
|
|
14
12
|
{
|
|
15
|
-
|
|
16
|
-
}
|
|
13
|
+
const transformer = transforms.ItemGet(node.tagName.toLowerCase());
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if(!transformer)
|
|
16
|
+
{
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// Don't stop children processing - let each transform handle itself
|
|
21
|
+
// compile.children = false;
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
const html = node.outerHTML.replace(new RegExp(`^<${node.tagName.toLowerCase()}\\b`), `<div`) .replace(new RegExp(`</${node.tagName.toLowerCase()}>$`), `</div>`);
|
|
24
|
+
const compiled = item.Compile(html, compile.data);
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
data = directives.Fn('process.data', transformer.Get('config'), compiled.element.firstElementChild, compiled);
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
node.style.display = 'none';
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
30
|
+
await transforms.Fn('load.assets', transformer);
|
|
31
|
+
|
|
32
|
+
// Use Promise to handle async properly
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
const targetNode = compiled.element.firstElementChild;
|
|
36
|
+
transformer.Get('code').call({}, data, transformer, compile, targetNode, identifier);
|
|
37
|
+
node.replaceWith(targetNode);
|
|
38
|
+
resolve();
|
|
39
|
+
}, 0);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "divhunt",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "Full-stack isomorphic JavaScript framework built from scratch. One addon abstraction powers databases, servers, commands, pages, directives, queues, and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/load.js",
|