cloudflare-next-intl 0.9.19 → 0.9.20

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/README.md CHANGED
@@ -687,7 +687,7 @@ export default function GlobalError({
687
687
  }
688
688
  ```
689
689
 
690
- - `useStaleDeployRecovery(error: unknown, onRecover?: () => Promise<unknown>, delayMs = 5000): boolean`: Detects a stale-deploy error via `isStaleDeployError` and, **once per build id**, waits `delayMs`, runs `onRecover` (if provided) and `clearClientCache` in parallel, then reloads the page. The build id is read from `localStorage['buildId']` (set by `IntlHelperScript`'s `BUILD_ID` check) and a `sessionStorage` marker records which build id already spent its reload, so a repeat failure on the same build falls through to `false` (render your normal error UI) instead of reloading forever. A redeploy changes the build id and re-arms exactly one more attempt. **Exception:** if the build id was written within the last 60 seconds (`localStorage['buildIdSetAt']`, also set by `IntlHelperScript`), the hook recovers anyway — a stale-deploy error moments after adopting a new build is the deploy still settling, not a real failure, so the one-reload cap is bypassed for that window.
690
+ - `useStaleDeployRecovery(error: unknown, onRecover?: () => Promise<unknown>, delayMs = 5000): boolean`: Detects a stale-deploy error via `isStaleDeployError` and, **once per build id**, waits `delayMs`, runs `onRecover` (if provided) and `clearClientCache` in parallel, then reloads the page. The build id is read from `localStorage['buildId']` (set by `IntlHelperScript`'s `BUILD_ID` check) and a `sessionStorage` marker records which build id already spent its reload, so a repeat failure on the same build falls through to `false` (render your normal error UI) instead of reloading forever. A redeploy changes the build id and re-arms exactly one more attempt.
691
691
  - `shouldRecoverFromStaleDeploy(error: unknown, buildId: string, marker: string | null, recentBuild = false): boolean`: The pure predicate behind the hook, exported for testing.
692
692
  - `isRecentBuild(setAt: number | null, now: number, windowMs = 60000): boolean`: Whether `setAt` (typically `buildIdSetAt`) falls within `windowMs` of `now`.
693
693
 
@@ -1,3 +1,3 @@
1
1
  export declare function isRecentBuild(setAt: number | null, now: number, windowMs?: number): boolean;
2
- export declare function shouldRecoverFromStaleDeploy(error: unknown, buildId: string, marker: string | null, recentBuild?: boolean): boolean;
2
+ export declare function shouldRecoverFromStaleDeploy(error: unknown, buildId: string, marker: string | null, _recentBuild?: boolean): boolean;
3
3
  export default function useStaleDeployRecovery(error: unknown, onRecover?: () => Promise<unknown>, delayMs?: number): boolean;
@@ -26,9 +26,9 @@ function buildIdSetAt() {
26
26
  export function isRecentBuild(setAt, now, windowMs = RECENT_BUILD_WINDOW_MS) {
27
27
  return setAt !== null && now - setAt < windowMs;
28
28
  }
29
- export function shouldRecoverFromStaleDeploy(error, buildId, marker, recentBuild = false) {
29
+ export function shouldRecoverFromStaleDeploy(error, buildId, marker, _recentBuild = false) {
30
30
  const isMarkerActive = marker !== null && marker !== '' && (buildId === 'unknown' || marker === buildId);
31
- return isStaleDeployError(error) && (!isMarkerActive || recentBuild);
31
+ return isStaleDeployError(error) && !isMarkerActive;
32
32
  }
33
33
  function canRecover(error) {
34
34
  if (typeof window === 'undefined')
@@ -12,11 +12,16 @@ export function LocalTime({ format, timestampMs }) {
12
12
  }
13
13
  export function CopyButton({ text, label = 'Copy', copiedLabel = 'Copied', }) {
14
14
  const [copied, setCopied] = useState(false);
15
+ useEffect(() => {
16
+ if (!copied)
17
+ return;
18
+ const timer = setTimeout(() => setCopied(false), 1500);
19
+ return () => clearTimeout(timer);
20
+ }, [copied]);
15
21
  function handleCopy(event) {
16
22
  event.preventDefault();
17
23
  void navigator.clipboard.writeText(text).then(() => {
18
24
  setCopied(true);
19
- setTimeout(() => setCopied(false), 1500);
20
25
  });
21
26
  }
22
27
  return (_jsx("button", { type: "button", onClick: handleCopy, className: "rounded-md border border-gray-300 px-2 py-1 text-[11px] font-medium text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200", children: copied ? copiedLabel : label }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.19",
3
+ "version": "0.9.20",
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",