next-intl 3.0.1 → 3.0.3

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 (84) hide show
  1. package/dist/development/navigation/{BaseLink.js → react-client/BaseLink.js} +3 -3
  2. package/dist/development/navigation/{baseRedirect.js → react-client/baseRedirect.js} +2 -2
  3. package/dist/development/navigation/{createLocalizedPathnamesNavigation.js → react-client/createLocalizedPathnamesNavigation.js} +3 -3
  4. package/dist/development/navigation/{useBasePathname.js → react-client/useBasePathname.js} +2 -2
  5. package/dist/development/navigation/{useBaseRouter.js → react-client/useBaseRouter.js} +2 -2
  6. package/dist/development/navigation/react-server/BaseLink.js +3 -4
  7. package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
  8. package/dist/development/navigation/{utils.js → shared/utils.js} +1 -1
  9. package/dist/development/{navigation.js → navigation.react-client.js} +2 -2
  10. package/dist/development/plugin.js +1 -1
  11. package/dist/development/react-server/NextIntlClientProvider.js +11 -11
  12. package/dist/esm/navigation/react-client/BaseLink.js +1 -0
  13. package/dist/esm/navigation/react-client/baseRedirect.js +1 -0
  14. package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -0
  15. package/dist/esm/navigation/react-client/useBasePathname.js +2 -0
  16. package/dist/esm/navigation/react-client/useBaseRouter.js +1 -0
  17. package/dist/esm/navigation/react-server/BaseLink.js +1 -1
  18. package/dist/esm/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
  19. package/dist/esm/navigation/shared/utils.js +1 -0
  20. package/dist/esm/navigation.react-client.js +1 -0
  21. package/dist/esm/plugin.js +1 -1
  22. package/dist/esm/react-server/NextIntlClientProvider.js +1 -1
  23. package/dist/index.react-client.js +7 -0
  24. package/dist/navigation.react-client.js +7 -0
  25. package/dist/production/navigation/react-client/BaseLink.js +1 -0
  26. package/dist/production/navigation/react-client/baseRedirect.js +1 -0
  27. package/dist/production/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -0
  28. package/dist/production/navigation/react-client/useBasePathname.js +2 -0
  29. package/dist/production/navigation/react-client/useBaseRouter.js +1 -0
  30. package/dist/production/navigation/react-server/BaseLink.js +1 -1
  31. package/dist/production/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
  32. package/dist/production/navigation/shared/utils.js +1 -0
  33. package/dist/production/navigation.react-client.js +1 -0
  34. package/dist/production/plugin.js +1 -1
  35. package/dist/production/react-server/NextIntlClientProvider.js +1 -1
  36. package/dist/types/src/navigation/{BaseLink.d.ts → react-client/BaseLink.d.ts} +2 -2
  37. package/dist/types/src/navigation/react-client/baseRedirect.d.ts +3 -0
  38. package/dist/types/src/navigation/{createLocalizedPathnamesNavigation.d.ts → react-client/createLocalizedPathnamesNavigation.d.ts} +4 -4
  39. package/dist/types/src/navigation/{createSharedPathnamesNavigation.d.ts → react-client/createSharedPathnamesNavigation.d.ts} +1 -1
  40. package/dist/types/src/navigation/{index.d.ts → react-client/index.d.ts} +1 -1
  41. package/dist/types/src/navigation/{useBaseRouter.d.ts → react-client/useBaseRouter.d.ts} +1 -1
  42. package/dist/types/src/navigation/react-server/BaseLink.d.ts +1 -1
  43. package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +3 -3
  44. package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +1 -1
  45. package/dist/types/src/navigation/{utils.d.ts → shared/utils.d.ts} +1 -1
  46. package/dist/types/src/navigation.react-client.d.ts +1 -0
  47. package/dist/types/src/react-server/NextIntlClientProvider.d.ts +1 -1
  48. package/dist/types/src/server/getTranslations.d.ts +4 -4
  49. package/dist/types/test/react-server/NextIntlClientProvider.test.d.ts +1 -0
  50. package/navigation.d.ts +1 -1
  51. package/package.json +19 -11
  52. package/dist/esm/navigation/BaseLink.js +0 -1
  53. package/dist/esm/navigation/baseRedirect.js +0 -1
  54. package/dist/esm/navigation/createLocalizedPathnamesNavigation.js +0 -1
  55. package/dist/esm/navigation/useBasePathname.js +0 -2
  56. package/dist/esm/navigation/useBaseRouter.js +0 -1
  57. package/dist/esm/navigation/utils.js +0 -1
  58. package/dist/esm/navigation.js +0 -1
  59. package/dist/index.js +0 -7
  60. package/dist/navigation.js +0 -7
  61. package/dist/production/navigation/BaseLink.js +0 -1
  62. package/dist/production/navigation/baseRedirect.js +0 -1
  63. package/dist/production/navigation/createLocalizedPathnamesNavigation.js +0 -1
  64. package/dist/production/navigation/useBasePathname.js +0 -2
  65. package/dist/production/navigation/useBaseRouter.js +0 -1
  66. package/dist/production/navigation/utils.js +0 -1
  67. package/dist/production/navigation.js +0 -1
  68. package/dist/types/src/navigation/baseRedirect.d.ts +0 -3
  69. package/dist/types/src/navigation.d.ts +0 -1
  70. /package/dist/development/{index.js → index.react-client.js} +0 -0
  71. /package/dist/development/navigation/{createSharedPathnamesNavigation.js → react-client/createSharedPathnamesNavigation.js} +0 -0
  72. /package/dist/esm/{index.js → index.react-client.js} +0 -0
  73. /package/dist/esm/navigation/{createSharedPathnamesNavigation.js → react-client/createSharedPathnamesNavigation.js} +0 -0
  74. /package/dist/production/{index.js → index.react-client.js} +0 -0
  75. /package/dist/production/navigation/{createSharedPathnamesNavigation.js → react-client/createSharedPathnamesNavigation.js} +0 -0
  76. /package/dist/types/src/{index.d.ts → index.react-client.d.ts} +0 -0
  77. /package/dist/types/src/navigation/{useBasePathname.d.ts → react-client/useBasePathname.d.ts} +0 -0
  78. /package/dist/types/src/navigation/{StrictParams.d.ts → shared/StrictParams.d.ts} +0 -0
  79. /package/dist/types/test/navigation/{BaseLink.test.d.ts → react-client/BaseLink.test.d.ts} +0 -0
  80. /package/dist/types/test/navigation/{createLocalizedPathnamesNavigation.test.d.ts → react-client/createLocalizedPathnamesNavigation.test.d.ts} +0 -0
  81. /package/dist/types/test/navigation/{createSharedPathnamesNavigation.test.d.ts → react-client/createSharedPathnamesNavigation.test.d.ts} +0 -0
  82. /package/dist/types/test/navigation/{useBasePathname.test.d.ts → react-client/useBasePathname.test.d.ts} +0 -0
  83. /package/dist/types/test/navigation/{useBaseRouter.test.d.ts → react-client/useBaseRouter.test.d.ts} +0 -0
  84. /package/dist/types/test/navigation/{utils.test.d.ts → shared/utils.test.d.ts} +0 -0
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var React = require('react');
7
- var useLocale = require('../react-client/useLocale.js');
8
- var BaseLinkWithLocale = require('../shared/BaseLinkWithLocale.js');
7
+ var useLocale = require('../../react-client/useLocale.js');
8
+ var BaseLinkWithLocale = require('../../shared/BaseLinkWithLocale.js');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var useLocale = require('../react-client/useLocale.js');
6
- var redirectWithLocale = require('../shared/redirectWithLocale.js');
5
+ var useLocale = require('../../react-client/useLocale.js');
6
+ var redirectWithLocale = require('../../shared/redirectWithLocale.js');
7
7
 
