intor 2.5.0 → 2.6.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.
Files changed (322) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/core/export/index.js +1 -0
  4. package/dist/core/src/client/shared/helpers/get-client-locale.js +5 -20
  5. package/dist/core/src/client/shared/utils/locale/detect-browser-locale.js +2 -8
  6. package/dist/core/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  7. package/dist/core/src/config/constants/cookie.js +9 -9
  8. package/dist/core/src/config/constants/routing.js +13 -14
  9. package/dist/core/src/config/define-intor-config.js +28 -44
  10. package/dist/core/src/config/resolvers/resolve-cookie-options.js +4 -4
  11. package/dist/core/src/config/resolvers/resolve-fallback-locales.js +33 -50
  12. package/dist/core/src/config/resolvers/resolve-routing-options.js +32 -61
  13. package/dist/core/src/config/validators/validate-default-locale.js +8 -13
  14. package/dist/core/src/config/validators/validate-id.js +8 -13
  15. package/dist/core/src/config/validators/validate-supported-locales.js +8 -13
  16. package/dist/core/src/core/constants/locale-placeholder.js +0 -1
  17. package/dist/core/src/core/error/intor-error.js +14 -29
  18. package/dist/core/src/core/locale/canonicalize-locale.js +7 -18
  19. package/dist/core/src/core/locale/match-locale.js +24 -50
  20. package/dist/core/src/core/locale/parse-locale.js +12 -22
  21. package/dist/core/src/core/logger/get-logger.js +26 -31
  22. package/dist/core/src/core/logger/global-logger-pool.js +4 -4
  23. package/dist/core/src/core/messages/internal-metadata.js +1 -1
  24. package/dist/core/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  25. package/dist/core/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  26. package/dist/core/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  27. package/dist/core/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  28. package/dist/core/src/core/messages/merge-messages.js +17 -28
  29. package/dist/core/src/core/messages/utils/is-valid-messages.js +22 -37
  30. package/dist/core/src/core/messages/utils/nest-object-from-path.js +5 -17
  31. package/dist/core/src/core/render/create-html-renderer.js +29 -37
  32. package/dist/core/src/core/render/utils/escape-html.js +1 -6
  33. package/dist/core/src/core/render/utils/render-attributes.js +6 -11
  34. package/dist/core/src/core/translator/create-t-rich.js +6 -15
  35. package/dist/core/src/core/translator/create-translator.js +16 -24
  36. package/dist/core/src/core/utils/deep-merge.js +24 -42
  37. package/dist/core/src/core/utils/normalizers/normalize-cache-key.js +14 -40
  38. package/dist/core/src/core/utils/normalizers/normalize-pathname.js +19 -37
  39. package/dist/core/src/core/utils/normalizers/normalize-query.js +6 -20
  40. package/dist/core/src/core/utils/parse-cookie-header.js +11 -18
  41. package/dist/core/src/core/utils/resolve-loader-options.js +6 -32
  42. package/dist/core/src/edge/helpers/get-translator.js +14 -20
  43. package/dist/core/src/edge/translator/init-translator.js +23 -31
  44. package/dist/core/src/routing/inbound/helpers/resolve-inbound-from-request.js +21 -28
  45. package/dist/core/src/routing/inbound/resolve-inbound.js +22 -37
  46. package/dist/core/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  47. package/dist/core/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  48. package/dist/core/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  49. package/dist/core/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  50. package/dist/core/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  51. package/dist/core/src/routing/locale/get-locale-from-accept-language.js +21 -36
  52. package/dist/core/src/routing/locale/get-locale-from-host.js +5 -28
  53. package/dist/core/src/routing/locale/get-locale-from-pathname.js +11 -37
  54. package/dist/core/src/routing/locale/get-locale-from-query.js +2 -17
  55. package/dist/core/src/routing/pathname/canonicalize-pathname.js +25 -67
  56. package/dist/core/src/routing/pathname/localize-pathname.js +12 -30
  57. package/dist/core/src/routing/pathname/materialize-pathname.js +9 -44
  58. package/dist/core/src/routing/pathname/standardize-pathname.js +6 -30
  59. package/dist/core/src/server/helpers/get-translator.js +26 -23
  60. package/dist/core/src/server/intor/intor.js +20 -25
  61. package/dist/core/src/server/messages/load-local-messages/cache/messages-pool.js +4 -7
  62. package/dist/core/src/server/messages/load-local-messages/load-local-messages.js +76 -92
  63. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/collect-file-entries/collect-file-entries.js +59 -80
  64. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/parse-file-entries.js +53 -87
  65. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/utils/json-reader.js +3 -6
  66. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/read-locale-messages.js +23 -35
  67. package/dist/core/src/server/messages/load-messages.js +56 -69
  68. package/dist/core/src/server/translator/init-translator.js +28 -30
  69. package/dist/express/src/adapters/express/create-intor-handler.js +35 -46
  70. package/dist/express/src/adapters/express/get-translator.js +2 -9
  71. package/dist/express/src/core/constants/locale-placeholder.js +0 -1
  72. package/dist/express/src/core/locale/canonicalize-locale.js +7 -18
  73. package/dist/express/src/core/locale/match-locale.js +24 -50
  74. package/dist/express/src/core/locale/parse-locale.js +12 -22
  75. package/dist/express/src/core/utils/normalizers/normalize-pathname.js +19 -37
  76. package/dist/express/src/core/utils/normalizers/normalize-query.js +6 -20
  77. package/dist/express/src/core/utils/parse-cookie-header.js +11 -18
  78. package/dist/express/src/routing/inbound/resolve-inbound.js +22 -37
  79. package/dist/express/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  80. package/dist/express/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  81. package/dist/express/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  82. package/dist/express/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  83. package/dist/express/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  84. package/dist/express/src/routing/locale/get-locale-from-accept-language.js +21 -36
  85. package/dist/express/src/routing/locale/get-locale-from-host.js +5 -28
  86. package/dist/express/src/routing/locale/get-locale-from-pathname.js +11 -37
  87. package/dist/express/src/routing/locale/get-locale-from-query.js +2 -17
  88. package/dist/express/src/routing/pathname/canonicalize-pathname.js +25 -67
  89. package/dist/express/src/routing/pathname/localize-pathname.js +12 -30
  90. package/dist/express/src/routing/pathname/materialize-pathname.js +9 -44
  91. package/dist/express/src/routing/pathname/standardize-pathname.js +6 -30
  92. package/dist/fastify/src/adapters/fastify/create-intor-handler.js +35 -47
  93. package/dist/fastify/src/adapters/fastify/get-translator.js +2 -9
  94. package/dist/fastify/src/adapters/fastify/intor-fastify-plugin.js +29 -38
  95. package/dist/fastify/src/core/constants/locale-placeholder.js +0 -1
  96. package/dist/fastify/src/core/locale/canonicalize-locale.js +7 -18
  97. package/dist/fastify/src/core/locale/match-locale.js +24 -50
  98. package/dist/fastify/src/core/locale/parse-locale.js +12 -22
  99. package/dist/fastify/src/core/utils/normalizers/normalize-pathname.js +19 -37
  100. package/dist/fastify/src/core/utils/normalizers/normalize-query.js +6 -20
  101. package/dist/fastify/src/core/utils/parse-cookie-header.js +11 -18
  102. package/dist/fastify/src/routing/inbound/resolve-inbound.js +22 -37
  103. package/dist/fastify/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  104. package/dist/fastify/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  105. package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  106. package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  107. package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  108. package/dist/fastify/src/routing/locale/get-locale-from-accept-language.js +21 -36
  109. package/dist/fastify/src/routing/locale/get-locale-from-host.js +5 -28
  110. package/dist/fastify/src/routing/locale/get-locale-from-pathname.js +11 -37
  111. package/dist/fastify/src/routing/locale/get-locale-from-query.js +2 -17
  112. package/dist/fastify/src/routing/pathname/canonicalize-pathname.js +25 -67
  113. package/dist/fastify/src/routing/pathname/localize-pathname.js +12 -30
  114. package/dist/fastify/src/routing/pathname/materialize-pathname.js +9 -44
  115. package/dist/fastify/src/routing/pathname/standardize-pathname.js +6 -30
  116. package/dist/hono/src/adapters/hono/create-intor-handler.js +33 -44
  117. package/dist/hono/src/adapters/hono/get-translator.js +2 -9
  118. package/dist/hono/src/core/constants/locale-placeholder.js +0 -1
  119. package/dist/hono/src/core/locale/canonicalize-locale.js +7 -18
  120. package/dist/hono/src/core/locale/match-locale.js +24 -50
  121. package/dist/hono/src/core/locale/parse-locale.js +12 -22
  122. package/dist/hono/src/core/utils/normalizers/normalize-pathname.js +19 -37
  123. package/dist/hono/src/core/utils/normalizers/normalize-query.js +6 -20
  124. package/dist/hono/src/core/utils/parse-cookie-header.js +11 -18
  125. package/dist/hono/src/routing/inbound/resolve-inbound.js +22 -37
  126. package/dist/hono/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  127. package/dist/hono/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  128. package/dist/hono/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  129. package/dist/hono/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  130. package/dist/hono/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  131. package/dist/hono/src/routing/locale/get-locale-from-accept-language.js +21 -36
  132. package/dist/hono/src/routing/locale/get-locale-from-host.js +5 -28
  133. package/dist/hono/src/routing/locale/get-locale-from-pathname.js +11 -37
  134. package/dist/hono/src/routing/locale/get-locale-from-query.js +2 -17
  135. package/dist/hono/src/routing/pathname/canonicalize-pathname.js +25 -67
  136. package/dist/hono/src/routing/pathname/localize-pathname.js +12 -30
  137. package/dist/hono/src/routing/pathname/materialize-pathname.js +9 -44
  138. package/dist/hono/src/routing/pathname/standardize-pathname.js +6 -30
  139. package/dist/next/export/next/server/index.js +1 -0
  140. package/dist/next/src/adapters/next/create-intor-handler.js +39 -48
  141. package/dist/next/src/adapters/next/header-keys.js +9 -0
  142. package/dist/next/src/adapters/next/link.js +33 -28
  143. package/dist/next/src/adapters/next/redirect.js +12 -15
  144. package/dist/next/src/adapters/next/server/get-locale.js +13 -24
  145. package/dist/next/src/adapters/next/server/get-translator.js +2 -9
  146. package/dist/next/src/adapters/next/server/intor.js +5 -13
  147. package/dist/next/src/adapters/next/server/read-intor-url-state.js +13 -0
  148. package/dist/next/src/adapters/next/use-router.js +47 -66
  149. package/dist/next/src/client/shared/navigation/execute-navigation.js +20 -38
  150. package/dist/next/src/client/shared/utils/build-cookie-string.js +18 -27
  151. package/dist/next/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  152. package/dist/next/src/core/constants/locale-placeholder.js +0 -1
  153. package/dist/next/src/core/locale/canonicalize-locale.js +7 -18
  154. package/dist/next/src/core/locale/match-locale.js +24 -50
  155. package/dist/next/src/core/locale/parse-locale.js +12 -22
  156. package/dist/next/src/core/utils/normalizers/normalize-pathname.js +19 -37
  157. package/dist/next/src/core/utils/normalizers/normalize-query.js +6 -20
  158. package/dist/next/src/core/utils/resolve-loader-options.js +6 -29
  159. package/dist/next/src/policies/shoud-full-reload.js +2 -5
  160. package/dist/next/src/policies/should-sync-locale.js +1 -4
  161. package/dist/next/src/routing/inbound/resolve-inbound.js +24 -39
  162. package/dist/next/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  163. package/dist/next/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  164. package/dist/next/src/routing/inbound/resolve-pathname/strategies/all.js +13 -29
  165. package/dist/next/src/routing/inbound/resolve-pathname/strategies/except-default.js +14 -30
  166. package/dist/next/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  167. package/dist/next/src/routing/locale/get-locale-from-accept-language.js +21 -36
  168. package/dist/next/src/routing/locale/get-locale-from-host.js +5 -28
  169. package/dist/next/src/routing/locale/get-locale-from-pathname.js +11 -37
  170. package/dist/next/src/routing/locale/get-locale-from-query.js +2 -17
  171. package/dist/next/src/routing/outbound/decide-strategy.js +9 -9
  172. package/dist/next/src/routing/outbound/determine-target.js +28 -44
  173. package/dist/next/src/routing/outbound/resolve-outbound.js +12 -16
  174. package/dist/next/src/routing/outbound/utils/derive-host-destination.js +5 -9
  175. package/dist/next/src/routing/outbound/utils/derive-query-destination.js +4 -7
  176. package/dist/next/src/routing/outbound/utils/is-external-destination.js +1 -7
  177. package/dist/next/src/routing/pathname/canonicalize-pathname.js +25 -67
  178. package/dist/next/src/routing/pathname/localize-pathname.js +12 -30
  179. package/dist/next/src/routing/pathname/materialize-pathname.js +9 -44
  180. package/dist/next/src/routing/pathname/standardize-pathname.js +6 -30
  181. package/dist/react/src/client/react/helpers/use-intor.js +25 -44
  182. package/dist/react/src/client/react/provider/effects/use-locale-effects.js +20 -25
  183. package/dist/react/src/client/react/provider/effects/use-messages-effects.js +17 -16
  184. package/dist/react/src/client/react/provider/intor-provider.js +63 -66
  185. package/dist/react/src/client/react/provider/use-intor-context.js +4 -4
  186. package/dist/react/src/client/react/render/create-react-renderer.js +18 -24
  187. package/dist/react/src/client/react/translator/create-t-rich.js +9 -22
  188. package/dist/react/src/client/react/translator/use-translator.js +11 -16
  189. package/dist/react/src/client/shared/messages/create-refetch-messages.js +41 -51
  190. package/dist/react/src/client/shared/provider/effective-state.js +2 -6
  191. package/dist/react/src/client/shared/utils/build-cookie-string.js +18 -27
  192. package/dist/react/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  193. package/dist/react/src/client/shared/utils/locale/set-document-locale.js +2 -8
  194. package/dist/react/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  195. package/dist/react/src/core/logger/get-logger.js +26 -31
  196. package/dist/react/src/core/logger/global-logger-pool.js +4 -4
  197. package/dist/react/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  198. package/dist/react/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  199. package/dist/react/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  200. package/dist/react/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  201. package/dist/react/src/core/messages/merge-messages.js +17 -28
  202. package/dist/react/src/core/messages/utils/is-valid-messages.js +22 -37
  203. package/dist/react/src/core/messages/utils/nest-object-from-path.js +5 -17
  204. package/dist/react/src/core/utils/deep-merge.js +24 -42
  205. package/dist/react/src/core/utils/resolve-loader-options.js +6 -29
  206. package/dist/react/src/policies/should-persist-on-first-visit.js +1 -4
  207. package/dist/svelte/export/svelte/index.js +0 -6
  208. package/dist/svelte/src/client/shared/messages/create-refetch-messages.js +41 -51
  209. package/dist/svelte/src/client/shared/provider/effective-state.js +2 -6
  210. package/dist/svelte/src/client/shared/utils/build-cookie-string.js +18 -27
  211. package/dist/svelte/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  212. package/dist/svelte/src/client/shared/utils/locale/set-document-locale.js +2 -8
  213. package/dist/svelte/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  214. package/dist/svelte/src/client/svelte/provider/create-intor-store.js +59 -63
  215. package/dist/svelte/src/client/svelte/provider/effects/attach-locale-effects.js +20 -25
  216. package/dist/svelte/src/client/svelte/provider/effects/attach-messages-effects.js +21 -18
  217. package/dist/svelte/src/client/svelte/provider/get-intor-context.js +4 -4
  218. package/dist/svelte/src/client/svelte/translator/use-translator.js +11 -16
  219. package/dist/svelte/src/core/logger/get-logger.js +26 -31
  220. package/dist/svelte/src/core/logger/global-logger-pool.js +4 -4
  221. package/dist/svelte/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  222. package/dist/svelte/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  223. package/dist/svelte/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  224. package/dist/svelte/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  225. package/dist/svelte/src/core/messages/merge-messages.js +17 -28
  226. package/dist/svelte/src/core/messages/utils/is-valid-messages.js +22 -37
  227. package/dist/svelte/src/core/messages/utils/nest-object-from-path.js +5 -17
  228. package/dist/svelte/src/core/render/create-html-renderer.js +29 -37
  229. package/dist/svelte/src/core/render/utils/escape-html.js +1 -6
  230. package/dist/svelte/src/core/render/utils/render-attributes.js +6 -11
  231. package/dist/svelte/src/core/translator/create-t-rich.js +6 -15
  232. package/dist/svelte/src/core/utils/deep-merge.js +24 -42
  233. package/dist/svelte/src/core/utils/resolve-loader-options.js +6 -29
  234. package/dist/svelte/src/policies/should-persist-on-first-visit.js +1 -4
  235. package/dist/svelte-kit/src/adapters/svelte-kit/create-intor-handler.js +37 -57
  236. package/dist/svelte-kit/src/adapters/svelte-kit/use-navigation.js +29 -27
  237. package/dist/svelte-kit/src/adapters/svelte-kit/utils/is-svelte-kit-ssg.js +4 -11
  238. package/dist/svelte-kit/src/client/shared/navigation/execute-navigation.js +19 -37
  239. package/dist/svelte-kit/src/client/shared/utils/build-cookie-string.js +18 -27
  240. package/dist/svelte-kit/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  241. package/dist/svelte-kit/src/core/constants/locale-placeholder.js +0 -1
  242. package/dist/svelte-kit/src/core/locale/canonicalize-locale.js +7 -18
  243. package/dist/svelte-kit/src/core/locale/match-locale.js +24 -50
  244. package/dist/svelte-kit/src/core/locale/parse-locale.js +12 -22
  245. package/dist/svelte-kit/src/core/utils/normalizers/normalize-pathname.js +19 -37
  246. package/dist/svelte-kit/src/core/utils/normalizers/normalize-query.js +6 -20
  247. package/dist/svelte-kit/src/core/utils/resolve-loader-options.js +6 -29
  248. package/dist/svelte-kit/src/policies/shoud-full-reload.js +2 -5
  249. package/dist/svelte-kit/src/policies/should-sync-locale.js +1 -4
  250. package/dist/svelte-kit/src/routing/inbound/resolve-inbound.js +22 -37
  251. package/dist/svelte-kit/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  252. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  253. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  254. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  255. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  256. package/dist/svelte-kit/src/routing/locale/get-locale-from-accept-language.js +21 -36
  257. package/dist/svelte-kit/src/routing/locale/get-locale-from-host.js +5 -28
  258. package/dist/svelte-kit/src/routing/locale/get-locale-from-pathname.js +11 -37
  259. package/dist/svelte-kit/src/routing/locale/get-locale-from-query.js +2 -17
  260. package/dist/svelte-kit/src/routing/outbound/decide-strategy.js +9 -9
  261. package/dist/svelte-kit/src/routing/outbound/determine-target.js +28 -44
  262. package/dist/svelte-kit/src/routing/outbound/resolve-outbound.js +12 -16
  263. package/dist/svelte-kit/src/routing/outbound/utils/derive-host-destination.js +5 -9
  264. package/dist/svelte-kit/src/routing/outbound/utils/derive-query-destination.js +4 -7
  265. package/dist/svelte-kit/src/routing/outbound/utils/is-external-destination.js +1 -7
  266. package/dist/svelte-kit/src/routing/pathname/canonicalize-pathname.js +25 -67
  267. package/dist/svelte-kit/src/routing/pathname/localize-pathname.js +12 -30
  268. package/dist/svelte-kit/src/routing/pathname/materialize-pathname.js +9 -44
  269. package/dist/svelte-kit/src/routing/pathname/standardize-pathname.js +6 -30
  270. package/dist/types/export/index.d.ts +1 -1
  271. package/dist/types/export/index.d.ts.map +1 -1
  272. package/dist/types/export/next/server/index.d.ts +1 -1
  273. package/dist/types/export/next/server/index.d.ts.map +1 -1
  274. package/dist/types/src/adapters/fastify/intor-fastify-plugin.d.ts.map +1 -1
  275. package/dist/types/src/adapters/next/create-intor-handler.d.ts.map +1 -1
  276. package/dist/types/src/{core/constants/headers.d.ts → adapters/next/header-keys.d.ts} +3 -2
  277. package/dist/types/src/adapters/next/header-keys.d.ts.map +1 -0
  278. package/dist/types/src/adapters/next/server/get-locale.d.ts.map +1 -1
  279. package/dist/types/src/adapters/next/server/index.d.ts +1 -0
  280. package/dist/types/src/adapters/next/server/index.d.ts.map +1 -1
  281. package/dist/types/src/adapters/next/server/read-intor-url-state.d.ts +13 -0
  282. package/dist/types/src/adapters/next/server/read-intor-url-state.d.ts.map +1 -0
  283. package/dist/types/src/core/constants/index.d.ts +0 -1
  284. package/dist/types/src/core/constants/index.d.ts.map +1 -1
  285. package/dist/types/src/core/constants/locale-placeholder.d.ts +5 -0
  286. package/dist/types/src/core/constants/locale-placeholder.d.ts.map +1 -1
  287. package/dist/types/src/core/index.d.ts +1 -1
  288. package/dist/types/src/core/index.d.ts.map +1 -1
  289. package/dist/types/src/edge/translator/init-translator.d.ts.map +1 -1
  290. package/dist/types/src/routing/outbound/decide-strategy.d.ts +1 -1
  291. package/dist/types/src/routing/outbound/decide-strategy.d.ts.map +1 -1
  292. package/dist/types/src/server/translator/init-translator.d.ts.map +1 -1
  293. package/dist/vue/src/client/shared/messages/create-refetch-messages.js +41 -51
  294. package/dist/vue/src/client/shared/provider/effective-state.js +2 -6
  295. package/dist/vue/src/client/shared/utils/build-cookie-string.js +18 -27
  296. package/dist/vue/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  297. package/dist/vue/src/client/shared/utils/locale/set-document-locale.js +2 -8
  298. package/dist/vue/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  299. package/dist/vue/src/client/vue/helpers/use-intor.js +20 -42
  300. package/dist/vue/src/client/vue/provider/effects/use-locale-effects.js +23 -24
  301. package/dist/vue/src/client/vue/provider/effects/use-messages-effects.js +15 -24
  302. package/dist/vue/src/client/vue/provider/inject-intor-context.js +4 -4
  303. package/dist/vue/src/client/vue/provider/intor-provider.js +61 -66
  304. package/dist/vue/src/client/vue/render/create-vue-renderer.js +18 -24
  305. package/dist/vue/src/client/vue/translator/create-t-rich.js +5 -17
  306. package/dist/vue/src/client/vue/translator/trans.js +24 -31
  307. package/dist/vue/src/client/vue/translator/use-translator.js +12 -17
  308. package/dist/vue/src/core/logger/get-logger.js +26 -31
  309. package/dist/vue/src/core/logger/global-logger-pool.js +4 -4
  310. package/dist/vue/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  311. package/dist/vue/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  312. package/dist/vue/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  313. package/dist/vue/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  314. package/dist/vue/src/core/messages/merge-messages.js +17 -28
  315. package/dist/vue/src/core/messages/utils/is-valid-messages.js +22 -37
  316. package/dist/vue/src/core/messages/utils/nest-object-from-path.js +5 -17
  317. package/dist/vue/src/core/utils/deep-merge.js +24 -42
  318. package/dist/vue/src/core/utils/resolve-loader-options.js +6 -29
  319. package/dist/vue/src/policies/should-persist-on-first-visit.js +1 -4
  320. package/package.json +53 -65
  321. package/dist/next/src/core/constants/headers.js +0 -8
  322. package/dist/types/src/core/constants/headers.d.ts.map +0 -1
