cloudflare-next-intl 0.6.3 → 0.6.5

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.
Files changed (148) hide show
  1. package/dist/src/error_handling/create_server_error_action.d.ts +19 -6
  2. package/dist/src/error_handling/create_server_error_action.js +19 -7
  3. package/dist/src/error_handling/default_ignored_console_errors.js +6 -0
  4. package/dist/src/firebase_auth/client/auth_user_provider.js +25 -20
  5. package/dist/src/firebase_auth/index.d.ts +1 -0
  6. package/dist/src/firebase_auth/index.js +1 -0
  7. package/dist/src/firebase_auth/server/clear_session_action.d.ts +7 -0
  8. package/dist/src/firebase_auth/server/clear_session_action.js +20 -0
  9. package/package.json +1 -1
  10. package/dist/types/client/components/client_helper_script.d.ts +0 -1
  11. package/dist/types/client/components/client_provider.d.ts +0 -34
  12. package/dist/types/client/components/locale_link.d.ts +0 -30
  13. package/dist/types/client/components/locale_link_client.d.ts +0 -3
  14. package/dist/types/client/functions/get_cookie.bench.d.ts +0 -1
  15. package/dist/types/client/functions/get_cookie.d.ts +0 -10
  16. package/dist/types/client/functions/get_cookie.test.d.ts +0 -1
  17. package/dist/types/client/functions/set_cookie.bench.d.ts +0 -1
  18. package/dist/types/client/functions/set_cookie.d.ts +0 -21
  19. package/dist/types/client/functions/set_cookie.test.d.ts +0 -1
  20. package/dist/types/client/hooks/client_hooks.bench.d.ts +0 -1
  21. package/dist/types/client/hooks/client_hooks.d.ts +0 -28
  22. package/dist/types/client/hooks/use_path_name.bench.d.ts +0 -1
  23. package/dist/types/client/hooks/use_path_name.d.ts +0 -10
  24. package/dist/types/client/index.d.ts +0 -4
  25. package/dist/types/config/cookie_key.bench.d.ts +0 -1
  26. package/dist/types/config/cookie_key.d.ts +0 -5
  27. package/dist/types/config/cookie_key.test.d.ts +0 -1
  28. package/dist/types/config/index.d.ts +0 -4
  29. package/dist/types/config/init_config.bench.d.ts +0 -1
  30. package/dist/types/config/init_config.d.ts +0 -18
  31. package/dist/types/config/init_config.test.d.ts +0 -1
  32. package/dist/types/config/intl_config.d.ts +0 -3
  33. package/dist/types/config/intl_config.test.d.ts +0 -1
  34. package/dist/types/config/intl_sitemap.bench.d.ts +0 -1
  35. package/dist/types/config/intl_sitemap.d.ts +0 -8
  36. package/dist/types/config/intl_sitemap.test.d.ts +0 -1
  37. package/dist/types/config/middleware.bench.d.ts +0 -1
  38. package/dist/types/config/middleware.d.ts +0 -21
  39. package/dist/types/config/middleware.test.d.ts +0 -1
  40. package/dist/types/cookie_consent/client/components/clarity_script.d.ts +0 -10
  41. package/dist/types/cookie_consent/client/components/cookie_consent_analytics.bench.d.ts +0 -1
  42. package/dist/types/cookie_consent/client/components/cookie_consent_analytics.d.ts +0 -19
  43. package/dist/types/cookie_consent/client/components/cookie_consent_dialog.d.ts +0 -35
  44. package/dist/types/cookie_consent/client/components/default_dialog_styles.d.ts +0 -2
  45. package/dist/types/cookie_consent/client/components/default_dialog_text.d.ts +0 -13
  46. package/dist/types/cookie_consent/client/components/default_privacy_policy_link.d.ts +0 -14
  47. package/dist/types/cookie_consent/client/components/dialog_portal.d.ts +0 -11
  48. package/dist/types/cookie_consent/client/components/privacy_policy_update_dialog.d.ts +0 -31
  49. package/dist/types/cookie_consent/client/cookie_consent_provider.bench.d.ts +0 -1
  50. package/dist/types/cookie_consent/client/cookie_consent_provider.d.ts +0 -39
  51. package/dist/types/cookie_consent/client/use_cookie_consent.d.ts +0 -6
  52. package/dist/types/cookie_consent/gdpr_countries.bench.d.ts +0 -1
  53. package/dist/types/cookie_consent/gdpr_countries.d.ts +0 -18
  54. package/dist/types/cookie_consent/gdpr_countries.perf.test.d.ts +0 -1
  55. package/dist/types/cookie_consent/gdpr_countries.test.d.ts +0 -1
  56. package/dist/types/cookie_consent/index.d.ts +0 -10
  57. package/dist/types/cookie_consent/require_config.d.ts +0 -7
  58. package/dist/types/cookie_consent/require_config.test.d.ts +0 -1
  59. package/dist/types/cookie_consent/types.d.ts +0 -57
  60. package/dist/types/error_handling/create_server_error_action.d.ts +0 -19
  61. package/dist/types/error_handling/create_server_error_action.test.d.ts +0 -1
  62. package/dist/types/error_handling/default_ignored_console_errors.d.ts +0 -13
  63. package/dist/types/error_handling/default_ignored_console_errors.test.d.ts +0 -1
  64. package/dist/types/error_handling/format_error_message.d.ts +0 -9
  65. package/dist/types/error_handling/format_error_message.test.d.ts +0 -1
  66. package/dist/types/error_handling/index.d.ts +0 -9
  67. package/dist/types/error_handling/install_console_error_override.bench.d.ts +0 -1
  68. package/dist/types/error_handling/install_console_error_override.d.ts +0 -29
  69. package/dist/types/error_handling/install_console_error_override.perf.test.d.ts +0 -1
  70. package/dist/types/error_handling/install_console_error_override.test.d.ts +0 -1
  71. package/dist/types/error_handling/report_error.bench.d.ts +0 -1
  72. package/dist/types/error_handling/report_error.d.ts +0 -40
  73. package/dist/types/error_handling/report_error.perf.test.d.ts +0 -1
  74. package/dist/types/error_handling/report_error.test.d.ts +0 -1
  75. package/dist/types/error_handling/stringify_unknown.bench.d.ts +0 -1
  76. package/dist/types/error_handling/stringify_unknown.d.ts +0 -12
  77. package/dist/types/error_handling/stringify_unknown.test.d.ts +0 -1
  78. package/dist/types/error_handling/with_error_handling.d.ts +0 -15
  79. package/dist/types/error_handling/with_error_handling.test.d.ts +0 -1
  80. package/dist/types/firebase_auth/client/auth_actions.bench.d.ts +0 -1
  81. package/dist/types/firebase_auth/client/auth_actions.d.ts +0 -46
  82. package/dist/types/firebase_auth/client/auth_actions.test.d.ts +0 -1
  83. package/dist/types/firebase_auth/client/auth_user_cache.bench.d.ts +0 -1
  84. package/dist/types/firebase_auth/client/auth_user_cache.d.ts +0 -4
  85. package/dist/types/firebase_auth/client/auth_user_cache.test.d.ts +0 -1
  86. package/dist/types/firebase_auth/client/auth_user_provider.d.ts +0 -36
  87. package/dist/types/firebase_auth/client/firebase_client.bench.d.ts +0 -1
  88. package/dist/types/firebase_auth/client/firebase_client.d.ts +0 -20
  89. package/dist/types/firebase_auth/client/firebase_client.test.d.ts +0 -1
  90. package/dist/types/firebase_auth/client/use_auth_user.bench.d.ts +0 -1
  91. package/dist/types/firebase_auth/client/use_auth_user.d.ts +0 -12
  92. package/dist/types/firebase_auth/error_messages/default_messages.en.bench.d.ts +0 -1
  93. package/dist/types/firebase_auth/error_messages/default_messages.en.d.ts +0 -1
  94. package/dist/types/firebase_auth/error_messages/default_messages.en.test.d.ts +0 -1
  95. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.bench.d.ts +0 -1
  96. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.d.ts +0 -6
  97. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.test.d.ts +0 -1
  98. package/dist/types/firebase_auth/index.d.ts +0 -9
  99. package/dist/types/firebase_auth/middleware/update_session.bench.d.ts +0 -1
  100. package/dist/types/firebase_auth/middleware/update_session.d.ts +0 -22
  101. package/dist/types/firebase_auth/middleware/update_session.test.d.ts +0 -1
  102. package/dist/types/firebase_auth/require_config.bench.d.ts +0 -1
  103. package/dist/types/firebase_auth/require_config.d.ts +0 -8
  104. package/dist/types/firebase_auth/require_config.test.d.ts +0 -1
  105. package/dist/types/firebase_auth/server/auth_user_server_provider.d.ts +0 -29
  106. package/dist/types/firebase_auth/server/firebase_server.bench.d.ts +0 -1
  107. package/dist/types/firebase_auth/server/firebase_server.d.ts +0 -15
  108. package/dist/types/firebase_auth/server/firebase_server.perf.test.d.ts +0 -1
  109. package/dist/types/firebase_auth/server/firebase_server.test.d.ts +0 -1
  110. package/dist/types/firebase_auth/server/use_auth_user_server.bench.d.ts +0 -1
  111. package/dist/types/firebase_auth/server/use_auth_user_server.d.ts +0 -39
  112. package/dist/types/firebase_auth/server/use_auth_user_server.test.d.ts +0 -1
  113. package/dist/types/firebase_auth/types.d.ts +0 -22
  114. package/dist/types/general/cache_variables.bench.d.ts +0 -1
  115. package/dist/types/general/cache_variables.d.ts +0 -14
  116. package/dist/types/general/cache_variables.test.d.ts +0 -1
  117. package/dist/types/general/general_functions.bench.d.ts +0 -1
  118. package/dist/types/general/general_functions.d.ts +0 -2
  119. package/dist/types/general/general_functions.test.d.ts +0 -1
  120. package/dist/types/general/index.d.ts +0 -2
  121. package/dist/types/general/metadata.bench.d.ts +0 -1
  122. package/dist/types/general/metadata.d.ts +0 -38
  123. package/dist/types/general/metadata.test.d.ts +0 -1
  124. package/dist/types/index.d.ts +0 -6
  125. package/dist/types/server/components/helper_script.d.ts +0 -20
  126. package/dist/types/server/components/link.d.ts +0 -25
  127. package/dist/types/server/components/server_provider.d.ts +0 -35
  128. package/dist/types/server/functions/get_user_locale.bench.d.ts +0 -1
  129. package/dist/types/server/functions/get_user_locale.d.ts +0 -3
  130. package/dist/types/server/functions/get_user_locale.test.d.ts +0 -1
  131. package/dist/types/server/functions/locale_static_params.d.ts +0 -15
  132. package/dist/types/server/functions/locale_static_params.test.d.ts +0 -1
  133. package/dist/types/server/functions/server.bench.d.ts +0 -1
  134. package/dist/types/server/functions/server.d.ts +0 -67
  135. package/dist/types/server/functions/server.perf.test.d.ts +0 -1
  136. package/dist/types/server/functions/server.test.d.ts +0 -1
  137. package/dist/types/server/functions/use_functions.bench.d.ts +0 -1
  138. package/dist/types/server/functions/use_functions.d.ts +0 -33
  139. package/dist/types/server/functions/use_functions.test.d.ts +0 -1
  140. package/dist/types/server/index.d.ts +0 -5
  141. package/dist/types/test_utils/mock_intl_config.d.ts +0 -3
  142. package/dist/types/test_utils/mock_next_server.d.ts +0 -5
  143. package/dist/types/theme_switcher/components/icons.d.ts +0 -6
  144. package/dist/types/theme_switcher/components/theme_switcher.d.ts +0 -15
  145. package/dist/types/theme_switcher/components/theme_switcher_button.d.ts +0 -6
  146. package/dist/types/theme_switcher/index.d.ts +0 -1
  147. package/dist/types/types/index.d.ts +0 -1
  148. package/dist/types/types/types.d.ts +0 -548
