cloudflare-next-intl 0.8.24 → 0.8.26

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,4 +1,5 @@
1
1
  "use client";
2
+ import reportError from "../../error_handling/report_error";
2
3
  /**
3
4
  * Client-only: reads a `document.cookie` value by name. Pairs with
4
5
  * {@link setCookie} for your OWN client-side cookies — this package's
@@ -28,7 +29,12 @@ export default function getCookie(name) {
28
29
  return decodeURIComponent(value);
29
30
  }
30
31
  catch (e) {
31
- console.error(`Get cookie on client side error: ${e}`);
32
+ void reportError(undefined, {
33
+ error: e,
34
+ classOrMethodName: 'getCookie',
35
+ isClient: true,
36
+ params: { name },
37
+ });
32
38
  return null;
33
39
  }
34
40
  }
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import reportError from "../../error_handling/report_error";
2
3
  /**
3
4
  * Client-only: sets a `document.cookie` value directly. Not used by this
4
5
  * package's own locale handling (that goes through `intlMiddleware` server-side)
@@ -21,7 +22,12 @@ export default function setCookie({ name, value, maxAge }) {
21
22
  document.cookie = cookieString;
22
23
  }
23
24
  catch (e) {
24
- console.error(`Set cookie on client side error: ${e}`);
25
+ void reportError(undefined, {
26
+ error: e,
27
+ classOrMethodName: 'setCookie',
28
+ isClient: true,
29
+ params: { name },
30
+ });
25
31
  }
26
32
  }
27
33
  ;
@@ -3,6 +3,7 @@ import { languageDetecotr } from '../server/functions/get_user_locale';
3
3
  import config from './intl_config';
4
4
  import { isBotCookieKey, localeCookieName } from './cookie_key';
5
5
  import { cache } from 'react';
6
+ import reportError from '../error_handling/report_error';
6
7
  const sameSite = false;
7
8
  const defaultCookieOption = {
8
9
  path: '/', // Cookie is valid for the entire domain
@@ -149,8 +150,10 @@ export default async function intlMiddleware(request, options) {
149
150
  return response;
150
151
  }
151
152
  catch (e) {
152
- console.error('[cloudflare-next-intl] intlMiddleware failed and fell back to passing the request through unmodified ' +
153
- '(no locale rewrite/redirect, no firebase_auth session refresh). Underlying error:', e);
153
+ void reportError({ errorHandling: config.errorHandling, generate: config.generate }, {
154
+ error: e,
155
+ classOrMethodName: 'intlMiddleware',
156
+ });
154
157
  return NextResponse.next({
155
158
  request,
156
159
  });
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import { useEffect } from 'react';
3
+ import reportError from '../../../error_handling/report_error';
3
4
  let cachedClarityModule;
4
5
  function getClarityModule() {
5
6
  if (!cachedClarityModule) {
@@ -21,7 +22,11 @@ export default function ClarityScript({ projectId }) {
21
22
  Clarity.init(projectId);
22
23
  Clarity.consent();
23
24
  })
24
- .catch((error) => console.error(`cloudflare-next-intl: failed to load @microsoft/clarity: ${error}`));
25
+ .catch((error) => void reportError(undefined, {
26
+ error,
27
+ classOrMethodName: 'ClarityScript',
28
+ isClient: true,
29
+ }));
25
30
  }, [projectId]);
26
31
  return null;
27
32
  }
@@ -35,6 +35,8 @@ function resolveActionModePaths(fa) {
35
35
  paths.verifyEmail = fa.verifyEmailPath;
36
36
  if (fa.recoverEmailPath)
37
37
  paths.recoverEmail = fa.recoverEmailPath;
38
+ if (fa.signInPath)
39
+ paths.signIn = fa.signInPath;
38
40
  return { ...paths, ...fa.actionModePaths };
39
41
  }
40
42
  export const DEFAULT_SESSION_MAX_AGE = 60 * 60 * 24 * 5;
@@ -256,7 +258,13 @@ export default async function updateSession(request, baseResponse, locale, rebui
256
258
  continuePath = '/';
257
259
  }
258
260
  }
259
- if (continuePath !== '/') {
261
+ // A continueUrl pointing back at the request's own
262
+ // path (e.g. the single project-wide action URL
263
+ // echoing itself as `actionCodeSettings.url`)
264
+ // carries no routing information — keep the
265
+ // mode-derived target instead of overwriting it
266
+ // with a no-op.
267
+ if (continuePath !== '/' && continuePath !== path) {
260
268
  target = continuePath;
261
269
  }
262
270
  }
@@ -1,4 +1,5 @@
1
1
  import { setTranslationCache } from "./cache_variables";
2
+ import reportError from "../error_handling/report_error";
2
3
  /**
3
4
  * Logs a warning message and returns a fallback translation function.
4
5
  * This function helps in debugging missing translations or incorrect structures.
@@ -16,7 +17,11 @@ const errorAndReturnFallback = (message, cacheKey, locale, namespace, key) => {
16
17
  key ? `Key: "${key}"` : '',
17
18
  `Locale: "${locale}"`,
18
19
  ].filter(Boolean); // Filter out empty parts
19
- console.error(parts.join(' | '));
20
+ void reportError(undefined, {
21
+ error: parts.join(' | '),
22
+ classOrMethodName: 'getTranslationsImpl',
23
+ params: { locale, namespace, key },
24
+ });
20
25
  const fallbackFn = (k) => k; // Fallback function simply returns the key
21
26
  fallbackFn.raw = (k) => k;
22
27
  setTranslationCache(cacheKey, fallbackFn);
@@ -1,5 +1,6 @@
1
1
  import { cache } from "react";
2
2
  import config from "../config/intl_config";
3
+ import reportError from "../error_handling/report_error";
3
4
  /**
4
5
  * Builds the `alternates` field for Next's `generateMetadata` — a canonical
5
6
  * URL plus per-locale `hreflang` links, exported memoized as `alternatesLinks`
@@ -34,7 +35,11 @@ export function iAlternatesLinks({ locale, url, canonical, linkPart }) {
34
35
  };
35
36
  }
36
37
  catch (e) {
37
- console.error(`[cloudflare-next-intl] alternatesLinks failed for url="${url}" linkPart="${linkPart}" — returning undefined, so "alternates" will be omitted from your metadata. Underlying error:`, e);
38
+ void reportError({ errorHandling: config.errorHandling, generate: config.generate }, {
39
+ error: e,
40
+ classOrMethodName: 'alternatesLinks',
41
+ params: { url, linkPart },
42
+ });
38
43
  return undefined;
39
44
  }
40
45
  }
@@ -1,6 +1,7 @@
1
1
  import { cache } from "react";
2
2
  import config from "../../config/intl_config";
3
3
  import { localesSet } from "../../config/middleware";
4
+ import reportError from "../../error_handling/report_error";
4
5
  export const languageDetecotr = cache(languageDetecotrImpl);
5
6
  // Helper function to determine the best matching locale from the Accept-Language header
6
7
  function languageDetecotrImpl(acceptLanguageHeader) {
@@ -31,7 +32,11 @@ function languageDetecotrImpl(acceptLanguageHeader) {
31
32
  return localeValue ? localeValue.locale : config.defaultLocale;
32
33
  }
33
34
  catch (e) {
34
- console.error(`Language Detect Error: acceptLanguageHeader: ${acceptLanguageHeader}, Error: ${e}`);
35
+ void reportError({ errorHandling: config.errorHandling, generate: config.generate }, {
36
+ error: e,
37
+ classOrMethodName: 'languageDetecotr',
38
+ params: { acceptLanguageHeader },
39
+ });
35
40
  return config.defaultLocale;
36
41
  }
37
42
  }
@@ -4,6 +4,7 @@ import { localeCookieName } from "../../config/cookie_key";
4
4
  import { getLocaleCache, getMessageCache, getTranslationCache, setLocaleCache, setMessageForLocaleCache } from "../../general/cache_variables";
5
5
  import { cache } from "react";
6
6
  import { localesSet } from "../../config/middleware";
7
+ import reportError from "../../error_handling/report_error";
7
8
  const isDev = process.env.NODE_ENV === 'development';
8
9
  let nextHeadersModule;
9
10
  /**
@@ -116,7 +117,10 @@ async function iGetLocale() {
116
117
  return localeValue;
117
118
  }
118
119
  catch (error) {
119
- console.error(`Error accessing cookies in getLocale, falling back to default: ${error}`);
120
+ void reportError({ errorHandling: config.errorHandling, generate: config.generate }, {
121
+ error,
122
+ classOrMethodName: 'getLocale',
123
+ });
120
124
  setLocaleCache(config.defaultLocale); // Cache fallback language on error
121
125
  return config.defaultLocale;
122
126
  }
@@ -508,6 +508,13 @@ export interface FirebaseAuthRoutingConfig {
508
508
  * warning.
509
509
  */
510
510
  recoverEmailPath?: string;
511
+ /**
512
+ * Path handling an emailed passwordless `signIn` action link. Omit to
513
+ * leave that mode unhandled — the request then falls through to normal
514
+ * routing instead of being forwarded. Must start with "/" —
515
+ * `setIntlConfig` auto-corrects a missing leading slash with a warning.
516
+ */
517
+ signInPath?: string;
511
518
  /**
512
519
  * Extra/overriding `?mode=` → path entries for the emailed-action-link
513
520
  * forward described on {@link resetPasswordPath}. Merged over the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.8.24",
3
+ "version": "0.8.26",
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",