next-intl 3.22.0-canary.0 → 3.22.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/middleware/middleware.js +13 -12
- package/dist/development/middleware/resolveLocale.js +19 -28
- package/dist/development/middleware/syncCookie.js +7 -7
- package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +3 -1
- package/dist/development/navigation/react-client/createNavigation.js +1 -1
- package/dist/development/navigation/react-client/createSharedPathnamesNavigation.js +3 -1
- package/dist/development/navigation/react-client/useBaseRouter.js +3 -3
- package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -0
- package/dist/development/navigation/react-server/createSharedPathnamesNavigation.js +2 -0
- package/dist/development/navigation/shared/BaseLink.js +2 -1
- package/dist/development/navigation/shared/LegacyBaseLink.js +3 -1
- package/dist/development/navigation/shared/createSharedNavigationFns.js +2 -1
- package/dist/development/navigation/shared/syncLocaleCookie.js +26 -5
- package/dist/development/routing/config.js +18 -1
- package/dist/development/shared/constants.js +0 -9
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/middleware/syncCookie.js +1 -1
- package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/createNavigation.js +1 -1
- package/dist/esm/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/esm/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/navigation/shared/LegacyBaseLink.js +1 -1
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/esm/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/esm/routing/config.js +1 -1
- package/dist/esm/shared/constants.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/middleware/syncCookie.js +1 -1
- package/dist/production/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/createNavigation.js +1 -1
- package/dist/production/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/production/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/shared/BaseLink.js +1 -1
- package/dist/production/navigation/shared/LegacyBaseLink.js +1 -1
- package/dist/production/navigation/shared/createSharedNavigationFns.js +1 -1
- package/dist/production/navigation/shared/syncLocaleCookie.js +1 -1
- package/dist/production/routing/config.js +1 -1
- package/dist/production/shared/constants.js +1 -1
- package/dist/types/src/middleware/middleware.d.ts +10 -2
- package/dist/types/src/middleware/resolveLocale.d.ts +1 -2
- package/dist/types/src/middleware/syncCookie.d.ts +2 -2
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +2 -1
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +2 -1
- package/dist/types/src/navigation/react-client/useBaseRouter.d.ts +2 -1
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +2 -1
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +1 -1
- package/dist/types/src/navigation/shared/BaseLink.d.ts +2 -0
- package/dist/types/src/navigation/shared/LegacyBaseLink.d.ts +2 -0
- package/dist/types/src/navigation/shared/createSharedNavigationFns.d.ts +4 -1
- package/dist/types/src/navigation/shared/syncLocaleCookie.d.ts +2 -1
- package/dist/types/src/routing/config.d.ts +29 -2
- package/dist/types/src/shared/constants.d.ts +0 -3
- package/package.json +36 -14
- package/dist/types/src/middleware/config.d.ts +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){return{...e,localePrefix:o(null==e?void 0:e.localePrefix)}}function o(e){return"object"==typeof e?e:{mode:e||"always"}}export{o as receiveLocalePrefixConfig,e as receiveRoutingConfig};
|
|
1
|
+
function e(e){var n,t;return{...e,localePrefix:o(null==e?void 0:e.localePrefix),localeCookie:l(e.localeCookie),localeDetection:null===(n=e.localeDetection)||void 0===n||n,alternateLinks:null===(t=e.alternateLinks)||void 0===t||t}}function l(e){return!(null!=e&&!e)&&{name:"NEXT_LOCALE",maxAge:31536e3,sameSite:"lax",..."object"==typeof e&&e}}function o(e){return"object"==typeof e?e:{mode:e||"always"}}export{l as receiveLocaleCookie,o as receiveLocalePrefixConfig,e as receiveRoutingConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const o="X-NEXT-INTL-LOCALE",L="locale";export{o as HEADER_LOCALE_NAME,L as LOCALE_SEGMENT_NAME};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../routing/config.js"),t=require("../shared/constants.js"),l=require("../shared/utils.js"),o=require("./getAlternateLinksHeaderValue.js"),n=require("./resolveLocale.js"),r=require("./syncCookie.js"),i=require("./utils.js");exports.default=function(s,c){var d,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../routing/config.js"),t=require("../shared/constants.js"),l=require("../shared/utils.js"),o=require("./getAlternateLinksHeaderValue.js"),n=require("./resolveLocale.js"),r=require("./syncCookie.js"),i=require("./utils.js");exports.default=function(s,c){var d,f,h;const m=a.receiveRoutingConfig({...s,alternateLinks:null!==(d=null==c?void 0:c.alternateLinks)&&void 0!==d?d:s.alternateLinks,localeDetection:null!==(f=null==c?void 0:c.localeDetection)&&void 0!==f?f:s.localeDetection,localeCookie:null!==(h=null==c?void 0:c.localeCookie)&&void 0!==h?h:s.localeCookie});return function(a){var s;let c;try{c=decodeURI(a.nextUrl.pathname)}catch(a){return e.NextResponse.next()}const d=i.sanitizePathname(c),{domain:f,locale:h}=n.default(m,a.headers,a.cookies,d),u=f?f.defaultLocale===h:h===m.defaultLocale,x=(null===(s=m.domains)||void 0===s?void 0:s.filter((e=>i.isLocaleSupportedOnDomain(h,e))))||[],P=null!=m.domains&&!f;function p(l){const o=new URL(l,a.url);a.nextUrl.basePath&&(o.pathname=i.applyBasePath(o.pathname,a.nextUrl.basePath));const n=new Headers(a.headers);return n.set(t.HEADER_LOCALE_NAME,h),e.NextResponse.rewrite(o,{request:{headers:n}})}function v(t,o){const n=new URL(l.normalizeTrailingSlash(t),a.url);if(x.length>0&&!o&&f){const e=i.getBestMatchingDomain(f,h,x);e&&(o=e.domain,e.defaultLocale===h&&"as-needed"===m.localePrefix.mode&&(n.pathname=i.getNormalizedPathname(n.pathname,m.locales,m.localePrefix)))}var r,s;o&&(n.host=o,a.headers.get("x-forwarded-host")&&(n.protocol=null!==(r=a.headers.get("x-forwarded-proto"))&&void 0!==r?r:a.nextUrl.protocol,n.port=null!==(s=a.headers.get("x-forwarded-port"))&&void 0!==s?s:""));return a.nextUrl.basePath&&(n.pathname=i.applyBasePath(n.pathname,a.nextUrl.basePath)),e.NextResponse.redirect(n.toString())}const g=i.getNormalizedPathname(d,m.locales,m.localePrefix),L=i.getPathnameMatch(d,m.locales,m.localePrefix),U=null!=L,k="never"===m.localePrefix.mode||u&&"as-needed"===m.localePrefix.mode;let q,j,C=g;const D=m.pathnames;if(D){let e;if([e,j]=i.getInternalTemplate(D,g,h),j){const t=D[j],o="string"==typeof t?t:t[h];if(l.matchesPathname(o,g))C=i.formatTemplatePathname(g,o,j);else{let n;n=e?"string"==typeof t?t:t[e]:j;const r=k?void 0:l.getLocalePrefix(h,m.localePrefix),s=i.formatTemplatePathname(g,n,o);q=v(i.formatPathname(s,r,a.nextUrl.search))}}}if(!q)if("/"!==C||U){const e=i.formatPathname(C,i.getLocaleAsPrefix(h),a.nextUrl.search);if(U){const t=i.formatPathname(g,L.prefix,a.nextUrl.search);if("never"===m.localePrefix.mode)q=v(i.formatPathname(g,void 0,a.nextUrl.search));else if(L.exact)if(u&&k)q=v(i.formatPathname(g,void 0,a.nextUrl.search));else if(m.domains){const a=i.getBestMatchingDomain(f,L.locale,x);q=(null==f?void 0:f.domain)===(null==a?void 0:a.domain)||P?p(e):v(t,null==a?void 0:a.domain)}else q=p(e);else q=v(t)}else q=k?p(e):v(i.formatPathname(g,l.getLocalePrefix(h,m.localePrefix),a.nextUrl.search))}else q=k?p(i.formatPathname(C,i.getLocaleAsPrefix(h),a.nextUrl.search)):v(i.formatPathname(g,l.getLocalePrefix(h,m.localePrefix),a.nextUrl.search));return m.localeDetection&&m.localeCookie&&r.default(a,q,h,m.localeCookie),"never"!==m.localePrefix.mode&&m.alternateLinks&&m.locales.length>1&&q.headers.set("Link",o.default({routing:m,localizedPathnames:null!=j&&D?null==D?void 0:D[j]:void 0,request:a,resolvedLocale:h})),q}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),o=require("negotiator"),l=require("./utils.js");function t(e){return e&&e.__esModule?e:{default:e}}var a=t(o);function n(o,l,t){let n;const c=new a.default({headers:{"accept-language":o.get("accept-language")||void 0}}).languages();try{const o=function(e){return e.slice().sort(((e,o)=>o.length-e.length))}(l);n=e.match(c,o,t)}catch(e){}return n}function c(e,o){if(e.localeCookie&&o.has(e.localeCookie.name)){var l;const t=null===(l=o.get(e.localeCookie.name))||void 0===l?void 0:l.value;if(t&&e.locales.includes(t))return t}}function i(e,o,t,a){let i;var r;a&&(i=null===(r=l.getPathnameMatch(a,e.locales,e.localePrefix))||void 0===r?void 0:r.locale);return!i&&e.localeDetection&&t&&(i=c(e,t)),!i&&e.localeDetection&&o&&(i=n(o,e.locales,e.defaultLocale)),i||(i=e.defaultLocale),i}function r(e,o,t,a){const r=function(e,o){const t=l.getHost(e);if(t&&o)return o.find((e=>e.domain===t))}(o,e.domains);if(!r)return{locale:i(e,o,t,a)};let u;if(a){var s;const o=null===(s=l.getPathnameMatch(a,e.locales,e.localePrefix))||void 0===s?void 0:s.locale;if(o){if(!l.isLocaleSupportedOnDomain(o,r))return{locale:o,domain:r};u=o}}if(!u&&e.localeDetection&&t){const o=c(e,t);o&&l.isLocaleSupportedOnDomain(o,r)&&(u=o)}if(!u&&e.localeDetection&&o){const l=n(o,r.locales||e.locales,r.defaultLocale);l&&(u=l)}return u||(u=r.defaultLocale),{locale:u,domain:r}}exports.default=function(e,o,l,t){return e.domains?r(e,o,l,t):{locale:i(e,o,l,t)}},exports.getAcceptLanguageLocale=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0})
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(e,t,o,s){var a;const{name:i,...l}=s;(null===(a=e.cookies.get(i))||void 0===a?void 0:a.value)!==o&&t.cookies.set(i,o,{path:e.nextUrl.basePath||void 0,...l})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),l=require("../../routing/config.js"),t=require("../shared/utils.js"),o=require("./ClientLink.js"),n=require("./redirects.js"),c=require("./useBasePathname.js"),i=require("./useBaseRouter.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=function(u){const f=l.receiveRoutingConfig(u),h=l.receiveLocaleCookie(null==u?void 0:u.localeCookie);function d(){const e=a.default();if(!f.locales.includes(e))throw new Error(void 0);return e}function m(r,a){let{href:l,locale:n,...c}=r;const i=d(),u=n||i;return s.default.createElement(o.default,e.extends({ref:a,href:t.compileLocalizedPathname({locale:u,pathname:l,params:"object"==typeof l?l.params:void 0,pathnames:f.pathnames}),locale:n,localeCookie:h,localePrefix:f.localePrefix},c))}const p=r.forwardRef(m);function v(e){let{href:r,locale:a}=e;return t.compileLocalizedPathname({...t.normalizeNameOrNameWithParams(r),locale:a,pathnames:f.pathnames})}return p.displayName="Link",{Link:p,redirect:function(e){const r=v({href:e,locale:d()});for(var a=arguments.length,l=new Array(a>1?a-1:0),t=1;t<a;t++)l[t-1]=arguments[t];return n.clientRedirect({pathname:r,localePrefix:f.localePrefix},...l)},permanentRedirect:function(e){const r=v({href:e,locale:d()});for(var a=arguments.length,l=new Array(a>1?a-1:0),t=1;t<a;t++)l[t-1]=arguments[t];return n.clientPermanentRedirect({pathname:r,localePrefix:f.localePrefix},...l)},usePathname:function(){const e=c.default(f.localePrefix),a=d();return r.useMemo((()=>e?t.getRoute(a,e,f.pathnames):e),[a,e])},useRouter:function(){const e=i.default(f.localePrefix,h),a=d();return r.useMemo((()=>({...e,push(r){for(var l,t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];const c=v({href:r,locale:(null===(l=o[0])||void 0===l?void 0:l.locale)||a});return e.push(c,...o)},replace(r){for(var l,t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];const c=v({href:r,locale:(null===(l=o[0])||void 0===l?void 0:l.locale)||a});return e.replace(c,...o)},prefetch(r){for(var l,t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];const c=v({href:r,locale:(null===(l=o[0])||void 0===l?void 0:l.locale)||a});return e.prefetch(c,...o)}})),[e,a])},getPathname:v}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("react"),r=require("../../react-client/useLocale.js"),n=require("../shared/createSharedNavigationFns.js"),a=require("../shared/syncLocaleCookie.js"),u=require("../shared/utils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),t=require("react"),r=require("../../react-client/useLocale.js"),n=require("../shared/createSharedNavigationFns.js"),a=require("../shared/syncLocaleCookie.js"),u=require("../shared/utils.js"),o=require("./useBasePathname.js");exports.default=function(s){function c(){return r.default()}const{Link:i,config:l,getPathname:h,...f}=n.default(c,s);return{...f,Link:i,usePathname:function(){const e=o.default(l.localePrefix),r=c();return t.useMemo((()=>e&&l.pathnames?u.getRoute(r,e,l.pathnames):e),[r,e])},useRouter:function(){const r=e.useRouter(),n=c(),u=e.usePathname();return t.useMemo((()=>{function e(e){return function(t,r){const{locale:o,...s}=r||{},c=[h({href:t,locale:o||n,domain:window.location.host})];Object.keys(s).length>0&&c.push(s),e(...c),a.default(l.localeCookie,u,n,o)}}return{...r,push:e(r.push),replace:e(r.replace),prefetch:e(r.prefetch)}}),[n,u,r])},getPathname:h}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../routing/config.js"),n=require("./ClientLink.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../routing/config.js"),n=require("./ClientLink.js"),i=require("./redirects.js"),u=require("./useBasePathname.js"),a=require("./useBaseRouter.js");function l(e){return e&&e.__esModule?e:{default:e}}var o=l(r);exports.default=function(l){const c=t.receiveLocalePrefixConfig(null==l?void 0:l.localePrefix),f=t.receiveLocaleCookie(null==l?void 0:l.localeCookie);function s(r,t){return o.default.createElement(n.default,e.extends({ref:t,localeCookie:f,localePrefix:c},r))}const d=r.forwardRef(s);return d.displayName="Link",{Link:d,redirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return i.clientRedirect({pathname:e,localePrefix:c},...t)},permanentRedirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return i.clientPermanentRedirect({pathname:e,localePrefix:c},...t)},usePathname:function(){return u.default(c)},useRouter:function(){return a.default(c,f)}}};
|
|
@@ -1 +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"),n=require("../shared/syncLocaleCookie.js"),s=require("../shared/utils.js");exports.default=function(a){const
|
|
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"),n=require("../shared/syncLocaleCookie.js"),s=require("../shared/utils.js");exports.default=function(a,c){const o=e.useRouter(),i=r.default(),l=e.usePathname();return t.useMemo((()=>{function e(e,t){let r=window.location.pathname;const n=s.getBasePath(l);n&&(r=r.replace(n,""));const c=t||i,o=u.getLocalePrefix(c,a);return u.localizeHref(e,c,i,r,o)}function t(t){return function(r,u){const{locale:s,...a}=u||{};n.default(c,l,i,s);const o=[e(r,s)];return Object.keys(a).length>0&&o.push(a),t(...o)}}return{...o,push:t(o.push),replace:t(o.replace),prefetch:t(o.prefetch)}}),[i,c,a,l,o])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../routing/config.js"),a=require("../../server/react-server/RequestLocaleLegacy.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../routing/config.js"),a=require("../../server/react-server/RequestLocaleLegacy.js"),o=require("../shared/utils.js"),n=require("./ServerLink.js"),l=require("./redirects.js");function c(e){return e&&e.__esModule?e:{default:e}}var i=c(r);exports.default=function(r){const c=t.receiveRoutingConfig(r);function u(e){let{href:r,locale:t}=e;return o.compileLocalizedPathname({...o.normalizeNameOrNameWithParams(r),locale:t,pathnames:c.pathnames})}function s(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:t,locale:l,...u}=r;const s=a.getRequestLocale(),f=l||s;return i.default.createElement(n.default,e.extends({href:o.compileLocalizedPathname({locale:f,pathname:t,params:"object"==typeof t?t.params:void 0,pathnames:c.pathnames}),locale:l,localeCookie:c.localeCookie,localePrefix:c.localePrefix},u))},redirect:function(e){const r=u({href:e,locale:a.getRequestLocale()});for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return l.serverRedirect({localePrefix:c.localePrefix,pathname:r},...o)},permanentRedirect:function(e){const r=u({href:e,locale:a.getRequestLocale()});for(var t=arguments.length,o=new Array(t>1?t-1:0),n=1;n<t;n++)o[n-1]=arguments[n];return l.serverPermanentRedirect({localePrefix:c.localePrefix,pathname:r},...o)},getPathname:u,usePathname:s("usePathname"),useRouter:s("useRouter")}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../routing/config.js"),n=require("./ServerLink.js"),o=require("./redirects.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../routing/config.js"),n=require("./ServerLink.js"),o=require("./redirects.js");function i(e){return e&&e.__esModule?e:{default:e}}var u=i(r);exports.default=function(r){const i=t.receiveLocalePrefixConfig(null==r?void 0:r.localePrefix),a=t.receiveLocaleCookie(null==r?void 0:r.localeCookie);function l(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){return u.default.createElement(n.default,e.extends({localeCookie:a,localePrefix:i},r))},redirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return o.serverRedirect({pathname:e,localePrefix:i},...t)},permanentRedirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return o.serverPermanentRedirect({pathname:e,localePrefix:i},...t)},usePathname:l("usePathname"),useRouter:l("useRouter")}};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("next/link"),r=require("next/navigation"),n=require("react"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),t=require("next/link"),r=require("next/navigation"),n=require("react"),a=require("../../react-client/useLocale.js"),u=require("./syncLocaleCookie.js");function o(e){return e&&e.__esModule?e:{default:e}}var l=o(t),i=o(n);function c(t,o){let{defaultLocale:c,href:f,locale:s,localeCookie:d,onClick:p,prefetch:h,unprefixed:v,...k}=t;const q=a.default(),x=s!==q,_=s||q,j=function(){const[e,t]=n.useState();return n.useEffect((()=>{t(window.location.host)}),[]),e}(),m=j&&v&&(v.domains[j]===_||!Object.keys(v.domains).includes(j)&&q===c&&!s)?v.pathname:f,C=r.usePathname();return x&&(h=!1),i.default.createElement(l.default,e.extends({ref:o,href:m,hrefLang:x?s:void 0,onClick:function(e){u.default(d,C,q,s),p&&p(e)},prefetch:h},k))}var f=n.forwardRef(c);exports.default=f;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("next/navigation"),
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("next/navigation"),l=require("react"),t=require("../../react-client/useLocale.js"),a=require("../../shared/utils.js"),i=require("./BaseLink.js");function u(e){return e&&e.__esModule?e:{default:e}}var o=u(l);function s(u,s){let{href:f,locale:n,localeCookie:c,localePrefixMode:d,prefix:p,...x}=u;const q=r.usePathname(),v=t.default(),_=n!==v,[j,h]=l.useState((()=>a.isLocalizableHref(f)&&("never"!==d||_)?a.prefixHref(f,p):f));return l.useEffect((()=>{q&&h(a.localizeHref(f,n,v,q,p))}),[v,f,n,q,p]),o.default.createElement(i.default,e.extends({ref:s,href:j,locale:n,localeCookie:c},x))}const f=l.forwardRef(s);f.displayName="ClientLink",exports.default=f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),a=require("next/navigation"),r=require("react"),t=require("../../routing/config.js"),n=require("../../shared/utils.js"),o=require("./BaseLink.js"),i=require("./utils.js");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r);exports.default=function(l,c){const s=t.receiveRoutingConfig(c||{}),f=s.pathnames,d="as-needed"===s.localePrefix.mode&&s.domains||void 0;function m(a,t){let i,c,{href:m,locale:p,...v}=a;"object"==typeof m?(i=m.pathname,c=m.params):i=m;const P=n.isLocalizableHref(m),g=l(),j=g instanceof Promise?r.use(g):g,q=P?h({locale:p||j,href:null==f?i:{pathname:i,params:c}},null!=p||d||void 0):i;return u.default.createElement(o.default,e.extends({ref:t,defaultLocale:s.defaultLocale,href:{..."object"==typeof m&&m,pathname:q},locale:p,unprefixed:d&&P?{domains:s.domains.reduce(((e,a)=>(e[a.domain]=a.defaultLocale,e)),{}),pathname:h({locale:j,href:null==f?i:{pathname:i,params:c}},!1)}:void 0},v))}const p=r.forwardRef(m);function h(e,a){const{href:r,locale:t}=e;let n;return null==f?"object"==typeof r?(n=r.pathname,r.query&&(n+=i.serializeSearchParams(r.query))):n=r:n=i.compileLocalizedPathname({locale:t,...i.normalizeNameOrNameWithParams(r),pathnames:s.pathnames}),i.applyPathnamePrefix(n,t,s,e.domain,a)}function v(e){return function(a){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return e(h(a,a.domain?void 0:d),...t)}}const P=v(a.redirect),g=v(a.permanentRedirect);return{config:s,Link:p,redirect:P,permanentRedirect:g,getPathname:h}};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),a=require("next/navigation"),r=require("react"),t=require("../../routing/config.js"),n=require("../../shared/utils.js"),o=require("./BaseLink.js"),i=require("./utils.js");function l(e){return e&&e.__esModule?e:{default:e}}var u=l(r);exports.default=function(l,c){const s=t.receiveRoutingConfig(c||{}),f=s.pathnames,d="as-needed"===s.localePrefix.mode&&s.domains||void 0;function m(a,t){let i,c,{href:m,locale:p,...v}=a;"object"==typeof m?(i=m.pathname,c=m.params):i=m;const P=n.isLocalizableHref(m),g=l(),j=g instanceof Promise?r.use(g):g,q=P?h({locale:p||j,href:null==f?i:{pathname:i,params:c}},null!=p||d||void 0):i;return u.default.createElement(o.default,e.extends({ref:t,defaultLocale:s.defaultLocale,href:{..."object"==typeof m&&m,pathname:q},locale:p,localeCookie:s.localeCookie,unprefixed:d&&P?{domains:s.domains.reduce(((e,a)=>(e[a.domain]=a.defaultLocale,e)),{}),pathname:h({locale:j,href:null==f?i:{pathname:i,params:c}},!1)}:void 0},v))}const p=r.forwardRef(m);function h(e,a){const{href:r,locale:t}=e;let n;return null==f?"object"==typeof r?(n=r.pathname,r.query&&(n+=i.serializeSearchParams(r.query))):n=r:n=i.compileLocalizedPathname({locale:t,...i.normalizeNameOrNameWithParams(r),pathnames:s.pathnames}),i.applyPathnamePrefix(n,t,s,e.domain,a)}function v(e){return function(a){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];return e(h(a,a.domain?void 0:d),...t)}}const P=v(a.redirect),g=v(a.permanentRedirect);return{config:s,Link:p,redirect:P,permanentRedirect:g,getPathname:h}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./utils.js");exports.default=function(t,o,a,c){if(!t||!(c!==a&&null!=c)||!o)return;const n=e.getBasePath(o),r=""!==n?n:"/",{name:s,...u}=t;u.path||(u.path=r);let i="".concat(s,"=").concat(c,";");for(const[e,t]of Object.entries(u)){i+="".concat("maxAge"===e?"max-age":e),"boolean"!=typeof t&&(i+="="+t),i+=";"}document.cookie=i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){return"object"==typeof e?e:{mode:e||"always"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.
|
|
1
|
+
"use strict";function e(e){return!(null!=e&&!e)&&{name:"NEXT_LOCALE",maxAge:31536e3,sameSite:"lax",..."object"==typeof e&&e}}function o(e){return"object"==typeof e?e:{mode:e||"always"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.receiveLocaleCookie=e,exports.receiveLocalePrefixConfig=o,exports.receiveRoutingConfig=function(l){var t,i;return{...l,localePrefix:o(null==l?void 0:l.localePrefix),localeCookie:e(l.localeCookie),localeDetection:null===(t=l.localeDetection)||void 0===t||t,alternateLinks:null===(i=l.alternateLinks)||void 0===i||i}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.HEADER_LOCALE_NAME="X-NEXT-INTL-LOCALE",exports.LOCALE_SEGMENT_NAME="locale";
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import { RoutingConfig } from '../routing/config';
|
|
3
3
|
import { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../routing/types';
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export default function createMiddleware<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode = 'always', AppPathnames extends Pathnames<AppLocales> = never, AppDomains extends DomainsConfig<AppLocales> = never>(routing: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>,
|
|
5
|
+
/** @deprecated Should be passed via the first parameter `routing` instead (ideally defined with `defineRouting`) */
|
|
6
|
+
options?: {
|
|
7
|
+
/** @deprecated Should be passed via the first parameter `routing` instead (ideally defined with `defineRouting`) */
|
|
8
|
+
localeCookie?: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>['localeCookie'];
|
|
9
|
+
/** @deprecated Should be passed via the first parameter `routing` instead (ideally defined with `defineRouting`) */
|
|
10
|
+
localeDetection?: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>['localeDetection'];
|
|
11
|
+
/** @deprecated Should be passed via the first parameter `routing` instead (ideally defined with `defineRouting`) */
|
|
12
|
+
alternateLinks?: RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>['alternateLinks'];
|
|
13
|
+
}): (request: NextRequest) => NextResponse<unknown>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { RequestCookies } from 'next/dist/server/web/spec-extension/cookies';
|
|
2
2
|
import { ResolvedRoutingConfig } from '../routing/config';
|
|
3
3
|
import { Locales, Pathnames, DomainsConfig, DomainConfig, LocalePrefixMode } from '../routing/types';
|
|
4
|
-
import { ResolvedMiddlewareOptions } from './config';
|
|
5
4
|
export declare function getAcceptLanguageLocale<AppLocales extends Locales>(requestHeaders: Headers, locales: AppLocales, defaultLocale: string): string | undefined;
|
|
6
|
-
export default function resolveLocale<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(routing: Omit<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'pathnames'>,
|
|
5
|
+
export default function resolveLocale<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(routing: Omit<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'pathnames'>, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): {
|
|
7
6
|
locale: AppLocales[number];
|
|
8
7
|
domain?: DomainConfig<AppLocales>;
|
|
9
8
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import {
|
|
3
|
-
export default function syncCookie(request: NextRequest, response: NextResponse, locale: string, localeCookie:
|
|
2
|
+
import { LocaleCookieConfig } from '../routing/config';
|
|
3
|
+
export default function syncCookie(request: NextRequest, response: NextResponse, locale: string, localeCookie: LocaleCookieConfig): void;
|
|
@@ -39,6 +39,7 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
39
39
|
locale: string;
|
|
40
40
|
prefix: string;
|
|
41
41
|
localePrefixMode: LocalePrefixMode;
|
|
42
|
+
localeCookie: import("../../routing/config").InitializedLocaleCookieConfig;
|
|
42
43
|
}, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale" | "prefix" | "localePrefixMode"> & {
|
|
43
44
|
locale?: string | undefined;
|
|
44
45
|
localePrefix: {
|
|
@@ -52,7 +53,7 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
52
53
|
};
|
|
53
54
|
} & {
|
|
54
55
|
ref?: React.LegacyRef<HTMLAnchorElement> | undefined;
|
|
55
|
-
}, "localePrefix" | "
|
|
56
|
+
}, "name" | "localePrefix" | "localeCookie" | "href"> & {
|
|
56
57
|
href: Pathname extends `${string}[[...${string}` ? Pathname | ({
|
|
57
58
|
pathname: Pathname;
|
|
58
59
|
params?: import("../shared/StrictParams").default<Pathname> | undefined;
|
|
@@ -37,12 +37,13 @@ export default function createSharedPathnamesNavigation<AppLocales extends Local
|
|
|
37
37
|
locale: string;
|
|
38
38
|
prefix: string;
|
|
39
39
|
localePrefixMode: LocalePrefixMode;
|
|
40
|
+
localeCookie: import("../../routing/config").InitializedLocaleCookieConfig;
|
|
40
41
|
}, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale" | "prefix" | "localePrefixMode"> & {
|
|
41
42
|
locale?: AppLocales[number] | undefined;
|
|
42
43
|
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>;
|
|
43
44
|
} & {
|
|
44
45
|
ref?: React.LegacyRef<HTMLAnchorElement> | undefined;
|
|
45
|
-
}, "localePrefix"> & {
|
|
46
|
+
}, "localePrefix" | "localeCookie"> & {
|
|
46
47
|
ref?: React.LegacyRef<HTMLAnchorElement> | undefined;
|
|
47
48
|
}) => ReactElement;
|
|
48
49
|
redirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InitializedLocaleCookieConfig } from '../../routing/config';
|
|
1
2
|
import { Locales, LocalePrefixConfigVerbose, LocalePrefixMode } from '../../routing/types';
|
|
2
3
|
type IntlNavigateOptions<AppLocales extends Locales> = {
|
|
3
4
|
locale?: AppLocales[number];
|
|
@@ -21,7 +22,7 @@ type IntlNavigateOptions<AppLocales extends Locales> = {
|
|
|
21
22
|
* router.push('/about', {locale: 'de'});
|
|
22
23
|
* ```
|
|
23
24
|
*/
|
|
24
|
-
export default function useBaseRouter<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode
|
|
25
|
+
export default function useBaseRouter<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>, localeCookie: InitializedLocaleCookieConfig): {
|
|
25
26
|
push: (href: string, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & IntlNavigateOptions<AppLocales>) | undefined) => void;
|
|
26
27
|
replace: (href: string, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & IntlNavigateOptions<AppLocales>) | undefined) => void;
|
|
27
28
|
prefetch: (href: string, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").PrefetchOptions & IntlNavigateOptions<AppLocales>) | undefined) => void;
|
|
@@ -35,6 +35,7 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
35
35
|
locale: string;
|
|
36
36
|
prefix: string;
|
|
37
37
|
localePrefixMode: LocalePrefixMode;
|
|
38
|
+
localeCookie: import("../../routing/config").InitializedLocaleCookieConfig;
|
|
38
39
|
}, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale" | "prefix" | "localePrefixMode"> & {
|
|
39
40
|
locale?: string | undefined;
|
|
40
41
|
localePrefix: {
|
|
@@ -46,7 +47,7 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
46
47
|
mode: "as-needed";
|
|
47
48
|
prefixes?: Partial<Record<string, string>> | undefined;
|
|
48
49
|
};
|
|
49
|
-
}, "localePrefix" | "
|
|
50
|
+
}, "name" | "localePrefix" | "localeCookie" | "href"> & {
|
|
50
51
|
href: Pathname extends `${string}[[...${string}` ? Pathname | ({
|
|
51
52
|
pathname: Pathname;
|
|
52
53
|
params?: import("../shared/StrictParams").default<Pathname> | undefined;
|
|
@@ -3,7 +3,7 @@ import { RoutingConfigSharedNavigation } from '../../routing/config';
|
|
|
3
3
|
import { DomainsConfig, LocalePrefixMode, Locales } from '../../routing/types';
|
|
4
4
|
import ServerLink from './ServerLink';
|
|
5
5
|
export default function createSharedPathnamesNavigation<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppDomains extends DomainsConfig<AppLocales> = never>(routing?: RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains>): {
|
|
6
|
-
Link: (props: Omit<ComponentProps<typeof ServerLink<AppLocales, AppLocalePrefixMode>>, "localePrefix">) => React.JSX.Element;
|
|
6
|
+
Link: (props: Omit<ComponentProps<typeof ServerLink<AppLocales, AppLocalePrefixMode>>, "localePrefix" | "localeCookie">) => React.JSX.Element;
|
|
7
7
|
redirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
8
8
|
permanentRedirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
9
9
|
usePathname: () => never;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import NextLink from 'next/link';
|
|
2
2
|
import React, { ComponentProps } from 'react';
|
|
3
|
+
import { InitializedLocaleCookieConfig } from '../../routing/config';
|
|
3
4
|
type Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {
|
|
4
5
|
locale?: string;
|
|
5
6
|
defaultLocale?: string;
|
|
7
|
+
localeCookie: InitializedLocaleCookieConfig;
|
|
6
8
|
/** Special case for `localePrefix: 'as-needed'` and `domains`. */
|
|
7
9
|
unprefixed?: {
|
|
8
10
|
domains: {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import NextLink from 'next/link';
|
|
2
2
|
import React, { ComponentProps } from 'react';
|
|
3
|
+
import { InitializedLocaleCookieConfig } from '../../routing/config';
|
|
3
4
|
import { LocalePrefixMode } from '../../routing/types';
|
|
4
5
|
type Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {
|
|
5
6
|
locale: string;
|
|
6
7
|
prefix: string;
|
|
7
8
|
localePrefixMode: LocalePrefixMode;
|
|
9
|
+
localeCookie: InitializedLocaleCookieConfig;
|
|
8
10
|
};
|
|
9
11
|
declare const LegacyBaseLinkWithRef: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
10
12
|
export default LegacyBaseLinkWithRef;
|
|
@@ -7,7 +7,7 @@ type PromiseOrValue<Type> = Type | Promise<Type>;
|
|
|
7
7
|
* Shared implementations for `react-server` and `react-client`
|
|
8
8
|
*/
|
|
9
9
|
export default function createSharedNavigationFns<const AppLocales extends Locales, const AppPathnames extends Pathnames<AppLocales> = never, const AppLocalePrefixMode extends LocalePrefixMode = 'always', const AppDomains extends DomainsConfig<AppLocales> = never>(getLocale: () => PromiseOrValue<AppLocales extends never ? string : AppLocales[number]>, routing?: [AppPathnames] extends [never] ? RoutingConfigSharedNavigation<AppLocales, AppLocalePrefixMode, AppDomains> | undefined : RoutingConfigLocalizedNavigation<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>): {
|
|
10
|
-
config: Omit<{}, "localePrefix"> & {
|
|
10
|
+
config: Omit<{}, "localePrefix" | "localeCookie" | "alternateLinks" | "localeDetection"> & {
|
|
11
11
|
localePrefix: {
|
|
12
12
|
mode: "never";
|
|
13
13
|
} | {
|
|
@@ -17,6 +17,9 @@ export default function createSharedNavigationFns<const AppLocales extends Local
|
|
|
17
17
|
mode: "as-needed";
|
|
18
18
|
prefixes?: Partial<Record<string, string>> | undefined;
|
|
19
19
|
};
|
|
20
|
+
localeCookie: import("../../routing/config").InitializedLocaleCookieConfig;
|
|
21
|
+
localeDetection: NonNullable<boolean | undefined>;
|
|
22
|
+
alternateLinks: NonNullable<boolean | undefined>;
|
|
20
23
|
};
|
|
21
24
|
Link: React.ForwardRefExoticComponent<Omit<{
|
|
22
25
|
locale?: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { InitializedLocaleCookieConfig } from '../../routing/config';
|
|
1
2
|
/**
|
|
2
3
|
* We have to keep the cookie value in sync as Next.js might
|
|
3
4
|
* skip a request to the server due to its router cache.
|
|
4
5
|
* See https://github.com/amannn/next-intl/issues/786.
|
|
5
6
|
*/
|
|
6
|
-
export default function syncLocaleCookie(pathname: string | null, locale: string, nextLocale?: string): void;
|
|
7
|
+
export default function syncLocaleCookie(localeCookie: InitializedLocaleCookieConfig, pathname: string | null, locale: string, nextLocale?: string): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { NextResponse } from 'next/server';
|
|
1
2
|
import { Locales, LocalePrefix, LocalePrefixConfigVerbose, DomainsConfig, Pathnames, LocalePrefixMode } from './types';
|
|
3
|
+
type CookieAttributes = Pick<NonNullable<Parameters<typeof NextResponse.prototype.cookies.set>['2']>, 'maxAge' | 'domain' | 'partitioned' | 'path' | 'priority' | 'sameSite' | 'secure' | 'name'>;
|
|
2
4
|
export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined> = {
|
|
3
5
|
/**
|
|
4
6
|
* All available locales.
|
|
@@ -20,6 +22,21 @@ export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extend
|
|
|
20
22
|
* @see https://next-intl-docs.vercel.app/docs/routing#domains
|
|
21
23
|
**/
|
|
22
24
|
domains?: AppDomains;
|
|
25
|
+
/**
|
|
26
|
+
* Can be used to disable the locale cookie or to customize it.
|
|
27
|
+
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#locale-cookie
|
|
28
|
+
*/
|
|
29
|
+
localeCookie?: boolean | CookieAttributes;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the `Link` response header to notify search engines about content in other languages (defaults to `true`). See https://developers.google.com/search/docs/specialty/international/localized-versions#http
|
|
32
|
+
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#alternate-links
|
|
33
|
+
**/
|
|
34
|
+
alternateLinks?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* By setting this to `false`, the cookie as well as the `accept-language` header will no longer be used for locale detection.
|
|
37
|
+
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#locale-detection
|
|
38
|
+
**/
|
|
39
|
+
localeDetection?: boolean;
|
|
23
40
|
} & ([AppPathnames] extends [never] ? {} : {
|
|
24
41
|
/**
|
|
25
42
|
* A map of localized pathnames per locale.
|
|
@@ -31,10 +48,13 @@ export type RoutingConfigSharedNavigation<AppLocales extends Locales, AppLocaleP
|
|
|
31
48
|
export type RoutingConfigLocalizedNavigation<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales>, AppDomains extends DomainsConfig<AppLocales> = never> = Omit<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'defaultLocale' | 'pathnames'> & Partial<Pick<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'defaultLocale'>> & {
|
|
32
49
|
pathnames: AppPathnames;
|
|
33
50
|
};
|
|
34
|
-
export type ResolvedRoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined> = Omit<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'localePrefix'> & {
|
|
51
|
+
export type ResolvedRoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined> = Omit<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'localePrefix' | 'localeCookie' | 'alternateLinks' | 'localeDetection'> & {
|
|
35
52
|
localePrefix: LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>;
|
|
53
|
+
localeCookie: InitializedLocaleCookieConfig;
|
|
54
|
+
alternateLinks: boolean;
|
|
55
|
+
localeDetection: boolean;
|
|
36
56
|
};
|
|
37
|
-
export declare function receiveRoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined, Config extends Partial<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>>>(input: Config): Omit<Config, "localePrefix"> & {
|
|
57
|
+
export declare function receiveRoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined, Config extends Partial<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>>>(input: Config): Omit<Config, "localePrefix" | "localeCookie" | "alternateLinks" | "localeDetection"> & {
|
|
38
58
|
localePrefix: {
|
|
39
59
|
mode: "never";
|
|
40
60
|
} | {
|
|
@@ -44,5 +64,12 @@ export declare function receiveRoutingConfig<AppLocales extends Locales, AppLoca
|
|
|
44
64
|
mode: "as-needed";
|
|
45
65
|
prefixes?: Partial<Record<AppLocales[number], string>> | undefined;
|
|
46
66
|
};
|
|
67
|
+
localeCookie: InitializedLocaleCookieConfig;
|
|
68
|
+
localeDetection: boolean | NonNullable<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>["localeDetection"]>;
|
|
69
|
+
alternateLinks: boolean | NonNullable<RoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>["alternateLinks"]>;
|
|
47
70
|
};
|
|
71
|
+
export declare function receiveLocaleCookie(localeCookie?: boolean | CookieAttributes): InitializedLocaleCookieConfig;
|
|
72
|
+
export type InitializedLocaleCookieConfig = false | LocaleCookieConfig;
|
|
73
|
+
export type LocaleCookieConfig = Omit<CookieAttributes, 'name' | 'maxAge' | 'sameSite'> & Required<Pick<CookieAttributes, 'name' | 'maxAge' | 'sameSite'>>;
|
|
48
74
|
export declare function receiveLocalePrefixConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode>(localePrefix?: LocalePrefix<AppLocales, AppLocalePrefixMode>): LocalePrefixConfigVerbose<AppLocales, AppLocalePrefixMode>;
|
|
75
|
+
export {};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export declare const COOKIE_LOCALE_NAME = "NEXT_LOCALE";
|
|
2
|
-
export declare const COOKIE_MAX_AGE = 31536000;
|
|
3
|
-
export declare const COOKIE_SAME_SITE = "lax";
|
|
4
1
|
export declare const COOKIE_BASE_PATH_NAME = "NEXT_INTL_BASE_PATH";
|
|
5
2
|
export declare const HEADER_LOCALE_NAME = "X-NEXT-INTL-LOCALE";
|
|
6
3
|
export declare const LOCALE_SEGMENT_NAME = "locale";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.22.0-canary.
|
|
3
|
+
"version": "3.22.0-canary.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -16,16 +16,6 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "https://github.com/amannn/next-intl"
|
|
18
18
|
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "rm -rf dist && rollup -c",
|
|
21
|
-
"test": "TZ=Europe/Berlin vitest",
|
|
22
|
-
"lint": "pnpm run lint:source && pnpm run lint:package",
|
|
23
|
-
"lint:source": "eslint src test && tsc --noEmit",
|
|
24
|
-
"lint:package": "publint && attw --pack",
|
|
25
|
-
"prepublishOnly": "turbo build && cp ../../README.md .",
|
|
26
|
-
"postpublish": "git checkout . && rm ./README.md",
|
|
27
|
-
"size": "size-limit"
|
|
28
|
-
},
|
|
29
19
|
"main": "./dist/index.react-client.js",
|
|
30
20
|
"module": "./dist/esm/index.react-client.js",
|
|
31
21
|
"typings": "./dist/types/src/index.react-client.d.ts",
|
|
@@ -87,11 +77,43 @@
|
|
|
87
77
|
"dependencies": {
|
|
88
78
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
89
79
|
"negotiator": "^0.6.3",
|
|
90
|
-
"use-intl": "
|
|
80
|
+
"use-intl": "3.21.2-canary.0"
|
|
91
81
|
},
|
|
92
82
|
"peerDependencies": {
|
|
93
83
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
94
84
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
95
85
|
},
|
|
96
|
-
"
|
|
97
|
-
|
|
86
|
+
"devDependencies": {
|
|
87
|
+
"@arethetypeswrong/cli": "^0.15.3",
|
|
88
|
+
"@edge-runtime/vm": "^3.2.0",
|
|
89
|
+
"@size-limit/preset-big-lib": "^11.1.4",
|
|
90
|
+
"@testing-library/react": "^16.0.0",
|
|
91
|
+
"@types/negotiator": "^0.6.3",
|
|
92
|
+
"@types/node": "^20.14.5",
|
|
93
|
+
"@types/react": "^18.3.3",
|
|
94
|
+
"@types/react-dom": "^18.3.0",
|
|
95
|
+
"eslint": "^8.56.0",
|
|
96
|
+
"eslint-config-molindo": "^7.0.0",
|
|
97
|
+
"eslint-plugin-deprecation": "^3.0.0",
|
|
98
|
+
"eslint-plugin-react-compiler": "0.0.0-experimental-8e3b87c-20240822",
|
|
99
|
+
"next": "^14.2.4",
|
|
100
|
+
"path-to-regexp": "^6.2.2",
|
|
101
|
+
"publint": "^0.2.8",
|
|
102
|
+
"react": "^18.3.1",
|
|
103
|
+
"react-dom": "^18.3.1",
|
|
104
|
+
"rollup": "^4.18.0",
|
|
105
|
+
"rollup-plugin-preserve-directives": "0.4.0",
|
|
106
|
+
"size-limit": "^11.1.4",
|
|
107
|
+
"typescript": "^5.5.3",
|
|
108
|
+
"vitest": "^2.0.2"
|
|
109
|
+
},
|
|
110
|
+
"prettier": "../../.prettierrc.json",
|
|
111
|
+
"scripts": {
|
|
112
|
+
"build": "rm -rf dist && rollup -c",
|
|
113
|
+
"test": "TZ=Europe/Berlin vitest",
|
|
114
|
+
"lint": "pnpm run lint:source && pnpm run lint:package",
|
|
115
|
+
"lint:source": "eslint src test && tsc --noEmit",
|
|
116
|
+
"lint:package": "publint && attw --pack",
|
|
117
|
+
"size": "size-limit"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { NextResponse } from 'next/server';
|
|
2
|
-
type ResponseCookieOptions = Pick<NonNullable<Parameters<typeof NextResponse.prototype.cookies.set>['2']>, 'maxAge' | 'domain' | 'expires' | 'partitioned' | 'path' | 'priority' | 'sameSite' | 'secure'>;
|
|
3
|
-
export type MiddlewareOptions = {
|
|
4
|
-
/**
|
|
5
|
-
* Sets the `Link` response header to notify search engines about content in other languages (defaults to `true`). See https://developers.google.com/search/docs/specialty/international/localized-versions#http
|
|
6
|
-
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#alternate-links
|
|
7
|
-
**/
|
|
8
|
-
alternateLinks?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Can be used to disable the locale cookie or to customize it.
|
|
11
|
-
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#locale-cookie
|
|
12
|
-
*/
|
|
13
|
-
localeCookie?: boolean | ResponseCookieOptions;
|
|
14
|
-
/**
|
|
15
|
-
* By setting this to `false`, the cookie as well as the `accept-language` header will no longer be used for locale detection.
|
|
16
|
-
* @see https://next-intl-docs.vercel.app/docs/routing/middleware#locale-detection
|
|
17
|
-
**/
|
|
18
|
-
localeDetection?: boolean;
|
|
19
|
-
};
|
|
20
|
-
export type ResolvedMiddlewareOptions = Required<MiddlewareOptions>;
|
|
21
|
-
export {};
|