next-intlayer 8.11.0 → 8.11.2
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/cjs/client/IntlayerClientProvider.cjs +0 -1
- package/dist/cjs/client/IntlayerClientProvider.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +0 -1
- package/dist/cjs/client/useLocale.cjs +0 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocalePageRouter.cjs +0 -1
- package/dist/cjs/client/useLocalePageRouter.cjs.map +1 -1
- package/dist/cjs/client/useRewriteURL.cjs +0 -1
- package/dist/cjs/generateStaticParams.cjs +0 -1
- package/dist/cjs/generateStaticParams.cjs.map +1 -1
- package/dist/cjs/index.cjs +0 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/proxy/intlayerProxy.cjs +0 -1
- package/dist/cjs/proxy/intlayerProxy.cjs.map +1 -1
- package/dist/cjs/proxy/localeDetector.cjs +0 -1
- package/dist/cjs/proxy/localeDetector.cjs.map +1 -1
- package/dist/cjs/proxy/multipleProxies.cjs +0 -1
- package/dist/cjs/proxy/multipleProxies.cjs.map +1 -1
- package/dist/cjs/server/getLocale.cjs +0 -1
- package/dist/cjs/server/getLocale.cjs.map +1 -1
- package/dist/cjs/server/index.cjs +0 -1
- package/dist/cjs/server/useDictionary.cjs +0 -1
- package/dist/cjs/server/useDictionary.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryAsync.cjs +0 -1
- package/dist/cjs/server/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/server/useDictionaryDynamic.cjs +0 -1
- package/dist/cjs/server/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/server/useIntlayer.cjs.map +1 -1
- package/dist/esm/server/useDictionary.mjs.map +1 -1
- package/dist/esm/server/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/server/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/server/useIntlayer.mjs.map +1 -1
- package/dist/types/generateStaticParams.d.ts +1 -3
- package/dist/types/generateStaticParams.d.ts.map +1 -1
- package/dist/types/index.d.ts +14 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts +1 -1
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +1 -1
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/dist/types/types/NextPage.d.ts +1 -1
- package/dist/types/types/NextPage.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
4
|
let react_intlayer = require("react-intlayer");
|
|
6
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
6
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerClientProvider.cjs","names":["IntlayerProvider"],"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport type { FC } from 'react';\n\nimport { IntlayerProvider, type IntlayerProviderProps } from 'react-intlayer';\n\nexport type IntlayerClientProviderProps = IntlayerProviderProps;\n\n/**\n * Provider for client-side components in Next.js.\n *\n * This component wraps the `IntlayerProvider` from `react-intlayer` and is intended\n * to be used within Next.js App Router client components.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { IntlayerClientProvider } from 'next-intlayer';\n *\n * export default function ClientLayout({ children, locale }) {\n * return (\n * <IntlayerClientProvider locale={locale}>\n * {children}\n * </IntlayerClientProvider>\n * );\n * }\n * ```\n */\nexport const IntlayerClientProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerProvider {...props} />\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerClientProvider.cjs","names":["IntlayerProvider"],"sources":["../../../src/client/IntlayerClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport type { FC } from 'react';\n\nimport { IntlayerProvider, type IntlayerProviderProps } from 'react-intlayer';\n\nexport type IntlayerClientProviderProps = IntlayerProviderProps;\n\n/**\n * Provider for client-side components in Next.js.\n *\n * This component wraps the `IntlayerProvider` from `react-intlayer` and is intended\n * to be used within Next.js App Router client components.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { IntlayerClientProvider } from 'next-intlayer';\n *\n * export default function ClientLayout({ children, locale }) {\n * return (\n * <IntlayerClientProvider locale={locale}>\n * {children}\n * </IntlayerClientProvider>\n * );\n * }\n * ```\n */\nexport const IntlayerClientProvider: FC<IntlayerProviderProps> = (props) => (\n <IntlayerProvider {...props} />\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,0BAAqD,UAChE,2CAACA,iCAAD,EAAkB,GAAI,MAAQ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
|
|
4
3
|
const require_client_useLocale = require('./useLocale.cjs');
|
|
5
4
|
const require_client_useLocalePageRouter = require('./useLocalePageRouter.cjs');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
4
|
let react_intlayer = require("react-intlayer");
|
|
6
5
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
7
6
|
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport {\n getLocalizedUrl,\n getPathWithoutLocale,\n} from '@intlayer/core/localization';\nimport { checkIsURLAbsolute } from '@intlayer/core/utils';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n type UseLocaleResult as UseLocaleResultReact,\n useLocale as useLocaleReact,\n} from 'react-intlayer';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n onChange?:\n | 'replace'\n | 'push'\n | 'none'\n | ((params: { locale: LocalesValues; path: string }) => void);\n};\n\nexport type UseLocaleResult = UseLocaleResultReact & {\n pathWithoutLocale: string;\n};\n\nconst usePathWithoutLocale = () => {\n const pathname = usePathname(); // updates on client navigations\n const [fullPath, setFullPath] = useState(pathname);\n\n useEffect(() => {\n // Runs only on client; avoids suspense.\n const search = typeof window !== 'undefined' ? window.location.search : '';\n setFullPath(search ? `${pathname}${search}` : pathname);\n }, [pathname]);\n\n // Your own helper\n return useMemo(() => getPathWithoutLocale(fullPath), [fullPath]);\n};\n\n/**\n * Hook to manage the current locale in Next.js App Router.\n *\n * This hook extends the base `useLocale` from `react-intlayer` by adding\n * Next.js-specific navigation logic for locale changes.\n *\n * @param props - Optional properties to configure locale change behavior.\n * @returns An object containing the current locale, path without locale, and functions to update the locale.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { useLocale } from 'next-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { setLocale } = useLocale({ onChange: 'push' });\n *\n * return (\n * <button onClick={() => setLocale('fr')}>Switch to French</button>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n onChange = 'replace',\n onLocaleChange,\n isCookieEnabled,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { replace, push } = useRouter();\n const pathWithoutLocale = usePathWithoutLocale();\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n if (!onChange) return;\n\n const currentDomain =\n process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' &&\n typeof window !== 'undefined'\n ? window.location.hostname\n : undefined;\n\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale, {\n currentDomain,\n });\n\n if (typeof onChange === 'function') {\n onChange({ locale, path: pathWithLocale });\n return;\n }\n\n // Cross-domain navigation: the Next.js router cannot navigate to a\n // different origin, so fall back to a full page load.\n if (\n process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' &&\n checkIsURLAbsolute(pathWithLocale)\n ) {\n try {\n const parsed = new URL(pathWithLocale);\n if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {\n window.location.href = pathWithLocale;\n }\n } catch {\n // Malformed URL — skip redirect\n }\n return;\n }\n\n if (onChange === 'replace') {\n replace(pathWithLocale);\n }\n if (onChange === 'push') {\n push(pathWithLocale);\n }\n\n onLocaleChange?.(locale as DeclaredLocales);\n },\n [replace, push, pathWithoutLocale, onChange, onLocaleChange]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n isCookieEnabled,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n } as UseLocaleResult;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport {\n getLocalizedUrl,\n getPathWithoutLocale,\n} from '@intlayer/core/localization';\nimport { checkIsURLAbsolute } from '@intlayer/core/utils';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport {\n type UseLocaleResult as UseLocaleResultReact,\n useLocale as useLocaleReact,\n} from 'react-intlayer';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n onChange?:\n | 'replace'\n | 'push'\n | 'none'\n | ((params: { locale: LocalesValues; path: string }) => void);\n};\n\nexport type UseLocaleResult = UseLocaleResultReact & {\n pathWithoutLocale: string;\n};\n\nconst usePathWithoutLocale = () => {\n const pathname = usePathname(); // updates on client navigations\n const [fullPath, setFullPath] = useState(pathname);\n\n useEffect(() => {\n // Runs only on client; avoids suspense.\n const search = typeof window !== 'undefined' ? window.location.search : '';\n setFullPath(search ? `${pathname}${search}` : pathname);\n }, [pathname]);\n\n // Your own helper\n return useMemo(() => getPathWithoutLocale(fullPath), [fullPath]);\n};\n\n/**\n * Hook to manage the current locale in Next.js App Router.\n *\n * This hook extends the base `useLocale` from `react-intlayer` by adding\n * Next.js-specific navigation logic for locale changes.\n *\n * @param props - Optional properties to configure locale change behavior.\n * @returns An object containing the current locale, path without locale, and functions to update the locale.\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { useLocale } from 'next-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { setLocale } = useLocale({ onChange: 'push' });\n *\n * return (\n * <button onClick={() => setLocale('fr')}>Switch to French</button>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n onChange = 'replace',\n onLocaleChange,\n isCookieEnabled,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { replace, push } = useRouter();\n const pathWithoutLocale = usePathWithoutLocale();\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n if (!onChange) return;\n\n const currentDomain =\n process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' &&\n typeof window !== 'undefined'\n ? window.location.hostname\n : undefined;\n\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale, {\n currentDomain,\n });\n\n if (typeof onChange === 'function') {\n onChange({ locale, path: pathWithLocale });\n return;\n }\n\n // Cross-domain navigation: the Next.js router cannot navigate to a\n // different origin, so fall back to a full page load.\n if (\n process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' &&\n checkIsURLAbsolute(pathWithLocale)\n ) {\n try {\n const parsed = new URL(pathWithLocale);\n if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {\n window.location.href = pathWithLocale;\n }\n } catch {\n // Malformed URL — skip redirect\n }\n return;\n }\n\n if (onChange === 'replace') {\n replace(pathWithLocale);\n }\n if (onChange === 'push') {\n push(pathWithLocale);\n }\n\n onLocaleChange?.(locale as DeclaredLocales);\n },\n [replace, push, pathWithoutLocale, onChange, onLocaleChange]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n isCookieEnabled,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;AAgCA,MAAM,6BAA6B;CACjC,MAAM,+CAAuB;CAC7B,MAAM,CAAC,UAAU,mCAAwB,QAAQ;CAEjD,2BAAgB;EAEd,MAAM,SAAS,OAAO,WAAW,cAAc,OAAO,SAAS,SAAS;EACxE,YAAY,SAAS,GAAG,WAAW,WAAW,QAAQ;CACxD,GAAG,CAAC,QAAQ,CAAC;CAGb,sFAA0C,QAAQ,GAAG,CAAC,QAAQ,CAAC;AACjE;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,aAAa,EACxB,WAAW,WACX,gBACA,oBACkB,CAAC,MAAuB;CAC1C,MAAM,EAAE,SAAS,2CAAmB;CACpC,MAAM,oBAAoB,qBAAqB;CAuD/C,OAAO;EACL,iCANqC;GACrC,wCAhDC,WAA0B;IACzB,IAAI,CAAC,UAAU;IAQf,MAAM,kEAAiC,mBAAmB,QAAQ,EAChE,eANA,QAAQ,IAAI,gCAAgC,WAC5C,OAAO,WAAW,cACd,OAAO,SAAS,WAChB,OAIN,CAAC;IAED,IAAI,OAAO,aAAa,YAAY;KAClC,SAAS;MAAE;MAAQ,MAAM;KAAe,CAAC;KACzC;IACF;IAIA,IACE,QAAQ,IAAI,gCAAgC,wDACzB,cAAc,GACjC;KACA,IAAI;MACF,MAAM,SAAS,IAAI,IAAI,cAAc;MACrC,IAAI,OAAO,aAAa,WAAW,OAAO,aAAa,UACrD,OAAO,SAAS,OAAO;KAE3B,QAAQ,CAER;KACA;IACF;IAEA,IAAI,aAAa,WACf,QAAQ,cAAc;IAExB,IAAI,aAAa,QACf,KAAK,cAAc;IAGrB,iBAAiB,MAAyB;GAC5C,GACA;IAAC;IAAS;IAAM;IAAmB;IAAU;GAAc,CAIzB;GAClC;EACF,CAGmB;EACjB;CACF;AACF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
5
4
|
let react_intlayer = require("react-intlayer");
|
|
6
5
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
7
6
|
let react = require("react");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalePageRouter.cjs","names":[],"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport {\n getLocalizedUrl,\n getPathWithoutLocale,\n} from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\nimport type { UseLocaleProps, UseLocaleResult } from './useLocale';\n\n/**\n * Hook to manage the current locale in Next.js Page Router.\n *\n * This hook provides locale management functionality tailored for the Next.js Page Router,\n * handling redirections and page reloads upon locale changes.\n *\n * @returns An object containing the current locale, path without locale, and functions to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocalePageRouter } from 'next-intlayer';\n *\n * const MyComponent = () => {\n * const { setLocale } = useLocalePageRouter();\n *\n * return (\n * <button onClick={() => setLocale('fr')}>Switch to French</button>\n * );\n * };\n * ```\n */\nexport const useLocalePageRouter = ({\n onLocaleChange,\n isCookieEnabled,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { push, pathname, reload } = useRouter();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n onLocaleChange?.(locale as Locale);\n\n return reload();\n },\n [pathWithoutLocale, onLocaleChange, reload]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n isCookieEnabled,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n } as UseLocaleResult;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocalePageRouter.cjs","names":[],"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport {\n getLocalizedUrl,\n getPathWithoutLocale,\n} from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\nimport type { UseLocaleProps, UseLocaleResult } from './useLocale';\n\n/**\n * Hook to manage the current locale in Next.js Page Router.\n *\n * This hook provides locale management functionality tailored for the Next.js Page Router,\n * handling redirections and page reloads upon locale changes.\n *\n * @returns An object containing the current locale, path without locale, and functions to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocalePageRouter } from 'next-intlayer';\n *\n * const MyComponent = () => {\n * const { setLocale } = useLocalePageRouter();\n *\n * return (\n * <button onClick={() => setLocale('fr')}>Switch to French</button>\n * );\n * };\n * ```\n */\nexport const useLocalePageRouter = ({\n onLocaleChange,\n isCookieEnabled,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { push, pathname, reload } = useRouter();\n const pathWithoutLocale = useMemo(\n () => getPathWithoutLocale(pathname),\n [pathname]\n );\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n push(pathWithLocale);\n\n onLocaleChange?.(locale as Locale);\n\n return reload();\n },\n [pathWithoutLocale, onLocaleChange, reload]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n isCookieEnabled,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,uBAAuB,EAClC,gBACA,oBACkB,CAAC,MAAuB;CAC1C,MAAM,EAAE,MAAM,UAAU,yCAAqB;CAC7C,MAAM,mGACuB,QAAQ,GACnC,CAAC,QAAQ,CACX;CAoBA,OAAO;EACL,iCANqC;GACrC,wCAbC,WAA0B;IAGzB,sDAFuC,mBAAmB,MAExC,CAAC;IAEnB,iBAAiB,MAAgB;IAEjC,OAAO,OAAO;GAChB,GACA;IAAC;IAAmB;IAAgB;GAAM,CAIR;GAClC;EACF,CAGmB;EACjB;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateStaticParams.cjs","names":["internationalization"],"sources":["../../src/generateStaticParams.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\n\nconst { locales } = internationalization;\n\n/**\n * Generates static parameters for Next.js's dynamic routes based on the configured locales.\n *\n * This function is typically used in Next.js App Router for `generateStaticParams`\n * to ensure all supported locales are pre-rendered at build time.\n *\n * @returns An array of objects containing the `locale` parameter for each configured locale.\n *\n * @example\n * ```tsx\n * // app/[locale]/layout.tsx\n * export { generateStaticParams } from 'next-intlayer';\n *\n * export default async function RootLayout({ children, params }) {\n * // ...\n * }\n * ```\n */\nexport const generateStaticParams = () => locales.map((locale) => ({ locale }));\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"generateStaticParams.cjs","names":["internationalization"],"sources":["../../src/generateStaticParams.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\n\nconst { locales } = internationalization;\n\n/**\n * Generates static parameters for Next.js's dynamic routes based on the configured locales.\n *\n * This function is typically used in Next.js App Router for `generateStaticParams`\n * to ensure all supported locales are pre-rendered at build time.\n *\n * @returns An array of objects containing the `locale` parameter for each configured locale.\n *\n * @example\n * ```tsx\n * // app/[locale]/layout.tsx\n * export { generateStaticParams } from 'next-intlayer';\n *\n * export default async function RootLayout({ children, params }) {\n * // ...\n * }\n * ```\n */\nexport const generateStaticParams = () => locales.map((locale) => ({ locale }));\n"],"mappings":";;;;AAEA,MAAM,EAAE,YAAYA;;;;;;;;;;;;;;;;;;;AAoBpB,MAAa,6BAA6B,QAAQ,KAAK,YAAY,EAAE,OAAO,EAAE"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_IntlayerClientProvider = require('./client/IntlayerClientProvider.cjs');
|
|
4
3
|
const require_client_useLocale = require('./client/useLocale.cjs');
|
|
5
4
|
const require_client_useLocalePageRouter = require('./client/useLocalePageRouter.cjs');
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["_MarkdownProvider","_useMarkdownContext","_renderMarkdown","_useMarkdownRenderer","_MarkdownRenderer"],"sources":["../../src/index.ts"],"sourcesContent":["export {\n getDictionary,\n getIntlayer,\n IntlayerClientContext,\n type IntlayerNode,\n localeCookie,\n localeInStorage,\n setLocaleCookie,\n setLocaleInStorage,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useI18n,\n useIntl,\n useIntlayer,\n useLoadDynamic,\n useLocaleCookie,\n useLocaleStorage,\n} from 'react-intlayer';\nexport * from './client/index';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14LayoutIntlayer,\n Next14PageIntlayer,\n Next15LayoutIntlayer,\n Next15PageIntlayer,\n NextLayoutIntlayer,\n NextPageIntlayer,\n} from './types/index';\n\nimport type {\n MarkdownProviderOptions as _MarkdownProviderOptions,\n MarkdownRendererProps as _MarkdownRendererProps,\n RenderMarkdownProps as _RenderMarkdownProps,\n} from './markdown';\nimport {\n MarkdownProvider as _MarkdownProvider,\n MarkdownRenderer as _MarkdownRenderer,\n renderMarkdown as _renderMarkdown,\n useMarkdownContext as _useMarkdownContext,\n useMarkdownRenderer as _useMarkdownRenderer,\n} from './markdown';\n\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const MarkdownProvider = _MarkdownProvider;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const useMarkdownContext = _useMarkdownContext;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport type MarkdownProviderOptions = _MarkdownProviderOptions;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const renderMarkdown = _renderMarkdown;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const useMarkdownRenderer = _useMarkdownRenderer;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const MarkdownRenderer = _MarkdownRenderer;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport type RenderMarkdownProps = _RenderMarkdownProps;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport type MarkdownRendererProps = _MarkdownRendererProps;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["_MarkdownProvider","_useMarkdownContext","_renderMarkdown","_useMarkdownRenderer","_MarkdownRenderer"],"sources":["../../src/index.ts"],"sourcesContent":["export {\n getDictionary,\n getIntlayer,\n IntlayerClientContext,\n type IntlayerNode,\n localeCookie,\n localeInStorage,\n setLocaleCookie,\n setLocaleInStorage,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useI18n,\n useIntl,\n useIntlayer,\n useLoadDynamic,\n useLocaleCookie,\n useLocaleStorage,\n} from 'react-intlayer';\nexport * from './client/index';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14LayoutIntlayer,\n Next14PageIntlayer,\n Next15LayoutIntlayer,\n Next15PageIntlayer,\n NextLayoutIntlayer,\n NextPageIntlayer,\n} from './types/index';\n\nimport type {\n MarkdownProviderOptions as _MarkdownProviderOptions,\n MarkdownRendererProps as _MarkdownRendererProps,\n RenderMarkdownProps as _RenderMarkdownProps,\n} from './markdown';\nimport {\n MarkdownProvider as _MarkdownProvider,\n MarkdownRenderer as _MarkdownRenderer,\n renderMarkdown as _renderMarkdown,\n useMarkdownContext as _useMarkdownContext,\n useMarkdownRenderer as _useMarkdownRenderer,\n} from './markdown';\n\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const MarkdownProvider = _MarkdownProvider;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const useMarkdownContext = _useMarkdownContext;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport type MarkdownProviderOptions = _MarkdownProviderOptions;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const renderMarkdown = _renderMarkdown;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const useMarkdownRenderer = _useMarkdownRenderer;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport const MarkdownRenderer = _MarkdownRenderer;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport type RenderMarkdownProps = _RenderMarkdownProps;\n/**\n * @deprecated import from next-intlayer/markdown instead\n */\nexport type MarkdownRendererProps = _MarkdownRendererProps;\n"],"mappings":";;;;;;;;;;;;AAiDA,MAAa,2DAAmBA;;;;AAIhC,MAAa,6DAAqBC;;;;AAQlC,MAAa,yDAAiBC;;;;AAI9B,MAAa,8DAAsBC;;;;AAInC,MAAa,2DAAmBC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_proxy_localeDetector = require('./localeDetector.cjs');
|
|
4
3
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
5
4
|
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerProxy.cjs","names":["internationalization","routing","ROUTING_MODE","NextResponse","localeDetector"],"sources":["../../../src/proxy/intlayerProxy.ts"],"sourcesContent":["import { internationalization, routing } from '@intlayer/config/built';\nimport { ROUTING_MODE } from '@intlayer/config/defaultValues';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\nimport {\n getCanonicalPath,\n getLocalizedPath,\n getRewriteRules,\n} from '@intlayer/core/localization';\nimport {\n getLocaleFromStorageServer,\n setLocaleInStorageServer,\n} from '@intlayer/core/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\nimport { localeDetector } from './localeDetector';\n\n/**\n * Controls whether locale detection occurs during Next.js prefetch requests\n * - true: Detect and apply locale during prefetch\n * - false: Use default locale during prefetch (recommended)\n *\n * This setting affects how Next.js handles locale prefetching:\n *\n * Example scenario:\n * - User's browser language is 'fr'\n * - Current page is /fr/about\n * - Link prefetches /about\n *\n * With `detectLocaleOnPrefetchNoPrefix:true`\n * - Prefetch detects 'fr' locale from browser\n * - Redirects prefetch to /fr/about\n *\n * With `detectLocaleOnPrefetchNoPrefix:false` (default)\n * - Prefetch uses default locale\n * - Redirects prefetch to /en/about (assuming 'en' is default)\n *\n * When to use true:\n * - Your app uses non-localized internal links (e.g. <a href=\"/about\">)\n * - You want consistent locale detection behavior between regular and prefetch requests\n *\n * When to use false (default):\n * - Your app uses locale-prefixed links (e.g. <a href=\"/fr/about\">)\n * - You want to optimize prefetching performance\n * - You want to avoid potential redirect loops\n */\nconst DEFAULT_DETECT_LOCALE_ON_PREFETCH_NO_PREFIX = false;\n\nconst { locales, defaultLocale } = internationalization ?? {};\nconst { basePath, mode, rewrite, domains } = routing ?? {};\n\n// Note: cookie names are resolved inside LocaleStorage based on configuration\n\n// Derived flags from routing.mode\nconst effectiveMode = mode ?? ROUTING_MODE;\nconst noPrefix =\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'no-prefix'\n ) &&\n effectiveMode === 'no-prefix') ||\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params'\n ) &&\n effectiveMode === 'search-params');\nconst prefixDefault =\n !(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'prefix-all' &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'prefix-no-default'\n ) && effectiveMode === 'prefix-all';\n\nconst internalPrefix = !noPrefix;\n\nconst rewriteRules =\n process.env['INTLAYER_ROUTING_REWRITE_RULES'] !== 'false'\n ? getRewriteRules(rewrite, 'url')\n : undefined;\n\n/**\n * Strips the protocol from a domain string and returns only the hostname.\n * e.g. 'https://intlayer.zh' → 'intlayer.zh', 'intlayer.zh' → 'intlayer.zh'\n */\nconst normalizeDomainHostname = (domain: string): string => {\n try {\n return /^https?:\\/\\//.test(domain) ? new URL(domain).hostname : domain;\n } catch {\n return domain;\n }\n};\n\n/**\n * Returns the locale exclusively mapped to a given hostname via `routing.domains`,\n * or undefined if zero or more than one locale share that hostname.\n *\n * Example: with domains = { zh: 'intlayer.zh', fr: 'intlayer.org' }\n * getLocaleFromDomain('intlayer.zh') → 'zh'\n * getLocaleFromDomain('intlayer.org') → undefined (multiple locales share it)\n */\nconst getLocaleFromDomain = (hostname: string): Locale | undefined => {\n if (!domains) return undefined;\n const matching = Object.entries(domains).filter(\n ([, domain]) => normalizeDomainHostname(domain!) === hostname\n );\n return matching.length === 1 ? (matching[0][0] as Locale) : undefined;\n};\n\n/**\n * Detects if the request is a prefetch request from Next.js.\n *\n * Next.js prefetch requests can be identified by several headers:\n * - purpose: 'prefetch' (standard prefetch header)\n * - next-router-prefetch: '1' (Next.js router prefetch)\n * - next-url: present (Next.js internal navigation)\n *\n * During prefetch, we should ignore cookie-based locale detection\n * to prevent unwanted redirects when users are switching locales.\n *\n * @param request - The incoming Next.js request object.\n * @returns - True if the request is a prefetch request, false otherwise.\n */\nconst isPrefetchRequest = (request: NextRequest): boolean => {\n const purpose = request.headers.get('purpose');\n const nextRouterPrefetch = request.headers.get('next-router-prefetch');\n const nextUrl = request.headers.get('next-url');\n const xNextjsData = request.headers.get('x-nextjs-data');\n\n return (\n purpose === 'prefetch' ||\n nextRouterPrefetch === '1' ||\n !!nextUrl ||\n !!xNextjsData\n );\n};\n\n// Ensure locale is reflected in search params when routing mode is 'search-params'\nconst appendLocaleSearchIfNeeded = (\n search: string | undefined,\n locale: Locale\n): string | undefined => {\n if (\n (process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params') ||\n effectiveMode !== 'search-params'\n )\n return search;\n const params = new URLSearchParams(search ?? '');\n params.set('locale', locale);\n return `?${params.toString()}`;\n};\n\n/**\n * Proxy that handles the internationalization layer\n *\n * Usage:\n *\n * ```ts\n * // ./src/proxy.ts\n *\n * export { intlayerProxy as proxy } from '@intlayer/next/proxy';\n *\n * // applies this proxy only to files in the app directory\n * export const config = {\n * matcher: '/((?!api|static|.*\\\\..*|_next).*)',\n * };\n * ```\n *\n * Main proxy function for handling internationalization.\n *\n * @param request - The incoming Next.js request object.\n * @param event - The Next.js fetch event (optional).\n * @param response - The Next.js response object (optional).\n * @returns - The response to be returned to the client.\n */\nexport const intlayerProxy = (\n request: NextRequest,\n _event?: NextFetchEvent,\n _response?: NextResponse\n): NextResponse => {\n const pathname = request.nextUrl.pathname;\n\n const localLocale = getLocalLocale(request);\n\n if (noPrefix) {\n return handleNoPrefix(request, localLocale, pathname);\n }\n\n const pathLocale = getPathLocale(pathname);\n\n // Domain routing: if the path locale is mapped to a different domain, redirect there.\n // e.g. intlayer.org/zh/about → https://intlayer.zh/about\n if (\n process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' &&\n pathLocale &&\n domains\n ) {\n const localeDomain = domains[pathLocale];\n\n if (localeDomain) {\n const domainHost = normalizeDomainHostname(localeDomain);\n\n if (domainHost !== request.nextUrl.hostname) {\n const rawPath = pathname.slice(`/${pathLocale}`.length) || '/';\n const targetOrigin = /^https?:\\/\\//.test(localeDomain)\n ? localeDomain\n : `https://${localeDomain}`;\n\n return NextResponse.redirect(\n new URL(`${rawPath}${request.nextUrl.search}`, targetOrigin)\n );\n }\n }\n }\n\n // Domain routing: if the current hostname is exclusively mapped to one locale,\n // treat it as that locale's domain — no URL prefix needed.\n // e.g. intlayer.zh/about → internally rewrite to /zh/about\n if (process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' && !pathLocale) {\n const domainLocale = getLocaleFromDomain(request.nextUrl.hostname);\n\n if (domainLocale) {\n const canonicalPath = getCanonicalPath(\n pathname,\n domainLocale,\n rewriteRules\n );\n const internalPath = `/${domainLocale}${canonicalPath}`;\n\n return rewriteUrl(\n request,\n internalPath + (request.nextUrl.search ?? ''),\n domainLocale\n );\n }\n }\n\n return handlePrefix(request, localLocale, pathLocale, pathname);\n};\n\n/**\n * Retrieves the locale from the request cookies if available and valid.\n *\n * @param request - The incoming Next.js request object.\n * @returns - The locale found in the cookies, or undefined if not found or invalid.\n */\nconst getLocalLocale = (request: NextRequest): Locale | undefined =>\n getLocaleFromStorageServer({\n getCookie: (name: string) => request.cookies.get(name)?.value ?? null,\n getHeader: (name: string) => request.headers.get(name) ?? null,\n });\n\n/**\n * Handles the case where URLs do not have locale prefixes.\n */\nconst handleNoPrefix = (\n request: NextRequest,\n localLocale: Locale | undefined,\n pathname: string\n): NextResponse => {\n const pathLocale = getPathLocale(pathname);\n\n if (pathLocale) {\n const pathWithoutLocale = pathname.slice(`/${pathLocale}`.length) || '/';\n\n const canonicalPath = getCanonicalPath(\n pathWithoutLocale,\n pathLocale,\n rewriteRules\n );\n\n const search = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n pathLocale\n );\n\n const redirectPath = search\n ? `${canonicalPath}${search}`\n : `${canonicalPath}${request.nextUrl.search ?? ''}`;\n\n return redirectUrl(request, redirectPath);\n }\n\n if (\n !(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params'\n ) &&\n effectiveMode === 'search-params'\n ) {\n const existingSearchParams = new URLSearchParams(request.nextUrl.search);\n const existingLocale = existingSearchParams.get('locale');\n\n const isExistingValid = locales?.includes(existingLocale as Locale);\n\n let locale = (localLocale ??\n (isExistingValid ? (existingLocale as Locale) : undefined) ??\n localLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locale;\n\n if (!locales?.includes(locale as Locale)) {\n locale = defaultLocale as Locale;\n }\n\n const canonicalPath = getCanonicalPath(\n pathname,\n locale as Locale,\n rewriteRules\n );\n\n if (existingLocale === locale) {\n const internalPath = internalPrefix\n ? `/${locale}${canonicalPath}`\n : canonicalPath;\n const rewritePath = `${internalPath}${request.nextUrl.search ?? ''}`;\n return rewriteUrl(request, rewritePath, locale as Locale);\n }\n\n const search = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n locale as Locale\n );\n // Use original pathname for redirect to preserve user's URL input, just adding params\n const redirectPath = search\n ? `${pathname}${search}`\n : `${pathname}${request.nextUrl.search ?? ''}`;\n\n return redirectUrl(request, redirectPath);\n }\n\n // effectiveMode === 'no-prefix'\n let locale = (localLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locale;\n\n if (!locales?.includes(locale as Locale)) {\n locale = defaultLocale as Locale;\n }\n\n const canonicalPath = getCanonicalPath(\n pathname,\n locale as Locale,\n rewriteRules\n );\n\n const internalPath = internalPrefix\n ? `/${locale}${canonicalPath}`\n : canonicalPath;\n const search = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n locale as Locale\n );\n const rewritePath = search\n ? `${internalPath}${search}`\n : `${internalPath}${request.nextUrl.search ?? ''}`;\n\n return rewriteUrl(request, rewritePath, locale as Locale);\n};\n\n/**\n * Extracts the locale from the URL pathname if present.\n *\n * @param pathname - The pathname from the request URL.\n * @returns - The locale found in the pathname, or undefined if not found.\n */\nconst getPathLocale = (pathname: string): Locale | undefined =>\n (locales as Locale[]).find(\n (locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`\n );\n\n/**\n * Handles the case where URLs have locale prefixes.\n *\n * @param request - The incoming Next.js request object.\n * @param localLocale - The locale from the cookie.\n * @param pathLocale - The locale extracted from the pathname.\n * @param pathname - The pathname from the request URL.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The response to be returned to the client.\n */\nconst handlePrefix = (\n request: NextRequest,\n localLocale: Locale | undefined,\n pathLocale: Locale | undefined,\n pathname: string\n): NextResponse => {\n if (!pathLocale) {\n const isPrefetch = isPrefetchRequest(request);\n if (isPrefetch && !DEFAULT_DETECT_LOCALE_ON_PREFETCH_NO_PREFIX) {\n return handleMissingPathLocale(\n request,\n defaultLocale as Locale,\n pathname\n );\n }\n return handleMissingPathLocale(request, localLocale, pathname);\n }\n\n return handleExistingPathLocale(request, pathLocale, pathname);\n};\n\n/**\n * Handles requests where the locale is missing from the URL pathname.\n *\n * @param request - The incoming Next.js request object.\n * @param localLocale - The locale from the cookie.\n * @param pathname - The pathname from the request URL.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The response to be returned to the client.\n */\nconst handleMissingPathLocale = (\n request: NextRequest,\n localLocale: Locale | undefined,\n pathname: string\n): NextResponse => {\n let locale = (localLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locale;\n\n if (!(locales as Locale[]).includes(locale)) {\n locale = defaultLocale as Locale;\n }\n\n // Resolve to canonical path.\n // If user visits /a-propos (implied 'fr'), we resolve to /about\n const canonicalPath = getCanonicalPath(pathname, locale, rewriteRules);\n\n // Determine target localized path for redirection\n // /about + 'fr' -> /a-propos\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n locale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n\n const newPath = constructPath(\n locale,\n targetLocalizedPath,\n basePath as string,\n appendLocaleSearchIfNeeded(request.nextUrl.search, locale)\n );\n\n return prefixDefault || locale !== defaultLocale\n ? redirectUrl(request, newPath)\n : rewriteUrl(\n request,\n internalPrefix ? `/${locale}${canonicalPath}` : canonicalPath,\n locale\n ); // Rewrite must use Canonical\n};\n\n/**\n * Handles requests where the locale exists in the URL pathname.\n *\n * @param request - The incoming Next.js request object.\n * @param localLocale - The locale from the cookie.\n * @param pathLocale - The locale extracted from the pathname.\n * @param pathname - The pathname from the request URL.\n * @returns - The response to be returned to the client.\n */\nconst handleExistingPathLocale = (\n request: NextRequest,\n pathLocale: Locale,\n pathname: string\n): NextResponse => {\n const rawPath = pathname.slice(`/${pathLocale}`.length) || '/';\n\n // 1. Identify the Canonical Path (Internal Next.js path)\n // Ex: /a-propos (from URL) -> /about (Canonical)\n const canonicalPath = getCanonicalPath(rawPath, pathLocale, rewriteRules);\n\n // By skipping the forced localLocale check, we allow the explicit pathLocale\n // to take precedence, which correctly updates the header/cookie when navigating.\n\n // Rewrite Logic\n // We must rewrite to the Next.js internal structure: /[locale]/[canonicalPath]\n // Ex: Rewrite /fr/a-propos -> /fr/about\n\n // 2. Redirect to localized path if needed (Canonical -> Localized)\n // Ex: /fr/about -> /fr/a-propos\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n pathLocale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n const isRewritten =\n typeof targetLocalizedPathResult === 'string'\n ? false\n : targetLocalizedPathResult.isRewritten;\n\n if (isRewritten && targetLocalizedPath !== rawPath) {\n const newPath = constructPath(\n pathLocale,\n targetLocalizedPath,\n basePath as string,\n appendLocaleSearchIfNeeded(request.nextUrl.search, pathLocale)\n );\n return redirectUrl(request, newPath);\n }\n\n const internalUrl = internalPrefix\n ? `/${pathLocale}${canonicalPath}`\n : canonicalPath;\n\n // Only handle redirect if we are strictly managing default locale prefixing\n // Fix: pass `canonicalPath` (the path *without* the locale prefix, e.g. /pricing)\n // instead of `pathname` (the full path including prefix, e.g. /en/pricing).\n // Previously this caused an infinite redirect loop in prefix-no-default mode\n // because handleDefaultLocaleRedirect built the redirect target from its third\n // argument, which reproduced the same URL on every response.\n if (!prefixDefault && pathLocale === defaultLocale) {\n return handleDefaultLocaleRedirect(request, pathLocale, canonicalPath);\n }\n\n const search = request.nextUrl.search;\n return rewriteUrl(request, internalUrl + (search ?? ''), pathLocale);\n};\n\n/**\n * Handles the scenario where the locale in the cookie does not match the locale in the URL pathname.\n *\n * @param request - The incoming Next.js request object.\n * @param pathname - The pathname from the request URL.\n * @param pathLocale - The locale extracted from the pathname.\n * @param localLocale - The locale from the cookie.\n * @param basePath - The base path of the application.\n * @returns - The new URL path with the correct locale.\n */\n// Function handleCookieLocaleMismatch was removed because the URL locale should take precedence over the stored locale.\n\n/**\n * The key fix for 404s without [locale] folders\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locale,\n canonicalPath: string // Internal path (e.g. /about)\n): NextResponse => {\n if (!prefixDefault && pathLocale === defaultLocale) {\n // Redirect to remove prefix\n // We use canonicalPath because in no-prefix default mode, the URL is usually just the path\n // But wait, if we are in this function, the URL *has* a prefix.\n // We want to redirect to /about (localized for EN).\n\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n pathLocale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n\n // Construct path without prefix\n const basePathTrailingSlash = (basePath as string).endsWith('/');\n let finalPath = targetLocalizedPath;\n if (finalPath.startsWith('/')) finalPath = finalPath.slice(1);\n\n const fullPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${finalPath}`;\n\n const searchWithLocale = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n pathLocale\n );\n\n return redirectUrl(\n request,\n fullPath + (searchWithLocale ?? request.nextUrl.search ?? '')\n );\n }\n\n const searchWithLocale = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n pathLocale\n );\n\n // If no redirect needed, we rewrite to the internal canonical path\n const internalPath = internalPrefix\n ? `/${pathLocale}${canonicalPath}`\n : canonicalPath;\n\n const rewriteTarget = searchWithLocale\n ? `${internalPath}${searchWithLocale}`\n : `${internalPath}${request.nextUrl.search ?? ''}`;\n\n return rewriteUrl(request, rewriteTarget, pathLocale);\n};\n\n/**\n * Constructs a new path by combining the locale, path, basePath, and search parameters.\n *\n * @param locale - The locale to include in the path.\n * @param path - The original path from the request.\n * @param basePath - The base path of the application.\n * @param [search] - The query string from the request URL (optional).\n * @returns - The constructed new path.\n */\nconst constructPath = (\n locale: Locale,\n path: string,\n basePath: string,\n search?: string\n): string => {\n // Remove existing locale prefix from path if it was passed by mistake,\n // though we usually pass localized paths here now.\n const pathWithoutPrefix = path.startsWith(`/${locale}`)\n ? path.slice(`/${locale}`.length) || '/'\n : path;\n\n if (\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'no-prefix'\n ) &&\n effectiveMode === 'no-prefix') ||\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params'\n ) &&\n effectiveMode === 'search-params')\n ) {\n return `${pathWithoutPrefix}${search ? `?${search}` : ''}`;\n }\n\n // Prefix handling\n const pathWithLocalePrefix = path.startsWith(`/${locale}`)\n ? path\n : `${locale}${path.startsWith('/') ? '' : '/'}${path}`;\n\n const basePathTrailingSlash = basePath.endsWith('/');\n const newPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${pathWithLocalePrefix}`;\n\n // Clean double slashes\n const cleanPath = newPath.replace(/\\/+/g, '/');\n\n return cleanPath;\n};\n\n/**\n * This handles the internal path Next.js sees.\n * To support optional [locale] folders, we need to decide if we\n * keep the locale prefix or strip it.\n */\nconst rewriteUrl = (\n request: NextRequest,\n newPath: string,\n locale: Locale\n): NextResponse => {\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n const requestHeaders = new Headers(request.headers);\n setLocaleInStorageServer(locale, {\n setHeader: (name: string, value: string) => {\n requestHeaders.set(name, value);\n },\n });\n\n const targetUrl = new URL(pathWithSearch, request.url);\n\n // If the target URL is exactly the current request URL,\n // we just want to `next()` to avoid losing headers on a redundant rewrite.\n const response =\n targetUrl.href === request.nextUrl.href\n ? NextResponse.next({\n request: {\n headers: requestHeaders,\n },\n })\n : NextResponse.rewrite(targetUrl, {\n request: {\n headers: requestHeaders,\n },\n });\n\n setLocaleInStorageServer(locale, {\n setHeader: (name: string, value: string) => {\n response.headers.set(name, value);\n },\n });\n return response;\n};\n\n/**\n * Redirects the request to the new path.\n *\n * @param request - The incoming Next.js request object.\n * @param newPath - The new path to redirect to.\n * @returns - The redirect response.\n */\nconst redirectUrl = (request: NextRequest, newPath: string): NextResponse => {\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n const target = new URL(pathWithSearch, request.url);\n\n // Prevent open redirect: if the resolved origin differs from the request\n // origin, strip it back to a same-origin URL using only the path/search/hash.\n const safeTarget =\n target.origin === request.nextUrl.origin\n ? target\n : new URL(\n `${target.pathname}${target.search}${target.hash}`,\n request.url\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AS,GACE,IAAI,KAAK,MAAM,uBAGvC,QAAQ,QAAQ,GAE3B;AACjB;;;;;;AAOA,MAAM,cACJ,SACA,SACA,WACiB;CACjB,MAAM,SAAS,QAAQ,QAAQ;CAC/B,MAAM,iBACJ,UAAU,CAAC,QAAQ,SAAS,GAAG,IAAI,GAAG,UAAU,WAAW;CAE7D,MAAM,iBAAiB,IAAI,QAAQ,QAAQ,OAAO;CAClD,mDAAyB,QAAQ,EAC/B,YAAY,MAAc,UAAkB;EAC1C,eAAe,IAAI,MAAM,KAAK;CAChC,EACF,CAAC;CAED,MAAM,YAAY,IAAI,IAAI,gBAAgB,QAAQ,GAAG;CAIrD,MAAM,WACJ,UAAU,SAAS,QAAQ,QAAQ,OAC/BD,yBAAa,KAAK,EAChB,SAAS,EACP,SAAS,eACX,EACF,CAAC,IACDA,yBAAa,QAAQ,WAAW,EAC9B,SAAS,EACP,SAAS,eACX,EACF,CAAC;CAEP,mDAAyB,QAAQ,EAC/B,YAAY,MAAc,UAAkB;EAC1C,SAAS,QAAQ,IAAI,MAAM,KAAK;CAClC,EACF,CAAC;CACD,OAAO;AACT;;;;;;;;AASA,MAAM,eAAe,SAAsB,YAAkC;CAC3E,MAAM,SAAS,QAAQ,QAAQ;CAC/B,MAAM,iBACJ,UAAU,CAAC,QAAQ,SAAS,GAAG,IAAI,GAAG,UAAU,WAAW;CAE7D,MAAM,SAAS,IAAI,IAAI,gBAAgB,QAAQ,GAAG;CAIlD,MAAM,aACJ,OAAO,WAAW,QAAQ,QAAQ,SAC9B,SACA,IAAI,IACF,GAAG,OAAO,WAAW,OAAO,SAAS,OAAO,QAC5C,QAAQ,GACV;CAEN,OAAOA,yBAAa,SAAS,UAAU;AACzC"}
|
|
1
|
+
{"version":3,"file":"intlayerProxy.cjs","names":["internationalization","routing","ROUTING_MODE","NextResponse","localeDetector"],"sources":["../../../src/proxy/intlayerProxy.ts"],"sourcesContent":["import { internationalization, routing } from '@intlayer/config/built';\nimport { ROUTING_MODE } from '@intlayer/config/defaultValues';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\nimport {\n getCanonicalPath,\n getLocalizedPath,\n getRewriteRules,\n} from '@intlayer/core/localization';\nimport {\n getLocaleFromStorageServer,\n setLocaleInStorageServer,\n} from '@intlayer/core/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\nimport { localeDetector } from './localeDetector';\n\n/**\n * Controls whether locale detection occurs during Next.js prefetch requests\n * - true: Detect and apply locale during prefetch\n * - false: Use default locale during prefetch (recommended)\n *\n * This setting affects how Next.js handles locale prefetching:\n *\n * Example scenario:\n * - User's browser language is 'fr'\n * - Current page is /fr/about\n * - Link prefetches /about\n *\n * With `detectLocaleOnPrefetchNoPrefix:true`\n * - Prefetch detects 'fr' locale from browser\n * - Redirects prefetch to /fr/about\n *\n * With `detectLocaleOnPrefetchNoPrefix:false` (default)\n * - Prefetch uses default locale\n * - Redirects prefetch to /en/about (assuming 'en' is default)\n *\n * When to use true:\n * - Your app uses non-localized internal links (e.g. <a href=\"/about\">)\n * - You want consistent locale detection behavior between regular and prefetch requests\n *\n * When to use false (default):\n * - Your app uses locale-prefixed links (e.g. <a href=\"/fr/about\">)\n * - You want to optimize prefetching performance\n * - You want to avoid potential redirect loops\n */\nconst DEFAULT_DETECT_LOCALE_ON_PREFETCH_NO_PREFIX = false;\n\nconst { locales, defaultLocale } = internationalization ?? {};\nconst { basePath, mode, rewrite, domains } = routing ?? {};\n\n// Note: cookie names are resolved inside LocaleStorage based on configuration\n\n// Derived flags from routing.mode\nconst effectiveMode = mode ?? ROUTING_MODE;\nconst noPrefix =\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'no-prefix'\n ) &&\n effectiveMode === 'no-prefix') ||\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params'\n ) &&\n effectiveMode === 'search-params');\nconst prefixDefault =\n !(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'prefix-all' &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'prefix-no-default'\n ) && effectiveMode === 'prefix-all';\n\nconst internalPrefix = !noPrefix;\n\nconst rewriteRules =\n process.env['INTLAYER_ROUTING_REWRITE_RULES'] !== 'false'\n ? getRewriteRules(rewrite, 'url')\n : undefined;\n\n/**\n * Strips the protocol from a domain string and returns only the hostname.\n * e.g. 'https://intlayer.zh' → 'intlayer.zh', 'intlayer.zh' → 'intlayer.zh'\n */\nconst normalizeDomainHostname = (domain: string): string => {\n try {\n return /^https?:\\/\\//.test(domain) ? new URL(domain).hostname : domain;\n } catch {\n return domain;\n }\n};\n\n/**\n * Returns the locale exclusively mapped to a given hostname via `routing.domains`,\n * or undefined if zero or more than one locale share that hostname.\n *\n * Example: with domains = { zh: 'intlayer.zh', fr: 'intlayer.org' }\n * getLocaleFromDomain('intlayer.zh') → 'zh'\n * getLocaleFromDomain('intlayer.org') → undefined (multiple locales share it)\n */\nconst getLocaleFromDomain = (hostname: string): Locale | undefined => {\n if (!domains) return undefined;\n const matching = Object.entries(domains).filter(\n ([, domain]) => normalizeDomainHostname(domain!) === hostname\n );\n return matching.length === 1 ? (matching[0][0] as Locale) : undefined;\n};\n\n/**\n * Detects if the request is a prefetch request from Next.js.\n *\n * Next.js prefetch requests can be identified by several headers:\n * - purpose: 'prefetch' (standard prefetch header)\n * - next-router-prefetch: '1' (Next.js router prefetch)\n * - next-url: present (Next.js internal navigation)\n *\n * During prefetch, we should ignore cookie-based locale detection\n * to prevent unwanted redirects when users are switching locales.\n *\n * @param request - The incoming Next.js request object.\n * @returns - True if the request is a prefetch request, false otherwise.\n */\nconst isPrefetchRequest = (request: NextRequest): boolean => {\n const purpose = request.headers.get('purpose');\n const nextRouterPrefetch = request.headers.get('next-router-prefetch');\n const nextUrl = request.headers.get('next-url');\n const xNextjsData = request.headers.get('x-nextjs-data');\n\n return (\n purpose === 'prefetch' ||\n nextRouterPrefetch === '1' ||\n !!nextUrl ||\n !!xNextjsData\n );\n};\n\n// Ensure locale is reflected in search params when routing mode is 'search-params'\nconst appendLocaleSearchIfNeeded = (\n search: string | undefined,\n locale: Locale\n): string | undefined => {\n if (\n (process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params') ||\n effectiveMode !== 'search-params'\n )\n return search;\n const params = new URLSearchParams(search ?? '');\n params.set('locale', locale);\n return `?${params.toString()}`;\n};\n\n/**\n * Proxy that handles the internationalization layer\n *\n * Usage:\n *\n * ```ts\n * // ./src/proxy.ts\n *\n * export { intlayerProxy as proxy } from '@intlayer/next/proxy';\n *\n * // applies this proxy only to files in the app directory\n * export const config = {\n * matcher: '/((?!api|static|.*\\\\..*|_next).*)',\n * };\n * ```\n *\n * Main proxy function for handling internationalization.\n *\n * @param request - The incoming Next.js request object.\n * @param event - The Next.js fetch event (optional).\n * @param response - The Next.js response object (optional).\n * @returns - The response to be returned to the client.\n */\nexport const intlayerProxy = (\n request: NextRequest,\n _event?: NextFetchEvent,\n _response?: NextResponse\n): NextResponse => {\n const pathname = request.nextUrl.pathname;\n\n const localLocale = getLocalLocale(request);\n\n if (noPrefix) {\n return handleNoPrefix(request, localLocale, pathname);\n }\n\n const pathLocale = getPathLocale(pathname);\n\n // Domain routing: if the path locale is mapped to a different domain, redirect there.\n // e.g. intlayer.org/zh/about → https://intlayer.zh/about\n if (\n process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' &&\n pathLocale &&\n domains\n ) {\n const localeDomain = domains[pathLocale];\n\n if (localeDomain) {\n const domainHost = normalizeDomainHostname(localeDomain);\n\n if (domainHost !== request.nextUrl.hostname) {\n const rawPath = pathname.slice(`/${pathLocale}`.length) || '/';\n const targetOrigin = /^https?:\\/\\//.test(localeDomain)\n ? localeDomain\n : `https://${localeDomain}`;\n\n return NextResponse.redirect(\n new URL(`${rawPath}${request.nextUrl.search}`, targetOrigin)\n );\n }\n }\n }\n\n // Domain routing: if the current hostname is exclusively mapped to one locale,\n // treat it as that locale's domain — no URL prefix needed.\n // e.g. intlayer.zh/about → internally rewrite to /zh/about\n if (process.env['INTLAYER_ROUTING_DOMAINS'] !== 'false' && !pathLocale) {\n const domainLocale = getLocaleFromDomain(request.nextUrl.hostname);\n\n if (domainLocale) {\n const canonicalPath = getCanonicalPath(\n pathname,\n domainLocale,\n rewriteRules\n );\n const internalPath = `/${domainLocale}${canonicalPath}`;\n\n return rewriteUrl(\n request,\n internalPath + (request.nextUrl.search ?? ''),\n domainLocale\n );\n }\n }\n\n return handlePrefix(request, localLocale, pathLocale, pathname);\n};\n\n/**\n * Retrieves the locale from the request cookies if available and valid.\n *\n * @param request - The incoming Next.js request object.\n * @returns - The locale found in the cookies, or undefined if not found or invalid.\n */\nconst getLocalLocale = (request: NextRequest): Locale | undefined =>\n getLocaleFromStorageServer({\n getCookie: (name: string) => request.cookies.get(name)?.value ?? null,\n getHeader: (name: string) => request.headers.get(name) ?? null,\n });\n\n/**\n * Handles the case where URLs do not have locale prefixes.\n */\nconst handleNoPrefix = (\n request: NextRequest,\n localLocale: Locale | undefined,\n pathname: string\n): NextResponse => {\n const pathLocale = getPathLocale(pathname);\n\n if (pathLocale) {\n const pathWithoutLocale = pathname.slice(`/${pathLocale}`.length) || '/';\n\n const canonicalPath = getCanonicalPath(\n pathWithoutLocale,\n pathLocale,\n rewriteRules\n );\n\n const search = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n pathLocale\n );\n\n const redirectPath = search\n ? `${canonicalPath}${search}`\n : `${canonicalPath}${request.nextUrl.search ?? ''}`;\n\n return redirectUrl(request, redirectPath);\n }\n\n if (\n !(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params'\n ) &&\n effectiveMode === 'search-params'\n ) {\n const existingSearchParams = new URLSearchParams(request.nextUrl.search);\n const existingLocale = existingSearchParams.get('locale');\n\n const isExistingValid = locales?.includes(existingLocale as Locale);\n\n let locale = (localLocale ??\n (isExistingValid ? (existingLocale as Locale) : undefined) ??\n localLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locale;\n\n if (!locales?.includes(locale as Locale)) {\n locale = defaultLocale as Locale;\n }\n\n const canonicalPath = getCanonicalPath(\n pathname,\n locale as Locale,\n rewriteRules\n );\n\n if (existingLocale === locale) {\n const internalPath = internalPrefix\n ? `/${locale}${canonicalPath}`\n : canonicalPath;\n const rewritePath = `${internalPath}${request.nextUrl.search ?? ''}`;\n return rewriteUrl(request, rewritePath, locale as Locale);\n }\n\n const search = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n locale as Locale\n );\n // Use original pathname for redirect to preserve user's URL input, just adding params\n const redirectPath = search\n ? `${pathname}${search}`\n : `${pathname}${request.nextUrl.search ?? ''}`;\n\n return redirectUrl(request, redirectPath);\n }\n\n // effectiveMode === 'no-prefix'\n let locale = (localLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locale;\n\n if (!locales?.includes(locale as Locale)) {\n locale = defaultLocale as Locale;\n }\n\n const canonicalPath = getCanonicalPath(\n pathname,\n locale as Locale,\n rewriteRules\n );\n\n const internalPath = internalPrefix\n ? `/${locale}${canonicalPath}`\n : canonicalPath;\n const search = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n locale as Locale\n );\n const rewritePath = search\n ? `${internalPath}${search}`\n : `${internalPath}${request.nextUrl.search ?? ''}`;\n\n return rewriteUrl(request, rewritePath, locale as Locale);\n};\n\n/**\n * Extracts the locale from the URL pathname if present.\n *\n * @param pathname - The pathname from the request URL.\n * @returns - The locale found in the pathname, or undefined if not found.\n */\nconst getPathLocale = (pathname: string): Locale | undefined =>\n (locales as Locale[]).find(\n (locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}`\n );\n\n/**\n * Handles the case where URLs have locale prefixes.\n *\n * @param request - The incoming Next.js request object.\n * @param localLocale - The locale from the cookie.\n * @param pathLocale - The locale extracted from the pathname.\n * @param pathname - The pathname from the request URL.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The response to be returned to the client.\n */\nconst handlePrefix = (\n request: NextRequest,\n localLocale: Locale | undefined,\n pathLocale: Locale | undefined,\n pathname: string\n): NextResponse => {\n if (!pathLocale) {\n const isPrefetch = isPrefetchRequest(request);\n if (isPrefetch && !DEFAULT_DETECT_LOCALE_ON_PREFETCH_NO_PREFIX) {\n return handleMissingPathLocale(\n request,\n defaultLocale as Locale,\n pathname\n );\n }\n return handleMissingPathLocale(request, localLocale, pathname);\n }\n\n return handleExistingPathLocale(request, pathLocale, pathname);\n};\n\n/**\n * Handles requests where the locale is missing from the URL pathname.\n *\n * @param request - The incoming Next.js request object.\n * @param localLocale - The locale from the cookie.\n * @param pathname - The pathname from the request URL.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The response to be returned to the client.\n */\nconst handleMissingPathLocale = (\n request: NextRequest,\n localLocale: Locale | undefined,\n pathname: string\n): NextResponse => {\n let locale = (localLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locale;\n\n if (!(locales as Locale[]).includes(locale)) {\n locale = defaultLocale as Locale;\n }\n\n // Resolve to canonical path.\n // If user visits /a-propos (implied 'fr'), we resolve to /about\n const canonicalPath = getCanonicalPath(pathname, locale, rewriteRules);\n\n // Determine target localized path for redirection\n // /about + 'fr' -> /a-propos\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n locale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n\n const newPath = constructPath(\n locale,\n targetLocalizedPath,\n basePath as string,\n appendLocaleSearchIfNeeded(request.nextUrl.search, locale)\n );\n\n return prefixDefault || locale !== defaultLocale\n ? redirectUrl(request, newPath)\n : rewriteUrl(\n request,\n internalPrefix ? `/${locale}${canonicalPath}` : canonicalPath,\n locale\n ); // Rewrite must use Canonical\n};\n\n/**\n * Handles requests where the locale exists in the URL pathname.\n *\n * @param request - The incoming Next.js request object.\n * @param localLocale - The locale from the cookie.\n * @param pathLocale - The locale extracted from the pathname.\n * @param pathname - The pathname from the request URL.\n * @returns - The response to be returned to the client.\n */\nconst handleExistingPathLocale = (\n request: NextRequest,\n pathLocale: Locale,\n pathname: string\n): NextResponse => {\n const rawPath = pathname.slice(`/${pathLocale}`.length) || '/';\n\n // 1. Identify the Canonical Path (Internal Next.js path)\n // Ex: /a-propos (from URL) -> /about (Canonical)\n const canonicalPath = getCanonicalPath(rawPath, pathLocale, rewriteRules);\n\n // By skipping the forced localLocale check, we allow the explicit pathLocale\n // to take precedence, which correctly updates the header/cookie when navigating.\n\n // Rewrite Logic\n // We must rewrite to the Next.js internal structure: /[locale]/[canonicalPath]\n // Ex: Rewrite /fr/a-propos -> /fr/about\n\n // 2. Redirect to localized path if needed (Canonical -> Localized)\n // Ex: /fr/about -> /fr/a-propos\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n pathLocale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n const isRewritten =\n typeof targetLocalizedPathResult === 'string'\n ? false\n : targetLocalizedPathResult.isRewritten;\n\n if (isRewritten && targetLocalizedPath !== rawPath) {\n const newPath = constructPath(\n pathLocale,\n targetLocalizedPath,\n basePath as string,\n appendLocaleSearchIfNeeded(request.nextUrl.search, pathLocale)\n );\n return redirectUrl(request, newPath);\n }\n\n const internalUrl = internalPrefix\n ? `/${pathLocale}${canonicalPath}`\n : canonicalPath;\n\n // Only handle redirect if we are strictly managing default locale prefixing\n // Fix: pass `canonicalPath` (the path *without* the locale prefix, e.g. /pricing)\n // instead of `pathname` (the full path including prefix, e.g. /en/pricing).\n // Previously this caused an infinite redirect loop in prefix-no-default mode\n // because handleDefaultLocaleRedirect built the redirect target from its third\n // argument, which reproduced the same URL on every response.\n if (!prefixDefault && pathLocale === defaultLocale) {\n return handleDefaultLocaleRedirect(request, pathLocale, canonicalPath);\n }\n\n const search = request.nextUrl.search;\n return rewriteUrl(request, internalUrl + (search ?? ''), pathLocale);\n};\n\n/**\n * Handles the scenario where the locale in the cookie does not match the locale in the URL pathname.\n *\n * @param request - The incoming Next.js request object.\n * @param pathname - The pathname from the request URL.\n * @param pathLocale - The locale extracted from the pathname.\n * @param localLocale - The locale from the cookie.\n * @param basePath - The base path of the application.\n * @returns - The new URL path with the correct locale.\n */\n// Function handleCookieLocaleMismatch was removed because the URL locale should take precedence over the stored locale.\n\n/**\n * The key fix for 404s without [locale] folders\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locale,\n canonicalPath: string // Internal path (e.g. /about)\n): NextResponse => {\n if (!prefixDefault && pathLocale === defaultLocale) {\n // Redirect to remove prefix\n // We use canonicalPath because in no-prefix default mode, the URL is usually just the path\n // But wait, if we are in this function, the URL *has* a prefix.\n // We want to redirect to /about (localized for EN).\n\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n pathLocale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n\n // Construct path without prefix\n const basePathTrailingSlash = (basePath as string).endsWith('/');\n let finalPath = targetLocalizedPath;\n if (finalPath.startsWith('/')) finalPath = finalPath.slice(1);\n\n const fullPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${finalPath}`;\n\n const searchWithLocale = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n pathLocale\n );\n\n return redirectUrl(\n request,\n fullPath + (searchWithLocale ?? request.nextUrl.search ?? '')\n );\n }\n\n const searchWithLocale = appendLocaleSearchIfNeeded(\n request.nextUrl.search,\n pathLocale\n );\n\n // If no redirect needed, we rewrite to the internal canonical path\n const internalPath = internalPrefix\n ? `/${pathLocale}${canonicalPath}`\n : canonicalPath;\n\n const rewriteTarget = searchWithLocale\n ? `${internalPath}${searchWithLocale}`\n : `${internalPath}${request.nextUrl.search ?? ''}`;\n\n return rewriteUrl(request, rewriteTarget, pathLocale);\n};\n\n/**\n * Constructs a new path by combining the locale, path, basePath, and search parameters.\n *\n * @param locale - The locale to include in the path.\n * @param path - The original path from the request.\n * @param basePath - The base path of the application.\n * @param [search] - The query string from the request URL (optional).\n * @returns - The constructed new path.\n */\nconst constructPath = (\n locale: Locale,\n path: string,\n basePath: string,\n search?: string\n): string => {\n // Remove existing locale prefix from path if it was passed by mistake,\n // though we usually pass localized paths here now.\n const pathWithoutPrefix = path.startsWith(`/${locale}`)\n ? path.slice(`/${locale}`.length) || '/'\n : path;\n\n if (\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'no-prefix'\n ) &&\n effectiveMode === 'no-prefix') ||\n (!(\n process.env['INTLAYER_ROUTING_MODE'] &&\n process.env['INTLAYER_ROUTING_MODE'] !== 'search-params'\n ) &&\n effectiveMode === 'search-params')\n ) {\n return `${pathWithoutPrefix}${search ? `?${search}` : ''}`;\n }\n\n // Prefix handling\n const pathWithLocalePrefix = path.startsWith(`/${locale}`)\n ? path\n : `${locale}${path.startsWith('/') ? '' : '/'}${path}`;\n\n const basePathTrailingSlash = basePath.endsWith('/');\n const newPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${pathWithLocalePrefix}`;\n\n // Clean double slashes\n const cleanPath = newPath.replace(/\\/+/g, '/');\n\n return cleanPath;\n};\n\n/**\n * This handles the internal path Next.js sees.\n * To support optional [locale] folders, we need to decide if we\n * keep the locale prefix or strip it.\n */\nconst rewriteUrl = (\n request: NextRequest,\n newPath: string,\n locale: Locale\n): NextResponse => {\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n const requestHeaders = new Headers(request.headers);\n setLocaleInStorageServer(locale, {\n setHeader: (name: string, value: string) => {\n requestHeaders.set(name, value);\n },\n });\n\n const targetUrl = new URL(pathWithSearch, request.url);\n\n // If the target URL is exactly the current request URL,\n // we just want to `next()` to avoid losing headers on a redundant rewrite.\n const response =\n targetUrl.href === request.nextUrl.href\n ? NextResponse.next({\n request: {\n headers: requestHeaders,\n },\n })\n : NextResponse.rewrite(targetUrl, {\n request: {\n headers: requestHeaders,\n },\n });\n\n setLocaleInStorageServer(locale, {\n setHeader: (name: string, value: string) => {\n response.headers.set(name, value);\n },\n });\n return response;\n};\n\n/**\n * Redirects the request to the new path.\n *\n * @param request - The incoming Next.js request object.\n * @param newPath - The new path to redirect to.\n * @returns - The redirect response.\n */\nconst redirectUrl = (request: NextRequest, newPath: string): NextResponse => {\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n const target = new URL(pathWithSearch, request.url);\n\n // Prevent open redirect: if the resolved origin differs from the request\n // origin, strip it back to a same-origin URL using only the path/search/hash.\n const safeTarget =\n target.origin === request.nextUrl.origin\n ? target\n : new URL(\n `${target.pathname}${target.search}${target.hash}`,\n request.url\n );\n\n return NextResponse.redirect(safeTarget);\n};\n"],"mappings":";;;;;;;;;AAuDA,MAAM,EAAE,SAAS,kBAAkBA,+CAAwB,CAAC;AAC5D,MAAM,EAAE,UAAU,MAAM,SAAS,YAAYC,kCAAW,CAAC;AAKzD,MAAM,gBAAgB,QAAQC;AAC9B,MAAM,WACH,EACC,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BAA6B,gBAEzC,kBAAkB,eACnB,EACC,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BAA6B,oBAEzC,kBAAkB;AACtB,MAAM,gBACJ,EACE,QAAQ,IAAI,4BACZ,QAAQ,IAAI,6BAA6B,gBACzC,QAAQ,IAAI,6BAA6B,wBACtC,kBAAkB;AAEzB,MAAM,iBAAiB,CAAC;AAExB,MAAM,eACJ,QAAQ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,CAAC,IACDA,yBAAa,QAAQ,WAAW,EAC9B,SAAS,EACP,SAAS,eACX,EACF,CAAC;CAEP,mDAAyB,QAAQ,EAC/B,YAAY,MAAc,UAAkB;EAC1C,SAAS,QAAQ,IAAI,MAAM,KAAK;CAClC,EACF,CAAC;CACD,OAAO;AACT;;;;;;;;AASA,MAAM,eAAe,SAAsB,YAAkC;CAC3E,MAAM,SAAS,QAAQ,QAAQ;CAC/B,MAAM,iBACJ,UAAU,CAAC,QAAQ,SAAS,GAAG,IAAI,GAAG,UAAU,WAAW;CAE7D,MAAM,SAAS,IAAI,IAAI,gBAAgB,QAAQ,GAAG;CAIlD,MAAM,aACJ,OAAO,WAAW,QAAQ,QAAQ,SAC9B,SACA,IAAI,IACF,GAAG,OAAO,WAAW,OAAO,SAAS,OAAO,QAC5C,QAAQ,GACV;CAEN,OAAOA,yBAAa,SAAS,UAAU;AACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localeDetector.cjs","names":[],"sources":["../../../src/proxy/localeDetector.ts"],"sourcesContent":["import { localeDetector as localeDetectorCore } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { NextRequest } from 'next/server.js';\n\n/**\n * Detects the locale from the request headers\n *\n * Headers are provided by the browser and can be used to determine the user's preferred language\n */\nexport const localeDetector = (request: NextRequest): LocalesValues => {\n const negotiatorHeaders: Record<string, string> = {};\n\n request.headers.forEach((value, key) => {\n negotiatorHeaders[key] = value;\n });\n\n const locale = localeDetectorCore(negotiatorHeaders);\n\n return locale;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"localeDetector.cjs","names":[],"sources":["../../../src/proxy/localeDetector.ts"],"sourcesContent":["import { localeDetector as localeDetectorCore } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { NextRequest } from 'next/server.js';\n\n/**\n * Detects the locale from the request headers\n *\n * Headers are provided by the browser and can be used to determine the user's preferred language\n */\nexport const localeDetector = (request: NextRequest): LocalesValues => {\n const negotiatorHeaders: Record<string, string> = {};\n\n request.headers.forEach((value, key) => {\n negotiatorHeaders[key] = value;\n });\n\n const locale = localeDetectorCore(negotiatorHeaders);\n\n return locale;\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,kBAAkB,YAAwC;CACrE,MAAM,oBAA4C,CAAC;CAEnD,QAAQ,QAAQ,SAAS,OAAO,QAAQ;EACtC,kBAAkB,OAAO;CAC3B,CAAC;CAID,uDAFkC,iBAEtB;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipleProxies.cjs","names":["NextResponse"],"sources":["../../../src/proxy/multipleProxies.ts"],"sourcesContent":["import {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\n\n/**\n * Utility to combine multiple Next.js proxies into one.\n *\n * It executes proxies in order, passing each result as the `response` argument\n * to the next proxy. Routing instructions (redirects / rewrites) and custom\n * response headers are merged across the entire chain, so a later proxy that\n * returns `NextResponse.next()` does not accidentally discard a rewrite set by\n * an earlier proxy.\n *\n * @example\n * import { multipleProxies, intlayerProxy } from \"next-intlayer/proxy\";\n * import { NextResponse } from \"next/server\";\n *\n * const authMiddleware = (req: NextRequest) => {\n * if (!req.cookies.get(\"token\")) {\n * return NextResponse.redirect(new URL(\"/login\", req.url));\n * }\n * return NextResponse.next();\n * };\n *\n * export default multipleProxies([\n * intlayerProxy,\n * authMiddleware,\n * ]);\n *\n * @param proxies - An array of proxy functions to execute in order.\n * @returns A single proxy function that runs all provided proxies.\n */\nexport const multipleProxies =\n (\n proxies: ((\n req: NextRequest,\n event?: NextFetchEvent,\n response?: NextResponse\n ) => NextResponse | Promise<NextResponse>)[]\n ) =>\n async (req: NextRequest, event?: NextFetchEvent, response?: NextResponse) => {\n // Snapshots of each proxy's response headers, collected in order.\n const proxyHeaders: Headers[] = [];\n let finalStatus = 200;\n let redirectLocation: string | null = null;\n\n // Each proxy receives the previous proxy's result so it can inspect or\n // augment it. Start with the caller-supplied response (or a plain next()).\n let currentResponse: NextResponse = response ?? NextResponse.next();\n\n for (const proxy of proxies) {\n const result = await proxy(req, event, currentResponse);\n\n // Bail immediately on server errors.\n if (result.status >= 500) {\n return result;\n }\n\n // Track the strongest redirect in the chain.\n if (result.status >= 300 && result.status < 400) {\n finalStatus = result.status;\n const location = result.headers.get('location');\n if (location) redirectLocation = location;\n }\n\n // Snapshot headers *now* to avoid later mutations to the same object\n // corrupting already-recorded entries from earlier proxies.\n proxyHeaders.push(new Headers(result.headers));\n currentResponse = result;\n }\n\n // ── Merge all collected headers ───────────────────────────────────────────\n\n // mergedHeaders: response headers visible to the browser / Next.js routing.\n const mergedHeaders = new Headers();\n // transmittedHeaders: request headers forwarded to the next route handler.\n const transmittedHeaders = new Headers(req.headers);\n\n proxyHeaders.forEach((headers) => {\n for (const [key, value] of headers.entries()) {\n // Routing headers must not be concatenated — last writer wins.\n if (\n key === 'x-middleware-rewrite' ||\n key === 'x-middleware-request-redirect'\n ) {\n mergedHeaders.set(key, value);\n } else {\n mergedHeaders.append(key, value);\n }\n\n // x-middleware-request-<name> → forwarded as <name> to route handlers.\n if (key.startsWith('x-middleware-request-')) {\n const stripped = key.slice('x-middleware-request-'.length);\n transmittedHeaders.set(stripped, value);\n }\n }\n });\n\n // ── Construct the final response ──────────────────────────────────────────\n\n const redirectHeader = mergedHeaders.get('x-middleware-request-redirect');\n const rewriteHeader = mergedHeaders.get('x-middleware-rewrite');\n\n let finalResponse: NextResponse;\n\n if (redirectHeader || redirectLocation) {\n const rawRedirect = (redirectHeader ?? redirectLocation) as string;\n const target = new URL(rawRedirect, req.url);\n // Prevent open redirect: strip to same-origin path/search/hash if the\n // resolved origin differs from the request origin.\n const safeTarget =\n target.origin === req.nextUrl.origin\n ? target\n : new URL(\n `${target.pathname}${target.search}${target.hash}`,\n req.url\n );\n\n finalResponse = NextResponse.redirect(safeTarget, {\n status: finalStatus >= 300 ? finalStatus : 307,\n });\n } else if (rewriteHeader) {\n finalResponse = NextResponse.rewrite(new URL(rewriteHeader, req.url), {\n request: { headers: transmittedHeaders },\n });\n } else {\n finalResponse = NextResponse.next({\n request: { headers: transmittedHeaders },\n });\n }\n\n // Copy all accumulated custom response headers onto the final response,\n // skipping internal Next.js routing headers (already handled above).\n mergedHeaders.forEach((value, key) => {\n if (\n key !== 'x-middleware-rewrite' &&\n key !== 'x-middleware-request-redirect' &&\n !key.startsWith('x-middleware-request-') &&\n key !== 'location'\n ) {\n finalResponse.headers.set(key, value);\n }\n });\n\n return finalResponse;\n };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"multipleProxies.cjs","names":["NextResponse"],"sources":["../../../src/proxy/multipleProxies.ts"],"sourcesContent":["import {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\n\n/**\n * Utility to combine multiple Next.js proxies into one.\n *\n * It executes proxies in order, passing each result as the `response` argument\n * to the next proxy. Routing instructions (redirects / rewrites) and custom\n * response headers are merged across the entire chain, so a later proxy that\n * returns `NextResponse.next()` does not accidentally discard a rewrite set by\n * an earlier proxy.\n *\n * @example\n * import { multipleProxies, intlayerProxy } from \"next-intlayer/proxy\";\n * import { NextResponse } from \"next/server\";\n *\n * const authMiddleware = (req: NextRequest) => {\n * if (!req.cookies.get(\"token\")) {\n * return NextResponse.redirect(new URL(\"/login\", req.url));\n * }\n * return NextResponse.next();\n * };\n *\n * export default multipleProxies([\n * intlayerProxy,\n * authMiddleware,\n * ]);\n *\n * @param proxies - An array of proxy functions to execute in order.\n * @returns A single proxy function that runs all provided proxies.\n */\nexport const multipleProxies =\n (\n proxies: ((\n req: NextRequest,\n event?: NextFetchEvent,\n response?: NextResponse\n ) => NextResponse | Promise<NextResponse>)[]\n ) =>\n async (req: NextRequest, event?: NextFetchEvent, response?: NextResponse) => {\n // Snapshots of each proxy's response headers, collected in order.\n const proxyHeaders: Headers[] = [];\n let finalStatus = 200;\n let redirectLocation: string | null = null;\n\n // Each proxy receives the previous proxy's result so it can inspect or\n // augment it. Start with the caller-supplied response (or a plain next()).\n let currentResponse: NextResponse = response ?? NextResponse.next();\n\n for (const proxy of proxies) {\n const result = await proxy(req, event, currentResponse);\n\n // Bail immediately on server errors.\n if (result.status >= 500) {\n return result;\n }\n\n // Track the strongest redirect in the chain.\n if (result.status >= 300 && result.status < 400) {\n finalStatus = result.status;\n const location = result.headers.get('location');\n if (location) redirectLocation = location;\n }\n\n // Snapshot headers *now* to avoid later mutations to the same object\n // corrupting already-recorded entries from earlier proxies.\n proxyHeaders.push(new Headers(result.headers));\n currentResponse = result;\n }\n\n // ── Merge all collected headers ───────────────────────────────────────────\n\n // mergedHeaders: response headers visible to the browser / Next.js routing.\n const mergedHeaders = new Headers();\n // transmittedHeaders: request headers forwarded to the next route handler.\n const transmittedHeaders = new Headers(req.headers);\n\n proxyHeaders.forEach((headers) => {\n for (const [key, value] of headers.entries()) {\n // Routing headers must not be concatenated — last writer wins.\n if (\n key === 'x-middleware-rewrite' ||\n key === 'x-middleware-request-redirect'\n ) {\n mergedHeaders.set(key, value);\n } else {\n mergedHeaders.append(key, value);\n }\n\n // x-middleware-request-<name> → forwarded as <name> to route handlers.\n if (key.startsWith('x-middleware-request-')) {\n const stripped = key.slice('x-middleware-request-'.length);\n transmittedHeaders.set(stripped, value);\n }\n }\n });\n\n // ── Construct the final response ──────────────────────────────────────────\n\n const redirectHeader = mergedHeaders.get('x-middleware-request-redirect');\n const rewriteHeader = mergedHeaders.get('x-middleware-rewrite');\n\n let finalResponse: NextResponse;\n\n if (redirectHeader || redirectLocation) {\n const rawRedirect = (redirectHeader ?? redirectLocation) as string;\n const target = new URL(rawRedirect, req.url);\n // Prevent open redirect: strip to same-origin path/search/hash if the\n // resolved origin differs from the request origin.\n const safeTarget =\n target.origin === req.nextUrl.origin\n ? target\n : new URL(\n `${target.pathname}${target.search}${target.hash}`,\n req.url\n );\n\n finalResponse = NextResponse.redirect(safeTarget, {\n status: finalStatus >= 300 ? finalStatus : 307,\n });\n } else if (rewriteHeader) {\n finalResponse = NextResponse.rewrite(new URL(rewriteHeader, req.url), {\n request: { headers: transmittedHeaders },\n });\n } else {\n finalResponse = NextResponse.next({\n request: { headers: transmittedHeaders },\n });\n }\n\n // Copy all accumulated custom response headers onto the final response,\n // skipping internal Next.js routing headers (already handled above).\n mergedHeaders.forEach((value, key) => {\n if (\n key !== 'x-middleware-rewrite' &&\n key !== 'x-middleware-request-redirect' &&\n !key.startsWith('x-middleware-request-') &&\n key !== 'location'\n ) {\n finalResponse.headers.set(key, value);\n }\n });\n\n return finalResponse;\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,mBAET,YAMF,OAAO,KAAkB,OAAwB,aAA4B;CAE3E,MAAM,eAA0B,CAAC;CACjC,IAAI,cAAc;CAClB,IAAI,mBAAkC;CAItC,IAAI,kBAAgC,YAAYA,yBAAa,KAAK;CAElE,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,SAAS,MAAM,MAAM,KAAK,OAAO,eAAe;EAGtD,IAAI,OAAO,UAAU,KACnB,OAAO;EAIT,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,KAAK;GAC/C,cAAc,OAAO;GACrB,MAAM,WAAW,OAAO,QAAQ,IAAI,UAAU;GAC9C,IAAI,UAAU,mBAAmB;EACnC;EAIA,aAAa,KAAK,IAAI,QAAQ,OAAO,OAAO,CAAC;EAC7C,kBAAkB;CACpB;CAKA,MAAM,gBAAgB,IAAI,QAAQ;CAElC,MAAM,qBAAqB,IAAI,QAAQ,IAAI,OAAO;CAElD,aAAa,SAAS,YAAY;EAChC,KAAK,MAAM,CAAC,KAAK,UAAU,QAAQ,QAAQ,GAAG;GAE5C,IACE,QAAQ,0BACR,QAAQ,iCAER,cAAc,IAAI,KAAK,KAAK;QAE5B,cAAc,OAAO,KAAK,KAAK;GAIjC,IAAI,IAAI,WAAW,uBAAuB,GAAG;IAC3C,MAAM,WAAW,IAAI,MAAM,EAA8B;IACzD,mBAAmB,IAAI,UAAU,KAAK;GACxC;EACF;CACF,CAAC;CAID,MAAM,iBAAiB,cAAc,IAAI,+BAA+B;CACxE,MAAM,gBAAgB,cAAc,IAAI,sBAAsB;CAE9D,IAAI;CAEJ,IAAI,kBAAkB,kBAAkB;EAEtC,MAAM,SAAS,IAAI,IADE,kBAAkB,kBACH,IAAI,GAAG;EAG3C,MAAM,aACJ,OAAO,WAAW,IAAI,QAAQ,SAC1B,SACA,IAAI,IACF,GAAG,OAAO,WAAW,OAAO,SAAS,OAAO,QAC5C,IAAI,GACN;EAEN,gBAAgBA,yBAAa,SAAS,YAAY,EAChD,QAAQ,eAAe,MAAM,cAAc,IAC7C,CAAC;CACH,OAAO,IAAI,eACT,gBAAgBA,yBAAa,QAAQ,IAAI,IAAI,eAAe,IAAI,GAAG,GAAG,EACpE,SAAS,EAAE,SAAS,mBAAmB,EACzC,CAAC;MAED,gBAAgBA,yBAAa,KAAK,EAChC,SAAS,EAAE,SAAS,mBAAmB,EACzC,CAAC;CAKH,cAAc,SAAS,OAAO,QAAQ;EACpC,IACE,QAAQ,0BACR,QAAQ,mCACR,CAAC,IAAI,WAAW,uBAAuB,KACvC,QAAQ,YAER,cAAc,QAAQ,IAAI,KAAK,KAAK;CAExC,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
4
3
|
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
5
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLocale.cjs","names":["internationalization","DEFAULT_LOCALE"],"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { DEFAULT_LOCALE } from '@intlayer/config/defaultValues';\nimport { localeDetector } from '@intlayer/core/localization';\nimport { getLocaleFromStorageServer } from '@intlayer/core/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { cookies, headers } from 'next/headers.js';\n\n// Helper function to extract locale from headers/cookies\n/**\n * Helper function to extract the current locale from Next.js headers and cookies.\n *\n * This function is designed to be used in Server Components, Server Actions, or Route Handlers\n * to determine the locale preferred by the user or stored in their preferences.\n *\n * @returns A promise that resolves to the detected `Locale`.\n *\n * @example\n * ```tsx\n * import { getLocale } from 'next-intlayer/server';\n *\n * export default async function MyServerComponent() {\n * const locale = await getLocale();\n * // ...\n * }\n * ```\n */\nexport const getLocale = async (): Promise<Locale> => {\n const defaultLocale = internationalization?.defaultLocale ?? DEFAULT_LOCALE;\n\n // Try locale from header\n const headersList = await headers();\n const cookiesList = await cookies();\n\n const storedLocale = getLocaleFromStorageServer({\n getCookie: (name: string) => cookiesList.get(name)?.value ?? null,\n getHeader: (name: string) => headersList.get(name) ?? null,\n });\n\n if (storedLocale) return storedLocale as Locale;\n\n // Fallback to Accept-Language negotiation\n const negotiatorHeaders: Record<string, string> = {};\n headersList.forEach((value, key) => {\n negotiatorHeaders[key] = value;\n });\n\n const userFallbackLocale = localeDetector(negotiatorHeaders);\n if (userFallbackLocale) return userFallbackLocale as Locale;\n\n // Default locale\n return defaultLocale;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLocale.cjs","names":["internationalization","DEFAULT_LOCALE"],"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { DEFAULT_LOCALE } from '@intlayer/config/defaultValues';\nimport { localeDetector } from '@intlayer/core/localization';\nimport { getLocaleFromStorageServer } from '@intlayer/core/utils';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { cookies, headers } from 'next/headers.js';\n\n// Helper function to extract locale from headers/cookies\n/**\n * Helper function to extract the current locale from Next.js headers and cookies.\n *\n * This function is designed to be used in Server Components, Server Actions, or Route Handlers\n * to determine the locale preferred by the user or stored in their preferences.\n *\n * @returns A promise that resolves to the detected `Locale`.\n *\n * @example\n * ```tsx\n * import { getLocale } from 'next-intlayer/server';\n *\n * export default async function MyServerComponent() {\n * const locale = await getLocale();\n * // ...\n * }\n * ```\n */\nexport const getLocale = async (): Promise<Locale> => {\n const defaultLocale = internationalization?.defaultLocale ?? DEFAULT_LOCALE;\n\n // Try locale from header\n const headersList = await headers();\n const cookiesList = await cookies();\n\n const storedLocale = getLocaleFromStorageServer({\n getCookie: (name: string) => cookiesList.get(name)?.value ?? null,\n getHeader: (name: string) => headersList.get(name) ?? null,\n });\n\n if (storedLocale) return storedLocale as Locale;\n\n // Fallback to Accept-Language negotiation\n const negotiatorHeaders: Record<string, string> = {};\n headersList.forEach((value, key) => {\n negotiatorHeaders[key] = value;\n });\n\n const userFallbackLocale = localeDetector(negotiatorHeaders);\n if (userFallbackLocale) return userFallbackLocale as Locale;\n\n // Default locale\n return defaultLocale;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,YAAY,YAA6B;CACpD,MAAM,gBAAgBA,6CAAsB,iBAAiBC;CAG7D,MAAM,cAAc,mCAAc;CAClC,MAAM,cAAc,mCAAc;CAElC,MAAM,oEAA0C;EAC9C,YAAY,SAAiB,YAAY,IAAI,IAAI,GAAG,SAAS;EAC7D,YAAY,SAAiB,YAAY,IAAI,IAAI,KAAK;CACxD,CAAC;CAED,IAAI,cAAc,OAAO;CAGzB,MAAM,oBAA4C,CAAC;CACnD,YAAY,SAAS,OAAO,QAAQ;EAClC,kBAAkB,OAAO;CAC3B,CAAC;CAED,MAAM,qEAAoC,iBAAiB;CAC3D,IAAI,oBAAoB,OAAO;CAG/B,OAAO;AACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_server_getLocale = require('./getLocale.cjs');
|
|
4
3
|
const require_server_withIntlayer = require('./withIntlayer.cjs');
|
|
5
4
|
let react_intlayer_server = require("react-intlayer/server");
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_server_useIntlayer = require('./useIntlayer.cjs');
|
|
4
3
|
let react_intlayer_server = require("react-intlayer/server");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["safeUseLocale"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useDictionary as useDictionaryBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): ReturnType<typeof useDictionaryBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryBase<T, L>(dictionary, locale, storedLocale);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["safeUseLocale"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useDictionary as useDictionaryBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): ReturnType<typeof useDictionaryBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryBase<T, L>(dictionary, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;;;AAUA,MAAa,iBAIX,YACA,WAC+C;CAG/C,gDAA+B,YAAY,QAFtBA,yCAEyC,CAAC;AACjE"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_server_getLocale = require('./getLocale.cjs');
|
|
4
3
|
let react_intlayer_server = require("react-intlayer/server");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.cjs","names":["getLocale"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryAsync as useDictionaryAsyncBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n T extends Dictionary,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): ReturnType<typeof useDictionaryAsyncBase<T, L>> => {\n const storedLocale = await getLocale();\n\n return useDictionaryAsyncBase<T, L>(dictionaryPromise, locale, storedLocale);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.cjs","names":["getLocale"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryAsync as useDictionaryAsyncBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n const T extends Dictionary,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): ReturnType<typeof useDictionaryAsyncBase<T, L>> => {\n const storedLocale = await getLocale();\n\n return useDictionaryAsyncBase<T, L>(dictionaryPromise, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;;;AAaA,MAAa,qBAAqB,OAIhC,mBACA,WACoD;CAGpD,qDAAoC,mBAAmB,QAAQ,MAFpCA,mCAAU,CAEsC;AAC7E"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_server_useIntlayer = require('./useIntlayer.cjs');
|
|
4
3
|
let react_intlayer_server = require("react-intlayer/server");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["safeUseLocale"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryDynamic as useDictionaryDynamicBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L\n): ReturnType<typeof useDictionaryDynamicBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryDynamicBase<T, L>(\n dictionaryPromise,\n key,\n locale,\n storedLocale\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["safeUseLocale"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryDynamic as useDictionaryDynamicBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L\n): ReturnType<typeof useDictionaryDynamicBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryDynamicBase<T, L>(\n dictionaryPromise,\n key,\n locale,\n storedLocale\n );\n};\n"],"mappings":";;;;;;;;;;AAaA,MAAa,wBAIX,mBACA,KACA,WACsD;CAGtD,uDACE,mBACA,KACA,QALmBA,yCAMR,CACb;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["React","getLocale"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n} from '@intlayer/types/module_augmentation';\nimport React from 'react';\nimport { useIntlayer as useIntlayerBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\nconst getCachedLocale =\n typeof React.cache === 'function' ? React.cache(getLocale) : getLocale;\n\nexport const safeUseLocale = (): Locale | undefined => {\n // getLocale returns a Promise based on your TS error\n const localeData = getCachedLocale() as Promise<Locale> | Locale;\n\n if (localeData instanceof Promise) {\n if (typeof React.use === 'function') {\n return React.use(localeData); // Safely unwraps in React 19+\n }\n\n // React < 19 cannot synchronously unwrap Promises in hooks.\n // Return undefined to trigger the localeTarget fallback.\n return undefined;\n }\n\n return localeData;\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): ReturnType<typeof useIntlayerBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useIntlayerBase<T, L>(key, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;AASA,MAAM,kBACJ,OAAOA,cAAM,UAAU,aAAaA,cAAM,MAAMC,kCAAS,IAAIA;AAE/D,MAAa,sBAA0C;CAErD,MAAM,aAAa,gBAAgB;CAEnC,IAAI,sBAAsB,SAAS;EACjC,IAAI,OAAOD,cAAM,QAAQ,YACvB,OAAOA,cAAM,IAAI,UAAU;EAK7B;CACF;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,eAIX,KACA,WAC6C;CAG7C,8CAA6B,KAAK,QAFb,cAEgC,CAAC;AACxD"}
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["React","getLocale"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n} from '@intlayer/types/module_augmentation';\nimport React from 'react';\nimport { useIntlayer as useIntlayerBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\nconst getCachedLocale =\n typeof React.cache === 'function' ? React.cache(getLocale) : getLocale;\n\nexport const safeUseLocale = (): Locale | undefined => {\n // getLocale returns a Promise based on your TS error\n const localeData = getCachedLocale() as Promise<Locale> | Locale;\n\n if (localeData instanceof Promise) {\n if (typeof React.use === 'function') {\n return React.use(localeData); // Safely unwraps in React 19+\n }\n\n // React < 19 cannot synchronously unwrap Promises in hooks.\n // Return undefined to trigger the localeTarget fallback.\n return undefined;\n }\n\n return localeData;\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): ReturnType<typeof useIntlayerBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useIntlayerBase<T, L>(key, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;AASA,MAAM,kBACJ,OAAOA,cAAM,UAAU,aAAaA,cAAM,MAAMC,kCAAS,IAAIA;AAE/D,MAAa,sBAA0C;CAErD,MAAM,aAAa,gBAAgB;CAEnC,IAAI,sBAAsB,SAAS;EACjC,IAAI,OAAOD,cAAM,QAAQ,YACvB,OAAOA,cAAM,IAAI,UAAU;EAK7B;CACF;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,eAIX,KACA,WAC6C;CAG7C,8CAA6B,KAAK,QAFb,cAEgC,CAAC;AACxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":["useDictionaryBase"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useDictionary as useDictionaryBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): ReturnType<typeof useDictionaryBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryBase<T, L>(dictionary, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,iBAIX,YACA,WAC+C;CAG/C,OAAOA,gBAAwB,YAAY,QAFtB,cAEyC,CAAC;AACjE"}
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":["useDictionaryBase"],"sources":["../../../src/server/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales } from '@intlayer/types/module_augmentation';\nimport { useDictionary as useDictionaryBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): ReturnType<typeof useDictionaryBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryBase<T, L>(dictionary, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,iBAIX,YACA,WAC+C;CAG/C,OAAOA,gBAAwB,YAAY,QAFtB,cAEyC,CAAC;AACjE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.mjs","names":["useDictionaryAsyncBase"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryAsync as useDictionaryAsyncBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n T extends Dictionary,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): ReturnType<typeof useDictionaryAsyncBase<T, L>> => {\n const storedLocale = await getLocale();\n\n return useDictionaryAsyncBase<T, L>(dictionaryPromise, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;;AAaA,MAAa,qBAAqB,OAIhC,mBACA,WACoD;CAGpD,OAAOA,qBAA6B,mBAAmB,QAAQ,MAFpC,UAAU,CAEsC;AAC7E"}
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.mjs","names":["useDictionaryAsyncBase"],"sources":["../../../src/server/useDictionaryAsync.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryAsync as useDictionaryAsyncBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryAsync = async <\n const T extends Dictionary,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: L\n): ReturnType<typeof useDictionaryAsyncBase<T, L>> => {\n const storedLocale = await getLocale();\n\n return useDictionaryAsyncBase<T, L>(dictionaryPromise, locale, storedLocale);\n};\n"],"mappings":";;;;;;;;;AAaA,MAAa,qBAAqB,OAIhC,mBACA,WACoD;CAGpD,OAAOA,qBAA6B,mBAAmB,QAAQ,MAFpC,UAAU,CAEsC;AAC7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":["useDictionaryDynamicBase"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryDynamic as useDictionaryDynamicBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L\n): ReturnType<typeof useDictionaryDynamicBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryDynamicBase<T, L>(\n dictionaryPromise,\n key,\n locale,\n storedLocale\n );\n};\n"],"mappings":";;;;;;;;;AAaA,MAAa,wBAIX,mBACA,KACA,WACsD;CAGtD,OAAOA,uBACL,mBACA,KACA,QALmB,cAMR,CACb;AACF"}
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":["useDictionaryDynamicBase"],"sources":["../../../src/server/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useDictionaryDynamic as useDictionaryDynamicBase } from 'react-intlayer/server';\nimport { safeUseLocale } from './useIntlayer';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: string,\n locale?: L\n): ReturnType<typeof useDictionaryDynamicBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useDictionaryDynamicBase<T, L>(\n dictionaryPromise,\n key,\n locale,\n storedLocale\n );\n};\n"],"mappings":";;;;;;;;;AAaA,MAAa,wBAIX,mBACA,KACA,WACsD;CAGtD,OAAOA,uBACL,mBACA,KACA,QALmB,cAMR,CACb;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":["useIntlayerBase"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n} from '@intlayer/types/module_augmentation';\nimport React from 'react';\nimport { useIntlayer as useIntlayerBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\nconst getCachedLocale =\n typeof React.cache === 'function' ? React.cache(getLocale) : getLocale;\n\nexport const safeUseLocale = (): Locale | undefined => {\n // getLocale returns a Promise based on your TS error\n const localeData = getCachedLocale() as Promise<Locale> | Locale;\n\n if (localeData instanceof Promise) {\n if (typeof React.use === 'function') {\n return React.use(localeData); // Safely unwraps in React 19+\n }\n\n // React < 19 cannot synchronously unwrap Promises in hooks.\n // Return undefined to trigger the localeTarget fallback.\n return undefined;\n }\n\n return localeData;\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n T extends DictionaryKeys,\n L extends DeclaredLocales = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): ReturnType<typeof useIntlayerBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useIntlayerBase<T, L>(key, locale, storedLocale);\n};\n"],"mappings":";;;;;AASA,MAAM,kBACJ,OAAO,MAAM,UAAU,aAAa,MAAM,MAAM,SAAS,IAAI;AAE/D,MAAa,sBAA0C;CAErD,MAAM,aAAa,gBAAgB;CAEnC,IAAI,sBAAsB,SAAS;EACjC,IAAI,OAAO,MAAM,QAAQ,YACvB,OAAO,MAAM,IAAI,UAAU;EAK7B;CACF;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,eAIX,KACA,WAC6C;CAG7C,OAAOA,cAAsB,KAAK,QAFb,cAEgC,CAAC;AACxD"}
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":["useIntlayerBase"],"sources":["../../../src/server/useIntlayer.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n} from '@intlayer/types/module_augmentation';\nimport React from 'react';\nimport { useIntlayer as useIntlayerBase } from 'react-intlayer/server';\nimport { getLocale } from './getLocale';\n\nconst getCachedLocale =\n typeof React.cache === 'function' ? React.cache(getLocale) : getLocale;\n\nexport const safeUseLocale = (): Locale | undefined => {\n // getLocale returns a Promise based on your TS error\n const localeData = getCachedLocale() as Promise<Locale> | Locale;\n\n if (localeData instanceof Promise) {\n if (typeof React.use === 'function') {\n return React.use(localeData); // Safely unwraps in React 19+\n }\n\n // React < 19 cannot synchronously unwrap Promises in hooks.\n // Return undefined to trigger the localeTarget fallback.\n return undefined;\n }\n\n return localeData;\n};\n\n/**\n * On the server side, Hook that picking one dictionary by its key and return the content\n *\n * If the locale is not provided, it will use the locale from the server context\n */\nexport const useIntlayer = <\n const T extends DictionaryKeys,\n const L extends DeclaredLocales = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): ReturnType<typeof useIntlayerBase<T, L>> => {\n const storedLocale = safeUseLocale();\n\n return useIntlayerBase<T, L>(key, locale, storedLocale);\n};\n"],"mappings":";;;;;AASA,MAAM,kBACJ,OAAO,MAAM,UAAU,aAAa,MAAM,MAAM,SAAS,IAAI;AAE/D,MAAa,sBAA0C;CAErD,MAAM,aAAa,gBAAgB;CAEnC,IAAI,sBAAsB,SAAS;EACjC,IAAI,OAAO,MAAM,QAAQ,YACvB,OAAO,MAAM,IAAI,UAAU;EAK7B;CACF;CAEA,OAAO;AACT;;;;;;AAOA,MAAa,eAIX,KACA,WAC6C;CAG7C,OAAOA,cAAsB,KAAK,QAFb,cAEgC,CAAC;AACxD"}
|
|
@@ -17,9 +17,7 @@
|
|
|
17
17
|
* }
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
declare const generateStaticParams: () =>
|
|
21
|
-
locale: import("@intlayer/types").Locale;
|
|
22
|
-
}[];
|
|
20
|
+
declare const generateStaticParams: () => any;
|
|
23
21
|
//#endregion
|
|
24
22
|
export { generateStaticParams };
|
|
25
23
|
//# sourceMappingURL=generateStaticParams.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateStaticParams.d.ts","names":[],"sources":["../../src/generateStaticParams.ts"],"mappings":";;AAsBA
|
|
1
|
+
{"version":3,"file":"generateStaticParams.d.ts","names":[],"sources":["../../src/generateStaticParams.ts"],"mappings":";;AAsBA;;;;AAA+E;;;;;;;;;;;;;cAAlE,oBAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -14,9 +14,6 @@ import { IntlayerClientContext, IntlayerNode, getDictionary, getIntlayer, locale
|
|
|
14
14
|
declare const MarkdownProvider: import("react").FC<index_d_exports.MarkdownProviderOptions & {
|
|
15
15
|
components?: {} & {
|
|
16
16
|
object?: import("react").FC<import("react").DetailedHTMLProps<import("react").ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
17
|
-
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
18
|
-
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
19
|
-
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
20
17
|
html?: import("react").FC<import("react").DetailedHTMLProps<import("react").HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
21
18
|
head?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
22
19
|
body?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -70,6 +67,8 @@ declare const MarkdownProvider: import("react").FC<index_d_exports.MarkdownProvi
|
|
|
70
67
|
thead?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
71
68
|
tbody?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
72
69
|
tfoot?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
70
|
+
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
71
|
+
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
73
72
|
td?: import("react").FC<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
74
73
|
caption?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
75
74
|
colgroup?: import("react").FC<import("react").DetailedHTMLProps<import("react").ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -104,6 +103,7 @@ declare const MarkdownProvider: import("react").FC<index_d_exports.MarkdownProvi
|
|
|
104
103
|
summary?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
105
104
|
dialog?: import("react").FC<import("react").DetailedHTMLProps<import("react").DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
106
105
|
br?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
106
|
+
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
107
107
|
wbr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
108
108
|
ruby?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
109
109
|
rt?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -119,9 +119,6 @@ declare const MarkdownProvider: import("react").FC<index_d_exports.MarkdownProvi
|
|
|
119
119
|
wrapper?: import("react").FC<import("react").HTMLAttributes<HTMLElement>>;
|
|
120
120
|
renderMarkdown?: (markdown: string, options?: index_d_exports.MarkdownProviderOptions, components?: {} & {
|
|
121
121
|
object?: import("react").FC<import("react").DetailedHTMLProps<import("react").ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
122
|
-
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
123
|
-
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
124
|
-
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
125
122
|
html?: import("react").FC<import("react").DetailedHTMLProps<import("react").HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
126
123
|
head?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
127
124
|
body?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -175,6 +172,8 @@ declare const MarkdownProvider: import("react").FC<index_d_exports.MarkdownProvi
|
|
|
175
172
|
thead?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
176
173
|
tbody?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
177
174
|
tfoot?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
175
|
+
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
176
|
+
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
178
177
|
td?: import("react").FC<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
179
178
|
caption?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
180
179
|
colgroup?: import("react").FC<import("react").DetailedHTMLProps<import("react").ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -209,6 +208,7 @@ declare const MarkdownProvider: import("react").FC<index_d_exports.MarkdownProvi
|
|
|
209
208
|
summary?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
210
209
|
dialog?: import("react").FC<import("react").DetailedHTMLProps<import("react").DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
211
210
|
br?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
211
|
+
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
212
212
|
wbr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
213
213
|
ruby?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
214
214
|
rt?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -230,9 +230,6 @@ declare const MarkdownProvider: import("react").FC<index_d_exports.MarkdownProvi
|
|
|
230
230
|
declare const useMarkdownContext: () => {
|
|
231
231
|
components?: {} & {
|
|
232
232
|
object?: import("react").FC<import("react").DetailedHTMLProps<import("react").ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
233
|
-
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
234
|
-
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
235
|
-
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
236
233
|
html?: import("react").FC<import("react").DetailedHTMLProps<import("react").HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
237
234
|
head?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
238
235
|
body?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -286,6 +283,8 @@ declare const useMarkdownContext: () => {
|
|
|
286
283
|
thead?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
287
284
|
tbody?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
288
285
|
tfoot?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
286
|
+
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
287
|
+
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
289
288
|
td?: import("react").FC<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
290
289
|
caption?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
291
290
|
colgroup?: import("react").FC<import("react").DetailedHTMLProps<import("react").ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -320,6 +319,7 @@ declare const useMarkdownContext: () => {
|
|
|
320
319
|
summary?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
321
320
|
dialog?: import("react").FC<import("react").DetailedHTMLProps<import("react").DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
322
321
|
br?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
322
|
+
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
323
323
|
wbr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
324
324
|
ruby?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
325
325
|
rt?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -334,9 +334,6 @@ declare const useMarkdownContext: () => {
|
|
|
334
334
|
};
|
|
335
335
|
renderMarkdown: (markdown: string, options?: index_d_exports.MarkdownProviderOptions, components?: {} & {
|
|
336
336
|
object?: import("react").FC<import("react").DetailedHTMLProps<import("react").ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
337
|
-
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
338
|
-
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
339
|
-
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
340
337
|
html?: import("react").FC<import("react").DetailedHTMLProps<import("react").HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
341
338
|
head?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
342
339
|
body?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -390,6 +387,8 @@ declare const useMarkdownContext: () => {
|
|
|
390
387
|
thead?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
391
388
|
tbody?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
392
389
|
tfoot?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
390
|
+
tr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
391
|
+
th?: import("react").FC<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
393
392
|
td?: import("react").FC<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
394
393
|
caption?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
395
394
|
colgroup?: import("react").FC<import("react").DetailedHTMLProps<import("react").ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -424,6 +423,7 @@ declare const useMarkdownContext: () => {
|
|
|
424
423
|
summary?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
425
424
|
dialog?: import("react").FC<import("react").DetailedHTMLProps<import("react").DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
426
425
|
br?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
426
|
+
hr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
427
427
|
wbr?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
428
428
|
ruby?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
429
429
|
rt?: import("react").FC<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -444,7 +444,7 @@ type MarkdownProviderOptions = index_d_exports.MarkdownProviderOptions;
|
|
|
444
444
|
/**
|
|
445
445
|
* @deprecated import from next-intlayer/markdown instead
|
|
446
446
|
*/
|
|
447
|
-
declare const renderMarkdown: (content: string, {
|
|
447
|
+
declare const renderMarkdown: (content: string | import("react-intlayer/markdown").ParsedMarkdown, {
|
|
448
448
|
components,
|
|
449
449
|
wrapper,
|
|
450
450
|
forceBlock,
|
|
@@ -462,7 +462,7 @@ declare const useMarkdownRenderer: ({
|
|
|
462
462
|
forceInline,
|
|
463
463
|
preserveFrontmatter,
|
|
464
464
|
tagfilter
|
|
465
|
-
}?: index_d_exports.RenderMarkdownProps) => (content: string) => string | number | bigint | boolean | import("react").
|
|
465
|
+
}?: index_d_exports.RenderMarkdownProps) => (content: string | import("react-intlayer/markdown").ParsedMarkdown) => string | number | bigint | boolean | Iterable<import("react").ReactNode> | Promise<import("react").ReactNode> | import("react").JSX.Element;
|
|
466
466
|
/**
|
|
467
467
|
* @deprecated import from next-intlayer/markdown instead
|
|
468
468
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/index.ts"],"mappings":";;;;;;;;;;;;;cAiDa,gBAAA,kBAAgB,EAAA,CAAA,eAAA,CAAA,uBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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+8,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
8
8
|
*
|
|
9
9
|
* If the locale is not provided, it will use the locale from the server context
|
|
10
10
|
*/
|
|
11
|
-
declare const useDictionary: <T extends Dictionary, L extends DeclaredLocales = DeclaredLocales>(dictionary: T, locale?: L) => ReturnType<typeof useDictionary$1<T, L>>;
|
|
11
|
+
declare const useDictionary: <const T extends Dictionary, const L extends DeclaredLocales = DeclaredLocales>(dictionary: T, locale?: L) => ReturnType<typeof useDictionary$1<T, L>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { useDictionary };
|
|
14
14
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;AAUA;;;cAAa,aAAA,
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/server/useDictionary.ts"],"mappings":";;;;;;;AAUA;;;cAAa,aAAA,mBACK,UAAA,kBACA,eAAA,GAAkB,eAAA,EAElC,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,KACR,UAAA,QAAkB,eAAA,CAAkB,CAAA,EAAG,CAAA"}
|
|
@@ -8,7 +8,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
8
8
|
*
|
|
9
9
|
* If the locale is not provided, it will use the locale from the server context
|
|
10
10
|
*/
|
|
11
|
-
declare const useDictionaryAsync: <T extends Dictionary, L extends DeclaredLocales = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: L) => ReturnType<typeof useDictionaryAsync$1<T, L>>;
|
|
11
|
+
declare const useDictionaryAsync: <const T extends Dictionary, const L extends DeclaredLocales = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: L) => ReturnType<typeof useDictionaryAsync$1<T, L>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { useDictionaryAsync };
|
|
14
14
|
//# sourceMappingURL=useDictionaryAsync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"mappings":";;;;;;;AAaA;;;cAAa,kBAAA,
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.d.ts","names":[],"sources":["../../../src/server/useDictionaryAsync.ts"],"mappings":";;;;;;;AAaA;;;cAAa,kBAAA,mBACK,UAAA,kBACA,eAAA,GAAkB,eAAA,EAElC,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,MAAA,GAAS,CAAA,KACR,UAAA,QAAkB,oBAAA,CAAuB,CAAA,EAAG,CAAA"}
|
|
@@ -8,7 +8,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
8
8
|
*
|
|
9
9
|
* If the locale is not provided, it will use the locale from the server context
|
|
10
10
|
*/
|
|
11
|
-
declare const useDictionaryDynamic: <T extends Dictionary, L extends DeclaredLocales = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: string, locale?: L) => ReturnType<typeof useDictionaryDynamic$1<T, L>>;
|
|
11
|
+
declare const useDictionaryDynamic: <const T extends Dictionary, const L extends DeclaredLocales = DeclaredLocales>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, key: string, locale?: L) => ReturnType<typeof useDictionaryDynamic$1<T, L>>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { useDictionaryDynamic };
|
|
14
14
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;AAaA;;;cAAa,oBAAA,
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/server/useDictionaryDynamic.ts"],"mappings":";;;;;;;AAaA;;;cAAa,oBAAA,mBACK,UAAA,kBACA,eAAA,GAAkB,eAAA,EAElC,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,UACA,MAAA,GAAS,CAAA,KACR,UAAA,QAAkB,sBAAA,CAAyB,CAAA,EAAG,CAAA"}
|
|
@@ -9,7 +9,7 @@ declare const safeUseLocale: () => Locale | undefined;
|
|
|
9
9
|
*
|
|
10
10
|
* If the locale is not provided, it will use the locale from the server context
|
|
11
11
|
*/
|
|
12
|
-
declare const useIntlayer: <T extends DictionaryKeys, L extends DeclaredLocales = DeclaredLocales>(key: T, locale?: L) => ReturnType<typeof useIntlayer$1<T, L>>;
|
|
12
|
+
declare const useIntlayer: <const T extends DictionaryKeys, const L extends DeclaredLocales = DeclaredLocales>(key: T, locale?: L) => ReturnType<typeof useIntlayer$1<T, L>>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { safeUseLocale, useIntlayer };
|
|
15
15
|
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/server/useIntlayer.ts"],"mappings":";;;;;cAYa,aAAA,QAAoB,MAAM;;AAAvC;;;;cAsBa,WAAA,
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/server/useIntlayer.ts"],"mappings":";;;;;cAYa,aAAA,QAAoB,MAAM;;AAAvC;;;;cAsBa,WAAA,mBACK,cAAA,kBACA,eAAA,GAAkB,eAAA,EAElC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,KACR,UAAA,QAAkB,aAAA,CAAgB,CAAA,EAAG,CAAA"}
|
|
@@ -18,7 +18,7 @@ type Next15PageIntlayer<T = {}> = (props: LocalPromiseParams<T>) => ReactNode |
|
|
|
18
18
|
type NextPageIntlayer<T = {}> = Next15PageIntlayer<T>;
|
|
19
19
|
type Next14LayoutIntlayer<T = {}> = NextPage<PropsWithChildren<LocalParams<T>>>;
|
|
20
20
|
type Next15LayoutIntlayer<T = {}> = (props: PropsWithChildren<LocalPromiseParams<T>>) => ReactNode | Promise<ReactNode>;
|
|
21
|
-
type NextLayoutIntlayer<T = {}> = (props: PropsWithChildren<LocalPromiseParams
|
|
21
|
+
type NextLayoutIntlayer<T = {}> = (props: PropsWithChildren<LocalPromiseParams<T>>) => ReactNode | Promise<ReactNode>;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { LocalParams, LocalPromiseParams, Next14LayoutIntlayer, Next14PageIntlayer, Next15LayoutIntlayer, Next15PageIntlayer, NextLayoutIntlayer, NextPageIntlayer };
|
|
24
24
|
//# sourceMappingURL=NextPage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextPage.d.ts","names":[],"sources":["../../../src/types/NextPage.ts"],"mappings":";;;;;KAIY,WAAA;EACV,MAAA;IAAU,MAAA,GAAS,aAAA;EAAA,IAAkB,CAAC;AAAA;AAAA,KAG5B,kBAAA;EACV,MAAA,EAAQ,OAAA;IAEJ,MAAA,GAAS,aAAA;EAAA,IACP,CAAA;AAAA;AAAA,KAII,kBAAA,WAA6B,QAAA,CAAS,WAAA,CAAY,CAAA;AAAA,KAClD,kBAAA,YACV,KAAA,EAAO,kBAAA,CAAmB,CAAA,MACvB,SAAA,GAAY,OAAA,CAAQ,SAAA;AAAA,KACb,gBAAA,WAA2B,kBAAkB,CAAC,CAAA;AAAA,KAE9C,oBAAA,WAA+B,QAAA,CACzC,iBAAA,CAAkB,WAAA,CAAY,CAAA;AAAA,KAEpB,oBAAA,YACV,KAAA,EAAO,iBAAA,CAAkB,kBAAA,CAAmB,CAAA,OACzC,SAAA,GAAY,OAAA,CAAQ,SAAA;AAAA,KAEb,kBAAA,YACV,KAAA,EAAO,iBAAA,CAAkB,kBAAA,
|
|
1
|
+
{"version":3,"file":"NextPage.d.ts","names":[],"sources":["../../../src/types/NextPage.ts"],"mappings":";;;;;KAIY,WAAA;EACV,MAAA;IAAU,MAAA,GAAS,aAAA;EAAA,IAAkB,CAAC;AAAA;AAAA,KAG5B,kBAAA;EACV,MAAA,EAAQ,OAAA;IAEJ,MAAA,GAAS,aAAA;EAAA,IACP,CAAA;AAAA;AAAA,KAII,kBAAA,WAA6B,QAAA,CAAS,WAAA,CAAY,CAAA;AAAA,KAClD,kBAAA,YACV,KAAA,EAAO,kBAAA,CAAmB,CAAA,MACvB,SAAA,GAAY,OAAA,CAAQ,SAAA;AAAA,KACb,gBAAA,WAA2B,kBAAkB,CAAC,CAAA;AAAA,KAE9C,oBAAA,WAA+B,QAAA,CACzC,iBAAA,CAAkB,WAAA,CAAY,CAAA;AAAA,KAEpB,oBAAA,YACV,KAAA,EAAO,iBAAA,CAAkB,kBAAA,CAAmB,CAAA,OACzC,SAAA,GAAY,OAAA,CAAQ,SAAA;AAAA,KAEb,kBAAA,YACV,KAAA,EAAO,iBAAA,CAAkB,kBAAA,CAAmB,CAAA,OACzC,SAAA,GAAY,OAAA,CAAQ,SAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intlayer",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Simplify internationalization i18n in Next.js with context providers, hooks, locale detection, and multilingual content integration.",
|
|
6
6
|
"keywords": [
|
|
@@ -128,15 +128,15 @@
|
|
|
128
128
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
129
129
|
},
|
|
130
130
|
"dependencies": {
|
|
131
|
-
"@intlayer/chokidar": "8.11.
|
|
132
|
-
"@intlayer/config": "8.11.
|
|
133
|
-
"@intlayer/core": "8.11.
|
|
134
|
-
"@intlayer/dictionaries-entry": "8.11.
|
|
135
|
-
"@intlayer/types": "8.11.
|
|
136
|
-
"@intlayer/webpack": "8.11.
|
|
131
|
+
"@intlayer/chokidar": "8.11.2",
|
|
132
|
+
"@intlayer/config": "8.11.2",
|
|
133
|
+
"@intlayer/core": "8.11.2",
|
|
134
|
+
"@intlayer/dictionaries-entry": "8.11.2",
|
|
135
|
+
"@intlayer/types": "8.11.2",
|
|
136
|
+
"@intlayer/webpack": "8.11.2",
|
|
137
137
|
"defu": "6.1.7",
|
|
138
138
|
"node-loader": "2.1.0",
|
|
139
|
-
"react-intlayer": "8.11.
|
|
139
|
+
"react-intlayer": "8.11.2"
|
|
140
140
|
},
|
|
141
141
|
"devDependencies": {
|
|
142
142
|
"@types/node": "25.9.1",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"@utils/ts-config-types": "1.0.4",
|
|
147
147
|
"@utils/tsdown-config": "1.0.4",
|
|
148
148
|
"rimraf": "6.1.3",
|
|
149
|
-
"tsdown": "0.22.
|
|
149
|
+
"tsdown": "0.22.1",
|
|
150
150
|
"typescript": "6.0.3",
|
|
151
151
|
"vitest": "4.1.7"
|
|
152
152
|
},
|