boltdocs 3.3.5 → 3.4.0

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 (126) hide show
  1. package/dist/{adapters-BKzKe2mO.mjs → adapters-BXiBWAKs.mjs} +1 -1
  2. package/dist/{adapters-DwDTQoCG.cjs → adapters-Czl3WtQt.cjs} +1 -1
  3. package/dist/{build-B672n0hL.cjs → build-CNkXRdk8.cjs} +1 -1
  4. package/dist/{build-BVoMHMhw.mjs → build-CqUBsXVC.mjs} +1 -1
  5. package/dist/client/index.cjs +245 -56
  6. package/dist/client/index.d.cts +3 -3
  7. package/dist/client/index.d.ts +3 -3
  8. package/dist/client/index.js +246 -60
  9. package/dist/client/mdx.cjs +1 -1
  10. package/dist/client/mdx.js +1 -1
  11. package/dist/client/primitives.cjs +5 -5
  12. package/dist/client/primitives.d.cts +92 -42
  13. package/dist/client/primitives.d.ts +101 -51
  14. package/dist/client/primitives.js +4 -4
  15. package/dist/client/router.cjs +1 -1
  16. package/dist/client/router.d.cts +1 -1
  17. package/dist/client/router.d.ts +1 -1
  18. package/dist/client/router.js +1 -1
  19. package/dist/client/theme/reset.css +41 -0
  20. package/dist/config-B3SEoVjG.cjs +7 -0
  21. package/dist/{config-PLvresCv.cjs → config-Bfakeadu.cjs} +1 -1
  22. package/dist/config-CTcfF-0c.mjs +7 -0
  23. package/dist/dev-D1DmOSjn.mjs +6 -0
  24. package/dist/dev-DH6cSge8.cjs +6 -0
  25. package/dist/{docs-layout-CbZ7LDRe.js → docs-layout-CmntYM6p.js} +46 -147
  26. package/dist/{docs-layout-vzfXed1Q.cjs → docs-layout-DIgxJ5c7.cjs} +23 -130
  27. package/dist/{doctor-DMECtdK6.cjs → doctor-BLxm2alc.cjs} +1 -1
  28. package/dist/{doctor-FuFY1jBz.cjs → doctor-Dd-JMTRo.cjs} +1 -1
  29. package/dist/{doctor-i8Qmd8DJ.mjs → doctor-DogHujrP.mjs} +1 -1
  30. package/dist/{image-Hnaa2bJd.cjs → image-Bke2ojW1.cjs} +3 -3
  31. package/dist/{image-B-NDSDuY.js → image-CaY2w0ua.js} +2 -1
  32. package/dist/index--xbYbT8N.d.ts +343 -0
  33. package/dist/{index-Bg-JtZeK.d.cts → index-B_o5y34l.d.cts} +112 -13
  34. package/dist/{index-B3o307nd.d.ts → index-Bx0CUd7Q.d.ts} +112 -13
  35. package/dist/index-RK7W_Fxy.d.cts +343 -0
  36. package/dist/{link-CgdI6O2o.js → link-CSe_oD8Y.js} +137 -139
  37. package/dist/{link-vZjmD-es.cjs → link-Xb69Oy2F.cjs} +144 -169
  38. package/dist/{mdx-D0Absdq5.cjs → mdx-BCOrMd-P.cjs} +68 -16
  39. package/dist/{mdx-BRT71V5Q.js → mdx-BijiEbkp.js} +62 -15
  40. package/dist/{native-nLA4Jr0T.cjs → native-BbtRkce5.cjs} +1 -1
  41. package/dist/node/cli-entry.cjs +1 -1
  42. package/dist/node/cli-entry.mjs +1 -1
  43. package/dist/node/highlight.d.cts +2 -2
  44. package/dist/node/highlight.d.mts +2 -2
  45. package/dist/node/index.cjs +1 -1
  46. package/dist/node/index.d.cts +19 -37
  47. package/dist/node/index.d.mts +20 -38
  48. package/dist/node/index.mjs +1 -1
  49. package/dist/node/mdx/shiki-adapter.cjs +1 -1
  50. package/dist/node/mdx/shiki-adapter.d.cts +7 -2
  51. package/dist/node/mdx/shiki-adapter.d.mts +7 -2
  52. package/dist/node/mdx/shiki-adapter.mjs +1 -1
  53. package/dist/node-BgiLCa0I.cjs +39 -0
  54. package/dist/node-Da3tYBHo.mjs +39 -0
  55. package/dist/{package-CNqjEYE1.cjs → package-D1gVs5gQ.cjs} +1 -1
  56. package/dist/{package-sdcKhDhe.mjs → package-YgQJn3Yh.mjs} +1 -1
  57. package/dist/pages-external-B_r6gvqP.cjs +6 -0
  58. package/dist/pages-external-jmK7AHaO.mjs +6 -0
  59. package/dist/{parser-CD8Oo8qh.mjs → parser-CvNZc5s3.mjs} +1 -1
  60. package/dist/{parser-vPaKvzLp.cjs → parser-DJLWTiO-.cjs} +1 -1
  61. package/dist/plugin-DW9K2fW5.mjs +69 -0
  62. package/dist/plugin-NwGKyTJX.cjs +69 -0
  63. package/dist/{plugin-context-DuSg-Hax.mjs → plugin-context-COh-cbsW.mjs} +1 -1
  64. package/dist/{plugin-context-CscLcXjH.cjs → plugin-context-FIHaWn6r.cjs} +2 -2
  65. package/dist/{plugin-lifecycle-BywrEoWK.cjs → plugin-lifecycle-D9fTRaWY.cjs} +1 -1
  66. package/dist/{registry-BbB6NqSv.d.cts → registry-BFmzj1yg.d.mts} +1 -1
  67. package/dist/{registry-sJqDv0kE.d.mts → registry-BoswPzYV.d.cts} +1 -1
  68. package/dist/{resolve-C5rT6B21.mjs → resolve-5puUe7eS.mjs} +1 -1
  69. package/dist/{resolve-BelytNYR.cjs → resolve-CF4ZLfqx.cjs} +1 -1
  70. package/dist/route-paths-B6ocUfNY.cjs +6 -0
  71. package/dist/route-paths-DyDji4bX.mjs +6 -0
  72. package/dist/{router-CZBxMRAH.js → router-B5e8k4qK.js} +175 -10
  73. package/dist/{router-C3kygdRK.cjs → router-DKC0Lu0n.cjs} +204 -9
  74. package/dist/{routes-C3_w9fLX.cjs → routes-D55M8UrH.cjs} +1 -1
  75. package/dist/routes-DdE6Lfcl.cjs +6 -0
  76. package/dist/routes-_I_8PQYF.mjs +6 -0
  77. package/dist/{search-dialog-x_qHU8ty.cjs → search-dialog-BOQRHKTb.cjs} +197 -24
  78. package/dist/{search-dialog-BqkzDTq2.js → search-dialog-BXil4_7P.js} +190 -29
  79. package/dist/search-dialog-CwlBd-Mu.cjs +747 -0
  80. package/dist/{search-dialog-B9mdxsUC.js → search-dialog-D3Obh3eA.js} +1 -1
  81. package/dist/search-dialog-DeplpVEB.js +717 -0
  82. package/dist/{search-dialog-DCtm2dyR.cjs → search-dialog-cHXR5zhL.cjs} +1 -1
  83. package/dist/server/index.cjs +1 -1
  84. package/dist/server/index.d.mts +1 -1
  85. package/dist/server/index.mjs +1 -1
  86. package/dist/ssg-static-options-Br1_u9qp.mjs +6 -0
  87. package/dist/ssg-static-options-CVvGKM8i.cjs +6 -0
  88. package/dist/types-58Ac3UGI.d.cts +114 -0
  89. package/dist/types-BwnGf-1E.d.mts +114 -0
  90. package/dist/virtual-modules-C4-qxFlL.cjs +40 -0
  91. package/dist/virtual-modules-DiWUKJGP.mjs +40 -0
  92. package/package.json +8 -5
  93. package/src/shared/types.ts +133 -987
  94. package/dist/config-CrsQJHQz.cjs +0 -7
  95. package/dist/config-DC0nMMk7.mjs +0 -7
  96. package/dist/dev-B49V6O6p.mjs +0 -6
  97. package/dist/dev-DbuhNcF5.cjs +0 -6
  98. package/dist/index-CgWkOCCn.d.cts +0 -1193
  99. package/dist/index-CuNSD3E2.d.ts +0 -1193
  100. package/dist/node-BljvHMpS.cjs +0 -23
  101. package/dist/node-CWxGw4H4.mjs +0 -23
  102. package/dist/pages-external-BBw8ObVK.mjs +0 -6
  103. package/dist/pages-external-DPiPFxxP.cjs +0 -6
  104. package/dist/plugin-BPcm1cU0.mjs +0 -69
  105. package/dist/plugin-WUhxnpko.cjs +0 -69
  106. package/dist/routes-C0kb4ue6.cjs +0 -6
  107. package/dist/routes-C4wrLWwu.mjs +0 -6
  108. package/dist/search-dialog-Bp_ouN1c.cjs +0 -550
  109. package/dist/search-dialog-an2BNMj6.js +0 -526
  110. package/dist/types-Db6zToZH.d.mts +0 -975
  111. package/dist/types-o7iZ2BAR.d.cts +0 -975
  112. package/dist/virtual-modules-B2X4Ht2r.mjs +0 -39
  113. package/dist/virtual-modules-DPsdHKcu.cjs +0 -39
  114. /package/dist/{audit-CMc_ydRr.mjs → audit-CYAkXXvP.mjs} +0 -0
  115. /package/dist/{audit-CHkGiV3c.cjs → audit-DxCZZTuX.cjs} +0 -0
  116. /package/dist/{csp-BiGAG8aF.cjs → csp-B-gc2Iha.cjs} +0 -0
  117. /package/dist/{csp-D0BOH8ae.mjs → csp-f8DOcI_7.mjs} +0 -0
  118. /package/dist/{generator-BCrZL53x.cjs → generator-CBAPKY6r.cjs} +0 -0
  119. /package/dist/{generator-CFukoGa0.mjs → generator-MRpn-yp6.mjs} +0 -0
  120. /package/dist/{handler-Lex5DbvG.mjs → handler-DBZqoWt2.mjs} +0 -0
  121. /package/dist/{handler-Ch-Q9NAB.cjs → handler-ryZR9Q41.cjs} +0 -0
  122. /package/dist/{index-HAwIo4nZ.d.mts → index-CPr34I2C.d.mts} +0 -0
  123. /package/dist/{native-BYKMke79.mjs → native-DZ6WMwjG.mjs} +0 -0
  124. /package/dist/{native-BOet8hpE.cjs → native-DeKxny_T.cjs} +0 -0
  125. /package/dist/{update-check-BXD1atVv.mjs → update-check-BXx8te9F.mjs} +0 -0
  126. /package/dist/{update-check-DFQZyoSU.cjs → update-check-CiIeC7CX.cjs} +0 -0
