cloudflare-next-intl 0.9.61 → 0.9.62
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/dist/src/client/components/client_provider.js +2 -1
- package/dist/src/firebase_auth/client/auth_user_context.d.ts +10 -0
- package/dist/src/firebase_auth/client/auth_user_context.js +4 -0
- package/dist/src/firebase_auth/client/auth_user_pending_provider.d.ts +5 -0
- package/dist/src/firebase_auth/client/auth_user_pending_provider.js +17 -0
- package/dist/src/firebase_auth/client/auth_user_provider.d.ts +4 -9
- package/dist/src/firebase_auth/client/auth_user_provider.js +3 -2
- package/dist/src/firebase_auth/client/use_auth_user.d.ts +1 -1
- package/dist/src/firebase_auth/client/use_auth_user.js +1 -1
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ import useLazyWrappingProvider from "./use_lazy_wrapping_provider.js";
|
|
|
7
7
|
import config from "@intl-config";
|
|
8
8
|
import installConsoleErrorOverride from "../../error_handling/install_console_error_override.js";
|
|
9
9
|
import installGlobalErrorOverride from "../../error_handling/install_global_error_override.js";
|
|
10
|
+
import AuthUserPendingProvider from "../../firebase_auth/client/auth_user_pending_provider.js";
|
|
10
11
|
export const LocaleContext = createContext(undefined);
|
|
11
12
|
const loadAuthUserProvider = () => import("../../firebase_auth/client/auth_user_provider.js");
|
|
12
13
|
const AutoFirebasePerformanceEvents = dynamic(() => import("../../firebase_auth/client/components/auto_firebase_performance_events.js"));
|
|
@@ -24,7 +25,7 @@ export default function LocationzationClientProvider({ language, messages, initi
|
|
|
24
25
|
const { Provider: CookieConsentProvider, isReady: cookieConsentReady } = useLazyWrappingProvider(loadCookieConsentProvider);
|
|
25
26
|
let providedChildren = children;
|
|
26
27
|
if (config.firebaseAuth && !skipAuthProvider) {
|
|
27
|
-
providedChildren = _jsxs(AuthUserProvider, { initialUser: initialAuthUser, children: [children, config.firebaseAuth.performance !== false && _jsx(AutoFirebasePerformanceEvents, {})] });
|
|
28
|
+
providedChildren = _jsx(AuthUserPendingProvider, { initialUser: initialAuthUser, children: _jsxs(AuthUserProvider, { initialUser: initialAuthUser, children: [children, config.firebaseAuth.performance !== false && _jsx(AutoFirebasePerformanceEvents, {})] }) });
|
|
28
29
|
}
|
|
29
30
|
if (config.cookieConsent) {
|
|
30
31
|
providedChildren = _jsxs(CookieConsentProvider, { requiresConsent: requiresConsent, children: [providedChildren, cookieConsentReady && analyticsConfig && _jsx(CookieConsentAnalytics, { config: analyticsConfig }), cookieConsentReady && analyticsConfig && (analyticsConfig.googleAnalyticsId || analyticsConfig.googleAdsId) && _jsx(AutoAnalyticsEvents, { config: autoAnalyticsEventsConfig }), cookieConsentReady && autoWireDialogs && _jsx(CookieConsentDialog, { ...dialogProps }), cookieConsentReady && autoWireDialogs && _jsx(PrivacyPolicyUpdateDialog, { ...updateDialogProps })] });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuthActionCodeSettings, AuthUser } from '../types.js';
|
|
2
|
+
export interface AuthUserContextType {
|
|
3
|
+
user: AuthUser | null;
|
|
4
|
+
loading: boolean;
|
|
5
|
+
reloadUser: () => Promise<void>;
|
|
6
|
+
sendVerificationEmail: (actionCodeSettings?: AuthActionCodeSettings) => Promise<void>;
|
|
7
|
+
logout: () => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare const AuthUserContext: import("react").Context<AuthUserContextType | null>;
|
|
10
|
+
export default AuthUserContext;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { AuthUserContext } from './auth_user_context.js';
|
|
5
|
+
function notReady() {
|
|
6
|
+
return Promise.reject(new Error('AuthUserProvider is still loading'));
|
|
7
|
+
}
|
|
8
|
+
export default function AuthUserPendingProvider({ initialUser = null, children }) {
|
|
9
|
+
const value = useMemo(() => ({
|
|
10
|
+
user: initialUser,
|
|
11
|
+
loading: initialUser === null,
|
|
12
|
+
reloadUser: notReady,
|
|
13
|
+
sendVerificationEmail: notReady,
|
|
14
|
+
logout: notReady,
|
|
15
|
+
}), [initialUser]);
|
|
16
|
+
return _jsx(AuthUserContext.Provider, { value: value, children: children });
|
|
17
|
+
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
reloadUser: () => Promise<void>;
|
|
6
|
-
sendVerificationEmail: (actionCodeSettings?: AuthActionCodeSettings) => Promise<void>;
|
|
7
|
-
logout: () => Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export declare const AuthUserContext: import("react").Context<AuthUserContextType | null>;
|
|
1
|
+
import type { SerializedAuthUser } from '../types.js';
|
|
2
|
+
import { AuthUserContext, type AuthUserContextType } from './auth_user_context.js';
|
|
3
|
+
export { AuthUserContext };
|
|
4
|
+
export type { AuthUserContextType };
|
|
10
5
|
export default function AuthUserProvider({ initialUser, children }: {
|
|
11
6
|
initialUser?: SerializedAuthUser | null;
|
|
12
7
|
children: React.ReactNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { useRouter } from 'next/navigation.js';
|
|
5
5
|
import usePathname from '../../client/hooks/use_path_name.js';
|
|
6
6
|
import config from '@intl-config';
|
|
@@ -14,7 +14,8 @@ import withRedirectQuery from '../preserve_redirect_query.js';
|
|
|
14
14
|
import setCookie from '../../client/functions/set_cookie.js';
|
|
15
15
|
import getCookie from '../../client/functions/get_cookie.js';
|
|
16
16
|
import clearSessionAction from '../server/clear_session_action.js';
|
|
17
|
-
|
|
17
|
+
import { AuthUserContext } from './auth_user_context.js';
|
|
18
|
+
export { AuthUserContext };
|
|
18
19
|
function writeSessionCookie(sessionCookieName, idToken, maxAge) {
|
|
19
20
|
setCookie({ name: sessionCookieName, value: idToken, maxAge });
|
|
20
21
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type AuthUserContextType } from './
|
|
1
|
+
import { type AuthUserContextType } from './auth_user_context.js';
|
|
2
2
|
export default function useAuthUser(): AuthUserContextType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
|
-
import { AuthUserContext } from './
|
|
3
|
+
import { AuthUserContext } from './auth_user_context.js';
|
|
4
4
|
export default function useAuthUser() {
|
|
5
5
|
const context = useContext(AuthUserContext);
|
|
6
6
|
if (context === null) {
|