next-intlayer 5.7.4 → 5.7.6-canary.0

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.
@@ -23,9 +23,9 @@ __export(client_exports, {
23
23
  useLocalePageRouter: () => import_useLocalePageRouter.useLocalePageRouter
24
24
  });
25
25
  module.exports = __toCommonJS(client_exports);
26
+ var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
26
27
  var import_useLocale = require('./useLocale.cjs');
27
28
  var import_useLocalePageRouter = require('./useLocalePageRouter.cjs');
28
- var import_IntlayerClientProvider = require('./IntlayerClientProvider.cjs');
29
29
  // Annotate the CommonJS export names for ESM import in node:
30
30
  0 && (module.exports = {
31
31
  IntlayerClientProvider,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export { useLocale } from './useLocale';\nexport { useLocalePageRouter } from './useLocalePageRouter';\nexport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './IntlayerClientProvider';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B;AAC1B,iCAAoC;AACpC,oCAGO;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './IntlayerClientProvider';\nexport { useLocale } from './useLocale';\nexport { useLocalePageRouter } from './useLocalePageRouter';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAGO;AACP,uBAA0B;AAC1B,iCAAoC;","names":[]}
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  useDictionary: () => import_react_intlayer.useDictionary,
27
27
  useDictionaryAsync: () => import_react_intlayer.useDictionaryAsync,
28
28
  useDictionaryDynamic: () => import_react_intlayer.useDictionaryDynamic,
29
+ useI18n: () => import_react_intlayer.useI18n,
29
30
  useIntlayer: () => import_react_intlayer.useIntlayer,
30
31
  useIntlayerAsync: () => import_react_intlayer.useIntlayerAsync,
31
32
  useLoadDynamic: () => import_react_intlayer.useLoadDynamic,
@@ -47,6 +48,7 @@ var import_generateStaticParams = require('./generateStaticParams.cjs');
47
48
  useDictionary,
48
49
  useDictionaryAsync,
49
50
  useDictionaryDynamic,
51
+ useI18n,
50
52
  useIntlayer,
51
53
  useIntlayerAsync,
52
54
  useLoadDynamic,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n IntlayerClientContext,\n MarkdownProvider,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useIntlayer,\n useIntlayerAsync,\n useLoadDynamic,\n useLocaleCookie,\n type IntlayerNode,\n} from 'react-intlayer';\nexport {\n IntlayerClientProvider,\n useLocale,\n useLocalePageRouter,\n type IntlayerClientProviderProps,\n} from './client/index';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14LayoutIntlayer,\n Next14PageIntlayer,\n Next15LayoutIntlayer,\n Next15PageIntlayer,\n NextLayoutIntlayer,\n NextPageIntlayer,\n} from './types/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAYO;AACP,oBAKO;AACP,kCAAqC;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n IntlayerClientContext,\n MarkdownProvider,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useIntlayerAsync,\n useLoadDynamic,\n useLocaleCookie,\n type IntlayerNode,\n} from 'react-intlayer';\nexport {\n IntlayerClientProvider,\n useLocale,\n useLocalePageRouter,\n type IntlayerClientProviderProps,\n} from './client/index';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14LayoutIntlayer,\n Next14PageIntlayer,\n Next15LayoutIntlayer,\n Next15PageIntlayer,\n NextLayoutIntlayer,\n NextPageIntlayer,\n} from './types/index';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAaO;AACP,oBAKO;AACP,kCAAqC;","names":[]}
@@ -42,7 +42,8 @@ const {
42
42
  prefixDefault,
43
43
  basePath,
44
44
  serverSetCookie,
45
- noPrefix
45
+ noPrefix,
46
+ detectLocaleOnPrefetchNoPrefix
46
47
  } = middleware;
