@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/README.md +28 -7
- package/bin/cli.js +21 -1
- package/dist/expat.es6.js +41 -47
- package/dist/expat.es6.js.map +1 -1
- package/dist/expat.js +41 -47
- package/dist/expat.js.map +1 -1
- package/dist/expat.node.es6.js +41 -47
- package/dist/expat.node.es6.js.map +1 -1
- package/dist/expat.node.js +41 -47
- package/dist/expat.node.js.map +1 -1
- package/dist/graphviz.es6.js +57 -91
- package/dist/graphviz.es6.js.map +1 -1
- package/dist/graphviz.js +57 -91
- package/dist/graphviz.js.map +1 -1
- package/dist/graphviz.node.es6.js +57 -91
- package/dist/graphviz.node.es6.js.map +1 -1
- package/dist/graphviz.node.js +57 -91
- package/dist/graphviz.node.js.map +1 -1
- package/dist/graphvizlib.wasm +0 -0
- package/dist/index.es6.js +91 -131
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +91 -131
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.node.es6.js +91 -131
- package/dist/index.node.es6.js.map +1 -1
- package/dist/index.node.js +91 -131
- package/dist/index.node.js.map +1 -1
- package/package.json +13 -13
package/dist/index.node.es6.js
CHANGED
|
@@ -38,10 +38,10 @@ module.exports = cpp;
|
|
|
38
38
|
|
|
39
39
|
var expatlib_node = expatlib_node$1.exports;
|
|
40
40
|
|
|
41
|
-
var expatlib = /*#__PURE__*/
|
|
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
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
85
|
-
locateFile:
|
|
86
|
-
return
|
|
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
|
-
|
|
95
|
-
|
|
94
|
+
class StackElement {
|
|
95
|
+
constructor(tag, attrs) {
|
|
96
96
|
this.tag = tag;
|
|
97
97
|
this.attrs = attrs;
|
|
98
98
|
this._content = "";
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
function StackParser() {
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
class StackParser {
|
|
108
|
+
constructor() {
|
|
114
109
|
this._stack = [];
|
|
115
110
|
}
|
|
116
|
-
|
|
111
|
+
parse(xml, wasmFolder, wasmBinary) {
|
|
117
112
|
return parse(xml, this, wasmFolder, wasmBinary);
|
|
118
|
-
}
|
|
119
|
-
|
|
113
|
+
}
|
|
114
|
+
top() {
|
|
120
115
|
return this._stack[this._stack.length - 1];
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
}
|
|
117
|
+
startElement(tag, attrs) {
|
|
118
|
+
const retVal = new StackElement(tag, attrs);
|
|
124
119
|
this._stack.push(retVal);
|
|
125
120
|
return retVal;
|
|
126
|
-
}
|
|
127
|
-
|
|
121
|
+
}
|
|
122
|
+
endElement(tag) {
|
|
128
123
|
return this._stack.pop();
|
|
129
|
-
}
|
|
130
|
-
|
|
124
|
+
}
|
|
125
|
+
characterData(content) {
|
|
131
126
|
this.top().appendContent(content);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
}());
|
|
127
|
+
}
|
|
128
|
+
}
|
|
135
129
|
function parseAttrs(attrs) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
keys.split(sep2).filter(
|
|
141
|
-
|
|
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(
|
|
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(
|
|
153
|
-
|
|
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
|
-
|
|
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__*/
|
|
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
|
-
|
|
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:
|
|
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
|
-
|
|
229
|
-
|
|
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(
|
|
213
|
+
return loadWasm(graphvizlib, wasmFolder, wasmBinary).then(module => {
|
|
233
214
|
return module.Graphviz.prototype.version();
|
|
234
215
|
});
|
|
235
216
|
}
|
|
236
|
-
|
|
237
|
-
layout
|
|
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(
|
|
243
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
287
|
-
|
|
257
|
+
class GraphvizSync {
|
|
258
|
+
constructor(_wasm) {
|
|
288
259
|
this._wasm = _wasm;
|
|
289
260
|
}
|
|
290
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
337
|
-
}());
|
|
296
|
+
}
|
|
297
|
+
}
|
|
338
298
|
function graphvizSync(wasmFolder, wasmBinary) {
|
|
339
|
-
return loadWasm(graphvizlib, wasmFolder, wasmBinary).then(
|
|
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 };
|