@@ -2,37 +2,19 @@ import { canonicalizePathname } from './canonicalize-pathname.js';
2
2
  import { materializePathname } from './materialize-pathname.js';
3
3
  import { standardizePathname } from './standardize-pathname.js';
4
4
 
5
- /**
6
- * Localizes a pathname by composing canonicalization,
7
- * standardization, and locale prefix strategies.
8
- *
9
- * @example
10
- * ```ts
11
- * // config.supportedLocales: ["en-US"]
12
- * // config.routing.basePath: "/app"
13
- * // config.routing.prefix: "all"
14
- * localizePathname("/app/en-US/about", config, "en-US");
15
- * // => {
16
- * // pathname: '/app/en-US/about'
17
- * // canonicalPathname: '/about',
18
- * // templatedPathname: '/app/{locale}/about',
19
- * // }
20
- * ```
21
- *
22
- * @public
23
- */
24
5
  const localizePathname = (rawPathname, config, locale) => {
25
- // 1. Canonicalize: normalize and remove routing-specific prefixes
26
- const canonicalPathname = canonicalizePathname(rawPathname, config);
27
- // 2. Standardize: convert to internal pathname shape with locale placeholder
28
- const standardizedPathname = standardizePathname(canonicalPathname, config);
29
- // 3. Materialize: apply routing rules to produce the final pathname
30
- const materializedPathname = materializePathname(standardizedPathname, config, locale);
31
- return {
32
- canonicalPathname,
33
- templatedPathname: standardizedPathname,
34
- pathname: materializedPathname,
35
- };
6
+ const canonicalPathname = canonicalizePathname(rawPathname, config);
7
+ const standardizedPathname = standardizePathname(canonicalPathname, config);
8
+ const materializedPathname = materializePathname(
9
+ standardizedPathname,
10
+ config,
11
+ locale
12
+ );
13
+ return {
14
+ canonicalPathname,
15
+ templatedPathname: standardizedPathname,
16
+ pathname: materializedPathname
17
+ };
36
18
  };
