@emaarco/bpmn-js-data-simulation 0.5.0 → 0.7.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/README.md +2 -1
- package/dist/assets/bpmn-js-data-simulation.css +9 -4
- package/dist/domain/GatewayRouter.d.ts +3 -2
- package/dist/domain/GatewayRouter.d.ts.map +1 -1
- package/dist/domain/InstanceCounter.d.ts +9 -0
- package/dist/domain/InstanceCounter.d.ts.map +1 -0
- package/dist/domain/InstanceLoop.d.ts +12 -0
- package/dist/domain/InstanceLoop.d.ts.map +1 -0
- package/dist/domain/PathResolver.d.ts +1 -0
- package/dist/domain/PathResolver.d.ts.map +1 -1
- package/dist/domain/PathVariableDeriver.d.ts +4 -2
- package/dist/domain/PathVariableDeriver.d.ts.map +1 -1
- package/dist/domain/model.d.ts +20 -1
- package/dist/domain/model.d.ts.map +1 -1
- package/dist/engines/camunda7/Camunda7Engine.d.ts +3 -1
- package/dist/engines/camunda7/Camunda7Engine.d.ts.map +1 -1
- package/dist/engines/types.d.ts +4 -1
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/engines/zeebe/ZeebeEngine.d.ts +3 -1
- package/dist/engines/zeebe/ZeebeEngine.d.ts.map +1 -1
- package/dist/index.cjs +492 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +492 -81
- package/dist/index.js.map +1 -1
- package/dist/integration/DataGateways.d.ts +3 -0
- package/dist/integration/DataGateways.d.ts.map +1 -1
- package/dist/integration/DataSimulation.d.ts.map +1 -1
- package/dist/integration/DataSimulationOverlays.d.ts +6 -5
- package/dist/integration/DataSimulationOverlays.d.ts.map +1 -1
- package/dist/integration/MultiInstanceActivities.d.ts +32 -0
- package/dist/integration/MultiInstanceActivities.d.ts.map +1 -0
- package/dist/integration/PathGraphReader.d.ts +1 -0
- package/dist/integration/PathGraphReader.d.ts.map +1 -1
- package/dist/integration/PathSimulation.d.ts +6 -2
- package/dist/integration/PathSimulation.d.ts.map +1 -1
- package/dist/integration/VariableUsageCollector.d.ts.map +1 -1
- package/dist/integration/behaviors/DataActivityBehavior.d.ts +12 -0
- package/dist/integration/behaviors/DataActivityBehavior.d.ts.map +1 -0
- package/dist/integration/behaviors/MultiInstanceBehaviors.d.ts +9 -0
- package/dist/integration/behaviors/MultiInstanceBehaviors.d.ts.map +1 -0
- package/dist/integration/index.d.ts.map +1 -1
- package/dist/integration/tokenSimulation.d.ts +26 -0
- package/dist/integration/tokenSimulation.d.ts.map +1 -1
- package/dist/simulation/DataSimulationStore.d.ts +10 -4
- package/dist/simulation/DataSimulationStore.d.ts.map +1 -1
- package/dist/ui/DecisionCard.d.ts +1 -0
- package/dist/ui/DecisionCard.d.ts.map +1 -1
- package/dist/ui/InstanceProgress.d.ts +9 -0
- package/dist/ui/InstanceProgress.d.ts.map +1 -0
- package/dist/ui/VariablesPanel.d.ts +2 -0
- package/dist/ui/VariablesPanel.d.ts.map +1 -1
- package/dist/utils/diagramElements.d.ts +4 -1
- package/dist/utils/diagramElements.d.ts.map +1 -1
- package/dist/utils/moddle.d.ts +6 -0
- package/dist/utils/moddle.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -11,15 +11,17 @@ class GatewayRouter {
|
|
|
11
11
|
const evaluations = [];
|
|
12
12
|
for (const flow of conditional) {
|
|
13
13
|
const alreadyDecided = kind === "exclusive" && evaluations.some((evaluation) => this.isDecisive(evaluation));
|
|
14
|
-
evaluations.push(alreadyDecided ? { flow, outcome: "skipped" } : this.evaluateFlow(flow, evaluateCondition));
|
|
14
|
+
evaluations.push(alreadyDecided ? { flow, outcome: "skipped" } : this.evaluateFlow(kind, flow, evaluateCondition));
|
|
15
15
|
}
|
|
16
16
|
const failed = evaluations.find((evaluation) => evaluation.outcome === "error");
|
|
17
17
|
if (failed) {
|
|
18
|
-
|
|
18
|
+
const decision = this.stuck(
|
|
19
19
|
evaluations,
|
|
20
20
|
defaultFlow,
|
|
21
21
|
`Condition of "${failed.flow.name ?? failed.flow.id}" failed: ${failed.reason}`
|
|
22
22
|
);
|
|
23
|
+
const missingVariables = [...new Set(evaluations.flatMap((evaluation) => evaluation.missingVariables ?? []))];
|
|
24
|
+
return missingVariables.length ? { ...decision, missingVariables } : decision;
|
|
23
25
|
}
|
|
24
26
|
const taken = evaluations.filter((evaluation) => evaluation.outcome === "taken");
|
|
25
27
|
if (taken.length) {
|
|
@@ -35,13 +37,22 @@ class GatewayRouter {
|
|
|
35
37
|
}
|
|
36
38
|
return this.stuck(evaluations, defaultFlow, "No condition is true and there is no default flow");
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
refuse(outgoing, reason) {
|
|
41
|
+
return {
|
|
42
|
+
flows: outgoing.map((flow) => ({ flow, outcome: "skipped" })),
|
|
43
|
+
takenFlowIds: [],
|
|
44
|
+
stuckReason: reason,
|
|
45
|
+
refusedByEngine: true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
evaluateFlow(kind, flow, evaluateCondition) {
|
|
39
49
|
if (flow.expression === void 0) {
|
|
40
|
-
return { flow, outcome: "error", reason: "Missing condition" };
|
|
50
|
+
return kind === "activity" ? { flow, outcome: "taken", reason: "No condition" } : { flow, outcome: "error", reason: "Missing condition" };
|
|
41
51
|
}
|
|
42
52
|
const evaluation = evaluateCondition(flow.expression);
|
|
43
53
|
if (!evaluation.ok) {
|
|
44
|
-
|
|
54
|
+
const { reason, missingVariables } = evaluation;
|
|
55
|
+
return missingVariables ? { flow, outcome: "error", reason, missingVariables } : { flow, outcome: "error", reason };
|
|
45
56
|
}
|
|
46
57
|
if (typeof evaluation.value !== "boolean") {
|
|
47
58
|
return {
|
|
@@ -200,6 +211,16 @@ function readConditionExpression(sequenceFlow) {
|
|
|
200
211
|
language: typeof condition.language === "string" ? condition.language : void 0
|
|
201
212
|
};
|
|
202
213
|
}
|
|
214
|
+
function readMultiInstanceLoop(element) {
|
|
215
|
+
const characteristics = element.loopCharacteristics;
|
|
216
|
+
if (characteristics?.$type !== "bpmn:MultiInstanceLoopCharacteristics") return void 0;
|
|
217
|
+
const cardinality = characteristics.loopCardinality?.body;
|
|
218
|
+
return {
|
|
219
|
+
characteristics,
|
|
220
|
+
mode: characteristics.isSequential ? "sequential" : "parallel",
|
|
221
|
+
cardinality: typeof cardinality === "string" ? cardinality.trim() || void 0 : void 0
|
|
222
|
+
};
|
|
223
|
+
}
|
|
203
224
|
|
|
204
225
|
class JuelError extends Error {
|
|
205
226
|
constructor() {
|
|
@@ -616,6 +637,15 @@ class Camunda7Engine {
|
|
|
616
637
|
const isJuel = !condition?.language || condition.language.toLowerCase() === "juel";
|
|
617
638
|
return isJuel ? condition?.body?.trim() || void 0 : void 0;
|
|
618
639
|
}
|
|
640
|
+
readLoop(activity) {
|
|
641
|
+
const loop = readMultiInstanceLoop(activity);
|
|
642
|
+
if (!loop) return void 0;
|
|
643
|
+
return {
|
|
644
|
+
mode: loop.mode,
|
|
645
|
+
cardinality: loop.cardinality,
|
|
646
|
+
collection: this.collectionExpression(loop.characteristics)
|
|
647
|
+
};
|
|
648
|
+
}
|
|
619
649
|
canEvaluate(expression) {
|
|
620
650
|
try {
|
|
621
651
|
JuelTemplate.parse(expression);
|
|
@@ -641,6 +671,12 @@ class Camunda7Engine {
|
|
|
641
671
|
return [];
|
|
642
672
|
}
|
|
643
673
|
}
|
|
674
|
+
collectionExpression(characteristics) {
|
|
675
|
+
const collection = typeof characteristics.collection === "string" ? characteristics.collection.trim() : "";
|
|
676
|
+
if (!collection) return void 0;
|
|
677
|
+
const isVariableName = !/[$#]\{/.test(collection);
|
|
678
|
+
return isVariableName ? `\${${collection}}` : collection;
|
|
679
|
+
}
|
|
644
680
|
readMappings(element, property) {
|
|
645
681
|
const inputOutput = findExtension(element, "camunda:InputOutput");
|
|
646
682
|
return listProperty(inputOutput, property).filter((parameter) => typeof parameter.name === "string" && parameter.name && !parameter.definition).map((parameter) => ({
|
|
@@ -657,6 +693,7 @@ class ZeebeEngine {
|
|
|
657
693
|
this.label = "Zeebe";
|
|
658
694
|
this.expressionLanguage = "FEEL";
|
|
659
695
|
this.taskResultPropagation = "without-output-mappings";
|
|
696
|
+
this.activityConditionRefusal = "Zeebe rejects this model on deploy: conditional sequence flows are only supported at exclusive or inclusive gateways";
|
|
660
697
|
}
|
|
661
698
|
writeVariable(variables, target, value) {
|
|
662
699
|
return setVariable(variables, target, value);
|
|
@@ -670,6 +707,13 @@ class ZeebeEngine {
|
|
|
670
707
|
readCondition(sequenceFlow) {
|
|
671
708
|
return readConditionExpression(sequenceFlow)?.body?.trim() || void 0;
|
|
672
709
|
}
|
|
710
|
+
readLoop(activity) {
|
|
711
|
+
const loop = readMultiInstanceLoop(activity);
|
|
712
|
+
if (!loop) return void 0;
|
|
713
|
+
const inputCollection = findExtension(loop.characteristics, "zeebe:LoopCharacteristics")?.inputCollection;
|
|
714
|
+
const collection = typeof inputCollection === "string" ? inputCollection.trim() || void 0 : void 0;
|
|
715
|
+
return { mode: loop.mode, cardinality: loop.cardinality, collection };
|
|
716
|
+
}
|
|
673
717
|
canEvaluate(expression) {
|
|
674
718
|
return this.isFeel(expression) && this.parsesAsFeel(expression);
|
|
675
719
|
}
|
|
@@ -817,6 +861,9 @@ class DataSimulationStore {
|
|
|
817
861
|
addWaiting(instanceId, waiting) {
|
|
818
862
|
this.updateInstance(instanceId, (instance) => ({ ...instance, waiting: [...instance.waiting, waiting] }));
|
|
819
863
|
}
|
|
864
|
+
isWaitingScope(scopeId) {
|
|
865
|
+
return [...this.instances.values()].some((instance) => instance.waiting.some((waiting) => waiting.scopeId === scopeId));
|
|
866
|
+
}
|
|
820
867
|
removeWaiting(scopeId) {
|
|
821
868
|
const instance = [...this.instances.values()].find(
|
|
822
869
|
(candidate) => candidate.waiting.some((waiting) => waiting.scopeId === scopeId)
|
|
@@ -964,6 +1011,26 @@ class SimpleStartFormRenderer {
|
|
|
964
1011
|
}
|
|
965
1012
|
}
|
|
966
1013
|
|
|
1014
|
+
class DataActivityBehavior {
|
|
1015
|
+
constructor(behavior, dataGateways) {
|
|
1016
|
+
this.dataGateways = dataGateways;
|
|
1017
|
+
const exitThroughAllFlows = behavior.exit.bind(behavior);
|
|
1018
|
+
behavior.exit = (context) => {
|
|
1019
|
+
const { element, scope } = context;
|
|
1020
|
+
const completing = scope.active && !scope.failed;
|
|
1021
|
+
if (!completing || !this.dataGateways.routesActivityByData(element)) {
|
|
1022
|
+
exitThroughAllFlows(context);
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
this.dataGateways.exitActivity(
|
|
1026
|
+
context,
|
|
1027
|
+
(takenFlows) => exitThroughAllFlows({ ...context, element: { ...element, outgoing: takenFlows } })
|
|
1028
|
+
);
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
DataActivityBehavior.$inject = ["activityBehavior", "dataGateways"];
|
|
1033
|
+
|
|
967
1034
|
const FLOW_CHOICE_TYPES = ["bpmn:ExclusiveGateway", "bpmn:InclusiveGateway"];
|
|
968
1035
|
const TRIGGER_TYPE = "bpmn:Event";
|
|
969
1036
|
class DataContextPads {
|
|
@@ -1033,6 +1100,9 @@ function findProcessInstance(scope) {
|
|
|
1033
1100
|
while (current.parent) current = current.parent;
|
|
1034
1101
|
return current;
|
|
1035
1102
|
}
|
|
1103
|
+
function isLoopInstance(scope) {
|
|
1104
|
+
return scope.parent?.element === scope.element;
|
|
1105
|
+
}
|
|
1036
1106
|
function elementName(element) {
|
|
1037
1107
|
const name = element.businessObject.name;
|
|
1038
1108
|
return typeof name === "string" && name.trim() ? name.trim() : element.id;
|
|
@@ -1047,10 +1117,19 @@ function flowNodesOf(elementRegistry) {
|
|
|
1047
1117
|
function isGateway(element) {
|
|
1048
1118
|
return element.type === "bpmn:ExclusiveGateway" || element.type === "bpmn:InclusiveGateway";
|
|
1049
1119
|
}
|
|
1050
|
-
function
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1120
|
+
function decidingElementOf(element) {
|
|
1121
|
+
return element.type === "bpmn:SequenceFlow" ? element.source?.id : element.id;
|
|
1122
|
+
}
|
|
1123
|
+
function activityRouting(activity, engine) {
|
|
1124
|
+
if (!is(activity, "bpmn:Activity")) return "none";
|
|
1125
|
+
const conditional = outgoingSequenceFlows(activity).filter((flow) => readConditionExpression(flow.businessObject));
|
|
1126
|
+
if (engine.activityConditionRefusal) return conditional.length ? "refused" : "none";
|
|
1127
|
+
if (!conditional.length && !activity.businessObject.default) return "none";
|
|
1128
|
+
const evaluable = conditional.every((flow) => {
|
|
1129
|
+
const expression = engine.readCondition(flow.businessObject);
|
|
1130
|
+
return expression !== void 0 && engine.canEvaluate(expression);
|
|
1131
|
+
});
|
|
1132
|
+
return evaluable ? "by-conditions" : "none";
|
|
1054
1133
|
}
|
|
1055
1134
|
function outgoingSequenceFlows(element) {
|
|
1056
1135
|
return (element.outgoing ?? []).filter((flow) => is(flow, "bpmn:SequenceFlow"));
|
|
@@ -1065,6 +1144,33 @@ function readOutgoingFlow(sequenceFlow, engine) {
|
|
|
1065
1144
|
};
|
|
1066
1145
|
}
|
|
1067
1146
|
|
|
1147
|
+
class MultiInstanceBehaviors {
|
|
1148
|
+
constructor(activity, subProcess, multiInstance) {
|
|
1149
|
+
this.multiInstance = multiInstance;
|
|
1150
|
+
this.runInstances(activity);
|
|
1151
|
+
this.runInstances(subProcess);
|
|
1152
|
+
}
|
|
1153
|
+
runInstances(behavior) {
|
|
1154
|
+
const enterOnce = behavior.enter.bind(behavior);
|
|
1155
|
+
const exitOnce = behavior.exit.bind(behavior);
|
|
1156
|
+
behavior.enter = (context) => {
|
|
1157
|
+
const loop = this.multiInstance.loopOf(context.element);
|
|
1158
|
+
if (!loop) enterOnce(context);
|
|
1159
|
+
else if (isLoopInstance(context.scope))
|
|
1160
|
+
this.multiInstance.enterInstance(context, enterOnce);
|
|
1161
|
+
else this.multiInstance.enterBody(context, loop);
|
|
1162
|
+
};
|
|
1163
|
+
behavior.exit = (context) => {
|
|
1164
|
+
if (this.multiInstance.loopOf(context.element) && isLoopInstance(context.scope)) {
|
|
1165
|
+
this.multiInstance.exitInstance(context);
|
|
1166
|
+
} else {
|
|
1167
|
+
exitOnce(context);
|
|
1168
|
+
}
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
MultiInstanceBehaviors.$inject = ["activityBehavior", "subProcessBehavior", "multiInstanceActivities"];
|
|
1173
|
+
|
|
1068
1174
|
class DataGateways {
|
|
1069
1175
|
constructor(dataSimulation, store, simulator) {
|
|
1070
1176
|
this.dataSimulation = dataSimulation;
|
|
@@ -1077,6 +1183,9 @@ class DataGateways {
|
|
|
1077
1183
|
const outgoing = this.outgoingFlows(gateway);
|
|
1078
1184
|
return this.dataSimulation.isEnabled() && outgoing.length > 1 && outgoing.filter((flow) => !flow.isDefault).every((flow) => flow.expression !== void 0 && engine.canEvaluate(flow.expression));
|
|
1079
1185
|
}
|
|
1186
|
+
routesActivityByData(activity) {
|
|
1187
|
+
return this.dataSimulation.isEnabled() && activityRouting(activity, this.dataSimulation.getEngine()) !== "none";
|
|
1188
|
+
}
|
|
1080
1189
|
exit(context, kind) {
|
|
1081
1190
|
const { element: gateway, scope } = context;
|
|
1082
1191
|
const decision = this.decide(gateway, scope, kind);
|
|
@@ -1084,11 +1193,19 @@ class DataGateways {
|
|
|
1084
1193
|
this.waitForRetry(gateway, scope);
|
|
1085
1194
|
return;
|
|
1086
1195
|
}
|
|
1087
|
-
for (const
|
|
1088
|
-
const flow = outgoingSequenceFlows(gateway).find((candidate) => candidate.id === flowId);
|
|
1196
|
+
for (const flow of this.takenFlows(gateway, decision)) {
|
|
1089
1197
|
this.simulator.enter({ element: flow, scope: scope.parent });
|
|
1090
1198
|
}
|
|
1091
1199
|
}
|
|
1200
|
+
exitActivity(context, leaveThrough) {
|
|
1201
|
+
const { element: activity, scope } = context;
|
|
1202
|
+
const decision = this.decide(activity, scope, "activity");
|
|
1203
|
+
if (decision.stuckReason) {
|
|
1204
|
+
this.waitForRetry(activity, scope);
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
leaveThrough(this.takenFlows(activity, decision));
|
|
1208
|
+
}
|
|
1092
1209
|
recordClickDecision(context, kind) {
|
|
1093
1210
|
if (!this.dataSimulation.isEnabled()) return;
|
|
1094
1211
|
const { element: gateway, scope } = context;
|
|
@@ -1105,45 +1222,48 @@ class DataGateways {
|
|
|
1105
1222
|
};
|
|
1106
1223
|
this.record(gateway, scope, kind, "click", decision, []);
|
|
1107
1224
|
}
|
|
1108
|
-
decide(
|
|
1225
|
+
decide(element, scope, kind) {
|
|
1109
1226
|
const engine = this.dataSimulation.getEngine();
|
|
1110
1227
|
const variables = this.dataSimulation.getVariables(scope);
|
|
1111
|
-
const outgoing = this.outgoingFlows(
|
|
1112
|
-
const
|
|
1228
|
+
const outgoing = this.outgoingFlows(element);
|
|
1229
|
+
const refusal = kind === "activity" ? engine.activityConditionRefusal : void 0;
|
|
1230
|
+
const decision = refusal ? this.router.refuse(outgoing, refusal) : this.router.route(kind, outgoing, (expression) => engine.evaluate(expression, variables));
|
|
1113
1231
|
const names = outgoing.flatMap((flow) => flow.expression ? engine.readVariableNames(flow.expression) : []);
|
|
1114
1232
|
const inputs = [...new Set(names)].map((name) => ({ name, value: structuredClone(variables[name]) }));
|
|
1115
|
-
this.record(
|
|
1233
|
+
this.record(element, scope, kind, "data", decision, inputs);
|
|
1116
1234
|
return decision;
|
|
1117
1235
|
}
|
|
1118
|
-
|
|
1236
|
+
takenFlows(element, decision) {
|
|
1237
|
+
return outgoingSequenceFlows(element).filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
1238
|
+
}
|
|
1239
|
+
record(element, scope, gatewayKind, chosenBy, decision, inputs) {
|
|
1119
1240
|
this.store.record({
|
|
1120
1241
|
kind: "decision",
|
|
1121
1242
|
instanceId: findProcessInstance(scope).id,
|
|
1122
|
-
elementId:
|
|
1123
|
-
elementName: elementName(
|
|
1243
|
+
elementId: element.id,
|
|
1244
|
+
elementName: elementName(element),
|
|
1124
1245
|
gatewayKind,
|
|
1125
1246
|
chosenBy,
|
|
1126
1247
|
decision,
|
|
1127
1248
|
inputs
|
|
1128
1249
|
});
|
|
1129
1250
|
}
|
|
1130
|
-
waitForRetry(
|
|
1131
|
-
const waitingScope = this.simulator.createScope({ element
|
|
1251
|
+
waitForRetry(element, scope) {
|
|
1252
|
+
const waitingScope = this.simulator.createScope({ element, parent: scope.parent, initiator: scope }).start();
|
|
1132
1253
|
this.store.addWaiting(findProcessInstance(scope).id, {
|
|
1133
1254
|
scopeId: waitingScope.id,
|
|
1134
|
-
gatewayId:
|
|
1135
|
-
gatewayName: elementName(
|
|
1255
|
+
gatewayId: element.id,
|
|
1256
|
+
gatewayName: elementName(element)
|
|
1136
1257
|
});
|
|
1137
|
-
const retry = { element
|
|
1258
|
+
const retry = { element, type: "continue", interrupting: false, boundary: false };
|
|
1138
1259
|
const subscription = this.simulator.subscribe(waitingScope, retry, (initiator) => {
|
|
1139
1260
|
subscription.remove();
|
|
1140
|
-
this.
|
|
1141
|
-
this.simulator.exit({ element: gateway, scope: waitingScope, initiator });
|
|
1261
|
+
this.simulator.exit({ element, scope: waitingScope, initiator });
|
|
1142
1262
|
});
|
|
1143
1263
|
}
|
|
1144
|
-
outgoingFlows(
|
|
1264
|
+
outgoingFlows(element) {
|
|
1145
1265
|
const engine = this.dataSimulation.getEngine();
|
|
1146
|
-
return outgoingSequenceFlows(
|
|
1266
|
+
return outgoingSequenceFlows(element).map((flow) => readOutgoingFlow(flow, engine));
|
|
1147
1267
|
}
|
|
1148
1268
|
}
|
|
1149
1269
|
DataGateways.$inject = ["dataSimulation", "dataSimulationStore", "simulator"];
|
|
@@ -1196,6 +1316,8 @@ const RESET_SIMULATION_EVENT = "tokenSimulation.resetSimulation";
|
|
|
1196
1316
|
const SCOPE_CREATE_EVENT = "tokenSimulation.simulator.createScope";
|
|
1197
1317
|
const SCOPE_DESTROYED_EVENT = "tokenSimulation.simulator.destroyScope";
|
|
1198
1318
|
const TRACE_EVENT = "tokenSimulation.simulator.trace";
|
|
1319
|
+
const ELEMENT_CHANGED_EVENT = "tokenSimulation.simulator.elementChanged";
|
|
1320
|
+
const TOKEN_COUNT_OVERLAY = "bts-token-count";
|
|
1199
1321
|
const DATA_TOGGLE_EVENT = "dataSimulation.toggle";
|
|
1200
1322
|
|
|
1201
1323
|
class DataSimulation {
|
|
@@ -1265,7 +1387,8 @@ class DataSimulation {
|
|
|
1265
1387
|
this.store.startInstance(scope.id, elementName(scope.element));
|
|
1266
1388
|
}
|
|
1267
1389
|
applyMappings(element, scope) {
|
|
1268
|
-
|
|
1390
|
+
const isRetry = this.store.isWaitingScope(scope.id);
|
|
1391
|
+
if (!is(element, "bpmn:FlowNode") || isLoopInstance(scope) || scope.failed || scope.canceled || isRetry) return;
|
|
1269
1392
|
const instanceId = findProcessInstance(scope).id;
|
|
1270
1393
|
if (this.store.hasInstance(instanceId)) this.ioMappings.apply(element, instanceId);
|
|
1271
1394
|
}
|
|
@@ -1323,6 +1446,11 @@ class OutcomeBadge {
|
|
|
1323
1446
|
}
|
|
1324
1447
|
}
|
|
1325
1448
|
|
|
1449
|
+
const KIND_LABELS = {
|
|
1450
|
+
exclusive: "exclusive",
|
|
1451
|
+
inclusive: "inclusive",
|
|
1452
|
+
activity: "conditional flows"
|
|
1453
|
+
};
|
|
1326
1454
|
class DecisionCard {
|
|
1327
1455
|
constructor({ elementName, gatewayKind, chosenBy, decision, inputs }, onClose) {
|
|
1328
1456
|
this.element = h(
|
|
@@ -1332,14 +1460,14 @@ class DecisionCard {
|
|
|
1332
1460
|
"div",
|
|
1333
1461
|
{ className: "bds-decision-title" },
|
|
1334
1462
|
h("span", {}, elementName),
|
|
1335
|
-
h(
|
|
1463
|
+
h(
|
|
1464
|
+
"span",
|
|
1465
|
+
{ className: "bds-tag" },
|
|
1466
|
+
chosenBy === "click" ? `${KIND_LABELS[gatewayKind]} \xB7 by click` : KIND_LABELS[gatewayKind]
|
|
1467
|
+
),
|
|
1336
1468
|
onClose ? this.closeButton(onClose) : null
|
|
1337
1469
|
),
|
|
1338
|
-
decision.stuckReason ? h(
|
|
1339
|
-
"p",
|
|
1340
|
-
{ className: "bds-error" },
|
|
1341
|
-
`${decision.stuckReason}. Change the variables in Process Data, then press \u25B6 on the gateway.`
|
|
1342
|
-
) : null,
|
|
1470
|
+
decision.stuckReason ? h("p", { className: "bds-error" }, this.stuckMessage(decision, gatewayKind)) : null,
|
|
1343
1471
|
h(
|
|
1344
1472
|
"ul",
|
|
1345
1473
|
{ className: "bds-flows" },
|
|
@@ -1356,6 +1484,11 @@ class DecisionCard {
|
|
|
1356
1484
|
inputs.length ? this.inputList(inputs) : null
|
|
1357
1485
|
);
|
|
1358
1486
|
}
|
|
1487
|
+
stuckMessage({ stuckReason, refusedByEngine }, kind) {
|
|
1488
|
+
if (refusedByEngine) return `${stuckReason}.`;
|
|
1489
|
+
const element = kind === "activity" ? "activity" : "gateway";
|
|
1490
|
+
return `${stuckReason}. Change the variables in Process Data, then press \u25B6 on the ${element}.`;
|
|
1491
|
+
}
|
|
1359
1492
|
closeButton(onClose) {
|
|
1360
1493
|
const button = h(
|
|
1361
1494
|
"button",
|
|
@@ -1414,7 +1547,7 @@ function isInView(anchor, bounds) {
|
|
|
1414
1547
|
return anchor.x + anchor.width > 0 && anchor.x < bounds.width && anchor.y + anchor.height > 0 && anchor.y < bounds.height;
|
|
1415
1548
|
}
|
|
1416
1549
|
|
|
1417
|
-
var componentStyles = ":host {\n all: initial;\n display: contents;\n}\n\n.bds-panel {\n position: absolute;\n top: 30%;\n right: 20px;\n bottom: 50px;\n z-index: 10000;\n display: flex;\n flex-direction: column;\n width: 300px;\n overflow: hidden;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--token-simulation-control-background, #f1f2f4);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel[hidden] {\n display: none;\n}\n\n.bds-panel-header {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n height: 30px;\n padding: 6px 8px;\n font-size: 16px;\n color: var(--token-simulation-control-surface, #fff);\n background: var(--token-simulation-primary, #0067cc);\n}\n\n.bds-panel-heading {\n flex: 1;\n margin: 0;\n font: inherit;\n text-align: center;\n}\n\n.bds-panel-close {\n display: inline-flex;\n align-items: center;\n padding: 0;\n color: inherit;\n background: none;\n border: none;\n cursor: pointer;\n}\n\n.bds-variables-icon svg,\n.bds-panel-close svg {\n width: 1em;\n height: 1em;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.bds-variables-icon {\n display: inline-flex;\n align-items: center;\n}\n\n.bds-panel-body {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 7px 3px 7px 12px;\n padding: 5px 9px 5px 0;\n overflow-y: auto;\n}\n\n.bds-panel-engine {\n margin: 0;\n}\n\n.bds-panel .bds-section {\n padding: var(--bds-space-2);\n background: var(--token-simulation-control-surface, #fff);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n}\n\n.bds-engine {\n padding: 2px 8px;\n font-size: 11px;\n font-weight: 600;\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-icon-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n width: 26px;\n height: 26px;\n padding: 0;\n color: var(--bds-muted);\n background: transparent;\n border: 1px solid transparent;\n border-radius: var(--bds-radius-sm);\n cursor: pointer;\n}\n\n.bds-icon-button svg {\n width: 16px;\n height: 16px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.5;\n stroke-linecap: round;\n stroke-linejoin: round;\n transition: transform var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-icon-button:hover {\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n}\n\n.bds-section {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-section[hidden] {\n display: none;\n}\n\n.bds-section-title,\n.bds-label {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n color: var(--bds-muted);\n}\n\n.bds-section-title {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n}\n\n.bds-hint {\n margin: 0;\n font-size: 12px;\n color: var(--bds-muted);\n}\n\n.bds-hint[hidden],\n.bds-error[hidden] {\n display: none;\n}\n\n.bds-error {\n margin: 0;\n font-size: 12px;\n color: var(--bds-danger);\n}\n\n.bds-input {\n box-sizing: border-box;\n width: 100%;\n padding: 6px 10px;\n font-family: inherit;\n font-size: 13px;\n font-weight: 400;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n transition:\n border-color var(--bds-motion-fast) var(--bds-ease),\n box-shadow var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-input:focus,\n.bds-input:focus-visible {\n outline: none;\n border-color: var(--bds-accent);\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-input--invalid,\n.bds-input--invalid:focus {\n border-color: var(--bds-danger);\n box-shadow: 0 0 0 3px var(--bds-danger-soft);\n}\n\n.bds-json {\n min-height: 72px;\n font-family: var(--bds-font-mono);\n font-size: 12px;\n line-height: 1.5;\n resize: vertical;\n}\n\n.bds-instance-select[hidden] {\n display: none;\n}\n\n.bds-instance-select {\n padding: 4px 8px;\n font-size: 12px;\n}\n\n.bds-actions {\n display: flex;\n justify-content: flex-end;\n gap: var(--bds-space-2);\n margin-top: var(--bds-space-2);\n}\n\n.bds-button {\n padding: 5px 12px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 600;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n box-shadow: var(--bds-shadow-1);\n cursor: pointer;\n transition:\n background var(--bds-motion-fast) var(--bds-ease),\n border-color var(--bds-motion-fast) var(--bds-ease),\n color var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-button:hover {\n color: var(--bds-accent-ink);\n border-color: var(--bds-accent);\n background: var(--bds-accent-soft);\n}\n\n.bds-button--primary {\n color: var(--bds-on-accent);\n background: var(--bds-accent);\n border-color: var(--bds-accent);\n}\n\n.bds-button--primary:hover {\n color: var(--bds-on-accent);\n background: var(--bds-accent-ink);\n}\n\n.bds-button:focus-visible,\n.bds-icon-button:focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-status {\n margin: 0 0 var(--bds-space-1);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-status--running {\n color: var(--bds-accent-ink);\n}\n\n.bds-status--completed {\n color: var(--bds-success);\n}\n\n.bds-status--waiting {\n color: var(--bds-danger);\n}\n\n.bds-variables {\n width: 100%;\n border-collapse: collapse;\n}\n\n.bds-variables th,\n.bds-variables td {\n padding: 4px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--bds-line);\n}\n\n.bds-variables tr:last-child th,\n.bds-variables tr:last-child td {\n border-bottom: none;\n}\n\n.bds-variables th {\n width: 1%;\n padding-right: var(--bds-space-3);\n font-weight: 500;\n white-space: nowrap;\n}\n\n.bds-variables code,\n.bds-flow code {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n overflow-wrap: anywhere;\n}\n\n.bds-log {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-log-entry {\n padding: var(--bds-space-2);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n}\n\n.bds-log-entry--issue {\n border-color: var(--bds-danger-soft);\n background: linear-gradient(var(--bds-danger-soft), var(--bds-danger-soft)), var(--bds-surface);\n}\n\n.bds-log-title {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n margin-bottom: var(--bds-space-1);\n font-weight: 600;\n}\n\n.bds-tag {\n padding: 1px 6px;\n font-size: 11px;\n font-weight: 500;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-flows {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-flow {\n display: grid;\n grid-template-columns: 18px 1fr;\n align-items: center;\n column-gap: var(--bds-space-2);\n row-gap: 2px;\n}\n\n.bds-flow code,\n.bds-flow .bds-tag {\n grid-column: 2;\n justify-self: start;\n}\n\n.bds-flow code {\n padding: 1px 4px;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: 4px;\n}\n\n.bds-flow--skipped,\n.bds-flow--not-taken {\n color: var(--bds-muted);\n}\n\n.bds-outcome {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 700;\n line-height: 1;\n border-radius: var(--bds-radius-pill);\n border: 1px solid transparent;\n cursor: default;\n}\n\n.bds-outcome--taken {\n color: var(--bds-on-accent);\n background: var(--bds-success);\n}\n\n.bds-outcome--not-taken {\n color: var(--bds-muted);\n background: var(--bds-surface);\n border-color: var(--bds-line);\n}\n\n.bds-outcome--error {\n color: var(--bds-on-accent);\n background: var(--bds-danger);\n}\n\n.bds-outcome--skipped {\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n}\n\n.bds-outcome--on-flow {\n display: flex;\n box-shadow: var(--bds-shadow-1);\n transform: translate(-50%, -50%);\n}\n\n.bds-popover {\n position: absolute;\n z-index: 100;\n overflow-y: auto;\n}\n\n.bds-popover[hidden] {\n display: none;\n}\n\n.bds-decision {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n width: 300px;\n padding: 12px;\n font-family: var(--bds-font);\n font-size: 12px;\n line-height: 1.4;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-md);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-decision--stuck {\n border-color: var(--bds-danger);\n}\n\n.bds-decision-title {\n display: flex;\n align-items: center;\n gap: var(--bds-space-2);\n font-size: 13px;\n font-weight: 600;\n}\n\n.bds-decision-title .bds-tag {\n margin-left: auto;\n}\n\n.bds-decision-close {\n margin-left: 0;\n width: 22px;\n height: 22px;\n font-size: 16px;\n line-height: 1;\n}\n\n.bds-decision-inputs {\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 2px var(--bds-space-3);\n margin: 0;\n padding-top: var(--bds-space-2);\n border-top: 1px solid var(--bds-line);\n}\n\n.bds-decision-inputs dt {\n font-family: var(--bds-font-mono);\n color: var(--bds-muted);\n}\n\n.bds-decision-inputs dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.bds-decision-inputs code {\n font-family: var(--bds-font-mono);\n}\n\n.bds-dialog-backdrop {\n position: fixed;\n inset: 0;\n z-index: 10010;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--bds-space-3);\n background: rgba(29, 29, 29, 0.24);\n}\n\n.bds-dialog {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n box-sizing: border-box;\n width: 420px;\n max-width: 100%;\n max-height: 100%;\n margin: 0;\n padding: 20px;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-lg);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-dialog-content {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n min-height: 0;\n overflow-y: auto;\n}\n\n.bds-dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n}\n\n.bds-dialog .bds-actions {\n margin-top: 0;\n}\n\n.bds-form {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.bds-field {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-field-name {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-field-hint {\n font-size: 11px;\n color: var(--bds-muted);\n}\n\n.bds-checkbox {\n display: inline-flex;\n align-items: center;\n gap: var(--bds-space-2);\n cursor: pointer;\n}\n\n.bds-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: var(--bds-accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 0.001ms !important;\n }\n}\n\n.bds-form .bds-json {\n min-height: 0;\n}\n";
|
|
1550
|
+
var componentStyles = ":host {\n all: initial;\n display: contents;\n}\n\n.bds-panel {\n position: absolute;\n top: 30%;\n right: 20px;\n bottom: 50px;\n z-index: 10000;\n display: flex;\n flex-direction: column;\n width: 300px;\n overflow: hidden;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--token-simulation-control-background, #f1f2f4);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel[hidden] {\n display: none;\n}\n\n.bds-panel-header {\n display: flex;\n flex: 0 0 auto;\n align-items: center;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n height: 30px;\n padding: 6px 8px;\n font-size: 16px;\n color: var(--token-simulation-control-surface, #fff);\n background: var(--token-simulation-primary, #0067cc);\n}\n\n.bds-panel-heading {\n flex: 1;\n margin: 0;\n font: inherit;\n text-align: center;\n}\n\n.bds-panel-close {\n display: inline-flex;\n align-items: center;\n padding: 0;\n color: inherit;\n background: none;\n border: none;\n cursor: pointer;\n}\n\n.bds-variables-icon svg,\n.bds-panel-close svg {\n width: 1em;\n height: 1em;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.6;\n stroke-linecap: round;\n stroke-linejoin: round;\n}\n\n.bds-variables-icon {\n display: inline-flex;\n align-items: center;\n}\n\n.bds-panel-body {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 7px 3px 7px 12px;\n padding: 5px 9px 5px 0;\n overflow-y: auto;\n}\n\n.bds-panel-engine {\n margin: 0;\n}\n\n.bds-panel .bds-section {\n padding: var(--bds-space-2);\n background: var(--token-simulation-control-surface, #fff);\n border-radius: var(--surface-border-radius, 4px);\n}\n\n.bds-panel-title {\n margin: 0;\n font-size: 14px;\n font-weight: 600;\n}\n\n.bds-engine {\n padding: 2px 8px;\n font-size: 11px;\n font-weight: 600;\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-icon-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n margin-left: auto;\n width: 26px;\n height: 26px;\n padding: 0;\n color: var(--bds-muted);\n background: transparent;\n border: 1px solid transparent;\n border-radius: var(--bds-radius-sm);\n cursor: pointer;\n}\n\n.bds-icon-button svg {\n width: 16px;\n height: 16px;\n fill: none;\n stroke: currentColor;\n stroke-width: 1.5;\n stroke-linecap: round;\n stroke-linejoin: round;\n transition: transform var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-icon-button:hover {\n color: var(--bds-accent-ink);\n background: var(--bds-accent-soft);\n}\n\n.bds-section {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-section[hidden] {\n display: none;\n}\n\n.bds-section-title,\n.bds-label {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n margin: 0;\n font-size: 12px;\n font-weight: 600;\n letter-spacing: 0.01em;\n color: var(--bds-muted);\n}\n\n.bds-section-title {\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n}\n\n.bds-hint {\n margin: 0;\n font-size: 12px;\n color: var(--bds-muted);\n}\n\n.bds-hint[hidden],\n.bds-error[hidden] {\n display: none;\n}\n\n.bds-error {\n margin: 0;\n font-size: 12px;\n color: var(--bds-danger);\n}\n\n.bds-input {\n box-sizing: border-box;\n width: 100%;\n padding: 6px 10px;\n font-family: inherit;\n font-size: 13px;\n font-weight: 400;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n transition:\n border-color var(--bds-motion-fast) var(--bds-ease),\n box-shadow var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-input:focus,\n.bds-input:focus-visible {\n outline: none;\n border-color: var(--bds-accent);\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-input--invalid,\n.bds-input--invalid:focus {\n border-color: var(--bds-danger);\n box-shadow: 0 0 0 3px var(--bds-danger-soft);\n}\n\n.bds-json {\n min-height: 72px;\n font-family: var(--bds-font-mono);\n font-size: 12px;\n line-height: 1.5;\n resize: vertical;\n}\n\n.bds-instance-select[hidden] {\n display: none;\n}\n\n.bds-instance-select {\n padding: 4px 8px;\n font-size: 12px;\n}\n\n.bds-actions {\n display: flex;\n justify-content: flex-end;\n gap: var(--bds-space-2);\n margin-top: var(--bds-space-2);\n}\n\n.bds-button {\n padding: 5px 12px;\n font-family: inherit;\n font-size: 12px;\n font-weight: 600;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n box-shadow: var(--bds-shadow-1);\n cursor: pointer;\n transition:\n background var(--bds-motion-fast) var(--bds-ease),\n border-color var(--bds-motion-fast) var(--bds-ease),\n color var(--bds-motion-fast) var(--bds-ease);\n}\n\n.bds-button:hover {\n color: var(--bds-accent-ink);\n border-color: var(--bds-accent);\n background: var(--bds-accent-soft);\n}\n\n.bds-button--primary {\n color: var(--bds-on-accent);\n background: var(--bds-accent);\n border-color: var(--bds-accent);\n}\n\n.bds-button--primary:hover {\n color: var(--bds-on-accent);\n background: var(--bds-accent-ink);\n}\n\n.bds-button:focus-visible,\n.bds-icon-button:focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px var(--bds-accent-soft);\n}\n\n.bds-status {\n margin: 0 0 var(--bds-space-1);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-status--running {\n color: var(--bds-accent-ink);\n}\n\n.bds-status--completed {\n color: var(--bds-success);\n}\n\n.bds-status--waiting {\n color: var(--bds-danger);\n}\n\n.bds-variables {\n width: 100%;\n border-collapse: collapse;\n}\n\n.bds-variables th,\n.bds-variables td {\n padding: 4px 0;\n text-align: left;\n vertical-align: top;\n border-bottom: 1px solid var(--bds-line);\n}\n\n.bds-variables tr:last-child th,\n.bds-variables tr:last-child td {\n border-bottom: none;\n}\n\n.bds-variables th {\n width: 1%;\n padding-right: var(--bds-space-3);\n font-weight: 500;\n white-space: nowrap;\n}\n\n.bds-variables code,\n.bds-flow code {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n overflow-wrap: anywhere;\n}\n\n.bds-log {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-log-entry {\n padding: var(--bds-space-2);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-sm);\n}\n\n.bds-log-entry--issue {\n border-color: var(--bds-danger-soft);\n background: linear-gradient(var(--bds-danger-soft), var(--bds-danger-soft)), var(--bds-surface);\n}\n\n.bds-log-title {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n margin-bottom: var(--bds-space-1);\n font-weight: 600;\n}\n\n.bds-tag {\n padding: 1px 6px;\n font-size: 11px;\n font-weight: 500;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-flows {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.bds-flow {\n display: grid;\n grid-template-columns: 18px 1fr;\n align-items: center;\n column-gap: var(--bds-space-2);\n row-gap: 2px;\n}\n\n.bds-flow code,\n.bds-flow .bds-tag {\n grid-column: 2;\n justify-self: start;\n}\n\n.bds-flow code {\n padding: 1px 4px;\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n border-radius: 4px;\n}\n\n.bds-flow--skipped,\n.bds-flow--not-taken {\n color: var(--bds-muted);\n}\n\n.bds-outcome {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 18px;\n height: 18px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 700;\n line-height: 1;\n border-radius: var(--bds-radius-pill);\n border: 1px solid transparent;\n cursor: default;\n}\n\n.bds-outcome--taken {\n color: var(--bds-on-accent);\n background: var(--bds-success);\n}\n\n.bds-outcome--not-taken {\n color: var(--bds-muted);\n background: var(--bds-surface);\n border-color: var(--bds-line);\n}\n\n.bds-outcome--error {\n color: var(--bds-on-accent);\n background: var(--bds-danger);\n}\n\n.bds-outcome--skipped {\n color: var(--bds-muted);\n background: var(--bds-code-bg);\n}\n\n.bds-outcome--on-flow {\n display: flex;\n box-shadow: var(--bds-shadow-1);\n transform: translate(-50%, -50%);\n}\n\n.bds-popover {\n position: absolute;\n z-index: 100;\n overflow-y: auto;\n}\n\n.bds-popover[hidden] {\n display: none;\n}\n\n.bds-decision {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-2);\n box-sizing: border-box;\n width: 300px;\n padding: 12px;\n font-family: var(--bds-font);\n font-size: 12px;\n line-height: 1.4;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-md);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-decision--stuck {\n border-color: var(--bds-danger);\n}\n\n.bds-decision-title {\n display: flex;\n align-items: center;\n gap: var(--bds-space-2);\n font-size: 13px;\n font-weight: 600;\n}\n\n.bds-decision-title .bds-tag {\n margin-left: auto;\n}\n\n.bds-decision-close {\n margin-left: 0;\n width: 22px;\n height: 22px;\n font-size: 16px;\n line-height: 1;\n}\n\n.bds-decision-inputs {\n display: grid;\n grid-template-columns: auto 1fr;\n gap: 2px var(--bds-space-3);\n margin: 0;\n padding-top: var(--bds-space-2);\n border-top: 1px solid var(--bds-line);\n}\n\n.bds-decision-inputs dt {\n font-family: var(--bds-font-mono);\n color: var(--bds-muted);\n}\n\n.bds-decision-inputs dd {\n margin: 0;\n overflow-wrap: anywhere;\n}\n\n.bds-decision-inputs code {\n font-family: var(--bds-font-mono);\n}\n\n.bds-dialog-backdrop {\n position: fixed;\n inset: 0;\n z-index: 10010;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: var(--bds-space-3);\n background: rgba(29, 29, 29, 0.24);\n}\n\n.bds-dialog {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n box-sizing: border-box;\n width: 420px;\n max-width: 100%;\n max-height: 100%;\n margin: 0;\n padding: 20px;\n font-family: var(--bds-font);\n font-size: 13px;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-lg);\n box-shadow: var(--bds-shadow-3);\n}\n\n.bds-dialog-content {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-3);\n min-height: 0;\n overflow-y: auto;\n}\n\n.bds-dialog-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--bds-space-2);\n}\n\n.bds-dialog .bds-actions {\n margin-top: 0;\n}\n\n.bds-form {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.bds-field {\n display: flex;\n flex-direction: column;\n gap: var(--bds-space-1);\n}\n\n.bds-field-name {\n font-family: var(--bds-font-mono);\n font-size: 12px;\n font-weight: 600;\n}\n\n.bds-field-hint {\n font-size: 11px;\n color: var(--bds-muted);\n}\n\n.bds-checkbox {\n display: inline-flex;\n align-items: center;\n gap: var(--bds-space-2);\n cursor: pointer;\n}\n\n.bds-checkbox input {\n width: 16px;\n height: 16px;\n margin: 0;\n accent-color: var(--bds-accent);\n}\n\n@media (prefers-reduced-motion: reduce) {\n * {\n transition-duration: 0.001ms !important;\n }\n}\n\n.bds-form .bds-json {\n min-height: 0;\n}\n\n.bds-loop {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n padding: 2px 6px;\n font-family: var(--bds-font);\n font-size: 11px;\n font-weight: 600;\n line-height: 1;\n white-space: nowrap;\n color: var(--bds-ink);\n background: var(--bds-surface);\n border: 1px solid var(--bds-line);\n border-radius: var(--bds-radius-pill);\n}\n\n.bds-loop-dot {\n box-sizing: border-box;\n width: 8px;\n height: 8px;\n border-radius: var(--bds-radius-pill);\n border: 1.5px solid var(--bds-muted);\n}\n\n.bds-loop-dot--running {\n border-color: var(--bds-accent);\n background: var(--bds-accent);\n}\n\n.bds-loop-dot--done {\n border-color: var(--bds-success);\n background: var(--bds-success);\n}\n\n.bds-loop-count {\n margin-left: 2px;\n color: var(--bds-muted);\n}\n";
|
|
1418
1551
|
|
|
1419
1552
|
let sharedSheet;
|
|
1420
1553
|
function inShadow(...children) {
|
|
@@ -1448,8 +1581,8 @@ class DataSimulationOverlays {
|
|
|
1448
1581
|
this.overlays = overlays;
|
|
1449
1582
|
this.elementRegistry = elementRegistry;
|
|
1450
1583
|
this.canvas = canvas;
|
|
1451
|
-
this.
|
|
1452
|
-
this.
|
|
1584
|
+
this.pinnedElementIds = /* @__PURE__ */ new Set();
|
|
1585
|
+
this.markedElements = [];
|
|
1453
1586
|
this.popovers = [];
|
|
1454
1587
|
this.popoverLayer = inShadow();
|
|
1455
1588
|
this.renderedState = "";
|
|
@@ -1459,12 +1592,12 @@ class DataSimulationOverlays {
|
|
|
1459
1592
|
this.render();
|
|
1460
1593
|
});
|
|
1461
1594
|
eventBus.on("element.hover", ({ element }) => {
|
|
1462
|
-
this.
|
|
1595
|
+
this.hoveredElementId = decidingElementOf(element);
|
|
1463
1596
|
this.render();
|
|
1464
1597
|
});
|
|
1465
1598
|
eventBus.on("element.click", ({ element }) => {
|
|
1466
|
-
if (!isGateway(element)) return;
|
|
1467
|
-
if (!this.
|
|
1599
|
+
if (!isGateway(element) && !this.hasDecision(element)) return;
|
|
1600
|
+
if (!this.pinnedElementIds.delete(element.id)) this.pinnedElementIds.add(element.id);
|
|
1468
1601
|
this.render();
|
|
1469
1602
|
});
|
|
1470
1603
|
eventBus.on(["canvas.viewbox.changed", "canvas.resized"], () => this.placePopovers());
|
|
@@ -1477,33 +1610,36 @@ class DataSimulationOverlays {
|
|
|
1477
1610
|
render() {
|
|
1478
1611
|
const { decisions, shown } = new GatewayDecisionView(this.snapshot);
|
|
1479
1612
|
const cards = shown.filter(
|
|
1480
|
-
({ elementId }) => elementId === this.
|
|
1613
|
+
({ elementId }) => elementId === this.hoveredElementId || this.pinnedElementIds.has(elementId)
|
|
1481
1614
|
);
|
|
1482
1615
|
const state = JSON.stringify([
|
|
1483
1616
|
decisions.map((entry) => entry.id),
|
|
1484
1617
|
shown.map((entry) => entry.id),
|
|
1485
|
-
cards.map((entry) => [entry.id, this.
|
|
1618
|
+
cards.map((entry) => [entry.id, this.pinnedElementIds.has(entry.elementId)])
|
|
1486
1619
|
]);
|
|
1487
1620
|
if (state === this.renderedState) return;
|
|
1488
1621
|
this.renderedState = state;
|
|
1489
1622
|
this.overlays.remove({ type: OUTCOME_OVERLAY });
|
|
1490
|
-
this.
|
|
1623
|
+
this.unmarkElements();
|
|
1491
1624
|
for (const entry of decisions) this.showOutcomes(entry.decision);
|
|
1492
|
-
for (const entry of shown) this.
|
|
1625
|
+
for (const entry of shown) this.markElement(entry);
|
|
1493
1626
|
this.showCards(cards);
|
|
1494
1627
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
if (!gateway) return;
|
|
1498
|
-
this.canvas.addMarker(gateway, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1499
|
-
this.markedGateways.push(gateway);
|
|
1628
|
+
hasDecision(element) {
|
|
1629
|
+
return new GatewayDecisionView(this.snapshot).shown.some(({ elementId }) => elementId === element.id);
|
|
1500
1630
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1631
|
+
markElement({ elementId, decision }) {
|
|
1632
|
+
const element = this.elementRegistry.get(elementId);
|
|
1633
|
+
if (!element) return;
|
|
1634
|
+
this.canvas.addMarker(element, decision.stuckReason ? STUCK_MARKER$1 : DECIDED_MARKER);
|
|
1635
|
+
this.markedElements.push(element);
|
|
1636
|
+
}
|
|
1637
|
+
unmarkElements() {
|
|
1638
|
+
for (const element of this.markedElements) {
|
|
1639
|
+
this.canvas.removeMarker(element, DECIDED_MARKER);
|
|
1640
|
+
this.canvas.removeMarker(element, STUCK_MARKER$1);
|
|
1505
1641
|
}
|
|
1506
|
-
this.
|
|
1642
|
+
this.markedElements = [];
|
|
1507
1643
|
}
|
|
1508
1644
|
showOutcomes(decision) {
|
|
1509
1645
|
for (const { flow, outcome, reason } of decision.flows) {
|
|
@@ -1520,16 +1656,16 @@ class DataSimulationOverlays {
|
|
|
1520
1656
|
}
|
|
1521
1657
|
showCards(entries) {
|
|
1522
1658
|
this.popovers = entries.flatMap((entry) => {
|
|
1523
|
-
const
|
|
1524
|
-
if (!
|
|
1659
|
+
const element = this.elementRegistry.get(entry.elementId);
|
|
1660
|
+
if (!element) return [];
|
|
1525
1661
|
const close = () => {
|
|
1526
|
-
this.
|
|
1662
|
+
this.pinnedElementIds.delete(entry.elementId);
|
|
1527
1663
|
this.render();
|
|
1528
1664
|
};
|
|
1529
|
-
const card = new DecisionCard(entry, this.
|
|
1665
|
+
const card = new DecisionCard(entry, this.pinnedElementIds.has(entry.elementId) ? close : void 0).element;
|
|
1530
1666
|
card.classList.add("bds-popover");
|
|
1531
1667
|
card.dataset.elementId = entry.elementId;
|
|
1532
|
-
return [{
|
|
1668
|
+
return [{ element, card }];
|
|
1533
1669
|
});
|
|
1534
1670
|
this.popoverLayer.shadowRoot.replaceChildren(...this.popovers.map(({ card }) => card));
|
|
1535
1671
|
this.placePopovers();
|
|
@@ -1537,10 +1673,10 @@ class DataSimulationOverlays {
|
|
|
1537
1673
|
placePopovers() {
|
|
1538
1674
|
const container = this.canvas.getContainer();
|
|
1539
1675
|
const bounds = { width: container.clientWidth, height: container.clientHeight };
|
|
1540
|
-
for (const {
|
|
1676
|
+
for (const { element, card } of this.popovers) {
|
|
1541
1677
|
card.style.maxHeight = "";
|
|
1542
1678
|
const { left, top, maxHeight, hidden } = placePopover(
|
|
1543
|
-
this.canvas.getAbsoluteBBox(
|
|
1679
|
+
this.canvas.getAbsoluteBBox(element),
|
|
1544
1680
|
{ width: card.offsetWidth, height: card.offsetHeight },
|
|
1545
1681
|
bounds
|
|
1546
1682
|
);
|
|
@@ -1702,11 +1838,13 @@ class VariablesPanel {
|
|
|
1702
1838
|
}
|
|
1703
1839
|
renderIssues({ log, selectedInstanceId }) {
|
|
1704
1840
|
const issues = log.filter(
|
|
1705
|
-
(entry) => entry.
|
|
1841
|
+
(entry) => entry.instanceId === selectedInstanceId && this.isIssue(entry)
|
|
1706
1842
|
);
|
|
1707
1843
|
this.issueSection.hidden = !issues.length;
|
|
1708
1844
|
this.issueList.replaceChildren(
|
|
1709
|
-
...issues.slice().reverse().map(
|
|
1845
|
+
...issues.slice().reverse().map(
|
|
1846
|
+
(issue) => issue.kind === "mapping-issue" ? this.renderMappingIssue(issue) : this.renderInstanceCountIssue(issue)
|
|
1847
|
+
)
|
|
1710
1848
|
);
|
|
1711
1849
|
}
|
|
1712
1850
|
describeStatus({ processName, status, waiting }) {
|
|
@@ -1726,6 +1864,17 @@ class VariablesPanel {
|
|
|
1726
1864
|
h("p", { className: "bds-error" }, `${target}: ${reason}`)
|
|
1727
1865
|
);
|
|
1728
1866
|
}
|
|
1867
|
+
isIssue(entry) {
|
|
1868
|
+
return entry.kind === "mapping-issue" || entry.kind === "multi-instance" && Boolean(entry.count.reason);
|
|
1869
|
+
}
|
|
1870
|
+
renderInstanceCountIssue({ elementName, count }) {
|
|
1871
|
+
return h(
|
|
1872
|
+
"li",
|
|
1873
|
+
{ className: "bds-log-entry bds-log-entry--issue" },
|
|
1874
|
+
h("div", { className: "bds-log-title" }, elementName, h("span", { className: "bds-tag" }, "instances")),
|
|
1875
|
+
h("p", { className: "bds-error" }, `Ran ${count.count} instances by default: ${count.reason}`)
|
|
1876
|
+
);
|
|
1877
|
+
}
|
|
1729
1878
|
parseVariables(text) {
|
|
1730
1879
|
try {
|
|
1731
1880
|
const value = JSON.parse(text || "{}");
|
|
@@ -1998,8 +2147,10 @@ class VariableUsageCollector {
|
|
|
1998
2147
|
}
|
|
1999
2148
|
if (!is(element, "bpmn:FlowNode")) return void 0;
|
|
2000
2149
|
const { inputs, outputs } = this.engine.readIoMappings(businessObject);
|
|
2150
|
+
const loop = this.engine.readLoop?.(businessObject);
|
|
2151
|
+
const readOnEnter = [loop?.cardinality, loop?.collection, ...inputs.map((mapping) => mapping.source)];
|
|
2001
2152
|
return this.usage(element, {
|
|
2002
|
-
inputReads:
|
|
2153
|
+
inputReads: readOnEnter.flatMap((expression) => expression ? this.engine.readVariableNames(expression) : []),
|
|
2003
2154
|
inputTargets: inputs.map((mapping) => mapping.target),
|
|
2004
2155
|
outputReads: outputs.flatMap((mapping) => this.engine.readVariableNames(mapping.source)),
|
|
2005
2156
|
outputTargets: outputs.map((mapping) => mapping.target)
|
|
@@ -2068,6 +2219,210 @@ class DataStartForm {
|
|
|
2068
2219
|
}
|
|
2069
2220
|
DataStartForm.$inject = ["config.dataSimulation", "eventBus", "dataSimulation", "dataSimulationStore"];
|
|
2070
2221
|
|
|
2222
|
+
const DEFAULT_INSTANCE_COUNT = 3;
|
|
2223
|
+
class InstanceCounter {
|
|
2224
|
+
count({ cardinality, collection }, evaluate) {
|
|
2225
|
+
if (!evaluate) return { count: DEFAULT_INSTANCE_COUNT, source: "default" };
|
|
2226
|
+
if (cardinality) return this.fromCardinality(cardinality, evaluate(cardinality));
|
|
2227
|
+
if (collection) return this.fromCollection(collection, evaluate(collection));
|
|
2228
|
+
return { count: DEFAULT_INSTANCE_COUNT, source: "default" };
|
|
2229
|
+
}
|
|
2230
|
+
fromCardinality(expression, evaluation) {
|
|
2231
|
+
if (!evaluation.ok) return this.fallback(expression, evaluation.reason);
|
|
2232
|
+
const count = typeof evaluation.value === "string" ? Number(evaluation.value) : evaluation.value;
|
|
2233
|
+
if (typeof count !== "number" || !Number.isInteger(count) || count < 0) {
|
|
2234
|
+
return this.fallback(expression, `Loop cardinality ${JSON.stringify(evaluation.value)} is not a whole number`);
|
|
2235
|
+
}
|
|
2236
|
+
return { count, source: "cardinality", expression };
|
|
2237
|
+
}
|
|
2238
|
+
fromCollection(expression, evaluation) {
|
|
2239
|
+
if (!evaluation.ok) return this.fallback(expression, evaluation.reason);
|
|
2240
|
+
if (!Array.isArray(evaluation.value)) {
|
|
2241
|
+
return this.fallback(expression, `Collection ${JSON.stringify(evaluation.value)} is not a list`);
|
|
2242
|
+
}
|
|
2243
|
+
return { count: evaluation.value.length, source: "collection", expression };
|
|
2244
|
+
}
|
|
2245
|
+
fallback(expression, reason) {
|
|
2246
|
+
return { count: DEFAULT_INSTANCE_COUNT, source: "default", expression, reason };
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
class InstanceLoop {
|
|
2251
|
+
constructor(mode, count) {
|
|
2252
|
+
this.mode = mode;
|
|
2253
|
+
this.statuses = Array.from({ length: count }, () => "waiting");
|
|
2254
|
+
}
|
|
2255
|
+
get progress() {
|
|
2256
|
+
return this.statuses;
|
|
2257
|
+
}
|
|
2258
|
+
get finished() {
|
|
2259
|
+
return this.statuses.every((status) => status === "done");
|
|
2260
|
+
}
|
|
2261
|
+
start() {
|
|
2262
|
+
const first = this.mode === "parallel" ? this.statuses.map((_, index) => index) : [0];
|
|
2263
|
+
return first.filter((index) => index < this.statuses.length).map((index) => this.run(index));
|
|
2264
|
+
}
|
|
2265
|
+
complete(index) {
|
|
2266
|
+
this.statuses[index] = "done";
|
|
2267
|
+
const next = this.statuses.indexOf("waiting");
|
|
2268
|
+
return this.mode === "sequential" && next >= 0 ? this.run(next) : void 0;
|
|
2269
|
+
}
|
|
2270
|
+
run(index) {
|
|
2271
|
+
this.statuses[index] = "running";
|
|
2272
|
+
return index;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
const MAX_DOTS = 12;
|
|
2277
|
+
class InstanceProgress {
|
|
2278
|
+
constructor(mode, count) {
|
|
2279
|
+
this.element = h("span", { className: "bds-loop" });
|
|
2280
|
+
this.description = this.describe(mode, count);
|
|
2281
|
+
}
|
|
2282
|
+
show(progress) {
|
|
2283
|
+
const done = progress.filter((status) => status === "done").length;
|
|
2284
|
+
const dots = progress.length <= MAX_DOTS ? progress.map(
|
|
2285
|
+
(status) => h("span", { className: `bds-loop-dot bds-loop-dot--${status}`, "data-status": status })
|
|
2286
|
+
) : [];
|
|
2287
|
+
this.element.title = this.description;
|
|
2288
|
+
this.element.replaceChildren(...dots, h("span", { className: "bds-loop-count" }, `${done}/${progress.length}`));
|
|
2289
|
+
}
|
|
2290
|
+
describe(mode, { count, source, expression, reason }) {
|
|
2291
|
+
if (!count) return `No instance: ${expression} is empty`;
|
|
2292
|
+
const instances = `${count} ${mode} instance${count === 1 ? "" : "s"}`;
|
|
2293
|
+
if (source === "collection") return `${instances}, one per item of ${expression}`;
|
|
2294
|
+
if (source === "cardinality") return `${instances}, loop cardinality ${expression}`;
|
|
2295
|
+
return reason ? `${instances} (default): ${reason}` : `${instances} (default without data)`;
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
const PROGRESS_OVERLAY = "bds-loop-progress";
|
|
2300
|
+
const PROGRESS_OFFSET_TOP = -26;
|
|
2301
|
+
const BELOW_TOKEN_COUNT = 250;
|
|
2302
|
+
const STAGGER_STEP_LENGTH = 6;
|
|
2303
|
+
class MultiInstanceActivities {
|
|
2304
|
+
constructor(dataSimulation, store, simulator, scopeBehavior, overlays, eventBus, injector) {
|
|
2305
|
+
this.dataSimulation = dataSimulation;
|
|
2306
|
+
this.store = store;
|
|
2307
|
+
this.simulator = simulator;
|
|
2308
|
+
this.scopeBehavior = scopeBehavior;
|
|
2309
|
+
this.overlays = overlays;
|
|
2310
|
+
this.counter = new InstanceCounter();
|
|
2311
|
+
this.loops = /* @__PURE__ */ new Map();
|
|
2312
|
+
this.instanceIndexes = /* @__PURE__ */ new WeakMap();
|
|
2313
|
+
this.animation = injector.get("animation", false);
|
|
2314
|
+
eventBus.on(ELEMENT_CHANGED_EVENT, BELOW_TOKEN_COUNT, ({ element }) => {
|
|
2315
|
+
if (this.loopOf(element)) this.overlays.remove({ element, type: TOKEN_COUNT_OVERLAY });
|
|
2316
|
+
});
|
|
2317
|
+
eventBus.on(SCOPE_DESTROYED_EVENT, ({ scope }) => this.loops.delete(scope.id));
|
|
2318
|
+
eventBus.on([RESET_SIMULATION_EVENT, TOGGLE_MODE_EVENT], () => {
|
|
2319
|
+
this.loops.clear();
|
|
2320
|
+
this.overlays.remove({ type: PROGRESS_OVERLAY });
|
|
2321
|
+
});
|
|
2322
|
+
}
|
|
2323
|
+
loopOf(activity) {
|
|
2324
|
+
return this.dataSimulation.getEngine().readLoop?.(activity.businessObject);
|
|
2325
|
+
}
|
|
2326
|
+
enterBody(context, loop) {
|
|
2327
|
+
const { element, scope: body } = context;
|
|
2328
|
+
const count = this.count(body, loop);
|
|
2329
|
+
this.record(element, body, loop, count);
|
|
2330
|
+
const instanceLoop = new InstanceLoop(loop.mode, count.count);
|
|
2331
|
+
const progress = this.showProgress(element, new InstanceProgress(loop.mode, count));
|
|
2332
|
+
if (!count.count) {
|
|
2333
|
+
progress.show(instanceLoop.progress);
|
|
2334
|
+
this.simulator.exit(context);
|
|
2335
|
+
return;
|
|
2336
|
+
}
|
|
2337
|
+
this.loops.set(body.id, { loop: instanceLoop, progress });
|
|
2338
|
+
for (const index of instanceLoop.start()) this.startInstance(element, body, index);
|
|
2339
|
+
progress.show(instanceLoop.progress);
|
|
2340
|
+
}
|
|
2341
|
+
enterInstance(context, enterActivity) {
|
|
2342
|
+
const { element, scope, loopIndex } = context;
|
|
2343
|
+
const loop = this.loops.get(scope.parent.id)?.loop;
|
|
2344
|
+
this.instanceIndexes.set(scope, loopIndex);
|
|
2345
|
+
const runInstance = is(element, "bpmn:SubProcess") ? () => enterActivity(context) : () => this.passThrough(element, scope, () => enterActivity(context));
|
|
2346
|
+
const staggerSteps = loop?.mode === "parallel" ? loopIndex : 0;
|
|
2347
|
+
this.stagger(element, scope, staggerSteps, runInstance);
|
|
2348
|
+
}
|
|
2349
|
+
exitInstance({ element, scope }) {
|
|
2350
|
+
const body = scope.parent;
|
|
2351
|
+
const run = this.loops.get(body.id);
|
|
2352
|
+
if (!run) return;
|
|
2353
|
+
const { loop, progress } = run;
|
|
2354
|
+
const next = loop.complete(this.instanceIndexes.get(scope));
|
|
2355
|
+
if (next !== void 0) this.startInstance(element, body, next);
|
|
2356
|
+
progress.show(loop.progress);
|
|
2357
|
+
if (loop.finished) {
|
|
2358
|
+
this.loops.delete(body.id);
|
|
2359
|
+
this.scopeBehavior.tryExit(body, scope);
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
count(body, loop) {
|
|
2363
|
+
if (!this.dataSimulation.isEnabled()) return this.counter.count(loop);
|
|
2364
|
+
const engine = this.dataSimulation.getEngine();
|
|
2365
|
+
const variables = this.dataSimulation.getVariables(body);
|
|
2366
|
+
return this.counter.count(loop, (expression) => engine.evaluate(expression, variables));
|
|
2367
|
+
}
|
|
2368
|
+
record(activity, body, { mode }, count) {
|
|
2369
|
+
const instanceId = findProcessInstance(body).id;
|
|
2370
|
+
if (!this.dataSimulation.isEnabled() || !this.store.hasInstance(instanceId)) return;
|
|
2371
|
+
this.store.record({
|
|
2372
|
+
kind: "multi-instance",
|
|
2373
|
+
instanceId,
|
|
2374
|
+
elementId: activity.id,
|
|
2375
|
+
elementName: elementName(activity),
|
|
2376
|
+
mode,
|
|
2377
|
+
count
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
showProgress(activity, progress) {
|
|
2381
|
+
this.overlays.remove({ element: activity, type: PROGRESS_OVERLAY });
|
|
2382
|
+
this.overlays.add(activity, PROGRESS_OVERLAY, {
|
|
2383
|
+
position: { top: PROGRESS_OFFSET_TOP, left: 0 },
|
|
2384
|
+
scale: { min: 1 },
|
|
2385
|
+
html: inShadow(progress.element)
|
|
2386
|
+
});
|
|
2387
|
+
return progress;
|
|
2388
|
+
}
|
|
2389
|
+
startInstance(activity, body, index) {
|
|
2390
|
+
this.simulator.enter({ element: activity, scope: body, initiator: body, loopIndex: index });
|
|
2391
|
+
}
|
|
2392
|
+
passThrough(activity, scope, done) {
|
|
2393
|
+
if (!this.animation) {
|
|
2394
|
+
done();
|
|
2395
|
+
return;
|
|
2396
|
+
}
|
|
2397
|
+
const entry = this.entryPoint(activity);
|
|
2398
|
+
const exit = { x: entry.x + (activity.width ?? 0), y: entry.y };
|
|
2399
|
+
this.animation.animate({ waypoints: [entry, exit] }, scope, done);
|
|
2400
|
+
}
|
|
2401
|
+
stagger(activity, scope, steps, done) {
|
|
2402
|
+
if (!this.animation || !steps) {
|
|
2403
|
+
done();
|
|
2404
|
+
return;
|
|
2405
|
+
}
|
|
2406
|
+
const entry = this.entryPoint(activity);
|
|
2407
|
+
const pause = { waypoints: [entry, { x: entry.x + STAGGER_STEP_LENGTH, y: entry.y }] };
|
|
2408
|
+
const waiting = this.animation.createAnimation(pause, scope, () => this.stagger(activity, scope, steps - 1, done));
|
|
2409
|
+
if (waiting) waiting.hide();
|
|
2410
|
+
else done();
|
|
2411
|
+
}
|
|
2412
|
+
entryPoint({ x = 0, y = 0, height = 0 }) {
|
|
2413
|
+
return { x, y: y + height / 2 };
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
MultiInstanceActivities.$inject = [
|
|
2417
|
+
"dataSimulation",
|
|
2418
|
+
"dataSimulationStore",
|
|
2419
|
+
"simulator",
|
|
2420
|
+
"scopeBehavior",
|
|
2421
|
+
"overlays",
|
|
2422
|
+
"eventBus",
|
|
2423
|
+
"injector"
|
|
2424
|
+
];
|
|
2425
|
+
|
|
2071
2426
|
class PathResolver {
|
|
2072
2427
|
constructor() {
|
|
2073
2428
|
this.router = new GatewayRouter();
|
|
@@ -2096,11 +2451,15 @@ class PathResolver {
|
|
|
2096
2451
|
};
|
|
2097
2452
|
}
|
|
2098
2453
|
leave(node, evaluateCondition, decisions) {
|
|
2099
|
-
if (!
|
|
2100
|
-
const decision = this.router.route(node.
|
|
2454
|
+
if (!this.routesByData(node)) return node.outgoing;
|
|
2455
|
+
const decision = node.refusalReason ? this.router.refuse(node.outgoing, node.refusalReason) : this.router.route(node.routingKind, node.outgoing, evaluateCondition);
|
|
2101
2456
|
decisions[node.id] = decision;
|
|
2102
2457
|
return node.outgoing.filter((flow) => decision.takenFlowIds.includes(flow.id));
|
|
2103
2458
|
}
|
|
2459
|
+
routesByData(node) {
|
|
2460
|
+
if (node.routingKind === "activity") return node.outgoing.length > 0;
|
|
2461
|
+
return node.routingKind !== void 0 && node.outgoing.length > 1;
|
|
2462
|
+
}
|
|
2104
2463
|
sumMeasures(nodes) {
|
|
2105
2464
|
const totals = {};
|
|
2106
2465
|
for (const node of nodes) {
|
|
@@ -2113,26 +2472,54 @@ class PathResolver {
|
|
|
2113
2472
|
const NICE_STEPS = [1, 2, 5, 10];
|
|
2114
2473
|
const RANGE_STEPS = 100;
|
|
2115
2474
|
const NUMBER_LITERAL = /(?<![\w.])\d+(?:\.\d+)?/g;
|
|
2475
|
+
const COMPARISON = String.raw`(?:<=|>=|==|!=|<|>|=|\b(?:lt|gt|le|ge|eq|ne)\b)`;
|
|
2476
|
+
const EQUALITY = String.raw`(?:==|!=|=|\b(?:eq|ne)\b)`;
|
|
2477
|
+
const BOOLEAN_LEFT = String.raw`(?:^|(?<![\w$.])\(|\bnot\s*\(|!|&&|\|\||\b(?:and|or|not)\b)`;
|
|
2478
|
+
const BOOLEAN_RIGHT = String.raw`(?=$|\)|&&|\|\||\b(?:and|or)\b)`;
|
|
2116
2479
|
class PathVariableDeriver {
|
|
2117
|
-
derive(conditions, values) {
|
|
2480
|
+
derive(conditions, values, rangeOverrides = {}) {
|
|
2118
2481
|
const names = [...new Set(conditions.flatMap((condition) => condition.variableNames))];
|
|
2119
2482
|
return names.map((name) => {
|
|
2120
2483
|
const conditionsReadingName = conditions.filter((condition) => condition.variableNames.includes(name));
|
|
2121
|
-
return this.variableFor(name, values[name], conditionsReadingName);
|
|
2484
|
+
return this.variableFor(name, values[name], conditionsReadingName, rangeOverrides[name] ?? {});
|
|
2122
2485
|
});
|
|
2123
2486
|
}
|
|
2124
|
-
variableFor(name, value, conditionsReadingName) {
|
|
2125
|
-
|
|
2126
|
-
if (
|
|
2487
|
+
variableFor(name, value, conditionsReadingName, rangeOverride) {
|
|
2488
|
+
const type = value === void 0 ? this.typeFromConditions(name, conditionsReadingName) : typeof value;
|
|
2489
|
+
if (type === "boolean") return { name, type: "boolean" };
|
|
2490
|
+
if (type === "number") {
|
|
2127
2491
|
const comparedNumbers = conditionsReadingName.flatMap((condition) => this.numberLiterals(condition.expression));
|
|
2128
|
-
return { name, type: "number", range: this.rangeAround(value, comparedNumbers) };
|
|
2492
|
+
return { name, type: "number", range: this.rangeAround(Number(value ?? 0), comparedNumbers, rangeOverride) };
|
|
2129
2493
|
}
|
|
2130
2494
|
if (value === void 0 || typeof value === "string") return { name, type: "text" };
|
|
2131
2495
|
return { name, type: "json" };
|
|
2132
2496
|
}
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2497
|
+
// Without a value the conditions tell the type: compared with a number, or used as a condition of its own.
|
|
2498
|
+
typeFromConditions(name, conditions) {
|
|
2499
|
+
const variable = String.raw`(?<![\w.$])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\w.(])`;
|
|
2500
|
+
const comparedWithNumber = new RegExp(
|
|
2501
|
+
String.raw`${variable}\s*${COMPARISON}\s*-?\d|\d\s*${COMPARISON}\s*${variable}`
|
|
2502
|
+
);
|
|
2503
|
+
const usedAsBoolean = new RegExp(
|
|
2504
|
+
String.raw`${BOOLEAN_LEFT}\s*${variable}\s*${BOOLEAN_RIGHT}|${variable}\s*${EQUALITY}\s*(?:true|false)\b|\b(?:true|false)\s*${EQUALITY}\s*${variable}`
|
|
2505
|
+
);
|
|
2506
|
+
const bodies = conditions.map((condition) => this.body(condition.expression));
|
|
2507
|
+
if (bodies.some((body) => comparedWithNumber.test(body))) return "number";
|
|
2508
|
+
if (bodies.some((body) => usedAsBoolean.test(body))) return "boolean";
|
|
2509
|
+
return void 0;
|
|
2510
|
+
}
|
|
2511
|
+
// The expression without its FEEL `=` or its JUEL `${…}`.
|
|
2512
|
+
body(expression) {
|
|
2513
|
+
const trimmed = expression.trim();
|
|
2514
|
+
const juel = /^\$\{([\s\S]*)\}$/.exec(trimmed);
|
|
2515
|
+
if (juel) return juel[1].trim();
|
|
2516
|
+
return trimmed.replace(/^=/, "").trim();
|
|
2517
|
+
}
|
|
2518
|
+
// The value itself is not doubled: a slider dragged to the end then keeps its range when derived again.
|
|
2519
|
+
rangeAround(value, comparedNumbers, override) {
|
|
2520
|
+
const min = override.min ?? 0;
|
|
2521
|
+
const max = override.max ?? this.niceCeiling(Math.max(Math.abs(value), 2 * Math.max(0, ...comparedNumbers)));
|
|
2522
|
+
return { min, max, step: override.step ?? (max - min) / RANGE_STEPS };
|
|
2136
2523
|
}
|
|
2137
2524
|
niceCeiling(value) {
|
|
2138
2525
|
if (value <= 0) return 1;
|
|
@@ -2166,7 +2553,7 @@ class PathGraphReader {
|
|
|
2166
2553
|
const entersSubProcess = is(node, "bpmn:SubProcess") && !node.businessObject.triggeredByEvent;
|
|
2167
2554
|
return {
|
|
2168
2555
|
id: node.id,
|
|
2169
|
-
...
|
|
2556
|
+
...this.routingOf(node),
|
|
2170
2557
|
outgoing: outgoingSequenceFlows(node).map((flow) => ({
|
|
2171
2558
|
...readOutgoingFlow(flow, this.engine),
|
|
2172
2559
|
targetId: flow.target.id
|
|
@@ -2175,6 +2562,18 @@ class PathGraphReader {
|
|
|
2175
2562
|
measures: Object.fromEntries(measureNames.map((name) => [name, this.readMeasure(node.businessObject, name)]))
|
|
2176
2563
|
};
|
|
2177
2564
|
}
|
|
2565
|
+
routingOf(node) {
|
|
2566
|
+
const gatewayKind = GATEWAY_KINDS[node.type];
|
|
2567
|
+
if (gatewayKind) return { routingKind: gatewayKind };
|
|
2568
|
+
switch (activityRouting(node, this.engine)) {
|
|
2569
|
+
case "by-conditions":
|
|
2570
|
+
return { routingKind: "activity" };
|
|
2571
|
+
case "refused":
|
|
2572
|
+
return { routingKind: "activity", refusalReason: this.engine.activityConditionRefusal };
|
|
2573
|
+
case "none":
|
|
2574
|
+
return {};
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2178
2577
|
isProcess(element) {
|
|
2179
2578
|
return element?.$type === "bpmn:Process";
|
|
2180
2579
|
}
|
|
@@ -2199,7 +2598,7 @@ class PathMarkers {
|
|
|
2199
2598
|
for (const id of path.taken) this.mark(id, TAKEN_MARKER);
|
|
2200
2599
|
for (const id of path.skipped) this.mark(id, SKIPPED_MARKER);
|
|
2201
2600
|
for (const [gatewayId, decision] of Object.entries(path.decisions)) {
|
|
2202
|
-
if (decision.stuckReason) this.mark(gatewayId, STUCK_MARKER);
|
|
2601
|
+
if (decision.stuckReason && !decision.missingVariables) this.mark(gatewayId, STUCK_MARKER);
|
|
2203
2602
|
}
|
|
2204
2603
|
}
|
|
2205
2604
|
clear() {
|
|
@@ -2251,12 +2650,12 @@ class PathSimulation {
|
|
|
2251
2650
|
}
|
|
2252
2651
|
simulate(variables, options = {}) {
|
|
2253
2652
|
const graph = this.pathGraphReader.read(options.measures ?? []);
|
|
2254
|
-
const path = this.pathResolver.resolve(graph, (expression) => this.
|
|
2653
|
+
const path = this.pathResolver.resolve(graph, (expression) => this.evaluate(expression, variables));
|
|
2255
2654
|
this.pathMarkers.show(path);
|
|
2256
2655
|
return path;
|
|
2257
2656
|
}
|
|
2258
|
-
deriveVariables(values) {
|
|
2259
|
-
return this.pathVariableDeriver.derive(this.evaluableConditions(), values);
|
|
2657
|
+
deriveVariables(values, options = {}) {
|
|
2658
|
+
return this.pathVariableDeriver.derive(this.evaluableConditions(), values, options.ranges);
|
|
2260
2659
|
}
|
|
2261
2660
|
variablesOf(scenario, fallbacks = []) {
|
|
2262
2661
|
return this.scenarioVariables.of(scenario, fallbacks);
|
|
@@ -2264,6 +2663,13 @@ class PathSimulation {
|
|
|
2264
2663
|
clear() {
|
|
2265
2664
|
this.pathMarkers.clear();
|
|
2266
2665
|
}
|
|
2666
|
+
// A failed condition names the variables it reads that are not set: the gateway then waits for data.
|
|
2667
|
+
evaluate(expression, variables) {
|
|
2668
|
+
const evaluation = this.engine.evaluate(expression, variables);
|
|
2669
|
+
if (evaluation.ok) return evaluation;
|
|
2670
|
+
const missingVariables = this.engine.readVariableNames(expression).filter((name) => variables[name] === void 0);
|
|
2671
|
+
return missingVariables.length ? { ...evaluation, missingVariables } : evaluation;
|
|
2672
|
+
}
|
|
2267
2673
|
evaluableConditions() {
|
|
2268
2674
|
return this.pathGraphReader.read([]).nodes.flatMap((node) => node.outgoing.map((flow) => flow.expression)).filter((expression) => expression !== void 0 && this.engine.canEvaluate(expression)).map((expression) => ({ expression, variableNames: this.engine.readVariableNames(expression) }));
|
|
2269
2675
|
}
|
|
@@ -2282,6 +2688,8 @@ const DataSimulationModule = {
|
|
|
2282
2688
|
"dataSimulationPanel",
|
|
2283
2689
|
"dataSimulationToggle",
|
|
2284
2690
|
"dataGatewayBehaviors",
|
|
2691
|
+
"dataActivityBehavior",
|
|
2692
|
+
"multiInstanceBehaviors",
|
|
2285
2693
|
"dataGatewaySettings",
|
|
2286
2694
|
"dataContextPads"
|
|
2287
2695
|
],
|
|
@@ -2293,8 +2701,11 @@ const DataSimulationModule = {
|
|
|
2293
2701
|
dataGateways: ["type", DataGateways],
|
|
2294
2702
|
dataStartForm: ["type", DataStartForm],
|
|
2295
2703
|
dataGatewayBehaviors: ["type", DataGatewayBehaviors],
|
|
2704
|
+
dataActivityBehavior: ["type", DataActivityBehavior],
|
|
2296
2705
|
dataGatewaySettings: ["type", DataGatewaySettings],
|
|
2297
|
-
dataContextPads: ["type", DataContextPads]
|
|
2706
|
+
dataContextPads: ["type", DataContextPads],
|
|
2707
|
+
multiInstanceActivities: ["type", MultiInstanceActivities],
|
|
2708
|
+
multiInstanceBehaviors: ["type", MultiInstanceBehaviors]
|
|
2298
2709
|
};
|
|
2299
2710
|
|
|
2300
2711
|
exports.Camunda7Engine = Camunda7Engine;
|