@fnet/cli 0.2.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.
Files changed (133) hide show
  1. package/dist/fbin/index.js +2 -0
  2. package/dist/fnet/index.-SGbq2cI.js +1 -0
  3. package/dist/fnet/index.B0TQiWy6.js +1 -0
  4. package/dist/fnet/index.B5XE4ChJ.js +1 -0
  5. package/dist/fnet/index.Bft2w7m3.js +1 -0
  6. package/dist/fnet/index.BuYxdKtK.js +1 -0
  7. package/dist/fnet/index.C2S9JYhS.js +1 -0
  8. package/dist/fnet/index.C7saWH6d.js +1 -0
  9. package/dist/fnet/index.CDct_kkF.js +1 -0
  10. package/dist/fnet/index.CMC8mlye.js +1 -0
  11. package/dist/fnet/index.CmMM-Ek9.js +1 -0
  12. package/dist/fnet/index.CuMyez3E.js +1 -0
  13. package/dist/fnet/index.CzAV0S36.js +1 -0
  14. package/dist/fnet/index.D2N9YZmA.js +1 -0
  15. package/dist/fnet/index.D3p7pncT.js +1 -0
  16. package/dist/fnet/index.DG8TqL-1.js +1 -0
  17. package/dist/fnet/index.DI3yyTtl.js +1 -0
  18. package/dist/fnet/index.DWpw12No.js +1 -0
  19. package/dist/fnet/index.DrwlOzAe.js +1 -0
  20. package/dist/fnet/index.Q-CYRcna.js +1 -0
  21. package/dist/fnet/index.W6RYgypK.js +1 -0
  22. package/dist/fnet/index.js +2 -0
  23. package/dist/fnet/index.rSKuKke7.js +1 -0
  24. package/dist/fnet/index.xd8c7XMr.js +1 -0
  25. package/dist/fnode/index.-SGbq2cI.js +1 -0
  26. package/dist/fnode/index.1IxoA5DY.js +1 -0
  27. package/dist/fnode/index.B5XE4ChJ.js +1 -0
  28. package/dist/fnode/index.Bft2w7m3.js +1 -0
  29. package/dist/fnode/index.BuYxdKtK.js +1 -0
  30. package/dist/fnode/index.C2S9JYhS.js +1 -0
  31. package/dist/fnode/index.C7saWH6d.js +1 -0
  32. package/dist/fnode/index.CDct_kkF.js +1 -0
  33. package/dist/fnode/index.CJ4EhqPO.js +1 -0
  34. package/dist/fnode/index.CMC8mlye.js +1 -0
  35. package/dist/fnode/index.CmMM-Ek9.js +1 -0
  36. package/dist/fnode/index.CuMyez3E.js +1 -0
  37. package/dist/fnode/index.CzAV0S36.js +1 -0
  38. package/dist/fnode/index.D2N9YZmA.js +1 -0
  39. package/dist/fnode/index.D3p7pncT.js +1 -0
  40. package/dist/fnode/index.DG8TqL-1.js +1 -0
  41. package/dist/fnode/index.DI3yyTtl.js +1 -0
  42. package/dist/fnode/index.DWpw12No.js +1 -0
  43. package/dist/fnode/index.DrwlOzAe.js +1 -0
  44. package/dist/fnode/index.N_a5FdgA.js +1 -0
  45. package/dist/fnode/index.Q-CYRcna.js +1 -0
  46. package/dist/fnode/index.UNoFg95r.js +1 -0
  47. package/dist/fnode/index.W6RYgypK.js +1 -0
  48. package/dist/fnode/index.js +2 -0
  49. package/dist/fnode/index.tq-9YxMP.js +1 -0
  50. package/dist/fnode/index.xd8c7XMr.js +1 -0
  51. package/dist/frun/index.js +2 -0
  52. package/dist/fservice/index.js +2 -0
  53. package/package.json +89 -0
  54. package/readme.md +251 -0
  55. package/template/fnet/core/assert.js +6 -0
  56. package/template/fnet/core/message.js +3 -0
  57. package/template/fnet/core/object.js +47 -0
  58. package/template/fnet/core/print.js +1 -0
  59. package/template/fnet/core/sleep.js +5 -0
  60. package/template/fnet/node/.gitignore.njk +9 -0
  61. package/template/fnet/node/build.js.njk +153 -0
  62. package/template/fnet/node/package.json.njk +118 -0
  63. package/template/fnet/node/readme.md.njk +21 -0
  64. package/template/fnet/node/rollup.config.mjs.njk +498 -0
  65. package/template/fnet/node/src/app/index.html.njk +67 -0
  66. package/template/fnet/node/src/app/index.js.njk +36 -0
  67. package/template/fnet/node/src/cli/index.js.njk +319 -0
  68. package/template/fnet/node/src/default/blocks/assign.js.njk +53 -0
  69. package/template/fnet/node/src/default/blocks/call.js.njk +156 -0
  70. package/template/fnet/node/src/default/blocks/for.js.njk +87 -0
  71. package/template/fnet/node/src/default/blocks/form.js.njk +69 -0
  72. package/template/fnet/node/src/default/blocks/modules.js.njk +57 -0
  73. package/template/fnet/node/src/default/blocks/new.js.njk +87 -0
  74. package/template/fnet/node/src/default/blocks/next.js.njk +37 -0
  75. package/template/fnet/node/src/default/blocks/output.js.njk +53 -0
  76. package/template/fnet/node/src/default/blocks/raise.js.njk +31 -0
  77. package/template/fnet/node/src/default/blocks/return.js.njk +33 -0
  78. package/template/fnet/node/src/default/blocks/signal.js.njk +37 -0
  79. package/template/fnet/node/src/default/blocks/steps.js.njk +63 -0
  80. package/template/fnet/node/src/default/blocks/switch.js.njk +79 -0
  81. package/template/fnet/node/src/default/blocks/tryexcept.js.njk +74 -0
  82. package/template/fnet/node/src/default/blocks/wait.js.njk +34 -0
  83. package/template/fnet/node/src/default/engine.js.njk +79 -0
  84. package/template/fnet/node/src/default/input.args.js.njk +122 -0
  85. package/template/fnet/node/src/default/macros/block-assign.js.njk +3 -0
  86. package/template/fnet/node/src/default/macros/block-body-header.js.njk +7 -0
  87. package/template/fnet/node/src/default/macros/block-entry-args.js.njk +2 -0
  88. package/template/fnet/node/src/default/macros/block-footer.js.njk +3 -0
  89. package/template/fnet/node/src/default/macros/block-header.js.njk +14 -0
  90. package/template/fnet/node/src/default/macros/block-library-header.js.njk +43 -0
  91. package/template/fnet/node/src/default/macros/block-modules-header.js.njk +8 -0
  92. package/template/fnet/node/src/default/macros/block-modules.js.njk +29 -0
  93. package/template/fnet/node/src/default/macros/block-next-header.js.njk +6 -0
  94. package/template/fnet/node/src/default/macros/block-next.js.njk +21 -0
  95. package/template/fnet/node/src/default/macros/block-run-footer.js.njk +7 -0
  96. package/template/fnet/node/src/default/macros/block-run-form.js.njk +32 -0
  97. package/template/fnet/node/src/default/macros/block-run-header.js.njk +31 -0
  98. package/template/fnet/node/src/default/macros/block-signal.js.njk +3 -0
  99. package/template/fnet/node/src/default/macros/page.js.njk +8 -0
  100. package/template/fnet/node/src/default/macros/workflow-header.js.njk +7 -0
  101. package/template/fnet/node/src/default/workflow.js.njk +123 -0
  102. package/template/fnet/node/tsconfig.json.njk +16 -0
  103. package/template/fnet/project/.gitignore.njk +7 -0
  104. package/template/fnet/project/.vscode/launch.json.njk +41 -0
  105. package/template/fnet/project/.vscode/tasks.json.njk +46 -0
  106. package/template/fnet/project/fnet/flows.yaml.njk +4 -0
  107. package/template/fnet/project/fnet/targets.yaml.njk +7 -0
  108. package/template/fnet/project/fnet.yaml.njk +3 -0
  109. package/template/fnode/node/.gitignore.njk +9 -0
  110. package/template/fnode/node/build.js.njk +149 -0
  111. package/template/fnode/node/package.json.njk +120 -0
  112. package/template/fnode/node/readme.md.njk +21 -0
  113. package/template/fnode/node/rollup.config.mjs.njk +498 -0
  114. package/template/fnode/node/src/app/index-js-with-react-host.njk +50 -0
  115. package/template/fnode/node/src/app/index-js-without-react-host.njk +23 -0
  116. package/template/fnode/node/src/app/index.html.njk +67 -0
  117. package/template/fnode/node/src/app/index.js.njk +9 -0
  118. package/template/fnode/node/src/cli/index.js.njk +403 -0
  119. package/template/fnode/node/src/default/engine.js.njk +17 -0
  120. package/template/fnode/node/src/default/input.args.js.njk +122 -0
  121. package/template/fnode/node/tsconfig.json.njk +16 -0
  122. package/template/fnode/project/.gitignore.njk +11 -0
  123. package/template/fnode/project/.vscode/launch.json.njk +78 -0
  124. package/template/fnode/project/.vscode/tasks.json.njk +46 -0
  125. package/template/fnode/project/fnet/targets.yaml.njk +25 -0
  126. package/template/fnode/project/fnode.yaml.njk +12 -0
  127. package/template/fnode/python/.gitignore.njk +7 -0
  128. package/template/fnode/python/package.json.njk +4 -0
  129. package/template/fnode/python/pyproject.toml.njk +3 -0
  130. package/template/fnode/python/readme.md.njk +12 -0
  131. package/template/fnode/python/setup.py.njk +19 -0
  132. package/template/fnode/python/src/cli/index.py.njk +25 -0
  133. package/template/schemas/to-npm.yaml +14 -0
