cloudflare-next-intl 0.8.58 → 0.8.60

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.
@@ -5,9 +5,9 @@ import requireFirebaseAuthConfig from '../require_config';
5
5
  import { defaultAppCheckTokenCookieName, defaultRefreshTokenCookieName, defaultSessionCookieName, isIdTokenExpired, refreshIdToken, sessionCookieOptions } from '../middleware/update_session';
6
6
  import reportError from '../../error_handling/report_error';
7
7
  import mintServerAppCheckToken from './mint_server_app_check_token';
8
- let baseApp;
9
- let firebaseAppModule;
10
- let firebaseAuthModule;
8
+ let baseAppReady;
9
+ let firebaseAppModuleReady;
10
+ let firebaseAuthModuleReady;
11
11
  /**
12
12
  * Writes a freshly-minted session/refresh pair back to the cookie jar so the
13
13
  * NEXT request doesn't repeat the rejected-token round-trip. Next only allows
@@ -89,12 +89,10 @@ export const getAuthenticatedAppForUser = cache(async function getAuthenticatedA
89
89
  // with `currentUser === null`. So a null user (not a throw) is the signal
90
90
  // to drop the bad token and mint a replacement from the refresh cookie.
91
91
  const attempt = async (idToken) => {
92
- if (!firebaseAppModule)
93
- firebaseAppModule = await import('firebase/app');
94
- if (!firebaseAuthModule)
95
- firebaseAuthModule = await import('firebase/auth');
96
- const { initializeApp, initializeServerApp } = firebaseAppModule;
97
- const { getAuth } = firebaseAuthModule;
92
+ firebaseAppModuleReady ?? (firebaseAppModuleReady = import('firebase/app'));
93
+ firebaseAuthModuleReady ?? (firebaseAuthModuleReady = import('firebase/auth'));
94
+ const { initializeApp, initializeServerApp } = await firebaseAppModuleReady;
95
+ const { getAuth } = await firebaseAuthModuleReady;
98
96
  const firebaseConfig = {
99
97
  apiKey: fa.apiKey,
100
98
  authDomain: fa.authDomain,
@@ -109,8 +107,12 @@ export const getAuthenticatedAppForUser = cache(async function getAuthenticatedA
109
107
  // named app per token: `initializeServerApp` derives a distinct,
110
108
  // token-scoped auth context from this same base app without
111
109
  // registering a new named app in Firebase's global app registry.
112
- if (!baseApp)
113
- baseApp = initializeApp(firebaseConfig, 'firebase-auth-server-base');
110
+ // Cached as a promise (not the resolved app) so concurrent requests
111
+ // racing this on a cold start share one `initializeApp` call instead
112
+ // of each calling `initializeApp` with the same name and racing
113
+ // Firebase's internal app registry.
114
+ baseAppReady ?? (baseAppReady = (async () => initializeApp(firebaseConfig, 'firebase-auth-server-base'))());
115
+ const baseApp = await baseAppReady;
114
116
  const firebaseServerApp = initializeServerApp(baseApp, { authIdToken: idToken, appCheckToken });
115
117
  const auth = getAuth(firebaseServerApp);
116
118
  await auth.authStateReady();
@@ -1,6 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import NextImage, { getImageProps as nextGetImageProps } from "next/image";
3
- import manifest from "virtual:cloudflare-next-intl-images-manifest";
4
3
  import { getImageBlurSvg } from "./blur_svg.js";
5
4
  /**
6
5
  * When an image was generated at multiple widths (because it's used at
@@ -19,7 +18,13 @@ function pickVariant(entry, requestedWidth) {
19
18
  }
20
19
  return entry.variants.reduce((best, v) => (v.width > best.width ? v : best));
21
20
  }
22
- const manifestData = manifest;
21
+ let manifestData;
22
+ try {
23
+ manifestData = (await import(/* @vite-ignore */ "virtual:cloudflare-next-intl-images-manifest")).default;
24
+ }
25
+ catch {
26
+ manifestData = undefined;
27
+ }
23
28
  const images = (manifestData && typeof manifestData === "object" && manifestData.images)
24
29
  ? manifestData.images
25
30
  : {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.8.58",
3
+ "version": "0.8.60",
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",