@takazudo/zfb-runtime 0.1.0-next.8 → 0.1.0-next.81

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +220 -15
  3. package/dist/client-router/events.d.ts +0 -1
  4. package/dist/client-router/events.js +2 -2
  5. package/dist/client-router/events.js.map +1 -1
  6. package/dist/client-router/index.d.ts +2 -3
  7. package/dist/client-router/index.js +2 -2
  8. package/dist/client-router/index.js.map +1 -1
  9. package/dist/client-router/prefetch.d.ts +0 -1
  10. package/dist/client-router/prefetch.js +126 -53
  11. package/dist/client-router/prefetch.js.map +1 -1
  12. package/dist/client-router/router.d.ts +28 -2
  13. package/dist/client-router/router.js +364 -30
  14. package/dist/client-router/router.js.map +1 -1
  15. package/dist/client-router/swap-functions.d.ts +0 -1
  16. package/dist/client-router/swap-functions.js +71 -11
  17. package/dist/client-router/swap-functions.js.map +1 -1
  18. package/dist/client-router/types.d.ts +4 -1
  19. package/dist/client-router/types.js.map +1 -1
  20. package/dist/client-router.d.ts +38 -2
  21. package/dist/client-router.js +56 -20
  22. package/dist/client-router.js.map +1 -1
  23. package/dist/framework.d.ts +0 -1
  24. package/dist/framework.js.map +1 -1
  25. package/dist/index.d.ts +2 -4
  26. package/dist/index.js +13 -4
  27. package/dist/index.js.map +1 -1
  28. package/dist/router.d.ts +32 -2
  29. package/dist/router.js +192 -33
  30. package/dist/router.js.map +1 -1
  31. package/dist/server.d.ts +2 -0
  32. package/dist/server.js +14 -0
  33. package/dist/server.js.map +1 -0
  34. package/dist/snapshot.d.ts +0 -1
  35. package/dist/snapshot.js +3 -2
  36. package/dist/snapshot.js.map +1 -1
  37. package/dist/view-transitions.d.ts +0 -1
  38. package/dist/view-transitions.js.map +1 -1
  39. package/package.json +26 -4
  40. package/dist/client-router/cssesc.d.ts +0 -9
  41. package/dist/client-router/cssesc.d.ts.map +0 -1
  42. package/dist/client-router/cssesc.js +0 -95
  43. package/dist/client-router/cssesc.js.map +0 -1
  44. package/dist/client-router/events.d.ts.map +0 -1
  45. package/dist/client-router/index.d.ts.map +0 -1
  46. package/dist/client-router/prefetch.d.ts.map +0 -1
  47. package/dist/client-router/router.d.ts.map +0 -1
  48. package/dist/client-router/swap-functions.d.ts.map +0 -1
  49. package/dist/client-router/types.d.ts.map +0 -1
  50. package/dist/client-router.d.ts.map +0 -1
  51. package/dist/framework.d.ts.map +0 -1
  52. package/dist/index.d.ts.map +0 -1
  53. package/dist/router.d.ts.map +0 -1
  54. package/dist/snapshot.d.ts.map +0 -1
  55. package/dist/view-transitions.d.ts.map +0 -1
@@ -18,16 +18,22 @@
18
18
  let initialized = false;
19
19
  let prefetchAll = false;
20
20
  let defaultStrategy = "hover";
21
- // Set of hrefs that have been completed or are in-flight.
21
+ // Set of hrefs that have been successfully prefetched.
22
22
  const prefetched = new Set();
23
- // Map of in-flight prefetch promises for dedup.
23
+ // Map of in-flight prefetch promises for dedup (also used as the concurrent short-circuit guard).
24
24
  const inFlight = new Map();
25
+ // How long to wait for a <link rel=prefetch>'s load/error before treating
26
+ // the prefetch as settled anyway (see executePrefetch).
27
+ const LINK_SETTLE_TIMEOUT_MS = 10_000;
25
28
  // The viewport observer — retained across post-swap re-scans so new elements
26
29
  // can be observed without recreating the observer.
27
30
  let viewportObserver = null;
28
31
  // Hover cancel handle — set when a pointerenter idle-callback fires, cleared on
29
32
  // pointerleave before the callback executes.
30
33
  const hoverCancelHandles = new Map();
