@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/index.js CHANGED
@@ -41,10 +41,10 @@
41
41
 
42
42
  var expatlib = expatlib$2.exports;
43
43
 
44
- var expatlib$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({
44
+ var expatlib$1 = /*#__PURE__*/_mergeNamespaces({
45
45
  __proto__: null,
46
46
  'default': expatlib
47
- }, [expatlib$2.exports]));
47
+ }, [expatlib$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,13 +80,13 @@
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
  }
@@ -94,66 +94,60 @@
94
94
  }
95
95
 
96
96
  // @ts-ignore
97
- var StackElement = /** @class */ (function () {
98
- function StackElement(tag, attrs) {
97
+ class StackElement {
98
+ constructor(tag, attrs) {
99
99
  this.tag = tag;
100
100
  this.attrs = attrs;
101
101
  this._content = "";
102
102
  }
103
- Object.defineProperty(StackElement.prototype, "content", {
104
- get: function () {
105
- return this._content;
106
- },
107
- enumerable: false,
108
- configurable: true
109
- });
110
- StackElement.prototype.appendContent = function (content) {
103
+ get content() {
104
+ return this._content;
105
+ }
106
+ appendContent(content) {
111
107
  this._content += content;
112
- };
113
- return StackElement;
114
- }());
115
- var StackParser = /** @class */ (function () {
116
- function StackParser() {
108
+ }
109
+ }
110
+ class StackParser {
111
+ constructor() {
117
112
  this._stack = [];
118
113
  }
119
- StackParser.prototype.parse = function (xml, wasmFolder, wasmBinary) {
114
+ parse(xml, wasmFolder, wasmBinary) {
120
115
  return parse(xml, this, wasmFolder, wasmBinary);
121
- };
122
- StackParser.prototype.top = function () {
116
+ }
117
+ top() {
123
118
  return this._stack[this._stack.length - 1];
124
- };
125
- StackParser.prototype.startElement = function (tag, attrs) {
126
- var retVal = new StackElement(tag, attrs);
119
+ }
120
+ startElement(tag, attrs) {
121
+ const retVal = new StackElement(tag, attrs);
127
122
  this._stack.push(retVal);
128
123
  return retVal;
129
- };
130
- StackParser.prototype.endElement = function (tag) {
124
+ }
125
+ endElement(tag) {
131
126
  return this._stack.pop();
132
- };
133
- StackParser.prototype.characterData = function (content) {
127
+ }
128
+ characterData(content) {
134
129
  this.top().appendContent(content);
135
- };
136
- return StackParser;
137
- }());
130
+ }
131
+ }
138
132
  function parseAttrs(attrs) {
139
- var retVal = {};
140
- var keys = attrs;
141
- var sep = "".concat(String.fromCharCode(1));
142
- var sep2 = "".concat(sep).concat(sep);
143
- keys.split(sep2).filter(function (key) { return !!key; }).forEach(function (key) {
144
- var parts = key.split(sep);
133
+ const retVal = {};
134
+ const keys = attrs;
135
+ const sep = `${String.fromCharCode(1)}`;
136
+ const sep2 = `${sep}${sep}`;
137
+ keys.split(sep2).filter((key) => !!key).forEach((key) => {
138
+ const parts = key.split(sep);
145
139
  retVal[parts[0]] = parts[1];
146
140
  });
147
141
  return retVal;
148
142
  }
149
143
  function expatVersion(wasmFolder, wasmBinary) {
150
- return loadWasm(expatlib$1, wasmFolder, wasmBinary).then(function (module) {
144
+ return loadWasm(expatlib$1, wasmFolder, wasmBinary).then(module => {
151
145
  return module.CExpat.prototype.version();
152
146
  });
153
147
  }
154
148
  function parse(xml, callback, wasmFolder, wasmBinary) {
155
- return loadWasm(expatlib$1, wasmFolder, wasmBinary).then(function (module) {
156
- var parser = new module.CExpatJS();
149
+ return loadWasm(expatlib$1, wasmFolder, wasmBinary).then(module => {
150
+ const parser = new module.CExpatJS();
157
151
  parser.startElement = function () {
158
152
  callback.startElement(this.tag(), parseAttrs(this.attrs()));
159
153
  };
@@ -164,7 +158,7 @@
164
158
  callback.characterData(this.content());
165
159
  };
166
160
  parser.create();
167
- var retVal = parser.parse(xml);
161
+ const retVal = parser.parse(xml);
168
162
  parser.destroy();
169
163
  module.destroy(parser);
170
164
  return retVal;
@@ -193,59 +187,44 @@
193
187
 
194
188
  var graphvizlib = graphvizlib$2.exports;
195
189
 
196
- var graphvizlib$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/_mergeNamespaces({
190
+ var graphvizlib$1 = /*#__PURE__*/_mergeNamespaces({
197
191
  __proto__: null,
198
192
  'default': graphvizlib
199
- }, [graphvizlib$2.exports]));
193
+ }, [graphvizlib$2.exports]);
200
194
 
201
- var __assign = (undefined && undefined.__assign) || function () {
202
- __assign = Object.assign || function(t) {
203
- for (var s, i = 1, n = arguments.length; i < n; i++) {
204
- s = arguments[i];
205
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
206
- t[p] = s[p];
207
- }
208
- return t;
209
- };
210
- return __assign.apply(this, arguments);
211
- };
212
- var __spreadArray = (undefined && undefined.__spreadArray) || function (to, from, pack) {
213
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
214
- if (ar || !(i in from)) {
215
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
216
- ar[i] = from[i];
217
- }
218
- }
219
- return to.concat(ar || Array.prototype.slice.call(from));
220
- };
195
+ // @ts-ignore
221
196
  function imageToFile(image) {
222
197
  return {
223
198
  path: image.path,
224
- 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>")
199
+ data: `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
200
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
201
+ <svg width="${image.width}" height="${image.height}"></svg>`
225
202
  };
226
203
  }
227
204
  function imagesToFiles(images) {
228
205
  return images.map(imageToFile);
229
206
  }
230
207
  function createFiles(graphviz, _ext) {
231
- var ext = __assign({ images: [], files: [] }, _ext);
232
- __spreadArray(__spreadArray([], ext.files, true), imagesToFiles(ext.images), true).forEach(function (file) { return graphviz.createFile(file.path, file.data); });
208
+ const ext = {
209
+ images: [],
210
+ files: [],
211
+ ..._ext
212
+ };
213
+ [...ext.files, ...imagesToFiles(ext.images)].forEach(file => graphviz.createFile(file.path, file.data));
233
214
  }
234
215
  function graphvizVersion(wasmFolder, wasmBinary) {
235
- return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(function (module) {
216
+ return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(module => {
236
217
  return module.Graphviz.prototype.version();
237
218
  });
238
219
  }
239
- var graphviz = {
240
- layout: function (dotSource, outputFormat, layoutEngine, ext) {
241
- if (outputFormat === void 0) { outputFormat = "svg"; }
242
- if (layoutEngine === void 0) { layoutEngine = "dot"; }
220
+ const graphviz = {
221
+ layout(dotSource, outputFormat = "svg", layoutEngine = "dot", ext) {
243
222
  if (!dotSource)
244
223
  return Promise.resolve("");
245
- 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) {
246
- 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);
224
+ return loadWasm(graphvizlib$1, ext === null || ext === void 0 ? void 0 : ext.wasmFolder, ext === null || ext === void 0 ? void 0 : ext.wasmBinary).then(module => {
225
+ 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);
247
226
  createFiles(graphViz, ext);
248
- var retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
227
+ const retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
249
228
  module.destroy(graphViz);
250
229
  if (!retVal) {
251
230
  throw new Error(module.Graphviz.prototype.lastError());
@@ -253,93 +232,74 @@
253
232
  return retVal;
254
233
  });
255
234
  },
256
- circo: function (dotSource, outputFormat, ext) {
257
- if (outputFormat === void 0) { outputFormat = "svg"; }
235
+ circo(dotSource, outputFormat = "svg", ext) {
258
236
  return this.layout(dotSource, outputFormat, "circo", ext);
259
237
  },
260
- dot: function (dotSource, outputFormat, ext) {
261
- if (outputFormat === void 0) { outputFormat = "svg"; }
238
+ dot(dotSource, outputFormat = "svg", ext) {
262
239
  return this.layout(dotSource, outputFormat, "dot", ext);
263
240
  },
264
- fdp: function (dotSource, outputFormat, ext) {
265
- if (outputFormat === void 0) { outputFormat = "svg"; }
241
+ fdp(dotSource, outputFormat = "svg", ext) {
266
242
  return this.layout(dotSource, outputFormat, "fdp", ext);
267
243
  },
268
- sfdp: function (dotSource, outputFormat, ext) {
269
- if (outputFormat === void 0) { outputFormat = "svg"; }
244
+ sfdp(dotSource, outputFormat = "svg", ext) {
270
245
  return this.layout(dotSource, outputFormat, "sfdp", ext);
271
246
  },
272
- neato: function (dotSource, outputFormat, ext) {
273
- if (outputFormat === void 0) { outputFormat = "svg"; }
247
+ neato(dotSource, outputFormat = "svg", ext) {
274
248
  return this.layout(dotSource, outputFormat, "neato", ext);
275
249
  },
276
- osage: function (dotSource, outputFormat, ext) {
277
- if (outputFormat === void 0) { outputFormat = "svg"; }
250
+ osage(dotSource, outputFormat = "svg", ext) {
278
251
  return this.layout(dotSource, outputFormat, "osage", ext);
279
252
  },
280
- patchwork: function (dotSource, outputFormat, ext) {
281
- if (outputFormat === void 0) { outputFormat = "svg"; }
253
+ patchwork(dotSource, outputFormat = "svg", ext) {
282
254
  return this.layout(dotSource, outputFormat, "patchwork", ext);
283
255
  },
284
- twopi: function (dotSource, outputFormat, ext) {
285
- if (outputFormat === void 0) { outputFormat = "svg"; }
256
+ twopi(dotSource, outputFormat = "svg", ext) {
286
257
  return this.layout(dotSource, outputFormat, "twopi", ext);
287
258
  }
288
259
  };
289
- var GraphvizSync = /** @class */ (function () {
290
- function GraphvizSync(_wasm) {
260
+ class GraphvizSync {
261
+ constructor(_wasm) {
291
262
  this._wasm = _wasm;
292
263
  }
293
- GraphvizSync.prototype.layout = function (dotSource, outputFormat, layoutEngine, ext) {
294
- if (outputFormat === void 0) { outputFormat = "svg"; }
295
- if (layoutEngine === void 0) { layoutEngine = "dot"; }
264
+ layout(dotSource, outputFormat = "svg", layoutEngine = "dot", ext) {
296
265
  if (!dotSource)
297
266
  return "";
298
- 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);
267
+ 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);
299
268
  createFiles(graphViz, ext);
300
- var retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
269
+ const retVal = graphViz.layout(dotSource, outputFormat, layoutEngine);
301
270
  this._wasm.destroy(graphViz);
302
271
  if (!retVal) {
303
272
  throw new Error(this._wasm.Graphviz.prototype.lastError());
304
273
  }
305
274
  return retVal;
306
- };
307
- GraphvizSync.prototype.circo = function (dotSource, outputFormat, ext) {
308
- if (outputFormat === void 0) { outputFormat = "svg"; }
275
+ }
276
+ circo(dotSource, outputFormat = "svg", ext) {
309
277
  return this.layout(dotSource, outputFormat, "circo", ext);
310
- };
311
- GraphvizSync.prototype.dot = function (dotSource, outputFormat, ext) {
312
- if (outputFormat === void 0) { outputFormat = "svg"; }
278
+ }
279
+ dot(dotSource, outputFormat = "svg", ext) {
313
280
  return this.layout(dotSource, outputFormat, "dot", ext);
314
- };
315
- GraphvizSync.prototype.fdp = function (dotSource, outputFormat, ext) {
316
- if (outputFormat === void 0) { outputFormat = "svg"; }
281
+ }
282
+ fdp(dotSource, outputFormat = "svg", ext) {
317
283
  return this.layout(dotSource, outputFormat, "fdp", ext);
318
- };
319
- GraphvizSync.prototype.sfdp = function (dotSource, outputFormat, ext) {
320
- if (outputFormat === void 0) { outputFormat = "svg"; }
284
+ }
285
+ sfdp(dotSource, outputFormat = "svg", ext) {
321
286
  return this.layout(dotSource, outputFormat, "sfdp", ext);
322
- };
323
- GraphvizSync.prototype.neato = function (dotSource, outputFormat, ext) {
324
- if (outputFormat === void 0) { outputFormat = "svg"; }
287
+ }
288
+ neato(dotSource, outputFormat = "svg", ext) {
325
289
  return this.layout(dotSource, outputFormat, "neato", ext);
326
- };
327
- GraphvizSync.prototype.osage = function (dotSource, outputFormat, ext) {
328
- if (outputFormat === void 0) { outputFormat = "svg"; }
290
+ }
291
+ osage(dotSource, outputFormat = "svg", ext) {
329
292
  return this.layout(dotSource, outputFormat, "osage", ext);
330
- };
331
- GraphvizSync.prototype.patchwork = function (dotSource, outputFormat, ext) {
332
- if (outputFormat === void 0) { outputFormat = "svg"; }
293
+ }
294
+ patchwork(dotSource, outputFormat = "svg", ext) {
333
295
  return this.layout(dotSource, outputFormat, "patchwork", ext);
334
- };
335
- GraphvizSync.prototype.twopi = function (dotSource, outputFormat, ext) {
336
- if (outputFormat === void 0) { outputFormat = "svg"; }
296
+ }
297
+ twopi(dotSource, outputFormat = "svg", ext) {
337
298
  return this.layout(dotSource, outputFormat, "twopi", ext);
338
- };
339
- return GraphvizSync;
340
- }());
299
+ }
300
+ }
341
301
  function graphvizSync(wasmFolder, wasmBinary) {
342
- return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(function (wasm) { return new GraphvizSync(wasm); });
302
+ return loadWasm(graphvizlib$1, wasmFolder, wasmBinary).then(wasm => new GraphvizSync(wasm));
343
303
  }
344
304
 
345
305
  exports.GraphvizSync = GraphvizSync;