@@ -3,8 +3,8 @@
3
3
  * Copyright (c) 2026 Jesus Alcala
4
4
  * Licensed under the MIT License.
5
5
  */
6
- import { E as useLocation, O as useNavigate, c as hasUriScheme, h as resolveUrlReference, k as usePrefetch, l as hasUrlBase, m as parseUrlReference } from "./router-CZBxMRAH.js";
7
- import { createContext, use, useCallback, useEffect, useMemo, useState } from "react";
6
+ import { E as useLocation, O as useNavigate, V as useConfig, c as hasUriScheme, h as resolveUrlReference, k as usePrefetch, l as hasUrlBase, m as parseUrlReference, z as useViewTransition } from "./router-B5e8k4qK.js";
7
+ import React, { createContext, use, useCallback, useEffect, useMemo, useState } from "react";
8
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { clsx } from "clsx";
10
10
  import { twMerge } from "tailwind-merge";
@@ -39,10 +39,10 @@ function getSavedPrefs() {
39
39
  return {};
40
40
  }
41
41
  }
42
- const globalRegistry$1 = globalThis;
43
- const existingContext = globalRegistry$1[BOLTDOCS_CONTEXT_SYMBOL];
42
+ const globalRegistry = globalThis;
43
+ const existingContext = globalRegistry[BOLTDOCS_CONTEXT_SYMBOL];
44
44
  const BoltdocsContext = existingContext || createContext(void 0);