37
19
 
38
20
  export { localizePathname };
@@ -3,51 +3,16 @@ import 'logry';
3
3
  import 'p-limit';
4
4
  import 'intor-translator';
5
5
 
6
- /**
7
- * Materializes a standardized pathname into a concrete, locale-aware URL.
8
- *
9
- * This function resolves the `{locale}` placeholder according to the
10
- * configured `localePrefix` strategy and produces the final pathname.
11
- *
12
- * Behavior:
13
- * - "all": always injects the locale segment
14
- * - "except-default": injects the locale unless it equals `defaultLocale`
15
- * - "none": removes the locale placeholder entirely
16
- *
17
- * Invariants:
18
- * - `standardizedPathname` must be produced by `standardizePathname`
19
- * - The pathname must contain exactly one `{locale}` placeholder
20
- * - The placeholder must appear as the first path segment
21
- *
22
- * This function performs structural transformation only.
23
- * It does not normalize or sanitize the resulting pathname.
24
- *
25
- * @example
26
- * ```ts
27
- * // config.routing.localePrefix: "all"
28
- * materializePathname("/app/{locale}/about", config, "en");
29
- * // => /app/en/about
30
- *
31
- * // config.routing.localePrefix: "none"
32
- * materializePathname("/app/{locale}/about", config, "en");
33
- * // => /app/about
34
- * ```
35
- */
36
6
  const materializePathname = (standardizedPathname, config, locale) => {
37
- const { localePrefix } = config.routing;
38
- const removeLocale = () => {
39
- const result = standardizedPathname.replace(`/${LOCALE_PLACEHOLDER}`, "");
40
- return result === "" ? "/" : result;
41
- };
42
- const injectLocale = () => standardizedPathname.replace(LOCALE_PLACEHOLDER, locale);
43
- // localePrefix: "none"
44
- if (localePrefix === "none")
45
- return removeLocale();
46
- // localePrefix: "all"
47
- if (localePrefix === "all")
48
- return injectLocale();
49
- // localePrefix: "except-default"
50
- return locale === config.defaultLocale ? removeLocale() : injectLocale();
7
+ const { localePrefix } = config.routing;
8
+ const removeLocale = () => {
9
+ const result = standardizedPathname.replace(`/${LOCALE_PLACEHOLDER}`, "");
10
+ return result === "" ? "/" : result;
11
+ };
12
+ const injectLocale = () => standardizedPathname.replace(LOCALE_PLACEHOLDER, locale);
13
+ if (localePrefix === "none") return removeLocale();
14
+ if (localePrefix === "all") return injectLocale();
15
+ return locale === config.defaultLocale ? removeLocale() : injectLocale();
51
16
  };
