next-intl 2.14.3-alpha.1 → 2.14.6
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/link/Link.d.ts +3 -3
- package/dist/middleware/middleware.d.ts +1 -4
- package/dist/server/index.d.ts +1 -4
- package/dist/src/link/Link.d.ts +3 -3
- package/dist/src/link/Link.js +6 -5
- package/dist/src/link/Link.js.map +1 -1
- package/dist/src/middleware/middleware.d.ts +1 -4
- package/dist/src/middleware/middleware.js +5 -8
- package/dist/src/middleware/middleware.js.map +1 -1
- package/dist/src/server/index.d.ts +1 -4
- package/package.json +13 -10
- package/src/link/Link.tsx +7 -5
- package/src/middleware/middleware.tsx +5 -10
package/dist/link/Link.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
|
2
2
|
import BaseLink from '../shared/BaseLink';
|
|
3
3
|
type Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
|
|
4
4
|
locale?: string;
|
|
@@ -23,5 +23,5 @@ type Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
|
|
|
23
23
|
* the `set-cookie` response header would cause the locale cookie on the current
|
|
24
24
|
* page to be overwritten before the user even decides to change the locale.
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
export
|
|
26
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
27
|
+
export default _default;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import MiddlewareConfig from './NextIntlMiddlewareConfig';
|
|
3
|
-
export default function createMiddleware(config: MiddlewareConfig):
|
|
4
|
-
(request: NextRequest): NextResponse;
|
|
5
|
-
middleware: any;
|
|
6
|
-
};
|
|
3
|
+
export default function createMiddleware(config: MiddlewareConfig): (request: NextRequest) => NextResponse;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3,7 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import MiddlewareConfig from '../middleware/NextIntlMiddlewareConfig';
|
|
5
5
|
/** @deprecated Should be imported as `import createMiddleware from 'next-intl/middleware', not from `next-intl/server`. */
|
|
6
|
-
export declare function createIntlMiddleware(config: MiddlewareConfig):
|
|
7
|
-
(request: import("next/server").NextRequest): import("next/server").NextResponse;
|
|
8
|
-
middleware: any;
|
|
9
|
-
};
|
|
6
|
+
export declare function createIntlMiddleware(config: MiddlewareConfig): (request: import("next/server").NextRequest) => import("next/server").NextResponse;
|
package/dist/src/link/Link.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentProps } from 'react';
|
|
1
|
+
import React, { ComponentProps } from 'react';
|
|
2
2
|
import BaseLink from '../shared/BaseLink';
|
|
3
3
|
type Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
|
|
4
4
|
locale?: string;
|
|
@@ -23,5 +23,5 @@ type Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
|
|
|
23
23
|
* the `set-cookie` response header would cause the locale cookie on the current
|
|
24
24
|
* page to be overwritten before the user even decides to change the locale.
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
export
|
|
26
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
27
|
+
export default _default;
|
package/dist/src/link/Link.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
2
|
import useClientLocale from '../client/useClientLocale';
|
|
3
3
|
import BaseLink from '../shared/BaseLink';
|
|
4
|
+
function Link({ locale, ...rest }, ref) {
|
|
5
|
+
const defaultLocale = useClientLocale();
|
|
6
|
+
return React.createElement(BaseLink, { ref: ref, locale: locale || defaultLocale, ...rest });
|
|
7
|
+
}
|
|
4
8
|
/**
|
|
5
9
|
* Wraps `next/link` and prefixes the `href` with the current locale if
|
|
6
10
|
* necessary.
|
|
@@ -21,8 +25,5 @@ import BaseLink from '../shared/BaseLink';
|
|
|
21
25
|
* the `set-cookie` response header would cause the locale cookie on the current
|
|
22
26
|
* page to be overwritten before the user even decides to change the locale.
|
|
23
27
|
*/
|
|
24
|
-
export default
|
|
25
|
-
const defaultLocale = useClientLocale();
|
|
26
|
-
return React.createElement(BaseLink, { locale: locale || defaultLocale, ...rest });
|
|
27
|
-
}
|
|
28
|
+
export default forwardRef(Link);
|
|
28
29
|
//# sourceMappingURL=Link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../../src/link/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,UAAU,EAAC,MAAM,OAAO,CAAC;AACxD,OAAO,eAAe,MAAM,2BAA2B,CAAC;AACxD,OAAO,QAAQ,MAAM,oBAAoB,CAAC;AAM1C,SAAS,IAAI,CAAC,EAAC,MAAM,EAAE,GAAG,IAAI,EAAQ,EAAE,GAAiB;IACvD,MAAM,aAAa,GAAG,eAAe,EAAE,CAAC;IACxC,OAAO,oBAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,IAAI,aAAa,KAAM,IAAI,GAAI,CAAC;AAC3E,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAe,UAAU,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
import MiddlewareConfig from './NextIntlMiddlewareConfig';
|
|
3
|
-
export default function createMiddleware(config: MiddlewareConfig):
|
|
4
|
-
(request: NextRequest): NextResponse;
|
|
5
|
-
middleware: any;
|
|
6
|
-
};
|
|
3
|
+
export default function createMiddleware(config: MiddlewareConfig): (request: NextRequest) => NextResponse;
|
|
@@ -19,7 +19,7 @@ export default function createMiddleware(config) {
|
|
|
19
19
|
// Currently only in use to enable a seamless upgrade path from the
|
|
20
20
|
// `{createIntlMiddleware} from 'next-intl/server'` API.
|
|
21
21
|
const matcher = config._matcher;
|
|
22
|
-
function middleware(request) {
|
|
22
|
+
return function middleware(request) {
|
|
23
23
|
var _a, _b;
|
|
24
24
|
const matches = !matcher ||
|
|
25
25
|
matcher.some((pattern) => request.nextUrl.pathname.match(pattern));
|
|
@@ -128,18 +128,15 @@ export default function createMiddleware(config) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
if (hasOutdatedCookie) {
|
|
131
|
-
response.cookies.set(COOKIE_LOCALE_NAME, locale
|
|
131
|
+
response.cookies.set(COOKIE_LOCALE_NAME, locale, {
|
|
132
|
+
sameSite: 'strict'
|
|
133
|
+
});
|
|
132
134
|
}
|
|
133
135
|
if (configWithDefaults.alternateLinks &&
|
|
134
136
|
configWithDefaults.locales.length > 1) {
|
|
135
137
|
response.headers.set('Link', getAlternateLinksHeaderValue(configWithDefaults, request));
|
|
136
138
|
}
|
|
137
139
|
return response;
|
|
138
|
-
}
|
|
139
|
-
// Next.js is ambiguous if a middleware should be defined as a named
|
|
140
|
-
// or default export. We support both patterns for compatibility.
|
|
141
|
-
// https://github.com/amannn/next-intl/issues/290
|
|
142
|
-
middleware.middleware = middleware;
|
|
143
|
-
return middleware;
|
|
140
|
+
};
|
|
144
141
|
}
|
|
145
142
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/middleware/middleware.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAC,MAAM,aAAa,CAAC;AACtD,OAAO,EAAC,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAIvD,OAAO,4BAA4B,MA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}
|
|
@@ -3,7 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import MiddlewareConfig from '../middleware/NextIntlMiddlewareConfig';
|
|
5
5
|
/** @deprecated Should be imported as `import createMiddleware from 'next-intl/middleware', not from `next-intl/server`. */
|
|
6
|
-
export declare function createIntlMiddleware(config: MiddlewareConfig):
|
|
7
|
-
(request: import("next/server").NextRequest): import("next/server").NextResponse;
|
|
8
|
-
middleware: any;
|
|
9
|
-
};
|
|
6
|
+
export declare function createIntlMiddleware(config: MiddlewareConfig): (request: import("next/server").NextRequest) => import("next/server").NextResponse;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.6",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"description": "A minimal, but complete solution for internationalization in Next.js apps.",
|
|
@@ -10,6 +10,15 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/amannn/next-intl"
|
|
12
12
|
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "pnpm build:default && pnpm build:rsc",
|
|
15
|
+
"build:default": "rm -rf dist && dts build",
|
|
16
|
+
"build:rsc": "tsc && rm -rf dist/test",
|
|
17
|
+
"test": "TZ=Europe/Berlin dts test --testPathIgnorePatterns=dist",
|
|
18
|
+
"lint": "eslint src test && tsc --noEmit",
|
|
19
|
+
"prepublishOnly": "turbo test && turbo lint && turbo build && cp ../../README.md .",
|
|
20
|
+
"postpublish": "git checkout . && rm ./README.md"
|
|
21
|
+
},
|
|
13
22
|
"main": "dist/index.js",
|
|
14
23
|
"module": "dist/next-intl.esm.js",
|
|
15
24
|
"typings": "dist/index.d.ts",
|
|
@@ -50,7 +59,7 @@
|
|
|
50
59
|
"dependencies": {
|
|
51
60
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
52
61
|
"negotiator": "^0.6.3",
|
|
53
|
-
"use-intl": "^2.14.
|
|
62
|
+
"use-intl": "^2.14.6"
|
|
54
63
|
},
|
|
55
64
|
"peerDependencies": {
|
|
56
65
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
|
|
@@ -75,11 +84,5 @@
|
|
|
75
84
|
"engines": {
|
|
76
85
|
"node": ">=10"
|
|
77
86
|
},
|
|
78
|
-
"
|
|
79
|
-
|
|
80
|
-
"build:default": "rm -rf dist && dts build",
|
|
81
|
-
"build:rsc": "tsc && rm -rf dist/test",
|
|
82
|
-
"test": "TZ=Europe/Berlin dts test --testPathIgnorePatterns=dist",
|
|
83
|
-
"lint": "eslint src test && tsc --noEmit"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
87
|
+
"gitHead": "a1854592a86b33a4de19a70deec8709c23f3d802"
|
|
88
|
+
}
|
package/src/link/Link.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {ComponentProps} from 'react';
|
|
1
|
+
import React, {ComponentProps, forwardRef} from 'react';
|
|
2
2
|
import useClientLocale from '../client/useClientLocale';
|
|
3
3
|
import BaseLink from '../shared/BaseLink';
|
|
4
4
|
|
|
@@ -6,6 +6,11 @@ type Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
|
|
|
6
6
|
locale?: string;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
function Link({locale, ...rest}: Props, ref: Props['ref']) {
|
|
10
|
+
const defaultLocale = useClientLocale();
|
|
11
|
+
return <BaseLink ref={ref} locale={locale || defaultLocale} {...rest} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* Wraps `next/link` and prefixes the `href` with the current locale if
|
|
11
16
|
* necessary.
|
|
@@ -26,7 +31,4 @@ type Props = Omit<ComponentProps<typeof BaseLink>, 'locale'> & {
|
|
|
26
31
|
* the `set-cookie` response header would cause the locale cookie on the current
|
|
27
32
|
* page to be overwritten before the user even decides to change the locale.
|
|
28
33
|
*/
|
|
29
|
-
export default
|
|
30
|
-
const defaultLocale = useClientLocale();
|
|
31
|
-
return <BaseLink locale={locale || defaultLocale} {...rest} />;
|
|
32
|
-
}
|
|
34
|
+
export default forwardRef(Link);
|
|
@@ -31,7 +31,7 @@ export default function createMiddleware(config: MiddlewareConfig) {
|
|
|
31
31
|
// `{createIntlMiddleware} from 'next-intl/server'` API.
|
|
32
32
|
const matcher: Array<string> | undefined = (config as any)._matcher;
|
|
33
33
|
|
|
34
|
-
function middleware(request: NextRequest) {
|
|
34
|
+
return function middleware(request: NextRequest) {
|
|
35
35
|
const matches =
|
|
36
36
|
!matcher ||
|
|
37
37
|
matcher.some((pattern) => request.nextUrl.pathname.match(pattern));
|
|
@@ -180,7 +180,9 @@ export default function createMiddleware(config: MiddlewareConfig) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
if (hasOutdatedCookie) {
|
|
183
|
-
response.cookies.set(COOKIE_LOCALE_NAME, locale
|
|
183
|
+
response.cookies.set(COOKIE_LOCALE_NAME, locale, {
|
|
184
|
+
sameSite: 'strict'
|
|
185
|
+
});
|
|
184
186
|
}
|
|
185
187
|
|
|
186
188
|
if (
|
|
@@ -194,12 +196,5 @@ export default function createMiddleware(config: MiddlewareConfig) {
|
|
|
194
196
|
}
|
|
195
197
|
|
|
196
198
|
return response;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Next.js is ambiguous if a middleware should be defined as a named
|
|
200
|
-
// or default export. We support both patterns for compatibility.
|
|
201
|
-
// https://github.com/amannn/next-intl/issues/290
|
|
202
|
-
middleware.middleware = middleware;
|
|
203
|
-
|
|
204
|
-
return middleware;
|
|
199
|
+
};
|
|
205
200
|
}
|