Skip to content

Run bpmn-js in headless environments

Notifications You must be signed in to change notification settings

bpmn-io/bpmn-js-headless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Warning

This is an experimental library and not officially supported / endorsed by bpmn.io. See also caveats.

bpmn-js-headless

CI

Run bpmn-js in headless environments.

Usage

Use just like bpmn-js, but be sure not to use interactive (extension) modules.

import Modeler from 'bpmn-js-headless/lib/Modeler';

const modeler = new BpmnModeler();

// import diagram
await modeler.importXML(myDiagram);

// perform a change operation
modeler.invoke((modeling, elementRegistry) => {

  const participant = elementRegistry.get('Participant_1');

  modeling.removeElements([ participant ]);
});

// export diagram
const {
  xml
} = await modeler.saveXML({ format: true });

Why?

This utility is useful whenever you want to apply complex modeling operations in headless (aka no browser) environments. Some examples:

How does it work

  • Uses only bpmn-js modules that are safe for headless execution
  • Overrides core diagram-js components to be independent of graphical representation

Caveats

This is a truely headless version of bpmn-js, i.e. it does not fake a browser environment. For extensions to be compatible they shall enforce a proper UI / behavior separation, and not rely on browser features.

You want to bundle this library along with extensions, as bpmn-js and dependent libraries require bundling, too.