8
8
  function baseRedirect(pathname) {
9
9
  let locale;
@@ -2,14 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var React = require('react');
7
- var useLocale = require('../react-client/useLocale.js');
7
+ var useLocale = require('../../react-client/useLocale.js');
8
+ var utils = require('../shared/utils.js');
8
9
  var BaseLink = require('./BaseLink.js');
9
10
  var baseRedirect = require('./baseRedirect.js');
10
11
  var useBasePathname = require('./useBasePathname.js');
11
12
  var useBaseRouter = require('./useBaseRouter.js');
12
- var utils = require('./utils.js');
13
13
 
14
14
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
15
 
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var navigation = require('next/navigation');
7
7
  var React = require('react');
8
- var useLocale = require('../react-client/useLocale.js');
9
- var utils = require('../shared/utils.js');
8
+ var useLocale = require('../../react-client/useLocale.js');
9
+ var utils = require('../../shared/utils.js');
10
10
 
11
11
  /**
12
12
  * Returns the pathname without a potential locale prefix.
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var navigation = require('next/navigation');
6
6
  var React = require('react');
7
- var useLocale = require('../react-client/useLocale.js');
8
- var utils = require('../shared/utils.js');
7
+ var useLocale = require('../../react-client/useLocale.js');
8
+ var utils = require('../../shared/utils.js');
9
9
 
10
10
  /**
11
11
  * Returns a wrapped instance of `useRouter` from `next/navigation` that
@@ -4,21 +4,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var React = require('react');
7
- var useLocale = require('../../react-server/useLocale.js');
8
7
  var BaseLinkWithLocale = require('../../shared/BaseLinkWithLocale.js');
8
+ var getLocale = require('../../server/getLocale.js');
9
9
 
10
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
11
 
12
12
  var React__default = /*#__PURE__*/_interopDefault(React);
13
13
 
14
- function BaseLink(_ref) {
14
+ async function BaseLink(_ref) {
15
15
  let {
16
16
  locale,
17
17
  ...rest
18
18
  } = _ref;
19
- const defaultLocale = useLocale.default();
20
19
  return /*#__PURE__*/React__default.default.createElement(BaseLinkWithLocale.default, _rollupPluginBabelHelpers.extends({
21
- locale: locale || defaultLocale
20
+ locale: locale || (await getLocale.default())
22
21
  }, rest));
23
22
  }
24
23
 
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var React = require('react');
7
7
  var RequestLocale = require('../../server/RequestLocale.js');
8
- var utils = require('../utils.js');
8
+ var utils = require('../shared/utils.js');
9
9
  var BaseLink = require('./BaseLink.js');
10
10
  var baseRedirect = require('./baseRedirect.js');
11
11
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var utils = require('../shared/utils.js');
5
+ var utils = require('../../shared/utils.js');
6
6
 
7
7
  // Minor false positive: A route that has both optional and
8
8
  // required params will allow optional params.
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var createSharedPathnamesNavigation = require('./navigation/createSharedPathnamesNavigation.js');
6
- var createLocalizedPathnamesNavigation = require('./navigation/createLocalizedPathnamesNavigation.js');
5
+ var createSharedPathnamesNavigation = require('./navigation/react-client/createSharedPathnamesNavigation.js');
6
+ var createLocalizedPathnamesNavigation = require('./navigation/react-client/createLocalizedPathnamesNavigation.js');
7
7
 
8
8
 
9
9
 
@@ -27,7 +27,7 @@ function resolveI18nPath(cwd, providedPath) {
27
27
  }
28
28
  function initPlugin(i18nPath, nextConfig) {
29
29
  if ((nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) != null) {
30
- 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/feat/next-13-rsc/packages/example-next-13-with-pages\n");
30
+ 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/packages/example-app-router-migration\n");
31
31
  }
32
32
  return Object.assign({}, nextConfig, {
33
33
  webpack() {
@@ -5,28 +5,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
6
6
  var React = require('react');
7
7
  var NextIntlClientProvider$1 = require('../shared/NextIntlClientProvider.js');
8
- var useLocale = require('./useLocale.js');
9
- var useNow = require('./useNow.js');
10
- var useTimeZone = require('./useTimeZone.js');
8
+ var getLocale = require('../server/getLocale.js');
9
+ var getNow = require('../server/getNow.js');
10
+ var getTimeZone = require('../server/getTimeZone.js');
11
11
 
12
12
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
13
 
14
14
  var React__default = /*#__PURE__*/_interopDefault(React);
15
15
 
16
- function NextIntlClientProvider(_ref) {
16
+ async function NextIntlClientProvider(_ref) {
17
17
  let {
18
18
  locale,
19
19
  now,
20
20
  timeZone,
21
21
  ...rest
22
22
  } = _ref;
23
- const defaultLocale = useLocale.default();
24
- const defaultNow = useNow.default();
25
- const defaultTimeZone = useTimeZone.default();
26
- return /*#__PURE__*/React__default.default.createElement(NextIntlClientProvider$1.default, _rollupPluginBabelHelpers.extends({
27
- locale: locale !== null && locale !== void 0 ? locale : defaultLocale,
28
- now: now !== null && now !== void 0 ? now : defaultNow,
29
- timeZone: timeZone !== null && timeZone !== void 0 ? timeZone : defaultTimeZone
23
+ return /*#__PURE__*/React__default.default.createElement(NextIntlClientProvider$1.default
24
+ // We need to be careful about potentially reading from headers here.
25
+ // See https://github.com/amannn/next-intl/issues/631
26
+ , _rollupPluginBabelHelpers.extends({
27
+ locale: locale !== null && locale !== void 0 ? locale : await getLocale.default(),
28
+ now: now !== null && now !== void 0 ? now : await getNow.default(),
29
+ timeZone: timeZone !== null && timeZone !== void 0 ? timeZone : await getTimeZone.default()
30
30
  }, rest));
31
31
  }
32
32
 
@@ -0,0 +1 @@
1
+ import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import a from"../../react-client/useLocale.js";import l from"../../shared/BaseLinkWithLocale.js";function o(t,o){let{locale:s,...i}=t;const n=a(),c=s||n;return r.createElement(l,e({ref:o,hrefLang:c,locale:c},i))}const s=t(o);s.displayName="Link";var i=s;export{i as default};
@@ -0,0 +1 @@
1
+ import r from"../../react-client/useLocale.js";import e from"../../shared/redirectWithLocale.js";function t(t){let n;try{n=r()}catch(r){throw new Error("`redirect()` can only be called during render. To redirect in an event handler or similar, you can use `useRouter()` instead.")}for(var a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return e(t,n,...o)}export{t as default};
@@ -0,0 +1 @@
1
+ import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import o from"../../react-client/useLocale.js";import{getRoute as a,compileLocalizedPathname as n,normalizeNameOrNameWithParams as l}from"../shared/utils.js";import c from"./BaseLink.js";import s from"./baseRedirect.js";import u from"./useBasePathname.js";import i from"./useBaseRouter.js";function f(f){let{locales:m,pathnames:p}=f;function h(){const e=o();if(!m.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `app/[locale]/layout.tsx`.'));return e}function d(t,o){let{href:a,locale:l,...s}=t;const u=h(),i=l||u;return r.createElement(c,e({ref:o,href:n({locale:i,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:p}),locale:l},s))}const v=t(d);function j(e){let{href:r,locale:t}=e;return n({...l(r),locale:t,pathnames:p})}return v.displayName="Link",{Link:v,redirect:function(e){const r=j({href:e,locale:h()});for(var t=arguments.length,o=new Array(t>1?t-1:0),a=1;a<t;a++)o[a-1]=arguments[a];return s(r,...o)},usePathname:function(){const e=u(),r=h();return a({pathname:e,locale:r,pathnames:p})},useRouter:function(){const e=i(),r=h();return{...e,push(t){for(var o,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=j({href:t,locale:(null===(o=n[0])||void 0===o?void 0:o.locale)||r});return e.push(c,...n)},replace(t){for(var o,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=j({href:t,locale:(null===(o=n[0])||void 0===o?void 0:o.locale)||r});return e.replace(c,...n)},prefetch(t){for(var o,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=j({href:t,locale:(null===(o=n[0])||void 0===o?void 0:o.locale)||r});return e.prefetch(c,...n)}}},getPathname:j}}export{f as default};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ import{usePathname as r}from"next/navigation";import{useMemo as t}from"react";import o from"../../react-client/useLocale.js";import{hasPathnamePrefixed as e,unlocalizePathname as i}from"../../shared/utils.js";function n(){const n=r(),a=o();return t((()=>{if(!n)return n;return e(a,n)?i(n,a):n}),[a,n])}export{n as default};
@@ -0,0 +1 @@
1
+ import{useRouter as e}from"next/navigation";import{useMemo as t}from"react";import r from"../../react-client/useLocale.js";import{localizeHref as n}from"../../shared/utils.js";function o(){const o=e(),c=r();return t((()=>{function e(e,t){return n(e,t||c,c,window.location.pathname)}return{...o,push(t,r){const{locale:n,...c}=r||{},s=[e(t,n)];return Object.keys(c).length>0&&s.push(c),o.push(...s)},replace(t,r){const{locale:n,...c}=r||{},s=[e(t,n)];return Object.keys(c).length>0&&s.push(c),o.replace(...s)},prefetch(t,r){const{locale:n,...c}=r||{},s=[e(t,n)];return Object.keys(c).length>0&&s.push(c),o.prefetch(...s)}}}),[c,o])}export{o as default};
@@ -1 +1 @@
1
- import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"../../react-server/useLocale.js";import o from"../../shared/BaseLinkWithLocale.js";function l(l){let{locale:a,...s}=l;const c=t();return r.createElement(o,e({locale:a||c},s))}export{l as default};
1
+ import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"../../shared/BaseLinkWithLocale.js";import a from"../../server/getLocale.js";async function l(l){let{locale:o,...s}=l;return r.createElement(t,e({locale:o||await a()},s))}export{l as default};
@@ -1 +1 @@
1
- import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import t from"react";import{getRequestLocale as r}from"../../server/RequestLocale.js";import{compileLocalizedPathname as o,normalizeNameOrNameWithParams as n}from"../utils.js";import a from"./BaseLink.js";import s from"./baseRedirect.js";function l(l){let{locales:u,pathnames:c}=l;function m(e){let{href:t,locale:r}=e;return o({...n(t),locale:r,pathnames:c})}function i(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(n){let{href:s,locale:l,...u}=n;const m=r(),i=l||m;return t.createElement(a,e({href:o({locale:i,pathname:s,params:"object"==typeof s?s.params:void 0,pathnames:c}),locale:l},u))},redirect:function(e){const t=m({href:e,locale:r()});for(var o=arguments.length,n=new Array(o>1?o-1:0),a=1;a<o;a++)n[a-1]=arguments[a];return s(t,...n)},getPathname:m,usePathname:i("usePathname"),useRouter:i("useRouter")}}export{l as default};
1
+ import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import t from"react";import{getRequestLocale as r}from"../../server/RequestLocale.js";import{compileLocalizedPathname as o,normalizeNameOrNameWithParams as n}from"../shared/utils.js";import a from"./BaseLink.js";import s from"./baseRedirect.js";function l(l){let{locales:u,pathnames:c}=l;function m(e){let{href:t,locale:r}=e;return o({...n(t),locale:r,pathnames:c})}function i(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(n){let{href:s,locale:l,...u}=n;const m=r(),i=l||m;return t.createElement(a,e({href:o({locale:i,pathname:s,params:"object"==typeof s?s.params:void 0,pathnames:c}),locale:l},u))},redirect:function(e){const t=m({href:e,locale:r()});for(var o=arguments.length,n=new Array(o>1?o-1:0),a=1;a<o;a++)n[a-1]=arguments[a];return s(t,...n)},getPathname:m,usePathname:i("usePathname"),useRouter:i("useRouter")}}export{l as default};
@@ -0,0 +1 @@
1
+ import{unlocalizePathname 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,a]of Object.entries(t))Array.isArray(a)?a.forEach((t=>{r.append(e,n(t))})):r.set(e,n(a));return"?"+r.toString()}function a(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,r]=t;o=Array.isArray(r)?o.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),r.map((t=>String(t))).join("/")):o.replace("[".concat(n,"]"),String(r))})),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,...r}=n;return{...r,pathname:s(c(t))}}}function o(r){var e;let{locale:a,pathname:o,pathnames:i}=r;const c=t(o,a);let s=null===(e=Object.entries(i).find((t=>{let[,r]=t;const e="string"!=typeof r?r[a]:r;return n(e,c)})))||void 0===e?void 0:e[0];return s||(s=o),s}export{a as compileLocalizedPathname,o as getRoute,r as normalizeNameOrNameWithParams,e as serializeSearchParams};
@@ -0,0 +1 @@
1
+ export{default as createSharedPathnamesNavigation}from"./navigation/react-client/createSharedPathnamesNavigation.js";export{default as createLocalizedPathnamesNavigation}from"./navigation/react-client/createLocalizedPathnamesNavigation.js";
@@ -1 +1 @@
1
- import n from"fs";import e from"path";function t(t,o){return 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/feat/next-13-rsc/packages/example-next-13-with-pages\n"),Object.assign({},o,{webpack(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];let[a,l]=r;return a.resolve.alias["next-intl/config"]=require.resolve(function(t,o){let i=o;if(i){if(i=e.resolve(i),!n.existsSync(i))throw new Error("Could not find i18n config at ".concat(i,", please provide a valid path."))}else if(i=["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"].map((n=>e.resolve(t,n))).find((e=>n.existsSync(e))),!i)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");return i}(a.context,t)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(a,l):a}})}module.exports=function(n){return e=>t(n,e)};
1
+ import n from"fs";import e from"path";function t(t,o){return 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/packages/example-app-router-migration\n"),Object.assign({},o,{webpack(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];let[a,l]=r;return a.resolve.alias["next-intl/config"]=require.resolve(function(t,o){let i=o;if(i){if(i=e.resolve(i),!n.existsSync(i))throw new Error("Could not find i18n config at ".concat(i,", please provide a valid path."))}else if(i=["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"].map((n=>e.resolve(t,n))).find((e=>n.existsSync(e))),!i)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");return i}(a.context,t)),"function"==typeof(null==o?void 0:o.webpack)?o.webpack(a,l):a}})}module.exports=function(n){return e=>t(n,e)};
@@ -1 +1 @@
1
- import{extends as e}from"../_virtual/_rollupPluginBabelHelpers.js";import o from"react";import r from"../shared/NextIntlClientProvider.js";import l from"./useLocale.js";import t from"./useNow.js";import n from"./useTimeZone.js";function m(m){let{locale:i,now:s,timeZone:u,...a}=m;const p=l(),f=t(),c=n();return o.createElement(r,e({locale:null!=i?i:p,now:null!=s?s:f,timeZone:null!=u?u:c},a))}export{m as default};
1
+ import{extends as e}from"../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"../shared/NextIntlClientProvider.js";import o from"../server/getLocale.js";import l from"../server/getNow.js";import a from"../server/getTimeZone.js";async function i(i){let{locale:n,now:m,timeZone:s,...p}=i;return r.createElement(t,e({locale:null!=n?n:await o(),now:null!=m?m:await l(),timeZone:null!=s?s:await a()},p))}export{i as default};
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./production/index.react-client.js');
5
+ } else {
6
+ module.exports = require('./development/index.react-client.js');
7
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ if (process.env.NODE_ENV === 'production') {
4
+ module.exports = require('./production/navigation.react-client.js');
5
+ } else {
6
+ module.exports = require('./development/navigation.react-client.js');
7
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../react-client/useLocale.js"),a=require("../../shared/BaseLinkWithLocale.js");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r);function s(r,l){let{locale:s,...n}=r;const i=t.default(),o=s||i;return u.default.createElement(a.default,e.extends({ref:l,hrefLang:o,locale:o},n))}const n=r.forwardRef(s);n.displayName="Link";var i=n;exports.default=i;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../react-client/useLocale.js"),r=require("../../shared/redirectWithLocale.js");exports.default=function(t){let a;try{a=e.default()}catch(e){throw new Error(void 0)}for(var o=arguments.length,u=new Array(o>1?o-1:0),c=1;c<o;c++)u[c-1]=arguments[c];return r.default(t,a,...u)};
@@ -0,0 +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/utils.js"),l=require("./BaseLink.js"),n=require("./baseRedirect.js"),o=require("./useBasePathname.js"),u=require("./useBaseRouter.js");function c(e){return e&&e.__esModule?e:{default:e}}var s=c(r);exports.default=function(c){let{locales:i,pathnames:f}=c;function h(){const e=a.default();if(!i.includes(e))throw new Error(void 0);return e}function d(r,a){let{href:n,locale:o,...u}=r;const c=h(),i=o||c;return s.default.createElement(l.default,e.extends({ref:a,href:t.compileLocalizedPathname({locale:i,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:f}),locale:o},u))}const p=r.forwardRef(d);function m(e){let{href:r,locale:a}=e;return t.compileLocalizedPathname({...t.normalizeNameOrNameWithParams(r),locale:a,pathnames:f})}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 n.default(r,...t)},usePathname:function(){const e=o.default(),r=h();return t.getRoute({pathname:e,locale:r,pathnames:f})},useRouter:function(){const e=u.default(),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 u=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(u,...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 u=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(u,...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 u=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(u,...n)}}},getPathname:m}};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("react"),t=require("../../react-client/useLocale.js"),a=require("../../shared/utils.js");exports.default=function(){const u=e.usePathname(),n=t.default();return r.useMemo((()=>{if(!u)return u;return a.hasPathnamePrefixed(n,u)?a.unlocalizePathname(u,n):u}),[n,u])};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("react"),r=require("../../react-client/useLocale.js"),u=require("../../shared/utils.js");exports.default=function(){const n=e.useRouter(),c=r.default();return t.useMemo((()=>{function e(e,t){return u.localizeHref(e,t||c,c,window.location.pathname)}return{...n,push(t,r){const{locale:u,...c}=r||{},s=[e(t,u)];return Object.keys(c).length>0&&s.push(c),n.push(...s)},replace(t,r){const{locale:u,...c}=r||{},s=[e(t,u)];return Object.keys(c).length>0&&s.push(c),n.replace(...s)},prefetch(t,r){const{locale:u,...c}=r||{},s=[e(t,u)];return Object.keys(c).length>0&&s.push(c),n.prefetch(...s)}}}),[c,n])};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../react-server/useLocale.js"),l=require("../../shared/BaseLinkWithLocale.js");function u(e){return e&&e.__esModule?e:{default:e}}var a=u(r);exports.default=function(r){let{locale:u,...s}=r;const o=t.default();return a.default.createElement(l.default,e.extends({locale:u||o},s))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../shared/BaseLinkWithLocale.js"),l=require("../../server/getLocale.js");function a(e){return e&&e.__esModule?e:{default:e}}var u=a(r);exports.default=async function(r){let{locale:a,...s}=r;return u.default.createElement(t.default,e.extends({locale:a||await l.default()},s))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),r=require("../../server/RequestLocale.js"),a=require("../utils.js"),o=require("./BaseLink.js"),n=require("./baseRedirect.js");function u(e){return e&&e.__esModule?e:{default:e}}var l=u(t);exports.default=function(t){let{locales:u,pathnames:s}=t;function c(e){let{href:t,locale:r}=e;return a.compileLocalizedPathname({...a.normalizeNameOrNameWithParams(t),locale:r,pathnames:s})}function i(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(t){let{href:n,locale:u,...c}=t;const i=r.getRequestLocale(),m=u||i;return l.default.createElement(o.default,e.extends({href:a.compileLocalizedPathname({locale:m,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:s}),locale:u},c))},redirect:function(e){const t=c({href:e,locale:r.getRequestLocale()});for(var a=arguments.length,o=new Array(a>1?a-1:0),u=1;u<a;u++)o[u-1]=arguments[u];return n.default(t,...o)},getPathname:c,usePathname:i("usePathname"),useRouter:i("useRouter")}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("react"),r=require("../../server/RequestLocale.js"),a=require("../shared/utils.js"),o=require("./BaseLink.js"),n=require("./baseRedirect.js");function u(e){return e&&e.__esModule?e:{default:e}}var l=u(t);exports.default=function(t){let{locales:u,pathnames:s}=t;function c(e){let{href:t,locale:r}=e;return a.compileLocalizedPathname({...a.normalizeNameOrNameWithParams(t),locale:r,pathnames:s})}function i(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(t){let{href:n,locale:u,...c}=t;const i=r.getRequestLocale(),m=u||i;return l.default.createElement(o.default,e.extends({href:a.compileLocalizedPathname({locale:m,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:s}),locale:u},c))},redirect:function(e){const t=c({href:e,locale:r.getRequestLocale()});for(var a=arguments.length,o=new Array(a>1?a-1:0),u=1;u<a;u++)o[u-1]=arguments[u];return n.default(t,...o)},getPathname:c,usePathname:i("usePathname"),useRouter:i("useRouter")}};
@@ -0,0 +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 s(e){let t=o[e];return t||(t=e),t}function c(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 c(s(r))}{const{pathname:e,...t}=r;return{...t,pathname:c(s(e))}}},exports.getRoute=function(t){var r;let{locale:n,pathname:a,pathnames:o}=t;const i=e.unlocalizePathname(a,n);let s=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 s||(s=a),s},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./navigation/react-client/createSharedPathnamesNavigation.js"),a=require("./navigation/react-client/createLocalizedPathnamesNavigation.js");exports.createSharedPathnamesNavigation=e.default,exports.createLocalizedPathnamesNavigation=a.default;
@@ -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),i=t(e);function o(n,e){return 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/feat/next-13-rsc/packages/example-next-13-with-pages\n"),Object.assign({},e,{webpack(){for(var t=arguments.length,o=new Array(t),s=0;s<t;s++)o[s]=arguments[s];let[a,l]=o;return a.resolve.alias["next-intl/config"]=require.resolve(function(n,e){let t=e;if(t){if(t=i.default.resolve(t),!r.default.existsSync(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."))}else if(t=["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"].map((e=>i.default.resolve(n,e))).find((n=>r.default.existsSync(n))),!t)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");return t}(a.context,n)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(a,l):a}})}module.exports=function(n){return e=>o(n,e)};
1
+ "use strict";var n=require("fs"),e=require("path");function t(n){return n&&n.__esModule?n:{default:n}}var r=t(n),i=t(e);function o(n,e){return 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/packages/example-app-router-migration\n"),Object.assign({},e,{webpack(){for(var t=arguments.length,o=new Array(t),s=0;s<t;s++)o[s]=arguments[s];let[a,l]=o;return a.resolve.alias["next-intl/config"]=require.resolve(function(n,e){let t=e;if(t){if(t=i.default.resolve(t),!r.default.existsSync(t))throw new Error("Could not find i18n config at ".concat(t,", please provide a valid path."))}else if(t=["./i18n.tsx","./i18n.ts","./i18n.js","./i18n.jsx","./src/i18n.tsx","./src/i18n.ts","./src/i18n.js","./src/i18n.jsx"].map((e=>i.default.resolve(n,e))).find((n=>r.default.existsSync(n))),!t)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");return t}(a.context,n)),"function"==typeof(null==e?void 0:e.webpack)?e.webpack(a,l):a}})}module.exports=function(n){return e=>o(n,e)};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),l=require("react"),r=require("../shared/NextIntlClientProvider.js"),u=require("./useLocale.js"),t=require("./useNow.js"),n=require("./useTimeZone.js");function o(e){return e&&e.__esModule?e:{default:e}}var a=o(l);exports.default=function(l){let{locale:o,now:s,timeZone:i,...d}=l;const c=u.default(),f=t.default(),j=n.default();return a.default.createElement(r.default,e.extends({locale:null!=o?o:c,now:null!=s?s:f,timeZone:null!=i?i:j},d))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../shared/NextIntlClientProvider.js"),l=require("../server/getLocale.js"),u=require("../server/getNow.js"),a=require("../server/getTimeZone.js");function n(e){return e&&e.__esModule?e:{default:e}}var i=n(r);exports.default=async function(r){let{locale:n,now:o,timeZone:s,...d}=r;return i.default.createElement(t.default,e.extends({locale:null!=n?n:await l.default(),now:null!=o?o:await u.default(),timeZone:null!=s?s:await a.default()},d))};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import React, { ComponentProps, ReactElement } from 'react';
3
- import BaseLinkWithLocale from '../shared/BaseLinkWithLocale';
4
- import { AllLocales } from '../shared/types';
3
+ import BaseLinkWithLocale from '../../shared/BaseLinkWithLocale';
4
+ import { AllLocales } from '../../shared/types';
5
5
  type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLinkWithLocale>, 'locale'> & {
6
6
  locale?: Locales[number];
7
7
  };
@@ -0,0 +1,3 @@
1
+ import redirectWithLocale from '../../shared/redirectWithLocale';
2
+ import { ParametersExceptFirstTwo } from '../../shared/types';
3
+ export default function baseRedirect(pathname: string, ...args: ParametersExceptFirstTwo<typeof redirectWithLocale>): never;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import React, { ComponentProps, ReactElement } from 'react';
3
- import { AllLocales, Pathnames } from '../shared/types';
3
+ import { AllLocales, Pathnames } from '../../shared/types';
4
+ import { HrefOrHrefWithParams } from '../shared/utils';
4
5
  import BaseLink from './BaseLink';
5
- import { HrefOrHrefWithParams } from './utils';
6
6
  export default function createLocalizedPathnamesNavigation<Locales extends AllLocales, PathnamesConfig extends Pathnames<Locales>>({ locales, pathnames }: {
7
7
  locales: Locales;
8
8
  pathnames: PathnamesConfig;
@@ -44,10 +44,10 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
44
44
  }, "href" | "name"> & {
45
45
  href: Pathname extends `${string}[[...${string}` ? Pathname | ({
46
46
  pathname: Pathname;
47
- params?: import("./StrictParams").default<Pathname> | undefined;
47
+ params?: import("../shared/StrictParams").default<Pathname> | undefined;
48
48
  } & Omit<import("url").UrlObject, "pathname">) : Pathname extends `${string}[${string}` ? {
49
49
  pathname: Pathname;
50
- params: import("./StrictParams").default<Pathname>;
50
+ params: import("../shared/StrictParams").default<Pathname>;
51
51
  } & Omit<import("url").UrlObject, "pathname"> : Pathname | ({
52
52
  pathname: Pathname;
53
53
  } & Omit<import("url").UrlObject, "pathname">);
@@ -1,4 +1,4 @@
1
- import { AllLocales } from '../shared/types';
1
+ import { AllLocales } from '../../shared/types';
2
2
  import BaseLink from './BaseLink';
3
3
  import baseRedirect from './baseRedirect';
4
4
  import useBasePathname from './useBasePathname';
@@ -1,3 +1,3 @@
1
1
  export { default as createSharedPathnamesNavigation } from './createSharedPathnamesNavigation';
2
2
  export { default as createLocalizedPathnamesNavigation } from './createLocalizedPathnamesNavigation';
3
- export type { Pathnames } from '../shared/types';
3
+ export type { Pathnames } from '../../shared/types';
@@ -1,4 +1,4 @@
1
- import { AllLocales } from '../shared/types';
1
+ import { AllLocales } from '../../shared/types';
2
2
  type IntlNavigateOptions<Locales extends AllLocales> = {
3
3
  locale?: Locales[number];
4
4
  };
@@ -4,5 +4,5 @@ import { AllLocales } from '../../shared/types';
4
4
  type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLinkWithLocale>, 'locale'> & {
5
5
  locale?: Locales[number];
6
6
  };
7
- export default function BaseLink<Locales extends AllLocales>({ locale, ...rest }: Props<Locales>): React.JSX.Element;
7
+ export default function BaseLink<Locales extends AllLocales>({ locale, ...rest }: Props<Locales>): Promise<React.JSX.Element>;
8
8
  export {};
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import React from 'react';
3
3
  import { AllLocales, Pathnames } from '../../shared/types';
4
- import { HrefOrHrefWithParams } from '../utils';
4
+ import { HrefOrHrefWithParams } from '../shared/utils';
5
5
  export default function createLocalizedPathnamesNavigation<Locales extends AllLocales, PathnamesConfig extends Pathnames<Locales>>({ locales, pathnames }: {
6
6
  locales: Locales;
7
7
  pathnames: Pathnames<Locales>;
@@ -41,10 +41,10 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
41
41
  }, "href" | "name"> & {
42
42
  href: Pathname extends `${string}[[...${string}` ? Pathname | ({
43
43
  pathname: Pathname;
44
- params?: import("../StrictParams").default<Pathname> | undefined;
44
+ params?: import("../shared/StrictParams").default<Pathname> | undefined;
45
45
  } & Omit<import("url").UrlObject, "pathname">) : Pathname extends `${string}[${string}` ? {
46
46
  pathname: Pathname;
47
- params: import("../StrictParams").default<Pathname>;
47
+ params: import("../shared/StrictParams").default<Pathname>;
48
48
  } & Omit<import("url").UrlObject, "pathname"> : Pathname | ({
49
49
  pathname: Pathname;
50
50
  } & Omit<import("url").UrlObject, "pathname">);
@@ -37,7 +37,7 @@ export default function createSharedPathnamesNavigation<Locales extends AllLocal
37
37
  locale: string;
38
38
  }, "ref"> & import("react").RefAttributes<HTMLAnchorElement>, "locale"> & {
39
39
  locale?: Locales[number] | undefined;
40
- }) => import("react").JSX.Element;
40
+ }) => Promise<import("react").JSX.Element>;
41
41
  redirect: typeof baseRedirect;
42
42
  usePathname: () => never;
43
43
  useRouter: () => never;
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import type { ParsedUrlQueryInput } from 'node:querystring';
4
4
  import type { UrlObject } from 'url';
5
- import { AllLocales, Pathnames } from '../shared/types';
5
+ import { AllLocales, Pathnames } from '../../shared/types';
6
6
  import StrictParams from './StrictParams';
7
7
  type SearchParamValue = ParsedUrlQueryInput[keyof ParsedUrlQueryInput];
8
8
  type HrefOrHrefWithParamsImpl<Pathname, Other> = Pathname extends `${string}[[...${string}` ? // Optional catch-all
@@ -0,0 +1 @@
1
+ export * from './navigation/react-client/index';
@@ -1,5 +1,5 @@
1
1
  import React, { ComponentProps } from 'react';
2
2
  import BaseNextIntlClientProvider from '../shared/NextIntlClientProvider';
3
3
  type Props = ComponentProps<typeof BaseNextIntlClientProvider>;
4
- export default function NextIntlClientProvider({ locale, now, timeZone, ...rest }: Props): React.JSX.Element;
4
+ export default function NextIntlClientProvider({ locale, now, timeZone, ...rest }: Props): Promise<React.JSX.Element>;
5
5
  export {};
@@ -9,7 +9,7 @@ declare function getTranslations<NestedKey extends NamespaceKeys<IntlMessages, N
9
9
  '!': IntlMessages;
10
10
  }, [
11
11
  NestedKey
12
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
12
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: [TargetKey] extends [never] ? string : TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
13
13
  rich<TargetKey extends MessageKeys<NestedValueOf<{
14
14
  '!': IntlMessages;
15
15
  }, [
@@ -18,7 +18,7 @@ declare function getTranslations<NestedKey extends NamespaceKeys<IntlMessages, N
18
18
  '!': IntlMessages;
19
19
  }, [
20
20
  NestedKey
21
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: RichTranslationValues, formats?: Partial<Formats>): string | ReactElement | ReactNodeArray;
21
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: [TargetKey] extends [never] ? string : TargetKey, values?: RichTranslationValues, formats?: Partial<Formats>): string | ReactElement | ReactNodeArray;
22
22
  markup<TargetKey extends MessageKeys<NestedValueOf<{
23
23
  '!': IntlMessages;
24
24
  }, [
@@ -27,7 +27,7 @@ declare function getTranslations<NestedKey extends NamespaceKeys<IntlMessages, N
27
27
  '!': IntlMessages;
28
28
  }, [
29
29
  NestedKey
30
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: MarkupTranslationValues, formats?: Partial<Formats>): string;
30
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: [TargetKey] extends [never] ? string : TargetKey, values?: MarkupTranslationValues, formats?: Partial<Formats>): string;
31
31
  raw<TargetKey extends MessageKeys<NestedValueOf<{
32
32
  '!': IntlMessages;
33
33
  }, [
@@ -36,7 +36,7 @@ declare function getTranslations<NestedKey extends NamespaceKeys<IntlMessages, N
36
36
  '!': IntlMessages;
37
37
  }, [
38
38
  NestedKey
39
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
39
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: [TargetKey] extends [never] ? string : TargetKey): any;
40
40
  }>;
