@fnet/cli 0.122.0 → 0.125.0
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/dist/fnet/index.js +1 -1
- package/package.json +1 -1
- package/template/fnet/node/src/default/blocks/assign.js.njk +18 -6
- package/template/fnet/node/src/default/blocks/call.js.njk +6 -8
- package/template/fnet/node/src/default/blocks/for.js.njk +4 -0
- package/template/fnet/node/src/default/blocks/form.js.njk +3 -8
- package/template/fnet/node/src/default/blocks/jump.js.njk +5 -1
- package/template/fnet/node/src/default/blocks/modules.js.njk +9 -4
- package/template/fnet/node/src/default/blocks/raise.js.njk +3 -3
- package/template/fnet/node/src/default/blocks/return.js.njk +5 -1
- package/template/fnet/{bun/src/default/blocks/jump.js.njk → node/src/default/blocks/signal.js.njk} +12 -8
- package/template/fnet/node/src/default/blocks/steps.js.njk +6 -0
- package/template/fnet/node/src/default/blocks/switch.js.njk +5 -0
- package/template/fnet/node/src/default/blocks/tryexcept.js.njk +5 -1
- package/template/fnet/{bun/src/default/blocks/operation.js.njk → node/src/default/blocks/wait.js.njk} +13 -4
- package/template/fnet/node/src/default/macros/block-assign.js.njk +3 -0
- package/template/fnet/node/src/default/macros/block-next.js.njk +1 -1
- package/template/fnet/node/src/default/macros/block-signal.js.njk +3 -0
- package/template/fnet/node/src/default/workflow.js.njk +4 -1
- package/template/fnet/bun/src/app/index.html.njk +0 -67
- package/template/fnet/bun/src/app/index.js.njk +0 -36
- package/template/fnet/bun/src/cli/index.js.njk +0 -45
- package/template/fnet/bun/src/default/blocks/assign.js.njk +0 -40
- package/template/fnet/bun/src/default/blocks/call.js.njk +0 -97
- package/template/fnet/bun/src/default/blocks/for.js.njk +0 -81
- package/template/fnet/bun/src/default/blocks/form.js.njk +0 -70
- package/template/fnet/bun/src/default/blocks/modules.js.njk +0 -50
- package/template/fnet/bun/src/default/blocks/raise.js.njk +0 -29
- package/template/fnet/bun/src/default/blocks/return.js.njk +0 -27
- package/template/fnet/bun/src/default/blocks/steps.js.njk +0 -56
- package/template/fnet/bun/src/default/blocks/switch.js.njk +0 -68
- package/template/fnet/bun/src/default/blocks/tryexcept.js.njk +0 -79
- package/template/fnet/bun/src/default/engine.js.njk +0 -79
- package/template/fnet/bun/src/default/input.args.js.njk +0 -122
- package/template/fnet/bun/src/default/macros/block-body-header.js.njk +0 -7
- package/template/fnet/bun/src/default/macros/block-entry-args.js.njk +0 -2
- package/template/fnet/bun/src/default/macros/block-footer.js.njk +0 -3
- package/template/fnet/bun/src/default/macros/block-header.js.njk +0 -14
- package/template/fnet/bun/src/default/macros/block-library-header.js.njk +0 -19
- package/template/fnet/bun/src/default/macros/block-modules-header.js.njk +0 -8
- package/template/fnet/bun/src/default/macros/block-modules.js.njk +0 -29
- package/template/fnet/bun/src/default/macros/block-next-header.js.njk +0 -6
- package/template/fnet/bun/src/default/macros/block-next.js.njk +0 -21
- package/template/fnet/bun/src/default/macros/block-run-form.js.njk +0 -32
- package/template/fnet/bun/src/default/macros/block-run-header.js.njk +0 -39
- package/template/fnet/bun/src/default/macros/page.js.njk +0 -8
- package/template/fnet/bun/src/default/macros/workflow-header.js.njk +0 -7
- package/template/fnet/bun/src/default/workflow.js.njk +0 -117
- package/template/fnet/node/src/default/blocks/operation.js.njk +0 -24
|
@@ -28,11 +28,6 @@ export default function Block(context){
|
|
|
28
28
|
flow.waitForNext({
|
|
29
29
|
key:'{{indexKey}}',
|
|
30
30
|
next: async () => {
|
|
31
|
-
|
|
32
|
-
{% for assign in context.transform.assign %}
|
|
33
|
-
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
34
|
-
{% endfor%}
|
|
35
|
-
|
|
36
31
|
{% if context.transform.return %}
|
|
37
32
|
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
38
33
|
{% elseif context.next %}
|
|
@@ -53,10 +48,10 @@ export default function Block(context){
|
|
|
53
48
|
{% endif %}
|
|
54
49
|
|
|
55
50
|
{% include "src/default/macros/block-run-form.js.njk" %}
|
|
51
|
+
|
|
52
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
56
53
|
|
|
57
|
-
{%
|
|
58
|
-
flow.continueForNext({key:'{{indexKey}}'});
|
|
59
|
-
{% endif %}
|
|
54
|
+
{% include "src/default/macros/signal.js.njk" %}
|
|
60
55
|
}
|
|
61
56
|
catch(error){
|
|
62
57
|
reject(error);
|
|
@@ -15,13 +15,17 @@ export default function Block(context){
|
|
|
15
15
|
|
|
16
16
|
{% include "src/default/macros/page.js.njk" %}
|
|
17
17
|
|
|
18
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
19
|
+
|
|
20
|
+
{% include "src/default/macros/block-signal.js.njk" %}
|
|
21
|
+
|
|
18
22
|
{% if context.transform.return %}
|
|
19
23
|
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
20
24
|
{% elseif context.next %}
|
|
21
25
|
{% include "src/default/macros/block-next.js.njk" %}
|
|
22
26
|
{% else %}
|
|
23
27
|
resolve();
|
|
24
|
-
{% endif %}
|
|
28
|
+
{% endif %}
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
31
|
|
|
@@ -19,20 +19,25 @@ export default function Block(context){
|
|
|
19
19
|
|
|
20
20
|
{% include "src/default/macros/page.js.njk" %}
|
|
21
21
|
|
|
22
|
-
{% if context.next and context.transform.
|
|
22
|
+
{% if context.next and context.transform.wait==='next' %}
|
|
23
23
|
flow.waitForNext({
|
|
24
24
|
key:'{{indexKey}}',
|
|
25
|
-
next:
|
|
25
|
+
next: async () => {
|
|
26
26
|
{% include "src/default/macros/block-next.js.njk" %}
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
});
|
|
29
29
|
{% endif %}
|
|
30
30
|
|
|
31
31
|
{% include "src/default/macros/block-modules.js.njk" %}
|
|
32
32
|
|
|
33
|
+
|
|
34
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
35
|
+
|
|
36
|
+
{% include "src/default/macros/block-signal.js.njk" %}
|
|
37
|
+
|
|
33
38
|
{% if context.transform.return %}
|
|
34
39
|
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
35
|
-
{% elseif context.next and context.transform.
|
|
40
|
+
{% elseif context.next and context.transform.wait!=='next'%}
|
|
36
41
|
{% include "src/default/macros/block-next.js.njk" %}
|
|
37
42
|
{% elseif not context.next%}
|
|
38
43
|
resolve();
|
|
@@ -15,10 +15,10 @@ export default function Block(context){
|
|
|
15
15
|
|
|
16
16
|
const raise = {{context.transform.raise | safe}};
|
|
17
17
|
|
|
18
|
-
{%
|
|
19
|
-
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
20
|
-
{% endfor%}
|
|
18
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
21
19
|
|
|
20
|
+
{% include "src/default/macros/block-signal.js.njk" %}
|
|
21
|
+
|
|
22
22
|
onError? onError(new Error(raise?.message||raise||"Unknown error")) : reject(new Error(raise?.message||raise||"Unknown error"));
|
|
23
23
|
});
|
|
24
24
|
}
|
package/template/fnet/{bun/src/default/blocks/jump.js.njk → node/src/default/blocks/signal.js.njk}
RENAMED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
{% include "src/default/macros/block-header.js.njk" %}
|
|
2
2
|
|
|
3
|
-
{% include "src/default/macros/block-next-header.js.njk" %}
|
|
4
|
-
|
|
5
3
|
export default function Block(context){
|
|
6
|
-
|
|
4
|
+
|
|
7
5
|
{% include "src/default/macros/block-body-header.js.njk" %}
|
|
8
6
|
|
|
9
7
|
this.run= function (){
|
|
@@ -14,18 +12,24 @@ export default function Block(context){
|
|
|
14
12
|
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
15
13
|
|
|
16
14
|
{% include "src/default/macros/page.js.njk" %}
|
|
17
|
-
|
|
15
|
+
|
|
16
|
+
{% for assign in context.transform.assign %}
|
|
17
|
+
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
18
|
+
{% endfor%}
|
|
19
|
+
|
|
18
20
|
{% if context.transform.return %}
|
|
19
21
|
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
20
|
-
{% elseif context.next %}
|
|
22
|
+
{% elseif context.next and context.transform.wait!=='next'%}
|
|
21
23
|
{% include "src/default/macros/block-next.js.njk" %}
|
|
22
|
-
{%
|
|
24
|
+
{% elseif not context.next%}
|
|
23
25
|
resolve();
|
|
24
26
|
{% endif %}
|
|
27
|
+
|
|
28
|
+
{% if context.transform.signal==='next' %}
|
|
29
|
+
flow.continueForNext({key:'{{indexKey}}'});
|
|
30
|
+
{% endif %}
|
|
25
31
|
});
|
|
26
32
|
}
|
|
27
|
-
|
|
28
|
-
Object.freeze(this);
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
{% include "src/default/macros/block-footer.js.njk" %}
|
|
@@ -55,6 +55,10 @@ export default function Block(context) {
|
|
|
55
55
|
}
|
|
56
56
|
{% endfor%}
|
|
57
57
|
|
|
58
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
59
|
+
|
|
60
|
+
{% include "src/default/macros/block-signal.js.njk" %}
|
|
61
|
+
|
|
58
62
|
{% if not hasDefaultCondition %}
|
|
59
63
|
{% if context.transform.return %}
|
|
60
64
|
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
@@ -64,6 +68,7 @@ export default function Block(context) {
|
|
|
64
68
|
resolve();
|
|
65
69
|
{% endif %}
|
|
66
70
|
{% endif %}
|
|
71
|
+
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
74
|
|
|
@@ -54,11 +54,15 @@ export default function Block(context) {
|
|
|
54
54
|
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
55
55
|
{% endif %}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
resolve(Array.isArray(args)? await current.run.apply(current,args) : await current.run.call(current,args));
|
|
58
58
|
}
|
|
59
59
|
catch({{context.except.context.transform.as | safe}}){
|
|
60
60
|
throw new Error('Error must not reach here!');
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
{% include "src/default/macros/block-assign.js.njk" %}
|
|
64
|
+
|
|
65
|
+
{% include "src/default/macros/block-signal.js.njk" %}
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
|
|
@@ -13,10 +13,19 @@ export default function Block(context){
|
|
|
13
13
|
|
|
14
14
|
{% include "src/default/macros/page.js.njk" %}
|
|
15
15
|
|
|
16
|
-
{% if context.transform.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
{% if context.next and context.transform.wait==='next' %}
|
|
17
|
+
flow.waitForNext({
|
|
18
|
+
key:'{{indexKey}}',
|
|
19
|
+
next: async () => {
|
|
20
|
+
{% include "src/default/macros/block-next.js.njk" %}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
{% endif %}
|
|
24
|
+
|
|
25
|
+
{% for assign in context.transform.assign %}
|
|
26
|
+
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
27
|
+
{% endfor%}
|
|
28
|
+
|
|
20
29
|
});
|
|
21
30
|
}
|
|
22
31
|
}
|
|
@@ -41,10 +41,13 @@ export default class Workflow extends Object {
|
|
|
41
41
|
|
|
42
42
|
waitForNext(context){
|
|
43
43
|
this.#waitContext=context;
|
|
44
|
+
this.#waitContext?.timeoutId && clearTimeout(this.#waitContext.timeoutId) && (this.#waitContext.timeoutId=undefined);
|
|
45
|
+
this.#waitContext.timeoutId = setInterval(() => {}, 0x7FFFFFFF);
|
|
44
46
|
}
|
|
45
|
-
|
|
47
|
+
|
|
46
48
|
async continueForNext(context){
|
|
47
49
|
const next=this.#waitContext?.next;
|
|
50
|
+
this.#waitContext?.timeoutId && clearTimeout(this.#waitContext.timeoutId) && (this.#waitContext.timeoutId=undefined);
|
|
48
51
|
this.#waitContext=undefined;
|
|
49
52
|
next && await next();
|
|
50
53
|
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>{{atom.doc.title or atom.doc.name}}</title>
|
|
8
|
-
|
|
9
|
-
{% if atom.doc.features.css.options.extract===true %}
|
|
10
|
-
<link rel="stylesheet" href="./index.css" />
|
|
11
|
-
{% endif %}
|
|
12
|
-
|
|
13
|
-
{% if atom.doc.features.app.format==='iife' %}
|
|
14
|
-
<script src="./index.js"></script>
|
|
15
|
-
{% endif %}
|
|
16
|
-
|
|
17
|
-
</head>
|
|
18
|
-
<body style="height:100vh;margin:0;padding:0;background-color: #eeeeee;">
|
|
19
|
-
<div id="container" style="height:100%;"></div>
|
|
20
|
-
{% if atom.doc.features.app.export===true %}
|
|
21
|
-
{% if atom.doc.features.app.format==='esm' %}
|
|
22
|
-
<script type="module">
|
|
23
|
-
import { createApp } from "./index.js";
|
|
24
|
-
const run = createApp({container: document.getElementById("container")});
|
|
25
|
-
{% if atom.doc.features.app.props %}
|
|
26
|
-
const dispose=run({{ atom.doc.features.app.props | dump | safe }});
|
|
27
|
-
{% else %}
|
|
28
|
-
const dispose=run();
|
|
29
|
-
{% endif %}
|
|
30
|
-
</script>
|
|
31
|
-
{% endif %}
|
|
32
|
-
|
|
33
|
-
{% if atom.doc.features.app.format==='iife' %}
|
|
34
|
-
<script>
|
|
35
|
-
const { createApp } = window['{{atom.doc.bundleName}}'];
|
|
36
|
-
const run = createApp({container: document.getElementById("container")});
|
|
37
|
-
{% if atom.doc.features.app.props %}
|
|
38
|
-
const dispose=run({{ atom.doc.features.app.props | dump | safe }});
|
|
39
|
-
{% else %}
|
|
40
|
-
const dispose=run();
|
|
41
|
-
{% endif %}
|
|
42
|
-
</script>
|
|
43
|
-
{% endif %}
|
|
44
|
-
{% endif %}
|
|
45
|
-
|
|
46
|
-
{% if atom.doc.features.workbox_enabled %}
|
|
47
|
-
{% if atom.doc.features.rollup_output.app.workbox.enabled %}
|
|
48
|
-
<!-- Service Worker Registration -->
|
|
49
|
-
<script>
|
|
50
|
-
if ('serviceWorker' in navigator) {
|
|
51
|
-
window.addEventListener('load', () => {
|
|
52
|
-
navigator
|
|
53
|
-
.serviceWorker
|
|
54
|
-
.register('./sw.js', {scope: './'}) // Optionally add scope
|
|
55
|
-
.then((registration) => {
|
|
56
|
-
console.log('Service Worker registered with scope:', registration.scope);
|
|
57
|
-
})
|
|
58
|
-
.catch((error) => {
|
|
59
|
-
console.log('Service Worker registration failed:', error);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
</script>
|
|
64
|
-
{% endif%}
|
|
65
|
-
{% endif%}
|
|
66
|
-
</body>
|
|
67
|
-
</html>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{% if atom.doc.features.app.enabled===true %}
|
|
2
|
-
|
|
3
|
-
import { default as Engine } from "../default/{{ atom.doc.features.app_default_entry_file or atom.doc.features.main_default_entry_file }}";
|
|
4
|
-
|
|
5
|
-
{% if atom.doc.features.app.export===true %}
|
|
6
|
-
{% if atom.doc.features.app.extend===true %}
|
|
7
|
-
import { default as init } from '../../../app';
|
|
8
|
-
{% endif %}
|
|
9
|
-
const createApp = ({ container }) => {
|
|
10
|
-
{% if atom.doc.features.app.extend===true %}
|
|
11
|
-
return init({container,Engine});
|
|
12
|
-
{% else %}
|
|
13
|
-
return (props) => {
|
|
14
|
-
const engine = new Engine();
|
|
15
|
-
engine.run({ ...props, container }).catch((error) => {
|
|
16
|
-
console.log(error.message)
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
{% endif %}
|
|
20
|
-
};
|
|
21
|
-
export { createApp };
|
|
22
|
-
{% else %}
|
|
23
|
-
{% if atom.doc.features.app.extend===true %}
|
|
24
|
-
import { default as run } from '../../../app';
|
|
25
|
-
run({ Engine }).catch((error) => {
|
|
26
|
-
console.log(error.message)
|
|
27
|
-
});
|
|
28
|
-
{% else %}
|
|
29
|
-
const engine = new Engine();
|
|
30
|
-
engine.run().catch((error) => {
|
|
31
|
-
console.log(error.message)
|
|
32
|
-
});
|
|
33
|
-
{% endif %}
|
|
34
|
-
{% endif %}
|
|
35
|
-
|
|
36
|
-
{% endif %}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
{% if atom.doc.features.cli.enabled===true %}
|
|
2
|
-
import argv from '../default/input.args.js';
|
|
3
|
-
import { schema as inputSchema } from '../default/validate_input.js';
|
|
4
|
-
import { default as Engine } from '../default/{{atom.doc.features.cli_default_entry_file or atom.doc.features.main_default_entry_file}}';
|
|
5
|
-
|
|
6
|
-
{% if atom.doc.features.cli.extend===true %}
|
|
7
|
-
{# TYPE 1 #}
|
|
8
|
-
import { default as runExtended } from '../../../cli';
|
|
9
|
-
|
|
10
|
-
const run = async () => {
|
|
11
|
-
return await runExtended(await argv(),{ Engine });
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
run()
|
|
15
|
-
.then(() => {
|
|
16
|
-
{# process.exit(0); #}
|
|
17
|
-
})
|
|
18
|
-
.catch((error) => {
|
|
19
|
-
console.error(error.message);
|
|
20
|
-
process.exit(1);
|
|
21
|
-
});
|
|
22
|
-
{% else %}
|
|
23
|
-
{# TYPE 2 #}
|
|
24
|
-
const run = async () => {
|
|
25
|
-
const engine = new Engine();
|
|
26
|
-
return await engine.run(await argv());
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
run()
|
|
30
|
-
.then((result) => {
|
|
31
|
-
if (typeof result !== 'undefined')
|
|
32
|
-
{
|
|
33
|
-
// TODO: REMOVE THIS LINE
|
|
34
|
-
const stdout_format=process.argv.slice(2).indexOf()!==-1? process.argv.slice(2)[process.argv.slice(2).indexOf('--stdout_format')+1]:null;
|
|
35
|
-
if(stdout_format==='json') console.log(JSON.stringify(result,null,2));
|
|
36
|
-
else console.log(result);
|
|
37
|
-
}
|
|
38
|
-
{# process.exit(0); #}
|
|
39
|
-
})
|
|
40
|
-
.catch((error) => {
|
|
41
|
-
console.error(error.message);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
});
|
|
44
|
-
{% endif %}
|
|
45
|
-
{% endif %}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{% include "src/default/macros/block-header.js.njk" %}
|
|
2
|
-
|
|
3
|
-
{% include "src/default/macros/block-next-header.js.njk" %}
|
|
4
|
-
|
|
5
|
-
{% include "src/default/macros/block-modules-header.js.njk" %}
|
|
6
|
-
|
|
7
|
-
export default function Block(context){
|
|
8
|
-
|
|
9
|
-
{% include "src/default/macros/block-body-header.js.njk" %}
|
|
10
|
-
|
|
11
|
-
this.run= function (){
|
|
12
|
-
|
|
13
|
-
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
14
|
-
|
|
15
|
-
return new Promise(async (resolve,reject)=>{
|
|
16
|
-
|
|
17
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
18
|
-
|
|
19
|
-
{% include "src/default/macros/page.js.njk" %}
|
|
20
|
-
|
|
21
|
-
{% include "src/default/macros/block-modules.js.njk" %}
|
|
22
|
-
|
|
23
|
-
{% for assign in context.transform.assign %}
|
|
24
|
-
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
25
|
-
{% endfor%}
|
|
26
|
-
|
|
27
|
-
{% if context.transform.return %}
|
|
28
|
-
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
29
|
-
{% elseif context.next %}
|
|
30
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
31
|
-
{% else %}
|
|
32
|
-
resolve();
|
|
33
|
-
{% endif %}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
Object.freeze(this);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
{% include "src/default/macros/block-footer.js.njk" %}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
{% include "src/default/macros/block-header.js.njk" %}
|
|
2
|
-
|
|
3
|
-
{% include "src/default/macros/block-next-header.js.njk" %}
|
|
4
|
-
|
|
5
|
-
{% include "src/default/macros/block-library-header.js.njk" %}
|
|
6
|
-
|
|
7
|
-
{% include "src/default/macros/block-modules-header.js.njk" %}
|
|
8
|
-
|
|
9
|
-
export default function Block(context){
|
|
10
|
-
|
|
11
|
-
{% include "src/default/macros/block-body-header.js.njk" %}
|
|
12
|
-
|
|
13
|
-
this.run= function (){
|
|
14
|
-
|
|
15
|
-
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
16
|
-
|
|
17
|
-
return new Promise(async (resolve,reject)=>{
|
|
18
|
-
|
|
19
|
-
try{
|
|
20
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
21
|
-
|
|
22
|
-
{% include "src/default/macros/page.js.njk" %}
|
|
23
|
-
|
|
24
|
-
{% include "src/default/macros/block-modules.js.njk" %}
|
|
25
|
-
|
|
26
|
-
{% if context.next and context.transform.operation==='wait-for-next' %}
|
|
27
|
-
flow.waitForNext({
|
|
28
|
-
key:'{{indexKey}}',
|
|
29
|
-
next: new Promise((resolve,reject) => {
|
|
30
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
31
|
-
})
|
|
32
|
-
});
|
|
33
|
-
{% endif %}
|
|
34
|
-
|
|
35
|
-
{% if context.lib.type==='atom'%}
|
|
36
|
-
const lib=LIBRARY;
|
|
37
|
-
{% elseif context.lib.type==='subworkflow' %}
|
|
38
|
-
const lib={{context.lib.codeKey}};
|
|
39
|
-
{% elseif target.atom.protocol==='use:' %}
|
|
40
|
-
const lib={{context.transform.call}};
|
|
41
|
-
{% else %}
|
|
42
|
-
const lib=undefined;
|
|
43
|
-
throw new Error('Couldn file lib.');
|
|
44
|
-
{% endif %}
|
|
45
|
-
|
|
46
|
-
{% if context.lib.atom.doc.subtype==='workflow'%}
|
|
47
|
-
const Workflow=lib;
|
|
48
|
-
const workflow=new Workflow({app:engine.app,caller:c});
|
|
49
|
-
const callLib = workflow.run.bind(workflow);
|
|
50
|
-
{% elseif context.lib.type==='subworkflow'%}
|
|
51
|
-
const Workflow=lib;
|
|
52
|
-
const workflow=new Workflow({engine,flow,caller:c});
|
|
53
|
-
const callLib = workflow.run.bind(workflow);
|
|
54
|
-
{% else %}
|
|
55
|
-
const callLib = lib;
|
|
56
|
-
{% endif %}
|
|
57
|
-
|
|
58
|
-
{% if context.transform.args %}
|
|
59
|
-
{% if context.lib.type==='subworkflow' %}
|
|
60
|
-
const callArgs ={ params: {{ context.transform.args | safe }} };
|
|
61
|
-
{% else %}
|
|
62
|
-
const callArgs ={{ context.transform.args | safe }} ;
|
|
63
|
-
{% endif %}
|
|
64
|
-
|
|
65
|
-
const result = Array.isArray(callArgs)? await callLib.apply(_this,callArgs): await callLib.call(_this,callArgs);
|
|
66
|
-
|
|
67
|
-
{% else %}
|
|
68
|
-
const result = await callLib.call(_this);
|
|
69
|
-
{% endif %}
|
|
70
|
-
|
|
71
|
-
{% for assign in context.transform.result %}
|
|
72
|
-
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
73
|
-
{% endfor%}
|
|
74
|
-
|
|
75
|
-
{% for assign in context.transform.assign %}
|
|
76
|
-
flow.set({{assign.key | safe}},{{assign.value | safe}});
|
|
77
|
-
{% endfor%}
|
|
78
|
-
|
|
79
|
-
{% if context.transform.return %}
|
|
80
|
-
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
81
|
-
{% elseif context.next and context.transform.operation!=='wait-for-next'%}
|
|
82
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
83
|
-
{% elseif not context.next%}
|
|
84
|
-
resolve();
|
|
85
|
-
{% endif %}
|
|
86
|
-
}
|
|
87
|
-
catch(error){
|
|
88
|
-
onError? onError(error) : reject(error);
|
|
89
|
-
{# reject(error); #}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
Object.freeze(this);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
{% include "src/default/macros/block-footer.js.njk" %}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{% include "src/default/macros/block-header.js.njk" %}
|
|
3
|
-
|
|
4
|
-
{% include "src/default/macros/block-next-header.js.njk" %}
|
|
5
|
-
|
|
6
|
-
{% include "src/default/macros/block-modules-header.js.njk" %}
|
|
7
|
-
|
|
8
|
-
{% if childs.length %}
|
|
9
|
-
{% if not childs[0].definition.dynamic %}
|
|
10
|
-
// FIRST CHILD: {{childs[0].indexKey}}
|
|
11
|
-
import {{childs[0].codeKey}} from "./{{childs[0].codeKey}}";
|
|
12
|
-
{% endif %}
|
|
13
|
-
{% endif%}
|
|
14
|
-
|
|
15
|
-
export default function Block(context) {
|
|
16
|
-
|
|
17
|
-
{% include "src/default/macros/block-body-header.js.njk" %}
|
|
18
|
-
|
|
19
|
-
this.run= function (){
|
|
20
|
-
|
|
21
|
-
{% include "src/default/macros/block-entry-args.js.njk" %}
|
|
22
|
-
|
|
23
|
-
return new Promise(async (resolve,reject)=>{
|
|
24
|
-
|
|
25
|
-
{% include "src/default/macros/block-run-header.js.njk" %}
|
|
26
|
-
|
|
27
|
-
{% include "src/default/macros/page.js.njk" %}
|
|
28
|
-
|
|
29
|
-
{% include "src/default/macros/block-modules.js.njk" %}
|
|
30
|
-
|
|
31
|
-
{% if childs.length %}
|
|
32
|
-
{% if childs[0].definition.dynamic %}
|
|
33
|
-
// FIRST CHILD: {{childs[0].indexKey}}
|
|
34
|
-
const { default: {{childs[0].codeKey}} } = await import("./{{childs[0].codeKey}}");
|
|
35
|
-
{% endif %}
|
|
36
|
-
{% endif%}
|
|
37
|
-
|
|
38
|
-
for await(const {{context.transform.for.value | safe}} of {{context.transform.for.in | safe}}){
|
|
39
|
-
c.for={ {{context.transform.for.value | safe}} };
|
|
40
|
-
|
|
41
|
-
{% if childs.length %}
|
|
42
|
-
let current= new {{childs[0].codeKey}}({ parent:_this, engine, flow, caller:c });
|
|
43
|
-
let currentArgs=args;
|
|
44
|
-
|
|
45
|
-
do {
|
|
46
|
-
|
|
47
|
-
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
48
|
-
console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
49
|
-
{% endif %}
|
|
50
|
-
|
|
51
|
-
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
52
|
-
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
53
|
-
|
|
54
|
-
if(nextBlock?.type==='return') return resolve(nextBlock);
|
|
55
|
-
else if(nextBlock?.type!=='block') break;
|
|
56
|
-
|
|
57
|
-
if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
|
|
58
|
-
return resolve(nextBlock);
|
|
59
|
-
|
|
60
|
-
current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
|
|
61
|
-
currentArgs=nextBlock.input;
|
|
62
|
-
|
|
63
|
-
} while(true);
|
|
64
|
-
|
|
65
|
-
{% endif %}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
{% if context.transform.return %}
|
|
69
|
-
resolve({type:'return',value: {{context.transform.return | safe}}});
|
|
70
|
-
{% elseif context.next %}
|
|
71
|
-
{% include "src/default/macros/block-next.js.njk" %}
|
|
72
|
-
{% else %}
|
|
73
|
-
resolve();
|
|
74
|
-
{% endif %}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
Object.freeze(this);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
{% include "src/default/macros/block-footer.js.njk" %}
|