next-intl 3.16.0-dc8fb0d.0 → 3.16.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.
Files changed (60) hide show
  1. package/dist/development/middleware/getAlternateLinksHeaderValue.js +2 -0
  2. package/dist/development/middleware/middleware.js +5 -5
  3. package/dist/development/middleware/utils.js +19 -68
  4. package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -5
  5. package/dist/development/navigation/shared/redirects.js +1 -1
  6. package/dist/development/navigation/shared/utils.js +15 -15
  7. package/dist/development/plugin.js +29 -25
  8. package/dist/development/shared/utils.js +72 -4
  9. package/dist/esm/middleware/getAlternateLinksHeaderValue.js +1 -1
  10. package/dist/esm/middleware/middleware.js +1 -1
  11. package/dist/esm/middleware/utils.js +1 -1
  12. package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
  13. package/dist/esm/navigation/shared/redirects.js +1 -1
  14. package/dist/esm/navigation/shared/utils.js +1 -1
  15. package/dist/esm/plugin.js +1 -1
  16. package/dist/esm/shared/utils.js +1 -1
  17. package/dist/production/middleware/getAlternateLinksHeaderValue.js +1 -1
  18. package/dist/production/middleware/middleware.js +1 -1
  19. package/dist/production/middleware/utils.js +1 -1
  20. package/dist/production/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
  21. package/dist/production/navigation/shared/redirects.js +1 -1
  22. package/dist/production/navigation/shared/utils.js +1 -1
  23. package/dist/production/plugin.js +1 -1
  24. package/dist/production/shared/utils.js +1 -1
  25. package/dist/types/src/middleware/resolveLocale.d.ts +1 -1
  26. package/dist/types/src/middleware/utils.d.ts +2 -5
  27. package/dist/types/src/navigation/react-client/ClientLink.d.ts +3 -39
  28. package/dist/types/src/navigation/shared/utils.d.ts +1 -5
  29. package/dist/types/src/routing/config.d.ts +2 -2
  30. package/dist/types/src/routing/index.d.ts +1 -2
  31. package/dist/types/src/routing/types.d.ts +2 -1
  32. package/dist/types/src/shared/utils.d.ts +2 -2
  33. package/package.json +7 -7
  34. /package/dist/types/{test → src}/middleware/getAlternateLinksHeaderValue.test.d.ts +0 -0
  35. /package/dist/types/{test → src}/middleware/middleware.test.d.ts +0 -0
  36. /package/dist/types/{test → src}/middleware/resolveLocale.test.d.ts +0 -0
  37. /package/dist/types/{test → src}/middleware/utils.test.d.ts +0 -0
  38. /package/dist/types/{test → src}/navigation/createLocalizedPathnamesNavigation.test.d.ts +0 -0
  39. /package/dist/types/{test → src}/navigation/createSharedPathnamesNavigation.test.d.ts +0 -0
  40. /package/dist/types/{test → src}/navigation/react-client/ClientLink.test.d.ts +0 -0
  41. /package/dist/types/{test → src}/navigation/react-client/createLocalizedPathnamesNavigation.test.d.ts +0 -0
  42. /package/dist/types/{test → src}/navigation/react-client/createSharedPathnamesNavigation.test.d.ts +0 -0
  43. /package/dist/types/{test → src}/navigation/react-client/useBasePathname.test.d.ts +0 -0
  44. /package/dist/types/{test → src}/navigation/react-client/useBaseRouter.test.d.ts +0 -0
  45. /package/dist/types/{test → src}/navigation/shared/redirects.test.d.ts +0 -0
  46. /package/dist/types/{test → src}/navigation/shared/utils.test.d.ts +0 -0
  47. /package/dist/types/{test → src}/react-client/useFormatter.test.d.ts +0 -0
  48. /package/dist/types/{test → src}/react-client/useLocale.test.d.ts +0 -0
  49. /package/dist/types/{test → src}/react-client/useNow.test.d.ts +0 -0
  50. /package/dist/types/{test → src}/react-client/useTimeZone.test.d.ts +0 -0
  51. /package/dist/types/{test → src}/react-client/useTranslations.test.d.ts +0 -0
  52. /package/dist/types/{test → src}/react-server/NextIntlClientProviderServer.test.d.ts +0 -0
  53. /package/dist/types/{test → src}/react-server/index.test.d.ts +0 -0
  54. /package/dist/types/{test → src}/react-server/useTranslations.test.d.ts +0 -0
  55. /package/dist/types/{test → src}/react-server/utils.d.ts +0 -0
  56. /package/dist/types/{test → src}/routing/types.test.d.ts +0 -0
  57. /package/dist/types/{test → src}/server/react-client/index.test.d.ts +0 -0
  58. /package/dist/types/{test → src}/server/react-server/index.test.d.ts +0 -0
  59. /package/dist/types/{test → src}/shared/NextIntlClientProvider.test.d.ts +0 -0
  60. /package/dist/types/{test → src}/shared/utils.test.d.ts +0 -0
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var utils$1 = require('../shared/utils.js');
5
6
  var utils = require('./utils.js');
6
7
 