47
48
  const isPrefetchRequest = (request) => {
48
49
  const purpose = request.headers.get("purpose");
@@ -53,10 +54,6 @@ const isPrefetchRequest = (request) => {
53
54
  };
54
55
  const intlayerMiddleware = (request, _event, _response) => {
55
56
  const pathname = request.nextUrl.pathname;
56
- const isPrefetch = isPrefetchRequest(request);
57
- if (isPrefetch) {
58
- return import_server.NextResponse.next();
59
- }
60
57
  const cookieLocale = getCookieLocale(request);
61
58
  const basePathTrailingSlash = basePath.endsWith("/");
62
59
  if (noPrefix) {
@@ -99,6 +96,15 @@ const getPathLocale = (pathname) => locales.find(
99
96
  );
100
97
  const handlePrefix = (request, cookieLocale, pathLocale, pathname, basePathTrailingSlash) => {
101
98
  if (!pathLocale) {
99
+ const isPrefetch = isPrefetchRequest(request);
100
+ if (isPrefetch && !detectLocaleOnPrefetchNoPrefix) {
101
+ return handleMissingPathLocale(
102
+ request,
103
+ defaultLocale,
104
+ pathname,
105
+ basePathTrailingSlash
106
+ );
107
+ }
102
108
  return handleMissingPathLocale(
103
109
  request,
104
110
  cookieLocale,
@@ -185,12 +191,16 @@ const constructPath = (locale, path, basePath2, basePathTrailingSlash, search) =
185
191
  return newPath;
186
192
  };
187
193
  const rewriteUrl = (request, newPath, locale) => {
188
- const response = import_server.NextResponse.rewrite(new URL(newPath, request.url));
194
+ const search = request.nextUrl.search;
195
+ const pathWithSearch = search && !newPath.includes("?") ? `${newPath}${search}` : newPath;
196
+ const response = import_server.NextResponse.rewrite(new URL(pathWithSearch, request.url));
189
197
  response.headers.set(headerName, locale);
190
198
  return response;
191
199
  };
192
200
  const redirectUrl = (request, newPath) => {
193
- return import_server.NextResponse.redirect(new URL(newPath, request.url));
201
+ const search = request.nextUrl.search;
202
+ const pathWithSearch = search && !newPath.includes("?") ? `${newPath}${search}` : newPath;
203
+ return import_server.NextResponse.redirect(new URL(pathWithSearch, request.url));
194
204
  };
195
205
  // Annotate the CommonJS export names for ESM import in node:
196
206
  0 && (module.exports = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middleware/intlayerMiddleware.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locales } from '@intlayer/config/client';\n\nimport {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\nimport { localeDetector } from './localeDetector';\n\nconst { internationalization, middleware } = configuration;\nconst { locales, defaultLocale } = internationalization;\nconst {\n headerName,\n cookieName,\n prefixDefault,\n basePath,\n serverSetCookie,\n noPrefix,\n} = middleware;\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/**\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 = (\n request: NextRequest,\n _event?: NextFetchEvent,\n _response?: NextResponse\n): NextResponse => {\n const pathname = request.nextUrl.pathname;\n const isPrefetch = isPrefetchRequest(request);\n\n // If the request is only a prefetch, we skip all locale redirection logic.\n // Returning `NextResponse.next()` lets Next.js serve the page as-is without\n // rewriting or redirecting. This avoids unnecessary redirects when the\n // browser (or Next.js router) silently prefetches a route like \"/\" while the\n // user is already on a locale-specific page (e.g. \"/fr\").\n if (isPrefetch) {\n return NextResponse.next();\n }\n\n const cookieLocale = getCookieLocale(request);\n const basePathTrailingSlash = basePath.endsWith('/');\n\n if (\n noPrefix // If the application is configured not to use locale prefixes in URLs\n ) {\n return handleNoPrefix(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n const pathLocale = getPathLocale(pathname);\n\n return handlePrefix(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 getCookieLocale = (request: NextRequest): Locales | undefined => {\n if (!cookieName) return undefined;\n const cookieValue = request.cookies.get(cookieName)?.value as Locales;\n if (cookieValue && locales.includes(cookieValue)) {\n return cookieValue;\n }\n};\n\n/**\n * Handles the case where URLs do not have locale prefixes.\n *\n * @param request - The incoming Next.js request object.\n * @param cookieLocale - 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 rewritten response with the locale applied.\n */\nconst handleNoPrefix = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n const locale = cookieLocale ?? defaultLocale;\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n return rewriteUrl(request, newPath, 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): Locales | undefined =>\n locales.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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n !pathLocale // If the URL does not contain a locale prefix\n ) {\n return handleMissingPathLocale(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n // If the URL contains a locale prefix\n return handleExistingPathLocale(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n let locale = (cookieLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locales;\n if (!locales.includes(locale)) {\n locale = defaultLocale;\n }\n\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n\n return prefixDefault || locale !== defaultLocale\n ? redirectUrl(request, newPath)\n : rewriteUrl(request, newPath, locale);\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 cookieLocale - 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 handleExistingPathLocale = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If the cookie locale is set and differs from the locale in the URL, and server should not always set cookie\n cookieLocale &&\n cookieLocale !== pathLocale &&\n serverSetCookie !== 'always'\n ) {\n const newPath = handleCookieLocaleMismatch(\n request,\n pathname,\n pathLocale,\n cookieLocale,\n basePath,\n basePathTrailingSlash\n );\n return redirectUrl(request, newPath);\n }\n\n // If the cookie locale matches the path locale, or cookie locale is not set, or serverSetCookie is 'always'\n return handleDefaultLocaleRedirect(\n request,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - The locale from the cookie.\n * @param basePath - The base path of the application.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The new URL path with the correct locale.\n */\nconst handleCookieLocaleMismatch = (\n request: NextRequest,\n pathname: string,\n pathLocale: Locales,\n cookieLocale: Locales,\n basePath: string,\n basePathTrailingSlash: boolean\n): string => {\n // Replace the pathLocale in the pathname with the cookieLocale\n const newPath = pathname.replace(`/${pathLocale}`, `/${cookieLocale}`);\n\n return constructPath(\n cookieLocale,\n newPath,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n};\n\n/**\n * Handles redirection when the default locale is used and prefixing is not required.\n *\n * @param request - The incoming Next.js request object.\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 rewritten response without the locale prefix.\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If default locale should not be prefixed and the pathLocale is the defaultLocale\n !prefixDefault &&\n pathLocale === defaultLocale\n ) {\n let pathWithoutLocale = pathname.slice(`/${pathLocale}`.length) ?? '/';\n\n if (basePathTrailingSlash) {\n pathWithoutLocale = pathWithoutLocale.slice(1);\n }\n\n if (request.nextUrl.search) {\n pathWithoutLocale += request.nextUrl.search;\n }\n\n return rewriteUrl(request, `${basePath}${pathWithoutLocale}`, pathLocale);\n }\n\n // If prefixing default locale is required or pathLocale is not the defaultLocale\n\n return rewriteUrl(request, pathname, 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 basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @param [search] - The query string from the request URL (optional).\n * @returns - The constructed new path.\n */\nconst constructPath = (\n locale: Locales,\n path: string,\n basePath: string,\n basePathTrailingSlash: boolean,\n search?: string\n): string => {\n let newPath = `${locale}${path}`;\n\n newPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${newPath}`;\n if (search) {\n newPath += search;\n }\n return newPath;\n};\n\n/**\n * Rewrites the URL to the new path and sets the locale header.\n *\n * @param request - The incoming Next.js request object.\n * @param newPath - The new path to rewrite to.\n * @param locale - The locale to set in the response header.\n * @returns - The rewritten response.\n */\nconst rewriteUrl = (\n request: NextRequest,\n newPath: string,\n locale: Locales\n): NextResponse => {\n const response = NextResponse.rewrite(new URL(newPath, request.url));\n response.headers.set(headerName, locale);\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 return NextResponse.redirect(new URL(newPath, request.url));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAG1B,oBAIO;AACP,4BAA+B;AAE/B,MAAM,EAAE,sBAAsB,WAAW,IAAI,aAAAA;AAC7C,MAAM,EAAE,SAAS,cAAc,IAAI;AACnC,MAAM;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAI;AAgBJ,MAAM,oBAAoB,CAAC,YAAkC;AAC3D,QAAM,UAAU,QAAQ,QAAQ,IAAI,SAAS;AAC7C,QAAM,qBAAqB,QAAQ,QAAQ,IAAI,sBAAsB;AACrE,QAAM,UAAU,QAAQ,QAAQ,IAAI,UAAU;AAC9C,QAAM,cAAc,QAAQ,QAAQ,IAAI,eAAe;AAEvD,SACE,YAAY,cACZ,uBAAuB,OACvB,CAAC,CAAC,WACF,CAAC,CAAC;AAEN;AAyBO,MAAM,qBAAqB,CAChC,SACA,QACA,cACiB;AACjB,QAAM,WAAW,QAAQ,QAAQ;AACjC,QAAM,aAAa,kBAAkB,OAAO;AAO5C,MAAI,YAAY;AACd,WAAO,2BAAa,KAAK;AAAA,EAC3B;AAEA,QAAM,eAAe,gBAAgB,OAAO;AAC5C,QAAM,wBAAwB,SAAS,SAAS,GAAG;AAEnD,MACE,UACA;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa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,IAAI,IAAI,SAAS,QAAQ,GAAG,CAAC;AACnE,WAAS,QAAQ,IAAI,YAAY,MAAM;AACvC,SAAO;AACT;AASA,MAAM,cAAc,CAAC,SAAsB,YAAkC;AAC3E,SAAO,2BAAa,SAAS,IAAI,IAAI,SAAS,QAAQ,GAAG,CAAC;AAC5D;","names":["configuration","basePath"]}
1
+ {"version":3,"sources":["../../../src/middleware/intlayerMiddleware.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locales } from '@intlayer/config/client';\n\nimport {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\nimport { localeDetector } from './localeDetector';\n\nconst { internationalization, middleware } = configuration;\nconst { locales, defaultLocale } = internationalization;\nconst {\n headerName,\n cookieName,\n prefixDefault,\n basePath,\n serverSetCookie,\n noPrefix,\n detectLocaleOnPrefetchNoPrefix,\n} = middleware;\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/**\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 = (\n request: NextRequest,\n _event?: NextFetchEvent,\n _response?: NextResponse\n): NextResponse => {\n const pathname = request.nextUrl.pathname;\n\n const cookieLocale = getCookieLocale(request);\n const basePathTrailingSlash = basePath.endsWith('/');\n\n if (\n noPrefix // If the application is configured not to use locale prefixes in URLs\n ) {\n return handleNoPrefix(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n const pathLocale = getPathLocale(pathname);\n\n return handlePrefix(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 getCookieLocale = (request: NextRequest): Locales | undefined => {\n if (!cookieName) return undefined;\n const cookieValue = request.cookies.get(cookieName)?.value as Locales;\n if (cookieValue && locales.includes(cookieValue)) {\n return cookieValue;\n }\n};\n\n/**\n * Handles the case where URLs do not have locale prefixes.\n *\n * @param request - The incoming Next.js request object.\n * @param cookieLocale - 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 rewritten response with the locale applied.\n */\nconst handleNoPrefix = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n const locale = cookieLocale ?? defaultLocale;\n\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n return rewriteUrl(request, newPath, 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): Locales | undefined =>\n locales.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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n !pathLocale // If the URL does not contain a locale prefix\n ) {\n const isPrefetch = isPrefetchRequest(request);\n\n if (isPrefetch && !detectLocaleOnPrefetchNoPrefix) {\n return handleMissingPathLocale(\n request,\n defaultLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n return handleMissingPathLocale(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n // If the URL contains a locale prefix\n return handleExistingPathLocale(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n let locale = (cookieLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locales;\n if (!locales.includes(locale)) {\n locale = defaultLocale;\n }\n\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n\n return prefixDefault || locale !== defaultLocale\n ? redirectUrl(request, newPath)\n : rewriteUrl(request, newPath, locale);\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 cookieLocale - 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 handleExistingPathLocale = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If the cookie locale is set and differs from the locale in the URL, and server should not always set cookie\n cookieLocale &&\n cookieLocale !== pathLocale &&\n serverSetCookie !== 'always'\n ) {\n const newPath = handleCookieLocaleMismatch(\n request,\n pathname,\n pathLocale,\n cookieLocale,\n basePath,\n basePathTrailingSlash\n );\n return redirectUrl(request, newPath);\n }\n\n // If the cookie locale matches the path locale, or cookie locale is not set, or serverSetCookie is 'always'\n return handleDefaultLocaleRedirect(\n request,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - The locale from the cookie.\n * @param basePath - The base path of the application.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The new URL path with the correct locale.\n */\nconst handleCookieLocaleMismatch = (\n request: NextRequest,\n pathname: string,\n pathLocale: Locales,\n cookieLocale: Locales,\n basePath: string,\n basePathTrailingSlash: boolean\n): string => {\n // Replace the pathLocale in the pathname with the cookieLocale\n const newPath = pathname.replace(`/${pathLocale}`, `/${cookieLocale}`);\n\n return constructPath(\n cookieLocale,\n newPath,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n};\n\n/**\n * Handles redirection when the default locale is used and prefixing is not required.\n *\n * @param request - The incoming Next.js request object.\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 rewritten response without the locale prefix.\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If default locale should not be prefixed and the pathLocale is the defaultLocale\n !prefixDefault &&\n pathLocale === defaultLocale\n ) {\n let pathWithoutLocale = pathname.slice(`/${pathLocale}`.length) ?? '/';\n\n if (basePathTrailingSlash) {\n pathWithoutLocale = pathWithoutLocale.slice(1);\n }\n\n if (request.nextUrl.search) {\n pathWithoutLocale += request.nextUrl.search;\n }\n\n return rewriteUrl(request, `${basePath}${pathWithoutLocale}`, pathLocale);\n }\n\n // If prefixing default locale is required or pathLocale is not the defaultLocale\n\n return rewriteUrl(request, pathname, 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 basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @param [search] - The query string from the request URL (optional).\n * @returns - The constructed new path.\n */\nconst constructPath = (\n locale: Locales,\n path: string,\n basePath: string,\n basePathTrailingSlash: boolean,\n search?: string\n): string => {\n let newPath = `${locale}${path}`;\n\n newPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${newPath}`;\n if (search) {\n newPath += search;\n }\n return newPath;\n};\n\n/**\n * Rewrites the URL to the new path and sets the locale header.\n *\n * @param request - The incoming Next.js request object.\n * @param newPath - The new path to rewrite to.\n * @param locale - The locale to set in the response header.\n * @returns - The rewritten response.\n */\nconst rewriteUrl = (\n request: NextRequest,\n newPath: string,\n locale: Locales\n): NextResponse => {\n // Ensure we preserve the original search params if they were present and not explicitly included in newPath\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n const response = NextResponse.rewrite(new URL(pathWithSearch, request.url));\n response.headers.set(headerName, locale);\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 // Ensure we preserve the original search params if they were present and not explicitly included in newPath\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n return NextResponse.redirect(new URL(pathWithSearch, request.url));\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA0B;AAG1B,oBAIO;AACP,4BAA+B;AAE/B,MAAM,EAAE,sBAAsB,WAAW,IAAI,aAAAA;AAC7C,MAAM,EAAE,SAAS,cAAc,IAAI;AACnC,MAAM;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAI;AAgBJ,MAAM,oBAAoB,CAAC,YAAkC;AAC3D,QAAM,UAAU,QAAQ,QAAQ,IAAI,SAAS;AAC7C,QAAM,qBAAqB,QAAQ,QAAQ,IAAI,sBAAsB;AACrE,QAAM,UAAU,QAAQ,QAAQ,IAAI,UAAU;AAC9C,QAAM,cAAc,QAAQ,QAAQ,IAAI,eAAe;AAEvD,SACE,YAAY,cACZ,uBAAuB,OACvB,CAAC,CAAC,WACF,CAAC,CAAC;AAEN;AAyBO,MAAM,qBAAqB,CAChC,SACA,QACA,cACiB;AACjB,QAAM,WAAW,QAAQ,QAAQ;AAEjC,QAAM,eAAe,gBAAgB,OAAO;AAC5C,QAAM,wBAAwB,SAAS,SAAS,GAAG;AAEnD,MACE,UACA;AACA,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,QAAM,aAAa,cAAc,QAAQ;AAEzC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAQA,MAAM,kBAAkB,CAAC,YAA8C;AACrE,MAAI,CAAC,WAAY,QAAO;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BACJ,UAAU,CAAC,QAAQ,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,KAAK;AAE7D,QAAM,WAAW,2BAAa,QAAQ,IAAI,IAAI,gBAAgB,QAAQ,GAAG,CAAC;AAC1E,WAAS,QAAQ,IAAI,YAAY,MAAM;AACvC,SAAO;AACT;AASA,MAAM,cAAc,CAAC,SAAsB,YAAkC;AAE3E,QAAM,SAAS,QAAQ,QAAQ;AAC/B,QAAM,iBACJ,UAAU,CAAC,QAAQ,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,KAAK;AAE7D,SAAO,2BAAa,SAAS,IAAI,IAAI,gBAAgB,QAAQ,GAAG,CAAC;AACnE;","names":["configuration","basePath"]}
@@ -24,6 +24,7 @@ __export(server_exports, {
24
24
  t: () => import_server.t,
25
25
  useDictionary: () => import_server.useDictionary,
26
26
  useDictionaryDynamic: () => import_server.useDictionaryDynamic,
27
+ useI18n: () => import_server.useI18n,
27
28
  useIntlayer: () => import_server.useIntlayer,
28
29
  useLoadDynamic: () => import_server.useLoadDynamic,
29
30
  useLocale: () => import_server.useLocale,
@@ -40,6 +41,7 @@ var import_withIntlayer = require('./withIntlayer.cjs');
40
41
  t,
41
42
  useDictionary,
42
43
  useDictionaryDynamic,
44
+ useI18n,
43
45
  useIntlayer,
44
46
  useLoadDynamic,
45
47
  useLocale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAUO;AACP,0BAA6B;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAWO;AACP,0BAA6B;","names":[]}
@@ -122,7 +122,8 @@ const withIntlayer = async (nextConfig = {}) => {
122
122
  const relativeConfigurationPath = (0, import_path.relative)(baseDir, configurationPath);
123
123
  const turboConfig = {
124
124
  resolveAlias: {
125
- // "prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly."
125
+ // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.
126
+ // Normalize the path to avoid issues with the path separator on Windows
126
127
  "@intlayer/dictionaries-entry": (0, import_config.normalizePath)(
127
128
  `./${relativeDictionariesPath}`
128
129
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { prepareIntlayer, runOnce } from '@intlayer/chokidar';\nimport {\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n normalizePath,\n} from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport fg from 'fast-glob';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = () => {\n try {\n ESMxCJSRequire.resolve('@intlayer/swc');\n return true;\n } catch (e) {\n return false;\n }\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig\n): Partial<NextConfig> => {\n const { optimize, traversePattern, importMode } = intlayerConfig.build;\n const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } =\n intlayerConfig.content;\n\n if (!optimize) return {};\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable();\n\n if (!isSwcPluginAvailable) return {};\n\n const logger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(baseDir, '.next', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => logger('Intlayer prune plugin is enabled'),\n 1000 * 10 // 10 seconds\n );\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n ESMxCJSRequire.resolve('@intlayer/swc'),\n {\n dictionariesDir,\n dictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n } as any,\n ],\n ],\n },\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): Promise<NextConfig & T> => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n const sentinelPath = join(\n intlayerConfig.content.baseDir,\n '.next',\n 'cache',\n 'intlayer-prepared.lock'\n );\n\n // Only call prepareIntlayer once per server startup\n await runOnce(sentinelPath, () => prepareIntlayer(intlayerConfig));\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // \"prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly.\"\n '@intlayer/dictionaries-entry': normalizePath(\n `./${relativeDictionariesPath}`\n ),\n '@intlayer/unmerged-dictionaries-entry': normalizePath(\n `./${relativeUnmergedDictionariesPath}`\n ),\n '@intlayer/config/built': normalizePath(`./${relativeConfigurationPath}`),\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 newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // Skip preparation when running next start (production mode)\n const isBuildCommand =\n process.env.npm_lifecycle_event === 'build' ||\n process.argv.some((arg) => arg === 'build');\n\n if (!isBuildCommand && isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(intlayerConfig);\n\n const intlayerNextConfig: Partial<NextConfig> = merge(pruneConfig, newConfig);\n\n // Merge the new config with the user's config\n const result = merge(nextConfig, intlayerNextConfig) as NextConfig & T;\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyC;AACzC,oBAMO;AACP,qBAA+B;AAC/B,uBAAkB;AAClB,uBAAe;AAGf,kBAAwC;AACxC,4BAAgC;AAChC,4BAA+B;AAG/B,MAAM,qBACJ,QAAQ,IAAI,sBAAsB,SAAS,SAAS;AACtD,MAAM,kBAAc,sCAAe;AACnC,MAAM,kBAAc,uCAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,kBAAc,uCAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,w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A,QACT;AAAA,MACF;AAAA,IACN;AAAA,IAEA,SAAS,CAAC,QAA4B,YAA8B;AAElE,UAAI,OAAO,WAAW,YAAY,YAAY;AAC5C,iBAAS,WAAW,QAAQ,QAAQ,OAAO;AAAA,MAC7C;AAGA,aAAO,QAAQ,QAAQ;AAAA,QACrB,GAAG,OAAO,QAAQ;AAAA,QAClB,oCAAgC,qBAAQ,wBAAwB;AAAA,QAChE,6CAAyC;AAAA,UACvC;AAAA,QACF;AAAA,QACA,8BAA0B,qBAAQ,yBAAyB;AAAA,MAC7D;AAGA,aAAO,UAAU,KAAK;AAAA,QACpB,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,IAAI;AAAA,QACJ,UAAU;AAAA,QACV,UAAU;AAAA,MACZ,CAAC;AAGD,aAAO,OAAO,MAAM,KAAK;AAAA,QACvB,MAAM;AAAA,QACN,QAAQ;AAAA,MACV,CAAC;AAGD,YAAM,EAAE,UAAU,YAAY,IAAI;AAGlC,YAAM,iBACJ,QAAQ,IAAI,wBAAwB,WACpC,QAAQ,KAAK,KAAK,CAAC,QAAQ,QAAQ,OAAO;AAE5C,UAAI,CAAC,kBAAkB,YAAY,gBAAgB,UAAU;AAC3D,eAAO,QAAQ,KAAK,IAAI,8BAAe,CAAC;AAAA,MAC1C;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,cAAmC,eAAe,cAAc;AAEtE,QAAM,yBAA0C,iBAAAC,SAAM,aAAa,SAAS;AAG5E,QAAM,aAAS,iBAAAA,SAAM,YAAY,kBAAkB;AAEnD,SAAO;AACT;","names":["fg","merge"]}
1
+ {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { prepareIntlayer, runOnce } from '@intlayer/chokidar';\nimport {\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n normalizePath,\n} from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport fg from 'fast-glob';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = () => {\n try {\n ESMxCJSRequire.resolve('@intlayer/swc');\n return true;\n } catch (e) {\n return false;\n }\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig\n): Partial<NextConfig> => {\n const { optimize, traversePattern, importMode } = intlayerConfig.build;\n const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } =\n intlayerConfig.content;\n\n if (!optimize) return {};\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable();\n\n if (!isSwcPluginAvailable) return {};\n\n const logger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(baseDir, '.next', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => logger('Intlayer prune plugin is enabled'),\n 1000 * 10 // 10 seconds\n );\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n ESMxCJSRequire.resolve('@intlayer/swc'),\n {\n dictionariesDir,\n dictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n } as any,\n ],\n ],\n },\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): Promise<NextConfig & T> => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n const sentinelPath = join(\n intlayerConfig.content.baseDir,\n '.next',\n 'cache',\n 'intlayer-prepared.lock'\n );\n\n // Only call prepareIntlayer once per server startup\n await runOnce(sentinelPath, () => prepareIntlayer(intlayerConfig));\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n // Normalize the path to avoid issues with the path separator on Windows\n '@intlayer/dictionaries-entry': normalizePath(\n `./${relativeDictionariesPath}`\n ),\n '@intlayer/unmerged-dictionaries-entry': normalizePath(\n `./${relativeUnmergedDictionariesPath}`\n ),\n '@intlayer/config/built': normalizePath(`./${relativeConfigurationPath}`),\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 newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // Skip preparation when running next start (production mode)\n const isBuildCommand =\n process.env.npm_lifecycle_event === 'build' ||\n process.argv.some((arg) => arg === 'build');\n\n if (!isBuildCommand && isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(intlayerConfig);\n\n const intlayerNextConfig: Partial<NextConfig> = merge(pruneConfig, newConfig);\n\n // Merge the new config with the user's config\n const result = merge(nextConfig, intlayerNextConfig) as NextConfig & T;\n\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;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BAA0C,iBAAAC,SAAM,aAAa,SAAS;AAG5E,QAAM,aAAS,iBAAAA,SAAM,YAAY,kBAAkB;AAEnD,SAAO;AACT;","names":["fg","merge"]}
@@ -1,8 +1,8 @@
1
- import { useLocale } from "./useLocale.mjs";
2
- import { useLocalePageRouter } from "./useLocalePageRouter.mjs";
3
1
  import {
4
2
  IntlayerClientProvider
5
3
  } from "./IntlayerClientProvider.mjs";
4
+ import { useLocale } from "./useLocale.mjs";
5
+ import { useLocalePageRouter } from "./useLocalePageRouter.mjs";
6
6
  export {
7
7
  IntlayerClientProvider,
8
8
  useLocale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export { useLocale } from './useLocale';\nexport { useLocalePageRouter } from './useLocalePageRouter';\nexport {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './IntlayerClientProvider';\n"],"mappings":"AAAA,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,OAEK;","names":[]}
1
+ {"version":3,"sources":["../../../src/client/index.ts"],"sourcesContent":["export {\n IntlayerClientProvider,\n type IntlayerClientProviderProps,\n} from './IntlayerClientProvider';\nexport { useLocale } from './useLocale';\nexport { useLocalePageRouter } from './useLocalePageRouter';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAEK;AACP,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;","names":[]}
@@ -5,6 +5,7 @@ import {
5
5
  useDictionary,
6
6
  useDictionaryAsync,
7
7
  useDictionaryDynamic,
8
+ useI18n,
8
9
  useIntlayer,
9
10
  useIntlayerAsync,
10
11
  useLoadDynamic,
@@ -25,6 +26,7 @@ export {
25
26
  useDictionary,
26
27
  useDictionaryAsync,
27
28
  useDictionaryDynamic,
29
+ useI18n,
28
30
  useIntlayer,
29
31
  useIntlayerAsync,
30
32
  useLoadDynamic,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n IntlayerClientContext,\n MarkdownProvider,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useIntlayer,\n useIntlayerAsync,\n useLoadDynamic,\n useLocaleCookie,\n type IntlayerNode,\n} from 'react-intlayer';\nexport {\n IntlayerClientProvider,\n useLocale,\n useLocalePageRouter,\n type IntlayerClientProviderProps,\n} from './client/index';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14LayoutIntlayer,\n Next14PageIntlayer,\n Next15LayoutIntlayer,\n Next15PageIntlayer,\n NextLayoutIntlayer,\n NextPageIntlayer,\n} from './types/index';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,4BAA4B;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n IntlayerClientContext,\n MarkdownProvider,\n t,\n useDictionary,\n useDictionaryAsync,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useIntlayerAsync,\n useLoadDynamic,\n useLocaleCookie,\n type IntlayerNode,\n} from 'react-intlayer';\nexport {\n IntlayerClientProvider,\n useLocale,\n useLocalePageRouter,\n type IntlayerClientProviderProps,\n} from './client/index';\nexport { generateStaticParams } from './generateStaticParams';\nexport type {\n LocalParams,\n LocalPromiseParams,\n Next14LayoutIntlayer,\n Next14PageIntlayer,\n Next15LayoutIntlayer,\n Next15PageIntlayer,\n NextLayoutIntlayer,\n NextPageIntlayer,\n} from './types/index';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,4BAA4B;","names":[]}
@@ -11,7 +11,8 @@ const {
11
11
  prefixDefault,
12
12
  basePath,
13
13
  serverSetCookie,
14
- noPrefix
14
+ noPrefix,
15
+ detectLocaleOnPrefetchNoPrefix
15
16
  } = middleware;
16
17
  const isPrefetchRequest = (request) => {
17
18
  const purpose = request.headers.get("purpose");
@@ -22,10 +23,6 @@ const isPrefetchRequest = (request) => {
22
23
  };
23
24
  const intlayerMiddleware = (request, _event, _response) => {
24
25
  const pathname = request.nextUrl.pathname;
25
- const isPrefetch = isPrefetchRequest(request);
26
- if (isPrefetch) {
27
- return NextResponse.next();
28
- }
29
26
  const cookieLocale = getCookieLocale(request);
30
27
  const basePathTrailingSlash = basePath.endsWith("/");
31
28
  if (noPrefix) {
@@ -68,6 +65,15 @@ const getPathLocale = (pathname) => locales.find(
68
65
  );
69
66
  const handlePrefix = (request, cookieLocale, pathLocale, pathname, basePathTrailingSlash) => {
70
67
  if (!pathLocale) {
68
+ const isPrefetch = isPrefetchRequest(request);
69
+ if (isPrefetch && !detectLocaleOnPrefetchNoPrefix) {
70
+ return handleMissingPathLocale(
71
+ request,
72
+ defaultLocale,
73
+ pathname,
74
+ basePathTrailingSlash
75
+ );
76
+ }
71
77
  return handleMissingPathLocale(
72
78
  request,
73
79
  cookieLocale,
@@ -154,12 +160,16 @@ const constructPath = (locale, path, basePath2, basePathTrailingSlash, search) =
154
160
  return newPath;
155
161
  };
156
162
  const rewriteUrl = (request, newPath, locale) => {
157
- const response = NextResponse.rewrite(new URL(newPath, request.url));
163
+ const search = request.nextUrl.search;
164
+ const pathWithSearch = search && !newPath.includes("?") ? `${newPath}${search}` : newPath;
165
+ const response = NextResponse.rewrite(new URL(pathWithSearch, request.url));
158
166
  response.headers.set(headerName, locale);
159
167
  return response;
160
168
  };
161
169
  const redirectUrl = (request, newPath) => {
162
- return NextResponse.redirect(new URL(newPath, request.url));
170
+ const search = request.nextUrl.search;
171
+ const pathWithSearch = search && !newPath.includes("?") ? `${newPath}${search}` : newPath;
172
+ return NextResponse.redirect(new URL(pathWithSearch, request.url));
163
173
  };
164
174
  export {
165
175
  intlayerMiddleware
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/middleware/intlayerMiddleware.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locales } from '@intlayer/config/client';\n\nimport {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\nimport { localeDetector } from './localeDetector';\n\nconst { internationalization, middleware } = configuration;\nconst { locales, defaultLocale } = internationalization;\nconst {\n headerName,\n cookieName,\n prefixDefault,\n basePath,\n serverSetCookie,\n noPrefix,\n} = middleware;\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/**\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 = (\n request: NextRequest,\n _event?: NextFetchEvent,\n _response?: NextResponse\n): NextResponse => {\n const pathname = request.nextUrl.pathname;\n const isPrefetch = isPrefetchRequest(request);\n\n // If the request is only a prefetch, we skip all locale redirection logic.\n // Returning `NextResponse.next()` lets Next.js serve the page as-is without\n // rewriting or redirecting. This avoids unnecessary redirects when the\n // browser (or Next.js router) silently prefetches a route like \"/\" while the\n // user is already on a locale-specific page (e.g. \"/fr\").\n if (isPrefetch) {\n return NextResponse.next();\n }\n\n const cookieLocale = getCookieLocale(request);\n const basePathTrailingSlash = basePath.endsWith('/');\n\n if (\n noPrefix // If the application is configured not to use locale prefixes in URLs\n ) {\n return handleNoPrefix(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n const pathLocale = getPathLocale(pathname);\n\n return handlePrefix(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 getCookieLocale = (request: NextRequest): Locales | undefined => {\n if (!cookieName) return undefined;\n const cookieValue = request.cookies.get(cookieName)?.value as Locales;\n if (cookieValue && locales.includes(cookieValue)) {\n return cookieValue;\n }\n};\n\n/**\n * Handles the case where URLs do not have locale prefixes.\n *\n * @param request - The incoming Next.js request object.\n * @param cookieLocale - 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 rewritten response with the locale applied.\n */\nconst handleNoPrefix = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n const locale = cookieLocale ?? defaultLocale;\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n return rewriteUrl(request, newPath, 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): Locales | undefined =>\n locales.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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n !pathLocale // If the URL does not contain a locale prefix\n ) {\n return handleMissingPathLocale(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n // If the URL contains a locale prefix\n return handleExistingPathLocale(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n let locale = (cookieLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locales;\n if (!locales.includes(locale)) {\n locale = defaultLocale;\n }\n\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n\n return prefixDefault || locale !== defaultLocale\n ? redirectUrl(request, newPath)\n : rewriteUrl(request, newPath, locale);\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 cookieLocale - 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 handleExistingPathLocale = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If the cookie locale is set and differs from the locale in the URL, and server should not always set cookie\n cookieLocale &&\n cookieLocale !== pathLocale &&\n serverSetCookie !== 'always'\n ) {\n const newPath = handleCookieLocaleMismatch(\n request,\n pathname,\n pathLocale,\n cookieLocale,\n basePath,\n basePathTrailingSlash\n );\n return redirectUrl(request, newPath);\n }\n\n // If the cookie locale matches the path locale, or cookie locale is not set, or serverSetCookie is 'always'\n return handleDefaultLocaleRedirect(\n request,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - The locale from the cookie.\n * @param basePath - The base path of the application.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The new URL path with the correct locale.\n */\nconst handleCookieLocaleMismatch = (\n request: NextRequest,\n pathname: string,\n pathLocale: Locales,\n cookieLocale: Locales,\n basePath: string,\n basePathTrailingSlash: boolean\n): string => {\n // Replace the pathLocale in the pathname with the cookieLocale\n const newPath = pathname.replace(`/${pathLocale}`, `/${cookieLocale}`);\n\n return constructPath(\n cookieLocale,\n newPath,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n};\n\n/**\n * Handles redirection when the default locale is used and prefixing is not required.\n *\n * @param request - The incoming Next.js request object.\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 rewritten response without the locale prefix.\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If default locale should not be prefixed and the pathLocale is the defaultLocale\n !prefixDefault &&\n pathLocale === defaultLocale\n ) {\n let pathWithoutLocale = pathname.slice(`/${pathLocale}`.length) ?? '/';\n\n if (basePathTrailingSlash) {\n pathWithoutLocale = pathWithoutLocale.slice(1);\n }\n\n if (request.nextUrl.search) {\n pathWithoutLocale += request.nextUrl.search;\n }\n\n return rewriteUrl(request, `${basePath}${pathWithoutLocale}`, pathLocale);\n }\n\n // If prefixing default locale is required or pathLocale is not the defaultLocale\n\n return rewriteUrl(request, pathname, 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 basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @param [search] - The query string from the request URL (optional).\n * @returns - The constructed new path.\n */\nconst constructPath = (\n locale: Locales,\n path: string,\n basePath: string,\n basePathTrailingSlash: boolean,\n search?: string\n): string => {\n let newPath = `${locale}${path}`;\n\n newPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${newPath}`;\n if (search) {\n newPath += search;\n }\n return newPath;\n};\n\n/**\n * Rewrites the URL to the new path and sets the locale header.\n *\n * @param request - The incoming Next.js request object.\n * @param newPath - The new path to rewrite to.\n * @param locale - The locale to set in the response header.\n * @returns - The rewritten response.\n */\nconst rewriteUrl = (\n request: NextRequest,\n newPath: string,\n locale: Locales\n): NextResponse => {\n const response = NextResponse.rewrite(new URL(newPath, request.url));\n response.headers.set(headerName, locale);\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 return NextResponse.redirect(new URL(newPath, request.url));\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAG1B;AAAA,EA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AAU,IAAI,IAAI,YAAY,EAAE;AAErE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACAA;AAAA,IACA;AAAA,IACA,QAAQ,QAAQ;AAAA,EAClB;AACF;AAWA,MAAM,8BAA8B,CAClC,SACA,YACA,UACA,0BACiB;AACjB;AAAA;AAAA,IAEE,CAAC,iBACD,eAAe;AAAA,IACf;AACA,QAAI,oBAAoB,SAAS,MAAM,IAAI,UAAU,GAAG,MAAM,KAAK;AAEnE,QAAI,uBAAuB;AACzB,0BAAoB,kBAAkB,MAAM,CAAC;AAAA,IAC/C;AAEA,QAAI,QAAQ,QAAQ,QAAQ;AAC1B,2BAAqB,QAAQ,QAAQ;AAAA,IACvC;AAEA,WAAO,WAAW,SAAS,GAAG,QAAQ,GAAG,iBAAiB,IAAI,UAAU;AAAA,EAC1E;AAIA,SAAO,WAAW,SAAS,UAAU,UAAU;AACjD;AAYA,MAAM,gBAAgB,CACpB,QACA,MACAA,WACA,uBACA,WACW;AACX,MAAI,UAAU,GAAG,MAAM,GAAG,IAAI;AAE9B,YAAU,GAAGA,SAAQ,GAAG,wBAAwB,KAAK,GAAG,GAAG,OAAO;AAClE,MAAI,QAAQ;AACV,eAAW;AAAA,EACb;AACA,SAAO;AACT;AAUA,MAAM,aAAa,CACjB,SACA,SACA,WACiB;AACjB,QAAM,WAAW,aAAa,QAAQ,IAAI,IAAI,SAAS,QAAQ,GAAG,CAAC;AACnE,WAAS,QAAQ,IAAI,YAAY,MAAM;AACvC,SAAO;AACT;AASA,MAAM,cAAc,CAAC,SAAsB,YAAkC;AAC3E,SAAO,aAAa,SAAS,IAAI,IAAI,SAAS,QAAQ,GAAG,CAAC;AAC5D;","names":["basePath"]}
1
+ {"version":3,"sources":["../../../src/middleware/intlayerMiddleware.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { type Locales } from '@intlayer/config/client';\n\nimport {\n type NextFetchEvent,\n type NextRequest,\n NextResponse,\n} from 'next/server';\nimport { localeDetector } from './localeDetector';\n\nconst { internationalization, middleware } = configuration;\nconst { locales, defaultLocale } = internationalization;\nconst {\n headerName,\n cookieName,\n prefixDefault,\n basePath,\n serverSetCookie,\n noPrefix,\n detectLocaleOnPrefetchNoPrefix,\n} = middleware;\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/**\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 = (\n request: NextRequest,\n _event?: NextFetchEvent,\n _response?: NextResponse\n): NextResponse => {\n const pathname = request.nextUrl.pathname;\n\n const cookieLocale = getCookieLocale(request);\n const basePathTrailingSlash = basePath.endsWith('/');\n\n if (\n noPrefix // If the application is configured not to use locale prefixes in URLs\n ) {\n return handleNoPrefix(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n const pathLocale = getPathLocale(pathname);\n\n return handlePrefix(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 getCookieLocale = (request: NextRequest): Locales | undefined => {\n if (!cookieName) return undefined;\n const cookieValue = request.cookies.get(cookieName)?.value as Locales;\n if (cookieValue && locales.includes(cookieValue)) {\n return cookieValue;\n }\n};\n\n/**\n * Handles the case where URLs do not have locale prefixes.\n *\n * @param request - The incoming Next.js request object.\n * @param cookieLocale - 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 rewritten response with the locale applied.\n */\nconst handleNoPrefix = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n const locale = cookieLocale ?? defaultLocale;\n\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n return rewriteUrl(request, newPath, 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): Locales | undefined =>\n locales.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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n !pathLocale // If the URL does not contain a locale prefix\n ) {\n const isPrefetch = isPrefetchRequest(request);\n\n if (isPrefetch && !detectLocaleOnPrefetchNoPrefix) {\n return handleMissingPathLocale(\n request,\n defaultLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n return handleMissingPathLocale(\n request,\n cookieLocale,\n pathname,\n basePathTrailingSlash\n );\n }\n\n // If the URL contains a locale prefix\n return handleExistingPathLocale(\n request,\n cookieLocale,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - 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 cookieLocale: Locales | undefined,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n let locale = (cookieLocale ??\n localeDetector?.(request) ??\n defaultLocale) as Locales;\n if (!locales.includes(locale)) {\n locale = defaultLocale;\n }\n\n const newPath = constructPath(\n locale,\n pathname,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n\n return prefixDefault || locale !== defaultLocale\n ? redirectUrl(request, newPath)\n : rewriteUrl(request, newPath, locale);\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 cookieLocale - 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 handleExistingPathLocale = (\n request: NextRequest,\n cookieLocale: Locales | undefined,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If the cookie locale is set and differs from the locale in the URL, and server should not always set cookie\n cookieLocale &&\n cookieLocale !== pathLocale &&\n serverSetCookie !== 'always'\n ) {\n const newPath = handleCookieLocaleMismatch(\n request,\n pathname,\n pathLocale,\n cookieLocale,\n basePath,\n basePathTrailingSlash\n );\n return redirectUrl(request, newPath);\n }\n\n // If the cookie locale matches the path locale, or cookie locale is not set, or serverSetCookie is 'always'\n return handleDefaultLocaleRedirect(\n request,\n pathLocale,\n pathname,\n basePathTrailingSlash\n );\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 cookieLocale - The locale from the cookie.\n * @param basePath - The base path of the application.\n * @param basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @returns - The new URL path with the correct locale.\n */\nconst handleCookieLocaleMismatch = (\n request: NextRequest,\n pathname: string,\n pathLocale: Locales,\n cookieLocale: Locales,\n basePath: string,\n basePathTrailingSlash: boolean\n): string => {\n // Replace the pathLocale in the pathname with the cookieLocale\n const newPath = pathname.replace(`/${pathLocale}`, `/${cookieLocale}`);\n\n return constructPath(\n cookieLocale,\n newPath,\n basePath,\n basePathTrailingSlash,\n request.nextUrl.search\n );\n};\n\n/**\n * Handles redirection when the default locale is used and prefixing is not required.\n *\n * @param request - The incoming Next.js request object.\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 rewritten response without the locale prefix.\n */\nconst handleDefaultLocaleRedirect = (\n request: NextRequest,\n pathLocale: Locales,\n pathname: string,\n basePathTrailingSlash: boolean\n): NextResponse => {\n if (\n // If default locale should not be prefixed and the pathLocale is the defaultLocale\n !prefixDefault &&\n pathLocale === defaultLocale\n ) {\n let pathWithoutLocale = pathname.slice(`/${pathLocale}`.length) ?? '/';\n\n if (basePathTrailingSlash) {\n pathWithoutLocale = pathWithoutLocale.slice(1);\n }\n\n if (request.nextUrl.search) {\n pathWithoutLocale += request.nextUrl.search;\n }\n\n return rewriteUrl(request, `${basePath}${pathWithoutLocale}`, pathLocale);\n }\n\n // If prefixing default locale is required or pathLocale is not the defaultLocale\n\n return rewriteUrl(request, pathname, 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 basePathTrailingSlash - Indicates if the basePath ends with a slash.\n * @param [search] - The query string from the request URL (optional).\n * @returns - The constructed new path.\n */\nconst constructPath = (\n locale: Locales,\n path: string,\n basePath: string,\n basePathTrailingSlash: boolean,\n search?: string\n): string => {\n let newPath = `${locale}${path}`;\n\n newPath = `${basePath}${basePathTrailingSlash ? '' : '/'}${newPath}`;\n if (search) {\n newPath += search;\n }\n return newPath;\n};\n\n/**\n * Rewrites the URL to the new path and sets the locale header.\n *\n * @param request - The incoming Next.js request object.\n * @param newPath - The new path to rewrite to.\n * @param locale - The locale to set in the response header.\n * @returns - The rewritten response.\n */\nconst rewriteUrl = (\n request: NextRequest,\n newPath: string,\n locale: Locales\n): NextResponse => {\n // Ensure we preserve the original search params if they were present and not explicitly included in newPath\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n const response = NextResponse.rewrite(new URL(pathWithSearch, request.url));\n response.headers.set(headerName, locale);\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 // Ensure we preserve the original search params if they were present and not explicitly included in newPath\n const search = request.nextUrl.search;\n const pathWithSearch =\n search && !newPath.includes('?') ? `${newPath}${search}` : newPath;\n\n return NextResponse.redirect(new URL(pathWithSearch, request.url));\n};\n"],"mappings":"AAAA,OAAO,mBAAmB;AAG1B;AAAA,EAGE;AAAA,OACK;AACP,SAAS,sBAAsB;AAE/B,MAAM,EAAE,sBAAsB,WAAW,IAAI;AAC7C,MAAM,EAAE,SAAS,cAAc,IAAI;AACnC,MAAM;AAAA,EACJ;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]}
@@ -5,6 +5,7 @@ import {
5
5
  t,
6
6
  useDictionary,
7
7
  useDictionaryDynamic,
8
+ useI18n,
8
9
  useIntlayer,
9
10
  useLoadDynamic,
10
11
  useLocale
@@ -17,6 +18,7 @@ export {
17
18
  t,
18
19
  useDictionary,
19
20
  useDictionaryDynamic,
21
+ useI18n,
20
22
  useIntlayer,
21
23
  useLoadDynamic,
22
24
  useLocale,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\n IntlayerServer,\n IntlayerServerProvider,\n locale,\n t,\n useDictionary,\n useDictionaryDynamic,\n useI18n,\n useIntlayer,\n useLoadDynamic,\n useLocale,\n} from 'react-intlayer/server';\nexport { withIntlayer } from './withIntlayer';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;","names":[]}
@@ -94,7 +94,8 @@ const withIntlayer = async (nextConfig = {}) => {
94
94
  const relativeConfigurationPath = relative(baseDir, configurationPath);
95
95
  const turboConfig = {
96
96
  resolveAlias: {
97
- // "prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly."
97
+ // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.
98
+ // Normalize the path to avoid issues with the path separator on Windows
98
99
  "@intlayer/dictionaries-entry": normalizePath(
99
100
  `./${relativeDictionariesPath}`
100
101
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { prepareIntlayer, runOnce } from '@intlayer/chokidar';\nimport {\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n normalizePath,\n} from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport fg from 'fast-glob';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = () => {\n try {\n ESMxCJSRequire.resolve('@intlayer/swc');\n return true;\n } catch (e) {\n return false;\n }\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig\n): Partial<NextConfig> => {\n const { optimize, traversePattern, importMode } = intlayerConfig.build;\n const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } =\n intlayerConfig.content;\n\n if (!optimize) return {};\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable();\n\n if (!isSwcPluginAvailable) return {};\n\n const logger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(baseDir, '.next', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => logger('Intlayer prune plugin is enabled'),\n 1000 * 10 // 10 seconds\n );\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n ESMxCJSRequire.resolve('@intlayer/swc'),\n {\n dictionariesDir,\n dictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n } as any,\n ],\n ],\n },\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): Promise<NextConfig & T> => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n const sentinelPath = join(\n intlayerConfig.content.baseDir,\n '.next',\n 'cache',\n 'intlayer-prepared.lock'\n );\n\n // Only call prepareIntlayer once per server startup\n await runOnce(sentinelPath, () => prepareIntlayer(intlayerConfig));\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // \"prefix by './' to consider the path as relative to the project root. This is necessary for turbo to work correctly.\"\n '@intlayer/dictionaries-entry': normalizePath(\n `./${relativeDictionariesPath}`\n ),\n '@intlayer/unmerged-dictionaries-entry': normalizePath(\n `./${relativeUnmergedDictionariesPath}`\n ),\n '@intlayer/config/built': normalizePath(`./${relativeConfigurationPath}`),\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 newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // Skip preparation when running next start (production mode)\n const isBuildCommand =\n process.env.npm_lifecycle_event === 'build' ||\n process.argv.some((arg) => arg === 'build');\n\n if (!isBuildCommand && isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(intlayerConfig);\n\n const intlayerNextConfig: Partial<NextConfig> = merge(pruneConfig, newConfig);\n\n // Merge the new config with the user's config\n const result = merge(nextConfig, intlayerNextConfig) as NextConfig & T;\n\n return result;\n};\n"],"mappings":"AAAA,SAAS,iBAAiB,eAAe;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,OAAO,WAAW;AAClB,OAAO,QAAQ;AAGf,SAAS,MAAM,UAAU,eAAe;AACxC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAG/B,MAAM,qBACJ,QAAQ,IAAI,sBAAsB,SAAS,SAAS;AACtD,MAAM,cAAc,eAAe;AACnC,MAAM,cAAc,gBAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,cAAc,gBAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,oBAAoB,gBAAgB,aAAa,UAAK,QAAQ;AAGpE,MAAM,0BAA0B,MAAM;AACpC,MAAI;AACF,mBAAe,QAAQ,eAAe;AACtC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEA,MAAM,iBAAiB,CACrB,mBACwB;AACxB,QAAM,EAAE,UAAU,iBAAiB,WAAW,IAAI,eAAe;AACjE,QAAM,EAAE,iBAAiB,wBAAwB,SAAS,QAAQ,IAChE,eAAe;AAEjB,MAAI,CAAC,SAAU,QAAO,CAAC;AAEvB,MAAI,CAAC,YAAa,QAAO,CAAC;AAE1B,QAAM,uBAAuB,wBAAwB;AAErD,MAAI,CAAC,qBAAsB,QAAO,CAAC;AAEnC,QAAM,SAAS,aAAa,cAAc;AAE1C;AAAA,IACE,KAAK,SAAS,SAAS,SAAS,oCAAoC;AAAA,IACpE,MAAM,OAAO,kCAAkC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IAAI;AAGlC,YAAM,iBACJ,QAAQ,IAAI,wBAAwB,WACpC,QAAQ,KAAK,KAAK,CAAC,QAAQ,QAAQ,OAAO;AAE5C,UAAI,CAAC,kBAAkB,YAAY,gBAAgB,UAAU;AAC3D,eAAO,QAAQ,KAAK,IAAI,eAAe,CAAC;AAAA,MAC1C;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,cAAmC,eAAe,cAAc;AAEtE,QAAM,qBAA0C,MAAM,aAAa,SAAS;AAG5E,QAAM,SAAS,MAAM,YAAY,kBAAkB;AAEnD,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { prepareIntlayer, runOnce } from '@intlayer/chokidar';\nimport {\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n IntlayerConfig,\n normalizePath,\n} from '@intlayer/config';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport merge from 'deepmerge';\nimport fg from 'fast-glob';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport { join, relative, resolve } from 'path';\nimport { compareVersions } from './compareVersion';\nimport { getNextVersion } from './getNextVertion';\n\n// Extract from the start script if --turbo or --turbopack flag is used\nconst isTurbopackEnabled =\n process.env.npm_lifecycle_script?.includes('--turbo');\nconst nextVersion = getNextVersion();\nconst isGteNext13 = compareVersions(nextVersion, '≥', '13.0.0');\nconst isGteNext15 = compareVersions(nextVersion, '≥', '15.0.0');\nconst isTurbopackStable = compareVersions(nextVersion, '≥', '15.3.0');\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = () => {\n try {\n ESMxCJSRequire.resolve('@intlayer/swc');\n return true;\n } catch (e) {\n return false;\n }\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig\n): Partial<NextConfig> => {\n const { optimize, traversePattern, importMode } = intlayerConfig.build;\n const { dictionariesDir, dynamicDictionariesDir, mainDir, baseDir } =\n intlayerConfig.content;\n\n if (!optimize) return {};\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable();\n\n if (!isSwcPluginAvailable) return {};\n\n const logger = getAppLogger(intlayerConfig);\n\n runOnce(\n join(baseDir, '.next', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => logger('Intlayer prune plugin is enabled'),\n 1000 * 10 // 10 seconds\n );\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const filesListPattern = fg\n .sync(traversePattern, {\n cwd: baseDir,\n })\n .map((file) => join(baseDir, file));\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n return {\n experimental: {\n swcPlugins: [\n [\n ESMxCJSRequire.resolve('@intlayer/swc'),\n {\n dictionariesDir,\n dictionariesEntryPath,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: false,\n } as any,\n ],\n ],\n },\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variablesi\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T\n): Promise<NextConfig & T> => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration();\n\n const sentinelPath = join(\n intlayerConfig.content.baseDir,\n '.next',\n 'cache',\n 'intlayer-prepared.lock'\n );\n\n // Only call prepareIntlayer once per server startup\n await runOnce(sentinelPath, () => prepareIntlayer(intlayerConfig));\n\n // Format all configuration values as environment variables\n const { mainDir, configDir, baseDir } = intlayerConfig.content;\n\n const dictionariesPath = join(mainDir, 'dictionaries.mjs');\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n\n const unmergedDictionariesPath = join(mainDir, 'unmerged_dictionaries.mjs');\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n\n const configurationPath = join(configDir, 'configuration.json');\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: {\n // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n // Normalize the path to avoid issues with the path separator on Windows\n '@intlayer/dictionaries-entry': normalizePath(\n `./${relativeDictionariesPath}`\n ),\n '@intlayer/unmerged-dictionaries-entry': normalizePath(\n `./${relativeUnmergedDictionariesPath}`\n ),\n '@intlayer/config/built': normalizePath(`./${relativeConfigurationPath}`),\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 newConfig: Partial<NextConfig> = {\n // Only add `serverExternalPackages` if Next.js is v15+\n ...(isGteNext15\n ? {\n // only for Next ≥15\n serverExternalPackages,\n }\n : {\n // only for Next ≥13 and <15.3\n ...(isGteNext13 && {\n serverComponentsExternalPackages: serverExternalPackages,\n }),\n }),\n\n ...(isTurbopackEnabled && {\n ...(isGteNext15 && isTurbopackStable\n ? {\n // only for Next ≥15.3\n turbopack: turboConfig,\n }\n : {\n experimental: {\n // only for Next ≥13 and <15.3\n turbo: turboConfig,\n },\n }),\n }),\n\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\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 // Alias the dictionary entry for all builds\n config.resolve.alias = {\n ...config.resolve.alias,\n '@intlayer/dictionaries-entry': resolve(relativeDictionariesPath),\n '@intlayer/unmerged-dictionaries-entry': resolve(\n relativeUnmergedDictionariesPath\n ),\n '@intlayer/config/built': resolve(relativeConfigurationPath),\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 // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // Skip preparation when running next start (production mode)\n const isBuildCommand =\n process.env.npm_lifecycle_event === 'build' ||\n process.argv.some((arg) => arg === 'build');\n\n if (!isBuildCommand && isServer && nextRuntime === 'nodejs') {\n config.plugins.push(new IntlayerPlugin());\n }\n\n return config;\n },\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(intlayerConfig);\n\n const intlayerNextConfig: Partial<NextConfig> = merge(pruneConfig, newConfig);\n\n // Merge the new config with the user's config\n const result = merge(nextConfig, intlayerNextConfig) as NextConfig & T;\n\n return result;\n};\n"],"mappings":"AAAA,SAAS,iBAAiB,eAAe;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,OAAO,WAAW;AAClB,OAAO,QAAQ;AAGf,SAAS,MAAM,UAAU,eAAe;AACxC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAG/B,MAAM,qBACJ,QAAQ,IAAI,sBAAsB,SAAS,SAAS;AACtD,MAAM,cAAc,eAAe;AACnC,MAAM,cAAc,gBAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,cAAc,gBAAgB,aAAa,UAAK,QAAQ;AAC9D,MAAM,oBAAoB,gBAAgB,aAAa,UAAK,QAAQ;AAGpE,MAAM,0BAA0B,MAAM;AACpC,MAAI;AACF,mBAAe,QAAQ,eAAe;AACtC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEA,MAAM,iBAAiB,CACrB,mBACwB;AACxB,QAAM,EAAE,UAAU,iBAAiB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BAAwB;AAAA,QAChE,yCAAyC;AAAA,UACvC;AAAA,QACF;AAAA,QACA,0BAA0B,QAAQ,yBAAyB;AAAA,MAC7D;AAGA,aAAO,UAAU,KAAK;AAAA,QACpB,SAAS;AAAA,QACT,QAAQ;AAAA,QACR,IAAI;AAAA,QACJ,UAAU;AAAA,QACV,UAAU;AAAA,MACZ,CAAC;AAGD,aAAO,OAAO,MAAM,KAAK;AAAA,QACvB,MAAM;AAAA,QACN,QAAQ;AAAA,MACV,CAAC;AAGD,YAAM,EAAE,UAAU,YAAY,IAAI;AAGlC,YAAM,iBACJ,QAAQ,IAAI,wBAAwB,WACpC,QAAQ,KAAK,KAAK,CAAC,QAAQ,QAAQ,OAAO;AAE5C,UAAI,CAAC,kBAAkB,YAAY,gBAAgB,UAAU;AAC3D,eAAO,QAAQ,KAAK,IAAI,eAAe,CAAC;AAAA,MAC1C;AAEA,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,cAAmC,eAAe,cAAc;AAEtE,QAAM,qBAA0C,MAAM,aAAa,SAAS;AAG5E,QAAM,SAAS,MAAM,YAAY,kBAAkB;AAEnD,SAAO;AACT;","names":[]}
@@ -1,4 +1,4 @@
1
+ export { IntlayerClientProvider, type IntlayerClientProviderProps, } from './IntlayerClientProvider';
1
2
  export { useLocale } from './useLocale';
2
3
  export { useLocalePageRouter } from './useLocalePageRouter';
3
- export { IntlayerClientProvider, type IntlayerClientProviderProps, } from './IntlayerClientProvider';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACL,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -1,4 +1,4 @@
1
- export { IntlayerClientContext, MarkdownProvider, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useIntlayer, useIntlayerAsync, useLoadDynamic, useLocaleCookie, type IntlayerNode, } from 'react-intlayer';
1
+ export { IntlayerClientContext, MarkdownProvider, t, useDictionary, useDictionaryAsync, useDictionaryDynamic, useI18n, useIntlayer, useIntlayerAsync, useLoadDynamic, useLocaleCookie, type IntlayerNode, } from 'react-intlayer';
2
2
  export { IntlayerClientProvider, useLocale, useLocalePageRouter, type IntlayerClientProviderProps, } from './client/index';
3
3
  export { generateStaticParams } from './generateStaticParams';
4
4
  export type { LocalParams, LocalPromiseParams, Next14LayoutIntlayer, Next14PageIntlayer, Next15LayoutIntlayer, Next15PageIntlayer, NextLayoutIntlayer, NextPageIntlayer, } from './types/index';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,CAAC,EACD,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,mBAAmB,EACnB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,CAAC,EACD,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,sBAAsB,EACtB,SAAS,EACT,mBAAmB,EACnB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"intlayerMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/intlayerMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,YAAY,EACb,MAAM,aAAa,CAAC;AA0CrB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,WAAW,EACpB,SAAS,cAAc,EACvB,YAAY,YAAY,KACvB,YAoCF,CAAC"}
1
+ {"version":3,"file":"intlayerMiddleware.d.ts","sourceRoot":"","sources":["../../../src/middleware/intlayerMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,YAAY,EACb,MAAM,aAAa,CAAC;AA2CrB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,WAAW,EACpB,SAAS,cAAc,EACvB,YAAY,YAAY,KACvB,YA0BF,CAAC"}
@@ -1,3 +1,3 @@
1
- export { IntlayerServer, IntlayerServerProvider, locale, t, useDictionary, useDictionaryDynamic, useIntlayer, useLoadDynamic, useLocale, } from 'react-intlayer/server';
1
+ export { IntlayerServer, IntlayerServerProvider, locale, t, useDictionary, useDictionaryDynamic, useI18n, useIntlayer, useLoadDynamic, useLocale, } from 'react-intlayer/server';
2
2
  export { withIntlayer } from './withIntlayer';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,MAAM,EACN,CAAC,EACD,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,MAAM,EACN,CAAC,EACD,aAAa,EACb,oBAAoB,EACpB,OAAO,EACP,WAAW,EACX,cAAc,EACd,SAAS,GACV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"withIntlayer.d.ts","sourceRoot":"","sources":["../../../src/server/withIntlayer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAuFvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,SAAS,OAAO,CAAC,UAAU,CAAC,EAC9D,aAAY,CAAW,KACtB,OAAO,CAAC,UAAU,GAAG,CAAC,CA+IxB,CAAC"}
1
+ {"version":3,"file":"withIntlayer.d.ts","sourceRoot":"","sources":["../../../src/server/withIntlayer.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAuFvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,SAAS,OAAO,CAAC,UAAU,CAAC,EAC9D,aAAY,CAAW,KACtB,OAAO,CAAC,UAAU,GAAG,CAAC,CAgJxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intlayer",
3
- "version": "5.7.4",
3
+ "version": "5.7.6-canary.0",
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": [
@@ -69,12 +69,12 @@
69
69
  "dependencies": {
70
70
  "deepmerge": "^4.3.1",
71
71
  "node-loader": "^2.1.0",
72
- "@intlayer/chokidar": "5.7.4",
73
- "@intlayer/config": "5.7.4",
74
- "@intlayer/dictionaries-entry": "5.7.4",
75
- "@intlayer/core": "5.7.4",
76
- "@intlayer/webpack": "5.7.4",
77
- "react-intlayer": "5.7.4"
72
+ "@intlayer/chokidar": "5.7.6-canary.0",
73
+ "@intlayer/config": "5.7.6-canary.0",
74
+ "@intlayer/core": "5.7.6-canary.0",
75
+ "@intlayer/dictionaries-entry": "5.7.6-canary.0",
76
+ "@intlayer/webpack": "5.7.6-canary.0",
77
+ "react-intlayer": "5.7.6-canary.0"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@types/node": "^22.15.30",
@@ -93,18 +93,18 @@
93
93
  "@utils/ts-config": "1.0.4",
94
94
  "@utils/ts-config-types": "1.0.4",
95
95
  "@utils/tsup-config": "1.0.4",
96
- "intlayer": "5.7.4"
96
+ "intlayer": "5.7.6-canary.0"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "next": ">=14.0.0",
100
100
  "react": ">=16.0.0",
101
101
  "react-dom": ">=16.0.0",
102
- "@intlayer/config": "5.7.4",
103
- "@intlayer/dictionaries-entry": "5.7.4",
104
- "intlayer": "5.7.4",
105
- "@intlayer/core": "5.7.4",
106
- "@intlayer/webpack": "5.7.4",
107
- "react-intlayer": "5.7.4"
102
+ "@intlayer/config": "5.7.6-canary.0",
103
+ "@intlayer/core": "5.7.6-canary.0",
104
+ "@intlayer/webpack": "5.7.6-canary.0",
105
+ "@intlayer/dictionaries-entry": "5.7.6-canary.0",
106
+ "intlayer": "5.7.6-canary.0",
107
+ "react-intlayer": "5.7.6-canary.0"
108
108
  },
109
109
  "engines": {
110
110
  "node": ">=14.18"