41
41
  declare function getTranslations<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(opts?: {
42
42
  locale: string;
package/navigation.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './dist/types/src/navigation';
1
+ export * from './dist/types/src/navigation.react-client';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "description": "A minimal, but complete solution for internationalization in Next.js apps.",
@@ -18,14 +18,14 @@
18
18
  "postpublish": "git checkout . && rm ./README.md",
19
19
  "size": "size-limit"
20
20
  },
21
- "main": "./dist/index.js",
22
- "module": "./dist/esm/index.js",
23
- "typings": "./dist/types/src/index.d.ts",
21
+ "main": "./dist/index.react-client.js",
22
+ "module": "./dist/esm/index.react-client.js",
23
+ "typings": "./dist/types/src/index.react-client.d.ts",
24
24
  "exports": {
25
25
  ".": {
26
- "types": "./dist/types/src/index.d.ts",
26
+ "types": "./dist/types/src/index.react-client.d.ts",
27
27
  "react-server": "./dist/esm/index.react-server.js",
28
- "default": "./dist/index.js"
28
+ "default": "./dist/index.react-client.js"
29
29
  },
30
30
  "./server": {
31
31
  "types": "./server.d.ts",
@@ -42,7 +42,7 @@
42
42
  "./navigation": {
43
43
  "types": "./navigation.d.ts",
44
44
  "react-server": "./dist/esm/navigation.react-server.js",
45
- "default": "./dist/navigation.js"
45
+ "default": "./dist/navigation.react-client.js"
46
46
  },
47
47
  "./plugin": {
48
48
  "types": "./plugin.d.ts",
@@ -73,7 +73,7 @@
73
73
  "dependencies": {
74
74
  "@formatjs/intl-localematcher": "^0.2.32",
75
75
  "negotiator": "^0.6.3",
76
- "use-intl": "^3.0.1"
76
+ "use-intl": "^3.0.3"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
@@ -101,13 +101,21 @@
101
101
  },
102
102
  "size-limit": [
103
103
  {
104
- "path": "dist/production/index.js",
104
+ "path": "dist/production/index.react-client.js",
105
105
  "limit": "12.81 KB"
106
106
  },
107
107
  {
108
- "path": "dist/production/navigation.js",
108
+ "path": "dist/production/index.react-server.js",
109
+ "limit": "13.57 KB"
110
+ },
111
+ {
112
+ "path": "dist/production/navigation.react-client.js",
109
113
  "limit": "2.6 KB"
110
114
  },
115
+ {
116
+ "path": "dist/production/navigation.react-server.js",
117
+ "limit": "2.75 KB"
118
+ },
111
119
  {
112
120
  "path": "dist/production/server.js",
113
121
  "limit": "13.2 kB"
@@ -117,5 +125,5 @@
117
125
  "limit": "5.7 KB"
118
126
  }
119
127
  ],
120
- "gitHead": "b3297ca0514b9393f1ba091883c47e79a77be130"
128
+ "gitHead": "30b62603b4df925d69ec7111e4167fcee628ab33"
121
129
  }
@@ -1 +0,0 @@
1
- import{extends as e}from"../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import a from"../react-client/useLocale.js";import l from"../shared/BaseLinkWithLocale.js";function o(t,o){let{locale:s,...i}=t;const n=a(),c=s||n;return r.createElement(l,e({ref:o,hrefLang:c,locale:c},i))}const s=t(o);s.displayName="Link";var i=s;export{i as default};
@@ -1 +0,0 @@
1
- import r from"../react-client/useLocale.js";import e from"../shared/redirectWithLocale.js";function t(t){let n;try{n=r()}catch(r){throw new Error("`redirect()` can only be called during render. To redirect in an event handler or similar, you can use `useRouter()` instead.")}for(var a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return e(t,n,...o)}export{t as default};
@@ -1 +0,0 @@
1
- import{extends as e}from"../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import o from"../react-client/useLocale.js";import a from"./BaseLink.js";import n from"./baseRedirect.js";import l from"./useBasePathname.js";import c from"./useBaseRouter.js";import{getRoute as s,compileLocalizedPathname as u,normalizeNameOrNameWithParams as i}from"./utils.js";function f(f){let{locales:m,pathnames:p}=f;function h(){const e=o();if(!m.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `app/[locale]/layout.tsx`.'));return e}function d(t,o){let{href:n,locale:l,...c}=t;const s=h(),i=l||s;return r.createElement(a,e({ref:o,href:u({locale:i,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:p}),locale:l},c))}const v=t(d);function j(e){let{href:r,locale:t}=e;return u({...i(r),locale:t,pathnames:p})}return v.displayName="Link",{Link:v,redirect:function(e){const r=j({href:e,locale:h()});for(var t=arguments.length,o=new Array(t>1?t-1:0),a=1;a<t;a++)o[a-1]=arguments[a];return n(r,...o)},usePathname:function(){const e=l(),r=h();return s({pathname:e,locale:r,pathnames:p})},useRouter:function(){const e=c(),r=h();return{...e,push(t){for(var o,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=j({href:t,locale:(null===(o=n[0])||void 0===o?void 0:o.locale)||r});return e.push(c,...n)},replace(t){for(var o,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=j({href:t,locale:(null===(o=n[0])||void 0===o?void 0:o.locale)||r});return e.replace(c,...n)},prefetch(t){for(var o,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=j({href:t,locale:(null===(o=n[0])||void 0===o?void 0:o.locale)||r});return e.prefetch(c,...n)}}},getPathname:j}}export{f as default};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{usePathname as r}from"next/navigation";import{useMemo as t}from"react";import o from"../react-client/useLocale.js";import{hasPathnamePrefixed as e,unlocalizePathname as i}from"../shared/utils.js";function n(){const n=r(),a=o();return t((()=>{if(!n)return n;return e(a,n)?i(n,a):n}),[a,n])}export{n as default};
@@ -1 +0,0 @@
1
- import{useRouter as e}from"next/navigation";import{useMemo as t}from"react";import r from"../react-client/useLocale.js";import{localizeHref as n}from"../shared/utils.js";function o(){const o=e(),c=r();return t((()=>{function e(e,t){return n(e,t||c,c,window.location.pathname)}return{...o,push(t,r){const{locale:n,...c}=r||{},s=[e(t,n)];return Object.keys(c).length>0&&s.push(c),o.push(...s)},replace(t,r){const{locale:n,...c}=r||{},s=[e(t,n)];return Object.keys(c).length>0&&s.push(c),o.replace(...s)},prefetch(t,r){const{locale:n,...c}=r||{},s=[e(t,n)];return Object.keys(c).length>0&&s.push(c),o.prefetch(...s)}}}),[c,o])}export{o as default};
@@ -1 +0,0 @@
1
- import{unlocalizePathname 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,a]of Object.entries(t))Array.isArray(a)?a.forEach((t=>{r.append(e,n(t))})):r.set(e,n(a));return"?"+r.toString()}function a(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,r]=t;o=Array.isArray(r)?o.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),r.map((t=>String(t))).join("/")):o.replace("[".concat(n,"]"),String(r))})),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,...r}=n;return{...r,pathname:s(c(t))}}}function o(r){var e;let{locale:a,pathname:o,pathnames:i}=r;const c=t(o,a);let s=null===(e=Object.entries(i).find((t=>{let[,r]=t;const e="string"!=typeof r?r[a]:r;return n(e,c)})))||void 0===e?void 0:e[0];return s||(s=o),s}export{a as compileLocalizedPathname,o as getRoute,r as normalizeNameOrNameWithParams,e as serializeSearchParams};
@@ -1 +0,0 @@
1
- export{default as createSharedPathnamesNavigation}from"./navigation/createSharedPathnamesNavigation.js";export{default as createLocalizedPathnamesNavigation}from"./navigation/createLocalizedPathnamesNavigation.js";
package/dist/index.js DELETED
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./production/index.js');
5
- } else {
6
- module.exports = require('./development/index.js');
7
- }
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./production/navigation.js');
5
- } else {
6
- module.exports = require('./development/navigation.js');
7
- }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../react-client/useLocale.js"),a=require("../shared/BaseLinkWithLocale.js");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r);function s(r,l){let{locale:s,...n}=r;const i=t.default(),o=s||i;return u.default.createElement(a.default,e.extends({ref:l,hrefLang:o,locale:o},n))}const n=r.forwardRef(s);n.displayName="Link";var i=n;exports.default=i;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../react-client/useLocale.js"),r=require("../shared/redirectWithLocale.js");exports.default=function(t){let a;try{a=e.default()}catch(e){throw new Error(void 0)}for(var o=arguments.length,u=new Array(o>1?o-1:0),c=1;c<o;c++)u[c-1]=arguments[c];return r.default(t,a,...u)};
@@ -1 +0,0 @@
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("./BaseLink.js"),l=require("./baseRedirect.js"),n=require("./useBasePathname.js"),o=require("./useBaseRouter.js"),u=require("./utils.js");function c(e){return e&&e.__esModule?e:{default:e}}var s=c(r);exports.default=function(c){let{locales:i,pathnames:f}=c;function h(){const e=a.default();if(!i.includes(e))throw new Error(void 0);return e}function d(r,a){let{href:l,locale:n,...o}=r;const c=h(),i=n||c;return s.default.createElement(t.default,e.extends({ref:a,href:u.compileLocalizedPathname({locale:i,pathname:l,params:"object"==typeof l?l.params:void 0,pathnames:f}),locale:n},o))}const p=r.forwardRef(d);function m(e){let{href:r,locale:a}=e;return u.compileLocalizedPathname({...u.normalizeNameOrNameWithParams(r),locale:a,pathnames:f})}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),n=1;n<a;n++)t[n-1]=arguments[n];return l.default(r,...t)},usePathname:function(){const e=n.default(),r=h();return u.getRoute({pathname:e,locale:r,pathnames:f})},useRouter:function(){const e=o.default(),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 u=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(u,...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 u=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(u,...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 u=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(u,...n)}}},getPathname:m}};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("react"),t=require("../react-client/useLocale.js"),a=require("../shared/utils.js");exports.default=function(){const u=e.usePathname(),n=t.default();return r.useMemo((()=>{if(!u)return u;return a.hasPathnamePrefixed(n,u)?a.unlocalizePathname(u,n):u}),[n,u])};
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("react"),r=require("../react-client/useLocale.js"),u=require("../shared/utils.js");exports.default=function(){const n=e.useRouter(),c=r.default();return t.useMemo((()=>{function e(e,t){return u.localizeHref(e,t||c,c,window.location.pathname)}return{...n,push(t,r){const{locale:u,...c}=r||{},s=[e(t,u)];return Object.keys(c).length>0&&s.push(c),n.push(...s)},replace(t,r){const{locale:u,...c}=r||{},s=[e(t,u)];return Object.keys(c).length>0&&s.push(c),n.replace(...s)},prefetch(t,r){const{locale:u,...c}=r||{},s=[e(t,u)];return Object.keys(c).length>0&&s.push(c),n.prefetch(...s)}}}),[c,n])};
@@ -1 +0,0 @@
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 s(e){let t=o[e];return t||(t=e),t}function c(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 c(s(r))}{const{pathname:e,...t}=r;return{...t,pathname:c(s(e))}}},exports.getRoute=function(t){var r;let{locale:n,pathname:a,pathnames:o}=t;const i=e.unlocalizePathname(a,n);let s=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 s||(s=a),s},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./navigation/createSharedPathnamesNavigation.js"),a=require("./navigation/createLocalizedPathnamesNavigation.js");exports.createSharedPathnamesNavigation=e.default,exports.createLocalizedPathnamesNavigation=a.default;
@@ -1,3 +0,0 @@
1
- import redirectWithLocale from '../shared/redirectWithLocale';
2
- import { ParametersExceptFirstTwo } from '../shared/types';
3
- export default function baseRedirect(pathname: string, ...args: ParametersExceptFirstTwo<typeof redirectWithLocale>): never;
@@ -1 +0,0 @@
1
- export * from './navigation/index';
File without changes