next-intl 3.21.1 → 3.22.0-canary.0
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/development/middleware/middleware.js +11 -10
- package/dist/development/middleware/resolveLocale.js +2 -7
- package/dist/development/middleware/syncCookie.js +3 -2
- package/dist/development/navigation/react-client/ClientLink.js +2 -2
- package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +3 -0
- package/dist/development/navigation/react-client/createNavigation.js +83 -0
- package/dist/development/navigation/react-client/createSharedPathnamesNavigation.js +3 -0
- package/dist/development/navigation/react-client/useBasePathname.js +0 -14
- package/dist/development/navigation/react-server/ServerLink.js +4 -2
- package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +4 -4
- package/dist/development/navigation/react-server/createNavigation.js +30 -0
- package/dist/development/navigation/react-server/redirects.js +2 -2
- package/dist/development/navigation/shared/BaseLink.js +28 -25
- package/dist/development/navigation/shared/LegacyBaseLink.js +55 -0
- package/dist/development/navigation/shared/createSharedNavigationFns.js +147 -0
- package/dist/development/navigation/shared/redirects.js +3 -0
- package/dist/development/navigation/shared/utils.js +40 -1
- package/dist/development/navigation.react-client.js +2 -0
- package/dist/development/navigation.react-server.js +2 -0
- package/dist/development/react-client/index.js +0 -2
- package/dist/development/routing/config.js +1 -1
- package/dist/development/server/react-server/RequestLocale.js +15 -25
- package/dist/development/server/react-server/RequestLocaleCache.js +23 -0
- package/dist/development/server/react-server/RequestLocaleLegacy.js +43 -0
- package/dist/development/server/react-server/getConfig.js +15 -17
- package/dist/development/server/react-server/getRequestConfig.js +1 -1
- package/dist/development/server.react-server.js +2 -2
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/middleware/syncCookie.js +1 -1
- package/dist/esm/navigation/react-client/ClientLink.js +1 -1
- package/dist/esm/navigation/react-client/createNavigation.js +1 -0
- package/dist/esm/navigation/react-client/useBasePathname.js +0 -1
- package/dist/esm/navigation/react-server/ServerLink.js +1 -1
- package/dist/esm/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/createNavigation.js +1 -0
- package/dist/esm/navigation/react-server/redirects.js +1 -1
- package/dist/esm/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/navigation/shared/LegacyBaseLink.js +2 -0
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +1 -0
- package/dist/esm/navigation/shared/utils.js +1 -1
- package/dist/esm/navigation.react-client.js +1 -1
- package/dist/esm/navigation.react-server.js +1 -1
- package/dist/esm/routing/config.js +1 -1
- package/dist/esm/server/react-server/RequestLocale.js +1 -1
- package/dist/esm/server/react-server/RequestLocaleCache.js +1 -0
- package/dist/esm/server/react-server/RequestLocaleLegacy.js +1 -0
- package/dist/esm/server/react-server/getConfig.js +1 -1
- package/dist/esm/server.react-server.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/middleware/syncCookie.js +1 -1
- package/dist/production/navigation/react-client/ClientLink.js +1 -1
- package/dist/production/navigation/react-client/createNavigation.js +1 -0
- package/dist/production/navigation/react-client/useBasePathname.js +0 -1
- package/dist/production/navigation/react-server/ServerLink.js +1 -1
- package/dist/production/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/createNavigation.js +1 -0
- package/dist/production/navigation/react-server/redirects.js +1 -1
- package/dist/production/navigation/shared/BaseLink.js +1 -1
- package/dist/production/navigation/shared/LegacyBaseLink.js +2 -0
- package/dist/production/navigation/shared/createSharedNavigationFns.js +1 -0
- package/dist/production/navigation/shared/utils.js +1 -1
- package/dist/production/navigation.react-client.js +1 -1
- package/dist/production/navigation.react-server.js +1 -1
- package/dist/production/routing/config.js +1 -1
- package/dist/production/server/react-server/RequestLocale.js +1 -1
- package/dist/production/server/react-server/RequestLocaleCache.js +1 -0
- package/dist/production/server/react-server/RequestLocaleLegacy.js +1 -0
- package/dist/production/server/react-server/getConfig.js +1 -1
- package/dist/production/server.react-server.js +1 -1
- package/dist/types/src/middleware/config.d.ts +16 -2
- package/dist/types/src/middleware/getAlternateLinksHeaderValue.d.ts +3 -3
- package/dist/types/src/middleware/middleware.d.ts +2 -2
- package/dist/types/src/middleware/resolveLocale.d.ts +2 -2
- package/dist/types/src/middleware/syncCookie.d.ts +2 -1
- package/dist/types/src/middleware/utils.d.ts +4 -4
- package/dist/types/src/navigation/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-client/ClientLink.d.ts +6 -6
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +15 -4
- package/dist/types/src/navigation/react-client/createNavigation.d.ts +467 -0
- package/dist/types/src/navigation/react-client/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +7 -4
- package/dist/types/src/navigation/react-client/index.d.ts +1 -0
- package/dist/types/src/navigation/react-client/redirects.d.ts +4 -4
- package/dist/types/src/navigation/react-client/useBasePathname.d.ts +2 -15
- package/dist/types/src/navigation/react-client/useBaseRouter.d.ts +2 -2
- package/dist/types/src/navigation/react-server/ServerLink.d.ts +5 -5
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +12 -4
- package/dist/types/src/navigation/react-server/createNavigation.d.ts +385 -0
- package/dist/types/src/navigation/react-server/createNavigation.test.d.ts +1 -0
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +3 -3
- package/dist/types/src/navigation/react-server/index.d.ts +1 -0
- package/dist/types/src/navigation/react-server/redirects.d.ts +4 -4
- package/dist/types/src/navigation/shared/BaseLink.d.ts +11 -6
- package/dist/types/src/navigation/shared/LegacyBaseLink.d.ts +10 -0
- package/dist/types/src/navigation/shared/createSharedNavigationFns.d.ts +382 -0
- package/dist/types/src/navigation/shared/redirects.d.ts +5 -5
- package/dist/types/src/navigation/shared/utils.d.ts +10 -3
- package/dist/types/src/routing/config.d.ts +19 -11
- package/dist/types/src/routing/defineRouting.d.ts +2 -2
- package/dist/types/src/routing/types.d.ts +4 -4
- package/dist/types/src/server/react-server/RequestLocale.d.ts +1 -2
- package/dist/types/src/server/react-server/RequestLocaleCache.d.ts +2 -0
- package/dist/types/src/server/react-server/RequestLocaleLegacy.d.ts +1 -0
- package/dist/types/src/server/react-server/createRequestConfig.d.ts +2 -3
- package/dist/types/src/server/react-server/getRequestConfig.d.ts +32 -6
- package/dist/types/src/server/react-server/index.d.ts +1 -1
- package/dist/types/src/shared/types.d.ts +3 -0
- package/dist/types/src/shared/utils.d.ts +2 -2
- package/package.json +3 -3
|
@@ -7,8 +7,11 @@ var utils = require('../../shared/utils.js');
|
|
|
7
7
|
// Minor false positive: A route that has both optional and
|
|
8
8
|
// required params will allow optional params.
|
|
9
9
|
|
|
10
|
+
// For `Link`
|
|
11
|
+
|
|
12
|
+
// For `getPathname` (hence also its consumers: `redirect`, `useRouter`, …)
|
|
13
|
+
|
|
10
14
|
function normalizeNameOrNameWithParams(href) {
|
|
11
|
-
// @ts-expect-error -- `extends string` in the generic unfortunately weakens the type
|
|
12
15
|
return typeof href === 'string' ? {
|
|
13
16
|
pathname: href
|
|
14
17
|
} : href;
|
|
@@ -40,6 +43,7 @@ function compileLocalizedPathname(_ref) {
|
|
|
40
43
|
function getNamedPath(value) {
|
|
41
44
|
let namedPath = pathnames[value];
|
|
42
45
|
if (!namedPath) {
|
|
46
|
+
// Unknown pathnames
|
|
43
47
|
namedPath = value;
|
|
44
48
|
}
|
|
45
49
|
return namedPath;
|
|
@@ -118,9 +122,44 @@ function getBasePath(pathname) {
|
|
|
118
122
|
return windowPathname.replace(pathname, '');
|
|
119
123
|
}
|
|
120
124
|
}
|
|
125
|
+
function applyPathnamePrefix(pathname, locale, routing, domain, force) {
|
|
126
|
+
const {
|
|
127
|
+
mode
|
|
128
|
+
} = routing.localePrefix;
|
|
129
|
+
let shouldPrefix;
|
|
130
|
+
if (force !== undefined) {
|
|
131
|
+
shouldPrefix = force;
|
|
132
|
+
} else if (utils.isLocalizableHref(pathname)) {
|
|
133
|
+
if (mode === 'always') {
|
|
134
|
+
shouldPrefix = true;
|
|
135
|
+
} else if (mode === 'as-needed') {
|
|
136
|
+
let defaultLocale = routing.defaultLocale;
|
|
137
|
+
if (routing.domains) {
|
|
138
|
+
const domainConfig = routing.domains.find(cur => cur.domain === domain);
|
|
139
|
+
if (domainConfig) {
|
|
140
|
+
defaultLocale = domainConfig.defaultLocale;
|
|
141
|
+
} else {
|
|
142
|
+
if (!domain) {
|
|
143
|
+
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-docs.vercel.app/docs/routing#domains-localeprefix-asneeded");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
shouldPrefix = defaultLocale !== locale;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return shouldPrefix ? utils.prefixPathname(utils.getLocalePrefix(locale, routing.localePrefix), pathname) : pathname;
|
|
151
|
+
}
|
|
152
|
+
function validateReceivedConfig(config) {
|
|
153
|
+
var _config$localePrefix;
|
|
154
|
+
if (((_config$localePrefix = config.localePrefix) === null || _config$localePrefix === void 0 ? void 0 : _config$localePrefix.mode) === 'as-needed' && !('defaultLocale' in config)) {
|
|
155
|
+
throw new Error("`localePrefix: 'as-needed' requires a `defaultLocale`.");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
121
158
|
|
|
159
|
+
exports.applyPathnamePrefix = applyPathnamePrefix;
|
|
122
160
|
exports.compileLocalizedPathname = compileLocalizedPathname;
|
|
123
161
|
exports.getBasePath = getBasePath;
|
|
124
162
|
exports.getRoute = getRoute;
|
|
125
163
|
exports.normalizeNameOrNameWithParams = normalizeNameOrNameWithParams;
|
|
126
164
|
exports.serializeSearchParams = serializeSearchParams;
|
|
165
|
+
exports.validateReceivedConfig = validateReceivedConfig;
|
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var createSharedPathnamesNavigation = require('./navigation/react-client/createSharedPathnamesNavigation.js');
|
|
6
6
|
var createLocalizedPathnamesNavigation = require('./navigation/react-client/createLocalizedPathnamesNavigation.js');
|
|
7
|
+
var createNavigation = require('./navigation/react-client/createNavigation.js');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
|
|
11
12
|
exports.createLocalizedPathnamesNavigation = createLocalizedPathnamesNavigation.default;
|
|
13
|
+
exports.createNavigation = createNavigation.default;
|
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var createSharedPathnamesNavigation = require('./navigation/react-server/createSharedPathnamesNavigation.js');
|
|
6
6
|
var createLocalizedPathnamesNavigation = require('./navigation/react-server/createLocalizedPathnamesNavigation.js');
|
|
7
|
+
var createNavigation = require('./navigation/react-server/createNavigation.js');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
|
|
11
12
|
exports.createLocalizedPathnamesNavigation = createLocalizedPathnamesNavigation.default;
|
|
13
|
+
exports.createNavigation = createNavigation.default;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
function receiveRoutingConfig(input) {
|
|
6
6
|
return {
|
|
7
7
|
...input,
|
|
8
|
-
localePrefix: receiveLocalePrefixConfig(input.localePrefix)
|
|
8
|
+
localePrefix: receiveLocalePrefixConfig(input === null || input === void 0 ? void 0 : input.localePrefix)
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
function receiveLocalePrefixConfig(localePrefix) {
|
|
@@ -3,47 +3,37 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var headers = require('next/headers');
|
|
6
|
-
var navigation = require('next/navigation');
|
|
7
6
|
var React = require('react');
|
|
8
7
|
var constants = require('../../shared/constants.js');
|
|
8
|
+
var RequestLocaleCache = require('./RequestLocaleCache.js');
|
|
9
9
|
|
|
10
|
-
function
|
|
10
|
+
async function getHeadersImpl() {
|
|
11
|
+
const promiseOrValue = headers.headers();
|
|
12
|
+
|
|
13
|
+
// Compatibility with Next.js <15
|
|
14
|
+
return promiseOrValue instanceof Promise ? await promiseOrValue : promiseOrValue;
|
|
15
|
+
}
|
|
16
|
+
const getHeaders = React.cache(getHeadersImpl);
|
|
17
|
+
async function getLocaleFromHeaderImpl() {
|
|
11
18
|
let locale;
|
|
12
19
|
try {
|
|
13
|
-
locale =
|
|
20
|
+
locale = (await getHeaders()).get(constants.HEADER_LOCALE_NAME) || undefined;
|
|
14
21
|
} catch (error) {
|
|
15
22
|
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') {
|
|
16
|
-
|
|
23
|
+
const wrappedError = 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 `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering', {
|
|
17
24
|
cause: error
|
|
18
25
|
});
|
|
26
|
+
wrappedError.digest = error.digest;
|
|
27
|
+
throw wrappedError;
|
|
19
28
|
} else {
|
|
20
29
|
throw error;
|
|
21
30
|
}
|
|
22
31
|
}
|
|
23
|
-
if (!locale) {
|
|
24
|
-
{
|
|
25
|
-
console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n");
|
|
26
|
-
}
|
|
27
|
-
navigation.notFound();
|
|
28
|
-
}
|
|
29
32
|
return locale;
|
|
30
33
|
}
|
|
31
34
|
const getLocaleFromHeader = React.cache(getLocaleFromHeaderImpl);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function getCacheImpl() {
|
|
35
|
-
const value = {
|
|
36
|
-
locale: undefined
|
|
37
|
-
};
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
const getCache = React.cache(getCacheImpl);
|
|
41
|
-
function setRequestLocale(locale) {
|
|
42
|
-
getCache().locale = locale;
|
|
43
|
-
}
|
|
44
|
-
function getRequestLocale() {
|
|
45
|
-
return getCache().locale || getLocaleFromHeader();
|
|
35
|
+
async function getRequestLocale() {
|
|
36
|
+
return RequestLocaleCache.getCachedRequestLocale() || (await getLocaleFromHeader());
|
|
46
37
|
}
|
|
47
38
|
|
|
48
39
|
exports.getRequestLocale = getRequestLocale;
|
|
49
|
-
exports.setRequestLocale = setRequestLocale;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
// See https://github.com/vercel/next.js/discussions/58862
|
|
8
|
+
function getCacheImpl() {
|
|
9
|
+
const value = {
|
|
10
|
+
locale: undefined
|
|
11
|
+
};
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
const getCache = React.cache(getCacheImpl);
|
|
15
|
+
function getCachedRequestLocale() {
|
|
16
|
+
return getCache().locale;
|
|
17
|
+
}
|
|
18
|
+
function setCachedRequestLocale(locale) {
|
|
19
|
+
getCache().locale = locale;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.getCachedRequestLocale = getCachedRequestLocale;
|
|
23
|
+
exports.setCachedRequestLocale = setCachedRequestLocale;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var headers = require('next/headers');
|
|
6
|
+
var navigation = require('next/navigation');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var constants = require('../../shared/constants.js');
|
|
9
|
+
var RequestLocaleCache = require('./RequestLocaleCache.js');
|
|
10
|
+
|
|
11
|
+
// This was originally built for Next.js <14, where `headers()` was not async.
|
|
12
|
+
// With https://github.com/vercel/next.js/pull/68812, the API became async.
|
|
13
|
+
// This file can be removed once we remove the legacy navigation APIs.
|
|
14
|
+
function getHeaders() {
|
|
15
|
+
return headers.headers();
|
|
16
|
+
}
|
|
17
|
+
function getLocaleFromHeaderImpl() {
|
|
18
|
+
let locale;
|
|
19
|
+
try {
|
|
20
|
+
locale = getHeaders().get(constants.HEADER_LOCALE_NAME);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error instanceof Error && error.digest === 'DYNAMIC_SERVER_USAGE') {
|
|
23
|
+
throw 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 `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering', {
|
|
24
|
+
cause: error
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (!locale) {
|
|
31
|
+
{
|
|
32
|
+
console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n");
|
|
33
|
+
}
|
|
34
|
+
navigation.notFound();
|
|
35
|
+
}
|
|
36
|
+
return locale;
|
|
37
|
+
}
|
|
38
|
+
const getLocaleFromHeader = React.cache(getLocaleFromHeaderImpl);
|
|
39
|
+
function getRequestLocale() {
|
|
40
|
+
return RequestLocaleCache.getCachedRequestLocale() || getLocaleFromHeader();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.getRequestLocale = getRequestLocale;
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var navigation = require('next/navigation');
|
|
5
6
|
var React = require('react');
|
|
6
7
|
var core = require('use-intl/core');
|
|
7
8
|
var RequestLocale = require('./RequestLocale.js');
|
|
9
|
+
var RequestLocaleLegacy = require('./RequestLocaleLegacy.js');
|
|
8
10
|
var getRuntimeConfig = require('next-intl/config');
|
|
9
11
|
|
|
10
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -27,35 +29,31 @@ async function receiveRuntimeConfigImpl(getConfig, localeOverride) {
|
|
|
27
29
|
if (typeof getConfig !== 'function') {
|
|
28
30
|
throw new Error("Invalid i18n request configuration detected.\n\nPlease verify that:\n1. In case you've specified a custom location in your Next.js config, make sure that the path is correct.\n2. You have a default export in your i18n request configuration file.\n\nSee also: https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request\n");
|
|
29
31
|
}
|
|
30
|
-
let hasReadLocale = false;
|
|
31
|
-
|
|
32
|
-
// In case the consumer doesn't read `params.locale` and instead provides the
|
|
33
|
-
// `locale` (either in a single-language workflow or because the locale is
|
|
34
|
-
// read from the user settings), don't attempt to read the request locale.
|
|
35
32
|
const params = {
|
|
33
|
+
// In case the consumer doesn't read `params.locale` and instead provides the
|
|
34
|
+
// `locale` (either in a single-language workflow or because the locale is
|
|
35
|
+
// read from the user settings), don't attempt to read the request locale.
|
|
36
36
|
get locale() {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
return localeOverride || RequestLocaleLegacy.getRequestLocale();
|
|
38
|
+
},
|
|
39
|
+
get requestLocale() {
|
|
40
|
+
return localeOverride ? Promise.resolve(localeOverride) : RequestLocale.getRequestLocale();
|
|
39
41
|
}
|
|
40
42
|
};
|
|
41
43
|
let result = getConfig(params);
|
|
42
44
|
if (result instanceof Promise) {
|
|
43
45
|
result = await result;
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
} else {
|
|
51
|
-
if (!result.locale) {
|
|
52
|
-
console.error("\nYou haven't read the `locale` param that was passed to `getRequestConfig` and also haven't returned one from the function. This is likely an error, please ensure that you're consistently using a setup with or without i18n routing: https://next-intl-docs.vercel.app/docs/getting-started/app-router\n");
|
|
53
|
-
}
|
|
47
|
+
const locale = result.locale || (await params.requestLocale);
|
|
48
|
+
if (!locale) {
|
|
49
|
+
{
|
|
50
|
+
console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request and no `locale` was returned in `getRequestConfig`. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n");
|
|
54
51
|
}
|
|
52
|
+
navigation.notFound();
|
|
55
53
|
}
|
|
56
54
|
return {
|
|
57
55
|
...result,
|
|
58
|
-
locale
|
|
56
|
+
locale,
|
|
59
57
|
now: result.now || getDefaultNow(),
|
|
60
58
|
timeZone: result.timeZone || getDefaultTimeZone()
|
|
61
59
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Should be called in `i18n.ts` to create the configuration for the current request.
|
|
6
|
+
* Should be called in `i18n/request.ts` to create the configuration for the current request.
|
|
7
7
|
*/
|
|
8
8
|
function getRequestConfig(createRequestConfig) {
|
|
9
9
|
return createRequestConfig;
|
|
@@ -9,7 +9,7 @@ var getNow = require('./server/react-server/getNow.js');
|
|
|
9
9
|
var getTimeZone = require('./server/react-server/getTimeZone.js');
|
|
10
10
|
var getTranslations = require('./server/react-server/getTranslations.js');
|
|
11
11
|
var getLocale = require('./server/react-server/getLocale.js');
|
|
12
|
-
var
|
|
12
|
+
var RequestLocaleCache = require('./server/react-server/RequestLocaleCache.js');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
@@ -20,4 +20,4 @@ exports.getNow = getNow.default;
|
|
|
20
20
|
exports.getTimeZone = getTimeZone.default;
|
|
21
21
|
exports.getTranslations = getTranslations.default;
|
|
22
22
|
exports.getLocale = getLocale.default;
|
|
23
|
-
exports.unstable_setRequestLocale =
|
|
23
|
+
exports.unstable_setRequestLocale = RequestLocaleCache.setCachedRequestLocale;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as l}from"../routing/config.js";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as t,normalizeTrailingSlash as
|
|
1
|
+
import{NextResponse as e}from"next/server";import{receiveRoutingConfig as l}from"../routing/config.js";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as t,normalizeTrailingSlash as n,getLocalePrefix as r}from"../shared/utils.js";import a from"./getAlternateLinksHeaderValue.js";import i from"./resolveLocale.js";import s from"./syncCookie.js";import{sanitizePathname as c,isLocaleSupportedOnDomain as d,getNormalizedPathname as f,getPathnameMatch as u,getInternalTemplate as m,formatTemplatePathname as h,formatPathname as x,getBestMatchingDomain as v,applyBasePath as p,getLocaleAsPrefix as U}from"./utils.js";function P(P,k){var L,g,j,w,C,b;const y=l(P),D={alternateLinks:null===(L=null!==(g=null==k?void 0:k.alternateLinks)&&void 0!==g?g:P.alternateLinks)||void 0===L||L,localeDetection:null===(j=null!==(w=null==k?void 0:k.localeDetection)&&void 0!==w?w:null==P?void 0:P.localeDetection)||void 0===j||j,localeCookie:null===(C=null!==(b=null==k?void 0:k.localeCookie)&&void 0!==b?b:null==P?void 0:P.localeCookie)||void 0===C||C};return function(l){var P;let k;try{k=decodeURI(l.nextUrl.pathname)}catch(l){return e.next()}const L=c(k),{domain:g,locale:j}=i(y,D,l.headers,l.cookies,L),w=g?g.defaultLocale===j:j===y.defaultLocale,C=(null===(P=y.domains)||void 0===P?void 0:P.filter((e=>d(j,e))))||[],b=null!=y.domains&&!g;function R(t){const n=new URL(t,l.url);l.nextUrl.basePath&&(n.pathname=p(n.pathname,l.nextUrl.basePath));const r=new Headers(l.headers);return r.set(o,j),e.rewrite(n,{request:{headers:r}})}function q(o,t){const r=new URL(n(o),l.url);if(C.length>0&&!t&&g){const e=v(g,j,C);e&&(t=e.domain,e.defaultLocale===j&&"as-needed"===y.localePrefix.mode&&(r.pathname=f(r.pathname,y.locales,y.localePrefix)))}var a,i;t&&(r.host=t,l.headers.get("x-forwarded-host")&&(r.protocol=null!==(a=l.headers.get("x-forwarded-proto"))&&void 0!==a?a:l.nextUrl.protocol,r.port=null!==(i=l.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return l.nextUrl.basePath&&(r.pathname=p(r.pathname,l.nextUrl.basePath)),e.redirect(r.toString())}const H=f(L,y.locales,y.localePrefix),z=u(L,y.locales,y.localePrefix),A=null!=z,I="never"===y.localePrefix.mode||w&&"as-needed"===y.localePrefix.mode;let S,V,B=H;const E=y.pathnames;if(E){let e;if([e,V]=m(E,H,j),V){const o=E[V],n="string"==typeof o?o:o[j];if(t(n,H))B=h(H,n,V);else{let t;t=e?"string"==typeof o?o:o[e]:V;const a=I?void 0:r(j,y.localePrefix),i=h(H,t,n);S=q(x(i,a,l.nextUrl.search))}}}if(!S)if("/"!==B||A){const e=x(B,U(j),l.nextUrl.search);if(A){const o=x(H,z.prefix,l.nextUrl.search);if("never"===y.localePrefix.mode)S=q(x(H,void 0,l.nextUrl.search));else if(z.exact)if(w&&I)S=q(x(H,void 0,l.nextUrl.search));else if(y.domains){const l=v(g,z.locale,C);S=(null==g?void 0:g.domain)===(null==l?void 0:l.domain)||b?R(e):q(o,null==l?void 0:l.domain)}else S=R(e);else S=q(o)}else S=I?R(e):q(x(H,r(j,y.localePrefix),l.nextUrl.search))}else S=I?R(x(B,U(j),l.nextUrl.search)):q(x(H,r(j,y.localePrefix),l.nextUrl.search));return D.localeDetection&&D.localeCookie&&s(l,S,j,D.localeCookie),"never"!==y.localePrefix.mode&&D.alternateLinks&&y.locales.length>1&&S.headers.set("Link",a({routing:y,localizedPathnames:null!=V&&E?null==E?void 0:E[V]:void 0,request:l,resolvedLocale:j})),S}}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as
|
|
1
|
+
import{match as o}from"@formatjs/intl-localematcher";import e from"negotiator";import{COOKIE_LOCALE_NAME as l}from"../shared/constants.js";import{getPathnameMatch as t,isLocaleSupportedOnDomain as n,getHost as a}from"./utils.js";function c(l,t,n){let a;const c=new e({headers:{"accept-language":l.get("accept-language")||void 0}}).languages();try{const e=function(o){return o.slice().sort(((o,e)=>e.length-o.length))}(t);a=o(c,e,n)}catch(o){}return a}function i(o,e){if(o.has(l)){var t;const n=null===(t=o.get(l))||void 0===t?void 0:t.value;if(n&&e.includes(n))return n}}function r(o,e,l,n,a){let r,{defaultLocale:s,localePrefix:u,locales:f}=o,{localeDetection:d}=e;var m;a&&(r=null===(m=t(a,f,u))||void 0===m?void 0:m.locale);return!r&&d&&n&&(r=i(n,f)),!r&&d&&l&&(r=c(l,f,s)),r||(r=s),r}function s(o,e,l,s,u){const f=function(o,e){const l=a(o);if(l&&e)return e.find((o=>o.domain===l))}(l,o.domains);if(!f)return{locale:r(o,e,l,s,u)};let d;if(u){var m;const e=null===(m=t(u,o.locales,o.localePrefix))||void 0===m?void 0:m.locale;if(e){if(!n(e,f))return{locale:e,domain:f};d=e}}if(!d&&e.localeDetection&&s){const e=i(s,o.locales);e&&n(e,f)&&(d=e)}if(!d&&e.localeDetection&&l){const e=c(l,f.locales||o.locales,f.defaultLocale);e&&(d=e)}return d||(d=f.defaultLocale),{locale:d,domain:f}}function u(o,e,l,t,n){return o.domains?s(o,e,l,t,n):{locale:r(o,e,l,t,n)}}export{u as default,c as getAcceptLanguageLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COOKIE_LOCALE_NAME as e,COOKIE_SAME_SITE as o,COOKIE_MAX_AGE as t}from"../shared/constants.js";function a(a,s,i){var
|
|
1
|
+
import{COOKIE_LOCALE_NAME as e,COOKIE_SAME_SITE as o,COOKIE_MAX_AGE as t}from"../shared/constants.js";function a(a,s,i,n){var r;(null===(r=a.cookies.get(e))||void 0===r?void 0:r.value)!==i&&s.cookies.set(e,i,{path:a.nextUrl.basePath||void 0,sameSite:o,maxAge:t,..."object"==typeof n&&n})}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as l}from"react";import o from"../../react-client/useLocale.js";import{getLocalePrefix as t}from"../../shared/utils.js";import a from"../shared/
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as l}from"react";import o from"../../react-client/useLocale.js";import{getLocalePrefix as t}from"../../shared/utils.js";import a from"../shared/LegacyBaseLink.js";function i(l,i){let{locale:s,localePrefix:c,...m}=l;const n=o(),f=s||n,p=t(f,c);return r.createElement(a,e({ref:i,locale:f,localePrefixMode:c.mode,prefix:p},m))}const s=l(i);s.displayName="ClientLink";export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRouter as e,usePathname as t}from"next/navigation";import{useMemo as n}from"react";import o from"../../react-client/useLocale.js";import r from"../shared/createSharedNavigationFns.js";import a from"../shared/syncLocaleCookie.js";import{getRoute as s}from"../shared/utils.js";import c from"./useBasePathname.js";function i(i){function u(){return o()}const{Link:m,config:f,getPathname:h,...p}=r(u,i);return{...p,Link:m,usePathname:function(){const e=c(f.localePrefix),t=u();return n((()=>e&&f.pathnames?s(t,e,f.pathnames):e),[t,e])},useRouter:function(){const o=e(),r=u(),s=t();return n((()=>{function e(e){return function(t,n){const{locale:o,...c}=n||{},i=[h({href:t,locale:o||r,domain:window.location.host})];Object.keys(c).length>0&&i.push(c),e(...i),a(s,r,o)}}return{...o,push:e(o.push),replace:e(o.replace),prefetch:e(o.prefetch)}}),[r,s,o])},getPathname:h}}export{i as default};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import{usePathname as r}from"next/navigation";import{useMemo as t}from"react";import o from"../../react-client/useLocale.js";import{hasPathnamePrefixed as e,unprefixPathname as n,getLocalePrefix as i}from"../../shared/utils.js";function a(a){const m=r(),s=o();return t((()=>{if(!m)return m;const r=i(s,a);return e(r,m)?n(m,r):m}),[s,a,m])}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getLocalePrefix as o}from"../../shared/utils.js";import
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getLocalePrefix as o}from"../../shared/utils.js";import a from"../shared/LegacyBaseLink.js";import t from"../../server/react-server/getLocale.js";async function l(l){let{locale:s,localePrefix:i,...c}=l;const m=s||await t(),f=o(m,i);return r.createElement(a,e({locale:m,localePrefixMode:i.mode,prefix:f},c))}export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import{getRequestLocale as o}from"../../server/react-server/
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{receiveRoutingConfig as t}from"../../routing/config.js";import{getRequestLocale as o}from"../../server/react-server/RequestLocaleLegacy.js";import{compileLocalizedPathname as n,normalizeNameOrNameWithParams as a}from"../shared/utils.js";import l from"./ServerLink.js";import{serverRedirect as c,serverPermanentRedirect as i}from"./redirects.js";function s(s){const m=t(s);function f(e){let{href:r,locale:t}=e;return n({...a(r),locale:t,pathnames:m.pathnames})}function u(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(t){let{href:a,locale:c,...i}=t;const s=o(),f=c||s;return r.createElement(l,e({href:n({locale:f,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:m.pathnames}),locale:c,localePrefix:m.localePrefix},i))},redirect:function(e){const r=f({href:e,locale:o()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return c({localePrefix:m.localePrefix,pathname:r},...n)},permanentRedirect:function(e){const r=f({href:e,locale:o()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return i({localePrefix:m.localePrefix,pathname:r},...n)},getPathname:f,usePathname:u("usePathname"),useRouter:u("useRouter")}}export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getRequestLocale as e}from"../../server/react-server/RequestLocale.js";import o from"../shared/createSharedNavigationFns.js";function t(t){const{config:n,...r}=o((function(){return e()}),t);function s(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the calling component to a Client Component."))}}return{...r,usePathname:s("usePathname"),useRouter:s("useRouter")}}export{t as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getRequestLocale as r}from"../../server/react-server/
|
|
1
|
+
import{getRequestLocale as r}from"../../server/react-server/RequestLocaleLegacy.js";import{baseRedirect as e,basePermanentRedirect as t}from"../shared/redirects.js";function o(e){return function(t){const o=r();for(var n=arguments.length,c=new Array(n>1?n-1:0),s=1;s<n;s++)c[s-1]=arguments[s];return e({...t,locale:o},...c)}}const n=o(e),c=o(t);export{c as serverPermanentRedirect,n as serverRedirect};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import o from"next/link";import{usePathname as
|
|
2
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import o from"next/link";import{usePathname as t}from"next/navigation";import r,{forwardRef as n,useState as i,useEffect as c}from"react";import l from"../../react-client/useLocale.js";import a from"./syncLocaleCookie.js";function s(n,s){let{defaultLocale:p,href:f,locale:m,onClick:u,prefetch:h,unprefixed:d,...k}=n;const x=l(),L=m!==x,g=m||x,j=function(){const[e,o]=i();return c((()=>{o(window.location.host)}),[]),e}(),v=j&&d&&(d.domains[j]===g||!Object.keys(d.domains).includes(j)&&x===p&&!m)?d.pathname:f,w=t();return L&&(h&&console.error("The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`"),h=!1),r.createElement(o,e({ref:s,href:v,hrefLang:L?m:void 0,onClick:function(e){a(w,x,m),u&&u(e)},prefetch:h},k))}var p=n(s);export{p as default};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{usePathname as r}from"next/navigation";import t,{forwardRef as o,useState as l,useEffect as i}from"react";import a from"../../react-client/useLocale.js";import{isLocalizableHref as n,prefixHref as s,localizeHref as m}from"../../shared/utils.js";import f from"./BaseLink.js";function c(o,c){let{href:p,locale:u,localePrefixMode:d,prefix:x,...j}=o;const h=r(),v=a(),L=u!==v,[g,k]=l((()=>n(p)&&("never"!==d||L)?s(p,x):p));return i((()=>{h&&k(m(p,u,v,h,x))}),[v,p,u,h,x]),t.createElement(f,e({ref:c,href:g,locale:u},j))}const p=o(c);p.displayName="ClientLink";export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import{redirect as t,permanentRedirect as a}from"next/navigation";import o,{forwardRef as n,use as r}from"react";import{receiveRoutingConfig as l}from"../../routing/config.js";import{isLocalizableHref as i}from"../../shared/utils.js";import m from"./BaseLink.js";import{validateReceivedConfig as c,serializeSearchParams as f,compileLocalizedPathname as s,applyPathnamePrefix as u,normalizeNameOrNameWithParams as p}from"./utils.js";function d(d,h){const j=l(h||{});c(j);const g=j.pathnames,v="as-needed"===j.localePrefix.mode&&j.domains||void 0;function y(t,a){let n,l,{href:c,locale:f,...s}=t;"object"==typeof c?(n=c.pathname,l=c.params):n=c;const u=i(c),p=d(),h=p instanceof Promise?r(p):p,y=u?L({locale:f||h,href:null==g?n:{pathname:n,params:l}},null!=f||v||void 0):n;return o.createElement(m,e({ref:a,defaultLocale:j.defaultLocale,href:{..."object"==typeof c&&c,pathname:y},locale:f,unprefixed:v&&u?{domains:j.domains.reduce(((e,t)=>(e[t.domain]=t.defaultLocale,e)),{}),pathname:L({locale:h,href:null==g?n:{pathname:n,params:l}},!1)}:void 0},s))}const x=n(y);function L(e,t){const{href:a,locale:o}=e;let n;return null==g?"object"==typeof a?(n=a.pathname,a.query&&(n+=f(a.query))):n=a:n=s({locale:o,...p(a),pathnames:j.pathnames}),u(n,o,j,e.domain,t)}function b(e){return function(t){for(var a=arguments.length,o=new Array(a>1?a-1:0),n=1;n<a;n++)o[n-1]=arguments[n];return e(L(t,t.domain?void 0:v),...o)}}const P=b(t),k=b(a);return{config:j,Link:x,redirect:P,permanentRedirect:k,getPathname:L}}export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSortedPathnames as
|
|
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 c(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 s(e){let{pathname:n,locale:t,params:r,pathnames:o,query:i}=e;function s(e){let n=o[e];return n||(n=e),n}function f(e){const n="string"==typeof e?e:e[t];let o=n;if(r&&Object.entries(r).forEach((e=>{let n,t,[r,a]=e;Array.isArray(a)?(n="(\\[)?\\[...".concat(r,"\\](\\])?"),t=a.map((e=>String(e))).join("/")):(n="\\[".concat(r,"\\]"),t=String(a)),o=o.replace(new RegExp(n,"g"),t)})),o=o.replace(/\[\[\.\.\..+\]\]/g,""),o=a(o),o.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(r)));return i&&(o+=c(i)),o}if("string"==typeof n){return f(s(n))}{const{pathname:e,...t}=n;return{...t,pathname:f(s(e))}}}function f(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 l(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===e?n:n.replace(e,"")}function d(e,n,a,i,c){const{mode:s}=a.localePrefix;let f;if(void 0!==c)f=c;else if(t(e))if("always"===s)f=!0;else if("as-needed"===s){let e=a.defaultLocale;if(a.domains){const n=a.domains.find((e=>e.domain===i));n?e=n.defaultLocale:i||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-docs.vercel.app/docs/routing#domains-localeprefix-asneeded")}f=e!==n}return f?r(o(n,a.localePrefix),e):e}function u(e){var n;if("as-needed"===(null===(n=e.localePrefix)||void 0===n?void 0:n.mode)&&!("defaultLocale"in e))throw new Error("`localePrefix: 'as-needed' requires a `defaultLocale`.")}export{d as applyPathnamePrefix,s as compileLocalizedPathname,l as getBasePath,f as getRoute,i as normalizeNameOrNameWithParams,c as serializeSearchParams,u as validateReceivedConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as createSharedPathnamesNavigation}from"./navigation/react-client/createSharedPathnamesNavigation.js";export{default as createLocalizedPathnamesNavigation}from"./navigation/react-client/createLocalizedPathnamesNavigation.js";
|
|
1
|
+
export{default as createSharedPathnamesNavigation}from"./navigation/react-client/createSharedPathnamesNavigation.js";export{default as createLocalizedPathnamesNavigation}from"./navigation/react-client/createLocalizedPathnamesNavigation.js";export{default as createNavigation}from"./navigation/react-client/createNavigation.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as createSharedPathnamesNavigation}from"./navigation/react-server/createSharedPathnamesNavigation.js";export{default as createLocalizedPathnamesNavigation}from"./navigation/react-server/createLocalizedPathnamesNavigation.js";
|
|
1
|
+
export{default as createSharedPathnamesNavigation}from"./navigation/react-server/createSharedPathnamesNavigation.js";export{default as createLocalizedPathnamesNavigation}from"./navigation/react-server/createLocalizedPathnamesNavigation.js";export{default as createNavigation}from"./navigation/react-server/createNavigation.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return{...e,localePrefix:o(e.localePrefix)}}function o(e){return"object"==typeof e?e:{mode:e||"always"}}export{o as receiveLocalePrefixConfig,e as receiveRoutingConfig};
|
|
1
|
+
function e(e){return{...e,localePrefix:o(null==e?void 0:e.localePrefix)}}function o(e){return"object"==typeof e?e:{mode:e||"always"}}export{o as receiveLocalePrefixConfig,e as receiveRoutingConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{headers as
|
|
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 s=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 `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:t});throw e.digest=t.digest,e}throw t}return t}));async function i(){return r()||await s()}export{i as getRequestLocale};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cache as o}from"react";const n=o((function(){return{locale:void 0}}));function t(){return n().locale}function c(o){n().locale=o}export{t as getCachedRequestLocale,c as setCachedRequestLocale};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{headers as e}from"next/headers";import{notFound as t}from"next/navigation";import{cache as n}from"react";import{HEADER_LOCALE_NAME as o}from"../../shared/constants.js";import{getCachedRequestLocale as r}from"./RequestLocaleCache.js";const i=n((function(){let n;try{n=e().get(o)}catch(e){throw e instanceof Error&&"DYNAMIC_SERVER_USAGE"===e.digest?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 `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:e}):e}return n||(console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n"),t()),n}));function s(){return r()||i()}export{s as getRequestLocale};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{notFound as e}from"next/navigation";import{cache as t}from"react";import{_createIntlFormatters as n,_createCache as o,initializeConfig as r}from"use-intl/core";import{getRequestLocale as i}from"./RequestLocale.js";import{getRequestLocale as a}from"./RequestLocaleLegacy.js";import s from"next-intl/config";const c=t((function(){return new Date}));const l=t((function(){return Intl.DateTimeFormat().resolvedOptions().timeZone}));const u=t((async function(t,n){if("function"!=typeof t)throw new Error("Invalid i18n request configuration detected.\n\nPlease verify that:\n1. In case you've specified a custom location in your Next.js config, make sure that the path is correct.\n2. You have a default export in your i18n request configuration file.\n\nSee also: https://next-intl-docs.vercel.app/docs/usage/configuration#i18n-request\n");const o={get locale(){return n||a()},get requestLocale(){return n?Promise.resolve(n):i()}};let r=t(o);r instanceof Promise&&(r=await r);const s=r.locale||await o.requestLocale;return s||(console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request and no `locale` was returned in `getRequestConfig`. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n"),e()),{...r,locale:s,now:r.now||c(),timeZone:r.timeZone||l()}})),f=t(n),m=t(o);const d=t((async function(e){const t=await u(s,e);return{...r(t),_formatters:f(m())}}));export{d as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{default as getRequestConfig}from"./server/react-server/getRequestConfig.js";export{default as getFormatter}from"./server/react-server/getFormatter.js";export{default as getMessages}from"./server/react-server/getMessages.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 getLocale}from"./server/react-server/getLocale.js";export{
|
|
1
|
+
export{default as getRequestConfig}from"./server/react-server/getRequestConfig.js";export{default as getFormatter}from"./server/react-server/getFormatter.js";export{default as getMessages}from"./server/react-server/getMessages.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 getLocale}from"./server/react-server/getLocale.js";export{setCachedRequestLocale as unstable_setRequestLocale}from"./server/react-server/RequestLocaleCache.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../routing/config.js"),t=require("../shared/constants.js"),l=require("../shared/utils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../routing/config.js"),t=require("../shared/constants.js"),l=require("../shared/utils.js"),o=require("./getAlternateLinksHeaderValue.js"),n=require("./resolveLocale.js"),r=require("./syncCookie.js"),i=require("./utils.js");exports.default=function(s,c){var d,u,f,h,m,x;const P=a.receiveRoutingConfig(s),v={alternateLinks:null===(d=null!==(u=null==c?void 0:c.alternateLinks)&&void 0!==u?u:s.alternateLinks)||void 0===d||d,localeDetection:null===(f=null!==(h=null==c?void 0:c.localeDetection)&&void 0!==h?h:null==s?void 0:s.localeDetection)||void 0===f||f,localeCookie:null===(m=null!==(x=null==c?void 0:c.localeCookie)&&void 0!==x?x:null==s?void 0:s.localeCookie)||void 0===m||m};return function(a){var s;let c;try{c=decodeURI(a.nextUrl.pathname)}catch(a){return e.NextResponse.next()}const d=i.sanitizePathname(c),{domain:u,locale:f}=n.default(P,v,a.headers,a.cookies,d),h=u?u.defaultLocale===f:f===P.defaultLocale,m=(null===(s=P.domains)||void 0===s?void 0:s.filter((e=>i.isLocaleSupportedOnDomain(f,e))))||[],x=null!=P.domains&&!u;function p(l){const o=new URL(l,a.url);a.nextUrl.basePath&&(o.pathname=i.applyBasePath(o.pathname,a.nextUrl.basePath));const n=new Headers(a.headers);return n.set(t.HEADER_LOCALE_NAME,f),e.NextResponse.rewrite(o,{request:{headers:n}})}function g(t,o){const n=new URL(l.normalizeTrailingSlash(t),a.url);if(m.length>0&&!o&&u){const e=i.getBestMatchingDomain(u,f,m);e&&(o=e.domain,e.defaultLocale===f&&"as-needed"===P.localePrefix.mode&&(n.pathname=i.getNormalizedPathname(n.pathname,P.locales,P.localePrefix)))}var r,s;o&&(n.host=o,a.headers.get("x-forwarded-host")&&(n.protocol=null!==(r=a.headers.get("x-forwarded-proto"))&&void 0!==r?r:a.nextUrl.protocol,n.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(n.pathname=i.applyBasePath(n.pathname,a.nextUrl.basePath)),e.NextResponse.redirect(n.toString())}const L=i.getNormalizedPathname(d,P.locales,P.localePrefix),U=i.getPathnameMatch(d,P.locales,P.localePrefix),k=null!=U,q="never"===P.localePrefix.mode||h&&"as-needed"===P.localePrefix.mode;let j,C,D=L;const R=P.pathnames;if(R){let e;if([e,C]=i.getInternalTemplate(R,L,f),C){const t=R[C],o="string"==typeof t?t:t[f];if(l.matchesPathname(o,L))D=i.formatTemplatePathname(L,o,C);else{let n;n=e?"string"==typeof t?t:t[e]:C;const r=q?void 0:l.getLocalePrefix(f,P.localePrefix),s=i.formatTemplatePathname(L,n,o);j=g(i.formatPathname(s,r,a.nextUrl.search))}}}if(!j)if("/"!==D||k){const e=i.formatPathname(D,i.getLocaleAsPrefix(f),a.nextUrl.search);if(k){const t=i.formatPathname(L,U.prefix,a.nextUrl.search);if("never"===P.localePrefix.mode)j=g(i.formatPathname(L,void 0,a.nextUrl.search));else if(U.exact)if(h&&q)j=g(i.formatPathname(L,void 0,a.nextUrl.search));else if(P.domains){const a=i.getBestMatchingDomain(u,U.locale,m);j=(null==u?void 0:u.domain)===(null==a?void 0:a.domain)||x?p(e):g(t,null==a?void 0:a.domain)}else j=p(e);else j=g(t)}else j=q?p(e):g(i.formatPathname(L,l.getLocalePrefix(f,P.localePrefix),a.nextUrl.search))}else j=q?p(i.formatPathname(D,i.getLocaleAsPrefix(f),a.nextUrl.search)):g(i.formatPathname(L,l.getLocalePrefix(f,P.localePrefix),a.nextUrl.search));return v.localeDetection&&v.localeCookie&&r.default(a,j,f,v.localeCookie),"never"!==P.localePrefix.mode&&v.alternateLinks&&P.locales.length>1&&j.headers.set("Link",o.default({routing:P,localizedPathnames:null!=C&&R?null==R?void 0:R[C]:void 0,request:a,resolvedLocale:f})),j}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),o=require("../shared/constants.js"),a=require("./utils.js");function l(e){return e&&e.__esModule?e:{default:e}}var n=l(t);function c(t,o,a){let l;const c=new n.default({headers:{"accept-language":t.get("accept-language")||void 0}}).languages();try{const t=function(e){return e.slice().sort(((e,t)=>t.length-e.length))}(o);l=e.match(c,t,a)}catch(e){}return l}function i(e,t){if(e.has(o.COOKIE_LOCALE_NAME)){var a;const l=null===(a=e.get(o.COOKIE_LOCALE_NAME))||void 0===a?void 0:a.value;if(l&&t.includes(l))return l}}function r(e,t,o,l,n){let r,{defaultLocale:u,localePrefix:s,locales:f}=e,{localeDetection:d}=t;var g;n&&(r=null===(g=a.getPathnameMatch(n,f,s))||void 0===g?void 0:g.locale);return!r&&d&&l&&(r=i(l,f)),!r&&d&&o&&(r=c(o,f,u)),r||(r=u),r}function u(e,t,o,l,n){const u=function(e,t){const o=a.getHost(e);if(o&&t)return t.find((e=>e.domain===o))}(o,e.domains);if(!u)return{locale:r(e,t,o,l,n)};let s;if(n){var f;const t=null===(f=a.getPathnameMatch(n,e.locales,e.localePrefix))||void 0===f?void 0:f.locale;if(t){if(!a.isLocaleSupportedOnDomain(t,u))return{locale:t,domain:u};s=t}}if(!s&&t.localeDetection&&l){const t=i(l,e.locales);t&&a.isLocaleSupportedOnDomain(t,u)&&(s=t)}if(!s&&t.localeDetection&&o){const t=c(o,u.locales||e.locales,u.defaultLocale);t&&(s=t)}return s||(s=u.defaultLocale),{locale:s,domain:u}}exports.default=function(e,t,o,a,l){return e.domains?u(e,t,o,a,l):{locale:r(e,t,o,a,l)}},exports.getAcceptLanguageLocale=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/constants.js");exports.default=function(t,s,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/constants.js");exports.default=function(t,o,s,a){var r;(null===(r=t.cookies.get(e.COOKIE_LOCALE_NAME))||void 0===r?void 0:r.value)!==s&&o.cookies.set(e.COOKIE_LOCALE_NAME,s,{path:t.nextUrl.basePath||void 0,sameSite:e.COOKIE_SAME_SITE,maxAge:e.COOKIE_MAX_AGE,..."object"==typeof a&&a})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),l=require("../../react-client/useLocale.js"),t=require("../../shared/utils.js"),a=require("../shared/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),l=require("../../react-client/useLocale.js"),t=require("../../shared/utils.js"),a=require("../shared/LegacyBaseLink.js");function u(e){return e&&e.__esModule?e:{default:e}}var i=u(r);function s(r,u){let{locale:s,localePrefix:o,...c}=r;const n=l.default(),d=s||n,f=t.getLocalePrefix(d,o);return i.default.createElement(a.default,e.extends({ref:u,locale:d,localePrefixMode:o.mode,prefix:f},c))}const o=r.forwardRef(s);o.displayName="ClientLink",exports.default=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("react"),r=require("../../react-client/useLocale.js"),n=require("../shared/createSharedNavigationFns.js"),a=require("../shared/syncLocaleCookie.js"),u=require("../shared/utils.js"),s=require("./useBasePathname.js");exports.default=function(o){function c(){return r.default()}const{Link:i,config:l,getPathname:h,...f}=n.default(c,o);return{...f,Link:i,usePathname:function(){const e=s.default(l.localePrefix),r=c();return t.useMemo((()=>e&&l.pathnames?u.getRoute(r,e,l.pathnames):e),[r,e])},useRouter:function(){const r=e.useRouter(),n=c(),u=e.usePathname();return t.useMemo((()=>{function e(e){return function(t,r){const{locale:s,...o}=r||{},c=[h({href:t,locale:s||n,domain:window.location.host})];Object.keys(o).length>0&&c.push(o),e(...c),a.default(u,n,s)}}return{...r,push:e(r.push),replace:e(r.replace),prefetch:e(r.prefetch)}}),[n,u,r])},getPathname:h}};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("react"),t=require("../../react-client/useLocale.js"),a=require("../../shared/utils.js");exports.default=function(u){const n=e.usePathname(),i=t.default();return r.useMemo((()=>{if(!n)return n;const e=a.getLocalePrefix(i,u);return a.hasPathnamePrefixed(e,n)?a.unprefixPathname(n,e):n}),[i,u,n])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),l=require("../../shared/utils.js"),t=require("../shared/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),l=require("../../shared/utils.js"),t=require("../shared/LegacyBaseLink.js"),a=require("../../server/react-server/getLocale.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=async function(r){let{locale:u,localePrefix:i,...o}=r;const c=u||await a.default(),d=l.getLocalePrefix(c,i);return s.default.createElement(t.default,e.extends({locale:c,localePrefixMode:i.mode,prefix:d},o))};
|