@@ -0,0 +1,57 @@
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
+ try{
18
+ {% include "src/default/macros/block-run-header.js.njk" %}
19
+
20
+ {% include "src/default/macros/page.js.njk" %}
21
+
22
+ {% if context.next and context.transform.wait==='next' %}
23
+ flow.waitForNext({
24
+ key:'{{indexKey}}',
25
+ next: async () => {
26
+ {% include "src/default/macros/block-next.js.njk" %}
27
+ }
28
+ });
29
+ {% endif %}
30
+
31
+ {% include "src/default/macros/block-modules.js.njk" %}
32
+
33
+
34
+ {% include "src/default/macros/block-assign.js.njk" %}
35
+
36
+ {% include "src/default/macros/block-signal.js.njk" %}
37
+
38
+ {% if context.transform.return %}
39
+ resolve({type:'return',value: {{context.transform.return | safe}}});
40
+ {% elseif context.next and context.transform.wait!=='next'%}
41
+ {% include "src/default/macros/block-next.js.njk" %}
42
+ {% elseif not context.next%}
43
+ resolve();
44
+ {% endif %}
45
+
46
+ {% include "src/default/macros/block-run-footer.js.njk" %}
47
+ }
48
+ catch(error){
49
+ reject(error);
50
+ }
51
+ });
52
+ }
53
+
54
+ Object.freeze(this);
55
+ }
56
+
57
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,87 @@
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.wait==='next' %}
27
+ flow.waitForNext({
28
+ key:'{{indexKey}}',
29
+ next: async () => {
30
+ {% include "src/default/macros/block-next.js.njk" %}
31
+ }
32
+ });
33
+ {% endif %}
34
+
35
+ {# NEW: Check if 'new' keyword is present for constructor call #}
36
+ {% if context.transform.new !== undefined %}
37
+ {# Constructor instantiation with 'new' keyword #}
38
+ {% if context.lib.type==='atom' and context.lib.atom.protocol!=='use:' %}
39
+ const LibClass=LIBRARY;
40
+ {% elseif context.lib.atom.protocol==='use:' %}
41
+ {# For use:e:: protocol, call value is the class name (e.g., use:e::Map → Map) #}
42
+ const LibClass={{context.transform.import}};
43
+ if(!LibClass) throw new Error('[use] Couldnt find class.');
44
+ {% else %}
45
+ throw new Error('Cannot instantiate: unsupported lib type.');
46
+ {% endif %}
47
+
48
+ {# Create instance with constructor args #}
49
+ {% if context.transform.new %}
50
+ const constructorArgs = {{ context.transform.new | safe }};
51
+ const instance = Array.isArray(constructorArgs) ? new LibClass(...constructorArgs) : new LibClass(constructorArgs);
52
+ {% else %}
53
+ const instance = new LibClass();
54
+ {% endif %}
55
+
56
+ {% endif %}
57
+
58
+ const result = instance;
59
+
60
+ {% for assign in context.transform.result %}
61
+ flow.set({{assign.key | safe}},{{assign.value | safe}});
62
+ {% endfor%}
63
+
64
+ {% include "src/default/macros/block-assign.js.njk" %}
65
+
66
+ {% include "src/default/macros/block-signal.js.njk" %}
67
+
68
+ {% if context.transform.return %}
69
+ resolve({type:'return',value: {{context.transform.return | safe}}});
70
+ {% elseif context.next and context.transform.wait!=='next'%}
71
+ {% include "src/default/macros/block-next.js.njk" %}
72
+ {% elseif not context.next%}
73
+ resolve();
74
+ {% endif %}
75
+
76
+ {% include "src/default/macros/block-run-footer.js.njk" %}
77
+ }
78
+ catch(error){
79
+ onError? onError(error) : reject(error);
80
+ }
81
+ });
82
+ }
83
+
84
+ Object.freeze(this);
85
+ }
86
+
87
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,37 @@
1
+ {% include "src/default/macros/block-header.js.njk" %}
2
+
3
+ {% include "src/default/macros/block-next-header.js.njk" %}
4
+
5
+ export default function Block(context){
6
+
7
+ {% include "src/default/macros/block-body-header.js.njk" %}
8
+
9
+ this.run= function (){
10
+
11
+ {% include "src/default/macros/block-entry-args.js.njk" %}
12
+
13
+ return new Promise(async (resolve,reject)=>{
14
+ {% include "src/default/macros/block-run-header.js.njk" %}
15
+
16
+ {% include "src/default/macros/page.js.njk" %}
17
+
18
+ {% include "src/default/macros/block-assign.js.njk" %}
19
+
20
+ {% include "src/default/macros/block-signal.js.njk" %}
21
+
22
+ {% if context.transform.return %}
23
+ resolve({type:'return',value: {{context.transform.return | safe}}});
24
+ {% elseif context.next %}
25
+ {% include "src/default/macros/block-next.js.njk" %}
26
+ {% else %}
27
+ resolve();
28
+ {% endif %}
29
+
30
+ {% include "src/default/macros/block-run-footer.js.njk" %}
31
+ });
32
+ }
33
+
34
+ Object.freeze(this);
35
+ }
36
+
37
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,53 @@
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
+ {% if context.next and context.transform.wait==='next' %}
24
+ flow.waitForNext({
25
+ key:'{{indexKey}}',
26
+ next: async () => {
27
+ {% include "src/default/macros/block-next.js.njk" %}
28
+ }
29
+ });
30
+ {% endif %}
31
+
32
+ {% for assign in context.transform.assign %}
33
+ flow.set({{assign.key | safe}},{{assign.value | safe}});
34
+ {% endfor%}
35
+
36
+ {% include "src/default/macros/block-signal.js.njk" %}
37
+
38
+ {% if context.transform.return %}
39
+ resolve({type:'return',value: {{context.transform.return | safe}}});
40
+ {% elseif context.next and context.transform.wait!=='next'%}
41
+ {% include "src/default/macros/block-next.js.njk" %}
42
+ {% elseif not context.next%}
43
+ resolve();
44
+ {% endif %}
45
+
46
+ {% include "src/default/macros/block-run-footer.js.njk" %}
47
+ });
48
+ }
49
+
50
+ Object.freeze(this);
51
+ }
52
+
53
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,31 @@
1
+ {% include "src/default/macros/block-header.js.njk" %}
2
+
3
+ export default function Block(context){
4
+
5
+ {% include "src/default/macros/block-body-header.js.njk" %}
6
+
7
+ this.run= function (){
8
+
9
+ {% include "src/default/macros/block-entry-args.js.njk" %}
10
+
11
+ return new Promise(async (resolve,reject)=>{
12
+ {% include "src/default/macros/block-run-header.js.njk" %}
13
+
14
+ {% include "src/default/macros/page.js.njk" %}
15
+
16
+ const raise = {{context.transform.raise | safe}};
17
+
18
+ {% include "src/default/macros/block-assign.js.njk" %}
19
+
20
+ {% include "src/default/macros/block-signal.js.njk" %}
21
+
22
+ onError? onError(new Error(raise?.message||raise||"Unknown error")) : reject(new Error(raise?.message||raise||"Unknown error"));
23
+
24
+ {% include "src/default/macros/block-run-footer.js.njk" %}
25
+ });
26
+ }
27
+
28
+ Object.freeze(this);
29
+ }
30
+
31
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,33 @@
1
+ {% include "src/default/macros/block-header.js.njk" %}
2
+
3
+ export default function Block(context){
4
+
5
+ {% include "src/default/macros/block-body-header.js.njk" %}
6
+
7
+ this.run= function (){
8
+
9
+ {% include "src/default/macros/block-entry-args.js.njk" %}
10
+
11
+ return new Promise(async (resolve,reject)=>{
12
+ {% include "src/default/macros/block-run-header.js.njk" %}
13
+
14
+ {% include "src/default/macros/page.js.njk" %}
15
+
16
+ const value = {{context.transform.return | safe}};
17
+
18
+ flow.result={value: value};
19
+
20
+ {% include "src/default/macros/block-assign.js.njk" %}
21
+
22
+ {% include "src/default/macros/block-signal.js.njk" %}
23
+
24
+ resolve({type:'return',value: value});
25
+
26
+ {% include "src/default/macros/block-run-footer.js.njk" %}
27
+ });
28
+ }
29
+
30
+ Object.freeze(this);
31
+ }
32
+
33
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,37 @@
1
+ {% include "src/default/macros/block-header.js.njk" %}
2
+
3
+ export default function Block(context){
4
+
5
+ {% include "src/default/macros/block-body-header.js.njk" %}
6
+
7
+ this.run= function (){
8
+
9
+ {% include "src/default/macros/block-entry-args.js.njk" %}
10
+
11
+ return new Promise(async (resolve,reject)=>{
12
+ {% include "src/default/macros/block-run-header.js.njk" %}
13
+
14
+ {% include "src/default/macros/page.js.njk" %}
15
+
16
+ {% for assign in context.transform.assign %}
17
+ flow.set({{assign.key | safe}},{{assign.value | safe}});
18
+ {% endfor%}
19
+
20
+ {% if context.transform.return %}
21
+ resolve({type:'return',value: {{context.transform.return | safe}}});
22
+ {% elseif context.next and context.transform.wait!=='next'%}
23
+ {% include "src/default/macros/block-next.js.njk" %}
24
+ {% elseif not context.next%}
25
+ resolve();
26
+ {% endif %}
27
+
28
+ {% if context.transform.signal==='next' %}
29
+ flow.continueForNext({key:'{{indexKey}}'});
30
+ {% endif %}
31
+
32
+ {% include "src/default/macros/block-run-footer.js.njk" %}
33
+ });
34
+ }
35
+ }
36
+
37
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,63 @@
1
+ {% include "src/default/macros/block-header.js.njk" %}
2
+
3
+ {% include "src/default/macros/block-next-header.js.njk" %}
4
+
5
+ export default function Block(context){
6
+
7
+ {% include "src/default/macros/block-body-header.js.njk" %}
8
+
9
+ this.run= function (){
10
+
11
+ {% include "src/default/macros/block-entry-args.js.njk" %}
12
+
13
+ return new Promise(async (resolve,reject)=>{
14
+
15
+ {% include "src/default/macros/block-run-header.js.njk" %}
16
+
17
+ {% if context.next %}
18
+
19
+ // NEXT : {{context.next.indexKey}}
20
+ {% if context.next.definition.dynamic %}
21
+ const { default: {{context.next.codeKey}} } = await import("./{{context.next.codeKey}}.js");
22
+ {% endif %}
23
+
24
+ let current=new {{context.next.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
25
+ let currentArgs=args;
26
+
27
+ do {
28
+
29
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
30
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
31
+ {% endif %}
32
+
33
+ const nextBlock= typeof currentArgs==='undefined'? await current.run()
34
+ : Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
35
+
36
+ if(nextBlock?.type==='return') return resolve(nextBlock);
37
+ else if(nextBlock?.type!=='block') break;
38
+
39
+ if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
40
+ return resolve(nextBlock);
41
+
42
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, onError, error });
43
+ currentArgs=nextBlock.input;
44
+
45
+ } while(true);
46
+
47
+ {% endif %}
48
+
49
+
50
+ {% include "src/default/macros/block-assign.js.njk" %}
51
+
52
+ {% include "src/default/macros/block-signal.js.njk" %}
53
+
54
+ resolve();
55
+
56
+ {% include "src/default/macros/block-run-footer.js.njk" %}
57
+ });
58
+ }
59
+
60
+ Object.freeze(this);
61
+ }
62
+
63
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,79 @@
1
+ {% include "src/default/macros/block-header.js.njk" %}
2
+
3
+ {% if not hasDefaultCondition %}
4
+ {% include "src/default/macros/block-next-header.js.njk" %}
5
+ {% endif %}
6
+
7
+ {% include "src/default/macros/block-modules-header.js.njk" %}
8
+
9
+ {% for child in childs %}
10
+ {% if not child.definition.dynamic %}
11
+ // CHILD: {{child.indexKey}}
12
+ import {{child.codeKey}} from "./{{child.codeKey}}.js";
13
+ {% endif %}
14
+ {% endfor%}
15
+
16
+ export default function Block(context) {
17
+
18
+ {% include "src/default/macros/block-body-header.js.njk" %}
19
+
20
+ this.run= function (){
21
+
22
+ {% include "src/default/macros/block-entry-args.js.njk" %}
23
+
24
+ return new Promise(async (resolve,reject)=>{
25
+
26
+ {% include "src/default/macros/block-run-header.js.njk" %}
27
+
28
+ {% include "src/default/macros/page.js.njk" %}
29
+
30
+ {% include "src/default/macros/block-modules.js.njk" %}
31
+
32
+ {% for child in childs %}
33
+ {% if loop.first %}
34
+ if ({{child.context.transform.condition | safe}})
35
+ {% else %}
36
+ {%if child.context.transform.condition %}
37
+ else if ({{child.context.transform.condition | safe}})
38
+ {% else %}
39
+ else
40
+ {% endif %}
41
+ {% endif %}
42
+ {
43
+ {% if child.definition.dynamic %}
44
+ // CHILD: {{child.indexKey}}
45
+ const { default: {{child.codeKey}} } = await import("./{{child.codeKey}}.js");
46
+ {% endif %}
47
+
48
+ const current=new {{child.codeKey}}({ parent:_this, engine, flow, caller:c, onError });
49
+
50
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
51
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
52
+ {% endif %}
53
+
54
+ return resolve(Array.isArray(args)? await current.run.apply(current,args) : await current.run.call(current,args));
55
+ }
56
+ {% endfor%}
57
+
58
+ {% include "src/default/macros/block-assign.js.njk" %}
59
+
60
+ {% include "src/default/macros/block-signal.js.njk" %}
61
+
62
+ {% if not hasDefaultCondition %}
63
+ {% if context.transform.return %}
64
+ resolve({type:'return',value: {{context.transform.return | safe}}});
65
+ {% elseif context.next %}
66
+ {% include "src/default/macros/block-next.js.njk" %}
67
+ {% else %}
68
+ resolve();
69
+ {% endif %}
70
+ {% endif %}
71
+
72
+ {% include "src/default/macros/block-run-footer.js.njk" %}
73
+ });
74
+ }
75
+
76
+ Object.freeze(this);
77
+ }
78
+
79
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,74 @@
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
+ {% for child in childs %}
9
+ {% if not child.definition.dynamic %}
10
+ // CHILD: {{child.indexKey}}
11
+ import {{child.codeKey}} from "./{{child.codeKey}}.js";
12
+ {% endif %}
13
+ {% endfor%}
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
+ try{
32
+
33
+ const onError=error=>{
34
+ {% if context.except.definition.dynamic %}
35
+ const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}.js");
36
+ {% endif %}
37
+
38
+ const current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c , error });
39
+
40
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
41
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
42
+ {% endif %}
43
+
44
+ Array.isArray(args)? current.run.apply(current,args).then(resolve):current.run.call(current,args).then(resolve);
45
+ };
46
+
47
+ {% if context.try.definition.dynamic %}
48
+ const { default: {{context.try.codeKey}} } = await import("./{{context.try.codeKey}}.js");
49
+ {% endif %}
50
+
51
+ const current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c ,onError, error });
52
+
53
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
54
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
55
+ {% endif %}
56
+
57
+ resolve(Array.isArray(args)? await current.run.apply(current,args) : await current.run.call(current,args));
58
+ }
59
+ catch({{context.except.context.transform.as | safe}}){
60
+ throw new Error('Error must not reach here!');
61
+ }
62
+
63
+ {% include "src/default/macros/block-assign.js.njk" %}
64
+
65
+ {% include "src/default/macros/block-signal.js.njk" %}
66
+
67
+ {% include "src/default/macros/block-run-footer.js.njk" %}
68
+ });
69
+ }
70
+
71
+ Object.freeze(this);
72
+ }
73
+
74
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,34 @@
1
+ {% include "src/default/macros/block-header.js.njk" %}
2
+
3
+ export default function Block(context){
4
+
5
+ {% include "src/default/macros/block-body-header.js.njk" %}
6
+
7
+ this.run= function (){
8
+
9
+ {% include "src/default/macros/block-entry-args.js.njk" %}
10
+
11
+ return new Promise(async (resolve,reject)=>{
12
+ {% include "src/default/macros/block-run-header.js.njk" %}
13
+
14
+ {% include "src/default/macros/page.js.njk" %}
15
+
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
+
29
+ {% include "src/default/macros/block-run-footer.js.njk" %}
30
+ });
31
+ }
32
+ }
33
+
34
+ {% include "src/default/macros/block-footer.js.njk" %}
@@ -0,0 +1,79 @@
1
+ import Object from "../core/object.js";
2
+
3
+ import { default as Workflow } from "./{{flow.codeKey}}.js";
4
+
5
+ {% set form_enabled = false if flow.name === 'cli' else flow.parent.context.atom.doc.features.form_enabled %}
6
+
7
+ {% set form_enabled = false if flow.definition.features.server === true else form_enabled %}
8
+
9
+ {% if form_enabled %}
10
+ import { App } from "{{ui.package}}";
11
+ {% endif %}
12
+
13
+ export default class Engine extends Object {
14
+
15
+ #main;
16
+ {% if form_enabled %}
17
+ #app;
18
+ #appOwner;
19
+ {% endif %}
20
+
21
+ constructor(context) {
22
+ super(context);
23
+
24
+ this.#main = new Workflow({ engine: this });
25
+
26
+ {% if form_enabled %}
27
+ this.#app =context?.app || new App();
28
+ this.#appOwner = !!context?.app;
29
+ {% endif %}
30
+ }
31
+
32
+ async #init(context) {
33
+ {% if form_enabled %}
34
+ await this.#initApp(context);
35
+ {% endif %}
36
+ }
37
+
38
+ {% if form_enabled %}
39
+
40
+ async #initApp(context) {
41
+ const container = context.params?.container;
42
+ await this.#app.init({ container });
43
+ }
44
+
45
+ async setActiveForm(context) {
46
+ const form = context.form;
47
+ const props = context.props;
48
+
49
+ await this.#app.setActiveForm({form,props});
50
+ }
51
+
52
+ get app(){
53
+ return this.#app;
54
+ }
55
+
56
+ {% endif %}
57
+
58
+ // Main entry function to run workflow
59
+ async run(params) {
60
+
61
+ {% if flow.parent.context.atom.doc.features.print_steps %}
62
+ console.log(new Date().toLocaleString(),'{{ flow.parent.context.atom.doc.title or flow.parent.context.atom.doc.name }}');
63
+ {% endif %}
64
+
65
+ await this.#init({ params });
66
+
67
+ const response = await this.#main.run({ params });
68
+
69
+ return response?.value;
70
+ }
71
+
72
+ async destroy() {
73
+ {% if form_enabled %}
74
+ if (this.#appOwner) {
75
+ await this.#app.destroy();
76
+ }
77
+ {% endif %}
78
+ }
79
+ }