@youtyan/code-viewer 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/web/app.js +12 -31
- package/web/index.html +0 -1
- package/web/style.css +0 -22
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -241,7 +241,6 @@
|
|
|
241
241
|
collapsed: false,
|
|
242
242
|
files: [],
|
|
243
243
|
activeFile: null,
|
|
244
|
-
autoReload: localStorage.getItem("gdp:auto-reload") !== "0",
|
|
245
244
|
hideTests: localStorage.getItem("gdp:hide-tests") === "1",
|
|
246
245
|
syntaxHighlight: localStorage.getItem("gdp:syntax-highlight") !== "0",
|
|
247
246
|
viewedFiles: new Set(JSON.parse(localStorage.getItem("gdp:viewed-files") || "[]")),
|
|
@@ -764,8 +763,13 @@
|
|
|
764
763
|
const target = $("#diff");
|
|
765
764
|
const empty = $("#empty");
|
|
766
765
|
if (!newFiles.length) {
|
|
767
|
-
|
|
768
|
-
|
|
766
|
+
if (STATE.route.screen === "file") {
|
|
767
|
+
empty.classList.add("hidden");
|
|
768
|
+
applySourceRouteToShell();
|
|
769
|
+
} else {
|
|
770
|
+
empty.classList.remove("hidden");
|
|
771
|
+
target.replaceChildren();
|
|
772
|
+
}
|
|
769
773
|
LOAD_QUEUE.length = 0;
|
|
770
774
|
return;
|
|
771
775
|
}
|
|
@@ -2672,7 +2676,7 @@
|
|
|
2672
2676
|
syncHeaderMenu();
|
|
2673
2677
|
}).catch(() => setStatus("error"));
|
|
2674
2678
|
}
|
|
2675
|
-
function load(
|
|
2679
|
+
function load() {
|
|
2676
2680
|
if (STATE.route.screen === "repo")
|
|
2677
2681
|
return loadRepo();
|
|
2678
2682
|
setStatus("refreshing");
|
|
@@ -2683,8 +2687,6 @@
|
|
|
2683
2687
|
params.set("from", STATE.from);
|
|
2684
2688
|
if (STATE.to)
|
|
2685
2689
|
params.set("to", STATE.to);
|
|
2686
|
-
if (opts && opts.nocache)
|
|
2687
|
-
params.set("nocache", "1");
|
|
2688
2690
|
const url = "/diff.json" + (params.toString() ? "?" + params.toString() : "");
|
|
2689
2691
|
return trackLoad(fetch(url).then((r) => r.json())).then((data) => {
|
|
2690
2692
|
renderShell(data);
|
|
@@ -2693,7 +2695,10 @@
|
|
|
2693
2695
|
}
|
|
2694
2696
|
if (STATE.route.screen === "repo")
|
|
2695
2697
|
loadRepo();
|
|
2696
|
-
else
|
|
2698
|
+
else if (STATE.route.screen === "file" && STATE.route.view === "blob") {
|
|
2699
|
+
setStatus("live");
|
|
2700
|
+
applySourceRouteToShell();
|
|
2701
|
+
} else
|
|
2697
2702
|
load();
|
|
2698
2703
|
function syncRefInputs() {
|
|
2699
2704
|
const fi = $("#ref-from"), ti = $("#ref-to");
|
|
@@ -2970,31 +2975,7 @@
|
|
|
2970
2975
|
setTimeout(() => btn.classList.remove("spinning"), 200);
|
|
2971
2976
|
});
|
|
2972
2977
|
});
|
|
2973
|
-
const AUTO_RELOAD_MS = 3000;
|
|
2974
|
-
let autoTimer = null;
|
|
2975
|
-
function setAutoReload(on) {
|
|
2976
|
-
STATE.autoReload = on;
|
|
2977
|
-
localStorage.setItem("gdp:auto-reload", on ? "1" : "0");
|
|
2978
|
-
const btn = $("#auto-reload");
|
|
2979
|
-
if (btn) {
|
|
2980
|
-
btn.classList.toggle("active", on);
|
|
2981
|
-
btn.setAttribute("aria-pressed", on ? "true" : "false");
|
|
2982
|
-
}
|
|
2983
|
-
if (autoTimer) {
|
|
2984
|
-
clearInterval(autoTimer);
|
|
2985
|
-
autoTimer = null;
|
|
2986
|
-
}
|
|
2987
|
-
if (on)
|
|
2988
|
-
autoTimer = setInterval(() => {
|
|
2989
|
-
if (!document.hidden)
|
|
2990
|
-
load({ nocache: true });
|
|
2991
|
-
}, AUTO_RELOAD_MS);
|
|
2992
|
-
}
|
|
2993
|
-
setAutoReload(STATE.autoReload);
|
|
2994
|
-
$("#auto-reload").addEventListener("click", () => setAutoReload(!STATE.autoReload));
|
|
2995
2978
|
window.addEventListener("storage", (e) => {
|
|
2996
|
-
if (e.key === "gdp:auto-reload")
|
|
2997
|
-
setAutoReload(e.newValue !== "0");
|
|
2998
2979
|
if (e.key === "gdp:syntax-highlight")
|
|
2999
2980
|
setSyntaxHighlight(e.newValue !== "0");
|
|
3000
2981
|
});
|
package/web/index.html
CHANGED
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
<input class="ref-input" id="ref-to" placeholder="to…" autocomplete="off" readonly />
|
|
41
41
|
<button id="ref-reset" title="reset to HEAD .. worktree">×</button>
|
|
42
42
|
<button id="reload-prom" title="reload diff (R)">↻</button>
|
|
43
|
-
<button id="auto-reload" title="auto refresh every 3s">auto</button>
|
|
44
43
|
</div>
|
|
45
44
|
<div class="spacer"></div>
|
|
46
45
|
<div class="controls">
|
package/web/style.css
CHANGED
|
@@ -310,28 +310,6 @@ html, body {
|
|
|
310
310
|
#reload-prom:hover { background: var(--accent-emph); border-color: var(--accent-emph); }
|
|
311
311
|
#reload-prom.spinning { animation: gdp-spin 0.7s linear infinite; }
|
|
312
312
|
@keyframes gdp-spin { to { transform: rotate(360deg); } }
|
|
313
|
-
#auto-reload {
|
|
314
|
-
height: 26px; padding: 0 8px;
|
|
315
|
-
font-size: 11px; font-weight: 600;
|
|
316
|
-
letter-spacing: 0.04em;
|
|
317
|
-
width: auto;
|
|
318
|
-
border: 1px solid var(--border);
|
|
319
|
-
background: var(--bg);
|
|
320
|
-
color: var(--fg-muted);
|
|
321
|
-
border-radius: 6px;
|
|
322
|
-
cursor: pointer;
|
|
323
|
-
}
|
|
324
|
-
#auto-reload:hover { background: var(--bg-soft); color: var(--fg); }
|
|
325
|
-
#auto-reload.active {
|
|
326
|
-
background: #2da44e;
|
|
327
|
-
color: #fff;
|
|
328
|
-
border-color: #2da44e;
|
|
329
|
-
animation: gdp-auto-pulse 2.4s ease-in-out infinite;
|
|
330
|
-
}
|
|
331
|
-
@keyframes gdp-auto-pulse {
|
|
332
|
-
0%, 100% { box-shadow: 0 0 0 0 rgba(46, 164, 78, 0.45); }
|
|
333
|
-
50% { box-shadow: 0 0 0 4px rgba(46, 164, 78, 0); }
|
|
334
|
-
}
|
|
335
313
|
#hide-tests {
|
|
336
314
|
width: auto !important;
|
|
337
315
|
padding: 0 8px;
|