45
- if (!existingContext) Reflect.set(globalRegistry$1, BOLTDOCS_CONTEXT_SYMBOL, BoltdocsContext);
45
+ if (!existingContext) Reflect.set(globalRegistry, BOLTDOCS_CONTEXT_SYMBOL, BoltdocsContext);
46
46
  function BoltdocsProvider({ children, initialLocale = "", initialVersion = "" }) {
47
47
  const [locale, setLocaleState] = useState(() => {
48
48
  if (initialLocale) return initialLocale;
@@ -65,7 +65,7 @@ function BoltdocsProvider({ children, initialLocale = "", initialVersion = "" })
65
65
  return newL;
66
66
  });
67
67
  if (typeof globalThis !== "undefined") Reflect.set(globalThis, BOLTDOCS_INSTANCE_SYMBOL, {
68
- ...globalThis[BOLTDOCS_INSTANCE_SYMBOL],
68
+ ...globalRegistry[BOLTDOCS_INSTANCE_SYMBOL],
69
69
  currentLocale: newL
70
70
  });
71
71
  if (typeof window !== "undefined") try {
@@ -83,7 +83,7 @@ function BoltdocsProvider({ children, initialLocale = "", initialVersion = "" })
83
83
  return newV;
84
84
  });
85
85
  if (typeof globalThis !== "undefined") Reflect.set(globalThis, BOLTDOCS_INSTANCE_SYMBOL, {
86
- ...globalThis[BOLTDOCS_INSTANCE_SYMBOL],
86
+ ...globalRegistry[BOLTDOCS_INSTANCE_SYMBOL],
87
87
  currentVersion: newV
88
88
  });
