@fnet/cli 0.133.0 → 1.0.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 (182) hide show
  1. package/dist/fbin/index.js +14 -1
  2. package/dist/fnet/index.0jcm9pn5.js +1 -0
  3. package/dist/fnet/index.2084z2ed.js +2 -0
  4. package/dist/fnet/index.33f1ggpr.js +1 -0
  5. package/dist/fnet/index.3exge2js.js +1 -0
  6. package/dist/fnet/index.3kfx538h.js +1 -0
  7. package/dist/fnet/index.490y87nc.js +1 -0
  8. package/dist/fnet/index.4g9yezkq.js +1 -0
  9. package/dist/fnet/index.4jkat7r4.js +1 -0
  10. package/dist/fnet/index.7crx8ky1.js +1 -0
  11. package/dist/fnet/index.7vw06nrn.js +1 -0
  12. package/dist/fnet/index.9567fa9x.js +1 -0
  13. package/dist/fnet/index.gh75wt1m.js +1 -0
  14. package/dist/fnet/index.hzsfswvp.js +1 -0
  15. package/dist/fnet/index.jgpc3grc.js +1 -0
  16. package/dist/fnet/index.js +19 -1
  17. package/dist/fnet/index.p0zb7e1b.js +1 -0
  18. package/dist/fnet/index.r19p3bpa.js +2 -0
  19. package/dist/fnet/index.r82rtnmz.js +1 -0
  20. package/dist/fnet/index.s662t98v.js +1 -0
  21. package/dist/fnet/index.w74dpnpn.js +1 -0
  22. package/dist/fnet/index.xeaw5xa9.js +1 -0
  23. package/dist/fnet/index.zm4kesg6.js +1 -0
  24. package/dist/fnode/index.05n3mvs9.js +2 -0
  25. package/dist/fnode/index.2hc9tbyx.js +1 -0
  26. package/dist/fnode/index.2pnjg6dc.js +1 -0
  27. package/dist/fnode/index.9qgtmxq3.js +2 -0
  28. package/dist/fnode/index.b1q7y05p.js +1 -0
  29. package/dist/fnode/index.bhapgrs7.js +1 -0
  30. package/dist/fnode/index.cvxrf34y.js +2 -0
  31. package/dist/fnode/index.dp9wyahp.js +1 -0
  32. package/dist/fnode/index.eqxmcpdc.js +1 -0
  33. package/dist/fnode/index.f2tb0x3t.js +1 -0
  34. package/dist/fnode/index.fbzv6wwf.js +1 -0
  35. package/dist/fnode/index.gazd9raq.js +1 -0
  36. package/dist/fnode/index.hv4s25f0.js +3 -0
  37. package/dist/fnode/index.j5z7dtsx.js +1 -0
  38. package/dist/fnode/index.js +9 -1
  39. package/dist/fnode/index.kb4e4bxf.js +1 -0
  40. package/dist/fnode/index.qn0schqp.js +1 -0
  41. package/dist/fnode/index.rht29phd.js +1 -0
  42. package/dist/fnode/index.rzsfmek6.js +3 -0
  43. package/dist/fnode/index.s0nk6cv8.js +4 -0
  44. package/dist/fnode/index.s66v6wt4.js +1 -0
  45. package/dist/fnode/index.sv7v0y60.js +1 -0
  46. package/dist/fnode/index.tgkhgnrp.js +1 -0
  47. package/dist/fnode/index.vq706f75.js +1 -0
  48. package/dist/fnode/index.y8pvdcny.js +1 -0
  49. package/dist/fnode/index.z4vz93ww.js +1 -0
  50. package/dist/frun/index.js +1 -1
  51. package/dist/fservice/index.js +18 -1
  52. package/dist/fservice/index.q01yvaz0.js +2 -0
  53. package/package.json +21 -18
  54. package/readme.md +62 -15
  55. package/template/fnet/core/object.js +10 -10
  56. package/template/fnet/node/package.json.njk +6 -3
  57. package/template/fnet/node/src/cli/index.js.njk +5 -315
  58. package/template/fnet/node/src/cli/index.js.v1.njk +318 -0
  59. package/template/fnet/node/src/cli/v2/core/args-parser.njk +10 -0
  60. package/template/fnet/node/src/cli/v2/core/imports.njk +31 -0
  61. package/template/fnet/node/src/cli/v2/core/run-wrapper.njk +25 -0
  62. package/template/fnet/node/src/cli/v2/index.js.njk +184 -0
  63. package/template/fnet/node/src/cli/v2/modes/default/extend.njk +11 -0
  64. package/template/fnet/node/src/cli/v2/modes/default/standard.njk +20 -0
  65. package/template/fnet/node/src/cli/v2/modes/http/builtin.njk +66 -0
  66. package/template/fnet/node/src/cli/v2/modes/http/imports.njk +9 -0
  67. package/template/fnet/node/src/cli/v2/modes/http/index.njk +12 -0
  68. package/template/fnet/node/src/cli/v2/modes/mcp/imports.njk +33 -0
  69. package/template/fnet/node/src/cli/v2/modes/mcp/index.njk +30 -0
  70. package/template/fnet/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
  71. package/template/fnet/node/src/cli/v2/modes/mcp/tool-handlers.njk +46 -0
  72. package/template/fnet/node/src/cli/v2/modes/mcp/transport-http.njk +222 -0
  73. package/template/fnet/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
  74. package/template/fnet/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
  75. package/template/fnet/node/src/cli/v2/modes/pipeline/index.njk +113 -0
  76. package/template/fnet/node/src/cli/v2/modes/webhook/imports.njk +9 -0
  77. package/template/fnet/node/src/cli/v2/modes/webhook/index.njk +127 -0
  78. package/template/fnet/node/src/cli/v2/modes/websocket/imports.njk +15 -0
  79. package/template/fnet/node/src/cli/v2/modes/websocket/index.njk +104 -0
  80. package/template/fnet/node/src/default/blocks/assign.js.njk +10 -48
  81. package/template/fnet/node/src/default/blocks/call.js.njk +110 -156
  82. package/template/fnet/node/src/default/blocks/for.js.njk +58 -74
  83. package/template/fnet/node/src/default/blocks/form.js.njk +21 -59
  84. package/template/fnet/node/src/default/blocks/http.js.njk +135 -0
  85. package/template/fnet/node/src/default/blocks/modules.js.njk +10 -52
  86. package/template/fnet/node/src/default/blocks/new.js.njk +40 -85
  87. package/template/fnet/node/src/default/blocks/next.js.njk +10 -32
  88. package/template/fnet/node/src/default/blocks/output.js.njk +10 -48
  89. package/template/fnet/node/src/default/blocks/parallel.js.njk +64 -0
  90. package/template/fnet/node/src/default/blocks/pipeline.js.njk +109 -0
  91. package/template/fnet/node/src/default/blocks/raise.js.njk +9 -25
  92. package/template/fnet/node/src/default/blocks/retry.js.njk +70 -0
  93. package/template/fnet/node/src/default/blocks/return.js.njk +13 -25
  94. package/template/fnet/node/src/default/blocks/schedule.js.njk +66 -0
  95. package/template/fnet/node/src/default/blocks/signal.js.njk +10 -32
  96. package/template/fnet/node/src/default/blocks/steps.js.njk +32 -48
  97. package/template/fnet/node/src/default/blocks/switch.js.njk +37 -67
  98. package/template/fnet/node/src/default/blocks/tryexcept.js.njk +58 -52
  99. package/template/fnet/node/src/default/blocks/wait.js.njk +10 -30
  100. package/template/fnet/node/src/default/input.args.js.njk +5 -2
  101. package/template/fnet/node/src/default/macros/block-body-header.js.njk +1 -1
  102. package/template/fnet/node/src/default/macros/block-header.js.njk +0 -3
  103. package/template/fnet/node/src/default/macros/block-next.js.njk +1 -1
  104. package/template/fnet/node/src/default/macros/block-run-footer.js.njk +1 -1
  105. package/template/fnet/node/src/default/macros/block-run-header.js.njk +14 -2
  106. package/template/fnet/node/src/default/macros/page.js.njk +1 -1
  107. package/template/fnet/node/src/default/types/block.js.njk +133 -0
  108. package/template/fnet/node/src/default/workflow.js.njk +8 -6
  109. package/template/fnode/node/package.json.njk +5 -4
  110. package/template/fnode/node/src/cli/index.js.njk +3 -397
  111. package/template/fnode/node/src/cli/index.js.v1.njk +464 -0
  112. package/template/fnode/node/src/cli/v2/core/args-parser.njk +10 -0
  113. package/template/fnode/node/src/cli/v2/core/imports.njk +29 -0
  114. package/template/fnode/node/src/cli/v2/core/run-wrapper.njk +25 -0
  115. package/template/fnode/node/src/cli/v2/index.js.njk +184 -0
  116. package/template/fnode/node/src/cli/v2/modes/default/extend.njk +11 -0
  117. package/template/fnode/node/src/cli/v2/modes/default/standard.njk +19 -0
  118. package/template/fnode/node/src/cli/v2/modes/http/builtin.njk +61 -0
  119. package/template/fnode/node/src/cli/v2/modes/http/imports.njk +9 -0
  120. package/template/fnode/node/src/cli/v2/modes/http/index.njk +12 -0
  121. package/template/fnode/node/src/cli/v2/modes/mcp/imports.njk +33 -0
  122. package/template/fnode/node/src/cli/v2/modes/mcp/index.njk +30 -0
  123. package/template/fnode/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
  124. package/template/fnode/node/src/cli/v2/modes/mcp/tool-handlers.njk +41 -0
  125. package/template/fnode/node/src/cli/v2/modes/mcp/transport-http.njk +212 -0
  126. package/template/fnode/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
  127. package/template/fnode/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
  128. package/template/fnode/node/src/cli/v2/modes/pipeline/index.njk +103 -0
  129. package/template/fnode/node/src/cli/v2/modes/webhook/imports.njk +9 -0
  130. package/template/fnode/node/src/cli/v2/modes/webhook/index.njk +122 -0
  131. package/template/fnode/node/src/cli/v2/modes/websocket/imports.njk +15 -0
  132. package/template/fnode/node/src/cli/v2/modes/websocket/index.njk +99 -0
  133. package/template/fnode/node/src/default/input.args.js.njk +6 -2
  134. package/dist/fnet/index.-SGbq2cI.js +0 -1
  135. package/dist/fnet/index.B5XE4ChJ.js +0 -1
  136. package/dist/fnet/index.Bft2w7m3.js +0 -1
  137. package/dist/fnet/index.BuYxdKtK.js +0 -1
  138. package/dist/fnet/index.C0YpfQ5j.js +0 -1
  139. package/dist/fnet/index.C2S9JYhS.js +0 -1
  140. package/dist/fnet/index.C7saWH6d.js +0 -1
  141. package/dist/fnet/index.CDct_kkF.js +0 -1
  142. package/dist/fnet/index.CMC8mlye.js +0 -1
  143. package/dist/fnet/index.CmMM-Ek9.js +0 -1
  144. package/dist/fnet/index.CuMyez3E.js +0 -1
  145. package/dist/fnet/index.CzAV0S36.js +0 -1
  146. package/dist/fnet/index.D2N9YZmA.js +0 -1
  147. package/dist/fnet/index.D3p7pncT.js +0 -1
  148. package/dist/fnet/index.DG8TqL-1.js +0 -1
  149. package/dist/fnet/index.DI3yyTtl.js +0 -1
  150. package/dist/fnet/index.DOYkqsYT.js +0 -1
  151. package/dist/fnet/index.DWpw12No.js +0 -1
  152. package/dist/fnet/index.DrwlOzAe.js +0 -1
  153. package/dist/fnet/index.Q-CYRcna.js +0 -1
  154. package/dist/fnet/index.W6RYgypK.js +0 -1
  155. package/dist/fnet/index.xd8c7XMr.js +0 -1
  156. package/dist/fnode/index.-SGbq2cI.js +0 -1
  157. package/dist/fnode/index.B5XE4ChJ.js +0 -1
  158. package/dist/fnode/index.B8gal9up.js +0 -1
  159. package/dist/fnode/index.BU1440aO.js +0 -1
  160. package/dist/fnode/index.BcGYSPne.js +0 -1
  161. package/dist/fnode/index.Bft2w7m3.js +0 -1
  162. package/dist/fnode/index.BuYxdKtK.js +0 -1
  163. package/dist/fnode/index.C2S9JYhS.js +0 -1
  164. package/dist/fnode/index.C7saWH6d.js +0 -1
  165. package/dist/fnode/index.CDct_kkF.js +0 -1
  166. package/dist/fnode/index.CMC8mlye.js +0 -1
  167. package/dist/fnode/index.CmMM-Ek9.js +0 -1
  168. package/dist/fnode/index.CuMyez3E.js +0 -1
  169. package/dist/fnode/index.CzAV0S36.js +0 -1
  170. package/dist/fnode/index.D2N9YZmA.js +0 -1
  171. package/dist/fnode/index.D3p7pncT.js +0 -1
  172. package/dist/fnode/index.DG8TqL-1.js +0 -1
  173. package/dist/fnode/index.DI3yyTtl.js +0 -1
  174. package/dist/fnode/index.DWpw12No.js +0 -1
  175. package/dist/fnode/index.DrwlOzAe.js +0 -1
  176. package/dist/fnode/index.N_a5FdgA.js +0 -1
  177. package/dist/fnode/index.Q-CYRcna.js +0 -1
  178. package/dist/fnode/index.UNoFg95r.js +0 -1
  179. package/dist/fnode/index.W6RYgypK.js +0 -1
  180. package/dist/fnode/index.xd8c7XMr.js +0 -1
  181. package/template/fnet/core/print.js +0 -1
  182. package/template/fnet/node/src/default/macros/workflow-header.js.njk +0 -7
@@ -1,74 +1,80 @@
1
+ {% set assign=true %}
2
+ {% set signal=true %}
3
+ {% set resolve=true %}
1
4
 
2
- {% include "src/default/macros/block-header.js.njk" %}
5
+ {% import "src/default/types/block.js.njk" as block with context %}
3
6
 
4
- {# {% include "src/default/macros/block-next-header.js.njk" %} #}
7
+ {% call block.header() %}
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
+ {% endcall %}
5
15
 
6
- {% include "src/default/macros/block-modules-header.js.njk" %}
16
+ {% call block.definition() %}
17
+
18
+ try{
7
19
 
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%}
20
+ {% if context.try.definition.dynamic %}
21
+ const { default: {{context.try.codeKey}} } = await import("./{{context.try.codeKey}}.js");
22
+ {% endif %}
14
23
 
15
- export default function Block(context) {
24
+ let current=new {{context.try.codeKey}}({ parent:_this, engine, flow, caller:c, error });
25
+ let currentArgs=args;
16
26
 
17
- {% include "src/default/macros/block-body-header.js.njk" %}
27
+ do {
18
28
 
19
- this.run= function (){
20
-
21
- {% include "src/default/macros/block-entry-args.js.njk" %}
29
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
30
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
31
+ {% endif %}
22
32
 
23
- return new Promise(async (resolve,reject)=>{
24
-
25
- {% include "src/default/macros/block-run-header.js.njk" %}
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) ;
26
35
 
27
- {% include "src/default/macros/page.js.njk" %}
36
+ if(nextBlock?.type==='return') return resolve(nextBlock);
37
+ else if(nextBlock?.type!=='block') break;
28
38
 
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 %}
39
+ if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
40
+ return resolve(nextBlock);
37
41
 
38
- const current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c , error });
42
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
43
+ currentArgs=nextBlock.input;
39
44
 
40
- {% if workflow.parent.context.atom.doc.features.print_runners %}
41
- console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
42
- {% endif %}
45
+ } while(true);
46
+ }
47
+ catch(error){
48
+
49
+ {% if context.except.definition.dynamic %}
50
+ const { default: {{context.except.codeKey}} } = await import("./{{context.except.codeKey}}.js");
51
+ {% endif %}
52
+
53
+ let current=new {{context.except.codeKey}}({ parent:_this, engine, flow, caller:c , error });
54
+ let currentArgs=args;
43
55
 
44
- Array.isArray(args)? current.run.apply(current,args).then(resolve):current.run.call(current,args).then(resolve);
45
- };
56
+ do {
46
57
 
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 });
58
+ {% if workflow.parent.context.atom.doc.features.print_runners %}
59
+ console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
60
+ {% endif %}
52
61
 
53
- {% if workflow.parent.context.atom.doc.features.print_runners %}
54
- console.log(new Date().toLocaleString(),' * ',_this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
55
- {% endif %}
62
+ const nextBlock= typeof currentArgs==='undefined'? await current.run()
63
+ : Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
56
64
 
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
- }
65
+ if(nextBlock?.type==='return') return resolve(nextBlock);
66
+ else if(nextBlock?.type!=='block') break;
62
67
 
63
- {% include "src/default/macros/block-assign.js.njk" %}
68
+ if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
69
+ return resolve(nextBlock);
64
70
 
65
- {% include "src/default/macros/block-signal.js.njk" %}
71
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
72
+ currentArgs=nextBlock.input;
66
73
 
67
- {% include "src/default/macros/block-run-footer.js.njk" %}
68
- });
74
+ } while(true);
69
75
  }
70
76
 
71
- Object.freeze(this);
72
- }
77
+ {% endcall %}
73
78
 
74
- {% include "src/default/macros/block-footer.js.njk" %}
79
+ {% call block.footer()%}
80
+ {% endcall %}
@@ -1,34 +1,14 @@
1
- {% include "src/default/macros/block-header.js.njk" %}
1
+ {% set assign=true %}
2
+ {% set signal=true %}
3
+ {% set resolve=true %}
2
4
 