@@ -1,13 +1,26 @@
1
1
  import type { ErrorHandlingParams } from '../types/types';
2
2
  import { type ReportErrorConfig } from './report_error';
3
3
  /**
4
- * Creates a `"use server"` action that reports a client-originated error via
5
- * `reportError`, so `config` (and anything it closes over — secrets,
4
+ * Builds a function that reports a client-originated error via
5
+ * `reportError`, meant to be re-exported directly from your OWN
6
+ * `"use server"` file so `config` (and anything it closes over — secrets,
6
7
  * `Secrets.telegramBotToken`-style env reads inside your `onError`) never
7
- * has to be imported into client-side code. Call this once (server-side,
8
- * e.g. next to your `RoutingConfig`) and pass the returned function to
9
- * client components that need to report an error — they only ever handle
10
- * the error value itself, never `config`.
8
+ * has to be imported into client-side code:
9
+ *
10
+ * ```ts
11
+ * // report_client_error.ts
12
+ * "use server";
13
+ * import createServerErrorAction from "cloudflare-next-intl/createServerErrorAction";
14
+ * import intlConfig from "./intl_config";
15
+ * export const reportClientError = createServerErrorAction(intlConfig);
16
+ * ```
17
+ *
18
+ * This function itself must NOT be called from a file marked `"use server"`
19
+ * — Next.js requires every top-level export of such a file to be an async
20
+ * function directly; a factory that returns one doesn't qualify. Put
21
+ * `"use server"` in your OWN file (as above), not in a file that calls
22
+ * `createServerErrorAction` and re-exports its result under a different
23
+ * name than a plain `const`.
11
24
  *
12
25
  * The error is stringified before crossing the client→server action
13
26
  * boundary (Next.js server actions serialize arguments; an `Error` instance
@@ -1,14 +1,26 @@
1
- "use server";
2
1
  import reportError from './report_error';
3
2
  import stringifyUnknown from './stringify_unknown';
4
3
  /**
5
- * Creates a `"use server"` action that reports a client-originated error via
6
- * `reportError`, so `config` (and anything it closes over — secrets,
4
+ * Builds a function that reports a client-originated error via
5
+ * `reportError`, meant to be re-exported directly from your OWN
6
+ * `"use server"` file so `config` (and anything it closes over — secrets,
7
7
  * `Secrets.telegramBotToken`-style env reads inside your `onError`) never
8
- * has to be imported into client-side code. Call this once (server-side,
9
- * e.g. next to your `RoutingConfig`) and pass the returned function to
10
- * client components that need to report an error — they only ever handle
11
- * the error value itself, never `config`.
8
+ * has to be imported into client-side code:
9
+ *
10
+ * ```ts
11
+ * // report_client_error.ts
12
+ * "use server";
13
+ * import createServerErrorAction from "cloudflare-next-intl/createServerErrorAction";
14
+ * import intlConfig from "./intl_config";
15
+ * export const reportClientError = createServerErrorAction(intlConfig);
16
+ * ```
17
+ *
18
+ * This function itself must NOT be called from a file marked `"use server"`
19
+ * — Next.js requires every top-level export of such a file to be an async
20
+ * function directly; a factory that returns one doesn't qualify. Put
21
+ * `"use server"` in your OWN file (as above), not in a file that calls
22
+ * `createServerErrorAction` and re-exports its result under a different
23
+ * name than a plain `const`.
12
24
  *
13
25
  * The error is stringified before crossing the client→server action
14
26
  * boundary (Next.js server actions serialize arguments; an `Error` instance
@@ -24,4 +24,10 @@ export const defaultIgnoredConsoleErrors = [
24
24
  'auth/expired-action-code',
25
25
  'auth/invalid-action-code',
26
26
  'auth/user-token-expired',
27
+ 'The `punycode` module is deprecated. Please use a userland alternative instead.',
28
+ 'failed to pipe response',
29
+ 'Failed to fetch RSC payload',
30
+ ...(process.env.NODE_ENV === 'development'
31
+ ? ['A DurableObjectNamespace in the config referenced the class "DOQueueHandler", but no such Durable Object class is exported from the worker. Please make sure the class name matches,']
32
+ : []),
27
33
  ];
@@ -9,6 +9,7 @@ import { getFirebaseAuthClient, getFirebaseAuthModule } from './firebase_client'
9
9
  import { setAuthUserCache } from './auth_user_cache';
10
10
  import { defaultRefreshTokenCookieName, defaultSessionCookieName } from '../middleware/update_session';
11
11
  import setCookie from '../../client/functions/set_cookie';
12
+ import clearSessionAction from '../server/clear_session_action';
12
13
  // `null` default (instead of a `{ loading: true, ... }` stand-in) lets
13
14
  // `useAuthUser` distinguish "not wrapped in AuthUserProvider" (throw) from
14
15
  // "wrapped, still loading" (`loading: true`).
@@ -25,6 +26,25 @@ function writeRefreshTokenCookie(refreshTokenCookieName, user, maxAge) {
25
26
  function clearRefreshTokenCookie(refreshTokenCookieName) {
26
27
  setCookie({ name: refreshTokenCookieName, value: '', maxAge: 0 });
27
28
  }
29
+ async function clearSession(sessionCookieName, refreshTokenCookieName) {
30
+ clearSessionCookie(sessionCookieName);
31
+ clearRefreshTokenCookie(refreshTokenCookieName);
32
+ try {
33
+ await clearSessionAction();
34
+ }
35
+ catch (e) {
36
+ console.error('AuthUserProvider: clearSessionAction failed', e);
37
+ }
38
+ }
39
+ async function writeSession(user, sessionCookieName, maxAge, refreshTokenCookieName, refreshTokenMaxAge) {
40
+ try {
41
+ writeRefreshTokenCookie(refreshTokenCookieName, user, refreshTokenMaxAge);
42
+ }
43
+ catch (e) {
44
+ console.error('AuthUserProvider: refresh-token cookie sync failed', e);
45
+ }
46
+ writeSessionCookie(sessionCookieName, await user.getIdToken(true), maxAge);
47
+ }
28
48
  /**
29
49
  * Client-side auth-state provider for `firebase_auth`. Wrap your root layout
30
50
  * (or a client boundary below it) with this to make `useAuthUser()`
@@ -94,18 +114,10 @@ export default function AuthUserProvider({ initialUser = null, children }) {
94
114
  const previous = syncedSignedIn.current;
95
115
  try {
96
116
  if (user) {
97
- try {
98
- writeRefreshTokenCookie(refreshTokenCookieName, user, refreshTokenMaxAge);
99
- }
100
- catch (e) {
101
- console.error('AuthUserProvider: refresh-token cookie sync failed', e);
102
- }
103
- const token = await user.getIdToken(true);
104
- writeSessionCookie(sessionCookieName, token, maxAge);
117
+ await writeSession(user, sessionCookieName, maxAge, refreshTokenCookieName, refreshTokenMaxAge);
105
118
  }
106
- else if (previous) {
107
- clearSessionCookie(sessionCookieName);
108
- clearRefreshTokenCookie(refreshTokenCookieName);
119
+ else {
120
+ await clearSession(sessionCookieName, refreshTokenCookieName);
109
121
  }
110
122
  }
111
123
  catch (e) {
@@ -147,13 +159,7 @@ export default function AuthUserProvider({ initialUser = null, children }) {
147
159
  try {
148
160
  const { reload } = await getFirebaseAuthModule();
149
161
  await reload(user);
150
- try {
151
- writeRefreshTokenCookie(refreshTokenCookieName, user, refreshTokenMaxAge);
152
- }
153
- catch (e) {
154
- console.error('AuthUserProvider: refresh-token cookie sync failed', e);
155
- }
156
- writeSessionCookie(sessionCookieName, await user.getIdToken(true), maxAge);
162
+ await writeSession(user, sessionCookieName, maxAge, refreshTokenCookieName, refreshTokenMaxAge);
157
163
  setAuthUserCache(user);
158
164
  setState({ user, loading: false });
159
165
  }
@@ -176,8 +182,7 @@ export default function AuthUserProvider({ initialUser = null, children }) {
176
182
  await signOut(auth);
177
183
  }
178
184
  finally {
179
- clearSessionCookie(sessionCookieName);
180
- clearRefreshTokenCookie(refreshTokenCookieName);
185
+ await clearSession(sessionCookieName, refreshTokenCookieName);
181
186
  window.location.assign(fa.redirectAuthPath);
182
187
  }
183
188
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -3,6 +3,7 @@ export { default as FirebaseAuthServerProvider } from './server/auth_user_server
3
3
  export { default as useFirebaseAuthUserClient } from './client/use_auth_user';
4
4
  export { default as useFirebaseAuthUserServer } from './server/use_auth_user_server';
5
5
  export { createLoginAction, createSignUpAction, createForgotPasswordAction } from './client/auth_actions';
6
+ export { default as clearFirebaseAuthSession } from './server/clear_session_action';
6
7
  export { default as updateFirebaseAuthSession, defaultSessionCookieName as firebaseAuthSessionCookieName } from './middleware/update_session';
7
8
  export { getFirebaseAuthClient } from './client/firebase_client';
8
9
  export type { SerializedAuthUser, AuthFormState, AuthActionMessages, AuthUser } from './types';
@@ -9,5 +9,6 @@ export { default as FirebaseAuthServerProvider } from './server/auth_user_server
9
9
  export { default as useFirebaseAuthUserClient } from './client/use_auth_user';
10
10
  export { default as useFirebaseAuthUserServer } from './server/use_auth_user_server';
11
11
  export { createLoginAction, createSignUpAction, createForgotPasswordAction } from './client/auth_actions';
12
+ export { default as clearFirebaseAuthSession } from './server/clear_session_action';
12
13
  export { default as updateFirebaseAuthSession, defaultSessionCookieName as firebaseAuthSessionCookieName } from './middleware/update_session';
13
14
  export { getFirebaseAuthClient } from './client/firebase_client';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Server action: clears the httpOnly session/refresh-token cookies.
3
+ * `document.cookie` on the client can't touch httpOnly cookies, so
4
+ * `AuthUserProvider`'s `logout()` calls this instead of clearing them
5
+ * itself.
6
+ */
7
+ export default function clearSessionAction(): Promise<void>;
@@ -0,0 +1,20 @@
1
+ "use server";
2
+ import { cookies } from "next/headers";
3
+ import config from "@intl-config";
4
+ import { defaultRefreshTokenCookieName, defaultSessionCookieName } from "../middleware/update_session";
5
+ /**
6
+ * Server action: clears the httpOnly session/refresh-token cookies.
7
+ * `document.cookie` on the client can't touch httpOnly cookies, so
8
+ * `AuthUserProvider`'s `logout()` calls this instead of clearing them
9
+ * itself.
10
+ */
11
+ export default async function clearSessionAction() {
12
+ const fa = config.firebaseAuth;
13
+ if (!fa)
14
+ return;
15
+ const sessionCookieName = fa.sessionCookieName ?? defaultSessionCookieName;
16
+ const refreshTokenCookieName = fa.refreshTokenCookieName ?? defaultRefreshTokenCookieName;
17
+ const cookieStore = await cookies();
18
+ cookieStore.delete(sessionCookieName);
19
+ cookieStore.delete(refreshTokenCookieName);
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
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",
@@ -1 +0,0 @@
1
- export default function ClientHelperScript(): null;
@@ -1,34 +0,0 @@
1
- import type { TranslationObject } from "../../types/types";
2
- import type { SerializedAuthUser } from "../../firebase_auth/types";
3
- import type { CookieConsentAnalyticsConfig } from "../../types/types";
4
- import type { CookieConsentDialogProps } from "../../cookie_consent/client/components/cookie_consent_dialog";
5
- import type { PrivacyPolicyUpdateDialogProps } from "../../cookie_consent/client/components/privacy_policy_update_dialog";
6
- interface LocaleContextType {
7
- language: string;
8
- messages: TranslationObject;
9
- }
10
- export declare const LocaleContext: import("react").Context<LocaleContextType | undefined>;
11
- export default function LocationzationClientProvider({ language, messages, initialAuthUser, skipAuthProvider, analyticsConfig, requiresConsent, autoWireDialogs, dialogProps, updateDialogProps, children }: {
12
- language: string;
13
- messages: TranslationObject;
14
- initialAuthUser?: SerializedAuthUser | null;
15
- /** Set when `firebaseAuth.autoWireClientProvider` is `false` — skips wrapping `children` in the client `AuthUserProvider` entirely. */
16
- skipAuthProvider?: boolean;
17
- /** Resolved server-side from `cookieConsent.analytics`/`getAnalytics` when `autoWireAnalytics` isn't `false`. */
18
- analyticsConfig?: CookieConsentAnalyticsConfig;
19
- /**
20
- * Resolved server-side from `cookieConsent.getCountryCode`/`gdprCountries`.
21
- * `false` means the visitor's country doesn't require the consent
22
- * banner — `CookieConsentProvider` seeds consent as implicitly granted
23
- * for a first-time visitor instead of `null`.
24
- */
25
- requiresConsent?: boolean;
26
- /** From `cookieConsent.autoWireDialogs` — renders `CookieConsentDialog`/`PrivacyPolicyUpdateDialog` automatically when `true` (default). */
27
- autoWireDialogs?: boolean;
28
- /** From `cookieConsent.dialogProps` — forwarded as-is to the auto-wired `CookieConsentDialog`. */
29
- dialogProps?: CookieConsentDialogProps;
30
- /** From `cookieConsent.updateDialogProps` — forwarded as-is to the auto-wired `PrivacyPolicyUpdateDialog`. */
31
- updateDialogProps?: PrivacyPolicyUpdateDialogProps;
32
- children: React.ReactNode;
33
- }): Component;
34
- export {};
@@ -1,30 +0,0 @@
1
- import { type LinkProps } from 'next/link';
2
- import { type ComponentProps } from 'react';
3
- type NextLinkProps = Omit<ComponentProps<'a'>, keyof LinkProps> & Omit<LinkProps, 'locale' | 'href' | 'prefetch' | 'onNavigate' | 'hrefLang' | 'replace' | 'scroll'>;
4
- export type LocaleLinkProps = NextLinkProps & {
5
- locale: string;
6
- };
7
- /**
8
- * Client-only link component for linking to a SPECIFIC locale — e.g. a
9
- * language switcher. Import from `cloudflare-next-intl/LocaleLink`.
10
- *
11
- * For normal in-app navigation that should stay on the current locale, use
12
- * the server-side `Link` (`cloudflare-next-intl/Link`) instead — it infers
13
- * the locale automatically and doesn't require `"use client"`.
14
- *
15
- * Renders inside a `Suspense` boundary; falls back to a disabled `<a>`
16
- * (`pointer-events-none`) while resolving.
17
- *
18
- * @param locale Required. The locale to link to (e.g. `"de"`), prepended to
19
- * `href` regardless of the current locale.
20
- *
21
- * @example
22
- * ```tsx
23
- * "use client";
24
- * import LocaleLink from "cloudflare-next-intl/LocaleLink";
25
- *
26
- * <LocaleLink href="/about" locale="de">Über uns</LocaleLink> // -> "/de/about"
27
- * ```
28
- */
29
- declare const LocaleLink: import("react").ForwardRefExoticComponent<Omit<LocaleLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
30
- export default LocaleLink;
@@ -1,3 +0,0 @@
1
- import type { LocaleLinkProps } from './locale_link';
2
- declare const LocaleLinkClient: import("react").ForwardRefExoticComponent<Omit<LocaleLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
3
- export default LocaleLinkClient;
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * Client-only: reads a `document.cookie` value by name. Pairs with
3
- * {@link setCookie} for your OWN client-side cookies — this package's
4
- * locale/theme cookies are managed internally, you don't need this for those.
5
- *
6
- * @param name Cookie name to look up.
7
- * @returns The decoded cookie value, or `null` if not found (or on error,
8
- * logged instead of thrown).
9
- */
10
- export default function getCookie(name: string): string | null;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- /**
2
- * Client-only: sets a `document.cookie` value directly. Not used by this
3
- * package's own locale handling (that goes through `intlMiddleware` server-side)
4
- * — this is a small utility for your OWN client-side cookies (e.g. a
5
- * "dismissed banner" flag).
6
- *
7
- * @param name Cookie name.
8
- * @param value Cookie value; stringified via template literal (no encoding
9
- * applied — avoid values containing `;`). Must be a primitive
10
- * (`string`/`number`/`boolean`) — objects would silently serialize to
11
- * `"[object Object]"`.
12
- * @param maxAge Seconds until expiry. Defaults to 1 year.
13
- *
14
- * Always `path=/; SameSite=Lax`. Swallows errors (e.g. in restrictive
15
- * environments) and logs them instead of throwing.
16
- */
17
- export default function setCookie({ name, value, maxAge }: {
18
- name: string;
19
- value: string | number | boolean;
20
- maxAge?: number;
21
- }): void;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,28 +0,0 @@
1
- import type { TranslatorReturnType } from "../../types/types";
2
- /**
3
- * Client Component `useLocale` — reached via the default condition of the
4
- * `cloudflare-next-intl/use` subpath (Server Components get the
5
- * `use_functions.ts` variant automatically instead; always import from
6
- * `"cloudflare-next-intl/use"`, never this file directly).
7
- *
8
- * Reads the locale from React context set up by `IntlProvider`.
9
- *
10
- * @returns The current locale (e.g. `"en"`).
11
- * @throws If rendered outside `IntlProvider`.
12
- * @example
13
- * const locale = useLocale(); // "en"
14
- */
15
- export declare function useLocale(): string;
16
- /**
17
- * Client Component `useTranslations` — see {@link useLocale} for the
18
- * subpath-resolution note.
19
- *
20
- * @param namespace Dot-separated key prefix into your messages file.
21
- * @returns A `(key: string) => string` translation function, memoized on
22
- * `[language, messages, namespace]`.
23
- * @throws If rendered outside `IntlProvider`.
24
- * @example
25
- * const t = useTranslations("Index");
26
- * return <h1>{t("title")}</h1>;
27
- */
28
- export declare function useTranslations(namespace: string): TranslatorReturnType;
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * Client hook: like `next/navigation`'s `usePathname`, but with the locale
3
- * segment stripped — so `/de/about` returns `/about`, matching the
4
- * locale-agnostic paths used elsewhere in this package (e.g. `Link` href).
5
- * Must be used inside `IntlProvider`/`LocaleContext` (via {@link useLocale}).
6
- *
7
- * @returns The current pathname without its locale prefix (e.g. `/about`, or
8
- * `/` for the root).
9
- */
10
- export default function usePathname(): string;
@@ -1,4 +0,0 @@
1
- export { default as LocaleLink } from './components/locale_link';
2
- export { default as usePathname } from './hooks/use_path_name';
3
- export { default as setCookieClient } from './functions/set_cookie';
4
- export { default as getCookieClient } from './functions/get_cookie';
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- export declare const localeCookieName = "__user_locale_key__";
2
- export declare const isBotCookieKey = "__is_bot_key__";
3
- export declare const isDarkCookieKey = "__is_dark_key__";
4
- export declare const cookieConsentCookieKey = "__cookie_consent_key__";
5
- export declare const privacyPolicyDateCookieKey = "__privacy_policy_date_key__";
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export { isBotCookieKey, localeCookieName, isDarkCookieKey, cookieConsentCookieKey, privacyPolicyDateCookieKey } from './cookie_key';
2
- export { default as intlMiddleware } from './middleware';
3
- export { setIntlConfig } from './init_config';
4
- export { default as generateIntlSitemap } from './intl_sitemap';
@@ -1 +0,0 @@
1
- export {};
@@ -1,18 +0,0 @@
1
- import type { LocalePrefixMode, Locales, RoutingConfig } from '../types/types';
2
- /**
3
- * Defines and type-checks your app's i18n routing config.
4
- *
5
- * Identity function at runtime — it exists purely so TypeScript infers
6
- * `AppLocales`/`AppLocalePrefixMode` from the literal config object you pass
7
- * in, giving you autocomplete/type errors on `locale` params elsewhere.
8
- *
9
- * Export the result from the file referenced by `@intl-config` (see your
10
- * `next.config`), e.g.:
11
- * ```ts
12
- * export default setIntlConfig({
13
- * locales: ["en", "fr"] as const,
14
- * defaultLocale: "en",
15
- * });
16
- * ```
17
- */
18
- export declare function setIntlConfig<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'as-needed'>(config: RoutingConfig<AppLocales, AppLocalePrefixMode>): RoutingConfig<AppLocales, AppLocalePrefixMode>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import type { LocalePrefixMode, Locales, RoutingConfig } from '../types/types';
2
- declare const config: RoutingConfig<Locales, LocalePrefixMode>;
3
- export default config;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type { MetadataRoute } from 'next';
2
- import type { IntlSitemap } from '../types/types';
3
- declare function generateIntlSitemapIml({ intlSitemap, url }: {
4
- intlSitemap: IntlSitemap[];
5
- url: string;
6
- }): MetadataRoute.Sitemap;
7
- declare const generateIntlSitemap: typeof generateIntlSitemapIml;
8
- export default generateIntlSitemap;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import type { NextRequest } from 'next/server';
2
- import { NextResponse } from 'next/server';
3
- import type { MiddlewareCustomHandler } from '../types/types';
4
- export declare const localesSet: Set<string>;
5
- /**
6
- * This middleware function runs for every incoming request. Handles locale
7
- * detection/routing, then optionally defers to your own custom logic.
8
- *
9
- * @param request The incoming request (pass through from your `middleware.ts`).
10
- * @param options.middlewareHandler Your own logic (auth, feature flags, etc.),
11
- * run alongside locale routing — see {@link MiddlewareCustomHandler} for the
12
- * full contract (`rewriteUrl` / `redirectUrl` and what to return).
13
- * @param options.runHandlerOnRedirect By default, `middlewareHandler` does
14
- * NOT run for the locale-redirect case (so it never receives a
15
- * `redirectUrl`). Set to `true` to also run it on redirects.
16
- * Defaults to `false`.
17
- */
18
- export default function intlMiddleware(request: NextRequest, options?: {
19
- middlewareHandler?: MiddlewareCustomHandler;
20
- runHandlerOnRedirect?: boolean;
21
- }): Promise<NextResponse<unknown>>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,10 +0,0 @@
1
- /**
2
- * Loads and initializes Microsoft Clarity. Split into its own module and
3
- * loaded via `next/dynamic` from `cookie_consent_analytics.tsx` so it's
4
- * only fetched as a separate chunk once actually rendered (consent granted
5
- * and `analytics.clarityProjectId` set) — `@microsoft/clarity` is a real
6
- * dependency of this package, so it's always installed regardless.
7
- */
8
- export default function ClarityScript({ projectId }: {
9
- projectId: string;
10
- }): null;
@@ -1,19 +0,0 @@
1
- import type { CookieConsentAnalyticsConfig } from '../../../types/types';
2
- /**
3
- * Renders whichever analytics/ads scripts have a resolved secret, gated on
4
- * consent: Google Consent Mode bootstrap always loads (defaults to
5
- * `denied`, only sends `update` once `consent` is decided); Cloudflare Web
6
- * Analytics beacon and Microsoft Clarity only load once `consent === true`.
7
- * Rendered automatically by `IntlProvider` when `cookieConsent.analytics`/
8
- * `getAnalytics` resolves at least one field and `autoWireAnalytics` isn't
9
- * `false` — render manually instead if you set `autoWireAnalytics: false`.
10
- */
11
- export default function CookieConsentAnalytics({ config }: {
12
- config: CookieConsentAnalyticsConfig;
13
- }): React.ReactElement | null;
14
- /**
15
- * Denies storage by default and loads the configured Google tags; the
16
- * effect above sends the `update` once consent is known. Only IDs present
17
- * in `config` are included.
18
- */
19
- export declare function googleConsentModeBootstrapScript(config: CookieConsentAnalyticsConfig): string;
@@ -1,35 +0,0 @@
1
- import type { ConsentValue, CookieDialogClassNames, CookieDialogStyles } from '../../types';
2
- export interface CookieConsentDialogProps {
3
- /** Banner message text. */
4
- message?: React.ReactNode;
5
- /**
6
- * Link element rendered right after `message`. Defaults to a link to
7
- * `cookieConsent.privacyPolicyPath` (`'/privacy-policy'` unless
8
- * configured otherwise) with `privacyPolicyLinkText` as its label. Pass
9
- * `null` to render no link, or your own element to override it.
10
- */
11
- link?: React.ReactNode;
12
- /** Label for the default privacy-policy link. Ignored when `link` is set. */
13
- privacyPolicyLinkText?: string;
14
- acceptText?: string;
15
- declineText?: string;
16
- /** Hides the decline ("necessary only") button, leaving only accept. */
17
- hideDecline?: boolean;
18
- id?: string;
19
- classNames?: CookieDialogClassNames;
20
- styles?: CookieDialogStyles;
21
- /**
22
- * Full custom render — receives the resolved consent state/actions and
23
- * bypasses the default markup entirely. Use for a fully bespoke dialog.
24
- */
25
- render?: (props: {
26
- setConsent: (value: ConsentValue) => void;
27
- }) => React.ReactNode;
28
- }
29
- /**
30
- * Cookie-consent banner. Renders `null` once `consent` is already decided.
31
- * Every visual aspect is overridable via `classNames`/`styles` (per-slot) or
32
- * `render` (full custom markup) — none of it is hardcoded to Tailwind or any
33
- * particular design system.
34
- */
35
- export default function CookieConsentDialog({ message, link, privacyPolicyLinkText, acceptText, declineText, hideDecline, id, classNames, styles, render, }: CookieConsentDialogProps): React.ReactElement | null;
@@ -1,2 +0,0 @@
1
- import type { CookieDialogClassNames } from '../../types';
2
- export declare const defaultCookieDialogClassNames: CookieDialogClassNames;
@@ -1,13 +0,0 @@
1
- export interface CookieConsentDefaultText {
2
- message: string;
3
- privacyPolicyLinkText: string;
4
- acceptText: string;
5
- declineText: string;
6
- }
7
- export interface PrivacyPolicyUpdateDefaultText {
8
- message: string;
9
- privacyPolicyLinkText: string;
10
- closeText: string;
11
- }
12
- export declare const defaultCookieConsentText: Record<string, CookieConsentDefaultText>;
13
- export declare const defaultPrivacyPolicyUpdateText: Record<string, PrivacyPolicyUpdateDefaultText>;
@@ -1,14 +0,0 @@
1
- /**
2
- * Renders the default privacy-policy link used by `CookieConsentDialog`/
3
- * `PrivacyPolicyUpdateDialog` when their `link` prop is omitted. Returns
4
- * `null` when `privacyPolicyPath` is `false` (disabled via
5
- * `cookieConsent.privacyPolicyPath`). Locale-prefixes `privacyPolicyPath`
6
- * the same way the server `Link` component does — reads the locale set by
7
- * `LocationzationClientProvider` on the current render.
8
- */
9
- export default function DefaultPrivacyPolicyLink({ privacyPolicyPath, text, className, style }: {
10
- privacyPolicyPath: string | false;
11
- text: string;
12
- className?: string;
13
- style?: React.CSSProperties;
14
- }): React.ReactElement | null;
@@ -1,11 +0,0 @@
1
- /**
2
- * Renders `children` into `document.body` via a portal, so the default
3
- * dialogs always stack on top of the host app regardless of its own
4
- * stacking contexts (a `z-index` alone can't escape an ancestor with
5
- * `transform`/`filter`/`opacity`/`isolation`, all common in app shells).
6
- * Only called client-side (both dialogs already gate on `isMounted`), so
7
- * `document` is always defined here.
8
- */
9
- export default function DialogPortal({ children }: {
10
- children: React.ReactNode;
11
- }): React.ReactPortal;