diff --git a/Dockerfile b/Dockerfile index a71c86e..a4076c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,6 +38,8 @@ WORKDIR /app COPY . . # Build the application +# Note: fix-links.sh rewrites asset paths for GitHub Pages (/simplicity-webide/ subdirectory). +# For local Docker development, comment out "sh fix-links.sh" below. RUN trunk build --release && \ sh fix-links.sh diff --git a/flake.nix b/flake.nix index 8301784..d3af3d1 100644 --- a/flake.nix +++ b/flake.nix @@ -18,6 +18,7 @@ "x86_64-linux" "aarch64-linux" "x86_64-darwin" + "aarch64-darwin" ] (system: let overlays = [ diff --git a/index.html b/index.html index f3225a8..249b64c 100644 --- a/index.html +++ b/index.html @@ -21,6 +21,10 @@ + + + +
diff --git a/src/assets/js/dag_viewer.js b/src/assets/js/dag_viewer.js new file mode 100644 index 0000000..d17b0c1 --- /dev/null +++ b/src/assets/js/dag_viewer.js @@ -0,0 +1,217 @@ +// DAG Viewer using D3.js for Simplicity program visualization + +let dagSvg, dagZoom, dagZoomInitialTransform; +let dagRenderedFor = null; // Track which JSON we've rendered to avoid re-renders + +// Color scheme for different node types +const kindColors = { + jet: '#ff9517', // Orange - jets are important + leaf: '#4ade80', // Green - leaf nodes (witness, word, fail) + plumbing: '#6b7280', // Gray - structural nodes (iden, unit, comp, take, drop) + sum: '#8b5cf6', // Purple - sum types (injl, injr, case) + product: '#3b82f6', // Blue - product types (pair) + assertion: '#ef4444', // Red - assertions + advanced: '#f59e0b', // Amber - advanced (disconnect) +}; + +// Make renderDag available globally for Rust to call +window.renderDag = function(containerId, dagJson) { + const container = document.getElementById(containerId); + if (!container) return; + + if (dagRenderedFor === dagJson && container.querySelector('svg')) { + return; + } + dagRenderedFor = dagJson; + + let dag; + try { + dag = JSON.parse(dagJson); + } catch (e) { + console.error('Failed to parse DAG JSON:', e); + return; + } + + if (!dag.nodes || dag.nodes.length === 0) { + container.innerHTML = '