cloudflare-next-intl 0.9.24 → 0.9.25
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.
|
@@ -1 +1,2 @@
|
|
|
1
|
+
export declare const defaultReloadHtml = "<div style=\"position:fixed;inset:0;background:#ffffff;display:flex;align-items:center;justify-content:center;z-index:9999999;\"><div style=\"width:36px;height:36px;border:3px solid #e5e7eb;border-top-color:#17181b;border-radius:50%;animation:cfni-spin 0.8s linear infinite;\"></div><style>@keyframes cfni-spin{to{transform:rotate(360deg)}}</style></div>";
|
|
1
2
|
export default function HelperScript(): Component | null;
|
|
@@ -4,10 +4,12 @@ import config from "../../config/intl_config.js";
|
|
|
4
4
|
import ClientHelperScript from "../../client/components/client_helper_script.js";
|
|
5
5
|
import { defaultStaleDeployPatterns } from "../../error_handling/is_stale_deploy_error.js";
|
|
6
6
|
const isDev = process.env.NODE_ENV === 'development';
|
|
7
|
+
export const defaultReloadHtml = '<div style="position:fixed;inset:0;background:#ffffff;display:flex;align-items:center;justify-content:center;z-index:9999999;"><div style="width:36px;height:36px;border:3px solid #e5e7eb;border-top-color:#17181b;border-radius:50%;animation:cfni-spin 0.8s linear infinite;"></div><style>@keyframes cfni-spin{to{transform:rotate(360deg)}}</style></div>';
|
|
7
8
|
const appCheck = config.firebaseAuth?.appCheck;
|
|
8
9
|
const shouldLoadExplicitRecaptchaScript = !!appCheck?.recaptchaV3SiteKey && appCheck.useExplicitRecaptchaScript !== false;
|
|
9
10
|
const secureCookieAttribute = isDev ? '+ " Secure;"' : '';
|
|
10
11
|
export default function HelperScript() {
|
|
12
|
+
const reloadHtml = config.errorHandling?.staleDeployReloadHtml ?? defaultReloadHtml;
|
|
11
13
|
return _jsxs(_Fragment, { children: [shouldLoadExplicitRecaptchaScript &&
|
|
12
14
|
_jsx("script", { src: "https://www.google.com/recaptcha/api.js?render=explicit", async: true, defer: true }), !isDev &&
|
|
13
15
|
_jsx("script", { id: "stale-deploy-early-catch", dangerouslySetInnerHTML: {
|
|
@@ -38,10 +40,13 @@ export default function HelperScript() {
|
|
|
38
40
|
}
|
|
39
41
|
attemptedThisLoad = true;
|
|
40
42
|
sessionStorage.setItem(key, buildId);
|
|
41
|
-
console.warn('[StaleDeploy early-catch] Reloading for buildId:', buildId);
|
|
42
43
|
try {
|
|
43
44
|
if (document.documentElement) {
|
|
44
|
-
document.documentElement.style.
|
|
45
|
+
document.documentElement.style.backgroundColor = '#ffffff';
|
|
46
|
+
}
|
|
47
|
+
if (document.body) {
|
|
48
|
+
document.body.style.backgroundColor = '#ffffff';
|
|
49
|
+
document.body.innerHTML = ${JSON.stringify(reloadHtml)};
|
|
45
50
|
}
|
|
46
51
|
} catch (e) {}
|
|
47
52
|
try {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import LinkComponent from 'next/link.js';
|
|
4
|
-
import { forwardRef, useEffect, useState, useTransition, } from 'react';
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useState, useTransition, } from 'react';
|
|
5
5
|
import config from '../../config/intl_config.js';
|
|
6
6
|
import { getLocaleCache } from '../../general/cache_variables.js';
|
|
7
7
|
import { usePathname, useRouter } from 'next/navigation.js';
|
|
@@ -28,7 +28,7 @@ function CustomLinkFunction({ href, prefetch, prefetchType = 'custom', onClick,
|
|
|
28
28
|
useEffect(() => {
|
|
29
29
|
setIsNavigating(false);
|
|
30
30
|
}, [pathname]);
|
|
31
|
-
const triggerPrefetch = () => {
|
|
31
|
+
const triggerPrefetch = useCallback(() => {
|
|
32
32
|
if (!isCustom || !urlString || urlString.startsWith('#') || prefetchedRoutes.has(urlString)) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -38,13 +38,13 @@ function CustomLinkFunction({ href, prefetch, prefetchType = 'custom', onClick,
|
|
|
38
38
|
}
|
|
39
39
|
catch {
|
|
40
40
|
}
|
|
41
|
-
};
|
|
41
|
+
}, [isCustom, urlString, pathnames, router]);
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
if (!isCustom)
|
|
44
44
|
return;
|
|
45
|
-
const timer = setTimeout(triggerPrefetch,
|
|
45
|
+
const timer = setTimeout(triggerPrefetch, 500);
|
|
46
46
|
return () => clearTimeout(timer);
|
|
47
|
-
}, [urlString, isCustom]);
|
|
47
|
+
}, [urlString, isCustom, triggerPrefetch]);
|
|
48
48
|
const handleHoverPrefetch = () => {
|
|
49
49
|
if (isCustom) {
|
|
50
50
|
triggerPrefetch();
|
|
@@ -64,6 +64,7 @@ export interface ErrorHandlingRoutingConfig {
|
|
|
64
64
|
suppressClientConsoleError?: boolean;
|
|
65
65
|
ignoreConsoleErrors?: readonly string[];
|
|
66
66
|
staleDeployPatterns?: readonly string[];
|
|
67
|
+
staleDeployReloadHtml?: string;
|
|
67
68
|
ignoreConsoleError?: (message: string) => boolean;
|
|
68
69
|
overrideWindowErrors?: boolean;
|
|
69
70
|
dedup?: boolean;
|