89
89
  if (typeof window !== "undefined") try {
@@ -122,41 +122,6 @@ function useBoltdocsContext() {
122
122
  return context;
123
123
  }
124
124
 
125
- //#endregion
126
- //#region src/client/app/config-context.tsx
127
- /**
128
- * Context for the global documentation configuration.
129
- * Using a global singleton pattern to survive dual-package or duplicated-code hazards.
130
- */
131
- const CONFIG_CONTEXT_SYMBOL = Symbol.for("__BDOCS_CONFIG_CONTEXT__");
132
- const CONFIG_INSTANCE_SYMBOL = Symbol.for("__BDOCS_CONFIG_INSTANCE__");
133
- const globalRegistry = globalThis;
134
- const existingConfigContext = globalRegistry[CONFIG_CONTEXT_SYMBOL];
135
- const ConfigContext = existingConfigContext || createContext(null);
136
- if (!existingConfigContext) globalRegistry[CONFIG_CONTEXT_SYMBOL] = ConfigContext;
137
- /**
138
- * Hook to access the Boltdocs configuration when one is available.
139
- *
140
- * Low-level primitives such as icons can also be rendered standalone (for
141
- * example in a component preview or a unit test), so they must not be forced
142
- * to mount the full application provider just to render an inline SVG.
143
- */
144
- function useOptionalConfig() {
145
- const context = use(ConfigContext);
146
- if (context) return context;
147
- const globalConfig = globalRegistry[CONFIG_INSTANCE_SYMBOL];
148
- if (globalConfig) return globalConfig;
149
- return null;
150
- }
151
- /**
152
- * Hook to access the Boltdocs configuration.
153
- */
154
- function useConfig() {
155
- const config = useOptionalConfig();
156
- if (!config) throw new Error("useConfig must be used within a ConfigProvider");
157
- return config;
158
- }
159
-
160
125
  //#endregion
161
126
  //#region src/client/components/ui-base/icons.tsx
162
127
  var icons_exports = /* @__PURE__ */ __exportAll({
@@ -564,6 +529,66 @@ const FaceBad = createIcon("FaceBad", /* @__PURE__ */ jsxs(Fragment$1, { childre
564
529
  })
565
530
  ] }));
566
531
 
