@intlayer/next-intl 9.0.0-canary.2 → 9.0.0-canary.20

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.
Files changed (183) hide show
  1. package/dist/cjs/client/NextIntlClientProvider.cjs +8 -4
  2. package/dist/cjs/client/NextIntlClientProvider.cjs.map +1 -1
  3. package/dist/cjs/client/index.cjs +55 -13
  4. package/dist/cjs/client/useLocale.cjs +0 -1
  5. package/dist/cjs/client/useLocale.cjs.map +1 -1
  6. package/dist/cjs/getDictionary.cjs +19 -30
  7. package/dist/cjs/getDictionary.cjs.map +1 -1
  8. package/dist/cjs/getDictionaryDynamic.cjs +8 -24
  9. package/dist/cjs/getDictionaryDynamic.cjs.map +1 -1
  10. package/dist/cjs/index.cjs +91 -15
  11. package/dist/cjs/middleware.cjs +0 -1
  12. package/dist/cjs/middleware.cjs.map +1 -1
  13. package/dist/cjs/navigation/Link.cjs.map +1 -1
  14. package/dist/cjs/navigation/createNavigation.cjs +0 -1
  15. package/dist/cjs/navigation/createNavigation.cjs.map +1 -1
  16. package/dist/cjs/navigation/hooks.cjs +0 -1
  17. package/dist/cjs/navigation/hooks.cjs.map +1 -1
  18. package/dist/cjs/navigation/localizeHref.cjs +0 -1
  19. package/dist/cjs/navigation/localizeHref.cjs.map +1 -1
  20. package/dist/cjs/plugin/index.cjs +9 -15
  21. package/dist/cjs/plugin/index.cjs.map +1 -1
  22. package/dist/cjs/routing.cjs +0 -1
  23. package/dist/cjs/routing.cjs.map +1 -1
  24. package/dist/cjs/server/getLocale.cjs +15 -2
  25. package/dist/cjs/server/getLocale.cjs.map +1 -1
  26. package/dist/cjs/server/getMessages.cjs +0 -1
  27. package/dist/cjs/server/getMessages.cjs.map +1 -1
  28. package/dist/cjs/server/getRequestConfig.cjs +27 -0
  29. package/dist/cjs/server/getRequestConfig.cjs.map +1 -0
  30. package/dist/cjs/server/getTranslations.cjs +8 -4
  31. package/dist/cjs/server/getTranslations.cjs.map +1 -1
  32. package/dist/cjs/server/helpers.cjs +4 -3
  33. package/dist/cjs/server/helpers.cjs.map +1 -1
  34. package/dist/cjs/server/index.cjs +5 -1
  35. package/dist/cjs/server/requestLocaleCache.cjs +35 -0
  36. package/dist/cjs/server/requestLocaleCache.cjs.map +1 -0
  37. package/dist/cjs/server/setLocale.cjs +0 -1
  38. package/dist/cjs/server/setLocale.cjs.map +1 -1
  39. package/dist/cjs/server/setRequestLocale.cjs +33 -0
  40. package/dist/cjs/server/setRequestLocale.cjs.map +1 -0
  41. package/dist/esm/client/NextIntlClientProvider.mjs +9 -4
  42. package/dist/esm/client/NextIntlClientProvider.mjs.map +1 -1
  43. package/dist/esm/client/index.mjs +1 -4
  44. package/dist/esm/client/useLocale.mjs.map +1 -1
  45. package/dist/esm/getDictionary.mjs +19 -29
  46. package/dist/esm/getDictionary.mjs.map +1 -1
  47. package/dist/esm/getDictionaryDynamic.mjs +8 -23
  48. package/dist/esm/getDictionaryDynamic.mjs.map +1 -1
  49. package/dist/esm/index.mjs +3 -6
  50. package/dist/esm/middleware.mjs.map +1 -1
  51. package/dist/esm/navigation/Link.mjs.map +1 -1
  52. package/dist/esm/navigation/createNavigation.mjs.map +1 -1
  53. package/dist/esm/navigation/hooks.mjs.map +1 -1
  54. package/dist/esm/navigation/localizeHref.mjs.map +1 -1
  55. package/dist/esm/plugin/index.mjs +8 -14
  56. package/dist/esm/plugin/index.mjs.map +1 -1
  57. package/dist/esm/routing.mjs.map +1 -1
  58. package/dist/esm/server/getLocale.mjs +15 -1
  59. package/dist/esm/server/getLocale.mjs.map +1 -1
  60. package/dist/esm/server/getMessages.mjs.map +1 -1
  61. package/dist/esm/server/getRequestConfig.mjs +25 -0
  62. package/dist/esm/server/getRequestConfig.mjs.map +1 -0
  63. package/dist/esm/server/getTranslations.mjs +8 -4
  64. package/dist/esm/server/getTranslations.mjs.map +1 -1
  65. package/dist/esm/server/helpers.mjs +4 -3
  66. package/dist/esm/server/helpers.mjs.map +1 -1
  67. package/dist/esm/server/index.mjs +3 -1
  68. package/dist/esm/server/requestLocaleCache.mjs +33 -0
  69. package/dist/esm/server/requestLocaleCache.mjs.map +1 -0
  70. package/dist/esm/server/setLocale.mjs.map +1 -1
  71. package/dist/esm/server/setRequestLocale.mjs +32 -0
  72. package/dist/esm/server/setRequestLocale.mjs.map +1 -0
  73. package/dist/types/client/NextIntlClientProvider.d.ts +0 -1
  74. package/dist/types/client/NextIntlClientProvider.d.ts.map +1 -1
  75. package/dist/types/client/index.d.ts +1 -4
  76. package/dist/types/client/useLocale.d.ts +0 -1
  77. package/dist/types/client/useLocale.d.ts.map +1 -1
  78. package/dist/types/getDictionary.d.ts +25 -13
  79. package/dist/types/getDictionary.d.ts.map +1 -1
  80. package/dist/types/getDictionaryDynamic.d.ts +15 -7
  81. package/dist/types/getDictionaryDynamic.d.ts.map +1 -1
  82. package/dist/types/index.d.ts +3 -6
  83. package/dist/types/middleware.d.ts +0 -1
  84. package/dist/types/middleware.d.ts.map +1 -1
  85. package/dist/types/navigation/Link.d.ts +3 -6
  86. package/dist/types/navigation/Link.d.ts.map +1 -1
  87. package/dist/types/navigation/createNavigation.d.ts +0 -1
  88. package/dist/types/navigation/createNavigation.d.ts.map +1 -1
  89. package/dist/types/navigation/hooks.d.ts +4 -6
  90. package/dist/types/navigation/hooks.d.ts.map +1 -1
  91. package/dist/types/navigation/localizeHref.d.ts.map +1 -1
  92. package/dist/types/plugin/index.d.ts +0 -1
  93. package/dist/types/plugin/index.d.ts.map +1 -1
  94. package/dist/types/routing.d.ts +0 -1
  95. package/dist/types/routing.d.ts.map +1 -1
  96. package/dist/types/server/getLocale.d.ts +9 -1
  97. package/dist/types/server/getLocale.d.ts.map +1 -1
  98. package/dist/types/server/getMessages.d.ts +0 -1
  99. package/dist/types/server/getMessages.d.ts.map +1 -1
  100. package/dist/types/server/getRequestConfig.d.ts +18 -0
  101. package/dist/types/server/getRequestConfig.d.ts.map +1 -0
  102. package/dist/types/server/getTranslations.d.ts +13 -33
  103. package/dist/types/server/getTranslations.d.ts.map +1 -1
  104. package/dist/types/server/helpers.d.ts +2 -2
  105. package/dist/types/server/helpers.d.ts.map +1 -1
  106. package/dist/types/server/index.d.ts +3 -1
  107. package/dist/types/server/requestLocaleCache.d.ts +16 -0
  108. package/dist/types/server/requestLocaleCache.d.ts.map +1 -0
  109. package/dist/types/server/setLocale.d.ts.map +1 -1
  110. package/dist/types/server/setRequestLocale.d.ts +28 -0
  111. package/dist/types/server/setRequestLocale.d.ts.map +1 -0
  112. package/package.json +14 -13
  113. package/dist/cjs/client/helpers.cjs +0 -66
  114. package/dist/cjs/client/helpers.cjs.map +0 -1
  115. package/dist/cjs/client/useTranslations.cjs +0 -39
  116. package/dist/cjs/client/useTranslations.cjs.map +0 -1
  117. package/dist/cjs/createFormatter.cjs +0 -59
  118. package/dist/cjs/createFormatter.cjs.map +0 -1
  119. package/dist/cjs/createTranslator.cjs +0 -111
  120. package/dist/cjs/createTranslator.cjs.map +0 -1
  121. package/dist/cjs/getTranslationsDictionary.cjs +0 -31
  122. package/dist/cjs/getTranslationsDictionary.cjs.map +0 -1
  123. package/dist/cjs/getTranslationsDictionaryDynamic.cjs +0 -27
  124. package/dist/cjs/getTranslationsDictionaryDynamic.cjs.map +0 -1
  125. package/dist/cjs/hasLocale.cjs +0 -25
  126. package/dist/cjs/hasLocale.cjs.map +0 -1
  127. package/dist/cjs/package.cjs +0 -122
  128. package/dist/cjs/package.cjs.map +0 -1
  129. package/dist/cjs/useDictionary.cjs +0 -45
  130. package/dist/cjs/useDictionary.cjs.map +0 -1
  131. package/dist/cjs/useDictionaryDynamic.cjs +0 -37
  132. package/dist/cjs/useDictionaryDynamic.cjs.map +0 -1
  133. package/dist/cjs/useTranslationsDictionary.cjs +0 -37
  134. package/dist/cjs/useTranslationsDictionary.cjs.map +0 -1
  135. package/dist/cjs/useTranslationsDictionaryDynamic.cjs +0 -29
  136. package/dist/cjs/useTranslationsDictionaryDynamic.cjs.map +0 -1
  137. package/dist/esm/_virtual/_rolldown/runtime.mjs +0 -8
  138. package/dist/esm/client/helpers.mjs +0 -59
  139. package/dist/esm/client/helpers.mjs.map +0 -1
  140. package/dist/esm/client/useTranslations.mjs +0 -37
  141. package/dist/esm/client/useTranslations.mjs.map +0 -1
  142. package/dist/esm/createFormatter.mjs +0 -57
  143. package/dist/esm/createFormatter.mjs.map +0 -1
  144. package/dist/esm/createTranslator.mjs +0 -108
  145. package/dist/esm/createTranslator.mjs.map +0 -1
  146. package/dist/esm/getTranslationsDictionary.mjs +0 -29
  147. package/dist/esm/getTranslationsDictionary.mjs.map +0 -1
  148. package/dist/esm/getTranslationsDictionaryDynamic.mjs +0 -25
  149. package/dist/esm/getTranslationsDictionaryDynamic.mjs.map +0 -1
  150. package/dist/esm/hasLocale.mjs +0 -23
  151. package/dist/esm/hasLocale.mjs.map +0 -1
  152. package/dist/esm/package.mjs +0 -119
  153. package/dist/esm/package.mjs.map +0 -1
  154. package/dist/esm/useDictionary.mjs +0 -43
  155. package/dist/esm/useDictionary.mjs.map +0 -1
  156. package/dist/esm/useDictionaryDynamic.mjs +0 -35
  157. package/dist/esm/useDictionaryDynamic.mjs.map +0 -1
  158. package/dist/esm/useTranslationsDictionary.mjs +0 -35
  159. package/dist/esm/useTranslationsDictionary.mjs.map +0 -1
  160. package/dist/esm/useTranslationsDictionaryDynamic.mjs +0 -27
  161. package/dist/esm/useTranslationsDictionaryDynamic.mjs.map +0 -1
  162. package/dist/types/client/helpers.d.ts +0 -45
  163. package/dist/types/client/helpers.d.ts.map +0 -1
  164. package/dist/types/client/useTranslations.d.ts +0 -74
  165. package/dist/types/client/useTranslations.d.ts.map +0 -1
  166. package/dist/types/createFormatter.d.ts +0 -15
  167. package/dist/types/createFormatter.d.ts.map +0 -1
  168. package/dist/types/createTranslator.d.ts +0 -40
  169. package/dist/types/createTranslator.d.ts.map +0 -1
  170. package/dist/types/getTranslationsDictionary.d.ts +0 -15
  171. package/dist/types/getTranslationsDictionary.d.ts.map +0 -1
  172. package/dist/types/getTranslationsDictionaryDynamic.d.ts +0 -12
  173. package/dist/types/getTranslationsDictionaryDynamic.d.ts.map +0 -1
  174. package/dist/types/hasLocale.d.ts +0 -20
  175. package/dist/types/hasLocale.d.ts.map +0 -1
  176. package/dist/types/useDictionary.d.ts +0 -22
  177. package/dist/types/useDictionary.d.ts.map +0 -1
  178. package/dist/types/useDictionaryDynamic.d.ts +0 -15
  179. package/dist/types/useDictionaryDynamic.d.ts.map +0 -1
  180. package/dist/types/useTranslationsDictionary.d.ts +0 -19
  181. package/dist/types/useTranslationsDictionary.d.ts.map +0 -1
  182. package/dist/types/useTranslationsDictionaryDynamic.d.ts +0 -12
  183. package/dist/types/useTranslationsDictionaryDynamic.d.ts.map +0 -1
