next-intl 4.0.0-beta-4106641 → 4.0.0-beta-021e874
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/development/middleware/middleware.js +1 -1
- package/dist/esm/development/middleware/resolveLocale.js +2 -2
- package/dist/esm/development/middleware/utils.js +17 -14
- package/dist/esm/development/navigation/react-client/createNavigation.js +1 -4
- package/dist/esm/development/navigation/shared/BaseLink.js +2 -24
- package/dist/esm/development/navigation/shared/createSharedNavigationFns.js +7 -46
- package/dist/esm/development/navigation/shared/utils.js +5 -13
- package/dist/esm/development/routing/defineRouting.js +20 -0
- package/dist/esm/production/middleware/middleware.js +1 -1
- package/dist/esm/production/middleware/resolveLocale.js +1 -1
- package/dist/esm/production/middleware/utils.js +1 -1
- package/dist/esm/production/navigation/react-client/createNavigation.js +1 -1
- package/dist/esm/production/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/production/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/esm/production/navigation/shared/utils.js +1 -1
- package/dist/types/middleware/utils.d.ts +1 -1
- package/dist/types/navigation/react-client/createNavigation.d.ts +6 -22
- package/dist/types/navigation/react-server/createNavigation.d.ts +3 -13
- package/dist/types/navigation/shared/BaseLink.d.ts +0 -8
- package/dist/types/navigation/shared/createSharedNavigationFns.d.ts +3 -33
- package/dist/types/navigation/shared/utils.d.ts +1 -1
- package/dist/types/routing/types.d.ts +2 -2
- package/package.json +3 -3
|
@@ -70,7 +70,7 @@ function createMiddleware(routing) {
|
|
|
70
70
|
return NextResponse.redirect(urlObj.toString());
|
|
71
71
|
}
|
|
72
72
|
const unprefixedExternalPathname = getNormalizedPathname(externalPathname, resolvedRouting.locales, resolvedRouting.localePrefix);
|
|
73
|
-
const pathnameMatch = getPathnameMatch(externalPathname, resolvedRouting.locales, resolvedRouting.localePrefix);
|
|
73
|
+
const pathnameMatch = getPathnameMatch(externalPathname, resolvedRouting.locales, resolvedRouting.localePrefix, domain);
|
|
74
74
|
const hasLocalePrefix = pathnameMatch != null;
|
|
75
75
|
const isUnprefixedRouting = resolvedRouting.localePrefix.mode === 'never' || hasMatchedDefaultLocale && resolvedRouting.localePrefix.mode === 'as-needed';
|
|
76
76
|
let response;
|
|
@@ -72,7 +72,7 @@ function resolveLocaleFromDomain(routing, requestHeaders, requestCookies, pathna
|
|
|
72
72
|
|
|
73
73
|
// Prio 1: Use route prefix
|
|
74
74
|
if (pathname) {
|
|
75
|
-
const prefixLocale = getPathnameMatch(pathname, routing.locales, routing.localePrefix)?.locale;
|
|
75
|
+
const prefixLocale = getPathnameMatch(pathname, routing.locales, routing.localePrefix, domain)?.locale;
|
|
76
76
|
if (prefixLocale) {
|
|
77
77
|
if (isLocaleSupportedOnDomain(prefixLocale, domain)) {
|
|
78
78
|
locale = prefixLocale;
|
|
@@ -98,7 +98,7 @@ function resolveLocaleFromDomain(routing, requestHeaders, requestCookies, pathna
|
|
|
98
98
|
|
|
99
99
|
// Prio 3: Use the `accept-language` header
|
|
100
100
|
if (!locale && routing.localeDetection) {
|
|
101
|
-
const headerLocale = getAcceptLanguageLocale(requestHeaders, domain.locales
|
|
101
|
+
const headerLocale = getAcceptLanguageLocale(requestHeaders, domain.locales, domain.defaultLocale);
|
|
102
102
|
if (headerLocale) {
|
|
103
103
|
locale = headerLocale;
|
|
104
104
|
}
|
|
@@ -76,8 +76,21 @@ function getLocalePrefixes(locales, localePrefix, sort = true) {
|
|
|
76
76
|
}
|
|
77
77
|
return prefixes;
|
|
78
78
|
}
|
|
79
|
-
function getPathnameMatch(pathname, locales, localePrefix) {
|
|
79
|
+
function getPathnameMatch(pathname, locales, localePrefix, domain) {
|
|
80
80
|
const localePrefixes = getLocalePrefixes(locales, localePrefix);
|
|
81
|
+
|
|
82
|
+
// Sort to prioritize domain locales
|
|
83
|
+
if (domain) {
|
|
84
|
+
localePrefixes.sort(([localeA], [localeB]) => {
|
|
85
|
+
if (localeA === domain.defaultLocale) return -1;
|
|
86
|
+
if (localeB === domain.defaultLocale) return 1;
|
|
87
|
+
const isLocaleAInDomain = domain.locales.includes(localeA);
|
|
88
|
+
const isLocaleBInDomain = domain.locales.includes(localeB);
|
|
89
|
+
if (isLocaleAInDomain && !isLocaleBInDomain) return -1;
|
|
90
|
+
if (!isLocaleAInDomain && isLocaleBInDomain) return 1;
|
|
91
|
+
return 0;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
81
94
|
for (const [locale, prefix] of localePrefixes) {
|
|
82
95
|
let exact, matches;
|
|
83
96
|
if (pathname === prefix || pathname.startsWith(prefix + '/')) {
|
|
@@ -139,7 +152,7 @@ function getHost(requestHeaders) {
|
|
|
139
152
|
return requestHeaders.get('x-forwarded-host') ?? requestHeaders.get('host') ?? undefined;
|
|
140
153
|
}
|
|
141
154
|
function isLocaleSupportedOnDomain(locale, domain) {
|
|
142
|
-
return domain.defaultLocale === locale ||
|
|
155
|
+
return domain.defaultLocale === locale || domain.locales.includes(locale);
|
|
143
156
|
}
|
|
144
157
|
function getBestMatchingDomain(curHostDomain, locale, domainsConfig) {
|
|
145
158
|
let domainConfig;
|
|
@@ -154,19 +167,9 @@ function getBestMatchingDomain(curHostDomain, locale, domainsConfig) {
|
|
|
154
167
|
domainConfig = domainsConfig.find(cur => cur.defaultLocale === locale);
|
|
155
168
|
}
|
|
156
169
|
|
|
157
|
-
// Prio 3: Use alternative domain
|
|
158
|
-
if (!domainConfig) {
|
|
159
|
-
domainConfig = domainsConfig.find(cur => cur.locales?.includes(locale));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Prio 4: Stay on the current domain if it supports all locales
|
|
163
|
-
if (!domainConfig && curHostDomain?.locales == null) {
|
|
164
|
-
domainConfig = curHostDomain;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Prio 5: Use alternative domain that supports all locales
|
|
170
|
+
// Prio 3: Use alternative domain that supports the locale
|
|
168
171
|
if (!domainConfig) {
|
|
169
|
-
domainConfig = domainsConfig.find(cur =>
|
|
172
|
+
domainConfig = domainsConfig.find(cur => cur.locales.includes(locale));
|
|
170
173
|
}
|
|
171
174
|
return domainConfig;
|
|
172
175
|
}
|
|
@@ -37,12 +37,9 @@ function createNavigation(routing) {
|
|
|
37
37
|
locale: nextLocale,
|
|
38
38
|
...rest
|
|
39
39
|
} = options || {};
|
|
40
|
-
|
|
41
|
-
// @ts-expect-error -- We're passing a domain here just in case
|
|
42
40
|
const pathname = getPathname({
|
|
43
41
|
href,
|
|
44
|
-
locale: nextLocale || curLocale
|
|
45
|
-
domain: window.location.host
|
|
42
|
+
locale: nextLocale || curLocale
|
|
46
43
|
});
|
|
47
44
|
const args = [pathname];
|
|
48
45
|
if (Object.keys(rest).length > 0) {
|
|
@@ -1,36 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import NextLink from 'next/link';
|
|
3
3
|
import { usePathname } from 'next/navigation';
|
|
4
|
-
import { forwardRef
|
|
4
|
+
import { forwardRef } from 'react';
|
|
5
5
|
import { useLocale } from 'use-intl';
|
|
6
6
|
import syncLocaleCookie from './syncLocaleCookie.js';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
function BaseLink({
|
|
10
|
-
defaultLocale,
|
|
11
10
|
href,
|
|
12
11
|
locale,
|
|
13
12
|
localeCookie,
|
|
14
13
|
onClick,
|
|
15
14
|
prefetch,
|
|
16
|
-
unprefixed,
|
|
17
15
|
...rest
|
|
18
16
|
}, ref) {
|
|
19
17
|
const curLocale = useLocale();
|
|
20
18
|
const isChangingLocale = locale != null && locale !== curLocale;
|
|
21
|
-
const linkLocale = locale || curLocale;
|
|
22
|
-
const host = useHost();
|
|
23
|
-
const finalHref =
|
|
24
|
-
// Only after hydration (to avoid mismatches)
|
|
25
|
-
host &&
|
|
26
|
-
// If there is an `unprefixed` prop, the
|
|
27
|
-
// `defaultLocale` might differ by domain
|
|
28
|
-
unprefixed && (
|
|
29
|
-
// Unprefix the pathname if a domain matches
|
|
30
|
-
unprefixed.domains[host] === linkLocale ||
|
|
31
|
-
// … and handle unknown domains by applying the
|
|
32
|
-
// global `defaultLocale` (e.g. on localhost)
|
|
33
|
-
!Object.keys(unprefixed.domains).includes(host) && curLocale === defaultLocale && !locale) ? unprefixed.pathname : href;
|
|
34
19
|
|
|
35
20
|
// The types aren't entirely correct here. Outside of Next.js
|
|
36
21
|
// `useParams` can be called, but the return type is `null`.
|
|
@@ -51,20 +36,13 @@ function BaseLink({
|
|
|
51
36
|
const Link = NextLink;
|
|
52
37
|
return /*#__PURE__*/jsx(Link, {
|
|
53
38
|
ref: ref,
|
|
54
|
-
href:
|
|
39
|
+
href: href,
|
|
55
40
|
hrefLang: isChangingLocale ? locale : undefined,
|
|
56
41
|
onClick: onLinkClick,
|
|
57
42
|
prefetch: prefetch,
|
|
58
43
|
...rest
|
|
59
44
|
});
|
|
60
45
|
}
|
|
61
|
-
function useHost() {
|
|
62
|
-
const [host, setHost] = useState();
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
setHost(window.location.host);
|
|
65
|
-
}, []);
|
|
66
|
-
return host;
|
|
67
|
-
}
|
|
68
46
|
var BaseLink$1 = /*#__PURE__*/forwardRef(BaseLink);
|
|
69
47
|
|
|
70
48
|
export { BaseLink$1 as default };
|
|
@@ -16,23 +16,14 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
16
16
|
validateReceivedConfig(config);
|
|
17
17
|
}
|
|
18
18
|
const pathnames = config.pathnames;
|
|
19
|
-
|
|
20
|
-
// This combination requires that the current host is known in order to
|
|
21
|
-
// compute a correct pathname. Since that can only be achieved by reading from
|
|
22
|
-
// headers, this would break static rendering. Therefore, as a workaround we
|
|
23
|
-
// always add a prefix in this case to be on the safe side. The downside is
|
|
24
|
-
// that the user might get redirected again if the middleware detects that the
|
|
25
|
-
// prefix is not needed.
|
|
26
|
-
const forcePrefixSsr = config.localePrefix.mode === 'as-needed' && config.domains || undefined;
|
|
27
19
|
function Link({
|
|
28
20
|
href,
|
|
29
21
|
locale,
|
|
30
22
|
...rest
|
|
31
23
|
}, ref) {
|
|
32
|
-
let pathname, params
|
|
24
|
+
let pathname, params;
|
|
33
25
|
if (typeof href === 'object') {
|
|
34
26
|
pathname = href.pathname;
|
|
35
|
-
query = href.query;
|
|
36
27
|
// @ts-expect-error -- This is ok
|
|
37
28
|
params = href.params;
|
|
38
29
|
} else {
|
|
@@ -43,20 +34,16 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
43
34
|
const isLocalizable = isLocalizableHref(href);
|
|
44
35
|
const localePromiseOrValue = getLocale();
|
|
45
36
|
const curLocale = isPromise(localePromiseOrValue) ? use(localePromiseOrValue) : localePromiseOrValue;
|
|
46
|
-
const finalPathname = isLocalizable ? getPathname(
|
|
47
|
-
// @ts-expect-error -- This is ok
|
|
48
|
-
{
|
|
37
|
+
const finalPathname = isLocalizable ? getPathname({
|
|
49
38
|
locale: locale || curLocale,
|
|
39
|
+
// @ts-expect-error -- This is ok
|
|
50
40
|
href: pathnames == null ? pathname : {
|
|
51
41
|
pathname,
|
|
52
42
|
params
|
|
53
43
|
}
|
|
54
|
-
}, locale != null ||
|
|
44
|
+
}, locale != null || undefined) : pathname;
|
|
55
45
|
return /*#__PURE__*/jsx(BaseLink, {
|
|
56
46
|
ref: ref
|
|
57
|
-
// @ts-expect-error -- Available after the validation
|
|
58
|
-
,
|
|
59
|
-
defaultLocale: config.defaultLocale
|
|
60
47
|
// @ts-expect-error -- This is ok
|
|
61
48
|
,
|
|
62
49
|
href: typeof href === 'object' ? {
|
|
@@ -64,29 +51,7 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
64
51
|
pathname: finalPathname
|
|
65
52
|
} : finalPathname,
|
|
66
53
|
locale: locale,
|
|
67
|
-
localeCookie: config.localeCookie
|
|
68
|
-
// Provide the minimal relevant information to the client side in order
|
|
69
|
-
// to potentially remove the prefix in case of the `forcePrefixSsr` case
|
|
70
|
-
,
|
|
71
|
-
unprefixed: forcePrefixSsr && isLocalizable ? {
|
|
72
|
-
domains: config.domains.reduce((acc, domain) => {
|
|
73
|
-
acc[domain.domain] = domain.defaultLocale;
|
|
74
|
-
return acc;
|
|
75
|
-
}, {}),
|
|
76
|
-
pathname: getPathname(
|
|
77
|
-
// @ts-expect-error -- This is ok
|
|
78
|
-
{
|
|
79
|
-
locale: curLocale,
|
|
80
|
-
href: pathnames == null ? {
|
|
81
|
-
pathname,
|
|
82
|
-
query
|
|
83
|
-
} : {
|
|
84
|
-
pathname,
|
|
85
|
-
query,
|
|
86
|
-
params
|
|
87
|
-
}
|
|
88
|
-
}, false)
|
|
89
|
-
} : undefined,
|
|
54
|
+
localeCookie: config.localeCookie,
|
|
90
55
|
...rest
|
|
91
56
|
});
|
|
92
57
|
}
|
|
@@ -116,16 +81,12 @@ function createSharedNavigationFns(getLocale, routing) {
|
|
|
116
81
|
pathnames: config.pathnames
|
|
117
82
|
});
|
|
118
83
|
}
|
|
119
|
-
return applyPathnamePrefix(pathname, locale, config,
|
|
120
|
-
// @ts-expect-error -- This is ok
|
|
121
|
-
args.domain, _forcePrefix);
|
|
84
|
+
return applyPathnamePrefix(pathname, locale, config, _forcePrefix);
|
|
122
85
|
}
|
|
123
86
|
function getRedirectFn(fn) {
|
|
124
87
|
/** @see https://next-intl.dev/docs/routing/navigation#redirect */
|
|
125
88
|
return function redirectFn(args, ...rest) {
|
|
126
|
-
return fn(
|
|
127
|
-
// @ts-expect-error -- We're forcing the prefix when no domain is provided
|
|
128
|
-
getPathname(args, args.domain ? undefined : forcePrefixSsr), ...rest);
|
|
89
|
+
return fn(getPathname(args), ...rest);
|
|
129
90
|
};
|
|
130
91
|
}
|
|
131
92
|
const redirect$1 = getRedirectFn(redirect);
|
|
@@ -115,7 +115,7 @@ function getBasePath(pathname, windowPathname = window.location.pathname) {
|
|
|
115
115
|
return windowPathname.replace(pathname, '');
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
function applyPathnamePrefix(pathname, locale, routing,
|
|
118
|
+
function applyPathnamePrefix(pathname, locale, routing, force) {
|
|
119
119
|
const {
|
|
120
120
|
mode
|
|
121
121
|
} = routing.localePrefix;
|
|
@@ -126,18 +126,10 @@ function applyPathnamePrefix(pathname, locale, routing, domain, force) {
|
|
|
126
126
|
if (mode === 'always') {
|
|
127
127
|
shouldPrefix = true;
|
|
128
128
|
} else if (mode === 'as-needed') {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
defaultLocale = domainConfig.defaultLocale;
|
|
134
|
-
} else {
|
|
135
|
-
if (!domain) {
|
|
136
|
-
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");
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
shouldPrefix = defaultLocale !== locale;
|
|
129
|
+
shouldPrefix = routing.domains ?
|
|
130
|
+
// Since locales are unique per domain, any locale that is a
|
|
131
|
+
// default locale of a domain doesn't require a prefix
|
|
132
|
+
!routing.domains.some(cur => cur.defaultLocale === locale) : locale !== routing.defaultLocale;
|
|
141
133
|
}
|
|
142
134
|
}
|
|
143
135
|
return shouldPrefix ? prefixPathname(getLocalePrefix(locale, routing.localePrefix), pathname) : pathname;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
function defineRouting(config) {
|
|
2
|
+
if (config.domains) {
|
|
3
|
+
validateUniqueLocalesPerDomain(config.domains);
|
|
4
|
+
}
|
|
2
5
|
return config;
|
|
3
6
|
}
|
|
7
|
+
function validateUniqueLocalesPerDomain(domains) {
|
|
8
|
+
const domainsByLocale = new Map();
|
|
9
|
+
for (const {
|
|
10
|
+
domain,
|
|
11
|
+
locales
|
|
12
|
+
} of domains) {
|
|
13
|
+
for (const locale of locales) {
|
|
14
|
+
const localeDomains = domainsByLocale.get(locale) || new Set();
|
|
15
|
+
localeDomains.add(domain);
|
|
16
|
+
domainsByLocale.set(locale, localeDomains);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const duplicateLocaleMessages = Array.from(domainsByLocale.entries()).filter(([, localeDomains]) => localeDomains.size > 1).map(([locale, localeDomains]) => `- "${locale}" is used by: ${Array.from(localeDomains).join(', ')}`);
|
|
20
|
+
if (duplicateLocaleMessages.length > 0) {
|
|
21
|
+
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');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
4
24
|
|
|
5
25
|
export { defineRouting as default };
|
|
@@ -1 +1 @@
|
|
|
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)))}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=U(l.pathname,t.nextUrl.basePath)),V=!0,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,B=H;const D=v.pathnames;if(D){let e;if([e,S]=h(D,H,w),S){const r=D[S],a="string"==typeof r?r:r[w];if(o(a,H))B=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("/"!==B||A){const e=p(B,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(B,P(w),t.nextUrl.search)):q(p(H,l(w,v.localePrefix),t.nextUrl.search));return i(t,I,w,v,j),!V&&"never"!==v.localePrefix.mode&&v.alternateLinks&&v.locales.length>1&&I.headers.set("Link",n({routing:v,localizedPathnames:null!=S&&D?D[S]:void 0,request:t,resolvedLocale:w})),I}}export{g as default};
|
|
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)))}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=U(l.pathname,t.nextUrl.basePath)),V=!0,e.redirect(l.toString())}const H=f(L,v.locales,v.localePrefix),z=m(L,v.locales,v.localePrefix,j),A=null!=z,C="never"===v.localePrefix.mode||k&&"as-needed"===v.localePrefix.mode;let I,S,V,B=H;const D=v.pathnames;if(D){let e;if([e,S]=h(D,H,w),S){const r=D[S],a="string"==typeof r?r:r[w];if(o(a,H))B=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("/"!==B||A){const e=p(B,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(B,P(w),t.nextUrl.search)):q(p(H,l(w,v.localePrefix),t.nextUrl.search));return i(t,I,w,v,j),!V&&"never"!==v.localePrefix.mode&&v.alternateLinks&&v.locales.length>1&&I.headers.set("Link",n({routing:v,localizedPathnames:null!=S&&D?D[S]:void 0,request:t,resolvedLocale:w})),I}}export{g as default};
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,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 @@
|
|
|
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
|
|
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 f(e,t,r,o){let c="";return c+=d(r,a(t,e)),c=n(c),c}function l(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 f=i?"/"+i[2]:e;return"/"!==f&&(f=n(f)),f}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,r){const o=s(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 a(e,t){const r=n(t),c=n(e),i=o(c).exec(r);if(!i)return;const f={};for(let e=1;e<i.length;e++){const t=c.match(/\[([^\]]+)\]/g)?.[e-1].replace(/[[\]]/g,"");t&&(f[t]=i[e])}return f}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.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}function m(e,t){return n(t+e)}function j(e){return`/${e}`}function L(e){return e.replace(/\\/g,"%5C").replace(/\/+/g,"/")}export{m as applyBasePath,h as formatPathname,d as formatPathnameTemplate,f as formatTemplatePathname,x as getBestMatchingDomain,p as getHost,i as getInternalTemplate,j as getLocaleAsPrefix,s as getLocalePrefixes,l as getNormalizedPathname,u as getPathnameMatch,a as getRouteParams,g as isLocaleSupportedOnDomain,L as sanitizePathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as
|
|
1
|
+
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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import o from"next/link";import{usePathname as
|
|
2
|
+
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 @@
|
|
|
1
|
-
import{redirect as e,permanentRedirect as
|
|
1
|
+
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 @@
|
|
|
1
|
-
import{getSortedPathnames as e,matchesPathname as
|
|
1
|
+
import{getSortedPathnames as e,matchesPathname as t,isLocalizableHref as n,prefixPathname as r,getLocalePrefix as o,normalizeTrailingSlash as a}from"../../shared/utils.js";function i(e){return"string"==typeof e?{pathname:e}:e}function c(e){function t(e){return String(e)}const n=new URLSearchParams;for(const[r,o]of Object.entries(e))Array.isArray(o)?o.forEach((e=>{n.append(r,t(e))})):n.set(r,t(o));return"?"+n.toString()}function s({pathname:e,locale:t,params:n,pathnames:r,query:o}){function i(e){let t=r[e];return t||(t=e),t}function s(e){let r="string"==typeof e?e:e[t];return n&&Object.entries(n).forEach((([e,t])=>{let n,o;Array.isArray(t)?(n=`(\\[)?\\[...${e}\\](\\])?`,o=t.map((e=>String(e))).join("/")):(n=`\\[${e}\\]`,o=String(t)),r=r.replace(new RegExp(n,"g"),o)})),r=r.replace(/\[\[\.\.\..+\]\]/g,""),r=a(r),o&&(r+=c(o)),r}if("string"==typeof e){return s(i(e))}{const{pathname:t,...n}=e;return{...n,pathname:s(i(t))}}}function f(n,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(t(r,i))return e}else if(t(r[n],i))return e}return r}function u(e,t=window.location.pathname){return"/"===e?t:t.replace(e,"")}function l(e,t,a,i){const{mode:c}=a.localePrefix;let s;return void 0!==i?s=i:n(e)&&("always"===c?s=!0:"as-needed"===c&&(s=a.domains?!a.domains.some((e=>e.defaultLocale===t)):t!==a.defaultLocale)),s?r(o(t,a.localePrefix),e):e}export{l as applyPathnamePrefix,s as compileLocalizedPathname,u as getBasePath,f as getRoute,i as normalizeNameOrNameWithParams,c as serializeSearchParams};
|
|
@@ -9,7 +9,7 @@ export declare function formatTemplatePathname(sourcePathname: string, sourceTem
|
|
|
9
9
|
export declare function getNormalizedPathname<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>): string;
|
|
10
10
|
export declare function findCaseInsensitiveString(candidate: string, strings: Array<string>): string | undefined;
|
|
11
11
|
export declare function getLocalePrefixes<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>, sort?: boolean): Array<[AppLocales[number], string]>;
|
|
12
|
-
export declare function getPathnameMatch<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>): {
|
|
12
|
+
export declare function getPathnameMatch<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>, domain?: DomainConfig<AppLocales>): {
|
|
13
13
|
locale: AppLocales[number];
|
|
14
14
|
prefix: string;
|
|
15
15
|
matchedPrefix: string;
|
|
@@ -332,9 +332,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
332
332
|
query?: import("../shared/utils.js").QueryParams;
|
|
333
333
|
}) : never : never;
|
|
334
334
|
locale: Locale;
|
|
335
|
-
}
|
|
336
|
-
domain: AppDomains[number]["domain"];
|
|
337
|
-
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
335
|
+
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
338
336
|
locale?: Locale;
|
|
339
337
|
}) | undefined) => void;
|
|
340
338
|
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
@@ -358,9 +356,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
358
356
|
query?: import("../shared/utils.js").QueryParams;
|
|
359
357
|
}) : never : never;
|
|
360
358
|
locale: Locale;
|
|
361
|
-
}
|
|
362
|
-
domain: AppDomains[number]["domain"];
|
|
363
|
-
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
359
|
+
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions> & {
|
|
364
360
|
locale?: Locale;
|
|
365
361
|
}) | undefined) => void;
|
|
366
362
|
/** @see https://next-intl.dev/docs/routing/navigation#userouter */
|
|
@@ -384,9 +380,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
384
380
|
query?: import("../shared/utils.js").QueryParams;
|
|
385
381
|
}) : never : never;
|
|
386
382
|
locale: Locale;
|
|
387
|
-
}
|
|
388
|
-
domain: AppDomains[number]["domain"];
|
|
389
|
-
} : {})) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").PrefetchOptions> & {
|
|
383
|
+
}) => string>[0]["href"], options?: (Partial<import("next/dist/shared/lib/app-router-context.shared-runtime.js").PrefetchOptions> & {
|
|
390
384
|
locale?: Locale;
|
|
391
385
|
}) | undefined) => void;
|
|
392
386
|
back(): void;
|
|
@@ -413,9 +407,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
413
407
|
query?: import("../shared/utils.js").QueryParams;
|
|
414
408
|
}) : never : never;
|
|
415
409
|
locale: Locale;
|
|
416
|
-
}
|
|
417
|
-
domain: AppDomains[number]["domain"];
|
|
418
|
-
} : {})) => string;
|
|
410
|
+
}) => string;
|
|
419
411
|
redirect: (args: Omit<{
|
|
420
412
|
href: [AppPathnames] extends [never] ? string | {
|
|
421
413
|
pathname: string;
|
|
@@ -436,11 +428,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
436
428
|
query?: import("../shared/utils.js").QueryParams;
|
|
437
429
|
}) : never : never;
|
|
438
430
|
locale: Locale;
|
|
439
|
-
}
|
|
440
|
-
domain: AppDomains[number]["domain"];
|
|
441
|
-
} : {}), "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] ? {} : {
|
|
442
|
-
domain: AppDomains[number]["domain"];
|
|
443
|
-
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
431
|
+
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
444
432
|
permanentRedirect: (args: Omit<{
|
|
445
433
|
href: [AppPathnames] extends [never] ? string | {
|
|
446
434
|
pathname: string;
|
|
@@ -461,9 +449,5 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
461
449
|
query?: import("../shared/utils.js").QueryParams;
|
|
462
450
|
}) : never : never;
|
|
463
451
|
locale: Locale;
|
|
464
|
-
}
|
|
465
|
-
domain: AppDomains[number]["domain"];
|
|
466
|
-
} : {}), "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] ? {} : {
|
|
467
|
-
domain: AppDomains[number]["domain"];
|
|
468
|
-
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
452
|
+
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
469
453
|
};
|
|
@@ -330,11 +330,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
330
330
|
query?: import("../shared/utils.js").QueryParams;
|
|
331
331
|
}) : never : never;
|
|
332
332
|
locale: import("use-intl").Locale;
|
|
333
|
-
}
|
|
334
|
-
domain: AppDomains[number]["domain"];
|
|
335
|
-
} : {}), "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] ? {} : {
|
|
336
|
-
domain: AppDomains[number]["domain"];
|
|
337
|
-
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
333
|
+
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
338
334
|
permanentRedirect: (args: Omit<{
|
|
339
335
|
href: [AppPathnames] extends [never] ? string | {
|
|
340
336
|
pathname: string;
|
|
@@ -355,11 +351,7 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
355
351
|
query?: import("../shared/utils.js").QueryParams;
|
|
356
352
|
}) : never : never;
|
|
357
353
|
locale: import("use-intl").Locale;
|
|
358
|
-
}
|
|
359
|
-
domain: AppDomains[number]["domain"];
|
|
360
|
-
} : {}), "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] ? {} : {
|
|
361
|
-
domain: AppDomains[number]["domain"];
|
|
362
|
-
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
354
|
+
}, "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
363
355
|
getPathname: (args: {
|
|
364
356
|
href: [AppPathnames] extends [never] ? string | {
|
|
365
357
|
pathname: string;
|
|
@@ -380,7 +372,5 @@ export default function createNavigation<const AppLocales extends Locales, const
|
|
|
380
372
|
query?: import("../shared/utils.js").QueryParams;
|
|
381
373
|
}) : never : never;
|
|
382
374
|
locale: import("use-intl").Locale;
|
|
383
|
-
}
|
|
384
|
-
domain: AppDomains[number]["domain"];
|
|
385
|
-
} : {})) => string;
|
|
375
|
+
}) => string;
|
|
386
376
|
};
|
|
@@ -5,15 +5,7 @@ import type { InitializedLocaleCookieConfig } from '../../routing/config.js';
|
|
|
5
5
|
type NextLinkProps = Omit<ComponentProps<'a'>, keyof LinkProps> & Omit<LinkProps, 'locale'>;
|
|
6
6
|
type Props = NextLinkProps & {
|
|
7
7
|
locale?: Locale;
|
|
8
|
-
defaultLocale?: Locale;
|
|
9
8
|
localeCookie: InitializedLocaleCookieConfig;
|
|
10
|
-
/** Special case for `localePrefix: 'as-needed'` and `domains`. */
|
|
11
|
-
unprefixed?: {
|
|
12
|
-
domains: {
|
|
13
|
-
[domain: string]: Locale;
|
|
14
|
-
};
|
|
15
|
-
pathname: string;
|
|
16
|
-
};
|
|
17
9
|
};
|
|
18
10
|
declare const _default: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
19
11
|
export default _default;
|
|
@@ -335,19 +335,7 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
335
335
|
query?: QueryParams;
|
|
336
336
|
} : HrefOrHrefWithParams<keyof AppPathnames>;
|
|
337
337
|
locale: Locale;
|
|
338
|
-
}
|
|
339
|
-
/**
|
|
340
|
-
* 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.
|
|
341
|
-
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
342
|
-
*/
|
|
343
|
-
domain: AppDomains[number]["domain"];
|
|
344
|
-
} : {}), _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] ? {} : {
|
|
345
|
-
/**
|
|
346
|
-
* 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.
|
|
347
|
-
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
348
|
-
*/
|
|
349
|
-
domain: AppDomains[number]["domain"];
|
|
350
|
-
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
338
|
+
}, _forcePrefix?: boolean) => string>[0], "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
351
339
|
permanentRedirect: (args: Omit<Parameters<(args: {
|
|
352
340
|
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
353
341
|
href: [AppPathnames] extends [never] ? string | {
|
|
@@ -355,19 +343,7 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
355
343
|
query?: QueryParams;
|
|
356
344
|
} : HrefOrHrefWithParams<keyof AppPathnames>;
|
|
357
345
|
locale: Locale;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* 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.
|
|
361
|
-
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
362
|
-
*/
|
|
363
|
-
domain: AppDomains[number]["domain"];
|
|
364
|
-
} : {}), _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] ? {} : {
|
|
365
|
-
/**
|
|
366
|
-
* 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.
|
|
367
|
-
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
368
|
-
*/
|
|
369
|
-
domain: AppDomains[number]["domain"];
|
|
370
|
-
} : {}>, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
346
|
+
}, _forcePrefix?: boolean) => string>[0], "domain">, type?: import("next/navigation.js").RedirectType | undefined) => never;
|
|
371
347
|
getPathname: (args: Parameters<(args: {
|
|
372
348
|
/** @see https://next-intl.dev/docs/routing/navigation#getpathname */
|
|
373
349
|
href: [AppPathnames] extends [never] ? string | {
|
|
@@ -375,12 +351,6 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
375
351
|
query?: QueryParams;
|
|
376
352
|
} : HrefOrHrefWithParams<keyof AppPathnames>;
|
|
377
353
|
locale: Locale;
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* 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.
|
|
381
|
-
* @see https://next-intl.dev/docs/routing/navigation#getpathname
|
|
382
|
-
*/
|
|
383
|
-
domain: AppDomains[number]["domain"];
|
|
384
|
-
} : {}), _forcePrefix?: boolean) => string>[0]) => string;
|
|
354
|
+
}, _forcePrefix?: boolean) => string>[0]) => string;
|
|
385
355
|
};
|
|
386
356
|
export {};
|
|
@@ -49,6 +49,6 @@ export declare function compileLocalizedPathname<AppLocales extends Locales, Pat
|
|
|
49
49
|
}): UrlObject;
|
|
50
50
|
export declare function getRoute<AppLocales extends Locales>(locale: AppLocales[number], pathname: string, pathnames: Pathnames<AppLocales>): keyof Pathnames<AppLocales>;
|
|
51
51
|
export declare function getBasePath(pathname: string, windowPathname?: string): string;
|
|
52
|
-
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'>>,
|
|
52
|
+
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;
|
|
53
53
|
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;
|
|
54
54
|
export {};
|
|
@@ -17,8 +17,8 @@ export type DomainConfig<AppLocales extends Locales> = {
|
|
|
17
17
|
defaultLocale: AppLocales[number];
|
|
18
18
|
/** The domain name (e.g. "example.com", "www.example.com" or "fr.example.com"). Note that the `x-forwarded-host` or alternatively the `host` header will be used to determine the requested domain. */
|
|
19
19
|
domain: string;
|
|
20
|
-
/**
|
|
21
|
-
locales
|
|
20
|
+
/** The locales that are available on this domain. */
|
|
21
|
+
locales: Array<AppLocales[number]>;
|
|
22
22
|
};
|
|
23
23
|
export type DomainsConfig<AppLocales extends Locales> = Array<DomainConfig<AppLocales>>;
|
|
24
24
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.0.0-beta-
|
|
3
|
+
"version": "4.0.0-beta-021e874",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "4.0.0-beta-
|
|
115
|
+
"use-intl": "4.0.0-beta-021e874"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"optional": true
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "83ba4bf6a7655546f78853424e4f7497ed077a53"
|
|
128
128
|
}
|