cloudflare-next-intl 0.6.4 → 0.6.6

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 (154) hide show
  1. package/dist/src/client/components/client_provider.js +2 -0
  2. package/dist/src/error_handling/default_ignored_console_errors.js +6 -0
  3. package/dist/src/error_handling/index.d.ts +1 -0
  4. package/dist/src/error_handling/index.js +1 -0
  5. package/dist/src/error_handling/install_global_error_override.d.ts +20 -0
  6. package/dist/src/error_handling/install_global_error_override.js +44 -0
  7. package/dist/src/error_handling/report_error.d.ts +7 -3
  8. package/dist/src/error_handling/report_error.js +21 -10
  9. package/dist/src/firebase_auth/client/auth_user_provider.js +26 -21
  10. package/dist/src/firebase_auth/index.d.ts +1 -0
  11. package/dist/src/firebase_auth/index.js +1 -0
  12. package/dist/src/firebase_auth/server/clear_session_action.d.ts +7 -0
  13. package/dist/src/firebase_auth/server/clear_session_action.js +20 -0
  14. package/dist/src/types/types.d.ts +28 -3
  15. package/package.json +5 -1
  16. package/dist/types/client/components/client_helper_script.d.ts +0 -1
  17. package/dist/types/client/components/client_provider.d.ts +0 -34
  18. package/dist/types/client/components/locale_link.d.ts +0 -30
  19. package/dist/types/client/components/locale_link_client.d.ts +0 -3
  20. package/dist/types/client/functions/get_cookie.bench.d.ts +0 -1
  21. package/dist/types/client/functions/get_cookie.d.ts +0 -10
  22. package/dist/types/client/functions/get_cookie.test.d.ts +0 -1
  23. package/dist/types/client/functions/set_cookie.bench.d.ts +0 -1
  24. package/dist/types/client/functions/set_cookie.d.ts +0 -21
  25. package/dist/types/client/functions/set_cookie.test.d.ts +0 -1
  26. package/dist/types/client/hooks/client_hooks.bench.d.ts +0 -1
  27. package/dist/types/client/hooks/client_hooks.d.ts +0 -28
  28. package/dist/types/client/hooks/use_path_name.bench.d.ts +0 -1
  29. package/dist/types/client/hooks/use_path_name.d.ts +0 -10
  30. package/dist/types/client/index.d.ts +0 -4
  31. package/dist/types/config/cookie_key.bench.d.ts +0 -1
  32. package/dist/types/config/cookie_key.d.ts +0 -5
  33. package/dist/types/config/cookie_key.test.d.ts +0 -1
  34. package/dist/types/config/index.d.ts +0 -4
  35. package/dist/types/config/init_config.bench.d.ts +0 -1
  36. package/dist/types/config/init_config.d.ts +0 -18
  37. package/dist/types/config/init_config.test.d.ts +0 -1
  38. package/dist/types/config/intl_config.d.ts +0 -3
  39. package/dist/types/config/intl_config.test.d.ts +0 -1
  40. package/dist/types/config/intl_sitemap.bench.d.ts +0 -1
  41. package/dist/types/config/intl_sitemap.d.ts +0 -8
  42. package/dist/types/config/intl_sitemap.test.d.ts +0 -1
  43. package/dist/types/config/middleware.bench.d.ts +0 -1
  44. package/dist/types/config/middleware.d.ts +0 -21
  45. package/dist/types/config/middleware.test.d.ts +0 -1
  46. package/dist/types/cookie_consent/client/components/clarity_script.d.ts +0 -10
  47. package/dist/types/cookie_consent/client/components/cookie_consent_analytics.bench.d.ts +0 -1
  48. package/dist/types/cookie_consent/client/components/cookie_consent_analytics.d.ts +0 -19
  49. package/dist/types/cookie_consent/client/components/cookie_consent_dialog.d.ts +0 -35
  50. package/dist/types/cookie_consent/client/components/default_dialog_styles.d.ts +0 -2
  51. package/dist/types/cookie_consent/client/components/default_dialog_text.d.ts +0 -13
  52. package/dist/types/cookie_consent/client/components/default_privacy_policy_link.d.ts +0 -14
  53. package/dist/types/cookie_consent/client/components/dialog_portal.d.ts +0 -11
  54. package/dist/types/cookie_consent/client/components/privacy_policy_update_dialog.d.ts +0 -31
  55. package/dist/types/cookie_consent/client/cookie_consent_provider.bench.d.ts +0 -1
  56. package/dist/types/cookie_consent/client/cookie_consent_provider.d.ts +0 -39
  57. package/dist/types/cookie_consent/client/use_cookie_consent.d.ts +0 -6
  58. package/dist/types/cookie_consent/gdpr_countries.bench.d.ts +0 -1
  59. package/dist/types/cookie_consent/gdpr_countries.d.ts +0 -18
  60. package/dist/types/cookie_consent/gdpr_countries.perf.test.d.ts +0 -1
  61. package/dist/types/cookie_consent/gdpr_countries.test.d.ts +0 -1
  62. package/dist/types/cookie_consent/index.d.ts +0 -10
  63. package/dist/types/cookie_consent/require_config.d.ts +0 -7
  64. package/dist/types/cookie_consent/require_config.test.d.ts +0 -1
  65. package/dist/types/cookie_consent/types.d.ts +0 -57
  66. package/dist/types/error_handling/create_server_error_action.d.ts +0 -19
  67. package/dist/types/error_handling/create_server_error_action.test.d.ts +0 -1
  68. package/dist/types/error_handling/default_ignored_console_errors.d.ts +0 -13
  69. package/dist/types/error_handling/default_ignored_console_errors.test.d.ts +0 -1
  70. package/dist/types/error_handling/format_error_message.d.ts +0 -9
  71. package/dist/types/error_handling/format_error_message.test.d.ts +0 -1
  72. package/dist/types/error_handling/index.d.ts +0 -9
  73. package/dist/types/error_handling/install_console_error_override.bench.d.ts +0 -1
  74. package/dist/types/error_handling/install_console_error_override.d.ts +0 -29
  75. package/dist/types/error_handling/install_console_error_override.perf.test.d.ts +0 -1
  76. package/dist/types/error_handling/install_console_error_override.test.d.ts +0 -1
  77. package/dist/types/error_handling/report_error.bench.d.ts +0 -1
  78. package/dist/types/error_handling/report_error.d.ts +0 -40
  79. package/dist/types/error_handling/report_error.perf.test.d.ts +0 -1
  80. package/dist/types/error_handling/report_error.test.d.ts +0 -1
  81. package/dist/types/error_handling/stringify_unknown.bench.d.ts +0 -1
  82. package/dist/types/error_handling/stringify_unknown.d.ts +0 -12
  83. package/dist/types/error_handling/stringify_unknown.test.d.ts +0 -1
  84. package/dist/types/error_handling/with_error_handling.d.ts +0 -15
  85. package/dist/types/error_handling/with_error_handling.test.d.ts +0 -1
  86. package/dist/types/firebase_auth/client/auth_actions.bench.d.ts +0 -1
  87. package/dist/types/firebase_auth/client/auth_actions.d.ts +0 -46
  88. package/dist/types/firebase_auth/client/auth_actions.test.d.ts +0 -1
  89. package/dist/types/firebase_auth/client/auth_user_cache.bench.d.ts +0 -1
  90. package/dist/types/firebase_auth/client/auth_user_cache.d.ts +0 -4
  91. package/dist/types/firebase_auth/client/auth_user_cache.test.d.ts +0 -1
  92. package/dist/types/firebase_auth/client/auth_user_provider.d.ts +0 -36
  93. package/dist/types/firebase_auth/client/firebase_client.bench.d.ts +0 -1
  94. package/dist/types/firebase_auth/client/firebase_client.d.ts +0 -20
  95. package/dist/types/firebase_auth/client/firebase_client.test.d.ts +0 -1
  96. package/dist/types/firebase_auth/client/use_auth_user.bench.d.ts +0 -1
  97. package/dist/types/firebase_auth/client/use_auth_user.d.ts +0 -12
  98. package/dist/types/firebase_auth/error_messages/default_messages.en.bench.d.ts +0 -1
  99. package/dist/types/firebase_auth/error_messages/default_messages.en.d.ts +0 -1
  100. package/dist/types/firebase_auth/error_messages/default_messages.en.test.d.ts +0 -1
  101. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.bench.d.ts +0 -1
  102. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.d.ts +0 -6
  103. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.test.d.ts +0 -1
  104. package/dist/types/firebase_auth/index.d.ts +0 -9
  105. package/dist/types/firebase_auth/middleware/update_session.bench.d.ts +0 -1
  106. package/dist/types/firebase_auth/middleware/update_session.d.ts +0 -22
  107. package/dist/types/firebase_auth/middleware/update_session.test.d.ts +0 -1
  108. package/dist/types/firebase_auth/require_config.bench.d.ts +0 -1
  109. package/dist/types/firebase_auth/require_config.d.ts +0 -8
  110. package/dist/types/firebase_auth/require_config.test.d.ts +0 -1
  111. package/dist/types/firebase_auth/server/auth_user_server_provider.d.ts +0 -29
  112. package/dist/types/firebase_auth/server/firebase_server.bench.d.ts +0 -1
  113. package/dist/types/firebase_auth/server/firebase_server.d.ts +0 -15
  114. package/dist/types/firebase_auth/server/firebase_server.perf.test.d.ts +0 -1
  115. package/dist/types/firebase_auth/server/firebase_server.test.d.ts +0 -1
  116. package/dist/types/firebase_auth/server/use_auth_user_server.bench.d.ts +0 -1
  117. package/dist/types/firebase_auth/server/use_auth_user_server.d.ts +0 -39
  118. package/dist/types/firebase_auth/server/use_auth_user_server.test.d.ts +0 -1
  119. package/dist/types/firebase_auth/types.d.ts +0 -22
  120. package/dist/types/general/cache_variables.bench.d.ts +0 -1
  121. package/dist/types/general/cache_variables.d.ts +0 -14
  122. package/dist/types/general/cache_variables.test.d.ts +0 -1
  123. package/dist/types/general/general_functions.bench.d.ts +0 -1
  124. package/dist/types/general/general_functions.d.ts +0 -2
  125. package/dist/types/general/general_functions.test.d.ts +0 -1
  126. package/dist/types/general/index.d.ts +0 -2
  127. package/dist/types/general/metadata.bench.d.ts +0 -1
  128. package/dist/types/general/metadata.d.ts +0 -38
  129. package/dist/types/general/metadata.test.d.ts +0 -1
  130. package/dist/types/index.d.ts +0 -6
  131. package/dist/types/server/components/helper_script.d.ts +0 -20
  132. package/dist/types/server/components/link.d.ts +0 -25
  133. package/dist/types/server/components/server_provider.d.ts +0 -35
  134. package/dist/types/server/functions/get_user_locale.bench.d.ts +0 -1
  135. package/dist/types/server/functions/get_user_locale.d.ts +0 -3
  136. package/dist/types/server/functions/get_user_locale.test.d.ts +0 -1
  137. package/dist/types/server/functions/locale_static_params.d.ts +0 -15
  138. package/dist/types/server/functions/locale_static_params.test.d.ts +0 -1
  139. package/dist/types/server/functions/server.bench.d.ts +0 -1
  140. package/dist/types/server/functions/server.d.ts +0 -67
  141. package/dist/types/server/functions/server.perf.test.d.ts +0 -1
  142. package/dist/types/server/functions/server.test.d.ts +0 -1
  143. package/dist/types/server/functions/use_functions.bench.d.ts +0 -1
  144. package/dist/types/server/functions/use_functions.d.ts +0 -33
  145. package/dist/types/server/functions/use_functions.test.d.ts +0 -1
  146. package/dist/types/server/index.d.ts +0 -5
  147. package/dist/types/test_utils/mock_intl_config.d.ts +0 -3
  148. package/dist/types/test_utils/mock_next_server.d.ts +0 -5
  149. package/dist/types/theme_switcher/components/icons.d.ts +0 -6
  150. package/dist/types/theme_switcher/components/theme_switcher.d.ts +0 -15
  151. package/dist/types/theme_switcher/components/theme_switcher_button.d.ts +0 -6
  152. package/dist/types/theme_switcher/index.d.ts +0 -1
  153. package/dist/types/types/index.d.ts +0 -1
  154. package/dist/types/types/types.d.ts +0 -548
