next-intlayer 8.0.4 → 8.0.5

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.
@@ -1,4 +1,4 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
4
5
  let react_intlayer = require("react-intlayer");
5
6
  let react_jsx_runtime = require("react/jsx-runtime");
6
7
 
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,0BAAqD,UAChE,2CAACA,mCAAiB,GAAI,QAAS"}
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,mCAAiB,GAAI,QAAS"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_client_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
3
4
  const require_client_useLocale = require('./useLocale.cjs');
4
5
  const require_client_useLocalePageRouter = require('./useLocalePageRouter.cjs');
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
4
5
  let react_intlayer = require("react-intlayer");
5
6
  let _intlayer_core = require("@intlayer/core");
6
7
  let next_navigation_js = require("next/navigation.js");
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\ntype UseLocaleProps = {\n onChange?: 'replace' | 'push' | 'none' | ((locale: LocalesValues) => void);\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 = ({ onChange = 'replace' }: UseLocaleProps = {}) => {\n const { replace, push } = useRouter();\n const pathWithoutLocale = usePathWithoutLocale();\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n if (!onChange) return;\n\n if (typeof onChange === 'function') {\n onChange(locale);\n return;\n }\n\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n if (onChange === 'replace') {\n replace(pathWithLocale);\n }\n if (onChange === 'push') {\n push(pathWithLocale);\n }\n },\n [replace, push, pathWithoutLocale, onChange]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;AAYA,MAAM,6BAA6B;CACjC,MAAM,gDAAwB;CAC9B,MAAM,CAAC,UAAU,mCAAwB,SAAS;AAElD,4BAAgB;EAEd,MAAM,SAAS,OAAO,WAAW,cAAc,OAAO,SAAS,SAAS;AACxE,cAAY,SAAS,GAAG,WAAW,WAAW,SAAS;IACtD,CAAC,SAAS,CAAC;AAGd,0EAA0C,SAAS,EAAE,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BlE,MAAa,aAAa,EAAE,WAAW,cAA8B,EAAE,KAAK;CAC1E,MAAM,EAAE,SAAS,4CAAoB;CACrC,MAAM,oBAAoB,sBAAsB;AA2BhD,QAAO;EACL,iCALqC,EACrC,wCArBC,WAA0B;AACzB,OAAI,CAAC,SAAU;AAEf,OAAI,OAAO,aAAa,YAAY;AAClC,aAAS,OAAO;AAChB;;GAGF,MAAM,qDAAiC,mBAAmB,OAAO;AAEjE,OAAI,aAAa,UACf,SAAQ,eAAe;AAEzB,OAAI,aAAa,OACf,MAAK,eAAe;KAGxB;GAAC;GAAS;GAAM;GAAmB;GAAS,CAC7C,EAIA,CAAC;EAIA;EACD"}
1
+ {"version":3,"file":"useLocale.cjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { usePathname, useRouter } from 'next/navigation.js';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\n\ntype UseLocaleProps = {\n onChange?: 'replace' | 'push' | 'none' | ((locale: LocalesValues) => void);\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 = ({ onChange = 'replace' }: UseLocaleProps = {}) => {\n const { replace, push } = useRouter();\n const pathWithoutLocale = usePathWithoutLocale();\n\n const redirectionFunction = useCallback(\n (locale: LocalesValues) => {\n if (!onChange) return;\n\n if (typeof onChange === 'function') {\n onChange(locale);\n return;\n }\n\n const pathWithLocale = getLocalizedUrl(pathWithoutLocale, locale);\n\n if (onChange === 'replace') {\n replace(pathWithLocale);\n }\n if (onChange === 'push') {\n push(pathWithLocale);\n }\n },\n [replace, push, pathWithoutLocale, onChange]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;;AAYA,MAAM,6BAA6B;CACjC,MAAM,gDAAwB;CAC9B,MAAM,CAAC,UAAU,mCAAwB,SAAS;AAElD,4BAAgB;EAEd,MAAM,SAAS,OAAO,WAAW,cAAc,OAAO,SAAS,SAAS;AACxE,cAAY,SAAS,GAAG,WAAW,WAAW,SAAS;IACtD,CAAC,SAAS,CAAC;AAGd,0EAA0C,SAAS,EAAE,CAAC,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BlE,MAAa,aAAa,EAAE,WAAW,cAA8B,EAAE,KAAK;CAC1E,MAAM,EAAE,SAAS,4CAAoB;CACrC,MAAM,oBAAoB,sBAAsB;AA2BhD,QAAO;EACL,iCALqC,EACrC,wCArBC,WAA0B;AACzB,OAAI,CAAC,SAAU;AAEf,OAAI,OAAO,aAAa,YAAY;AAClC,aAAS,OAAO;AAChB;;GAGF,MAAM,qDAAiC,mBAAmB,OAAO;AAEjE,OAAI,aAAa,UACf,SAAQ,eAAe;AAEzB,OAAI,aAAa,OACf,MAAK,eAAe;KAGxB;GAAC;GAAS;GAAM;GAAmB;GAAS,CAC7C,EAIA,CAAC;EAIA;EACD"}
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
4
5
  let react_intlayer = require("react-intlayer");
5
6
  let _intlayer_core = require("@intlayer/core");
6
7
  let react = require("react");
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalePageRouter.cjs","names":[],"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\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 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 return reload();\n },\n [pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,4BAA4B;CACvC,MAAM,EAAE,MAAM,UAAU,0CAAsB;CAC9C,MAAM,sFACuB,SAAS,EACpC,CAAC,SAAS,CACX;AAiBD,QAAO;EACL,iCALqC,EACrC,wCAXC,WAA0B;AAGzB,4CAFuC,mBAAmB,OAAO,CAE7C;AAEpB,UAAO,QAAQ;KAEjB,CAAC,kBAAkB,CACpB,EAIA,CAAC;EAIA;EACD"}
1
+ {"version":3,"file":"useLocalePageRouter.cjs","names":[],"sources":["../../../src/client/useLocalePageRouter.ts"],"sourcesContent":["'use client';\n\nimport { getLocalizedUrl, getPathWithoutLocale } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\nimport { useRouter } from 'next/router.js';\nimport { useCallback, useMemo } from 'react';\nimport { useLocale as useLocaleReact } from 'react-intlayer';\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 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 return reload();\n },\n [pathWithoutLocale]\n );\n\n const reactLocaleHook = useLocaleReact({\n onLocaleChange: redirectionFunction,\n });\n\n return {\n ...reactLocaleHook,\n pathWithoutLocale,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,4BAA4B;CACvC,MAAM,EAAE,MAAM,UAAU,0CAAsB;CAC9C,MAAM,sFACuB,SAAS,EACpC,CAAC,SAAS,CACX;AAiBD,QAAO;EACL,iCALqC,EACrC,wCAXC,WAA0B;AAGzB,4CAFuC,mBAAmB,OAAO,CAE7C;AAEpB,UAAO,QAAQ;KAEjB,CAAC,kBAAkB,CACpB,EAIA,CAAC;EAIA;EACD"}
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
 
3
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
4
5
  let react_intlayer = require("react-intlayer");
5
6
 
6
7
  Object.defineProperty(exports, 'useRewriteURL', {
@@ -1,6 +1,7 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
  let _intlayer_config_built = require("@intlayer/config/built");
3
- _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
4
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
4
5
 
5
6
  //#region src/generateStaticParams.ts
6
7
  const { locales } = _intlayer_config_built.default.internationalization;
@@ -1 +1 @@
1
- {"version":3,"file":"generateStaticParams.cjs","names":["configuration"],"sources":["../../src/generateStaticParams.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nconst { locales } = configuration.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,+BAAc;;;;;;;;;;;;;;;;;;;AAoBlC,MAAa,6BAA6B,QAAQ,KAAK,YAAY,EAAE,QAAQ,EAAE"}
1
+ {"version":3,"file":"generateStaticParams.cjs","names":["configuration"],"sources":["../../src/generateStaticParams.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\n\nconst { locales } = configuration.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,+BAAc;;;;;;;;;;;;;;;;;;;AAoBlC,MAAa,6BAA6B,QAAQ,KAAK,YAAY,EAAE,QAAQ,EAAE"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
  const require_generateStaticParams = require('./generateStaticParams.cjs');
3
4
  const require_client_IntlayerClientProvider = require('./client/IntlayerClientProvider.cjs');
4
5
  const require_client_useLocale = require('./client/useLocale.cjs');
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_proxy_localeDetector = require('./localeDetector.cjs');
2
3
  const require_proxy_intlayerProxy = require('./intlayerProxy.cjs');
3
4
  const require_proxy_multipleProxies = require('./multipleProxies.cjs');
@@ -1,7 +1,8 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_proxy_localeDetector = require('./localeDetector.cjs');
3
4
  let _intlayer_config_built = require("@intlayer/config/built");
4
- _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
5
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
5
6
  let _intlayer_core = require("@intlayer/core");
6
7
  let _intlayer_config_client = require("@intlayer/config/client");
7
8
  let next_server = require("next/server");
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerProxy.cjs","names":["configuration","DefaultValues","localeDetector","NextResponse"],"sources":["../../../src/proxy/intlayerProxy.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport {\n getCanonicalPath,\n getLocaleFromStorage,\n getLocalizedPath,\n getRewriteRules,\n setLocaleInStorage,\n} from '@intlayer/core';\nimport type { Locale } from '@intlayer/types';\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 { internationalization, routing } = configuration ?? {};\nconst { locales, defaultLocale } = internationalization ?? {};\nconst { basePath, mode, rewrite } = routing ?? {};\n\n// Note: cookie names are resolved inside LocaleStorage based on configuration\n\n// Derived flags from routing.mode\nconst effectiveMode = mode ?? DefaultValues.Routing.ROUTING_MODE;\nconst noPrefix =\n effectiveMode === 'no-prefix' || effectiveMode === 'search-params';\nconst prefixDefault = effectiveMode === 'prefix-all';\n\nconst internalPrefix = !noPrefix;\n\nconst rewriteRules = getRewriteRules(rewrite, 'url');\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 (effectiveMode !== 'search-params') 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 const localLocale = getLocalLocale(request);\n\n if (noPrefix) {\n return handleNoPrefix(request, localLocale, pathname);\n }\n\n const pathLocale = getPathLocale(pathname);\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 getLocaleFromStorage({\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 const locale = localLocale ?? defaultLocale;\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 // Resolve the internal canonical path\n // If user visits /a-propos (no prefix), and we detect 'fr', we resolve to /about\n const canonicalPath = getCanonicalPath(\n pathname,\n locale as Locale,\n rewriteRules\n );\n\n if (effectiveMode === 'search-params') {\n const existingSearchParams = new URLSearchParams(request.nextUrl.search);\n const existingLocale = existingSearchParams.get('locale');\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 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, localLocale, 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 localLocale: Locale | undefined,\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 if (localLocale && localLocale !== pathLocale) {\n // Cookie mismatch: Redirect to the correct locale using the Canonical Path as the source\n const newPath = handleCookieLocaleMismatch(\n request,\n canonicalPath, // Pass /about\n localLocale,\n basePath as string\n );\n return redirectUrl(request, newPath);\n }\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 if (!prefixDefault && pathLocale === defaultLocale) {\n return handleDefaultLocaleRedirect(\n request,\n pathLocale,\n pathname,\n canonicalPath\n );\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 */\nconst handleCookieLocaleMismatch = (\n request: NextRequest,\n canonicalPath: string,\n localLocale: Locale,\n basePath: string\n): string => {\n // Translate canonical path (/about) to target locale path (/es/acerca)\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n localLocale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n\n return constructPath(\n localLocale,\n targetLocalizedPath,\n basePath,\n appendLocaleSearchIfNeeded(request.nextUrl.search, localLocale)\n );\n};\n\n/**\n * The key fix for 404s without [locale] folders\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locale,\n pathname: string, // Current URL path (e.g. /en/about)\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 (effectiveMode === 'no-prefix' || effectiveMode === 'search-params') {\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 setLocaleInStorage(locale, {\n setHeader: (name: string, value: string) => {\n requestHeaders.set(name, value);\n },\n });\n\n const response = NextResponse.rewrite(new URL(pathWithSearch, request.url), {\n request: {\n headers: requestHeaders,\n },\n });\n\n setLocaleInStorage(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 return NextResponse.redirect(new URL(pathWithSearch, request.url));\n};\n"],"mappings":";;;;;;;;;AAgDA,MAAM,EAAE,sBAAsB,YAAYA,kCAAiB,EAAE;AAC7D,MAAM,EAAE,SAAS,kBAAkB,wBAAwB,EAAE;AAC7D,MAAM,EAAE,UAAU,MAAM,YAAY,WAAW,EAAE;AAKjD,MAAM,gBAAgB,QAAQC,sCAAc,QAAQ;AACpD,MAAM,WACJ,kBAAkB,eAAe,kBAAkB;AACrD,MAAM,gBAAgB,kBAAkB;AAExC,MAAM,iBAAiB,CAAC;AAExB,MAAM,mDAA+B,SAAS,MAAM;;;;;;;;;;;;;;;AAgBpD,MAAM,qBAAqB,YAAkC;CAC3D,MAAM,UAAU,QAAQ,QAAQ,IAAI,UAAU;CAC9C,MAAM,qBAAqB,QAAQ,QAAQ,IAAI,uBAAuB;CACtE,MAAM,UAAU,QAAQ,QAAQ,IAAI,WAAW;CAC/C,MAAM,cAAc,QAAQ,QAAQ,IAAI,gBAAgB;AAExD,QACE,YAAY,cACZ,uBAAuB,OACvB,CAAC,CAAC,WACF,CAAC,CAAC;;AAKN,MAAM,8BACJ,QACA,WACuB;AACvB,KAAI,kBAAkB,gBAAiB,QAAO;CAC9C,MAAM,SAAS,IAAI,gBAAgB,UAAU,GAAG;AAChD,QAAO,IAAI,UAAU,OAAO;AAC5B,QAAO,IAAI,OAAO,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;AA0B9B,MAAa,iBACX,SACA,QACA,cACiB;CACjB,MAAM,WAAW,QAAQ,QAAQ;CACjC,MAAM,cAAc,eAAe,QAAQ;AAE3C,KAAI,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AG,SAAS,KAAK,WAAW,IAAI,GAAG,KAAK,MAAM;AAQlD,QALgB,GAAG,WADW,SAAS,SAAS,IAAI,GACE,KAAK,MAAM,uBAGvC,QAAQ,QAAQ,IAAI;;;;;;;AAUhD,MAAM,cACJ,SACA,SACA,WACiB;CACjB,MAAM,SAAS,QAAQ,QAAQ;CAC/B,MAAM,iBACJ,UAAU,CAAC,QAAQ,SAAS,IAAI,GAAG,GAAG,UAAU,WAAW;CAE7D,MAAM,iBAAiB,IAAI,QAAQ,QAAQ,QAAQ;AACnD,wCAAmB,QAAQ,EACzB,YAAY,MAAc,UAAkB;AAC1C,iBAAe,IAAI,MAAM,MAAM;IAElC,CAAC;CAEF,MAAM,WAAWC,yBAAa,QAAQ,IAAI,IAAI,gBAAgB,QAAQ,IAAI,EAAE,EAC1E,SAAS,EACP,SAAS,gBACV,EACF,CAAC;AAEF,wCAAmB,QAAQ,EACzB,YAAY,MAAc,UAAkB;AAC1C,WAAS,QAAQ,IAAI,MAAM,MAAM;IAEpC,CAAC;AACF,QAAO;;;;;;;;;AAUT,MAAM,eAAe,SAAsB,YAAkC;CAC3E,MAAM,SAAS,QAAQ,QAAQ;CAC/B,MAAM,iBACJ,UAAU,CAAC,QAAQ,SAAS,IAAI,GAAG,GAAG,UAAU,WAAW;AAC7D,QAAOA,yBAAa,SAAS,IAAI,IAAI,gBAAgB,QAAQ,IAAI,CAAC"}
1
+ {"version":3,"file":"intlayerProxy.cjs","names":["configuration","DefaultValues","localeDetector","NextResponse"],"sources":["../../../src/proxy/intlayerProxy.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { DefaultValues } from '@intlayer/config/client';\nimport {\n getCanonicalPath,\n getLocaleFromStorage,\n getLocalizedPath,\n getRewriteRules,\n setLocaleInStorage,\n} from '@intlayer/core';\nimport type { Locale } from '@intlayer/types';\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 { internationalization, routing } = configuration ?? {};\nconst { locales, defaultLocale } = internationalization ?? {};\nconst { basePath, mode, rewrite } = routing ?? {};\n\n// Note: cookie names are resolved inside LocaleStorage based on configuration\n\n// Derived flags from routing.mode\nconst effectiveMode = mode ?? DefaultValues.Routing.ROUTING_MODE;\nconst noPrefix =\n effectiveMode === 'no-prefix' || effectiveMode === 'search-params';\nconst prefixDefault = effectiveMode === 'prefix-all';\n\nconst internalPrefix = !noPrefix;\n\nconst rewriteRules = getRewriteRules(rewrite, 'url');\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 (effectiveMode !== 'search-params') 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 const localLocale = getLocalLocale(request);\n\n if (noPrefix) {\n return handleNoPrefix(request, localLocale, pathname);\n }\n\n const pathLocale = getPathLocale(pathname);\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 getLocaleFromStorage({\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 const locale = localLocale ?? defaultLocale;\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 // Resolve the internal canonical path\n // If user visits /a-propos (no prefix), and we detect 'fr', we resolve to /about\n const canonicalPath = getCanonicalPath(\n pathname,\n locale as Locale,\n rewriteRules\n );\n\n if (effectiveMode === 'search-params') {\n const existingSearchParams = new URLSearchParams(request.nextUrl.search);\n const existingLocale = existingSearchParams.get('locale');\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 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, localLocale, 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 localLocale: Locale | undefined,\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 if (localLocale && localLocale !== pathLocale) {\n // Cookie mismatch: Redirect to the correct locale using the Canonical Path as the source\n const newPath = handleCookieLocaleMismatch(\n request,\n canonicalPath, // Pass /about\n localLocale,\n basePath as string\n );\n return redirectUrl(request, newPath);\n }\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 if (!prefixDefault && pathLocale === defaultLocale) {\n return handleDefaultLocaleRedirect(\n request,\n pathLocale,\n pathname,\n canonicalPath\n );\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 */\nconst handleCookieLocaleMismatch = (\n request: NextRequest,\n canonicalPath: string,\n localLocale: Locale,\n basePath: string\n): string => {\n // Translate canonical path (/about) to target locale path (/es/acerca)\n const targetLocalizedPathResult = getLocalizedPath(\n canonicalPath,\n localLocale,\n rewriteRules\n );\n const targetLocalizedPath =\n typeof targetLocalizedPathResult === 'string'\n ? targetLocalizedPathResult\n : targetLocalizedPathResult.path;\n\n return constructPath(\n localLocale,\n targetLocalizedPath,\n basePath,\n appendLocaleSearchIfNeeded(request.nextUrl.search, localLocale)\n );\n};\n\n/**\n * The key fix for 404s without [locale] folders\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locale,\n pathname: string, // Current URL path (e.g. /en/about)\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 (effectiveMode === 'no-prefix' || effectiveMode === 'search-params') {\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 setLocaleInStorage(locale, {\n setHeader: (name: string, value: string) => {\n requestHeaders.set(name, value);\n },\n });\n\n const response = NextResponse.rewrite(new URL(pathWithSearch, request.url), {\n request: {\n headers: requestHeaders,\n },\n });\n\n setLocaleInStorage(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 return NextResponse.redirect(new URL(pathWithSearch, request.url));\n};\n"],"mappings":";;;;;;;;;;AAgDA,MAAM,EAAE,sBAAsB,YAAYA,kCAAiB,EAAE;AAC7D,MAAM,EAAE,SAAS,kBAAkB,wBAAwB,EAAE;AAC7D,MAAM,EAAE,UAAU,MAAM,YAAY,WAAW,EAAE;AAKjD,MAAM,gBAAgB,QAAQC,sCAAc,QAAQ;AACpD,MAAM,WACJ,kBAAkB,eAAe,kBAAkB;AACrD,MAAM,gBAAgB,kBAAkB;AAExC,MAAM,iBAAiB,CAAC;AAExB,MAAM,mDAA+B,SAAS,MAAM;;;;;;;;;;;;;;;AAgBpD,MAAM,qBAAqB,YAAkC;CAC3D,MAAM,UAAU,QAAQ,QAAQ,IAAI,UAAU;CAC9C,MAAM,qBAAqB,QAAQ,QAAQ,IAAI,uBAAuB;CACtE,MAAM,UAAU,QAAQ,QAAQ,IAAI,WAAW;CAC/C,MAAM,cAAc,QAAQ,QAAQ,IAAI,gBAAgB;AAExD,QACE,YAAY,cACZ,uBAAuB,OACvB,CAAC,CAAC,WACF,CAAC,CAAC;;AAKN,MAAM,8BACJ,QACA,WACuB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ty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  let _intlayer_core = require("@intlayer/core");
3
4
 
4
5
  //#region src/proxy/localeDetector.ts
@@ -1 +1 @@
1
- {"version":3,"file":"localeDetector.cjs","names":[],"sources":["../../../src/proxy/localeDetector.ts"],"sourcesContent":["import { localeDetector as localeDetectorCore } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\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,EAAE;AAEpD,SAAQ,QAAQ,SAAS,OAAO,QAAQ;AACtC,oBAAkB,OAAO;GACzB;AAIF,2CAFkC,kBAAkB"}
1
+ {"version":3,"file":"localeDetector.cjs","names":[],"sources":["../../../src/proxy/localeDetector.ts"],"sourcesContent":["import { localeDetector as localeDetectorCore } from '@intlayer/core';\nimport type { LocalesValues } from '@intlayer/types';\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,EAAE;AAEpD,SAAQ,QAAQ,SAAS,OAAO,QAAQ;AACtC,oBAAkB,OAAO;GACzB;AAIF,2CAFkC,kBAAkB"}
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_proxy_intlayerProxy = require('./intlayerProxy.cjs');
2
3
  const require_proxy_multipleProxies = require('./multipleProxies.cjs');
3
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.cjs","names":["intlayerProxy","multipleProxies"],"sources":["../../../src/proxy/middleware.ts"],"sourcesContent":["import { intlayerProxy } from './intlayerProxy';\nimport { multipleProxies } from './multipleProxies';\n\n/**\n * Reexport for nextjs <=15\n */\n\n/**\n * Middleware that handles the internationalization layer\n *\n * Usage:\n *\n * ```ts\n * // ./src/middleware.ts\n *\n * export { intlayerMiddleware as middleware } from '@intlayer/next/middleware';\n *\n * // applies this middleware only to files in the app directory\n * export const config = {\n * matcher: '/((?!api|static|.*\\\\..*|_next).*)',\n * };\n * ```\n *\n * Main middleware 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 intlayerMiddleware = intlayerProxy;\n\nexport const multipleMiddlewares = multipleProxies;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,qBAAqBA;AAElC,MAAa,sBAAsBC"}
1
+ {"version":3,"file":"middleware.cjs","names":["intlayerProxy","multipleProxies"],"sources":["../../../src/proxy/middleware.ts"],"sourcesContent":["import { intlayerProxy } from './intlayerProxy';\nimport { multipleProxies } from './multipleProxies';\n\n/**\n * Reexport for nextjs <=15\n */\n\n/**\n * Middleware that handles the internationalization layer\n *\n * Usage:\n *\n * ```ts\n * // ./src/middleware.ts\n *\n * export { intlayerMiddleware as middleware } from '@intlayer/next/middleware';\n *\n * // applies this middleware only to files in the app directory\n * export const config = {\n * matcher: '/((?!api|static|.*\\\\..*|_next).*)',\n * };\n * ```\n *\n * Main middleware 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 intlayerMiddleware = intlayerProxy;\n\nexport const multipleMiddlewares = multipleProxies;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,qBAAqBA;AAElC,MAAa,sBAAsBC"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  let next_server = require("next/server");
3
4
 
4
5
  //#region src/proxy/multipleProxies.ts
@@ -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, merges headers, and correctly handles\n * redirects and rewrites.\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 // Array to store proxy headers\n const proxyHeader: Headers[] = [];\n\n // Loop through proxy functions\n for (const proxy of proxies) {\n // Execute proxy function and await the result\n const result = await proxy(req, event, response);\n\n // Check if the result is not okay and return it\n if (!result.ok) {\n return result;\n }\n\n // Push proxy headers to the array\n proxyHeader.push(result.headers);\n }\n\n // Merge all the headers to check if there is a redirection or rewrite\n const mergedHeaders = new Headers();\n\n // Merge all the custom headers added by the proxies\n const transmittedHeaders = new Headers();\n\n // Merge headers\n proxyHeader.forEach((header) => {\n for (const [key, value] of header.entries()) {\n mergedHeaders.append(key, value);\n\n // check if it's a custom header added by one of the proxies\n if (key.startsWith('x-middleware-request-')) {\n // remove the prefix to get the original key\n const fixedKey = key.replace('x-middleware-request-', '');\n\n // add the original key to the transmitted headers\n transmittedHeaders.append(fixedKey, value);\n }\n }\n });\n\n // Look for the 'x-middleware-request-redirect' header\n const redirect = mergedHeaders.get('x-middleware-request-redirect');\n\n // If a redirection is required based on the proxy headers\n if (redirect) {\n // Perform the redirection\n return NextResponse.redirect(new URL(redirect, req.url), {\n status: 307, // Temporary redirect\n });\n }\n\n // Look for the 'x-middleware-rewrite' header\n const rewrite = mergedHeaders.get('x-middleware-rewrite');\n if (rewrite) {\n // Perform the rewrite\n return NextResponse.rewrite(new URL(rewrite, req.url), {\n request: {\n headers: transmittedHeaders,\n },\n });\n }\n\n // Default: continue to next proxy\n return NextResponse.next({\n request: {\n headers: transmittedHeaders,\n },\n });\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,mBAET,YAMF,OAAO,KAAkB,OAAwB,aAA4B;CAE3E,MAAM,cAAyB,EAAE;AAGjC,MAAK,MAAM,SAAS,SAAS;EAE3B,MAAM,SAAS,MAAM,MAAM,KAAK,OAAO,SAAS;AAGhD,MAAI,CAAC,OAAO,GACV,QAAO;AAIT,cAAY,KAAK,OAAO,QAAQ;;CAIlC,MAAM,gBAAgB,IAAI,SAAS;CAGnC,MAAM,qBAAqB,IAAI,SAAS;AAGxC,aAAY,SAAS,WAAW;AAC9B,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,SAAS,EAAE;AAC3C,iBAAc,OAAO,KAAK,MAAM;AAGhC,OAAI,IAAI,WAAW,wBAAwB,EAAE;IAE3C,MAAM,WAAW,IAAI,QAAQ,yBAAyB,GAAG;AAGzD,uBAAmB,OAAO,UAAU,MAAM;;;GAG9C;CAGF,MAAM,WAAW,cAAc,IAAI,gCAAgC;AAGnE,KAAI,SAEF,QAAOA,yBAAa,SAAS,IAAI,IAAI,UAAU,IAAI,IAAI,EAAE,EACvD,QAAQ,KACT,CAAC;CAIJ,MAAM,UAAU,cAAc,IAAI,uBAAuB;AACzD,KAAI,QAEF,QAAOA,yBAAa,QAAQ,IAAI,IAAI,SAAS,IAAI,IAAI,EAAE,EACrD,SAAS,EACP,SAAS,oBACV,EACF,CAAC;AAIJ,QAAOA,yBAAa,KAAK,EACvB,SAAS,EACP,SAAS,oBACV,EACF,CAAC"}
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, merges headers, and correctly handles\n * redirects and rewrites.\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 // Array to store proxy headers\n const proxyHeader: Headers[] = [];\n\n // Loop through proxy functions\n for (const proxy of proxies) {\n // Execute proxy function and await the result\n const result = await proxy(req, event, response);\n\n // Check if the result is not okay and return it\n if (!result.ok) {\n return result;\n }\n\n // Push proxy headers to the array\n proxyHeader.push(result.headers);\n }\n\n // Merge all the headers to check if there is a redirection or rewrite\n const mergedHeaders = new Headers();\n\n // Merge all the custom headers added by the proxies\n const transmittedHeaders = new Headers();\n\n // Merge headers\n proxyHeader.forEach((header) => {\n for (const [key, value] of header.entries()) {\n mergedHeaders.append(key, value);\n\n // check if it's a custom header added by one of the proxies\n if (key.startsWith('x-middleware-request-')) {\n // remove the prefix to get the original key\n const fixedKey = key.replace('x-middleware-request-', '');\n\n // add the original key to the transmitted headers\n transmittedHeaders.append(fixedKey, value);\n }\n }\n });\n\n // Look for the 'x-middleware-request-redirect' header\n const redirect = mergedHeaders.get('x-middleware-request-redirect');\n\n // If a redirection is required based on the proxy headers\n if (redirect) {\n // Perform the redirection\n return NextResponse.redirect(new URL(redirect, req.url), {\n status: 307, // Temporary redirect\n });\n }\n\n // Look for the 'x-middleware-rewrite' header\n const rewrite = mergedHeaders.get('x-middleware-rewrite');\n if (rewrite) {\n // Perform the rewrite\n return NextResponse.rewrite(new URL(rewrite, req.url), {\n request: {\n headers: transmittedHeaders,\n },\n });\n }\n\n // Default: continue to next proxy\n return NextResponse.next({\n request: {\n headers: transmittedHeaders,\n },\n });\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,mBAET,YAMF,OAAO,KAAkB,OAAwB,aAA4B;CAE3E,MAAM,cAAyB,EAAE;AAGjC,MAAK,MAAM,SAAS,SAAS;EAE3B,MAAM,SAAS,MAAM,MAAM,KAAK,OAAO,SAAS;AAGhD,MAAI,CAAC,OAAO,GACV,QAAO;AAIT,cAAY,KAAK,OAAO,QAAQ;;CAIlC,MAAM,gBAAgB,IAAI,SAAS;CAGnC,MAAM,qBAAqB,IAAI,SAAS;AAGxC,aAAY,SAAS,WAAW;AAC9B,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,SAAS,EAAE;AAC3C,iBAAc,OAAO,KAAK,MAAM;AAGhC,OAAI,IAAI,WAAW,wBAAwB,EAAE;IAE3C,MAAM,WAAW,IAAI,QAAQ,yBAAyB,GAAG;AAGzD,uBAAmB,OAAO,UAAU,MAAM;;;GAG9C;CAGF,MAAM,WAAW,cAAc,IAAI,gCAAgC;AAGnE,KAAI,SAEF,QAAOA,yBAAa,SAAS,IAAI,IAAI,UAAU,IAAI,IAAI,EAAE,EACvD,QAAQ,KACT,CAAC;CAIJ,MAAM,UAAU,cAAc,IAAI,uBAAuB;AACzD,KAAI,QAEF,QAAOA,yBAAa,QAAQ,IAAI,IAAI,SAAS,IAAI,IAAI,EAAE,EACrD,SAAS,EACP,SAAS,oBACV,EACF,CAAC;AAIJ,QAAOA,yBAAa,KAAK,EACvB,SAAS,EACP,SAAS,oBACV,EACF,CAAC"}
@@ -1,6 +1,7 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  let _intlayer_config_built = require("@intlayer/config/built");
3
- _intlayer_config_built = require_rolldown_runtime.__toESM(_intlayer_config_built);
4
+ _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
4
5
  let _intlayer_core = require("@intlayer/core");
5
6
  let _intlayer_types = require("@intlayer/types");
6
7
  let next_headers_js = require("next/headers.js");
@@ -1 +1 @@
1
- {"version":3,"file":"getLocale.cjs","names":["configuration","Locales"],"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { getLocaleFromStorage, localeDetector } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\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 =\n configuration?.internationalization?.defaultLocale ?? Locales.ENGLISH;\n\n // Try locale from header\n const headersList = await headers();\n const cookiesList = await cookies();\n\n const storedLocale = getLocaleFromStorage({\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,YAAY,YAA6B;CACpD,MAAM,gBACJA,gCAAe,sBAAsB,iBAAiBC,wBAAQ;CAGhE,MAAM,cAAc,oCAAe;CACnC,MAAM,cAAc,oCAAe;CAEnC,MAAM,wDAAoC;EACxC,YAAY,SAAiB,YAAY,IAAI,KAAK,EAAE,SAAS;EAC7D,YAAY,SAAiB,YAAY,IAAI,KAAK,IAAI;EACvD,CAAC;AAEF,KAAI,aAAc,QAAO;CAGzB,MAAM,oBAA4C,EAAE;AACpD,aAAY,SAAS,OAAO,QAAQ;AAClC,oBAAkB,OAAO;GACzB;CAEF,MAAM,wDAAoC,kBAAkB;AAC5D,KAAI,mBAAoB,QAAO;AAG/B,QAAO"}
1
+ {"version":3,"file":"getLocale.cjs","names":["configuration","Locales"],"sources":["../../../src/server/getLocale.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { getLocaleFromStorage, localeDetector } from '@intlayer/core';\nimport { type Locale, Locales } from '@intlayer/types';\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 =\n configuration?.internationalization?.defaultLocale ?? Locales.ENGLISH;\n\n // Try locale from header\n const headersList = await headers();\n const cookiesList = await cookies();\n\n const storedLocale = getLocaleFromStorage({\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,YAAY,YAA6B;CACpD,MAAM,gBACJA,gCAAe,sBAAsB,iBAAiBC,wBAAQ;CAGhE,MAAM,cAAc,oCAAe;CACnC,MAAM,cAAc,oCAAe;CAEnC,MAAM,wDAAoC;EACxC,YAAY,SAAiB,YAAY,IAAI,KAAK,EAAE,SAAS;EAC7D,YAAY,SAAiB,YAAY,IAAI,KAAK,IAAI;EACvD,CAAC;AAEF,KAAI,aAAc,QAAO;CAGzB,MAAM,oBAA4C,EAAE;AACpD,aAAY,SAAS,OAAO,QAAQ;AAClC,oBAAkB,OAAO;GACzB;CAEF,MAAM,wDAAoC,kBAAkB;AAC5D,KAAI,mBAAoB,QAAO;AAG/B,QAAO"}
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  const require_server_getLocale = require('./getLocale.cjs');
3
4
  const require_server_withIntlayer = require('./withIntlayer.cjs');
4
5
  let react_intlayer_server = require("react-intlayer/server");
@@ -1,4 +1,5 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
3
  let node_path = require("node:path");
3
4
  let _intlayer_chokidar = require("@intlayer/chokidar");
4
5
  let _intlayer_config = require("@intlayer/config");
@@ -6,7 +7,7 @@ let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
6
7
  let _intlayer_webpack = require("@intlayer/webpack");
7
8
  let defu = require("defu");
8
9
  let next_package_json = require("next/package.json");
9
- next_package_json = require_rolldown_runtime.__toESM(next_package_json);
10
+ next_package_json = require_runtime.__toESM(next_package_json);
10
11
 
11
12
  //#region src/server/withIntlayer.ts
12
13
  const isGteNext13 = (0, _intlayer_config.compareVersions)(next_package_json.default.version, "≥", "13.0.0");
@@ -1 +1 @@
1
- {"version":3,"file":"withIntlayer.cjs","names":["nextPackageJSON","ANSIColors","DefaultValues","IntlayerPlugin"],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport {\n getComponentTransformPatternSync,\n prepareIntlayer,\n runOnce,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n compareVersions,\n DefaultValues,\n type GetConfigurationOptions,\n getAlias,\n getAppLogger,\n getConfiguration,\n getProjectRequire,\n normalizePath,\n} from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\n\nconst isGteNext13 = compareVersions(nextPackageJSON.version, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextPackageJSON.version, '≥', '15.0.0');\nconst isGteNext16 = compareVersions(nextPackageJSON.version, '≥', '16.0.0');\nconst isTurbopackStable = compareVersions(\n nextPackageJSON.version,\n '≥',\n '15.3.0'\n);\n\nconst isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enable turbopack by default, and offer the possibility to disable it if --webpack flag is used\n !process.env.npm_lifecycle_script?.includes('--webpack')\n : // Next@15 use --turbopack flag, Next@14 use --turbo flag\n process.env.npm_lifecycle_script?.includes('--turbo');\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig,\n isBuildCommand: boolean,\n isTurbopackEnabled: boolean\n): Partial<NextConfig> => {\n const { optimize } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.content;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable) {\n logger('Build optimization enabled');\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation: ',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/en/bundle_optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n if (!isSwcPluginAvailable) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = getComponentTransformPatternSync(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ??\n importMode ??\n DefaultValues.Dictionary.IMPORT_MODE;\n });\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n dictionaryModeMap,\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env.npm_lifecycle_event;\n const lifecycleScript = process.env.npm_lifecycle_script ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration(configOptions);\n const logger = getAppLogger(intlayerConfig);\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n logger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n ];\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {};\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark these modules as externals\n config.externals.push({\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n });\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled ?? false\n );\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n const intlayerConfig = getConfiguration(configOptions);\n\n const { mode } = intlayerConfig.build;\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (isDevCommand || isBuildCommand || mode === 'auto') {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n });\n }\n\n const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, configOptions);\n};\n"],"mappings":";;;;;;;;;;;AA0BA,MAAM,oDAA8BA,0BAAgB,SAAS,KAAK,SA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,cAAc,EACd,YACD,EAGuC,WAAW;;;;;;;;;;;;;;;;;AAoBrD,MAAa,eAAe,OAC1B,aAA6B,EAAE,EAC/B,kBAC4B;CAC5B,MAAM,EAAE,gBAAgB,iBAAiB,kBAAkB;CAC3D,MAAM,wDAAkC,cAAc;CAEtD,MAAM,EAAE,SAAS,eAAe;AAKhC,KAAI,gBAAgB,kBAAkB,SAAS,OAE7C,+CAAsB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MAAO,KACP,MAAO,KAAK;EACjB,CAAC;AAKJ,QAAO,iBAFoB,MAAM,YAEW,cAAc"}
1
+ {"version":3,"file":"withIntlayer.cjs","names":["nextPackageJSON","ANSIColors","DefaultValues","IntlayerPlugin"],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport {\n getComponentTransformPatternSync,\n prepareIntlayer,\n runOnce,\n} from '@intlayer/chokidar';\nimport {\n ANSIColors,\n colorize,\n compareVersions,\n DefaultValues,\n type GetConfigurationOptions,\n getAlias,\n getAppLogger,\n getConfiguration,\n getProjectRequire,\n normalizePath,\n} from '@intlayer/config';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { Dictionary, IntlayerConfig } from '@intlayer/types';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\n\nconst isGteNext13 = compareVersions(nextPackageJSON.version, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextPackageJSON.version, '≥', '15.0.0');\nconst isGteNext16 = compareVersions(nextPackageJSON.version, '≥', '16.0.0');\nconst isTurbopackStable = compareVersions(\n nextPackageJSON.version,\n '≥',\n '15.3.0'\n);\n\nconst isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enable turbopack by default, and offer the possibility to disable it if --webpack flag is used\n !process.env.npm_lifecycle_script?.includes('--webpack')\n : // Next@15 use --turbopack flag, Next@14 use --turbo flag\n process.env.npm_lifecycle_script?.includes('--turbo');\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig,\n isBuildCommand: boolean,\n isTurbopackEnabled: boolean\n): Partial<NextConfig> => {\n const { optimize } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.content;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable) {\n logger('Build optimization enabled');\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation: ',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/en/bundle_optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n if (!isSwcPluginAvailable) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = getComponentTransformPatternSync(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ??\n importMode ??\n DefaultValues.Dictionary.IMPORT_MODE;\n });\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n dictionaryModeMap,\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env.npm_lifecycle_event;\n const lifecycleScript = process.env.npm_lifecycle_script ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration(configOptions);\n const logger = getAppLogger(intlayerConfig);\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n logger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n ];\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {};\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark these modules as externals\n config.externals.push({\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n });\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled ?? false\n );\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n const intlayerConfig = getConfiguration(configOptions);\n\n const { mode } = intlayerConfig.build;\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (isDevCommand || isBuildCommand || mode === 'auto') {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n });\n }\n\n const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, configOptions);\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,oDAA8BA,0BAAgB,SAAS,KAAK,SAAS;AAC3E,MAAM,oDAA8BA,0BAAgB,SAAS,KAAK,SAAS;AAC3E,MAAM,oDAA8BA,0BAAgB,SAAS,KAAK,SAAS;AAC3E,MAAM,0DACJA,0BAAgB,SAChB,KACA,SACD;AAED,MAAM,gCAAgC,cAElC,CAAC,QAAQ,IAAI,sBAAsB,SAAS,YAAY,GAExD,QAAQ,IAAI,sBAAsB,SAAS,UAAU;AAGzD,MAAM,2BAA2B,mBAAmC;AAClE,KAAI;AAGF,GADE,eAAe,OAAO,oDAA8B,EACtC,QAAQ,gBAAgB;AACxC,SAAO;UACA,IAAI;AACX,SAAO;;;AA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,4 +1,4 @@
1
- import * as _intlayer_types3 from "@intlayer/types";
1
+ import * as _intlayer_types0 from "@intlayer/types";
2
2
  import { LocalesValues } from "@intlayer/types";
3
3
 
4
4
  //#region src/client/useLocalePageRouter.d.ts
@@ -25,9 +25,9 @@ import { LocalesValues } from "@intlayer/types";
25
25
  */
26
26
  declare const useLocalePageRouter: () => {
27
27
  pathWithoutLocale: string;
28
- locale: _intlayer_types3.DeclaredLocales;
29
- defaultLocale: _intlayer_types3.DeclaredLocales;
30
- availableLocales: _intlayer_types3.DeclaredLocales[];
28
+ locale: _intlayer_types0.DeclaredLocales;
29
+ defaultLocale: _intlayer_types0.DeclaredLocales;
30
+ availableLocales: _intlayer_types0.DeclaredLocales[];
31
31
  setLocale: (locale: LocalesValues) => void;
32
32
  };
33
33
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intlayer",
3
- "version": "8.0.4",
3
+ "version": "8.0.5",
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": [
@@ -118,25 +118,25 @@
118
118
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
119
119
  },
120
120
  "dependencies": {
121
- "@intlayer/chokidar": "8.0.4",
122
- "@intlayer/config": "8.0.4",
123
- "@intlayer/core": "8.0.4",
124
- "@intlayer/dictionaries-entry": "8.0.4",
125
- "@intlayer/types": "8.0.4",
126
- "@intlayer/webpack": "8.0.4",
121
+ "@intlayer/chokidar": "8.0.5",
122
+ "@intlayer/config": "8.0.5",
123
+ "@intlayer/core": "8.0.5",
124
+ "@intlayer/dictionaries-entry": "8.0.5",
125
+ "@intlayer/types": "8.0.5",
126
+ "@intlayer/webpack": "8.0.5",
127
127
  "defu": "6.1.4",
128
128
  "node-loader": "2.1.0",
129
- "react-intlayer": "8.0.4"
129
+ "react-intlayer": "8.0.5"
130
130
  },
131
131
  "devDependencies": {
132
- "@types/node": "25.0.10",
132
+ "@types/node": "25.2.2",
133
133
  "@types/react": ">=16.0.0",
134
134
  "@types/react-dom": ">=16.0.0",
135
135
  "@utils/ts-config": "1.0.4",
136
136
  "@utils/ts-config-types": "1.0.4",
137
137
  "@utils/tsdown-config": "1.0.4",
138
138
  "rimraf": "6.1.2",
139
- "tsdown": "0.20.1",
139
+ "tsdown": "0.20.3",
140
140
  "typescript": "5.9.3",
141
141
  "vitest": "4.0.18"
142
142
  },