cloudflare-next-intl 0.9.60 → 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.
@@ -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,4 @@
1
+ 'use client';
2
+ import { createContext } from 'react';
3
+ export const AuthUserContext = createContext(null);
4
+ export default AuthUserContext;
@@ -0,0 +1,5 @@
1
+ import type { SerializedAuthUser } from '../types.js';
2
+ export default function AuthUserPendingProvider({ initialUser, children }: {
3
+ initialUser?: SerializedAuthUser | null;
4
+ children?: React.ReactNode;
5
+ }): React.JSX.Element;
@@ -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 { AuthActionCodeSettings, AuthUser, SerializedAuthUser } 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>;
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 { createContext, useCallback, useEffect, useRef, useState } from 'react';
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
- export const AuthUserContext = createContext(null);
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 './auth_user_provider.js';
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 './auth_user_provider.js';
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) {
@@ -55,7 +55,17 @@ export default function HelperScript() {
55
55
  if (!document.getElementById(overlayStyleId)) {
56
56
  var st = document.createElement('style');
57
57
  st.id = overlayStyleId;
58
- st.textContent = 'html{background:#ffffff !important}body>*:not(#' + overlayId + '){visibility:hidden !important}';
58
+ st.textContent = [
59
+ 'html,body{background:#ffffff !important}',
60
+ 'body>*:not(#' + overlayId + '){visibility:hidden !important}',
61
+ // Until <body> exists there is nowhere to put
62
+ // the spinner element, and a blank screen reads
63
+ // as a hang. A pseudo-element needs no host, so
64
+ // it covers that gap and steps aside as soon as
65
+ // the real overlay is in the document.
66
+ 'html:not(:has(#' + overlayId + '))::after{content:"";position:fixed;top:50%;left:50%;width:2.25rem;height:2.25rem;margin:-1.125rem 0 0 -1.125rem;border:0.1875rem solid #e5e7eb;border-top-color:#17181b;border-radius:50%;animation:cfni-spin 0.8s linear infinite;z-index:2147483647}',
67
+ '@keyframes cfni-spin{to{transform:rotate(360deg)}}'
68
+ ].join('');
59
69
  (document.head || document.documentElement).appendChild(st);
60
70
  }
61
71
  if (document.getElementById(overlayId)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.60",
3
+ "version": "0.9.62",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",