next-intl 3.6.0-alpha.1 → 3.7.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/navigation/react-client/clientPermanentRedirect.js +25 -0
- package/dist/development/navigation/react-client/createLocalizedPathnamesNavigation.js +23 -6
- package/dist/development/navigation/react-client/createSharedPathnamesNavigation.js +11 -0
- package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +16 -0
- package/dist/development/navigation/react-server/createSharedPathnamesNavigation.js +11 -0
- package/dist/development/navigation/react-server/serverPermanentRedirect.js +19 -0
- package/dist/development/navigation/shared/basePermanentRedirect.js +16 -0
- package/dist/esm/navigation/react-client/clientPermanentRedirect.js +1 -0
- 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-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/esm/navigation/react-server/serverPermanentRedirect.js +1 -0
- package/dist/esm/navigation/shared/basePermanentRedirect.js +1 -0
- package/dist/production/navigation/react-client/clientPermanentRedirect.js +1 -0
- 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-server/createLocalizedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/createSharedPathnamesNavigation.js +1 -1
- package/dist/production/navigation/react-server/serverPermanentRedirect.js +1 -0
- package/dist/production/navigation/shared/basePermanentRedirect.js +1 -0
- package/dist/types/src/navigation/react-client/clientPermanentRedirect.d.ts +6 -0
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +4 -3
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +1 -0
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +1 -0
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +1 -0
- package/dist/types/src/navigation/react-server/serverPermanentRedirect.d.ts +6 -0
- package/dist/types/src/navigation/shared/basePermanentRedirect.d.ts +7 -0
- package/package.json +16 -13
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var useLocale = require('../../react-client/useLocale.js');
|
|
6
|
+
var basePermanentRedirect = require('../shared/basePermanentRedirect.js');
|
|
7
|
+
|
|
8
|
+
function clientPermanentRedirect(params) {
|
|
9
|
+
let locale;
|
|
10
|
+
try {
|
|
11
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context here is fine, since `redirect` should be called during render
|
|
12
|
+
locale = useLocale.default();
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw new Error('`permanentRedirect()` can only be called during render. To redirect in an event handler or similar, you can use `useRouter()` instead.' );
|
|
15
|
+
}
|
|
16
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
17
|
+
args[_key - 1] = arguments[_key];
|
|
18
|
+
}
|
|
19
|
+
return basePermanentRedirect.default({
|
|
20
|
+
...params,
|
|
21
|
+
locale
|
|
22
|
+
}, ...args);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.default = clientPermanentRedirect;
|
|
@@ -7,6 +7,7 @@ var React = require('react');
|
|
|
7
7
|
var useLocale = require('../../react-client/useLocale.js');
|
|
8
8
|
var utils = require('../shared/utils.js');
|
|
9
9
|
var ClientLink = require('./ClientLink.js');
|
|
10
|
+
var clientPermanentRedirect = require('./clientPermanentRedirect.js');
|
|
10
11
|
var clientRedirect = require('./clientRedirect.js');
|
|
11
12
|
var useBasePathname = require('./useBasePathname.js');
|
|
12
13
|
var useBaseRouter = require('./useBaseRouter.js');
|
|
@@ -63,6 +64,21 @@ function createLocalizedPathnamesNavigation(opts) {
|
|
|
63
64
|
pathname: resolvedHref
|
|
64
65
|
}, ...args);
|
|
65
66
|
}
|
|
67
|
+
function permanentRedirect(href) {
|
|
68
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context here is fine, since `redirect` should be called during render
|
|
69
|
+
const locale = useTypedLocale();
|
|
70
|
+
const resolvedHref = getPathname({
|
|
71
|
+
href,
|
|
72
|
+
locale
|
|
73
|
+
});
|
|
74
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
75
|
+
args[_key2 - 1] = arguments[_key2];
|
|
76
|
+
}
|
|
77
|
+
return clientPermanentRedirect.default({
|
|
78
|
+
...opts,
|
|
79
|
+
pathname: resolvedHref
|
|
80
|
+
}, ...args);
|
|
81
|
+
}
|
|
66
82
|
function useRouter() {
|
|
67
83
|
const baseRouter = useBaseRouter.default();
|
|
68
84
|
const defaultLocale = useTypedLocale();
|
|
@@ -70,8 +86,8 @@ function createLocalizedPathnamesNavigation(opts) {
|
|
|
70
86
|
...baseRouter,
|
|
71
87
|
push(href) {
|
|
72
88
|
var _args$;
|
|
73
|
-
for (var
|
|
74
|
-
args[
|
|
89
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
90
|
+
args[_key3 - 1] = arguments[_key3];
|
|
75
91
|
}
|
|
76
92
|
const resolvedHref = getPathname({
|
|
77
93
|
href,
|
|
@@ -81,8 +97,8 @@ function createLocalizedPathnamesNavigation(opts) {
|
|
|
81
97
|
},
|
|
82
98
|
replace(href) {
|
|
83
99
|
var _args$2;
|
|
84
|
-
for (var
|
|
85
|
-
args[
|
|
100
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
101
|
+
args[_key4 - 1] = arguments[_key4];
|
|
86
102
|
}
|
|
87
103
|
const resolvedHref = getPathname({
|
|
88
104
|
href,
|
|
@@ -92,8 +108,8 @@ function createLocalizedPathnamesNavigation(opts) {
|
|
|
92
108
|
},
|
|
93
109
|
prefetch(href) {
|
|
94
110
|
var _args$3;
|
|
95
|
-
for (var
|
|
96
|
-
args[
|
|
111
|
+
for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
|
|
112
|
+
args[_key5 - 1] = arguments[_key5];
|
|
97
113
|
}
|
|
98
114
|
const resolvedHref = getPathname({
|
|
99
115
|
href,
|
|
@@ -127,6 +143,7 @@ function createLocalizedPathnamesNavigation(opts) {
|
|
|
127
143
|
return {
|
|
128
144
|
Link: LinkWithRef,
|
|
129
145
|
redirect,
|
|
146
|
+
permanentRedirect,
|
|
130
147
|
usePathname,
|
|
131
148
|
useRouter,
|
|
132
149
|
getPathname
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var ClientLink = require('./ClientLink.js');
|
|
8
|
+
var clientPermanentRedirect = require('./clientPermanentRedirect.js');
|
|
8
9
|
var clientRedirect = require('./clientRedirect.js');
|
|
9
10
|
var useBasePathname = require('./useBasePathname.js');
|
|
10
11
|
var useBaseRouter = require('./useBaseRouter.js');
|
|
@@ -31,6 +32,15 @@ function createSharedPathnamesNavigation(opts) {
|
|
|
31
32
|
pathname
|
|
32
33
|
}, ...args);
|
|
33
34
|
}
|
|
35
|
+
function permanentRedirect(pathname) {
|
|
36
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
37
|
+
args[_key2 - 1] = arguments[_key2];
|
|
38
|
+
}
|
|
39
|
+
return clientPermanentRedirect.default({
|
|
40
|
+
...opts,
|
|
41
|
+
pathname
|
|
42
|
+
}, ...args);
|
|
43
|
+
}
|
|
34
44
|
function usePathname() {
|
|
35
45
|
// @ts-expect-error -- Mirror the behavior from Next.js, where `null` is returned when `usePathname` is used outside of Next, but the types indicate that a string is always returned.
|
|
36
46
|
return useBasePathname.default();
|
|
@@ -38,6 +48,7 @@ function createSharedPathnamesNavigation(opts) {
|
|
|
38
48
|
return {
|
|
39
49
|
Link: LinkWithRef,
|
|
40
50
|
redirect,
|
|
51
|
+
permanentRedirect,
|
|
41
52
|
usePathname,
|
|
42
53
|
useRouter: useBaseRouter.default
|
|
43
54
|
};
|
|
@@ -7,6 +7,7 @@ var React = require('react');
|
|
|
7
7
|
var RequestLocale = require('../../server/react-server/RequestLocale.js');
|
|
8
8
|
var utils = require('../shared/utils.js');
|
|
9
9
|
var ServerLink = require('./ServerLink.js');
|
|
10
|
+
var serverPermanentRedirect = require('./serverPermanentRedirect.js');
|
|
10
11
|
var serverRedirect = require('./serverRedirect.js');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -54,6 +55,20 @@ function createLocalizedPathnamesNavigation(_ref) {
|
|
|
54
55
|
pathname
|
|
55
56
|
}, ...args);
|
|
56
57
|
}
|
|
58
|
+
function permanentRedirect(href) {
|
|
59
|
+
const locale = RequestLocale.getRequestLocale();
|
|
60
|
+
const pathname = getPathname({
|
|
61
|
+
href,
|
|
62
|
+
locale
|
|
63
|
+
});
|
|
64
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
65
|
+
args[_key2 - 1] = arguments[_key2];
|
|
66
|
+
}
|
|
67
|
+
return serverPermanentRedirect.default({
|
|
68
|
+
localePrefix,
|
|
69
|
+
pathname
|
|
70
|
+
}, ...args);
|
|
71
|
+
}
|
|
57
72
|
function getPathname(_ref3) {
|
|
58
73
|
let {
|
|
59
74
|
href,
|
|
@@ -73,6 +88,7 @@ function createLocalizedPathnamesNavigation(_ref) {
|
|
|
73
88
|
return {
|
|
74
89
|
Link,
|
|
75
90
|
redirect,
|
|
91
|
+
permanentRedirect,
|
|
76
92
|
getPathname,
|
|
77
93
|
usePathname: notSupported('usePathname'),
|
|
78
94
|
useRouter: notSupported('useRouter')
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var ServerLink = require('./ServerLink.js');
|
|
8
|
+
var serverPermanentRedirect = require('./serverPermanentRedirect.js');
|
|
8
9
|
var serverRedirect = require('./serverRedirect.js');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -31,9 +32,19 @@ function createSharedPathnamesNavigation(opts) {
|
|
|
31
32
|
pathname
|
|
32
33
|
}, ...args);
|
|
33
34
|
}
|
|
35
|
+
function permanentRedirect(pathname) {
|
|
36
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
37
|
+
args[_key2 - 1] = arguments[_key2];
|
|
38
|
+
}
|
|
39
|
+
return serverPermanentRedirect.default({
|
|
40
|
+
...opts,
|
|
41
|
+
pathname
|
|
42
|
+
}, ...args);
|
|
43
|
+
}
|
|
34
44
|
return {
|
|
35
45
|
Link,
|
|
36
46
|
redirect,
|
|
47
|
+
permanentRedirect,
|
|
37
48
|
usePathname: notSupported('usePathname'),
|
|
38
49
|
useRouter: notSupported('useRouter')
|
|
39
50
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var RequestLocale = require('../../server/react-server/RequestLocale.js');
|
|
6
|
+
var basePermanentRedirect = require('../shared/basePermanentRedirect.js');
|
|
7
|
+
|
|
8
|
+
function serverPermanentRedirect(params) {
|
|
9
|
+
const locale = RequestLocale.getRequestLocale();
|
|
10
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
11
|
+
args[_key - 1] = arguments[_key];
|
|
12
|
+
}
|
|
13
|
+
return basePermanentRedirect.default({
|
|
14
|
+
...params,
|
|
15
|
+
locale
|
|
16
|
+
}, ...args);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.default = serverPermanentRedirect;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var navigation = require('next/navigation');
|
|
6
|
+
var utils = require('../../shared/utils.js');
|
|
7
|
+
|
|
8
|
+
function basePermanentRedirect(params) {
|
|
9
|
+
const localizedPathname = params.localePrefix === 'never' ? params.pathname : utils.prefixPathname(params.locale, params.pathname);
|
|
10
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
11
|
+
args[_key - 1] = arguments[_key];
|
|
12
|
+
}
|
|
13
|
+
return navigation.permanentRedirect(localizedPathname, ...args);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.default = basePermanentRedirect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"../../react-client/useLocale.js";import r from"../shared/basePermanentRedirect.js";function n(n){let t;try{t=e()}catch(e){throw new Error("`permanentRedirect()` can only be called during render. To redirect in an event handler or similar, you can use `useRouter()` instead.")}for(var a=arguments.length,o=new Array(a>1?a-1:0),c=1;c<a;c++)o[c-1]=arguments[c];return r({...n,locale:t},...o)}export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import n from"../../react-client/useLocale.js";import{getRoute as a,compileLocalizedPathname as o,normalizeNameOrNameWithParams as l}from"../shared/utils.js";import c from"./ClientLink.js";import s from"./clientPermanentRedirect.js";import i from"./clientRedirect.js";import u from"./useBasePathname.js";import f from"./useBaseRouter.js";function m(m){function p(){const e=n();if(!m.locales.includes(e))throw new Error('Unknown locale encountered: "'.concat(e,'". Make sure to validate the locale in `app/[locale]/layout.tsx`.'));return e}function h(t,n){let{href:a,locale:l,...s}=t;const i=p(),u=l||i;return r.createElement(c,e({ref:n,href:o({locale:u,pathname:a,params:"object"==typeof a?a.params:void 0,pathnames:m.pathnames}),locale:l,localePrefix:m.localePrefix},s))}const d=t(h);function v(e){let{href:r,locale:t}=e;return o({...l(r),locale:t,pathnames:m.pathnames})}return d.displayName="Link",{Link:d,redirect:function(e){const r=v({href:e,locale:p()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return i({...m,pathname:r},...n)},permanentRedirect:function(e){const r=v({href:e,locale:p()});for(var t=arguments.length,n=new Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];return s({...m,pathname:r},...n)},usePathname:function(){const e=u(),r=p();return e?a({pathname:e,locale:r,pathnames:m.pathnames}):e},useRouter:function(){const e=f(),r=p();return{...e,push(t){for(var n,a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];const c=v({href:t,locale:(null===(n=o[0])||void 0===n?void 0:n.locale)||r});return e.push(c,...o)},replace(t){for(var n,a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];const c=v({href:t,locale:(null===(n=o[0])||void 0===n?void 0:n.locale)||r});return e.replace(c,...o)},prefetch(t){for(var n,a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];const c=v({href:t,locale:(null===(n=o[0])||void 0===n?void 0:n.locale)||r});return e.prefetch(c,...o)}}},getPathname:v}}export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import n from"./ClientLink.js";import o from"./
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r,{forwardRef as t}from"react";import n from"./ClientLink.js";import o from"./clientPermanentRedirect.js";import i from"./clientRedirect.js";import a from"./useBasePathname.js";import m from"./useBaseRouter.js";function u(u){function l(t,o){return r.createElement(n,e({ref:o,localePrefix:null==u?void 0:u.localePrefix},t))}const f=t(l);return f.displayName="Link",{Link:f,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({...u,pathname:e},...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({...u,pathname:e},...t)},usePathname:function(){return a()},useRouter:m}}export{u 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{compileLocalizedPathname as o,normalizeNameOrNameWithParams as
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import{getRequestLocale as t}from"../../server/react-server/RequestLocale.js";import{compileLocalizedPathname as o,normalizeNameOrNameWithParams as n}from"../shared/utils.js";import a from"./ServerLink.js";import l from"./serverPermanentRedirect.js";import c from"./serverRedirect.js";function s(s){let{localePrefix:i,locales:m,pathnames:u}=s;function f(e){let{href:r,locale:t}=e;return o({...n(r),locale:t,pathnames:u})}function p(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(n){let{href:l,locale:c,...s}=n;const m=t(),f=c||m;return r.createElement(a,e({href:o({locale:f,pathname:l,params:"object"==typeof l?l.params:void 0,pathnames:u}),locale:c,localePrefix:i},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:i,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 l({localePrefix:i,pathname:r},...n)},getPathname:f,usePathname:p("usePathname"),useRouter:p("useRouter")}}export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"./ServerLink.js";import o from"./serverRedirect.js";function
|
|
1
|
+
import{extends as e}from"../../_virtual/_rollupPluginBabelHelpers.js";import r from"react";import t from"./ServerLink.js";import n from"./serverPermanentRedirect.js";import o from"./serverRedirect.js";function a(a){function i(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(n){return r.createElement(t,e({localePrefix:null==a?void 0:a.localePrefix},n))},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({...a,pathname:e},...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 n({...a,pathname:e},...t)},usePathname:i("usePathname"),useRouter:i("useRouter")}}export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getRequestLocale as e}from"../../server/react-server/RequestLocale.js";import r from"../shared/basePermanentRedirect.js";function t(t){const a=e();for(var o=arguments.length,s=new Array(o>1?o-1:0),n=1;n<o;n++)s[n-1]=arguments[n];return r({...t,locale:a},...s)}export{t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{permanentRedirect as e}from"next/navigation";import{prefixPathname as r}from"../../shared/utils.js";function a(a){const t="never"===a.localePrefix?a.pathname:r(a.locale,a.pathname);for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return e(t,...o)}export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../react-client/useLocale.js"),r=require("../shared/basePermanentRedirect.js");exports.default=function(t){let a;try{a=e.default()}catch(e){throw new Error(void 0)}for(var l=arguments.length,o=new Array(l>1?l-1:0),u=1;u<l;u++)o[u-1]=arguments[u];return r.default({...t,locale:a},...o)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),t=require("../shared/utils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),a=require("../../react-client/useLocale.js"),t=require("../shared/utils.js"),n=require("./ClientLink.js"),l=require("./clientPermanentRedirect.js"),o=require("./clientRedirect.js"),u=require("./useBasePathname.js"),c=require("./useBaseRouter.js");function i(e){return e&&e.__esModule?e:{default:e}}var s=i(r);exports.default=function(i){function f(){const e=a.default();if(!i.locales.includes(e))throw new Error(void 0);return e}function h(r,a){let{href:l,locale:o,...u}=r;const c=f(),h=o||c;return s.default.createElement(n.default,e.extends({ref:a,href:t.compileLocalizedPathname({locale:h,pathname:l,params:"object"==typeof l?l.params:void 0,pathnames:i.pathnames}),locale:o,localePrefix:i.localePrefix},u))}const d=r.forwardRef(h);function p(e){let{href:r,locale:a}=e;return t.compileLocalizedPathname({...t.normalizeNameOrNameWithParams(r),locale:a,pathnames:i.pathnames})}return d.displayName="Link",{Link:d,redirect:function(e){const r=p({href:e,locale:f()});for(var a=arguments.length,t=new Array(a>1?a-1:0),n=1;n<a;n++)t[n-1]=arguments[n];return o.default({...i,pathname:r},...t)},permanentRedirect:function(e){const r=p({href:e,locale:f()});for(var a=arguments.length,t=new Array(a>1?a-1:0),n=1;n<a;n++)t[n-1]=arguments[n];return l.default({...i,pathname:r},...t)},usePathname:function(){const e=u.default(),r=f();return e?t.getRoute({pathname:e,locale:r,pathnames:i.pathnames}):e},useRouter:function(){const e=c.default(),r=f();return{...e,push(a){for(var t,n=arguments.length,l=new Array(n>1?n-1:0),o=1;o<n;o++)l[o-1]=arguments[o];const u=p({href:a,locale:(null===(t=l[0])||void 0===t?void 0:t.locale)||r});return e.push(u,...l)},replace(a){for(var t,n=arguments.length,l=new Array(n>1?n-1:0),o=1;o<n;o++)l[o-1]=arguments[o];const u=p({href:a,locale:(null===(t=l[0])||void 0===t?void 0:t.locale)||r});return e.replace(u,...l)},prefetch(a){for(var t,n=arguments.length,l=new Array(n>1?n-1:0),o=1;o<n;o++)l[o-1]=arguments[o];const u=p({href:a,locale:(null===(t=l[0])||void 0===t?void 0:t.locale)||r});return e.prefetch(u,...l)}}},getPathname:p}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("./ClientLink.js"),u=require("./clientRedirect.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("./ClientLink.js"),n=require("./clientPermanentRedirect.js"),u=require("./clientRedirect.js"),a=require("./useBasePathname.js"),i=require("./useBaseRouter.js");function l(e){return e&&e.__esModule?e:{default:e}}var f=l(r);exports.default=function(l){function s(r,n){return f.default.createElement(t.default,e.extends({ref:n,localePrefix:null==l?void 0:l.localePrefix},r))}const o=r.forwardRef(s);return o.displayName="Link",{Link:o,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 u.default({...l,pathname:e},...t)},permanentRedirect:function(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),u=1;u<r;u++)t[u-1]=arguments[u];return n.default({...l,pathname:e},...t)},usePathname:function(){return a.default()},useRouter:i.default}};
|
|
@@ -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/utils.js"),
|
|
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/utils.js"),n=require("./ServerLink.js"),o=require("./serverPermanentRedirect.js"),l=require("./serverRedirect.js");function u(e){return e&&e.__esModule?e:{default:e}}var c=u(r);exports.default=function(r){let{localePrefix:u,locales:s,pathnames:i}=r;function f(e){let{href:r,locale:t}=e;return a.compileLocalizedPathname({...a.normalizeNameOrNameWithParams(r),locale:t,pathnames:i})}function m(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:o,locale:l,...s}=r;const f=t.getRequestLocale(),m=l||f;return c.default.createElement(n.default,e.extends({href:a.compileLocalizedPathname({locale:m,pathname:o,params:"object"==typeof o?o.params:void 0,pathnames:i}),locale:l,localePrefix:u},s))},redirect:function(e){const r=f({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.default({localePrefix:u,pathname:r},...n)},permanentRedirect:function(e){const r=f({href:e,locale:t.getRequestLocale()});for(var a=arguments.length,n=new Array(a>1?a-1:0),l=1;l<a;l++)n[l-1]=arguments[l];return o.default({localePrefix:u,pathname:r},...n)},getPathname:f,usePathname:m("usePathname"),useRouter:m("useRouter")}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("./ServerLink.js"),n=require("./serverRedirect.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_rollupPluginBabelHelpers.js"),r=require("react"),t=require("./ServerLink.js"),n=require("./serverPermanentRedirect.js"),u=require("./serverRedirect.js");function o(e){return e&&e.__esModule?e:{default:e}}var a=o(r);exports.default=function(r){function o(e){return()=>{throw new Error("`".concat(e,"` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."))}}return{Link:function(n){return a.default.createElement(t.default,e.extends({localePrefix:null==r?void 0:r.localePrefix},n))},redirect:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return u.default({...r,pathname:e},...n)},permanentRedirect:function(e){for(var t=arguments.length,u=new Array(t>1?t-1:0),o=1;o<t;o++)u[o-1]=arguments[o];return n.default({...r,pathname:e},...u)},usePathname:o("usePathname"),useRouter:o("useRouter")}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../server/react-server/RequestLocale.js"),r=require("../shared/basePermanentRedirect.js");exports.default=function(t){const s=e.getRequestLocale();for(var a=arguments.length,u=new Array(a>1?a-1:0),o=1;o<a;o++)u[o-1]=arguments[o];return r.default({...t,locale:s},...u)};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("next/navigation"),r=require("../../shared/utils.js");exports.default=function(t){const a="never"===t.localePrefix?t.pathname:r.prefixPathname(t.locale,t.pathname);for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return e.permanentRedirect(a,...i)};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LocalePrefix, ParametersExceptFirst } from '../../shared/types';
|
|
2
|
+
import basePermanentRedirect from '../shared/basePermanentRedirect';
|
|
3
|
+
export default function clientPermanentRedirect(params: {
|
|
4
|
+
localePrefix?: LocalePrefix;
|
|
5
|
+
pathname: string;
|
|
6
|
+
}, ...args: ParametersExceptFirst<typeof basePermanentRedirect>): never;
|
|
@@ -58,15 +58,16 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
|
|
|
58
58
|
ref?: ComponentProps<typeof ClientLink>['ref'];
|
|
59
59
|
}) => ReactElement;
|
|
60
60
|
redirect: <Pathname_1 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_1>, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
61
|
+
permanentRedirect: <Pathname_2 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_2>, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
61
62
|
usePathname: () => keyof PathnamesConfig;
|
|
62
63
|
useRouter: () => {
|
|
63
|
-
push<
|
|
64
|
+
push<Pathname_3 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_3>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & {
|
|
64
65
|
locale?: string | undefined;
|
|
65
66
|
}) | undefined): void;
|
|
66
|
-
replace<
|
|
67
|
+
replace<Pathname_4 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_4>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & {
|
|
67
68
|
locale?: string | undefined;
|
|
68
69
|
}) | undefined): void;
|
|
69
|
-
prefetch<
|
|
70
|
+
prefetch<Pathname_5 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_5>, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").PrefetchOptions & {
|
|
70
71
|
locale?: string | undefined;
|
|
71
72
|
}) | undefined): void;
|
|
72
73
|
back(): void;
|
|
@@ -45,6 +45,7 @@ export default function createSharedPathnamesNavigation<Locales extends AllLocal
|
|
|
45
45
|
ref?: React.Ref<HTMLAnchorElement> | undefined;
|
|
46
46
|
}) => ReactElement;
|
|
47
47
|
redirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
48
|
+
permanentRedirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
48
49
|
usePathname: () => string;
|
|
49
50
|
useRouter: typeof useBaseRouter;
|
|
50
51
|
};
|
|
@@ -53,6 +53,7 @@ export default function createLocalizedPathnamesNavigation<Locales extends AllLo
|
|
|
53
53
|
locale?: Locales[number] | undefined;
|
|
54
54
|
}) => React.JSX.Element;
|
|
55
55
|
redirect: <Pathname_1 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_1>, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
56
|
+
permanentRedirect: <Pathname_2 extends keyof PathnamesConfig>(href: HrefOrHrefWithParams<Pathname_2>, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
56
57
|
getPathname: ({ href, locale }: {
|
|
57
58
|
locale: Locales[number];
|
|
58
59
|
href: HrefOrHrefWithParams<keyof PathnamesConfig>;
|
|
@@ -7,6 +7,7 @@ export default function createSharedPathnamesNavigation<Locales extends AllLocal
|
|
|
7
7
|
}): {
|
|
8
8
|
Link: (props: ComponentProps<typeof ServerLink<Locales>>) => React.JSX.Element;
|
|
9
9
|
redirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
10
|
+
permanentRedirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
10
11
|
usePathname: () => never;
|
|
11
12
|
useRouter: () => never;
|
|
12
13
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LocalePrefix, ParametersExceptFirst } from '../../shared/types';
|
|
2
|
+
import basePermanentRedirect from '../shared/basePermanentRedirect';
|
|
3
|
+
export default function serverPermanentRedirect(params: {
|
|
4
|
+
pathname: string;
|
|
5
|
+
localePrefix?: LocalePrefix;
|
|
6
|
+
}, ...args: ParametersExceptFirst<typeof basePermanentRedirect>): never;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { permanentRedirect as nextPermanentRedirect } from 'next/navigation';
|
|
2
|
+
import { AllLocales, LocalePrefix, ParametersExceptFirst } from '../../shared/types';
|
|
3
|
+
export default function basePermanentRedirect(params: {
|
|
4
|
+
pathname: string;
|
|
5
|
+
locale: AllLocales[number];
|
|
6
|
+
localePrefix?: LocalePrefix;
|
|
7
|
+
}, ...args: ParametersExceptFirst<typeof nextPermanentRedirect>): never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -16,6 +16,16 @@
|
|
|
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": "CI=true turbo test && turbo lint && turbo build && cp ../../README.md .",
|
|
26
|
+
"postpublish": "git checkout . && rm ./README.md",
|
|
27
|
+
"size": "size-limit"
|
|
28
|
+
},
|
|
19
29
|
"main": "./dist/index.react-client.js",
|
|
20
30
|
"module": "./dist/esm/index.react-client.js",
|
|
21
31
|
"typings": "./dist/types/src/index.react-client.d.ts",
|
|
@@ -72,7 +82,7 @@
|
|
|
72
82
|
"dependencies": {
|
|
73
83
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
74
84
|
"negotiator": "^0.6.3",
|
|
75
|
-
"use-intl": "3.
|
|
85
|
+
"use-intl": "^3.7.0"
|
|
76
86
|
},
|
|
77
87
|
"peerDependencies": {
|
|
78
88
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
@@ -112,11 +122,11 @@
|
|
|
112
122
|
},
|
|
113
123
|
{
|
|
114
124
|
"path": "dist/production/navigation.react-client.js",
|
|
115
|
-
"limit": "2.
|
|
125
|
+
"limit": "2.89 KB"
|
|
116
126
|
},
|
|
117
127
|
{
|
|
118
128
|
"path": "dist/production/navigation.react-server.js",
|
|
119
|
-
"limit": "
|
|
129
|
+
"limit": "3.01 KB"
|
|
120
130
|
},
|
|
121
131
|
{
|
|
122
132
|
"path": "dist/production/server.react-client.js",
|
|
@@ -131,12 +141,5 @@
|
|
|
131
141
|
"limit": "5.81 KB"
|
|
132
142
|
}
|
|
133
143
|
],
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
"test": "TZ=Europe/Berlin vitest",
|
|
137
|
-
"lint": "pnpm run lint:source && pnpm run lint:package",
|
|
138
|
-
"lint:source": "eslint src test && tsc --noEmit",
|
|
139
|
-
"lint:package": "publint && attw --pack",
|
|
140
|
-
"size": "size-limit"
|
|
141
|
-
}
|
|
142
|
-
}
|
|
144
|
+
"gitHead": "482c83d73b930cfce70979639a93d480f52901c2"
|
|
145
|
+
}
|