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