release: WRNexusJS 0.8.2
Quality / quality (ubuntu-latest) (push) Failing after 22s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-03 02:14:54 +05:30
parent 3c6b659f36
commit 4550a11460
84 changed files with 214 additions and 150 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/csr",
"version": "0.8.1",
"version": "0.8.2",
"type": "module",
"main": "src/index.ts",
"exports": {
+4 -1
View File
@@ -638,7 +638,10 @@ export const NAV_RUNTIME = String.raw`
while (prefetched.size > 20) prefetched.delete(prefetched.keys().next().value);
}
document.addEventListener("pointerover", function (event) {
// Prefetch only on explicit pointer intent. Delegated pointerover fires when
// scrolling moves links underneath a stationary pointer, which can otherwise
// download every link on a long index page.
document.addEventListener("pointerdown", function (event) {
var anchor = event.target && event.target.closest ? event.target.closest("a") : null;
prefetch(anchor);
}, { passive: true });
+12
View File
@@ -82,6 +82,18 @@ test("prefetches focused routes once and reuses the document during navigation",
expect(win.document.querySelector("h1")?.textContent).toBe("Prefetched");
});
test("does not prefetch links merely passing under the pointer while scrolling", async () => {
install(`<div id="app"><a href="/about" id="prefetch">About</a></div>`);
const link = win.document.getElementById("prefetch");
link.dispatchEvent(new win.PointerEvent("pointerover", { bubbles: true }));
await flush();
expect(fetchCalls).toHaveLength(0);
link.dispatchEvent(new win.PointerEvent("pointerdown", { bubbles: true }));
await flush();
expect(fetchCalls).toHaveLength(1);
expect(fetchCalls[0]?.opts.headers["x-wrnexus-prefetch"]).toBe("1");
});
test("ignores cross-origin links (full navigation)", async () => {
install(`<div id="app"><a href="https://other.test/x" id="lnk">x</a></div>`);
win.document.getElementById("lnk").click();