cloudflare-next-intl 0.10.10 → 0.10.13

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.
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { setLocaleCache, setMessageForLocaleCache } from "../../general/cache_variables.js";
4
- import { createContext, useMemo } from "react";
4
+ import { createContext, useMemo, Suspense } from "react";
5
5
  import dynamic from "next/dynamic.js";
6
6
  import useLazyWrappingProvider from "./use_lazy_wrapping_provider.js";
7
7
  import config from "@intl-config";
@@ -25,10 +25,10 @@ export default function LocationzationClientProvider({ language, messages, initi
25
25
  const { Provider: CookieConsentProvider, isReady: cookieConsentReady } = useLazyWrappingProvider(loadCookieConsentProvider);
26
26
  let providedChildren = children;
27
27
  if (config.firebaseAuth && !skipAuthProvider) {
28
- providedChildren = _jsx(AuthUserPendingProvider, { initialUser: initialAuthUser, children: _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(Suspense, { fallback: null, children: _jsx(AutoFirebasePerformanceEvents, {}) }))] }) });
29
29
  }
30
30
  if (config.cookieConsent) {
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 })] });
31
+ providedChildren = _jsxs(CookieConsentProvider, { requiresConsent: requiresConsent, children: [providedChildren, cookieConsentReady && analyticsConfig && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentAnalytics, { config: analyticsConfig }) })), cookieConsentReady && analyticsConfig && (analyticsConfig.googleAnalyticsId || analyticsConfig.googleAdsId) && (_jsx(Suspense, { fallback: null, children: _jsx(AutoAnalyticsEvents, { config: autoAnalyticsEventsConfig }) })), cookieConsentReady && autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentDialog, { ...dialogProps }) })), cookieConsentReady && autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(PrivacyPolicyUpdateDialog, { ...updateDialogProps }) }))] });
32
32
  }
33
33
  const contextValue = useMemo(() => ({ language, messages }), [language, messages]);
34
34
  return _jsx(LocaleContext.Provider, { value: contextValue, children: providedChildren });
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { setLocaleCache, setMessageForLocaleCache } from "../../general/cache_variables.js";
4
- import { createContext, useMemo } from "react";
4
+ import { createContext, useMemo, Suspense } from "react";
5
5
  import dynamic from "next/dynamic.js";
6
6
  import useLazyWrappingProvider from "./use_lazy_wrapping_provider.js";
7
7
  import config from "@intl-config";
@@ -21,7 +21,7 @@ export default function LocationzationClientProvider({ language, messages, analy
21
21
  const { Provider: CookieConsentProvider, isReady: cookieConsentReady } = useLazyWrappingProvider(loadCookieConsentProvider);
22
22
  let providedChildren = children;
23
23
  if (config.cookieConsent) {
24
- 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 })] });
24
+ providedChildren = _jsxs(CookieConsentProvider, { requiresConsent: requiresConsent, children: [providedChildren, cookieConsentReady && analyticsConfig && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentAnalytics, { config: analyticsConfig }) })), cookieConsentReady && analyticsConfig && (analyticsConfig.googleAnalyticsId || analyticsConfig.googleAdsId) && (_jsx(Suspense, { fallback: null, children: _jsx(AutoAnalyticsEvents, { config: autoAnalyticsEventsConfig }) })), cookieConsentReady && autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsentDialog, { ...dialogProps }) })), cookieConsentReady && autoWireDialogs && (_jsx(Suspense, { fallback: null, children: _jsx(PrivacyPolicyUpdateDialog, { ...updateDialogProps }) }))] });
25
25
  }
26
26
  const contextValue = useMemo(() => ({ language, messages }), [language, messages]);
27
27
  return _jsx(LocaleContext.Provider, { value: contextValue, children: providedChildren });
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useEffect } from 'react';
3
+ import { useEffect, Suspense } from 'react';
4
4
  import dynamic from 'next/dynamic.js';
5
5
  import useCookieConsent from '../use_cookie_consent.js';
6
6
  const ClarityScript = dynamic(() => import('./clarity_script.js'));
@@ -22,7 +22,7 @@ export default function CookieConsentAnalytics({ config }) {
22
22
  });
23
23
  }, [consent, requiresConsent, granted]);
24
24
  const hasGoogle = Boolean(config.googleAnalyticsId || config.googleAdsId || config.googleAdSenseId);
25
- return (_jsxs(_Fragment, { children: [hasGoogle && (_jsx("script", { id: "cookie-consent-google-consent-mode", dangerouslySetInnerHTML: { __html: googleConsentModeBootstrapScript(config) } })), granted && config.cloudflareBeaconToken && (_jsx("script", { defer: true, src: "https://static.cloudflareinsights.com/beacon.min.js", "data-cf-beacon": config.cloudflareBeaconToken })), granted && config.clarityProjectId && _jsx(ClarityScript, { projectId: config.clarityProjectId })] }));
25
+ return (_jsxs(_Fragment, { children: [hasGoogle && (_jsx("script", { id: "cookie-consent-google-consent-mode", dangerouslySetInnerHTML: { __html: googleConsentModeBootstrapScript(config) } })), granted && config.cloudflareBeaconToken && (_jsx("script", { defer: true, src: "https://static.cloudflareinsights.com/beacon.min.js", "data-cf-beacon": config.cloudflareBeaconToken })), granted && config.clarityProjectId && (_jsx(Suspense, { fallback: null, children: _jsx(ClarityScript, { projectId: config.clarityProjectId }) }))] }));
26
26
  }
27
27
  export function googleConsentModeBootstrapScript(config) {
28
28
  const configCalls = [config.googleAnalyticsId, config.googleAdsId]
@@ -197,7 +197,9 @@ export default async function updateSession(request, baseResponse, locale, rebui
197
197
  }
198
198
  }
199
199
  }
200
- const isWhiteListed = isWhitelisted(path, fa.whiteListPaths);
200
+ const isWhiteListed = fa.protectedPaths
201
+ ? !fa.protectedPaths(path) && !fa.isAuthPath(path)
202
+ : isWhitelisted(path, fa.whiteListPaths);
201
203
  if (isWhiteListed)
202
204
  return baseResponse;
203
205
  const isAuthPage = fa.isAuthPath(path);
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import dynamic from 'next/dynamic.js';
3
+ import { Suspense } from 'react';
3
4
  import { headers } from 'next/headers.js';
4
5
  import { redirect } from 'next/navigation.js';
5
6
  import config from '@intl-config';
@@ -32,5 +33,5 @@ export async function resolveAuthUserAndRedirect() {
32
33
  }
33
34
  export default async function AuthUserServerProvider({ children }) {
34
35
  const initialUser = await resolveAuthUserAndRedirect();
35
- return _jsx(AuthUserProvider, { initialUser: initialUser, children: children });
36
+ return (_jsx(Suspense, { fallback: children, children: _jsx(AuthUserProvider, { initialUser: initialUser, children: children }) }));
36
37
  }
@@ -4,5 +4,6 @@ export interface LoadResolvedFirebaseAuthOptions {
4
4
  viteConfig: Pick<ResolvedConfig, "root" | "envDir" | "mode"> & {
5
5
  resolve: Pick<ResolvedConfig["resolve"], "alias">;
6
6
  };
7
+ envDefaults?: Record<string, string>;
7
8
  }
8
9
  export declare function loadResolvedFirebaseAuth(options: LoadResolvedFirebaseAuthOptions): Promise<Record<string, unknown> | undefined>;
@@ -1,5 +1,12 @@
1
1
  export async function loadResolvedFirebaseAuth(options) {
2
2
  let server;
3
+ const restoreEnv = [];
4
+ for (const [key, value] of Object.entries(options.envDefaults ?? {})) {
5
+ if (process.env[key])
6
+ continue;
7
+ restoreEnv.push([key, process.env[key]]);
8
+ process.env[key] = value;
9
+ }
3
10
  try {
4
11
  const { createServer } = await import("vite");
5
12
  server = await createServer({
@@ -47,5 +54,11 @@ export async function loadResolvedFirebaseAuth(options) {
47
54
  }
48
55
  finally {
49
56
  await server?.close();
57
+ for (const [key, value] of restoreEnv) {
58
+ if (value === undefined)
59
+ delete process.env[key];
60
+ else
61
+ process.env[key] = value;
62
+ }
50
63
  }
51
64
  }
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { setLocaleCache, setMessageForLocaleCache } from "../../general/cache_variables.js";
3
3
  import { getMessage } from "../functions/server.js";
4
+ import { Suspense } from "react";
4
5
  import dynamic from "next/dynamic.js";
5
6
  import { localesSet } from "../../config/middleware.js";
6
7
  import config from "../../config/intl_config.js";
@@ -58,5 +59,5 @@ export default async function LocationzationProvider({ language, messages, stati
58
59
  }
59
60
  }
60
61
  }
61
- return _jsx(LocationzationClientProvider, { language: language, messages: messagesValue, initialAuthUser: initialAuthUser, skipAuthProvider: !autoWireClientProvider, analyticsConfig: analyticsConfig, autoAnalyticsEventsConfig: config.cookieConsent?.autoAnalyticsEvents, requiresConsent: requiresConsent, autoWireDialogs: config.cookieConsent?.autoWireDialogs !== false, dialogProps: config.cookieConsent?.dialogProps, updateDialogProps: config.cookieConsent?.updateDialogProps, children: children });
62
+ return (_jsx(Suspense, { fallback: children, children: _jsx(LocationzationClientProvider, { language: language, messages: messagesValue, initialAuthUser: initialAuthUser, skipAuthProvider: !autoWireClientProvider, analyticsConfig: analyticsConfig, autoAnalyticsEventsConfig: config.cookieConsent?.autoAnalyticsEvents, requiresConsent: requiresConsent, autoWireDialogs: config.cookieConsent?.autoWireDialogs !== false, dialogProps: config.cookieConsent?.dialogProps, updateDialogProps: config.cookieConsent?.updateDialogProps, children: children }) }));
62
63
  }
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { setLocaleCache, setMessageForLocaleCache } from "../../general/cache_variables.js";
3
3
  import { getMessage } from "../functions/server.js";
4
+ import { Suspense } from "react";
4
5
  import dynamic from "next/dynamic.js";
5
6
  import { localesSet } from "../../config/middleware.js";
6
7
  import config from "../../config/intl_config.js";
@@ -47,5 +48,5 @@ export default async function LocationzationProvider({ language, messages, child
47
48
  }
48
49
  }
49
50
  }
50
- return _jsx(LocationzationClientProvider, { language: language, messages: messagesValue, analyticsConfig: analyticsConfig, autoAnalyticsEventsConfig: config.cookieConsent?.autoAnalyticsEvents, requiresConsent: requiresConsent, autoWireDialogs: config.cookieConsent?.autoWireDialogs !== false, dialogProps: config.cookieConsent?.dialogProps, updateDialogProps: config.cookieConsent?.updateDialogProps, children: children });
51
+ return (_jsx(Suspense, { fallback: children, children: _jsx(LocationzationClientProvider, { language: language, messages: messagesValue, analyticsConfig: analyticsConfig, autoAnalyticsEventsConfig: config.cookieConsent?.autoAnalyticsEvents, requiresConsent: requiresConsent, autoWireDialogs: config.cookieConsent?.autoWireDialogs !== false, dialogProps: config.cookieConsent?.dialogProps, updateDialogProps: config.cookieConsent?.updateDialogProps, children: children }) }));
51
52
  }
@@ -1,12 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
2
3
  import { Moon, Sun } from "./icons.js";
3
4
  import ThemeSwticherButton from "./theme_switcher_button.js";
4
5
  export default function ThemeSwticher(params) {
5
- return _jsxs(ThemeSwticherButton, { ...params, children: [_jsx(Sun, { className: "transition-transform duration-500 ease-in-out" +
6
- " rotate-0 scale-100 opacity-100 cursor-pointer" +
7
- " dark:rotate-90 dark:scale-0 dark:opacity-0" +
8
- " dark:w-0 dark:h-0 h-max w-max" }), _jsx(Moon, { className: "transition-transform duration-500 ease-in-out" +
9
- " -rotate-90 scale-0 opacity-0 cursor-pointer" +
10
- " dark:rotate-0 dark:scale-100 dark:opacity-100" +
11
- " w-0 h-0 dark:h-max dark:w-max" })] });
6
+ return (_jsx(Suspense, { fallback: _jsx("div", { "aria-hidden": "true", className: "relative flex items-center justify-center pointer-events-none select-none" +
7
+ " p-2.5 aspect-square h-11.5 rounded-full overflow-hidden" +
8
+ " animate-pulse bg-gray-200 dark:bg-gray-700 " +
9
+ (params.className ?? "") }), children: _jsxs(ThemeSwticherButton, { ...params, children: [_jsx(Sun, { className: "transition-transform duration-500 ease-in-out" +
10
+ " rotate-0 scale-100 opacity-100 cursor-pointer" +
11
+ " dark:rotate-90 dark:scale-0 dark:opacity-0" +
12
+ " dark:w-0 dark:h-0 h-max w-max" }), _jsx(Moon, { className: "transition-transform duration-500 ease-in-out" +
13
+ " -rotate-90 scale-0 opacity-0 cursor-pointer" +
14
+ " dark:rotate-0 dark:scale-100 dark:opacity-100" +
15
+ " w-0 h-0 dark:h-max dark:w-max" })] }) }));
12
16
  }
@@ -148,6 +148,7 @@ export interface FirebaseAuthRoutingConfig {
148
148
  preserveRedirectQuery?: boolean;
149
149
  isAuthPath: (path: string) => boolean;
150
150
  whiteListPaths?: readonly string[];
151
+ protectedPaths?: (path: string) => boolean;
151
152
  sessionCookieMaxAge?: number;
152
153
  refreshTokenCookieMaxAge?: number;
153
154
  sessionCookieName?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.10.10",
3
+ "version": "0.10.13",
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",