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