52
17
 
53
18
  export { materializePathname };
@@ -3,37 +3,13 @@ import 'logry';
3
3
  import 'p-limit';
4
4
  import 'intor-translator';
5
5
 
6
- /**
7
- * Standardizes a canonical pathname into an internal routing template.
8
- *
9
- * Standardized representation:
10
- * - Prepends the deployment prefix (`basePath`) if defined
11
- * - Injects the `{locale}` placeholder as the first path segment
12
- * - Preserves the canonical pathname structure
13
- *
14
- * Input must be a canonical pathname.
15
- *
16
- * Output is an internal routing template and
17
- * is not a locale-resolved URL.
18
- *
19
- * @example
20
- * ```ts
21
- * // config.routing.basePath: "/app",
22
- * standardizePathname("/about", config);
23
- * // => "/app/{locale}/about"
24
- * ```
25
- */
26
6
  const standardizePathname = (canonicalPathname, config) => {
27
- const { routing } = config;
28
- const basePath = routing.basePath && routing.basePath !== "/" ? routing.basePath : "";
29
- if (canonicalPathname === "/") {
30
- return basePath
31
- ? `${basePath}/${LOCALE_PLACEHOLDER}`
32
- : `/${LOCALE_PLACEHOLDER}`;
33
- }
34
- return basePath
35
- ? `${basePath}/${LOCALE_PLACEHOLDER}${canonicalPathname}`
36
- : `/${LOCALE_PLACEHOLDER}${canonicalPathname}`;
7
+ const { routing } = config;
8
+ const basePath = routing.basePath && routing.basePath !== "/" ? routing.basePath : "";
9
+ if (canonicalPathname === "/") {
10
+ return basePath ? `${basePath}/${LOCALE_PLACEHOLDER}` : `/${LOCALE_PLACEHOLDER}`;
11
+ }
12
+ return basePath ? `${basePath}/${LOCALE_PLACEHOLDER}${canonicalPathname}` : `/${LOCALE_PLACEHOLDER}${canonicalPathname}`;
37
13
  };
