From 5f8da04cd8a823f699665bb1fc1d07944eb89117 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 17 May 2024 18:41:02 +0200 Subject: [PATCH] remove graphviz --- examples/buildless/tidal.html | 96 +++++++++++++++++++++++++++++++++++ packages/tidal/graph.mjs | 43 ---------------- packages/tidal/index.html | 1 - packages/tidal/main.js | 9 ---- packages/tidal/package.json | 2 - 5 files changed, 96 insertions(+), 55 deletions(-) create mode 100644 examples/buildless/tidal.html delete mode 100644 packages/tidal/graph.mjs diff --git a/examples/buildless/tidal.html b/examples/buildless/tidal.html new file mode 100644 index 00000000..459ad0ed --- /dev/null +++ b/examples/buildless/tidal.html @@ -0,0 +1,96 @@ + + + + + + tidal.html + + + +

+    
+    
+    
+  
+
diff --git a/packages/tidal/graph.mjs b/packages/tidal/graph.mjs
deleted file mode 100644
index bac3d135..00000000
--- a/packages/tidal/graph.mjs
+++ /dev/null
@@ -1,43 +0,0 @@
-import { Graphviz } from '@hpcc-js/wasm';
-import toDot from 'jgf-dot';
-
-const graphvizLoaded = Graphviz.load();
-
-function walk(node, branch = [0], parent) {
-  let nodes = [];
-  let edges = [];
-  const color = 'white';
-  const current = {
-    id: branch.join('-'),
-    color,
-    fontcolor: color,
-    label: node.type.replace('\\', 'lambda'), // backslash kills graphviz..
-  };
-  nodes.push(current);
-  parent && edges.push({ source: parent.id, target: current.id, color });
-  if (node.children.length) {
-    node.children.forEach((child, j) => {
-      const { nodes: childNodes, edges: childEdges } = walk(child, branch.concat([j]), current);
-      nodes = nodes.concat(childNodes || []);
-      edges = edges.concat(childEdges || []);
-    });
-  }
-  return { nodes, edges };
-}
-
-export async function renderGraph(tree, container) {
-  const { nodes, edges } = walk(tree.rootNode);
-  const graphviz = await graphvizLoaded;
-  let dot = toDot({
-    graph: {
-      nodes,
-      edges,
-    },
-  });
-  dot = dot.split('\n');
-  dot.splice(1, 0, 'bgcolor="transparent"');
-  dot.splice(1, 0, 'color="white"');
-  dot = dot.join('\n');
-  const svg = await graphviz.layout(dot, 'svg', 'dot', {});
-  container.innerHTML = svg;
-}
diff --git a/packages/tidal/index.html b/packages/tidal/index.html
index 532bce3d..cfa818b0 100644
--- a/packages/tidal/index.html
+++ b/packages/tidal/index.html
@@ -23,7 +23,6 @@
   
     
     

-    
diff --git a/packages/tidal/main.js b/packages/tidal/main.js index 0b2ac7d5..0d948504 100644 --- a/packages/tidal/main.js +++ b/packages/tidal/main.js @@ -1,12 +1,9 @@ import { run, parse } from 'hs2js'; -import { renderGraph } from './graph.mjs'; import { initStrudel, reify, late, samples, stack } from '@strudel/web'; initStrudel({ prebake: () => samples('github:tidalcycles/dirt-samples'), }); -const graphContainer = document.getElementById('graph'); - const textarea = document.getElementById('code'); if (window.location.hash) { textarea.value = atob(window.location.hash.slice(1)); @@ -60,12 +57,6 @@ async function update() { } console.log('parsed tree'); console.log(tree.rootNode.toString()); - try { - renderGraph(tree, graphContainer); - } catch (err) { - console.warn('could not render graph'); - console.error(err); - } try { let patterns = {}; window.p = (name, pattern) => { diff --git a/packages/tidal/package.json b/packages/tidal/package.json index 3cab8182..0e2d8aa5 100644 --- a/packages/tidal/package.json +++ b/packages/tidal/package.json @@ -27,8 +27,6 @@ }, "homepage": "https://github.com/tidalcycles/strudel#readme", "dependencies": { - "@hpcc-js/wasm": "^2.15.3", - "jgf-dot": "^1.1.1", "@strudel/web": "workspace:*", "hs2js": "workspace:*" },