@jk2908/solas 0.17.0 → 0.17.1
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/CHANGELOG.md +6 -0
- package/dist/internal/browser-router/link.js +15 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,22 +5,33 @@ import { usePrefetchObserver } from './prefetch-observer.js';
|
|
|
5
5
|
import * as BrowserRouter from './shared.js';
|
|
6
6
|
import { useRouter } from './use-router.js';
|
|
7
7
|
const HOVER_DELAY = 100;
|
|
8
|
+
function isCurrent(path) {
|
|
9
|
+
try {
|
|
10
|
+
const url = new URL(path, window.location.href);
|
|
11
|
+
return (url.pathname === window.location.pathname && url.search === window.location.search);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
function guard(path, prefetcher) {
|
|
9
|
-
const connection = window.navigator.connection;
|
|
10
18
|
if (document.visibilityState === 'hidden')
|
|
11
19
|
return;
|
|
20
|
+
const connection = window.navigator.connection;
|
|
12
21
|
if (connection?.saveData)
|
|
13
22
|
return;
|
|
14
23
|
if (['2g', 'slow-2g'].includes(connection?.effectiveType ?? ''))
|
|
15
24
|
return;
|
|
25
|
+
if (isCurrent(path))
|
|
26
|
+
return;
|
|
16
27
|
prefetcher(path);
|
|
17
28
|
}
|
|
18
|
-
function getPrefetchStrategy(prefetch,
|
|
29
|
+
function getPrefetchStrategy(prefetch, hoverable, observable) {
|
|
19
30
|
if (prefetch !== 'auto')
|
|
20
31
|
return prefetch;
|
|
21
|
-
if (
|
|
32
|
+
if (hoverable)
|
|
22
33
|
return 'hover';
|
|
23
|
-
return
|
|
34
|
+
return observable ? 'viewport' : 'intent';
|
|
24
35
|
}
|
|
25
36
|
export function Link({ children, href, params, prefetch = false, query, ref, scroll, ...rest }) {
|
|
26
37
|
const { go, prefetch: prefetcher } = useRouter();
|
package/package.json
CHANGED