38
14
 
39
15
  export { standardizePathname };
@@ -1,3 +1,4 @@
1
1
  export { intor } from '../../../src/adapters/next/server/intor.js';
2
2
  export { getLocale } from '../../../src/adapters/next/server/get-locale.js';
3
3
  export { getTranslator } from '../../../src/adapters/next/server/get-translator.js';
4
+ export { readIntorUrlState } from '../../../src/adapters/next/server/read-intor-url-state.js';
@@ -1,60 +1,51 @@
1
1
  import { NextResponse } from 'next/server';
2
- import { INTOR_HEADERS } from '../../core/constants/headers.js';
3
2
  import { normalizeQuery } from '../../core/utils/normalizers/normalize-query.js';
4
3
  import 'logry';
5
4
  import 'p-limit';
6
5
  import 'intor-translator';
7
6
  import { resolveInbound } from '../../routing/inbound/resolve-inbound.js';
8
7
  import { getLocaleFromAcceptLanguage } from '../../routing/locale/get-locale-from-accept-language.js';
8
+ import { INTOR_HEADER_KEYS } from './header-keys.js';
9
9
 
10
- /**
11
- * Resolves locale-aware routing for the current execution context.
12
- *
13
- * The resolved routing state is exposed via response headers.
14
- *
15
- * - Acts as the canonical routing authority, guaranteeing a canonical routing result for every request.
16
- *
17
- * @public
18
- */
19
10
  function createIntorHandler(config) {
20
- return function intorHandler(request) {
21
- const { host, searchParams, pathname: rawPathname } = request.nextUrl;
22
- // Locale from Accept-Language header
23
- const acceptLanguageHeader = request.headers.get("accept-language");
24
- const localeFromAcceptLanguage = getLocaleFromAcceptLanguage(acceptLanguageHeader, config.supportedLocales);
25
- // Check whether this navigation flow has already redirected
26
- const hasRedirected = request.headers.get(INTOR_HEADERS.REDIRECTED) === "1";
27
- // ----------------------------------------------------------
28
- // Resolve inbound routing decision (pure computation)
29
- // ----------------------------------------------------------
30
- const cookie = request.cookies.get(config.cookie.name)?.value;
31
- const { locale, localeSource, pathname, shouldRedirect } = resolveInbound(config, rawPathname, {
32
- host,
33
- query: normalizeQuery(Object.fromEntries(searchParams.entries())),
34
- ...(cookie !== undefined ? { cookie } : {}),
35
- ...(localeFromAcceptLanguage !== undefined
36
- ? { detected: localeFromAcceptLanguage }
37
- : {}),
38
- }, { hasRedirected });
39
- // ----------------------------------------------------------
40
- // Prepare Next.js response (redirect or pass-through)
41
- // ----------------------------------------------------------
42
- const url = request.nextUrl.clone();
43
- url.pathname = pathname;
44
- const response = shouldRedirect
45
- ? NextResponse.redirect(url)
46
- : NextResponse.next();
47
- // ----------------------------------------------------------
48
- // Attach routing metadata to response headers
49
- // ----------------------------------------------------------
50
- response.headers.set(INTOR_HEADERS.LOCALE, locale);
51
- response.headers.set(INTOR_HEADERS.LOCALE_SOURCE, localeSource);
52
- response.headers.set(INTOR_HEADERS.PATHNAME, pathname);
53
- // Mark redirect to prevent infinite loops in this flow
54
- if (shouldRedirect)
55
- response.headers.set(INTOR_HEADERS.REDIRECTED, "1");
56
- return response;
57
- };
11
+ return function intorHandler(request) {
12
+ const {
13
+ host,
14
+ searchParams,
15
+ pathname: rawPathname,
16
+ search
17
+ } = request.nextUrl;
18
+ const acceptLanguageHeader = request.headers.get("accept-language");
19
+ const localeFromAcceptLanguage = getLocaleFromAcceptLanguage(
20
+ acceptLanguageHeader,
21
+ config.supportedLocales
22
+ );
23
+ const hasRedirected = request.headers.get(INTOR_HEADER_KEYS.REDIRECTED) === "1";
24
+ const cookie = request.cookies.get(config.cookie.name)?.value;
25
+ const { locale, localeSource, pathname, shouldRedirect } = resolveInbound(
26
+ config,
27
+ rawPathname,
28
+ {
29
+ host,
30
+ query: normalizeQuery(Object.fromEntries(searchParams.entries())),
31
+ ...cookie !== void 0 ? { cookie } : {},
32
+ ...localeFromAcceptLanguage !== void 0 ? { detected: localeFromAcceptLanguage } : {}
33
+ },
34
+ { hasRedirected }
35
+ );
36
+ const url = request.nextUrl.clone();
37
+ if (shouldRedirect) {
38
+ url.pathname = pathname;
39
+ url.search = search;
40
+ }
41
+ const response = shouldRedirect ? NextResponse.redirect(url) : NextResponse.next();
42
+ response.headers.set(INTOR_HEADER_KEYS.LOCALE, locale);
43
+ response.headers.set(INTOR_HEADER_KEYS.LOCALE_SOURCE, localeSource);
44
+ response.headers.set(INTOR_HEADER_KEYS.PATHNAME, pathname);
45
+ response.headers.set(INTOR_HEADER_KEYS.SEARCH, search);
46
+ if (shouldRedirect) response.headers.set(INTOR_HEADER_KEYS.REDIRECTED, "1");
47
+ return response;
48
+ };
58
49
  }
