cloudflare-next-intl 0.9.28 → 0.9.29
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,4 +7,6 @@ export type ResolvedDbMode = {
|
|
|
7
7
|
mode: 'supabase';
|
|
8
8
|
supabase: SupabaseDbConfig;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
declare function resolveDbModeUncached(db: DbRoutingConfig, generate?: GenerateRoutingConfig): Promise<ResolvedDbMode>;
|
|
11
|
+
declare const resolveDbMode: typeof resolveDbModeUncached;
|
|
12
|
+
export default resolveDbMode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
1
2
|
import resolveConfigValue from './resolve_config_value.js';
|
|
2
3
|
import { resolveHyperdriveConnectionString } from './resolve_hyperdrive_connection_string.js';
|
|
3
|
-
|
|
4
|
+
async function resolveDbModeUncached(db, generate) {
|
|
4
5
|
const connectionString = await resolveConfigValue(db.connectionString);
|
|
5
6
|
if (connectionString)
|
|
6
7
|
return { mode: 'postgres', connectionString };
|
|
@@ -13,3 +14,5 @@ export default async function resolveDbMode(db, generate) {
|
|
|
13
14
|
return { mode: 'supabase', supabase: db.supabase };
|
|
14
15
|
return { mode: 'postgres', connectionString: undefined };
|
|
15
16
|
}
|
|
17
|
+
const resolveDbMode = cache(resolveDbModeUncached);
|
|
18
|
+
export default resolveDbMode;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
1
2
|
import resolveSupabaseEndpoint from './supabase_config.js';
|
|
3
|
+
const getOrCreateClient = cache(async (supabase, bearerToken) => {
|
|
4
|
+
const { url, anonKey } = await resolveSupabaseEndpoint(supabase);
|
|
5
|
+
const { createClient } = await import('@supabase/supabase-js');
|
|
6
|
+
return createClient(url, anonKey, { accessToken: async () => bearerToken });
|
|
7
|
+
});
|
|
2
8
|
export default function createRestClient(supabase, bearerToken) {
|
|
3
9
|
let clientPromise = null;
|
|
4
|
-
return () =>
|
|
5
|
-
clientPromise ?? (clientPromise = (async () => {
|
|
6
|
-
const { url, anonKey } = await resolveSupabaseEndpoint(supabase);
|
|
7
|
-
const { createClient } = await import('@supabase/supabase-js');
|
|
8
|
-
return createClient(url, anonKey, { accessToken: async () => bearerToken });
|
|
9
|
-
})());
|
|
10
|
-
return clientPromise;
|
|
11
|
-
};
|
|
10
|
+
return () => (clientPromise ?? (clientPromise = getOrCreateClient(supabase, bearerToken)));
|
|
12
11
|
}
|
|
@@ -27,6 +27,12 @@ function CustomLinkFunction({ href, prefetch, prefetchType = 'custom', onClick,
|
|
|
27
27
|
useEffect(() => {
|
|
28
28
|
setIsNavigating(false);
|
|
29
29
|
}, [pathname]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!isNavigating)
|
|
32
|
+
return;
|
|
33
|
+
const timer = setTimeout(() => setIsNavigating(false), 10000);
|
|
34
|
+
return () => clearTimeout(timer);
|
|
35
|
+
}, [isNavigating]);
|
|
30
36
|
const isCustom = prefetchType === 'custom' && prefetch !== false;
|
|
31
37
|
const triggerPrefetch = useCallback(() => {
|
|
32
38
|
if (!isCustom || !urlString || urlString.startsWith('#') || prefetchedRoutes.has(urlString)) {
|
|
@@ -3,4 +3,6 @@ export declare const defaultCountryHeaderNames: readonly string[];
|
|
|
3
3
|
export declare const defaultTimezoneHeaderNames: readonly string[];
|
|
4
4
|
export declare function getCountry(input?: RequestOrHeaders, generate?: GenerateRoutingConfig, headerNames?: readonly string[]): Promise<string | undefined>;
|
|
5
5
|
export declare function getTimezone(input?: RequestOrHeaders, fallback?: string, generate?: GenerateRoutingConfig, headerNames?: readonly string[]): Promise<string | undefined>;
|
|
6
|
-
|
|
6
|
+
declare function resolveEnvUncached(generate?: GenerateRoutingConfig): Promise<Record<string, unknown> | undefined>;
|
|
7
|
+
export declare const resolveEnv: typeof resolveEnvUncached;
|
|
8
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cache } from 'react';
|
|
1
2
|
import { countryCookieKey, timezoneCookieKey } from '../../config/cookie_key.js';
|
|
2
3
|
export const defaultCountryHeaderNames = ['x-cf-country', 'cf-ipcountry'];
|
|
3
4
|
export const defaultTimezoneHeaderNames = ['x-cf-timezone', 'cf-timezone'];
|
|
@@ -201,7 +202,7 @@ export async function getTimezone(input, fallback, generate, headerNames) {
|
|
|
201
202
|
}
|
|
202
203
|
return fallback;
|
|
203
204
|
}
|
|
204
|
-
|
|
205
|
+
async function resolveEnvUncached(generate) {
|
|
205
206
|
if (!generate)
|
|
206
207
|
return undefined;
|
|
207
208
|
if (generate.env) {
|
|
@@ -219,3 +220,4 @@ export async function resolveEnv(generate) {
|
|
|
219
220
|
}
|
|
220
221
|
return undefined;
|
|
221
222
|
}
|
|
223
|
+
export const resolveEnv = cache(resolveEnvUncached);
|