next-intl 3.1.4 → 3.2.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 (71) hide show
  1. package/dist/development/middleware/middleware.js +6 -6
  2. package/dist/development/navigation/react-client/{BaseLink.js → ClientLink.js} +7 -7
  3. package/dist/development/navigation/react-client/{baseRedirect.js → clientRedirect.js} +7 -4
  4. package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +18 -18
  5. package/dist/development/navigation/react-client/createSharedPathnamesNavigation.js +27 -4
  6. package/dist/development/navigation/react-server/{BaseLink.js → ServerLink.js} +4 -4
  7. package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +11 -6
  8. package/dist/development/navigation/react-server/createSharedPathnamesNavigation.js +24 -4
  9. package/dist/development/navigation/react-server/{baseRedirect.js → serverRedirect.js} +7 -4
  10. package/dist/development/{shared/BaseLinkWithLocale.js → navigation/shared/BaseLink.js} +21 -16
  11. package/dist/development/navigation/shared/baseRedirect.js +16 -0
  12. package/dist/development/shared/utils.js +7 -7
  13. package/dist/esm/middleware/middleware.js +1 -1
  14. package/dist/esm/navigation/react-client/ClientLink.js +1 -0
  15. package/dist/esm/navigation/react-client/clientRedirect.js +1 -0
  16. package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
  17. package/dist/esm/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
  18. package/dist/esm/navigation/react-server/ServerLink.js +1 -0
  19. package/dist/esm/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
  20. package/dist/esm/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
  21. package/dist/esm/navigation/react-server/serverRedirect.js +1 -0
  22. package/dist/esm/navigation/shared/BaseLink.js +2 -0
  23. package/dist/esm/navigation/shared/baseRedirect.js +1 -0
  24. package/dist/esm/shared/utils.js +1 -1
  25. package/dist/production/middleware/middleware.js +1 -1
  26. package/dist/production/navigation/react-client/ClientLink.js +1 -0
  27. package/dist/production/navigation/react-client/clientRedirect.js +1 -0
  28. package/dist/production/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
  29. package/dist/production/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
  30. package/dist/production/navigation/react-server/ServerLink.js +1 -0
  31. package/dist/production/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
  32. package/dist/production/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
  33. package/dist/production/navigation/react-server/serverRedirect.js +1 -0
  34. package/dist/production/navigation/shared/BaseLink.js +2 -0
  35. package/dist/production/navigation/shared/baseRedirect.js +1 -0
  36. package/dist/production/shared/utils.js +1 -1
  37. package/dist/types/src/middleware/NextIntlMiddlewareConfig.d.ts +1 -2
  38. package/dist/types/src/navigation/react-client/{BaseLink.d.ts → ClientLink.d.ts} +5 -4
  39. package/dist/types/src/navigation/react-client/clientRedirect.d.ts +6 -0
  40. package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +7 -5
  41. package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +43 -5
  42. package/dist/types/src/navigation/react-server/ServerLink.d.ts +8 -0
  43. package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +5 -3
  44. package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +6 -38
  45. package/dist/types/src/navigation/react-server/serverRedirect.d.ts +6 -0
  46. package/dist/types/src/navigation/shared/BaseLink.d.ts +9 -0
  47. package/dist/types/src/navigation/shared/baseRedirect.d.ts +7 -0
  48. package/dist/types/src/shared/types.d.ts +1 -0
  49. package/dist/types/src/shared/utils.d.ts +3 -3
  50. package/dist/types/test/navigation/createSharedPathnamesNavigation.test.d.ts +1 -0
  51. package/dist/types/test/navigation/react-client/ClientLink.test.d.ts +1 -0
  52. package/package.json +8 -7
  53. package/dist/development/shared/redirectWithLocale.js +0 -16
  54. package/dist/esm/navigation/react-client/BaseLink.js +0 -1
  55. package/dist/esm/navigation/react-client/baseRedirect.js +0 -1
  56. package/dist/esm/navigation/react-server/BaseLink.js +0 -1
  57. package/dist/esm/navigation/react-server/baseRedirect.js +0 -1
  58. package/dist/esm/shared/BaseLinkWithLocale.js +0 -2
  59. package/dist/esm/shared/redirectWithLocale.js +0 -1
  60. package/dist/production/navigation/react-client/BaseLink.js +0 -1
  61. package/dist/production/navigation/react-client/baseRedirect.js +0 -1
  62. package/dist/production/navigation/react-server/BaseLink.js +0 -1
  63. package/dist/production/navigation/react-server/baseRedirect.js +0 -1
  64. package/dist/production/shared/BaseLinkWithLocale.js +0 -2
  65. package/dist/production/shared/redirectWithLocale.js +0 -1
  66. package/dist/types/src/navigation/react-client/baseRedirect.d.ts +0 -3
  67. package/dist/types/src/navigation/react-server/BaseLink.d.ts +0 -8
  68. package/dist/types/src/navigation/react-server/baseRedirect.d.ts +0 -3
  69. package/dist/types/src/shared/BaseLinkWithLocale.d.ts +0 -7
  70. package/dist/types/src/shared/redirectWithLocale.d.ts +0 -3
  71. /package/dist/types/test/navigation/{react-client/BaseLink.test.d.ts → createLocalizedPathnamesNavigation.test.d.ts} +0 -0
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),t=require("../shared/constants.js"),a=require("../shared/utils.js"),n=require("./getAlternateLinksHeaderValue.js"),l=require("./resolveLocale.js"),o=require("./utils.js");exports.default=function(r){const i=function(e){var t,a,n;return{...e,alternateLinks:null===(t=e.alternateLinks)||void 0===t||t,localePrefix:null!==(a=e.localePrefix)&&void 0!==a?a:"always",localeDetection:null===(n=e.localeDetection)||void 0===n||n}}(r);return function(r){var s,c;const{domain:d,locale:u}=l.default(i,r.headers,r.cookies,r.nextUrl.pathname),f=i.localeDetection&&(null===(s=r.cookies.get(t.COOKIE_LOCALE_NAME))||void 0===s?void 0:s.value)!==u,h=d?d.defaultLocale===u:u===i.defaultLocale,m=(null===(c=i.domains)||void 0===c?void 0:c.filter((e=>o.isLocaleSupportedOnDomain(u,e))))||[],v=null!=i.domains&&!d;function p(a){return e.NextResponse.rewrite(new URL(a,r.url),function(){const e=new Headers(r.headers);return e.set(t.HEADER_LOCALE_NAME,u),{request:{headers:e}}}())}function x(t,a){const n=new URL(t,r.url);if(m.length>0&&!a){const e=o.getBestMatchingDomain(d,u,m);e&&(a=e.domain,e.defaultLocale===u&&"as-needed"===i.localePrefix&&(n.pathname=n.pathname.replace("/".concat(u),"")))}var l;a&&(n.protocol=null!==(l=r.headers.get("x-forwarded-proto"))&&void 0!==l?l:r.nextUrl.protocol,n.port="",n.host=a);return e.NextResponse.redirect(n.toString())}const L=o.getNormalizedPathname(r.nextUrl.pathname,i.locales),g=o.getKnownLocaleFromPathname(r.nextUrl.pathname,i.locales),P=null!=g;let E,U,A=r.nextUrl.pathname;if(i.pathnames){let e;if([e=u,U]=o.getInternalTemplate(i.pathnames,L),U){const t=i.pathnames[U],n="string"==typeof t?t:t[u];if(a.matchesPathname(n,L))A=o.formatTemplatePathname(L,n,U,g);else{const a=i.defaultLocale===u||(null==d?void 0:d.defaultLocale)===u;E=x(o.getPathWithSearch(o.formatTemplatePathname(L,"string"==typeof t?t:t[e],n,g||!a?u:void 0),r.nextUrl.search))}}}if(!E)if("/"===A){const e=o.getPathWithSearch("/".concat(u),r.nextUrl.search);E="never"===i.localePrefix||h&&"as-needed"===i.localePrefix?p(e):x(e)}else{const e=o.getPathWithSearch(A,r.nextUrl.search);if(P){const t=o.getBasePath(e,g);if("never"===i.localePrefix)E=x(t);else if(g===u)if(h&&"as-needed"===i.localePrefix)E=x(t);else if(i.domains){const a=o.getBestMatchingDomain(d,g,m);E=(null==d?void 0:d.domain)===(null==a?void 0:a.domain)||v?p(e):x(t,null==a?void 0:a.domain)}else E=p(e);else E=x("/".concat(u).concat(t))}else E="never"===i.localePrefix||h&&("as-needed"===i.localePrefix||i.domains)?p("/".concat(u).concat(e)):x("/".concat(u).concat(e))}var O;(f&&E.cookies.set(t.COOKIE_LOCALE_NAME,u,{sameSite:"strict",maxAge:31536e3}),"never"!==i.localePrefix&&i.alternateLinks&&i.locales.length>1)&&E.headers.set("Link",n.default({config:i,localizedPathnames:null!=U?null===(O=i.pathnames)||void 0===O?void 0:O[U]:void 0,request:r,resolvedLocale:u}));return E}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),t=require("../shared/constants.js"),a=require("../shared/utils.js"),n=require("./getAlternateLinksHeaderValue.js"),l=require("./resolveLocale.js"),o=require("./utils.js");exports.default=function(r){const i=function(e){var t,a,n;return{...e,alternateLinks:null===(t=e.alternateLinks)||void 0===t||t,localePrefix:null!==(a=e.localePrefix)&&void 0!==a?a:"always",localeDetection:null===(n=e.localeDetection)||void 0===n||n}}(r);return function(r){var s,c;const{domain:d,locale:u}=l.default(i,r.headers,r.cookies,r.nextUrl.pathname),h=i.localeDetection&&(null===(s=r.cookies.get(t.COOKIE_LOCALE_NAME))||void 0===s?void 0:s.value)!==u,f=d?d.defaultLocale===u:u===i.defaultLocale,m=(null===(c=i.domains)||void 0===c?void 0:c.filter((e=>o.isLocaleSupportedOnDomain(u,e))))||[],v=null!=i.domains&&!d;function p(a){return e.NextResponse.rewrite(new URL(a,r.url),function(){const e=new Headers(r.headers);return e.set(t.HEADER_LOCALE_NAME,u),{request:{headers:e}}}())}function x(t,a){const n=new URL(t,r.url);if(m.length>0&&!a){const e=o.getBestMatchingDomain(d,u,m);e&&(a=e.domain,e.defaultLocale===u&&"as-needed"===i.localePrefix&&(n.pathname=n.pathname.replace("/".concat(u),"")))}var l;a&&(n.protocol=null!==(l=r.headers.get("x-forwarded-proto"))&&void 0!==l?l:r.nextUrl.protocol,n.port="",n.host=a);return e.NextResponse.redirect(n.toString())}const g=o.getNormalizedPathname(r.nextUrl.pathname,i.locales),L=o.getKnownLocaleFromPathname(r.nextUrl.pathname,i.locales),P=null!=L;let U,E,A=r.nextUrl.pathname;if(i.pathnames){let e;if([e=u,E]=o.getInternalTemplate(i.pathnames,g),E){const t=i.pathnames[E],n="string"==typeof t?t:t[u];if(a.matchesPathname(n,g))A=o.formatTemplatePathname(g,n,E,L);else{const a=i.defaultLocale===u||(null==d?void 0:d.defaultLocale)===u;U=x(o.getPathWithSearch(o.formatTemplatePathname(g,"string"==typeof t?t:t[e],n,L||!a?u:void 0),r.nextUrl.search))}}}if(!U)if("/"===A){const e=o.getPathWithSearch("/".concat(u),r.nextUrl.search);U="never"===i.localePrefix||f&&"as-needed"===i.localePrefix?p(e):x(e)}else{const e=o.getPathWithSearch(A,r.nextUrl.search);if(P){const t=o.getBasePath(o.getPathWithSearch(g,r.nextUrl.search),L);if("never"===i.localePrefix)U=x(t);else if(L===u)if(f&&"as-needed"===i.localePrefix)U=x(t);else if(i.domains){const a=o.getBestMatchingDomain(d,L,m);U=(null==d?void 0:d.domain)===(null==a?void 0:a.domain)||v?p(e):x(t,null==a?void 0:a.domain)}else U=p(e);else U=x("/".concat(u).concat(t))}else U="never"===i.localePrefix||f&&("as-needed"===i.localePrefix||i.domains)?p("/".concat(u).concat(e)):x("/".concat(u).concat(e))}var O;(h&&U.cookies.set(t.COOKIE_LOCALE_NAME,u,{sameSite:"strict",maxAge:31536e3}),"never"!==i.localePrefix&&i.alternateLinks&&i.locales.length>1)&&U.headers.set("Link",n.default({config:i,localizedPathnames:null!=E?null===(O=i.pathnames)||void 0===O?void 0:O[E]:void 0,request:r,resolvedLocale:u}));return U}};
@@ -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"),l=require("../shared/BaseLink.js");function a(e){return e&&e.__esModule?e:{default:e}}var u=a(r);function n(r,a){let{locale:n,...s}=r;const i=t.default(),o=n||i;return u.default.createElement(l.default,e.extends({ref:a,hrefLang:o,locale:o},s))}const s=r.forwardRef(n);s.displayName="ClientLink";var i=s;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/baseRedirect.js");exports.default=function(t){let a;try{a=e.default()}catch(e){throw new Error(void 0)}for(var l=arguments.length,o=new Array(l>1?l-1:0),u=1;u<l;u++)o[u-1]=arguments[u];return r.default({...t,locale:a},...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/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}};
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("./ClientLink.js"),n=require("./clientRedirect.js"),o=require("./useBasePathname.js"),u=require("./useBaseRouter.js");function c(e){return e&&e.__esModule?e:{default:e}}var i=c(r);exports.default=function(c){function s(){const e=a.default();if(!c.locales.includes(e))throw new Error(void 0);return e}function f(r,a){let{href:n,locale:o,...u}=r;const f=s(),h=o||f;return i.default.createElement(l.default,e.extends({ref:a,href:t.compileLocalizedPathname({locale:h,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:c.pathnames}),locale:o,localePrefix:c.localePrefix},u))}const h=r.forwardRef(f);function d(e){let{href:r,locale:a}=e;return t.compileLocalizedPathname({...t.normalizeNameOrNameWithParams(r),locale:a,pathnames:c.pathnames})}return h.displayName="Link",{Link:h,redirect:function(e){const r=d({href:e,locale:s()});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({...c,pathname:r},...t)},usePathname:function(){const e=o.default(),r=s();return t.getRoute({pathname:e,locale:r,pathnames:c.pathnames})},useRouter:function(){const e=u.default(),r=s();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=d({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=d({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=d({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(u,...n)}}},getPathname:d}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./BaseLink.js"),r=require("./baseRedirect.js"),u=require("./useBasePathname.js"),t=require("./useBaseRouter.js");exports.default=function(s){return{Link:e.default,redirect:r.default,usePathname:u.default,useRouter:t.default}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("./ClientLink.js"),u=require("./clientRedirect.js"),a=require("./useBasePathname.js"),n=require("./useBaseRouter.js");function l(e){return e&&e.__esModule?e:{default:e}}var i=l(r);exports.default=function(l){function s(r,u){return i.default.createElement(t.default,e.extends({ref:u,localePrefix:l.localePrefix},r))}const f=r.forwardRef(s);return f.displayName="Link",{Link:f,redirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),a=1;a<r;a++)t[a-1]=arguments[a];return u.default({...l,pathname:e},...t)},usePathname:a.default,useRouter:n.default}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../shared/BaseLink.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("../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")}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../server/RequestLocale.js"),a=require("../shared/utils.js"),o=require("./ServerLink.js"),n=require("./serverRedirect.js");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r);exports.default=function(r){let{localePrefix:l,locales:s,pathnames:c}=r;function i(e){let{href:r,locale:t}=e;return a.compileLocalizedPathname({...a.normalizeNameOrNameWithParams(r),locale:t,pathnames:c})}function f(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(r){let{href:n,locale:s,...i}=r;const f=t.getRequestLocale(),m=s||f;return u.default.createElement(o.default,e.extends({href:a.compileLocalizedPathname({locale:m,pathname:n,params:"object"==typeof n?n.params:void 0,pathnames:c}),locale:s,localePrefix:l},i))},redirect:function(e){const r=i({href:e,locale:t.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({localePrefix:l,pathname:r},...o)},getPathname:i,usePathname:f("usePathname"),useRouter:f("useRouter")}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./BaseLink.js"),t=require("./baseRedirect.js");exports.default=function(r){function o(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:e.default,redirect:t.default,usePathname:o("usePathname"),useRouter:o("useRouter")}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("./ServerLink.js"),n=require("./serverRedirect.js");function u(e){return e&&e.__esModule?e:{default:e}}var o=u(r);exports.default=function(r){function u(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(n){return o.default.createElement(t.default,e.extends({localePrefix:r.localePrefix},n))},redirect:function(e){for(var t=arguments.length,u=new Array(t>1?t-1:0),o=1;o<t;o++)u[o-1]=arguments[o];return n.default({...r,pathname:e},...u)},usePathname:u("usePathname"),useRouter:u("useRouter")}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../server/RequestLocale.js"),r=require("../shared/baseRedirect.js");exports.default=function(t){const s=e.getRequestLocale();for(var a=arguments.length,u=new Array(a>1?a-1:0),o=1;o<a;o++)u[o-1]=arguments[o];return r.default({...t,locale:s},...u)};
@@ -0,0 +1,2 @@
1
+ 'use client';
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("next/link"),t=require("next/navigation"),l=require("react"),a=require("../../react-client/useLocale.js"),u=require("../../shared/utils.js");function i(e){return e&&e.__esModule?e:{default:e}}var n=i(r),f=i(l);function s(r,i){let{href:s,locale:c,localePrefix:o,prefetch:d,...p}=r;const v=t.usePathname(),x=a.default(),h=c!==x,[q,_]=l.useState((()=>u.isLocalHref(s)&&("never"!==o||h)?u.prefixHref(s,c):s));return l.useEffect((()=>{v&&"never"!==o&&_(u.localizeHref(s,c,x,null!=v?v:void 0))}),[x,s,c,o,v]),h&&(d=!1),f.default.createElement(n.default,e.extends({ref:i,href:q,prefetch:d},p))}const c=l.forwardRef(s);c.displayName="ClientLink";var o=c;exports.default=o;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("../../shared/utils.js");exports.default=function(t){const a="never"===t.localePrefix?t.pathname:r.prefixPathname(t.locale,t.pathname);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return e.redirect(a,...i)};
@@ -1 +1 @@
1
- "use strict";function t(t){const e="object"==typeof t?t.pathname:t;return null!=e&&!e.startsWith("/")}function e(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function n(t,e){let n;return"string"==typeof t?n=r(e,t):(n={...t},t.pathname&&(n.pathname=r(e,t.pathname))),n}function r(t,e){let n="/"+t;return/^\/(\?.*)?$/.test(e)&&(e=e.slice(1)),n+=e,n}function o(t,e){const n="/".concat(t);return e===n||e.startsWith("".concat(n,"/"))}function a(t){const e=t.replace(/\[([^\]]+)\]/g,(t=>t.startsWith("[...")||t.startsWith("[[...")?"(.*)":"([^/]+)")).replaceAll("(.*)]","(.*)");return new RegExp("^".concat(e,"$"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.hasPathnamePrefixed=o,exports.isLocalHref=e,exports.isRelativeHref=t,exports.localizeHref=function(r,a){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,c=arguments.length>3?arguments[3]:void 0;if(!e(r)||t(r))return r;const l=a!==s;return(null==a||o(a,c)||l)&&null!=a?n(r,a):r},exports.localizePathname=r,exports.matchesPathname=function(t,e){return a(t).test(e)},exports.prefixHref=n,exports.templateToRegex=a,exports.unlocalizePathname=function(t,e){return t.replace(new RegExp("^/".concat(e)),"")||"/"};
1
+ "use strict";function t(t){const e="object"==typeof t?t.pathname:t;return null!=e&&!e.startsWith("/")}function e(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function n(t,e){let n;return"string"==typeof t?n=r(e,t):(n={...t},t.pathname&&(n.pathname=r(e,t.pathname))),n}function r(t,e){let n="/"+t;return/^\/(\?.*)?$/.test(e)&&(e=e.slice(1)),n+=e,n}function o(t,e){const n="/".concat(t);return e===n||e.startsWith("".concat(n,"/"))}function a(t){const e=t.replace(/\[([^\]]+)\]/g,(t=>t.startsWith("[...")||t.startsWith("[[...")?"(.*)":"([^/]+)")).replaceAll("(.*)]","(.*)");return new RegExp("^".concat(e,"$"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.hasPathnamePrefixed=o,exports.isLocalHref=e,exports.isRelativeHref=t,exports.localizeHref=function(r,a){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,c=arguments.length>3?arguments[3]:void 0;if(!e(r)||t(r))return r;const i=a!==s,l=null==a||o(a,c);return(i||l)&&null!=a?n(r,a):r},exports.matchesPathname=function(t,e){return a(t).test(e)},exports.prefixHref=n,exports.prefixPathname=r,exports.templateToRegex=a,exports.unlocalizePathname=function(t,e){return t.replace(new RegExp("^/".concat(e)),"")||"/"};
@@ -1,5 +1,4 @@
1
- import { AllLocales, Pathnames } from '../shared/types';
2
- type LocalePrefix = 'as-needed' | 'always' | 'never';
1
+ import { AllLocales, LocalePrefix, Pathnames } from '../shared/types';
3
2
  type RoutingBaseConfig<Locales extends AllLocales> = {
4
3
  /** A list of all locales that are supported. */
5
4
  locales: Locales;
@@ -1,8 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import React, { ComponentProps, ReactElement } from 'react';
3
- import BaseLinkWithLocale from '../../shared/BaseLinkWithLocale';
4
3
  import { AllLocales } from '../../shared/types';
5
- type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLinkWithLocale>, 'locale'> & {
4
+ import BaseLink from '../shared/BaseLink';
5
+ type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
6
6
  locale?: Locales[number];
7
7
  };
8
8
  /**
@@ -25,7 +25,7 @@ type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLinkWith
25
25
  * the `set-cookie` response header would cause the locale cookie on the current
26
26
  * page to be overwritten before the user even decides to change the locale.
27
27
  */
28
- declare const BaseLinkWithRef: <Locales extends AllLocales>(props: Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
28
+ declare const ClientLinkWithRef: <Locales extends AllLocales>(props: Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
29
29
  href: string | import("url").UrlObject;
30
30
  as?: (string | import("url").UrlObject) | undefined;
31
31
  replace?: boolean | undefined;
@@ -55,9 +55,10 @@ declare const BaseLinkWithRef: <Locales extends AllLocales>(props: Omit<Omit<Omi
55
55
  children?: React.ReactNode;
56
56
  } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
57
57
  locale: string;
58
+ localePrefix?: import("../../shared/types").LocalePrefix | undefined;
58
59
  }, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
59
60
  locale?: Locales[number] | undefined;
60
61
  } & {
61
62
  ref?: React.Ref<HTMLAnchorElement> | undefined;
62
63
  }) => ReactElement;
63
- export default BaseLinkWithRef;
64
+ export default ClientLinkWithRef;
@@ -0,0 +1,6 @@
1
+ import { LocalePrefix, ParametersExceptFirstTwo } from '../../shared/types';
2
+ import baseRedirect from '../shared/baseRedirect';
3
+ export default function clientRedirect(params: {
4
+ localePrefix?: LocalePrefix;
5
+ pathname: string;
6
+ }, ...args: ParametersExceptFirstTwo<typeof baseRedirect>): never;
@@ -1,11 +1,12 @@
1
1
  /// <reference types="node" />
2
2
  import React, { ComponentProps, ReactElement } from 'react';
3
- import { AllLocales, Pathnames } from '../../shared/types';
3
+ import { AllLocales, LocalePrefix, Pathnames } from '../../shared/types';
4
4
  import { HrefOrHrefWithParams } from '../shared/utils';
5
- import BaseLink from './BaseLink';
6
- export default function createLocalizedPathnamesNavigation<Locales extends AllLocales, PathnamesConfig extends Pathnames<Locales>>({ locales, pathnames }: {
5
+ import ClientLink from './ClientLink';
6
+ export default function createLocalizedPathnamesNavigation<Locales extends AllLocales, PathnamesConfig extends Pathnames<Locales>>(opts: {
7
7
  locales: Locales;
8
8
  pathnames: PathnamesConfig;
9
+ localePrefix?: LocalePrefix;
9
10
  }): {
10
11
  Link: <Pathname extends keyof PathnamesConfig>(props: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
11
12
  href: string | import("url").UrlObject;
@@ -37,6 +38,7 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
37
38
  children?: React.ReactNode;
38
39
  } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
39
40
  locale: string;
41
+ localePrefix?: LocalePrefix | undefined;
40
42
  }, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
41
43
  locale?: string | undefined;
42
44
  } & {
@@ -53,9 +55,9 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
53
55
  } & Omit<import("url").UrlObject, "pathname">);
54
56
  locale?: Locales[number] | undefined;
55
57
  } & {
56
- ref?: ComponentProps<typeof BaseLink>['ref'];
58
+ ref?: ComponentProps<typeof ClientLink>['ref'];
57
59
  }) => ReactElement;
58
- redirect: <Pathname_1 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_1>, type?: import("next/navigation").RedirectType | undefined) => never;
60
+ redirect: <Pathname_1 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_1>) => never;
59
61
  usePathname: () => keyof PathnamesConfig;
60
62
  useRouter: () => {
61
63
  push<Pathname_2 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_2>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & {
@@ -1,13 +1,51 @@
1
- import { AllLocales } from '../../shared/types';
2
- import BaseLink from './BaseLink';
3
- import baseRedirect from './baseRedirect';
1
+ /// <reference types="node" />
2
+ import React, { ReactElement } from 'react';
3
+ import { AllLocales, LocalePrefix } from '../../shared/types';
4
4
  import useBasePathname from './useBasePathname';
5
5
  import useBaseRouter from './useBaseRouter';
6
6
  export default function createSharedPathnamesNavigation<Locales extends AllLocales>(opts: {
7
7
  locales: Locales;
8
+ localePrefix?: LocalePrefix;
8
9
  }): {
9
- Link: typeof BaseLink<Locales>;
10
- redirect: typeof baseRedirect;
10
+ Link: (props: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
11
+ href: string | import("url").UrlObject;
12
+ as?: (string | import("url").UrlObject) | undefined;
13
+ replace?: boolean | undefined;
14
+ scroll?: boolean | undefined;
15
+ shallow?: boolean | undefined;
16
+ passHref?: boolean | undefined;
17
+ prefetch?: boolean | undefined;
18
+ locale?: string | false | undefined;
19
+ legacyBehavior?: boolean | undefined;
20
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
21
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
22
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
23
+ }> & {
24
+ href: string | import("url").UrlObject;
25
+ as?: (string | import("url").UrlObject) | undefined;
26
+ replace?: boolean | undefined;
27
+ scroll?: boolean | undefined;
28
+ shallow?: boolean | undefined;
29
+ passHref?: boolean | undefined;
30
+ prefetch?: boolean | undefined;
31
+ locale?: string | false | undefined;
32
+ legacyBehavior?: boolean | undefined;
33
+ onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
34
+ onTouchStart?: React.TouchEventHandler<HTMLAnchorElement> | undefined;
35
+ onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
36
+ } & {
37
+ children?: React.ReactNode;
38
+ } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
39
+ locale: string;
40
+ localePrefix?: LocalePrefix | undefined;
41
+ }, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
42
+ locale?: Locales[number] | undefined;
43
+ } & {
44
+ ref?: React.Ref<HTMLAnchorElement> | undefined;
45
+ }, "localePrefix"> & {
46
+ ref?: React.Ref<HTMLAnchorElement> | undefined;
47
+ }) => ReactElement;
48
+ redirect: (pathname: string) => never;
11
49
  usePathname: typeof useBasePathname;
12
50
  useRouter: typeof useBaseRouter;
13
51
  };
@@ -0,0 +1,8 @@
1
+ import React, { ComponentProps } from 'react';
2
+ import { AllLocales } from '../../shared/types';
3
+ import BaseLink from '../shared/BaseLink';
4
+ type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
5
+ locale?: Locales[number];
6
+ };
7
+ export default function ServerLink<Locales extends AllLocales>({ locale, ...rest }: Props<Locales>): Promise<React.JSX.Element>;
8
+ export {};
@@ -1,10 +1,11 @@
1
1
  /// <reference types="node" />
2
2
  import React from 'react';
3
- import { AllLocales, Pathnames } from '../../shared/types';
3
+ import { AllLocales, LocalePrefix, Pathnames } from '../../shared/types';
4
4
  import { HrefOrHrefWithParams } from '../shared/utils';
5
- export default function createLocalizedPathnamesNavigation<Locales extends AllLocales, PathnamesConfig extends Pathnames<Locales>>({ locales, pathnames }: {
5
+ export default function createLocalizedPathnamesNavigation<Locales extends AllLocales, PathnamesConfig extends Pathnames<Locales>>({ localePrefix, locales, pathnames }: {
6
6
  locales: Locales;
7
7
  pathnames: Pathnames<Locales>;
8
+ localePrefix?: LocalePrefix;
8
9
  }): {
9
10
  Link: <Pathname extends keyof PathnamesConfig>({ href, locale, ...rest }: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
10
11
  href: string | import("url").UrlObject;
@@ -36,6 +37,7 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
36
37
  children?: React.ReactNode;
37
38
  } & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
38
39
  locale: string;
40
+ localePrefix?: LocalePrefix | undefined;
39
41
  }, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
40
42
  locale?: string | undefined;
41
43
  }, "href" | "name"> & {
@@ -50,7 +52,7 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
50
52
  } & Omit<import("url").UrlObject, "pathname">);
51
53
  locale?: Locales[number] | undefined;
52
54
  }) => React.JSX.Element;
53
- redirect: <Pathname_1 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_1>, type?: import("next/navigation").RedirectType | undefined) => never;
55
+ redirect: <Pathname_1 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_1>) => never;
54
56
  getPathname: ({ href, locale }: {
55
57
  locale: Locales[number];
56
58
  href: HrefOrHrefWithParams<keyof PathnamesConfig>;
@@ -1,44 +1,12 @@
1
- /// <reference types="react" />
2
- /// <reference types="node" />
3
- import { AllLocales } from '../../shared/types';
4
- import baseRedirect from './baseRedirect';
1
+ import React, { ComponentProps } from 'react';
2
+ import { AllLocales, LocalePrefix } from '../../shared/types';
3
+ import ServerLink from './ServerLink';
5
4
  export default function createSharedPathnamesNavigation<Locales extends AllLocales>(opts: {
6
5
  locales: Locales;
6
+ localePrefix?: LocalePrefix;
7
7
  }): {
8
- Link: ({ locale, ...rest }: Omit<Omit<Omit<Omit<import("react").AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
9
- href: string | import("url").UrlObject;
10
- as?: (string | import("url").UrlObject) | undefined;
11
- replace?: boolean | undefined;
12
- scroll?: boolean | undefined;
13
- shallow?: boolean | undefined;
14
- passHref?: boolean | undefined;
15
- prefetch?: boolean | undefined;
16
- locale?: string | false | undefined;
17
- legacyBehavior?: boolean | undefined;
18
- onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
19
- onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
20
- onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
21
- }> & {
22
- href: string | import("url").UrlObject;
23
- as?: (string | import("url").UrlObject) | undefined;
24
- replace?: boolean | undefined;
25
- scroll?: boolean | undefined;
26
- shallow?: boolean | undefined;
27
- passHref?: boolean | undefined;
28
- prefetch?: boolean | undefined;
29
- locale?: string | false | undefined;
30
- legacyBehavior?: boolean | undefined;
31
- onMouseEnter?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
32
- onTouchStart?: import("react").TouchEventHandler<HTMLAnchorElement> | undefined;
33
- onClick?: import("react").MouseEventHandler<HTMLAnchorElement> | undefined;
34
- } & {
35
- children?: import("react").ReactNode;
36
- } & import("react").RefAttributes<HTMLAnchorElement>, "locale"> & {
37
- locale: string;
38
- }, "ref"> & import("react").RefAttributes<HTMLAnchorElement>, "locale"> & {
39
- locale?: Locales[number] | undefined;
40
- }) => Promise<import("react").JSX.Element>;
41
- redirect: typeof baseRedirect;
8
+ Link: (props: ComponentProps<typeof ServerLink<Locales>>) => React.JSX.Element;
9
+ redirect: (pathname: string) => never;
42
10
  usePathname: () => never;
43
11
  useRouter: () => never;
44
12
  };
@@ -0,0 +1,6 @@
1
+ import { LocalePrefix, ParametersExceptFirstTwo } from '../../shared/types';
2
+ import baseRedirect from '../shared/baseRedirect';
3
+ export default function serverRedirect(params: {
4
+ pathname: string;
5
+ localePrefix?: LocalePrefix;
6
+ }, ...args: ParametersExceptFirstTwo<typeof baseRedirect>): never;
@@ -0,0 +1,9 @@
1
+ import NextLink from 'next/link';
2
+ import React, { ComponentProps } from 'react';
3
+ import { LocalePrefix } from '../../shared/types';
4
+ type Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {
5
+ locale: string;
6
+ localePrefix?: LocalePrefix;
7
+ };
8
+ declare const BaseLinkWithRef: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
9
+ export default BaseLinkWithRef;
@@ -0,0 +1,7 @@
1
+ import { redirect as nextRedirect } from 'next/navigation';
2
+ import { AllLocales, LocalePrefix, ParametersExceptFirst } from '../../shared/types';
3
+ export default function baseRedirect(params: {
4
+ pathname: string;
5
+ locale: AllLocales[number];
6
+ localePrefix?: LocalePrefix;
7
+ }, ...args: ParametersExceptFirst<typeof nextRedirect>): never;
@@ -1,4 +1,5 @@
1
1
  export type AllLocales = ReadonlyArray<string>;
2
+ export type LocalePrefix = 'as-needed' | 'always' | 'never';
2
3
  export type Pathnames<Locales extends AllLocales> = Record<string, {
3
4
  [Key in Locales[number]]: string;
4
5
  } | string>;
@@ -5,12 +5,12 @@ import { ComponentProps } from 'react';
5
5
  type Href = ComponentProps<typeof NextLink>['href'];
6
6
  export declare function isRelativeHref(href: Href): boolean;
7
7
  export declare function isLocalHref(href: Href): boolean;
8
- export declare function localizeHref(href: string, locale: string, defaultLocale: string, pathname: string): string;
9
- export declare function localizeHref(href: UrlObject | string, locale: string, defaultLocale: string, pathname: string): UrlObject | string;
8
+ export declare function localizeHref(href: string, locale: string, curLocale: string, pathname: string): string;
9
+ export declare function localizeHref(href: UrlObject | string, locale: string, curLocale: string, pathname: string): UrlObject | string;
10
10
  export declare function prefixHref(href: string, locale: string): string;
11
11
  export declare function prefixHref(href: UrlObject | string, locale: string): UrlObject | string;
12
12
  export declare function unlocalizePathname(pathname: string, locale: string): string;
13
- export declare function localizePathname(locale: string, pathname: string): string;
13
+ export declare function prefixPathname(locale: string, pathname: string): string;
14
14
  export declare function hasPathnamePrefixed(locale: string, pathname: string): boolean;
15
15
  export declare function matchesPathname(
16
16
  /** E.g. `/users/[userId]-[userName]` */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "3.1.4",
3
+ "version": "3.2.0",
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.",
@@ -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.1.4"
76
+ "use-intl": "^3.2.0"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
@@ -86,10 +86,11 @@
86
86
  "@types/negotiator": "^0.6.1",
87
87
  "@types/node": "^17.0.23",
88
88
  "@types/react": "18.2.34",
89
- "eslint": "^8.46.0",
89
+ "@types/react-dom": "^18.2.17",
90
+ "eslint": "^8.54.0",
90
91
  "eslint-config-molindo": "^7.0.0",
91
92
  "eslint-plugin-deprecation": "^1.4.1",
92
- "next": "14.0.3",
93
+ "next": "^14.0.3",
93
94
  "path-to-regexp": "^6.2.1",
94
95
  "react": "^18.2.0",
95
96
  "react-dom": "^18.2.0",
@@ -110,11 +111,11 @@
110
111
  },
111
112
  {
112
113
  "path": "dist/production/navigation.react-client.js",
113
- "limit": "2.6 KB"
114
+ "limit": "2.62 KB"
114
115
  },
115
116
  {
116
117
  "path": "dist/production/navigation.react-server.js",
117
- "limit": "2.75 KB"
118
+ "limit": "2.8 KB"
118
119
  },
119
120
  {
120
121
  "path": "dist/production/server.js",
@@ -125,5 +126,5 @@
125
126
  "limit": "5.72 KB"
126
127
  }
127
128
  ],
128
- "gitHead": "ae5c0347f70e19ee61fe94b0828655936759df6f"
129
+ "gitHead": "10ef8c5b6a4cff0b98bf7c0215e428a2962639fb"
129
130
  }
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var navigation = require('next/navigation');
6
- var utils = require('./utils.js');
7
-
8
- function redirectWithLocale(pathname, locale) {
9
- const localizedPathname = utils.localizePathname(locale, pathname);
10
- for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
11
- args[_key - 2] = arguments[_key];
12
- }
13
- return navigation.redirect(localizedPathname, ...args);
14
- }
15
-
16
- exports.default = redirectWithLocale;
@@ -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 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 +0,0 @@
1
- import{getRequestLocale as r}from"../../server/RequestLocale.js";import e from"../../shared/redirectWithLocale.js";function t(t){const o=r();for(var a=arguments.length,s=new Array(a>1?a-1:0),n=1;n<a;n++)s[n-1]=arguments[n];return e(t,o,...s)}export{t as default};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- import{extends as e}from"../_virtual/_rollupPluginBabelHelpers.js";import r from"next/link";import{usePathname as t}from"next/navigation";import o,{forwardRef as l,useState as n,useEffect as i}from"react";import p from"../react-client/useLocale.js";import{isLocalHref as c,prefixHref as a,localizeHref as s}from"./utils.js";function f(l,f){let{href:m,locale:u,prefetch:h,...d}=l;const v=t(),x=p(),g=u!==x,[j,k]=n((()=>c(m)&&u?a(m,u):m));return i((()=>{v&&k(s(m,u,x,null!=v?v:void 0))}),[x,m,u,v]),g&&(h&&console.error("The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`"),h=!1),o.createElement(r,e({ref:f,href:j,prefetch:h},d))}var m=l(f);export{m as default};
@@ -1 +0,0 @@
1
- import{redirect as r}from"next/navigation";import{localizePathname as t}from"./utils.js";function n(n,o){const a=t(o,n);for(var e=arguments.length,i=new Array(e>2?e-2:0),f=2;f<e;f++)i[f-2]=arguments[f];return r(a,...i)}export{n as default};
@@ -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"),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 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../server/RequestLocale.js"),r=require("../../shared/redirectWithLocale.js");exports.default=function(t){const s=e.getRequestLocale();for(var u=arguments.length,a=new Array(u>1?u-1:0),o=1;o<u;o++)a[o-1]=arguments[o];return r.default(t,s,...a)};
@@ -1,2 +0,0 @@
1
- 'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_rollupPluginBabelHelpers.js"),r=require("next/link"),t=require("next/navigation"),u=require("react"),l=require("../react-client/useLocale.js"),a=require("./utils.js");function f(e){return e&&e.__esModule?e:{default:e}}var i=f(r),n=f(u);function s(r,f){let{href:s,locale:c,prefetch:o,...d}=r;const p=t.usePathname(),v=l.default(),q=c!==v,[x,_]=u.useState((()=>a.isLocalHref(s)&&c?a.prefixHref(s,c):s));return u.useEffect((()=>{p&&_(a.localizeHref(s,c,v,null!=p?p:void 0))}),[v,s,c,p]),q&&(o=!1),n.default.createElement(i.default,e.extends({ref:f,href:x,prefetch:o},d))}var c=u.forwardRef(s);exports.default=c;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("./utils.js");exports.default=function(t,n){const a=r.localizePathname(n,t);for(var i=arguments.length,o=new Array(i>2?i-2:0),u=2;u<i;u++)o[u-2]=arguments[u];return e.redirect(a,...o)};
@@ -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,8 +0,0 @@
1
- import React, { ComponentProps } from 'react';
2
- import BaseLinkWithLocale from '../../shared/BaseLinkWithLocale';
3
- import { AllLocales } from '../../shared/types';
4
- type Props<Locales extends AllLocales> = Omit<ComponentProps<typeof BaseLinkWithLocale>, 'locale'> & {
5
- locale?: Locales[number];
6
- };
7
- export default function BaseLink<Locales extends AllLocales>({ locale, ...rest }: Props<Locales>): Promise<React.JSX.Element>;
8
- export {};
@@ -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,7 +0,0 @@
1
- import NextLink from 'next/link';
2
- import React, { ComponentProps } from 'react';
3
- type Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {
4
- locale: string;
5
- };
6
- declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
7
- export default _default;
@@ -1,3 +0,0 @@
1
- import { redirect as nextRedirect } from 'next/navigation';
2
- import { AllLocales, ParametersExceptFirst } from './types';
3
- export default function redirectWithLocale(pathname: string, locale: AllLocales[number], ...args: ParametersExceptFirst<typeof nextRedirect>): never;