@synergenius/flow-weaver 0.21.20 → 0.21.21
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/api/inline-runtime.js +4 -4
- package/dist/cli/flow-weaver.mjs +40 -29
- package/dist/generated-version.d.ts +1 -1
- package/dist/generated-version.js +1 -1
- package/dist/generator/code-utils.js +3 -3
- package/dist/generator/scope-function-generator.js +4 -4
- package/dist/generator/unified.js +25 -20
- package/package.json +1 -1
|
@@ -100,7 +100,7 @@ export function generateInlineRuntime(production, exportClasses = false, outputF
|
|
|
100
100
|
lines.push(' | TWorkflowCompletedEvent;');
|
|
101
101
|
lines.push('');
|
|
102
102
|
lines.push(`${exportKeyword}type TDebugger = {`);
|
|
103
|
-
lines.push(' sendEvent: (event: TEvent) => void
|
|
103
|
+
lines.push(' sendEvent: (event: TEvent) => void | Promise<void>;');
|
|
104
104
|
lines.push(' innerFlowInvocation: boolean;');
|
|
105
105
|
lines.push(' sessionId?: string;');
|
|
106
106
|
lines.push('};');
|
|
@@ -371,16 +371,16 @@ export function generateInlineRuntime(production, exportClasses = false, outputF
|
|
|
371
371
|
lines.push('');
|
|
372
372
|
// Debug event methods (only in development mode)
|
|
373
373
|
if (!production) {
|
|
374
|
-
lines.push(' sendStatusChangedEvent(args: {');
|
|
374
|
+
lines.push(' async sendStatusChangedEvent(args: {');
|
|
375
375
|
lines.push(' nodeTypeName: string;');
|
|
376
376
|
lines.push(' id: string;');
|
|
377
377
|
lines.push(' scope?: string;');
|
|
378
378
|
lines.push(' side?: "start" | "exit";');
|
|
379
379
|
lines.push(' executionIndex: number;');
|
|
380
380
|
lines.push(' status: TStatusType;');
|
|
381
|
-
lines.push(' }): void {');
|
|
381
|
+
lines.push(' }): Promise<void> {');
|
|
382
382
|
lines.push(' if (this.flowWeaverDebugger) {');
|
|
383
|
-
lines.push(' this.flowWeaverDebugger.sendEvent({');
|
|
383
|
+
lines.push(' await this.flowWeaverDebugger.sendEvent({');
|
|
384
384
|
lines.push(' type: "STATUS_CHANGED",');
|
|
385
385
|
lines.push(' ...args,');
|
|
386
386
|
lines.push(' innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,');
|
package/dist/cli/flow-weaver.mjs
CHANGED
|
@@ -9671,7 +9671,7 @@ var VERSION;
|
|
|
9671
9671
|
var init_generated_version = __esm({
|
|
9672
9672
|
"src/generated-version.ts"() {
|
|
9673
9673
|
"use strict";
|
|
9674
|
-
VERSION = "0.21.
|
|
9674
|
+
VERSION = "0.21.21";
|
|
9675
9675
|
}
|
|
9676
9676
|
});
|
|
9677
9677
|
|
|
@@ -10324,12 +10324,13 @@ function generateScopeFunctionClosure(scopeName, parentNodeId, parentNodeType, w
|
|
|
10324
10324
|
return;
|
|
10325
10325
|
}
|
|
10326
10326
|
const safeChildId = toValidIdentifier(child.id);
|
|
10327
|
+
const awaitPrefix = isAsync2 ? "await " : "";
|
|
10327
10328
|
lines.push(``);
|
|
10328
10329
|
lines.push(` // Execute: ${child.id} (${child.nodeType})`);
|
|
10329
10330
|
lines.push(` scopedCtx.checkAborted('${child.id}');`);
|
|
10330
10331
|
lines.push(` const ${safeChildId}Idx = scopedCtx.addExecution('${child.id}');`);
|
|
10331
10332
|
lines.push(` if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${child.id}';`);
|
|
10332
|
-
lines.push(` scopedCtx.sendStatusChangedEvent({`);
|
|
10333
|
+
lines.push(` ${awaitPrefix}scopedCtx.sendStatusChangedEvent({`);
|
|
10333
10334
|
lines.push(` nodeTypeName: '${child.nodeType}',`);
|
|
10334
10335
|
lines.push(` id: '${child.id}',`);
|
|
10335
10336
|
lines.push(` executionIndex: ${safeChildId}Idx,`);
|
|
@@ -10375,7 +10376,6 @@ function generateScopeFunctionClosure(scopeName, parentNodeId, parentNodeType, w
|
|
|
10375
10376
|
nodeTypeName: child.nodeType
|
|
10376
10377
|
});
|
|
10377
10378
|
argLines.forEach((line) => lines.push(line));
|
|
10378
|
-
const awaitPrefix = isAsync2 ? "await " : "";
|
|
10379
10379
|
if (childNodeType.expression) {
|
|
10380
10380
|
lines.push(
|
|
10381
10381
|
` const ${safeChildId}Result = ${awaitPrefix}${child.nodeType}(${args.join(", ")});`
|
|
@@ -10409,7 +10409,7 @@ function generateScopeFunctionClosure(scopeName, parentNodeId, parentNodeType, w
|
|
|
10409
10409
|
);
|
|
10410
10410
|
});
|
|
10411
10411
|
}
|
|
10412
|
-
lines.push(` scopedCtx.sendStatusChangedEvent({`);
|
|
10412
|
+
lines.push(` ${awaitPrefix}scopedCtx.sendStatusChangedEvent({`);
|
|
10413
10413
|
lines.push(` nodeTypeName: '${child.nodeType}',`);
|
|
10414
10414
|
lines.push(` id: '${child.id}',`);
|
|
10415
10415
|
lines.push(` executionIndex: ${safeChildId}Idx,`);
|
|
@@ -10417,7 +10417,7 @@ function generateScopeFunctionClosure(scopeName, parentNodeId, parentNodeType, w
|
|
|
10417
10417
|
lines.push(` });`);
|
|
10418
10418
|
lines.push(` } catch (error: unknown) {`);
|
|
10419
10419
|
lines.push(` const isCancellation = CancellationError.isCancellationError(error);`);
|
|
10420
|
-
lines.push(` scopedCtx.sendStatusChangedEvent({`);
|
|
10420
|
+
lines.push(` ${awaitPrefix}scopedCtx.sendStatusChangedEvent({`);
|
|
10421
10421
|
lines.push(` nodeTypeName: '${child.nodeType}',`);
|
|
10422
10422
|
lines.push(` id: '${child.id}',`);
|
|
10423
10423
|
lines.push(` executionIndex: ${safeChildId}Idx,`);
|
|
@@ -10881,6 +10881,7 @@ function generateControlFlowWithExecutionContext(workflow, nodeTypes, isAsync2,
|
|
|
10881
10881
|
lines.push("");
|
|
10882
10882
|
}
|
|
10883
10883
|
lines.push(` const startIdx = ctx.addExecution('${RESERVED_NODE_NAMES.START}');`);
|
|
10884
|
+
const awaitPrefixTop = isAsync2 ? "await " : "";
|
|
10884
10885
|
Object.keys(extractStartPorts(workflow)).forEach((portName) => {
|
|
10885
10886
|
const setCall2 = isAsync2 ? `await ctx.setVariable` : `ctx.setVariable`;
|
|
10886
10887
|
const valueSource = isExecutePort(portName) ? "execute" : `params.${portName}`;
|
|
@@ -10888,7 +10889,7 @@ function generateControlFlowWithExecutionContext(workflow, nodeTypes, isAsync2,
|
|
|
10888
10889
|
` ${setCall2}({ id: '${RESERVED_NODE_NAMES.START}', portName: '${portName}', executionIndex: startIdx, nodeTypeName: '${RESERVED_NODE_NAMES.START}' }, ${valueSource});`
|
|
10889
10890
|
);
|
|
10890
10891
|
});
|
|
10891
|
-
lines.push(` ctx.sendStatusChangedEvent({`);
|
|
10892
|
+
lines.push(` ${awaitPrefixTop}ctx.sendStatusChangedEvent({`);
|
|
10892
10893
|
lines.push(` nodeTypeName: '${RESERVED_NODE_NAMES.START}',`);
|
|
10893
10894
|
lines.push(` id: '${RESERVED_NODE_NAMES.START}',`);
|
|
10894
10895
|
lines.push(` executionIndex: startIdx,`);
|
|
@@ -11384,7 +11385,7 @@ function generateControlFlowWithExecutionContext(workflow, nodeTypes, isAsync2,
|
|
|
11384
11385
|
const allProps = defaults3.length > 0 ? `${defaults3.join(", ")}${returnProps.length > 0 ? ", " : ""}${returnProps.join(", ")}` : returnProps.join(", ");
|
|
11385
11386
|
lines.push(` const finalResult = { ${allProps} };`);
|
|
11386
11387
|
lines.push("");
|
|
11387
|
-
lines.push(` ctx.sendStatusChangedEvent({`);
|
|
11388
|
+
lines.push(` ${awaitPrefixTop}ctx.sendStatusChangedEvent({`);
|
|
11388
11389
|
lines.push(` nodeTypeName: '${RESERVED_NODE_NAMES.EXIT}',`);
|
|
11389
11390
|
lines.push(` id: '${RESERVED_NODE_NAMES.EXIT}',`);
|
|
11390
11391
|
lines.push(` executionIndex: exitIdx,`);
|
|
@@ -11594,13 +11595,14 @@ function sortBranchNodesTopologically(nodeIds, workflow) {
|
|
|
11594
11595
|
}
|
|
11595
11596
|
return result;
|
|
11596
11597
|
}
|
|
11597
|
-
function generateCancelledEventsForBranch(nodeIds, workflow, allNodeTypes, lines, indent, ctxVar = "ctx") {
|
|
11598
|
+
function generateCancelledEventsForBranch(nodeIds, workflow, allNodeTypes, lines, indent, ctxVar = "ctx", isAsync2 = false) {
|
|
11599
|
+
const awaitPrefix = isAsync2 ? "await " : "";
|
|
11598
11600
|
nodeIds.forEach((instanceId) => {
|
|
11599
11601
|
const instance = workflow.instances.find((i) => i.id === instanceId);
|
|
11600
11602
|
if (!instance) return;
|
|
11601
11603
|
const safeId = toValidIdentifier(instanceId);
|
|
11602
11604
|
lines.push(`${indent}const ${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
11603
|
-
lines.push(`${indent}${ctxVar}.sendStatusChangedEvent({`);
|
|
11605
|
+
lines.push(`${indent}${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
11604
11606
|
lines.push(`${indent} nodeTypeName: '${instance.nodeType}',`);
|
|
11605
11607
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
11606
11608
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -11711,7 +11713,8 @@ function generateBranchingChainCode(chain, workflow, nodeTypes, branchingNodes,
|
|
|
11711
11713
|
nodeTypes,
|
|
11712
11714
|
lines,
|
|
11713
11715
|
indent + " ",
|
|
11714
|
-
ctxVar
|
|
11716
|
+
ctxVar,
|
|
11717
|
+
isAsync2
|
|
11715
11718
|
);
|
|
11716
11719
|
lines.push(`${indent}}`);
|
|
11717
11720
|
}
|
|
@@ -11741,6 +11744,7 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
11741
11744
|
lines.push(`${indent}if (${awaitHook}__ctrl__.beforeNode('${instanceId}', ${ctxVar})) {`);
|
|
11742
11745
|
indent = `${indent} `;
|
|
11743
11746
|
}
|
|
11747
|
+
const awaitPrefix = isAsync2 ? "await " : "";
|
|
11744
11748
|
if (!production) {
|
|
11745
11749
|
lines.push("");
|
|
11746
11750
|
lines.push(`${indent}// \u2500\u2500 ${instanceId} (${functionName}) \u2500\u2500`);
|
|
@@ -11748,7 +11752,7 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
11748
11752
|
lines.push(`${indent}${ctxVar}.checkAborted('${instanceId}');`);
|
|
11749
11753
|
lines.push(`${indent}${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
11750
11754
|
lines.push(`${indent}if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${instanceId}';`);
|
|
11751
|
-
lines.push(`${indent}${ctxVar}.sendStatusChangedEvent({`);
|
|
11755
|
+
lines.push(`${indent}${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
11752
11756
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
11753
11757
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
11754
11758
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -11876,7 +11880,7 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
11876
11880
|
);
|
|
11877
11881
|
});
|
|
11878
11882
|
}
|
|
11879
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
11883
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
11880
11884
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
11881
11885
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
11882
11886
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -11893,7 +11897,7 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
11893
11897
|
}
|
|
11894
11898
|
lines.push(`${indent}} catch (error: unknown) {`);
|
|
11895
11899
|
lines.push(`${indent} const isCancellation = CancellationError.isCancellationError(error);`);
|
|
11896
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
11900
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
11897
11901
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
11898
11902
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
11899
11903
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -11923,7 +11927,8 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
11923
11927
|
allNodeTypes,
|
|
11924
11928
|
lines,
|
|
11925
11929
|
`${indent} `,
|
|
11926
|
-
ctxVar
|
|
11930
|
+
ctxVar,
|
|
11931
|
+
isAsync2
|
|
11927
11932
|
);
|
|
11928
11933
|
}
|
|
11929
11934
|
if (hasFailureDownstream) {
|
|
@@ -11933,7 +11938,8 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
11933
11938
|
allNodeTypes,
|
|
11934
11939
|
lines,
|
|
11935
11940
|
`${indent} `,
|
|
11936
|
-
ctxVar
|
|
11941
|
+
ctxVar,
|
|
11942
|
+
isAsync2
|
|
11937
11943
|
);
|
|
11938
11944
|
}
|
|
11939
11945
|
lines.push(`${indent} throw error;`);
|
|
@@ -11957,7 +11963,8 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
11957
11963
|
allNodeTypes,
|
|
11958
11964
|
lines,
|
|
11959
11965
|
`${indent} `,
|
|
11960
|
-
ctxVar
|
|
11966
|
+
ctxVar,
|
|
11967
|
+
isAsync2
|
|
11961
11968
|
);
|
|
11962
11969
|
}
|
|
11963
11970
|
const successVars = new Map(availableVars);
|
|
@@ -12033,7 +12040,8 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
12033
12040
|
allNodeTypes,
|
|
12034
12041
|
lines,
|
|
12035
12042
|
`${indent} `,
|
|
12036
|
-
ctxVar
|
|
12043
|
+
ctxVar,
|
|
12044
|
+
isAsync2
|
|
12037
12045
|
);
|
|
12038
12046
|
}
|
|
12039
12047
|
const failureVars = new Map(availableVars);
|
|
@@ -12110,7 +12118,8 @@ function generateBranchingNodeCode(instance, branchNode, workflow, allNodeTypes,
|
|
|
12110
12118
|
allNodeTypes,
|
|
12111
12119
|
lines,
|
|
12112
12120
|
`${indent} `,
|
|
12113
|
-
ctxVar
|
|
12121
|
+
ctxVar,
|
|
12122
|
+
isAsync2
|
|
12114
12123
|
);
|
|
12115
12124
|
lines.push(`${indent}}`);
|
|
12116
12125
|
} else {
|
|
@@ -12127,6 +12136,7 @@ function generatePullNodeWithContext(instance, nodeType, workflow, lines, indent
|
|
|
12127
12136
|
const executorIsAsync = isAsync2 || nodeType.isAsync;
|
|
12128
12137
|
const asyncKeyword = executorIsAsync ? "async " : "";
|
|
12129
12138
|
const awaitKeyword = nodeType.isAsync ? "await " : "";
|
|
12139
|
+
const awaitPrefix = executorIsAsync ? "await " : "";
|
|
12130
12140
|
lines.push(`${indent}// Pull execution node: ${instanceId}`);
|
|
12131
12141
|
lines.push(`${indent}const ${safeId}_executor = ${asyncKeyword}() => {`);
|
|
12132
12142
|
lines.push(`${indent} if (${safeId}Idx !== undefined) {`);
|
|
@@ -12135,7 +12145,7 @@ function generatePullNodeWithContext(instance, nodeType, workflow, lines, indent
|
|
|
12135
12145
|
lines.push(`${indent} ${ctxVar}.checkAborted('${instanceId}');`);
|
|
12136
12146
|
lines.push(`${indent} ${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
12137
12147
|
lines.push(`${indent} if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${instanceId}';`);
|
|
12138
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
12148
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
12139
12149
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
12140
12150
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
12141
12151
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -12201,7 +12211,7 @@ function generatePullNodeWithContext(instance, nodeType, workflow, lines, indent
|
|
|
12201
12211
|
`${indent} ${setCall}({ id: '${instanceId}', portName: '${portName}', executionIndex: ${safeId}Idx, nodeTypeName: '${functionName}' }, ${resultVar}.${portName});`
|
|
12202
12212
|
);
|
|
12203
12213
|
});
|
|
12204
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
12214
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
12205
12215
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
12206
12216
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
12207
12217
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -12209,7 +12219,7 @@ function generatePullNodeWithContext(instance, nodeType, workflow, lines, indent
|
|
|
12209
12219
|
lines.push(`${indent} });`);
|
|
12210
12220
|
lines.push(`${indent} } catch (error: unknown) {`);
|
|
12211
12221
|
lines.push(`${indent} const isCancellation = CancellationError.isCancellationError(error);`);
|
|
12212
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
12222
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
12213
12223
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
12214
12224
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
12215
12225
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -12360,10 +12370,11 @@ function generateNodeCallWithContext(instance, nodeType, workflow, _availableVar
|
|
|
12360
12370
|
indent = `${indent} `;
|
|
12361
12371
|
}
|
|
12362
12372
|
const varDecl = useConst && !emitDebugHooks ? "const " : "";
|
|
12373
|
+
const awaitPrefix = isAsync2 ? "await " : "";
|
|
12363
12374
|
lines.push(`${indent}${ctxVar}.checkAborted('${instanceId}');`);
|
|
12364
12375
|
lines.push(`${indent}${varDecl}${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
12365
12376
|
lines.push(`${indent}if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${instanceId}';`);
|
|
12366
|
-
lines.push(`${indent}${ctxVar}.sendStatusChangedEvent({`);
|
|
12377
|
+
lines.push(`${indent}${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
12367
12378
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
12368
12379
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
12369
12380
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -12510,7 +12521,7 @@ function generateNodeCallWithContext(instance, nodeType, workflow, _availableVar
|
|
|
12510
12521
|
);
|
|
12511
12522
|
});
|
|
12512
12523
|
}
|
|
12513
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
12524
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
12514
12525
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
12515
12526
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
12516
12527
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -12522,7 +12533,7 @@ function generateNodeCallWithContext(instance, nodeType, workflow, _availableVar
|
|
|
12522
12533
|
}
|
|
12523
12534
|
lines.push(`${indent}} catch (error: unknown) {`);
|
|
12524
12535
|
lines.push(`${indent} const isCancellation = CancellationError.isCancellationError(error);`);
|
|
12525
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
12536
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
12526
12537
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
12527
12538
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
12528
12539
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -17022,7 +17033,7 @@ function generateInlineRuntime(production, exportClasses = false, outputFormat =
|
|
|
17022
17033
|
lines.push(" | TWorkflowCompletedEvent;");
|
|
17023
17034
|
lines.push("");
|
|
17024
17035
|
lines.push(`${exportKeyword}type TDebugger = {`);
|
|
17025
|
-
lines.push(" sendEvent: (event: TEvent) => void
|
|
17036
|
+
lines.push(" sendEvent: (event: TEvent) => void | Promise<void>;");
|
|
17026
17037
|
lines.push(" innerFlowInvocation: boolean;");
|
|
17027
17038
|
lines.push(" sessionId?: string;");
|
|
17028
17039
|
lines.push("};");
|
|
@@ -17286,16 +17297,16 @@ function generateInlineRuntime(production, exportClasses = false, outputFormat =
|
|
|
17286
17297
|
lines.push(" }");
|
|
17287
17298
|
lines.push("");
|
|
17288
17299
|
if (!production) {
|
|
17289
|
-
lines.push(" sendStatusChangedEvent(args: {");
|
|
17300
|
+
lines.push(" async sendStatusChangedEvent(args: {");
|
|
17290
17301
|
lines.push(" nodeTypeName: string;");
|
|
17291
17302
|
lines.push(" id: string;");
|
|
17292
17303
|
lines.push(" scope?: string;");
|
|
17293
17304
|
lines.push(' side?: "start" | "exit";');
|
|
17294
17305
|
lines.push(" executionIndex: number;");
|
|
17295
17306
|
lines.push(" status: TStatusType;");
|
|
17296
|
-
lines.push(" }): void {");
|
|
17307
|
+
lines.push(" }): Promise<void> {");
|
|
17297
17308
|
lines.push(" if (this.flowWeaverDebugger) {");
|
|
17298
|
-
lines.push(" this.flowWeaverDebugger.sendEvent({");
|
|
17309
|
+
lines.push(" await this.flowWeaverDebugger.sendEvent({");
|
|
17299
17310
|
lines.push(' type: "STATUS_CHANGED",');
|
|
17300
17311
|
lines.push(" ...args,");
|
|
17301
17312
|
lines.push(" innerFlowInvocation: this.flowWeaverDebugger.innerFlowInvocation,");
|
|
@@ -93270,7 +93281,7 @@ function displayInstalledPackage(pkg) {
|
|
|
93270
93281
|
// src/cli/index.ts
|
|
93271
93282
|
init_logger();
|
|
93272
93283
|
init_error_utils();
|
|
93273
|
-
var version2 = true ? "0.21.
|
|
93284
|
+
var version2 = true ? "0.21.21" : "0.0.0-dev";
|
|
93274
93285
|
var program2 = new Command();
|
|
93275
93286
|
program2.name("fw").description("Flow Weaver Annotations - Compile and validate workflow files").option("-v, --version", "Output the current version").option("--no-color", "Disable colors").option("--color", "Force colors").on("option:version", () => {
|
|
93276
93287
|
logger.banner(version2);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.21.
|
|
1
|
+
export declare const VERSION = "0.21.21";
|
|
2
2
|
//# sourceMappingURL=generated-version.d.ts.map
|
|
@@ -417,7 +417,7 @@ export function generateNodeWithExecutionContext(node, workflow, lines, isAsync,
|
|
|
417
417
|
const setCall = isAsync ? 'await ctx.setVariable' : 'ctx.setVariable';
|
|
418
418
|
lines.push(`${indent}const ${safeNodeName}Idx = ctx.addExecution('${nodeName}');`);
|
|
419
419
|
lines.push(`${indent}if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${nodeName}';`);
|
|
420
|
-
lines.push(`${indent}ctx.sendStatusChangedEvent({`);
|
|
420
|
+
lines.push(`${indent}${awaitPrefix}ctx.sendStatusChangedEvent({`);
|
|
421
421
|
lines.push(`${indent} nodeTypeName: '${nodeName}',`);
|
|
422
422
|
lines.push(`${indent} id: '${nodeName}',`);
|
|
423
423
|
lines.push(`${indent} executionIndex: ${safeNodeName}Idx,`);
|
|
@@ -440,7 +440,7 @@ export function generateNodeWithExecutionContext(node, workflow, lines, isAsync,
|
|
|
440
440
|
return;
|
|
441
441
|
lines.push(`${indent} ${setCall}({ id: '${nodeName}', portName: '${portName}', executionIndex: ${safeNodeName}Idx, nodeTypeName: '${nodeName}' }, ${resultVar}.${portName});`);
|
|
442
442
|
});
|
|
443
|
-
lines.push(`${indent} ctx.sendStatusChangedEvent({`);
|
|
443
|
+
lines.push(`${indent} ${awaitPrefix}ctx.sendStatusChangedEvent({`);
|
|
444
444
|
lines.push(`${indent} nodeTypeName: '${nodeName}',`);
|
|
445
445
|
lines.push(`${indent} id: '${nodeName}',`);
|
|
446
446
|
lines.push(`${indent} executionIndex: ${safeNodeName}Idx,`);
|
|
@@ -457,7 +457,7 @@ export function generateNodeWithExecutionContext(node, workflow, lines, isAsync,
|
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
lines.push(`${indent}} catch (error: unknown) {`);
|
|
460
|
-
lines.push(`${indent} ctx.sendStatusChangedEvent({`);
|
|
460
|
+
lines.push(`${indent} ${awaitPrefix}ctx.sendStatusChangedEvent({`);
|
|
461
461
|
lines.push(`${indent} nodeTypeName: '${nodeName}',`);
|
|
462
462
|
lines.push(`${indent} id: '${nodeName}',`);
|
|
463
463
|
lines.push(`${indent} executionIndex: ${safeNodeName}Idx,`);
|
|
@@ -180,12 +180,13 @@ export function generateScopeFunctionClosure(scopeName, parentNodeId, parentNode
|
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
182
|
const safeChildId = toValidIdentifier(child.id);
|
|
183
|
+
const awaitPrefix = isAsync ? 'await ' : '';
|
|
183
184
|
lines.push(``);
|
|
184
185
|
lines.push(` // Execute: ${child.id} (${child.nodeType})`);
|
|
185
186
|
lines.push(` scopedCtx.checkAborted('${child.id}');`);
|
|
186
187
|
lines.push(` const ${safeChildId}Idx = scopedCtx.addExecution('${child.id}');`);
|
|
187
188
|
lines.push(` if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${child.id}';`);
|
|
188
|
-
lines.push(` scopedCtx.sendStatusChangedEvent({`);
|
|
189
|
+
lines.push(` ${awaitPrefix}scopedCtx.sendStatusChangedEvent({`);
|
|
189
190
|
lines.push(` nodeTypeName: '${child.nodeType}',`);
|
|
190
191
|
lines.push(` id: '${child.id}',`);
|
|
191
192
|
lines.push(` executionIndex: ${safeChildId}Idx,`);
|
|
@@ -235,7 +236,6 @@ export function generateScopeFunctionClosure(scopeName, parentNodeId, parentNode
|
|
|
235
236
|
// Add argument building lines
|
|
236
237
|
argLines.forEach((line) => lines.push(line));
|
|
237
238
|
// Call the child node function
|
|
238
|
-
const awaitPrefix = isAsync ? 'await ' : '';
|
|
239
239
|
if (childNodeType.expression) {
|
|
240
240
|
// Expression nodes use original signature (positional args, no execute)
|
|
241
241
|
lines.push(` const ${safeChildId}Result = ${awaitPrefix}${child.nodeType}(${args.join(', ')});`);
|
|
@@ -269,7 +269,7 @@ export function generateScopeFunctionClosure(scopeName, parentNodeId, parentNode
|
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
// Add SUCCEEDED status event
|
|
272
|
-
lines.push(` scopedCtx.sendStatusChangedEvent({`);
|
|
272
|
+
lines.push(` ${awaitPrefix}scopedCtx.sendStatusChangedEvent({`);
|
|
273
273
|
lines.push(` nodeTypeName: '${child.nodeType}',`);
|
|
274
274
|
lines.push(` id: '${child.id}',`);
|
|
275
275
|
lines.push(` executionIndex: ${safeChildId}Idx,`);
|
|
@@ -277,7 +277,7 @@ export function generateScopeFunctionClosure(scopeName, parentNodeId, parentNode
|
|
|
277
277
|
lines.push(` });`);
|
|
278
278
|
lines.push(` } catch (error: unknown) {`);
|
|
279
279
|
lines.push(` const isCancellation = CancellationError.isCancellationError(error);`);
|
|
280
|
-
lines.push(` scopedCtx.sendStatusChangedEvent({`);
|
|
280
|
+
lines.push(` ${awaitPrefix}scopedCtx.sendStatusChangedEvent({`);
|
|
281
281
|
lines.push(` nodeTypeName: '${child.nodeType}',`);
|
|
282
282
|
lines.push(` id: '${child.id}',`);
|
|
283
283
|
lines.push(` executionIndex: ${safeChildId}Idx,`);
|
|
@@ -122,13 +122,14 @@ export function generateControlFlowWithExecutionContext(workflow, nodeTypes, isA
|
|
|
122
122
|
lines.push('');
|
|
123
123
|
}
|
|
124
124
|
lines.push(` const startIdx = ctx.addExecution('${RESERVED_NODE_NAMES.START}');`);
|
|
125
|
+
const awaitPrefixTop = isAsync ? 'await ' : '';
|
|
125
126
|
Object.keys(extractStartPorts(workflow)).forEach((portName) => {
|
|
126
127
|
const setCall = isAsync ? `await ctx.setVariable` : `ctx.setVariable`;
|
|
127
128
|
// STEP Port Architecture: execute comes from workflow parameter, data from params object
|
|
128
129
|
const valueSource = isExecutePort(portName) ? 'execute' : `params.${portName}`;
|
|
129
130
|
lines.push(` ${setCall}({ id: '${RESERVED_NODE_NAMES.START}', portName: '${portName}', executionIndex: startIdx, nodeTypeName: '${RESERVED_NODE_NAMES.START}' }, ${valueSource});`);
|
|
130
131
|
});
|
|
131
|
-
lines.push(` ctx.sendStatusChangedEvent({`);
|
|
132
|
+
lines.push(` ${awaitPrefixTop}ctx.sendStatusChangedEvent({`);
|
|
132
133
|
lines.push(` nodeTypeName: '${RESERVED_NODE_NAMES.START}',`);
|
|
133
134
|
lines.push(` id: '${RESERVED_NODE_NAMES.START}',`);
|
|
134
135
|
lines.push(` executionIndex: startIdx,`);
|
|
@@ -594,7 +595,7 @@ export function generateControlFlowWithExecutionContext(workflow, nodeTypes, isA
|
|
|
594
595
|
: returnProps.join(', ');
|
|
595
596
|
lines.push(` const finalResult = { ${allProps} };`);
|
|
596
597
|
lines.push('');
|
|
597
|
-
lines.push(` ctx.sendStatusChangedEvent({`);
|
|
598
|
+
lines.push(` ${awaitPrefixTop}ctx.sendStatusChangedEvent({`);
|
|
598
599
|
lines.push(` nodeTypeName: '${RESERVED_NODE_NAMES.EXIT}',`);
|
|
599
600
|
lines.push(` id: '${RESERVED_NODE_NAMES.EXIT}',`);
|
|
600
601
|
lines.push(` executionIndex: exitIdx,`);
|
|
@@ -805,8 +806,9 @@ function sortBranchNodesTopologically(nodeIds, workflow) {
|
|
|
805
806
|
* the non-taken path as CANCELLED. We must add an execution index first to have a
|
|
806
807
|
* valid reference for the event.
|
|
807
808
|
*/
|
|
808
|
-
function generateCancelledEventsForBranch(nodeIds, workflow, allNodeTypes, lines, indent, ctxVar = 'ctx' // Context variable name (for scoped contexts)
|
|
809
|
-
) {
|
|
809
|
+
function generateCancelledEventsForBranch(nodeIds, workflow, allNodeTypes, lines, indent, ctxVar = 'ctx', // Context variable name (for scoped contexts)
|
|
810
|
+
isAsync = false) {
|
|
811
|
+
const awaitPrefix = isAsync ? 'await ' : '';
|
|
810
812
|
nodeIds.forEach((instanceId) => {
|
|
811
813
|
const instance = workflow.instances.find((i) => i.id === instanceId);
|
|
812
814
|
if (!instance)
|
|
@@ -814,7 +816,7 @@ function generateCancelledEventsForBranch(nodeIds, workflow, allNodeTypes, lines
|
|
|
814
816
|
const safeId = toValidIdentifier(instanceId);
|
|
815
817
|
// Add execution index for this skipped node so the event has a valid reference
|
|
816
818
|
lines.push(`${indent}const ${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
817
|
-
lines.push(`${indent}${ctxVar}.sendStatusChangedEvent({`);
|
|
819
|
+
lines.push(`${indent}${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
818
820
|
lines.push(`${indent} nodeTypeName: '${instance.nodeType}',`);
|
|
819
821
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
820
822
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -911,7 +913,7 @@ function generateBranchingChainCode(chain, workflow, nodeTypes, branchingNodes,
|
|
|
911
913
|
region.successNodes.forEach((n) => remainingNodes.add(n));
|
|
912
914
|
region.failureNodes.forEach((n) => remainingNodes.add(n));
|
|
913
915
|
}
|
|
914
|
-
generateCancelledEventsForBranch(remainingNodes, workflow, nodeTypes, lines, indent + ' ', ctxVar);
|
|
916
|
+
generateCancelledEventsForBranch(remainingNodes, workflow, nodeTypes, lines, indent + ' ', ctxVar, isAsync);
|
|
915
917
|
lines.push(`${indent}}`);
|
|
916
918
|
}
|
|
917
919
|
// Add success condition for next iteration's guard
|
|
@@ -949,6 +951,7 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
949
951
|
lines.push(`${indent}if (${awaitHook}__ctrl__.beforeNode('${instanceId}', ${ctxVar})) {`);
|
|
950
952
|
indent = `${indent} `;
|
|
951
953
|
}
|
|
954
|
+
const awaitPrefix = isAsync ? 'await ' : '';
|
|
952
955
|
if (!production) {
|
|
953
956
|
lines.push('');
|
|
954
957
|
lines.push(`${indent}// ── ${instanceId} (${functionName}) ──`);
|
|
@@ -956,7 +959,7 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
956
959
|
lines.push(`${indent}${ctxVar}.checkAborted('${instanceId}');`);
|
|
957
960
|
lines.push(`${indent}${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
958
961
|
lines.push(`${indent}if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${instanceId}';`);
|
|
959
|
-
lines.push(`${indent}${ctxVar}.sendStatusChangedEvent({`);
|
|
962
|
+
lines.push(`${indent}${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
960
963
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
961
964
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
962
965
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1098,7 +1101,7 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
1098
1101
|
lines.push(`${indent} ${setCall}({ id: '${instanceId}', portName: '${portName}', executionIndex: ${safeId}Idx, nodeTypeName: '${functionName}' }, ${safeId}Result.${portName});`);
|
|
1099
1102
|
});
|
|
1100
1103
|
}
|
|
1101
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
1104
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1102
1105
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1103
1106
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1104
1107
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1116,7 +1119,7 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
1116
1119
|
}
|
|
1117
1120
|
lines.push(`${indent}} catch (error: unknown) {`);
|
|
1118
1121
|
lines.push(`${indent} const isCancellation = CancellationError.isCancellationError(error);`);
|
|
1119
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
1122
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1120
1123
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1121
1124
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1122
1125
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1137,10 +1140,10 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
1137
1140
|
lines.push(`${indent} }`);
|
|
1138
1141
|
// Emit CANCELLED for all downstream nodes since branching node threw
|
|
1139
1142
|
if (hasSuccessDownstream) {
|
|
1140
|
-
generateCancelledEventsForBranch(region.successNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar);
|
|
1143
|
+
generateCancelledEventsForBranch(region.successNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar, isAsync);
|
|
1141
1144
|
}
|
|
1142
1145
|
if (hasFailureDownstream) {
|
|
1143
|
-
generateCancelledEventsForBranch(region.failureNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar);
|
|
1146
|
+
generateCancelledEventsForBranch(region.failureNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar, isAsync);
|
|
1144
1147
|
}
|
|
1145
1148
|
// Re-throw the error to propagate it up (important for recursive workflows)
|
|
1146
1149
|
lines.push(`${indent} throw error;`);
|
|
@@ -1165,7 +1168,7 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
1165
1168
|
lines.push(`${indent}if (${safeId}_success) {`);
|
|
1166
1169
|
// Emit CANCELLED for failure branch nodes since success path was taken
|
|
1167
1170
|
if (hasFailureDownstream) {
|
|
1168
|
-
generateCancelledEventsForBranch(region.failureNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar);
|
|
1171
|
+
generateCancelledEventsForBranch(region.failureNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar, isAsync);
|
|
1169
1172
|
}
|
|
1170
1173
|
const successVars = new Map(availableVars);
|
|
1171
1174
|
Object.keys(branchNode.outputs).forEach((portName) => {
|
|
@@ -1206,7 +1209,7 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
1206
1209
|
lines.push(`${indent}} else {`);
|
|
1207
1210
|
// Emit CANCELLED for success branch nodes since failure path was taken
|
|
1208
1211
|
if (hasSuccessDownstream) {
|
|
1209
|
-
generateCancelledEventsForBranch(region.successNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar);
|
|
1212
|
+
generateCancelledEventsForBranch(region.successNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar, isAsync);
|
|
1210
1213
|
}
|
|
1211
1214
|
const failureVars = new Map(availableVars);
|
|
1212
1215
|
Object.keys(branchNode.outputs).forEach((portName) => {
|
|
@@ -1248,7 +1251,7 @@ bundleMode = false, preDeclaredSuccessFlags = new Set(), forceTrackSuccess = fal
|
|
|
1248
1251
|
// No failure branch - emit CANCELLED for success nodes and close
|
|
1249
1252
|
if (hasSuccessDownstream) {
|
|
1250
1253
|
lines.push(`${indent}} else {`);
|
|
1251
|
-
generateCancelledEventsForBranch(region.successNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar);
|
|
1254
|
+
generateCancelledEventsForBranch(region.successNodes, workflow, allNodeTypes, lines, `${indent} `, ctxVar, isAsync);
|
|
1252
1255
|
lines.push(`${indent}}`);
|
|
1253
1256
|
}
|
|
1254
1257
|
else {
|
|
@@ -1270,6 +1273,7 @@ bundleMode = false) {
|
|
|
1270
1273
|
const executorIsAsync = isAsync || nodeType.isAsync;
|
|
1271
1274
|
const asyncKeyword = executorIsAsync ? 'async ' : '';
|
|
1272
1275
|
const awaitKeyword = nodeType.isAsync ? 'await ' : '';
|
|
1276
|
+
const awaitPrefix = executorIsAsync ? 'await ' : '';
|
|
1273
1277
|
// Create a lazy execution function for this pull node
|
|
1274
1278
|
// The function will only execute when its outputs are accessed
|
|
1275
1279
|
lines.push(`${indent}// Pull execution node: ${instanceId}`);
|
|
@@ -1280,7 +1284,7 @@ bundleMode = false) {
|
|
|
1280
1284
|
lines.push(`${indent} ${ctxVar}.checkAborted('${instanceId}');`);
|
|
1281
1285
|
lines.push(`${indent} ${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
1282
1286
|
lines.push(`${indent} if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${instanceId}';`);
|
|
1283
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
1287
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1284
1288
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1285
1289
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1286
1290
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1356,7 +1360,7 @@ bundleMode = false) {
|
|
|
1356
1360
|
return;
|
|
1357
1361
|
lines.push(`${indent} ${setCall}({ id: '${instanceId}', portName: '${portName}', executionIndex: ${safeId}Idx, nodeTypeName: '${functionName}' }, ${resultVar}.${portName});`);
|
|
1358
1362
|
});
|
|
1359
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
1363
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1360
1364
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1361
1365
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1362
1366
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1364,7 +1368,7 @@ bundleMode = false) {
|
|
|
1364
1368
|
lines.push(`${indent} });`);
|
|
1365
1369
|
lines.push(`${indent} } catch (error: unknown) {`);
|
|
1366
1370
|
lines.push(`${indent} const isCancellation = CancellationError.isCancellationError(error);`);
|
|
1367
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
1371
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1368
1372
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1369
1373
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1370
1374
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1549,10 +1553,11 @@ production = false // When false, emit debug controller hooks (beforeNode/afterN
|
|
|
1549
1553
|
}
|
|
1550
1554
|
// When debug hooks hoist the declaration, we use assignment only inside the block.
|
|
1551
1555
|
const varDecl = (useConst && !emitDebugHooks) ? 'const ' : '';
|
|
1556
|
+
const awaitPrefix = isAsync ? 'await ' : '';
|
|
1552
1557
|
lines.push(`${indent}${ctxVar}.checkAborted('${instanceId}');`);
|
|
1553
1558
|
lines.push(`${indent}${varDecl}${safeId}Idx = ${ctxVar}.addExecution('${instanceId}');`);
|
|
1554
1559
|
lines.push(`${indent}if (typeof globalThis !== 'undefined') (globalThis as any).__fw_current_node_id__ = '${instanceId}';`);
|
|
1555
|
-
lines.push(`${indent}${ctxVar}.sendStatusChangedEvent({`);
|
|
1560
|
+
lines.push(`${indent}${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1556
1561
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1557
1562
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1558
1563
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1712,7 +1717,7 @@ production = false // When false, emit debug controller hooks (beforeNode/afterN
|
|
|
1712
1717
|
lines.push(`${indent} ${setCall}({ id: '${instanceId}', portName: '${portName}', executionIndex: ${safeId}Idx, nodeTypeName: '${functionName}' }, ${resultVar}.${portName});`);
|
|
1713
1718
|
});
|
|
1714
1719
|
}
|
|
1715
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
1720
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1716
1721
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1717
1722
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1718
1723
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
|
@@ -1725,7 +1730,7 @@ production = false // When false, emit debug controller hooks (beforeNode/afterN
|
|
|
1725
1730
|
}
|
|
1726
1731
|
lines.push(`${indent}} catch (error: unknown) {`);
|
|
1727
1732
|
lines.push(`${indent} const isCancellation = CancellationError.isCancellationError(error);`);
|
|
1728
|
-
lines.push(`${indent} ${ctxVar}.sendStatusChangedEvent({`);
|
|
1733
|
+
lines.push(`${indent} ${awaitPrefix}${ctxVar}.sendStatusChangedEvent({`);
|
|
1729
1734
|
lines.push(`${indent} nodeTypeName: '${functionName}',`);
|
|
1730
1735
|
lines.push(`${indent} id: '${instanceId}',`);
|
|
1731
1736
|
lines.push(`${indent} executionIndex: ${safeId}Idx,`);
|
package/package.json
CHANGED