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