chore(deps): update to bpmn-moddle v7.0.1
Adds awaitable import and export apis. Related to https://github.com/bpmn-io/bpmn-js/issues/812
This commit is contained in:
parent
6bff933d92
commit
506321eafd
|
@ -104,26 +104,26 @@ BaseViewer.prototype.importXML = function(xml, bpmnDiagram, done) {
|
|||
// allow xml manipulation
|
||||
xml = this._emit('import.parse.start', { xml: xml }) || xml;
|
||||
|
||||
this._moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
|
||||
this._moddle.fromXML(xml, 'bpmn:Definitions').then(function(result) {
|
||||
var definitions = result.rootElement;
|
||||
var references = result.references;
|
||||
var parseWarnings = result.warnings;
|
||||
var elementsById = result.elementsById;
|
||||
|
||||
var context = {
|
||||
elementsById: elementsById,
|
||||
references: references,
|
||||
warnings: parseWarnings
|
||||
};
|
||||
|
||||
// hook in post parse listeners +
|
||||
// allow definitions manipulation
|
||||
definitions = self._emit('import.parse.complete', {
|
||||
error: err,
|
||||
error: null,
|
||||
definitions: definitions,
|
||||
context: context
|
||||
}) || definitions;
|
||||
|
||||
var parseWarnings = context.warnings;
|
||||
|
||||
if (err) {
|
||||
err = checkValidationError(err);
|
||||
|
||||
self._emit('import.done', { error: err, warnings: parseWarnings });
|
||||
|
||||
return done(err, parseWarnings);
|
||||
}
|
||||
|
||||
self.importDefinitions(definitions, bpmnDiagram, function(err, importWarnings) {
|
||||
var allWarnings = [].concat(parseWarnings, importWarnings || []);
|
||||
|
||||
|
@ -131,6 +131,17 @@ BaseViewer.prototype.importXML = function(xml, bpmnDiagram, done) {
|
|||
|
||||
done(err, allWarnings);
|
||||
});
|
||||
}).catch(function(err) {
|
||||
|
||||
self._emit('import.parse.complete', {
|
||||
error: err
|
||||
});
|
||||
|
||||
err = checkValidationError(err);
|
||||
|
||||
self._emit('import.done', { error: err, warnings: err.warnings });
|
||||
|
||||
return done(err, err.warnings);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -263,23 +274,27 @@ BaseViewer.prototype.saveXML = function(options, done) {
|
|||
definitions: definitions
|
||||
}) || definitions;
|
||||
|
||||
this._moddle.toXML(definitions, options, function(err, xml) {
|
||||
this._moddle.toXML(definitions, options).then(function(result) {
|
||||
|
||||
var xml = result.xml;
|
||||
|
||||
try {
|
||||
xml = self._emit('saveXML.serialized', {
|
||||
error: err,
|
||||
error: null,
|
||||
xml: xml
|
||||
}) || xml;
|
||||
|
||||
self._emit('saveXML.done', {
|
||||
error: err,
|
||||
error: null,
|
||||
xml: xml
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('error in saveXML life-cycle listener', e);
|
||||
}
|
||||
|
||||
done(err, xml);
|
||||
done(null, xml);
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -650,4 +665,4 @@ function addProjectLogo(container) {
|
|||
});
|
||||
}
|
||||
|
||||
/* </project-logo> */
|
||||
/* </project-logo> */
|
||||
|
|
|
@ -1107,13 +1107,13 @@
|
|||
"dev": true
|
||||
},
|
||||
"bpmn-moddle": {
|
||||
"version": "6.0.6",
|
||||
"resolved": "https://registry.npmjs.org/bpmn-moddle/-/bpmn-moddle-6.0.6.tgz",
|
||||
"integrity": "sha512-GbriI2Jt+qiLCaZV/oo9B7PM1fzBz+Mt0ls1irAXEUZek9VMaM71lL0KiN2wCHMcvEVqCMQLMdR9hTW42ji/iQ==",
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/bpmn-moddle/-/bpmn-moddle-7.0.1.tgz",
|
||||
"integrity": "sha512-Y9zLrDi39L+I2IdYR+9cdef8asyhhQsJdDghhfvUicflZ7ayzopt8hpdzhkwGai1KMVGc8izn/BUB9kK8F12Og==",
|
||||
"requires": {
|
||||
"min-dash": "^3.0.0",
|
||||
"moddle": "^5.0.1",
|
||||
"moddle-xml": "^8.0.7"
|
||||
"moddle-xml": "^9.0.1"
|
||||
}
|
||||
},
|
||||
"brace-expansion": {
|
||||
|
@ -5837,9 +5837,9 @@
|
|||
}
|
||||
},
|
||||
"moddle-xml": {
|
||||
"version": "8.0.7",
|
||||
"resolved": "https://registry.npmjs.org/moddle-xml/-/moddle-xml-8.0.7.tgz",
|
||||
"integrity": "sha512-ynoIED3UwDuvhwpLzSjBX2qXAAgXeMvkjU0xlG2Q9eZGHakNOFJ6TYHEnEOSuaxUrGe3k5c2rZ8jMM7nvlpU7g==",
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/moddle-xml/-/moddle-xml-9.0.1.tgz",
|
||||
"integrity": "sha512-AXT3C1XGxo2h2ckk9hz62MY/spDobyhR+A2o30it0ZAO/NFDWpzYm+y/WeC52XrWi/MzUrVz8JVtfJu+W2DESA==",
|
||||
"requires": {
|
||||
"min-dash": "^3.0.0",
|
||||
"moddle": "^5.0.1",
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
"webpack": "^4.35.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"bpmn-moddle": "^6.0.6",
|
||||
"bpmn-moddle": "^7.0.1",
|
||||
"css.escape": "^1.5.1",
|
||||
"diagram-js": "^6.6.1",
|
||||
"diagram-js-direct-editing": "^1.6.1",
|
||||
|
|
|
@ -3,9 +3,9 @@ import BpmnModdle from 'bpmn-moddle';
|
|||
|
||||
describe('bpmn-moddle', function() {
|
||||
|
||||
function parse(xml, done) {
|
||||
function parse(xml) {
|
||||
var moddle = new BpmnModdle();
|
||||
moddle.fromXML(xml, 'bpmn:Definitions', done);
|
||||
return moddle.fromXML(xml, 'bpmn:Definitions');
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,11 +22,9 @@ describe('bpmn-moddle', function() {
|
|||
'</bpmn2:definitions>';
|
||||
|
||||
// when
|
||||
parse(xml, function(err, definitions) {
|
||||
parse(xml).then(function(result) {
|
||||
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
||||
var definitions = result.rootElement;
|
||||
|
||||
// then
|
||||
expect(definitions.id).to.equal('simple');
|
||||
|
@ -36,6 +34,8 @@ describe('bpmn-moddle', function() {
|
|||
expect(definitions.rootElements[0].id).to.equal('Process_1');
|
||||
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -47,18 +47,17 @@ describe('bpmn-moddle', function() {
|
|||
var start = new Date().getTime();
|
||||
|
||||
// when
|
||||
parse(xml, function(err) {
|
||||
parse(xml).then(function() {
|
||||
|
||||
// then
|
||||
// parsing a XML document should not take too long
|
||||
expect((new Date().getTime() - start)).to.be.below(1000);
|
||||
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
done(err);
|
||||
});
|
||||
|
||||
// then
|
||||
// everything should be a.o.k
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,7 +35,9 @@ describe('import - BpmnTreeWalker', function() {
|
|||
error: errorSpy
|
||||
});
|
||||
|
||||
createModdle(simpleXML, function(err, definitions, context, moddle) {
|
||||
createModdle(simpleXML).then(function(result) {
|
||||
|
||||
var definitions = result.rootElement;
|
||||
|
||||
// when
|
||||
walker.handleDefinitions(definitions);
|
||||
|
@ -46,6 +48,9 @@ describe('import - BpmnTreeWalker', function() {
|
|||
expect(errorSpy.notCalled).to.be.true;
|
||||
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -63,7 +68,10 @@ describe('import - BpmnTreeWalker', function() {
|
|||
error: errorSpy
|
||||
});
|
||||
|
||||
createModdle(simpleXML, function(err, definitions, context, moddle) {
|
||||
createModdle(simpleXML).then(function(result) {
|
||||
|
||||
var definitions = result.rootElement;
|
||||
|
||||
var subProcess = findElementWithId(definitions, 'SubProcess_1');
|
||||
|
||||
var plane = definitions.diagrams[0].plane,
|
||||
|
@ -83,6 +91,9 @@ describe('import - BpmnTreeWalker', function() {
|
|||
expect(errorSpy.notCalled).to.be.true;
|
||||
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -100,7 +111,9 @@ describe('import - BpmnTreeWalker', function() {
|
|||
error: errorSpy
|
||||
});
|
||||
|
||||
createModdle(simpleXML, function(err, definitions, context, moddle) {
|
||||
createModdle(simpleXML).then(function(result) {
|
||||
|
||||
var definitions = result.rootElement;
|
||||
|
||||
var element = findElementWithId(definitions, 'SubProcess_1');
|
||||
|
||||
|
@ -116,6 +129,9 @@ describe('import - BpmnTreeWalker', function() {
|
|||
expect(errorSpy.calledOnce).to.be.true;
|
||||
|
||||
done();
|
||||
}).catch(function(err) {
|
||||
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -127,9 +143,7 @@ describe('import - BpmnTreeWalker', function() {
|
|||
function createModdle(xml, done) {
|
||||
var moddle = new BpmnModdle();
|
||||
|
||||
moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
|
||||
done(err, definitions, context, moddle);
|
||||
});
|
||||
return moddle.fromXML(xml, 'bpmn:Definitions');
|
||||
}
|
||||
|
||||
function createWalker(listeners) {
|
||||
|
@ -174,4 +188,4 @@ function findElementWithId(definitions, id) {
|
|||
return findElement(rootElement) || foundElement;
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,9 @@ describe('import - Importer', function() {
|
|||
|
||||
var moddle = new BpmnModdle();
|
||||
|
||||
moddle.fromXML(xml, function(err, definitions) {
|
||||
moddle.fromXML(xml).then(function(result) {
|
||||
|
||||
var definitions = result.rootElement;
|
||||
|
||||
var selectedDiagram = find(definitions.diagrams, function(element) {
|
||||
return element.id === diagramId;
|
||||
|
@ -711,4 +713,4 @@ function expectChildren(diagram, parent, children) {
|
|||
expect(existingChildrenGfx).to.eql(expectedChildrenGfx);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue