@hpcc-js/wasm 1.13.0 → 1.14.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.
package/dist/graphviz.js CHANGED
@@ -41,10 +41,10 @@
41
41
 
42
42
  var graphvizlib = graphvizlib$2.exports;
43
43
 
44
- var graphvizlib$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({
44
+ var graphvizlib$1 = /*#__PURE__*/_mergeNamespaces({
45
45
  __proto__: null,
46
46
  'default': graphvizlib
47
- }, [graphvizlib$2.exports]));
47
+ }, [graphvizlib$2.exports]);
48
48
 
49
49
  function getGlobal() {
50
50
  if (typeof self !== "undefined") {
@@ -58,12 +58,12 @@
58
58
  }
59
59
  throw new Error("unable to locate global object");
60
60
  }
61
- var globalNS = getGlobal();
62
- var _wasmFolder = globalNS.__hpcc_wasmFolder || undefined;
61
+ const globalNS = getGlobal();
62
+ let _wasmFolder = globalNS.__hpcc_wasmFolder || undefined;
63
63
  function wasmFolder(_) {
64
64
  if (!arguments.length)
65
65
  return _wasmFolder;
66
- var retVal = _wasmFolder;
66
+ const retVal = _wasmFolder;
67
67
  _wasmFolder = _;
68
68
  return retVal;
69
69
  }
@@ -80,67 +80,52 @@
80
80
  return str;
81
81
  }
82
82
  function loadWasm(_wasmLib, wf, wasmBinary) {
83
- var wasmLib = _wasmLib.default || _wasmLib;
83
+ const wasmLib = _wasmLib.default || _wasmLib;
84
84
  // Prevent double load ---
85
85
  if (!wasmLib.__hpcc_promise) {
86
86
  wasmLib.__hpcc_promise = wasmLib({
87
- wasmBinary: wasmBinary,
88
- locateFile: function (path, prefix) {
89
- return "".concat(trimEnd(wf || wasmFolder() || prefix || ".", "/"), "/").concat(trimStart(path, "/"));
87
+ wasmBinary,
88
+ locateFile: (path, prefix) => {
89
+ return `${trimEnd(wf || wasmFolder() || prefix || ".", "/")}/${trimStart(path, "/")}`;
90
90
  }
91
91
  });
92
92
  }
93
93
  return wasmLib.__hpcc_promise;
94
94
  }
95
95
 
96
- var __assign = (undefined && undefined.__assign) || function () {
97
- __assign = Object.assign || function(t) {
98
- for (var s, i = 1, n = arguments.length; i < n; i++) {
99
- s = arguments[i];
100
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
101
- t[p] = s[p];
102
- }
103
- return t;
104
- };
105
- return __assign.apply(this, arguments);
106
- };
107
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
108
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
109
- if (ar || !(i in from)) {
110
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
111
- ar[i] = from[i];
112
- }
113
- }
114
- return to.concat(ar || Array.prototype.slice.call(from));
115
- };
96
+ // @ts-ignore
116
97
  function imageToFile(image) {
117
98
  return {
118
99
  path: image.path,
119
- data: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg width=\"".concat(image.width, "\" height=\"").concat(image.height, "\"></svg>")
100
+ data: `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
101
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
102
+ <svg width="${image.width}" height="${image.height}"></svg>`
120
103
  };
121
104
  }
122
105
  function imagesToFiles(images) {
123
106
  return images.map(imageToFile);
124
107
  }
125
108
  function createFiles(graphviz, _ext) {
126
- var ext = __assign({ images: [], files: [] }, _ext);
127
- __spreadArray(__spreadArray([], ext.files, true), imagesToFiles(ext.images), true).forEach(function (file) { return graphviz.createFile(file.path, file.data); });
109
+ const ext = {
110
+ images: [],
111
+ files: [],
112
+ ..._ext
113
+ };
114
+ [...ext.files, ...imagesToFiles(ext.images)].forEach(file => graphviz.createFile(file.path, file.data));
128
115
  }
