next-intl
Advanced tools
Comparing version
@@ -8,2 +8,3 @@ import { normalizeTrailingSlash } from '../shared/utils.js'; | ||
function getAlternateLinksHeaderValue({ | ||
internalTemplateName, | ||
localizedPathnames, | ||
@@ -32,3 +33,4 @@ request, | ||
if (localizedPathnames && typeof localizedPathnames === 'object') { | ||
return formatTemplatePathname(pathname, localizedPathnames[resolvedLocale], localizedPathnames[locale]); | ||
const sourceTemplate = localizedPathnames[resolvedLocale]; | ||
return formatTemplatePathname(pathname, sourceTemplate ?? internalTemplateName, localizedPathnames[locale] ?? internalTemplateName); | ||
} else { | ||
@@ -80,6 +82,9 @@ return pathname; | ||
// For domain-based routing there is no reasonable x-default | ||
!routing.domains && (routing.localePrefix.mode !== 'always' || normalizedUrl.pathname === '/'); | ||
!routing.domains || routing.domains.length === 0; | ||
if (shouldAddXDefault) { | ||
const url = new URL(getLocalizedPathname(normalizedUrl.pathname, routing.defaultLocale), normalizedUrl); | ||
links.push(getAlternateEntry(url, 'x-default')); | ||
const localizedPathname = getLocalizedPathname(normalizedUrl.pathname, routing.defaultLocale); | ||
if (localizedPathname) { | ||
const url = new URL(localizedPathname, normalizedUrl); | ||
links.push(getAlternateEntry(url, 'x-default')); | ||
} | ||
} | ||
@@ -86,0 +91,0 @@ return links.join(', '); |
import { NextResponse } from 'next/server'; | ||
import { receiveRoutingConfig } from '../routing/config.js'; | ||
import { HEADER_LOCALE_NAME } from '../shared/constants.js'; | ||
import { matchesPathname, normalizeTrailingSlash, getLocalePrefix } from '../shared/utils.js'; | ||
import { matchesPathname, normalizeTrailingSlash, getLocalePrefix, getLocalizedTemplate } from '../shared/utils.js'; | ||
import getAlternateLinksHeaderValue from './getAlternateLinksHeaderValue.js'; | ||
@@ -62,3 +62,4 @@ import resolveLocale from './resolveLocale.js'; | ||
urlObj.protocol = request.headers.get('x-forwarded-proto') ?? request.nextUrl.protocol; | ||
urlObj.port = request.headers.get('x-forwarded-port') ?? ''; | ||
const redirectDomainPort = redirectDomain.split(':')[1]; | ||
urlObj.port = redirectDomainPort ?? request.headers.get('x-forwarded-port') ?? ''; | ||
} | ||
@@ -69,6 +70,7 @@ } | ||
} | ||
hasRedirected = true; | ||
return NextResponse.redirect(urlObj.toString()); | ||
} | ||
const unprefixedExternalPathname = getNormalizedPathname(externalPathname, resolvedRouting.locales, resolvedRouting.localePrefix); | ||
const pathnameMatch = getPathnameMatch(externalPathname, resolvedRouting.locales, resolvedRouting.localePrefix); | ||
const pathnameMatch = getPathnameMatch(externalPathname, resolvedRouting.locales, resolvedRouting.localePrefix, domain); | ||
const hasLocalePrefix = pathnameMatch != null; | ||
@@ -78,2 +80,3 @@ const isUnprefixedRouting = resolvedRouting.localePrefix.mode === 'never' || hasMatchedDefaultLocale && resolvedRouting.localePrefix.mode === 'as-needed'; | ||
let internalTemplateName; | ||
let hasRedirected; | ||
let unprefixedInternalPathname = unprefixedExternalPathname; | ||
@@ -86,3 +89,3 @@ const pathnames = resolvedRouting.pathnames; | ||
const pathnameConfig = pathnames[internalTemplateName]; | ||
const localeTemplate = typeof pathnameConfig === 'string' ? pathnameConfig : pathnameConfig[locale]; | ||
const localeTemplate = getLocalizedTemplate(pathnameConfig, locale, internalTemplateName); | ||
if (matchesPathname(localeTemplate, unprefixedExternalPathname)) { | ||
@@ -94,3 +97,3 @@ unprefixedInternalPathname = formatTemplatePathname(unprefixedExternalPathname, localeTemplate, internalTemplateName); | ||
// A localized pathname from another locale has matched | ||
sourceTemplate = typeof pathnameConfig === 'string' ? pathnameConfig : pathnameConfig[resolvedTemplateLocale]; | ||
sourceTemplate = getLocalizedTemplate(pathnameConfig, resolvedTemplateLocale, internalTemplateName); | ||
} else { | ||
@@ -148,5 +151,6 @@ // An internal pathname has matched that | ||
syncCookie(request, response, locale, resolvedRouting, domain); | ||
if (resolvedRouting.localePrefix.mode !== 'never' && resolvedRouting.alternateLinks && resolvedRouting.locales.length > 1) { | ||
if (!hasRedirected && resolvedRouting.localePrefix.mode !== 'never' && resolvedRouting.alternateLinks && resolvedRouting.locales.length > 1) { | ||
response.headers.set('Link', getAlternateLinksHeaderValue({ | ||
routing: resolvedRouting, | ||
internalTemplateName, | ||
localizedPathnames: internalTemplateName != null && pathnames ? pathnames[internalTemplateName] : undefined, | ||
@@ -153,0 +157,0 @@ request, |
@@ -75,3 +75,3 @@ import { match } from '@formatjs/intl-localematcher'; | ||
if (pathname) { | ||
const prefixLocale = getPathnameMatch(pathname, routing.locales, routing.localePrefix)?.locale; | ||
const prefixLocale = getPathnameMatch(pathname, routing.locales, routing.localePrefix, domain)?.locale; | ||
if (prefixLocale) { | ||
@@ -102,3 +102,3 @@ if (isLocaleSupportedOnDomain(prefixLocale, domain)) { | ||
if (!locale && routing.localeDetection) { | ||
const headerLocale = getAcceptLanguageLocale(requestHeaders, domain.locales || routing.locales, domain.defaultLocale); | ||
const headerLocale = getAcceptLanguageLocale(requestHeaders, domain.locales, domain.defaultLocale); | ||
if (headerLocale) { | ||
@@ -105,0 +105,0 @@ locale = headerLocale; |
@@ -1,2 +0,2 @@ | ||
import { getSortedPathnames, matchesPathname, normalizeTrailingSlash, getLocalePrefix, templateToRegex, prefixPathname } from '../shared/utils.js'; | ||
import { getSortedPathnames, matchesPathname, normalizeTrailingSlash, getLocalePrefix, templateToRegex, prefixPathname, getLocalizedTemplate } from '../shared/utils.js'; | ||
@@ -22,4 +22,5 @@ function getInternalTemplate(pathnames, pathname, locale) { | ||
} | ||
for (const [entryLocale, entryPathname] of sortedEntries) { | ||
if (matchesPathname(entryPathname, pathname)) { | ||
for (const [entryLocale] of sortedEntries) { | ||
const localizedTemplate = getLocalizedTemplate(pathnames[internalPathname], entryLocale, internalPathname); | ||
if (matchesPathname(localizedTemplate, pathname)) { | ||
return [entryLocale, internalPathname]; | ||
@@ -80,4 +81,17 @@ } | ||
} | ||
function getPathnameMatch(pathname, locales, localePrefix) { | ||
function getPathnameMatch(pathname, locales, localePrefix, domain) { | ||
const localePrefixes = getLocalePrefixes(locales, localePrefix); | ||
// Sort to prioritize domain locales | ||
if (domain) { | ||
localePrefixes.sort(([localeA], [localeB]) => { | ||
if (localeA === domain.defaultLocale) return -1; | ||
if (localeB === domain.defaultLocale) return 1; | ||
const isLocaleAInDomain = domain.locales.includes(localeA); | ||
const isLocaleBInDomain = domain.locales.includes(localeB); | ||
if (isLocaleAInDomain && !isLocaleBInDomain) return -1; | ||
if (!isLocaleAInDomain && isLocaleBInDomain) return 1; | ||
return 0; | ||
}); | ||
} | ||
for (const [locale, prefix] of localePrefixes) { | ||
@@ -144,3 +158,3 @@ let exact, matches; | ||
function isLocaleSupportedOnDomain(locale, domain) { | ||
return domain.defaultLocale === locale || !domain.locales || domain.locales.includes(locale); | ||
return domain.defaultLocale === locale || domain.locales.includes(locale); | ||
} | ||
@@ -160,16 +174,6 @@ function getBestMatchingDomain(curHostDomain, locale, domainsConfig) { | ||
// Prio 3: Use alternative domain with restricted matching locale | ||
// Prio 3: Use alternative domain that supports the locale | ||
if (!domainConfig) { | ||
domainConfig = domainsConfig.find(cur => cur.locales?.includes(locale)); | ||
domainConfig = domainsConfig.find(cur => cur.locales.includes(locale)); | ||
} | ||
// Prio 4: Stay on the current domain if it supports all locales | ||
if (!domainConfig && curHostDomain?.locales == null) { | ||
domainConfig = curHostDomain; | ||
} | ||
// Prio 5: Use alternative domain that supports all locales | ||
if (!domainConfig) { | ||
domainConfig = domainsConfig.find(cur => !cur.locales); | ||
} | ||
return domainConfig; | ||
@@ -176,0 +180,0 @@ } |
@@ -40,8 +40,5 @@ import { useRouter, usePathname } from 'next/navigation'; | ||
} = options || {}; | ||
// @ts-expect-error -- We're passing a domain here just in case | ||
const pathname = getPathname({ | ||
href, | ||
locale: nextLocale || curLocale, | ||
domain: window.location.host | ||
locale: nextLocale || curLocale | ||
}); | ||
@@ -48,0 +45,0 @@ const args = [pathname]; |
"use client"; | ||
import NextLink from 'next/link'; | ||
import { usePathname } from 'next/navigation'; | ||
import { forwardRef, useState, useEffect } from 'react'; | ||
import { forwardRef } from 'react'; | ||
import { useLocale } from 'use-intl'; | ||
@@ -10,3 +10,2 @@ import syncLocaleCookie from './syncLocaleCookie.js'; | ||
function BaseLink({ | ||
defaultLocale, | ||
href, | ||
@@ -17,3 +16,2 @@ locale, | ||
prefetch, | ||
unprefixed, | ||
...rest | ||
@@ -23,15 +21,2 @@ }, ref) { | ||
const isChangingLocale = locale != null && locale !== curLocale; | ||
const linkLocale = locale || curLocale; | ||
const host = useHost(); | ||
const finalHref = | ||
// Only after hydration (to avoid mismatches) | ||
host && | ||
// If there is an `unprefixed` prop, the | ||
// `defaultLocale` might differ by domain | ||
unprefixed && ( | ||
// Unprefix the pathname if a domain matches | ||
unprefixed.domains[host] === linkLocale || | ||
// … and handle unknown domains by applying the | ||
// global `defaultLocale` (e.g. on localhost) | ||
!Object.keys(unprefixed.domains).includes(host) && curLocale === defaultLocale && !locale) ? unprefixed.pathname : href; | ||
@@ -57,3 +42,3 @@ // The types aren't entirely correct here. Outside of Next.js | ||
ref: ref, | ||
href: finalHref, | ||
href: href, | ||
hrefLang: isChangingLocale ? locale : undefined, | ||
@@ -65,11 +50,4 @@ onClick: onLinkClick, | ||
} | ||
function useHost() { | ||
const [host, setHost] = useState(); | ||
useEffect(() => { | ||
setHost(window.location.host); | ||
}, []); | ||
return host; | ||
} | ||
var BaseLink$1 = /*#__PURE__*/forwardRef(BaseLink); | ||
export { BaseLink$1 as default }; |
@@ -5,3 +5,3 @@ import { redirect, permanentRedirect } from 'next/navigation'; | ||
import use from '../../shared/use.js'; | ||
import { isLocalizableHref } from '../../shared/utils.js'; | ||
import { isLocalizableHref, isPromise } from '../../shared/utils.js'; | ||
import BaseLink from './BaseLink.js'; | ||
@@ -20,10 +20,2 @@ import { validateReceivedConfig, serializeSearchParams, compileLocalizedPathname, applyPathnamePrefix, normalizeNameOrNameWithParams } from './utils.js'; | ||
const pathnames = config.pathnames; | ||
// This combination requires that the current host is known in order to | ||
// compute a correct pathname. Since that can only be achieved by reading from | ||
// headers, this would break static rendering. Therefore, as a workaround we | ||
// always add a prefix in this case to be on the safe side. The downside is | ||
// that the user might get redirected again if the middleware detects that the | ||
// prefix is not needed. | ||
const forcePrefixSsr = config.localePrefix.mode === 'as-needed' && config.domains || undefined; | ||
function Link({ | ||
@@ -46,7 +38,6 @@ href, | ||
const localePromiseOrValue = getLocale(); | ||
const curLocale = localePromiseOrValue instanceof Promise ? use(localePromiseOrValue) : localePromiseOrValue; | ||
const finalPathname = isLocalizable ? getPathname( | ||
// @ts-expect-error -- This is ok | ||
{ | ||
const curLocale = isPromise(localePromiseOrValue) ? use(localePromiseOrValue) : localePromiseOrValue; | ||
const finalPathname = isLocalizable ? getPathname({ | ||
locale: locale || curLocale, | ||
// @ts-expect-error -- This is ok | ||
href: pathnames == null ? pathname : { | ||
@@ -56,8 +47,5 @@ pathname, | ||
} | ||
}, locale != null || forcePrefixSsr || undefined) : pathname; | ||
}, locale != null || undefined) : pathname; | ||
return /*#__PURE__*/jsx(BaseLink, { | ||
ref: ref | ||
// @ts-expect-error -- Available after the validation | ||
, | ||
defaultLocale: config.defaultLocale | ||
// @ts-expect-error -- This is ok | ||
@@ -70,21 +58,3 @@ , | ||
locale: locale, | ||
localeCookie: config.localeCookie | ||
// Provide the minimal relevant information to the client side in order | ||
// to potentially remove the prefix in case of the `forcePrefixSsr` case | ||
, | ||
unprefixed: forcePrefixSsr && isLocalizable ? { | ||
domains: config.domains.reduce((acc, domain) => { | ||
acc[domain.domain] = domain.defaultLocale; | ||
return acc; | ||
}, {}), | ||
pathname: getPathname( | ||
// @ts-expect-error -- This is ok | ||
{ | ||
locale: curLocale, | ||
href: pathnames == null ? pathname : { | ||
pathname, | ||
params | ||
} | ||
}, false) | ||
} : undefined, | ||
localeCookie: config.localeCookie, | ||
...rest | ||
@@ -119,5 +89,3 @@ }); | ||
} | ||
return applyPathnamePrefix(pathname, locale, config, | ||
// @ts-expect-error -- This is ok | ||
args.domain, _forcePrefix); | ||
return applyPathnamePrefix(pathname, locale, config, _forcePrefix); | ||
} | ||
@@ -127,5 +95,3 @@ function getRedirectFn(fn) { | ||
return function redirectFn(args, ...rest) { | ||
return fn( | ||
// @ts-expect-error -- We're forcing the prefix when no domain is provided | ||
getPathname(args, args.domain ? undefined : forcePrefixSsr), ...rest); | ||
return fn(getPathname(args), ...rest); | ||
}; | ||
@@ -132,0 +98,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { getSortedPathnames, matchesPathname, isLocalizableHref, prefixPathname, getLocalePrefix, normalizeTrailingSlash } from '../../shared/utils.js'; | ||
import { getSortedPathnames, matchesPathname, getLocalizedTemplate, isLocalizableHref, prefixPathname, getLocalePrefix, normalizeTrailingSlash } from '../../shared/utils.js'; | ||
@@ -46,4 +46,4 @@ // Minor false positive: A route that has both optional and | ||
} | ||
function compilePath(namedPath) { | ||
const template = typeof namedPath === 'string' ? namedPath : namedPath[locale]; | ||
function compilePath(namedPath, internalPathname) { | ||
const template = getLocalizedTemplate(namedPath, locale, internalPathname); | ||
let compiled = template; | ||
@@ -78,11 +78,11 @@ if (params) { | ||
const namedPath = getNamedPath(pathname); | ||
const compiled = compilePath(namedPath); | ||
const compiled = compilePath(namedPath, pathname); | ||
return compiled; | ||
} else { | ||
const { | ||
pathname: href, | ||
pathname: internalPathname, | ||
...rest | ||
} = pathname; | ||
const namedPath = getNamedPath(href); | ||
const compiled = compilePath(namedPath); | ||
const namedPath = getNamedPath(internalPathname); | ||
const compiled = compilePath(namedPath, internalPathname); | ||
const result = { | ||
@@ -106,3 +106,3 @@ ...rest, | ||
} else { | ||
if (matchesPathname(localizedPathnamesOrPathname[locale], decoded)) { | ||
if (matchesPathname(getLocalizedTemplate(localizedPathnamesOrPathname, locale, internalPathname), decoded)) { | ||
return internalPathname; | ||
@@ -121,3 +121,3 @@ } | ||
} | ||
function applyPathnamePrefix(pathname, locale, routing, domain, force) { | ||
function applyPathnamePrefix(pathname, locale, routing, force) { | ||
const { | ||
@@ -133,14 +133,6 @@ mode | ||
} else if (mode === 'as-needed') { | ||
let defaultLocale = routing.defaultLocale; | ||
if (routing.domains) { | ||
const domainConfig = routing.domains.find(cur => cur.domain === domain); | ||
if (domainConfig) { | ||
defaultLocale = domainConfig.defaultLocale; | ||
} else { | ||
if (!domain) { | ||
console.error("You're using a routing configuration with `localePrefix: 'as-needed'` in combination with `domains`. In order to compute a correct pathname, you need to provide a `domain` parameter.\n\nSee: https://next-intl.dev/docs/routing#domains-localeprefix-asneeded"); | ||
} | ||
} | ||
} | ||
shouldPrefix = defaultLocale !== locale; | ||
shouldPrefix = routing.domains ? | ||
// Since locales are unique per domain, any locale that is a | ||
// default locale of a domain doesn't require a prefix | ||
!routing.domains.some(cur => cur.defaultLocale === locale) : locale !== routing.defaultLocale; | ||
} | ||
@@ -147,0 +139,0 @@ } |
import fs from 'fs'; | ||
import path from 'path'; | ||
import { throwError } from './utils.js'; | ||
import watchFile from './watchFile.js'; | ||
@@ -12,22 +13,22 @@ function runOnce(fn) { | ||
} | ||
function createMessagesDeclaration(messagesPath) { | ||
const fullPath = path.resolve(messagesPath); | ||
if (!fs.existsSync(fullPath)) { | ||
throwError(`\`createMessagesDeclaration\` points to a non-existent file: ${fullPath}`); | ||
} | ||
if (!fullPath.endsWith('.json')) { | ||
throwError(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${fullPath}`); | ||
} | ||
const isDev = process.argv.includes('dev'); | ||
const isBuild = process.argv.includes('build'); | ||
if (!isDev && !isBuild) { | ||
return; | ||
} | ||
function createMessagesDeclaration(messagesPaths) { | ||
// Next.js can call the Next.js config multiple | ||
// times - ensure we only run once. | ||
runOnce(() => { | ||
compileDeclaration(messagesPath); | ||
if (isDev) { | ||
startWatching(messagesPath); | ||
for (const messagesPath of messagesPaths) { | ||
const fullPath = path.resolve(messagesPath); | ||
if (!fs.existsSync(fullPath)) { | ||
throwError(`\`createMessagesDeclaration\` points to a non-existent file: ${fullPath}`); | ||
} | ||
if (!fullPath.endsWith('.json')) { | ||
throwError(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${fullPath}`); | ||
} | ||
// Keep this as a runtime check and don't replace | ||
// this with a constant during the build process | ||
const env = process.env['NODE_ENV'.trim()]; | ||
compileDeclaration(messagesPath); | ||
if (env === 'development') { | ||
startWatching(messagesPath); | ||
} | ||
} | ||
@@ -37,6 +38,4 @@ }); | ||
function startWatching(messagesPath) { | ||
const watcher = fs.watch(messagesPath, eventType => { | ||
if (eventType === 'change') { | ||
compileDeclaration(messagesPath, true); | ||
} | ||
const watcher = watchFile(messagesPath, () => { | ||
compileDeclaration(messagesPath, true); | ||
}); | ||
@@ -43,0 +42,0 @@ process.on('exit', () => { |
@@ -9,4 +9,5 @@ import createMessagesDeclaration from './createMessagesDeclaration.js'; | ||
} | ||
if (pluginConfig.experimental?.createMessagesDeclaration) { | ||
createMessagesDeclaration(pluginConfig.experimental.createMessagesDeclaration); | ||
const messagesPathOrPaths = pluginConfig.experimental?.createMessagesDeclaration; | ||
if (messagesPathOrPaths) { | ||
createMessagesDeclaration(typeof messagesPathOrPaths === 'string' ? [messagesPathOrPaths] : messagesPathOrPaths); | ||
} | ||
@@ -13,0 +14,0 @@ return getNextConfig(pluginConfig, nextConfig); |
@@ -6,2 +6,3 @@ import getConfigNow from '../server/react-server/getConfigNow.js'; | ||
import getLocaleCached from '../server/react-server/getLocale.js'; | ||
import getMessages from '../server/react-server/getMessages.js'; | ||
import getTimeZone from '../server/react-server/getTimeZone.js'; | ||
@@ -12,2 +13,3 @@ | ||
locale, | ||
messages, | ||
now, | ||
@@ -22,3 +24,4 @@ timeZone, | ||
formats: formats === undefined ? await getFormats() : formats, | ||
locale: locale ?? (await getLocaleCached()) | ||
locale: locale ?? (await getLocaleCached()), | ||
messages: messages === undefined ? await getMessages() : messages | ||
// Note that we don't assign a default for `now` here, | ||
@@ -25,0 +28,0 @@ // we only read one from the request config - if any. |
@@ -1,10 +0,25 @@ | ||
import validateLocales from './validateLocales.js'; | ||
function defineRouting(config) { | ||
{ | ||
validateLocales(config.locales); | ||
if (config.domains) { | ||
validateUniqueLocalesPerDomain(config.domains); | ||
} | ||
return config; | ||
} | ||
function validateUniqueLocalesPerDomain(domains) { | ||
const domainsByLocale = new Map(); | ||
for (const { | ||
domain, | ||
locales | ||
} of domains) { | ||
for (const locale of locales) { | ||
const localeDomains = domainsByLocale.get(locale) || new Set(); | ||
localeDomains.add(domain); | ||
domainsByLocale.set(locale, localeDomains); | ||
} | ||
} | ||
const duplicateLocaleMessages = Array.from(domainsByLocale.entries()).filter(([, localeDomains]) => localeDomains.size > 1).map(([locale, localeDomains]) => `- "${locale}" is used by: ${Array.from(localeDomains).join(', ')}`); | ||
if (duplicateLocaleMessages.length > 0) { | ||
console.warn('Locales are expected to be unique per domain, but found overlap:\n' + duplicateLocaleMessages.join('\n') + '\nPlease see https://next-intl.dev/docs/routing#domains'); | ||
} | ||
} | ||
export { defineRouting as default }; |
export { default as getRequestConfig } from './server/react-server/getRequestConfig.js'; | ||
export { default as getFormatter } from './server/react-server/getFormatter.js'; | ||
export { default as getNow } from './server/react-server/getNow.js'; | ||
export { default as getMessages } from './server/react-server/getMessages.js'; | ||
export { default as getTimeZone } from './server/react-server/getTimeZone.js'; | ||
export { default as getTranslations } from './server/react-server/getTranslations.js'; | ||
export { default as getMessages } from './server/react-server/getMessages.js'; | ||
export { default as getLocale } from './server/react-server/getLocale.js'; | ||
export { setCachedRequestLocale as setRequestLocale } from './server/react-server/RequestLocaleCache.js'; |
import { cache } from 'react'; | ||
import { _createIntlFormatters, _createCache, initializeConfig } from 'use-intl/core'; | ||
import { isPromise } from '../../shared/utils.js'; | ||
import { getRequestLocale } from './RequestLocale.js'; | ||
import getRuntimeConfig from 'next-intl/config'; | ||
import validateLocale from './validateLocale.js'; | ||
@@ -33,3 +35,3 @@ // This is automatically inherited by `NextIntlClientProvider` if | ||
let result = getConfig(params); | ||
if (result instanceof Promise) { | ||
if (isPromise(result)) { | ||
result = await result; | ||
@@ -40,2 +42,5 @@ } | ||
} | ||
{ | ||
validateLocale(result.locale); | ||
} | ||
return result; | ||
@@ -42,0 +47,0 @@ } |
@@ -6,6 +6,2 @@ import { cache } from 'react'; | ||
function getFormatterCachedImpl(config) { | ||
// same here? | ||
// also add a test | ||
// also for getTranslations/useTranslations | ||
// add a test with a getter maybe, don't mock | ||
return createFormatter({ | ||
@@ -12,0 +8,0 @@ ...config, |
import { headers } from 'next/headers'; | ||
import { cache } from 'react'; | ||
import { HEADER_LOCALE_NAME } from '../../shared/constants.js'; | ||
import { isPromise } from '../../shared/utils.js'; | ||
import { getCachedRequestLocale } from './RequestLocaleCache.js'; | ||
@@ -10,3 +11,3 @@ | ||
// Compatibility with Next.js <15 | ||
return promiseOrValue instanceof Promise ? await promiseOrValue : promiseOrValue; | ||
return isPromise(promiseOrValue) ? await promiseOrValue : promiseOrValue; | ||
} | ||
@@ -13,0 +14,0 @@ const getHeaders = cache(getHeadersImpl); |
@@ -40,2 +40,5 @@ function isRelativeHref(href) { | ||
} | ||
function getLocalizedTemplate(pathnameConfig, locale, internalTemplate) { | ||
return typeof pathnameConfig === 'string' ? pathnameConfig : pathnameConfig[locale] || internalTemplate; | ||
} | ||
function normalizeTrailingSlash(pathname) { | ||
@@ -126,3 +129,7 @@ const trailingSlash = hasTrailingSlash(); | ||
} | ||
function isPromise(value) { | ||
// https://github.com/amannn/next-intl/issues/1711 | ||
return typeof value.then === 'function'; | ||
} | ||
export { getLocaleAsPrefix, getLocalePrefix, getSortedPathnames, hasPathnamePrefixed, isLocalizableHref, matchesPathname, normalizeTrailingSlash, prefixPathname, templateToRegex, unprefixPathname }; | ||
export { getLocaleAsPrefix, getLocalePrefix, getLocalizedTemplate, getSortedPathnames, hasPathnamePrefixed, isLocalizableHref, isPromise, matchesPathname, normalizeTrailingSlash, prefixPathname, templateToRegex, unprefixPathname }; |
@@ -1,1 +0,1 @@ | ||
import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as o,isLocaleSupportedOnDomain as n,applyBasePath as l,formatTemplatePathname as r}from"./utils.js";function m({localizedPathnames:m,request:p,resolvedLocale:s,routing:c}){const f=p.nextUrl.clone(),h=a(p.headers);function i(a,t){return a.pathname=e(a.pathname),p.nextUrl.basePath&&((a=new URL(a)).pathname=l(a.pathname,p.nextUrl.basePath)),`<${a.toString()}>; rel="alternate"; hreflang="${t}"`}function u(e,a){return m&&"object"==typeof m?r(e,m[s],m[a]):e}h&&(f.port="",f.host=h),f.protocol=p.headers.get("x-forwarded-proto")??f.protocol,f.pathname=t(f.pathname,c.locales,c.localePrefix);const d=o(c.locales,c.localePrefix,!1).flatMap((([e,a])=>{function t(e){return"/"===e?a:a+e}let o;if(c.domains){return c.domains.filter((a=>n(e,a))).map((a=>(o=new URL(f),o.port="",o.host=a.domain,o.pathname=u(f.pathname,e),e===a.defaultLocale&&"always"!==c.localePrefix.mode||(o.pathname=t(o.pathname)),i(o,e))))}{let a;a=m&&"object"==typeof m?u(f.pathname,e):f.pathname,e===c.defaultLocale&&"always"!==c.localePrefix.mode||(a=t(a)),o=new URL(a,f)}return i(o,e)}));if(!c.domains&&("always"!==c.localePrefix.mode||"/"===f.pathname)){const e=new URL(u(f.pathname,c.defaultLocale),f);d.push(i(e,"x-default"))}return d.join(", ")}export{m as default}; | ||
import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as n,isLocaleSupportedOnDomain as o,applyBasePath as r,formatTemplatePathname as l}from"./utils.js";function s({internalTemplateName:s,localizedPathnames:m,request:i,resolvedLocale:p,routing:c}){const f=i.nextUrl.clone(),h=a(i.headers);function u(a,t){return a.pathname=e(a.pathname),i.nextUrl.basePath&&((a=new URL(a)).pathname=r(a.pathname,i.nextUrl.basePath)),`<${a.toString()}>; rel="alternate"; hreflang="${t}"`}function d(e,a){if(m&&"object"==typeof m){const t=m[p];return l(e,t??s,m[a]??s)}return e}h&&(f.port="",f.host=h),f.protocol=i.headers.get("x-forwarded-proto")??f.protocol,f.pathname=t(f.pathname,c.locales,c.localePrefix);const x=n(c.locales,c.localePrefix,!1).flatMap((([e,a])=>{function t(e){return"/"===e?a:a+e}let n;if(c.domains){return c.domains.filter((a=>o(e,a))).map((a=>(n=new URL(f),n.port="",n.host=a.domain,n.pathname=d(f.pathname,e),e===a.defaultLocale&&"always"!==c.localePrefix.mode||(n.pathname=t(n.pathname)),u(n,e))))}{let a;a=m&&"object"==typeof m?d(f.pathname,e):f.pathname,e===c.defaultLocale&&"always"!==c.localePrefix.mode||(a=t(a)),n=new URL(a,f)}return u(n,e)}));if(!c.domains||0===c.domains.length){const e=d(f.pathname,c.defaultLocale);if(e){const a=new URL(e,f);x.push(u(a,"x-default"))}}return x.join(", ")}export{s as default}; |
@@ -1,1 +0,1 @@ | ||
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as o,normalizeTrailingSlash as a,getLocalePrefix as l}from"../shared/utils.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as m,getInternalTemplate as h,formatTemplatePathname as x,formatPathname as p,getBestMatchingDomain as u,applyBasePath as U,getLocaleAsPrefix as P}from"./utils.js";function g(g){const v=t(g);return function(t){let g;try{g=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const L=c(g),{domain:j,locale:w}=s(v,t.headers,t.cookies,L),k=j?j.defaultLocale===w:w===v.defaultLocale,b=v.domains?.filter((e=>d(w,e)))||[],y=null!=v.domains&&!j;function R(o){const a=new URL(o,t.url);t.nextUrl.basePath&&(a.pathname=U(a.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);return l.set(r,w),e.rewrite(a,{request:{headers:l}})}function q(r,o){const l=new URL(r,t.url);if(l.pathname=a(l.pathname),b.length>0&&!o&&j){const e=u(j,w,b);e&&(o=e.domain,e.defaultLocale===w&&"as-needed"===v.localePrefix.mode&&(l.pathname=f(l.pathname,v.locales,v.localePrefix)))}return o&&(l.host=o,t.headers.get("x-forwarded-host")&&(l.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol,l.port=t.headers.get("x-forwarded-port")??"")),t.nextUrl.basePath&&(l.pathname=U(l.pathname,t.nextUrl.basePath)),e.redirect(l.toString())}const H=f(L,v.locales,v.localePrefix),z=m(L,v.locales,v.localePrefix),A=null!=z,C="never"===v.localePrefix.mode||k&&"as-needed"===v.localePrefix.mode;let I,S,V=H;const B=v.pathnames;if(B){let e;if([e,S]=h(B,H,w),S){const r=B[S],a="string"==typeof r?r:r[w];if(o(a,H))V=x(H,a,S);else{let o;o=e?"string"==typeof r?r:r[e]:S;const n=C?void 0:l(w,v.localePrefix),s=x(H,o,a);I=q(p(s,n,t.nextUrl.search))}}}if(!I)if("/"!==V||A){const e=p(V,P(w),t.nextUrl.search);if(A){const r=p(H,z.prefix,t.nextUrl.search);if("never"===v.localePrefix.mode)I=q(p(H,void 0,t.nextUrl.search));else if(z.exact)if(k&&C)I=q(p(H,void 0,t.nextUrl.search));else if(v.domains){const t=u(j,z.locale,b);I=j?.domain===t?.domain||y?R(e):q(r,t?.domain)}else I=R(e);else I=q(r)}else I=C?R(e):q(p(H,l(w,v.localePrefix),t.nextUrl.search))}else I=C?R(p(V,P(w),t.nextUrl.search)):q(p(H,l(w,v.localePrefix),t.nextUrl.search));return i(t,I,w,v,j),"never"!==v.localePrefix.mode&&v.alternateLinks&&v.locales.length>1&&I.headers.set("Link",n({routing:v,localizedPathnames:null!=S&&B?B[S]:void 0,request:t,resolvedLocale:w})),I}}export{g as default}; | ||
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as t}from"../routing/config.js";import{HEADER_LOCALE_NAME as r}from"../shared/constants.js";import{matchesPathname as o,normalizeTrailingSlash as a,getLocalePrefix as l,getLocalizedTemplate as n}from"../shared/utils.js";import s from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import c from"./syncCookie.js";import{sanitizePathname as d,isLocaleSupportedOnDomain as f,getNormalizedPathname as m,getPathnameMatch as h,getInternalTemplate as x,formatTemplatePathname as p,formatPathname as u,getBestMatchingDomain as U,applyBasePath as P,getLocaleAsPrefix as g}from"./utils.js";function v(v){const L=t(v);return function(t){let v;try{v=decodeURI(t.nextUrl.pathname)}catch{return e.next()}const j=d(v),{domain:w,locale:k}=i(L,t.headers,t.cookies,j),b=w?w.defaultLocale===k:k===L.defaultLocale,R=L.domains?.filter((e=>f(k,e)))||[],q=null!=L.domains&&!w;function y(o){const a=new URL(o,t.url);t.nextUrl.basePath&&(a.pathname=P(a.pathname,t.nextUrl.basePath));const l=new Headers(t.headers);return l.set(r,k),e.rewrite(a,{request:{headers:l}})}function H(r,o){const l=new URL(r,t.url);if(l.pathname=a(l.pathname),R.length>0&&!o&&w){const e=U(w,k,R);e&&(o=e.domain,e.defaultLocale===k&&"as-needed"===L.localePrefix.mode&&(l.pathname=m(l.pathname,L.locales,L.localePrefix)))}if(o&&(l.host=o,t.headers.get("x-forwarded-host"))){l.protocol=t.headers.get("x-forwarded-proto")??t.nextUrl.protocol;const e=o.split(":")[1];l.port=e??t.headers.get("x-forwarded-port")??""}return t.nextUrl.basePath&&(l.pathname=P(l.pathname,t.nextUrl.basePath)),T=!0,e.redirect(l.toString())}const z=m(j,L.locales,L.localePrefix),A=h(j,L.locales,L.localePrefix,w),C=null!=A,I="never"===L.localePrefix.mode||b&&"as-needed"===L.localePrefix.mode;let N,S,T,V=z;const B=L.pathnames;if(B){let e;if([e,S]=x(B,z,k),S){const r=B[S],a=n(r,k,S);if(o(a,z))V=p(z,a,S);else{let o;o=e?n(r,e,S):S;const s=I?void 0:l(k,L.localePrefix),i=p(z,o,a);N=H(u(i,s,t.nextUrl.search))}}}if(!N)if("/"!==V||C){const e=u(V,g(k),t.nextUrl.search);if(C){const r=u(z,A.prefix,t.nextUrl.search);if("never"===L.localePrefix.mode)N=H(u(z,void 0,t.nextUrl.search));else if(A.exact)if(b&&I)N=H(u(z,void 0,t.nextUrl.search));else if(L.domains){const t=U(w,A.locale,R);N=w?.domain===t?.domain||q?y(e):H(r,t?.domain)}else N=y(e);else N=H(r)}else N=I?y(e):H(u(z,l(k,L.localePrefix),t.nextUrl.search))}else N=I?y(u(V,g(k),t.nextUrl.search)):H(u(z,l(k,L.localePrefix),t.nextUrl.search));return c(t,N,k,L,w),!T&&"never"!==L.localePrefix.mode&&L.alternateLinks&&L.locales.length>1&&N.headers.set("Link",s({routing:L,internalTemplateName:S,localizedPathnames:null!=S&&B?B[S]:void 0,request:t,resolvedLocale:k})),N}}export{v as default}; |
@@ -1,1 +0,1 @@ | ||
import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{getPathnameMatch as l,isLocaleSupportedOnDomain as t,getHost as a}from"./utils.js";function c(l,t,a){let c;const n=new o({headers:{"accept-language":l.get("accept-language")||void 0}}).languages();try{const o=function(e){return e.slice().sort(((e,o)=>o.length-e.length))}(t);c=e(n,o,a)}catch{}return c}function n(e,o){if(e.localeCookie&&o.has(e.localeCookie.name)){const l=o.get(e.localeCookie.name)?.value;if(l&&e.locales.includes(l))return l}}function i(e,o,t,a){let i;return a&&(i=l(a,e.locales,e.localePrefix)?.locale),!i&&e.localeDetection&&(i=n(e,t)),!i&&e.localeDetection&&(i=c(o,e.locales,e.defaultLocale)),i||(i=e.defaultLocale),i}function r(e,o,r,f){const u=function(e,o){const l=a(e);if(l)return o.find((e=>e.domain===l))}(o,e.domains);if(!u)return{locale:i(e,o,r,f)};let s;if(f){const o=l(f,e.locales,e.localePrefix)?.locale;if(o){if(!t(o,u))return{locale:o,domain:u};s=o}}if(!s&&e.localeDetection){const o=n(e,r);o&&t(o,u)&&(s=o)}if(!s&&e.localeDetection){const l=c(o,u.locales||e.locales,u.defaultLocale);l&&(s=l)}return s||(s=u.defaultLocale),{locale:s,domain:u}}function f(e,o,l,t){return e.domains?r(e,o,l,t):{locale:i(e,o,l,t)}}export{f as default,c as getAcceptLanguageLocale}; | ||
import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{getPathnameMatch as l,isLocaleSupportedOnDomain as t,getHost as a}from"./utils.js";function c(l,t,a){let c;const n=new o({headers:{"accept-language":l.get("accept-language")||void 0}}).languages();try{const o=function(e){return e.slice().sort(((e,o)=>o.length-e.length))}(t);c=e(n,o,a)}catch{}return c}function n(e,o){if(e.localeCookie&&o.has(e.localeCookie.name)){const l=o.get(e.localeCookie.name)?.value;if(l&&e.locales.includes(l))return l}}function i(e,o,t,a){let i;return a&&(i=l(a,e.locales,e.localePrefix)?.locale),!i&&e.localeDetection&&(i=n(e,t)),!i&&e.localeDetection&&(i=c(o,e.locales,e.defaultLocale)),i||(i=e.defaultLocale),i}function r(e,o,r,f){const u=function(e,o){const l=a(e);if(l)return o.find((e=>e.domain===l))}(o,e.domains);if(!u)return{locale:i(e,o,r,f)};let s;if(f){const o=l(f,e.locales,e.localePrefix,u)?.locale;if(o){if(!t(o,u))return{locale:o,domain:u};s=o}}if(!s&&e.localeDetection){const o=n(e,r);o&&t(o,u)&&(s=o)}if(!s&&e.localeDetection){const e=c(o,u.locales,u.defaultLocale);e&&(s=e)}return s||(s=u.defaultLocale),{locale:s,domain:u}}function f(e,o,l,t){return e.domains?r(e,o,l,t):{locale:i(e,o,l,t)}}export{f as default,c as getAcceptLanguageLocale}; |
@@ -1,1 +0,1 @@ | ||
import{getSortedPathnames as e,matchesPathname as t,normalizeTrailingSlash as n,getLocalePrefix as r,templateToRegex as o,prefixPathname as c}from"../shared/utils.js";function i(n,r,o){const c=e(Object.keys(n));for(const e of c){const c=n[e];if("string"==typeof c){if(t(c,r))return[void 0,e]}else{const n=Object.entries(c),i=n.findIndex((([e])=>e===o));i>0&&n.unshift(n.splice(i,1)[0]);for(const[o,c]of n)if(t(c,r))return[o,e]}}for(const e of Object.keys(n))if(t(e,r))return[void 0,e];return[void 0,void 0]}function l(e,t,r,o){let c="";return c+=d(r,a(t,e)),c=n(c),c}function f(e,t,r){e.endsWith("/")||(e+="/");const o=s(t,r),c=new RegExp(`^(${o.map((([,e])=>e.replaceAll("/","\\/"))).join("|")})/(.*)`,"i"),i=e.match(c);let l=i?"/"+i[2]:e;return"/"!==l&&(l=n(l)),l}function s(e,t,n=!0){const o=e.map((e=>[e,r(e,t)]));return n&&o.sort(((e,t)=>t[1].length-e[1].length)),o}function u(e,t,n){const r=s(t,n);for(const[t,n]of r){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),c=n.toLowerCase();(t===c||t.startsWith(c+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}}function a(e,t){const r=n(t),c=n(e),i=o(c).exec(r);if(!i)return;const l={};for(let e=1;e<i.length;e++){const t=c.match(/\[([^\]]+)\]/g)?.[e-1].replace(/[[\]]/g,"");t&&(l[t]=i[e])}return l}function d(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((([e,t])=>{n=n.replace(`[${e}]`,t)})),n}function h(e,t,n){let r=e;return t&&(r=c(t,r)),n&&(r+=n),r}function p(e){return e.get("x-forwarded-host")??e.get("host")??void 0}function g(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function x(e,t,n){let r;return e&&g(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>e.locales?.includes(t)))),r||null!=e?.locales||(r=e),r||(r=n.find((e=>!e.locales))),r}function m(e,t){return n(t+e)}function j(e){return`/${e}`}function v(e){return e.replace(/\\/g,"%5C").replace(/\/+/g,"/")}export{m as applyBasePath,h as formatPathname,d as formatPathnameTemplate,l as formatTemplatePathname,x as getBestMatchingDomain,p as getHost,i as getInternalTemplate,j as getLocaleAsPrefix,s as getLocalePrefixes,f as getNormalizedPathname,u as getPathnameMatch,a as getRouteParams,g as isLocaleSupportedOnDomain,v as sanitizePathname}; | ||
import{getSortedPathnames as e,matchesPathname as t,normalizeTrailingSlash as n,getLocalePrefix as r,templateToRegex as o,prefixPathname as c,getLocalizedTemplate as i}from"../shared/utils.js";function s(n,r,o){const c=e(Object.keys(n));for(const e of c){const c=n[e];if("string"==typeof c){if(t(c,r))return[void 0,e]}else{const s=Object.entries(c),f=s.findIndex((([e])=>e===o));f>0&&s.unshift(s.splice(f,1)[0]);for(const[o]of s){const c=i(n[e],o,e);if(t(c,r))return[o,e]}}}for(const e of Object.keys(n))if(t(e,r))return[void 0,e];return[void 0,void 0]}function f(e,t,r,o){let c="";return c+=h(r,d(t,e)),c=n(c),c}function l(e,t,r){e.endsWith("/")||(e+="/");const o=u(t,r),c=new RegExp(`^(${o.map((([,e])=>e.replaceAll("/","\\/"))).join("|")})/(.*)`,"i"),i=e.match(c);let s=i?"/"+i[2]:e;return"/"!==s&&(s=n(s)),s}function u(e,t,n=!0){const o=e.map((e=>[e,r(e,t)]));return n&&o.sort(((e,t)=>t[1].length-e[1].length)),o}function a(e,t,n,r){const o=u(t,n);r&&o.sort((([e],[t])=>{if(e===r.defaultLocale)return-1;if(t===r.defaultLocale)return 1;const n=r.locales.includes(e),o=r.locales.includes(t);return n&&!o?-1:!n&&o?1:0}));for(const[t,n]of o){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),c=n.toLowerCase();(t===c||t.startsWith(c+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}}function d(e,t){const r=n(t),c=n(e),i=o(c).exec(r);if(!i)return;const s={};for(let e=1;e<i.length;e++){const t=c.match(/\[([^\]]+)\]/g)?.[e-1].replace(/[[\]]/g,"");t&&(s[t]=i[e])}return s}function h(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((([e,t])=>{n=n.replace(`[${e}]`,t)})),n}function p(e,t,n){let r=e;return t&&(r=c(t,r)),n&&(r+=n),r}function g(e){return e.get("x-forwarded-host")??e.get("host")??void 0}function x(e,t){return t.defaultLocale===e||t.locales.includes(e)}function m(e,t,n){let r;return e&&x(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>e.locales.includes(t)))),r}function j(e,t){return n(t+e)}function L(e){return`/${e}`}function v(e){return e.replace(/\\/g,"%5C").replace(/\/+/g,"/")}export{j as applyBasePath,p as formatPathname,h as formatPathnameTemplate,f as formatTemplatePathname,m as getBestMatchingDomain,g as getHost,s as getInternalTemplate,L as getLocaleAsPrefix,u as getLocalePrefixes,l as getNormalizedPathname,a as getPathnameMatch,d as getRouteParams,x as isLocaleSupportedOnDomain,v as sanitizePathname}; |
@@ -1,1 +0,1 @@ | ||
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as o}from"react";import{useLocale as n}from"use-intl";import r from"../shared/createSharedNavigationFns.js";import a from"../shared/syncLocaleCookie.js";import{getRoute as s}from"../shared/utils.js";import i from"./useBasePathname.js";function c(c){const{Link:m,config:u,getPathname:h,...f}=r(n,c);return{...f,Link:m,usePathname:function(){const e=i(u),t=n();return o((()=>e&&u.pathnames?s(t,e,u.pathnames):e),[t,e])},useRouter:function(){const r=e(),s=n(),i=t();return o((()=>{function e(e){return function(t,o){const{locale:n,...r}=o||{},c=[h({href:t,locale:n||s,domain:window.location.host})];Object.keys(r).length>0&&c.push(r),e(...c),a(u.localeCookie,i,s,n)}}return{...r,push:e(r.push),replace:e(r.replace),prefetch:e(r.prefetch)}}),[s,i,r])},getPathname:h}}export{c as default}; | ||
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as r}from"react";import{useLocale as n}from"use-intl";import o from"../shared/createSharedNavigationFns.js";import a from"../shared/syncLocaleCookie.js";import{getRoute as s}from"../shared/utils.js";import i from"./useBasePathname.js";function c(c){const{Link:m,config:u,getPathname:f,...h}=o(n,c);return{...h,Link:m,usePathname:function(){const e=i(u),t=n();return r((()=>e&&u.pathnames?s(t,e,u.pathnames):e),[t,e])},useRouter:function(){const o=e(),s=n(),i=t();return r((()=>{function e(e){return function(t,r){const{locale:n,...o}=r||{},c=[f({href:t,locale:n||s})];Object.keys(o).length>0&&c.push(o),e(...c),a(u.localeCookie,i,s,n)}}return{...o,push:e(o.push),replace:e(o.replace),prefetch:e(o.prefetch)}}),[s,i,o])},getPathname:f}}export{c as default}; |
"use client"; | ||
import o from"next/link";import{usePathname as e}from"next/navigation";import{forwardRef as n,useState as t,useEffect as r}from"react";import{useLocale as i}from"use-intl";import c from"./syncLocaleCookie.js";import{jsx as a}from"react/jsx-runtime";function f({defaultLocale:n,href:f,locale:l,localeCookie:m,onClick:s,prefetch:u,unprefixed:p,...d},h){const k=i(),j=null!=l&&l!==k,x=l||k,C=function(){const[o,e]=t();return r((()=>{e(window.location.host)}),[]),o}(),v=C&&p&&(p.domains[C]===x||!Object.keys(p.domains).includes(C)&&k===n&&!l)?p.pathname:f,L=e();j&&(u=!1);return a(o,{ref:h,href:v,hrefLang:j?l:void 0,onClick:function(o){c(m,L,k,l),s&&s(o)},prefetch:u,...d})}var l=n(f);export{l as default}; | ||
import o from"next/link";import{usePathname as r}from"next/navigation";import{forwardRef as e}from"react";import{useLocale as t}from"use-intl";import i from"./syncLocaleCookie.js";import{jsx as n}from"react/jsx-runtime";function f({href:e,locale:f,localeCookie:c,onClick:m,prefetch:l,...a},p){const s=t(),u=null!=f&&f!==s,h=r();u&&(l=!1);return n(o,{ref:p,href:e,hrefLang:u?f:void 0,onClick:function(o){i(c,h,s,f),m&&m(o)},prefetch:l,...a})}var c=e(f);export{c as default}; |
@@ -1,1 +0,1 @@ | ||
import{redirect as e,permanentRedirect as o}from"next/navigation";import{forwardRef as a}from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import n from"../../shared/use.js";import{isLocalizableHref as r}from"../../shared/utils.js";import i from"./BaseLink.js";import{serializeSearchParams as m,compileLocalizedPathname as l,applyPathnamePrefix as c,normalizeNameOrNameWithParams as f}from"./utils.js";import{jsx as s}from"react/jsx-runtime";function u(u,p){const d=t(p||{}),h=d.pathnames,j="as-needed"===d.localePrefix.mode&&d.domains||void 0;function g({href:e,locale:o,...a},t){let m,l;"object"==typeof e?(m=e.pathname,l=e.params):m=e;const c=r(e),f=u(),p=f instanceof Promise?n(f):f,g=c?x({locale:o||p,href:null==h?m:{pathname:m,params:l}},null!=o||j||void 0):m;return s(i,{ref:t,defaultLocale:d.defaultLocale,href:"object"==typeof e?{...e,pathname:g}:g,locale:o,localeCookie:d.localeCookie,unprefixed:j&&c?{domains:d.domains.reduce(((e,o)=>(e[o.domain]=o.defaultLocale,e)),{}),pathname:x({locale:p,href:null==h?m:{pathname:m,params:l}},!1)}:void 0,...a})}const v=a(g);function x(e,o){const{href:a,locale:t}=e;let n;return null==h?"object"==typeof a?(n=a.pathname,a.query&&(n+=m(a.query))):n=a:n=l({locale:t,...f(a),pathnames:d.pathnames}),c(n,t,d,e.domain,o)}function y(e){return function(o,...a){return e(x(o,o.domain?void 0:j),...a)}}const L=y(e),k=y(o);return{config:d,Link:v,redirect:L,permanentRedirect:k,getPathname:x}}export{u as default}; | ||
import{redirect as e,permanentRedirect as t}from"next/navigation";import{forwardRef as o}from"react";import{receiveRoutingConfig as r}from"../../routing/config.js";import n from"../../shared/use.js";import{isLocalizableHref as a,isPromise as i}from"../../shared/utils.js";import m from"./BaseLink.js";import{serializeSearchParams as c,compileLocalizedPathname as l,applyPathnamePrefix as f,normalizeNameOrNameWithParams as s}from"./utils.js";import{jsx as p}from"react/jsx-runtime";function u(u,h){const j=r(h||{}),d=j.pathnames;function g({href:e,locale:t,...o},r){let c,l;"object"==typeof e?(c=e.pathname,l=e.params):c=e;const f=a(e),s=u(),h=i(s)?n(s):s,g=f?k({locale:t||h,href:null==d?c:{pathname:c,params:l}},null!=t||void 0):c;return p(m,{ref:r,href:"object"==typeof e?{...e,pathname:g}:g,locale:t,localeCookie:j.localeCookie,...o})}const y=o(g);function k(e,t){const{href:o,locale:r}=e;let n;return null==d?"object"==typeof o?(n=o.pathname,o.query&&(n+=c(o.query))):n=o:n=l({locale:r,...s(o),pathnames:j.pathnames}),f(n,r,j,t)}function b(e){return function(t,...o){return e(k(t),...o)}}const x=b(e),q=b(t);return{config:j,Link:y,redirect:x,permanentRedirect:q,getPathname:k}}export{u as default}; |
@@ -1,1 +0,1 @@ | ||
import{getSortedPathnames as e,matchesPathname as n,isLocalizableHref as t,prefixPathname as r,getLocalePrefix as o,normalizeTrailingSlash as a}from"../../shared/utils.js";function i(e){return"string"==typeof e?{pathname:e}:e}function f(e){function n(e){return String(e)}const t=new URLSearchParams;for(const[r,o]of Object.entries(e))Array.isArray(o)?o.forEach((e=>{t.append(r,n(e))})):t.set(r,n(o));return"?"+t.toString()}function c({pathname:e,locale:n,params:t,pathnames:r,query:o}){function i(e){let n=r[e];return n||(n=e),n}function c(e){let r="string"==typeof e?e:e[n];return t&&Object.entries(t).forEach((([e,n])=>{let t,o;Array.isArray(n)?(t=`(\\[)?\\[...${e}\\](\\])?`,o=n.map((e=>String(e))).join("/")):(t=`\\[${e}\\]`,o=String(n)),r=r.replace(new RegExp(t,"g"),o)})),r=r.replace(/\[\[\.\.\..+\]\]/g,""),r=a(r),o&&(r+=f(o)),r}if("string"==typeof e){return c(i(e))}{const{pathname:n,...t}=e;return{...t,pathname:c(i(n))}}}function s(t,r,o){const a=e(Object.keys(o)),i=decodeURI(r);for(const e of a){const r=o[e];if("string"==typeof r){if(n(r,i))return e}else if(n(r[t],i))return e}return r}function u(e,n=window.location.pathname){return"/"===e?n:n.replace(e,"")}function l(e,n,a,i,f){const{mode:c}=a.localePrefix;let s;if(void 0!==f)s=f;else if(t(e))if("always"===c)s=!0;else if("as-needed"===c){let e=a.defaultLocale;if(a.domains){const n=a.domains.find((e=>e.domain===i));n&&(e=n.defaultLocale)}s=e!==n}return s?r(o(n,a.localePrefix),e):e}export{l as applyPathnamePrefix,c as compileLocalizedPathname,u as getBasePath,s as getRoute,i as normalizeNameOrNameWithParams,f as serializeSearchParams}; | ||
import{getSortedPathnames as e,matchesPathname as n,getLocalizedTemplate as t,isLocalizableHref as r,prefixPathname as o,getLocalePrefix as a,normalizeTrailingSlash as i}from"../../shared/utils.js";function c(e){return"string"==typeof e?{pathname:e}:e}function s(e){function n(e){return String(e)}const t=new URLSearchParams;for(const[r,o]of Object.entries(e))Array.isArray(o)?o.forEach((e=>{t.append(r,n(e))})):t.set(r,n(o));return"?"+t.toString()}function f({pathname:e,locale:n,params:r,pathnames:o,query:a}){function c(e){let n=o[e];return n||(n=e),n}function f(e,o){let c=t(e,n,o);return r&&Object.entries(r).forEach((([e,n])=>{let t,r;Array.isArray(n)?(t=`(\\[)?\\[...${e}\\](\\])?`,r=n.map((e=>String(e))).join("/")):(t=`\\[${e}\\]`,r=String(n)),c=c.replace(new RegExp(t,"g"),r)})),c=c.replace(/\[\[\.\.\..+\]\]/g,""),c=i(c),a&&(c+=s(a)),c}if("string"==typeof e){return f(c(e),e)}{const{pathname:n,...t}=e;return{...t,pathname:f(c(n),n)}}}function u(r,o,a){const i=e(Object.keys(a)),c=decodeURI(o);for(const e of i){const o=a[e];if("string"==typeof o){if(n(o,c))return e}else if(n(t(o,r,e),c))return e}return o}function l(e,n=window.location.pathname){return"/"===e?n:n.replace(e,"")}function p(e,n,t,i){const{mode:c}=t.localePrefix;let s;return void 0!==i?s=i:r(e)&&("always"===c?s=!0:"as-needed"===c&&(s=t.domains?!t.domains.some((e=>e.defaultLocale===n)):n!==t.defaultLocale)),s?o(a(n,t.localePrefix),e):e}export{p as applyPathnamePrefix,f as compileLocalizedPathname,l as getBasePath,u as getRoute,c as normalizeNameOrNameWithParams,s as serializeSearchParams}; |
@@ -1,1 +0,1 @@ | ||
import e from"fs";import s from"path";import{throwError as t}from"./utils.js";function n(n){const i=s.resolve(n);e.existsSync(i)||t(`\`createMessagesDeclaration\` points to a non-existent file: ${i}`),i.endsWith(".json")||t(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${i}`);const r=process.argv.includes("dev"),c=process.argv.includes("build");var a;(r||c)&&(a=()=>{o(n),r&&function(s){const t=e.watch(s,(e=>{"change"===e&&o(s,!0)}));process.on("exit",(()=>{t.close()}))}(n)},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",a()))}function o(s,t=!1){const n=s.replace(/\.json$/,".d.json.ts");function o(e){return`// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments\n\ndeclare const messages: ${e.trim()};\nexport default messages;`}if(t)return e.promises.readFile(s,"utf-8").then((s=>e.promises.writeFile(n,o(s))));const i=e.readFileSync(s,"utf-8");e.writeFileSync(n,o(i))}export{n as default}; | ||
import e from"fs";import t from"path";import{throwError as s}from"./utils.js";import o from"./watchFile.js";function n(o){var n;n=()=>{for(const n of o){const o=t.resolve(n);e.existsSync(o)||s(`\`createMessagesDeclaration\` points to a non-existent file: ${o}`),o.endsWith(".json")||s(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${o}`);const c=process.env["NODE_ENV".trim()];r(n),"development"===c&&i(n)}},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",n())}function i(e){const t=o(e,(()=>{r(e,!0)}));process.on("exit",(()=>{t.close()}))}function r(t,s=!1){const o=t.replace(/\.json$/,".d.json.ts");function n(e){return`// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments\n\ndeclare const messages: ${e.trim()};\nexport default messages;`}if(s)return e.promises.readFile(t,"utf-8").then((t=>e.promises.writeFile(o,n(t))));const i=e.readFileSync(t,"utf-8");e.writeFileSync(o,n(i))}export{n as default}; |
@@ -1,1 +0,1 @@ | ||
import e from"./createMessagesDeclaration.js";import t from"./getNextConfig.js";import{warn as r}from"./utils.js";function n(n={}){const o="string"==typeof n?{requestConfig:n}:n;return function(n){return function(n,o){return null!=o?.i18n&&r("\n[next-intl] An `i18n` property was found in your Next.js config. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the Pages Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n"),n.experimental?.createMessagesDeclaration&&e(n.experimental.createMessagesDeclaration),t(n,o)}(o,n)}}export{n as default}; | ||
import e from"./createMessagesDeclaration.js";import t from"./getNextConfig.js";import{warn as n}from"./utils.js";function r(r={}){const o="string"==typeof r?{requestConfig:r}:r;return function(r){return function(r,o){null!=o?.i18n&&n("\n[next-intl] An `i18n` property was found in your Next.js config. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the Pages Router, you can refer to this example: https://next-intl.dev/examples#app-router-migration\n");const i=r.experimental?.createMessagesDeclaration;return i&&e("string"==typeof i?[i]:i),t(r,o)}(o,r)}}export{r as default}; |
@@ -1,1 +0,1 @@ | ||
import r from"../server/react-server/getConfigNow.js";import e from"../server/react-server/getFormats.js";import t from"../shared/NextIntlClientProvider.js";import{jsx as o}from"react/jsx-runtime";import a from"../server/react-server/getLocale.js";import s from"../server/react-server/getTimeZone.js";async function i({formats:i,locale:m,now:n,timeZone:f,...c}){return o(t,{formats:void 0===i?await e():i,locale:m??await a(),now:n??await r(),timeZone:f??await s(),...c})}export{i as default}; | ||
import e from"../server/react-server/getConfigNow.js";import r from"../server/react-server/getFormats.js";import t from"../shared/NextIntlClientProvider.js";import{jsx as o}from"react/jsx-runtime";import s from"../server/react-server/getLocale.js";import a from"../server/react-server/getMessages.js";import m from"../server/react-server/getTimeZone.js";async function i({formats:i,locale:n,messages:v,now:f,timeZone:c,...g}){return o(t,{formats:void 0===i?await r():i,locale:n??await s(),messages:void 0===v?await a():v,now:f??await e(),timeZone:c??await m(),...g})}export{i as default}; |
@@ -1,1 +0,1 @@ | ||
export{default as getRequestConfig}from"./server/react-server/getRequestConfig.js";export{default as getFormatter}from"./server/react-server/getFormatter.js";export{default as getNow}from"./server/react-server/getNow.js";export{default as getMessages}from"./server/react-server/getMessages.js";export{default as getTimeZone}from"./server/react-server/getTimeZone.js";export{default as getTranslations}from"./server/react-server/getTranslations.js";export{default as getLocale}from"./server/react-server/getLocale.js";export{setCachedRequestLocale as setRequestLocale}from"./server/react-server/RequestLocaleCache.js"; | ||
export{default as getRequestConfig}from"./server/react-server/getRequestConfig.js";export{default as getFormatter}from"./server/react-server/getFormatter.js";export{default as getNow}from"./server/react-server/getNow.js";export{default as getTimeZone}from"./server/react-server/getTimeZone.js";export{default as getTranslations}from"./server/react-server/getTranslations.js";export{default as getMessages}from"./server/react-server/getMessages.js";export{default as getLocale}from"./server/react-server/getLocale.js";export{setCachedRequestLocale as setRequestLocale}from"./server/react-server/RequestLocaleCache.js"; |
@@ -1,1 +0,1 @@ | ||
import{cache as e}from"react";import{_createIntlFormatters as t,_createCache as o,initializeConfig as n}from"use-intl/core";import{getRequestLocale as r}from"./RequestLocale.js";import i from"next-intl/config";const s=e((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const a=e((async function(e,t){let o=e({locale:t,get requestLocale(){return t?Promise.resolve(t):r()}});if(o instanceof Promise&&(o=await o),!o.locale)throw new Error("No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request");return o})),c=e(t),m=e(o);const l=e((async function(e){const t=await a(i,e);return{...n(t),_formatters:c(m()),timeZone:t.timeZone||s()}}));export{l as default}; | ||
import{cache as e}from"react";import{_createIntlFormatters as t,_createCache as o,initializeConfig as r}from"use-intl/core";import{isPromise as n}from"../../shared/utils.js";import{getRequestLocale as i}from"./RequestLocale.js";import s from"next-intl/config";const a=e((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const c=e((async function(e,t){let o=e({locale:t,get requestLocale(){return t?Promise.resolve(t):i()}});if(n(o)&&(o=await o),!o.locale)throw new Error("No locale was returned from `getRequestConfig`.\n\nSee https://next-intl.dev/docs/usage/configuration#i18n-request");return o})),m=e(t),l=e(o);const u=e((async function(e){const t=await c(s,e);return{...r(t),_formatters:m(l()),timeZone:t.timeZone||a()}}));export{u as default}; |
@@ -1,1 +0,1 @@ | ||
import{headers as t}from"next/headers";import{cache as e}from"react";import{HEADER_LOCALE_NAME as n}from"../../shared/constants.js";import{getCachedRequestLocale as r}from"./RequestLocaleCache.js";const o=e((async function(){const e=t();return e instanceof Promise?await e:e}));const i=e((async function(){let t;try{t=(await o()).get(n)||void 0}catch(t){if(t instanceof Error&&"DYNAMIC_SERVER_USAGE"===t.digest){const e=new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:t});throw e.digest=t.digest,e}throw t}return t}));async function s(){return r()||await i()}export{s as getRequestLocale}; | ||
import{headers as t}from"next/headers";import{cache as e}from"react";import{HEADER_LOCALE_NAME as n}from"../../shared/constants.js";import{isPromise as r}from"../../shared/utils.js";import{getCachedRequestLocale as o}from"./RequestLocaleCache.js";const s=e((async function(){const e=t();return r(e)?await e:e}));const i=e((async function(){let t;try{t=(await s()).get(n)||void 0}catch(t){if(t instanceof Error&&"DYNAMIC_SERVER_USAGE"===t.digest){const e=new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `setRequestLocale` API to enable static rendering, see https://next-intl.dev/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:t});throw e.digest=t.digest,e}throw t}return t}));async function a(){return o()||await i()}export{a as getRequestLocale}; |
@@ -1,1 +0,1 @@ | ||
function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(n,t){return n.replace(new RegExp(`^${t}`),"")||"/"}function e(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function r(n,t){return t===n||t.startsWith(`${n}/`)}function u(n){const t=function(){try{return"true"===process.env._next_intl_trailing_slash}catch{return!1}}();if("/"!==n){const e=n.endsWith("/");t&&!e?n+="/":!t&&e&&(n=n.slice(0,-1))}return n}function i(n,t){const e=u(n),r=u(t);return f(e).test(r)}function c(n,t){return"never"!==t.mode&&t.prefixes?.[n]||o(n)}function o(n){return"/"+n}function f(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp(`^${t}$`)}function s(n){return n.includes("[[...")}function l(n){return n.includes("[...")}function a(n){return n.includes("[")}function p(n,t){const e=n.split("/"),r=t.split("/"),u=Math.max(e.length,r.length);for(let n=0;n<u;n++){const t=e[n],u=r[n];if(!t&&u)return-1;if(t&&!u)return 1;if(t||u){if(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1;if(!l(t)&&l(u))return-1;if(l(t)&&!l(u))return 1;if(!s(t)&&s(u))return-1;if(s(t)&&!s(u))return 1}}return 0}function h(n){return n.sort(p)}export{o as getLocaleAsPrefix,c as getLocalePrefix,h as getSortedPathnames,r as hasPathnamePrefixed,n as isLocalizableHref,i as matchesPathname,u as normalizeTrailingSlash,e as prefixPathname,f as templateToRegex,t as unprefixPathname}; | ||
function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(n,t){return n.replace(new RegExp(`^${t}`),"")||"/"}function e(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function r(n,t){return t===n||t.startsWith(`${n}/`)}function u(n,t,e){return"string"==typeof n?n:n[t]||e}function i(n){const t=function(){try{return"true"===process.env._next_intl_trailing_slash}catch{return!1}}();if("/"!==n){const e=n.endsWith("/");t&&!e?n+="/":!t&&e&&(n=n.slice(0,-1))}return n}function c(n,t){const e=i(n),r=i(t);return s(e).test(r)}function o(n,t){return"never"!==t.mode&&t.prefixes?.[n]||f(n)}function f(n){return"/"+n}function s(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp(`^${t}$`)}function l(n){return n.includes("[[...")}function p(n){return n.includes("[...")}function a(n){return n.includes("[")}function h(n,t){const e=n.split("/"),r=t.split("/"),u=Math.max(e.length,r.length);for(let n=0;n<u;n++){const t=e[n],u=r[n];if(!t&&u)return-1;if(t&&!u)return 1;if(t||u){if(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1;if(!p(t)&&p(u))return-1;if(p(t)&&!p(u))return 1;if(!l(t)&&l(u))return-1;if(l(t)&&!l(u))return 1}}return 0}function g(n){return n.sort(h)}function x(n){return"function"==typeof n.then}export{f as getLocaleAsPrefix,o as getLocalePrefix,u as getLocalizedTemplate,g as getSortedPathnames,r as hasPathnamePrefixed,n as isLocalizableHref,x as isPromise,c as matchesPathname,i as normalizeTrailingSlash,e as prefixPathname,s as templateToRegex,t as unprefixPathname}; |
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
export * from './react-client/index.tsx'; | ||
export * from './react-client/index.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './react-server/index.tsx'; | ||
export * from './react-server/index.js'; |
@@ -1,1 +0,1 @@ | ||
export { default } from './middleware/index.tsx'; | ||
export { default } from './middleware/index.js'; |
import type { NextRequest } from 'next/server.js'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
/** | ||
* See https://developers.google.com/search/docs/specialty/international/localized-versions | ||
*/ | ||
export default function getAlternateLinksHeaderValue<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>({ localizedPathnames, request, resolvedLocale, routing }: { | ||
export default function getAlternateLinksHeaderValue<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>({ internalTemplateName, localizedPathnames, request, resolvedLocale, routing }: { | ||
routing: Omit<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'pathnames'>; | ||
@@ -12,2 +12,3 @@ request: NextRequest; | ||
localizedPathnames?: Pathnames<AppLocales>[string]; | ||
internalTemplateName?: string; | ||
}): string; |
/** | ||
* The middleware, available as `next-intl/middleware`. | ||
*/ | ||
export { default } from './middleware.tsx'; | ||
export { default } from './middleware.js'; |
import { type NextRequest, NextResponse } from 'next/server.js'; | ||
import { type RoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import { type RoutingConfig } from '../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export default function createMiddleware<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(routing: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): (request: NextRequest) => NextResponse<unknown>; |
import type { RequestCookies } from 'next/dist/server/web/spec-extension/cookies.js'; | ||
import type { Locale } from 'use-intl'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { ResolvedRoutingConfig } from '../routing/config.js'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export declare function getAcceptLanguageLocale<AppLocales extends Locales>(requestHeaders: Headers, locales: AppLocales, defaultLocale: Locale): string | undefined; | ||
@@ -6,0 +6,0 @@ export default function resolveLocale<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(routing: Omit<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'pathnames'>, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): { |
import type { NextRequest, NextResponse } from 'next/server.js'; | ||
import type { Locale } from 'use-intl'; | ||
import type { InitializedLocaleCookieConfig, ResolvedRoutingConfig } from '../routing/config.tsx'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { InitializedLocaleCookieConfig, ResolvedRoutingConfig } from '../routing/config.js'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export default function syncCookie<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(request: NextRequest, response: NextResponse, locale: Locale, routing: Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'locales' | 'defaultLocale'> & { | ||
localeCookie: InitializedLocaleCookieConfig; | ||
}, domain?: DomainConfig<AppLocales>): void; |
import type { Locale } from 'use-intl'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from '../routing/types.tsx'; | ||
import type { DomainConfig, DomainsConfig, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
export declare function getFirstPathnameSegment(pathname: string): string; | ||
@@ -12,3 +12,3 @@ export declare function getInternalTemplate<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(pathnames: AppPathnames, pathname: string, locale: AppLocales[number]): [AppLocales[number] | undefined, keyof AppPathnames | undefined]; | ||
export declare function getLocalePrefixes<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>, sort?: boolean): Array<[AppLocales[number], string]>; | ||
export declare function getPathnameMatch<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>): { | ||
export declare function getPathnameMatch<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>, domain?: DomainConfig<AppLocales>): { | ||
locale: AppLocales[number]; | ||
@@ -15,0 +15,0 @@ prefix: string; |
@@ -1,1 +0,1 @@ | ||
export * from './navigation/react-client/index.tsx'; | ||
export * from './navigation/react-client/index.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './navigation/react-server/index.tsx'; | ||
export * from './navigation/react-server/index.js'; |
import { type Locale } from 'use-intl'; | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
export default function createNavigation<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(routing?: [AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): { | ||
@@ -304,6 +304,6 @@ Link: import("react").ForwardRefExoticComponent<Omit<{ | ||
pathname: T; | ||
params?: import("../shared/StrictParams.tsx").default<T> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T> | undefined; | ||
} & Omit<import("url").UrlObject, "pathname">) : T extends `${string}[${string}` ? { | ||
pathname: T; | ||
params: import("../shared/StrictParams.tsx").default<T>; | ||
params: import("../shared/StrictParams.js").default<T>; | ||
} & Omit<import("url").UrlObject, "pathname"> : T | ({ | ||
@@ -319,22 +319,20 @@ pathname: T; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & { | ||
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & { | ||
locale?: Locale; | ||
@@ -346,22 +344,20 @@ }) | undefined) => void; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & { | ||
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & { | ||
locale?: Locale; | ||
@@ -373,22 +369,20 @@ }) | undefined) => void; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").PrefetchOptions> & { | ||
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").PrefetchOptions> & { | ||
locale?: Locale; | ||
@@ -403,72 +397,62 @@ }) | undefined) => void; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {})) => string; | ||
}) => string; | ||
redirect: (args: Omit<{ | ||
href: [AppPathnames] extends [never] ? string | { | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}), "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
permanentRedirect: (args: Omit<{ | ||
href: [AppPathnames] extends [never] ? string | { | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}), "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
}; |
@@ -1,2 +0,2 @@ | ||
export { default as createNavigation } from './createNavigation.tsx'; | ||
export type { QueryParams } from '../shared/utils.tsx'; | ||
export { default as createNavigation } from './createNavigation.js'; | ||
export type { QueryParams } from '../shared/utils.js'; |
@@ -1,2 +0,2 @@ | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../../routing/types.tsx'; | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../../routing/types.js'; | ||
export default function useBasePathname<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(config: { | ||
@@ -3,0 +3,0 @@ localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>; |
@@ -1,3 +0,3 @@ | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import type { RoutingConfigLocalizedNavigation, RoutingConfigSharedNavigation } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
export default function createNavigation<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(routing?: [AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): { | ||
@@ -305,6 +305,6 @@ usePathname: () => never; | ||
pathname: T; | ||
params?: import("../shared/StrictParams.tsx").default<T> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T> | undefined; | ||
} & Omit<import("url").UrlObject, "pathname">) : T extends `${string}[${string}` ? { | ||
pathname: T; | ||
params: import("../shared/StrictParams.tsx").default<T>; | ||
params: import("../shared/StrictParams.js").default<T>; | ||
} & Omit<import("url").UrlObject, "pathname"> : T | ({ | ||
@@ -317,72 +317,62 @@ pathname: T; | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: import("use-intl").Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}), "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
permanentRedirect: (args: Omit<{ | ||
href: [AppPathnames] extends [never] ? string | { | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: import("use-intl").Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}), "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
getPathname: (args: { | ||
href: [AppPathnames] extends [never] ? string | { | ||
pathname: string; | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : keyof AppPathnames extends infer T_1 ? T_1 extends keyof AppPathnames ? T_1 extends `${string}[[...${string}` ? T_1 | ({ | ||
pathname: T_1; | ||
params?: import("../shared/StrictParams.tsx").default<T_1> | undefined; | ||
params?: import("../shared/StrictParams.js").default<T_1> | undefined; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : T_1 extends `${string}[${string}` ? { | ||
pathname: T_1; | ||
params: import("../shared/StrictParams.tsx").default<T_1>; | ||
params: import("../shared/StrictParams.js").default<T_1>; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
} : T_1 | ({ | ||
pathname: T_1; | ||
} & { | ||
query?: import("../shared/utils.tsx").QueryParams; | ||
query?: import("../shared/utils.js").QueryParams; | ||
}) : never : never; | ||
locale: import("use-intl").Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
domain: AppDomains[number]["domain"]; | ||
} : {})) => string; | ||
}) => string; | ||
}; |
@@ -1,2 +0,2 @@ | ||
export { default as createNavigation } from './createNavigation.tsx'; | ||
export type { Pathnames } from '../../routing/types.tsx'; | ||
export { default as createNavigation } from './createNavigation.js'; | ||
export type { Pathnames } from '../../routing/types.js'; |
import { type LinkProps } from 'next/link.js'; | ||
import { type ComponentProps } from 'react'; | ||
import { type Locale } from 'use-intl'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.tsx'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.js'; | ||
type NextLinkProps = Omit<ComponentProps<'a'>, keyof LinkProps> & Omit<LinkProps, 'locale'>; | ||
type Props = NextLinkProps & { | ||
locale?: Locale; | ||
defaultLocale?: Locale; | ||
localeCookie: InitializedLocaleCookieConfig; | ||
/** Special case for `localePrefix: 'as-needed'` and `domains`. */ | ||
unprefixed?: { | ||
domains: { | ||
[domain: string]: Locale; | ||
}; | ||
pathname: string; | ||
}; | ||
}; | ||
declare const _default: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>; | ||
export default _default; |
import type { Locale } from 'use-intl'; | ||
import { type RoutingConfigLocalizedNavigation, type RoutingConfigSharedNavigation } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import { type HrefOrHrefWithParams, type QueryParams } from './utils.tsx'; | ||
import { type RoutingConfigLocalizedNavigation, type RoutingConfigSharedNavigation } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
import { type HrefOrHrefWithParams, type QueryParams } from './utils.js'; | ||
type PromiseOrValue<Type> = Type | Promise<Type>; | ||
@@ -20,3 +20,3 @@ /** | ||
}; | ||
localeCookie: import("../../routing/config.tsx").InitializedLocaleCookieConfig; | ||
localeCookie: import("../../routing/config.js").InitializedLocaleCookieConfig; | ||
localeDetection: NonNullable<boolean | undefined>; | ||
@@ -324,6 +324,6 @@ alternateLinks: NonNullable<boolean | undefined>; | ||
pathname: T; | ||
params?: import("./StrictParams.tsx").default<T> | undefined; | ||
params?: import("./StrictParams.js").default<T> | undefined; | ||
} & Omit<import("url").UrlObject, "pathname">) : T extends `${string}[${string}` ? { | ||
pathname: T; | ||
params: import("./StrictParams.tsx").default<T>; | ||
params: import("./StrictParams.js").default<T>; | ||
} & Omit<import("url").UrlObject, "pathname"> : T | ({ | ||
@@ -340,15 +340,3 @@ pathname: T; | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
/** | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
domain: AppDomains[number]["domain"]; | ||
} : {}), _forcePrefix?: boolean) => string>[0], "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
/** | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
domain: AppDomains[number]["domain"]; | ||
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
}, _forcePrefix?: boolean) => string>[0], "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
permanentRedirect: (args: Omit<Parameters<(args: { | ||
@@ -361,15 +349,3 @@ /** @see https://next-intl.dev/docs/routing/navigation#getpathname */ | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
/** | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
domain: AppDomains[number]["domain"]; | ||
} : {}), _forcePrefix?: boolean) => string>[0], "domain"> & Partial<([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
/** | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
domain: AppDomains[number]["domain"]; | ||
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
}, _forcePrefix?: boolean) => string>[0], "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never; | ||
getPathname: (args: Parameters<(args: { | ||
@@ -382,10 +358,4 @@ /** @see https://next-intl.dev/docs/routing/navigation#getpathname */ | ||
locale: Locale; | ||
} & (([AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>) | undefined extends undefined ? {} : AppLocalePrefixMode extends "as-needed" ? [AppDomains] extends [never] ? {} : { | ||
/** | ||
* In case you're using `localePrefix: 'as-needed'` in combination with `domains`, the `defaultLocale` can differ by domain and therefore the locales that need to be prefixed can differ as well. For this particular case, this parameter should be provided in order to compute the correct pathname. Note that the actual domain is not part of the result, but only the pathname is returned. | ||
* @see https://next-intl.dev/docs/routing/navigation#getpathname | ||
*/ | ||
domain: AppDomains[number]["domain"]; | ||
} : {}), _forcePrefix?: boolean) => string>[0]) => string; | ||
}, _forcePrefix?: boolean) => string>[0]) => string; | ||
}; | ||
export {}; |
import type { Locale } from 'use-intl'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.tsx'; | ||
import type { InitializedLocaleCookieConfig } from '../../routing/config.js'; | ||
/** | ||
@@ -4,0 +4,0 @@ * We have to keep the cookie value in sync as Next.js might |
import type { ParsedUrlQueryInput } from 'node:querystring'; | ||
import type { UrlObject } from 'url'; | ||
import type { Locale } from 'use-intl'; | ||
import type { ResolvedRoutingConfig } from '../../routing/config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.tsx'; | ||
import type StrictParams from './StrictParams.tsx'; | ||
import type { ResolvedRoutingConfig } from '../../routing/config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types.js'; | ||
import type StrictParams from './StrictParams.js'; | ||
type SearchParamValue = ParsedUrlQueryInput[keyof ParsedUrlQueryInput]; | ||
@@ -52,4 +52,4 @@ type HrefOrHrefWithParamsImpl<Pathname, Other> = Pathname extends `${string}[[...${string}` ? // Optional catch-all | ||
export declare function getBasePath(pathname: string, windowPathname?: string): string; | ||
export declare function applyPathnamePrefix<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(pathname: string, locale: Locales[number], routing: Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'localePrefix' | 'domains'> & Partial<Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'defaultLocale'>>, domain?: string, force?: boolean): string; | ||
export declare function applyPathnamePrefix<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(pathname: string, locale: Locales[number], routing: Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'localePrefix' | 'domains'> & Partial<Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'defaultLocale'>>, force?: boolean): string; | ||
export declare function validateReceivedConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(config: Partial<Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'defaultLocale' | 'localePrefix'>>): void; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
export { default } from './plugin/index.tsx'; | ||
export { default } from './plugin/index.js'; |
@@ -1,1 +0,1 @@ | ||
export default function createMessagesDeclaration(messagesPath: string): void; | ||
export default function createMessagesDeclaration(messagesPaths: Array<string>): void; |
import type { NextConfig } from 'next'; | ||
import type { PluginConfig } from './types.tsx'; | ||
import type { PluginConfig } from './types.js'; | ||
export default function createNextIntlPlugin(i18nPathOrConfig?: string | PluginConfig): (nextConfig?: NextConfig) => NextConfig; |
import type { NextConfig } from 'next'; | ||
import type { PluginConfig } from './types.tsx'; | ||
import type { PluginConfig } from './types.js'; | ||
export default function getNextConfig(pluginConfig: PluginConfig, nextConfig?: NextConfig): NextConfig & Partial<NextConfig>; |
@@ -1,1 +0,1 @@ | ||
export { default } from './createNextIntlPlugin.tsx'; | ||
export { default } from './createNextIntlPlugin.js'; |
export type PluginConfig = { | ||
requestConfig?: string; | ||
experimental?: { | ||
createMessagesDeclaration?: string; | ||
/** A path to the messages file that you'd like to create a declaration for. In case you want to consider multiple files, you can pass an array of paths. */ | ||
createMessagesDeclaration?: string | Array<string>; | ||
}; | ||
}; |
@@ -14,2 +14,2 @@ /** | ||
export declare const useFormatter: typeof base_useFormatter; | ||
export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider.tsx'; | ||
export { default as NextIntlClientProvider } from '../shared/NextIntlClientProvider.js'; |
@@ -8,9 +8,9 @@ /** | ||
*/ | ||
export { default as useLocale } from './useLocale.tsx'; | ||
export { default as useTranslations } from './useTranslations.tsx'; | ||
export { default as useFormatter } from './useFormatter.tsx'; | ||
export { default as useNow } from './useNow.tsx'; | ||
export { default as useTimeZone } from './useTimeZone.tsx'; | ||
export { default as useMessages } from './useMessages.tsx'; | ||
export { default as NextIntlClientProvider } from './NextIntlClientProviderServer.tsx'; | ||
export { default as useLocale } from './useLocale.js'; | ||
export { default as useTranslations } from './useTranslations.js'; | ||
export { default as useFormatter } from './useFormatter.js'; | ||
export { default as useNow } from './useNow.js'; | ||
export { default as useTimeZone } from './useTimeZone.js'; | ||
export { default as useMessages } from './useMessages.js'; | ||
export { default as NextIntlClientProvider } from './NextIntlClientProviderServer.js'; | ||
export * from 'use-intl/core'; |
import type { ComponentProps } from 'react'; | ||
import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider.tsx'; | ||
import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider.js'; | ||
type Props = ComponentProps<typeof BaseNextIntlClientProvider>; | ||
export default function NextIntlClientProviderServer({ formats, locale, now, timeZone, ...rest }: Props): Promise<import("react/jsx-runtime").JSX.Element>; | ||
export default function NextIntlClientProviderServer({ formats, locale, messages, now, timeZone, ...rest }: Props): Promise<import("react/jsx-runtime").JSX.Element>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
import getConfig from '../server/react-server/getConfig.tsx'; | ||
import getConfig from '../server/react-server/getConfig.js'; | ||
export default function useConfig(hookName: string): Awaited<ReturnType<typeof getConfig>>; |
@@ -1,1 +0,1 @@ | ||
export * from './routing/index.tsx'; | ||
export * from './routing/index.js'; |
import type { NextResponse } from 'next/server.js'; | ||
import type { DomainsConfig, LocalePrefix, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from './types.tsx'; | ||
import type { DomainsConfig, LocalePrefix, LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from './types.js'; | ||
type CookieAttributes = Pick<NonNullable<Parameters<typeof NextResponse.prototype.cookies.set>['2']>, 'maxAge' | 'domain' | 'partitioned' | 'path' | 'priority' | 'sameSite' | 'secure' | 'name'>; | ||
@@ -4,0 +4,0 @@ export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined> = { |
@@ -1,3 +0,3 @@ | ||
import type { RoutingConfig } from './config.tsx'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from './types.tsx'; | ||
import type { RoutingConfig } from './config.js'; | ||
import type { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from './types.js'; | ||
export default function defineRouting<const AppLocales extends Locales, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppPathnames extends Pathnames<AppLocales> = never, const AppDomains extends DomainsConfig<AppLocales> = never>(config: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>; |
@@ -1,3 +0,3 @@ | ||
export type { Pathnames, LocalePrefix, DomainsConfig, LocalePrefixMode } from './types.tsx'; | ||
export { default as defineRouting } from './defineRouting.tsx'; | ||
export type { RoutingConfig } from './config.tsx'; | ||
export type { Pathnames, LocalePrefix, DomainsConfig, LocalePrefixMode } from './types.js'; | ||
export { default as defineRouting } from './defineRouting.js'; | ||
export type { RoutingConfig } from './config.js'; |
@@ -15,3 +15,3 @@ export type Locales = ReadonlyArray<string>; | ||
export type LocalePrefix<AppLocales extends Locales = [], AppLocalePrefixMode extends LocalePrefixMode = 'always'> = AppLocalePrefixMode | LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>; | ||
export type Pathnames<AppLocales extends Locales> = Record<Pathname, Record<AppLocales[number], Pathname> | Pathname>; | ||
export type Pathnames<AppLocales extends Locales> = Record<Pathname, Partial<Record<AppLocales[number], Pathname>> | Pathname>; | ||
export type DomainConfig<AppLocales extends Locales> = { | ||
@@ -21,6 +21,6 @@ defaultLocale: AppLocales[number]; | ||
domain: string; | ||
/** Optionally restrict which locales are available on this domain. */ | ||
locales?: Array<AppLocales[number]>; | ||
/** The locales that are available on this domain. */ | ||
locales: Array<AppLocales[number]>; | ||
}; | ||
export type DomainsConfig<AppLocales extends Locales> = Array<DomainConfig<AppLocales>>; | ||
export {}; |
@@ -1,1 +0,1 @@ | ||
export * from './server/react-client/index.tsx'; | ||
export * from './server/react-client/index.js'; |
@@ -1,1 +0,1 @@ | ||
export * from './server/react-server/index.tsx'; | ||
export * from './server/react-server/index.js'; |
@@ -1,2 +0,2 @@ | ||
import type { getFormatter as getFormatter_type, getLocale as getLocale_type, getMessages as getMessages_type, getNow as getNow_type, getRequestConfig as getRequestConfig_type, getTimeZone as getTimeZone_type, setRequestLocale as setRequestLocale_type } from '../react-server/index.tsx'; | ||
import type { getFormatter as getFormatter_type, getLocale as getLocale_type, getMessages as getMessages_type, getNow as getNow_type, getRequestConfig as getRequestConfig_type, getTimeZone as getTimeZone_type, setRequestLocale as setRequestLocale_type } from '../react-server/index.js'; | ||
export declare function getRequestConfig(...args: Parameters<typeof getRequestConfig_type>): ReturnType<typeof getRequestConfig_type>; | ||
@@ -3,0 +3,0 @@ export declare const getFormatter: typeof getFormatter_type; |
@@ -1,3 +0,3 @@ | ||
import type { GetRequestConfigParams, RequestConfig } from './getRequestConfig.tsx'; | ||
import type { GetRequestConfigParams, RequestConfig } from './getRequestConfig.js'; | ||
declare const _default: (params: GetRequestConfigParams) => RequestConfig | Promise<RequestConfig>; | ||
export default _default; |
import { type IntlConfig, type Locale, _createIntlFormatters } from 'use-intl/core'; | ||
declare function getConfigImpl(localeOverride?: Locale): Promise<IntlConfig & { | ||
declare function getConfigImpl(localeOverride?: Locale): Promise<{ | ||
locale: IntlConfig['locale']; | ||
formats?: NonNullable<IntlConfig['formats']>; | ||
timeZone: NonNullable<IntlConfig['timeZone']>; | ||
onError: NonNullable<IntlConfig['onError']>; | ||
getMessageFallback: NonNullable<IntlConfig['getMessageFallback']>; | ||
onError: NonNullable<IntlConfig['onError']>; | ||
timeZone: NonNullable<IntlConfig['timeZone']>; | ||
messages?: NonNullable<IntlConfig['messages']>; | ||
now?: NonNullable<IntlConfig['now']>; | ||
_formatters: ReturnType<typeof _createIntlFormatters>; | ||
@@ -7,0 +11,0 @@ }>; |
import type { Locale, useMessages as useMessagesType } from 'use-intl'; | ||
import getConfig from './getConfig.tsx'; | ||
import getConfig from './getConfig.js'; | ||
export declare function getMessagesFromConfig(config: Awaited<ReturnType<typeof getConfig>>): ReturnType<typeof useMessagesType>; | ||
@@ -4,0 +4,0 @@ export default function getMessages(opts?: { |
import { createFormatter } from 'use-intl/core'; | ||
declare function getFormatterCachedImpl(config: Parameters<typeof createFormatter>[0]): { | ||
dateTime: (value: Date | number, formatOrOptions?: string | import("use-intl/core").DateTimeFormatOptions) => string; | ||
number: (value: number | bigint, formatOrOptions?: string | import("use-intl/core").NumberFormatOptions) => string; | ||
relativeTime: (date: number | Date, nowOrOptions?: import("use-intl/core").RelativeTimeFormatOptions["now"] | import("use-intl/core").RelativeTimeFormatOptions) => string; | ||
list: <Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, formatOrOptions?: string | Intl.ListFormatOptions) => Value extends string ? string : Iterable<import("react").ReactElement>; | ||
dateTimeRange: (start: Date | number, end: Date | number, formatOrOptions?: string | import("use-intl/core").DateTimeFormatOptions) => string; | ||
dateTime: { | ||
(value: Date | number, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
(value: Date | number, format?: string, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
}; | ||
number: { | ||
(value: number | bigint, options?: import("use-intl/core").NumberFormatOptions): string; | ||
(value: number | bigint, format?: string, options?: import("use-intl/core").NumberFormatOptions): string; | ||
}; | ||
relativeTime: { | ||
(date: number | Date, now?: import("use-intl/core").RelativeTimeFormatOptions["now"]): string; | ||
(date: number | Date, options?: import("use-intl/core").RelativeTimeFormatOptions): string; | ||
}; | ||
list: { | ||
<Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, options?: Intl.ListFormatOptions): Value extends string ? string : Iterable<import("react").ReactElement>; | ||
<Value extends string | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>>(value: Iterable<Value>, format?: string, options?: Intl.ListFormatOptions): Value extends string ? string : Iterable<import("react").ReactElement>; | ||
}; | ||
dateTimeRange: { | ||
(start: Date | number, end: Date | number, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
(start: Date | number, end: Date | number, format?: string, options?: import("use-intl/core").DateTimeFormatOptions): string; | ||
}; | ||
}; | ||
declare const getFormatterCached: typeof getFormatterCachedImpl; | ||
export default getFormatterCached; |
/** | ||
* Server-only APIs available via `next-intl/server`. | ||
*/ | ||
export { default as getRequestConfig, type GetRequestConfigParams, type RequestConfig } from './getRequestConfig.tsx'; | ||
export { default as getFormatter } from './getFormatter.tsx'; | ||
export { default as getNow } from './getNow.tsx'; | ||
export { default as getTimeZone } from './getTimeZone.tsx'; | ||
export { default as getTranslations } from './getTranslations.tsx'; | ||
export { default as getMessages } from './getMessages.tsx'; | ||
export { default as getLocale } from './getLocale.tsx'; | ||
export { setCachedRequestLocale as setRequestLocale } from './RequestLocaleCache.tsx'; | ||
export { default as getRequestConfig, type GetRequestConfigParams, type RequestConfig } from './getRequestConfig.js'; | ||
export { default as getFormatter } from './getFormatter.js'; | ||
export { default as getNow } from './getNow.js'; | ||
export { default as getTimeZone } from './getTimeZone.js'; | ||
export { default as getTranslations } from './getTranslations.js'; | ||
export { default as getMessages } from './getMessages.js'; | ||
export { default as getLocale } from './getLocale.js'; | ||
export { setCachedRequestLocale as setRequestLocale } from './RequestLocaleCache.js'; |
import type { LinkProps } from 'next/link.js'; | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales } from '../routing/types.tsx'; | ||
import type { LocalePrefixConfigVerbose, LocalePrefixMode, Locales, Pathnames } from '../routing/types.js'; | ||
type Href = LinkProps['href']; | ||
@@ -8,2 +8,3 @@ export declare function isLocalizableHref(href: Href): boolean; | ||
export declare function hasPathnamePrefixed(prefix: string | undefined, pathname: string): boolean; | ||
export declare function getLocalizedTemplate<AppLocales extends Locales>(pathnameConfig: Pathnames<AppLocales>[keyof Pathnames<AppLocales>], locale: AppLocales[number], internalTemplate: string): string; | ||
export declare function normalizeTrailingSlash(pathname: string): string; | ||
@@ -19,2 +20,3 @@ export declare function matchesPathname( | ||
export declare function getSortedPathnames(pathnames: Array<string>): string[]; | ||
export declare function isPromise<Value>(value: Value | Promise<Value>): value is Promise<Value>; | ||
export {}; |
{ | ||
"name": "next-intl", | ||
"version": "4.0.0-beta-ddd5ae5", | ||
"version": "4.0.0-beta-dea867b", | ||
"sideEffects": false, | ||
@@ -115,3 +115,3 @@ "author": "Jan Amann <jan@amann.work>", | ||
"negotiator": "^1.0.0", | ||
"use-intl": "4.0.0-beta-ddd5ae5" | ||
"use-intl": "4.0.0-beta-dea867b" | ||
}, | ||
@@ -128,3 +128,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "1f0e953c2dd85407f7f386eee8ee17181f5d03df" | ||
"gitHead": "d6b499d3c2e9d5b1fa7df908ac892c0f41d26d3b" | ||
} |
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
205
1.49%233870
-3.15%3900
-1.29%20
33.33%+ Added
- Removed
Updated