532
+ //#endregion
533
+ //#region src/client/router/prefetch-viewport.ts
534
+ /**
535
+ * Viewport-triggered route prefetching.
536
+ *
537
+ * Hover prefetching only warms a link once the pointer commits to it, which
538
+ * misses the most common case: a reader scrolls the sidebar, reads a heading,
539
+ * and clicks without ever hovering. Every destination they are plausibly
540
+ * heading for sits on screen, untouched.
541
+ *
542
+ * A single shared `IntersectionObserver` watches anchors registered by
543
+ * `Link` and fires the normal prefetch pipeline when one becomes visible, so
544
+ * the route chunk and its loader data are already cached by the time the click
545
+ * lands. Hover keeps working and still wins: whichever signal arrives first
546
+ * populates `prefetchCache`, and the other is a cache hit.
547
+ *
548
+ * The existing prefetch queue bounds the cost (two in flight, a shallow
549
+ * backlog) and drops work when saturated, so this stays opportunistic
550
+ * exactly like hover prefetching is.
551
+ */
552
+ /**
553
+ * Start slightly before the link is on screen so a short scroll already feels
554
+ * instant, without warming the whole page below the fold.
555
+ */
556
+ const VIEWPORT_PREFETCH_MARGIN = "200px 0px";
557
+ let observer = null;
558
+ const pending = /* @__PURE__ */ new WeakMap();
559
+ function getObserver() {
560
+ if (typeof window === "undefined") return null;
561
+ if (typeof IntersectionObserver === "undefined") return null;
562
+ if (observer) return observer;
563
+ observer = new IntersectionObserver((entries) => {
564
+ for (const entry of entries) {
565
+ if (!entry.isIntersecting) continue;
566
+ const run = pending.get(entry.target);
567
+ if (!run) continue;
568
+ observer?.unobserve(entry.target);
569
+ pending.delete(entry.target);
570
+ run();
571
+ }
572
+ }, { rootMargin: VIEWPORT_PREFETCH_MARGIN });
573
+ return observer;
574
+ }
575
+ /**
576
+ * Watches `element` and invokes `run` once it approaches the viewport.
577
+ *
578
+ * Returns a cleanup function. Safe to call during SSR, where it is a no-op.
579
+ */
580
+ function observeForPrefetch(element, run) {
581
+ if (!element) return () => {};
582
+ const target = getObserver();
583
+ if (!target) return () => {};
584
+ pending.set(element, run);
585
+ target.observe(element);
586
+ return () => {
587
+ target.unobserve(element);
588
+ pending.delete(element);
589
+ };
590
+ }
591
+
567
592
  //#endregion
568
593
  //#region src/client/utils/path.ts
569
594
  /**
@@ -590,13 +615,58 @@ function resolvePublicAssetUrl(value, base) {
590
615
 
591
616
  //#endregion
592
617
  //#region src/client/app/routes-context.tsx
618
+ const emptyRouteIndex = {
619
+ byPath: /* @__PURE__ */ new Map(),
620
+ hintsByPath: /* @__PURE__ */ new Map(),
621
+ collectionNames: [],
622
+ byCollectionPath: /* @__PURE__ */ new Map(),
623
+ countsByFilePath: /* @__PURE__ */ new Map()
624
+ };
625
+ function getCollectionPathKey(route) {
626
+ if (!route.collection) return void 0;
627
+ const parts = normalizePath(route.path).split("/").filter(Boolean);
628
+ const collectionIndex = parts.indexOf(route.collection);
629
+ if (collectionIndex < 0) return void 0;
630
+ return `/${parts.slice(collectionIndex).join("/")}`;
631
+ }
632
+ /** Build all client route lookup structures in one cached pass. */
633
+ function createRouteIndex(routes) {
634
+ const byPath = /* @__PURE__ */ new Map();
635
+ const hintsByPath = /* @__PURE__ */ new Map();
636
+ const byCollectionPath = /* @__PURE__ */ new Map();
637
+ const countsByFilePath = /* @__PURE__ */ new Map();
638
+ const collectionNames = /* @__PURE__ */ new Set();
639
+ for (const route of routes) {
640
+ if (!route.path) continue;
641
+ const path = normalizePath(route.path);
642
+ byPath.set(path, route);
643
+ hintsByPath.set(path, {
644
+ path: route.path,
645
+ kind: route.collection ? "collection" : void 0,
646
+ collection: route.collection
647
+ });
648
+ countsByFilePath.set(route.filePath, (countsByFilePath.get(route.filePath) || 0) + 1);
649
+ if (route.collection) {
650
+ collectionNames.add(route.collection);
651
+ const collectionPath = getCollectionPathKey(route);
652
+ if (collectionPath) {
653
+ const variants = byCollectionPath.get(collectionPath) || [];
654
+ variants.push(route);
655
+ byCollectionPath.set(collectionPath, variants);
656
+ }
657
+ }
658
+ }
659
+ return {
660
+ byPath,
661
+ hintsByPath,
662
+ byCollectionPath,
663
+ countsByFilePath,
664
+ collectionNames: [...collectionNames]
665
+ };
666
+ }
593
667
  const RoutesContext = createContext({
594
668
  routes: [],
595
- index: {
596
- byPath: /* @__PURE__ */ new Map(),
597
- hintsByPath: /* @__PURE__ */ new Map(),
598
- collectionNames: []
599
- }
669
+ index: emptyRouteIndex
600
670
  });
