initial version, can start a server that serves the diff, gen an html file in tmp and open it or generate it in a specific location

This commit is contained in:
Stefan Stefanov 2026-06-05 21:18:42 +03:00
commit 872d29f3e1
6 changed files with 2409 additions and 0 deletions

25
src/client.js Normal file
View file

@ -0,0 +1,25 @@
import { FileTree } from '@pierre/trees';
const dataEl = document.getElementById('diff-files-data');
const files = JSON.parse(dataEl.textContent);
const paths = files.map(f => f.name);
const mount = document.getElementById('file-tree');
mount.style.height = (window.innerHeight - mount.getBoundingClientRect().top) + 'px';
const tree = new FileTree({
paths,
initialExpansion: 'open',
onSelectionChange: (selectedPaths) => {
if (selectedPaths.length !== 1) return;
const id = 'DF-' + selectedPaths[0].replace(/[^a-zA-Z0-9_-]/g, '_');
const el = document.getElementById(id);
if (el) {
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
el.classList.add('diff-highlight');
setTimeout(() => el.classList.remove('diff-highlight'), 1500);
}
},
});
tree.render({ fileTreeContainer: mount });