59
50
 
60
51
  export { createIntorHandler };
@@ -0,0 +1,9 @@
1
+ const INTOR_HEADER_KEYS = {
2
+ LOCALE: "x-intor-locale",
3
+ LOCALE_SOURCE: "x-intor-locale-source",
4
+ PATHNAME: "x-intor-pathname",
5
+ SEARCH: "x-intor-search",
6
+ REDIRECTED: "x-intor-redirected"
7
+ };
8
+
9
+ export { INTOR_HEADER_KEYS };
@@ -1,8 +1,7 @@
1
1
  "use client";
2
- import { jsx } from 'react/jsx-runtime';
3
2
  import NextLink from 'next/link';
4
3
  import { usePathname } from 'next/navigation';
5
- import 'react';
4
+ import * as React from 'react';
6
5
  import 'logry';
7
6
  import 'p-limit';
8
7
  import 'intor-translator';
@@ -10,32 +9,38 @@ import { executeNavigation } from '../../client/shared/navigation/execute-naviga
10
9
  import { useIntorContext } from 'intor/react/internal';
11
10
  import { resolveOutbound } from '../../routing/outbound/resolve-outbound.js';
12
11
 
13
- /**
14
- * Render a locale-aware link for the current execution context.
15
- *
16
- * - Resolves a locale-aware navigation destination.
17
- * - Determines whether navigation should be executed client-side or via full reload.
18
- *
19
- * @public
20
- */
21
- const Link = ({ href, locale, children, onClick, ...props }) => {
22
- const { config, locale: currentLocale, setLocale } = useIntorContext();
23
- const currentPathname = usePathname();
24
- // Resolve navigation result for this link
25
- const outboundResult = resolveOutbound(config, currentLocale, currentPathname, {
26
- ...(href !== undefined ? { destination: href } : {}),
27
- ...(locale !== undefined ? { locale } : {}),
28
- });
29
- // --------------------------------------------------
30
- // Execute navigation on user interaction
31
- // --------------------------------------------------
32
- const handleClick = (e) => {
33
- onClick?.(e);
34
- if (e.defaultPrevented)
35
- return;
36
- executeNavigation(outboundResult, { config, currentLocale, setLocale }, e);
37
- };
38
- return (jsx(NextLink, { href: outboundResult.destination, onClick: handleClick, ...props, children: children }));
12
+ const Link = ({
13
+ href,
14
+ locale,
15
+ children,
16
+ onClick,
17
+ ...props
18
+ }) => {
19
+ const { config, locale: currentLocale, setLocale } = useIntorContext();
20
+ const currentPathname = usePathname();
21
+ const outboundResult = resolveOutbound(
22
+ config,
23
+ currentLocale,
24
+ currentPathname,
25
+ {
26
+ ...href !== void 0 ? { destination: href } : {},
27
+ ...locale !== void 0 ? { locale } : {}
28
+ }
29
+ );
30
+ const handleClick = (e) => {
31
+ onClick?.(e);
32
+ if (e.defaultPrevented) return;
33
+ executeNavigation(outboundResult, { config, currentLocale, setLocale }, e);
34
+ };
35
+ return /* @__PURE__ */ React.createElement(
36
+ NextLink,
37
+ {
38
+ href: outboundResult.destination,
39
+ onClick: handleClick,
40
+ ...props
41
+ },
42
+ children
43
+ );
39
44
  };
40
45
 
41
46
  export { Link };
@@ -5,23 +5,20 @@ import 'intor-translator';
5
5
  import { resolveOutbound } from '../../routing/outbound/resolve-outbound.js';
6
6
  import { getLocale } from './server/get-locale.js';
7
7
 
8
- /**
9
- * Redirect to a locale-aware destination for the current execution context.
10
- *
11
- * - Bypasses localization for external destinations.
12
- * - Automatically resolves the effective locale from the execution context.
13
- *
14
- * @public
15
- */
16
8
  const redirect = async (config, url, options) => {
17
- const { locale, type } = options ?? {};
18
- const currentLocale = await getLocale(config);
19
- const { destination } = resolveOutbound(config, currentLocale, "", // server redirect does not depend on current pathname
9
+ const { locale, type } = options ?? {};
10
+ const currentLocale = await getLocale(config);
11
+ const { destination } = resolveOutbound(
12
+ config,
13
+ currentLocale,
14
+ "",
15
+ // server redirect does not depend on current pathname
20
16
  {
21
- destination: url,
22
- ...(locale !== undefined ? { locale } : {}),
23
- });
24
- return redirect$1(destination, type);
17
+ destination: url,
18
+ ...locale !== void 0 ? { locale } : {}
19
+ }
20
+ );
21
+ return redirect$1(destination, type);
25
22
  };