@@ -1,36 +0,0 @@
1
- import type { AuthUser, SerializedAuthUser } from '../types';
2
- export interface AuthUserContextType {
3
- /** Current Firebase user, or `null` if signed out (or not yet resolved while `loading`). */
4
- user: AuthUser | null;
5
- /** `true` until the initial auth state has resolved on the client. */
6
- loading: boolean;
7
- /** Force-refreshes the current user's ID token/claims and re-syncs the session cookie. */
8
- reloadUser: () => Promise<void>;
9
- /** Sends a verification email to the currently signed-in user. */
10
- sendVerificationEmail: () => Promise<void>;
11
- /** Signs out, clears the session cookie, and redirects to `firebaseAuth.redirectAuthPath`. */
12
- logout: () => Promise<void>;
13
- }
14
- export declare const AuthUserContext: import("react").Context<AuthUserContextType | null>;
15
- /**
16
- * Client-side auth-state provider for `firebase_auth`. Wrap your root layout
17
- * (or a client boundary below it) with this to make `useAuthUser()`
18
- * (`cloudflare-next-intl/useFirebaseAuthUser`, client variant) resolve
19
- * `{ user, loading }` from the live Firebase `onIdTokenChanged` listener,
20
- * and to get automatic session-cookie sync + redirect-on-sign-out/verify
21
- * behavior driven by `firebaseAuth.isAuthPath` / `whiteListPaths` /
22
- * `redirectAuthPath` / `verifyEmailPath` on your `RoutingConfig`.
23
- *
24
- * Requires `firebaseAuth` to be set on the config passed to `setIntlConfig`
25
- * — throws via {@link requireFirebaseAuthConfig} otherwise.
26
- *
27
- * @param initialUser Server-resolved user (e.g. from
28
- * `useFirebaseAuthUser`'s `react-server` variant) to avoid a
29
- * loading flash on first paint; pass `null`/omit if unavailable.
30
- * @example
31
- * <AuthUserProvider initialUser={initialUser}>{children}</AuthUserProvider>
32
- */
33
- export default function AuthUserProvider({ initialUser, children }: {
34
- initialUser?: SerializedAuthUser | null;
35
- children: React.ReactNode;
36
- }): import("react").JSX.Element;
@@ -1,20 +0,0 @@
1
- import type { FirebaseApp } from 'firebase/app';
2
- import type { Auth } from 'firebase/auth';
3
- /**
4
- * Lazily loads and initializes `firebase/app`/`firebase/auth` — a dynamic
5
- * import, not a static one, so consumers who never call a firebase_auth
6
- * export never pull these packages into their bundle or runtime at all.
7
- * Throws if `firebaseAuth` is missing from `RoutingConfig` (see
8
- * `require_config.ts`) instead of silently no-op'ing.
9
- */
10
- export declare function getFirebaseAuthClient(): Promise<{
11
- app: FirebaseApp;
12
- auth: Auth;
13
- }>;
14
- /** Synchronous read of the cached client, or `undefined` before the first `getFirebaseAuthClient()` resolves. */
15
- export declare function getFirebaseAuthClientSync(): {
16
- app: FirebaseApp;
17
- auth: Auth;
18
- } | undefined;
19
- /** Memoized `import('firebase/auth')` — see {@link getFirebaseAuthClient} for why this is worth caching. */
20
- export declare function getFirebaseAuthModule(): Promise<typeof import('firebase/auth')>;
@@ -1,12 +0,0 @@
1
- import { type AuthUserContextType } from './auth_user_provider';
2
- /**
3
- * Reads the current Firebase auth user and its actions from
4
- * `AuthUserProvider`'s context.
5
- *
6
- * @throws If called without an `AuthUserProvider` above it in the tree.
7
- * @example
8
- * const { user, loading, logout } = useAuthUser();
9
- * if (loading) return null;
10
- * return user ? <button onClick={logout}>Log out</button> : null;
11
- */
12
- export default function useAuthUser(): AuthUserContextType;
@@ -1 +0,0 @@
1
- export declare const DEFAULT_MESSAGES_EN: Record<string, string>;
@@ -1,6 +0,0 @@
1
- /**
2
- * Resolves a Firebase auth error to a user-facing message. If the consumer's
3
- * locale messages have a `firebaseAuth` namespace with a matching key, that
4
- * translation is used; otherwise falls back to the bundled English default.
5
- */
6
- export default function firebaseAuthErrorMessage(locale: string, error: unknown): string;
@@ -1,9 +0,0 @@
1
- export { default as FirebaseAuthClientProvider } from './client/auth_user_provider';
2
- export { default as FirebaseAuthServerProvider } from './server/auth_user_server_provider';
3
- export { default as useFirebaseAuthUserClient } from './client/use_auth_user';
4
- export { default as useFirebaseAuthUserServer } from './server/use_auth_user_server';
5
- export { createLoginAction, createSignUpAction, createForgotPasswordAction } from './client/auth_actions';
6
- export { default as updateFirebaseAuthSession, defaultSessionCookieName as firebaseAuthSessionCookieName } from './middleware/update_session';
7
- export { getFirebaseAuthClient } from './client/firebase_client';
8
- export type { SerializedAuthUser, AuthFormState, AuthActionMessages, AuthUser } from './types';
9
- export type { FirebaseAuthRoutingConfig } from '../types/types';
@@ -1,22 +0,0 @@
1
- import { NextResponse, type NextRequest } from 'next/server';
2
- export declare const defaultSessionCookieName = "__fa_session__";
3
- export declare const defaultRefreshTokenCookieName = "__fa_refresh_token__";
4
- /**
5
- * Layers Firebase session-cookie validation/refresh and auth redirects onto
6
- * an already-built middleware response. Called internally by `intlMiddleware`
7
- * (via dynamic import) when `config.firebaseAuth` is set and
8
- * `middlewareEnabled !== false` — not intended to be called directly unless
9
- * that auto-wiring is opted out of.
10
- *
11
- * @param baseResponse The response `intlMiddleware` already produced for
12
- * locale routing (its own next()/rewrite()/redirect(), with the locale
13
- * cookie / bot cookie / `Content-Language` header already set). On the
14
- * pass-through path this function returns `baseResponse` itself (with
15
- * Firebase cookies layered on) so none of that is dropped; on the
16
- * guest/auth-page redirect paths it returns a NEW response instead, since
17
- * a redirect response can't also carry forward a rewrite/next decision —
18
- * its cookies/headers are copied across from `baseResponse` so locale
19
- * state still survives the redirect.
20
- * @param locale The effective locale `intlMiddleware` resolved for this request.
21
- */
22
- export default function updateSession(request: NextRequest, baseResponse: NextResponse, locale: string): Promise<NextResponse>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- import type { FirebaseAuthRoutingConfig } from '../types/types';
2
- /**
3
- * Every firebase_auth export calls this before touching `firebase/*`. Throws
4
- * instead of silently no-op'ing so a consumer who calls e.g. `useAuthUser()`
5
- * without setting `firebaseAuth` on their `RoutingConfig` gets an immediate,
6
- * actionable error rather than a silent null/undefined.
7
- */
8
- export default function requireFirebaseAuthConfig(fa: FirebaseAuthRoutingConfig | undefined): asserts fa is FirebaseAuthRoutingConfig;
@@ -1 +0,0 @@
1
- export {};
@@ -1,29 +0,0 @@
1
- import type { SerializedAuthUser } from '../types';
2
- /**
3
- * Resolves the signed-in user from the session cookie and performs the
4
- * authoritative pre-render redirect (guest→`redirectAuthPath`, signed-in→
5
- * `homePath` on auth pages) — middleware only checks cookie *presence*, not
6
- * validity; a forged, expired, or otherwise invalid-but-present cookie
7
- * sails through it. Only this function's token validation
8
- * (`getAuthenticatedAppForUser`) catches that, so this redirect must happen
9
- * here, before any HTML is sent — relying solely on the client
10
- * `AuthUserProvider` effect to redirect afterwards produces a visible
11
- * flash (page renders signed-in, then bounces). Plain async function, not
12
- * a component: callers decide where/how to use the resolved user relative
13
- * to their own component tree (see `AuthUserServerProvider` below for the
14
- * simple case, and `IntlProvider`'s auto-wiring for the case where ordering
15
- * against `LocaleContext` matters).
16
- */
17
- export declare function resolveAuthUserAndRedirect(): Promise<SerializedAuthUser | null>;
18
- /**
19
- * Convenience component for the manual-override path
20
- * (`firebaseAuth.middlewareEnabled: false`-style manual wiring): resolves +
21
- * redirects, then wraps `children` in the client `AuthUserProvider`
22
- * directly. NOT used by the default auto-wiring path — `IntlProvider`/
23
- * `LocationzationClientProvider` call `resolveAuthUserAndRedirect` and the
24
- * client `AuthUserProvider` separately instead, so the client provider can
25
- * render inside `LocaleContext.Provider` rather than outside it.
26
- */
27
- export default function AuthUserServerProvider({ children }: {
28
- children: React.ReactNode;
29
- }): Promise<import("react").JSX.Element>;
@@ -1,15 +0,0 @@
1
- import type { FirebaseApp } from 'firebase/app';
2
- import type { User } from 'firebase/auth';
3
- /**
4
- * Resolves the signed-in user on the server from the session cookie.
5
- * `initializeServerApp` validates the token with the Auth service, so a
6
- * missing, expired, or forged token yields `currentUser === null`.
7
- * Wrapped in React's `cache()` so multiple server components in one request
8
- * share a single Auth service lookup. Lazily imports `firebase/app`/
9
- * `firebase/auth` — never touched unless this is actually called, and
10
- * throws if `firebaseAuth` is missing from `RoutingConfig`.
11
- */
12
- export declare const getAuthenticatedAppForUser: () => Promise<{
13
- firebaseServerApp: FirebaseApp | null;
14
- currentUser: User | null;
15
- }>;
@@ -1,39 +0,0 @@
1
- import type { User } from 'firebase/auth';
2
- /**
3
- * Resolves the current request's authenticated Firebase user.
4
- * @returns `{ user, loading: false }` — `loading` is always `false` here;
5
- * server resolution is synchronous with respect to the awaited call.
6
- */
7
- declare function iGetAuthUser(): Promise<{
8
- user: User | null;
9
- loading: false;
10
- }>;
11
- /**
12
- * Server Component/Action only: resolves the current request's
13
- * authenticated Firebase user, same style as {@link getLocale}/
14
- * {@link getTranslations} — an unconditional, always-`async` export
15
- * (`cloudflare-next-intl/getFirebaseAuthUser`), so the `await` requirement
16
- * is visible from the type itself in every editor.
17
- *
18
- * Returns the same `{ user, loading }` shape the client `useAuthUser()`
19
- * hook's context exposes, so `const { user } = await getAuthUser()`
20
- * generalizes correctly from `const { user } = useAuthUser()` on the client.
21
- *
22
- * @example
23
- * ```tsx
24
- * const { user } = await getAuthUser();
25
- * ```
26
- */
27
- export declare const getAuthUser: typeof iGetAuthUser;
28
- /**
29
- * Server Component counterpart of the client `useAuthUser()` hook, reached
30
- * via `cloudflare-next-intl/useFirebaseAuthUser`'s `react-server` condition
31
- * (resolved automatically — not meant to be imported directly by name).
32
- * Prefer {@link getAuthUser} for an unconditional, editor-typed-as-async
33
- * equivalent.
34
- */
35
- export default function useAuthUser(): Promise<{
36
- user: User | null;
37
- loading: false;
38
- }>;
39
- export {};
@@ -1,22 +0,0 @@
1
- import type { User } from 'firebase/auth';
2
- /**
3
- * Plain, RSC-serializable projection of `firebase/auth`'s `User` — enough
4
- * for first paint on the server; superseded by the real `User` once the
5
- * client's `onIdTokenChanged` listener fires.
6
- */
7
- export interface SerializedAuthUser {
8
- uid: string;
9
- email: string | null;
10
- emailVerified: boolean;
11
- displayName: string | null;
12
- }
13
- export type AuthFormState = {
14
- error?: string;
15
- success?: boolean;
16
- };
17
- /** Overrides for the default English auth error/status messages. */
18
- export interface AuthActionMessages {
19
- success?: string;
20
- mismatch?: string;
21
- }
22
- export type AuthUser = User | SerializedAuthUser;
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- import type { TranslationObject, TranslatorReturnType } from "../types/types";
2
- /**
3
- * Sets the current locale.
4
- * @param locale The language to set.
5
- */
6
- export declare function setLocaleCache(locale: string): void;
7
- export declare function setLocaleAsync(params: Promise<{
8
- locale: string;
9
- }>): Promise<void>;
10
- export declare function getLocaleCache(): string | undefined;
11
- export declare function setMessageForLocaleCache(locale: string, message: TranslationObject): void;
12
- export declare function getMessageCache(locale?: string): TranslationObject | undefined;
13
- export declare function setTranslationCache(cache: string, value: TranslatorReturnType): void;
14
- export declare function getTranslationCache(cacheKey: string): TranslatorReturnType | undefined;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import type { TranslationObject, TranslatorReturnType } from "../types/types";
2
- export declare function getTranslationsImpl(locale: string, messages: TranslationObject, namespace: string, cacheKey?: string): TranslatorReturnType;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export { setLocaleCache as setLocale, setLocaleAsync } from './cache_variables';
2
- export { alternatesLinks } from './metadata';
@@ -1 +0,0 @@
1
- export {};
@@ -1,38 +0,0 @@
1
- /**
2
- * Builds the `alternates` field for Next's `generateMetadata` — a canonical
3
- * URL plus per-locale `hreflang` links, exported memoized as `alternatesLinks`
4
- * from `cloudflare-next-intl/metadata`.
5
- *
6
- * @param url Absolute base URL of your site (no locale, no path),
7
- * e.g. `"https://example.com"`.
8
- * @param locale The current page's locale — used to decide the
9
- * `canonical` URL (only set for `defaultLocale` unless you pass one).
10
- * @param linkPart The path segment after the locale, e.g. `"/about"`.
11
- * Pass `"/"` or omit for the root page.
12
- * @param canonical Optional override for the canonical URL.
13
- * @returns `{ canonical, languages }` ready to spread into `Metadata.alternates`,
14
- * or `undefined` if building the links threw (logged, not re-thrown).
15
- *
16
- * @example
17
- * ```ts
18
- * export async function generateMetadata({ params }) {
19
- * const { locale } = await params;
20
- * return {
21
- * alternates: alternatesLinks({ url: "https://example.com", locale, linkPart: "/about" }),
22
- * };
23
- * }
24
- * ```
25
- */
26
- export declare function iAlternatesLinks({ locale, url, canonical, linkPart }: {
27
- url: string;
28
- locale: string;
29
- linkPart?: string;
30
- canonical?: string;
31
- }): {
32
- canonical?: string;
33
- languages: Record<string, string>;
34
- } | undefined;
35
- export declare const alternatesLinks: typeof iAlternatesLinks;
36
- declare function iLanguages(url: string, linkPart?: string): Record<string, string>;
37
- export declare const languages: typeof iLanguages;
38
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- export * from './config';
2
- export * from './general';
3
- export * from './server';
4
- export * from './client';
5
- export * from './theme_switcher';
6
- export * from './types';
@@ -1,20 +0,0 @@
1
- /**
2
- * Server component exported as `IntlHelperScript` from
3
- * `cloudflare-next-intl/IntlHelperScript`. Renders inline bootstrap
4
- * `<script>` tags that run before hydration to avoid FOUC/flicker:
5
- * - syncs dark-mode class from the theme cookie (or `prefers-color-scheme`)
6
- * - redirects to the locale-prefixed URL if the locale cookie disagrees
7
- * with the current path (covers client-side navigation edge cases)
8
- * - (prod only) checks `BUILD_ID` and force-reloads on stale deploys
9
- *
10
- * Place it once in your root layout's `<head>`, alongside `IntlProvider`.
11
- * No props.
12
- *
13
- * @example
14
- * ```tsx
15
- * <head>
16
- * <IntlHelperScript />
17
- * </head>
18
- * ```
19
- */
20
- export default function HelperScript(): Component | null;
@@ -1,25 +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'>;
4
- /**
5
- * Server-safe, locale-aware drop-in replacement for `next/link`. Import
6
- * from `cloudflare-next-intl/Link` (a separate subpath from the client-side
7
- * `LocaleLink`).
8
- *
9
- * Prepends the current locale segment to `href` automatically when the
10
- * current locale isn't the `defaultLocale` — you never build the
11
- * `/en/about`-style path yourself. To link to a SPECIFIC locale (a language
12
- * switcher) use `LocaleLink` instead, which takes an explicit `locale` prop.
13
- *
14
- * All other `next/link` props (`prefetch`, `replace`, `scroll`, etc.) and
15
- * standard `<a>` props are passed straight through.
16
- *
17
- * @example
18
- * ```tsx
19
- * import Link from "cloudflare-next-intl/Link";
20
- *
21
- * <Link href="/about">About</Link> // -> "/about" or "/de/about"
22
- * ```
23
- */
24
- declare const Link: import("react").ForwardRefExoticComponent<Omit<NextLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
25
- export default Link;
@@ -1,35 +0,0 @@
1
- import type { TranslationObject } from "../../types/types";
2
- /**
3
- * Server component that provides locale/messages context to the rest of the
4
- * tree. Exported publicly as `IntlProvider` from `cloudflare-next-intl/serverProvider`.
5
- *
6
- * Wrap this around your app once, near the root layout, below `[locale]`.
7
- * It seeds the server-side locale/message caches (for `getLocale`/`getTranslations`)
8
- * and also passes them to the client `LocaleContext` (for `useLocale`/`useTranslations`
9
- * in client components).
10
- *
11
- * @param language The current route's locale (typically the `[locale]` route
12
- * param). Must be one of your configured `locales` — calls `notFound()`
13
- * otherwise.
14
- * @param messages Optional pre-loaded messages for `language`. If omitted,
15
- * they're loaded via `getMessage(language)`.
16
- *
17
- * @example
18
- * ```tsx
19
- * export default async function RootLayout({ children, params }) {
20
- * const { locale } = await params;
21
- * return (
22
- * <html lang={locale}>
23
- * <body>
24
- * <IntlProvider language={locale}>{children}</IntlProvider>
25
- * </body>
26
- * </html>
27
- * );
28
- * }
29
- * ```
30
- */
31
- export default function LocationzationProvider({ language, messages, children }: {
32
- language: string;
33
- messages?: TranslationObject;
34
- children: React.ReactNode;
35
- }): Promise<Component>;
@@ -1,3 +0,0 @@
1
- export declare const languageDetecotr: typeof languageDetecotrImpl;
2
- declare function languageDetecotrImpl(acceptLanguageHeader: string | null): string;
3
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- /**
2
- * Generates the `[locale]` route params for every configured locale — pass
3
- * directly as your `[locale]/layout.tsx`'s `generateStaticParams` so Next
4
- * pre-renders/statically-generates a route for each locale.
5
- *
6
- * @returns One `{ locale }` object per entry in your `setIntlConfig({ locales })`.
7
- *
8
- * @example
9
- * ```tsx
10
- * export const generateStaticParams = getLocaleStaticParams;
11
- * ```
12
- */
13
- export declare function getLocaleStaticParams(): {
14
- locale: string;
15
- }[];
@@ -1 +0,0 @@
1
- export {};
@@ -1,67 +0,0 @@
1
- import type { TranslationObject, TranslatorReturnType } from "../../types/types";
2
- /**
3
- * Loads and caches messages for a specific locale using dynamic import.
4
- * Prevents redundant file loads and handles import errors gracefully.
5
- * @param locale The locale for which to load messages.
6
- * @returns A promise that resolves to the TranslationObject for the given locale.
7
- */
8
- declare function iGetMessage(locale: string): Promise<TranslationObject>;
9
- /**
10
- * Server-only: loads (and caches) the translation messages for a locale.
11
- * Use {@link getTranslations} instead unless you need the raw message object.
12
- *
13
- * @param locale The locale to load messages for (e.g. `"en"`).
14
- * @returns The `TranslationObject` for that locale.
15
- * @throws via `notFound()` if `locale` isn't in your configured locales.
16
- */
17
- export declare const getMessage: typeof iGetMessage;
18
- /**
19
- * Retrieves a translation function for a specific namespace and locale.
20
- * This function handles caching of both translation files and memoized translation functions.
21
- * @param namespace The dot-separated namespace (e.g., "common.buttons").
22
- * @param locale Optional: The specific locale to use. If not provided, it will be determined.
23
- * @returns A promise that resolves to a function, which takes a key and returns the translated string.
24
- */
25
- declare function iGetTranslations(namespace: string, locale?: string): Promise<TranslatorReturnType>;
26
- /**
27
- * Server Component only: gets a translation function for a namespace.
28
- *
29
- * @param namespace Dot-separated key prefix into your messages file
30
- * (e.g. `"HomePage"`, `"Common.buttons"`).
31
- * @param locale Optional. Defaults to {@link getLocale}'s result — pass
32
- * this explicitly only if you already resolved the locale (e.g. from route
33
- * params) to avoid an extra lookup.
34
- * @returns A function `(key: string) => string` that looks up `key` inside
35
- * `namespace`.
36
- *
37
- * @example
38
- * ```tsx
39
- * export default async function Page() {
40
- * const t = await getTranslations("HomePage");
41
- * return <h1>{t("title")}</h1>;
42
- * }
43
- * ```
44
- */
45
- export declare const getTranslations: typeof iGetTranslations;
46
- /**
47
- * Determines the current locale. It first checks for an explicitly set locale,
48
- * and finally reads from cookies.
49
- * @returns A promise that resolves to the determined Language.
50
- */
51
- declare function iGetLocale(): Promise<string>;
52
- /**
53
- * Server Component only: resolves the current request's locale.
54
- *
55
- * Order of resolution: an explicitly-set locale (e.g. via `IntlProvider`)
56
- * takes priority, then falls back to the `NEXT_LOCALE`-style cookie set by
57
- * `intlMiddleware`, then to `defaultLocale` from your `setIntlConfig` config.
58
- *
59
- * @returns The resolved locale string (e.g. `"en"`).
60
- *
61
- * @example
62
- * ```tsx
63
- * const locale = await getLocale();
64
- * ```
65
- */
66
- export declare const getLocale: typeof iGetLocale;
67
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,33 +0,0 @@
1
- import type { TranslatorReturnType } from "../../types/types";
2
- /**
3
- * React Server Component `useLocale`, reached via the `cloudflare-next-intl/use`
4
- * subpath's `react-server` condition (resolved automatically — you always
5
- * just `import { useLocale } from "cloudflare-next-intl/use"`; the matching
6
- * client-hook version from `client_hooks.ts` is used automatically in client
7
- * components instead).
8
- *
9
- * Uses React's `use()` on the locale promise resolved by `getLocale()`/
10
- * `IntlProvider` — must be called within a component tree wrapped in
11
- * `IntlProvider`.
12
- *
13
- * @returns The current locale (e.g. `"en"`).
14
- * @throws If called without an `IntlProvider` above it in the tree.
15
- * @example
16
- * const locale = useLocale(); // "en"
17
- */
18
- export declare function useLocaleImpl(): string;
19
- export declare const useLocale: typeof useLocaleImpl;
20
- /**
21
- * React Server Component `useTranslations` — see {@link useLocaleImpl} for
22
- * the `react-server`/client resolution note.
23
- *
24
- * @param namespace Dot-separated key prefix into your messages file.
25
- * @returns A `(key: string) => string` translation function.
26
- * @throws If called without an `IntlProvider` above it in the tree.
27
- * @example
28
- * const t = useTranslations("Index");
29
- * return <h1>{t("title")}</h1>;
30
- */
31
- declare function useTranslationsImpl(namespace: string): TranslatorReturnType;
32
- export declare const useTranslations: typeof useTranslationsImpl;
33
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- export { getMessage as getMessage, getTranslations, getLocale } from './functions/server';
2
- export { default as IntlProvider } from './components/server_provider';
3
- export { default as Link } from './components/link';
4
- export { default as IntlHelperScript } from './components/helper_script';
5
- export { getLocaleStaticParams } from './functions/locale_static_params';
@@ -1,3 +0,0 @@
1
- import type { RoutingConfig } from '../types/types';
2
- declare const mockIntlConfig: RoutingConfig<readonly ['en', 'de'], 'as-needed'>;
3
- export default mockIntlConfig;