7
8
  /**
@@ -24,6 +25,7 @@ function getAlternateLinksHeaderValue(_ref) {
24
25
  normalizedUrl.protocol = (_request$headers$get = request.headers.get('x-forwarded-proto')) !== null && _request$headers$get !== void 0 ? _request$headers$get : normalizedUrl.protocol;
25
26
  normalizedUrl.pathname = utils.getNormalizedPathname(normalizedUrl.pathname, config.locales, config.localePrefix);
26
27
  function getAlternateEntry(url, locale) {
28
+ url.pathname = utils$1.normalizeTrailingSlash(url.pathname);
27
29
  if (request.nextUrl.basePath) {
28
30
  url = new URL(url);
29
31
  url.pathname = utils.applyBasePath(url.pathname, request.nextUrl.basePath);
@@ -22,7 +22,7 @@ function createMiddleware(input) {
22
22
  locale
23
23
  } = resolveLocale.default(config$1, request.headers, request.cookies, externalPathname);
24
24
  const hasMatchedDefaultLocale = domain ? domain.defaultLocale === locale : locale === config$1.defaultLocale;
25
- const domainConfigs = ((_config$domains = config$1.domains) === null || _config$domains === void 0 ? void 0 : _config$domains.filter(curDomain => utils.isLocaleSupportedOnDomain(locale, curDomain))) || [];
25
+ const domainsConfig = ((_config$domains = config$1.domains) === null || _config$domains === void 0 ? void 0 : _config$domains.filter(curDomain => utils.isLocaleSupportedOnDomain(locale, curDomain))) || [];
26
26
  const hasUnknownHost = config$1.domains != null && !domain;
27
27
  function rewrite(url) {
28
28
  const urlObj = new URL(url, request.url);
@@ -38,9 +38,9 @@ function createMiddleware(input) {
38
38
  });
39
39
  }
40
40
  function redirect(url, redirectDomain) {
41
- const urlObj = new URL(utils.normalizeTrailingSlash(url), request.url);
42
- if (domainConfigs.length > 0 && !redirectDomain) {
43
- const bestMatchingDomain = utils.getBestMatchingDomain(domain, locale, domainConfigs);
41
+ const urlObj = new URL(utils$1.normalizeTrailingSlash(url), request.url);
42
+ if (domainsConfig.length > 0 && !redirectDomain) {
43
+ const bestMatchingDomain = utils.getBestMatchingDomain(domain, locale, domainsConfig);
44
44
  if (bestMatchingDomain) {
45
45
  redirectDomain = bestMatchingDomain.domain;
46
46
  if (bestMatchingDomain.defaultLocale === locale && config$1.localePrefix.mode === 'as-needed') {
@@ -114,7 +114,7 @@ function createMiddleware(input) {
114
114
  response = redirect(utils.formatPathname(unprefixedExternalPathname, undefined, request.nextUrl.search));
115
115
  } else {
116
116
  if (config$1.domains) {
117
- const pathDomain = utils.getBestMatchingDomain(domain, pathnameMatch.locale, domainConfigs);
117
+ const pathDomain = utils.getBestMatchingDomain(domain, pathnameMatch.locale, domainsConfig);
118
118
  if ((domain === null || domain === void 0 ? void 0 : domain.domain) !== (pathDomain === null || pathDomain === void 0 ? void 0 : pathDomain.domain) && !hasUnknownHost) {
119
119
  response = redirect(externalHref, pathDomain === null || pathDomain === void 0 ? void 0 : pathDomain.domain);
120
120
  } else {
@@ -4,54 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var utils = require('../shared/utils.js');
6
6
 
7
- function isOptionalCatchAllSegment(pathname) {
8
- return pathname.includes('[[...');
9
- }
10
- function isCatchAllSegment(pathname) {
11
- return pathname.includes('[...');
12
- }
13
- function isDynamicSegment(pathname) {
14
- return pathname.includes('[');
15
- }
16
- function comparePathnamePairs(a, b) {
17
- const pathA = a.split('/');
18
- const pathB = b.split('/');
19
- const maxLength = Math.max(pathA.length, pathB.length);
20
- for (let i = 0; i < maxLength; i++) {
21
- const segmentA = pathA[i];
22
- const segmentB = pathB[i];
23
-
24
- // If one of the paths ends, prioritize the shorter path
25
- if (!segmentA && segmentB) return -1;
26
- if (segmentA && !segmentB) return 1;
27
-
28
- // Prioritize static segments over dynamic segments
29
- if (!isDynamicSegment(segmentA) && isDynamicSegment(segmentB)) return -1;
30
- if (isDynamicSegment(segmentA) && !isDynamicSegment(segmentB)) return 1;
31
-
32
- // Prioritize non-catch-all segments over catch-all segments
33
- if (!isCatchAllSegment(segmentA) && isCatchAllSegment(segmentB)) return -1;
34
- if (isCatchAllSegment(segmentA) && !isCatchAllSegment(segmentB)) return 1;
35
-
36
- // Prioritize non-optional catch-all segments over optional catch-all segments
37
- if (!isOptionalCatchAllSegment(segmentA) && isOptionalCatchAllSegment(segmentB)) {
38
- return -1;
39
- }
40
- if (isOptionalCatchAllSegment(segmentA) && !isOptionalCatchAllSegment(segmentB)) {
41
- return 1;
42
- }
43
- if (segmentA === segmentB) continue;
44
- }
45
-
46
- // Both pathnames are completely static
47
- return 0;
48
- }
49
- function getSortedPathnames(pathnames) {
50
- const sortedPathnames = pathnames.sort(comparePathnamePairs);
51
- return sortedPathnames;
52
- }
53
7
  function getInternalTemplate(pathnames, pathname, locale) {
54
- const sortedPathnames = getSortedPathnames(Object.keys(pathnames));
8
+ const sortedPathnames = utils.getSortedPathnames(Object.keys(pathnames));
55
9
 
56
10
  // Try to find a localized pathname that matches
57
11
  for (const internalPathname of sortedPathnames) {
@@ -81,7 +35,7 @@ function getInternalTemplate(pathnames, pathname, locale) {
81
35
  }
82
36
 
83
37
  // Try to find an internal pathname that matches (this can be the case
84
- // if all localized pathnames are different from the internal pathnames).
38
+ // if all localized pathnames are different from the internal pathnames)
85
39
  for (const internalPathname of Object.keys(pathnames)) {
86
40
  if (utils.matchesPathname(internalPathname, pathname)) {
87
41
  return [undefined, internalPathname];
@@ -95,7 +49,11 @@ function formatTemplatePathname(sourcePathname, sourceTemplate, targetTemplate,
95
49
  const params = getRouteParams(sourceTemplate, sourcePathname);
96
50
  let targetPathname = '';
97
51
  targetPathname += formatPathnameTemplate(targetTemplate, params);
98
- targetPathname = normalizeTrailingSlash(targetPathname);
52
+
53
+ // A pathname with an optional catchall like `/categories/[[...slug]]`
54
+ // should be normalized to `/categories` if the catchall is not present
55
+ // and no trailing slash is configured
56
+ targetPathname = utils.normalizeTrailingSlash(targetPathname);
99
57
  return targetPathname;
100
58
  }
101
59
 
@@ -116,7 +74,7 @@ function getNormalizedPathname(pathname, locales, localePrefix) {
116
74
  const match = pathname.match(regex);
117
75
  let result = match ? '/' + match[2] : pathname;
118
76
  if (result !== '/') {
119
- result = normalizeTrailingSlash(result);
77
+ result = utils.normalizeTrailingSlash(result);
120
78
  }
121
79
  return result;
122
80
  }
@@ -148,13 +106,15 @@ function getPathnameMatch(pathname, locales, localePrefix) {
148
106
  }
149
107
  }
150
108
  function getRouteParams(template, pathname) {
151
- const regex = utils.templateToRegex(template);
152
- const match = regex.exec(pathname);
109
+ const normalizedPathname = utils.normalizeTrailingSlash(pathname);
110
+ const normalizedTemplate = utils.normalizeTrailingSlash(template);
111
+ const regex = utils.templateToRegex(normalizedTemplate);
112
+ const match = regex.exec(normalizedPathname);
153
113
  if (!match) return undefined;
154
114
  const params = {};
155
115
  for (let i = 1; i < match.length; i++) {
156
- var _template$match;
157
- const key = (_template$match = template.match(/\[([^\]]+)\]/g)) === null || _template$match === void 0 ? void 0 : _template$match[i - 1].replace(/[[\]]/g, '');
116
+ var _normalizedTemplate$m;
117
+ const key = (_normalizedTemplate$m = normalizedTemplate.match(/\[([^\]]+)\]/g)) === null || _normalizedTemplate$m === void 0 ? void 0 : _normalizedTemplate$m[i - 1].replace(/[[\]]/g, '');
158
118
  if (key) params[key] = match[i];
159
119
  }
160
120
  return params;
@@ -189,7 +149,7 @@ function getHost(requestHeaders) {
189
149
  function isLocaleSupportedOnDomain(locale, domain) {
190
150
  return domain.defaultLocale === locale || !domain.locales || domain.locales.includes(locale);
191
151
  }
192
- function getBestMatchingDomain(curHostDomain, locale, domainConfigs) {
152
+ function getBestMatchingDomain(curHostDomain, locale, domainsConfig) {
193
153
  let domainConfig;
194
154
 
195
155
  // Prio 1: Stay on current domain
@@ -199,12 +159,12 @@ function getBestMatchingDomain(curHostDomain, locale, domainConfigs) {
199
159
 
200
160
  // Prio 2: Use alternative domain with matching default locale
201
161
  if (!domainConfig) {
202
- domainConfig = domainConfigs.find(cur => cur.defaultLocale === locale);
162
+ domainConfig = domainsConfig.find(cur => cur.defaultLocale === locale);
203
163
  }
204
164
 
205
165
  // Prio 3: Use alternative domain with restricted matching locale
206
166
  if (!domainConfig) {
207
- domainConfig = domainConfigs.find(cur => cur.locales != null && cur.locales.includes(locale));
167
+ domainConfig = domainsConfig.find(cur => cur.locales != null && cur.locales.includes(locale));
208
168
  }
209
169
 
210
170
  // Prio 4: Stay on the current domain if it supports all locales
@@ -214,25 +174,18 @@ function getBestMatchingDomain(curHostDomain, locale, domainConfigs) {
214
174
 
215
175
  // Prio 5: Use alternative domain that supports all locales
216
176
  if (!domainConfig) {
217
- domainConfig = domainConfigs.find(cur => !cur.locales);
177
+ domainConfig = domainsConfig.find(cur => !cur.locales);
218
178
  }
219
179
  return domainConfig;
220
180
  }
221
181
  function applyBasePath(pathname, basePath) {
222
- return normalizeTrailingSlash(basePath + pathname);
223
- }
224
- function normalizeTrailingSlash(pathname) {
225
- if (pathname !== '/' && pathname.endsWith('/')) {
226
- pathname = pathname.slice(0, -1);
227
- }
228
- return pathname;
182
+ return utils.normalizeTrailingSlash(basePath + pathname);
229
183
  }
230
184
  function getLocaleAsPrefix(locale) {
231
185
  return "/".concat(locale);
232
186
  }
233
187
 
234
188
  exports.applyBasePath = applyBasePath;
235
- exports.comparePathnamePairs = comparePathnamePairs;
236
189
  exports.formatPathname = formatPathname;
237
190
  exports.formatPathnameTemplate = formatPathnameTemplate;
238
191
  exports.formatTemplatePathname = formatTemplatePathname;
@@ -244,6 +197,4 @@ exports.getLocalePrefixes = getLocalePrefixes;
244
197
  exports.getNormalizedPathname = getNormalizedPathname;
245
198
  exports.getPathnameMatch = getPathnameMatch;
246
199
  exports.getRouteParams = getRouteParams;
247
- exports.getSortedPathnames = getSortedPathnames;
248
200
  exports.isLocaleSupportedOnDomain = isLocaleSupportedOnDomain;
249
- exports.normalizeTrailingSlash = normalizeTrailingSlash;
@@ -125,11 +125,7 @@ function createLocalizedPathnamesNavigation(input) {
125
125
  const locale = useTypedLocale();
126
126
 
127
127
  // @ts-expect-error -- Mirror the behavior from Next.js, where `null` is returned when `usePathname` is used outside of Next, but the types indicate that a string is always returned.
128
- return pathname ? utils.getRoute({
129
- pathname,
130
- locale,
131
- pathnames: config$1.pathnames
132
- }) : pathname;
128
+ return pathname ? utils.getRoute(locale, pathname, config$1.pathnames) : pathname;
133
129
  }
134
130
  function getPathname(_ref2) {
135
131
  let {
@@ -8,7 +8,7 @@ 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
- const localizedPathname = params.localePrefix.mode === 'never' || !utils.isLocalHref(params.pathname) ? params.pathname : utils.prefixPathname(prefix, params.pathname);
11
+ const localizedPathname = params.localePrefix.mode === 'never' || !utils.isLocalizableHref(params.pathname) ? params.pathname : utils.prefixPathname(prefix, params.pathname);
12
12
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
13
13
  args[_key - 1] = arguments[_key];
14
14
  }
@@ -84,23 +84,23 @@ function compileLocalizedPathname(_ref) {
84
84
  return result;
85
85
  }
86
86
  }
87
- function getRoute(_ref3) {
88
- var _Object$entries$find;
89
- let {
90
- locale,
91
- pathname,
92
- pathnames
93
- } = _ref3;
87
+ function getRoute(locale, pathname, pathnames) {
88
+ const sortedPathnames = utils.getSortedPathnames(Object.keys(pathnames));
94
89
  const decoded = decodeURI(pathname);
95
- let template = (_Object$entries$find = Object.entries(pathnames).find(_ref4 => {
96
- let [, routePath] = _ref4;
97
- const routePathname = typeof routePath !== 'string' ? routePath[locale] : routePath;
98
- return utils.matchesPathname(routePathname, decoded);
99
- })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
100
- if (!template) {
101
- template = pathname;
90
+ for (const internalPathname of sortedPathnames) {
91
+ const localizedPathnamesOrPathname = pathnames[internalPathname];
92
+ if (typeof localizedPathnamesOrPathname === 'string') {
93
+ const localizedPathname = localizedPathnamesOrPathname;
94
+ if (utils.matchesPathname(localizedPathname, decoded)) {
95
+ return internalPathname;
96
+ }
97
+ } else {
98
+ if (utils.matchesPathname(localizedPathnamesOrPathname[locale], decoded)) {
99
+ return internalPathname;
100
+ }
101
+ }
102
102
  }
103
- return template;
103
+ return pathname;
104
104
  }
105
105
  function getBasePath(pathname) {
106
106
  let windowPathname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : window.location.pathname;
@@ -36,45 +36,49 @@ function resolveI18nPath(providedPath, cwd) {
36
36
  }
37
37
  function initPlugin(i18nPath, nextConfig) {
38
38
  if ((nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) != null) {
39
- console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/examples/example-app-router-migration\n");
39
+ console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");
40
40
  }
41
41
  const useTurbo = process.env.TURBOPACK != null;
42
- let nextIntlConfig;
42
+ const nextIntlConfig = {};
43
+
44
+ // Assign alias for `next-intl/config`
43
45
  if (useTurbo) {
44
46
  var _nextConfig$experimen, _nextConfig$experimen2;
45
47
  if (i18nPath && i18nPath.startsWith('/')) {
46
48
  throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: " + i18nPath + '\n');
47
49
  }
48
- nextIntlConfig = {
49
- experimental: {
50
- ...(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental),
51
- turbo: {
52
- ...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen = nextConfig.experimental) === null || _nextConfig$experimen === void 0 ? void 0 : _nextConfig$experimen.turbo),
53
- resolveAlias: {
54
- ...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen2 = nextConfig.experimental) === null || _nextConfig$experimen2 === void 0 || (_nextConfig$experimen2 = _nextConfig$experimen2.turbo) === null || _nextConfig$experimen2 === void 0 ? void 0 : _nextConfig$experimen2.resolveAlias),
55
- // Turbo aliases don't work with absolute
56
- // paths (see error handling above)
57
- 'next-intl/config': resolveI18nPath(i18nPath)
58
- }
50
+ nextIntlConfig.experimental = {
51
+ ...(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.experimental),
52
+ turbo: {
53
+ ...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen = nextConfig.experimental) === null || _nextConfig$experimen === void 0 ? void 0 : _nextConfig$experimen.turbo),
54
+ resolveAlias: {
55
+ ...(nextConfig === null || nextConfig === void 0 || (_nextConfig$experimen2 = nextConfig.experimental) === null || _nextConfig$experimen2 === void 0 || (_nextConfig$experimen2 = _nextConfig$experimen2.turbo) === null || _nextConfig$experimen2 === void 0 ? void 0 : _nextConfig$experimen2.resolveAlias),
56
+ // Turbo aliases don't work with absolute
57
+ // paths (see error handling above)
58
+ 'next-intl/config': resolveI18nPath(i18nPath)
59
59
  }
60
60
  }
61
61
  };
62
62
  } else {
63
- nextIntlConfig = {
64
- webpack() {
65
- for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
66
- _ref[_key] = arguments[_key];
67
- }
68
- let [config, options] = _ref;
69
- // Webpack requires absolute paths
70
- config.resolve.alias['next-intl/config'] = path__default.default.resolve(config.context, resolveI18nPath(i18nPath, config.context));
71
- if (typeof (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.webpack) === 'function') {
72
- return nextConfig.webpack(config, options);
73
- }
74
- return config;
63
+ nextIntlConfig.webpack = function webpack() {
64
+ for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
65
+ _ref[_key] = arguments[_key];
75
66
  }
67
+ let [config, options] = _ref;
68
+ // Webpack requires absolute paths
69
+ config.resolve.alias['next-intl/config'] = path__default.default.resolve(config.context, resolveI18nPath(i18nPath, config.context));
70
+ if (typeof (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.webpack) === 'function') {
71
+ return nextConfig.webpack(config, options);
72
+ }
73
+ return config;
76
74
  };
77
75
  }
76
+
77
+ // Forward config
78
+ nextIntlConfig.env = {
79
+ ...(nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.env),
80
+ _next_intl_trailing_slash: nextConfig !== null && nextConfig !== void 0 && nextConfig.trailingSlash ? 'true' : undefined
81
+ };
78
82
  return Object.assign({}, nextConfig, nextIntlConfig);
79
83
  }
80
84
  module.exports = function createNextIntlPlugin(i18nPath) {
@@ -62,11 +62,33 @@ function prefixPathname(prefix, pathname) {
62
62
  function hasPathnamePrefixed(prefix, pathname) {
63
63
  return pathname === prefix || pathname.startsWith("".concat(prefix, "/"));
64
64
  }
65
+ function hasTrailingSlash() {
66
+ try {
67
+ // Provided via `env` setting in `next.config.js` via the plugin
68
+ return process.env._next_intl_trailing_slash === 'true';
69
+ } catch (e) {
70
+ return false;
71
+ }
72
+ }
73
+ function normalizeTrailingSlash(pathname) {
74
+ const trailingSlash = hasTrailingSlash();
75
+ if (pathname !== '/') {
76
+ const pathnameEndsWithSlash = pathname.endsWith('/');
77
+ if (trailingSlash && !pathnameEndsWithSlash) {
78
+ pathname += '/';
79
+ } else if (!trailingSlash && pathnameEndsWithSlash) {
80
+ pathname = pathname.slice(0, -1);
81
+ }
82
+ }
83
+ return pathname;
84
+ }
65
85
  function matchesPathname( /** E.g. `/users/[userId]-[userName]` */