3
- export default function Block(context){
5
+ {% import "src/default/types/block.js.njk" as block with context %}
4
6
 
5
- {% include "src/default/macros/block-body-header.js.njk" %}
7
+ {% call block.header() %}
8
+ {% endcall %}
6
9
 
7
- this.run= function (){
8
-
9
- {% include "src/default/macros/block-entry-args.js.njk" %}
10
+ {% call block.definition() %}
11
+ {% endcall %}
10
12
 
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" %}
13
+ {% call block.footer()%}
14
+ {% endcall %}
@@ -1,9 +1,9 @@
1
1
  {% if atom.doc.features.project.format === 'esm' %}
2
- import fnetArgs from '@fnet/args';
2
+ import fnetArgs,{argsParser} from '@fnet/args';
3
3
  import validate,{schema as inputSchema} from "./validate_input.js";
4
4
 
5
5
  {% elif atom.doc.features.project.format === 'cjs' %}
6
- const fnetArgs = require('@fnet/args');
6
+ const {default:fnetArgs,argsParser} = require('@fnet/args');
7
7
  const validate,{schema as inputSchema} = require("./validate_input.js");
8
8
  {% endif %}
9
9
 
@@ -75,6 +75,7 @@
75
75
  return await fnetArgs({schema,initial,validate,packageCallback});
76
76
  };
77
77
 
78
+ export { argsParser };
78
79
  {% elif atom.doc.features.project.format === 'cjs' %}
79
80
 
80
81
  module.exports = async () => {
@@ -119,4 +120,6 @@
119
120
 
120
121
  return await fnetArgs({schema,initial,validate,packageCallback});
121
122
  };
123
+
124
+ module.exports.argsParser = argsParser;
122
125
  {% endif %}
@@ -2,6 +2,6 @@ if (this.constructor !== Block) throw Error(Message.USE_CONSTRUCTOR);
2
2
 
3
3
  this.context=context;
4
4
 
5
- const { engine, flow, caller, onError, error }=context || {};
5
+ const { engine, flow, caller, error }=context || {};
6
6
 
7
7
  const _this=this;
@@ -1,9 +1,6 @@
1
1
  // BLOCK: {{indexKey}}
2
2
 
3
3
  import Message from "../../core/message.js";
4
- {% if context.transform.print %}
5
- import print from "../../core/print.js";
6
- {% endif %}
7
4
 
8
5
  {% if context.transform.sleep %}
9
6
  import sleep from "../../core/sleep.js";
@@ -12,7 +12,7 @@ resolve ({
12
12
  fromType: _this.constructor,
13
13
  fromClosure: c,
14
14
  toType:{{context.next.codeKey}},
15
- onError,
15
+ error,
16
16
  {% if context.transform.output %}
17
17
  input: {{context.transform.output | safe}},
18
18
  {% endif %}
@@ -1,5 +1,5 @@
1
1
  {% if context.transform.print %}
2
- print({{context.transform.print | safe}});
2
+ console.log({{context.transform.print | safe}});
3
3
  {% endif%}
4
4
 
5
5
  {% if context.transform.assert %}
@@ -16,13 +16,25 @@ const form=null;
16
16
  {% endif %}
17
17
 
18
18
  {# closure #}
19
- const c={ caller, resolve, reject, args, get form(){return form||caller?.form}, get module(){return m||caller?.module} };
19
+ const c={
20
+ caller,
21
+ resolve,
22
+ reject,
23
+ args,
24
+ get form(){return form||caller?.form},
25
+ get module(){return m||caller?.module},
26
+ get for(){
27
+ // Proxy pattern for nested loop variable resolution with closure semantics
28
+ // Inner loops shadow outer loops, but parent scope is accessible via fallback
29
+ return caller?.for || {};
30
+ }
31
+ };
20
32
 
21
33
  {% if workflow.parent.context.atom.doc.features.print_steps %}
22
34
  console.log(new Date().toLocaleString(),'{{indexKey}}');
23
35
  {% endif %}
24
36
 
25
- {% if definition.debugger %}
37
+ {% if context.transform.debugger %}
26
38
  debugger;
27
39
  {% endif %}
28
40
 
@@ -1,7 +1,7 @@
1
1
  {% if context.transform.page %}
2
2
  const page= {{context.transform.page | safe}};
3
3
 
4
- {% if definition.page.title %}
4
+ {% if context.transform.page.title %}
5
5
  document? document.title=page.title:undefined;
6
6
  {% endif %}
7
7
 
@@ -0,0 +1,133 @@
1
+ {% macro header() %}
2
+
3
+ {% include "src/default/macros/block-header.js.njk" %}
4
+
5
+ {% include "src/default/macros/block-next-header.js.njk" %}
6
+
7
+ {% include "src/default/macros/block-modules-header.js.njk" %}
8
+
9
+ {{ caller() }}
10
+
11
+ {% endmacro %}
12
+
13
+ {% macro definition() %}
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((resolve,reject)=>{
24
+
25
+ (async () => {
26
+ try{
27
+ {% include "src/default/macros/block-run-header.js.njk" %}
28
+
29
+ {% include "src/default/macros/page.js.njk" %}
30
+
31
+ {% include "src/default/macros/block-modules.js.njk" %}
32
+
33
+ {% if (context.next and context.transform.wait==='next') or waitForNext === true %}
34
+ flow.waitForNext({
35
+ key:'{{indexKey}}',
36
+ next: async () => {
37
+ {% if context.transform.return %}
38
+ resolve({type:'return',value: {{context.transform.return | safe}}});
39
+ {% elseif context.next %}
40
+ {% include "src/default/macros/block-next.js.njk" %}
41
+ {% else %}
42
+ resolve();
43
+ {% endif %}
44
+ }
45
+ });
46
+ {% endif %}
47
+
48
+ {{ caller() }}
49
+
50
+ {% if result === true %}
51
+ {% for assign in context.transform.result %}
52
+ flow.set({{assign.key | safe}},{{assign.value | safe}});
53
+ {% endfor%}
54
+ {% endif %}
55
+
56
+ {% if assign === true %}
57
+ {% include "src/default/macros/block-assign.js.njk" %}
58
+ {% endif %}
59
+
60
+ {% if signal === true %}
61
+ {% include "src/default/macros/block-signal.js.njk" %}
62
+ {% endif %}
63
+
64
+ {% if resolve === true %}
65
+ {% if context.transform.return %}
66
+ resolve({type:'return',value: {{context.transform.return | safe}}});
67
+ {% elseif context.next and context.transform.wait!=='next'%}
68
+ {% include "src/default/macros/block-next.js.njk" %}
69
+ {% elseif not context.next%}
70
+ resolve();
71
+ {% endif %}
72
+ {% endif %}
73
+
74
+ {% include "src/default/macros/block-run-footer.js.njk" %}
75
+ }
76
+ catch(error){
77
+ reject(error);
78
+ }
79
+ })();
80
+ });
81
+ }
82
+
83
+ Object.freeze(this);
84
+ }
85
+
86
+ {% endmacro %}
87
+
88
+ {% macro footer() %}
89
+ {% include "src/default/macros/block-footer.js.njk" %}
90
+ {{ caller() }}
91
+ {% endmacro %}
92
+
93
+ {% macro runner({ step: null }) %}
94
+ {% if step.definition.dynamic %}
95
+ const { default: {{step.codeKey}} } = await import("./{{step.codeKey}}.js");
96
+ {% endif %}
97
+
98
+ let current=new {{step.codeKey}}({ parent:_this, engine, flow, caller:c, error });
99
+ let currentArgs=args;
100
+
101
+ do {
102
+
103
+ const nextBlock= typeof currentArgs==='undefined'? await current.run()
104
+ : Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
105
+
106
+ if(nextBlock?.type==='return') return resolve(nextBlock);
107
+ else if(nextBlock?.type!=='block') break;
108
+
109
+ if(nextBlock.toType.ParentTypeId!==_this.constructor.TypeId)
110
+ return resolve(nextBlock);
111
+
112
+ current=new nextBlock.toType({ parent:_this, engine, flow, caller:c, error });
113
+ currentArgs=nextBlock.input;
114
+
115
+ } while(true);
116
+ {% endmacro %}
117
+
118
+ {# USAGE #}
119
+ {#
120
+
121
+ {% import "src/default/types/block.js.njk" as block with context %}
122
+
123
+ {% call block.header() %}
124
+ {% endcall %}
125
+
126
+ {% call block.definition() %}
127
+
128
+ {% endcall %}
129
+
130
+ {% call block.footer()%}
131
+ {% endcall %}
132
+
133
+ #}
@@ -1,4 +1,6 @@
1
- {% include "src/default/macros/workflow-header.js.njk" %}
1
+ // WORKFLOW: {{ indexKey }}
2
+
3
+ import Object from "../core/object.js";
2
4
 
3
5
  {% if context.next %}
4
6
  {% if not context.next.definition.dynamic %}
@@ -60,7 +62,7 @@ export default class Workflow extends Object {
60
62
  console.log(new Date().toLocaleString(),'{{indexKey}}');
61
63
  {% endif %}
62
64
 
63
- {% if definition.debugger %}
65
+ {% if context.transform.debugger %}
64
66
  debugger;
65
67
  {% endif %}
66
68
 
@@ -96,10 +98,10 @@ export default class Workflow extends Object {
96
98
  if(nextBlock?.type==='return') return nextBlock;
97
99
  else if(nextBlock?.type!=='block') break;
98
100
 
99
- if(nextBlock.toType.ParentTypeId!==this.constructor.TypeId)
101
+ if(nextBlock.toType.ParentTypeId!==this.constructor.TypeId)
100
102
  throw new Error('Unknown situation');
101
-
102
- current=new nextBlock.toType({ parent:this, engine:this.engine, flow:this, caller:c });
103
+
104
+ current=new nextBlock.toType({ parent:this, engine:this.engine, flow:this, caller:c, error:nextBlock.error });
103
105
  currentArgs=nextBlock.input;
104
106
 
105
107
  } while(true);
@@ -108,7 +110,7 @@ export default class Workflow extends Object {
108
110
 
109
111
 
110
112
  {% if context.transform.print %}
111
- print({{context.transform.print | safe}});
113
+ console.log({{context.transform.print | safe}});
112
114
  {% endif%}
113
115
 
114
116
  {% if context.transform.assert %}
@@ -13,7 +13,6 @@
13
13
  {% if atom.doc['npm::description'] %}
14
14
  "description": "{{atom.doc['npm::description'] | safe}}",
15
15
  {% endif %}
16
-
17
16
  {% if atom.doc.features.project.format ==='cjs' %}
18
17
  {% if atom.doc.features.rollup_output.esm.enabled === true%}
19
18
  "main": "dist/default/esm/index.js",
@@ -72,14 +71,14 @@
72
71
  {% if atom.doc.features.cli.enabled %}
73
72
  {% if atom.doc.features.project.format ==='cjs' %}
74
73
  ,"cli": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/index.cjs"
75
- {% if atom.doc.features.cli.mcp.enabled===true %}
74
+ {% if atom.doc.features.cli.mcp.enabled === true %}
76
75
  ,"mcp": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/index.cjs --cli-mode=mcp"
77
76
  ,"mcp-inspect": "bunx @modelcontextprotocol/inspector bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.dir}}/index.cjs --cli-mode=mcp"
78
77
  {% endif %}
79
78
  {% else %}
80
79
  ,"cli": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.output.file}}"
81
- ,"cli:dev": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.input.file}}"
82
- {% if atom.doc.features.cli.mcp.enabled===true %}
80
+ ,"cli:dev": "NODE_PRESERVE_SYMLINKS=1 bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.input.file}}"
81
+ {% if atom.doc.features.cli.mcp.enabled === true %}
83
82
  ,"cli:mcp": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.output.file}} --cli-mode=mcp"
84
83
  ,"cli:mcp:inspect": "bunx @modelcontextprotocol/inspector bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.output.file}} --cli-mode=mcp"
85
84
  ,"cli:mcp:dev": "bun {{atom.doc.features.cli.node_options}} {{atom.doc.features.cli.input.file}} --cli-mode=mcp"
@@ -89,6 +88,8 @@
89
88
  ,"cli:compile": "fbin compile {{atom.doc.features.cli.output.file}} -o .bin/{{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes"
90
89
  ,"cli:compile:dev": "fbin compile {{atom.doc.features.cli.input.file}} -o .bin/{{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes"
91
90
  ,"cli:install": "fbin install ./.bin/{{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes"
91
+ ,"cli:install:symlink": "fbin install ./.bin/{{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes --symlink"
92
+ ,"cli:uninstall": "fbin uninstall {{atom.doc['npm::bin'] or atom.doc['name'] or atom['id']}} --yes"
92
93
  {% endif %}
93
94
 
94
95
  {% if atom.doc.features.app.enabled %}