canvas_erd 0.1.0

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.
@@ -0,0 +1,227 @@
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ELK = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
+ "use strict";
3
+
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
9
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
10
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
11
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
13
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
+ /*******************************************************************************
15
+ * Copyright (c) 2017 Kiel University and others.
16
+ *
17
+ * This program and the accompanying materials are made available under the
18
+ * terms of the Eclipse Public License 2.0 which is available at
19
+ * https://www.eclipse.org/legal/epl-2.0.
20
+ *
21
+ * This Source Code may also be made available under the following Secondary
22
+ * Licenses when the conditions for such availability set forth in the Eclipse
23
+ * Public License v. 2.0 are satisfied: GPL-3.0 which is available at
24
+ * https://www.gnu.org/licenses/gpl-3.0-standalone.html.
25
+ *
26
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-3.0-or-later
27
+ *******************************************************************************/
28
+ var ELK = exports["default"] = /*#__PURE__*/function () {
29
+ function ELK() {
30
+ var _this = this;
31
+ var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
32
+ _ref$defaultLayoutOpt = _ref.defaultLayoutOptions,
33
+ defaultLayoutOptions = _ref$defaultLayoutOpt === void 0 ? {} : _ref$defaultLayoutOpt,
34
+ _ref$algorithms = _ref.algorithms,
35
+ algorithms = _ref$algorithms === void 0 ? ['layered', 'stress', 'mrtree', 'radial', 'force', 'disco', 'sporeOverlap', 'sporeCompaction', 'rectpacking'] : _ref$algorithms,
36
+ workerFactory = _ref.workerFactory,
37
+ workerUrl = _ref.workerUrl;
38
+ _classCallCheck(this, ELK);
39
+ this.defaultLayoutOptions = defaultLayoutOptions;
40
+ this.initialized = false;
41
+
42
+ // check valid worker construction possible
43
+ if (typeof workerUrl === 'undefined' && typeof workerFactory === 'undefined') {
44
+ throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");
45
+ }
46
+ var factory = workerFactory;
47
+ if (typeof workerUrl !== 'undefined' && typeof workerFactory === 'undefined') {
48
+ // use default Web Worker
49
+ factory = function factory(url) {
50
+ return new Worker(url);
51
+ };
52
+ }
53
+
54
+ // create the worker
55
+ var worker = factory(workerUrl);
56
+ if (typeof worker.postMessage !== 'function') {
57
+ throw new TypeError("Created worker does not provide" + " the required 'postMessage' function.");
58
+ }
59
+
60
+ // wrap the worker to return promises
61
+ this.worker = new PromisedWorker(worker);
62
+
63
+ // initially register algorithms
64
+ this.worker.postMessage({
65
+ cmd: 'register',
66
+ algorithms: algorithms
67
+ }).then(function (r) {
68
+ return _this.initialized = true;
69
+ })["catch"](console.err);
70
+ }
71
+ return _createClass(ELK, [{
72
+ key: "layout",
73
+ value: function layout(graph) {
74
+ var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
75
+ _ref2$layoutOptions = _ref2.layoutOptions,
76
+ layoutOptions = _ref2$layoutOptions === void 0 ? this.defaultLayoutOptions : _ref2$layoutOptions,
77
+ _ref2$logging = _ref2.logging,
78
+ logging = _ref2$logging === void 0 ? false : _ref2$logging,
79
+ _ref2$measureExecutio = _ref2.measureExecutionTime,
80
+ measureExecutionTime = _ref2$measureExecutio === void 0 ? false : _ref2$measureExecutio;
81
+ if (!graph) {
82
+ return Promise.reject(new Error("Missing mandatory parameter 'graph'."));
83
+ }
84
+ return this.worker.postMessage({
85
+ cmd: 'layout',
86
+ graph: graph,
87
+ layoutOptions: layoutOptions,
88
+ options: {
89
+ logging: logging,
90
+ measureExecutionTime: measureExecutionTime
91
+ }
92
+ });
93
+ }
94
+ }, {
95
+ key: "knownLayoutAlgorithms",
96
+ value: function knownLayoutAlgorithms() {
97
+ return this.worker.postMessage({
98
+ cmd: 'algorithms'
99
+ });
100
+ }
101
+ }, {
102
+ key: "knownLayoutOptions",
103
+ value: function knownLayoutOptions() {
104
+ return this.worker.postMessage({
105
+ cmd: 'options'
106
+ });
107
+ }
108
+ }, {
109
+ key: "knownLayoutCategories",
110
+ value: function knownLayoutCategories() {
111
+ return this.worker.postMessage({
112
+ cmd: 'categories'
113
+ });
114
+ }
115
+ }, {
116
+ key: "terminateWorker",
117
+ value: function terminateWorker() {
118
+ if (this.worker) this.worker.terminate();
119
+ }
120
+ }]);
121
+ }();
122
+ var PromisedWorker = /*#__PURE__*/function () {
123
+ function PromisedWorker(worker) {
124
+ var _this2 = this;
125
+ _classCallCheck(this, PromisedWorker);
126
+ if (worker === undefined) {
127
+ throw new Error("Missing mandatory parameter 'worker'.");
128
+ }
129
+ this.resolvers = {};
130
+ this.worker = worker;
131
+ this.worker.onmessage = function (answer) {
132
+ // why is this necessary?
133
+ setTimeout(function () {
134
+ _this2.receive(_this2, answer);
135
+ }, 0);
136
+ };
137
+ }
138
+ return _createClass(PromisedWorker, [{
139
+ key: "postMessage",
140
+ value: function postMessage(msg) {
141
+ var id = this.id || 0;
142
+ this.id = id + 1;
143
+ msg.id = id;
144
+ var self = this;
145
+ return new Promise(function (resolve, reject) {
146
+ // prepare the resolver
147
+ self.resolvers[id] = function (err, res) {
148
+ if (err) {
149
+ self.convertGwtStyleError(err);
150
+ reject(err);
151
+ } else {
152
+ resolve(res);
153
+ }
154
+ };
155
+ // post the message
156
+ self.worker.postMessage(msg);
157
+ });
158
+ }
159
+ }, {
160
+ key: "receive",
161
+ value: function receive(self, answer) {
162
+ var json = answer.data;
163
+ var resolver = self.resolvers[json.id];
164
+ if (resolver) {
165
+ delete self.resolvers[json.id];
166
+ if (json.error) {
167
+ resolver(json.error);
168
+ } else {
169
+ resolver(null, json.data);
170
+ }
171
+ }
172
+ }
173
+ }, {
174
+ key: "terminate",
175
+ value: function terminate() {
176
+ if (this.worker) {
177
+ this.worker.terminate();
178
+ }
179
+ }
180
+ }, {
181
+ key: "convertGwtStyleError",
182
+ value: function convertGwtStyleError(err) {
183
+ if (!err) {
184
+ return;
185
+ }
186
+ // Somewhat flatten the way GWT stores nested exception(s)
187
+ var javaException = err['__java$exception'];
188
+ if (javaException) {
189
+ // Note that the property name of the nested exception is different
190
+ // in the non-minified ('cause') and the minified (not deterministic) version.
191
+ // Hence, the version below only works for the non-minified version.
192
+ // However, as the minified stack trace is not of much use anyway, one
193
+ // should switch the used version for debugging in such a case.
194
+ if (javaException.cause && javaException.cause.backingJsObject) {
195
+ err.cause = javaException.cause.backingJsObject;
196
+ this.convertGwtStyleError(err.cause);
197
+ }
198
+ delete err['__java$exception'];
199
+ }
200
+ }
201
+ }]);
202
+ }();
203
+ },{}],2:[function(require,module,exports){
204
+ "use strict";
205
+
206
+ /*******************************************************************************
207
+ * Copyright (c) 2021 Kiel University and others.
208
+ *
209
+ * This program and the accompanying materials are made available under the
210
+ * terms of the Eclipse Public License 2.0 which is available at
211
+ * https://www.eclipse.org/legal/epl-2.0.
212
+ *
213
+ * This Source Code may also be made available under the following Secondary
214
+ * Licenses when the conditions for such availability set forth in the Eclipse
215
+ * Public License v. 2.0 are satisfied: GPL-3.0 which is available at
216
+ * https://www.gnu.org/licenses/gpl-3.0-standalone.html.
217
+ *
218
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-3.0-or-later
219
+ *******************************************************************************/
220
+ var ELK = require('./elk-api.js')["default"];
221
+ Object.defineProperty(module.exports, "__esModule", {
222
+ value: true
223
+ });
224
+ module.exports = ELK;
225
+ ELK["default"] = ELK;
226
+ },{"./elk-api.js":1}]},{},[2])(2)
227
+ });