In this section
- Repokuiper Nav interaction · cosmic / tools/explore/repokuiper/repokuiper-nav.js lines 1–424
- Repokuiper Overlays render · cosmic / tools/explore/repokuiper/repokuiper-overlays.css lines 1–42
Repokuiper Nav
A JavaScript module in the explore folder of Cosmic that parses hash (`parseHash`), makes hash (`makeHash`) and syncs hash (`syncHash`) (units: kV).
interactioncosmic / tools/explore/repokuiper/repokuiper-nav.js · lines 1–424 of 424 · Not reached from any entry point (candidate for review) · pattern openSearch (shared by 2 files)
- What it does
- It draws its content. Defines 41 functions or classes, including parseHash, encPath, makeHash, score, commonAncestor. Side effects: changes the web page (DOM); uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage field_execution (path word 'nav'): on-road and off-road field navigation to the farm gate (access gates, terrain slope, ground-bearing limits, electrical hazards), as Ventus Ltd describes its SatNav work.
- Inputs & outputs
- In: browser storage (getItem); form fields (user input). Out: browser storage (setItem).
- What it achieves
- It parses hash (`parseHash`), makes hash (`makeHash`) and syncs hash (`syncHash`). `repokuiper-nav.js` (K2, WAYFINDER-38): navigation and UX for a Kuiper universe, built on window.KUIPER (CONTRACT v1). It responds to popstate, hashchange and input events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- cosmic · tools/explore/repokuiper · JavaScript module
- Uses
- none found
- Used by
- none found
- Produces
- parseHash, encPath, makeHash, score, commonAncestor, reduced, fit, fname, bodyName, search, add, land
- Defines here
- parseHash, encPath, makeHash, score, commonAncestor, reduced, fit, fname, bodyName, search, add, land, fly, goFile, goFolder, current, syncHash, applyHash, remember, toast, rowHtml, browse, refresh, moveCursor, choose, openSearch, drawTrail, openTrail, closePanels, dismissHint
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 tools/explore/repokuiper/repokuiper-nav.js:1-424 · blob 564d1ef5f11b2f0fcf8a97f338c04267449ff284 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, storage · domain stage: field_execution · users: EPC_contractor, landowner_planner · canonical: unreached_review
// repokuiper-nav.js (K2, WAYFINDER-38): navigation and UX for a Kuiper universe, built on window.KUIPER
// (CONTRACT v1). Ranked search over folders, files and functions; a folder browser with breadcrumbs; smooth
// two-phase travel (pull out to the common ancestor, then dive in); keyboard; deep links (#file=, #folder=, &fn=)
// kept in browser history; a trail of visited places; a one-time onboarding hint; "random star"; phone zoom
// controls and two-finger rotate (only when the core offers cam.r). Positions come from the core; nothing is stored
// but the trail (sessionStorage) and the hint flag (localStorage). Vanilla, no dependencies.
(() => {
'use strict';
// ------------------------------------------------------------------ pure helpers (also unit-tested from node)
function parseHash(h) {
const out = {};
String(h || '').replace(/^#/, '').split('&').forEach((kv) => {
if (!kv) return;
const j = kv.indexOf('='), k = j < 0 ? kv : kv.slice(0, j), v = j < 0 ? '' : kv.slice(j + 1);
try { out[decodeURIComponent(k)] = decodeURIComponent(v.replace(/\+/g, ' ')); } catch (e) { /* malformed: skip */ }
});
return out;
}
const encPath = (p) => String(p).split('/').map(encodeURIComponent).join('/');
function makeHash(kind, path, fn) {
if (kind === 'file') return '#file=' + encPath(path) + (fn ? '&fn=' + encodeURIComponent(fn) : '');
if (kind === 'folder') return path ? '#folder=' + encPath(path) : '';
return '';
}
// score a lowercased haystack against a lowercased query: higher is better, -1 = no match.
// exact name 1000, name prefix 800, name substring 600 (earlier is better), path substring 400, then a
// subsequence match over the path (fuzzy) 0..200 by compactness. Shorter paths win ties.
function score(name, path, q, noFuzzy) {
if (!q) return 0;
let s = -1;
if (name === q) s = 1000;
else if (name.startsWith(q)) s = 800;
else { const k = name.indexOf(q); if (k >= 0) s = 600 - Math.min(100, k); else { const m = path.indexOf(q); if (m >= 0) s = 400 - Math.min(100, m); } }
if (s < 0) {
if (noFuzzy) return -1;
let j = 0, first = -1, lastHit = -1;
for (let i = 0; i < path.length && j < q.length; i++) if (path[i] === q[j]) { if (first < 0) first = i; lastHit = i; j++; }
if (j < q.length) return -1;
s = Math.max(1, 200 - (lastHit - first - q.length + 1) * 4);
}
return s - Math.min(60, path.length / 4);
}
function commonAncestor(a, b, fpar, fdepth) {
while (fdepth[a] > fdepth[b]) a = fpar[a];
while (fdepth[b] > fdepth[a]) b = fpar[b];
while (a !== b && a >= 0 && b >= 0) { a = fpar[a]; b = fpar[b]; }
return a < 0 ? 0 : a;
}
const api = { parseHash, makeHash, score, commonAncestor, encPath };
if (typeof window !== 'undefined') window.__rkNav = api;
if (typeof module !== 'undefined' && module.exports) module.exports = api;
if (typeof window === 'undefined' || !window.KUIPER || typeof document === 'undefined') return;
// ------------------------------------------------------------------ the module
window.KUIPER.use('nav', function nav(K) {
const D = K.D, A = K.arr, idx = !!K.isIndex;
const PAGE = (location.pathname.split('/').pop() || 'index.html');
const reduced = () => !!K.reducedMotion;
const esc = K.esc;
const fit = (f) => { const v = K.view(); return Math.min(v.w, v.h) * 0.46 / Math.max(1e-9, A.fr[f]); };
const fname = (f) => (f === 0 ? (D.repo || 'all repositories') : D.folders[f][0]);
const bodyName = (i) => D.files[i][0];
// ---------------------------------------------------------------- search index (built once, lowercased)
// kinds: 0 folder (i = folder), 1 file (i = body), 2 function (i = body, m = moon index)
const IX = [];
for (let f = 1; f < K.NF; f++) { const p = K.folderPath(f); IX.push([0, f, -1, D.folders[f][0].toLowerCase(), p.toLowerCase()]); }
for (let i = 0; i < K.NB; i++) {
const p = idx ? bodyName(i) : K.bodyPath(i), t = (D.files[i][7] || '').toLowerCase();
IX.push([1, i, -1, bodyName(i).toLowerCase(), (p + ' ' + t).toLowerCase()]);
const fns = D.files[i][11] || [];
for (let m = 0; m < fns.length; m++) { const n = String(fns[m]).split('(')[0]; IX.push([2, i, m, n.toLowerCase(), (n + ' ' + p).toLowerCase()]); }
}
const IXF = IX.filter((e) => e[0] !== 2); // folders and files only
let lastQ = '', lastHits = IX;
function search(q) {
q = q.trim().toLowerCase();
if (!q) return [];
// pass 1: exact / prefix / substring only; pass 2 (fuzzy subsequence) only when pass 1 finds too little.
// Keep a running floor so a common query over ~20k functions does not sort them all.
let res = [];
const add = (s, e) => { res.push([s + (e[0] === 1 ? 5 : e[0] === 0 ? 3 : 0), e]); if (res.length > 600) { res.sort((a, b) => b[0] - a[0]); res.length = 60; } };
// typing extends the query: only the previous query's matches can still match
const pool = q.length < 2 ? IXF : (lastQ && q.startsWith(lastQ)) ? lastHits : IX, hits = [];
for (const e of pool) { const s = score(e[3], e[4], q, true); if (s >= 0) { hits.push(e); add(s, e); } }
if (q.length < 2) { lastQ = ''; lastHits = IX; } else { lastQ = q; lastHits = hits; }
// fuzzy only over files and folders (not ~20k functions), and only when the plain match finds very little
if (res.length < 12 && q.length > 1) {
const seen = new Set(res.map((r) => r[1]));
for (const e of IXF) { if (seen.has(e)) continue; const s = score(e[3], e[4], q); if (s >= 0) add(s, e); }
}
res.sort((a, b) => b[0] - a[0]);
return res.slice(0, 60).map((r) => r[1]);
}
// ---------------------------------------------------------------- flight: pull out to the common ancestor, then dive
let flightTimer = 0, flightToken = 0;
function land(f, i, moon) {
if (i == null || i < 0) { K.closeCard(); K.travel(f); }
else { K.centreOn(i); K.select(i, moon == null ? -1 : moon); }
}
function fly(f, i, moon) {
clearTimeout(flightTimer); const tok = ++flightToken;
if (i != null && i >= 0) f = A.bfo[i];
const from = K.focus, anc = commonAncestor(from, f, A.fpar, A.fdepth);
const hops = (A.fdepth[from] - A.fdepth[anc]) + (A.fdepth[f] - A.fdepth[anc]);
if (reduced() || hops <= 1 || anc === f || anc === from) { land(f, i, moon); return; }
const ms = Math.min(700, 300 + 70 * hops);
K.flyTo(anc, 0, 0, fit(anc) * 0.85, ms);
flightTimer = setTimeout(() => { if (tok === flightToken) land(f, i, moon); }, ms + 40);
}
const goFile = (i, moon) => fly(null, i, moon);
const goFolder = (f) => fly(f, -1);
// ---------------------------------------------------------------- deep links + browser history
let applying = false, syncTimer = 0;
function current() {
if (K.sel >= 0) {
const fns = D.files[K.sel][11] || [];
return makeHash('file', idx ? bodyName(K.sel) : K.bodyPath(K.sel), K.selMoon >= 0 && fns[K.selMoon] ? String(fns[K.selMoon]).split('(')[0] : '');
}
return makeHash('folder', K.focus > 0 ? K.folderPath(K.focus) : '');
}
function syncHash() {
clearTimeout(syncTimer);
syncTimer = setTimeout(() => {
if (applying) return;
const h = current(), now = location.hash;
if (h === now || (!h && !now)) return;
try { history.pushState(null, '', h || (location.pathname + location.search)); } catch (e) { /* file:// or sandbox */ }
}, 80);
}
function applyHash(initial) {
const q = parseHash(location.hash), path = q.file != null ? q.file : q.folder;
if (path == null || path === '') {
if (!initial) { applying = true; K.closeCard(); K.home(); setTimeout(() => { applying = false; }, 120); }
return;
}
const hit = K.findPath(path);
if (!hit) { toast('Not in this universe: ' + path); return; }
applying = true;
if (hit.kind === 'file') {
let moon = -1;
if (q.fn) { const fns = D.files[hit.i][11] || []; moon = fns.findIndex((s) => String(s).split('(')[0] === q.fn); }
initial || reduced() ? land(null, hit.i, moon) : goFile(hit.i, moon);
} else {
initial || reduced() ? land(hit.i, -1) : goFolder(hit.i);
}
setTimeout(() => { applying = false; }, 900);
}
window.addEventListener('popstate', () => applyHash(false));
window.addEventListener('hashchange', () => { if (!applying) applyHash(false); });
// ---------------------------------------------------------------- trail (visited places, this tab only)
const TKEY = 'kuiper-nav-trail:' + PAGE;
let trail = [];
try { trail = JSON.parse(sessionStorage.getItem(TKEY) || '[]').filter((x) => Array.isArray(x)); } catch (e) { trail = []; }
function remember(kind, path) {
if (!path) return;
trail = trail.filter((x) => !(x[0] === kind && x[1] === path));
trail.unshift([kind, path]); if (trail.length > 30) trail.length = 30;
try { sessionStorage.setItem(TKEY, JSON.stringify(trail)); } catch (e) { /* private mode */ }
if (!trailPanel.hidden) drawTrail();
}
// ---------------------------------------------------------------- panels
const searchPanel = K.panel('nav-search'), trailPanel = K.panel('nav-trail'), hintPanel = K.panel('nav-hint');
const toastEl = document.createElement('div'); toastEl.className = 'nav-toast'; toastEl.hidden = true;
toastEl.setAttribute('role', 'status'); document.body.appendChild(toastEl);
let toastTimer = 0;
function toast(msg) { toastEl.textContent = msg; toastEl.hidden = false; clearTimeout(toastTimer); toastTimer = setTimeout(() => { toastEl.hidden = true; }, 2600); }
searchPanel.classList.add('nav-panel');
searchPanel.innerHTML = '<div class="nav-row"><input class="nav-q" type="search" enterkeyhint="go" autocomplete="off" spellcheck="false"'
+ ' aria-label="search this universe" placeholder="' + (idx ? 'repository name' : 'file, folder or function') + '">'
+ '<button class="nav-btn" data-nav="close" title="close (Esc)">×</button></div>'
+ '<div class="nav-crumbs"></div><ol class="nav-list" role="listbox"></ol>';
const qEl = searchPanel.querySelector('.nav-q'), listEl = searchPanel.querySelector('.nav-list'), crumbsEl = searchPanel.querySelector('.nav-crumbs');
let rows = [], cursor = 0, browseAt = 0;
const kindTag = ['folder', '', 'fn'];
function rowHtml(e, n) {
const [k, i, m] = e;
let main, sub;
if (k === 0) { main = esc(D.folders[i][0]) + '/'; sub = esc(K.folderPath(i)) + ' · ' + K.fmt(A.fsub[i]) + ' bodies'; }
else if (k === 1) { main = esc(bodyName(i)); sub = esc(idx ? (D.files[i][7] || '') : K.bodyPath(i)) + ' · ' + K.fmt(D.files[i][3]) + ' lines'; }
else { main = esc(String(D.files[i][11][m]).split('(')[0]) + '()'; sub = 'in ' + esc(idx ? bodyName(i) : K.bodyPath(i)); }
const col = k === 0 ? '' : (D.roles[D.files[i][4]] || ['', '', '#a6adbb'])[2];
return `<li role="option" data-nav-row="${n}"${n === cursor ? ' class="on" aria-selected="true"' : ''}>`
+ `<span class="nav-dot${k === 0 ? ' nav-ring' : ''}"${col ? ` style="background:${esc(col)}"` : ''}></span>`
+ `<span class="nav-main">${main}${kindTag[k] ? ` <em>${kindTag[k]}</em>` : ''}</span><span class="nav-sub">${sub}</span></li>`;
}
function browse(f) { // empty query: the folder browser, with breadcrumbs
browseAt = f;
const chain = []; for (let j = f; j >= 0; j = A.fpar[j]) chain.unshift(j);
crumbsEl.innerHTML = chain.map((j) => `<a href="#" data-nav-browse="${j}">${esc(fname(j))}</a>`).join(' / ')
+ (f > 0 ? ` <a href="#" class="nav-go" data-nav-gofolder="${f}">travel here →</a>` : '');
crumbsEl.hidden = false;
const kids = [...A.fkids[f]].sort((a, b) => D.folders[a][0].localeCompare(D.folders[b][0]));
const files = []; for (let i = 0; i < K.NB; i++) if (A.bfo[i] === f) files.push(i);
files.sort((a, b) => bodyName(a).localeCompare(bodyName(b)));
rows = kids.map((j) => [0, j, -1]).concat(files.map((i) => [1, i, -1]));
cursor = Math.min(cursor, Math.max(0, rows.length - 1));
listEl.innerHTML = rows.slice(0, 400).map(rowHtml).join('') || '<li class="nav-empty">empty folder</li>';
}
function refresh() {
const q = qEl.value;
if (!q.trim()) { browse(browseAt); return; }
crumbsEl.hidden = true;
rows = search(q); cursor = Math.min(cursor, Math.max(0, rows.length - 1));
listEl.innerHTML = rows.map(rowHtml).join('') || '<li class="nav-empty">nothing matches</li>';
}
function moveCursor(d) {
if (!rows.length) return;
cursor = (cursor + d + rows.length) % rows.length;
listEl.querySelectorAll('li.on').forEach((li) => { li.classList.remove('on'); li.removeAttribute('aria-selected'); });
const li = listEl.querySelector(`[data-nav-row="${cursor}"]`);
if (li) { li.classList.add('on'); li.setAttribute('aria-selected', 'true'); li.scrollIntoView({ block: 'nearest' }); }
}
function choose(n, keepOpen) {
const e = rows[n]; if (!e) return;
if (!qEl.value.trim() && e[0] === 0 && keepOpen) { cursor = 0; browse(e[1]); return; } // browsing: step into the folder
closePanels();
if (e[0] === 0) goFolder(e[1]); else goFile(e[1], e[0] === 2 ? e[2] : -1);
}
function openSearch() {
trailPanel.hidden = true;
if (searchPanel.hidden) { qEl.value = ''; cursor = 0; browseAt = K.sel >= 0 ? A.bfo[K.sel] : K.focus; refresh(); }
searchPanel.hidden = false; K.setButtonOn('nav-search', true);
setTimeout(() => qEl.focus(), 0);
}
let rq = 0;
qEl.addEventListener('input', () => { cursor = 0; cancelAnimationFrame(rq); rq = requestAnimationFrame(refresh); });
qEl.addEventListener('keydown', (e) => {
e.stopPropagation(); // typing here must never reach the universe's keys
if (e.key === 'ArrowDown') { e.preventDefault(); moveCursor(1); }
else if (e.key === 'ArrowUp') { e.preventDefault(); moveCursor(-1); }
else if (e.key === 'Enter') { e.preventDefault(); choose(cursor, true); }
else if (e.key === 'Escape') { e.preventDefault(); closePanels(); }
else if (e.key === 'Backspace' && !qEl.value && browseAt > 0) { e.preventDefault(); cursor = 0; browse(A.fpar[browseAt]); }
});
trailPanel.classList.add('nav-panel');
function drawTrail() {
const items = trail.map((x, n) => {
const hit = K.findPath(x[1]); if (!hit) return '';
const label = x[0] === 'file' ? esc(x[1].split('/').pop()) : esc(x[1].split('/').pop()) + '/';
return `<li data-nav-trail="${n}"><span class="nav-main">${label}</span><span class="nav-sub">${esc(x[1])}</span></li>`;
}).join('');
trailPanel.innerHTML = '<div class="nav-row"><b class="nav-title">Trail</b><span class="nav-sub">places visited in this tab, newest first</span>'
+ '<button class="nav-btn" data-nav="close" title="close (Esc)">×</button></div>'
+ `<ol class="nav-list">${items || '<li class="nav-empty">nothing yet: tap a star or travel into a ring</li>'}</ol>`
+ (items ? '<div class="nav-row"><button class="nav-btn nav-wide" data-nav="clear-trail">clear trail</button></div>' : '');
}
function openTrail() {
searchPanel.hidden = true; K.setButtonOn('nav-search', false);
const show = trailPanel.hidden; trailPanel.hidden = !show; K.setButtonOn('nav-trail', show);
if (show) drawTrail();
}
function closePanels() {
const was = !searchPanel.hidden || !trailPanel.hidden || !hintPanel.hidden;
searchPanel.hidden = true; trailPanel.hidden = true; dismissHint();
K.setButtonOn('nav-search', false); K.setButtonOn('nav-trail', false);
if (document.activeElement === qEl) qEl.blur();
return was;
}
// ---------------------------------------------------------------- onboarding hint (once per browser)
const HKEY = 'kuiper-nav-hint-v1';
let hintSeen = true; try { hintSeen = localStorage.getItem(HKEY) === '1'; } catch (e) { hintSeen = true; }
hintPanel.classList.add('nav-hint');
hintPanel.innerHTML = idx
? '<p><b>Every star is a repository.</b> Tap one for its card, then open its own universe.</p>'
+ '<p>Pinch or scroll to zoom, drag to pan. <b>Search</b> finds a repository by name; <b>random</b> picks one for you.</p>'
+ '<button class="nav-btn nav-wide" data-nav="hint-ok">got it</button>'
: '<p><b>Every star is a file; every ring is a folder.</b> Tap a star for its card. Tap inside a ring to travel in; <b>back</b> pulls out.</p>'
+ '<p>Pinch or scroll to zoom, drag to pan. <b>Search</b> finds any file, folder or function; <b>random</b> takes you somewhere new.</p>'
+ '<p class="nav-sub">Keys: / search, r random, t trail, arrows pan, [ ] neighbours, y copy link, c colour modes, ? the law.</p>'
+ '<button class="nav-btn nav-wide" data-nav="hint-ok">got it</button>';
function dismissHint() {
if (hintPanel.hidden) return;
hintPanel.hidden = true; try { localStorage.setItem(HKEY, '1'); } catch (e) { /* ignore */ }
}
// ---------------------------------------------------------------- toolbar buttons and phone controls
K.addButton({ id: 'nav-search', label: 'search', title: 'search files, folders and functions (/ or f)', toggle: true,
onClick: (on) => (searchPanel.hidden ? openSearch() : closePanels()) });
K.addButton({ id: 'nav-random', label: 'random', title: 'fly to a random star (r)', onClick: () => randomStar() });
K.addButton({ id: 'nav-trail', label: 'trail', title: 'places visited (t)', toggle: true, onClick: () => openTrail() });
const canRotate = !!(K.cam && 'r' in K.cam);
const pad = document.createElement('div');
pad.className = 'nav-pad'; pad.setAttribute('aria-label', 'zoom controls');
pad.innerHTML = '<button class="nav-btn" data-nav="zin" title="zoom in (+)" aria-label="zoom in">+</button>'
+ '<button class="nav-btn" data-nav="zout" title="zoom out (-)" aria-label="zoom out">−</button>'
+ (canRotate ? '<button class="nav-btn" data-nav="rot0" title="reset rotation" aria-label="reset rotation">N</button>' : '');
document.body.appendChild(pad);
function placePad() {
const hud = document.getElementById('hud'); // read its geometry only: the toolbar may have wrapped after buttons were added
const top = Math.max(K.safeTop || 0, hud ? Math.round(hud.getBoundingClientRect().bottom) : 0) + 8;
pad.style.top = top + 'px';
for (const p of [searchPanel, trailPanel]) p.style.top = top - 4 + 'px';
pad.classList.toggle('nav-pad-card', K.sel >= 0 && K.W >= 760);
}
placePad(); requestAnimationFrame(placePad);
K.on('resize', placePad);
function zoomBy(f) {
const v = K.view();
if (reduced()) { K.zoomAt(v.cx, v.cy, f); K.redraw(); return; }
let n = 0; const steps = 8, k = Math.pow(f, 1 / steps);
const tick = () => { K.zoomAt(v.cx, v.cy, k); K.redraw(); if (++n < steps) requestAnimationFrame(tick); };
requestAnimationFrame(tick);
}
function pan(dx, dy) { const c = K.cam; K.setCam({ x: c.x + dx / c.s, y: c.y + dy / c.s, s: c.s }); K.redraw(); }
function rotate(da) { if (!canRotate) return false; K.setCam({ r: (K.cam.r || 0) + da }); K.redraw(); return true; }
function randomStar() {
if (!K.NB) return;
const recent = new Set(trail.slice(0, 10).map((x) => x[1]));
let i = 0;
for (let tries = 0; tries < 12; tries++) {
i = Math.floor(Math.random() * K.NB);
if (!recent.has(idx ? bodyName(i) : K.bodyPath(i))) break;
}
closePanels(); goFile(i, -1);
}
function neighbour(d) {
const f = K.sel >= 0 ? A.bfo[K.sel] : K.focus, sib = [];
for (let i = 0; i < K.NB; i++) if (A.bfo[i] === f) sib.push(i);
if (!sib.length) { toast('No stars directly in ' + fname(f) + '/'); return; }
sib.sort((a, b) => bodyName(a).localeCompare(bodyName(b)));
const at = sib.indexOf(K.sel), n = at < 0 ? (d > 0 ? 0 : sib.length - 1) : (at + d + sib.length) % sib.length;
K.centreOn(sib[n]); K.select(sib[n], -1);
}
function copyLink() {
const url = location.href.split('#')[0] + current();
const ok = () => toast('Link copied: ' + (current() || 'this universe'));
if (navigator.clipboard && navigator.clipboard.writeText) navigator.clipboard.writeText(url).then(ok, () => toast(url));
else toast(url);
}
// ---------------------------------------------------------------- card section: the body's place, its neighbours, a link
K.addCardSection('nav', (i, moon) => {
if (idx) return `<div class="nav-card"><a href="#" data-nav="copy">copy link</a></div>`;
const chain = []; for (let j = A.bfo[i]; j >= 0; j = A.fpar[j]) chain.unshift(j);
return '<div class="nav-card"><div class="nav-sub">where: ' + chain.map((j) => `<a href="#" data-nav-gofolder="${j}">${esc(fname(j))}</a>`).join(' / ')
+ '</div><div class="nav-links"><a href="#" data-nav="prev">← neighbour</a><a href="#" data-nav="next">neighbour →</a>'
+ '<a href="#" data-nav="copy">copy link</a></div></div>';
});
// ---------------------------------------------------------------- keys (registered keys run before the core's)
const keymap = {
'/': () => { openSearch(); return true; },
'f': () => { if (searchPanel.hidden) openSearch(); else closePanels(); return true; },
'r': () => { randomStar(); return true; },
't': () => { openTrail(); return true; },
'y': () => { copyLink(); return true; }, // y: copy link ('c' is the colour modes of the overlays module)
'[': () => { neighbour(-1); return true; },
']': () => { neighbour(1); return true; },
'ArrowLeft': (e) => { pan(-(e && e.shiftKey ? 240 : 80), 0); return true; },
'ArrowRight': (e) => { pan(e && e.shiftKey ? 240 : 80, 0); return true; },
'ArrowUp': (e) => { pan(0, -(e && e.shiftKey ? 240 : 80)); return true; },
'ArrowDown': (e) => { pan(0, e && e.shiftKey ? 240 : 80); return true; },
',': () => rotate(-Math.PI / 24),
'.': () => rotate(Math.PI / 24),
'Escape': () => { closePanels(); return false; }, // let the core close its own card too
};
for (const k in keymap) K.addKey(k, (ev) => { if (ev && ev.preventDefault && k !== 'Escape' && k !== ',' && k !== '.') ev.preventDefault(); return keymap[k](ev); });
// ---------------------------------------------------------------- two-finger rotate (only when the core has cam.r)
if (canRotate) {
const cv = document.getElementById('sky'), P = new Map(); let rot = null;
const ang = () => { const [a, b] = [...P.values()]; return Math.atan2(b[1] - a[1], b[0] - a[0]); };
cv.addEventListener('pointerdown', (e) => { P.set(e.pointerId, [e.clientX, e.clientY]); if (P.size === 2) rot = { a: ang(), r: K.cam.r || 0 }; });
cv.addEventListener('pointermove', (e) => {
if (!P.has(e.pointerId)) return; P.set(e.pointerId, [e.clientX, e.clientY]);
if (rot && P.size === 2) { let d = ang() - rot.a; if (Math.abs(d) > 0.06) K.setCam({ r: rot.r + d }); }
});
const up = (e) => { P.delete(e.pointerId); if (P.size < 2) rot = null; };
cv.addEventListener('pointerup', up); cv.addEventListener('pointercancel', up);
}
// ---------------------------------------------------------------- clicks inside nav UI
document.addEventListener('click', (e) => {
const el = e.target.closest('[data-nav],[data-nav-row],[data-nav-trail],[data-nav-browse],[data-nav-gofolder]');
if (!el) { if (!hintPanel.hidden && !e.target.closest('.kp')) dismissHint(); return; }
e.preventDefault(); e.stopPropagation();
const d = el.dataset;
if (d.navRow != null) { cursor = +d.navRow; choose(cursor, true); return; }
if (d.navTrail != null) { const x = trail[+d.navTrail]; const hit = x && K.findPath(x[1]); if (hit) { closePanels(); hit.kind === 'file' ? goFile(hit.i, -1) : goFolder(hit.i); } return; }
if (d.navBrowse != null) { cursor = 0; qEl.value = ''; browse(+d.navBrowse); return; }
if (d.navGofolder != null) { closePanels(); goFolder(+d.navGofolder); return; }
switch (d.nav) {
case 'close': closePanels(); break;
case 'clear-trail': trail = []; try { sessionStorage.removeItem(TKEY); } catch (x) { /* ignore */ } drawTrail(); break;
case 'hint-ok': dismissHint(); break;
case 'zin': zoomBy(1.8); break;
case 'zout': zoomBy(1 / 1.8); break;
case 'rot0': K.setCam({ r: 0 }); K.redraw(); break;
case 'prev': if (K.sel >= 0) neighbour(-1); break;
case 'next': if (K.sel >= 0) neighbour(1); break;
case 'copy': copyLink(); break;
}
}, true);
// ---------------------------------------------------------------- events -> hash, trail, controls
K.on('select', (i) => { remember('file', idx ? bodyName(i) : K.bodyPath(i)); syncHash(); placePad(); dismissHint(); });
K.on('deselect', () => { syncHash(); placePad(); });
K.on('travel', (f) => { if (f > 0) remember('folder', K.folderPath(f)); syncHash(); });
K.on('tap', () => { dismissHint(); return false; });
// ---------------------------------------------------------------- start
if (location.hash) applyHash(true);
if (!hintSeen && !location.hash) hintPanel.hidden = false;
// self-test surface for Playwright (read-only helpers)
window.__rkNav = Object.assign(api, {
ready: true, search: (q) => search(q).map((e) => [e[0], e[1], e[2]]), goFile, goFolder, randomStar,
openSearch, closePanels, current, trail: () => trail.slice(), canRotate,
});
});
})();Repokuiper Overlays
A style sheet in the explore folder of Cosmic.
rendercosmic / tools/explore/repokuiper/repokuiper-overlays.css · lines 1–42 of 42 · Not reached from any entry point (candidate for review)
- What it does
- Side effects: changes the web page (DOM).
- What it achieves
- `repokuiper-overlays.css` (K3, ALBEDO-47): mode picker (#kp-ov), legend content (.ov-leg) and card lines (.ov-card).
- Why it matters
- No other file in the estate was found to import it.
- Application
- cosmic · tools/explore/repokuiper · style sheet
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- cosmic@51bebf892d63a617408bc5e25b270b9f893e9c03 tools/explore/repokuiper/repokuiper-overlays.css:1-42 · blob c8e09a132811148b11a55081c6fc709405c8a28d · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: unknown · users: none · canonical: unreached_review
/* repokuiper-overlays.css (K3, ALBEDO-47): mode picker (#kp-ov), legend content (.ov-leg) and card lines (.ov-card).
Site palette only; 44px taps on phones; nothing wider than the screen. */
#kp-ov { background: #0b0e14; border: 1px solid #2f343d; border-radius: 8px; padding: 8px 10px; color: #fff;
max-width: min(340px, calc(100vw - 16px)); max-height: 60vh; overflow-y: auto; box-sizing: border-box; }
#kp-ov .ov-h { margin: 0 0 6px; color: #a6adbb; font-size: 13px; }
#kp-ov .ov-modes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 4px; }
#kp-ov .ov-modes button { width: 100%; min-height: 44px; text-align: left; padding: 8px 10px; font: inherit; font-size: 14px;
color: #fff; background: #000; border: 1px solid #2f343d; border-radius: 6px; cursor: pointer; }
#kp-ov .ov-modes button[aria-pressed="true"] { border-color: #00ffff; color: #00ffff; }
#kp-ov .ov-modes button:focus-visible, .ov-leg button:focus-visible { outline: 2px solid #66ccff; outline-offset: 1px; }
#kp-ov .ov-note { margin: 8px 0 0; color: #a6adbb; font-size: 12px; line-height: 1.35; }
.ov-leg { color: #fff; font-size: 12px; line-height: 1.3; max-width: min(320px, calc(100vw - 16px)); box-sizing: border-box; }
.ov-leg b { color: #00ffff; font-weight: 600; }
.ov-leg .ov-state { color: #a6adbb; }
.ov-leg ol { list-style: none; margin: 4px 0; padding: 0; max-height: 34vh; overflow-y: auto; }
.ov-leg li { display: flex; align-items: center; gap: 6px; }
.ov-leg li.ov-off { opacity: 0.45; }
.ov-leg li.ov-on button { color: #00ffff; }
.ov-leg button { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; min-height: 32px; padding: 2px 4px;
font: inherit; color: inherit; background: none; border: 0; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.ov-leg button:disabled { cursor: default; }
.ov-leg i { flex: none; width: 12px; height: 12px; border-radius: 50%; border: 1px solid #2f343d; }
.ov-leg .ov-n { color: #a6adbb; margin-left: auto; padding-left: 6px; }
.ov-leg .ov-hub, .ov-leg .ov-key a { color: #66ccff; }
.ov-key { margin: 4px 0 0; color: #a6adbb; font-size: 11px; overflow-wrap: anywhere; }
.ov-card { border-top: 1px solid #2f343d; margin-top: 8px; padding-top: 6px; font-size: 13px; color: #fff; }
.ov-card ul { list-style: none; margin: 0; padding: 0; }
.ov-card li { margin: 3px 0; color: #a6adbb; overflow-wrap: anywhere; }
.ov-card li b { color: #fff; }
.ov-card li.ov-cur { color: #fff; border-left: 2px solid #00ffff; padding-left: 6px; }
.ov-card a { color: #66ccff; cursor: pointer; }
.ov-card .ov-id { color: #66ccff; font-size: 11px; }
.ov-card code { color: #00ffff; font-size: 12px; }
.ov-card .ov-state { color: #a6adbb; font-size: 11px; letter-spacing: 0.04em; }
@media (max-width: 759px) {
.ov-leg button { min-height: 44px; }
.ov-leg ol { max-height: 26vh; }
}
@media (prefers-reduced-motion: reduce) { #kp-ov * { transition: none !important; } }