@fnet/cli 0.4.25 → 0.5.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/fbin/index.js +15 -0
- package/dist/fnet/index.0jcm9pn5.js +1 -0
- package/dist/fnet/index.2084z2ed.js +2 -0
- package/dist/fnet/index.33f1ggpr.js +1 -0
- package/dist/fnet/index.3exge2js.js +1 -0
- package/dist/fnet/index.3kfx538h.js +1 -0
- package/dist/fnet/index.490y87nc.js +1 -0
- package/dist/fnet/index.4g9yezkq.js +1 -0
- package/dist/fnet/index.4jkat7r4.js +1 -0
- package/dist/fnet/index.7crx8ky1.js +1 -0
- package/dist/fnet/index.7vw06nrn.js +1 -0
- package/dist/fnet/index.9567fa9x.js +1 -0
- package/dist/fnet/index.gh75wt1m.js +1 -0
- package/dist/fnet/index.hzsfswvp.js +1 -0
- package/dist/fnet/index.jgpc3grc.js +1 -0
- package/dist/fnet/index.js +20 -0
- package/dist/fnet/index.p0zb7e1b.js +1 -0
- package/dist/fnet/index.r19p3bpa.js +2 -0
- package/dist/fnet/index.r82rtnmz.js +1 -0
- package/dist/fnet/index.s662t98v.js +1 -0
- package/dist/fnet/index.w74dpnpn.js +1 -0
- package/dist/fnet/index.xeaw5xa9.js +1 -0
- package/dist/fnet/index.zm4kesg6.js +1 -0
- package/dist/fnode/index.05n3mvs9.js +2 -0
- package/dist/fnode/index.2hc9tbyx.js +1 -0
- package/dist/fnode/index.2pnjg6dc.js +1 -0
- package/dist/fnode/index.9qgtmxq3.js +2 -0
- package/dist/fnode/index.b1q7y05p.js +1 -0
- package/dist/fnode/index.bhapgrs7.js +1 -0
- package/dist/fnode/index.cvxrf34y.js +2 -0
- package/dist/fnode/index.dp9wyahp.js +1 -0
- package/dist/fnode/index.eqxmcpdc.js +1 -0
- package/dist/fnode/index.f2tb0x3t.js +1 -0
- package/dist/fnode/index.fbzv6wwf.js +1 -0
- package/dist/fnode/index.gazd9raq.js +1 -0
- package/dist/fnode/index.hv4s25f0.js +3 -0
- package/dist/fnode/index.j5z7dtsx.js +1 -0
- package/dist/fnode/index.js +10 -0
- package/dist/fnode/index.kb4e4bxf.js +1 -0
- package/dist/fnode/index.qn0schqp.js +1 -0
- package/dist/fnode/index.rht29phd.js +1 -0
- package/dist/fnode/index.rzsfmek6.js +3 -0
- package/dist/fnode/index.s0nk6cv8.js +4 -0
- package/dist/fnode/index.s66v6wt4.js +1 -0
- package/dist/fnode/index.sv7v0y60.js +1 -0
- package/dist/fnode/index.tgkhgnrp.js +1 -0
- package/dist/fnode/index.vq706f75.js +1 -0
- package/dist/fnode/index.y8pvdcny.js +1 -0
- package/dist/fnode/index.z4vz93ww.js +1 -0
- package/dist/frun/index.js +2 -0
- package/dist/fservice/index.js +19 -0
- package/dist/fservice/index.q01yvaz0.js +2 -0
- package/package.json +74 -57
- package/readme.md +298 -0
- package/template/fnet/core/assert.js +6 -0
- package/template/fnet/core/message.js +3 -0
- package/template/fnet/core/object.js +47 -0
- package/template/fnet/core/sleep.js +5 -0
- package/template/fnet/node/.gitignore.njk +9 -0
- package/template/fnet/node/build.js.njk +153 -0
- package/template/fnet/node/package.json.njk +121 -0
- package/template/fnet/node/readme.md.njk +21 -0
- package/template/fnet/node/rollup.config.mjs.njk +498 -0
- package/template/fnet/node/src/app/index.html.njk +67 -0
- package/template/fnet/node/src/app/index.js.njk +36 -0
- package/template/fnet/node/src/cli/index.js.njk +9 -0
- package/template/fnet/node/src/cli/index.js.v1.njk +318 -0
- package/template/fnet/node/src/cli/v2/core/args-parser.njk +10 -0
- package/template/fnet/node/src/cli/v2/core/imports.njk +31 -0
- package/template/fnet/node/src/cli/v2/core/run-wrapper.njk +25 -0
- package/template/fnet/node/src/cli/v2/index.js.njk +184 -0
- package/template/fnet/node/src/cli/v2/modes/default/extend.njk +11 -0
- package/template/fnet/node/src/cli/v2/modes/default/standard.njk +20 -0
- package/template/fnet/node/src/cli/v2/modes/http/builtin.njk +66 -0
- package/template/fnet/node/src/cli/v2/modes/http/imports.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/http/index.njk +12 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/imports.njk +33 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/index.njk +30 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/tool-handlers.njk +46 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/transport-http.njk +222 -0
- package/template/fnet/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/pipeline/index.njk +113 -0
- package/template/fnet/node/src/cli/v2/modes/webhook/imports.njk +9 -0
- package/template/fnet/node/src/cli/v2/modes/webhook/index.njk +127 -0
- package/template/fnet/node/src/cli/v2/modes/websocket/imports.njk +15 -0
- package/template/fnet/node/src/cli/v2/modes/websocket/index.njk +104 -0
- package/template/fnet/node/src/default/blocks/assign.js.njk +15 -0
- package/template/fnet/node/src/default/blocks/call.js.njk +110 -0
- package/template/fnet/node/src/default/blocks/for.js.njk +71 -0
- package/template/fnet/node/src/default/blocks/form.js.njk +31 -0
- package/template/fnet/node/src/default/blocks/http.js.njk +135 -0
- package/template/fnet/node/src/default/blocks/modules.js.njk +15 -0
- package/template/fnet/node/src/default/blocks/new.js.njk +42 -0
- package/template/fnet/node/src/default/blocks/next.js.njk +15 -0
- package/template/fnet/node/src/default/blocks/output.js.njk +15 -0
- package/template/fnet/node/src/default/blocks/parallel.js.njk +64 -0
- package/template/fnet/node/src/default/blocks/pipeline.js.njk +109 -0
- package/template/fnet/node/src/default/blocks/raise.js.njk +15 -0
- package/template/fnet/node/src/default/blocks/retry.js.njk +70 -0
- package/template/fnet/node/src/default/blocks/return.js.njk +21 -0
- package/template/fnet/node/src/default/blocks/schedule.js.njk +66 -0
- package/template/fnet/node/src/default/blocks/signal.js.njk +15 -0
- package/template/fnet/node/src/default/blocks/steps.js.njk +47 -0
- package/template/fnet/node/src/default/blocks/switch.js.njk +49 -0
- package/template/fnet/node/src/default/blocks/tryexcept.js.njk +80 -0
- package/template/fnet/node/src/default/blocks/wait.js.njk +14 -0
- package/template/fnet/node/src/default/engine.js.njk +79 -0
- package/template/fnet/node/src/default/input.args.js.njk +125 -0
- package/template/fnet/node/src/default/macros/block-assign.js.njk +3 -0
- package/template/fnet/node/src/default/macros/block-body-header.js.njk +7 -0
- package/template/fnet/node/src/default/macros/block-entry-args.js.njk +2 -0
- package/template/fnet/node/src/default/macros/block-footer.js.njk +3 -0
- package/template/fnet/node/src/default/macros/block-header.js.njk +11 -0
- package/template/fnet/node/src/default/macros/block-library-header.js.njk +43 -0
- package/template/fnet/node/src/default/macros/block-modules-header.js.njk +8 -0
- package/template/fnet/node/src/default/macros/block-modules.js.njk +29 -0
- package/template/fnet/node/src/default/macros/block-next-header.js.njk +6 -0
- package/template/fnet/node/src/default/macros/block-next.js.njk +21 -0
- package/template/fnet/node/src/default/macros/block-run-footer.js.njk +7 -0
- package/template/fnet/node/src/default/macros/block-run-form.js.njk +32 -0
- package/template/fnet/node/src/default/macros/block-run-header.js.njk +43 -0
- package/template/fnet/node/src/default/macros/block-signal.js.njk +3 -0
- package/template/fnet/node/src/default/macros/page.js.njk +8 -0
- package/template/fnet/node/src/default/types/block.js.njk +133 -0
- package/template/fnet/node/src/default/workflow.js.njk +125 -0
- package/template/fnet/node/tsconfig.json.njk +16 -0
- package/template/fnet/project/.gitignore.njk +7 -0
- package/template/fnet/project/.vscode/launch.json.njk +41 -0
- package/template/fnet/project/.vscode/tasks.json.njk +46 -0
- package/template/fnet/project/fnet/flows.yaml.njk +4 -0
- package/template/fnet/project/fnet/targets.yaml.njk +7 -0
- package/template/fnet/project/fnet.yaml.njk +3 -0
- package/template/fnode/node/.gitignore.njk +9 -0
- package/template/fnode/node/build.js.njk +149 -0
- package/template/fnode/node/package.json.njk +121 -0
- package/template/fnode/node/readme.md.njk +21 -0
- package/template/fnode/node/rollup.config.mjs.njk +498 -0
- package/template/fnode/node/src/app/index-js-with-react-host.njk +50 -0
- package/template/fnode/node/src/app/index-js-without-react-host.njk +23 -0
- package/template/fnode/node/src/app/index.html.njk +67 -0
- package/template/fnode/node/src/app/index.js.njk +9 -0
- package/template/fnode/node/src/cli/index.js.njk +9 -0
- package/template/fnode/node/src/cli/index.js.v1.njk +464 -0
- package/template/fnode/node/src/cli/v2/core/args-parser.njk +10 -0
- package/template/fnode/node/src/cli/v2/core/imports.njk +29 -0
- package/template/fnode/node/src/cli/v2/core/run-wrapper.njk +25 -0
- package/template/fnode/node/src/cli/v2/index.js.njk +184 -0
- package/template/fnode/node/src/cli/v2/modes/default/extend.njk +11 -0
- package/template/fnode/node/src/cli/v2/modes/default/standard.njk +19 -0
- package/template/fnode/node/src/cli/v2/modes/http/builtin.njk +61 -0
- package/template/fnode/node/src/cli/v2/modes/http/imports.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/http/index.njk +12 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/imports.njk +33 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/index.njk +30 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/server-setup.njk +15 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/tool-handlers.njk +41 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/transport-http.njk +212 -0
- package/template/fnode/node/src/cli/v2/modes/mcp/transport-stdio.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/pipeline/imports.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/pipeline/index.njk +103 -0
- package/template/fnode/node/src/cli/v2/modes/webhook/imports.njk +9 -0
- package/template/fnode/node/src/cli/v2/modes/webhook/index.njk +122 -0
- package/template/fnode/node/src/cli/v2/modes/websocket/imports.njk +15 -0
- package/template/fnode/node/src/cli/v2/modes/websocket/index.njk +99 -0
- package/template/fnode/node/src/default/engine.js.njk +17 -0
- package/template/fnode/node/src/default/input.args.js.njk +126 -0
- package/template/fnode/node/tsconfig.json.njk +16 -0
- package/template/fnode/project/.gitignore.njk +11 -0
- package/template/fnode/project/.vscode/launch.json.njk +78 -0
- package/template/fnode/project/.vscode/tasks.json.njk +46 -0
- package/template/fnode/project/fnet/targets.yaml.njk +25 -0
- package/template/fnode/project/fnode.yaml.njk +12 -0
- package/template/fnode/python/.gitignore.njk +7 -0
- package/template/fnode/python/package.json.njk +4 -0
- package/template/fnode/python/pyproject.toml.njk +3 -0
- package/template/fnode/python/readme.md.njk +12 -0
- package/template/fnode/python/setup.py.njk +19 -0
- package/template/fnode/python/src/cli/index.py.njk +25 -0
- package/template/schemas/to-npm.yaml +14 -0
- package/dist/builder/lib-cli.js +0 -2
- package/dist/builder/wf-cli.js +0 -2
- package/dist/index.js +0 -2
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// BLOCK: {{indexKey}}
|
|
2
|
+
|
|
3
|
+
import Message from "../../core/message.js";
|
|
4
|
+
|
|
5
|
+
{% if context.transform.sleep %}
|
|
6
|
+
import sleep from "../../core/sleep.js";
|
|
7
|
+
{% endif %}
|
|
8
|
+
|
|
9
|
+
{% if context.transform.assert %}
|
|
10
|
+
import assert from "../../core/assert.js";
|
|
11
|
+
{% endif %}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{% if context.lib.type==='atom'%}
|
|
2
|
+
{# Check if this is a use: protocol (native JS) #}
|
|
3
|
+
{% if context.lib.atom.protocol==='use:' %}
|
|
4
|
+
{# NO IMPORT for use: protocol - it's native JS #}
|
|
5
|
+
// LIBRARY: {{context.lib.atom.name}} (native)
|
|
6
|
+
{% else %}
|
|
7
|
+
// LIBRARY: {{context.lib.atom.name}}
|
|
8
|
+
{% if context.lib.atom.relativePath %}
|
|
9
|
+
{% if context.transform.from and context.transform.import %}
|
|
10
|
+
{# NEW: from + import pattern (e.g., from: npm:eventemitter3, import: EventEmitter) #}
|
|
11
|
+
import { {{ context.transform.import | safe }} as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
12
|
+
{% elseif context.transform.import %}
|
|
13
|
+
{# EXISTING: import pattern (e.g., import: npm:lodash, call: cloneDeep) #}
|
|
14
|
+
{% if context.transform.libExp %}
|
|
15
|
+
import { default as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
16
|
+
{% else %}
|
|
17
|
+
import { {{ context.transform.call | safe }} as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
18
|
+
{% endif %}
|
|
19
|
+
{% else %}
|
|
20
|
+
{# EXISTING: default import #}
|
|
21
|
+
import { default as LIBRARY } from "{{context.lib.atom.relativePath}}";
|
|
22
|
+
{% endif %}
|
|
23
|
+
{% else %}
|
|
24
|
+
{% if context.transform.from and context.transform.import %}
|
|
25
|
+
{# NEW: from + import pattern for non-relative paths #}
|
|
26
|
+
{% if context.transform.libExp %}
|
|
27
|
+
import { default as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
28
|
+
{% else %}
|
|
29
|
+
import { {{ context.transform.import | safe }} as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
30
|
+
{% endif %}
|
|
31
|
+
{% elseif context.transform.import %}
|
|
32
|
+
{# EXISTING: import pattern for non-relative paths #}
|
|
33
|
+
import { {{ context.transform.call | safe }} as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
34
|
+
{% else %}
|
|
35
|
+
{# EXISTING: default import for non-relative paths #}
|
|
36
|
+
import { default as LIBRARY } from "../../libs/{{context.lib.atom.id or context.lib.atom.name}}";
|
|
37
|
+
{% endif %}
|
|
38
|
+
{% endif %}
|
|
39
|
+
{% endif %}
|
|
40
|
+
{% elseif context.lib.type==='subworkflow' %}
|
|
41
|
+
// LIBRARY: {{context.lib.indexKey}}
|
|
42
|
+
import { default as {{context.lib.codeKey}} } from "../{{context.lib.codeKey}}.js";
|
|
43
|
+
{% endif %}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{% for child in childs %}
|
|
2
|
+
|
|
3
|
+
{% if child.module===true%}
|
|
4
|
+
|
|
5
|
+
// MODULE : {{child.indexKey}}
|
|
6
|
+
{% if child.definition.dynamic %}
|
|
7
|
+
const { default: {{child.codeKey}} } = await import("./{{child.codeKey}}.js");
|
|
8
|
+
{% endif %}
|
|
9
|
+
|
|
10
|
+
m['{{child.name}}']=async function(){
|
|
11
|
+
const entry=new {{child.codeKey}}({engine,flow,parent:_this,caller:c,module:true});
|
|
12
|
+
const nextBlock=await entry.run.apply(entry,arguments);
|
|
13
|
+
|
|
14
|
+
if(nextBlock?.type==='return') return nextBlock.value;
|
|
15
|
+
else if(nextBlock?.type==='block') {
|
|
16
|
+
{% if workflow.parent.context.atom.doc.features.print_module_final_next %}
|
|
17
|
+
console.log('MODULE FINAL NEXT:',nextBlock);
|
|
18
|
+
{% endif %}
|
|
19
|
+
resolve(nextBlock);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
{% if child.context.transform.export %}
|
|
24
|
+
flow.setModule({{child.context.transform.export | safe}}, m['{{child.name}}']);
|
|
25
|
+
{% endif %}
|
|
26
|
+
|
|
27
|
+
{% endif %}
|
|
28
|
+
|
|
29
|
+
{% endfor%}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{% if context.next %}
|
|
2
|
+
|
|
3
|
+
// NEXT : {{context.next.indexKey}}
|
|
4
|
+
{% if context.next.definition.dynamic %}
|
|
5
|
+
const { default: {{context.next.codeKey}} } = await import("./{{context.next.codeKey}}.js");
|
|
6
|
+
{% endif %}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
resolve ({
|
|
10
|
+
type: 'block',
|
|
11
|
+
from: _this,
|
|
12
|
+
fromType: _this.constructor,
|
|
13
|
+
fromClosure: c,
|
|
14
|
+
toType:{{context.next.codeKey}},
|
|
15
|
+
error,
|
|
16
|
+
{% if context.transform.output %}
|
|
17
|
+
input: {{context.transform.output | safe}},
|
|
18
|
+
{% endif %}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
{% endif %}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{% if context.transform.props %}
|
|
2
|
+
const formProps ={{context.transform.props | safe}} ;
|
|
3
|
+
{% else %}
|
|
4
|
+
const formProps={};
|
|
5
|
+
{% endif %}
|
|
6
|
+
|
|
7
|
+
function actionClick(){
|
|
8
|
+
flow.continueForNext({key:'{{indexKey}}'});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
formProps.form=form;
|
|
12
|
+
|
|
13
|
+
formProps.actionClick=actionClick;
|
|
14
|
+
|
|
15
|
+
function Form(){
|
|
16
|
+
React.useEffect(()=>{
|
|
17
|
+
|
|
18
|
+
{% if workflow.parent.context.atom.doc.features.print_form_mounts %}
|
|
19
|
+
console.log('MOUNT:','{{indexKey}}');
|
|
20
|
+
{% endif %}
|
|
21
|
+
|
|
22
|
+
return ()=>{
|
|
23
|
+
{% if workflow.parent.context.atom.doc.features.print_form_mounts %}
|
|
24
|
+
console.log('UNMOUNT:','{{indexKey}}');
|
|
25
|
+
{% endif %}
|
|
26
|
+
}
|
|
27
|
+
},[]);
|
|
28
|
+
|
|
29
|
+
return React.createElement(formLib,formProps);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
engine.setActiveForm({ form: Form, props:formProps });
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{# variables #}
|
|
2
|
+
const v=flow.get();
|
|
3
|
+
|
|
4
|
+
{# module #}
|
|
5
|
+
{% if hasModules %}
|
|
6
|
+
const m={};
|
|
7
|
+
{% else %}
|
|
8
|
+
const m = null;
|
|
9
|
+
{% endif %}
|
|
10
|
+
|
|
11
|
+
{# form #}
|
|
12
|
+
{% if type === 'form' %}
|
|
13
|
+
const form={};
|
|
14
|
+
{% else %}
|
|
15
|
+
const form=null;
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{# closure #}
|
|
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
|
+
};
|
|
32
|
+
|
|
33
|
+
{% if workflow.parent.context.atom.doc.features.print_steps %}
|
|
34
|
+
console.log(new Date().toLocaleString(),'{{indexKey}}');
|
|
35
|
+
{% endif %}
|
|
36
|
+
|
|
37
|
+
{% if context.transform.debugger %}
|
|
38
|
+
debugger;
|
|
39
|
+
{% endif %}
|
|
40
|
+
|
|
41
|
+
{% if context.transform.sleep %}
|
|
42
|
+
await sleep({{context.transform.sleep}});
|
|
43
|
+
{% endif %}
|
|
@@ -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
|
+
#}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// WORKFLOW: {{ indexKey }}
|
|
2
|
+
|
|
3
|
+
import Object from "../core/object.js";
|
|
4
|
+
|
|
5
|
+
{% if context.next %}
|
|
6
|
+
{% if not context.next.definition.dynamic %}
|
|
7
|
+
// NEXT: {{context.next.indexKey}}
|
|
8
|
+
import {{context.next.codeKey}} from "./blocks/{{context.next.codeKey}}.js";
|
|
9
|
+
{% endif %}
|
|
10
|
+
{% endif %}
|
|
11
|
+
|
|
12
|
+
export default class Workflow extends Object {
|
|
13
|
+
|
|
14
|
+
#waitContext;
|
|
15
|
+
|
|
16
|
+
constructor(context) {
|
|
17
|
+
super(context);
|
|
18
|
+
|
|
19
|
+
this.engine=context.engine;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async init(context) {
|
|
23
|
+
|
|
24
|
+
{% if context.transform.params %}
|
|
25
|
+
const params = context?.params;
|
|
26
|
+
|
|
27
|
+
{% for param in context.transform.params %}
|
|
28
|
+
{% if param.hasDefault%}
|
|
29
|
+
{% if param.type ==='string'%}
|
|
30
|
+
this.set('{{param.key}}', Reflect.has(params,'{{param.key}}')? params['{{param.key}}']:'{{param.default}}');
|
|
31
|
+
{% elif param.type ==='object' %}
|
|
32
|
+
this.set('{{param.key}}', Reflect.has(params,'{{param.key}}')? params['{{param.key}}']:{{param.default | dump | safe}});
|
|
33
|
+
{% else %}
|
|
34
|
+
this.set('{{param.key}}', Reflect.has(params,'{{param.key}}')? params['{{param.key}}']:{{param.default | dump}});
|
|
35
|
+
{% endif %}
|
|
36
|
+
{% else %}
|
|
37
|
+
this.set('{{param.key}}',this.getValue(params,'{{param.key}}'));
|
|
38
|
+
{% endif %}
|
|
39
|
+
{% endfor%}
|
|
40
|
+
|
|
41
|
+
this.set('$params',params);
|
|
42
|
+
|
|
43
|
+
{% endif %}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
waitForNext(context){
|
|
47
|
+
this.#waitContext=context;
|
|
48
|
+
this.#waitContext?.timeoutId && clearTimeout(this.#waitContext.timeoutId) && (this.#waitContext.timeoutId=undefined);
|
|
49
|
+
this.#waitContext.timeoutId = setInterval(() => {}, 0x7FFFFFFF);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async continueForNext(context){
|
|
53
|
+
const next=this.#waitContext?.next;
|
|
54
|
+
this.#waitContext?.timeoutId && clearTimeout(this.#waitContext.timeoutId) && (this.#waitContext.timeoutId=undefined);
|
|
55
|
+
this.#waitContext=undefined;
|
|
56
|
+
next && await next();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async run(context) {
|
|
60
|
+
|
|
61
|
+
{% if workflow.parent.context.atom.doc.features.print_steps %}
|
|
62
|
+
console.log(new Date().toLocaleString(),'{{indexKey}}');
|
|
63
|
+
{% endif %}
|
|
64
|
+
|
|
65
|
+
{% if context.transform.debugger %}
|
|
66
|
+
debugger;
|
|
67
|
+
{% endif %}
|
|
68
|
+
|
|
69
|
+
{% if context.transform.sleep %}
|
|
70
|
+
await sleep({{context.transform.sleep}});
|
|
71
|
+
{% endif %}
|
|
72
|
+
|
|
73
|
+
await this.init(context);
|
|
74
|
+
|
|
75
|
+
{% if context.next %}
|
|
76
|
+
|
|
77
|
+
{% if context.next.definition.dynamic %}
|
|
78
|
+
// NEXT : {{context.next.indexKey}}
|
|
79
|
+
const { default: {{context.next.codeKey}} } = await import("./blocks/{{context.next.codeKey}}.js");
|
|
80
|
+
{% endif %}
|
|
81
|
+
|
|
82
|
+
{# closure #}
|
|
83
|
+
const c={};
|
|
84
|
+
|
|
85
|
+
let current=new {{context.next.codeKey}}({ parent:this, engine:this.engine, flow:this, caller:c });
|
|
86
|
+
let currentArgs;
|
|
87
|
+
|
|
88
|
+
do {
|
|
89
|
+
|
|
90
|
+
{% if workflow.parent.context.atom.doc.features.print_runners %}
|
|
91
|
+
console.log(new Date().toLocaleString(),' * ', this.constructor.IndexKey,' -> ',current.constructor.IndexKey);
|
|
92
|
+
{% endif %}
|
|
93
|
+
|
|
94
|
+
const nextBlock= typeof currentArgs==='undefined'? await current.run()
|
|
95
|
+
: Array.isArray(currentArgs)? await current.run.apply(current,currentArgs) : await current.run.call(current, currentArgs) ;
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if(nextBlock?.type==='return') return nextBlock;
|
|
99
|
+
else if(nextBlock?.type!=='block') break;
|
|
100
|
+
|
|
101
|
+
if(nextBlock.toType.ParentTypeId!==this.constructor.TypeId)
|
|
102
|
+
throw new Error('Unknown situation');
|
|
103
|
+
|
|
104
|
+
current=new nextBlock.toType({ parent:this, engine:this.engine, flow:this, caller:c, error:nextBlock.error });
|
|
105
|
+
currentArgs=nextBlock.input;
|
|
106
|
+
|
|
107
|
+
} while(true);
|
|
108
|
+
|
|
109
|
+
{% endif %}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
{% if context.transform.print %}
|
|
113
|
+
console.log({{context.transform.print | safe}});
|
|
114
|
+
{% endif%}
|
|
115
|
+
|
|
116
|
+
{% if context.transform.assert %}
|
|
117
|
+
assert({{context.transform.assert | safe}});
|
|
118
|
+
{% endif%}
|
|
119
|
+
|
|
120
|
+
return this.result;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
Workflow.TypeId="{{typeId}}";
|
|
125
|
+
Workflow.IndexKey="{{indexKey}}";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": [
|
|
3
|
+
"src/**/*.js"
|
|
4
|
+
],
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "./types",
|
|
7
|
+
"declaration": true,
|
|
8
|
+
"allowJs": true,
|
|
9
|
+
"emitDeclarationOnly": true,
|
|
10
|
+
"target": "es5",
|
|
11
|
+
"strict": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"skipLibCheck": true,
|
|
14
|
+
"jsx": "react-jsx"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "debug-fnet-cli",
|
|
9
|
+
"type": "node",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"skipFiles": [
|
|
12
|
+
"<node_internals>/**"
|
|
13
|
+
],
|
|
14
|
+
"program": "${workspaceFolder}/.workspace/src/cli/index.js",
|
|
15
|
+
"cwd": "${workspaceFolder}/.workspace",
|
|
16
|
+
"preLaunchTask": "fnet-watch",
|
|
17
|
+
"console": "integratedTerminal"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "debug-fnet-app",
|
|
21
|
+
"type": "chrome",
|
|
22
|
+
"request": "launch",
|
|
23
|
+
"url": "http://localhost:3000/dist/app/esm/",
|
|
24
|
+
"webRoot": "${workspaceFolder}/.workspace",
|
|
25
|
+
"preLaunchTask": "fnet-watch",
|
|
26
|
+
// "userDataDir": false,
|
|
27
|
+
// "runtimeArgs": [
|
|
28
|
+
// "--profile-directory=<profile-name>",
|
|
29
|
+
// ]
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
// "compounds": [
|
|
33
|
+
// {
|
|
34
|
+
// "name": "debug-fnet-all",
|
|
35
|
+
// "configurations": [
|
|
36
|
+
// "debug-fnet-cli",
|
|
37
|
+
// "debug-fnet-app"
|
|
38
|
+
// ]
|
|
39
|
+
// }
|
|
40
|
+
// ]
|
|
41
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"label": "fnet-build",
|
|
6
|
+
"type": "shell",
|
|
7
|
+
"command": "fnet build",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"label": "fnet-watch",
|
|
11
|
+
"type": "shell",
|
|
12
|
+
"command": "fnet watch",
|
|
13
|
+
"isBackground": true
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"label": "fnet-deploy",
|
|
17
|
+
"type": "shell",
|
|
18
|
+
"command": "fnet deploy",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"label": "fnet-cli",
|
|
22
|
+
"type": "shell",
|
|
23
|
+
"command": "fnet cli",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"label": "fnet-app",
|
|
27
|
+
"type": "shell",
|
|
28
|
+
"command": "fnet app",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"label": "fnet-project-update",
|
|
32
|
+
"type": "shell",
|
|
33
|
+
"command": "fnet project -u",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"label": "fnet-npm-update",
|
|
37
|
+
"type": "shell",
|
|
38
|
+
"command": "fnet npm update",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"label": "fnet-npm-outdated",
|
|
42
|
+
"type": "shell",
|
|
43
|
+
"command": "fnet npm outdated",
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|