@jylups/flowable-bpmn-js 0.1.0 → 0.1.2
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 +1 -0
- package/dist/flowable-bpmn-modeler.development.js +295 -3
- package/dist/flowable-bpmn-modeler.development.js.map +1 -1
- package/dist/flowable-bpmn-modeler.production.min.js +2 -2
- package/dist/flowable-bpmn-navigated-viewer.development.js +295 -3
- package/dist/flowable-bpmn-navigated-viewer.development.js.map +1 -1
- package/dist/flowable-bpmn-navigated-viewer.production.min.js +2 -2
- package/dist/flowable-bpmn-viewer.development.js +295 -3
- package/dist/flowable-bpmn-viewer.development.js.map +1 -1
- package/dist/flowable-bpmn-viewer.production.min.js +2 -2
- package/lib/xml/FlowableXML.js +24 -2
- package/lib/xml/WriteAsRead.js +174 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @jylups/flowable-bpmn-js 0.1.
|
|
1
|
+
/*! @jylups/flowable-bpmn-js 0.1.2 | MIT | bpmn-js (c) Camunda Services GmbH, bpmn.io license; keep the bpmn.io watermark visible */
|
|
2
2
|
var FlowableBpmnJS = (function () {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -27447,6 +27447,103 @@ var FlowableBpmnJS = (function () {
|
|
|
27447
27447
|
}
|
|
27448
27448
|
]
|
|
27449
27449
|
},
|
|
27450
|
+
{
|
|
27451
|
+
name: "Condition",
|
|
27452
|
+
superClass: [
|
|
27453
|
+
"Element"
|
|
27454
|
+
],
|
|
27455
|
+
meta: {
|
|
27456
|
+
allowedIn: [
|
|
27457
|
+
"bpmn:BaseElement"
|
|
27458
|
+
]
|
|
27459
|
+
},
|
|
27460
|
+
properties: [
|
|
27461
|
+
{
|
|
27462
|
+
name: "group",
|
|
27463
|
+
isAttr: true,
|
|
27464
|
+
type: "Boolean"
|
|
27465
|
+
},
|
|
27466
|
+
{
|
|
27467
|
+
name: "match",
|
|
27468
|
+
isAttr: true,
|
|
27469
|
+
type: "String"
|
|
27470
|
+
},
|
|
27471
|
+
{
|
|
27472
|
+
name: "targetAttribute",
|
|
27473
|
+
isAttr: true,
|
|
27474
|
+
type: "String"
|
|
27475
|
+
},
|
|
27476
|
+
{
|
|
27477
|
+
name: "sourceVariableType",
|
|
27478
|
+
isAttr: true,
|
|
27479
|
+
type: "String"
|
|
27480
|
+
},
|
|
27481
|
+
{
|
|
27482
|
+
name: "sourceName",
|
|
27483
|
+
isAttr: true,
|
|
27484
|
+
type: "String"
|
|
27485
|
+
},
|
|
27486
|
+
{
|
|
27487
|
+
name: "sourceType",
|
|
27488
|
+
isAttr: true,
|
|
27489
|
+
type: "String"
|
|
27490
|
+
},
|
|
27491
|
+
{
|
|
27492
|
+
name: "operator",
|
|
27493
|
+
isAttr: true,
|
|
27494
|
+
type: "String"
|
|
27495
|
+
},
|
|
27496
|
+
{
|
|
27497
|
+
name: "targetVariableType",
|
|
27498
|
+
isAttr: true,
|
|
27499
|
+
type: "String"
|
|
27500
|
+
},
|
|
27501
|
+
{
|
|
27502
|
+
name: "targetValue",
|
|
27503
|
+
isAttr: true,
|
|
27504
|
+
type: "String"
|
|
27505
|
+
},
|
|
27506
|
+
{
|
|
27507
|
+
name: "targetType",
|
|
27508
|
+
isAttr: true,
|
|
27509
|
+
type: "String"
|
|
27510
|
+
},
|
|
27511
|
+
{
|
|
27512
|
+
name: "conditions",
|
|
27513
|
+
type: "Condition",
|
|
27514
|
+
isMany: true
|
|
27515
|
+
}
|
|
27516
|
+
]
|
|
27517
|
+
},
|
|
27518
|
+
{
|
|
27519
|
+
name: "EdgeDockers",
|
|
27520
|
+
isAbstract: true,
|
|
27521
|
+
"extends": [
|
|
27522
|
+
"di:LabeledEdge"
|
|
27523
|
+
],
|
|
27524
|
+
properties: [
|
|
27525
|
+
{
|
|
27526
|
+
name: "sourceDockerX",
|
|
27527
|
+
isAttr: true,
|
|
27528
|
+
type: "String"
|
|
27529
|
+
},
|
|
27530
|
+
{
|
|
27531
|
+
name: "sourceDockerY",
|
|
27532
|
+
isAttr: true,
|
|
27533
|
+
type: "String"
|
|
27534
|
+
},
|
|
27535
|
+
{
|
|
27536
|
+
name: "targetDockerX",
|
|
27537
|
+
isAttr: true,
|
|
27538
|
+
type: "String"
|
|
27539
|
+
},
|
|
27540
|
+
{
|
|
27541
|
+
name: "targetDockerY",
|
|
27542
|
+
isAttr: true,
|
|
27543
|
+
type: "String"
|
|
27544
|
+
}
|
|
27545
|
+
]
|
|
27546
|
+
},
|
|
27450
27547
|
{
|
|
27451
27548
|
name: "ItemAwareElement",
|
|
27452
27549
|
isAbstract: true,
|
|
@@ -27792,6 +27889,181 @@ var FlowableBpmnJS = (function () {
|
|
|
27792
27889
|
definition.$parent = definitions;
|
|
27793
27890
|
}
|
|
27794
27891
|
|
|
27892
|
+
/**
|
|
27893
|
+
* Keeps a Flowable model as it was written where bpmn-js would change it
|
|
27894
|
+
* although nothing was edited:
|
|
27895
|
+
*
|
|
27896
|
+
* - Expanded subprocesses: Flowable Design and the Flowable engine write an
|
|
27897
|
+
* expanded subprocess shape without `isExpanded`, which BPMN DI reads as
|
|
27898
|
+
* collapsed. bpmn-js would draw it closed and, on save, move its children's
|
|
27899
|
+
* shapes to a diagram of their own with new coordinates. A subprocess shape
|
|
27900
|
+
* without `isExpanded` whose children are drawn on the same plane, or which
|
|
27901
|
+
* has no children, is read as expanded; the attribute isn't written back.
|
|
27902
|
+
* - Exclusive gateway markers: bpmn-js sets `isMarkerVisible` on a gateway
|
|
27903
|
+
* shape that has none, so the marker shows as it does in Flowable. It isn't
|
|
27904
|
+
* written back where the model had no such attribute.
|
|
27905
|
+
* - Attributes with their default value, such as `typeLanguage`,
|
|
27906
|
+
* `expressionLanguage` or `isInterrupting="true"`: moddle doesn't write a
|
|
27907
|
+
* value equal to the default, so a model that states it would lose it. A
|
|
27908
|
+
* value the model sets (read from the file or set by an edit) is written,
|
|
27909
|
+
* even when it equals the default.
|
|
27910
|
+
*/
|
|
27911
|
+
|
|
27912
|
+
/**
|
|
27913
|
+
* Reads the subprocess and gateway shapes as Flowable does. Call it when
|
|
27914
|
+
* the model is parsed, before bpmn-js draws it.
|
|
27915
|
+
*
|
|
27916
|
+
* @param {ModdleElement} definitions
|
|
27917
|
+
*
|
|
27918
|
+
* @return {{ expanded: Set<ModdleElement>, markers: Set<ModdleElement> }} the
|
|
27919
|
+
* shapes that got `isExpanded`, and the gateway shapes without
|
|
27920
|
+
* `isMarkerVisible`, so saving can leave the attributes out again
|
|
27921
|
+
*/
|
|
27922
|
+
function readAsFlowable(definitions) {
|
|
27923
|
+
const expanded = new Set();
|
|
27924
|
+
const markers = new Set();
|
|
27925
|
+
|
|
27926
|
+
const planes = (definitions.get('diagrams') || [])
|
|
27927
|
+
.map(diagram => diagram.plane)
|
|
27928
|
+
.filter(Boolean);
|
|
27929
|
+
|
|
27930
|
+
for (const plane of planes) {
|
|
27931
|
+
const shapes = (plane.get('planeElement') || []).filter(di => di.$instanceOf('bpmndi:BPMNShape'));
|
|
27932
|
+
const drawn = new Set(shapes.map(di => di.bpmnElement).filter(Boolean));
|
|
27933
|
+
|
|
27934
|
+
for (const di of shapes) {
|
|
27935
|
+
const element = di.bpmnElement;
|
|
27936
|
+
|
|
27937
|
+
if (!element) {
|
|
27938
|
+
continue;
|
|
27939
|
+
}
|
|
27940
|
+
|
|
27941
|
+
if (element.$instanceOf('bpmn:SubProcess') && !hasOwn(di, 'isExpanded') && isDrawnExpanded(element, drawn)) {
|
|
27942
|
+
di.isExpanded = true;
|
|
27943
|
+
expanded.add(di);
|
|
27944
|
+
}
|
|
27945
|
+
|
|
27946
|
+
if (element.$instanceOf('bpmn:ExclusiveGateway') && !hasOwn(di, 'isMarkerVisible')) {
|
|
27947
|
+
markers.add(di);
|
|
27948
|
+
}
|
|
27949
|
+
}
|
|
27950
|
+
}
|
|
27951
|
+
|
|
27952
|
+
return { expanded, markers };
|
|
27953
|
+
}
|
|
27954
|
+
|
|
27955
|
+
/**
|
|
27956
|
+
* Prepares the model to be written as it was read (see the module comment).
|
|
27957
|
+
* Call it when saving starts, and the returned function when saving is done.
|
|
27958
|
+
*
|
|
27959
|
+
* @param {ModdleElement} definitions
|
|
27960
|
+
* @param {{ expanded: Set<ModdleElement>, markers: Set<ModdleElement> }} read
|
|
27961
|
+
* what readAsFlowable returned
|
|
27962
|
+
*
|
|
27963
|
+
* @return {Function} restores the model as the editor uses it
|
|
27964
|
+
*/
|
|
27965
|
+
function writeAsRead(definitions, { expanded, markers }) {
|
|
27966
|
+
const restore = [];
|
|
27967
|
+
|
|
27968
|
+
// leave out what reading added, while it still has the value reading gave it
|
|
27969
|
+
for (const di of expanded) {
|
|
27970
|
+
leaveOut(di, 'isExpanded', true, restore);
|
|
27971
|
+
}
|
|
27972
|
+
|
|
27973
|
+
for (const di of markers) {
|
|
27974
|
+
leaveOut(di, 'isMarkerVisible', true, restore);
|
|
27975
|
+
}
|
|
27976
|
+
|
|
27977
|
+
// write values that equal the default as generic attributes, which moddle always writes
|
|
27978
|
+
forEachElement(definitions, element => {
|
|
27979
|
+
for (const property of element.$descriptor.properties) {
|
|
27980
|
+
if (!property.isAttr || property.isMany || property.default === undefined) {
|
|
27981
|
+
continue;
|
|
27982
|
+
}
|
|
27983
|
+
|
|
27984
|
+
if (!hasOwn(element, property.name) || element[property.name] !== property.default) {
|
|
27985
|
+
continue;
|
|
27986
|
+
}
|
|
27987
|
+
|
|
27988
|
+
const name = attributeName(element, property);
|
|
27989
|
+
const attrs = element.$attrs;
|
|
27990
|
+
|
|
27991
|
+
if (attrs[name] === undefined) {
|
|
27992
|
+
attrs[name] = String(property.default);
|
|
27993
|
+
restore.push(() => delete attrs[name]);
|
|
27994
|
+
}
|
|
27995
|
+
}
|
|
27996
|
+
});
|
|
27997
|
+
|
|
27998
|
+
return function() {
|
|
27999
|
+
restore.reverse().forEach(fn => fn());
|
|
28000
|
+
};
|
|
28001
|
+
}
|
|
28002
|
+
|
|
28003
|
+
|
|
28004
|
+
function isDrawnExpanded(subProcess, drawn) {
|
|
28005
|
+
const children = [
|
|
28006
|
+
...(subProcess.get('flowElements') || []),
|
|
28007
|
+
...(subProcess.get('artifacts') || [])
|
|
28008
|
+
];
|
|
28009
|
+
|
|
28010
|
+
return !children.length || children.some(child => drawn.has(child));
|
|
28011
|
+
}
|
|
28012
|
+
|
|
28013
|
+
function leaveOut(element, name, value, restore) {
|
|
28014
|
+
if (element[name] === value) {
|
|
28015
|
+
delete element[name];
|
|
28016
|
+
restore.push(() => {
|
|
28017
|
+
element[name] = value;
|
|
28018
|
+
});
|
|
28019
|
+
}
|
|
28020
|
+
}
|
|
28021
|
+
|
|
28022
|
+
/**
|
|
28023
|
+
* The name the attribute has in the XML: without a prefix in the element's
|
|
28024
|
+
* own namespace, with its prefix in another one (an extension attribute).
|
|
28025
|
+
*/
|
|
28026
|
+
function attributeName(element, property) {
|
|
28027
|
+
const ns = property.ns;
|
|
28028
|
+
|
|
28029
|
+
return ns.prefix === element.$descriptor.ns.prefix ? ns.localName : ns.prefix + ':' + ns.localName;
|
|
28030
|
+
}
|
|
28031
|
+
|
|
28032
|
+
/**
|
|
28033
|
+
* Calls fn for the element and every model element it contains (not the
|
|
28034
|
+
* ones it refers to).
|
|
28035
|
+
*/
|
|
28036
|
+
function forEachElement(element, fn, seen = new Set()) {
|
|
28037
|
+
if (!isModdleElement(element) || seen.has(element)) {
|
|
28038
|
+
return;
|
|
28039
|
+
}
|
|
28040
|
+
|
|
28041
|
+
seen.add(element);
|
|
28042
|
+
fn(element);
|
|
28043
|
+
|
|
28044
|
+
for (const property of element.$descriptor.properties) {
|
|
28045
|
+
if (property.isReference || property.isAttr) {
|
|
28046
|
+
continue;
|
|
28047
|
+
}
|
|
28048
|
+
|
|
28049
|
+
const value = element[property.name];
|
|
28050
|
+
|
|
28051
|
+
if (Array.isArray(value)) {
|
|
28052
|
+
value.forEach(child => forEachElement(child, fn, seen));
|
|
28053
|
+
} else {
|
|
28054
|
+
forEachElement(value, fn, seen);
|
|
28055
|
+
}
|
|
28056
|
+
}
|
|
28057
|
+
}
|
|
28058
|
+
|
|
28059
|
+
function isModdleElement(value) {
|
|
28060
|
+
return !!value && typeof value === 'object' && !!value.$descriptor && !!value.$attrs;
|
|
28061
|
+
}
|
|
28062
|
+
|
|
28063
|
+
function hasOwn(object, name) {
|
|
28064
|
+
return Object.prototype.hasOwnProperty.call(object, name);
|
|
28065
|
+
}
|
|
28066
|
+
|
|
27795
28067
|
/**
|
|
27796
28068
|
* Runs before bpmn-js claims the imported IDs, so created definitions are
|
|
27797
28069
|
* claimed too.
|
|
@@ -27810,11 +28082,17 @@ var FlowableBpmnJS = (function () {
|
|
|
27810
28082
|
* signal or escalation they stand for (createMissingDefinitions from the
|
|
27811
28083
|
* behaviors package), in the viewers too;
|
|
27812
28084
|
* - on save, other prefixes bound to the Flowable namespace are dropped, so
|
|
27813
|
-
* everything is written as flowable: (useFlowablePrefix)
|
|
28085
|
+
* everything is written as flowable: (useFlowablePrefix);
|
|
28086
|
+
* - an unedited model is written as it was read: expanded subprocesses
|
|
28087
|
+
* without `isExpanded`, gateway markers and attributes with their default
|
|
28088
|
+
* value stay as the file had them (see WriteAsRead.js).
|
|
27814
28089
|
*/
|
|
27815
28090
|
class FlowableXML {
|
|
27816
28091
|
|
|
27817
28092
|
constructor(eventBus, moddle) {
|
|
28093
|
+
let read = { expanded: new Set(), markers: new Set() };
|
|
28094
|
+
let restore = null;
|
|
28095
|
+
|
|
27818
28096
|
eventBus.on('import.parse.start', ({ xml }) => {
|
|
27819
28097
|
const migrated = migrateActivitiXML(xml);
|
|
27820
28098
|
|
|
@@ -27826,10 +28104,24 @@ var FlowableBpmnJS = (function () {
|
|
|
27826
28104
|
eventBus.on('import.parse.complete', HIGH_PRIORITY$1, ({ error, definitions, warnings, elementsById }) => {
|
|
27827
28105
|
if (!error && definitions) {
|
|
27828
28106
|
createMissingDefinitions(definitions, { warnings, elementsById });
|
|
28107
|
+
|
|
28108
|
+
// before bpmn-js draws the model (and moves the shapes of collapsed subprocesses)
|
|
28109
|
+
read = readAsFlowable(definitions);
|
|
27829
28110
|
}
|
|
27830
28111
|
});
|
|
27831
28112
|
|
|
27832
|
-
eventBus.on('saveXML.start', ({ definitions }) =>
|
|
28113
|
+
eventBus.on('saveXML.start', ({ definitions }) => {
|
|
28114
|
+
useFlowablePrefix(definitions);
|
|
28115
|
+
|
|
28116
|
+
restore = writeAsRead(definitions, read);
|
|
28117
|
+
});
|
|
28118
|
+
|
|
28119
|
+
eventBus.on('saveXML.done', () => {
|
|
28120
|
+
if (restore) {
|
|
28121
|
+
restore();
|
|
28122
|
+
restore = null;
|
|
28123
|
+
}
|
|
28124
|
+
});
|
|
27833
28125
|
}
|
|
27834
28126
|
}
|
|
27835
28127
|
|