34
+ // Focus cancel handle — set when a focusin idle-callback fires, cleared on
35
+ // focusout before the callback executes.
36
+ const focusCancelHandles = new Map();
31
37
  /**
32
38
  * Reset all module-level state. Exported for test isolation only — not part of
33
39
  * the public API and not re-exported from any barrel.
@@ -43,6 +49,7 @@ export function __resetForTests() {
43
49
  viewportObserver = null;
44
50
  }
45
51
  hoverCancelHandles.clear();
52
+ focusCancelHandles.clear();
46
53
  }
47
54
  // ---------------------------------------------------------------------------
48
55
  // Feature detection
@@ -84,23 +91,45 @@ function executePrefetch(href, opts) {
84
91
  if (existing)
85
92
  return existing;
86
93
  const p = (async () => {
87
- const method = opts.with ?? (supportsLinkPrefetch() ? "link" : "fetch");
88
- if (method === "link") {
89
- const link = document.createElement("link");
90
- link.rel = "prefetch";
91
- link.href = href;
92
- document.head.appendChild(link);
94
+ try {
95
+ const method = opts.with ?? (supportsLinkPrefetch() ? "link" : "fetch");
96
+ if (method === "link") {
97
+ const link = document.createElement("link");
98
+ link.rel = "prefetch";
99
+ link.href = href;
100
+ // Wait for load/error so we only mark success on actual load and allow
101
+ // retry after error — inserting without waiting would mark success
102
+ // immediately even on failure. (Bug: Takazudo/zudo-front-builder#896)
103
+ // Some browsers (e.g. Safari) never fire load/error on rel=prefetch
104
+ // links; without the settle timeout the href would sit in inFlight
105
+ // forever and block every future retry. Timing out counts as
106
+ // success — the resource was requested, which is all prefetch needs.
107
+ await new Promise((resolve, reject) => {
108
+ const timer = setTimeout(() => resolve(), LINK_SETTLE_TIMEOUT_MS);
109
+ link.addEventListener("load", () => {
110
+ clearTimeout(timer);
111
+ resolve();
112
+ }, { once: true });
113
+ link.addEventListener("error", () => {
114
+ clearTimeout(timer);
115
+ // Remove the failed element so retries don't accumulate
116
+ // dead <link> nodes in <head>.
117
+ link.remove();
118
+ reject(new Error(`prefetch link error: ${href}`));
119
+ }, { once: true });
120
+ document.head.appendChild(link);
121
+ });
122
+ }
123
+ else {
124
+ await fetch(href, { priority: "low" });
125
+ }
126
+ prefetched.add(href);
93
127
  }
94
- else {
95
- await fetch(href, { priority: "low" });
128
+ finally {
129
+ inFlight.delete(href);
96
130
  }
97
- prefetched.add(href);
98
- inFlight.delete(href);
99
131
  })();
100
132
  inFlight.set(href, p);
101
- // Also add to prefetched immediately to prevent concurrent triggers from
102
- // queuing duplicate in-flight entries before the async operation resolves.
103
- prefetched.add(href);
104
133
  return p;
105
134
  }
106
135
  /**
@@ -112,49 +141,84 @@ export function prefetch(url, opts = {}) {
112
141
  return; // cross-origin — skip
113
142
  if (opts.ignoreSlowConnection !== true && isSlowConnection())
114
143
  return;
115
- if (prefetched.has(href))
116
- return;
117
- void executePrefetch(href, opts);
118
- }
119
- // ---------------------------------------------------------------------------
120
- // Trigger: hover (pointerenter / focusin with cancel on pointerleave)
121
- // ---------------------------------------------------------------------------
122
- function onPointerEnter(e) {
123
- const link = e.target.closest("a[href]");
124
- if (!link)
125
- return;
126
- if (!shouldPrefetchLink(link, "hover"))
144
+ if (prefetched.has(href) || inFlight.has(href))
127
145
  return;
128
- // Use requestIdleCallback if available, else a small timeout.
129
- const fire = () => {
130
- hoverCancelHandles.delete(link);
131
- prefetch(link.href);
132
- };
133
- if (typeof requestIdleCallback !== "undefined") {
134
- const handle = requestIdleCallback(fire);
135
- hoverCancelHandles.set(link, handle);
136
- }
137
- else {
138
- const handle = setTimeout(fire, 100);
139
- hoverCancelHandles.set(link, handle);
140
- }
146
+ executePrefetch(href, opts).catch(() => { });
141
147
  }
142
- function onPointerLeave(e) {
143
- const link = e.target.closest("a[href]");
144
- if (!link)
145
- return;
146
- const handle = hoverCancelHandles.get(link);
147
- if (handle === undefined)
148
- return;
149
- if (typeof cancelIdleCallback !== "undefined") {
150
- cancelIdleCallback(handle);
148
+ function makeEnterLeaveHandlers(cancelHandles) {
149
+ function enterHandler(e) {
150
+ const link = e.target.closest("a[href]");
151
+ if (!link)
152
+ return;
153
+ if (!shouldPrefetchLink(link, "hover"))
154
+ return;
155
+ // A handle is already queued for this link — the pointer/focus moved
156
+ // between nested descendants of the SAME link, which re-fires enter on
157
+ // each one. Keep the original debounce window instead of overwriting it
158
+ // with a fresh requestIdleCallback/timeout that a busy pointer could keep
159
+ // resetting indefinitely. #1398.
160
+ if (cancelHandles.has(link))
161
+ return;
162
+ // The pending debounce already FIRED for this link — its idle callback ran
163
+ // prefetch(link.href), so the handle is gone from cancelHandles but the
164
+ // href is now prefetched (or in-flight). A later enter on the SAME link
165
+ // (e.g. an intra-link child->child move whose first callback fired in the
166
+ // gap between the two pointer moves — which the synchronous-dispatch L2
167
+ // suite cannot reproduce but a real browser does) must NOT queue a second,
168
+ // redundant idle callback whose prefetch() would only no-op. This is the
169
+ // fire+requeue companion to the cancel+requeue guard above. A failed
170
+ // prefetch leaves the href in NEITHER set (executePrefetch deletes it from
171
+ // inFlight without adding it to prefetched), so retry-after-error still
172
+ // works. #1398.
173
+ const resolvedHref = resolveHref(link.href);
174
+ if (resolvedHref && (prefetched.has(resolvedHref) || inFlight.has(resolvedHref)))
175
+ return;
176
+ // Use requestIdleCallback if available, else a small timeout.
177
+ const fire = () => {
178
+ cancelHandles.delete(link);
179
+ prefetch(link.href);
180
+ };
181
+ if (typeof requestIdleCallback !== "undefined") {
182
+ const handle = requestIdleCallback(fire);
183
+ cancelHandles.set(link, handle);
184
+ }
185
+ else {
186
+ const handle = setTimeout(fire, 100);
187
+ cancelHandles.set(link, handle);
188
+ }
151
189
  }
152
- else {
153
- clearTimeout(handle);
190
+ function leaveHandler(e) {
191
+ const link = e.target.closest("a[href]");
192
+ if (!link)
193
+ return;
194
+ // The pointer/focus is moving to relatedTarget. If that's still inside
195
+ // the same link (a nested descendant), this is NOT a real leave — skip
196
+ // the cancel so the pending prefetch survives intra-link moves. #1398.
197
+ const related = e.relatedTarget;
198
+ if (related instanceof Node && link.contains(related))
199
+ return;
200
+ const handle = cancelHandles.get(link);
201
+ if (handle === undefined)
202
+ return;
203
+ if (typeof cancelIdleCallback !== "undefined") {
204
+ cancelIdleCallback(handle);
205
+ }
206
+ else {
207
+ clearTimeout(handle);
208
+ }
209
+ cancelHandles.delete(link);
154
210
  }
155
- hoverCancelHandles.delete(link);
211
+ return [enterHandler, leaveHandler];
156
212
  }
157
213
  // ---------------------------------------------------------------------------
214
+ // Trigger: hover (pointerenter / pointerleave)
215
+ // ---------------------------------------------------------------------------
216
+ const [onPointerEnter, onPointerLeave] = makeEnterLeaveHandlers(hoverCancelHandles);
217
+ // ---------------------------------------------------------------------------
218
+ // Trigger: focus (focusin / focusout with cancel on focusout)
219
+ // ---------------------------------------------------------------------------
220
+ const [onFocusIn, onFocusOut] = makeEnterLeaveHandlers(focusCancelHandles);
221
+ // ---------------------------------------------------------------------------
158
222
  // Trigger: tap (touchstart / mousedown)
159
223
  // ---------------------------------------------------------------------------
160
224
  function onTap(e) {
@@ -241,6 +305,13 @@ function shouldPrefetchLink(link, triggerStrategy) {
241
305
  // Post-swap re-scan
242
306
  // ---------------------------------------------------------------------------
243
307
  function onAfterSwap() {
308
+ // Disconnect the existing observer before re-scanning so detached anchors from
309
+ // the old body are unobserved and don't accumulate across SPA swaps.
310
+ // (Bug: Takazudo/zudo-front-builder#896 — observer leak across SPA swaps)
311
+ if (viewportObserver) {
312
+ viewportObserver.disconnect();
313
+ viewportObserver = null;
314
+ }
244
315
  observeViewportLinks();
245
316
  prefetchLoadLinks();
246
317
  }
@@ -268,8 +339,10 @@ export function init(options) {
268
339
  defaultStrategy = options?.defaultStrategy ?? "hover";
269
340
  // Hover + tap — document delegation, picks up SPA-inserted links automatically.
270
341
  document.addEventListener("pointerenter", onPointerEnter, { capture: true });
271
- document.addEventListener("focusin", onPointerEnter, { capture: true });
272
342
  document.addEventListener("pointerleave", onPointerLeave, { capture: true });
343
+ // Focus — separate cancel map so hover and focus don't share handles.
344
+ document.addEventListener("focusin", onFocusIn, { capture: true });
345
+ document.addEventListener("focusout", onFocusOut, { capture: true });
273
346
  document.addEventListener("touchstart", onTap, { capture: true, passive: true });
274
347
  document.addEventListener("mousedown", onTap, { capture: true });
275
348
  // Viewport — observe current links immediately.
@@ -1 +1 @@
1
- {"version":3,"file":"prefetch.js","sourceRoot":"","sources":["../../src/client-router/prefetch.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,oCAAoC;AACpC,6CAA6C;AAC7C,EAAE;AACF,8EAA8E;AAC9E,6CAA6C;AAC7C,yCAAyC;AACzC,EAAE;AACF,oCAAoC;AACpC,yCAAyC;AACzC,qDAAqD;AACrD,sFAAsF;AACtF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,CAAC,CAAC;IAC7E,sEAAsE;IACtE,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACrE,QAAQ,CAAC,gBAAgB,CAAC,YAAY,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IACjF,QAAQ,CAAC,gBAAgB,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjE,gDAAgD;IAChD,oBAAoB,EAAE,CAAC;IAEvB,gDAAgD;IAChD,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAC5C,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACtC,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3E,CAAC;SAAM,CAAC;QACN,SAAS,EAAE,CAAC;IACd,CAAC;IAED,+EAA+E;IAC/E,QAAQ,CAAC,gBAAgB,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/// <reference lib=\"dom\" />\n/// <reference lib=\"dom.iterable\" />\n// `@takazudo/zfb-runtime` — prefetch module.\n//\n// Ported from Astro's prefetch module (packages/astro/src/prefetch/index.ts).\n// Source: https://github.com/withastro/astro\n// Issue: Takazudo/zudo-front-builder#276\n//\n// Mechanical renames per W1B §13.5:\n// astro:* event names → zfb:*\n// data-astro-prefetch → data-zfb-prefetch\n// __PREFETCH_DISABLED__ → <meta name=\"zfb-prefetch-disabled\" content=\"true\">\n//\n// DISABLED-FLAG CONTRACT — exact meta tag name and content value are locked:\n// meta[name=\"zfb-prefetch-disabled\"][content=\"true\"]\n// Both this module and sibling sub-issue #272-config pin this verbatim.\n\nexport type PrefetchStrategy = \"hover\" | \"viewport\" | \"load\" | \"tap\";\n\nexport interface PrefetchInitOptions {\n prefetchAll?: boolean;\n defaultStrategy?: PrefetchStrategy;\n}\n\nexport interface PrefetchOptions {\n ignoreSlowConnection?: boolean;\n with?: \"link\" | \"fetch\";\n}\n\n// Module-level state — persists across SPA navigations within a session.\nlet initialized = false;\nlet prefetchAll = false;\nlet defaultStrategy: PrefetchStrategy = \"hover\";\n\n// Set of hrefs that have been successfully prefetched.\nconst prefetched = new Set<string>();\n// Map of in-flight prefetch promises for dedup (also used as the concurrent short-circuit guard).\nconst inFlight = new Map<string, Promise<void>>();\n\n// How long to wait for a <link rel=prefetch>'s load/error before treating\n// the prefetch as settled anyway (see executePrefetch).\nconst LINK_SETTLE_TIMEOUT_MS = 10_000;\n\n// The viewport observer — retained across post-swap re-scans so new elements\n// can be observed without recreating the observer.\nlet viewportObserver: IntersectionObserver | null = null;\n\n// Hover cancel handle — set when a pointerenter idle-callback fires, cleared on\n// pointerleave before the callback executes.\nconst hoverCancelHandles = new Map<Element, ReturnType<typeof setTimeout> | number>();\n\n// Focus cancel handle — set when a focusin idle-callback fires, cleared on\n// focusout before the callback executes.\nconst focusCancelHandles = new Map<Element, ReturnType<typeof setTimeout> | number>();\n\n/**\n * Reset all module-level state. Exported for test isolation only — not part of\n * the public API and not re-exported from any barrel.\n */\nexport function __resetForTests(): void {\n initialized = false;\n prefetchAll = false;\n defaultStrategy = \"hover\";\n prefetched.clear();\n inFlight.clear();\n if (viewportObserver) {\n viewportObserver.disconnect();\n viewportObserver = null;\n }\n hoverCancelHandles.clear();\n focusCancelHandles.clear();\n}\n\n// ---------------------------------------------------------------------------\n// Feature detection\n// ---------------------------------------------------------------------------\n\nfunction supportsLinkPrefetch(): boolean {\n const link = document.createElement(\"link\");\n return link.relList?.supports?.(\"prefetch\") ?? false;\n}\n\nfunction isSlowConnection(): boolean {\n const nav = navigator as Navigator & {\n connection?: { saveData?: boolean; effectiveType?: string };\n };\n return (\n nav.connection?.saveData === true ||\n nav.connection?.effectiveType === \"2g\" ||\n nav.connection?.effectiveType === \"slow-2g\"\n );\n}\n\n// ---------------------------------------------------------------------------\n// Core prefetch logic\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve an href to an absolute URL string keyed against the current origin.\n * Returns null for cross-origin hrefs (these are skipped entirely).\n */\nfunction resolveHref(href: string): string | null {\n try {\n const url = new URL(href, location.href);\n if (url.origin !== location.origin) return null;\n return url.href;\n } catch {\n return null;\n }\n}\n\n/**\n * Execute a single prefetch for the given absolute href.\n * Uses <link rel=\"prefetch\"> (preferred) or fetch() fallback.\n */\nfunction executePrefetch(href: string, opts: PrefetchOptions): Promise<void> {\n const existing = inFlight.get(href);\n if (existing) return existing;\n\n const p: Promise<void> = (async () => {\n try {\n const method = opts.with ?? (supportsLinkPrefetch() ? \"link\" : \"fetch\");\n if (method === \"link\") {\n const link = document.createElement(\"link\");\n link.rel = \"prefetch\";\n link.href = href;\n // Wait for load/error so we only mark success on actual load and allow\n // retry after error — inserting without waiting would mark success\n // immediately even on failure. (Bug: Takazudo/zudo-front-builder#896)\n // Some browsers (e.g. Safari) never fire load/error on rel=prefetch\n // links; without the settle timeout the href would sit in inFlight\n // forever and block every future retry. Timing out counts as\n // success — the resource was requested, which is all prefetch needs.\n await new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => resolve(), LINK_SETTLE_TIMEOUT_MS);\n link.addEventListener(\n \"load\",\n () => {\n clearTimeout(timer);\n resolve();\n },\n { once: true },\n );\n link.addEventListener(\n \"error\",\n () => {\n clearTimeout(timer);\n // Remove the failed element so retries don't accumulate\n // dead <link> nodes in <head>.\n link.remove();\n reject(new Error(`prefetch link error: ${href}`));\n },\n { once: true },\n );\n document.head.appendChild(link);\n });\n } else {\n await fetch(href, { priority: \"low\" } as RequestInit & { priority?: string });\n }\n prefetched.add(href);\n } finally {\n inFlight.delete(href);\n }\n })();\n\n inFlight.set(href, p);\n return p;\n}\n\n/**\n * Public prefetch function. Idempotent per href.\n */\nexport function prefetch(url: string, opts: PrefetchOptions = {}): void {\n const href = resolveHref(url);\n if (!href) return; // cross-origin — skip\n\n if (opts.ignoreSlowConnection !== true && isSlowConnection()) return;\n\n if (prefetched.has(href) || inFlight.has(href)) return;\n\n executePrefetch(href, opts).catch(() => {});\n}\n\n// ---------------------------------------------------------------------------\n// Shared enter/leave handler factory\n// ---------------------------------------------------------------------------\n\ntype CancelHandleMap = Map<Element, ReturnType<typeof setTimeout> | number>;\n\n/**\n * Returns a pair of [enterHandler, leaveHandler] that queue and cancel an idle\n * prefetch callback, keyed on the supplied per-trigger cancel-handle map.\n *\n * Both the pointer (hover) and focus triggers use identical queue/cancel logic;\n * the only difference between them is which map tracks their pending handles.\n * Parameterising by the map eliminates that duplication.\n */\n// pointerenter/pointerleave (and focusin/focusout) fire on every element the\n// pointer/focus enters or leaves, including nested descendants — not just the\n// delegated document listener's eventual `closest(\"a[href]\")` target. For\n// `<a><span>text</span></a>`, moving the pointer between the link's own\n// children fires a leave on the child being left and an enter on the child\n// being entered, even though the pointer never left the LINK itself.\n// `relatedTarget` is where the pointer/focus is going (leave) or came from\n// (enter); reading it lets the two handlers below tell an intra-link move\n// apart from a real leave/first-enter. #1398.\ntype RelatedTargetEvent = Event & { relatedTarget?: EventTarget | null };\n\nfunction makeEnterLeaveHandlers(\n cancelHandles: CancelHandleMap,\n): [enterHandler: (e: Event) => void, leaveHandler: (e: Event) => void] {\n function enterHandler(e: Event): void {\n const link = (e.target as Element).closest(\"a[href]\") as HTMLAnchorElement | null;\n if (!link) return;\n if (!shouldPrefetchLink(link, \"hover\")) return;\n\n // A handle is already queued for this link — the pointer/focus moved\n // between nested descendants of the SAME link, which re-fires enter on\n // each one. Keep the original debounce window instead of overwriting it\n // with a fresh requestIdleCallback/timeout that a busy pointer could keep\n // resetting indefinitely. #1398.\n if (cancelHandles.has(link)) return;\n\n // The pending debounce already FIRED for this link — its idle callback ran\n // prefetch(link.href), so the handle is gone from cancelHandles but the\n // href is now prefetched (or in-flight). A later enter on the SAME link\n // (e.g. an intra-link child->child move whose first callback fired in the\n // gap between the two pointer moves — which the synchronous-dispatch L2\n // suite cannot reproduce but a real browser does) must NOT queue a second,\n // redundant idle callback whose prefetch() would only no-op. This is the\n // fire+requeue companion to the cancel+requeue guard above. A failed\n // prefetch leaves the href in NEITHER set (executePrefetch deletes it from\n // inFlight without adding it to prefetched), so retry-after-error still\n // works. #1398.\n const resolvedHref = resolveHref(link.href);\n if (resolvedHref && (prefetched.has(resolvedHref) || inFlight.has(resolvedHref))) return;\n\n // Use requestIdleCallback if available, else a small timeout.\n const fire = () => {\n cancelHandles.delete(link);\n prefetch(link.href);\n };\n\n if (typeof requestIdleCallback !== \"undefined\") {\n const handle = requestIdleCallback(fire);\n cancelHandles.set(link, handle);\n } else {\n const handle = setTimeout(fire, 100);\n cancelHandles.set(link, handle);\n }\n }\n\n function leaveHandler(e: Event): void {\n const link = (e.target as Element).closest(\"a[href]\") as HTMLAnchorElement | null;\n if (!link) return;\n\n // The pointer/focus is moving to relatedTarget. If that's still inside\n // the same link (a nested descendant), this is NOT a real leave — skip\n // the cancel so the pending prefetch survives intra-link moves. #1398.\n const related = (e as RelatedTargetEvent).relatedTarget;\n if (related instanceof Node && link.contains(related)) return;\n\n const handle = cancelHandles.get(link);\n if (handle === undefined) return;\n\n if (typeof cancelIdleCallback !== \"undefined\") {\n cancelIdleCallback(handle as number);\n } else {\n clearTimeout(handle as ReturnType<typeof setTimeout>);\n }\n cancelHandles.delete(link);\n }\n\n return [enterHandler, leaveHandler];\n}\n\n// ---------------------------------------------------------------------------\n// Trigger: hover (pointerenter / pointerleave)\n// ---------------------------------------------------------------------------\n\nconst [onPointerEnter, onPointerLeave] = makeEnterLeaveHandlers(hoverCancelHandles);\n\n// ---------------------------------------------------------------------------\n// Trigger: focus (focusin / focusout with cancel on focusout)\n// ---------------------------------------------------------------------------\n\nconst [onFocusIn, onFocusOut] = makeEnterLeaveHandlers(focusCancelHandles);\n\n// ---------------------------------------------------------------------------\n// Trigger: tap (touchstart / mousedown)\n// ---------------------------------------------------------------------------\n\nfunction onTap(e: Event): void {\n const link = (e.target as Element).closest(\"a[href]\") as HTMLAnchorElement | null;\n if (!link) return;\n if (!shouldPrefetchLink(link, \"tap\")) return;\n prefetch(link.href);\n}\n\n// ---------------------------------------------------------------------------\n// Trigger: viewport (IntersectionObserver)\n// ---------------------------------------------------------------------------\n\nfunction initViewportObserver(): IntersectionObserver {\n if (viewportObserver) return viewportObserver;\n\n viewportObserver = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n const link = entry.target as HTMLAnchorElement;\n prefetch(link.href);\n // Once observed and in-flight, no need to keep observing.\n viewportObserver?.unobserve(link);\n }\n }\n },\n { threshold: 0 },\n );\n\n return viewportObserver;\n}\n\nfunction observeViewportLinks(): void {\n const observer = initViewportObserver();\n const selector =\n prefetchAll && defaultStrategy === \"viewport\"\n ? \"a[href]:not([data-zfb-prefetch='false'])\"\n : \"a[data-zfb-prefetch='viewport']\";\n\n document.querySelectorAll<HTMLAnchorElement>(selector).forEach((link) => {\n const href = resolveHref(link.href);\n if (href && !prefetched.has(href)) {\n observer.observe(link);\n }\n });\n}\n\n// ---------------------------------------------------------------------------\n// Trigger: load (requestIdleCallback after DOMContentLoaded)\n// ---------------------------------------------------------------------------\n\nfunction prefetchLoadLinks(): void {\n const selector =\n prefetchAll && defaultStrategy === \"load\"\n ? \"a[href]:not([data-zfb-prefetch='false'])\"\n : \"a[data-zfb-prefetch='load']\";\n\n document.querySelectorAll<HTMLAnchorElement>(selector).forEach((link) => {\n const href = resolveHref(link.href);\n if (!href || prefetched.has(href)) return;\n\n if (typeof requestIdleCallback !== \"undefined\") {\n requestIdleCallback(() => prefetch(link.href));\n } else {\n setTimeout(() => prefetch(link.href), 0);\n }\n });\n}\n\n// ---------------------------------------------------------------------------\n// Per-link strategy resolution\n// ---------------------------------------------------------------------------\n\n/**\n * Determine whether a given link should be prefetched for the supplied trigger strategy.\n * Returns false if:\n * - data-zfb-prefetch=\"false\" (always disabled)\n * - The effective strategy for this link doesn't match the active trigger\n */\nfunction shouldPrefetchLink(link: HTMLAnchorElement, triggerStrategy: PrefetchStrategy): boolean {\n const attr = link.dataset[\"zfbPrefetch\"];\n\n // Explicitly disabled.\n if (attr === \"false\") return false;\n\n // Per-link explicit strategy.\n if (attr && attr !== \"false\") {\n return attr === triggerStrategy;\n }\n\n // No explicit attribute — rely on prefetchAll + defaultStrategy.\n if (!prefetchAll) return false;\n\n return defaultStrategy === triggerStrategy;\n}\n\n// ---------------------------------------------------------------------------\n// Post-swap re-scan\n// ---------------------------------------------------------------------------\n\nfunction onAfterSwap(): void {\n // Disconnect the existing observer before re-scanning so detached anchors from\n // the old body are unobserved and don't accumulate across SPA swaps.\n // (Bug: Takazudo/zudo-front-builder#896 — observer leak across SPA swaps)\n if (viewportObserver) {\n viewportObserver.disconnect();\n viewportObserver = null;\n }\n observeViewportLinks();\n prefetchLoadLinks();\n}\n\n// ---------------------------------------------------------------------------\n// init()\n// ---------------------------------------------------------------------------\n\n/**\n * Initialize the prefetch module.\n *\n * Idempotent — multiple calls are safe. The module-level `initialized` flag\n * ensures listeners are registered exactly once.\n *\n * DISABLED-FLAG CONTRACT: if `<meta name=\"zfb-prefetch-disabled\" content=\"true\">`\n * is present in the document at init() time, this function is a no-op.\n */\nexport function init(options?: PrefetchInitOptions): void {\n // Disabled-flag check — exact selector is the contract with #272-config.\n if (document.querySelector('meta[name=\"zfb-prefetch-disabled\"][content=\"true\"]')) {\n return;\n }\n\n if (initialized) return;\n initialized = true;\n\n prefetchAll = options?.prefetchAll ?? false;\n defaultStrategy = options?.defaultStrategy ?? \"hover\";\n\n // Hover + tap — document delegation, picks up SPA-inserted links automatically.\n document.addEventListener(\"pointerenter\", onPointerEnter, { capture: true });\n document.addEventListener(\"pointerleave\", onPointerLeave, { capture: true });\n // Focus — separate cancel map so hover and focus don't share handles.\n document.addEventListener(\"focusin\", onFocusIn, { capture: true });\n document.addEventListener(\"focusout\", onFocusOut, { capture: true });\n document.addEventListener(\"touchstart\", onTap, { capture: true, passive: true });\n document.addEventListener(\"mousedown\", onTap, { capture: true });\n\n // Viewport — observe current links immediately.\n observeViewportLinks();\n\n // Load — queue current links via idle callback.\n const queueLoad = () => prefetchLoadLinks();\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", queueLoad, { once: true });\n } else {\n queueLoad();\n }\n\n // Post-swap re-scan — re-walk viewport + load links after each SPA navigation.\n document.addEventListener(\"zfb:after-swap\", onAfterSwap);\n}\n"]}
@@ -1,7 +1,34 @@
1
- import type { Fallback, Options } from "./types.js";
1
+ import type { Fallback, Options, SyncHistoryEntryOptions } from "./types.js";
2
2
  export declare const supportsViewTransitions: boolean;