129
116
  function graphvizVersion(wasmFolder, wasmBinary) {
130
- return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(function (module) {
117
+ return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(module => {
131
118
  return module.Graphviz.prototype.version();
132
119
  });
133
120
  }
134
- var graphviz = {
135
- layout: function (dotSource, outputFormat, layoutEngine, ext) {
136
- if (outputFormat === void 0) { outputFormat = "svg"; }
137
- if (layoutEngine === void 0) { layoutEngine = "dot"; }
121
+ const graphviz = {
122
+ layout(dotSource, outputFormat = "svg", layoutEngine = "dot", ext) {
138
123
  if (!dotSource)
139
124
  return Promise.resolve("");
140
- return loadWasm(graphvizlib$1, ext === null || ext === void 0 ? void 0 : ext.wasmFolder, ext === null || ext === void 0 ? void 0 : ext.wasmBinary).then(function (module) {
141
- var graphViz = new module.Graphviz((ext === null || ext === void 0 ? void 0 : ext.yInvert) !== undefined ? ext === null || ext === void 0 ? void 0 : ext.yInvert : false, (ext === null || ext === void 0 ? void 0 : ext.nop) !== undefined ? ext === null || ext === void 0 ? void 0 : ext.nop : 0);
125
+ return loadWasm(graphvizlib$1, ext === null || ext === void 0 ? void 0 : ext.wasmFolder, ext === null || ext === void 0 ? void 0 : ext.wasmBinary).then(module => {
126
+ const graphViz = new module.Graphviz((ext === null || ext === void 0 ? void 0 : ext.yInvert) !== undefined ? ext === null || ext === void 0 ? void 0 : ext.yInvert : false, (ext === null || ext === void 0 ? void 0 : ext.nop) !== undefined ? ext === null || ext === void 0 ? void 0 : ext.nop : 0);
142
127
  createFiles(graphViz, ext);
143
- var retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
128
+ const retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
144
129
  module.destroy(graphViz);
145
130
  if (!retVal) {
146
131
  throw new Error(module.Graphviz.prototype.lastError());
@@ -148,93 +133,74 @@
148
133
  return retVal;
149
134
  });
150
135
  },
151
- circo: function (dotSource, outputFormat, ext) {
152
- if (outputFormat === void 0) { outputFormat = "svg"; }
136
+ circo(dotSource, outputFormat = "svg", ext) {
153
137
  return this.layout(dotSource, outputFormat, "circo", ext);
154
138
  },
155
- dot: function (dotSource, outputFormat, ext) {
156
- if (outputFormat === void 0) { outputFormat = "svg"; }
139
+ dot(dotSource, outputFormat = "svg", ext) {
157
140
  return this.layout(dotSource, outputFormat, "dot", ext);
158
141
  },
159
- fdp: function (dotSource, outputFormat, ext) {
160
- if (outputFormat === void 0) { outputFormat = "svg"; }
142
+ fdp(dotSource, outputFormat = "svg", ext) {
161
143
  return this.layout(dotSource, outputFormat, "fdp", ext);
162
144
  },
163
- sfdp: function (dotSource, outputFormat, ext) {
164
- if (outputFormat === void 0) { outputFormat = "svg"; }
145
+ sfdp(dotSource, outputFormat = "svg", ext) {
165
146
  return this.layout(dotSource, outputFormat, "sfdp", ext);
166
147
  },
167
- neato: function (dotSource, outputFormat, ext) {
168
- if (outputFormat === void 0) { outputFormat = "svg"; }
148
+ neato(dotSource, outputFormat = "svg", ext) {
169
149
  return this.layout(dotSource, outputFormat, "neato", ext);
170
150
  },
171
- osage: function (dotSource, outputFormat, ext) {
172
- if (outputFormat === void 0) { outputFormat = "svg"; }
151
+ osage(dotSource, outputFormat = "svg", ext) {
173
152
  return this.layout(dotSource, outputFormat, "osage", ext);
174
153
  },
175
- patchwork: function (dotSource, outputFormat, ext) {
176
- if (outputFormat === void 0) { outputFormat = "svg"; }
154
+ patchwork(dotSource, outputFormat = "svg", ext) {
177
155
  return this.layout(dotSource, outputFormat, "patchwork", ext);
178
156
  },
179
- twopi: function (dotSource, outputFormat, ext) {
180
- if (outputFormat === void 0) { outputFormat = "svg"; }
157
+ twopi(dotSource, outputFormat = "svg", ext) {
181
158
  return this.layout(dotSource, outputFormat, "twopi", ext);
182
159
  }
183
160
  };
184
- var GraphvizSync = /** @class */ (function () {
185
- function GraphvizSync(_wasm) {
161
+ class GraphvizSync {
162
+ constructor(_wasm) {
186
163
  this._wasm = _wasm;
187
164
  }
188
- GraphvizSync.prototype.layout = function (dotSource, outputFormat, layoutEngine, ext) {
189
- if (outputFormat === void 0) { outputFormat = "svg"; }
190
- if (layoutEngine === void 0) { layoutEngine = "dot"; }
165
+ layout(dotSource, outputFormat = "svg", layoutEngine = "dot", ext) {
191
166
  if (!dotSource)
192
167
  return "";
193
- var graphViz = new this._wasm.Graphviz((ext === null || ext === void 0 ? void 0 : ext.yInvert) ? 1 : 0, (ext === null || ext === void 0 ? void 0 : ext.nop) ? ext === null || ext === void 0 ? void 0 : ext.nop : 0);
168
+ const graphViz = new this._wasm.Graphviz((ext === null || ext === void 0 ? void 0 : ext.yInvert) ? 1 : 0, (ext === null || ext === void 0 ? void 0 : ext.nop) ? ext === null || ext === void 0 ? void 0 : ext.nop : 0);
194
169
  createFiles(graphViz, ext);
195
- var retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
170
+ const retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
196
171
  this._wasm.destroy(graphViz);
197
172
  if (!retVal) {
198
173
  throw new Error(this._wasm.Graphviz.prototype.lastError());
199
174
  }
200
175
  return retVal;
201
- };
202
- GraphvizSync.prototype.circo = function (dotSource, outputFormat, ext) {
203
- if (outputFormat === void 0) { outputFormat = "svg"; }
176
+ }
177
+ circo(dotSource, outputFormat = "svg", ext) {
204
178
  return this.layout(dotSource, outputFormat, "circo", ext);
205
- };
206
- GraphvizSync.prototype.dot = function (dotSource, outputFormat, ext) {
207
- if (outputFormat === void 0) { outputFormat = "svg"; }
179
+ }
180
+ dot(dotSource, outputFormat = "svg", ext) {
208
181
  return this.layout(dotSource, outputFormat, "dot", ext);
209
- };
210
- GraphvizSync.prototype.fdp = function (dotSource, outputFormat, ext) {
211
- if (outputFormat === void 0) { outputFormat = "svg"; }
182
+ }
183
+ fdp(dotSource, outputFormat = "svg", ext) {
212
184
  return this.layout(dotSource, outputFormat, "fdp", ext);
213
- };
214
- GraphvizSync.prototype.sfdp = function (dotSource, outputFormat, ext) {
215
- if (outputFormat === void 0) { outputFormat = "svg"; }
185
+ }
186
+ sfdp(dotSource, outputFormat = "svg", ext) {
216
187
  return this.layout(dotSource, outputFormat, "sfdp", ext);
217
- };
218
- GraphvizSync.prototype.neato = function (dotSource, outputFormat, ext) {
219
- if (outputFormat === void 0) { outputFormat = "svg"; }
188
+ }
189
+ neato(dotSource, outputFormat = "svg", ext) {
220
190
  return this.layout(dotSource, outputFormat, "neato", ext);
221
- };
222
- GraphvizSync.prototype.osage = function (dotSource, outputFormat, ext) {
223
- if (outputFormat === void 0) { outputFormat = "svg"; }
191
+ }
192
+ osage(dotSource, outputFormat = "svg", ext) {
224
193
  return this.layout(dotSource, outputFormat, "osage", ext);
225
- };
226
- GraphvizSync.prototype.patchwork = function (dotSource, outputFormat, ext) {
227
- if (outputFormat === void 0) { outputFormat = "svg"; }
194
+ }
195
+ patchwork(dotSource, outputFormat = "svg", ext) {
228
196
  return this.layout(dotSource, outputFormat, "patchwork", ext);
229
- };
230
- GraphvizSync.prototype.twopi = function (dotSource, outputFormat, ext) {
231
- if (outputFormat === void 0) { outputFormat = "svg"; }
197
+ }
198
+ twopi(dotSource, outputFormat = "svg", ext) {
232
199
  return this.layout(dotSource, outputFormat, "twopi", ext);
233
- };
234
- return GraphvizSync;
235
- }());
200
+ }
201
+ }
236
202
  function graphvizSync(wasmFolder, wasmBinary) {
237
- return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(function (wasm) { return new GraphvizSync(wasm); });
203
+ return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(wasm => new GraphvizSync(wasm));
238
204
  }
239
205
 
240
206
  exports.GraphvizSync = GraphvizSync;