cloudflare-next-intl 0.9.26 → 0.9.27

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.
@@ -3,15 +3,6 @@ export const defaultStaleDeployPatterns = [
3
3
  'dynamically imported module',
4
4
  'failed to fetch',
5
5
  'loading css chunk',
6
- 'connection closed',
7
- 'rsc payload',
8
- 'minified react error #412',
9
- 'the above error occurred in a react component',
10
- 'the connection to the page was unexpectedly closed',
11
- 'readablestream',
12
- 'readable stream',
13
- 'uncaught exception: undefined',
14
- 'uncaught undefined',
15
6
  'server action not found',
16
7
  'unrecognizedactionerror',
17
8
  ];
@@ -9,9 +9,6 @@ const prefetchedRoutes = new Set();
9
9
  function CustomLinkFunction({ href, prefetch, prefetchType = 'custom', onClick, onMouseEnter, onPointerDown, ...rest }, ref) {
10
10
  const localeValue = getLocaleCache();
11
11
  const router = useRouter();
12
- const pathname = usePathname();
13
- const [isPending, startTransition] = useTransition();
14
- const [isNavigating, setIsNavigating] = useState(false);
15
12
  const needsLangPath = localeValue !== config.defaultLocale || !localeValue;
16
13
  let pathnames;
17
14
  let urlString;
@@ -24,10 +21,13 @@ function CustomLinkFunction({ href, prefetch, prefetchType = 'custom', onClick,
24
21
  pathnames = href;
25
22
  urlString = typeof href === 'object' ? (href.pathname || '') : (href || '');
26
23
  }
27
- const isCustom = prefetchType === 'custom' && prefetch !== false;
24
+ const pathname = usePathname();
25
+ const [isPending, startTransition] = useTransition();
26
+ const [isNavigating, setIsNavigating] = useState(false);
28
27
  useEffect(() => {
29
28
  setIsNavigating(false);
30
29
  }, [pathname]);
30
+ const isCustom = prefetchType === 'custom' && prefetch !== false;
31
31
  const triggerPrefetch = useCallback(() => {
32
32
  if (!isCustom || !urlString || urlString.startsWith('#') || prefetchedRoutes.has(urlString)) {
33
33
  return;
@@ -42,7 +42,7 @@ function CustomLinkFunction({ href, prefetch, prefetchType = 'custom', onClick,
42
42
  useEffect(() => {
43
43
  if (!isCustom)
44
44
  return;
45
- const timer = setTimeout(triggerPrefetch, 500);
45
+ const timer = setTimeout(triggerPrefetch, 100);
46
46
  return () => clearTimeout(timer);
47
47
  }, [urlString, isCustom, triggerPrefetch]);
48
48
  const handleHoverPrefetch = () => {
@@ -59,9 +59,12 @@ function CustomLinkFunction({ href, prefetch, prefetchType = 'custom', onClick,
59
59
  return;
60
60
  }
61
61
  if (isCustom) {
62
- setIsNavigating(true);
62
+ const targetPath = typeof pathnames === 'string' ? pathnames : urlString;
63
+ if (pathname !== targetPath) {
64
+ setIsNavigating(true);
65
+ }
63
66
  startTransition(() => {
64
- router.push(typeof pathnames === 'string' ? pathnames : urlString);
67
+ router.push(targetPath);
65
68
  });
66
69
  e.preventDefault();
67
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.26",
3
+ "version": "0.9.27",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",