@soonflow/core
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -1,1 +0,1 @@ | ||
import{Signal as e}from"@robotlegsjs/signals";function t(e,t){return this.edges.filter((o=>o.sourceNodeId===e&&o.sourceNodeHandleId===t))}class o{async _runFlowHandler(e){const t=this.nodes.filter((({isStartNode:e})=>e));if(0===t.length)return Promise.reject("In SoonFlow: CommonHandler _runFlowHandler not find startNode");for(let o=0;o<t.length;o++)for(let s=0;s<t[o].outputs.length;s++)await e.call(this,t[o],t[o].outputs[s])}async _operateFlowNode(e,o,s){const n=t.call(this,o.id,s.id);if(console.log(" _operateFlowNode resolve done"),0===n.length)return;const r=n.map((e=>e.targetNodeId));for(let t=0;t<r.length;t++){const n=r[t],d=this.nodes.find((e=>e.id===n));if(!d)return Promise.reject("In SoonFlow: CommonHandler _operateFlowNode not find nextNode");const{type:a}=d,i=this.nodeTypeMethods[a];if(!i)return Promise.reject("In SoonFlow: CommonHandler _operateFlowNode not find nodeTypeMethod");await(i[e]?.call(this,{prevNode:o,node:d,inputData:s.data}))}}}class s extends o{nodes;edges;nodeTypeMethods;outInstances;#e=new Map;constructor(e,t,o,s){super(),this.nodes=e,this.edges=t,this.nodeTypeMethods=o,this.outInstances=s}getOutInstance(e){return this.outInstances[e]}getPrevNodeList(e){const t=this.edges.filter((t=>t.targetNodeHandleId===e)),o=[];return t.forEach((e=>{this.nodes.forEach((t=>{t.outputs.some((t=>t.id===e.sourceNodeHandleId))&&(o.find((e=>e.id===t.id))||o.push(t))}))})),o}async runParse(){return this._runFlowHandler(this.parseFlowNode)}async parseFlowNode(e,t){return this._operateFlowNode("parse",e,t)}addSignal(t,o){const s=new e;s.add(o),this.#e.set(t,s)}dispatchSignal(e){this.#e.get(e)?.dispatch()}}class n extends o{nodes;edges;nodeTypeMethods;outInstances;constructor(e,t,o,s){super(),this.nodes=e,this.edges=t,this.nodeTypeMethods=o,this.outInstances=s,this.#t()}#t(){this._runFlowHandler(this.unregisterFlowNode)}async unregisterFlowNode(e,t){return this._operateFlowNode("unregister",e,t)}}const r=(e,...t)=>{console.error(`In SoonFlow: ${e}`,...t)};class d{nodeTypeMethods;outInstances;constructor(e,t){this.nodeTypeMethods=e,this.outInstances=t}async parseFlow(e,t){return new s(e,t,this.nodeTypeMethods,this.outInstances).runParse()}unregisterFlow(e,t){new n(e,t,this.nodeTypeMethods,this.outInstances)}}export{s as SoonFlowParse,n as SoonFlowUnregister,d as default,r as error}; | ||
import{Signal as e}from"@robotlegsjs/signals";function t(e,t){return this.edges.filter((s=>s.sourceNodeId===e&&s.sourceNodeHandleId===t))}class s{async _runFlowHandler(e){const t=this.nodes.filter((({isStartNode:e})=>e));if(0===t.length)return Promise.reject("In SoonFlow: CommonHandler _runFlowHandler not find startNode");for(let s=0;s<t.length;s++)for(let o=0;o<t[s].outputs.length;o++)await e.call(this,t[s],t[s].outputs[o])}async _operateFlowNode(e,s,o){const n=t.call(this,s.id,o.id);if(0===n.length)return;const r=n.map((e=>e.targetNodeId));for(let t=0;t<r.length;t++){const n=r[t],d=this.nodes.find((e=>e.id===n));if(!d)return Promise.reject("In SoonFlow: CommonHandler _operateFlowNode not find nextNode");const{type:a}=d,i=this.nodeTypeMethods[a];if(!i)return Promise.reject("In SoonFlow: CommonHandler _operateFlowNode not find nodeTypeMethod");await(i[e]?.call(this,{prevNode:s,node:d,inputData:o.data}))}}}class o extends s{nodes;edges;nodeTypeMethods;outInstances;#e=new Map;constructor(e,t,s,o){super(),this.nodes=e,this.edges=t,this.nodeTypeMethods=s,this.outInstances=o}getOutInstance(e){return this.outInstances[e]}getPrevNodeList(e){const t=this.edges.filter((t=>t.targetNodeHandleId===e)),s=[];return t.forEach((e=>{this.nodes.forEach((t=>{t.outputs.some((t=>t.id===e.sourceNodeHandleId))&&(s.find((e=>e.id===t.id))||s.push(t))}))})),s}async runParse(){return this._runFlowHandler(this.parseFlowNode)}async parseFlowNode(e,t){return this._operateFlowNode("parse",e,t)}addSignal(t,s){const o=new e;o.add(s),this.#e.set(t,o)}dispatchSignal(e){this.#e.get(e)?.dispatch()}}class n extends s{nodes;edges;nodeTypeMethods;outInstances;constructor(e,t,s,o){super(),this.nodes=e,this.edges=t,this.nodeTypeMethods=s,this.outInstances=o,this.#t()}#t(){this._runFlowHandler(this.unregisterFlowNode)}async unregisterFlowNode(e,t){return this._operateFlowNode("unregister",e,t)}}const r=(e,...t)=>{console.error(`In SoonFlow: ${e}`,...t)};class d{nodeTypeMethods;outInstances;constructor(e,t){this.nodeTypeMethods=e,this.outInstances=t}async parseFlow(e,t){return new o(e,t,this.nodeTypeMethods,this.outInstances).runParse()}unregisterFlow(e,t){new n(e,t,this.nodeTypeMethods,this.outInstances)}}export{o as SoonFlowParse,n as SoonFlowUnregister,d as default,r as error}; |
{ | ||
"name": "@soonflow/core", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "Ssoonflow Core", | ||
@@ -17,3 +17,3 @@ "main": "dist/index.esm.js", | ||
}, | ||
"gitHead": "a3ce8f06e19e9c5aa7357631b0326e69c30cb735" | ||
"gitHead": "bcc20f736a92b5ccac403c845716c8853df1332d" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7526