next-intl 2.17.2 → 2.17.3
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/client/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as useRouter } from './useRouter.js';
|
|
2
2
|
export { default as usePathname } from './usePathname.js';
|
|
3
3
|
export { default as NextIntlClientProvider } from './NextIntlClientProvider.js';
|
|
4
|
+
import 'next/dist/shared/lib/app-router-context';
|
|
4
5
|
import 'react';
|
|
5
6
|
import '../shared/NextIntlClientProvider.js';
|
|
6
7
|
import 'use-intl';
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as next_dist_shared_lib_app_router_context from 'next/dist/shared/lib/app-router-context';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Returns a wrapped instance of `useRouter` from `next/navigation` that
|
|
3
5
|
* will automatically localize the `href` parameters it receives.
|
|
@@ -15,9 +17,9 @@
|
|
|
15
17
|
* ```
|
|
16
18
|
*/
|
|
17
19
|
declare function useRouter(): {
|
|
18
|
-
push(href: string): void;
|
|
19
|
-
replace(href: string): void;
|
|
20
|
-
prefetch(href: string): void;
|
|
20
|
+
push(href: string, options?: next_dist_shared_lib_app_router_context.NavigateOptions | undefined): void;
|
|
21
|
+
replace(href: string, options?: next_dist_shared_lib_app_router_context.NavigateOptions | undefined): void;
|
|
22
|
+
prefetch(href: string, options?: next_dist_shared_lib_app_router_context.PrefetchOptions | undefined): void;
|
|
21
23
|
back(): void;
|
|
22
24
|
forward(): void;
|
|
23
25
|
refresh(): void;
|
package/dist/client/useRouter.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var m=Object.create;var a=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var R=(e,r)=>{for(var t in r)a(e,t,{get:r[t],enumerable:!0})},p=(e,r,t,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of h(r))!P.call(e,o)&&o!==t&&a(e,o,{get:()=>r[o],enumerable:!(u=i(r,o))||u.enumerable});return e};var d=(e,r,t)=>(t=e!=null?m(y(e)):{},p(r||!e||!e.__esModule?a(t,"default",{value:e,enumerable:!0}):t,e)),w=e=>p(a({},"__esModule",{value:!0}),e);var x={};R(x,{default:()=>l});module.exports=w(x);var n=require("next/navigation"),c=require("react"),s=require("../shared/utils"),f=d(require("./useClientLocale"));function l(){const e=(0,n.useRouter)(),r=(0,f.default)();return(0,c.useMemo)(()=>{function t(u){return(0,s.localizeHref)(u,r,r,window.location.pathname)}return{...e,push(...[u,...o]){return e.push(t(u),...o)},replace(...[u,...o]){return e.replace(t(u),...o)},prefetch(...[u,...o]){return e.prefetch(t(u),...o)}}},[r,e])}
|
|
2
2
|
//# sourceMappingURL=useRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/useRouter.tsx"],"sourcesContent":["import {useRouter as useNextRouter} from 'next/navigation';\nimport {useMemo} from 'react';\nimport {localizeHref} from '../shared/utils';\nimport useClientLocale from './useClientLocale';\n\n/**\n * Returns a wrapped instance of `useRouter` from `next/navigation` that\n * will automatically localize the `href` parameters it receives.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import {useRouter} from 'next-intl/client';\n *\n * const router = useRouter();\n *\n * // When the user is on `/en`, the router will navigate to `/en/about`\n * router.push('/about');\n * ```\n */\nexport default function useRouter() {\n const router = useNextRouter();\n const locale = useClientLocale();\n\n return useMemo(() => {\n function localize(href: string) {\n return localizeHref(href, locale, locale, window.location.pathname);\n }\n\n return {\n ...router,\n push(href:
|
|
1
|
+
{"version":3,"sources":["../../src/client/useRouter.tsx"],"sourcesContent":["import {useRouter as useNextRouter} from 'next/navigation';\nimport {useMemo} from 'react';\nimport {localizeHref} from '../shared/utils';\nimport useClientLocale from './useClientLocale';\n\n/**\n * Returns a wrapped instance of `useRouter` from `next/navigation` that\n * will automatically localize the `href` parameters it receives.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import {useRouter} from 'next-intl/client';\n *\n * const router = useRouter();\n *\n * // When the user is on `/en`, the router will navigate to `/en/about`\n * router.push('/about');\n * ```\n */\nexport default function useRouter() {\n const router = useNextRouter();\n const locale = useClientLocale();\n\n return useMemo(() => {\n function localize(href: string) {\n return localizeHref(href, locale, locale, window.location.pathname);\n }\n\n return {\n ...router,\n push(...[href, ...args]: Parameters<typeof router.push>) {\n return router.push(localize(href), ...args);\n },\n replace(...[href, ...args]: Parameters<typeof router.replace>) {\n return router.replace(localize(href), ...args);\n },\n prefetch(...[href, ...args]: Parameters<typeof router.prefetch>) {\n return router.prefetch(localize(href), ...args);\n }\n };\n }, [locale, router]);\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyC,2BACzCC,EAAsB,iBACtBC,EAA2B,2BAC3BC,EAA4B,gCAkBb,SAARL,GAA6B,CAClC,MAAMM,KAAS,EAAAC,WAAc,EACvBC,KAAS,EAAAC,SAAgB,EAE/B,SAAO,WAAQ,IAAM,CACnB,SAASC,EAASC,EAAc,CAC9B,SAAO,gBAAaA,EAAMH,EAAQA,EAAQ,OAAO,SAAS,QAAQ,CACpE,CAEA,MAAO,CACL,GAAGF,EACH,QAAQ,CAACK,EAAM,GAAGC,CAAI,EAAmC,CACvD,OAAON,EAAO,KAAKI,EAASC,CAAI,EAAG,GAAGC,CAAI,CAC5C,EACA,WAAW,CAACD,EAAM,GAAGC,CAAI,EAAsC,CAC7D,OAAON,EAAO,QAAQI,EAASC,CAAI,EAAG,GAAGC,CAAI,CAC/C,EACA,YAAY,CAACD,EAAM,GAAGC,CAAI,EAAuC,CAC/D,OAAON,EAAO,SAASI,EAASC,CAAI,EAAG,GAAGC,CAAI,CAChD,CACF,CACF,EAAG,CAACJ,EAAQF,CAAM,CAAC,CACrB","names":["useRouter_exports","__export","useRouter","__toCommonJS","import_navigation","import_react","import_utils","import_useClientLocale","router","useNextRouter","locale","useClientLocale","localize","href","args"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.3",
|
|
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.",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@formatjs/intl-localematcher": "^0.2.32",
|
|
67
67
|
"negotiator": "^0.6.3",
|
|
68
|
-
"use-intl": "^2.17.
|
|
68
|
+
"use-intl": "^2.17.3"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=10"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "1d79658f70c1c3bae47e25bf20ff98fdac782f2f"
|
|
93
93
|
}
|
package/src/client/useRouter.tsx
CHANGED
|
@@ -30,14 +30,14 @@ export default function useRouter() {
|
|
|
30
30
|
|
|
31
31
|
return {
|
|
32
32
|
...router,
|
|
33
|
-
push(href:
|
|
34
|
-
return router.push(localize(href));
|
|
33
|
+
push(...[href, ...args]: Parameters<typeof router.push>) {
|
|
34
|
+
return router.push(localize(href), ...args);
|
|
35
35
|
},
|
|
36
|
-
replace(href:
|
|
37
|
-
return router.replace(localize(href));
|
|
36
|
+
replace(...[href, ...args]: Parameters<typeof router.replace>) {
|
|
37
|
+
return router.replace(localize(href), ...args);
|
|
38
38
|
},
|
|
39
|
-
prefetch(href:
|
|
40
|
-
return router.prefetch(localize(href));
|
|
39
|
+
prefetch(...[href, ...args]: Parameters<typeof router.prefetch>) {
|
|
40
|
+
return router.prefetch(localize(href), ...args);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
}, [locale, router]);
|