@@ -1,12 +1,13 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
4
  let _intlayer_config_built = require("@intlayer/config/built");
6
5
  let next_intlayer = require("next-intlayer");
7
- let react_jsx_runtime = require("react/jsx-runtime");
8
6
  let _intlayer_config_colors = require("@intlayer/config/colors");
9
7
  let _intlayer_config_logger = require("@intlayer/config/logger");
8
+ let _intlayer_core_localization = require("@intlayer/core/localization");
9
+ let next_navigation = require("next/navigation");
10
+ let react_jsx_runtime = require("react/jsx-runtime");
10
11
 
11
12
  //#region src/client/NextIntlClientProvider.tsx
12
13
  /**
@@ -16,11 +17,14 @@ let _intlayer_config_logger = require("@intlayer/config/logger");
16
17
  */
17
18
  const NextIntlClientProvider = ({ locale, children, messages: _messages, timeZone: _timeZone, now: _now, ...rest }) => {
18
19
  if (process.env.NODE_ENV === "development" && typeof _messages !== "undefined") (0, _intlayer_config_logger.getAppLogger)({ log: _intlayer_config_built.log })(`${(0, _intlayer_config_logger.colorize)("NextIntlClientProvider", _intlayer_config_colors.CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`);
20
+ const pathname = (0, next_navigation.usePathname)();
21
+ const mode = _intlayer_config_built.routing?.mode ?? "prefix-no-default";
22
+ const resolvedLocale = locale ?? (mode === "prefix-all" || mode === "prefix-no-default" ? (0, _intlayer_core_localization.getLocaleFromPath)(pathname) : void 0);
19
23
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(next_intlayer.IntlayerClientProvider, {
20
- locale,
24
+ locale: resolvedLocale,
21
25
  ...rest,
22
26
  children
23
- }, String(locale));
27
+ }, String(resolvedLocale));
24
28
  };
25
29
 