601
671
  /**
602
672
  * Hook to access the processed routes list from the closest provider.
@@ -609,27 +679,7 @@ function useRoutesContext() {
609
679
  */
610
680
  function RoutesProvider({ routes: initialRoutes, children }) {
611
681
  const [routes, setRoutes] = useState(initialRoutes);
612
- const index = useMemo(() => {
613
- const byPath = /* @__PURE__ */ new Map();
614
- const hintsByPath = /* @__PURE__ */ new Map();
615
- const collectionNames = /* @__PURE__ */ new Set();
616
- for (const route of routes) {
617
- if (!route.path) continue;
618
- const path = normalizePath(route.path);
619
- byPath.set(path, route);
620
- hintsByPath.set(path, {
621
- path: route.path,
622
- kind: route.collection ? "collection" : void 0,
623
- collection: route.collection
624
- });
625
- if (route.collection) collectionNames.add(route.collection);
626
- }
627
- return {
628
- byPath,
629
- hintsByPath,
630
- collectionNames: [...collectionNames]
631
- };
632
- }, [routes]);
682
+ const index = useMemo(() => createRouteIndex(routes), [routes]);
633
683
  useEffect(() => {
634
684
  if (!import.meta.hot) return;
635
685
  const handler = (payload) => {
@@ -723,74 +773,6 @@ function cn(...inputs) {
723
773
  return twMerge(clsx(inputs));
724
774
  }
725
775
 
726
- //#endregion
727
- //#region src/client/view-transitions.ts
728
- function resolveOptions(options) {
729
- if (options?.enabled === false) return void 0;
730
- return {
731
- enabled: true,
732
- ...options?.types?.length ? { types: options.types } : {}
733
- };
734
- }
735
- function isNativeViewTransitionSupported() {
736
- return typeof document !== "undefined" && typeof document.startViewTransition === "function";
737
- }
738
- /**
739
- * Starts a native document transition when the browser supports it. On older
740
- * browsers, the update still runs normally and the function returns null.
741
- */
742
- function startViewTransition(update, options) {
743
- const resolved = resolveOptions(options);
744
- if (typeof document === "undefined" || resolved?.enabled !== true) {
745
- update();
746
- return null;
747
- }
748
- const start = document.startViewTransition;
749
- if (!start) {
750
- update();
751
- return null;
752
- }
753
- const types = options?.types;
754
- return start.call(document, {
755
- update,
756
- ...types?.length ? { types } : {}
757
- });
758
- }
759
- /**
760
- * Returns a transition-aware runner that follows the project's experimental
761
- * configuration. It is safe to use in custom layouts and external pages.
762
- *
763
- * The returned value is callable for backwards compatibility:
764
- * `transition(() => setState(...))`. It also exposes `run` and `start` aliases
765
- * for discoverability in editor autocomplete.
766
- */
767
- function useViewTransition() {
768
- const configured = useOptionalConfig()?.experimental?.viewTransitions;
769
- const enabled = configured === true || typeof configured === "object" && configured.enabled === true;
770
- const supported = isNativeViewTransitionSupported();
771
- const run = useCallback((update, options) => {
772
- if (!enabled && options?.enabled !== true) {
773
- update();
774
- return null;
775
- }
776
- const configuredTypes = typeof configured === "object" ? configured.types : void 0;
777
- return startViewTransition(update, {
778
- ...options,
779
- types: options?.types || configuredTypes
780
- });
781
- }, [configured, enabled]);
782
- return useMemo(() => Object.assign(run, {
783
- run,
784
- start: run,
785
- enabled,
786
- supported
787
- }), [
788
- enabled,
789
- run,
790
- supported
791
- ]);
792
- }
793
-
794
776
  //#endregion
795
777
  //#region src/client/components/primitives/link.tsx
796
778
  /**
@@ -818,7 +800,7 @@ function Link(props) {
818
800
  }
819
801
  };
820
802
  const handlePrefetch = () => {
821
- if (prefetch === "hover" && localizedHref) prefetchRoute(localizedHref);
803
+ if (prefetch !== "none" && localizedHref) prefetchRoute(localizedHref);
822
804
  };
823
805
  const handleMouseEnter = (e) => {
824
806
  onMouseEnter?.(e);
@@ -828,9 +810,25 @@ function Link(props) {
828
810
  onFocus?.(e);
829
811
  handlePrefetch();
830
812
  };
813
+ const anchorRef = React.useRef(null);
814
+ const setRef = React.useCallback((node) => {
815
+ anchorRef.current = node;
816
+ if (typeof ref === "function") ref(node);
817
+ else if (ref) ref.current = node;
818
+ }, [ref]);
819
+ React.useEffect(() => {
820
+ if (prefetch !== "viewport" || !localizedHref) return;
821
+ return observeForPrefetch(anchorRef.current, () => {
822
+ prefetchRoute(localizedHref);
823
+ });
824
+ }, [
825
+ prefetch,
826
+ localizedHref,
827
+ prefetchRoute
828
+ ]);
831
829
  return /* @__PURE__ */ jsx("a", {
832
830
  ...rest,
833
- ref,
831
+ ref: setRef,
834
832
  href: localizedHref,
835
833
  target: linkTarget,
836
834
  download,
@@ -869,4 +867,4 @@ function NavLink(props) {
869
867
  }
870
868
 
871
869
  //#endregion
872
- export { Languages as A, TextAlignStart as B, FaceBad as C, Hash as D, FileText as E, Moon as F, useOptionalConfig as G, icons_exports as H, MoreVertical as I, BoltdocsProvider as K, Pencil as L, Link$1 as M, Menu as N, Home as O, Monitor as P, Search as R, ExternalLink as S, FaceRegular as T, ConfigContext as U, X as V, useConfig as W, ChevronLeft as _, useViewTransition as a, Copy as b, RoutesProvider as c, resolvePublicAssetUrl as d, AlertCircle as f, ChevronDown as g, Check as h, startViewTransition as i, Lightbulb as j, Info as k, useRoutesContext as l, ArrowLeft as m, NavLink as n, cn as o, AlertTriangle as p, useBoltdocsContext as q, TransitionLink as r, useLocalizedTo as s, Link as t, normalizePath as u, ChevronRight as v, FaceGood as w, CornerDownLeft as x, CircleHelp as y, Sun as z };
870
+ export { Lightbulb as A, X as B, FaceGood as C, Home as D, Hash as E, MoreVertical as F, BoltdocsProvider as H, Pencil as I, Search as L, Menu as M, Monitor as N, Info as O, Moon as P, Sun as R, FaceBad as S, FileText as T, useBoltdocsContext as U, icons_exports as V, ChevronRight as _, useLocalizedTo as a, CornerDownLeft as b, useRoutesContext as c, AlertCircle as d, AlertTriangle as f, ChevronLeft as g, ChevronDown as h, cn as i, Link$1 as j, Languages as k, normalizePath as l, Check as m, NavLink as n, RoutesProvider as o, ArrowLeft as p, TransitionLink as r, createRouteIndex as s, Link as t, resolvePublicAssetUrl as u, CircleHelp as v, FaceRegular as w, ExternalLink as x, Copy as y, TextAlignStart as z };