/** * tree.ts — File tree browser page module. * * The tree is fully SSR'd. This module only handles the branch selector * navigation, which requires JS to redirect on change. * * Registered as: window.MusePages['tree'] */ export function initTree(data: Record): void { const base = String(data.base ?? ''); const dirPath = String(data.dir_path ?? ''); const pathSuffix = dirPath ? '/' + dirPath : ''; const sel = document.getElementById('branch-sel') as HTMLSelectElement | null; sel?.addEventListener('change', () => { window.location.href = base + '/tree/' + encodeURIComponent(sel.value) + pathSuffix; }); }