@nodescript/core
Advanced tools
Comparing version 0.17.0 to 0.18.0
import { Graph } from '../model/index.js'; | ||
import { NodeEvalMode } from '../types/index.js'; | ||
export interface GraphCompilerOptions { | ||
@@ -8,2 +9,3 @@ rootNodeId: string; | ||
emitAll: boolean; | ||
evalMode: NodeEvalMode; | ||
} | ||
@@ -10,0 +12,0 @@ /** |
@@ -49,2 +49,3 @@ import { isSchemaCompatible } from '../util/index.js'; | ||
emitAll: false, | ||
evalMode: 'auto', | ||
...options | ||
@@ -147,2 +148,5 @@ }; | ||
this.code.block('try {', '}', () => { | ||
if (this.options.evalMode === 'manual') { | ||
this.code.line(`ctx.checkPendingNode(${JSON.stringify(node.id)});`); | ||
} | ||
this.code.line(`${this.sym.nodeEvaluated}.emit({` + | ||
@@ -149,0 +153,0 @@ `nodeId: ${JSON.stringify(node.id)},` + |
@@ -12,2 +12,3 @@ import { Event } from 'typesafe-event'; | ||
abstract nodeEvaluated: Event<t.NodeResult>; | ||
abstract pendingNodeIds: Set<string>; | ||
newScope(locals: Record<string, any>): BaseContext; | ||
@@ -17,2 +18,3 @@ toArray(value: unknown): unknown[]; | ||
convertType<T>(value: unknown, schema: t.DataSchema<T>): T; | ||
checkPendingNode(nodeId: string): void; | ||
} | ||
@@ -26,2 +28,3 @@ /** | ||
nodeEvaluated: Event<t.NodeResult>; | ||
pendingNodeIds: Set<string>; | ||
getLocal(_key: string): any; | ||
@@ -41,3 +44,8 @@ } | ||
get nodeEvaluated(): Event<t.NodeResult>; | ||
get pendingNodeIds(): Set<string>; | ||
getLocal(key: string): any; | ||
} | ||
export declare class NodePendingError extends Error { | ||
name: string; | ||
code: string; | ||
} |
@@ -26,2 +26,7 @@ import { getType, Schema } from 'airtight'; | ||
} | ||
checkPendingNode(nodeId) { | ||
if (this.pendingNodeIds.has(nodeId)) { | ||
throw new NodePendingError('Node evaluation is suspended.'); | ||
} | ||
} | ||
} | ||
@@ -37,2 +42,3 @@ /** | ||
this.nodeEvaluated = new Event(); | ||
this.pendingNodeIds = new Set(); | ||
} | ||
@@ -58,2 +64,3 @@ getLocal(_key) { | ||
get nodeEvaluated() { return this.parent.nodeEvaluated; } | ||
get pendingNodeIds() { return this.parent.pendingNodeIds; } | ||
getLocal(key) { | ||
@@ -67,2 +74,9 @@ const local = this.locals.get(key); | ||
} | ||
export class NodePendingError extends Error { | ||
constructor() { | ||
super(...arguments); | ||
this.name = this.constructor.name; | ||
this.code = 'EPENDING'; | ||
} | ||
} | ||
//# sourceMappingURL=ctx.js.map |
{ | ||
"name": "@nodescript/core", | ||
"version": "0.17.0", | ||
"version": "0.18.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "Visual programming language for Browser and Node", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
134329
2381