cloudflare-next-intl 0.6.2 → 0.6.4

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 (142) hide show
  1. package/dist/src/error_handling/create_server_error_action.d.ts +32 -0
  2. package/dist/src/error_handling/create_server_error_action.js +41 -0
  3. package/dist/types/client/components/client_helper_script.d.ts +1 -0
  4. package/dist/types/client/components/client_provider.d.ts +34 -0
  5. package/dist/types/client/components/locale_link.d.ts +30 -0
  6. package/dist/types/client/components/locale_link_client.d.ts +3 -0
  7. package/dist/types/client/functions/get_cookie.bench.d.ts +1 -0
  8. package/dist/types/client/functions/get_cookie.d.ts +10 -0
  9. package/dist/types/client/functions/get_cookie.test.d.ts +1 -0
  10. package/dist/types/client/functions/set_cookie.bench.d.ts +1 -0
  11. package/dist/types/client/functions/set_cookie.d.ts +21 -0
  12. package/dist/types/client/functions/set_cookie.test.d.ts +1 -0
  13. package/dist/types/client/hooks/client_hooks.bench.d.ts +1 -0
  14. package/dist/types/client/hooks/client_hooks.d.ts +28 -0
  15. package/dist/types/client/hooks/use_path_name.bench.d.ts +1 -0
  16. package/dist/types/client/hooks/use_path_name.d.ts +10 -0
  17. package/dist/types/client/index.d.ts +4 -0
  18. package/dist/types/config/cookie_key.bench.d.ts +1 -0
  19. package/dist/types/config/cookie_key.d.ts +5 -0
  20. package/dist/types/config/cookie_key.test.d.ts +1 -0
  21. package/dist/types/config/index.d.ts +4 -0
  22. package/dist/types/config/init_config.bench.d.ts +1 -0
  23. package/dist/types/config/init_config.d.ts +18 -0
  24. package/dist/types/config/init_config.test.d.ts +1 -0
  25. package/dist/types/config/intl_config.d.ts +3 -0
  26. package/dist/types/config/intl_config.test.d.ts +1 -0
  27. package/dist/types/config/intl_sitemap.bench.d.ts +1 -0
  28. package/dist/types/config/intl_sitemap.d.ts +8 -0
  29. package/dist/types/config/intl_sitemap.test.d.ts +1 -0
  30. package/dist/types/config/middleware.bench.d.ts +1 -0
  31. package/dist/types/config/middleware.d.ts +21 -0
  32. package/dist/types/config/middleware.test.d.ts +1 -0
  33. package/dist/types/cookie_consent/client/components/clarity_script.d.ts +10 -0
  34. package/dist/types/cookie_consent/client/components/cookie_consent_analytics.bench.d.ts +1 -0
  35. package/dist/types/cookie_consent/client/components/cookie_consent_analytics.d.ts +19 -0
  36. package/dist/types/cookie_consent/client/components/cookie_consent_dialog.d.ts +35 -0
  37. package/dist/types/cookie_consent/client/components/default_dialog_styles.d.ts +2 -0
  38. package/dist/types/cookie_consent/client/components/default_dialog_text.d.ts +13 -0
  39. package/dist/types/cookie_consent/client/components/default_privacy_policy_link.d.ts +14 -0
  40. package/dist/types/cookie_consent/client/components/dialog_portal.d.ts +11 -0
  41. package/dist/types/cookie_consent/client/components/privacy_policy_update_dialog.d.ts +31 -0
  42. package/dist/types/cookie_consent/client/cookie_consent_provider.bench.d.ts +1 -0
  43. package/dist/types/cookie_consent/client/cookie_consent_provider.d.ts +39 -0
  44. package/dist/types/cookie_consent/client/use_cookie_consent.d.ts +6 -0
  45. package/dist/types/cookie_consent/gdpr_countries.bench.d.ts +1 -0
  46. package/dist/types/cookie_consent/gdpr_countries.d.ts +18 -0
  47. package/dist/types/cookie_consent/gdpr_countries.perf.test.d.ts +1 -0
  48. package/dist/types/cookie_consent/gdpr_countries.test.d.ts +1 -0
  49. package/dist/types/cookie_consent/index.d.ts +10 -0
  50. package/dist/types/cookie_consent/require_config.d.ts +7 -0
  51. package/dist/types/cookie_consent/require_config.test.d.ts +1 -0
  52. package/dist/types/cookie_consent/types.d.ts +57 -0
  53. package/dist/types/error_handling/create_server_error_action.d.ts +19 -0
  54. package/dist/types/error_handling/create_server_error_action.test.d.ts +1 -0
  55. package/dist/types/error_handling/default_ignored_console_errors.d.ts +13 -0
  56. package/dist/types/error_handling/default_ignored_console_errors.test.d.ts +1 -0
  57. package/dist/types/error_handling/format_error_message.d.ts +9 -0
  58. package/dist/types/error_handling/format_error_message.test.d.ts +1 -0
  59. package/dist/types/error_handling/index.d.ts +9 -0
  60. package/dist/types/error_handling/install_console_error_override.bench.d.ts +1 -0
  61. package/dist/types/error_handling/install_console_error_override.d.ts +29 -0
  62. package/dist/types/error_handling/install_console_error_override.perf.test.d.ts +1 -0
  63. package/dist/types/error_handling/install_console_error_override.test.d.ts +1 -0
  64. package/dist/types/error_handling/report_error.bench.d.ts +1 -0
  65. package/dist/types/error_handling/report_error.d.ts +40 -0
  66. package/dist/types/error_handling/report_error.perf.test.d.ts +1 -0
  67. package/dist/types/error_handling/report_error.test.d.ts +1 -0
  68. package/dist/types/error_handling/stringify_unknown.bench.d.ts +1 -0
  69. package/dist/types/error_handling/stringify_unknown.d.ts +12 -0
  70. package/dist/types/error_handling/stringify_unknown.test.d.ts +1 -0
  71. package/dist/types/error_handling/with_error_handling.d.ts +15 -0
  72. package/dist/types/error_handling/with_error_handling.test.d.ts +1 -0
  73. package/dist/types/firebase_auth/client/auth_actions.bench.d.ts +1 -0
  74. package/dist/types/firebase_auth/client/auth_actions.d.ts +46 -0
  75. package/dist/types/firebase_auth/client/auth_actions.test.d.ts +1 -0
  76. package/dist/types/firebase_auth/client/auth_user_cache.bench.d.ts +1 -0
  77. package/dist/types/firebase_auth/client/auth_user_cache.d.ts +4 -0
  78. package/dist/types/firebase_auth/client/auth_user_cache.test.d.ts +1 -0
  79. package/dist/types/firebase_auth/client/auth_user_provider.d.ts +36 -0
  80. package/dist/types/firebase_auth/client/firebase_client.bench.d.ts +1 -0
  81. package/dist/types/firebase_auth/client/firebase_client.d.ts +20 -0
  82. package/dist/types/firebase_auth/client/firebase_client.test.d.ts +1 -0
  83. package/dist/types/firebase_auth/client/use_auth_user.bench.d.ts +1 -0
  84. package/dist/types/firebase_auth/client/use_auth_user.d.ts +12 -0
  85. package/dist/types/firebase_auth/error_messages/default_messages.en.bench.d.ts +1 -0
  86. package/dist/types/firebase_auth/error_messages/default_messages.en.d.ts +1 -0
  87. package/dist/types/firebase_auth/error_messages/default_messages.en.test.d.ts +1 -0
  88. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.bench.d.ts +1 -0
  89. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.d.ts +6 -0
  90. package/dist/types/firebase_auth/error_messages/firebase_auth_error_helper.test.d.ts +1 -0
  91. package/dist/types/firebase_auth/index.d.ts +9 -0
  92. package/dist/types/firebase_auth/middleware/update_session.bench.d.ts +1 -0
  93. package/dist/types/firebase_auth/middleware/update_session.d.ts +22 -0
  94. package/dist/types/firebase_auth/middleware/update_session.test.d.ts +1 -0
  95. package/dist/types/firebase_auth/require_config.bench.d.ts +1 -0
  96. package/dist/types/firebase_auth/require_config.d.ts +8 -0
  97. package/dist/types/firebase_auth/require_config.test.d.ts +1 -0
  98. package/dist/types/firebase_auth/server/auth_user_server_provider.d.ts +29 -0
  99. package/dist/types/firebase_auth/server/firebase_server.bench.d.ts +1 -0
  100. package/dist/types/firebase_auth/server/firebase_server.d.ts +15 -0
  101. package/dist/types/firebase_auth/server/firebase_server.perf.test.d.ts +1 -0
  102. package/dist/types/firebase_auth/server/firebase_server.test.d.ts +1 -0
  103. package/dist/types/firebase_auth/server/use_auth_user_server.bench.d.ts +1 -0
  104. package/dist/types/firebase_auth/server/use_auth_user_server.d.ts +39 -0
  105. package/dist/types/firebase_auth/server/use_auth_user_server.test.d.ts +1 -0
  106. package/dist/types/firebase_auth/types.d.ts +22 -0
  107. package/dist/types/general/cache_variables.bench.d.ts +1 -0
  108. package/dist/types/general/cache_variables.d.ts +14 -0
  109. package/dist/types/general/cache_variables.test.d.ts +1 -0
  110. package/dist/types/general/general_functions.bench.d.ts +1 -0
  111. package/dist/types/general/general_functions.d.ts +2 -0
  112. package/dist/types/general/general_functions.test.d.ts +1 -0
  113. package/dist/types/general/index.d.ts +2 -0
  114. package/dist/types/general/metadata.bench.d.ts +1 -0
  115. package/dist/types/general/metadata.d.ts +38 -0
  116. package/dist/types/general/metadata.test.d.ts +1 -0
  117. package/dist/types/index.d.ts +6 -0
  118. package/dist/types/server/components/helper_script.d.ts +20 -0
  119. package/dist/types/server/components/link.d.ts +25 -0
  120. package/dist/types/server/components/server_provider.d.ts +35 -0
  121. package/dist/types/server/functions/get_user_locale.bench.d.ts +1 -0
  122. package/dist/types/server/functions/get_user_locale.d.ts +3 -0
  123. package/dist/types/server/functions/get_user_locale.test.d.ts +1 -0
  124. package/dist/types/server/functions/locale_static_params.d.ts +15 -0
  125. package/dist/types/server/functions/locale_static_params.test.d.ts +1 -0
  126. package/dist/types/server/functions/server.bench.d.ts +1 -0
  127. package/dist/types/server/functions/server.d.ts +67 -0
  128. package/dist/types/server/functions/server.perf.test.d.ts +1 -0
  129. package/dist/types/server/functions/server.test.d.ts +1 -0
  130. package/dist/types/server/functions/use_functions.bench.d.ts +1 -0
  131. package/dist/types/server/functions/use_functions.d.ts +33 -0
  132. package/dist/types/server/functions/use_functions.test.d.ts +1 -0
  133. package/dist/types/server/index.d.ts +5 -0
  134. package/dist/types/test_utils/mock_intl_config.d.ts +3 -0
  135. package/dist/types/test_utils/mock_next_server.d.ts +5 -0
  136. package/dist/types/theme_switcher/components/icons.d.ts +6 -0
  137. package/dist/types/theme_switcher/components/theme_switcher.d.ts +15 -0
  138. package/dist/types/theme_switcher/components/theme_switcher_button.d.ts +6 -0
  139. package/dist/types/theme_switcher/index.d.ts +1 -0
  140. package/dist/types/types/index.d.ts +1 -0
  141. package/dist/types/types/types.d.ts +548 -0
  142. package/package.json +5 -1
@@ -0,0 +1,32 @@
1
+ import type { ErrorHandlingParams } from '../types/types';
2
+ import { type ReportErrorConfig } from './report_error';
3
+ /**
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
+ * `Secrets.telegramBotToken`-style env reads inside your `onError`) never
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`.
24
+ *
25
+ * The error is stringified before crossing the client→server action
26
+ * boundary (Next.js server actions serialize arguments; an `Error` instance
27
+ * doesn't survive that intact) and `isClient: true` is set automatically.
28
+ *
29
+ * @param config Pass the relevant slices of your `RoutingConfig` directly —
30
+ * `{ errorHandling: config.errorHandling, generate: config.generate }`.
31
+ */
32
+ export default function createServerErrorAction(config: ReportErrorConfig | undefined): (error: unknown, classOrMethodName: string, params?: ErrorHandlingParams["params"]) => Promise<void>;
@@ -0,0 +1,41 @@
1
+ import reportError from './report_error';
2
+ import stringifyUnknown from './stringify_unknown';
3
+ /**
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
+ * `Secrets.telegramBotToken`-style env reads inside your `onError`) never
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`.
24
+ *
25
+ * The error is stringified before crossing the client→server action
26
+ * boundary (Next.js server actions serialize arguments; an `Error` instance
27
+ * doesn't survive that intact) and `isClient: true` is set automatically.
28
+ *
29
+ * @param config Pass the relevant slices of your `RoutingConfig` directly —
30
+ * `{ errorHandling: config.errorHandling, generate: config.generate }`.
31
+ */
32
+ export default function createServerErrorAction(config) {
33
+ return async function reportClientError(error, classOrMethodName, params) {
34
+ await reportError(config, {
35
+ error: stringifyUnknown(error, true),
36
+ classOrMethodName,
37
+ params,
38
+ isClient: true,
39
+ });
40
+ };
41
+ }
@@ -0,0 +1 @@
1
+ export default function ClientHelperScript(): null;
@@ -0,0 +1,34 @@
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 {};
@@ -0,0 +1,30 @@
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;
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
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;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
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;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,4 @@
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';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
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__";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
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';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
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>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { LocalePrefixMode, Locales, RoutingConfig } from '../types/types';
2
+ declare const config: RoutingConfig<Locales, LocalePrefixMode>;
3
+ export default config;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
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>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,19 @@
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;
@@ -0,0 +1,35 @@
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;
@@ -0,0 +1,2 @@
1
+ import type { CookieDialogClassNames } from '../../types';
2
+ export declare const defaultCookieDialogClassNames: CookieDialogClassNames;
@@ -0,0 +1,13 @@
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>;
@@ -0,0 +1,14 @@
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;
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,31 @@
1
+ import type { CookieDialogClassNames, CookieDialogStyles } from '../../types';
2
+ export interface PrivacyPolicyUpdateDialogProps {
3
+ message?: React.ReactNode;
4
+ /**
5
+ * Link element rendered right after `message`. Defaults to a link to
6
+ * `cookieConsent.privacyPolicyPath` (`'/privacy-policy'` unless
7
+ * configured otherwise) with `privacyPolicyLinkText` as its label. Pass
8
+ * `null` to render no link, or your own element to override it.
9
+ */
10
+ link?: React.ReactNode;
11
+ /** Label for the default privacy-policy link. Ignored when `link` is set. */
12
+ privacyPolicyLinkText?: string;
13
+ closeText?: string;
14
+ id?: string;
15
+ classNames?: CookieDialogClassNames;
16
+ styles?: CookieDialogStyles;
17
+ /**
18
+ * Full custom render — receives the acknowledge action and bypasses the
19
+ * default markup entirely.
20
+ */
21
+ render?: (props: {
22
+ acknowledge: () => void;
23
+ }) => React.ReactNode;
24
+ }
25
+ /**
26
+ * "Privacy policy updated" banner. Auto-enabled only when
27
+ * `cookieConsent.privacyPolicyDate` is set on the `RoutingConfig` — renders
28
+ * `null` otherwise, or once acknowledged. Every visual aspect is overridable
29
+ * via `classNames`/`styles` (per-slot) or `render` (full custom markup).
30
+ */
31
+ export default function PrivacyPolicyUpdateDialog({ message, link, privacyPolicyLinkText, closeText, id, classNames, styles, render, }: PrivacyPolicyUpdateDialogProps): React.ReactElement | null;
@@ -0,0 +1,39 @@
1
+ import type { CookieConsentContextType } from '../types';
2
+ export declare const CookieConsentContext: import("react").Context<CookieConsentContextType | null>;
3
+ /**
4
+ * Provides cookie-consent + privacy-policy-update state to
5
+ * `useCookieConsent()` and the default `CookieConsentDialog`/
6
+ * `PrivacyPolicyUpdateDialog` components. Requires `cookieConsent` to be set
7
+ * on the `RoutingConfig` passed to `setIntlConfig` — throws a descriptive
8
+ * error otherwise.
9
+ *
10
+ * The privacy-policy-update banner turns on automatically, and only when
11
+ * `cookieConsent.privacyPolicyDate` is configured: once a visitor has
12
+ * consented, if their stored consent date predates `privacyPolicyDate`,
13
+ * `privacyPolicyUpdated` becomes `true` until they call
14
+ * `acknowledgePrivacyPolicyUpdate()` — or until they navigate to
15
+ * `cookieConsent.privacyPolicyPath`, which auto-acknowledges it (visiting
16
+ * the page counts as having seen the update; skipped entirely when
17
+ * `privacyPolicyPath` is `false`).
18
+ *
19
+ * @param requiresConsent Resolved server-side from
20
+ * `cookieConsent.getCountryCode`/`gdprCountries` — `false` means the
21
+ * visitor's country doesn't require the banner at all, so a first-time
22
+ * visitor (no stored cookie) gets `consent` seeded to `true` instead of
23
+ * `null`, skipping the dialog and unlocking analytics immediately.
24
+ * Defaults to `true` (always show the banner) when omitted, e.g. when
25
+ * `cookieConsent.getCountryCode` isn't configured.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * <CookieConsentProvider>
30
+ * {children}
31
+ * <CookieConsentDialog />
32
+ * <PrivacyPolicyUpdateDialog />
33
+ * </CookieConsentProvider>
34
+ * ```
35
+ */
36
+ export default function CookieConsentProvider({ requiresConsent, children }: {
37
+ requiresConsent?: boolean;
38
+ children: React.ReactNode;
39
+ }): React.ReactElement;
@@ -0,0 +1,6 @@
1
+ import type { CookieConsentContextType } from '../types';
2
+ /**
3
+ * Reads cookie-consent + privacy-policy-update state. Must be called within
4
+ * a `CookieConsentProvider`.
5
+ */
6
+ export default function useCookieConsent(): CookieConsentContextType;
@@ -0,0 +1,18 @@
1
+ import type { CookieConsentGetCloudflareContext, ErrorHandlingRoutingConfig } from '../types/types';
2
+ /**
3
+ * Default `cookieConsent.gdprCountries` — EU/EEA member states (GDPR),
4
+ * Iceland/Liechtenstein/Norway (EEA), the UK (UK-GDPR), and Switzerland
5
+ * (nFADP). ISO 3166-1 alpha-2.
6
+ */
7
+ export declare const defaultGdprCountries: readonly string[];
8
+ /**
9
+ * Resolves whether the cookie-consent banner is required for a visitor.
10
+ *
11
+ * - Neither getter set: fail-safe — consent is required by default since
12
+ * the visitor's country can't be determined at all.
13
+ * - Either getter set: fail-safe — a country that couldn't be resolved
14
+ * still requires consent; only a resolved country OUTSIDE
15
+ * `gdprCountries` skips the banner. `getCountryCode` takes precedence
16
+ * over `getCloudflareContext` when both are set.
17
+ */
18
+ export default function resolveRequiresConsent(getCountryCode: (() => string | undefined | Promise<string | undefined>) | undefined, getCloudflareContext: CookieConsentGetCloudflareContext | undefined, gdprCountries: readonly string[] | undefined, errorHandlingConfig?: ErrorHandlingRoutingConfig): Promise<boolean>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ export { default as CookieConsentProvider } from './client/cookie_consent_provider';
2
+ export { default as useCookieConsent } from './client/use_cookie_consent';
3
+ export { default as CookieConsentDialog } from './client/components/cookie_consent_dialog';
4
+ export { default as PrivacyPolicyUpdateDialog } from './client/components/privacy_policy_update_dialog';
5
+ export { default as CookieConsentAnalytics } from './client/components/cookie_consent_analytics';
6
+ export { defaultGdprCountries } from './gdpr_countries';
7
+ export type { CookieConsentContextType, ConsentValue, CookieDialogClassNames, CookieDialogStyles } from './types';
8
+ export type { CookieConsentDialogProps } from './client/components/cookie_consent_dialog';
9
+ export type { PrivacyPolicyUpdateDialogProps } from './client/components/privacy_policy_update_dialog';
10
+ export type { CookieConsentRoutingConfig, CookieConsentAnalyticsConfig, CookieConsentCloudflareContext, CookieConsentGetCloudflareContext, } from '../types/types';
@@ -0,0 +1,7 @@
1
+ import type { CookieConsentRoutingConfig } from '../types/types';
2
+ /**
3
+ * Throws a descriptive error instead of silently no-op'ing when the
4
+ * `cookie_consent` submodule is used without `cookieConsent` set on the
5
+ * `RoutingConfig` passed to `setIntlConfig`.
6
+ */
7
+ export default function requireCookieConsentConfig(value: CookieConsentRoutingConfig | undefined): CookieConsentRoutingConfig;
@@ -0,0 +1 @@
1
+ export {};