66
86
  template, /** E.g. `/users/23-jane` */
67
87
  pathname) {
68
- const regex = templateToRegex(template);
69
- return regex.test(pathname);
88
+ const normalizedTemplate = normalizeTrailingSlash(template);
89
+ const normalizedPathname = normalizeTrailingSlash(pathname);
90
+ const regex = templateToRegex(normalizedTemplate);
91
+ return regex.test(normalizedPathname);
70
92
  }
71
93
  function getLocalePrefix(locale, localePrefix) {
72
94
  var _localePrefix$prefixe;
@@ -85,14 +107,60 @@ function templateToRegex(template) {
85
107
  .replace(/\[([^\]]+)\]/g, '([^/]+)');
86
108
  return new RegExp("^".concat(regexPattern, "$"));
87
109
  }
110
+ function isOptionalCatchAllSegment(pathname) {
111
+ return pathname.includes('[[...');
112
+ }
113
+ function isCatchAllSegment(pathname) {
114
+ return pathname.includes('[...');
115
+ }
116
+ function isDynamicSegment(pathname) {
117
+ return pathname.includes('[');
118
+ }
119
+ function comparePathnamePairs(a, b) {
120
+ const pathA = a.split('/');
121
+ const pathB = b.split('/');
122
+ const maxLength = Math.max(pathA.length, pathB.length);
123
+ for (let i = 0; i < maxLength; i++) {
124
+ const segmentA = pathA[i];
125
+ const segmentB = pathB[i];
126
+
127
+ // If one of the paths ends, prioritize the shorter path
128
+ if (!segmentA && segmentB) return -1;
129
+ if (segmentA && !segmentB) return 1;
130
+ if (!segmentA && !segmentB) continue;
131
+
132
+ // Prioritize static segments over dynamic segments
133
+ if (!isDynamicSegment(segmentA) && isDynamicSegment(segmentB)) return -1;
134
+ if (isDynamicSegment(segmentA) && !isDynamicSegment(segmentB)) return 1;
135
+
136
+ // Prioritize non-catch-all segments over catch-all segments
137
+ if (!isCatchAllSegment(segmentA) && isCatchAllSegment(segmentB)) return -1;
138
+ if (isCatchAllSegment(segmentA) && !isCatchAllSegment(segmentB)) return 1;
139
+
140
+ // Prioritize non-optional catch-all segments over optional catch-all segments
141
+ if (!isOptionalCatchAllSegment(segmentA) && isOptionalCatchAllSegment(segmentB)) {
142
+ return -1;
143
+ }
144
+ if (isOptionalCatchAllSegment(segmentA) && !isOptionalCatchAllSegment(segmentB)) {
145
+ return 1;
146
+ }
147
+ if (segmentA === segmentB) continue;
148
+ }
149
+
150
+ // Both pathnames are completely static
151
+ return 0;
152
+ }
153
+ function getSortedPathnames(pathnames) {
154
+ return pathnames.sort(comparePathnamePairs);
155
+ }
88
156
 
89
157
  exports.getLocalePrefix = getLocalePrefix;
158
+ exports.getSortedPathnames = getSortedPathnames;
90
159
  exports.hasPathnamePrefixed = hasPathnamePrefixed;
91
- exports.isLocalHref = isLocalHref;
92
160
  exports.isLocalizableHref = isLocalizableHref;
93
- exports.isRelativeHref = isRelativeHref;
94
161
  exports.localizeHref = localizeHref;
95
162
  exports.matchesPathname = matchesPathname;
163
+ exports.normalizeTrailingSlash = normalizeTrailingSlash;
96
164
  exports.prefixHref = prefixHref;
97
165
  exports.prefixPathname = prefixPathname;
98
166
  exports.templateToRegex = templateToRegex;
