Skip to content

Commit

Permalink
port generate-nodes.js to ES modules and @hpcc-js/wasm 2.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
magjac committed Dec 17, 2023
1 parent aefaeaa commit 9340d00
Showing 1 changed file with 19 additions and 38 deletions.
57 changes: 19 additions & 38 deletions bin/generate-nodes.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
#! /usr/bin/env node

var hpccWasm = require("../node_modules/@hpcc-js/wasm/dist/index");
var fs_promises = require("fs").promises;

global.fetch = function(filename) {
return fs_promises.open(filename, 'r').then((filehandle) => {
return filehandle.readFile().then(data => {
return {
ok: true,
arrayBuffer: () => data,
};
});
});
}

global.document = {
"currentScript": {
src: './node_modules/@hpcc-js/wasm/dist/index.js'
}
};
import { Graphviz } from "@hpcc-js/wasm/graphviz";

const graphviz = await Graphviz.load();

shapes = [
const shapes = [
"box",
"polygon",
"ellipse",
Expand Down Expand Up @@ -93,29 +76,27 @@ shapes = [

console.log('const shapes = {');

hpccWasm.graphvizSync().then(graphviz => {
for (i = 0; i < shapes.length; i++) {
for (let i = 0; i < shapes.length; i++) {

shape = shapes[i];
const shape = shapes[i];

dotSrc = `digraph "" {
${shape} [shape=${shape} style=filled label=""]
}`;
const dotSrc = `digraph "" {
${shape} [shape=${shape} style=filled label=""]
}`;

var svg = graphviz.layout(dotSrc, 'svg', 'dot');
var svg = graphviz.layout(dotSrc, 'svg', 'dot');

console.log(`${shape}: \`${svg}\`,`);
}
console.log(`${shape}: \`${svg}\`,`);
}

dotSrc = `digraph "" {
"(default)" [style="filled, dashed" fillcolor="white" label=""]
}`;
const dotSrc = `digraph "" {
"(default)" [style="filled, dashed" fillcolor="white" label=""]
}`;

var svg = graphviz.layout(dotSrc, 'svg' , 'dot');
var svg = graphviz.layout(dotSrc, 'svg' , 'dot');

console.log(`'(default)': \`${svg}\`,`);
console.log(`'(default)': \`${svg}\`,`);

console.log('};');
console.log('');
console.log('export {shapes};');
});
console.log('};');
console.log('');
console.log('export {shapes};');

0 comments on commit 9340d00

Please sign in to comment.