next-intl 3.14.1 → 3.15.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.
- package/dist/development/config.js +1 -1
- package/dist/development/middleware/config.js +17 -0
- package/dist/development/middleware/getAlternateLinksHeaderValue.js +8 -7
- package/dist/development/middleware/middleware.js +69 -83
- package/dist/development/middleware/resolveLocale.js +5 -6
- package/dist/development/middleware/syncCookie.js +19 -0
- package/dist/development/middleware/utils.js +58 -30
- package/dist/development/navigation/react-client/ClientLink.js +7 -2
- package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +18 -16
- package/dist/development/navigation/react-client/createSharedPathnamesNavigation.js +17 -12
- package/dist/development/navigation/react-client/redirects.js +32 -0
- package/dist/development/navigation/react-client/useBasePathname.js +12 -4
- package/dist/development/navigation/react-client/useBaseRouter.js +8 -3
- package/dist/development/navigation/react-server/ServerLink.js +7 -1
- package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +15 -19
- package/dist/development/navigation/react-server/createSharedPathnamesNavigation.js +11 -10
- package/dist/development/navigation/react-server/redirects.js +24 -0
- package/dist/development/navigation/shared/BaseLink.js +6 -5
- package/dist/development/navigation/shared/config.js +30 -0
- package/dist/development/navigation/shared/redirects.js +22 -0
- package/dist/development/navigation/shared/utils.js +2 -4
- package/dist/development/routing/config.js +18 -0
- package/dist/development/routing.js +2 -0
- package/dist/development/server/react-server/RequestLocale.js +1 -1
- package/dist/development/shared/utils.js +26 -14
- package/dist/esm/config.js +1 -1
- package/dist/esm/middleware/config.js +1 -0
- package/dist/esm/middleware/getAlternateLinksHeaderValue.js +1 -1
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/middleware/syncCookie.js +1 -0
- package/dist/esm/middleware/utils.js +1 -1
- package/dist/esm/navigation/react-client/ClientLink.js +1 -1
- package/dist/esm/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-client/redirects.js +1 -0
- package/dist/esm/navigation/react-client/useBasePathname.js +1 -1
- package/dist/esm/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/esm/navigation/react-server/ServerLink.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/react-server/redirects.js +1 -0
- package/dist/esm/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/navigation/shared/config.js +1 -0
- package/dist/esm/navigation/shared/redirects.js +1 -0
- package/dist/esm/navigation/shared/utils.js +1 -1
- package/dist/esm/routing/config.js +1 -0
- package/dist/esm/routing.js +1 -0
- package/dist/esm/server/react-server/RequestLocale.js +1 -1
- package/dist/esm/shared/utils.js +1 -1
- package/dist/production/config.js +1 -1
- package/dist/production/middleware/config.js +1 -0
- package/dist/production/middleware/getAlternateLinksHeaderValue.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 -0
- package/dist/production/middleware/utils.js +1 -1
- package/dist/production/navigation/react-client/ClientLink.js +1 -1
- package/dist/production/navigation/react-client/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-client/redirects.js +1 -0
- package/dist/production/navigation/react-client/useBasePathname.js +1 -1
- package/dist/production/navigation/react-client/useBaseRouter.js +1 -1
- package/dist/production/navigation/react-server/ServerLink.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/react-server/redirects.js +1 -0
- package/dist/production/navigation/shared/BaseLink.js +1 -1
- package/dist/production/navigation/shared/config.js +1 -0
- package/dist/production/navigation/shared/redirects.js +1 -0
- package/dist/production/navigation/shared/utils.js +1 -1
- package/dist/production/routing/config.js +1 -0
- package/dist/production/routing.js +1 -0
- package/dist/production/server/react-server/RequestLocale.js +1 -1
- package/dist/production/shared/utils.js +1 -1
- package/dist/routing.js +7 -0
- package/dist/types/src/middleware/config.d.ts +18 -0
- package/dist/types/src/middleware/getAlternateLinksHeaderValue.d.ts +6 -6
- package/dist/types/src/middleware/middleware.d.ts +3 -3
- package/dist/types/src/middleware/resolveLocale.d.ts +6 -6
- package/dist/types/src/middleware/syncCookie.d.ts +2 -0
- package/dist/types/src/middleware/utils.d.ts +19 -12
- package/dist/types/src/navigation/react-client/ClientLink.d.ts +10 -7
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +21 -22
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +22 -10
- package/dist/types/src/navigation/react-client/index.d.ts +3 -1
- package/dist/types/src/navigation/react-client/redirects.d.ts +10 -0
- package/dist/types/src/navigation/react-client/useBasePathname.d.ts +2 -1
- package/dist/types/src/navigation/react-client/useBaseRouter.d.ts +7 -7
- package/dist/types/src/navigation/react-server/ServerLink.d.ts +5 -4
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +14 -15
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +4 -6
- package/dist/types/src/navigation/react-server/index.d.ts +1 -1
- package/dist/types/src/navigation/react-server/redirects.d.ts +10 -0
- package/dist/types/src/navigation/shared/BaseLink.d.ts +3 -2
- package/dist/types/src/navigation/shared/config.d.ts +24 -0
- package/dist/types/src/navigation/shared/redirects.d.ts +11 -0
- package/dist/types/src/navigation/shared/utils.d.ts +10 -10
- package/dist/types/src/routing/config.d.ts +14 -0
- package/dist/types/src/routing/index.d.ts +2 -0
- package/dist/types/src/routing/types.d.ts +23 -0
- package/dist/types/src/routing.d.ts +1 -0
- package/dist/types/src/shared/types.d.ts +0 -5
- package/dist/types/src/shared/utils.d.ts +10 -7
- package/package.json +16 -6
- package/routing.d.ts +1 -0
- package/dist/development/navigation/react-client/clientPermanentRedirect.js +0 -25
- package/dist/development/navigation/react-client/clientRedirect.js +0 -25
- package/dist/development/navigation/react-server/serverPermanentRedirect.js +0 -19
- package/dist/development/navigation/react-server/serverRedirect.js +0 -19
- package/dist/development/navigation/shared/basePermanentRedirect.js +0 -16
- package/dist/development/navigation/shared/baseRedirect.js +0 -16
- package/dist/esm/navigation/react-client/clientPermanentRedirect.js +0 -1
- package/dist/esm/navigation/react-client/clientRedirect.js +0 -1
- package/dist/esm/navigation/react-server/serverPermanentRedirect.js +0 -1
- package/dist/esm/navigation/react-server/serverRedirect.js +0 -1
- package/dist/esm/navigation/shared/basePermanentRedirect.js +0 -1
- package/dist/esm/navigation/shared/baseRedirect.js +0 -1
- package/dist/production/navigation/react-client/clientPermanentRedirect.js +0 -1
- package/dist/production/navigation/react-client/clientRedirect.js +0 -1
- package/dist/production/navigation/react-server/serverPermanentRedirect.js +0 -1
- package/dist/production/navigation/react-server/serverRedirect.js +0 -1
- package/dist/production/navigation/shared/basePermanentRedirect.js +0 -1
- package/dist/production/navigation/shared/baseRedirect.js +0 -1
- package/dist/types/src/middleware/NextIntlMiddlewareConfig.d.ts +0 -31
- package/dist/types/src/navigation/react-client/clientPermanentRedirect.d.ts +0 -6
- package/dist/types/src/navigation/react-client/clientRedirect.d.ts +0 -6
- package/dist/types/src/navigation/react-server/serverPermanentRedirect.d.ts +0 -6
- package/dist/types/src/navigation/react-server/serverRedirect.d.ts +0 -6
- package/dist/types/src/navigation/shared/basePermanentRedirect.d.ts +0 -7
- package/dist/types/src/navigation/shared/baseRedirect.d.ts +0 -7
- /package/dist/types/test/navigation/shared/{basePermanentRedirect.test.d.ts → redirects.test.d.ts} +0 -0
- /package/dist/types/test/{navigation/shared/baseRedirect.test.d.ts → routing/types.test.d.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{COOKIE_LOCALE_NAME as
|
|
1
|
+
import{match as e}from"@formatjs/intl-localematcher";import o from"negotiator";import{COOKIE_LOCALE_NAME as l}from"../shared/constants.js";import{getPathnameMatch as t,isLocaleSupportedOnDomain as a,getHost as n}from"./utils.js";function c(l,t,a){let n;const c=new o({headers:{"accept-language":l.get("accept-language")||void 0}}).languages();try{n=e(c,t,a)}catch(e){}return n}function i(e,o){if(e.has(l)){var t;const a=null===(t=e.get(l))||void 0===t?void 0:t.value;if(a&&o.includes(a))return a}}function r(e,o,l,a){let n,{defaultLocale:r,localeDetection:u,localePrefix:f,locales:s}=e;var d;a&&(n=null===(d=t(a,s,f))||void 0===d?void 0:d.locale);return!n&&u&&l&&(n=i(l,s)),!n&&u&&o&&(n=c(o,s,r)),n||(n=r),n}function u(e,o,l,u){const f=function(e,o){var l;let t=n(e);if(t=null===(l=t)||void 0===l?void 0:l.replace(/:\d+$/,""),t&&o)return o.find((e=>e.domain===t))}(o,e.domains);if(!f)return{locale:r(e,o,l,u)};let s;if(u){var d;const o=null===(d=t(u,e.locales,e.localePrefix))||void 0===d?void 0:d.locale;if(o){if(!a(o,f))return{locale:o,domain:f};s=o}}if(!s&&e.localeDetection&&l){const o=i(l,e.locales);o&&a(o,f)&&(s=o)}if(!s&&e.localeDetection&&o){const l=c(o,f.locales||e.locales,f.defaultLocale);l&&(s=l)}return s||(s=f.defaultLocale),{locale:s,domain:f}}function f(e,o,l,t){return e.domains?u(e,o,l,t):{locale:r(e,o,l,t)}}export{f as default,c as getAcceptLanguageLocale};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{COOKIE_LOCALE_NAME as e,COOKIE_SAME_SITE as o,COOKIE_MAX_AGE as t}from"../shared/constants.js";function a(a,s,i){var n;(null===(n=a.cookies.get(e))||void 0===n?void 0:n.value)!==i&&s.cookies.set(e,i,{path:a.nextUrl.basePath||void 0,sameSite:o,maxAge:t})}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{matchesPathname as n,templateToRegex as
|
|
1
|
+
import{matchesPathname as t,getLocalePrefix as n,templateToRegex as e,prefixPathname as r}from"../shared/utils.js";function o(t){return t.includes("[[...")}function c(t){return t.includes("[...")}function i(t){return t.includes("[")}function u(t,n){const e=t.split("/"),r=n.split("/"),u=Math.max(e.length,r.length);for(let t=0;t<u;t++){const n=e[t],u=r[t];if(!n&&u)return-1;if(n&&!u)return 1;if(!i(n)&&i(u))return-1;if(i(n)&&!i(u))return 1;if(!c(n)&&c(u))return-1;if(c(n)&&!c(u))return 1;if(!o(n)&&o(u))return-1;if(o(n)&&!o(u))return 1}return 0}function l(t){return t.sort(u)}function f(n,e,r){const o=l(Object.keys(n));for(const c of o){const o=n[c];if("string"==typeof o){if(t(o,e))return[void 0,c]}else{const n=Object.entries(o),i=n.findIndex((t=>{let[n]=t;return n===r}));i>0&&n.unshift(n.splice(i,1)[0]);for(const[r,o]of n)if(t(o,e))return[r,c]}}for(const r of Object.keys(n))if(t(r,e))return[void 0,r];return[void 0,void 0]}function s(t,n,e,r){const o=p(n,t);let c="";return r&&(c="/".concat(r)),c+=g(e,o),c=w(c),c}function a(t,n,e){t.endsWith("/")||(t+="/");const r=d(n,e),o=new RegExp("^(".concat(r.map((t=>{let[,n]=t;return n.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),c=t.match(o);let i=c?"/"+c[2]:t;return"/"!==i&&(i=w(i)),i}function d(t,e){return t.map((t=>[t,n(t,e)]))}function h(t,n,e){const r=d(n,e);for(const[n,e]of r){let r,o;if(t===e||t.startsWith(e+"/"))r=o=!0;else{const n=t.toLowerCase(),c=e.toLowerCase();(n===c||n.startsWith(c+"/"))&&(r=!1,o=!0)}if(o)return{locale:n,prefix:e,matchedPrefix:t.slice(0,e.length),exact:r}}}function p(t,n){const r=e(t).exec(n);if(!r)return;const o={};for(let n=1;n<r.length;n++){var c;const e=null===(c=t.match(/\[([^\]]+)\]/g))||void 0===c?void 0:c[n-1].replace(/[[\]]/g,"");e&&(o[e]=r[n])}return o}function g(t,n){if(!n)return t;let e=t=t.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(n).forEach((t=>{let[n,r]=t;e=e.replace("[".concat(n,"]"),r)})),e}function v(t,n,e){let o=t;return n&&(o=r(n,o)),e&&(o+=e),o}function x(t){var n,e;return null!==(n=null!==(e=t.get("x-forwarded-host"))&&void 0!==e?e:t.get("host"))&&void 0!==n?n:void 0}function m(t,n){return n.defaultLocale===t||!n.locales||n.locales.includes(t)}function j(t,n,e){let r;return t&&m(n,t)&&(r=t),r||(r=e.find((t=>t.defaultLocale===n))),r||(r=e.find((t=>null!=t.locales&&t.locales.includes(n)))),r||null!=(null==t?void 0:t.locales)||(r=t),r||(r=e.find((t=>!t.locales))),r}function b(t,n){return w(n+t)}function w(t){return"/"!==t&&t.endsWith("/")&&(t=t.slice(0,-1)),t}function L(t){return"/".concat(t)}export{b as applyBasePath,u as comparePathnamePairs,v as formatPathname,g as formatPathnameTemplate,s as formatTemplatePathname,j as getBestMatchingDomain,x as getHost,f as getInternalTemplate,L as getLocaleAsPrefix,d as getLocalePrefixes,a as getNormalizedPathname,h as getPathnameMatch,p as getRouteParams,l as getSortedPathnames,m as isLocaleSupportedOnDomain,w as normalizeTrailingSlash};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as l}from"react";import o from"../../react-client/useLocale.js";import{getLocalePrefix as t}from"../../shared/utils.js";import a from"../shared/BaseLink.js";function i(l,i){let{locale:s,localePrefix:m,...c}=l;const n=o(),f=s||n,p=t(f,m);return r.createElement(a,e({ref:i,locale:f,localePrefixMode:m.mode,prefix:p},c))}const s=l(i);s.displayName="ClientLink";var m=s;export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as o}from"react";import t from"../../react-client/useLocale.js";import{receiveLocalizedNavigationRoutingConfig as a}from"../shared/config.js";import{getRoute as n,compileLocalizedPathname as l,normalizeNameOrNameWithParams as c}from"../shared/utils.js";import i from"./ClientLink.js";import{clientRedirect as s,clientPermanentRedirect as f}from"./redirects.js";import u from"./useBasePathname.js";import m from"./useBaseRouter.js";function h(h){const p=a(h);function d(){const e=t();if(!p.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `i18n.ts`.'));return e}function v(o,t){let{href:a,locale:n,...c}=o;const s=d(),f=n||s;return r.createElement(i,e({ref:t,href:l({locale:f,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:p.pathnames}),locale:n,localePrefix:p.localePrefix},c))}const P=o(v);function x(e){let{href:r,locale:o}=e;return l({...c(r),locale:o,pathnames:p.pathnames})}return P.displayName="Link",{Link:P,redirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),a=1;a<o;a++)t[a-1]=arguments[a];return s({pathname:r,localePrefix:p.localePrefix},...t)},permanentRedirect:function(e){const r=x({href:e,locale:d()});for(var o=arguments.length,t=new Array(o>1?o-1:0),a=1;a<o;a++)t[a-1]=arguments[a];return f({pathname:r,localePrefix:p.localePrefix},...t)},usePathname:function(){const e=u(p.localePrefix),r=d();return e?n({pathname:e,locale:r,pathnames:p.pathnames}):e},useRouter:function(){const e=m(p.localePrefix),r=d();return{...e,push(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(o){for(var t,a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];const c=x({href:o,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:x}}export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import n
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import{receiveSharedNavigationRoutingConfig as n}from"../shared/config.js";import o from"./ClientLink.js";import{clientRedirect as a,clientPermanentRedirect as i}from"./redirects.js";import l from"./useBasePathname.js";import f from"./useBaseRouter.js";function c(c){const u=n(c);function m(t,n){return r.createElement(o,e({ref:n,localePrefix:u.localePrefix},t))}const s=t(m);return s.displayName="Link",{Link:s,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 a({pathname:e,localePrefix:u.localePrefix},...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({pathname:e,localePrefix:u.localePrefix},...t)},usePathname:function(){return l(u.localePrefix)},useRouter:function(){return f(u.localePrefix)}}}export{c as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"../../react-client/useLocale.js";import{baseRedirect as e,basePermanentRedirect as n}from"../shared/redirects.js";function t(e){return function(n){let t;try{t=r()}catch(r){throw new Error("`redirect()` and `permanentRedirect()` can only be called during render. To redirect in an event handler or similar, you can use `useRouter()` instead.")}for(var o=arguments.length,a=new Array(o>1?o-1:0),c=1;c<o;c++)a[c-1]=arguments[c];return e({...n,locale:t},...a)}}const o=t(e),a=t(n);export{a as clientPermanentRedirect,o as clientRedirect};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{usePathname as r}from"next/navigation";import{useMemo as t}from"react";import o from"../../react-client/useLocale.js";import{hasPathnamePrefixed as e,
|
|
2
|
+
import{usePathname as r}from"next/navigation";import{useMemo as t}from"react";import o from"../../react-client/useLocale.js";import{hasPathnamePrefixed as e,unprefixPathname as n,getLocalePrefix as i}from"../../shared/utils.js";function a(a){const m=r(),s=o();return t((()=>{if(!m)return m;const r=i(s,a);return e(r,m)?n(m,r):m}),[s,a,m])}export{a as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRouter as t,usePathname as e}from"next/navigation";import{useMemo as r}from"react";import o from"../../react-client/useLocale.js";import{localizeHref as
|
|
1
|
+
import{useRouter as t,usePathname as e}from"next/navigation";import{useMemo as r}from"react";import o from"../../react-client/useLocale.js";import{getLocalePrefix as n,localizeHref as c}from"../../shared/utils.js";import s from"../shared/syncLocaleCookie.js";import{getBasePath as a}from"../shared/utils.js";function i(i){const p=t(),u=o(),l=e();return r((()=>{function t(t,e){let r=window.location.pathname;const o=a(l);o&&(r=r.replace(o,""));const s=e||u,p=n(s,i);return c(t,s,u,r,p)}function e(e){return function(r,o){const{locale:n,...c}=o||{};s(l,u,n);const a=[t(r,n)];return Object.keys(c).length>0&&a.push(c),e(...a)}}return{...p,push:e(p.push),replace:e(p.replace),prefetch:e(p.prefetch)}}),[u,i,l,p])}export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"../shared/BaseLink.js";import a from"../../server/react-server/getLocale.js";async function l(l){let{locale:
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getLocalePrefix as o}from"../../shared/utils.js";import t from"../shared/BaseLink.js";import a from"../../server/react-server/getLocale.js";async function l(l){let{locale:s,localePrefix:i,...m}=l;const c=s||await a(),f=o(c,i);return r.createElement(t,e({locale:c,localePrefixMode:i.mode,prefix:f},m))}export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getRequestLocale as t}from"../../server/react-server/RequestLocale.js";import{
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getRequestLocale as t}from"../../server/react-server/RequestLocale.js";import{receiveLocalizedNavigationRoutingConfig as o}from"../shared/config.js";import{compileLocalizedPathname as n,normalizeNameOrNameWithParams as a}from"../shared/utils.js";import l from"./ServerLink.js";import{serverRedirect as c,serverPermanentRedirect as s}from"./redirects.js";function i(i){const m=o(i);function f(e){let{href:r,locale:t}=e;return n({...a(r),locale:t,pathnames:m.pathnames})}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(o){let{href:a,locale:c,...s}=o;const i=t(),f=c||i;return r.createElement(l,e({href:n({locale:f,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:m.pathnames}),locale:c,localePrefix:m.localePrefix},s))},redirect:function(e){const r=f({href:e,locale:t()});for(var o=arguments.length,n=new Array(o>1?o-1:0),a=1;a<o;a++)n[a-1]=arguments[a];return c({localePrefix:m.localePrefix,pathname:r},...n)},permanentRedirect:function(e){const r=f({href:e,locale:t()});for(var o=arguments.length,n=new Array(o>1?o-1:0),a=1;a<o;a++)n[a-1]=arguments[a];return s({localePrefix:m.localePrefix,pathname:r},...n)},getPathname:f,usePathname:u("usePathname"),useRouter:u("useRouter")}}export{i as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{receiveSharedNavigationRoutingConfig as t}from"../shared/config.js";import o from"./ServerLink.js";import{serverRedirect as n,serverPermanentRedirect as a}from"./redirects.js";function i(i){const u=t(i);function c(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){return r.createElement(o,e({localePrefix:u.localePrefix},t))},redirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),o=1;o<r;o++)t[o-1]=arguments[o];return n({pathname:e,localePrefix:u.localePrefix},...t)},permanentRedirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),o=1;o<r;o++)t[o-1]=arguments[o];return a({pathname:e,localePrefix:u.localePrefix},...t)},usePathname:c("usePathname"),useRouter:c("useRouter")}}export{i as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getRequestLocale as r}from"../../server/react-server/RequestLocale.js";import{baseRedirect as e,basePermanentRedirect as t}from"../shared/redirects.js";function o(e){return function(t){const o=r();for(var n=arguments.length,s=new Array(n>1?n-1:0),c=1;c<n;c++)s[c-1]=arguments[c];return e({...t,locale:o},...s)}}const n=o(e),s=o(t);export{s as serverPermanentRedirect,n as serverRedirect};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"next/link";import{usePathname as o}from"next/navigation";import t,{forwardRef as n,useState as i,useEffect as l}from"react";import c from"../../react-client/useLocale.js";import{
|
|
2
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"next/link";import{usePathname as o}from"next/navigation";import t,{forwardRef as n,useState as i,useEffect as l}from"react";import c from"../../react-client/useLocale.js";import{isLocalizableHref as a,prefixHref as p,localizeHref as s}from"../../shared/utils.js";import f from"./syncLocaleCookie.js";function m(n,m){let{href:h,locale:u,localePrefixMode:d,onClick:k,prefetch:x,prefix:v,...L}=n;const g=o(),j=c(),C=u!==j,[y,w]=i((()=>a(h)&&("never"!==d||C)?p(h,v):h));return l((()=>{g&&w(s(h,u,j,g,v))}),[j,h,u,g,v]),C&&(x&&console.error("The `prefetch` prop is currently not supported when using the `locale` prop on `Link` to switch the locale.`"),x=!1),t.createElement(r,e({ref:m,href:y,hrefLang:C?u:void 0,onClick:function(e){f(g,j,u),k&&k(e)},prefetch:x},L))}const h=n(m);h.displayName="ClientLink";var u=h;export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{receiveLocalePrefixConfig as o}from"../../routing/config.js";function l(l){return{...l,localePrefix:o(null==l?void 0:l.localePrefix)}}function r(l){return{...l,localePrefix:o(null==l?void 0:l.localePrefix)}}export{r as receiveLocalizedNavigationRoutingConfig,l as receiveSharedNavigationRoutingConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{redirect as e,permanentRedirect as n}from"next/navigation";import{getLocalePrefix as r,isLocalHref as t,prefixPathname as o}from"../../shared/utils.js";function a(e){return function(n){const a=r(n.locale,n.localePrefix),i="never"!==n.localePrefix.mode&&t(n.pathname)?o(a,n.pathname):n.pathname;for(var l=arguments.length,m=new Array(l>1?l-1:0),c=1;c<l;c++)m[c-1]=arguments[c];return e(i,...m)}}const i=a(e),l=a(n);export{l as basePermanentRedirect,i as baseRedirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{matchesPathname as t}from"../../shared/utils.js";function n(t){return"string"==typeof t?{pathname:t}:t}function e(t){function n(t){return String(t)}const e=new URLSearchParams;for(const[r,a]of Object.entries(t))Array.isArray(a)?a.forEach((t=>{e.append(r,n(t))})):e.set(r,n(a));return"?"+e.toString()}function r(t){let{pathname:n,locale:r,params:a,pathnames:o,query:i}=t;function c(t){let n=o[t];return n||(n=t),n}function s(t){const n="string"==typeof t?t:t[r];let o=n;if(a&&Object.entries(a).forEach((t=>{let[n,e]=t;o=Array.isArray(e)?o.replace(new RegExp("(\\[)?\\[...".concat(n,"\\](\\])?"),"g"),e.map((t=>String(t))).join("/")):o.replace("[".concat(n,"]"),String(e))})),o.includes("["))throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(n,"\nParams: ").concat(JSON.stringify(a)));return i&&(o+=e(i)),o}if("string"==typeof n){return s(c(n))}{const{pathname:t,...e}=n;return{...e,pathname:s(c(t))}}}function a(n){var e;let{locale:r,pathname:a,pathnames:o}=n;const i=decodeURI(a);let c=null===(e=Object.entries(o).find((n=>{let[,e]=n;const a="string"!=typeof e?e[r]:e;return t(a,i)})))||void 0===e?void 0:e[0];return c||(c=a),c}function o(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===t?n:n.replace(t,"")}export{r as compileLocalizedPathname,o as getBasePath,a as getRoute,n as normalizeNameOrNameWithParams,e as serializeSearchParams};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return"object"==typeof e?e:{mode:e||"always"}}export{e as receiveLocalePrefixConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{headers as e}from"next/headers";import{notFound as t}from"next/navigation";import{cache as n}from"react";import{HEADER_LOCALE_NAME as o}from"../../shared/constants.js";const r=n((function(){let n;try{n=e().get(o)}catch(e){throw e instanceof Error&&"DYNAMIC_SERVER_USAGE"===e.digest?new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router-
|
|
1
|
+
import{headers as e}from"next/headers";import{notFound as t}from"next/navigation";import{cache as n}from"react";import{HEADER_LOCALE_NAME as o}from"../../shared/constants.js";const r=n((function(){let n;try{n=e().get(o)}catch(e){throw e instanceof Error&&"DYNAMIC_SERVER_USAGE"===e.digest?new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:e}):e}return n||(console.error("\nUnable to find `next-intl` locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The `notFound()` function will be called as a result.\n"),t()),n}));const i=n((function(){return{locale:void 0}}));function a(e){i().locale=e}function l(){return i().locale||r()}export{l as getRequestLocale,a as setRequestLocale};
|
package/dist/esm/shared/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){const n="object"==typeof t?t.pathname:t;return null!=n&&!n.startsWith("/")}function n(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function e(e,
|
|
1
|
+
function t(t){const n="object"==typeof t?t.pathname:t;return null!=n&&!n.startsWith("/")}function n(t){if("object"==typeof t)return null==t.host&&null==t.hostname;return!/^[a-z]+:/i.test(t)}function e(e){return n(e)&&!t(e)}function r(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,u=arguments.length>3?arguments[3]:void 0,c=arguments.length>4?arguments[4]:void 0;if(!e(t))return t;const l=n!==r,a=i(c,u);return(l||a)&&null!=c?o(t,c):t}function o(t,n){let e;return"string"==typeof t?e=c(n,t):(e={...t},t.pathname&&(e.pathname=c(n,t.pathname))),e}function u(t,n){return t.replace(new RegExp("^".concat(n)),"")||"/"}function c(t,n){let e=t;return/^\/(\?.*)?$/.test(n)&&(n=n.slice(1)),e+=n,e}function i(t,n){return n===t||n.startsWith("".concat(t,"/"))}function l(t,n){return f(t).test(n)}function a(t,n){var e;return"never"!==n.mode&&(null===(e=n.prefixes)||void 0===e?void 0:e[t])||"/"+t}function f(t){const n=t.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(n,"$"))}export{a as getLocalePrefix,i as hasPathnamePrefixed,n as isLocalHref,e as isLocalizableHref,t as isRelativeHref,r as localizeHref,l as matchesPathname,o as prefixHref,c as prefixPathname,f as templateToRegex,u as unprefixPathname};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(){throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl-docs.vercel.app/docs/getting-started/app-router
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=function(){throw new Error("Couldn't find next-intl config file. Please follow the instructions at https://next-intl-docs.vercel.app/docs/getting-started/app-router")};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../routing/config.js");exports.receiveConfig=function(l){var i,o;return{...l,alternateLinks:null===(i=null==l?void 0:l.alternateLinks)||void 0===i||i,localeDetection:null===(o=null==l?void 0:l.localeDetection)||void 0===o||o,localePrefix:e.receiveLocalePrefixConfig(null==l?void 0:l.localePrefix)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./utils.js");exports.default=function(a){var t;let{config:o,localizedPathnames:n,request:l,resolvedLocale:r}=a;const c=l.nextUrl.clone(),s=e.getHost(l.headers);function p(a,t){return l.nextUrl.basePath&&((a=new URL(a)).pathname=e.applyBasePath(a.pathname,l.nextUrl.basePath)),"<".concat(a.toString(),'>; rel="alternate"; hreflang="').concat(t,'"')}function i(a,t){return n&&"object"==typeof n?e.formatTemplatePathname(a,n[r],n[t]):a}s&&(c.port="",c.host=s),c.protocol=null!==(t=l.headers.get("x-forwarded-proto"))&&void 0!==t?t:c.protocol,c.pathname=e.getNormalizedPathname(c.pathname,o.locales);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./utils.js");exports.default=function(a){var t;let{config:o,localizedPathnames:n,request:l,resolvedLocale:r}=a;const c=l.nextUrl.clone(),s=e.getHost(l.headers);function p(a,t){return l.nextUrl.basePath&&((a=new URL(a)).pathname=e.applyBasePath(a.pathname,l.nextUrl.basePath)),"<".concat(a.toString(),'>; rel="alternate"; hreflang="').concat(t,'"')}function i(a,t){return n&&"object"==typeof n?e.formatTemplatePathname(a,n[r],n[t]):a}s&&(c.port="",c.host=s),c.protocol=null!==(t=l.headers.get("x-forwarded-proto"))&&void 0!==t?t:c.protocol,c.pathname=e.getNormalizedPathname(c.pathname,o.locales,o.localePrefix);const m=e.getLocalePrefixes(o.locales,o.localePrefix).flatMap((a=>{let t,[l,r]=a;function s(e){return"/"===e?r:r+e}if(o.domains){return(o.domains.filter((a=>e.isLocaleSupportedOnDomain(l,a)))||[]).map((e=>(t=new URL(c),t.port="",t.host=e.domain,t.pathname=i(c.pathname,l),l===e.defaultLocale&&"always"!==o.localePrefix.mode||(t.pathname=s(t.pathname)),p(t,l))))}{let e;e=n&&"object"==typeof n?i(c.pathname,l):c.pathname,l===o.defaultLocale&&"always"!==o.localePrefix.mode||(e=s(e)),t=new URL(e,c)}return p(t,l)}));if(!o.domains&&("always"!==o.localePrefix.mode||"/"===c.pathname)){const e=new URL(i(c.pathname,o.defaultLocale),c);m.push(p(e,"x-default"))}return m.join(", ")};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/server"),a=require("../shared/constants.js"),t=require("../shared/utils.js"),r=require("./config.js"),l=require("./getAlternateLinksHeaderValue.js"),o=require("./resolveLocale.js"),n=require("./syncCookie.js"),s=require("./utils.js");exports.default=function(i){const c=r.receiveConfig(i);return function(r){var i;const d=decodeURI(r.nextUrl.pathname),{domain:f,locale:m}=o.default(c,r.headers,r.cookies,d),h=f?f.defaultLocale===m:m===c.defaultLocale,u=(null===(i=c.domains)||void 0===i?void 0:i.filter((e=>s.isLocaleSupportedOnDomain(m,e))))||[],x=null!=c.domains&&!f;function P(t){const l=new URL(t,r.url);r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath));const o=new Headers(r.headers);return o.set(a.HEADER_LOCALE_NAME,m),e.NextResponse.rewrite(l,{request:{headers:o}})}function p(a,t){const l=new URL(s.normalizeTrailingSlash(a),r.url);if(u.length>0&&!t){const e=s.getBestMatchingDomain(f,m,u);e&&(t=e.domain,e.defaultLocale===m&&"as-needed"===c.localePrefix.mode&&(l.pathname=s.getNormalizedPathname(l.pathname,c.locales,c.localePrefix)))}var o,n;t&&(l.host=t,r.headers.get("x-forwarded-host")&&(l.protocol=null!==(o=r.headers.get("x-forwarded-proto"))&&void 0!==o?o:r.nextUrl.protocol,l.port=null!==(n=r.headers.get("x-forwarded-port"))&&void 0!==n?n:""));return r.nextUrl.basePath&&(l.pathname=s.applyBasePath(l.pathname,r.nextUrl.basePath)),e.NextResponse.redirect(l.toString())}const g=s.getNormalizedPathname(d,c.locales,c.localePrefix),v=s.getPathnameMatch(d,c.locales,c.localePrefix),L=null!=v,U="never"===c.localePrefix.mode||h&&"as-needed"===c.localePrefix.mode;let q,j,w=g;if(c.pathnames){let e;if([e,j]=s.getInternalTemplate(c.pathnames,g,m),j){const a=c.pathnames[j],l="string"==typeof a?a:a[m];if(t.matchesPathname(l,g))w=s.formatTemplatePathname(g,l,j);else{let o;o=e?"string"==typeof a?a:a[e]:j;const n=U?void 0:t.getLocalePrefix(m,c.localePrefix),i=s.formatTemplatePathname(g,o,l);q=p(s.formatPathname(i,n,r.nextUrl.search))}}}if(!q)if("/"!==w||L){const e=s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search);if(L){const a=s.formatPathname(g,v.prefix,r.nextUrl.search);if("never"===c.localePrefix.mode)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(v.exact)if(h&&U)q=p(s.formatPathname(g,void 0,r.nextUrl.search));else if(c.domains){const t=s.getBestMatchingDomain(f,v.locale,u);q=(null==f?void 0:f.domain)===(null==t?void 0:t.domain)||x?P(e):p(a,null==t?void 0:t.domain)}else q=P(e);else q=p(a)}else q=U?P(e):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search))}else q=U?P(s.formatPathname(w,s.getLocaleAsPrefix(m),r.nextUrl.search)):p(s.formatPathname(g,t.getLocalePrefix(m,c.localePrefix),r.nextUrl.search));var y;(c.localeDetection&&n.default(r,q,m),"never"!==c.localePrefix.mode&&c.alternateLinks&&c.locales.length>1)&&q.headers.set("Link",l.default({config:c,localizedPathnames:null!=j?null===(y=c.pathnames)||void 0===y?void 0:y[j]:void 0,request:r,resolvedLocale:m}));return q}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@formatjs/intl-localematcher"),t=require("negotiator"),a=require("../shared/constants.js"),l=require("./utils.js");function o(e){return e&&e.__esModule?e:{default:e}}var n=o(t);function c(t,a,l){let o;const c=new n.default({headers:{"accept-language":t.get("accept-language")||void 0}}).languages();try{o=e.match(c,a,l)}catch(e){}return o}function i(e,t){if(e.has(a.COOKIE_LOCALE_NAME)){var l;const o=null===(l=e.get(a.COOKIE_LOCALE_NAME))||void 0===l?void 0:l.value;if(o&&t.includes(o))return o}}function r(e,t,a,o){let n,{defaultLocale:r,localeDetection:u,localePrefix:s,locales:d}=e;var f;o&&(n=null===(f=l.getPathnameMatch(o,d,s))||void 0===f?void 0:f.locale);return!n&&u&&a&&(n=i(a,d)),!n&&u&&t&&(n=c(t,d,r)),n||(n=r),n}function u(e,t,a,o){const n=function(e,t){var a;let o=l.getHost(e);if(o=null===(a=o)||void 0===a?void 0:a.replace(/:\d+$/,""),o&&t)return t.find((e=>e.domain===o))}(t,e.domains);if(!n)return{locale:r(e,t,a,o)};let u;if(o){var s;const t=null===(s=l.getPathnameMatch(o,e.locales,e.localePrefix))||void 0===s?void 0:s.locale;if(t){if(!l.isLocaleSupportedOnDomain(t,n))return{locale:t,domain:n};u=t}}if(!u&&e.localeDetection&&a){const t=i(a,e.locales);t&&l.isLocaleSupportedOnDomain(t,n)&&(u=t)}if(!u&&e.localeDetection&&t){const a=c(t,n.locales||e.locales,n.defaultLocale);a&&(u=a)}return u||(u=n.defaultLocale),{locale:u,domain:n}}exports.default=function(e,t,a,l){return e.domains?u(e,t,a,l):{locale:r(e,t,a,l)}},exports.getAcceptLanguageLocale=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/constants.js");exports.default=function(t,s,o){var a;(null===(a=t.cookies.get(e.COOKIE_LOCALE_NAME))||void 0===a?void 0:a.value)!==o&&s.cookies.set(e.COOKIE_LOCALE_NAME,o,{path:t.nextUrl.basePath||void 0,sameSite:e.COOKIE_SAME_SITE,maxAge:e.COOKIE_MAX_AGE})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../shared/utils.js");function t(e){return e.includes("[[...")}function n(e){return e.includes("[...")}function r(e){return e.includes("[")}function o(e,o){const a=e.split("/"),c=o.split("/"),i=Math.max(a.length,c.length);for(let e=0;e<i;e++){const o=a[e],i=c[e];if(!o&&i)return-1;if(o&&!i)return 1;if(!r(o)&&r(i))return-1;if(r(o)&&!r(i))return 1;if(!n(o)&&n(i))return-1;if(n(o)&&!n(i))return 1;if(!t(o)&&t(i))return-1;if(t(o)&&!t(i))return 1}return 0}function a(e){return e.sort(o)}function c(t,n){return t.map((t=>[t,e.getLocalePrefix(t,n)]))}function i(t,n){const r=e.templateToRegex(t).exec(n);if(!r)return;const o={};for(let e=1;e<r.length;e++){var a;const n=null===(a=t.match(/\[([^\]]+)\]/g))||void 0===a?void 0:a[e-1].replace(/[[\]]/g,"");n&&(o[n]=r[e])}return o}function s(e,t){if(!t)return e;let n=e=e.replace(/\[\[/g,"[").replace(/\]\]/g,"]");return Object.entries(t).forEach((e=>{let[t,r]=e;n=n.replace("[".concat(t,"]"),r)})),n}function l(e,t){return t.defaultLocale===e||!t.locales||t.locales.includes(e)}function u(e){return"/"!==e&&e.endsWith("/")&&(e=e.slice(0,-1)),e}exports.applyBasePath=function(e,t){return u(t+e)},exports.comparePathnamePairs=o,exports.formatPathname=function(t,n,r){let o=t;return n&&(o=e.prefixPathname(n,o)),r&&(o+=r),o},exports.formatPathnameTemplate=s,exports.formatTemplatePathname=function(e,t,n,r){const o=i(t,e);let a="";return r&&(a="/".concat(r)),a+=s(n,o),a=u(a),a},exports.getBestMatchingDomain=function(e,t,n){let r;return e&&l(t,e)&&(r=e),r||(r=n.find((e=>e.defaultLocale===t))),r||(r=n.find((e=>null!=e.locales&&e.locales.includes(t)))),r||null!=(null==e?void 0:e.locales)||(r=e),r||(r=n.find((e=>!e.locales))),r},exports.getHost=function(e){var t,n;return null!==(t=null!==(n=e.get("x-forwarded-host"))&&void 0!==n?n:e.get("host"))&&void 0!==t?t:void 0},exports.getInternalTemplate=function(t,n,r){const o=a(Object.keys(t));for(const a of o){const o=t[a];if("string"==typeof o){const t=o;if(e.matchesPathname(t,n))return[void 0,a]}else{const t=Object.entries(o),c=t.findIndex((e=>{let[t]=e;return t===r}));c>0&&t.unshift(t.splice(c,1)[0]);for(const[r,o]of t)if(e.matchesPathname(o,n))return[r,a]}}for(const r of Object.keys(t))if(e.matchesPathname(r,n))return[void 0,r];return[void 0,void 0]},exports.getLocaleAsPrefix=function(e){return"/".concat(e)},exports.getLocalePrefixes=c,exports.getNormalizedPathname=function(e,t,n){e.endsWith("/")||(e+="/");const r=c(t,n),o=new RegExp("^(".concat(r.map((e=>{let[,t]=e;return t.replaceAll("/","\\/")})).join("|"),")/(.*)"),"i"),a=e.match(o);let i=a?"/"+a[2]:e;return"/"!==i&&(i=u(i)),i},exports.getPathnameMatch=function(e,t,n){const r=c(t,n);for(const[t,n]of r){let r,o;if(e===n||e.startsWith(n+"/"))r=o=!0;else{const t=e.toLowerCase(),a=n.toLowerCase();(t===a||t.startsWith(a+"/"))&&(r=!1,o=!0)}if(o)return{locale:t,prefix:n,matchedPrefix:e.slice(0,n.length),exact:r}}},exports.getRouteParams=i,exports.getSortedPathnames=a,exports.isLocaleSupportedOnDomain=l,exports.normalizeTrailingSlash=u;
|
|
@@ -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"),l=require("../../react-client/useLocale.js"),t=require("../../shared/utils.js"),a=require("../shared/BaseLink.js");function u(e){return e&&e.__esModule?e:{default:e}}var i=u(r);function s(r,u){let{locale:s,localePrefix:o,...c}=r;const n=l.default(),d=s||n,f=t.getLocalePrefix(d,o);return i.default.createElement(a.default,e.extends({ref:u,locale:d,localePrefixMode:o.mode,prefix:f},c))}const o=r.forwardRef(s);o.displayName="ClientLink";var c=o;exports.default=c;
|
|
@@ -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/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),t=require("../shared/config.js"),l=require("../shared/utils.js"),n=require("./ClientLink.js"),o=require("./redirects.js"),c=require("./useBasePathname.js"),i=require("./useBaseRouter.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=function(u){const f=t.receiveLocalizedNavigationRoutingConfig(u);function h(){const e=a.default();if(!f.locales.includes(e))throw new Error(void 0);return e}function d(r,a){let{href:t,locale:o,...c}=r;const i=h(),u=o||i;return s.default.createElement(n.default,e.extends({ref:a,href:l.compileLocalizedPathname({locale:u,pathname:t,params:"object"==typeof t?t.params:void 0,pathnames:f.pathnames}),locale:o,localePrefix:f.localePrefix},c))}const p=r.forwardRef(d);function m(e){let{href:r,locale:a}=e;return l.compileLocalizedPathname({...l.normalizeNameOrNameWithParams(r),locale:a,pathnames:f.pathnames})}return p.displayName="Link",{Link:p,redirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientRedirect({pathname:r,localePrefix:f.localePrefix},...t)},permanentRedirect:function(e){const r=m({href:e,locale:h()});for(var a=arguments.length,t=new Array(a>1?a-1:0),l=1;l<a;l++)t[l-1]=arguments[l];return o.clientPermanentRedirect({pathname:r,localePrefix:f.localePrefix},...t)},usePathname:function(){const e=c.default(f.localePrefix),r=h();return e?l.getRoute({pathname:e,locale:r,pathnames:f.pathnames}):e},useRouter:function(){const e=i.default(f.localePrefix),r=h();return{...e,push(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.push(c,...n)},replace(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.replace(c,...n)},prefetch(a){for(var t,l=arguments.length,n=new Array(l>1?l-1:0),o=1;o<l;o++)n[o-1]=arguments[o];const c=m({href:a,locale:(null===(t=n[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(c,...n)}}},getPathname:m}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../shared/config.js"),n=require("./ClientLink.js"),a=require("./redirects.js"),i=require("./useBasePathname.js"),u=require("./useBaseRouter.js");function l(e){return e&&e.__esModule?e:{default:e}}var o=l(r);exports.default=function(l){const c=t.receiveSharedNavigationRoutingConfig(l);function f(r,t){return o.default.createElement(n.default,e.extends({ref:t,localePrefix:c.localePrefix},r))}const s=r.forwardRef(f);return s.displayName="Link",{Link:s,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 a.clientRedirect({pathname:e,localePrefix:c.localePrefix},...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 a.clientPermanentRedirect({pathname:e,localePrefix:c.localePrefix},...t)},usePathname:function(){return i.default(c.localePrefix)},useRouter:function(){return u.default(c.localePrefix)}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../react-client/useLocale.js"),r=require("../shared/redirects.js");function t(r){return function(t){let c;try{c=e.default()}catch(e){throw e}for(var n=arguments.length,a=new Array(n>1?n-1:0),i=1;i<n;i++)a[i-1]=arguments[i];return r({...t,locale:c},...a)}}const c=t(r.baseRedirect),n=t(r.basePermanentRedirect);exports.clientPermanentRedirect=n,exports.clientRedirect=c;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("react"),t=require("../../react-client/useLocale.js"),a=require("../../shared/utils.js");exports.default=function(){const
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("react"),t=require("../../react-client/useLocale.js"),a=require("../../shared/utils.js");exports.default=function(u){const n=e.usePathname(),i=t.default();return r.useMemo((()=>{if(!n)return n;const e=a.getLocalePrefix(i,u);return a.hasPathnamePrefixed(e,n)?a.unprefixPathname(n,e):n}),[i,u,n])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),
|
|
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 c=e.useRouter(),o=r.default(),i=e.usePathname();return t.useMemo((()=>{function e(e,t){let r=window.location.pathname;const n=s.getBasePath(i);n&&(r=r.replace(n,""));const c=t||o,l=u.getLocalePrefix(c,a);return u.localizeHref(e,c,o,r,l)}function t(t){return function(r,u){const{locale:s,...a}=u||{};n.default(i,o,s);const c=[e(r,s)];return Object.keys(a).length>0&&c.push(a),t(...c)}}return{...c,push:t(c.push),replace:t(c.replace),prefetch:t(c.prefetch)}}),[o,a,i,c])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../shared/BaseLink.js"),a=require("../../server/react-server/getLocale.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),l=require("../../shared/utils.js"),t=require("../shared/BaseLink.js"),a=require("../../server/react-server/getLocale.js");function u(e){return e&&e.__esModule?e:{default:e}}var s=u(r);exports.default=async function(r){let{locale:u,localePrefix:i,...o}=r;const c=u||await a.default(),d=l.getLocalePrefix(c,i);return s.default.createElement(t.default,e.extends({locale:c,localePrefixMode:i.mode,prefix:d},o))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../server/react-server/RequestLocale.js"),a=require("../shared/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../../server/react-server/RequestLocale.js"),a=require("../shared/config.js"),n=require("../shared/utils.js"),o=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=a.receiveLocalizedNavigationRoutingConfig(r);function u(e){let{href:r,locale:t}=e;return n.compileLocalizedPathname({...n.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:a,locale:l,...u}=r;const s=t.getRequestLocale(),f=l||s;return i.default.createElement(o.default,e.extends({href:n.compileLocalizedPathname({locale:f,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:c.pathnames}),locale:l,localePrefix:c.localePrefix},u))},redirect:function(e){const r=u({href:e,locale:t.getRequestLocale()});for(var a=arguments.length,n=new Array(a>1?a-1:0),o=1;o<a;o++)n[o-1]=arguments[o];return l.serverRedirect({localePrefix:c.localePrefix,pathname:r},...n)},permanentRedirect:function(e){const r=u({href:e,locale:t.getRequestLocale()});for(var a=arguments.length,n=new Array(a>1?a-1:0),o=1;o<a;o++)n[o-1]=arguments[o];return l.serverPermanentRedirect({localePrefix:c.localePrefix,pathname:r},...n)},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("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("../shared/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.receiveSharedNavigationRoutingConfig(r);function a(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({localePrefix:i.localePrefix},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.localePrefix},...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.localePrefix},...t)},usePathname:a("usePathname"),useRouter:a("useRouter")}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../server/react-server/RequestLocale.js"),r=require("../shared/redirects.js");function t(r){return function(t){const s=e.getRequestLocale();for(var c=arguments.length,n=new Array(c>1?c-1:0),a=1;a<c;a++)n[a-1]=arguments[a];return r({...t,locale:s},...n)}}const s=t(r.baseRedirect),c=t(r.basePermanentRedirect);exports.serverPermanentRedirect=c,exports.serverRedirect=s;
|
|
@@ -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/link"),t=require("next/navigation"),l=require("react"),a=require("../../react-client/useLocale.js"),i=require("../../shared/utils.js"),u=require("./syncLocaleCookie.js");function n(e){return e&&e.__esModule?e:{default:e}}var f=n(r),o=n(l);function c(r,n){let{href:c,locale:s,
|
|
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"),i=require("../../shared/utils.js"),u=require("./syncLocaleCookie.js");function n(e){return e&&e.__esModule?e:{default:e}}var f=n(r),o=n(l);function c(r,n){let{href:c,locale:s,localePrefixMode:d,onClick:p,prefetch:v,prefix:x,...h}=r;const q=t.usePathname(),_=a.default(),j=s!==_,[k,L]=l.useState((()=>i.isLocalizableHref(c)&&("never"!==d||j)?i.prefixHref(c,x):c));return l.useEffect((()=>{q&&L(i.localizeHref(c,s,_,q,x))}),[_,c,s,q,x]),j&&(v=!1),o.default.createElement(f.default,e.extends({ref:n,href:k,hrefLang:j?s:void 0,onClick:function(e){u.default(q,_,s),p&&p(e)},prefetch:v},h))}const s=l.forwardRef(c);s.displayName="ClientLink";var d=s;exports.default=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../routing/config.js");exports.receiveLocalizedNavigationRoutingConfig=function(i){return{...i,localePrefix:e.receiveLocalePrefixConfig(null==i?void 0:i.localePrefix)}},exports.receiveSharedNavigationRoutingConfig=function(i){return{...i,localePrefix:e.receiveLocalePrefixConfig(null==i?void 0:i.localePrefix)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("../../shared/utils.js");function t(e){return function(t){const a=r.getLocalePrefix(t.locale,t.localePrefix),n="never"!==t.localePrefix.mode&&r.isLocalHref(t.pathname)?r.prefixPathname(a,t.pathname):t.pathname;for(var i=arguments.length,o=new Array(i>1?i-1:0),c=1;c<i;c++)o[c-1]=arguments[c];return e(n,...o)}}const a=t(e.redirect),n=t(e.permanentRedirect);exports.basePermanentRedirect=n,exports.baseRedirect=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[n,a]of Object.entries(e))Array.isArray(a)?a.forEach((e=>{r.append(n,t(e))})):r.set(n,t(a));return"?"+r.toString()}exports.compileLocalizedPathname=function(e){let{pathname:r,locale:n,params:a,pathnames:o,query:i}=e;function c(e){let t=o[e];return t||(t=e),t}function s(e){let r="string"==typeof e?e:e[n];return a&&Object.entries(a).forEach((e=>{let[t,n]=e;r=Array.isArray(n)?r.replace(new RegExp("(\\[)?\\[...".concat(t,"\\](\\])?"),"g"),n.map((e=>String(e))).join("/")):r.replace("[".concat(t,"]"),String(n))})),i&&(r+=t(i)),r}if("string"==typeof r){return s(c(r))}{const{pathname:e,...t}=r;return{...t,pathname:s(c(e))}}},exports.getBasePath=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===e?t:t.replace(e,"")},exports.getRoute=function(t){var r;let{locale:n,pathname:a,pathnames:o}=t;const i=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../shared/utils.js");function t(e){function t(e){return String(e)}const r=new URLSearchParams;for(const[n,a]of Object.entries(e))Array.isArray(a)?a.forEach((e=>{r.append(n,t(e))})):r.set(n,t(a));return"?"+r.toString()}exports.compileLocalizedPathname=function(e){let{pathname:r,locale:n,params:a,pathnames:o,query:i}=e;function c(e){let t=o[e];return t||(t=e),t}function s(e){let r="string"==typeof e?e:e[n];return a&&Object.entries(a).forEach((e=>{let[t,n]=e;r=Array.isArray(n)?r.replace(new RegExp("(\\[)?\\[...".concat(t,"\\](\\])?"),"g"),n.map((e=>String(e))).join("/")):r.replace("[".concat(t,"]"),String(n))})),i&&(r+=t(i)),r}if("string"==typeof r){return s(c(r))}{const{pathname:e,...t}=r;return{...t,pathname:s(c(e))}}},exports.getBasePath=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:window.location.pathname;return"/"===e?t:t.replace(e,"")},exports.getRoute=function(t){var r;let{locale:n,pathname:a,pathnames:o}=t;const i=decodeURI(a);let c=null===(r=Object.entries(o).find((t=>{let[,r]=t;const a="string"!=typeof r?r[n]:r;return e.matchesPathname(a,i)})))||void 0===r?void 0:r[0];return c||(c=a),c},exports.normalizeNameOrNameWithParams=function(e){return"string"==typeof e?{pathname:e}:e},exports.serializeSearchParams=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.receiveLocalePrefixConfig=function(e){return"object"==typeof e?e:{mode:e||"always"}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/headers"),t=require("next/navigation"),n=require("react"),r=require("../../shared/constants.js");const o=n.cache((function(){let n;try{n=e.headers().get(r.HEADER_LOCALE_NAME)}catch(e){throw e instanceof Error&&"DYNAMIC_SERVER_USAGE"===e.digest?new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/headers"),t=require("next/navigation"),n=require("react"),r=require("../../shared/constants.js");const o=n.cache((function(){let n;try{n=e.headers().get(r.HEADER_LOCALE_NAME)}catch(e){throw e instanceof Error&&"DYNAMIC_SERVER_USAGE"===e.digest?new Error("Usage of next-intl APIs in Server Components currently opts into dynamic rendering. This limitation will eventually be lifted, but as a stopgap solution, you can use the `unstable_setRequestLocale` API to enable static rendering, see https://next-intl-docs.vercel.app/docs/getting-started/app-router/with-i18n-routing#static-rendering",{cause:e}):e}return n||t.notFound(),n}));const s=n.cache((function(){return{locale:void 0}}));exports.getRequestLocale=function(){return s().locale||o()},exports.setRequestLocale=function(e){s().locale=e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){const t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}function t(e){if("object"==typeof e)return null==e.host&&null==e.hostname;return!/^[a-z]+:/i.test(e)}function n(e,t){let n;return"string"==typeof e?n=
|
|
1
|
+
"use strict";function e(e){const t="object"==typeof e?e.pathname:e;return null!=t&&!t.startsWith("/")}function t(e){if("object"==typeof e)return null==e.host&&null==e.hostname;return!/^[a-z]+:/i.test(e)}function n(n){return t(n)&&!e(n)}function r(e,t){let n;return"string"==typeof e?n=o(t,e):(n={...e},e.pathname&&(n.pathname=o(t,e.pathname))),n}function o(e,t){let n=e;return/^\/(\?.*)?$/.test(t)&&(t=t.slice(1)),n+=t,n}function a(e,t){return t===e||t.startsWith("".concat(e,"/"))}function i(e){const t=e.replace(/\[\[(\.\.\.[^\]]+)\]\]/g,"?(.*)").replace(/\[(\.\.\.[^\]]+)\]/g,"(.+)").replace(/\[([^\]]+)\]/g,"([^/]+)");return new RegExp("^".concat(t,"$"))}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getLocalePrefix=function(e,t){var n;return"never"!==t.mode&&(null===(n=t.prefixes)||void 0===n?void 0:n[e])||"/"+e},exports.hasPathnamePrefixed=a,exports.isLocalHref=t,exports.isLocalizableHref=n,exports.isRelativeHref=e,exports.localizeHref=function(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!n(e))return e;const c=t!==o,u=a(s,i);return(c||u)&&null!=s?r(e,s):e},exports.matchesPathname=function(e,t){return i(e).test(t)},exports.prefixHref=r,exports.prefixPathname=o,exports.templateToRegex=i,exports.unprefixPathname=function(e,t){return e.replace(new RegExp("^".concat(t)),"")||"/"};
|
package/dist/routing.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RoutingBaseConfigInput } from '../routing/config';
|
|
2
|
+
import { Locales, LocalePrefixConfigVerbose, Pathnames } from '../routing/types';
|
|
3
|
+
export type MiddlewareRoutingConfigInput<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>> = RoutingBaseConfigInput<AppLocales> & {
|
|
4
|
+
locales: AppLocales;
|
|
5
|
+
defaultLocale: AppLocales[number];
|
|
6
|
+
/** 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 */
|
|
7
|
+
alternateLinks?: boolean;
|
|
8
|
+
/** By setting this to `false`, the cookie as well as the `accept-language` header will no longer be used for locale detection. */
|
|
9
|
+
localeDetection?: boolean;
|
|
10
|
+
/** Maps internal pathnames to external ones which can be localized per locale. */
|
|
11
|
+
pathnames?: AppPathnames;
|
|
12
|
+
};
|
|
13
|
+
export type MiddlewareRoutingConfig<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>> = Omit<MiddlewareRoutingConfigInput<AppLocales, AppPathnames>, 'alternateLinks' | 'localeDetection' | 'localePrefix'> & {
|
|
14
|
+
alternateLinks: boolean;
|
|
15
|
+
localeDetection: boolean;
|
|
16
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales>;
|
|
17
|
+
};
|
|
18
|
+
export declare function receiveConfig<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(input: MiddlewareRoutingConfigInput<AppLocales, AppPathnames>): MiddlewareRoutingConfig<AppLocales, AppPathnames>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { NextRequest } from 'next/server';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Locales, Pathnames } from '../routing/types';
|
|
3
|
+
import { MiddlewareRoutingConfig } from './config';
|
|
4
4
|
/**
|
|
5
5
|
* See https://developers.google.com/search/docs/specialty/international/localized-versions
|
|
6
6
|
*/
|
|
7
|
-
export default function getAlternateLinksHeaderValue<Locales extends
|
|
8
|
-
config:
|
|
7
|
+
export default function getAlternateLinksHeaderValue<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>({ config, localizedPathnames, request, resolvedLocale }: {
|
|
8
|
+
config: MiddlewareRoutingConfig<AppLocales, AppPathnames>;
|
|
9
9
|
request: NextRequest;
|
|
10
|
-
resolvedLocale:
|
|
11
|
-
localizedPathnames?: Pathnames<
|
|
10
|
+
resolvedLocale: AppLocales[number];
|
|
11
|
+
localizedPathnames?: Pathnames<AppLocales>[string];
|
|
12
12
|
}): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
export default function createMiddleware<Locales extends
|
|
2
|
+
import { Locales, Pathnames } from '../routing/types';
|
|
3
|
+
import { MiddlewareRoutingConfigInput } from './config';
|
|
4
|
+
export default function createMiddleware<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(input: MiddlewareRoutingConfigInput<AppLocales, AppPathnames>): (request: NextRequest) => NextResponse<unknown>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RequestCookies } from 'next/dist/server/web/spec-extension/cookies';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare function getAcceptLanguageLocale<
|
|
5
|
-
export default function resolveLocale<Locales extends
|
|
6
|
-
locale:
|
|
7
|
-
domain?: DomainConfig<
|
|
2
|
+
import { Locales, DomainConfig, Pathnames } from '../routing/types';
|
|
3
|
+
import { MiddlewareRoutingConfig } from './config';
|
|
4
|
+
export declare function getAcceptLanguageLocale<AppLocales extends Locales>(requestHeaders: Headers, locales: AppLocales, defaultLocale: string): string | undefined;
|
|
5
|
+
export default function resolveLocale<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(config: MiddlewareRoutingConfig<AppLocales, AppPathnames>, requestHeaders: Headers, requestCookies: RequestCookies, pathname: string): {
|
|
6
|
+
locale: AppLocales[number];
|
|
7
|
+
domain?: DomainConfig<AppLocales>;
|
|
8
8
|
};
|