3
3
  export declare const transitionEnabledOnThisPage: () => boolean;
4
4
  export declare function getFallback(): Fallback;
5
+ /**
6
+ * Write a router-managed history entry (push or replace) WITHOUT any
7
+ * navigation, DOM, or lifecycle side effect. This is the supported path for
8
+ * consumers deep-linking transient UI state (dialogs/modals, a photo
9
+ * viewer's `/photos/<slug>/` URL). Hand-rolled raw `history.pushState`
10
+ * desyncs `originalLocation` and the index bookkeeping that popstate
11
+ * direction detection ({@link derivePopDirection}) and the same-page
12
+ * traverse fast-path depend on; `navigate()` can't be used instead because
13
+ * it forces a fetch. See #1377 / #1374.
14
+ *
15
+ * Never scrolls the viewport itself — but the entry it writes IS stamped
16
+ * with the CURRENT scroll position (`scrollX`/`scrollY` at call time), not
17
+ * `(0, 0)` (issue #1398). This matters only for a later Forward-traversal
18
+ * back to this entry: the same-page traverse fast-path restores whatever
19
+ * scroll position was stamped on the entry, so a same-page push (e.g.
20
+ * opening a dialog) does not snap the underlying page to the top when the
21
+ * dialog is later reopened via Forward.
22
+ *
23
+ * @param url - The URL to write. Cross-origin URLs throw rather than
24
+ * silently falling back to a full-page load.
25
+ * @param options.replace - Use `history.replaceState` instead of
26
+ * `history.pushState` (no new Back-button entry). Default: push.
27
+ * @param options.state - Merged into the entry's `history.state`; the
28
+ * router's own bookkeeping keys (`index`, `scrollX`, `scrollY`) always win
29
+ * on a colliding key.
30
+ */
31
+ export declare function syncHistoryEntry(url: string | URL, options?: SyncHistoryEntryOptions): void;
5
32
  export declare function navigate(href: string, options?: Options): Promise<void>;
6
33
  export interface InitOptions {
7
34
  /** Reserved for forward-compat with Astro's prefetch integration. Ignored in v1. */
@@ -14,4 +41,3 @@ export interface InitOptions {
14
41
  * @param _options - Forward-compat hook matching Astro's init() signature. Ignored in v1.
15
42
  */
16
43
  export declare function init(_options?: InitOptions): void;
17
- //# sourceMappingURL=router.d.ts.map