Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dmn-js-shared

Package Overview
Dependencies
Maintainers
6
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dmn-js-shared - npm Package Compare versions

Comparing version 10.3.0 to 11.0.0

lib/util/CompatibilityUtils.js

10

lib/base/EditingManager.js

@@ -48,3 +48,3 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

if (!event.error) {
_this._collectIds(event.definitions, event.context);
_this._collectIds(event.definitions, event.elementsById);
}

@@ -74,3 +74,3 @@ });

* @param {ModdleElement} definitions
* @param {Context} context
* @param {Array<ModdleElement>} elementsById
*/

@@ -80,3 +80,3 @@

key: "_collectIds",
value: function _collectIds(definitions, context) {
value: function _collectIds(definitions, elementsById) {
var moddle = definitions.$model,

@@ -88,4 +88,4 @@ ids = moddle.ids,

for (id in context.elementsById) {
ids.claim(id, context.elementsById[id]);
for (id in elementsById) {
ids.claim(id, elementsById[id]);
}

@@ -92,0 +92,0 @@ }

@@ -13,4 +13,2 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -29,2 +27,11 @@

import { assign, debounce, every, find, isDefined, isFunction, isNumber } from 'min-dash';
import { wrapForCompatibility } from '../util/CompatibilityUtils';
/**
* @typedef {import('./View').OpenResult} OpenResult
*/
/**
* @typedef {import('./View').OpenError} OpenError
*/
var DEFAULT_CONTAINER_OPTIONS = {

@@ -68,7 +75,27 @@ width: '100%',

this._views = [];
this._viewers = {};
this._viewers = {}; // keep support for callbacks
this.open = wrapForCompatibility(this.open.bind(this));
this.importXML = wrapForCompatibility(this.importXML.bind(this));
this.saveXML = wrapForCompatibility(this.saveXML.bind(this));
this._init(options);
}
/**
* The importXML result.
*
* @typedef {Object} ImportXMLResult
*
* @property {Array<string>} warnings
*/
/**
* The importXML error.
*
* @typedef {Error} ImportXMLError
*
* @property {Array<string>} warnings
*/
/**
* Parse and render a DMN diagram.

@@ -94,3 +121,4 @@ *

* @param {boolean} [options.open=true]
* @param {Function} [done] invoked with (err, warnings=[])
*
* @return {Promise<ImportXMLResult, ImportXMLError>}
*/

@@ -101,64 +129,119 @@

key: "importXML",
value: function importXML(xml, options, done) {
var _this2 = this;
value: function importXML(xml, options) {
var self = this;
options = options || {
open: true
};
return new Promise(function (resolve, reject) {
// hook in pre-parse listeners +
// allow xml manipulation
xml = self._emit('import.parse.start', {
xml: xml
}) || xml;
var parseWarnings;
if (_typeof(options) !== 'object') {
done = options;
options = {
open: true
};
}
self._moddle.fromXML(xml, 'dmn:Definitions').then(function (parseResult) {
var definitions = parseResult.rootElement;
var references = parseResult.references;
var elementsById = parseResult.elementsById;
parseWarnings = parseResult.warnings; // hook in post parse listeners +
// allow definitions manipulation
if (typeof done !== 'function') {
done = noop;
} // hook in pre-parse listeners +
// allow xml manipulation
definitions = self._emit('import.parse.complete', ParseCompleteEvent({
error: null,
definitions: definitions,
elementsById: elementsById,
references: references,
warnings: parseWarnings
})) || definitions;
self._setDefinitions(definitions);
xml = this._emit('import.parse.start', {
xml: xml
}) || xml;
if (!options.open) {
self._emit('import.done', {
error: null,
warnings: parseWarnings
});
this._moddle.fromXML(xml, 'dmn:Definitions', function (err, definitions, context) {
// hook in post parse listeners +
// allow definitions manipulation
definitions = _this2._emit('import.parse.complete', {
error: err,
definitions: definitions,
context: context
}) || definitions;
var parseWarnings = context.warnings;
resolve({
warnings: parseWarnings
});
return;
}
_this2._setDefinitions(definitions);
var view = self._activeView || self._getInitialView(self._views);
if (err) {
err = checkDMNCompatibilityError(err, xml) || checkValidationError(err) || err;
}
if (!view) {
var noDisplayableContentsErr = new Error('no displayable contents');
if (err || !options.open) {
_this2._emit('import.done', {
error: err,
warmings: parseWarnings
});
self._emit('import.done', {
error: noDisplayableContentsErr,
warnings: parseWarnings
});
return done(err, parseWarnings);
}
noDisplayableContentsErr.warnings = parseWarnings;
return reject(noDisplayableContentsErr);
}
var view = _this2._activeView || _this2._getInitialView(_this2._views);
self.open(view).then(function (result) {
return {
warnings: result.warnings
};
})["catch"](function (error) {
return {
error: error,
warnings: error.warnings
};
}).then(function (result) {
var allWarnings = [].concat(parseWarnings, result.warnings);
if (!view) {
return done(new Error('no displayable contents'));
}
self._emit('import.done', {
error: result.error,
warnings: allWarnings
});
_this2.open(view, function (err, warnings) {
var allWarnings = [].concat(parseWarnings, warnings || []);
if (result.error) {
result.error.warnings = allWarnings;
reject(result.error);
} else {
resolve({
warnings: allWarnings
});
}
});
})["catch"](function (parseError) {
parseWarnings = parseError.warnings;
parseError = checkDMNCompatibilityError(parseError, xml) || checkValidationError(parseError) || parseError;
_this2._emit('import.done', {
error: err,
warnings: allWarnings
self._emit('import.parse.complete', ParseCompleteEvent({
error: parseError,
warnings: parseWarnings
}));
self._emit('import.done', {
error: parseError,
warnings: parseWarnings
});
done(err, allWarnings);
parseError.warnings = parseWarnings;
return reject(parseError);
});
});
}); // TODO: remove with future dmn-js version
function ParseCompleteEvent(data) {
var event = self._eventBus.createEvent(data);
Object.defineProperty(event, 'context', {
enumerable: true,
get: function get() {
console.warn(new Error('import.parse.complete <context> is deprecated ' + 'and will be removed in future library versions'));
return {
warnings: data.warnings,
references: data.references,
elementsById: data.elementsById
};
}
});
return event;
}
}

@@ -206,2 +289,10 @@ }, {

/**
* The saveXML result.
*
* @typedef {Object} SaveXMLResult
*
* @property {string} xml
*/
/**
* Export the currently displayed DMN diagram as

@@ -223,3 +314,4 @@ * a DMN XML document.

* @param {boolean} [options.preamble=true] output preamble
* @param {Function} done invoked with (err, xml)
*
* @return {Promise<SaveXMLResult, Error>}
*/

@@ -229,37 +321,40 @@

key: "saveXML",
value: function saveXML(options, done) {
var _this3 = this;
if (typeof options === 'function') {
done = options;
options = {};
}
value: function saveXML(options) {
var self = this;
options = options || {};
var definitions = this._definitions;
return new Promise(function (resolve, reject) {
if (!definitions) {
reject(new Error('no definitions loaded'));
return;
} // allow to fiddle around with definitions
if (!definitions) {
return done(new Error('no definitions loaded'));
} // allow to fiddle around with definitions
definitions = self._emit('saveXML.start', {
definitions: definitions
}) || definitions;
definitions = this._emit('saveXML.start', {
definitions: definitions
}) || definitions;
this._moddle.toXML(definitions, options, function (err, xml) {
try {
xml = _this3._emit('saveXML.serialized', {
error: err,
self._moddle.toXML(definitions, options).then(function (result) {
var xml = result.xml;
xml = self._emit('saveXML.serialized', {
xml: xml
}) || xml;
_this3._emit('saveXML.done', {
error: err,
return {
xml: xml
});
} catch (e) {
console.error('error in saveXML life-cycle listener', e);
}
};
})["catch"](function (error) {
return {
error: error
};
}).then(function (result) {
self._emit('saveXML.done', result);
done(err, xml);
if (result.error) {
reject(result.error);
} else {
resolve({
xml: result.xml
});
}
});
});

@@ -341,6 +436,6 @@ }

value: function destroy() {
var _this4 = this;
var _this2 = this;
Object.keys(this._viewers).forEach(function (viewerId) {
var viewer = _this4._viewers[viewerId];
var viewer = _this2._viewers[viewerId];
safeExecute(viewer, 'destroy');

@@ -371,6 +466,7 @@ });

/**
* Open diagram element.
* Open diagram view.
*
* @param {ModdleElement} element
* @param {Function} [done]
* @param {View} view
* @returns {Promise} Resolves with {OpenResult} when successful
* or rejects with {OpenError}
*/

@@ -381,5 +477,3 @@

value: function open(view) {
var done = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
this._switchView(view, done);
return this._switchView(view);
}

@@ -469,3 +563,5 @@ }, {

if (!newActiveView) {
return this._switchView(null);
this._switchView(null);
return;
}

@@ -500,3 +596,4 @@ } // Views have changed if

* @param {View} newView
* @param {Function} [done]
* @returns {Promise} Resolves with {OpenResult} when successful
* or rejects with {OpenError}
*/

@@ -507,52 +604,64 @@

value: function _switchView(newView) {
var _this5 = this;
var self = this;
return new Promise(function (resolve, reject) {
var complete = function complete(openError, openResult) {
self._viewsChanged();
var done = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
if (openError) {
reject(openError);
} else {
resolve(openResult);
}
};
var complete = function complete(err, warnings) {
_this5._viewsChanged();
var activeView = self.getActiveView(),
activeViewer;
done(err, warnings);
};
var newViewer = newView && self._getViewer(newView),
element = newView && newView.element;
var activeView = this.getActiveView(),
activeViewer;
if (activeView) {
activeViewer = self._getViewer(activeView);
var newViewer = newView && this._getViewer(newView),
element = newView && newView.element;
if (activeViewer !== newViewer) {
safeExecute(activeViewer, 'clear');
activeViewer.detach();
}
}
if (activeView) {
activeViewer = this._getViewer(activeView);
self._activeView = newView;
if (activeViewer !== newViewer) {
safeExecute(activeViewer, 'clear');
activeViewer.detach();
}
}
if (newViewer) {
if (activeViewer !== newViewer) {
newViewer.attachTo(self._container);
}
this._activeView = newView;
self._emit('import.render.start', {
view: newView,
element: element
});
if (newViewer) {
if (activeViewer !== newViewer) {
newViewer.attachTo(this._container);
}
newViewer.open(element).then(function (result) {
self._emit('import.render.complete', {
view: newView,
error: null,
warnings: result.warnings
});
this._emit('import.render.start', {
view: newView,
element: element
});
complete(null, result);
})["catch"](function (error) {
self._emit('import.render.complete', {
view: newView,
error: error,
warnings: error.warnings
});
return newViewer.open(element, function (err, warnings) {
_this5._emit('import.render.complete', {
view: newView,
error: err,
warnings: warnings
complete(error, null);
});
return;
} // no active view
complete(err, warnings);
});
} // no active view
complete();
complete();
});
}

@@ -633,6 +742,2 @@ }, {

export { Manager as default };
function noop() {}
/**

@@ -643,2 +748,4 @@ * Ensure the passed argument is a proper unit (defaulting to px)

export { Manager as default };
function ensureUnit(val) {

@@ -645,0 +752,0 @@ return val + (isNumber(val) ? 'px' : '');

@@ -34,6 +34,18 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/**
* Open view on the given element.
* @typedef {Object} OpenResult
* @property {Array<string>} warnings - Warnings occured during opening
*/
/**
* @typedef {Object} OpenError
* @property {Error} error
* @property {Array<string>} warnings - Warnings occured during opening
*/
/**
* Open diagram element.
*
* @param {View} view
* @param {Function} [done]
* @param {ModdleElement} view
* @returns {Promise} Resolves with {OpenResult} when successful
* or rejects with {OpenError}
*/

@@ -44,4 +56,7 @@

value: function open(view) {
var done = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
done();
return new Promise(function (resolve, reject) {
resolve({
warnings: []
});
});
}

@@ -85,8 +100,5 @@ /**

return View;
}(); // helpers //////////////////////
}();
export { View as default };
function noop() {}
//# sourceMappingURL=View.js.map
{
"name": "dmn-js-shared",
"description": "Shared components used by dmn-js",
"version": "10.3.0",
"version": "11.0.0",
"files": [

@@ -29,3 +29,3 @@ "assets",

"diagram-js": "^7.2.0",
"dmn-moddle": "^9.1.0",
"dmn-moddle": "^10.0.0",
"ids": "^0.2.0",

@@ -39,3 +39,3 @@ "inferno": "~5.6.2",

},
"gitHead": "9d3e194164b636b0540c25796a4e00538e68196a"
"gitHead": "dd3238d9e1c7dfa3db02f6951214c7c9f77fdf97"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc