cloudflare-next-intl 0.10.34 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/src/client/components/client_extensions.d.ts +20 -0
- package/dist/src/client/components/client_extensions.js +37 -0
- package/dist/src/client/components/client_helper_script.d.ts +2 -1
- package/dist/src/client/components/client_helper_script.js +2 -15
- package/dist/src/client/components/client_provider.d.ts +7 -16
- package/dist/src/client/components/client_provider.js +6 -36
- package/dist/src/client/components/client_provider_static.d.ts +2 -21
- package/dist/src/client/components/client_provider_static.js +2 -26
- package/dist/src/client/components/locale_link.d.ts +2 -8
- package/dist/src/client/components/locale_link.js +2 -8
- package/dist/src/client/components/locale_link_client.d.ts +2 -3
- package/dist/src/client/components/locale_link_client.js +2 -30
- package/dist/src/client/components/locale_provider.d.ts +2 -13
- package/dist/src/client/components/locale_provider.js +2 -8
- package/dist/src/client/functions/get_cookie.d.ts +2 -1
- package/dist/src/client/functions/get_cookie.js +2 -32
- package/dist/src/client/functions/set_cookie.d.ts +2 -5
- package/dist/src/client/functions/set_cookie.js +2 -17
- package/dist/src/client/hooks/client_hooks.d.ts +1 -3
- package/dist/src/client/hooks/client_hooks.js +1 -19
- package/dist/src/client/hooks/use_path_name.d.ts +2 -1
- package/dist/src/client/hooks/use_path_name.js +2 -17
- package/dist/src/client/index.d.ts +7 -3
- package/dist/src/client/index.js +7 -3
- package/dist/src/client_messages_scan/index.d.ts +1 -3
- package/dist/src/client_messages_scan/index.js +1 -3
- package/dist/src/client_messages_scan/match_namespace.d.ts +1 -1
- package/dist/src/client_messages_scan/match_namespace.js +1 -3
- package/dist/src/client_messages_scan/scan_file.d.ts +1 -16
- package/dist/src/client_messages_scan/scan_file.js +1 -175
- package/dist/src/client_messages_scan/scan_project.d.ts +1 -16
- package/dist/src/client_messages_scan/scan_project.js +1 -67
- package/dist/src/config/cookie_key.d.ts +2 -5
- package/dist/src/config/cookie_key.js +2 -5
- package/dist/src/config/init_config.js +13 -31
- package/dist/src/config/intl_config.js +12 -7
- package/dist/src/config/intl_sitemap.d.ts +2 -8
- package/dist/src/config/intl_sitemap.js +2 -28
- package/dist/src/config/middleware.d.ts +9 -6
- package/dist/src/config/middleware.js +11 -173
- package/dist/src/cookie_consent/client/cookie_consent_provider.d.ts +3 -1
- package/dist/src/cookie_consent/client/cookie_consent_provider.js +3 -3
- package/dist/src/db/resolve_db_config.js +2 -0
- package/dist/src/error_handling/clear_client_cache.d.ts +2 -1
- package/dist/src/error_handling/clear_client_cache.js +2 -17
- package/dist/src/error_handling/create_server_error_action.d.ts +2 -3
- package/dist/src/error_handling/create_server_error_action.js +2 -6
- package/dist/src/error_handling/default_ignored_console_errors.d.ts +1 -1
- package/dist/src/error_handling/default_ignored_console_errors.js +1 -33
- package/dist/src/error_handling/format_error_message.d.ts +2 -2
- package/dist/src/error_handling/format_error_message.js +2 -16
- package/dist/src/error_handling/index.d.ts +1 -13
- package/dist/src/error_handling/index.js +1 -10
- package/dist/src/error_handling/install_console_error_override.d.ts +2 -3
- package/dist/src/error_handling/install_console_error_override.js +2 -39
- package/dist/src/error_handling/install_global_error_override.d.ts +2 -2
- package/dist/src/error_handling/install_global_error_override.js +2 -30
- package/dist/src/error_handling/is_stale_deploy_error.d.ts +2 -4
- package/dist/src/error_handling/is_stale_deploy_error.js +2 -51
- package/dist/src/error_handling/match_error_message.d.ts +1 -2
- package/dist/src/error_handling/match_error_message.js +1 -10
- package/dist/src/error_handling/merge_report_params.d.ts +2 -2
- package/dist/src/error_handling/merge_report_params.js +2 -9
- package/dist/src/error_handling/report_client_error.d.ts +2 -3
- package/dist/src/error_handling/report_client_error.js +2 -15
- package/dist/src/error_handling/report_client_error_action.d.ts +1 -2
- package/dist/src/error_handling/report_client_error_action.js +1 -6
- package/dist/src/error_handling/report_client_error_core.d.ts +1 -3
- package/dist/src/error_handling/report_client_error_core.js +1 -26
- package/dist/src/error_handling/report_error.d.ts +2 -9
- package/dist/src/error_handling/report_error.js +2 -73
- package/dist/src/error_handling/stringify_unknown.d.ts +2 -5
- package/dist/src/error_handling/stringify_unknown.js +2 -57
- package/dist/src/error_handling/use_stale_deploy_recovery.d.ts +2 -4
- package/dist/src/error_handling/use_stale_deploy_recovery.js +2 -141
- package/dist/src/error_handling/with_error_handling.d.ts +2 -9
- package/dist/src/error_handling/with_error_handling.js +2 -13
- package/dist/src/firebase_auth/client/auth_actions.d.ts +1 -6
- package/dist/src/firebase_auth/client/auth_actions.js +1 -93
- package/dist/src/firebase_auth/client/auth_user_provider.d.ts +2 -8
- package/dist/src/firebase_auth/client/auth_user_provider.js +2 -283
- package/dist/src/firebase_auth/client/components/auto_firebase_performance_events.d.ts +2 -1
- package/dist/src/firebase_auth/client/components/auto_firebase_performance_events.js +2 -29
- package/dist/src/firebase_auth/client/firebase_client.d.ts +1 -33
- package/dist/src/firebase_auth/client/firebase_client.js +1 -218
- package/dist/src/firebase_auth/client/use_auth_user.d.ts +2 -2
- package/dist/src/firebase_auth/client/use_auth_user.js +2 -10
- package/dist/src/firebase_auth/index.d.ts +1 -10
- package/dist/src/firebase_auth/index.js +1 -8
- package/dist/src/firebase_auth/middleware/update_session.d.ts +2 -27
- package/dist/src/firebase_auth/middleware/update_session.js +2 -328
- package/dist/src/firebase_auth/server/auth_user_server_provider.d.ts +2 -5
- package/dist/src/firebase_auth/server/auth_user_server_provider.js +2 -37
- package/dist/src/firebase_auth/server/resolve_optional_auth_user.d.ts +2 -7
- package/dist/src/firebase_auth/server/resolve_optional_auth_user.js +2 -15
- package/dist/src/firebase_auth/server/use_auth_user_server.d.ts +2 -11
- package/dist/src/firebase_auth/server/use_auth_user_server.js +2 -9
- package/dist/src/firebase_auth/types.d.ts +1 -31
- package/dist/src/firebase_auth/types.js +1 -1
- package/dist/src/firebase_auth_check/index.d.ts +1 -2
- package/dist/src/firebase_auth_check/index.js +1 -2
- package/dist/src/general/cache_variables.d.ts +1 -10
- package/dist/src/general/cache_variables.js +1 -25
- package/dist/src/general/general_functions.d.ts +1 -2
- package/dist/src/general/general_functions.js +1 -110
- package/dist/src/general/index.d.ts +1 -2
- package/dist/src/general/index.js +1 -2
- package/dist/src/general/metadata.d.ts +1 -13
- package/dist/src/general/metadata.js +1 -29
- package/dist/src/general/pick_client_messages.d.ts +2 -2
- package/dist/src/general/pick_client_messages.js +2 -17
- package/dist/src/image_optimizer/next_image_shim.js +15 -17
- package/dist/src/server/components/helper_script.d.ts +4 -2
- package/dist/src/server/components/helper_script.js +20 -321
- package/dist/src/server/components/link.d.ts +2 -10
- package/dist/src/server/components/link.js +2 -143
- package/dist/src/server/components/server_provider.d.ts +4 -3
- package/dist/src/server/components/server_provider.js +15 -23
- package/dist/src/server/components/server_provider_static.d.ts +4 -3
- package/dist/src/server/components/server_provider_static.js +12 -24
- package/dist/src/server/functions/geo.d.ts +1 -8
- package/dist/src/server/functions/geo.js +1 -223
- package/dist/src/server/functions/get_user_locale.d.ts +1 -3
- package/dist/src/server/functions/get_user_locale.js +1 -38
- package/dist/src/server/functions/locale_static_params.d.ts +1 -3
- package/dist/src/server/functions/locale_static_params.js +1 -4
- package/dist/src/server/functions/server.d.ts +1 -8
- package/dist/src/server/functions/server.js +1 -67
- package/dist/src/server/functions/use_functions.d.ts +1 -6
- package/dist/src/server/functions/use_functions.js +1 -30
- package/dist/src/theme_switcher/components/theme_switcher.d.ts +2 -5
- package/dist/src/theme_switcher/components/theme_switcher.js +2 -16
- package/dist/src/types/index.d.ts +1 -1
- package/dist/src/types/index.js +1 -1
- package/dist/src/types/types.d.ts +8 -158
- package/dist/src/types/types.js +2 -3
- package/dist/src/vite/index.d.ts +3 -1
- package/dist/src/vite/index.js +3 -1
- package/dist/src/vite/plugin.d.ts +2 -0
- package/dist/src/vite/plugin.js +8 -0
- package/dist/src/vite/static_not_found_no_store.d.ts +10 -0
- package/dist/src/vite/static_not_found_no_store.js +19 -0
- package/dist/src/vite/tailwind_sources_plugin.d.ts +8 -0
- package/dist/src/vite/tailwind_sources_plugin.js +58 -0
- package/dist/src/vite/vinext_route_wiring_fix.d.ts +8 -0
- package/dist/src/vite/vinext_route_wiring_fix.js +85 -3
- package/package.json +10 -3
- package/dist/src/firebase_auth/client/auth_user_cache.d.ts +0 -4
- package/dist/src/firebase_auth/client/auth_user_cache.js +0 -12
- package/dist/src/firebase_auth/client/auth_user_context.d.ts +0 -10
- package/dist/src/firebase_auth/client/auth_user_context.js +0 -4
- package/dist/src/firebase_auth/decode_jwt_payload.d.ts +0 -5
- package/dist/src/firebase_auth/decode_jwt_payload.js +0 -20
- package/dist/src/firebase_auth/error_messages/default_messages.en.d.ts +0 -1
- package/dist/src/firebase_auth/error_messages/default_messages.en.js +0 -14
- package/dist/src/firebase_auth/error_messages/firebase_auth_error_helper.d.ts +0 -1
- package/dist/src/firebase_auth/error_messages/firebase_auth_error_helper.js +0 -37
- package/dist/src/firebase_auth/is_whitelisted.d.ts +0 -1
- package/dist/src/firebase_auth/is_whitelisted.js +0 -5
- package/dist/src/firebase_auth/preserve_redirect_query.d.ts +0 -2
- package/dist/src/firebase_auth/preserve_redirect_query.js +0 -9
- package/dist/src/firebase_auth/require_config.d.ts +0 -2
- package/dist/src/firebase_auth/require_config.js +0 -7
- package/dist/src/firebase_auth/server/clear_session_action.d.ts +0 -1
- package/dist/src/firebase_auth/server/clear_session_action.js +0 -14
- package/dist/src/firebase_auth/server/firebase_server.d.ts +0 -6
- package/dist/src/firebase_auth/server/firebase_server.js +0 -92
- package/dist/src/firebase_auth/server/mint_server_app_check_token.d.ts +0 -5
- package/dist/src/firebase_auth/server/mint_server_app_check_token.js +0 -84
- package/dist/src/firebase_auth/server/sign_custom_token_remote.d.ts +0 -5
- package/dist/src/firebase_auth/server/sign_custom_token_remote.js +0 -26
- package/dist/src/firebase_auth_check/check_firebase_auth_config.d.ts +0 -34
- package/dist/src/firebase_auth_check/check_firebase_auth_config.js +0 -606
- package/dist/src/firebase_auth_check/load_resolved_firebase_auth.d.ts +0 -9
- package/dist/src/firebase_auth_check/load_resolved_firebase_auth.js +0 -64
- package/dist/src/theme_switcher/components/icons.d.ts +0 -6
- package/dist/src/theme_switcher/components/icons.js +0 -7
- package/dist/src/theme_switcher/components/theme_switcher_button.d.ts +0 -6
- package/dist/src/theme_switcher/components/theme_switcher_button.js +0 -24
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Optimized internationalization (i18n) package specialized for Next.js App Router
|
|
4
4
|
and Cloudflare environment.
|
|
5
5
|
|
|
6
|
+
> **Note**: Core internationalization logic lives in [`cloudflare-next-intl-intl`](https://github.com/demian-ilnytskyi/cloudflare-next-intl/tree/main/packages/intl#readme), and Firebase Auth & App Check logic lives in [`cloudflare-next-intl-auth`](https://github.com/demian-ilnytskyi/cloudflare-next-intl/tree/main/packages/auth#readme). This umbrella package re-exports all primitives with full backward compatibility plus wires optional extensions.
|
|
7
|
+
|
|
6
8
|
## Features
|
|
7
9
|
|
|
8
10
|
- **Optimized for Cloudflare**: Designed to work seamlessly with Cloudflare
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SerializedAuthUser } from '../../firebase_auth/types.js';
|
|
2
|
+
import type { CookieConsentAnalyticsConfig, AutoAnalyticsEventsConfig, CookieConsentRoutingConfig } from '../../types/types.js';
|
|
3
|
+
import type { CookieConsentDialogProps } from '../../cookie_consent/client/components/cookie_consent_dialog.js';
|
|
4
|
+
import type { PrivacyPolicyUpdateDialogProps } from '../../cookie_consent/client/components/privacy_policy_update_dialog.js';
|
|
5
|
+
export interface ClientExtensionsProps {
|
|
6
|
+
initialAuthUser?: SerializedAuthUser | null;
|
|
7
|
+
skipAuthProvider?: boolean;
|
|
8
|
+
hasFirebaseAuth?: boolean;
|
|
9
|
+
enableFirebasePerformance?: boolean;
|
|
10
|
+
hasCookieConsent?: boolean;
|
|
11
|
+
cookieConsentConfig?: CookieConsentRoutingConfig;
|
|
12
|
+
requiresConsent?: boolean;
|
|
13
|
+
autoWireDialogs?: boolean;
|
|
14
|
+
dialogProps?: CookieConsentDialogProps;
|
|
15
|
+
updateDialogProps?: PrivacyPolicyUpdateDialogProps;
|
|
16
|
+
analyticsConfig?: CookieConsentAnalyticsConfig;
|
|
17
|
+
autoAnalyticsEventsConfig?: AutoAnalyticsEventsConfig;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export default function ClientExtensions({ initialAuthUser, skipAuthProvider, hasFirebaseAuth, enableFirebasePerformance, hasCookieConsent, cookieConsentConfig, requiresConsent, autoWireDialogs, dialogProps, updateDialogProps, analyticsConfig, autoAnalyticsEventsConfig, children, }: ClientExtensionsProps): React.ReactNode;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, Suspense } from 'react';
|
|
4
|
+
import dynamic from 'next/dynamic.js';
|
|
5
|
+
import CookieConsentProvider from '../../cookie_consent/client/cookie_consent_provider.js';
|
|
6
|
+
import AuthUserProvider from '../../firebase_auth/client/auth_user_provider.js';
|
|
7
|
+
import config from '../../config/intl_config.js';
|
|
8
|
+
import installConsoleErrorOverride from '../../error_handling/install_console_error_override.js';
|
|
9
|
+
import installGlobalErrorOverride from '../../error_handling/install_global_error_override.js';
|
|
10
|
+
import ClientThemeScript from 'cloudflare-next-intl-theme/ClientThemeScript';
|
|
11
|
+
const AutoFirebasePerformanceEvents = dynamic(() => import('../../firebase_auth/client/components/auto_firebase_performance_events.js'));
|
|
12
|
+
const CookieConsentAnalytics = dynamic(() => import('../../cookie_consent/client/components/cookie_consent_analytics.js'));
|
|
13
|
+
const AutoAnalyticsEvents = dynamic(() => import('../../cookie_consent/client/components/auto_analytics_events.js'));
|
|
14
|
+
const loadCookieConsentDialog = () => import('../../cookie_consent/client/components/cookie_consent_dialog.js');
|
|
15
|
+
const CookieConsentDialog = dynamic(loadCookieConsentDialog);
|
|
16
|
+
const PrivacyPolicyUpdateDialog = dynamic(() => import('../../cookie_consent/client/components/privacy_policy_update_dialog.js'));
|
|
17
|
+
export default function ClientExtensions({ initialAuthUser = null, skipAuthProvider = false, hasFirebaseAuth, enableFirebasePerformance, hasCookieConsent, cookieConsentConfig, requiresConsent = true, autoWireDialogs = true, dialogProps, updateDialogProps, analyticsConfig, autoAnalyticsEventsConfig, children, }) {
|
|
18
|
+
installConsoleErrorOverride(config, true);
|
|
19
|
+
installGlobalErrorOverride(config);
|
|
20
|
+
const isConsent = hasCookieConsent ?? Boolean(config.cookieConsent);
|
|
21
|
+
const isAuth = hasFirebaseAuth ?? Boolean(config.firebaseAuth);
|
|
22
|
+
const isPerf = enableFirebasePerformance ?? (config.firebaseAuth?.performance !== false);
|
|
23
|
+
const resolvedConsent = cookieConsentConfig ?? (hasCookieConsent !== undefined ? undefined : config.cookieConsent);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!isConsent || !autoWireDialogs)
|
|
26
|
+
return;
|
|
27
|
+
loadCookieConsentDialog().catch(() => undefined);
|
|
28
|
+
}, [isConsent, autoWireDialogs]);
|
|
29
|
+
let providedChildren = children;
|
|
30
|
+
if (isAuth && !skipAuthProvider) {
|
|
31
|
+
providedChildren = (_jsxs(AuthUserProvider, { initialUser: initialAuthUser, children: [children, isPerf && (_jsx(Suspense, { fallback: null, children: _jsx(AutoFirebasePerformanceEvents, {}) }))] }));
|
|
32
|
+
}
|
|
33
|
+
if (isConsent) {
|
|
34
|
+
providedChildren = (_jsxs(CookieConsentProvider, { requiresConsent: requiresConsent, cookieConsentConfig: resolvedConsent, children: [providedChildren, analyticsConfig && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentAnalytics, { config: analyticsConfig }) })), analyticsConfig && (analyticsConfig.googleAnalyticsId || analyticsConfig.googleAdsId) && (_jsx(Suspense, { fallback: null, children: _jsx(AutoAnalyticsEvents, { config: autoAnalyticsEventsConfig ?? resolvedConsent?.autoAnalyticsEvents }) })), autoWireDialogs && (_jsxs(_Fragment, { children: [_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentDialog, { ...(dialogProps ?? resolvedConsent?.dialogProps) }) }), _jsx(Suspense, { fallback: null, children: _jsx(PrivacyPolicyUpdateDialog, { ...(updateDialogProps ?? resolvedConsent?.updateDialogProps) }) })] }))] }));
|
|
35
|
+
}
|
|
36
|
+
return (_jsxs(_Fragment, { children: [_jsx(ClientThemeScript, {}), providedChildren] }));
|
|
37
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from 'cloudflare-next-intl-theme/ClientThemeScript';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-theme/ClientThemeScript';
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { isDarkCookieKey } from "../../config/index.js";
|
|
4
|
-
import getCookie from "../functions/get_cookie.js";
|
|
5
|
-
export default function ClientHelperScript() {
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const isDark = getCookie(isDarkCookieKey);
|
|
8
|
-
const classList = document.documentElement.classList;
|
|
9
|
-
const isDarkBool = isDark === 'true';
|
|
10
|
-
if (classList.contains('dark') !== isDarkBool) {
|
|
11
|
-
classList.toggle('dark', isDarkBool);
|
|
12
|
-
}
|
|
13
|
-
}, []);
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
1
|
+
export * from 'cloudflare-next-intl-theme/ClientThemeScript';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-theme/ClientThemeScript';
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type {
|
|
5
|
-
import type { PrivacyPolicyUpdateDialogProps } from "../../cookie_consent/client/components/privacy_policy_update_dialog.js";
|
|
6
|
-
import { LocaleContext } from "./locale_provider.js";
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LocaleContext } from 'cloudflare-next-intl-intl/internal/clientProvider';
|
|
3
|
+
import { type ClientExtensionsProps } from './client_extensions.js';
|
|
4
|
+
import type { TranslationObject } from 'cloudflare-next-intl-intl/types';
|
|
7
5
|
export { LocaleContext };
|
|
8
|
-
export
|
|
6
|
+
export interface LocationzationClientProviderProps extends ClientExtensionsProps {
|
|
9
7
|
language: string;
|
|
10
8
|
messages: TranslationObject;
|
|
11
|
-
initialAuthUser?: SerializedAuthUser | null;
|
|
12
|
-
skipAuthProvider?: boolean;
|
|
13
|
-
analyticsConfig?: CookieConsentAnalyticsConfig;
|
|
14
|
-
autoAnalyticsEventsConfig?: AutoAnalyticsEventsConfig;
|
|
15
|
-
requiresConsent?: boolean;
|
|
16
|
-
autoWireDialogs?: boolean;
|
|
17
|
-
dialogProps?: CookieConsentDialogProps;
|
|
18
|
-
updateDialogProps?: PrivacyPolicyUpdateDialogProps;
|
|
19
9
|
children: React.ReactNode;
|
|
20
|
-
}
|
|
10
|
+
}
|
|
11
|
+
export default function LocationzationClientProvider({ language, messages, children, ...clientExtensionProps }: LocationzationClientProviderProps): React.JSX.Element;
|
|
@@ -1,38 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import dynamic from "next/dynamic.js";
|
|
6
|
-
import CookieConsentProvider from "../../cookie_consent/client/cookie_consent_provider.js";
|
|
7
|
-
import AuthUserProvider from "../../firebase_auth/client/auth_user_provider.js";
|
|
8
|
-
import config from "@intl-config";
|
|
9
|
-
import installConsoleErrorOverride from "../../error_handling/install_console_error_override.js";
|
|
10
|
-
import installGlobalErrorOverride from "../../error_handling/install_global_error_override.js";
|
|
11
|
-
import { LocaleContext } from "./locale_provider.js";
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import LocationzationClientProviderCore, { LocaleContext } from 'cloudflare-next-intl-intl/internal/clientProvider';
|
|
4
|
+
import ClientExtensions from './client_extensions.js';
|
|
12
5
|
export { LocaleContext };
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const AutoAnalyticsEvents = dynamic(() => import("../../cookie_consent/client/components/auto_analytics_events.js"));
|
|
16
|
-
const loadCookieConsentDialog = () => import("../../cookie_consent/client/components/cookie_consent_dialog.js");
|
|
17
|
-
const CookieConsentDialog = dynamic(loadCookieConsentDialog);
|
|
18
|
-
const PrivacyPolicyUpdateDialog = dynamic(() => import("../../cookie_consent/client/components/privacy_policy_update_dialog.js"));
|
|
19
|
-
export default function LocationzationClientProvider({ language, messages, initialAuthUser = null, skipAuthProvider = false, analyticsConfig, autoAnalyticsEventsConfig, requiresConsent = true, autoWireDialogs = true, dialogProps, updateDialogProps, children }) {
|
|
20
|
-
setLocaleCache(language);
|
|
21
|
-
setMessageForLocaleCache(language, messages);
|
|
22
|
-
installConsoleErrorOverride(config, true);
|
|
23
|
-
installGlobalErrorOverride(config);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (!config.cookieConsent || !autoWireDialogs)
|
|
26
|
-
return;
|
|
27
|
-
loadCookieConsentDialog().catch(() => undefined);
|
|
28
|
-
}, [autoWireDialogs]);
|
|
29
|
-
let providedChildren = children;
|
|
30
|
-
if (config.firebaseAuth && !skipAuthProvider) {
|
|
31
|
-
providedChildren = _jsxs(AuthUserProvider, { initialUser: initialAuthUser, children: [children, config.firebaseAuth.performance !== false && (_jsx(Suspense, { fallback: null, children: _jsx(AutoFirebasePerformanceEvents, {}) }))] });
|
|
32
|
-
}
|
|
33
|
-
if (config.cookieConsent) {
|
|
34
|
-
providedChildren = _jsxs(CookieConsentProvider, { requiresConsent: requiresConsent, children: [providedChildren, analyticsConfig && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentAnalytics, { config: analyticsConfig }) })), analyticsConfig && (analyticsConfig.googleAnalyticsId || analyticsConfig.googleAdsId) && (_jsx(Suspense, { fallback: null, children: _jsx(AutoAnalyticsEvents, { config: autoAnalyticsEventsConfig ?? config.cookieConsent?.autoAnalyticsEvents }) })), autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentDialog, { ...(dialogProps ?? config.cookieConsent?.dialogProps) }) })), autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(PrivacyPolicyUpdateDialog, { ...(updateDialogProps ?? config.cookieConsent?.updateDialogProps) }) }))] });
|
|
35
|
-
}
|
|
36
|
-
const contextValue = useMemo(() => ({ language, messages }), [language, messages]);
|
|
37
|
-
return _jsx(LocaleContext.Provider, { value: contextValue, children: providedChildren });
|
|
6
|
+
export default function LocationzationClientProvider({ language, messages, children, ...clientExtensionProps }) {
|
|
7
|
+
return (_jsx(LocationzationClientProviderCore, { language: language, messages: messages, children: _jsx(ClientExtensions, { ...clientExtensionProps, children: children }) }));
|
|
38
8
|
}
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { CookieConsentDialogProps } from "../../cookie_consent/client/components/cookie_consent_dialog.js";
|
|
4
|
-
import type { PrivacyPolicyUpdateDialogProps } from "../../cookie_consent/client/components/privacy_policy_update_dialog.js";
|
|
5
|
-
interface LocaleContextType {
|
|
6
|
-
language: string;
|
|
7
|
-
messages: TranslationObject;
|
|
8
|
-
}
|
|
9
|
-
export declare const LocaleContext: import("react").Context<LocaleContextType | undefined>;
|
|
10
|
-
export default function LocationzationClientProvider({ language, messages, analyticsConfig, autoAnalyticsEventsConfig, requiresConsent, autoWireDialogs, dialogProps, updateDialogProps, children }: {
|
|
11
|
-
language: string;
|
|
12
|
-
messages: TranslationObject;
|
|
13
|
-
analyticsConfig?: CookieConsentAnalyticsConfig;
|
|
14
|
-
autoAnalyticsEventsConfig?: AutoAnalyticsEventsConfig;
|
|
15
|
-
requiresConsent?: boolean;
|
|
16
|
-
autoWireDialogs?: boolean;
|
|
17
|
-
dialogProps?: CookieConsentDialogProps;
|
|
18
|
-
updateDialogProps?: PrivacyPolicyUpdateDialogProps;
|
|
19
|
-
children: React.ReactNode;
|
|
20
|
-
}): Component;
|
|
21
|
-
export {};
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/internal/clientProviderStatic';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/internal/clientProviderStatic';
|
|
@@ -1,26 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { setLocaleCache, setMessageForLocaleCache } from "../../general/cache_variables.js";
|
|
4
|
-
import { createContext, useMemo, Suspense } from "react";
|
|
5
|
-
import dynamic from "next/dynamic.js";
|
|
6
|
-
import CookieConsentProvider from "../../cookie_consent/client/cookie_consent_provider.js";
|
|
7
|
-
import config from "@intl-config";
|
|
8
|
-
import installConsoleErrorOverride from "../../error_handling/install_console_error_override.js";
|
|
9
|
-
import installGlobalErrorOverride from "../../error_handling/install_global_error_override.js";
|
|
10
|
-
export const LocaleContext = createContext(undefined);
|
|
11
|
-
const CookieConsentAnalytics = dynamic(() => import("../../cookie_consent/client/components/cookie_consent_analytics.js"));
|
|
12
|
-
const AutoAnalyticsEvents = dynamic(() => import("../../cookie_consent/client/components/auto_analytics_events.js"));
|
|
13
|
-
const CookieConsentDialog = dynamic(() => import("../../cookie_consent/client/components/cookie_consent_dialog.js"));
|
|
14
|
-
const PrivacyPolicyUpdateDialog = dynamic(() => import("../../cookie_consent/client/components/privacy_policy_update_dialog.js"));
|
|
15
|
-
export default function LocationzationClientProvider({ language, messages, analyticsConfig, autoAnalyticsEventsConfig, requiresConsent = true, autoWireDialogs = true, dialogProps, updateDialogProps, children }) {
|
|
16
|
-
setLocaleCache(language);
|
|
17
|
-
setMessageForLocaleCache(language, messages);
|
|
18
|
-
installConsoleErrorOverride(config, true);
|
|
19
|
-
installGlobalErrorOverride(config);
|
|
20
|
-
let providedChildren = children;
|
|
21
|
-
if (config.cookieConsent) {
|
|
22
|
-
providedChildren = _jsxs(CookieConsentProvider, { requiresConsent: requiresConsent, children: [providedChildren, analyticsConfig && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentAnalytics, { config: analyticsConfig }) })), analyticsConfig && (analyticsConfig.googleAnalyticsId || analyticsConfig.googleAdsId) && (_jsx(Suspense, { fallback: null, children: _jsx(AutoAnalyticsEvents, { config: autoAnalyticsEventsConfig ?? config.cookieConsent?.autoAnalyticsEvents }) })), autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentDialog, { ...(dialogProps ?? config.cookieConsent?.dialogProps) }) })), autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(PrivacyPolicyUpdateDialog, { ...(updateDialogProps ?? config.cookieConsent?.updateDialogProps) }) }))] });
|
|
23
|
-
}
|
|
24
|
-
const contextValue = useMemo(() => ({ language, messages }), [language, messages]);
|
|
25
|
-
return _jsx(LocaleContext.Provider, { value: contextValue, children: providedChildren });
|
|
26
|
-
}
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/internal/clientProviderStatic';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/internal/clientProviderStatic';
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
declare const LocaleLink: import("react").ForwardRefExoticComponent<Omit<LocaleLinkProps, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
8
|
-
export default LocaleLink;
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/LocaleLink';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/LocaleLink';
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import LocaleLinkClient from './locale_link_client.js';
|
|
4
|
-
function LocaleLinkComponent(params, ref) {
|
|
5
|
-
return _jsx(Suspense, { fallback: _jsx("a", { ...params, ref: ref, className: params.className + ' pointer-events-none' }), children: _jsx(LocaleLinkClient, { ref: ref, ...params }) });
|
|
6
|
-
}
|
|
7
|
-
const LocaleLink = forwardRef(LocaleLinkComponent);
|
|
8
|
-
export default LocaleLink;
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/LocaleLink';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/LocaleLink';
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default LocaleLinkClient;
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/internal/localeLinkClient';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/internal/localeLinkClient';
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { forwardRef, useEffect, useState, } from 'react';
|
|
4
|
-
import config from '../../config/intl_config.js';
|
|
5
|
-
import usePathname from '../hooks/use_path_name.js';
|
|
6
|
-
import { localeCookieName } from '../../config/cookie_key.js';
|
|
7
|
-
import setCookie from '../functions/set_cookie.js';
|
|
8
|
-
import { useSearchParams } from 'next/navigation.js';
|
|
9
|
-
function ClientLocaleLinkComponent({ locale, className, ...rest }, ref) {
|
|
10
|
-
const pathname = usePathname();
|
|
11
|
-
const searchParams = useSearchParams();
|
|
12
|
-
const [hash, setHash] = useState('');
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
setHash(window.location.hash);
|
|
15
|
-
}, [pathname, searchParams]);
|
|
16
|
-
const isDefaultLocale = locale === config.defaultLocale;
|
|
17
|
-
const localePrefix = isDefaultLocale ? '' : `/${locale}`;
|
|
18
|
-
const search = searchParams.toString();
|
|
19
|
-
const newPathname = pathname === '/' && (localePrefix) ? '' : pathname;
|
|
20
|
-
const href = `${localePrefix}${newPathname}${search ? `?${search}` : ''}${hash}`;
|
|
21
|
-
function handleNavigate(e) {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
setCookie({ name: localeCookieName, value: locale });
|
|
24
|
-
window.location.replace(href);
|
|
25
|
-
}
|
|
26
|
-
;
|
|
27
|
-
return _jsx("a", { ref: ref, hrefLang: locale, className: className, ...rest, href: href, onClick: handleNavigate });
|
|
28
|
-
}
|
|
29
|
-
const LocaleLinkClient = forwardRef(ClientLocaleLinkComponent);
|
|
30
|
-
export default LocaleLinkClient;
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/internal/localeLinkClient';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/internal/localeLinkClient';
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface LocaleContextType {
|
|
4
|
-
language: string;
|
|
5
|
-
messages: TranslationObject;
|
|
6
|
-
}
|
|
7
|
-
export declare const LocaleContext: import("react").Context<LocaleContextType | undefined>;
|
|
8
|
-
export default function LocaleProvider({ language, messages, children }: {
|
|
9
|
-
language: string;
|
|
10
|
-
messages: TranslationObject;
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
}): React.JSX.Element;
|
|
13
|
-
export {};
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/internal/localeProvider';
|
|
2
|
+
export { default, LocaleContext } from 'cloudflare-next-intl-intl/internal/localeProvider';
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { createContext, useMemo } from "react";
|
|
4
|
-
export const LocaleContext = createContext(undefined);
|
|
5
|
-
export default function LocaleProvider({ language, messages, children }) {
|
|
6
|
-
const value = useMemo(() => ({ language, messages }), [language, messages]);
|
|
7
|
-
return _jsx(LocaleContext.Provider, { value: value, children: children });
|
|
8
|
-
}
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/internal/localeProvider';
|
|
2
|
+
export { default, LocaleContext } from 'cloudflare-next-intl-intl/internal/localeProvider';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/getCookieClient';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/getCookieClient';
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default function getCookie(name) {
|
|
4
|
-
try {
|
|
5
|
-
const cookie = document.cookie;
|
|
6
|
-
const prefix = `${name}=`;
|
|
7
|
-
let start = -1;
|
|
8
|
-
if (cookie.startsWith(prefix)) {
|
|
9
|
-
start = prefix.length;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
const idx = cookie.indexOf(`; ${prefix}`);
|
|
13
|
-
if (idx !== -1)
|
|
14
|
-
start = idx + 2 + prefix.length;
|
|
15
|
-
}
|
|
16
|
-
if (start === -1)
|
|
17
|
-
return null;
|
|
18
|
-
const end = cookie.indexOf(';', start);
|
|
19
|
-
const value = end === -1 ? cookie.slice(start) : cookie.slice(start, end);
|
|
20
|
-
return decodeURIComponent(value);
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
void reportError(undefined, {
|
|
24
|
-
error: e,
|
|
25
|
-
classOrMethodName: 'getCookie',
|
|
26
|
-
isClient: true,
|
|
27
|
-
params: { name },
|
|
28
|
-
});
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
;
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/getCookieClient';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/getCookieClient';
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
value: string | number | boolean;
|
|
4
|
-
maxAge?: number;
|
|
5
|
-
}): void;
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/setCookieClient';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/setCookieClient';
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default function setCookie({ name, value, maxAge }) {
|
|
4
|
-
try {
|
|
5
|
-
const cookieString = `${name}=${value}; path=/; max-age=${maxAge ?? 31536000}; SameSite=Lax;`;
|
|
6
|
-
document.cookie = cookieString;
|
|
7
|
-
}
|
|
8
|
-
catch (e) {
|
|
9
|
-
void reportError(undefined, {
|
|
10
|
-
error: e,
|
|
11
|
-
classOrMethodName: 'setCookie',
|
|
12
|
-
isClient: true,
|
|
13
|
-
params: { name },
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
;
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/setCookieClient';
|
|
2
|
+
export { default } from 'cloudflare-next-intl-intl/setCookieClient';
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { useContext, useMemo } from "react";
|
|
3
|
-
import { LocaleContext } from "../components/client_provider.js";
|
|
4
|
-
import { getTranslationsImpl } from "../../general/general_functions.js";
|
|
5
|
-
export function useLocale() {
|
|
6
|
-
const context = useContext(LocaleContext);
|
|
7
|
-
if (context === undefined) {
|
|
8
|
-
throw new Error('useLocale must be used within an IntlProvider');
|
|
9
|
-
}
|
|
10
|
-
return context.language;
|
|
11
|
-
}
|
|
12
|
-
export function useTranslations(namespace) {
|
|
13
|
-
const context = useContext(LocaleContext);
|
|
14
|
-
if (context === undefined) {
|
|
15
|
-
throw new Error('useTranslations must be used within an IntlProvider');
|
|
16
|
-
}
|
|
17
|
-
const { language, messages } = context;
|
|
18
|
-
return useMemo(() => getTranslationsImpl(language, messages, namespace), [language, messages, namespace]);
|
|
19
|
-
}
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/internal/clientHooks';
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/usePathname';
|
|
2
|
+
export { default, usePathname } from 'cloudflare-next-intl-intl/usePathname';
|
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { useLocale } from "./client_hooks.js";
|
|
4
|
-
export default function usePathname() {
|
|
5
|
-
const pathname = nextUsePathname();
|
|
6
|
-
const locale = useLocale();
|
|
7
|
-
if (!pathname) {
|
|
8
|
-
return '/';
|
|
9
|
-
}
|
|
10
|
-
const path = pathname.replace(`/${locale}`, '');
|
|
11
|
-
if (path) {
|
|
12
|
-
return path;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
return '/';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
1
|
+
export * from 'cloudflare-next-intl-intl/usePathname';
|
|
2
|
+
export { default, usePathname } from 'cloudflare-next-intl-intl/usePathname';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
export { default as LocaleProvider, LocaleContext } from './components/locale_provider.js';
|
|
2
|
+
export { default as LocationzationClientProvider } from './components/client_provider.js';
|
|
1
3
|
export { default as LocaleLink } from './components/locale_link.js';
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as LocaleLinkClient } from './components/locale_link_client.js';
|
|
5
|
+
export { default as getCookie } from './functions/get_cookie.js';
|
|
6
|
+
export { default as setCookie } from './functions/set_cookie.js';
|
|
7
|
+
export { usePathname } from './hooks/use_path_name.js';
|
|
8
|
+
export { useLocale, useTranslations } from './hooks/client_hooks.js';
|
package/dist/src/client/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
export { default as LocaleProvider, LocaleContext } from './components/locale_provider.js';
|
|
2
|
+
export { default as LocationzationClientProvider } from './components/client_provider.js';
|
|
1
3
|
export { default as LocaleLink } from './components/locale_link.js';
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as LocaleLinkClient } from './components/locale_link_client.js';
|
|
5
|
+
export { default as getCookie } from './functions/get_cookie.js';
|
|
6
|
+
export { default as setCookie } from './functions/set_cookie.js';
|
|
7
|
+
export { usePathname } from './hooks/use_path_name.js';
|
|
8
|
+
export { useLocale, useTranslations } from './hooks/client_hooks.js';
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { matchesNamespacePattern } from "./match_namespace.js";
|
|
3
|
-
export { scanProject, type ScanProjectOptions, type ClientMessagesManifest } from "./scan_project.js";
|
|
1
|
+
export * from "cloudflare-next-intl-intl/internal/clientMessagesScan";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from "cloudflare-next-intl-intl/internal/matchNamespace";
|
|
@@ -1,16 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
file: string;
|
|
3
|
-
line: number;
|
|
4
|
-
text: string;
|
|
5
|
-
prop?: {
|
|
6
|
-
component: string;
|
|
7
|
-
name: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export interface FileScanResult {
|
|
11
|
-
namespaces: string[];
|
|
12
|
-
dynamicCalls: DynamicCall[];
|
|
13
|
-
usesRoot: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare function findJsxPropValues(file: string, code: string, component: string, prop: string): string[] | null;
|
|
16
|
-
export declare function scanFile(file: string, code: string): FileScanResult;
|
|
1
|
+
export * from "cloudflare-next-intl-intl/internal/scanFile";
|