@@ -1 +1 @@
1
- import{getHost as e,getNormalizedPathname as a,getLocalePrefixes as t,isLocaleSupportedOnDomain as o,applyBasePath as n,formatTemplatePathname as l}from"./utils.js";function r(r){var c;let{config:f,localizedPathnames:p,request:s,resolvedLocale:i}=r;const m=s.nextUrl.clone(),h=e(s.headers);function d(e,a){return s.nextUrl.basePath&&((e=new URL(e)).pathname=n(e.pathname,s.nextUrl.basePath)),"<".concat(e.toString(),'>; rel="alternate"; hreflang="').concat(a,'"')}function u(e,a){return p&&"object"==typeof p?l(e,p[i],p[a]):e}h&&(m.port="",m.host=h),m.protocol=null!==(c=s.headers.get("x-forwarded-proto"))&&void 0!==c?c:m.protocol,m.pathname=a(m.pathname,f.locales,f.localePrefix);const x=t(f.locales,f.localePrefix).flatMap((e=>{let a,[t,n]=e;function l(e){return"/"===e?n:n+e}if(f.domains){return(f.domains.filter((e=>o(t,e)))||[]).map((e=>(a=new URL(m),a.port="",a.host=e.domain,a.pathname=u(m.pathname,t),t===e.defaultLocale&&"always"!==f.localePrefix.mode||(a.pathname=l(a.pathname)),d(a,t))))}{let e;e=p&&"object"==typeof p?u(m.pathname,t):m.pathname,t===f.defaultLocale&&"always"!==f.localePrefix.mode||(e=l(e)),a=new URL(e,m)}return d(a,t)}));if(!f.domains&&("always"!==f.localePrefix.mode||"/"===m.pathname)){const e=new URL(u(m.pathname,f.defaultLocale),m);x.push(d(e,"x-default"))}return x.join(", ")}export{r as default};
1
+ import{normalizeTrailingSlash as e}from"../shared/utils.js";import{getHost as a,getNormalizedPathname as t,getLocalePrefixes as o,isLocaleSupportedOnDomain as n,applyBasePath as l,formatTemplatePathname as r}from"./utils.js";function c(c){var m;let{config:p,localizedPathnames:s,request:f,resolvedLocale:i}=c;const h=f.nextUrl.clone(),d=a(f.headers);function u(a,t){return a.pathname=e(a.pathname),f.nextUrl.basePath&&((a=new URL(a)).pathname=l(a.pathname,f.nextUrl.basePath)),"<".concat(a.toString(),'>; rel="alternate"; hreflang="').concat(t,'"')}function x(e,a){return s&&"object"==typeof s?r(e,s[i],s[a]):e}d&&(h.port="",h.host=d),h.protocol=null!==(m=f.headers.get("x-forwarded-proto"))&&void 0!==m?m:h.protocol,h.pathname=t(h.pathname,p.locales,p.localePrefix);const w=o(p.locales,p.localePrefix).flatMap((e=>{let a,[t,o]=e;function l(e){return"/"===e?o:o+e}if(p.domains){return(p.domains.filter((e=>n(t,e)))||[]).map((e=>(a=new URL(h),a.port="",a.host=e.domain,a.pathname=x(h.pathname,t),t===e.defaultLocale&&"always"!==p.localePrefix.mode||(a.pathname=l(a.pathname)),u(a,t))))}{let e;e=s&&"object"==typeof s?x(h.pathname,t):h.pathname,t===p.defaultLocale&&"always"!==p.localePrefix.mode||(e=l(e)),a=new URL(e,h)}return u(a,t)}));if(!p.domains&&("always"!==p.localePrefix.mode||"/"===h.pathname)){const e=new URL(x(h.pathname,p.defaultLocale),h);w.push(u(e,"x-default"))}return w.join(", ")}export{c as default};
@@ -1 +1 @@
1
- import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,getLocalePrefix as r}from"../shared/utils.js";import{receiveConfig as t}from"./config.js";import a from"./getAlternateLinksHeaderValue.js";import n from"./resolveLocale.js";import s from"./syncCookie.js";import{isLocaleSupportedOnDomain as i,getNormalizedPathname as c,getPathnameMatch as d,getInternalTemplate as f,formatTemplatePathname as m,formatPathname as h,getBestMatchingDomain as x,applyBasePath as u,normalizeTrailingSlash as p,getLocaleAsPrefix as v}from"./utils.js";function U(U){const P=t(U);return function(t){var U;const g=decodeURI(t.nextUrl.pathname),{domain:L,locale:j}=n(P,t.headers,t.cookies,g),w=L?L.defaultLocale===j:j===P.defaultLocale,k=(null===(U=P.domains)||void 0===U?void 0:U.filter((e=>i(j,e))))||[],b=null!=P.domains&&!L;function y(l){const r=new URL(l,t.url);t.nextUrl.basePath&&(r.pathname=u(r.pathname,t.nextUrl.basePath));const a=new Headers(t.headers);return a.set(o,j),e.rewrite(r,{request:{headers:a}})}function R(o,l){const r=new URL(p(o),t.url);if(k.length>0&&!l){const e=x(L,j,k);e&&(l=e.domain,e.defaultLocale===j&&"as-needed"===P.localePrefix.mode&&(r.pathname=c(r.pathname,P.locales,P.localePrefix)))}var a,n;l&&(r.host=l,t.headers.get("x-forwarded-host")&&(r.protocol=null!==(a=t.headers.get("x-forwarded-proto"))&&void 0!==a?a:t.nextUrl.protocol,r.port=null!==(n=t.headers.get("x-forwarded-port"))&&void 0!==n?n:""));return t.nextUrl.basePath&&(r.pathname=u(r.pathname,t.nextUrl.basePath)),e.redirect(r.toString())}const q=c(g,P.locales,P.localePrefix),H=d(g,P.locales,P.localePrefix),z=null!=H,A="never"===P.localePrefix.mode||w&&"as-needed"===P.localePrefix.mode;let C,D,I=q;if(P.pathnames){let e;if([e,D]=f(P.pathnames,q,j),D){const o=P.pathnames[D],a="string"==typeof o?o:o[j];if(l(a,q))I=m(q,a,D);else{let l;l=e?"string"==typeof o?o:o[e]:D;const n=A?void 0:r(j,P.localePrefix),s=m(q,l,a);C=R(h(s,n,t.nextUrl.search))}}}if(!C)if("/"!==I||z){const e=h(I,v(j),t.nextUrl.search);if(z){const o=h(q,H.prefix,t.nextUrl.search);if("never"===P.localePrefix.mode)C=R(h(q,void 0,t.nextUrl.search));else if(H.exact)if(w&&A)C=R(h(q,void 0,t.nextUrl.search));else if(P.domains){const l=x(L,H.locale,k);C=(null==L?void 0:L.domain)===(null==l?void 0:l.domain)||b?y(e):R(o,null==l?void 0:l.domain)}else C=y(e);else C=R(o)}else C=A?y(e):R(h(q,r(j,P.localePrefix),t.nextUrl.search))}else C=A?y(h(I,v(j),t.nextUrl.search)):R(h(q,r(j,P.localePrefix),t.nextUrl.search));var S;(P.localeDetection&&s(t,C,j),"never"!==P.localePrefix.mode&&P.alternateLinks&&P.locales.length>1)&&C.headers.set("Link",a({config:P,localizedPathnames:null!=D?null===(S=P.pathnames)||void 0===S?void 0:S[D]:void 0,request:t,resolvedLocale:j}));return C}}export{U as default};
1
+ import{NextResponse as e}from"next/server";import{HEADER_LOCALE_NAME as o}from"../shared/constants.js";import{matchesPathname as l,normalizeTrailingSlash as r,getLocalePrefix as t}from"../shared/utils.js";import{receiveConfig as a}from"./config.js";import n from"./getAlternateLinksHeaderValue.js";import s from"./resolveLocale.js";import i from"./syncCookie.js";import{isLocaleSupportedOnDomain as c,getNormalizedPathname as d,getPathnameMatch as f,getInternalTemplate as m,formatTemplatePathname as h,formatPathname as x,getBestMatchingDomain as u,applyBasePath as p,getLocaleAsPrefix as v}from"./utils.js";function U(U){const P=a(U);return function(a){var U;const g=decodeURI(a.nextUrl.pathname),{domain:L,locale:j}=s(P,a.headers,a.cookies,g),w=L?L.defaultLocale===j:j===P.defaultLocale,k=(null===(U=P.domains)||void 0===U?void 0:U.filter((e=>c(j,e))))||[],b=null!=P.domains&&!L;function y(l){const r=new URL(l,a.url);a.nextUrl.basePath&&(r.pathname=p(r.pathname,a.nextUrl.basePath));const t=new Headers(a.headers);return t.set(o,j),e.rewrite(r,{request:{headers:t}})}function R(o,l){const t=new URL(r(o),a.url);if(k.length>0&&!l){const e=u(L,j,k);e&&(l=e.domain,e.defaultLocale===j&&"as-needed"===P.localePrefix.mode&&(t.pathname=d(t.pathname,P.locales,P.localePrefix)))}var n,s;l&&(t.host=l,a.headers.get("x-forwarded-host")&&(t.protocol=null!==(n=a.headers.get("x-forwarded-proto"))&&void 0!==n?n:a.nextUrl.protocol,t.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(t.pathname=p(t.pathname,a.nextUrl.basePath)),e.redirect(t.toString())}const q=d(g,P.locales,P.localePrefix),H=f(g,P.locales,P.localePrefix),z=null!=H,A="never"===P.localePrefix.mode||w&&"as-needed"===P.localePrefix.mode;let C,D,I=q;if(P.pathnames){let e;if([e,D]=m(P.pathnames,q,j),D){const o=P.pathnames[D],r="string"==typeof o?o:o[j];if(l(r,q))I=h(q,r,D);else{let l;l=e?"string"==typeof o?o:o[e]:D;const n=A?void 0:t(j,P.localePrefix),s=h(q,l,r);C=R(x(s,n,a.nextUrl.search))}}}if(!C)if("/"!==I||z){const e=x(I,v(j),a.nextUrl.search);if(z){const o=x(q,H.prefix,a.nextUrl.search);if("never"===P.localePrefix.mode)C=R(x(q,void 0,a.nextUrl.search));else if(H.exact)if(w&&A)C=R(x(q,void 0,a.nextUrl.search));else if(P.domains){const l=u(L,H.locale,k);C=(null==L?void 0:L.domain)===(null==l?void 0:l.domain)||b?y(e):R(o,null==l?void 0:l.domain)}else C=y(e);else C=R(o)}else C=A?y(e):R(x(q,t(j,P.localePrefix),a.nextUrl.search))}else C=A?y(x(I,v(j),a.nextUrl.search)):R(x(q,t(j,P.localePrefix),a.nextUrl.search));var S;(P.localeDetection&&i(a,C,j),"never"!==P.localePrefix.mode&&P.alternateLinks&&P.locales.length>1)&&C.headers.set("Link",n({config:P,localizedPathnames:null!=D?null===(S=P.pathnames)||void 0===S?void 0:S[D]:void 0,request:a,resolvedLocale:j}));return C}}export{U as default};
@@ -1 +1 @@
1
- import{matchesPathname as t,getLocalePrefix as n,templateToRegex as e,prefixPathname as r}from"../shared/utils.js";function o(t){return t.includes("[[...")}function i(t){return t.includes("[...")}function c(t){return t.includes("[")}function u(t,n){const e=t.split("/"),r=n.split("/"),u=Math.max(e.length,r.length);for(let t=0;t<u;t++){const n=e[t],u=r[t];if(!n&&u)return-1;if(n&&!u)return 1;if(!c(n)&&c(u))return-1;if(c(n)&&!c(u))return 1;if(!i(n)&&i(u))return-1;if(i(n)&&!i(u))return 1;if(!o(n)&&o(u))return-1;if(o(n)&&!o(u))return 1}return 0}function l(t){return t.sort(u)}function f(n,e,r){const o=l(Object.keys(n));for(const i of o){const o=n[i];if("string"==typeof o){if(t(o,e))return[void 0,i]}else{const n=Object.entries(o),c=n.findIndex((t=>{let[n]=t;return n===r}));c>0&&n.unshift(n.splice(c,1)[0]);for(const[r,o]of n)if(t(o,e))return[r,i]}}for(const r of Object.keys(n))if(t(r,e))return[void 0,r];return[void 0,void 0]}function s(t,n,e,r){let o="";return o+=g(e,p(n,t)),o=w(o),o}function a(t,n,e){t.endsWith("/")||(t+="/");const r=d(n,e),o=new RegExp("^(".concat(r.map((t=>{let[,n]=t;return n.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),i=t.match(o);let c=i?"/"+i[2]:t;return"/"!==c&&(c=w(c)),c}function d(t,e){return t.map((t=>[t,n(t,e)]))}function h(t,n,e){const r=d(n,e);for(const[n,e]of r){let r,o;if(t===e||t.startsWith(e+"/"))r=o=!0;else{const n=t.toLowerCase(),i=e.toLowerCase();(n===i||n.startsWith(i+"/"))&&(r=!1,o=!0)}if(o)return{locale:n,prefix:e,matchedPrefix:t.slice(0,e.length),exact:r}}}function p(t,n){const r=e(t).exec(n);if(!r)return;const o={};for(let n=1;n<r.length;n++){var i;const e=null===(i=t.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[n-1].replace(/[[\]]/g,"");e&&(o[e]=r[n])}return o}function g(t,n){if(!n)return t;let e=t=t.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(n).forEach((t=>{let[n,r]=t;e=e.replace("[".concat(n,"]"),r)})),e}function v(t,n,e){let o=t;return n&&(o=r(n,o)),e&&(o+=e),o}function x(t){var n,e;return null!==(n=null!==(e=t.get("x-forwarded-host"))&&void 0!==e?e:t.get("host"))&&void 0!==n?n:void 0}function m(t,n){return n.defaultLocale===t||!n.locales||n.locales.includes(t)}function j(t,n,e){let r;return t&&m(n,t)&&(r=t),r||(r=e.find((t=>t.defaultLocale===n))),r||(r=e.find((t=>null!=t.locales&&t.locales.includes(n)))),r||null!=(null==t?void 0:t.locales)||(r=t),r||(r=e.find((t=>!t.locales))),r}function b(t,n){return w(n+t)}function w(t){return"/"!==t&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function L(t){return"/".concat(t)}export{b as applyBasePath,u as comparePathnamePairs,v as formatPathname,g as formatPathnameTemplate,s as formatTemplatePathname,j as getBestMatchingDomain,x as getHost,f as getInternalTemplate,L as getLocaleAsPrefix,d as getLocalePrefixes,a as getNormalizedPathname,h as getPathnameMatch,p as getRouteParams,l as getSortedPathnames,m as isLocaleSupportedOnDomain,w as normalizeTrailingSlash};
1
+ import{getSortedPathnames as t,matchesPathname as e,normalizeTrailingSlash as n,getLocalePrefix as o,templateToRegex as r,prefixPathname as c}from"../shared/utils.js";function l(n,o,r){const c=t(Object.keys(n));for(const t of c){const c=n[t];if("string"==typeof c){if(e(c,o))return[void 0,t]}else{const n=Object.entries(c),l=n.findIndex((t=>{let[e]=t;return e===r}));l>0&&n.unshift(n.splice(l,1)[0]);for(const[r,c]of n)if(e(c,o))return[r,t]}}for(const t of Object.keys(n))if(e(t,o))return[void 0,t];return[void 0,void 0]}function i(t,e,o,r){let c="";return c+=d(o,a(e,t)),c=n(c),c}function u(t,e,o){t.endsWith("/")||(t+="/");const r=f(e,o),c=new RegExp("^(".concat(r.map((t=>{let[,e]=t;return e.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),l=t.match(c);let i=l?"/"+l[2]:t;return"/"!==i&&(i=n(i)),i}function f(t,e){return t.map((t=>[t,o(t,e)]))}function s(t,e,n){const o=f(e,n);for(const[e,n]of o){let o,r;if(t===n||t.startsWith(n+"/"))o=r=!0;else{const e=t.toLowerCase(),c=n.toLowerCase();(e===c||e.startsWith(c+"/"))&&(o=!1,r=!0)}if(r)return{locale:e,prefix:n,matchedPrefix:t.slice(0,n.length),exact:o}}}function a(t,e){const o=n(e),c=n(t),l=r(c).exec(o);if(!l)return;const i={};for(let t=1;t<l.length;t++){var u;const e=null===(u=c.match(/\[([^\]]+)\]/g))||void 0===u?void 0:u[t-1].replace(/[[\]]/g,"");e&&(i[e]=l[t])}return i}function d(t,e){if(!e)return t;let n=t=t.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(e).forEach((t=>{let[e,o]=t;n=n.replace("[".concat(e,"]"),o)})),n}function h(t,e,n){let o=t;return e&&(o=c(e,o)),n&&(o+=n),o}function p(t){var e,n;return null!==(e=null!==(n=t.get("x-forwarded-host"))&&void 0!==n?n:t.get("host"))&&void 0!==e?e:void 0}function v(t,e){return e.defaultLocale===t||!e.locales||e.locales.includes(t)}function g(t,e,n){let o;return t&&v(e,t)&&(o=t),o||(o=n.find((t=>t.defaultLocale===e))),o||(o=n.find((t=>null!=t.locales&&t.locales.includes(e)))),o||null!=(null==t?void 0:t.locales)||(o=t),o||(o=n.find((t=>!t.locales))),o}function x(t,e){return n(e+t)}function m(t){return"/".concat(t)}export{x as applyBasePath,h as formatPathname,d as formatPathnameTemplate,i as formatTemplatePathname,g as getBestMatchingDomain,p as getHost,l as getInternalTemplate,m as getLocaleAsPrefix,f as getLocalePrefixes,u as getNormalizedPathname,s as getPathnameMatch,a as getRouteParams,v as isLocaleSupportedOnDomain};
@@ -1 +1 @@
1
- import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o}from"react";import t from"../../react-client/useLocale.js";import{receiveLocalizedNavigationRoutingConfig as a}from"../shared/config.js";import{getRoute as n,compileLocalizedPathname as l,normalizeNameOrNameWithParams as c}from"../shared/utils.js";import i from"./ClientLink.js";import{clientRedirect as s,clientPermanentRedirect as f}from"./redirects.js";import u from"./useBasePathname.js";import m from"./useBaseRouter.js";function h(h){const p=a(h);function d(){const e=t();if(!p.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `i18n.ts`.'));return e}function v(o,t){let{href:a,locale:n,...c}=o;const s=d(),f=n||s;return r.createElement(i,e({ref:t,href:l({locale:f,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:p.pathnames}),locale:n,localePrefix:p.localePrefix},c))}const P=o(v);function x(e){let{href:r,locale:o}=e;return l({...c(r),locale:o,pathnames:p.pathnames})}return P.displayName="Link",{Link:P,redirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),a=1;a<o;a++)t[a-1]=arguments[a];return s({pathname:r,localePrefix:p.localePrefix},...t)},permanentRedirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),a=1;a<o;a++)t[a-1]=arguments[a];return f({pathname:r,localePrefix:p.localePrefix},...t)},usePathname:function(){const e=u(p.localePrefix),r=d();return e?n({pathname:e,locale:r,pathnames:p.pathnames}):e},useRouter:function(){const e=m(p.localePrefix),r=d();return{...e,push(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:x}}export{h as default};
1
+ import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o}from"react";import t from"../../react-client/useLocale.js";import{receiveLocalizedNavigationRoutingConfig as n}from"../shared/config.js";import{getRoute as a,compileLocalizedPathname as l,normalizeNameOrNameWithParams as c}from"../shared/utils.js";import i from"./ClientLink.js";import{clientRedirect as s,clientPermanentRedirect as f}from"./redirects.js";import u from"./useBasePathname.js";import m from"./useBaseRouter.js";function h(h){const p=n(h);function d(){const e=t();if(!p.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `i18n.ts`.'));return e}function v(o,t){let{href:n,locale:a,...c}=o;const s=d(),f=a||s;return r.createElement(i,e({ref:t,href:l({locale:f,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:p.pathnames}),locale:a,localePrefix:p.localePrefix},c))}const P=o(v);function x(e){let{href:r,locale:o}=e;return l({...c(r),locale:o,pathnames:p.pathnames})}return P.displayName="Link",{Link:P,redirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),n=1;n<o;n++)t[n-1]=arguments[n];return s({pathname:r,localePrefix:p.localePrefix},...t)},permanentRedirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),n=1;n<o;n++)t[n-1]=arguments[n];return f({pathname:r,localePrefix:p.localePrefix},...t)},usePathname:function(){const e=u(p.localePrefix),r=d();return e?a(r,e,p.pathnames):e},useRouter:function(){const e=m(p.localePrefix),r=d();return{...e,push(o){for(var t,n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=a[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...a)},replace(o){for(var t,n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=a[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...a)},prefetch(o){for(var t,n=arguments.length,a=new Array(n>1?n-1:0),l=1;l<n;l++)a[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=a[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...a)}}},getPathname:x}}export{h as default};
@@ -1 +1 @@
1
- import{redirect as e,permanentRedirect as n}from"next/navigation";import{getLocalePrefix as r,isLocalHref as t,prefixPathname as o}from"../../shared/utils.js";function a(e){return function(n){const a=r(n.locale,n.localePrefix),i="never"!==n.localePrefix.mode&&t(n.pathname)?o(a,n.pathname):n.pathname;for(var l=arguments.length,m=new Array(l>1?l-1:0),c=1;c<l;c++)m[c-1]=arguments[c];return e(i,...m)}}const i=a(e),l=a(n);export{l as basePermanentRedirect,i as baseRedirect};
1
+ import{redirect as e,permanentRedirect as n}from"next/navigation";import{getLocalePrefix as r,isLocalizableHref as t,prefixPathname as o}from"../../shared/utils.js";function a(e){return function(n){const a=r(n.locale,n.localePrefix),i="never"!==n.localePrefix.mode&&t(n.pathname)?o(a,n.pathname):n.pathname;for(var l=arguments.length,m=new Array(l>1?l-1:0),c=1;c<l;c++)m[c-1]=arguments[c];return e(i,...m)}}const i=a(e),l=a(n);export{l as basePermanentRedirect,i as baseRedirect};
@@ -1 +1 @@
1
- import{matchesPathname as t}from"../../shared/utils.js";function n(t){return"string"==typeof t?{pathname:t}:t}function e(t){function n(t){return String(t)}const e=new URLSearchParams;for(const[r,a]of Object.entries(t))Array.isArray(a)?a.forEach((t=>{e.append(r,n(t))})):e.set(r,n(a));return"?"+e.toString()}function r(t){let{pathname:n,locale:r,params:a,pathnames:o,query:i}=t;function c(t){let n=o[t];return n||(n=t),n}function s(t){const n="string"==typeof t?t:t[r];let o=n;if(a&&Object.entries(a).forEach((t=>{let[n,e]=t;o=Array.isArray(e)?o.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),e.map((t=>String(t))).join("/")):o.replace("[".concat(n,"]"),String(e))})),o.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(a)));return i&&(o+=e(i)),o}if("string"==typeof n){return s(c(n))}{const{pathname:t,...e}=n;return{...e,pathname:s(c(t))}}}function a(n){var e;let{locale:r,pathname:a,pathnames:o}=n;const i=decodeURI(a);let c=null===(e=Object.entries(o).find((n=>{let[,e]=n;const a="string"!=typeof e?e[r]:e;return t(a,i)})))||void 0===e?void 0:e[0];return c||(c=a),c}function o(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===t?n:n.replace(t,"")}export{r as compileLocalizedPathname,o as getBasePath,a as getRoute,n as normalizeNameOrNameWithParams,e as serializeSearchParams};
1
+ import{getSortedPathnames as t,matchesPathname as n}from"../../shared/utils.js";function r(t){return"string"==typeof t?{pathname:t}:t}function e(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 o(t){let{pathname:n,locale:r,params:o,pathnames:a,query:c}=t;function i(t){let n=a[t];return n||(n=t),n}function s(t){const n="string"==typeof t?t:t[r];let a=n;if(o&&Object.entries(o).forEach((t=>{let[n,r]=t;a=Array.isArray(r)?a.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),r.map((t=>String(t))).join("/")):a.replace("[".concat(n,"]"),String(r))})),a.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(o)));return c&&(a+=e(c)),a}if("string"==typeof n){return s(i(n))}{const{pathname:t,...r}=n;return{...r,pathname:s(i(t))}}}function a(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 c(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===t?n:n.replace(t,"")}export{o as compileLocalizedPathname,c as getBasePath,a as getRoute,r as normalizeNameOrNameWithParams,e as serializeSearchParams};
@@ -1 +1 @@
1
- import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(o){return function(n,o){let r;if(null!=(null==o?void 0:o.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/examples/example-app-router-migration\n"),null!=process.env.TURBOPACK){var i,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");r={experimental:{...null==o?void 0:o.experimental,turbo:{...null==o||null===(i=o.experimental)||void 0===i?void 0:i.turbo,resolveAlias:{...null==o||null===(s=o.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":t(n)}}}}}else r={webpack(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,u]=i;return l.resolve.alias["next-intl/config"]=e.resolve(l.context,t(n,l.context)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(l,u):l}};return Object.assign({},o,r)}(n,o)}};
1
+ import n from"fs";import e from"path";function t(t,o){function r(t){return n.existsSync(function(n){const t=[];return o&&t.push(o),t.push(n),e.resolve(...t)}(t))}if(t){if(!r(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."));return t}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(r(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(o){return function(n,o){null!=(null==o?void 0:o.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const r={};if(null!=process.env.TURBOPACK){var i,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");r.experimental={...null==o?void 0:o.experimental,turbo:{...null==o||null===(i=o.experimental)||void 0===i?void 0:i.turbo,resolveAlias:{...null==o||null===(s=o.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":t(n)}}}}else r.webpack=function(){for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];let[l,u]=i;return l.resolve.alias["next-intl/config"]=e.resolve(l.context,t(n,l.context)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(l,u):l};return r.env={...null==o?void 0:o.env,_next_intl_trailing_slash:null!=o&&o.trailingSlash?"true":void 0},Object.assign({},o,r)}(n,o)}};
@@ -1 +1 @@
1
- function t(t){const n="object"==typeof t?t.pathname:t;return null!=n&&!n.startsWith("/")}function n(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function e(e){return n(e)&&!t(e)}function r(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,u=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!e(t))return t;const l=n!==r,a=i(c,u);return(l||a)&&null!=c?o(t,c):t}function o(t,n){let e;return"string"==typeof t?e=c(n,t):(e={...t},t.pathname&&(e.pathname=c(n,t.pathname))),e}function u(t,n){return t.replace(new RegExp("^".concat(n)),"")||"/"}function c(t,n){let e=t;return/^\/(\?.*)?$/.test(n)&&(n=n.slice(1)),e+=n,e}function i(t,n){return n===t||n.startsWith("".concat(t,"/"))}function l(t,n){return f(t).test(n)}function a(t,n){var e;return"never"!==n.mode&&(null===(e=n.prefixes)||void 0===e?void 0:e[t])||"/"+t}function f(t){const n=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(n,"$"))}export{a as getLocalePrefix,i as hasPathnamePrefixed,n as isLocalHref,e as isLocalizableHref,t as isRelativeHref,r as localizeHref,l as matchesPathname,o as prefixHref,c as prefixPathname,f as templateToRegex,u as unprefixPathname};
1
+ function n(n){return function(n){return"object"==typeof n?null==n.host&&null==n.hostname:!/^[a-z]+:/i.test(n)}(n)&&!function(n){const t="object"==typeof n?n.pathname:n;return null!=t&&!t.startsWith("/")}(n)}function t(t,r){let u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r,c=arguments.length>3?arguments[3]:void 0,o=arguments.length>4?arguments[4]:void 0;if(!n(t))return t;const f=r!==u,l=i(o,c);return(f||l)&&null!=o?e(t,o):t}function e(n,t){let e;return"string"==typeof n?e=u(t,n):(e={...n},n.pathname&&(e.pathname=u(t,n.pathname))),e}function r(n,t){return n.replace(new RegExp("^".concat(t)),"")||"/"}function u(n,t){let e=n;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),e+=t,e}function i(n,t){return t===n||t.startsWith("".concat(n,"/"))}function c(n){const t=function(){try{return"true"===process.env._next_intl_trailing_slash}catch(n){return!1}}();if("/"!==n){const e=n.endsWith("/");t&&!e?n+="/":!t&&e&&(n=n.slice(0,-1))}return n}function o(n,t){const e=c(n),r=c(t);return l(e).test(r)}function f(n,t){var e;return"never"!==t.mode&&(null===(e=t.prefixes)||void 0===e?void 0:e[n])||"/"+n}function l(n){const t=n.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}function s(n){return n.includes("[[...")}function a(n){return n.includes("[...")}function p(n){return n.includes("[")}function h(n,t){const e=n.split("/"),r=t.split("/"),u=Math.max(e.length,r.length);for(let n=0;n<u;n++){const t=e[n],u=r[n];if(!t&&u)return-1;if(t&&!u)return 1;if(t||u){if(!p(t)&&p(u))return-1;if(p(t)&&!p(u))return 1;if(!a(t)&&a(u))return-1;if(a(t)&&!a(u))return 1;if(!s(t)&&s(u))return-1;if(s(t)&&!s(u))return 1}}return 0}function g(n){return n.sort(h)}export{f as getLocalePrefix,g as getSortedPathnames,i as hasPathnamePrefixed,n as isLocalizableHref,t as localizeHref,o as matchesPathname,c as normalizeTrailingSlash,e as prefixHref,u as prefixPathname,l as templateToRegex,r as unprefixPathname};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./utils.js");exports.default=function(a){var t;let{config:o,localizedPathnames:n,request:l,resolvedLocale:r}=a;const c=l.nextUrl.clone(),s=e.getHost(l.headers);function p(a,t){return l.nextUrl.basePath&&((a=new URL(a)).pathname=e.applyBasePath(a.pathname,l.nextUrl.basePath)),"<".concat(a.toString(),'>; rel="alternate"; hreflang="').concat(t,'"')}function i(a,t){return n&&"object"==typeof n?e.formatTemplatePathname(a,n[r],n[t]):a}s&&(c.port="",c.host=s),c.protocol=null!==(t=l.headers.get("x-forwarded-proto"))&&void 0!==t?t:c.protocol,c.pathname=e.getNormalizedPathname(c.pathname,o.locales,o.localePrefix);const m=e.getLocalePrefixes(o.locales,o.localePrefix).flatMap((a=>{let t,[l,r]=a;function s(e){return"/"===e?r:r+e}if(o.domains){return(o.domains.filter((a=>e.isLocaleSupportedOnDomain(l,a)))||[]).map((e=>(t=new URL(c),t.port="",t.host=e.domain,t.pathname=i(c.pathname,l),l===e.defaultLocale&&"always"!==o.localePrefix.mode||(t.pathname=s(t.pathname)),p(t,l))))}{let e;e=n&&"object"==typeof n?i(c.pathname,l):c.pathname,l===o.defaultLocale&&"always"!==o.localePrefix.mode||(e=s(e)),t=new URL(e,c)}return p(t,l)}));if(!o.domains&&("always"!==o.localePrefix.mode||"/"===c.pathname)){const e=new URL(i(c.pathname,o.defaultLocale),c);m.push(p(e,"x-default"))}return m.join(", ")};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js"),a=require("./utils.js");exports.default=function(t){var o;let{config:n,localizedPathnames:l,request:r,resolvedLocale:s}=t;const i=r.nextUrl.clone(),c=a.getHost(r.headers);function p(t,o){return t.pathname=e.normalizeTrailingSlash(t.pathname),r.nextUrl.basePath&&((t=new URL(t)).pathname=a.applyBasePath(t.pathname,r.nextUrl.basePath)),"<".concat(t.toString(),'>; rel="alternate"; hreflang="').concat(o,'"')}function m(e,t){return l&&"object"==typeof l?a.formatTemplatePathname(e,l[s],l[t]):e}c&&(i.port="",i.host=c),i.protocol=null!==(o=r.headers.get("x-forwarded-proto"))&&void 0!==o?o:i.protocol,i.pathname=a.getNormalizedPathname(i.pathname,n.locales,n.localePrefix);const h=a.getLocalePrefixes(n.locales,n.localePrefix).flatMap((e=>{let t,[o,r]=e;function s(e){return"/"===e?r:r+e}if(n.domains){return(n.domains.filter((e=>a.isLocaleSupportedOnDomain(o,e)))||[]).map((e=>(t=new URL(i),t.port="",t.host=e.domain,t.pathname=m(i.pathname,o),o===e.defaultLocale&&"always"!==n.localePrefix.mode||(t.pathname=s(t.pathname)),p(t,o))))}{let e;e=l&&"object"==typeof l?m(i.pathname,o):i.pathname,o===n.defaultLocale&&"always"!==n.localePrefix.mode||(e=s(e)),t=new URL(e,i)}return p(t,o)}));if(!n.domains&&("always"!==n.localePrefix.mode||"/"===i.pathname)){const e=new URL(m(i.pathname,n.defaultLocale),i);h.push(p(e,"x-default"))}return h.join(", ")};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),{domain:f,locale:m}=o.default(c,r.headers,r.cookies,d),h=f?f.defaultLocale===m:m===c.defaultLocale,u=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(m,e))))||[],x=null!=c.domains&&!f;function P(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(l,{request:{headers:o}})}function p(a,t){const l=new URL(s.normalizeTrailingSlash(a),r.url);if(u.length>0&&!t){const e=s.getBestMatchingDomain(f,m,u);e&&(t=e.domain,e.defaultLocale===m&&"as-needed"===c.localePrefix.mode&&(l.pathname=s.getNormalizedPathname(l.pathname,c.locales,c.localePrefix)))}var o,n;t&&(l.host=t,r.headers.get("x-forwarded-host")&&(l.protocol=null!==(o=r.headers.get("x-forwarded-proto"))&&void 0!==o?o:r.nextUrl.protocol,l.port=null!==(n=r.headers.get("x-forwarded-port"))&&void 0!==n?n:""));return r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(l.toString())}const g=s.getNormalizedPathname(d,c.locales,c.localePrefix),v=s.getPathnameMatch(d,c.locales,c.localePrefix),L=null!=v,U="never"===c.localePrefix.mode||h&&"as-needed"===c.localePrefix.mode;let q,j,w=g;if(c.pathnames){let e;if([e,j]=s.getInternalTemplate(c.pathnames,g,m),j){const a=c.pathnames[j],l="string"==typeof a?a:a[m];if(t.matchesPathname(l,g))w=s.formatTemplatePathname(g,l,j);else{let o;o=e?"string"==typeof a?a:a[e]:j;const n=U?void 0:t.getLocalePrefix(m,c.localePrefix),i=s.formatTemplatePathname(g,o,l);q=p(s.formatPathname(i,n,r.nextUrl.search))}}}if(!q)if("/"!==w||L){const e=s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search);if(L){const a=s.formatPathname(g,v.prefix,r.nextUrl.search);if("never"===c.localePrefix.mode)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(v.exact)if(h&&U)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(c.domains){const t=s.getBestMatchingDomain(f,v.locale,u);q=(null==f?void 0:f.domain)===(null==t?void 0:t.domain)||x?P(e):p(a,null==t?void 0:t.domain)}else q=P(e);else q=p(a)}else q=U?P(e):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search))}else q=U?P(s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search)):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search));var y;(c.localeDetection&&n.default(r,q,m),"never"!==c.localePrefix.mode&&c.alternateLinks&&c.locales.length>1)&&q.headers.set("Link",l.default({config:c,localizedPathnames:null!=j?null===(y=c.pathnames)||void 0===y?void 0:y[j]:void 0,request:r,resolvedLocale:m}));return q}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),{domain:f,locale:m}=o.default(c,r.headers,r.cookies,d),h=f?f.defaultLocale===m:m===c.defaultLocale,u=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(m,e))))||[],x=null!=c.domains&&!f;function P(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(l,{request:{headers:o}})}function p(a,l){const o=new URL(t.normalizeTrailingSlash(a),r.url);if(u.length>0&&!l){const e=s.getBestMatchingDomain(f,m,u);e&&(l=e.domain,e.defaultLocale===m&&"as-needed"===c.localePrefix.mode&&(o.pathname=s.getNormalizedPathname(o.pathname,c.locales,c.localePrefix)))}var n,i;l&&(o.host=l,r.headers.get("x-forwarded-host")&&(o.protocol=null!==(n=r.headers.get("x-forwarded-proto"))&&void 0!==n?n:r.nextUrl.protocol,o.port=null!==(i=r.headers.get("x-forwarded-port"))&&void 0!==i?i:""));return r.nextUrl.basePath&&(o.pathname=s.applyBasePath(o.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(o.toString())}const g=s.getNormalizedPathname(d,c.locales,c.localePrefix),v=s.getPathnameMatch(d,c.locales,c.localePrefix),L=null!=v,U="never"===c.localePrefix.mode||h&&"as-needed"===c.localePrefix.mode;let q,j,w=g;if(c.pathnames){let e;if([e,j]=s.getInternalTemplate(c.pathnames,g,m),j){const a=c.pathnames[j],l="string"==typeof a?a:a[m];if(t.matchesPathname(l,g))w=s.formatTemplatePathname(g,l,j);else{let o;o=e?"string"==typeof a?a:a[e]:j;const n=U?void 0:t.getLocalePrefix(m,c.localePrefix),i=s.formatTemplatePathname(g,o,l);q=p(s.formatPathname(i,n,r.nextUrl.search))}}}if(!q)if("/"!==w||L){const e=s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search);if(L){const a=s.formatPathname(g,v.prefix,r.nextUrl.search);if("never"===c.localePrefix.mode)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(v.exact)if(h&&U)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(c.domains){const t=s.getBestMatchingDomain(f,v.locale,u);q=(null==f?void 0:f.domain)===(null==t?void 0:t.domain)||x?P(e):p(a,null==t?void 0:t.domain)}else q=P(e);else q=p(a)}else q=U?P(e):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search))}else q=U?P(s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search)):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search));var y;(c.localeDetection&&n.default(r,q,m),"never"!==c.localePrefix.mode&&c.alternateLinks&&c.locales.length>1)&&q.headers.set("Link",l.default({config:c,localizedPathnames:null!=j?null===(y=c.pathnames)||void 0===y?void 0:y[j]:void 0,request:r,resolvedLocale:m}));return q}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.includes("[[...")}function n(e){return e.includes("[...")}function r(e){return e.includes("[")}function o(e,o){const a=e.split("/"),i=o.split("/"),s=Math.max(a.length,i.length);for(let e=0;e<s;e++){const o=a[e],s=i[e];if(!o&&s)return-1;if(o&&!s)return 1;if(!r(o)&&r(s))return-1;if(r(o)&&!r(s))return 1;if(!n(o)&&n(s))return-1;if(n(o)&&!n(s))return 1;if(!t(o)&&t(s))return-1;if(t(o)&&!t(s))return 1}return 0}function a(e){return e.sort(o)}function i(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}function s(t,n){const r=e.templateToRegex(t).exec(n);if(!r)return;const o={};for(let e=1;e<r.length;e++){var a;const n=null===(a=t.match(/\[([^\]]+)\]/g))||void 0===a?void 0:a[e-1].replace(/[[\]]/g,"");n&&(o[n]=r[e])}return o}function c(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((e=>{let[t,r]=e;n=n.replace("[".concat(t,"]"),r)})),n}function l(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function u(e){return"/"!==e&&e.endsWith("/")&&(e=e.slice(0,-1)),e}exports.applyBasePath=function(e,t){return u(t+e)},exports.comparePathnamePairs=o,exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=c,exports.formatTemplatePathname=function(e,t,n,r){let o="";return o+=c(n,s(t,e)),o=u(o),o},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&l(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>null!=e.locales&&e.locales.includes(t)))),r||null!=(null==e?void 0:e.locales)||(r=e),r||(r=n.find((e=>!e.locales))),r},exports.getHost=function(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0},exports.getInternalTemplate=function(t,n,r){const o=a(Object.keys(t));for(const a of o){const o=t[a];if("string"==typeof o){const t=o;if(e.matchesPathname(t,n))return[void 0,a]}else{const t=Object.entries(o),i=t.findIndex((e=>{let[t]=e;return t===r}));i>0&&t.unshift(t.splice(i,1)[0]);for(const[r,o]of t)if(e.matchesPathname(o,n))return[r,a]}}for(const r of Object.keys(t))if(e.matchesPathname(r,n))return[void 0,r];return[void 0,void 0]},exports.getLocaleAsPrefix=function(e){return"/".concat(e)},exports.getLocalePrefixes=i,exports.getNormalizedPathname=function(e,t,n){e.endsWith("/")||(e+="/");const r=i(t,n),o=new RegExp("^(".concat(r.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),a=e.match(o);let s=a?"/"+a[2]:e;return"/"!==s&&(s=u(s)),s},exports.getPathnameMatch=function(e,t,n){const r=i(t,n);for(const[t,n]of r){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),a=n.toLowerCase();(t===a||t.startsWith(a+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}},exports.getRouteParams=s,exports.getSortedPathnames=a,exports.isLocaleSupportedOnDomain=l,exports.normalizeTrailingSlash=u;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}function n(t,n){const r=e.normalizeTrailingSlash(n),o=e.normalizeTrailingSlash(t),a=e.templateToRegex(o).exec(r);if(!a)return;const l={};for(let e=1;e<a.length;e++){var i;const t=null===(i=o.match(/\[([^\]]+)\]/g))||void 0===i?void 0:i[e-1].replace(/[[\]]/g,"");t&&(l[t]=a[e])}return l}function r(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((e=>{let[t,r]=e;n=n.replace("[".concat(t,"]"),r)})),n}function o(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}exports.applyBasePath=function(t,n){return e.normalizeTrailingSlash(n+t)},exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=r,exports.formatTemplatePathname=function(t,o,a,l){let i="";return i+=r(a,n(o,t)),i=e.normalizeTrailingSlash(i),i},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&o(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>null!=e.locales&&e.locales.includes(t)))),r||null!=(null==e?void 0:e.locales)||(r=e),r||(r=n.find((e=>!e.locales))),r},exports.getHost=function(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0},exports.getInternalTemplate=function(t,n,r){const o=e.getSortedPathnames(Object.keys(t));for(const a of o){const o=t[a];if("string"==typeof o){const t=o;if(e.matchesPathname(t,n))return[void 0,a]}else{const t=Object.entries(o),l=t.findIndex((e=>{let[t]=e;return t===r}));l>0&&t.unshift(t.splice(l,1)[0]);for(const[r,o]of t)if(e.matchesPathname(o,n))return[r,a]}}for(const r of Object.keys(t))if(e.matchesPathname(r,n))return[void 0,r];return[void 0,void 0]},exports.getLocaleAsPrefix=function(e){return"/".concat(e)},exports.getLocalePrefixes=t,exports.getNormalizedPathname=function(n,r,o){n.endsWith("/")||(n+="/");const a=t(r,o),l=new RegExp("^(".concat(a.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),i=n.match(l);let s=i?"/"+i[2]:n;return"/"!==s&&(s=e.normalizeTrailingSlash(s)),s},exports.getPathnameMatch=function(e,n,r){const o=t(n,r);for(const[t,n]of o){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),a=n.toLowerCase();(t===a||t.startsWith(a+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}},exports.getRouteParams=n,exports.isLocaleSupportedOnDomain=o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),t=require("../shared/config.js"),l=require("../shared/utils.js"),n=require("./ClientLink.js"),o=require("./redirects.js"),c=require("./useBasePathname.js"),i=require("./useBaseRouter.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=function(u){const f=t.receiveLocalizedNavigationRoutingConfig(u);function h(){const e=a.default();if(!f.locales.includes(e))throw new Error(void 0);return e}function d(r,a){let{href:t,locale:o,...c}=r;const i=h(),u=o||i;return s.default.createElement(n.default,e.extends({ref:a,href:l.compileLocalizedPathname({locale:u,pathname:t,params:"object"==typeof t?t.params:void 0,pathnames:f.pathnames}),locale:o,localePrefix:f.localePrefix},c))}const p=r.forwardRef(d);function m(e){let{href:r,locale:a}=e;return l.compileLocalizedPathname({...l.normalizeNameOrNameWithParams(r),locale:a,pathnames:f.pathnames})}return p.displayName="Link",{Link:p,redirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientRedirect({pathname:r,localePrefix:f.localePrefix},...t)},permanentRedirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientPermanentRedirect({pathname:r,localePrefix:f.localePrefix},...t)},usePathname:function(){const e=c.default(f.localePrefix),r=h();return e?l.getRoute({pathname:e,locale:r,pathnames:f.pathnames}):e},useRouter:function(){const e=i.default(f.localePrefix),r=h();return{...e,push(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:m}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),t=require("../shared/config.js"),l=require("../shared/utils.js"),n=require("./ClientLink.js"),o=require("./redirects.js"),c=require("./useBasePathname.js"),i=require("./useBaseRouter.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=function(u){const f=t.receiveLocalizedNavigationRoutingConfig(u);function h(){const e=a.default();if(!f.locales.includes(e))throw new Error(void 0);return e}function d(r,a){let{href:t,locale:o,...c}=r;const i=h(),u=o||i;return s.default.createElement(n.default,e.extends({ref:a,href:l.compileLocalizedPathname({locale:u,pathname:t,params:"object"==typeof t?t.params:void 0,pathnames:f.pathnames}),locale:o,localePrefix:f.localePrefix},c))}const p=r.forwardRef(d);function m(e){let{href:r,locale:a}=e;return l.compileLocalizedPathname({...l.normalizeNameOrNameWithParams(r),locale:a,pathnames:f.pathnames})}return p.displayName="Link",{Link:p,redirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientRedirect({pathname:r,localePrefix:f.localePrefix},...t)},permanentRedirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientPermanentRedirect({pathname:r,localePrefix:f.localePrefix},...t)},usePathname:function(){const e=c.default(f.localePrefix),r=h();return e?l.getRoute(r,e,f.pathnames):e},useRouter:function(){const e=i.default(f.localePrefix),r=h();return{...e,push(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:m}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("../../shared/utils.js");function t(e){return function(t){const a=r.getLocalePrefix(t.locale,t.localePrefix),n="never"!==t.localePrefix.mode&&r.isLocalHref(t.pathname)?r.prefixPathname(a,t.pathname):t.pathname;for(var i=arguments.length,o=new Array(i>1?i-1:0),c=1;c<i;c++)o[c-1]=arguments[c];return e(n,...o)}}const a=t(e.redirect),n=t(e.permanentRedirect);exports.basePermanentRedirect=n,exports.baseRedirect=a;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("../../shared/utils.js");function t(e){return function(t){const a=r.getLocalePrefix(t.locale,t.localePrefix),n="never"!==t.localePrefix.mode&&r.isLocalizableHref(t.pathname)?r.prefixPathname(a,t.pathname):t.pathname;for(var i=arguments.length,o=new Array(i>1?i-1:0),c=1;c<i;c++)o[c-1]=arguments[c];return e(n,...o)}}const a=t(e.redirect),n=t(e.permanentRedirect);exports.basePermanentRedirect=n,exports.baseRedirect=a;
@@ -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[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(e){let{pathname:r,locale:n,params:a,pathnames:o,query:i}=e;function c(e){let t=o[e];return t||(t=e),t}function s(e){let r="string"==typeof e?e:e[n];return a&&Object.entries(a).forEach((e=>{let[t,n]=e;r=Array.isArray(n)?r.replace(new RegExp("(\\[)?\\[...".concat(t,"\\](\\])?"),"g"),n.map((e=>String(e))).join("/")):r.replace("[".concat(t,"]"),String(n))})),i&&(r+=t(i)),r}if("string"==typeof r){return s(c(r))}{const{pathname:e,...t}=r;return{...t,pathname:s(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){var r;let{locale:n,pathname:a,pathnames:o}=t;const i=decodeURI(a);let c=null===(r=Object.entries(o).find((t=>{let[,r]=t;const a="string"!=typeof r?r[n]:r;return e.matchesPathname(a,i)})))||void 0===r?void 0:r[0];return c||(c=a),c},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
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(e){let{pathname:r,locale:n,params:a,pathnames:o,query:s}=e;function c(e){let t=o[e];return t||(t=e),t}function i(e){let r="string"==typeof e?e:e[n];return a&&Object.entries(a).forEach((e=>{let[t,n]=e;r=Array.isArray(n)?r.replace(new RegExp("(\\[)?\\[...".concat(t,"\\](\\])?"),"g"),n.map((e=>String(e))).join("/")):r.replace("[".concat(t,"]"),String(n))})),s&&(r+=t(s)),r}if("string"==typeof r){return i(c(r))}{const{pathname:e,...t}=r;return{...t,pathname:i(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";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var r=t(n),o=t(e);function i(n,e){function t(n){return r.default.existsSync(function(n){const t=[];return e&&t.push(e),t.push(n),o.default.resolve(...t)}(n))}if(n){if(!t(n))throw new Error("Could not find i18n config at ".concat(n,", please provide a valid path."));return n}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(t(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(e){return function(n,e){let t;if(null!=(null==e?void 0:e.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/main/examples/example-app-router-migration\n"),null!=process.env.TURBOPACK){var r,s;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");t={experimental:{...null==e?void 0:e.experimental,turbo:{...null==e||null===(r=e.experimental)||void 0===r?void 0:r.turbo,resolveAlias:{...null==e||null===(s=e.experimental)||void 0===s||null===(s=s.turbo)||void 0===s?void 0:s.resolveAlias,"next-intl/config":i(n)}}}}}else t={webpack(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];let[l,u]=r;return l.resolve.alias["next-intl/config"]=o.default.resolve(l.context,i(n,l.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(l,u):l}};return Object.assign({},e,t)}(n,e)}};
1
+ "use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var o=t(n),r=t(e);function i(n,e){function t(n){return o.default.existsSync(function(n){const t=[];return e&&t.push(e),t.push(n),r.default.resolve(...t)}(n))}if(n){if(!t(n))throw new Error("Could not find i18n config at ".concat(n,", please provide a valid path."));return n}for(const n of["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"])if(t(n))return n;throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n")}module.exports=function(n){return function(e){return function(n,e){null!=(null==e?void 0:e.i18n)&&console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://next-intl-docs.vercel.app/examples#app-router-migration\n");const t={};if(null!=process.env.TURBOPACK){var o,l;if(n&&n.startsWith("/"))throw new Error("Turbopack support for next-intl currently does not support absolute paths, please provide a relative one (e.g. './src/i18n/config.ts').\n\nFound: "+n+"\n");t.experimental={...null==e?void 0:e.experimental,turbo:{...null==e||null===(o=e.experimental)||void 0===o?void 0:o.turbo,resolveAlias:{...null==e||null===(l=e.experimental)||void 0===l||null===(l=l.turbo)||void 0===l?void 0:l.resolveAlias,"next-intl/config":i(n)}}}}else t.webpack=function(){for(var t=arguments.length,o=new Array(t),l=0;l<t;l++)o[l]=arguments[l];let[s,u]=o;return s.resolve.alias["next-intl/config"]=r.default.resolve(s.context,i(n,s.context)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(s,u):s};return t.env={...null==e?void 0:e.env,_next_intl_trailing_slash:null!=e&&e.trailingSlash?"true":void 0},Object.assign({},e,t)}(n,e)}};
@@ -1 +1 @@
1
- "use strict";function e(e){const t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}function t(e){if("object"==typeof e)return null==e.host&&null==e.hostname;return!/^[a-z]+:/i.test(e)}function n(n){return t(n)&&!e(n)}function r(e,t){let n;return"string"==typeof e?n=o(t,e):(n={...e},e.pathname&&(n.pathname=o(t,e.pathname))),n}function o(e,t){let n=e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function a(e,t){return t===e||t.startsWith("".concat(e,"/"))}function i(e){const t=e.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocalePrefix=function(e,t){var n;return"never"!==t.mode&&(null===(n=t.prefixes)||void 0===n?void 0:n[e])||"/"+e},exports.hasPathnamePrefixed=a,exports.isLocalHref=t,exports.isLocalizableHref=n,exports.isRelativeHref=e,exports.localizeHref=function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!n(e))return e;const c=t!==o,u=a(s,i);return(c||u)&&null!=s?r(e,s):e},exports.matchesPathname=function(e,t){return i(e).test(t)},exports.prefixHref=r,exports.prefixPathname=o,exports.templateToRegex=i,exports.unprefixPathname=function(e,t){return e.replace(new RegExp("^".concat(t)),"")||"/"};
1
+ "use strict";function t(t){return function(t){return"object"==typeof t?null==t.host&&null==t.hostname:!/^[a-z]+:/i.test(t)}(t)&&!function(t){const e="object"==typeof t?t.pathname:t;return null!=e&&!e.startsWith("/")}(t)}function e(t,e){let r;return"string"==typeof t?r=n(e,t):(r={...t},t.pathname&&(r.pathname=n(e,t.pathname))),r}function n(t,e){let n=t;return/^\/(\?.*)?$/.test(e)&&(e=e.slice(1)),n+=e,n}function r(t,e){return e===t||e.startsWith("".concat(t,"/"))}function o(t){const e=function(){try{return"true"===process.env._next_intl_trailing_slash}catch(t){return!1}}();if("/"!==t){const n=t.endsWith("/");e&&!n?t+="/":!e&&n&&(t=t.slice(0,-1))}return t}function i(t){const e=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(e,"$"))}function u(t){return t.includes("[[...")}function c(t){return t.includes("[...")}function s(t){return t.includes("[")}function a(t,e){const n=t.split("/"),r=e.split("/"),o=Math.max(n.length,r.length);for(let t=0;t<o;t++){const e=n[t],o=r[t];if(!e&&o)return-1;if(e&&!o)return 1;if(e||o){if(!s(e)&&s(o))return-1;if(s(e)&&!s(o))return 1;if(!c(e)&&c(o))return-1;if(c(e)&&!c(o))return 1;if(!u(e)&&u(o))return-1;if(u(e)&&!u(o))return 1}}return 0}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocalePrefix=function(t,e){var n;return"never"!==e.mode&&(null===(n=e.prefixes)||void 0===n?void 0:n[t])||"/"+t},exports.getSortedPathnames=function(t){return t.sort(a)},exports.hasPathnamePrefixed=r,exports.isLocalizableHref=t,exports.localizeHref=function(n,o){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,u=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!t(n))return n;const s=o!==i,a=r(c,u);return(s||a)&&null!=c?e(n,c):n},exports.matchesPathname=function(t,e){const n=o(t),r=o(e);return i(n).test(r)},exports.normalizeTrailingSlash=o,exports.prefixHref=e,exports.prefixPathname=n,exports.templateToRegex=i,exports.unprefixPathname=function(t,e){return t.replace(new RegExp("^".concat(e)),"")||"/"};
@@ -1,5 +1,5 @@
1
1
  import { RequestCookies } from 'next/dist/server/web/spec-extension/cookies';
2
- import { Locales, DomainConfig, Pathnames } from '../routing/types';
2
+ import { Locales, Pathnames, DomainConfig } from '../routing/types';
3
3
  import { MiddlewareRoutingConfig } from './config';
4
4
  export declare function getAcceptLanguageLocale<AppLocales extends Locales>(requestHeaders: Headers, locales: AppLocales, defaultLocale: string): string | undefined;
5
5
  export default function resolveLocale<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(config: MiddlewareRoutingConfig<AppLocales, AppPathnames>, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): {
@@ -1,7 +1,5 @@
1
- import { Locales, LocalePrefixConfigVerbose, DomainConfig, Pathnames } from '../routing/types';
1
+ import { Locales, LocalePrefixConfigVerbose, DomainConfig, Pathnames, DomainsConfig } from '../routing/types';
2
2
  export declare function getFirstPathnameSegment(pathname: string): string;
3
- export declare function comparePathnamePairs(a: string, b: string): number;
4
- export declare function getSortedPathnames(pathnames: Array<string>): string[];
5
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];
6
4
  export declare function formatTemplatePathname(sourcePathname: string, sourceTemplate: string, targetTemplate: string, prefix?: string): string;
7
5
  /**
@@ -21,7 +19,6 @@ export declare function formatPathnameTemplate(template: string, params?: object
21
19
  export declare function formatPathname(pathname: string, prefix: string | undefined, search: string | undefined): string;
22
20
  export declare function getHost(requestHeaders: Headers): string | undefined;
23
21
  export declare function isLocaleSupportedOnDomain<AppLocales extends Locales>(locale: string, domain: DomainConfig<AppLocales>): boolean;
24
- export declare function getBestMatchingDomain<AppLocales extends Locales>(curHostDomain: DomainConfig<AppLocales> | undefined, locale: string, domainConfigs: Array<DomainConfig<AppLocales>>): DomainConfig<AppLocales> | undefined;
22
+ export declare function getBestMatchingDomain<AppLocales extends Locales>(curHostDomain: DomainConfig<AppLocales> | undefined, locale: string, domainsConfig: DomainsConfig<AppLocales>): DomainConfig<AppLocales> | undefined;
25
23
  export declare function applyBasePath(pathname: string, basePath: string): string;
26
- export declare function normalizeTrailingSlash(pathname: string): string;
27
24
  export declare function getLocaleAsPrefix<AppLocales extends Locales>(locale: AppLocales[number]): string;
@@ -1,5 +1,4 @@
1
- /// <reference types="node" />
2
- import React, { ComponentProps, ReactElement } from 'react';
1
+ import { ComponentProps, ReactElement } from 'react';
3
2
  import { Locales, LocalePrefixConfigVerbose } from '../../routing/types';
4
3
  import BaseLink from '../shared/BaseLink';
5
4
  type Props<AppLocales extends Locales> = Omit<ComponentProps<typeof BaseLink>, 'locale' | 'prefix' | 'localePrefixMode'> & {
@@ -26,42 +25,7 @@ type Props<AppLocales extends Locales> = Omit<ComponentProps<typeof BaseLink>, '
26
25
  * the `set-cookie` response header would cause the locale cookie on the current
27
26
  * page to be overwritten before the user even decides to change the locale.
28
27
  */
29
- declare const ClientLinkWithRef: <AppLocales extends Locales>(props: Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
30
- href: string | import("url").UrlObject;
31
- as?: (string | import("url").UrlObject) | undefined;
32
- replace?: boolean | undefined;
33
- scroll?: boolean | undefined;
34
- shallow?: boolean | undefined;
35
- passHref?: boolean | undefined;
36
- prefetch?: boolean | undefined;
37
- locale?: string | false | undefined;
38
- legacyBehavior?: boolean | undefined;
39
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
40
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
41
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
42
- }> & {
43
- href: string | import("url").UrlObject;
44
- as?: (string | import("url").UrlObject) | undefined;
45
- replace?: boolean | undefined;
46
- scroll?: boolean | undefined;
47
- shallow?: boolean | undefined;
48
- passHref?: boolean | undefined;
49
- prefetch?: boolean | undefined;
50
- locale?: string | false | undefined;
51
- legacyBehavior?: boolean | undefined;
52
- onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
53
- onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
54
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
55
- } & {
56
- children?: React.ReactNode;
57
- } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
58
- locale: string;
59
- prefix: string;
60
- localePrefixMode: import("../../routing/types").LocalePrefixMode;
61
- }, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale" | "prefix" | "localePrefixMode"> & {
62
- locale?: AppLocales[number] | undefined;
63
- localePrefix: LocalePrefixConfigVerbose<AppLocales>;
64
- } & {
65
- ref?: React.LegacyRef<HTMLAnchorElement> | undefined;
28
+ declare const ClientLinkWithRef: <AppLocales extends Locales>(props: Props<AppLocales> & {
29
+ ref?: Props<AppLocales>['ref'];
66
30
  }) => ReactElement;
67
31
  export default ClientLinkWithRef;
@@ -43,10 +43,6 @@ export declare function compileLocalizedPathname<AppLocales extends Locales, Pat
43
43
  pathnames: Pathnames<AppLocales>;
44
44
  query?: Record<string, SearchParamValue>;
45
45
  }): UrlObject;
46
- export declare function getRoute<AppLocales extends Locales>({ locale, pathname, pathnames }: {
47
- locale: AppLocales[number];
48
- pathname: string;
49
- pathnames: Pathnames<AppLocales>;
50
- }): string;
46
+ export declare function getRoute<AppLocales extends Locales>(locale: AppLocales[number], pathname: string, pathnames: Pathnames<AppLocales>): keyof Pathnames<AppLocales>;
51
47
  export declare function getBasePath(pathname: string, windowPathname?: string): string;
52
48
  export {};
@@ -1,4 +1,4 @@
1
- import { Locales, DomainConfig, LocalePrefix, LocalePrefixConfigVerbose } from './types';
1
+ import { Locales, LocalePrefix, LocalePrefixConfigVerbose, DomainsConfig } from './types';
2
2
  /**
3
3
  * Maintainer note: The config that is accepted by the middleware, the shared
4
4
  * and the localized pathnames navigation factory function is slightly
@@ -9,6 +9,6 @@ export type RoutingBaseConfigInput<AppLocales extends Locales> = {
9
9
  /** @see https://next-intl-docs.vercel.app/docs/routing#locale-prefix */
10
10
  localePrefix?: LocalePrefix<AppLocales>;
11
11
  /** Can be used to change the locale handling per domain. */
12
- domains?: Array<DomainConfig<AppLocales>>;
12
+ domains?: DomainsConfig<AppLocales>;
13
13
  };
14
14
  export declare function receiveLocalePrefixConfig<AppLocales extends Locales>(localePrefix?: LocalePrefix<AppLocales>): LocalePrefixConfigVerbose<AppLocales>;
@@ -1,2 +1 @@
1
- export type { LocalePrefix } from './types';
2
- export type { Pathnames } from './types';
1
+ export type { Pathnames, LocalePrefix, DomainsConfig } from './types';
@@ -18,6 +18,7 @@ export type DomainConfig<AppLocales extends Locales> = {
18
18
  /** The domain name (e.g. "example.com", "www.example.com" or "fr.example.com"). Note that the `x-forwarded-host` or alternatively the `host` header will be used to determine the requested domain. */
19
19
  domain: string;
20
20
  /** Optionally restrict which locales are available on this domain. */
21
- locales?: AppLocales;
21
+ locales?: Array<AppLocales[number]>;
22
22
  };
23
+ export type DomainsConfig<AppLocales extends Locales> = Array<DomainConfig<AppLocales>>;
23
24
  export {};
@@ -4,8 +4,6 @@ import NextLink from 'next/link';
4
4
  import { ComponentProps } from 'react';
5
5
  import { Locales, LocalePrefixConfigVerbose } from '../routing/types';
6
6
  type Href = ComponentProps<typeof NextLink>['href'];
7
- export declare function isRelativeHref(href: Href): boolean;
8
- export declare function isLocalHref(href: Href): boolean;
9
7
  export declare function isLocalizableHref(href: Href): boolean;
10
8
  export declare function localizeHref(href: string, locale: string, curLocale: string, curPathname: string, prefix: string): string;
11
9
  export declare function localizeHref(href: UrlObject | string, locale: string, curLocale: string, curPathname: string, prefix: string): UrlObject | string;
@@ -14,6 +12,7 @@ export declare function prefixHref(href: UrlObject | string, prefix: string): Ur
14
12
  export declare function unprefixPathname(pathname: string, prefix: string): string;
15
13
  export declare function prefixPathname(prefix: string, pathname: string): string;
16
14
  export declare function hasPathnamePrefixed(prefix: string, pathname: string): boolean;
15
+ export declare function normalizeTrailingSlash(pathname: string): string;
17
16
  export declare function matchesPathname(
18
17
  /** E.g. `/users/[userId]-[userName]` */
19
18
  template: string,
@@ -21,4 +20,5 @@ template: string,
21
20
  pathname: string): boolean;
22
21
  export declare function getLocalePrefix<AppLocales extends Locales>(locale: AppLocales[number], localePrefix: LocalePrefixConfigVerbose<AppLocales>): string;
23
22
  export declare function templateToRegex(template: string): RegExp;
23
+ export declare function getSortedPathnames(pathnames: Array<string>): string[];
24
24
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.16.0-dc8fb0d.0+dc8fb0d",
3
+ "version": "3.16.0",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "funding": [
@@ -87,7 +87,7 @@
87
87
  "dependencies": {
88
88
  "@formatjs/intl-localematcher": "^0.2.32",
89
89
  "negotiator": "^0.6.3",
90
- "use-intl": "^3.16.0-dc8fb0d.0+dc8fb0d"
90
+ "use-intl": "^3.16.0"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
@@ -96,7 +96,7 @@
96
96
  "size-limit": [
97
97
  {
98
98
  "path": "dist/production/index.react-client.js",
99
- "limit": "15.765 KB"
99
+ "limit": "15.785 KB"
100
100
  },
101
101
  {
102
102
  "path": "dist/production/index.react-server.js",
@@ -104,11 +104,11 @@
104
104
  },
105
105
  {
106
106
  "path": "dist/production/navigation.react-client.js",
107
- "limit": "3.235 KB"
107
+ "limit": "3.465 KB"
108
108
  },
109
109
  {
110
110
  "path": "dist/production/navigation.react-server.js",
111
- "limit": "17.82 KB"
111
+ "limit": "18.075 KB"
112
112
  },
113
113
  {
114
114
  "path": "dist/production/server.react-client.js",
@@ -120,12 +120,12 @@
120
120
  },
121
121
  {
122
122
  "path": "dist/production/middleware.js",
123
- "limit": "6.42 KB"
123
+ "limit": "6.485 KB"
124
124
  },
125
125
  {
126
126
  "path": "dist/production/routing.js",
127
127
  "limit": "0 KB"
128
128
  }
129
129
  ],
130
- "gitHead": "dc8fb0d9a83bfe2cfb8c39ebe295098621796271"
130
+ "gitHead": "44a87a4ff07e779df8ac929c0edcf22fb398f576"
131
131
  }
File without changes