next-intl 3.20.1-canary.0 → 3.21.1
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 +6 -6
- package/dist/development/middleware/resolveLocale.js +7 -2
- package/dist/development/navigation/react-client/ClientLink.js +2 -2
- package/dist/development/navigation/react-client/useBasePathname.js +14 -0
- package/dist/development/navigation/react-server/ServerLink.js +2 -4
- package/dist/development/navigation/shared/BaseLink.js +25 -28
- package/dist/development/navigation/shared/redirects.js +0 -3
- package/dist/development/navigation/shared/utils.js +1 -40
- package/dist/development/navigation.react-client.js +0 -2
- package/dist/development/navigation.react-server.js +0 -2
- package/dist/development/react-client/index.js +2 -0
- package/dist/development/routing/config.js +1 -1
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/navigation/react-client/ClientLink.js +1 -1
- package/dist/esm/navigation/react-client/useBasePathname.js +1 -0
- package/dist/esm/navigation/react-server/ServerLink.js +1 -1
- package/dist/esm/navigation/shared/BaseLink.js +1 -1
- 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/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/navigation/react-client/ClientLink.js +1 -1
- package/dist/production/navigation/react-client/useBasePathname.js +1 -0
- package/dist/production/navigation/react-server/ServerLink.js +1 -1
- package/dist/production/navigation/shared/BaseLink.js +1 -1
- 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/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/utils.d.ts +4 -4
- package/dist/types/src/navigation/react-client/ClientLink.d.ts +6 -6
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +4 -12
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +4 -4
- package/dist/types/src/navigation/react-client/index.d.ts +0 -1
- package/dist/types/src/navigation/react-client/redirects.d.ts +4 -4
- package/dist/types/src/navigation/react-client/useBasePathname.d.ts +15 -2
- 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 +4 -12
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +3 -3
- package/dist/types/src/navigation/react-server/index.d.ts +0 -1
- package/dist/types/src/navigation/react-server/redirects.d.ts +4 -4
- package/dist/types/src/navigation/shared/BaseLink.d.ts +6 -11
- package/dist/types/src/navigation/shared/redirects.d.ts +5 -5
- package/dist/types/src/navigation/shared/utils.d.ts +3 -10
- package/dist/types/src/react-server/getTranslator.d.ts +9 -0
- package/dist/types/src/routing/config.d.ts +11 -19
- 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/getTranslations.d.ts +9 -0
- package/dist/types/src/shared/types.d.ts +0 -3
- package/dist/types/src/shared/utils.d.ts +2 -2
- package/package.json +3 -3
- package/dist/development/navigation/react-client/createNavigation.js +0 -83
- package/dist/development/navigation/react-server/createNavigation.js +0 -30
- package/dist/development/navigation/shared/LegacyBaseLink.js +0 -55
- package/dist/development/navigation/shared/createSharedNavigationFns.js +0 -147
- package/dist/esm/navigation/react-client/createNavigation.js +0 -1
- package/dist/esm/navigation/react-server/createNavigation.js +0 -1
- package/dist/esm/navigation/shared/LegacyBaseLink.js +0 -2
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +0 -1
- package/dist/production/navigation/react-client/createNavigation.js +0 -1
- package/dist/production/navigation/react-server/createNavigation.js +0 -1
- package/dist/production/navigation/shared/LegacyBaseLink.js +0 -2
- package/dist/production/navigation/shared/createSharedNavigationFns.js +0 -1
- package/dist/types/src/navigation/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/react-client/createNavigation.d.ts +0 -467
- package/dist/types/src/navigation/react-client/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/react-server/createNavigation.d.ts +0 -385
- package/dist/types/src/navigation/react-server/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/shared/LegacyBaseLink.d.ts +0 -10
- package/dist/types/src/navigation/shared/createSharedNavigationFns.d.ts +0 -382
|
@@ -55,7 +55,7 @@ function createMiddleware(routing, options) {
|
|
|
55
55
|
}
|
|
56
56
|
function redirect(url, redirectDomain) {
|
|
57
57
|
const urlObj = new URL(utils$1.normalizeTrailingSlash(url), request.url);
|
|
58
|
-
if (domainsConfig.length > 0 && !redirectDomain
|
|
58
|
+
if (domainsConfig.length > 0 && !redirectDomain) {
|
|
59
59
|
const bestMatchingDomain = utils.getBestMatchingDomain(domain, locale, domainsConfig);
|
|
60
60
|
if (bestMatchingDomain) {
|
|
61
61
|
redirectDomain = bestMatchingDomain.domain;
|
|
@@ -84,12 +84,11 @@ function createMiddleware(routing, options) {
|
|
|
84
84
|
let response;
|
|
85
85
|
let internalTemplateName;
|
|
86
86
|
let unprefixedInternalPathname = unprefixedExternalPathname;
|
|
87
|
-
|
|
88
|
-
if (pathnames) {
|
|
87
|
+
if ('pathnames' in resolvedRouting) {
|
|
89
88
|
let resolvedTemplateLocale;
|
|
90
|
-
[resolvedTemplateLocale, internalTemplateName] = utils.getInternalTemplate(pathnames, unprefixedExternalPathname, locale);
|
|
89
|
+
[resolvedTemplateLocale, internalTemplateName] = utils.getInternalTemplate(resolvedRouting.pathnames, unprefixedExternalPathname, locale);
|
|
91
90
|
if (internalTemplateName) {
|
|
92
|
-
const pathnameConfig = pathnames[internalTemplateName];
|
|
91
|
+
const pathnameConfig = resolvedRouting.pathnames[internalTemplateName];
|
|
93
92
|
const localeTemplate = typeof pathnameConfig === 'string' ? pathnameConfig :
|
|
94
93
|
// @ts-expect-error -- This is fine
|
|
95
94
|
pathnameConfig[locale];
|
|
@@ -157,9 +156,10 @@ function createMiddleware(routing, options) {
|
|
|
157
156
|
syncCookie.default(request, response, locale);
|
|
158
157
|
}
|
|
159
158
|
if (resolvedRouting.localePrefix.mode !== 'never' && resolvedOptions.alternateLinks && resolvedRouting.locales.length > 1) {
|
|
159
|
+
var _resolvedRouting$path;
|
|
160
160
|
response.headers.set('Link', getAlternateLinksHeaderValue.default({
|
|
161
161
|
routing: resolvedRouting,
|
|
162
|
-
localizedPathnames: internalTemplateName != null && pathnames ? pathnames === null ||
|
|
162
|
+
localizedPathnames: internalTemplateName != null && 'pathnames' in resolvedRouting ? (_resolvedRouting$path = resolvedRouting.pathnames) === null || _resolvedRouting$path === void 0 ? void 0 : _resolvedRouting$path[internalTemplateName] : undefined,
|
|
163
163
|
request,
|
|
164
164
|
resolvedLocale: locale
|
|
165
165
|
}));
|
|
@@ -12,7 +12,11 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
12
12
|
var Negotiator__default = /*#__PURE__*/_interopDefault(Negotiator);
|
|
13
13
|
|
|
14
14
|
function findDomainFromHost(requestHeaders, domains) {
|
|
15
|
-
|
|
15
|
+
var _host;
|
|
16
|
+
let host = utils.getHost(requestHeaders);
|
|
17
|
+
|
|
18
|
+
// Remove port (easier for local development)
|
|
19
|
+
host = (_host = host) === null || _host === void 0 ? void 0 : _host.replace(/:\d+$/, '');
|
|
16
20
|
if (host && domains) {
|
|
17
21
|
return domains.find(cur => cur.domain === host);
|
|
18
22
|
}
|
|
@@ -135,7 +139,8 @@ function resolveLocaleFromDomain(routing, options, requestHeaders, requestCookie
|
|
|
135
139
|
}
|
|
136
140
|
function resolveLocale(routing, options, requestHeaders, requestCookies, pathname) {
|
|
137
141
|
if (routing.domains) {
|
|
138
|
-
|
|
142
|
+
const routingWithDomains = routing;
|
|
143
|
+
return resolveLocaleFromDomain(routingWithDomains, options, requestHeaders, requestCookies, pathname);
|
|
139
144
|
} else {
|
|
140
145
|
return {
|
|
141
146
|
locale: resolveLocaleFromPrefix(routing, options, requestHeaders, requestCookies, pathname)
|
|
@@ -6,7 +6,7 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var useLocale = require('../../react-client/useLocale.js');
|
|
8
8
|
var utils = require('../../shared/utils.js');
|
|
9
|
-
var
|
|
9
|
+
var BaseLink = require('../shared/BaseLink.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ function ClientLink(_ref, ref) {
|
|
|
21
21
|
const defaultLocale = useLocale.default();
|
|
22
22
|
const finalLocale = locale || defaultLocale;
|
|
23
23
|
const prefix = utils.getLocalePrefix(finalLocale, localePrefix);
|
|
24
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
24
|
+
return /*#__PURE__*/React__default.default.createElement(BaseLink.default, _rollupPluginBabelHelpers.extends({
|
|
25
25
|
ref: ref,
|
|
26
26
|
locale: finalLocale,
|
|
27
27
|
localePrefixMode: localePrefix.mode,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -7,6 +8,19 @@ var React = require('react');
|
|
|
7
8
|
var useLocale = require('../../react-client/useLocale.js');
|
|
8
9
|
var utils = require('../../shared/utils.js');
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Returns the pathname without a potential locale prefix.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* 'use client';
|
|
17
|
+
*
|
|
18
|
+
* import {usePathname} from 'next-intl/client';
|
|
19
|
+
*
|
|
20
|
+
* // When the user is on `/en`, this will be `/`
|
|
21
|
+
* const pathname = usePathname();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
10
24
|
function useBasePathname(localePrefix) {
|
|
11
25
|
// The types aren't entirely correct here. Outside of Next.js
|
|
12
26
|
// `useParams` can be called, but the return type is `null`.
|
|
@@ -5,15 +5,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var utils = require('../../shared/utils.js');
|
|
8
|
-
var
|
|
8
|
+
var BaseLink = require('../shared/BaseLink.js');
|
|
9
9
|
var getLocale = require('../../server/react-server/getLocale.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
13
13
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
14
14
|
|
|
15
|
-
// Only used by legacy navigation APIs, can be removed when they are removed
|
|
16
|
-
|
|
17
15
|
async function ServerLink(_ref) {
|
|
18
16
|
let {
|
|
19
17
|
locale,
|
|
@@ -22,7 +20,7 @@ async function ServerLink(_ref) {
|
|
|
22
20
|
} = _ref;
|
|
23
21
|
const finalLocale = locale || (await getLocale.default());
|
|
24
22
|
const prefix = utils.getLocalePrefix(finalLocale, localePrefix);
|
|
25
|
-
return /*#__PURE__*/React__default.default.createElement(
|
|
23
|
+
return /*#__PURE__*/React__default.default.createElement(BaseLink.default, _rollupPluginBabelHelpers.extends({
|
|
26
24
|
locale: finalLocale,
|
|
27
25
|
localePrefixMode: localePrefix.mode,
|
|
28
26
|
prefix: prefix
|
|
@@ -8,6 +8,7 @@ var NextLink = require('next/link');
|
|
|
8
8
|
var navigation = require('next/navigation');
|
|
9
9
|
var React = require('react');
|
|
10
10
|
var useLocale = require('../../react-client/useLocale.js');
|
|
11
|
+
var utils = require('../../shared/utils.js');
|
|
11
12
|
var syncLocaleCookie = require('./syncLocaleCookie.js');
|
|
12
13
|
|
|
13
14
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -17,37 +18,39 @@ var React__default = /*#__PURE__*/_interopDefault(React);
|
|
|
17
18
|
|
|
18
19
|
function BaseLink(_ref, ref) {
|
|
19
20
|
let {
|
|
20
|
-
defaultLocale,
|
|
21
21
|
href,
|
|
22
22
|
locale,
|
|
23
|
+
localePrefixMode,
|
|
23
24
|
onClick,
|
|
24
25
|
prefetch,
|
|
25
|
-
|
|
26
|
+
prefix,
|
|
26
27
|
...rest
|
|
27
28
|
} = _ref;
|
|
28
|
-
const curLocale = useLocale.default();
|
|
29
|
-
const isChangingLocale = locale !== curLocale;
|
|
30
|
-
const linkLocale = locale || curLocale;
|
|
31
|
-
const host = useHost();
|
|
32
|
-
const finalHref =
|
|
33
|
-
// Only after hydration (to avoid mismatches)
|
|
34
|
-
host &&
|
|
35
|
-
// If there is an `unprefixed` prop, the
|
|
36
|
-
// `defaultLocale` might differ by domain
|
|
37
|
-
unprefixed && (
|
|
38
|
-
// Unprefix the pathname if a domain matches
|
|
39
|
-
unprefixed.domains[host] === linkLocale ||
|
|
40
|
-
// … and handle unknown domains by applying the
|
|
41
|
-
// global `defaultLocale` (e.g. on localhost)
|
|
42
|
-
!Object.keys(unprefixed.domains).includes(host) && curLocale === defaultLocale && !locale) ? unprefixed.pathname : href;
|
|
43
|
-
|
|
44
29
|
// The types aren't entirely correct here. Outside of Next.js
|
|
45
30
|
// `useParams` can be called, but the return type is `null`.
|
|
46
31
|
const pathname = navigation.usePathname();
|
|
32
|
+
const curLocale = useLocale.default();
|
|
33
|
+
const isChangingLocale = locale !== curLocale;
|
|
34
|
+
const [localizedHref, setLocalizedHref] = React.useState(() => utils.isLocalizableHref(href) && (localePrefixMode !== 'never' || isChangingLocale) ?
|
|
35
|
+
// For the `localePrefix: 'as-needed' strategy, the href shouldn't
|
|
36
|
+
// be prefixed if the locale is the default locale. To determine this, we
|
|
37
|
+
// need a) the default locale and b) the information if we use prefixed
|
|
38
|
+
// routing. The default locale can vary by domain, therefore during the
|
|
39
|
+
// RSC as well as the SSR render, we can't determine the default locale
|
|
40
|
+
// statically. Therefore we always prefix the href since this will
|
|
41
|
+
// always result in a valid URL, even if it might cause a redirect. This
|
|
42
|
+
// is better than pointing to a non-localized href during the server
|
|
43
|
+
// render, which would potentially be wrong. The final href is
|
|
44
|
+
// determined in the effect below.
|
|
45
|
+
utils.prefixHref(href, prefix) : href);
|
|
47
46
|
function onLinkClick(event) {
|
|
48
47
|
syncLocaleCookie.default(pathname, curLocale, locale);
|
|
49
48
|
if (onClick) onClick(event);
|
|
50
49
|
}
|
|
50
|
+
React.useEffect(() => {
|
|
51
|
+
if (!pathname) return;
|
|
52
|
+
setLocalizedHref(utils.localizeHref(href, locale, curLocale, pathname, prefix));
|
|
53
|
+
}, [curLocale, href, locale, pathname, prefix]);
|
|
51
54
|
if (isChangingLocale) {
|
|
52
55
|
if (prefetch && "development" !== 'production') {
|
|
53
56
|
console.error('The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`');
|
|
@@ -56,19 +59,13 @@ function BaseLink(_ref, ref) {
|
|
|
56
59
|
}
|
|
57
60
|
return /*#__PURE__*/React__default.default.createElement(NextLink__default.default, _rollupPluginBabelHelpers.extends({
|
|
58
61
|
ref: ref,
|
|
59
|
-
href:
|
|
62
|
+
href: localizedHref,
|
|
60
63
|
hrefLang: isChangingLocale ? locale : undefined,
|
|
61
64
|
onClick: onLinkClick,
|
|
62
65
|
prefetch: prefetch
|
|
63
66
|
}, rest));
|
|
64
67
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
setHost(window.location.host);
|
|
69
|
-
}, []);
|
|
70
|
-
return host;
|
|
71
|
-
}
|
|
72
|
-
var BaseLink$1 = /*#__PURE__*/React.forwardRef(BaseLink);
|
|
68
|
+
const BaseLinkWithRef = /*#__PURE__*/React.forwardRef(BaseLink);
|
|
69
|
+
BaseLinkWithRef.displayName = 'ClientLink';
|
|
73
70
|
|
|
74
|
-
exports.default =
|
|
71
|
+
exports.default = BaseLinkWithRef;
|
|
@@ -8,9 +8,6 @@ var utils = require('../../shared/utils.js');
|
|
|
8
8
|
function createRedirectFn(redirectFn) {
|
|
9
9
|
return function baseRedirect(params) {
|
|
10
10
|
const prefix = utils.getLocalePrefix(params.locale, params.localePrefix);
|
|
11
|
-
|
|
12
|
-
// This logic is considered legacy and is replaced by `applyPathnamePrefix`.
|
|
13
|
-
// We keep it this way for now for backwards compatibility.
|
|
14
11
|
const localizedPathname = params.localePrefix.mode === 'never' || !utils.isLocalizableHref(params.pathname) ? params.pathname : utils.prefixPathname(prefix, params.pathname);
|
|
15
12
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
16
13
|
args[_key - 1] = arguments[_key];
|
|
@@ -7,11 +7,8 @@ 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
|
-
|
|
14
10
|
function normalizeNameOrNameWithParams(href) {
|
|
11
|
+
// @ts-expect-error -- `extends string` in the generic unfortunately weakens the type
|
|
15
12
|
return typeof href === 'string' ? {
|
|
16
13
|
pathname: href
|
|
17
14
|
} : href;
|
|
@@ -43,7 +40,6 @@ function compileLocalizedPathname(_ref) {
|
|
|
43
40
|
function getNamedPath(value) {
|
|
44
41
|
let namedPath = pathnames[value];
|
|
45
42
|
if (!namedPath) {
|
|
46
|
-
// Unknown pathnames
|
|
47
43
|
namedPath = value;
|
|
48
44
|
}
|
|
49
45
|
return namedPath;
|
|
@@ -122,44 +118,9 @@ function getBasePath(pathname) {
|
|
|
122
118
|
return windowPathname.replace(pathname, '');
|
|
123
119
|
}
|
|
124
120
|
}
|
|
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
|
-
}
|
|
158
121
|
|
|
159
|
-
exports.applyPathnamePrefix = applyPathnamePrefix;
|
|
160
122
|
exports.compileLocalizedPathname = compileLocalizedPathname;
|
|
161
123
|
exports.getBasePath = getBasePath;
|
|
162
124
|
exports.getRoute = getRoute;
|
|
163
125
|
exports.normalizeNameOrNameWithParams = normalizeNameOrNameWithParams;
|
|
164
126
|
exports.serializeSearchParams = serializeSearchParams;
|
|
165
|
-
exports.validateReceivedConfig = validateReceivedConfig;
|
|
@@ -4,10 +4,8 @@ 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');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
|
|
12
11
|
exports.createLocalizedPathnamesNavigation = createLocalizedPathnamesNavigation.default;
|
|
13
|
-
exports.createNavigation = createNavigation.default;
|
|
@@ -4,10 +4,8 @@ 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');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
|
|
12
11
|
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
|
|
8
|
+
localePrefix: receiveLocalePrefixConfig(input.localePrefix)
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
11
|
function receiveLocalePrefixConfig(localePrefix) {
|
|
@@ -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 a,getLocalePrefix as n}from"../shared/utils.js";import r 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 m,getInternalTemplate as h,formatTemplatePathname as u,formatPathname as x,getBestMatchingDomain as v,applyBasePath as p,getLocaleAsPrefix as U}from"./utils.js";function P(P,L){var g,k,j,w;const b=l(P),y={alternateLinks:null===(g=null!==(k=null==L?void 0:L.alternateLinks)&&void 0!==k?k:P.alternateLinks)||void 0===g||g,localeDetection:null===(j=null!==(w=null==L?void 0:L.localeDetection)&&void 0!==w?w:null==P?void 0:P.localeDetection)||void 0===j||j};return function(l){var P;let L;try{L=decodeURI(l.nextUrl.pathname)}catch(l){return e.next()}const g=c(L),{domain:k,locale:j}=i(b,y,l.headers,l.cookies,g),w=k?k.defaultLocale===j:j===b.defaultLocale,D=(null===(P=b.domains)||void 0===P?void 0:P.filter((e=>d(j,e))))||[],R=null!=b.domains&&!k;function q(t){const a=new URL(t,l.url);l.nextUrl.basePath&&(a.pathname=p(a.pathname,l.nextUrl.basePath));const n=new Headers(l.headers);return n.set(o,j),e.rewrite(a,{request:{headers:n}})}function H(o,t){const n=new URL(a(o),l.url);if(D.length>0&&!t){const e=v(k,j,D);e&&(t=e.domain,e.defaultLocale===j&&"as-needed"===b.localePrefix.mode&&(n.pathname=f(n.pathname,b.locales,b.localePrefix)))}var r,i;t&&(n.host=t,l.headers.get("x-forwarded-host")&&(n.protocol=null!==(r=l.headers.get("x-forwarded-proto"))&&void 0!==r?r:l.nextUrl.protocol,n.port=null!==(i=l.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return l.nextUrl.basePath&&(n.pathname=p(n.pathname,l.nextUrl.basePath)),e.redirect(n.toString())}const z=f(g,b.locales,b.localePrefix),A=m(g,b.locales,b.localePrefix),C=null!=A,I="never"===b.localePrefix.mode||w&&"as-needed"===b.localePrefix.mode;let S,V,B=z;if("pathnames"in b){let e;if([e,V]=h(b.pathnames,z,j),V){const o=b.pathnames[V],a="string"==typeof o?o:o[j];if(t(a,z))B=u(z,a,V);else{let t;t=e?"string"==typeof o?o:o[e]:V;const r=I?void 0:n(j,b.localePrefix),i=u(z,t,a);S=H(x(i,r,l.nextUrl.search))}}}if(!S)if("/"!==B||C){const e=x(B,U(j),l.nextUrl.search);if(C){const o=x(z,A.prefix,l.nextUrl.search);if("never"===b.localePrefix.mode)S=H(x(z,void 0,l.nextUrl.search));else if(A.exact)if(w&&I)S=H(x(z,void 0,l.nextUrl.search));else if(b.domains){const l=v(k,A.locale,D);S=(null==k?void 0:k.domain)===(null==l?void 0:l.domain)||R?q(e):H(o,null==l?void 0:l.domain)}else S=q(e);else S=H(o)}else S=I?q(e):H(x(z,n(j,b.localePrefix),l.nextUrl.search))}else S=I?q(x(B,U(j),l.nextUrl.search)):H(x(z,n(j,b.localePrefix),l.nextUrl.search));var E;(y.localeDetection&&s(l,S,j),"never"!==b.localePrefix.mode&&y.alternateLinks&&b.locales.length>1)&&S.headers.set("Link",r({routing:b,localizedPathnames:null!=V&&"pathnames"in b?null===(E=b.pathnames)||void 0===E?void 0:E[V]:void 0,request:l,resolvedLocale:j}));return S}}export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as
|
|
1
|
+
import{match as e}from"@formatjs/intl-localematcher";import o 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 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);a=e(c,o,n)}catch(e){}return a}function i(e,o){if(e.has(l)){var t;const n=null===(t=e.get(l))||void 0===t?void 0:t.value;if(n&&o.includes(n))return n}}function r(e,o,l,n,a){let r,{defaultLocale:u,localePrefix:f,locales:s}=e,{localeDetection:d}=o;var m;a&&(r=null===(m=t(a,s,f))||void 0===m?void 0:m.locale);return!r&&d&&n&&(r=i(n,s)),!r&&d&&l&&(r=c(l,s,u)),r||(r=u),r}function u(e,o,l,u,f){const s=function(e,o){var l;let t=a(e);if(t=null===(l=t)||void 0===l?void 0:l.replace(/:\d+$/,""),t&&o)return o.find((e=>e.domain===t))}(l,e.domains);if(!s)return{locale:r(e,o,l,u,f)};let d;if(f){var m;const o=null===(m=t(f,e.locales,e.localePrefix))||void 0===m?void 0:m.locale;if(o){if(!n(o,s))return{locale:o,domain:s};d=o}}if(!d&&o.localeDetection&&u){const o=i(u,e.locales);o&&n(o,s)&&(d=o)}if(!d&&o.localeDetection&&l){const o=c(l,s.locales||e.locales,s.defaultLocale);o&&(d=o)}return d||(d=s.defaultLocale),{locale:d,domain:s}}function f(e,o,l,t,n){if(e.domains){return u(e,o,l,t,n)}return{locale:r(e,o,l,t,n)}}export{f as default,c as getAcceptLanguageLocale};
|
|
@@ -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/BaseLink.js";function i(l,i){let{locale:s,localePrefix:m,...c}=l;const n=o(),f=s||n,p=t(f,m);return r.createElement(a,e({ref:i,locale:f,localePrefixMode:m.mode,prefix:p},c))}const s=l(i);s.displayName="ClientLink";export{s as default};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
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 t from"../shared/BaseLink.js";import a from"../../server/react-server/getLocale.js";async function l(l){let{locale:s,localePrefix:i,...m}=l;const c=s||await a(),f=o(c,i);return r.createElement(t,e({locale:c,localePrefixMode:i.mode,prefix:f},m))}export{l as default};
|
|
@@ -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 r}from"next/navigation";import t,{forwardRef as n,useState as i,useEffect as l}from"react";import c from"../../react-client/useLocale.js";import{isLocalizableHref as p,prefixHref as a,localizeHref as s}from"../../shared/utils.js";import f from"./syncLocaleCookie.js";function m(n,m){let{href:h,locale:u,localePrefixMode:d,onClick:k,prefetch:x,prefix:L,...g}=n;const j=r(),v=c(),C=u!==v,[y,w]=i((()=>p(h)&&("never"!==d||C)?a(h,L):h));return l((()=>{j&&w(s(h,u,v,j,L))}),[v,h,u,j,L]),C&&(x&&console.error("The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`"),x=!1),t.createElement(o,e({ref:m,href:y,hrefLang:C?u:void 0,onClick:function(e){f(j,v,u),k&&k(e)},prefetch:x},g))}const h=n(m);h.displayName="ClientLink";export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getSortedPathnames as
|
|
1
|
+
import{getSortedPathnames as t,matchesPathname as n,normalizeTrailingSlash as r}from"../../shared/utils.js";function e(t){return"string"==typeof t?{pathname:t}:t}function o(t){function n(t){return String(t)}const r=new URLSearchParams;for(const[e,o]of Object.entries(t))Array.isArray(o)?o.forEach((t=>{r.append(e,n(t))})):r.set(e,n(o));return"?"+r.toString()}function a(t){let{pathname:n,locale:e,params:a,pathnames:c,query:i}=t;function s(t){let n=c[t];return n||(n=t),n}function f(t){const n="string"==typeof t?t:t[e];let c=n;if(a&&Object.entries(a).forEach((t=>{let n,r,[e,o]=t;Array.isArray(o)?(n="(\\[)?\\[...".concat(e,"\\](\\])?"),r=o.map((t=>String(t))).join("/")):(n="\\[".concat(e,"\\]"),r=String(o)),c=c.replace(new RegExp(n,"g"),r)})),c=c.replace(/\[\[\.\.\..+\]\]/g,""),c=r(c),c.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(a)));return i&&(c+=o(i)),c}if("string"==typeof n){return f(s(n))}{const{pathname:t,...r}=n;return{...r,pathname:f(s(t))}}}function c(r,e,o){const a=t(Object.keys(o)),c=decodeURI(e);for(const t of a){const e=o[t];if("string"==typeof e){if(n(e,c))return t}else if(n(e[r],c))return t}return e}function i(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===t?n:n.replace(t,"")}export{a as compileLocalizedPathname,i as getBasePath,c as getRoute,e as normalizeNameOrNameWithParams,o as serializeSearchParams};
|
|
@@ -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";
|
|
@@ -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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return{...e,localePrefix:o(
|
|
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 +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"),n=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),r=require("./syncCookie.js"),i=require("./utils.js");exports.default=function(s,c){var d,
|
|
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"),n=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),r=require("./syncCookie.js"),i=require("./utils.js");exports.default=function(s,c){var d,h,m,f;const u=a.receiveRoutingConfig(s),x={alternateLinks:null===(d=null!==(h=null==c?void 0:c.alternateLinks)&&void 0!==h?h:s.alternateLinks)||void 0===d||d,localeDetection:null===(m=null!==(f=null==c?void 0:c.localeDetection)&&void 0!==f?f:null==s?void 0:s.localeDetection)||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:h,locale:m}=o.default(u,x,a.headers,a.cookies,d),f=h?h.defaultLocale===m:m===u.defaultLocale,P=(null===(s=u.domains)||void 0===s?void 0:s.filter((e=>i.isLocaleSupportedOnDomain(m,e))))||[],p=null!=u.domains&&!h;function v(l){const n=new URL(l,a.url);a.nextUrl.basePath&&(n.pathname=i.applyBasePath(n.pathname,a.nextUrl.basePath));const o=new Headers(a.headers);return o.set(t.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(n,{request:{headers:o}})}function g(t,n){const o=new URL(l.normalizeTrailingSlash(t),a.url);if(P.length>0&&!n){const e=i.getBestMatchingDomain(h,m,P);e&&(n=e.domain,e.defaultLocale===m&&"as-needed"===u.localePrefix.mode&&(o.pathname=i.getNormalizedPathname(o.pathname,u.locales,u.localePrefix)))}var r,s;n&&(o.host=n,a.headers.get("x-forwarded-host")&&(o.protocol=null!==(r=a.headers.get("x-forwarded-proto"))&&void 0!==r?r:a.nextUrl.protocol,o.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(o.pathname=i.applyBasePath(o.pathname,a.nextUrl.basePath)),e.NextResponse.redirect(o.toString())}const L=i.getNormalizedPathname(d,u.locales,u.localePrefix),U=i.getPathnameMatch(d,u.locales,u.localePrefix),q=null!=U,j="never"===u.localePrefix.mode||f&&"as-needed"===u.localePrefix.mode;let k,D,R=L;if("pathnames"in u){let e;if([e,D]=i.getInternalTemplate(u.pathnames,L,m),D){const t=u.pathnames[D],n="string"==typeof t?t:t[m];if(l.matchesPathname(n,L))R=i.formatTemplatePathname(L,n,D);else{let o;o=e?"string"==typeof t?t:t[e]:D;const r=j?void 0:l.getLocalePrefix(m,u.localePrefix),s=i.formatTemplatePathname(L,o,n);k=g(i.formatPathname(s,r,a.nextUrl.search))}}}if(!k)if("/"!==R||q){const e=i.formatPathname(R,i.getLocaleAsPrefix(m),a.nextUrl.search);if(q){const t=i.formatPathname(L,U.prefix,a.nextUrl.search);if("never"===u.localePrefix.mode)k=g(i.formatPathname(L,void 0,a.nextUrl.search));else if(U.exact)if(f&&j)k=g(i.formatPathname(L,void 0,a.nextUrl.search));else if(u.domains){const a=i.getBestMatchingDomain(h,U.locale,P);k=(null==h?void 0:h.domain)===(null==a?void 0:a.domain)||p?v(e):g(t,null==a?void 0:a.domain)}else k=v(e);else k=g(t)}else k=j?v(e):g(i.formatPathname(L,l.getLocalePrefix(m,u.localePrefix),a.nextUrl.search))}else k=j?v(i.formatPathname(R,i.getLocaleAsPrefix(m),a.nextUrl.search)):g(i.formatPathname(L,l.getLocalePrefix(m,u.localePrefix),a.nextUrl.search));var w;(x.localeDetection&&r.default(a,k,m),"never"!==u.localePrefix.mode&&x.alternateLinks&&u.locales.length>1)&&k.headers.set("Link",n.default({routing:u,localizedPathnames:null!=D&&"pathnames"in u?null===(w=u.pathnames)||void 0===w?void 0:w[D]:void 0,request:a,resolvedLocale:m}));return k}};
|
|
@@ -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"),l=require("../shared/constants.js"),o=require("./utils.js");function a(e){return e&&e.__esModule?e:{default:e}}var n=a(t);function c(t,l,o){let a;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))}(l);a=e.match(c,t,o)}catch(e){}return a}function r(e,t){if(e.has(l.COOKIE_LOCALE_NAME)){var o;const a=null===(o=e.get(l.COOKIE_LOCALE_NAME))||void 0===o?void 0:o.value;if(a&&t.includes(a))return a}}function i(e,t,l,a,n){let i,{defaultLocale:u,localePrefix:s,locales:d}=e,{localeDetection:f}=t;var g;n&&(i=null===(g=o.getPathnameMatch(n,d,s))||void 0===g?void 0:g.locale);return!i&&f&&a&&(i=r(a,d)),!i&&f&&l&&(i=c(l,d,u)),i||(i=u),i}function u(e,t,l,a,n){const u=function(e,t){var l;let a=o.getHost(e);if(a=null===(l=a)||void 0===l?void 0:l.replace(/:\d+$/,""),a&&t)return t.find((e=>e.domain===a))}(l,e.domains);if(!u)return{locale:i(e,t,l,a,n)};let s;if(n){var d;const t=null===(d=o.getPathnameMatch(n,e.locales,e.localePrefix))||void 0===d?void 0:d.locale;if(t){if(!o.isLocaleSupportedOnDomain(t,u))return{locale:t,domain:u};s=t}}if(!s&&t.localeDetection&&a){const t=r(a,e.locales);t&&o.isLocaleSupportedOnDomain(t,u)&&(s=t)}if(!s&&t.localeDetection&&l){const t=c(l,u.locales||e.locales,u.defaultLocale);t&&(s=t)}return s||(s=u.defaultLocale),{locale:s,domain:u}}exports.default=function(e,t,l,o,a){if(e.domains){return u(e,t,l,o,a)}return{locale:i(e,t,l,o,a)}},exports.getAcceptLanguageLocale=c;
|
|
@@ -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/BaseLink.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;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
"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/BaseLink.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))};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("next/link"),t=require("next/navigation"),l=require("react"),i=require("../../react-client/useLocale.js"),a=require("../../shared/utils.js"),u=require("./syncLocaleCookie.js");function n(e){return e&&e.__esModule?e:{default:e}}var f=n(r),o=n(l);function c(r,n){let{href:c,locale:s,localePrefixMode:d,onClick:p,prefetch:x,prefix:h,...q}=r;const v=t.usePathname(),_=i.default(),j=s!==_,[k,L]=l.useState((()=>a.isLocalizableHref(c)&&("never"!==d||j)?a.prefixHref(c,h):c));return l.useEffect((()=>{v&&L(a.localizeHref(c,s,_,v,h))}),[_,c,s,v,h]),j&&(x=!1),o.default.createElement(f.default,e.extends({ref:n,href:k,hrefLang:j?s:void 0,onClick:function(e){u.default(v,_,s),p&&p(e)},prefetch:x},q))}const s=l.forwardRef(c);s.displayName="ClientLink",exports.default=s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[a
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[n,a]of Object.entries(e))Array.isArray(a)?a.forEach((e=>{r.append(n,t(e))})):r.set(n,t(a));return"?"+r.toString()}exports.compileLocalizedPathname=function(r){let{pathname:n,locale:a,params:o,pathnames:i,query:s}=r;function c(e){let t=i[e];return t||(t=e),t}function p(r){let n="string"==typeof r?r:r[a];return o&&Object.entries(o).forEach((e=>{let t,r,[a,o]=e;Array.isArray(o)?(t="(\\[)?\\[...".concat(a,"\\](\\])?"),r=o.map((e=>String(e))).join("/")):(t="\\[".concat(a,"\\]"),r=String(o)),n=n.replace(new RegExp(t,"g"),r)})),n=n.replace(/\[\[\.\.\..+\]\]/g,""),n=e.normalizeTrailingSlash(n),s&&(n+=t(s)),n}if("string"==typeof n){return p(c(n))}{const{pathname:e,...t}=n;return{...t,pathname:p(c(e))}}},exports.getBasePath=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===e?t:t.replace(e,"")},exports.getRoute=function(t,r,n){const a=e.getSortedPathnames(Object.keys(n)),o=decodeURI(r);for(const r of a){const a=n[r];if("string"==typeof a){const t=a;if(e.matchesPathname(t,o))return r}else if(e.matchesPathname(a[t],o))return r}return r},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./navigation/react-client/createSharedPathnamesNavigation.js"),a=require("./navigation/react-client/createLocalizedPathnamesNavigation.js")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./navigation/react-client/createSharedPathnamesNavigation.js"),a=require("./navigation/react-client/createLocalizedPathnamesNavigation.js");exports.createSharedPathnamesNavigation=e.default,exports.createLocalizedPathnamesNavigation=a.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./navigation/react-server/createSharedPathnamesNavigation.js"),a=require("./navigation/react-server/createLocalizedPathnamesNavigation.js")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./navigation/react-server/createSharedPathnamesNavigation.js"),a=require("./navigation/react-server/createLocalizedPathnamesNavigation.js");exports.createSharedPathnamesNavigation=e.default,exports.createLocalizedPathnamesNavigation=a.default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return"object"==typeof e?e:{mode:e||"always"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.receiveLocalePrefixConfig=e,exports.receiveRoutingConfig=function(o){return{...o,localePrefix:e(
|
|
1
|
+
"use strict";function e(e){return"object"==typeof e?e:{mode:e||"always"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.receiveLocalePrefixConfig=e,exports.receiveRoutingConfig=function(o){return{...o,localePrefix:e(o.localePrefix)}};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
2
|
import { ResolvedRoutingConfig } from '../routing/config';
|
|
3
|
-
import {
|
|
3
|
+
import { Locales, Pathnames } from '../routing/types';
|
|
4
4
|
/**
|
|
5
5
|
* See https://developers.google.com/search/docs/specialty/international/localized-versions
|
|
6
6
|
*/
|
|
7
|
-
export default function getAlternateLinksHeaderValue<AppLocales extends Locales,
|
|
8
|
-
routing:
|
|
7
|
+
export default function getAlternateLinksHeaderValue<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales> = never>({ localizedPathnames, request, resolvedLocale, routing }: {
|
|
8
|
+
routing: ResolvedRoutingConfig<AppLocales, AppPathnames>;
|
|
9
9
|
request: NextRequest;
|
|
10
10
|
resolvedLocale: AppLocales[number];
|
|
11
11
|
localizedPathnames?: Pathnames<AppLocales>[string];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import { RoutingConfig } from '../routing/config';
|
|
3
|
-
import {
|
|
3
|
+
import { Locales, Pathnames } from '../routing/types';
|
|
4
4
|
import { MiddlewareOptions } from './config';
|
|
5
|
-
export default function createMiddleware<AppLocales extends Locales,
|
|
5
|
+
export default function createMiddleware<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales> = never>(routing: RoutingConfig<AppLocales, AppPathnames> & MiddlewareOptions, options?: MiddlewareOptions): (request: NextRequest) => NextResponse<unknown>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RequestCookies } from 'next/dist/server/web/spec-extension/cookies';
|
|
2
2
|
import { ResolvedRoutingConfig } from '../routing/config';
|
|
3
|
-
import { Locales, Pathnames,
|
|
3
|
+
import { Locales, Pathnames, DomainConfig } from '../routing/types';
|
|
4
4
|
import { ResolvedMiddlewareOptions } from './config';
|
|
5
5
|
export declare function getAcceptLanguageLocale<AppLocales extends Locales>(requestHeaders: Headers, locales: AppLocales, defaultLocale: string): string | undefined;
|
|
6
|
-
export default function resolveLocale<AppLocales extends Locales,
|
|
6
|
+
export default function resolveLocale<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales> = never>(routing: ResolvedRoutingConfig<AppLocales, AppPathnames>, options: ResolvedMiddlewareOptions, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): {
|
|
7
7
|
locale: AppLocales[number];
|
|
8
8
|
domain?: DomainConfig<AppLocales>;
|
|
9
9
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Locales, LocalePrefixConfigVerbose, DomainConfig, Pathnames, DomainsConfig
|
|
1
|
+
import { Locales, LocalePrefixConfigVerbose, DomainConfig, Pathnames, DomainsConfig } from '../routing/types';
|
|
2
2
|
export declare function getFirstPathnameSegment(pathname: string): string;
|
|
3
3
|
export declare function getInternalTemplate<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(pathnames: AppPathnames, pathname: string, locale: AppLocales[number]): [AppLocales[number] | undefined, keyof AppPathnames | undefined];
|
|
4
4
|
export declare function formatTemplatePathname(sourcePathname: string, sourceTemplate: string, targetTemplate: string, prefix?: string): string;
|
|
5
5
|
/**
|
|
6
6
|
* Removes potential prefixes from the pathname.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getNormalizedPathname<AppLocales extends Locales
|
|
8
|
+
export declare function getNormalizedPathname<AppLocales extends Locales>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales>): string;
|
|
9
9
|
export declare function findCaseInsensitiveString(candidate: string, strings: Array<string>): string | undefined;
|
|
10
|
-
export declare function getLocalePrefixes<AppLocales extends Locales
|
|
11
|
-
export declare function getPathnameMatch<AppLocales extends Locales
|
|
10
|
+
export declare function getLocalePrefixes<AppLocales extends Locales>(locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales>, sort?: boolean): Array<[AppLocales[number], string]>;
|
|
11
|
+
export declare function getPathnameMatch<AppLocales extends Locales>(pathname: string, locales: AppLocales, localePrefix: LocalePrefixConfigVerbose<AppLocales>): {
|
|
12
12
|
locale: AppLocales[number];
|
|
13
13
|
prefix: string;
|
|
14
14
|
matchedPrefix: string;
|