26
23
 
27
24
  export { redirect };
@@ -1,34 +1,23 @@
1
1
  import { headers, cookies } from 'next/headers';
2
- import { INTOR_HEADERS } from '../../../core/constants/headers.js';
3
2
  import { matchLocale } from '../../../core/locale/match-locale.js';
4
3
  import 'logry';
5
4
  import 'p-limit';
6
5
  import 'intor-translator';
6
+ import { INTOR_HEADER_KEYS } from '../header-keys.js';
7
7
 
8
- /**
9
- * Get the locale for the current execution context.
10
- *
11
- * Uses inbound routing context when available, otherwise falls back to persisted state.
12
- *
13
- * @public
14
- */
15
8
  const getLocale = async (config) => {
16
- const headersStore = await headers();
17
- // Inbound routing context (authoritative)
18
- const headerLocale = headersStore.get(INTOR_HEADERS.LOCALE);
19
- if (headerLocale) {
20
- return headerLocale;
21
- }
22
- // Persisted state
23
- const cookieStore = await cookies();
24
- const cookieLocale = cookieStore.get(config.cookie.name)?.value;
25
- if (cookieLocale) {
26
- const matched = matchLocale(cookieLocale, config.supportedLocales);
27
- if (matched)
28
- return matched;
29
- }
30
- // Explicit default
31
- return config.defaultLocale;
9
+ const headersList = await headers();
10
+ const headerLocale = headersList.get(INTOR_HEADER_KEYS.LOCALE);
11
+ if (headerLocale) {
12
+ return headerLocale;
13
+ }
14
+ const cookieStore = await cookies();
15
+ const cookieLocale = cookieStore.get(config.cookie.name)?.value;
16
+ if (cookieLocale) {
17
+ const matched = matchLocale(cookieLocale, config.supportedLocales);
18
+ if (matched) return matched;
19
+ }
20
+ return config.defaultLocale;
32
21
  };
33
22
 
34
23
  export { getLocale };
@@ -1,16 +1,9 @@
1
1
  import { getTranslator as getTranslator$1 } from 'intor/server';
2
2
  import { getLocale } from './get-locale.js';
3
3
 
4
- /**
5
- * Get a server-side translator for the current execution context.
6
- *
7
- * - Automatically resolves the locale from the framework context.
8
- *
9
- * @public
10
- */
11
4
  async function getTranslator(config, params) {
12
- const locale = await getLocale(config);
13
- return getTranslator$1(config, { locale, ...(params ?? {}) });
5
+ const locale = await getLocale(config);
6
+ return getTranslator$1(config, { locale, ...params ?? {} });
14
7
  }
15
8
 
16
9
  export { getTranslator };
