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