@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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Fixes
6
+
7
+ - Links no longer prefetch the route currently displayed. The comparison uses pathname and search, so the same path with a different query still prefetches.
8
+
3
9
  ## 0.17.0
4
10
 
5
11
  ### Breaking
@@ -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, hover, hasObserver) {
29
+ function getPrefetchStrategy(prefetch, hoverable, observable) {
19
30
  if (prefetch !== 'auto')
20
31
  return prefetch;
21
- if (hover)
32
+ if (hoverable)
22
33
  return 'hover';
23
- return hasObserver ? 'viewport' : 'intent';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jk2908/solas",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "A Vite + React meta-framework exploring streaming, Server Components, and partial prerendering. Designed for simplicity and lightness",
5
5
  "keywords": [
6
6
  "framework",