next-intl 3.20.1-canary.0 → 3.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/middleware/middleware.js +6 -6
- package/dist/development/middleware/resolveLocale.js +7 -2
- package/dist/development/navigation/react-client/ClientLink.js +2 -2
- package/dist/development/navigation/react-client/useBasePathname.js +14 -0
- package/dist/development/navigation/react-server/ServerLink.js +2 -4
- package/dist/development/navigation/shared/BaseLink.js +25 -28
- package/dist/development/navigation/shared/redirects.js +0 -3
- package/dist/development/navigation/shared/utils.js +1 -40
- package/dist/development/navigation.react-client.js +0 -2
- package/dist/development/navigation.react-server.js +0 -2
- package/dist/development/react-client/index.js +2 -0
- package/dist/development/routing/config.js +1 -1
- package/dist/esm/middleware/middleware.js +1 -1
- package/dist/esm/middleware/resolveLocale.js +1 -1
- package/dist/esm/navigation/react-client/ClientLink.js +1 -1
- package/dist/esm/navigation/react-client/useBasePathname.js +1 -0
- package/dist/esm/navigation/react-server/ServerLink.js +1 -1
- package/dist/esm/navigation/shared/BaseLink.js +1 -1
- package/dist/esm/navigation/shared/utils.js +1 -1
- package/dist/esm/navigation.react-client.js +1 -1
- package/dist/esm/navigation.react-server.js +1 -1
- package/dist/esm/routing/config.js +1 -1
- package/dist/production/middleware/middleware.js +1 -1
- package/dist/production/middleware/resolveLocale.js +1 -1
- package/dist/production/navigation/react-client/ClientLink.js +1 -1
- package/dist/production/navigation/react-client/useBasePathname.js +1 -0
- package/dist/production/navigation/react-server/ServerLink.js +1 -1
- package/dist/production/navigation/shared/BaseLink.js +1 -1
- package/dist/production/navigation/shared/utils.js +1 -1
- package/dist/production/navigation.react-client.js +1 -1
- package/dist/production/navigation.react-server.js +1 -1
- package/dist/production/routing/config.js +1 -1
- package/dist/types/src/middleware/getAlternateLinksHeaderValue.d.ts +3 -3
- package/dist/types/src/middleware/middleware.d.ts +2 -2
- package/dist/types/src/middleware/resolveLocale.d.ts +2 -2
- package/dist/types/src/middleware/utils.d.ts +4 -4
- package/dist/types/src/navigation/react-client/ClientLink.d.ts +6 -6
- package/dist/types/src/navigation/react-client/createLocalizedPathnamesNavigation.d.ts +4 -12
- package/dist/types/src/navigation/react-client/createSharedPathnamesNavigation.d.ts +4 -4
- package/dist/types/src/navigation/react-client/index.d.ts +0 -1
- package/dist/types/src/navigation/react-client/redirects.d.ts +4 -4
- package/dist/types/src/navigation/react-client/useBasePathname.d.ts +15 -2
- package/dist/types/src/navigation/react-client/useBaseRouter.d.ts +2 -2
- package/dist/types/src/navigation/react-server/ServerLink.d.ts +5 -5
- package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +4 -12
- package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +3 -3
- package/dist/types/src/navigation/react-server/index.d.ts +0 -1
- package/dist/types/src/navigation/react-server/redirects.d.ts +4 -4
- package/dist/types/src/navigation/shared/BaseLink.d.ts +6 -11
- package/dist/types/src/navigation/shared/redirects.d.ts +5 -5
- package/dist/types/src/navigation/shared/utils.d.ts +3 -10
- package/dist/types/src/react-server/getTranslator.d.ts +9 -0
- package/dist/types/src/routing/config.d.ts +11 -19
- package/dist/types/src/routing/defineRouting.d.ts +2 -2
- package/dist/types/src/routing/types.d.ts +4 -4
- package/dist/types/src/server/react-server/getTranslations.d.ts +9 -0
- package/dist/types/src/shared/types.d.ts +0 -3
- package/dist/types/src/shared/utils.d.ts +2 -2
- package/package.json +3 -3
- package/dist/development/navigation/react-client/createNavigation.js +0 -83
- package/dist/development/navigation/react-server/createNavigation.js +0 -30
- package/dist/development/navigation/shared/LegacyBaseLink.js +0 -55
- package/dist/development/navigation/shared/createSharedNavigationFns.js +0 -147
- package/dist/esm/navigation/react-client/createNavigation.js +0 -1
- package/dist/esm/navigation/react-server/createNavigation.js +0 -1
- package/dist/esm/navigation/shared/LegacyBaseLink.js +0 -2
- package/dist/esm/navigation/shared/createSharedNavigationFns.js +0 -1
- package/dist/production/navigation/react-client/createNavigation.js +0 -1
- package/dist/production/navigation/react-server/createNavigation.js +0 -1
- package/dist/production/navigation/shared/LegacyBaseLink.js +0 -2
- package/dist/production/navigation/shared/createSharedNavigationFns.js +0 -1
- package/dist/types/src/navigation/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/react-client/createNavigation.d.ts +0 -467
- package/dist/types/src/navigation/react-client/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/react-server/createNavigation.d.ts +0 -385
- package/dist/types/src/navigation/react-server/createNavigation.test.d.ts +0 -1
- package/dist/types/src/navigation/shared/LegacyBaseLink.d.ts +0 -10
- package/dist/types/src/navigation/shared/createSharedNavigationFns.d.ts +0 -382
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ComponentProps, ReactElement } from 'react';
|
|
2
|
-
import { Locales, LocalePrefixConfigVerbose
|
|
3
|
-
import
|
|
4
|
-
type Props<AppLocales extends Locales
|
|
2
|
+
import { Locales, LocalePrefixConfigVerbose } from '../../routing/types';
|
|
3
|
+
import BaseLink from '../shared/BaseLink';
|
|
4
|
+
type Props<AppLocales extends Locales> = Omit<ComponentProps<typeof BaseLink>, 'locale' | 'prefix' | 'localePrefixMode'> & {
|
|
5
5
|
locale?: AppLocales[number];
|
|
6
|
-
localePrefix: LocalePrefixConfigVerbose<AppLocales
|
|
6
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales>;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* Wraps `next/link` and prefixes the `href` with the current locale if
|
|
@@ -25,7 +25,7 @@ type Props<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixM
|
|
|
25
25
|
* the `set-cookie` response header would cause the locale cookie on the current
|
|
26
26
|
* page to be overwritten before the user even decides to change the locale.
|
|
27
27
|
*/
|
|
28
|
-
declare const ClientLinkWithRef: <AppLocales extends Locales
|
|
29
|
-
ref?: Props<AppLocales
|
|
28
|
+
declare const ClientLinkWithRef: <AppLocales extends Locales>(props: Props<AppLocales> & {
|
|
29
|
+
ref?: Props<AppLocales>["ref"];
|
|
30
30
|
}) => ReactElement;
|
|
31
31
|
export default ClientLinkWithRef;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { ComponentProps, ReactElement } from 'react';
|
|
2
2
|
import { RoutingConfigLocalizedNavigation } from '../../routing/config';
|
|
3
|
-
import {
|
|
3
|
+
import { Locales, Pathnames } from '../../routing/types';
|
|
4
4
|
import { HrefOrHrefWithParams } from '../shared/utils';
|
|
5
5
|
import ClientLink from './ClientLink';
|
|
6
|
-
export default function createLocalizedPathnamesNavigation<AppLocales extends Locales,
|
|
6
|
+
export default function createLocalizedPathnamesNavigation<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(routing: RoutingConfigLocalizedNavigation<AppLocales, AppPathnames>): {
|
|
7
7
|
Link: <Pathname extends keyof AppPathnames>(props: (Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
|
|
8
8
|
href: string | import("url").UrlObject;
|
|
9
9
|
as?: string | import("url").UrlObject;
|
|
@@ -35,18 +35,10 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
35
35
|
} & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
|
|
36
36
|
locale: string;
|
|
37
37
|
prefix: string;
|
|
38
|
-
localePrefixMode: LocalePrefixMode;
|
|
38
|
+
localePrefixMode: import("../../routing/types").LocalePrefixMode;
|
|
39
39
|
}, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale" | "prefix" | "localePrefixMode"> & {
|
|
40
40
|
locale?: string | undefined;
|
|
41
|
-
localePrefix:
|
|
42
|
-
mode: "never";
|
|
43
|
-
} | {
|
|
44
|
-
mode: "always";
|
|
45
|
-
prefixes?: Partial<Record<string, string>> | undefined;
|
|
46
|
-
} | {
|
|
47
|
-
mode: "as-needed";
|
|
48
|
-
prefixes?: Partial<Record<string, string>> | undefined;
|
|
49
|
-
};
|
|
41
|
+
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<Locales>;
|
|
50
42
|
} & {
|
|
51
43
|
ref?: React.LegacyRef<HTMLAnchorElement> | undefined;
|
|
52
44
|
}, "localePrefix" | "href" | "name"> & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactElement } from 'react';
|
|
2
2
|
import { RoutingConfigSharedNavigation } from '../../routing/config';
|
|
3
|
-
import {
|
|
4
|
-
export default function createSharedPathnamesNavigation<AppLocales extends Locales
|
|
3
|
+
import { Locales } from '../../routing/types';
|
|
4
|
+
export default function createSharedPathnamesNavigation<const AppLocales extends Locales>(routing?: RoutingConfigSharedNavigation<AppLocales, never>): {
|
|
5
5
|
Link: (props: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
|
|
6
6
|
href: string | import("url").UrlObject;
|
|
7
7
|
as?: string | import("url").UrlObject;
|
|
@@ -33,10 +33,10 @@ export default function createSharedPathnamesNavigation<AppLocales extends Local
|
|
|
33
33
|
} & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
|
|
34
34
|
locale: string;
|
|
35
35
|
prefix: string;
|
|
36
|
-
localePrefixMode: LocalePrefixMode;
|
|
36
|
+
localePrefixMode: import("../../routing/types").LocalePrefixMode;
|
|
37
37
|
}, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale" | "prefix" | "localePrefixMode"> & {
|
|
38
38
|
locale?: AppLocales[number] | undefined;
|
|
39
|
-
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales
|
|
39
|
+
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
|
|
40
40
|
} & {
|
|
41
41
|
ref?: React.LegacyRef<HTMLAnchorElement> | undefined;
|
|
42
42
|
}, "localePrefix"> & {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { default as createSharedPathnamesNavigation } from './createSharedPathnamesNavigation';
|
|
2
2
|
export { default as createLocalizedPathnamesNavigation } from './createLocalizedPathnamesNavigation';
|
|
3
|
-
export { default as createNavigation } from './createNavigation';
|
|
4
3
|
import type { Pathnames as PathnamesDeprecatedExport, Locales } from '../../routing/types';
|
|
5
4
|
/** @deprecated Please import from `next-intl/routing` instead. */
|
|
6
5
|
export type Pathnames<AppLocales extends Locales> = PathnamesDeprecatedExport<AppLocales>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const clientRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales
|
|
1
|
+
export declare const clientRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
|
|
2
2
|
pathname: string;
|
|
3
3
|
locale: import("../../routing/types").Locales[number];
|
|
4
|
-
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales
|
|
4
|
+
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
|
|
5
5
|
}, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
6
|
-
export declare const clientPermanentRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales
|
|
6
|
+
export declare const clientPermanentRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
|
|
7
7
|
pathname: string;
|
|
8
8
|
locale: import("../../routing/types").Locales[number];
|
|
9
|
-
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales
|
|
9
|
+
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
|
|
10
10
|
}, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import { Locales, LocalePrefixConfigVerbose
|
|
2
|
-
|
|
1
|
+
import { Locales, LocalePrefixConfigVerbose } from '../../routing/types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the pathname without a potential locale prefix.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* 'use client';
|
|
8
|
+
*
|
|
9
|
+
* import {usePathname} from 'next-intl/client';
|
|
10
|
+
*
|
|
11
|
+
* // When the user is on `/en`, this will be `/`
|
|
12
|
+
* const pathname = usePathname();
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export default function useBasePathname<AppLocales extends Locales>(localePrefix: LocalePrefixConfigVerbose<AppLocales>): string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Locales, LocalePrefixConfigVerbose
|
|
1
|
+
import { Locales, LocalePrefixConfigVerbose } from '../../routing/types';
|
|
2
2
|
type IntlNavigateOptions<AppLocales extends Locales> = {
|
|
3
3
|
locale?: AppLocales[number];
|
|
4
4
|
};
|
|
@@ -21,7 +21,7 @@ type IntlNavigateOptions<AppLocales extends Locales> = {
|
|
|
21
21
|
* router.push('/about', {locale: 'de'});
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
export default function useBaseRouter<AppLocales extends Locales
|
|
24
|
+
export default function useBaseRouter<AppLocales extends Locales>(localePrefix: LocalePrefixConfigVerbose<AppLocales>): {
|
|
25
25
|
push: (href: string, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & IntlNavigateOptions<AppLocales>) | undefined) => void;
|
|
26
26
|
replace: (href: string, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").NavigateOptions & IntlNavigateOptions<AppLocales>) | undefined) => void;
|
|
27
27
|
prefetch: (href: string, options?: (import("next/dist/shared/lib/app-router-context.shared-runtime").PrefetchOptions & IntlNavigateOptions<AppLocales>) | undefined) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { ComponentProps } from 'react';
|
|
2
|
-
import { Locales, LocalePrefixConfigVerbose
|
|
3
|
-
import
|
|
4
|
-
type Props<AppLocales extends Locales
|
|
2
|
+
import { Locales, LocalePrefixConfigVerbose } from '../../routing/types';
|
|
3
|
+
import BaseLink from '../shared/BaseLink';
|
|
4
|
+
type Props<AppLocales extends Locales> = Omit<ComponentProps<typeof BaseLink>, 'locale' | 'prefix' | 'localePrefixMode'> & {
|
|
5
5
|
locale?: AppLocales[number];
|
|
6
|
-
localePrefix: LocalePrefixConfigVerbose<AppLocales
|
|
6
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales>;
|
|
7
7
|
};
|
|
8
|
-
export default function ServerLink<AppLocales extends Locales
|
|
8
|
+
export default function ServerLink<AppLocales extends Locales>({ locale, localePrefix, ...rest }: Props<AppLocales>): Promise<React.JSX.Element>;
|
|
9
9
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { RoutingConfigLocalizedNavigation } from '../../routing/config';
|
|
3
|
-
import {
|
|
3
|
+
import { Locales, Pathnames } from '../../routing/types';
|
|
4
4
|
import { HrefOrHrefWithParams } from '../shared/utils';
|
|
5
|
-
export default function createLocalizedPathnamesNavigation<AppLocales extends Locales,
|
|
5
|
+
export default function createLocalizedPathnamesNavigation<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>>(routing: RoutingConfigLocalizedNavigation<AppLocales, AppPathnames>): {
|
|
6
6
|
Link: <Pathname extends keyof AppPathnames>({ href, locale, ...rest }: Omit<Omit<Omit<Omit<Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof {
|
|
7
7
|
href: string | import("url").UrlObject;
|
|
8
8
|
as?: string | import("url").UrlObject;
|
|
@@ -34,18 +34,10 @@ export default function createLocalizedPathnamesNavigation<AppLocales extends Lo
|
|
|
34
34
|
} & React.RefAttributes<HTMLAnchorElement>, "locale"> & {
|
|
35
35
|
locale: string;
|
|
36
36
|
prefix: string;
|
|
37
|
-
localePrefixMode: LocalePrefixMode;
|
|
37
|
+
localePrefixMode: import("../../routing/types").LocalePrefixMode;
|
|
38
38
|
}, "ref"> & React.RefAttributes<HTMLAnchorElement>, "locale" | "prefix" | "localePrefixMode"> & {
|
|
39
39
|
locale?: string | undefined;
|
|
40
|
-
localePrefix:
|
|
41
|
-
mode: "never";
|
|
42
|
-
} | {
|
|
43
|
-
mode: "always";
|
|
44
|
-
prefixes?: Partial<Record<string, string>> | undefined;
|
|
45
|
-
} | {
|
|
46
|
-
mode: "as-needed";
|
|
47
|
-
prefixes?: Partial<Record<string, string>> | undefined;
|
|
48
|
-
};
|
|
40
|
+
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<Locales>;
|
|
49
41
|
}, "localePrefix" | "href" | "name"> & {
|
|
50
42
|
href: Pathname extends `${string}[[...${string}` ? Pathname | ({
|
|
51
43
|
pathname: Pathname;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { ComponentProps } from 'react';
|
|
2
2
|
import { RoutingConfigSharedNavigation } from '../../routing/config';
|
|
3
|
-
import {
|
|
3
|
+
import { Locales } from '../../routing/types';
|
|
4
4
|
import ServerLink from './ServerLink';
|
|
5
|
-
export default function createSharedPathnamesNavigation<AppLocales extends Locales
|
|
6
|
-
Link: (props: Omit<ComponentProps<typeof ServerLink<AppLocales
|
|
5
|
+
export default function createSharedPathnamesNavigation<AppLocales extends Locales>(routing?: RoutingConfigSharedNavigation<AppLocales, never>): {
|
|
6
|
+
Link: (props: Omit<ComponentProps<typeof ServerLink<AppLocales>>, "localePrefix" | "locales">) => React.JSX.Element;
|
|
7
7
|
redirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
8
8
|
permanentRedirect: (pathname: string, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
9
9
|
usePathname: () => never;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { default as createSharedPathnamesNavigation } from './createSharedPathnamesNavigation';
|
|
2
2
|
export { default as createLocalizedPathnamesNavigation } from './createLocalizedPathnamesNavigation';
|
|
3
|
-
export { default as createNavigation } from './createNavigation';
|
|
4
3
|
export type { Pathnames } from '../../routing/types';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const serverRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales
|
|
1
|
+
export declare const serverRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
|
|
2
2
|
pathname: string;
|
|
3
3
|
locale: import("../../routing/types").Locales[number];
|
|
4
|
-
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales
|
|
4
|
+
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
|
|
5
5
|
}, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
6
|
-
export declare const serverPermanentRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales
|
|
6
|
+
export declare const serverPermanentRedirect: (params: Omit<Parameters<(<AppLocales extends import("../../routing/types").Locales>(params: {
|
|
7
7
|
pathname: string;
|
|
8
8
|
locale: import("../../routing/types").Locales[number];
|
|
9
|
-
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales
|
|
9
|
+
localePrefix: import("../../routing/types").LocalePrefixConfigVerbose<AppLocales>;
|
|
10
10
|
}, type?: import("next/navigation").RedirectType | undefined) => never)>[0], "locale">, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import NextLink from 'next/link';
|
|
2
2
|
import React, { ComponentProps } from 'react';
|
|
3
|
+
import { LocalePrefixMode } from '../../routing/types';
|
|
3
4
|
type Props = Omit<ComponentProps<typeof NextLink>, 'locale'> & {
|
|
4
|
-
locale
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
unprefixed?: {
|
|
8
|
-
domains: {
|
|
9
|
-
[domain: string]: string;
|
|
10
|
-
};
|
|
11
|
-
pathname: string;
|
|
12
|
-
};
|
|
5
|
+
locale: string;
|
|
6
|
+
prefix: string;
|
|
7
|
+
localePrefixMode: LocalePrefixMode;
|
|
13
8
|
};
|
|
14
|
-
declare const
|
|
15
|
-
export default
|
|
9
|
+
declare const BaseLinkWithRef: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
|
|
10
|
+
export default BaseLinkWithRef;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Locales, LocalePrefixConfigVerbose
|
|
2
|
-
export declare const baseRedirect: <AppLocales extends Locales
|
|
1
|
+
import { Locales, LocalePrefixConfigVerbose } from '../../routing/types';
|
|
2
|
+
export declare const baseRedirect: <AppLocales extends Locales>(params: {
|
|
3
3
|
pathname: string;
|
|
4
4
|
locale: Locales[number];
|
|
5
|
-
localePrefix: LocalePrefixConfigVerbose<AppLocales
|
|
5
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales>;
|
|
6
6
|
}, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
7
|
-
export declare const basePermanentRedirect: <AppLocales extends Locales
|
|
7
|
+
export declare const basePermanentRedirect: <AppLocales extends Locales>(params: {
|
|
8
8
|
pathname: string;
|
|
9
9
|
locale: Locales[number];
|
|
10
|
-
localePrefix: LocalePrefixConfigVerbose<AppLocales
|
|
10
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales>;
|
|
11
11
|
}, type?: import("next/navigation").RedirectType | undefined) => never;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ParsedUrlQueryInput } from 'node:querystring';
|
|
2
2
|
import type { UrlObject } from 'url';
|
|
3
|
-
import {
|
|
4
|
-
import { DomainsConfig, LocalePrefixMode, Locales, Pathnames } from '../../routing/types';
|
|
3
|
+
import { Locales, Pathnames } from '../../routing/types';
|
|
5
4
|
import StrictParams from './StrictParams';
|
|
6
5
|
type SearchParamValue = ParsedUrlQueryInput[keyof ParsedUrlQueryInput];
|
|
7
6
|
type HrefOrHrefWithParamsImpl<Pathname, Other> = Pathname extends `${string}[[...${string}` ? // Optional catch-all
|
|
@@ -17,14 +16,10 @@ Pathname | ({
|
|
|
17
16
|
pathname: Pathname;
|
|
18
17
|
} & Other);
|
|
19
18
|
export type HrefOrUrlObjectWithParams<Pathname> = HrefOrHrefWithParamsImpl<Pathname, Omit<UrlObject, 'pathname'>>;
|
|
20
|
-
export type QueryParams = Record<string, SearchParamValue>;
|
|
21
19
|
export type HrefOrHrefWithParams<Pathname> = HrefOrHrefWithParamsImpl<Pathname, {
|
|
22
|
-
query?:
|
|
20
|
+
query?: Record<string, SearchParamValue>;
|
|
23
21
|
}>;
|
|
24
|
-
export declare function normalizeNameOrNameWithParams<Pathname>(href: HrefOrHrefWithParams<Pathname>
|
|
25
|
-
locale: string;
|
|
26
|
-
href: HrefOrHrefWithParams<Pathname>;
|
|
27
|
-
}): {
|
|
22
|
+
export declare function normalizeNameOrNameWithParams<Pathname>(href: HrefOrHrefWithParams<Pathname>): {
|
|
28
23
|
pathname: Pathname;
|
|
29
24
|
params?: StrictParams<Pathname>;
|
|
30
25
|
};
|
|
@@ -48,6 +43,4 @@ export declare function compileLocalizedPathname<AppLocales extends Locales, Pat
|
|
|
48
43
|
}): UrlObject;
|
|
49
44
|
export declare function getRoute<AppLocales extends Locales>(locale: AppLocales[number], pathname: string, pathnames: Pathnames<AppLocales>): keyof Pathnames<AppLocales>;
|
|
50
45
|
export declare function getBasePath(pathname: string, windowPathname?: string): string;
|
|
51
|
-
export declare function applyPathnamePrefix<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(pathname: string, locale: Locales[number], routing: Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'localePrefix' | 'domains'> & Partial<Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'defaultLocale'>>, domain?: string, force?: boolean): string;
|
|
52
|
-
export declare function validateReceivedConfig<AppLocales extends Locales, AppLocalePrefixMode extends LocalePrefixMode, AppPathnames extends Pathnames<AppLocales> | undefined, AppDomains extends DomainsConfig<AppLocales> | undefined>(config: Partial<Pick<ResolvedRoutingConfig<AppLocales, AppLocalePrefixMode, AppPathnames, AppDomains>, 'defaultLocale' | 'localePrefix'>>): void;
|
|
53
46
|
export {};
|
|
@@ -37,6 +37,15 @@ declare function getTranslatorImpl<NestedKey extends NamespaceKeys<IntlMessages,
|
|
|
37
37
|
}, [
|
|
38
38
|
NestedKey
|
|
39
39
|
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
|
|
40
|
+
has<TargetKey extends MessageKeys<NestedValueOf<{
|
|
41
|
+
'!': IntlMessages;
|
|
42
|
+
}, [
|
|
43
|
+
NestedKey
|
|
44
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
45
|
+
'!': IntlMessages;
|
|
46
|
+
}, [
|
|
47
|
+
NestedKey
|
|
48
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): boolean;
|
|
40
49
|
};
|
|
41
50
|
declare const _default: typeof getTranslatorImpl;
|
|
42
51
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Locales, LocalePrefix, LocalePrefixConfigVerbose, DomainsConfig, Pathnames
|
|
2
|
-
export type RoutingConfig<AppLocales extends Locales,
|
|
1
|
+
import { Locales, LocalePrefix, LocalePrefixConfigVerbose, DomainsConfig, Pathnames } from './types';
|
|
2
|
+
export type RoutingConfig<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>> = {
|
|
3
3
|
/**
|
|
4
4
|
* All available locales.
|
|
5
5
|
* @see https://next-intl-docs.vercel.app/docs/routing
|
|
@@ -14,12 +14,12 @@ export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extend
|
|
|
14
14
|
* Configures whether and which prefix is shown for a given locale.
|
|
15
15
|
* @see https://next-intl-docs.vercel.app/docs/routing#locale-prefix
|
|
16
16
|
**/
|
|
17
|
-
localePrefix?: LocalePrefix<AppLocales
|
|
17
|
+
localePrefix?: LocalePrefix<AppLocales>;
|
|
18
18
|
/**
|
|
19
19
|
* Can be used to change the locale handling per domain.
|
|
20
20
|
* @see https://next-intl-docs.vercel.app/docs/routing#domains
|
|
21
21
|
**/
|
|
22
|
-
domains?:
|
|
22
|
+
domains?: DomainsConfig<AppLocales>;
|
|
23
23
|
} & ([AppPathnames] extends [never] ? {} : {
|
|
24
24
|
/**
|
|
25
25
|
* A map of localized pathnames per locale.
|
|
@@ -27,22 +27,14 @@ export type RoutingConfig<AppLocales extends Locales, AppLocalePrefixMode extend
|
|
|
27
27
|
**/
|
|
28
28
|
pathnames: AppPathnames;
|
|
29
29
|
});
|
|
30
|
-
export type RoutingConfigSharedNavigation<AppLocales extends Locales,
|
|
31
|
-
export type RoutingConfigLocalizedNavigation<AppLocales extends Locales,
|
|
30
|
+
export type RoutingConfigSharedNavigation<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>> = Omit<RoutingConfig<AppLocales, AppPathnames>, 'defaultLocale' | 'locales' | 'pathnames'> & Partial<Pick<RoutingConfig<AppLocales, AppPathnames>, 'defaultLocale' | 'locales'>>;
|
|
31
|
+
export type RoutingConfigLocalizedNavigation<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>> = Omit<RoutingConfig<AppLocales, AppPathnames>, 'defaultLocale' | 'pathnames'> & Partial<Pick<RoutingConfig<AppLocales, AppPathnames>, 'defaultLocale'>> & {
|
|
32
32
|
pathnames: AppPathnames;
|
|
33
33
|
};
|
|
34
|
-
export type ResolvedRoutingConfig<AppLocales extends Locales,
|
|
35
|
-
localePrefix: LocalePrefixConfigVerbose<AppLocales
|
|
34
|
+
export type ResolvedRoutingConfig<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales> = never> = Omit<RoutingConfig<AppLocales, AppPathnames>, 'localePrefix'> & {
|
|
35
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales>;
|
|
36
36
|
};
|
|
37
|
-
export declare function receiveRoutingConfig<AppLocales extends Locales,
|
|
38
|
-
localePrefix:
|
|
39
|
-
mode: "never";
|
|
40
|
-
} | {
|
|
41
|
-
mode: "always";
|
|
42
|
-
prefixes?: Partial<Record<AppLocales[number], string>> | undefined;
|
|
43
|
-
} | {
|
|
44
|
-
mode: "as-needed";
|
|
45
|
-
prefixes?: Partial<Record<AppLocales[number], string>> | undefined;
|
|
46
|
-
};
|
|
37
|
+
export declare function receiveRoutingConfig<AppLocales extends Locales, AppPathnames extends Pathnames<AppLocales>, Config extends Partial<RoutingConfig<AppLocales, AppPathnames>>>(input: Config): Config & {
|
|
38
|
+
localePrefix: LocalePrefixConfigVerbose<AppLocales>;
|
|
47
39
|
};
|
|
48
|
-
export declare function receiveLocalePrefixConfig<AppLocales extends Locales
|
|
40
|
+
export declare function receiveLocalePrefixConfig<AppLocales extends Locales>(localePrefix?: LocalePrefix<AppLocales>): LocalePrefixConfigVerbose<AppLocales>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { RoutingConfig } from './config';
|
|
2
|
-
import {
|
|
3
|
-
export default function defineRouting<const AppLocales extends Locales, const
|
|
2
|
+
import { Locales, Pathnames } from './types';
|
|
3
|
+
export default function defineRouting<const AppLocales extends Locales, const AppPathnames extends Pathnames<AppLocales> = never>(config: RoutingConfig<AppLocales, AppPathnames>): RoutingConfig<AppLocales, AppPathnames>;
|
|
@@ -2,16 +2,16 @@ export type Locales = ReadonlyArray<string>;
|
|
|
2
2
|
export type LocalePrefixMode = 'always' | 'as-needed' | 'never';
|
|
3
3
|
type Pathname = string;
|
|
4
4
|
export type LocalePrefixes<AppLocales extends Locales> = Partial<Record<AppLocales[number], Pathname>>;
|
|
5
|
-
export type LocalePrefixConfigVerbose<AppLocales extends Locales
|
|
5
|
+
export type LocalePrefixConfigVerbose<AppLocales extends Locales> = {
|
|
6
6
|
mode: 'always';
|
|
7
7
|
prefixes?: LocalePrefixes<AppLocales>;
|
|
8
|
-
}
|
|
8
|
+
} | {
|
|
9
9
|
mode: 'as-needed';
|
|
10
10
|
prefixes?: LocalePrefixes<AppLocales>;
|
|
11
|
-
}
|
|
11
|
+
} | {
|
|
12
12
|
mode: 'never';
|
|
13
13
|
};
|
|
14
|
-
export type LocalePrefix<AppLocales extends Locales =
|
|
14
|
+
export type LocalePrefix<AppLocales extends Locales = never> = LocalePrefixMode | LocalePrefixConfigVerbose<AppLocales>;
|
|
15
15
|
export type Pathnames<AppLocales extends Locales> = Record<Pathname, Record<AppLocales[number], Pathname> | Pathname>;
|
|
16
16
|
export type DomainConfig<AppLocales extends Locales> = {
|
|
17
17
|
defaultLocale: AppLocales[number];
|
|
@@ -37,6 +37,15 @@ declare function getTranslations<NestedKey extends NamespaceKeys<IntlMessages, N
|
|
|
37
37
|
}, [
|
|
38
38
|
NestedKey
|
|
39
39
|
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: [TargetKey] extends [never] ? string : TargetKey): any;
|
|
40
|
+
has<TargetKey extends MessageKeys<NestedValueOf<{
|
|
41
|
+
'!': IntlMessages;
|
|
42
|
+
}, [
|
|
43
|
+
NestedKey
|
|
44
|
+
] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
|
|
45
|
+
'!': IntlMessages;
|
|
46
|
+
}, [
|
|
47
|
+
NestedKey
|
|
48
|
+
] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: [TargetKey] extends [never] ? string : TargetKey): boolean;
|
|
40
49
|
}>;
|
|
41
50
|
declare function getTranslations<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>(opts?: {
|
|
42
51
|
locale: string;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
export type ParametersExceptFirst<Fn> = Fn extends (arg0: any, ...rest: infer R) => any ? R : never;
|
|
2
2
|
export type ParametersExceptFirstTwo<Fn> = Fn extends (arg0: any, arg1: any, ...rest: infer R) => any ? R : never;
|
|
3
|
-
export type Prettify<Type> = {
|
|
4
|
-
[Key in keyof Type]: Type[Key];
|
|
5
|
-
} & {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UrlObject } from 'url';
|
|
2
2
|
import NextLink from 'next/link';
|
|
3
3
|
import { ComponentProps } from 'react';
|
|
4
|
-
import { Locales, LocalePrefixConfigVerbose
|
|
4
|
+
import { Locales, LocalePrefixConfigVerbose } from '../routing/types';
|
|
5
5
|
type Href = ComponentProps<typeof NextLink>['href'];
|
|
6
6
|
export declare function isLocalizableHref(href: Href): boolean;
|
|
7
7
|
export declare function localizeHref(href: string, locale: string, curLocale: string, curPathname: string, prefix: string): string;
|
|
@@ -17,7 +17,7 @@ export declare function matchesPathname(
|
|
|
17
17
|
template: string,
|
|
18
18
|
/** E.g. `/users/23-jane` */
|
|
19
19
|
pathname: string): boolean;
|
|
20
|
-
export declare function getLocalePrefix<AppLocales extends Locales
|
|
20
|
+
export declare function getLocalePrefix<AppLocales extends Locales>(locale: AppLocales[number], localePrefix: LocalePrefixConfigVerbose<AppLocales>): string;
|
|
21
21
|
export declare function templateToRegex(template: string): RegExp;
|
|
22
22
|
export declare function getSortedPathnames(pathnames: Array<string>): string[];
|
|
23
23
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -87,11 +87,11 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
89
89
|
"negotiator": "^0.6.3",
|
|
90
|
-
"use-intl": "^3.
|
|
90
|
+
"use-intl": "^3.21.1"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0",
|
|
94
94
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "cd3d7a2c76a3824b176e00957ff69b2dda2b879b"
|
|
97
97
|
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var navigation = require('next/navigation');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var useLocale = require('../../react-client/useLocale.js');
|
|
8
|
-
var createSharedNavigationFns = require('../shared/createSharedNavigationFns.js');
|
|
9
|
-
var syncLocaleCookie = require('../shared/syncLocaleCookie.js');
|
|
10
|
-
var utils = require('../shared/utils.js');
|
|
11
|
-
var useBasePathname = require('./useBasePathname.js');
|
|
12
|
-
|
|
13
|
-
function createNavigation(routing) {
|
|
14
|
-
function useTypedLocale() {
|
|
15
|
-
return useLocale.default();
|
|
16
|
-
}
|
|
17
|
-
const {
|
|
18
|
-
Link,
|
|
19
|
-
config,
|
|
20
|
-
getPathname,
|
|
21
|
-
...redirects
|
|
22
|
-
} = createSharedNavigationFns.default(useTypedLocale, routing);
|
|
23
|
-
|
|
24
|
-
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#usepathname */
|
|
25
|
-
function usePathname() {
|
|
26
|
-
const pathname = useBasePathname.default(config.localePrefix);
|
|
27
|
-
const locale = useTypedLocale();
|
|
28
|
-
|
|
29
|
-
// @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.
|
|
30
|
-
return React.useMemo(() => pathname &&
|
|
31
|
-
// @ts-expect-error -- This is fine
|
|
32
|
-
config.pathnames ? utils.getRoute(locale, pathname,
|
|
33
|
-
// @ts-expect-error -- This is fine
|
|
34
|
-
config.pathnames) : pathname, [locale, pathname]);
|
|
35
|
-
}
|
|
36
|
-
function useRouter() {
|
|
37
|
-
const router = navigation.useRouter();
|
|
38
|
-
const curLocale = useTypedLocale();
|
|
39
|
-
const nextPathname = navigation.usePathname();
|
|
40
|
-
return React.useMemo(() => {
|
|
41
|
-
function createHandler(fn) {
|
|
42
|
-
return function handler(href, options) {
|
|
43
|
-
const {
|
|
44
|
-
locale: nextLocale,
|
|
45
|
-
...rest
|
|
46
|
-
} = options || {};
|
|
47
|
-
|
|
48
|
-
// @ts-expect-error -- We're passing a domain here just in case
|
|
49
|
-
const pathname = getPathname({
|
|
50
|
-
href,
|
|
51
|
-
locale: nextLocale || curLocale,
|
|
52
|
-
domain: window.location.host
|
|
53
|
-
});
|
|
54
|
-
const args = [pathname];
|
|
55
|
-
if (Object.keys(rest).length > 0) {
|
|
56
|
-
// @ts-expect-error -- This is fine
|
|
57
|
-
args.push(rest);
|
|
58
|
-
}
|
|
59
|
-
fn(...args);
|
|
60
|
-
syncLocaleCookie.default(nextPathname, curLocale, nextLocale);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
...router,
|
|
65
|
-
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */
|
|
66
|
-
push: createHandler(router.push),
|
|
67
|
-
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */
|
|
68
|
-
replace: createHandler(router.replace),
|
|
69
|
-
/** @see https://next-intl-docs.vercel.app/docs/routing/navigation#userouter */
|
|
70
|
-
prefetch: createHandler(router.prefetch)
|
|
71
|
-
};
|
|
72
|
-
}, [curLocale, nextPathname, router]);
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
...redirects,
|
|
76
|
-
Link,
|
|
77
|
-
usePathname,
|
|
78
|
-
useRouter,
|
|
79
|
-
getPathname
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
exports.default = createNavigation;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var RequestLocale = require('../../server/react-server/RequestLocale.js');
|
|
6
|
-
var createSharedNavigationFns = require('../shared/createSharedNavigationFns.js');
|
|
7
|
-
|
|
8
|
-
function createNavigation(routing) {
|
|
9
|
-
function getLocale() {
|
|
10
|
-
return RequestLocale.getRequestLocale();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
|
-
const {
|
|
15
|
-
config,
|
|
16
|
-
...fns
|
|
17
|
-
} = createSharedNavigationFns.default(getLocale, routing);
|
|
18
|
-
function notSupported(hookName) {
|
|
19
|
-
return () => {
|
|
20
|
-
throw new Error("`".concat(hookName, "` is not supported in Server Components. You can use this hook if you convert the calling component to a Client Component."));
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
...fns,
|
|
25
|
-
usePathname: notSupported('usePathname'),
|
|
26
|
-
useRouter: notSupported('useRouter')
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
exports.default = createNavigation;
|