@@ -1,20 +1,12 @@
1
1
  import { intor as intor$1 } from 'intor/server';
2
2
  import { getLocale } from './get-locale.js';
3
3
 
4
- /**
5
- * Initializes Intor for the current execution context.
6
- *
7
- * - Automatically resolves the locale from the framework context.
8
- * - Permits cache writes during server execution.
9
- *
10
- * @public
11
- */
12
4
  async function intor(config, options) {
13
- const { readers, allowCacheWrite = true } = options ?? {};
14
- return await intor$1(config, await getLocale(config), {
15
- ...(readers !== undefined ? { readers } : {}),
16
- allowCacheWrite,
17
- });
5
+ const { readers, allowCacheWrite = true } = options ?? {};
6
+ return await intor$1(config, await getLocale(config), {
7
+ ...readers !== void 0 ? { readers } : {},
8
+ allowCacheWrite
9
+ });
18
10
  }
19
11
 
20
12
  export { intor };
@@ -0,0 +1,13 @@
1
+ import { headers } from 'next/headers';
2
+ import { INTOR_HEADER_KEYS } from '../header-keys.js';
3
+
4
+ async function readIntorUrlState() {
5
+ const headersList = await headers();
6
+ return {
7
+ locale: headersList.get(INTOR_HEADER_KEYS.LOCALE) ?? null,
8
+ pathname: headersList.get(INTOR_HEADER_KEYS.PATHNAME) ?? "/",
9
+ search: headersList.get(INTOR_HEADER_KEYS.SEARCH) ?? ""
10
+ };
11
+ }
12
+
13
+ export { readIntorUrlState };
@@ -6,76 +6,57 @@ import { executeNavigation } from '../../client/shared/navigation/execute-naviga
6
6
  import { useIntorContext } from 'intor/react/internal';
7
7
  import { resolveOutbound } from '../../routing/outbound/resolve-outbound.js';
8
8
 
9
- /**
10
- * Locale-aware router hook for the current execution context.
11
- *
12
- * - Resolves a locale-aware navigation destination.
13
- * - Commits locale changes only on actual navigation.
14
- * - Keeps routing logic pure and side-effects explicit.
15
- *
16
- * @public
17
- */
18
9
  function useRouter() {
19
- const { config, locale: currentLocale, setLocale } = useIntorContext();
20
- const currentPathname = usePathname();
21
- const nextRouter = useRouter$1();
22
- function resolve(href, locale) {
23
- return resolveOutbound(config, currentLocale, currentPathname, {
24
- destination: href,
25
- ...(locale !== undefined ? { locale } : {}),
26
- });
10
+ const { config, locale: currentLocale, setLocale } = useIntorContext();
11
+ const currentPathname = usePathname();
12
+ const nextRouter = useRouter$1();
13
+ function resolve(href, locale) {
14
+ return resolveOutbound(config, currentLocale, currentPathname, {
15
+ destination: href,
16
+ ...locale !== void 0 ? { locale } : {}
17
+ });
18
+ }
19
+ function execute(outboundResult) {
20
+ executeNavigation(outboundResult, { config, currentLocale, setLocale });
21
+ }
22
+ function push(href, options) {
23
+ const outboundResult = resolve(href, options?.locale);
24
+ execute(outboundResult);
25
+ if (!options) {
26
+ nextRouter.push(outboundResult.destination);
27
+ return;
27
28
  }
28
- function execute(outboundResult) {
29
- executeNavigation(outboundResult, { config, currentLocale, setLocale });
29
+ const { locale: _, ...rest } = options;
30
+ nextRouter.push(outboundResult.destination, rest);
31
+ }
32
+ function replace(href, options) {
33
+ const outboundResult = resolve(href, options?.locale);
34
+ execute(outboundResult);
35
+ if (!options) {
36
+ nextRouter.replace(outboundResult.destination);
37
+ return;
30
38
  }
31
- // --------------------------------------------------
32
- // push
33
- // --------------------------------------------------
34
- function push(href, options) {
35
- const outboundResult = resolve(href, options?.locale);
36
- execute(outboundResult);
37
- if (!options) {
38
- nextRouter.push(outboundResult.destination);
39
- return;
40
- }
41
- const { locale: _, ...rest } = options;
42
- nextRouter.push(outboundResult.destination, rest);
39
+ const { locale: _, ...rest } = options;
40
+ nextRouter.replace(outboundResult.destination, rest);
41
+ }
42
+ function prefetch(href, options) {
43
+ const outboundResult = resolve(href, options?.locale);
44
+ if (outboundResult.kind !== "client") return;
45
+ if (!options) {
46
+ nextRouter.prefetch(outboundResult.destination);
47
+ return;
43
48
  }
44
- // --------------------------------------------------
45
- // replace
46
- // --------------------------------------------------
47
- function replace(href, options) {
48
- const outboundResult = resolve(href, options?.locale);
49
- execute(outboundResult);
50
- if (!options) {
51
- nextRouter.replace(outboundResult.destination);
52
- return;
53
- }
54
- const { locale: _, ...rest } = options;
55
- nextRouter.replace(outboundResult.destination, rest);
56
- }
57
- // --------------------------------------------------
58
- // prefetch (NO side effects)
59
- // --------------------------------------------------
60
- function prefetch(href, options) {
61
- const outboundResult = resolve(href, options?.locale);
62
- if (outboundResult.kind !== "client")
63
- return;
64
- if (!options) {
65
- nextRouter.prefetch(outboundResult.destination);
66
- return;
67
- }
68
- const { locale: _, ...rest } = options;
69
- nextRouter.prefetch(outboundResult.destination, rest);
70
- }
71
- return {
72
- push,
73
- replace,
74
- prefetch,
75
- back: () => nextRouter.back(),
76
- forward: () => nextRouter.forward(),
77
- refresh: () => nextRouter.refresh(),
78
- };
49
+ const { locale: _, ...rest } = options;
50
+ nextRouter.prefetch(outboundResult.destination, rest);
51
+ }
52
+ return {
53
+ push,
54
+ replace,
55
+ prefetch,
56
+ back: () => nextRouter.back(),
57
+ forward: () => nextRouter.forward(),
58
+ refresh: () => nextRouter.refresh()
59
+ };
79
60
  }
80
61
 
81
62
  export { useRouter };