@nikku
on GitHub1️⃣ Where we started
2️⃣ What we accomplished
🟡 Single instance process-engine, scattered across the whole code base, i.e. context pad handlers and simulation behavior.
🟢 Dedicated, multi-instance simulator with own state management. Driven via API, hooked into via events.
🟢 Executes signals, escalation, message flows and most other complex BPMN behaviors.
🟢 Scopes represent activities
🟢 Behaviors implement element specific scope enter, exit and signal (user trigger) actions
const processElement = elementRegistry.get('Process');
const startEventElement = elementRegistry.get('StartEvent');
// start instance of <Process>
simulator.signal({
element: processElement,
startEvent: startEventElement
});
const processElement = elementRegistry.get('Process');
// active instances in <Process>
const runningScopes = simulator.findScopes({
element: processElement
});
function TaskBehavior(simulator) {
simulator.registerBehavior('bpmn:Task', this);
}
TaskBehavior.prototype.exit = function(context) {
context.element.outgoing.filter(isSequenceFlow).map(flow => {
simulator.enter({
element: flow,
parentScope: context.scope.parent
});
});
};
🟡 UI integration testing only.
🟢 Dedicated tests against the simulator API.
🟢 UI tests as a layer on top.
verify('simple', () => {
// when
signal({
element: element('Process_1')
});
// then
expectTrace(...);
});
it('should execute happy path', async function() {
// when
triggerElement('StartEvent_1');
await scopeDestroyed();
// then
expectHistory(...);
});
AnimatedSequenceFlowBehavior.prototype.enter = function(context) {
const {
element,
scope
} = context;
this._animation.animate(element, scope, () => {
SequenceFlowBehavior.prototype.enter.call(this, context);
});
};
🟢 Migrate to ES modules
🟢 Migrate to GitHub actions
🟢 Remove SVG.js
in favor of own animation core