26
30
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"NextIntlClientProvider.cjs","names":["CYAN","IntlayerClientProvider"],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { NextIntlClientProvider as _NextIntlClientProvider } from 'next-intl';\nimport { IntlayerClientProvider } from 'next-intlayer';\nimport type { ComponentProps } from 'react';\n\n/**\n * Drop-in for next-intl's `NextIntlClientProvider`.\n * `messages`, `timeZone`, and `now` are accepted for API compatibility\n * but have no effect — Intlayer uses its own compiled dictionaries.\n */\nexport const NextIntlClientProvider: typeof _NextIntlClientProvider = ({\n locale,\n children,\n messages: _messages,\n timeZone: _timeZone,\n now: _now,\n ...rest\n}) => {\n if (\n process.env.NODE_ENV === 'development' &&\n typeof _messages !== 'undefined'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('NextIntlClientProvider', CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n // `key={locale}` remounts the provider when the locale changes via navigation\n // (next-intl switches locale by routing to a locale-prefixed path). This\n // re-seeds the client locale context from the new `locale` prop so client\n // components re-render in the new language instead of keeping the previous one.\n return (\n <IntlayerClientProvider key={String(locale)} locale={locale} {...rest}>\n {children}\n </IntlayerClientProvider>\n );\n};\n\n/**\n *\n */\nexport type NextIntlClientProviderProps = Omit<\n ComponentProps<typeof _NextIntlClientProvider>,\n 'messages'\n> & {\n /**\n * @deprecated\n * has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason\n */\n messages?: never;\n /**\n * locale\n */\n locale: LocalesValues;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,0BAA0D,EACrE,QACA,UACA,UAAU,WACV,UAAU,WACV,KAAK,MACL,GAAG,WACC;AACJ,KACE,QAAQ,IAAI,aAAa,iBACzB,OAAO,cAAc,YAGrB,2CAD+B,EAAE,iCAAK,CAC7B,CACP,yCAAY,0BAA0BA,6BAAK,CAAC,+HAC7C;AAOH,QACE,2CAACC,sCAAD;EAAqD;EAAQ,GAAI;EAC9D;EACsB,EAFI,OAAO,OAAO,CAElB"}
1
+ {"version":3,"file":"NextIntlClientProvider.cjs","names":["CYAN","routing","IntlayerClientProvider"],"sources":["../../../src/client/NextIntlClientProvider.tsx"],"sourcesContent":["'use client';\n\nimport { log, routing } from '@intlayer/config/built';\nimport { CYAN } from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { getLocaleFromPath } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { usePathname } from 'next/navigation';\nimport type { NextIntlClientProvider as _NextIntlClientProvider } from 'next-intl';\nimport { IntlayerClientProvider } from 'next-intlayer';\nimport type { ComponentProps } from 'react';\n\n/**\n * Drop-in for next-intl's `NextIntlClientProvider`.\n * `messages`, `timeZone`, and `now` are accepted for API compatibility\n * but have no effect — Intlayer uses its own compiled dictionaries.\n */\nexport const NextIntlClientProvider: typeof _NextIntlClientProvider = ({\n locale,\n children,\n messages: _messages,\n timeZone: _timeZone,\n now: _now,\n ...rest\n}) => {\n if (\n process.env.NODE_ENV === 'development' &&\n typeof _messages !== 'undefined'\n ) {\n const appLogger = getAppLogger({ log });\n appLogger(\n `${colorize('NextIntlClientProvider', CYAN)} do not pass the messages prop with intlayer. Messages are loaded automatically under the hood for bundle optimization reason`\n );\n }\n\n // next-intl drives the locale from the request: apps render\n // `<NextIntlClientProvider>` without a `locale` prop and the server resolves it\n // from the `[locale]` route segment. As a client component we cannot read the\n // server request here, so when no explicit `locale` is given we derive it from\n // the URL (the same `[locale]` segment) using Intlayer's routing config. This\n // keeps `useLocale`, `Link` and the locale switcher in sync with the URL\n // instead of falling back to the stored cookie / default locale.\n //\n // Only prefix-based routing carries the locale in the path. For `no-prefix` /\n // `search-params` the path has no locale segment, so we leave `locale`\n // undefined and let the provider resolve it from storage (cookie) — deriving\n // from the path there would wrongly clobber the cookie with the default locale.\n const pathname = usePathname();\n const mode = routing?.mode ?? 'prefix-no-default';\n const isPrefixMode = mode === 'prefix-all' || mode === 'prefix-no-default';\n const resolvedLocale =\n locale ?? (isPrefixMode ? getLocaleFromPath(pathname) : undefined);\n\n // `key={resolvedLocale}` remounts the provider when the locale changes via\n // navigation (next-intl switches locale by routing to a locale-prefixed path).\n // This re-seeds the client locale context so client components re-render in\n // the new language instead of keeping the previous one.\n return (\n <IntlayerClientProvider\n key={String(resolvedLocale)}\n locale={resolvedLocale}\n {...rest}\n >\n {children}\n </IntlayerClientProvider>\n );\n};\n\n/**\n *\n */\nexport type NextIntlClientProviderProps = Omit<\n ComponentProps<typeof _NextIntlClientProvider>,\n 'messages'\n> & {\n /**\n * @deprecated\n * has no use case with intlayer. Messages are loaded automatically under the hood for bundle optimization reason\n */\n messages?: never;\n /**\n * locale\n */\n locale: LocalesValues;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,0BAA0D,EACrE,QACA,UACA,UAAU,WACV,UAAU,WACV,KAAK,MACL,GAAG,WACC;CACJ,IACE,QAAQ,IAAI,aAAa,iBACzB,OAAO,cAAc,aAGrB,0CAD+B,EAAE,gCAAI,CAC7B,CAAC,CACP,yCAAY,0BAA0BA,4BAAI,EAAE,8HAC9C;CAeF,MAAM,4CAAuB;CAC7B,MAAM,OAAOC,gCAAS,QAAQ;CAE9B,MAAM,iBACJ,WAFmB,SAAS,gBAAgB,SAAS,yEAET,QAAQ,IAAI;CAM1D,OACE,2CAACC,sCAAD;EAEE,QAAQ;EACR,GAAI;EAEH;CACqB,GALjB,OAAO,cAAc,CAKJ;AAE5B"}
@@ -1,19 +1,61 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_useDictionaryDynamic = require('../useDictionaryDynamic.cjs');
3
- const require_useDictionary = require('../useDictionary.cjs');
4
- const require_client_helpers = require('./helpers.cjs');
5
2
  const require_client_NextIntlClientProvider = require('./NextIntlClientProvider.cjs');
6
3
  const require_client_useLocale = require('./useLocale.cjs');
7
- const require_client_useTranslations = require('./useTranslations.cjs');
4
+ let _intlayer_use_intl = require("@intlayer/use-intl");
8
5
 
9
- exports.IntlProvider = require_client_helpers.IntlProvider;
6
+ Object.defineProperty(exports, 'IntlProvider', {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _intlayer_use_intl.IntlProvider;
10
+ }
11
+ });
10
12
  exports.NextIntlClientProvider = require_client_NextIntlClientProvider.NextIntlClientProvider;
11
- exports.useDictionary = require_useDictionary.useDictionary;
12
- exports.useDictionaryDynamic = require_useDictionaryDynamic.useDictionaryDynamic;
13
- exports.useExtracted = require_client_helpers.useExtracted;
14
- exports.useFormatter = require_client_helpers.useFormatter;
13
+ Object.defineProperty(exports, 'useDictionary', {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _intlayer_use_intl.useDictionary;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, 'useDictionaryDynamic', {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _intlayer_use_intl.useDictionaryDynamic;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, 'useExtracted', {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _intlayer_use_intl._useExtracted;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, 'useFormatter', {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _intlayer_use_intl.useFormatter;
35
+ }
36
+ });
15
37
  exports.useLocale = require_client_useLocale.useLocale;
16
- exports.useMessages = require_client_helpers.useMessages;
17
- exports.useNow = require_client_helpers.useNow;
18
- exports.useTimeZone = require_client_helpers.useTimeZone;
19
- exports.useTranslations = require_client_useTranslations.useTranslations;
38
+ Object.defineProperty(exports, 'useMessages', {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _intlayer_use_intl.useMessages;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, 'useNow', {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _intlayer_use_intl.useNow;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, 'useTimeZone', {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _intlayer_use_intl.useTimeZone;
54
+ }
55
+ });
56
+ Object.defineProperty(exports, 'useTranslations', {
57
+ enumerable: true,
58
+ get: function () {
59
+ return _intlayer_use_intl.useTranslations;
60
+ }
61
+ });
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
4
  let next_intlayer = require("next-intlayer");
6
5
 
7
6
  //#region src/client/useLocale.ts
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport type { useLocale as _useLocale } from 'next-intl';\nimport { useLocale as useLocaleIntlayer } from 'next-intlayer';\n\n/**\n * Drop-in for next-intl's `useLocale`.\n */\nexport const useLocale: typeof _useLocale = (): string => {\n const { locale } = useLocaleIntlayer();\n return locale as string;\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,kBAA6C;CACxD,MAAM,EAAE,yCAA8B;AACtC,QAAO"}
1
+ {"version":3,"file":"useLocale.cjs","names":[],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["'use client';\n\nimport type { useLocale as _useLocale } from 'next-intl';\nimport { useLocale as useLocaleIntlayer } from 'next-intlayer';\n\n/**\n * Drop-in for next-intl's `useLocale`.\n */\nexport const useLocale: typeof _useLocale = (): string => {\n const { locale } = useLocaleIntlayer();\n return locale as string;\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,kBAA6C;CACxD,MAAM,EAAE,wCAA6B;CACrC,OAAO;AACT"}
@@ -1,44 +1,33 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  const require_server_getLocale = require('./server/getLocale.cjs');
3
+ let _intlayer_use_intl = require("@intlayer/use-intl");
4
4
  let next_intlayer = require("next-intlayer");
5
5
 
6
6
  //#region src/getDictionary.ts
7
- const navigatePath = (objectValue, path) => {
8
- if (!path) return objectValue;
9
- const parts = path.split(".");
10
- let current = objectValue;
11
- for (const part of parts) {
12
- if (current === null || current === void 0 || typeof current !== "object") return;
13
- current = current[part];
14
- }
15
- return current;
7
+ const readRestArgument = (rest) => {
8
+ if (typeof rest === "string") return { namespacePrefix: rest };
9
+ return { localeOverride: rest?.locale };
16
10
  };
17
11
  /**
18
12
  * Dictionary-accepting variant of `getTranslations`.
19
13
  *
20
- * Used internally by the SWC optimization: instead of looking up the dictionary
21
- * at runtime by key, the SWC plugin pre-imports the dictionary JSON at build time
22
- * and passes it directly here. This enables tree-shaking of unused locale content.
14
+ * Used internally by the build-time optimization: instead of looking up the
15
+ * dictionary at runtime by key, the babel/swc plugin pre-imports the dictionary
16
+ * JSON at build time and passes it directly here. This enables tree-shaking of
17
+ * unused locale content.
23
18
  *
24
- * Runs on the server, where next-intl apps do not mount an `IntlayerServerProvider`.
25
- * The request locale therefore cannot be read from a server context and is resolved
26
- * asynchronously from the cookie/header via `getLocale()`. `getTranslations` is always
27
- * awaited, so an async resolver is a drop-in replacement.
19
+ * Runs on the server, where next-intl apps do not mount an
20
+ * `IntlayerServerProvider`. The request locale therefore cannot be read from a
21
+ * server context and is resolved asynchronously from the cookie/header via
22
+ * `getLocale()` (or the explicit `{ locale }` of the object overload).
23
+ * `getTranslations` is always awaited, so an async resolver is a drop-in
24
+ * replacement.
28
25
  */
29
- const getDictionary = async (dictionary, namespacePrefix) => {
30
- const content = (0, next_intlayer.getDictionary)(dictionary, await require_server_getLocale.getLocale());
31
- const resolveKey = (key) => namespacePrefix ? `${namespacePrefix}.${key}` : key;
32
- return Object.assign((lookup, params) => {
33
- const rawValue = navigatePath(content, resolveKey(String(lookup)));
34
- const str = String(rawValue ?? resolveKey(String(lookup)));
35
- if (!params) return str;
36
- return str.replace(/\{(\w+)\}/g, (_, k) => params[k] != null ? String(params[k]) : `{${k}}`);
37
- }, {
38
- has: (lookup) => navigatePath(content, resolveKey(String(lookup))) != null,
39
- raw: (lookup) => navigatePath(content, resolveKey(String(lookup)))
40
- });
41
- };
26
+ const getDictionary = (async (dictionary, rest) => {
27
+ const { namespacePrefix, localeOverride } = readRestArgument(rest);
28
+ const locale = localeOverride ?? await require_server_getLocale.getLocale();
29
+ return (0, _intlayer_use_intl.createDictionaryTranslator)(locale, (0, next_intlayer.getDictionary)(dictionary, locale), namespacePrefix);
30
+ });
42
31
 
43
32
  //#endregion
44
33
  exports.getDictionary = getDictionary;
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.cjs","names":["getLocale"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getDictionary as getDictionaryBase } from 'next-intlayer';\nimport { getLocale } from './server/getLocale';\n\nconst navigatePath = (objectValue: unknown, path: string): unknown => {\n if (!path) return objectValue;\n const parts = path.split('.');\n let current: unknown = objectValue;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Dictionary-accepting variant of `getTranslations`.\n *\n * Used internally by the SWC optimization: instead of looking up the dictionary\n * at runtime by key, the SWC plugin pre-imports the dictionary JSON at build time\n * and passes it directly here. This enables tree-shaking of unused locale content.\n *\n * Runs on the server, where next-intl apps do not mount an `IntlayerServerProvider`.\n * The request locale therefore cannot be read from a server context and is resolved\n * asynchronously from the cookie/header via `getLocale()`. `getTranslations` is always\n * awaited, so an async resolver is a drop-in replacement.\n */\nexport const getDictionary = async <T extends Dictionary>(\n dictionary: T,\n namespacePrefix?: string\n) => {\n const locale = (await getLocale()) as LocalesValues;\n const content = getDictionaryBase(dictionary, locale);\n\n const resolveKey = (key: string): string =>\n namespacePrefix ? `${namespacePrefix}.${key}` : key;\n\n return Object.assign(\n <P extends ValidDotPathsFor<any>>(\n lookup: P,\n params?: Record<string, unknown>\n ): string => {\n const rawValue = navigatePath(content, resolveKey(String(lookup)));\n const str = String(rawValue ?? resolveKey(String(lookup)));\n if (!params) return str;\n return str.replace(/\\{(\\w+)\\}/g, (_, k) =>\n params[k] != null ? String(params[k]) : `{${k}}`\n );\n },\n {\n has: <P extends ValidDotPathsFor<any>>(lookup: P): boolean =>\n navigatePath(content, resolveKey(String(lookup))) != null,\n raw: <P extends ValidDotPathsFor<any>>(lookup: P): unknown =>\n navigatePath(content, resolveKey(String(lookup))),\n }\n );\n};\n"],"mappings":";;;;;;AAMA,MAAM,gBAAgB,aAAsB,SAA0B;AACpE,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,IAAI,UAAmB;AACvB,MAAK,MAAM,QAAQ,OAAO;AACxB,MACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,SAEnB;AAEF,YAAW,QAAoC;;AAEjD,QAAO;;;;;;;;;;;;;;AAeT,MAAa,gBAAgB,OAC3B,YACA,oBACG;CAEH,MAAM,2CAA4B,YAAY,MADxBA,oCAAW,CACoB;CAErD,MAAM,cAAc,QAClB,kBAAkB,GAAG,gBAAgB,GAAG,QAAQ;AAElD,QAAO,OAAO,QAEV,QACA,WACW;EACX,MAAM,WAAW,aAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EAClE,MAAM,MAAM,OAAO,YAAY,WAAW,OAAO,OAAO,CAAC,CAAC;AAC1D,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,IAAI,QAAQ,eAAe,GAAG,MACnC,OAAO,MAAM,OAAO,OAAO,OAAO,GAAG,GAAG,IAAI,EAAE,GAC/C;IAEH;EACE,MAAuC,WACrC,aAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC,IAAI;EACvD,MAAuC,WACrC,aAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EACpD,CACF"}
1
+ {"version":3,"file":"getDictionary.cjs","names":["getLocale"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type ScopedTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { getDictionary as getDictionaryBase } from 'next-intlayer';\nimport { getLocale } from './server/getLocale';\n\n/**\n * Trailing argument left by the optimize pass. `getTranslations('ns.scope')`\n * yields the key-prefix remainder as a string, while the object overload\n * `getTranslations({ locale, namespace })` keeps its options object (with the\n * namespace stripped, since the dictionary is now passed directly).\n */\ntype DictionaryTranslatorRest = string | { locale?: LocalesValues };\n\nconst readRestArgument = (\n rest: DictionaryTranslatorRest | undefined\n): { namespacePrefix?: string; localeOverride?: LocalesValues } => {\n if (typeof rest === 'string') return { namespacePrefix: rest };\n return { localeOverride: rest?.locale };\n};\n\n/**\n * Overload set for {@link getDictionary}: a string rest argument is the\n * key-prefix remainder of a nested namespace (relative dot-paths under the\n * scope); otherwise the translator is typed against the dictionary's\n * dot-paths.\n */\ntype GetDictionary = {\n <T extends Dictionary, Prefix extends string>(\n dictionary: T,\n namespacePrefix: Prefix\n ): Promise<ScopedTranslateFunction<T['key'] & DictionaryKeys, Prefix>>;\n <T extends Dictionary>(\n dictionary: T,\n options?: { locale?: LocalesValues }\n ): Promise<TranslateFunction<T['key'] & DictionaryKeys>>;\n};\n\n/**\n * Dictionary-accepting variant of `getTranslations`.\n *\n * Used internally by the build-time optimization: instead of looking up the\n * dictionary at runtime by key, the babel/swc plugin pre-imports the dictionary\n * JSON at build time and passes it directly here. This enables tree-shaking of\n * unused locale content.\n *\n * Runs on the server, where next-intl apps do not mount an\n * `IntlayerServerProvider`. The request locale therefore cannot be read from a\n * server context and is resolved asynchronously from the cookie/header via\n * `getLocale()` (or the explicit `{ locale }` of the object overload).\n * `getTranslations` is always awaited, so an async resolver is a drop-in\n * replacement.\n */\nexport const getDictionary = (async <T extends Dictionary>(\n dictionary: T,\n rest?: DictionaryTranslatorRest\n) => {\n const { namespacePrefix, localeOverride } = readRestArgument(rest);\n const locale = localeOverride ?? ((await getLocale()) as LocalesValues);\n const content = getDictionaryBase(dictionary, locale);\n\n return createDictionaryTranslator(locale, content, namespacePrefix);\n}) as GetDictionary;\n"],"mappings":";;;;;;AAqBA,MAAM,oBACJ,SACiE;CACjE,IAAI,OAAO,SAAS,UAAU,OAAO,EAAE,iBAAiB,KAAK;CAC7D,OAAO,EAAE,gBAAgB,MAAM,OAAO;AACxC;;;;;;;;;;;;;;;;AAkCA,MAAa,iBAAiB,OAC5B,YACA,SACG;CACH,MAAM,EAAE,iBAAiB,mBAAmB,iBAAiB,IAAI;CACjE,MAAM,SAAS,kBAAoB,MAAMA,mCAAU;CAGnD,0DAAkC,yCAFA,YAAY,MAEE,GAAG,eAAe;AACpE"}
@@ -1,34 +1,18 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
+ const require_server_getLocale = require('./server/getLocale.cjs');
3
+ let _intlayer_use_intl = require("@intlayer/use-intl");
3
4
  let next_intlayer_server = require("next-intlayer/server");
4
5
 
5
6
  //#region src/getDictionaryDynamic.ts
6
- const navigatePath = (objectValue, path) => {
7
- if (!path) return objectValue;
8
- const parts = path.split(".");
9
- let current = objectValue;
10
- for (const part of parts) {
11
- if (current === null || current === void 0 || typeof current !== "object") return;
12
- current = current[part];
13
- }
14
- return current;
15
- };
16
7
  /**
17
8
  * Dynamic dictionary-accepting variant of `getTranslations`.
9
+ *
10
+ * Counterpart to {@link getDictionary} for dictionaries imported lazily per
11
+ * locale. Used internally by the build-time optimization.
18
12
  */
19
- const getDictionaryDynamic = async (dictionaryPromise, key, namespacePrefix) => {
20
- const content = await (0, next_intlayer_server.useDictionaryDynamic)(dictionaryPromise, key);
21
- const resolveKey = (lookupKey) => namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;
22
- return Object.assign((lookup, params) => {
23
- const rawValue = navigatePath(content, resolveKey(String(lookup)));
24
- const str = String(rawValue ?? resolveKey(String(lookup)));
25
- if (!params) return str;
26
- return str.replace(/\{(\w+)\}/g, (_, k) => params[k] != null ? String(params[k]) : `{${k}}`);
27
- }, {
28
- has: (lookup) => navigatePath(content, resolveKey(String(lookup))) != null,
29
- raw: (lookup) => navigatePath(content, resolveKey(String(lookup)))
30
- });
31
- };
13
+ const getDictionaryDynamic = (async (dictionaryPromise, key, namespacePrefix) => {
14
+ return (0, _intlayer_use_intl.createDictionaryTranslator)(await require_server_getLocale.getLocale(), await (0, next_intlayer_server.useDictionaryDynamic)(dictionaryPromise, key), namespacePrefix);
15
+ });
32
16
 
33
17
  //#endregion
34
18
  exports.getDictionaryDynamic = getDictionaryDynamic;
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionaryDynamic.cjs","names":[],"sources":["../../src/getDictionaryDynamic.ts"],"sourcesContent":["import type { ValidDotPathsFor } from '@intlayer/core/transpiler';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useDictionaryDynamic as getDictionaryDynamicBase } from 'next-intlayer/server';\n\nconst navigatePath = (objectValue: unknown, path: string): unknown => {\n if (!path) return objectValue;\n const parts = path.split('.');\n let current: unknown = objectValue;\n for (const part of parts) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/**\n * Dynamic dictionary-accepting variant of `getTranslations`.\n */\nexport const getDictionaryDynamic = async <\n const T extends Dictionary,\n const K extends string,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n namespacePrefix?: string\n) => {\n const content = await getDictionaryDynamicBase<T, any>(\n dictionaryPromise,\n key as any\n );\n\n const resolveKey = (lookupKey: string): string =>\n namespacePrefix ? `${namespacePrefix}.${lookupKey}` : lookupKey;\n\n return Object.assign(\n <P extends ValidDotPathsFor<any>>(\n lookup: P,\n params?: Record<string, unknown>\n ): string => {\n const rawValue = navigatePath(content, resolveKey(String(lookup)));\n const str = String(rawValue ?? resolveKey(String(lookup)));\n if (!params) return str;\n return str.replace(/\\{(\\w+)\\}/g, (_, k) =>\n params[k] != null ? String(params[k]) : `{${k}}`\n );\n },\n {\n has: <P extends ValidDotPathsFor<any>>(lookup: P): boolean =>\n navigatePath(content, resolveKey(String(lookup))) != null,\n raw: <P extends ValidDotPathsFor<any>>(lookup: P): unknown =>\n navigatePath(content, resolveKey(String(lookup))),\n }\n );\n};\n"],"mappings":";;;;;AAKA,MAAM,gBAAgB,aAAsB,SAA0B;AACpE,KAAI,CAAC,KAAM,QAAO;CAClB,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,IAAI,UAAmB;AACvB,MAAK,MAAM,QAAQ,OAAO;AACxB,MACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,SAEnB;AAEF,YAAW,QAAoC;;AAEjD,QAAO;;;;;AAMT,MAAa,uBAAuB,OAIlC,mBACA,KACA,oBACG;CACH,MAAM,UAAU,qDACd,mBACA,IACD;CAED,MAAM,cAAc,cAClB,kBAAkB,GAAG,gBAAgB,GAAG,cAAc;AAExD,QAAO,OAAO,QAEV,QACA,WACW;EACX,MAAM,WAAW,aAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EAClE,MAAM,MAAM,OAAO,YAAY,WAAW,OAAO,OAAO,CAAC,CAAC;AAC1D,MAAI,CAAC,OAAQ,QAAO;AACpB,SAAO,IAAI,QAAQ,eAAe,GAAG,MACnC,OAAO,MAAM,OAAO,OAAO,OAAO,GAAG,GAAG,IAAI,EAAE,GAC/C;IAEH;EACE,MAAuC,WACrC,aAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC,IAAI;EACvD,MAAuC,WACrC,aAAa,SAAS,WAAW,OAAO,OAAO,CAAC,CAAC;EACpD,CACF"}
1
+ {"version":3,"file":"getDictionaryDynamic.cjs","names":["getLocale"],"sources":["../../src/getDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport {\n createDictionaryTranslator,\n type ScopedTranslateFunction,\n type TranslateFunction,\n} from '@intlayer/use-intl';\nimport { useDictionaryDynamic as getDictionaryDynamicBase } from 'next-intlayer/server';\nimport { getLocale } from './server/getLocale';\n\n/**\n * Overload set for {@link getDictionaryDynamic}: without a prefix the\n * translator is typed against the dictionary's dot-paths; with a prefix the\n * keys are relative dot-paths under that scope.\n */\ntype GetDictionaryDynamic = {\n <T extends Dictionary, K extends DictionaryKeys>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K\n ): Promise<TranslateFunction<K>>;\n <T extends Dictionary, K extends DictionaryKeys, Prefix extends string>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n namespacePrefix: Prefix\n ): Promise<ScopedTranslateFunction<K, Prefix>>;\n};\n\n/**\n * Dynamic dictionary-accepting variant of `getTranslations`.\n *\n * Counterpart to {@link getDictionary} for dictionaries imported lazily per\n * locale. Used internally by the build-time optimization.\n */\nexport const getDictionaryDynamic = (async <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n namespacePrefix?: string\n) => {\n const locale = (await getLocale()) as LocalesValues;\n const content = await getDictionaryDynamicBase<T, K>(dictionaryPromise, key);\n\n return createDictionaryTranslator(locale, content, namespacePrefix);\n}) as GetDictionaryDynamic;\n"],"mappings":";;;;;;;;;;;;AAqCA,MAAa,wBAAwB,OAInC,mBACA,KACA,oBACG;CAIH,0DAAkC,MAHZA,mCAAU,GAGU,qDAFW,mBAAmB,GAAG,GAExB,eAAe;AACpE"}
@@ -1,23 +1,99 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_routing = require('./routing.cjs');
3
- const require_hasLocale = require('./hasLocale.cjs');
4
- const require_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
5
- const require_useDictionary = require('./useDictionary.cjs');
6
- const require_client_helpers = require('./client/helpers.cjs');
7
3
  const require_client_NextIntlClientProvider = require('./client/NextIntlClientProvider.cjs');
8
4
  const require_client_useLocale = require('./client/useLocale.cjs');
9
- const require_client_useTranslations = require('./client/useTranslations.cjs');
5
+ let _intlayer_use_intl = require("@intlayer/use-intl");
10
6
 
11
- exports.IntlProvider = require_client_helpers.IntlProvider;
7
+ Object.defineProperty(exports, 'IntlError', {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _intlayer_use_intl.IntlError;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, 'IntlErrorCode', {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _intlayer_use_intl.IntlErrorCode;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, 'IntlProvider', {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _intlayer_use_intl.IntlProvider;
23
+ }
24
+ });
12
25
  exports.NextIntlClientProvider = require_client_NextIntlClientProvider.NextIntlClientProvider;
26
+ Object.defineProperty(exports, 'createFormatter', {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _intlayer_use_intl.createFormatter;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, 'createTranslator', {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _intlayer_use_intl.createTranslator;
36
+ }
37
+ });
13
38
  exports.defineRouting = require_routing.defineRouting;
14
- exports.hasLocale = require_hasLocale.hasLocale;
15
- exports.useDictionary = require_useDictionary.useDictionary;
16
- exports.useDictionaryDynamic = require_useDictionaryDynamic.useDictionaryDynamic;
17
- exports.useExtracted = require_client_helpers.useExtracted;
18
- exports.useFormatter = require_client_helpers.useFormatter;
39
+ Object.defineProperty(exports, 'hasLocale', {
40
+ enumerable: true,
41
+ get: function () {
42
+ return _intlayer_use_intl.hasLocale;
43
+ }
44
+ });
45
+ Object.defineProperty(exports, 'initializeConfig', {
46
+ enumerable: true,
47
+ get: function () {
48
+ return _intlayer_use_intl.initializeConfig;
49
+ }
50
+ });
51
+ Object.defineProperty(exports, 'useDictionary', {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _intlayer_use_intl.useDictionary;
55
+ }
56
+ });
57
+ Object.defineProperty(exports, 'useDictionaryDynamic', {
58
+ enumerable: true,
59
+ get: function () {
60
+ return _intlayer_use_intl.useDictionaryDynamic;
61
+ }
62
+ });
63
+ Object.defineProperty(exports, 'useExtracted', {
64
+ enumerable: true,
65
+ get: function () {
66
+ return _intlayer_use_intl._useExtracted;
67
+ }
68
+ });
69
+ Object.defineProperty(exports, 'useFormatter', {
70
+ enumerable: true,
71
+ get: function () {
72
+ return _intlayer_use_intl.useFormatter;
73
+ }
74
+ });
19
75
  exports.useLocale = require_client_useLocale.useLocale;
20
- exports.useMessages = require_client_helpers.useMessages;
21
- exports.useNow = require_client_helpers.useNow;
22
- exports.useTimeZone = require_client_helpers.useTimeZone;
23
- exports.useTranslations = require_client_useTranslations.useTranslations;
76
+ Object.defineProperty(exports, 'useMessages', {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _intlayer_use_intl.useMessages;
80
+ }
81
+ });
82
+ Object.defineProperty(exports, 'useNow', {
83
+ enumerable: true,
84
+ get: function () {
85
+ return _intlayer_use_intl.useNow;
86
+ }
87
+ });
88
+ Object.defineProperty(exports, 'useTimeZone', {
89
+ enumerable: true,
90
+ get: function () {
91
+ return _intlayer_use_intl.useTimeZone;
92
+ }
93
+ });
94
+ Object.defineProperty(exports, 'useTranslations', {
95
+ enumerable: true,
96
+ get: function () {
97
+ return _intlayer_use_intl.useTranslations;
98
+ }
99
+ });
@@ -1,5 +1,4 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
2
  let next_intlayer_middleware = require("next-intlayer/middleware");
4
3
 
5
4
  //#region src/middleware.ts
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.cjs","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { NextFetchEvent, NextRequest } from 'next/server';\nimport type _createMiddleware from 'next-intl/middleware';\nimport { intlayerMiddleware } from 'next-intlayer/middleware';\n\n/**\n * Drop-in replacement for next-intl's `createMiddleware`.\n *\n * Returns Intlayer's proxy/middleware, which handles locale detection and\n * routing from the Intlayer configuration. The `routing` argument is accepted\n * for API compatibility but ignored — locales come from `intlayer.config`.\n *\n * @example\n * ```ts\n * // proxy.ts (or middleware.ts on Next <= 15)\n * import createMiddleware from 'next-intl/middleware';\n * export default createMiddleware(routing);\n * export const config = { matcher: ['/((?!api|_next|.*\\\\..*).*)'] };\n * ```\n */\nexport const createMiddleware: typeof _createMiddleware =\n (_routing?: unknown) => (request: NextRequest, event?: NextFetchEvent) => {\n const response = intlayerMiddleware(request, event);\n\n if (response) {\n // Intlayer middleware writes the resolved locale to the x-intlayer-locale header\n // We read it and explicitly set the NEXT_LOCALE cookie to maintain compatibility with next-intl\n const resolvedLocale = response.headers.get('x-intlayer-locale');\n if (resolvedLocale) {\n response.cookies.set('NEXT_LOCALE', resolvedLocale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n }\n }\n\n return response;\n };\n\nexport default createMiddleware;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,MAAa,oBACV,cAAwB,SAAsB,UAA2B;CACxE,MAAM,4DAA8B,SAAS,MAAM;AAEnD,KAAI,UAAU;EAGZ,MAAM,iBAAiB,SAAS,QAAQ,IAAI,oBAAoB;AAChE,MAAI,eACF,UAAS,QAAQ,IAAI,eAAe,gBAAgB;GAClD,MAAM;GACN,UAAU;GACV,QAAQ,OAAU,KAAK;GACxB,CAAC;;AAIN,QAAO"}
1
+ {"version":3,"file":"middleware.cjs","names":[],"sources":["../../src/middleware.ts"],"sourcesContent":["import type { NextFetchEvent, NextRequest } from 'next/server';\nimport type _createMiddleware from 'next-intl/middleware';\nimport { intlayerMiddleware } from 'next-intlayer/middleware';\n\n/**\n * Drop-in replacement for next-intl's `createMiddleware`.\n *\n * Returns Intlayer's proxy/middleware, which handles locale detection and\n * routing from the Intlayer configuration. The `routing` argument is accepted\n * for API compatibility but ignored — locales come from `intlayer.config`.\n *\n * @example\n * ```ts\n * // proxy.ts (or middleware.ts on Next <= 15)\n * import createMiddleware from 'next-intl/middleware';\n * export default createMiddleware(routing);\n * export const config = { matcher: ['/((?!api|_next|.*\\\\..*).*)'] };\n * ```\n */\nexport const createMiddleware: typeof _createMiddleware =\n (_routing?: unknown) => (request: NextRequest, event?: NextFetchEvent) => {\n const response = intlayerMiddleware(request, event);\n\n if (response) {\n // Intlayer middleware writes the resolved locale to the x-intlayer-locale header\n // We read it and explicitly set the NEXT_LOCALE cookie to maintain compatibility with next-intl\n const resolvedLocale = response.headers.get('x-intlayer-locale');\n if (resolvedLocale) {\n response.cookies.set('NEXT_LOCALE', resolvedLocale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n }\n }\n\n return response;\n };\n\nexport default createMiddleware;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAa,oBACV,cAAwB,SAAsB,UAA2B;CACxE,MAAM,4DAA8B,SAAS,KAAK;CAElD,IAAI,UAAU;EAGZ,MAAM,iBAAiB,SAAS,QAAQ,IAAI,mBAAmB;EAC/D,IAAI,gBACF,SAAS,QAAQ,IAAI,eAAe,gBAAgB;GAClD,MAAM;GACN,UAAU;GACV,QAAQ,OAAU,KAAK;EACzB,CAAC;CAEL;CAEA,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"Link.cjs","names":["NextLink","localizeHref"],"sources":["../../../src/navigation/Link.tsx"],"sourcesContent":["'use client';\n\nimport NextLink from 'next/link';\nimport { useLocale } from 'next-intlayer';\nimport { type ComponentPropsWithoutRef, forwardRef, type Ref } from 'react';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Props for the compat `Link`: identical to `next/link` except `href` accepts a\n * `next-intl` href and an optional `locale` overrides the current one.\n */\nexport type LinkProps = Omit<\n ComponentPropsWithoutRef<typeof NextLink>,\n 'href' | 'locale'\n> & {\n href: NextIntlHref;\n locale?: string;\n};\n\n/**\n * Drop-in for the `Link` returned by next-intl's `createNavigation`. Prefixes\n * `href` with the active locale (or the `locale` prop) before delegating to\n * `next/link`.\n */\nexport const Link = forwardRef(\n ({ href, locale, ...rest }: LinkProps, ref: Ref<HTMLAnchorElement>) => {\n const { locale: currentLocale } = useLocale();\n const targetLocale = locale ?? (currentLocale as string);\n\n return (\n <NextLink ref={ref} href={localizeHref(href, targetLocale)} {...rest} />\n );\n }\n);\n\nLink.displayName = 'Link';\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAa,8BACV,EAAE,MAAM,QAAQ,GAAG,QAAmB,QAAgC;CACrE,MAAM,EAAE,QAAQ,gDAA6B;AAG7C,QACE,2CAACA,mBAAD;EAAe;EAAK,MAAMC,6CAAa,MAHpB,UAAW,cAG4B;EAAE,GAAI;EAAQ;EAG7E;AAED,KAAK,cAAc"}
1
+ {"version":3,"file":"Link.cjs","names":["NextLink","localizeHref"],"sources":["../../../src/navigation/Link.tsx"],"sourcesContent":["'use client';\n\nimport NextLink from 'next/link';\nimport { useLocale } from 'next-intlayer';\nimport { type ComponentPropsWithoutRef, forwardRef, type Ref } from 'react';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Props for the compat `Link`: identical to `next/link` except `href` accepts a\n * `next-intl` href and an optional `locale` overrides the current one.\n */\nexport type LinkProps = Omit<\n ComponentPropsWithoutRef<typeof NextLink>,\n 'href' | 'locale'\n> & {\n href: NextIntlHref;\n locale?: string;\n};\n\n/**\n * Drop-in for the `Link` returned by next-intl's `createNavigation`. Prefixes\n * `href` with the active locale (or the `locale` prop) before delegating to\n * `next/link`.\n */\nexport const Link = forwardRef(\n ({ href, locale, ...rest }: LinkProps, ref: Ref<HTMLAnchorElement>) => {\n const { locale: currentLocale } = useLocale();\n const targetLocale = locale ?? (currentLocale as string);\n\n return (\n <NextLink ref={ref} href={localizeHref(href, targetLocale)} {...rest} />\n );\n }\n);\n\nLink.displayName = 'Link';\n"],"mappings":";;;;;;;;;;;;;;;;;AAwBA,MAAa,8BACV,EAAE,MAAM,QAAQ,GAAG,QAAmB,QAAgC;CACrE,MAAM,EAAE,QAAQ,+CAA4B;CAG5C,OACE,2CAACA,mBAAD;EAAe;EAAK,MAAMC,6CAAa,MAHpB,UAAW,aAG2B;EAAG,GAAI;CAAO;AAE3E,CACF;AAEA,KAAK,cAAc"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_navigation_localizeHref = require('./localizeHref.cjs');
4
3
  const require_navigation_Link = require('./Link.cjs');
5
4
  const require_navigation_hooks = require('./hooks.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"createNavigation.cjs","names":["localizeHref","Link"],"sources":["../../../src/navigation/createNavigation.ts"],"sourcesContent":["import {\n permanentRedirect as nextPermanentRedirect,\n redirect as nextRedirect,\n} from 'next/navigation';\nimport type { createNavigation as _createNavigation } from 'next-intl/navigation';\nimport { usePathname, useRouter } from './hooks';\nimport { Link } from './Link';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/** Arguments shared by `getPathname`, `redirect` and `permanentRedirect`. */\ntype LocalizedHrefArgs = { href: NextIntlHref; locale: string };\n\n/** The optional `RedirectType` accepted by `next/navigation`'s redirect APIs. */\ntype RedirectTypeArg = Parameters<typeof nextRedirect>[1];\n\n/**\n * Drop-in replacement for next-intl's `createNavigation`.\n *\n * Returns locale-aware navigation APIs (`Link`, `usePathname`, `useRouter`,\n * `getPathname`, `redirect`, `permanentRedirect`) backed by Intlayer's routing\n * configuration. The `routing` argument is accepted for API compatibility;\n * locales come from the Intlayer configuration.\n *\n * @example\n * ```ts\n * export const { Link, redirect, usePathname, useRouter, getPathname } =\n * createNavigation();\n * ```\n */\nexport const createNavigation: typeof _createNavigation = (\n _routing?: unknown\n) => {\n const getPathname = ({ href, locale }: LocalizedHrefArgs): string =>\n localizeHref(href, locale);\n\n const redirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextRedirect(localizeHref(href, locale), type);\n\n const permanentRedirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextPermanentRedirect(localizeHref(href, locale), type);\n\n return {\n Link: Link as ReturnType<typeof _createNavigation>['Link'],\n usePathname,\n useRouter,\n getPathname,\n redirect,\n permanentRedirect,\n } as ReturnType<typeof _createNavigation>;\n};\n\nexport default createNavigation;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,oBACX,aACG;CACH,MAAM,eAAe,EAAE,MAAM,aAC3BA,6CAAa,MAAM,OAAO;CAE5B,MAAM,YACJ,EAAE,MAAM,UACR,uCACgBA,6CAAa,MAAM,OAAO,EAAE,KAAK;CAEnD,MAAM,qBACJ,EAAE,MAAM,UACR,gDACyBA,6CAAa,MAAM,OAAO,EAAE,KAAK;AAE5D,QAAO;EACL,MAAMC;EACN;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"createNavigation.cjs","names":["localizeHref","Link"],"sources":["../../../src/navigation/createNavigation.ts"],"sourcesContent":["import {\n permanentRedirect as nextPermanentRedirect,\n redirect as nextRedirect,\n} from 'next/navigation';\nimport type { createNavigation as _createNavigation } from 'next-intl/navigation';\nimport { usePathname, useRouter } from './hooks';\nimport { Link } from './Link';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/** Arguments shared by `getPathname`, `redirect` and `permanentRedirect`. */\ntype LocalizedHrefArgs = { href: NextIntlHref; locale: string };\n\n/** The optional `RedirectType` accepted by `next/navigation`'s redirect APIs. */\ntype RedirectTypeArg = Parameters<typeof nextRedirect>[1];\n\n/**\n * Drop-in replacement for next-intl's `createNavigation`.\n *\n * Returns locale-aware navigation APIs (`Link`, `usePathname`, `useRouter`,\n * `getPathname`, `redirect`, `permanentRedirect`) backed by Intlayer's routing\n * configuration. The `routing` argument is accepted for API compatibility;\n * locales come from the Intlayer configuration.\n *\n * @example\n * ```ts\n * export const { Link, redirect, usePathname, useRouter, getPathname } =\n * createNavigation();\n * ```\n */\nexport const createNavigation: typeof _createNavigation = (\n _routing?: unknown\n) => {\n const getPathname = ({ href, locale }: LocalizedHrefArgs): string =>\n localizeHref(href, locale);\n\n const redirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextRedirect(localizeHref(href, locale), type);\n\n const permanentRedirect = (\n { href, locale }: LocalizedHrefArgs,\n type?: RedirectTypeArg\n ) => nextPermanentRedirect(localizeHref(href, locale), type);\n\n return {\n Link: Link as ReturnType<typeof _createNavigation>['Link'],\n usePathname,\n useRouter,\n getPathname,\n redirect,\n permanentRedirect,\n } as ReturnType<typeof _createNavigation>;\n};\n\nexport default createNavigation;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,oBACX,aACG;CACH,MAAM,eAAe,EAAE,MAAM,aAC3BA,6CAAa,MAAM,MAAM;CAE3B,MAAM,YACJ,EAAE,MAAM,UACR,uCACgBA,6CAAa,MAAM,MAAM,GAAG,IAAI;CAElD,MAAM,qBACJ,EAAE,MAAM,UACR,gDACyBA,6CAAa,MAAM,MAAM,GAAG,IAAI;CAE3D,OAAO;EACL,MAAMC;EACN;EACA;EACA;EACA;EACA;CACF;AACF"}
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
5
4
  const require_navigation_localizeHref = require('./localizeHref.cjs');
6
5
  let next_intlayer = require("next-intlayer");
7
6
  let next_navigation = require("next/navigation");
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.cjs","names":["localizeHref"],"sources":["../../../src/navigation/hooks.ts"],"sourcesContent":["'use client';\n\nimport {\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n} from 'next/navigation';\nimport { useLocale } from 'next-intlayer';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Options accepted by the locale-aware router methods: the standard Next.js\n * navigate options plus an optional target `locale`.\n */\ntype NavigateOptions = { locale?: string } & Record<string, unknown>;\n\n/**\n * Drop-in for the `usePathname` returned by next-intl's `createNavigation`.\n * Returns the current pathname with the locale prefix stripped.\n */\nexport const usePathname = (): string => {\n const pathname = useNextPathname();\n const { locale } = useLocale();\n const prefix = `/${locale}`;\n\n if (pathname === prefix) return '/';\n if (pathname.startsWith(`${prefix}/`)) return pathname.slice(prefix.length);\n return pathname;\n};\n\n/**\n * Drop-in for the `useRouter` returned by next-intl's `createNavigation`.\n * Wraps the Next.js router so `push`/`replace`/`prefetch` localize their href\n * (honouring an optional `locale` option) before navigating.\n */\nexport const useRouter = () => {\n const router = useNextRouter();\n const { locale: currentLocale } = useLocale();\n\n const localize = (href: NextIntlHref, locale?: string): string =>\n localizeHref(href, locale ?? (currentLocale as string));\n\n return {\n ...router,\n push: (href: NextIntlHref, options?: NavigateOptions) =>\n router.push(\n localize(href, options?.locale),\n options as Parameters<typeof router.push>[1]\n ),\n replace: (href: NextIntlHref, options?: NavigateOptions) =>\n router.replace(\n localize(href, options?.locale),\n options as Parameters<typeof router.replace>[1]\n ),\n prefetch: (href: NextIntlHref, options?: NavigateOptions) =>\n router.prefetch(localize(href, options?.locale)),\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,oBAA4B;CACvC,MAAM,6CAA4B;CAClC,MAAM,EAAE,yCAAsB;CAC9B,MAAM,SAAS,IAAI;AAEnB,KAAI,aAAa,OAAQ,QAAO;AAChC,KAAI,SAAS,WAAW,GAAG,OAAO,GAAG,CAAE,QAAO,SAAS,MAAM,OAAO,OAAO;AAC3E,QAAO;;;;;;;AAQT,MAAa,kBAAkB;CAC7B,MAAM,yCAAwB;CAC9B,MAAM,EAAE,QAAQ,gDAA6B;CAE7C,MAAM,YAAY,MAAoB,WACpCA,6CAAa,MAAM,UAAW,cAAyB;AAEzD,QAAO;EACL,GAAG;EACH,OAAO,MAAoB,YACzB,OAAO,KACL,SAAS,MAAM,SAAS,OAAO,EAC/B,QACD;EACH,UAAU,MAAoB,YAC5B,OAAO,QACL,SAAS,MAAM,SAAS,OAAO,EAC/B,QACD;EACH,WAAW,MAAoB,YAC7B,OAAO,SAAS,SAAS,MAAM,SAAS,OAAO,CAAC;EACnD"}
1
+ {"version":3,"file":"hooks.cjs","names":["localizeHref"],"sources":["../../../src/navigation/hooks.ts"],"sourcesContent":["'use client';\n\nimport {\n usePathname as useNextPathname,\n useRouter as useNextRouter,\n} from 'next/navigation';\nimport { useLocale } from 'next-intlayer';\nimport { localizeHref, type NextIntlHref } from './localizeHref';\n\n/**\n * Options accepted by the locale-aware router methods: the standard Next.js\n * navigate options plus an optional target `locale`.\n */\ntype NavigateOptions = { locale?: string } & Record<string, unknown>;\n\n/**\n * Drop-in for the `usePathname` returned by next-intl's `createNavigation`.\n * Returns the current pathname with the locale prefix stripped.\n */\nexport const usePathname = (): string => {\n const pathname = useNextPathname();\n const { locale } = useLocale();\n const prefix = `/${locale}`;\n\n if (pathname === prefix) return '/';\n if (pathname.startsWith(`${prefix}/`)) return pathname.slice(prefix.length);\n return pathname;\n};\n\n/**\n * Drop-in for the `useRouter` returned by next-intl's `createNavigation`.\n * Wraps the Next.js router so `push`/`replace`/`prefetch` localize their href\n * (honouring an optional `locale` option) before navigating.\n */\nexport const useRouter = () => {\n const router = useNextRouter();\n const { locale: currentLocale } = useLocale();\n\n const localize = (href: NextIntlHref, locale?: string): string =>\n localizeHref(href, locale ?? (currentLocale as string));\n\n return {\n ...router,\n push: (href: NextIntlHref, options?: NavigateOptions) =>\n router.push(\n localize(href, options?.locale),\n options as Parameters<typeof router.push>[1]\n ),\n replace: (href: NextIntlHref, options?: NavigateOptions) =>\n router.replace(\n localize(href, options?.locale),\n options as Parameters<typeof router.replace>[1]\n ),\n prefetch: (href: NextIntlHref, options?: NavigateOptions) =>\n router.prefetch(localize(href, options?.locale)),\n };\n};\n"],"mappings":";;;;;;;;;;;;AAmBA,MAAa,oBAA4B;CACvC,MAAM,4CAA2B;CACjC,MAAM,EAAE,wCAAqB;CAC7B,MAAM,SAAS,IAAI;CAEnB,IAAI,aAAa,QAAQ,OAAO;CAChC,IAAI,SAAS,WAAW,GAAG,OAAO,EAAE,GAAG,OAAO,SAAS,MAAM,OAAO,MAAM;CAC1E,OAAO;AACT;;;;;;AAOA,MAAa,kBAAkB;CAC7B,MAAM,wCAAuB;CAC7B,MAAM,EAAE,QAAQ,+CAA4B;CAE5C,MAAM,YAAY,MAAoB,WACpCA,6CAAa,MAAM,UAAW,aAAwB;CAExD,OAAO;EACL,GAAG;EACH,OAAO,MAAoB,YACzB,OAAO,KACL,SAAS,MAAM,SAAS,MAAM,GAC9B,OACF;EACF,UAAU,MAAoB,YAC5B,OAAO,QACL,SAAS,MAAM,SAAS,MAAM,GAC9B,OACF;EACF,WAAW,MAAoB,YAC7B,OAAO,SAAS,SAAS,MAAM,SAAS,MAAM,CAAC;CACnD;AACF"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  let _intlayer_core_localization = require("@intlayer/core/localization");
4
3
 
5
4
  //#region src/navigation/localizeHref.ts
@@ -1 +1 @@
1
- {"version":3,"file":"localizeHref.cjs","names":[],"sources":["../../../src/navigation/localizeHref.ts"],"sourcesContent":["import { getLocalizedUrl } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * A `next-intl` navigation href: either a pathname string or an object with a\n * `pathname` and optional `query`. The `pathnames` (typed routes) feature is\n * accepted for API compatibility but not interpolated.\n */\nexport type NextIntlHref =\n | string\n | {\n pathname: string;\n query?: Record<string, string | number | (string | number)[]>;\n params?: Record<string, string | number | (string | number)[]>;\n };\n\n/**\n * Prefix a `next-intl` href with the given locale using Intlayer's\n * `getLocalizedUrl`, preserving any query parameters.\n *\n * @param href - The target href (string or `{ pathname, query }`).\n * @param locale - The locale to localize the href for.\n * @returns The localized URL string.\n */\nexport const localizeHref = (href: NextIntlHref, locale: string): string => {\n const pathname = typeof href === 'string' ? href : href.pathname;\n const localizedPathname = getLocalizedUrl(pathname, locale as LocalesValues);\n\n if (typeof href === 'string' || !href.query) {\n return localizedPathname;\n }\n\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(href.query)) {\n if (Array.isArray(value)) {\n for (const entry of value) {\n searchParams.append(key, String(entry));\n }\n } else {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString\n ? `${localizedPathname}?${queryString}`\n : localizedPathname;\n};\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAa,gBAAgB,MAAoB,WAA2B;CAE1E,MAAM,qEADW,OAAO,SAAS,WAAW,OAAO,KAAK,UACJ,OAAwB;AAE5E,KAAI,OAAO,SAAS,YAAY,CAAC,KAAK,MACpC,QAAO;CAGT,MAAM,eAAe,IAAI,iBAAiB;AAC1C,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,MAAM,CACnD,KAAI,MAAM,QAAQ,MAAM,CACtB,MAAK,MAAM,SAAS,MAClB,cAAa,OAAO,KAAK,OAAO,MAAM,CAAC;KAGzC,cAAa,OAAO,KAAK,OAAO,MAAM,CAAC;CAI3C,MAAM,cAAc,aAAa,UAAU;AAC3C,QAAO,cACH,GAAG,kBAAkB,GAAG,gBACxB"}
1
+ {"version":3,"file":"localizeHref.cjs","names":[],"sources":["../../../src/navigation/localizeHref.ts"],"sourcesContent":["import { getLocalizedUrl } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * A `next-intl` navigation href: either a pathname string or an object with a\n * `pathname` and optional `query`. The `pathnames` (typed routes) feature is\n * accepted for API compatibility but not interpolated.\n */\nexport type NextIntlHref =\n | string\n | {\n pathname: string;\n query?: Record<string, string | number | (string | number)[]>;\n params?: Record<string, string | number | (string | number)[]>;\n };\n\n/**\n * Prefix a `next-intl` href with the given locale using Intlayer's\n * `getLocalizedUrl`, preserving any query parameters.\n *\n * @param href - The target href (string or `{ pathname, query }`).\n * @param locale - The locale to localize the href for.\n * @returns The localized URL string.\n */\nexport const localizeHref = (href: NextIntlHref, locale: string): string => {\n const pathname = typeof href === 'string' ? href : href.pathname;\n const localizedPathname = getLocalizedUrl(pathname, locale as LocalesValues);\n\n if (typeof href === 'string' || !href.query) {\n return localizedPathname;\n }\n\n const searchParams = new URLSearchParams();\n for (const [key, value] of Object.entries(href.query)) {\n if (Array.isArray(value)) {\n for (const entry of value) {\n searchParams.append(key, String(entry));\n }\n } else {\n searchParams.append(key, String(value));\n }\n }\n\n const queryString = searchParams.toString();\n return queryString\n ? `${localizedPathname}?${queryString}`\n : localizedPathname;\n};\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAa,gBAAgB,MAAoB,WAA2B;CAE1E,MAAM,qEADW,OAAO,SAAS,WAAW,OAAO,KAAK,UACJ,MAAuB;CAE3E,IAAI,OAAO,SAAS,YAAY,CAAC,KAAK,OACpC,OAAO;CAGT,MAAM,eAAe,IAAI,gBAAgB;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,KAAK,GAClD,IAAI,MAAM,QAAQ,KAAK,GACrB,KAAK,MAAM,SAAS,OAClB,aAAa,OAAO,KAAK,OAAO,KAAK,CAAC;MAGxC,aAAa,OAAO,KAAK,OAAO,KAAK,CAAC;CAI1C,MAAM,cAAc,aAAa,SAAS;CAC1C,OAAO,cACH,GAAG,kBAAkB,GAAG,gBACxB;AACN"}
@@ -6,8 +6,9 @@ _intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
6
6
  let _intlayer_config_logger = require("@intlayer/config/logger");
7
7
  let node_module = require("node:module");
8
8
  let node_path = require("node:path");
9
- let _intlayer_chokidar_utils = require("@intlayer/chokidar/utils");
9
+ let _intlayer_config_callers = require("@intlayer/config/callers");
10
10
  let _intlayer_config_node = require("@intlayer/config/node");
11
+ let _intlayer_engine_utils = require("@intlayer/engine/utils");
11
12
 
12
13
  //#region src/plugin/index.ts
13
14
  /**
@@ -89,19 +90,12 @@ const resolveEsmPath = (specifier) => {
89
90
  * @returns Relative specifier such as `./node_modules/@intlayer/next-intl/...`.
90
91
  */
91
92
  const toTurbopackAlias = (absolutePath) => `./${(0, node_path.relative)(process.cwd(), absolutePath).split(node_path.sep).join("/")}`;
92
- const NEXT_INTL_SWC_CALLERS = [{
93
- callerName: "useTranslations",
94
- importSources: ["next-intl", "@intlayer/next-intl"],
95
- namespaceArgIndex: 0,
96
- staticReplacement: "useDictionary",
97
- dynamicReplacement: "useDictionaryDynamic"
98
- }, {
99
- callerName: "getTranslations",
100
- importSources: ["next-intl/server", "@intlayer/next-intl/server"],
101
- namespaceArgIndex: 0,
102
- staticReplacement: "getDictionary",
103
- dynamicReplacement: "getDictionaryDynamic"
104
- }];
93
+ /**
94
+ * SWC extra-caller configs derived from the shared caller registry
95
+ * (`@intlayer/config/callers`) — the single source of truth also consumed by
96
+ * the babel analyzer/optimizer and the LSP.
97
+ */
98
+ const NEXT_INTL_SWC_CALLERS = (0, _intlayer_config_callers.toSwcExtraCallers)(_intlayer_config_callers.NEXT_INTL_CALLERS);
105
99
  /**
106
100
  * A Next.js plugin for next-intl compat that wraps next-intlayer's plugin
107
101
  * and configures resolve aliases so `next-intl` imports are served by
@@ -111,7 +105,7 @@ const createNextIntlPlugin = (_i18nPath) => {
111
105
  return async (nextConfig = {}) => {
112
106
  const intlayerConfig = (0, _intlayer_config_node.getConfiguration)();
113
107
  const appLogger = (0, _intlayer_config_logger.getAppLogger)(intlayerConfig);
114
- (0, _intlayer_chokidar_utils.runOnce)((0, node_path.join)(intlayerConfig?.system?.baseDir ?? process.cwd(), ".intlayer", "cache", "intlayer-issues-invitation.lock"), () => {
108
+ (0, _intlayer_engine_utils.runOnce)((0, node_path.join)(intlayerConfig?.system?.baseDir ?? process.cwd(), ".intlayer", "cache", "intlayer-issues-invitation.lock"), () => {
115
109
  appLogger([(0, _intlayer_config_logger.colorize)("Please report any issues you met on GitHub:", _intlayer_config_colors.GREY), (0, _intlayer_config_logger.colorize)("https://github.com/aymericzip/intlayer/issues", _intlayer_config_colors.GREY_LIGHT)]);
116
110
  }, { cacheTimeoutMs: 1e3 * 60 * 60 });
117
111
  const customWebpack = nextConfig.webpack;