intor 2.5.0 → 2.5.1

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 (294) hide show
  1. package/dist/core/src/client/shared/helpers/get-client-locale.js +5 -20
  2. package/dist/core/src/client/shared/utils/locale/detect-browser-locale.js +2 -8
  3. package/dist/core/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  4. package/dist/core/src/config/constants/cookie.js +9 -9
  5. package/dist/core/src/config/constants/routing.js +13 -14
  6. package/dist/core/src/config/define-intor-config.js +28 -44
  7. package/dist/core/src/config/resolvers/resolve-cookie-options.js +4 -4
  8. package/dist/core/src/config/resolvers/resolve-fallback-locales.js +33 -50
  9. package/dist/core/src/config/resolvers/resolve-routing-options.js +32 -61
  10. package/dist/core/src/config/validators/validate-default-locale.js +8 -13
  11. package/dist/core/src/config/validators/validate-id.js +8 -13
  12. package/dist/core/src/config/validators/validate-supported-locales.js +8 -13
  13. package/dist/core/src/core/constants/locale-placeholder.js +0 -1
  14. package/dist/core/src/core/error/intor-error.js +14 -29
  15. package/dist/core/src/core/locale/canonicalize-locale.js +7 -18
  16. package/dist/core/src/core/locale/match-locale.js +24 -50
  17. package/dist/core/src/core/locale/parse-locale.js +12 -22
  18. package/dist/core/src/core/logger/get-logger.js +26 -31
  19. package/dist/core/src/core/logger/global-logger-pool.js +4 -4
  20. package/dist/core/src/core/messages/internal-metadata.js +1 -1
  21. package/dist/core/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  22. package/dist/core/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  23. package/dist/core/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  24. package/dist/core/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  25. package/dist/core/src/core/messages/merge-messages.js +17 -28
  26. package/dist/core/src/core/messages/utils/is-valid-messages.js +22 -37
  27. package/dist/core/src/core/messages/utils/nest-object-from-path.js +5 -17
  28. package/dist/core/src/core/render/create-html-renderer.js +29 -37
  29. package/dist/core/src/core/render/utils/escape-html.js +1 -6
  30. package/dist/core/src/core/render/utils/render-attributes.js +6 -11
  31. package/dist/core/src/core/translator/create-t-rich.js +6 -15
  32. package/dist/core/src/core/translator/create-translator.js +16 -24
  33. package/dist/core/src/core/utils/deep-merge.js +24 -42
  34. package/dist/core/src/core/utils/normalizers/normalize-cache-key.js +14 -40
  35. package/dist/core/src/core/utils/normalizers/normalize-pathname.js +19 -37
  36. package/dist/core/src/core/utils/normalizers/normalize-query.js +6 -20
  37. package/dist/core/src/core/utils/parse-cookie-header.js +11 -18
  38. package/dist/core/src/core/utils/resolve-loader-options.js +6 -32
  39. package/dist/core/src/edge/helpers/get-translator.js +14 -20
  40. package/dist/core/src/edge/translator/init-translator.js +23 -31
  41. package/dist/core/src/routing/inbound/helpers/resolve-inbound-from-request.js +21 -28
  42. package/dist/core/src/routing/inbound/resolve-inbound.js +22 -37
  43. package/dist/core/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  44. package/dist/core/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  45. package/dist/core/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  46. package/dist/core/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  47. package/dist/core/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  48. package/dist/core/src/routing/locale/get-locale-from-accept-language.js +21 -36
  49. package/dist/core/src/routing/locale/get-locale-from-host.js +5 -28
  50. package/dist/core/src/routing/locale/get-locale-from-pathname.js +11 -37
  51. package/dist/core/src/routing/locale/get-locale-from-query.js +2 -17
  52. package/dist/core/src/routing/pathname/canonicalize-pathname.js +25 -67
  53. package/dist/core/src/routing/pathname/localize-pathname.js +12 -30
  54. package/dist/core/src/routing/pathname/materialize-pathname.js +9 -44
  55. package/dist/core/src/routing/pathname/standardize-pathname.js +6 -30
  56. package/dist/core/src/server/helpers/get-translator.js +26 -23
  57. package/dist/core/src/server/intor/intor.js +20 -25
  58. package/dist/core/src/server/messages/load-local-messages/cache/messages-pool.js +4 -7
  59. package/dist/core/src/server/messages/load-local-messages/load-local-messages.js +76 -92
  60. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/collect-file-entries/collect-file-entries.js +59 -80
  61. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/parse-file-entries.js +53 -87
  62. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/parse-file-entries/utils/json-reader.js +3 -6
  63. package/dist/core/src/server/messages/load-local-messages/read-locale-messages/read-locale-messages.js +23 -35
  64. package/dist/core/src/server/messages/load-messages.js +56 -69
  65. package/dist/core/src/server/translator/init-translator.js +28 -30
  66. package/dist/express/src/adapters/express/create-intor-handler.js +35 -46
  67. package/dist/express/src/adapters/express/get-translator.js +2 -9
  68. package/dist/express/src/core/constants/locale-placeholder.js +0 -1
  69. package/dist/express/src/core/locale/canonicalize-locale.js +7 -18
  70. package/dist/express/src/core/locale/match-locale.js +24 -50
  71. package/dist/express/src/core/locale/parse-locale.js +12 -22
  72. package/dist/express/src/core/utils/normalizers/normalize-pathname.js +19 -37
  73. package/dist/express/src/core/utils/normalizers/normalize-query.js +6 -20
  74. package/dist/express/src/core/utils/parse-cookie-header.js +11 -18
  75. package/dist/express/src/routing/inbound/resolve-inbound.js +22 -37
  76. package/dist/express/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  77. package/dist/express/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  78. package/dist/express/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  79. package/dist/express/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  80. package/dist/express/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  81. package/dist/express/src/routing/locale/get-locale-from-accept-language.js +21 -36
  82. package/dist/express/src/routing/locale/get-locale-from-host.js +5 -28
  83. package/dist/express/src/routing/locale/get-locale-from-pathname.js +11 -37
  84. package/dist/express/src/routing/locale/get-locale-from-query.js +2 -17
  85. package/dist/express/src/routing/pathname/canonicalize-pathname.js +25 -67
  86. package/dist/express/src/routing/pathname/localize-pathname.js +12 -30
  87. package/dist/express/src/routing/pathname/materialize-pathname.js +9 -44
  88. package/dist/express/src/routing/pathname/standardize-pathname.js +6 -30
  89. package/dist/fastify/src/adapters/fastify/create-intor-handler.js +35 -47
  90. package/dist/fastify/src/adapters/fastify/get-translator.js +2 -9
  91. package/dist/fastify/src/adapters/fastify/intor-fastify-plugin.js +29 -38
  92. package/dist/fastify/src/core/constants/locale-placeholder.js +0 -1
  93. package/dist/fastify/src/core/locale/canonicalize-locale.js +7 -18
  94. package/dist/fastify/src/core/locale/match-locale.js +24 -50
  95. package/dist/fastify/src/core/locale/parse-locale.js +12 -22
  96. package/dist/fastify/src/core/utils/normalizers/normalize-pathname.js +19 -37
  97. package/dist/fastify/src/core/utils/normalizers/normalize-query.js +6 -20
  98. package/dist/fastify/src/core/utils/parse-cookie-header.js +11 -18
  99. package/dist/fastify/src/routing/inbound/resolve-inbound.js +22 -37
  100. package/dist/fastify/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  101. package/dist/fastify/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  102. package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  103. package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  104. package/dist/fastify/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  105. package/dist/fastify/src/routing/locale/get-locale-from-accept-language.js +21 -36
  106. package/dist/fastify/src/routing/locale/get-locale-from-host.js +5 -28
  107. package/dist/fastify/src/routing/locale/get-locale-from-pathname.js +11 -37
  108. package/dist/fastify/src/routing/locale/get-locale-from-query.js +2 -17
  109. package/dist/fastify/src/routing/pathname/canonicalize-pathname.js +25 -67
  110. package/dist/fastify/src/routing/pathname/localize-pathname.js +12 -30
  111. package/dist/fastify/src/routing/pathname/materialize-pathname.js +9 -44
  112. package/dist/fastify/src/routing/pathname/standardize-pathname.js +6 -30
  113. package/dist/hono/src/adapters/hono/create-intor-handler.js +33 -44
  114. package/dist/hono/src/adapters/hono/get-translator.js +2 -9
  115. package/dist/hono/src/core/constants/locale-placeholder.js +0 -1
  116. package/dist/hono/src/core/locale/canonicalize-locale.js +7 -18
  117. package/dist/hono/src/core/locale/match-locale.js +24 -50
  118. package/dist/hono/src/core/locale/parse-locale.js +12 -22
  119. package/dist/hono/src/core/utils/normalizers/normalize-pathname.js +19 -37
  120. package/dist/hono/src/core/utils/normalizers/normalize-query.js +6 -20
  121. package/dist/hono/src/core/utils/parse-cookie-header.js +11 -18
  122. package/dist/hono/src/routing/inbound/resolve-inbound.js +22 -37
  123. package/dist/hono/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  124. package/dist/hono/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  125. package/dist/hono/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  126. package/dist/hono/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  127. package/dist/hono/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  128. package/dist/hono/src/routing/locale/get-locale-from-accept-language.js +21 -36
  129. package/dist/hono/src/routing/locale/get-locale-from-host.js +5 -28
  130. package/dist/hono/src/routing/locale/get-locale-from-pathname.js +11 -37
  131. package/dist/hono/src/routing/locale/get-locale-from-query.js +2 -17
  132. package/dist/hono/src/routing/pathname/canonicalize-pathname.js +25 -67
  133. package/dist/hono/src/routing/pathname/localize-pathname.js +12 -30
  134. package/dist/hono/src/routing/pathname/materialize-pathname.js +9 -44
  135. package/dist/hono/src/routing/pathname/standardize-pathname.js +6 -30
  136. package/dist/next/src/adapters/next/create-intor-handler.js +29 -47
  137. package/dist/next/src/adapters/next/link.js +33 -28
  138. package/dist/next/src/adapters/next/redirect.js +12 -15
  139. package/dist/next/src/adapters/next/server/get-locale.js +12 -23
  140. package/dist/next/src/adapters/next/server/get-translator.js +2 -9
  141. package/dist/next/src/adapters/next/server/intor.js +5 -13
  142. package/dist/next/src/adapters/next/use-router.js +47 -66
  143. package/dist/next/src/client/shared/navigation/execute-navigation.js +20 -38
  144. package/dist/next/src/client/shared/utils/build-cookie-string.js +18 -27
  145. package/dist/next/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  146. package/dist/next/src/core/constants/headers.js +4 -4
  147. package/dist/next/src/core/constants/locale-placeholder.js +0 -1
  148. package/dist/next/src/core/locale/canonicalize-locale.js +7 -18
  149. package/dist/next/src/core/locale/match-locale.js +24 -50
  150. package/dist/next/src/core/locale/parse-locale.js +12 -22
  151. package/dist/next/src/core/utils/normalizers/normalize-pathname.js +19 -37
  152. package/dist/next/src/core/utils/normalizers/normalize-query.js +6 -20
  153. package/dist/next/src/core/utils/resolve-loader-options.js +6 -29
  154. package/dist/next/src/policies/shoud-full-reload.js +2 -5
  155. package/dist/next/src/policies/should-sync-locale.js +1 -4
  156. package/dist/next/src/routing/inbound/resolve-inbound.js +24 -39
  157. package/dist/next/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  158. package/dist/next/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  159. package/dist/next/src/routing/inbound/resolve-pathname/strategies/all.js +13 -29
  160. package/dist/next/src/routing/inbound/resolve-pathname/strategies/except-default.js +14 -30
  161. package/dist/next/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  162. package/dist/next/src/routing/locale/get-locale-from-accept-language.js +21 -36
  163. package/dist/next/src/routing/locale/get-locale-from-host.js +5 -28
  164. package/dist/next/src/routing/locale/get-locale-from-pathname.js +11 -37
  165. package/dist/next/src/routing/locale/get-locale-from-query.js +2 -17
  166. package/dist/next/src/routing/outbound/decide-strategy.js +9 -9
  167. package/dist/next/src/routing/outbound/determine-target.js +28 -44
  168. package/dist/next/src/routing/outbound/resolve-outbound.js +12 -16
  169. package/dist/next/src/routing/outbound/utils/derive-host-destination.js +5 -9
  170. package/dist/next/src/routing/outbound/utils/derive-query-destination.js +4 -7
  171. package/dist/next/src/routing/outbound/utils/is-external-destination.js +1 -7
  172. package/dist/next/src/routing/pathname/canonicalize-pathname.js +25 -67
  173. package/dist/next/src/routing/pathname/localize-pathname.js +12 -30
  174. package/dist/next/src/routing/pathname/materialize-pathname.js +9 -44
  175. package/dist/next/src/routing/pathname/standardize-pathname.js +6 -30
  176. package/dist/react/src/client/react/helpers/use-intor.js +25 -44
  177. package/dist/react/src/client/react/provider/effects/use-locale-effects.js +20 -25
  178. package/dist/react/src/client/react/provider/effects/use-messages-effects.js +17 -16
  179. package/dist/react/src/client/react/provider/intor-provider.js +63 -66
  180. package/dist/react/src/client/react/provider/use-intor-context.js +4 -4
  181. package/dist/react/src/client/react/render/create-react-renderer.js +18 -24
  182. package/dist/react/src/client/react/translator/create-t-rich.js +9 -22
  183. package/dist/react/src/client/react/translator/use-translator.js +11 -16
  184. package/dist/react/src/client/shared/messages/create-refetch-messages.js +41 -51
  185. package/dist/react/src/client/shared/provider/effective-state.js +2 -6
  186. package/dist/react/src/client/shared/utils/build-cookie-string.js +18 -27
  187. package/dist/react/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  188. package/dist/react/src/client/shared/utils/locale/set-document-locale.js +2 -8
  189. package/dist/react/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  190. package/dist/react/src/core/logger/get-logger.js +26 -31
  191. package/dist/react/src/core/logger/global-logger-pool.js +4 -4
  192. package/dist/react/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  193. package/dist/react/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  194. package/dist/react/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  195. package/dist/react/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  196. package/dist/react/src/core/messages/merge-messages.js +17 -28
  197. package/dist/react/src/core/messages/utils/is-valid-messages.js +22 -37
  198. package/dist/react/src/core/messages/utils/nest-object-from-path.js +5 -17
  199. package/dist/react/src/core/utils/deep-merge.js +24 -42
  200. package/dist/react/src/core/utils/resolve-loader-options.js +6 -29
  201. package/dist/react/src/policies/should-persist-on-first-visit.js +1 -4
  202. package/dist/svelte/export/svelte/index.js +0 -6
  203. package/dist/svelte/src/client/shared/messages/create-refetch-messages.js +41 -51
  204. package/dist/svelte/src/client/shared/provider/effective-state.js +2 -6
  205. package/dist/svelte/src/client/shared/utils/build-cookie-string.js +18 -27
  206. package/dist/svelte/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  207. package/dist/svelte/src/client/shared/utils/locale/set-document-locale.js +2 -8
  208. package/dist/svelte/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  209. package/dist/svelte/src/client/svelte/provider/create-intor-store.js +59 -63
  210. package/dist/svelte/src/client/svelte/provider/effects/attach-locale-effects.js +20 -25
  211. package/dist/svelte/src/client/svelte/provider/effects/attach-messages-effects.js +21 -18
  212. package/dist/svelte/src/client/svelte/provider/get-intor-context.js +4 -4
  213. package/dist/svelte/src/client/svelte/translator/use-translator.js +11 -16
  214. package/dist/svelte/src/core/logger/get-logger.js +26 -31
  215. package/dist/svelte/src/core/logger/global-logger-pool.js +4 -4
  216. package/dist/svelte/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  217. package/dist/svelte/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  218. package/dist/svelte/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  219. package/dist/svelte/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  220. package/dist/svelte/src/core/messages/merge-messages.js +17 -28
  221. package/dist/svelte/src/core/messages/utils/is-valid-messages.js +22 -37
  222. package/dist/svelte/src/core/messages/utils/nest-object-from-path.js +5 -17
  223. package/dist/svelte/src/core/render/create-html-renderer.js +29 -37
  224. package/dist/svelte/src/core/render/utils/escape-html.js +1 -6
  225. package/dist/svelte/src/core/render/utils/render-attributes.js +6 -11
  226. package/dist/svelte/src/core/translator/create-t-rich.js +6 -15
  227. package/dist/svelte/src/core/utils/deep-merge.js +24 -42
  228. package/dist/svelte/src/core/utils/resolve-loader-options.js +6 -29
  229. package/dist/svelte/src/policies/should-persist-on-first-visit.js +1 -4
  230. package/dist/svelte-kit/src/adapters/svelte-kit/create-intor-handler.js +37 -57
  231. package/dist/svelte-kit/src/adapters/svelte-kit/use-navigation.js +29 -27
  232. package/dist/svelte-kit/src/adapters/svelte-kit/utils/is-svelte-kit-ssg.js +4 -11
  233. package/dist/svelte-kit/src/client/shared/navigation/execute-navigation.js +19 -37
  234. package/dist/svelte-kit/src/client/shared/utils/build-cookie-string.js +18 -27
  235. package/dist/svelte-kit/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  236. package/dist/svelte-kit/src/core/constants/locale-placeholder.js +0 -1
  237. package/dist/svelte-kit/src/core/locale/canonicalize-locale.js +7 -18
  238. package/dist/svelte-kit/src/core/locale/match-locale.js +24 -50
  239. package/dist/svelte-kit/src/core/locale/parse-locale.js +12 -22
  240. package/dist/svelte-kit/src/core/utils/normalizers/normalize-pathname.js +19 -37
  241. package/dist/svelte-kit/src/core/utils/normalizers/normalize-query.js +6 -20
  242. package/dist/svelte-kit/src/core/utils/resolve-loader-options.js +6 -29
  243. package/dist/svelte-kit/src/policies/shoud-full-reload.js +2 -5
  244. package/dist/svelte-kit/src/policies/should-sync-locale.js +1 -4
  245. package/dist/svelte-kit/src/routing/inbound/resolve-inbound.js +22 -37
  246. package/dist/svelte-kit/src/routing/inbound/resolve-locale/resolve-locale.js +22 -39
  247. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/resolve-pathname.js +24 -30
  248. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/all.js +10 -23
  249. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/except-default.js +11 -24
  250. package/dist/svelte-kit/src/routing/inbound/resolve-pathname/strategies/none.js +1 -4
  251. package/dist/svelte-kit/src/routing/locale/get-locale-from-accept-language.js +21 -36
  252. package/dist/svelte-kit/src/routing/locale/get-locale-from-host.js +5 -28
  253. package/dist/svelte-kit/src/routing/locale/get-locale-from-pathname.js +11 -37
  254. package/dist/svelte-kit/src/routing/locale/get-locale-from-query.js +2 -17
  255. package/dist/svelte-kit/src/routing/outbound/decide-strategy.js +9 -9
  256. package/dist/svelte-kit/src/routing/outbound/determine-target.js +28 -44
  257. package/dist/svelte-kit/src/routing/outbound/resolve-outbound.js +12 -16
  258. package/dist/svelte-kit/src/routing/outbound/utils/derive-host-destination.js +5 -9
  259. package/dist/svelte-kit/src/routing/outbound/utils/derive-query-destination.js +4 -7
  260. package/dist/svelte-kit/src/routing/outbound/utils/is-external-destination.js +1 -7
  261. package/dist/svelte-kit/src/routing/pathname/canonicalize-pathname.js +25 -67
  262. package/dist/svelte-kit/src/routing/pathname/localize-pathname.js +12 -30
  263. package/dist/svelte-kit/src/routing/pathname/materialize-pathname.js +9 -44
  264. package/dist/svelte-kit/src/routing/pathname/standardize-pathname.js +6 -30
  265. package/dist/types/src/routing/outbound/decide-strategy.d.ts +1 -1
  266. package/dist/types/src/routing/outbound/decide-strategy.d.ts.map +1 -1
  267. package/dist/vue/src/client/shared/messages/create-refetch-messages.js +41 -51
  268. package/dist/vue/src/client/shared/provider/effective-state.js +2 -6
  269. package/dist/vue/src/client/shared/utils/build-cookie-string.js +18 -27
  270. package/dist/vue/src/client/shared/utils/locale/get-locale-from-cookie.js +5 -12
  271. package/dist/vue/src/client/shared/utils/locale/set-document-locale.js +2 -8
  272. package/dist/vue/src/client/shared/utils/locale/set-locale-cookie.js +2 -9
  273. package/dist/vue/src/client/vue/helpers/use-intor.js +20 -42
  274. package/dist/vue/src/client/vue/provider/effects/use-locale-effects.js +23 -24
  275. package/dist/vue/src/client/vue/provider/effects/use-messages-effects.js +15 -24
  276. package/dist/vue/src/client/vue/provider/inject-intor-context.js +4 -4
  277. package/dist/vue/src/client/vue/provider/intor-provider.js +61 -66
  278. package/dist/vue/src/client/vue/render/create-vue-renderer.js +18 -24
  279. package/dist/vue/src/client/vue/translator/create-t-rich.js +5 -17
  280. package/dist/vue/src/client/vue/translator/trans.js +24 -31
  281. package/dist/vue/src/client/vue/translator/use-translator.js +12 -17
  282. package/dist/vue/src/core/logger/get-logger.js +26 -31
  283. package/dist/vue/src/core/logger/global-logger-pool.js +4 -4
  284. package/dist/vue/src/core/messages/load-remote-messages/collect-remote-resources.js +13 -22
  285. package/dist/vue/src/core/messages/load-remote-messages/fetch-remote-resource.js +30 -39
  286. package/dist/vue/src/core/messages/load-remote-messages/load-remote-messages.js +72 -89
  287. package/dist/vue/src/core/messages/load-remote-messages/resolve-remote-resources.js +7 -17
  288. package/dist/vue/src/core/messages/merge-messages.js +17 -28
  289. package/dist/vue/src/core/messages/utils/is-valid-messages.js +22 -37
  290. package/dist/vue/src/core/messages/utils/nest-object-from-path.js +5 -17
  291. package/dist/vue/src/core/utils/deep-merge.js +24 -42
  292. package/dist/vue/src/core/utils/resolve-loader-options.js +6 -29
  293. package/dist/vue/src/policies/should-persist-on-first-visit.js +1 -4
  294. package/package.json +2 -2
@@ -1,31 +1,22 @@
1
- /**
2
- * Build a serialized cookie string.
3
- */
4
1
  const buildCookieString = (cookieOptions, value) => {
5
- const { name, maxAge, path, domain, sameSite, secure } = cookieOptions;
6
- // Cookie name and encoded value
7
- const parts = [`${name}=${encodeURIComponent(value)}`];
8
- // Add expiration and max-age if provided
9
- if (maxAge !== undefined) {
10
- const expires = new Date(Date.now() + maxAge * 1000).toUTCString();
11
- parts.push(`expires=${expires}`, `max-age=${maxAge}`);
12
- }
13
- // Set path (default to "/")
14
- parts.push(`path=${path ?? "/"}`);
15
- // Add domain if specified
16
- if (domain) {
17
- parts.push(`domain=${domain}`);
18
- }
19
- // Add SameSite policy (e.g., Lax, Strict)
20
- if (sameSite) {
21
- const normalized = sameSite.charAt(0).toUpperCase() + sameSite.slice(1).toLowerCase();
22
- parts.push(`SameSite=${normalized}`);
23
- }
24
- // Add Secure flag if not explicitly disabled
25
- if (secure !== false) {
26
- parts.push(`Secure`);
27
- }
28
- return parts.join("; ");
2
+ const { name, maxAge, path, domain, sameSite, secure } = cookieOptions;
3
+ const parts = [`${name}=${encodeURIComponent(value)}`];
4
+ if (maxAge !== void 0) {
5
+ const expires = new Date(Date.now() + maxAge * 1e3).toUTCString();
6
+ parts.push(`expires=${expires}`, `max-age=${maxAge}`);
7
+ }
8
+ parts.push(`path=${path ?? "/"}`);
9
+ if (domain) {
10
+ parts.push(`domain=${domain}`);
11
+ }
12
+ if (sameSite) {
13
+ const normalized = sameSite.charAt(0).toUpperCase() + sameSite.slice(1).toLowerCase();
14
+ parts.push(`SameSite=${normalized}`);
15
+ }
16
+ if (secure !== false) {
17
+ parts.push(`Secure`);
18
+ }
19
+ return parts.join("; ");
29
20
  };
30
21
 
31
22
  export { buildCookieString };
@@ -1,15 +1,8 @@
1
1
  import { buildCookieString } from '../build-cookie-string.js';
2
2
 
3
- /**
4
- * Persist locale to a cookie.
5
- *
6
- * This function relies on `document.cookie`.
7
- */
8
3
  const setLocaleCookie = (cookieOptions, locale) => {
9
- if (typeof document === "undefined")
10
- return;
11
- // Build and apply the cookie string
12
- document.cookie = buildCookieString(cookieOptions, locale);
4
+ if (typeof document === "undefined") return;
5
+ document.cookie = buildCookieString(cookieOptions, locale);
13
6
  };
14
7
 
15
8
  export { setLocaleCookie };
@@ -1,8 +1,8 @@
1
1
  const INTOR_HEADERS = {
2
- LOCALE: "x-intor-locale",
3
- LOCALE_SOURCE: "x-intor-locale-source",
4
- PATHNAME: "x-intor-pathname",
5
- REDIRECTED: "x-intor-redirected",
2
+ LOCALE: "x-intor-locale",
3
+ LOCALE_SOURCE: "x-intor-locale-source",
4
+ PATHNAME: "x-intor-pathname",
5
+ REDIRECTED: "x-intor-redirected"
6
6
  };
7
7
 
8
8
  export { INTOR_HEADERS };
@@ -1,4 +1,3 @@
1
- // Default locale placeholder
2
1
  const LOCALE_PLACEHOLDER = "{locale}";
3
2
 
4
3
  export { LOCALE_PLACEHOLDER };
@@ -1,23 +1,12 @@
1
- /**
2
- * Canonicalizes a BCP 47 locale string.
3
- *
4
- * - Uses `Intl.getCanonicalLocales` when available.
5
- * - Returns the original input if `Intl` is unavailable.
6
- * - Returns `undefined` for invalid locale input.
7
- *
8
- * This function performs normalization only.
9
- * It does not perform matching or fallback.
10
- */
11
1
  function canonicalizeLocale(input) {
12
- try {
13
- if (typeof Intl === "undefined" || !Intl.getCanonicalLocales) {
14
- return input;
15
- }
16
- return Intl.getCanonicalLocales(input)[0];
17
- }
18
- catch {
19
- return;
2
+ try {
3
+ if (typeof Intl === "undefined" || !Intl.getCanonicalLocales) {
4
+ return input;
20
5
  }
6
+ return Intl.getCanonicalLocales(input)[0];
7
+ } catch {
8
+ return;
9
+ }
21
10
  }
22
11
 
23
12
  export { canonicalizeLocale };
@@ -1,61 +1,35 @@
1
1
  import { canonicalizeLocale } from './canonicalize-locale.js';
2
2
  import { parseLocale } from './parse-locale.js';
3
3
 
4
- /**
5
- * Matches a locale candidate against a list of supported locales.
6
- *
7
- * Resolution order:
8
- * 1. Exact canonical match
9
- * 2. Same language + same script
10
- * 3. Same language only (only if candidate has no script)
11
- *
12
- * Returns one of the original `supportedLocales` values if matched.
13
- * Returns `undefined` if no match is found.
14
- *
15
- * Notes:
16
- * - Matching is deterministic and order-sensitive.
17
- * - Does not perform automatic fallback to a default locale.
18
- * Consumers are responsible for applying fallback logic.
19
- * - If the candidate includes a script subtag, language-only fallback is skipped.
20
- *
21
- * @public
22
- */
23
4
  function matchLocale(locale, supportedLocales = []) {
24
- if (!locale || supportedLocales.length === 0)
25
- return;
26
- const canonicalCandidate = canonicalizeLocale(locale);
27
- if (!canonicalCandidate)
28
- return;
29
- const candidateParts = parseLocale(canonicalCandidate);
30
- const supportedCanonical = supportedLocales.flatMap((original) => {
31
- const canonical = canonicalizeLocale(original);
32
- if (!canonical)
33
- return [];
34
- return [{ original, canonical, parts: parseLocale(canonical) }];
35
- });
36
- // 1. Exact match
37
- for (const s of supportedCanonical) {
38
- if (s.canonical === canonicalCandidate) {
39
- return s.original;
40
- }
41
- }
42
- // 2. Same language + same script
43
- if (candidateParts.script) {
44
- for (const s of supportedCanonical) {
45
- if (s.parts.language === candidateParts.language &&
46
- s.parts.script === candidateParts.script) {
47
- return s.original;
48
- }
49
- }
50
- return;
5
+ if (!locale || supportedLocales.length === 0) return;
6
+ const canonicalCandidate = canonicalizeLocale(locale);
7
+ if (!canonicalCandidate) return;
8
+ const candidateParts = parseLocale(canonicalCandidate);
9
+ const supportedCanonical = supportedLocales.flatMap((original) => {
10
+ const canonical = canonicalizeLocale(original);
11
+ if (!canonical) return [];
12
+ return [{ original, canonical, parts: parseLocale(canonical) }];
13
+ });
14
+ for (const s of supportedCanonical) {
15
+ if (s.canonical === canonicalCandidate) {
16
+ return s.original;
51
17
  }
52
- // 3. Same language only
18
+ }
19
+ if (candidateParts.script) {
53
20
  for (const s of supportedCanonical) {
54
- if (s.parts.language === candidateParts.language) {
55
- return s.original;
56
- }
21
+ if (s.parts.language === candidateParts.language && s.parts.script === candidateParts.script) {
22
+ return s.original;
23
+ }
57
24
  }
58
25
  return;
26
+ }
27
+ for (const s of supportedCanonical) {
28
+ if (s.parts.language === candidateParts.language) {
29
+ return s.original;
30
+ }
31
+ }
32
+ return;
59
33
  }
60
34
 
61
35
  export { matchLocale };
@@ -1,27 +1,17 @@
1
- /**
2
- * Parses a canonical locale tag into structural components.
3
- *
4
- * - Uses `Intl.Locale` when available.
5
- * - Falls back to minimal parsing (language only) if unavailable.
6
- *
7
- * This function does not validate or match locales.
8
- */
9
1
  function parseLocale(tag) {
10
- try {
11
- if (typeof Intl !== "undefined" && typeof Intl.Locale === "function") {
12
- const locale = new Intl.Locale(tag);
13
- return {
14
- language: locale.language,
15
- ...(locale.script !== undefined ? { script: locale.script } : {}),
16
- ...(locale.region !== undefined ? { region: locale.region } : {}),
17
- };
18
- }
2
+ try {
3
+ if (typeof Intl !== "undefined" && typeof Intl.Locale === "function") {
4
+ const locale = new Intl.Locale(tag);
5
+ return {
6
+ language: locale.language,
7
+ ...locale.script !== void 0 ? { script: locale.script } : {},
8
+ ...locale.region !== void 0 ? { region: locale.region } : {}
9
+ };
19
10
  }
20
- catch {
21
- // fallback below
22
- }
23
- const parts = tag.split("-");
24
- return { language: parts[0].toLowerCase() };
11
+ } catch {
12
+ }
13
+ const parts = tag.split("-");
14
+ return { language: parts[0].toLowerCase() };
25
15
  }
26
16
 
27
17
  export { parseLocale };
@@ -1,42 +1,24 @@
1
- /**
2
- * Normalizes a raw pathname string into a consistent structural form.
3
- *
4
- * Canonical guarantees:
5
- * - Leading and trailing whitespace (code points ≤ 32) are trimmed
6
- * - Consecutive slashes are collapsed into a single slash
7
- * - The result always starts with a single "/"
8
- * - Redundant trailing slashes are removed
9
- * - The root path is represented as "/"
10
- *
11
- * This function is deterministic and allocation-minimized.
12
- */
13
1
  const normalizePathname = (rawPathname) => {
14
- const length = rawPathname.length;
15
- let start = 0;
16
- let end = length - 1;
17
- // Trim leading whitespace
18
- while (start <= end && rawPathname.codePointAt(start) <= 32)
19
- start++;
20
- // Trim trailing whitespace
21
- while (end >= start && rawPathname.codePointAt(end) <= 32)
22
- end--;
23
- if (start > end)
24
- return "/"; // Only whitespace
25
- let result = "";
26
- let hasSlash = false;
27
- for (let i = start; i <= end; i++) {
28
- const char = rawPathname[i];
29
- if (char === "/") {
30
- if (!hasSlash) {
31
- hasSlash = true;
32
- }
33
- }
34
- else {
35
- result += hasSlash || result === "" ? "/" + char : char;
36
- hasSlash = false;
37
- }
2
+ const length = rawPathname.length;
3
+ let start = 0;
4
+ let end = length - 1;
5
+ while (start <= end && rawPathname.codePointAt(start) <= 32) start++;
6
+ while (end >= start && rawPathname.codePointAt(end) <= 32) end--;
7
+ if (start > end) return "/";
8
+ let result = "";
9
+ let hasSlash = false;
10
+ for (let i = start; i <= end; i++) {
11
+ const char = rawPathname[i];
12
+ if (char === "/") {
13
+ if (!hasSlash) {
14
+ hasSlash = true;
15
+ }
16
+ } else {
17
+ result += hasSlash || result === "" ? "/" + char : char;
18
+ hasSlash = false;
38
19
  }
39
- return result || "/";
20
+ }
21
+ return result || "/";
40
22
  };
41
23
 
42
24
  export { normalizePathname };
@@ -1,25 +1,11 @@
1
- /**
2
- * Normalize a raw query object into a string-only map.
3
- *
4
- * This utility is used to sanitize framework-specific query inputs
5
- * into a stable shape that the routing core
6
- * can safely consume.
7
- *
8
- * Behavior:
9
- * - Keeps only entries whose values are strings
10
- * - Ignores arrays, objects, and other non-string values
11
- * - Does not throw or attempt to coerce values
12
- *
13
- * This function is intentionally conservative by design.
14
- */
15
1
  function normalizeQuery(query) {
16
- const normalized = {};
17
- for (const [key, value] of Object.entries(query)) {
18
- if (typeof value === "string") {
19
- normalized[key] = value;
20
- }
2
+ const normalized = {};
3
+ for (const [key, value] of Object.entries(query)) {
4
+ if (typeof value === "string") {
5
+ normalized[key] = value;
21
6
  }
22
- return normalized;
7
+ }
8
+ return normalized;
23
9
  }
24
10
 
25
11
  export { normalizeQuery };
@@ -1,34 +1,11 @@
1
- /**
2
- * Resolve the effective message loader for a given runtime.
3
- *
4
- * Loader resolution follows an inheritance-based priority model:
5
- *
6
- * - client runtime:
7
- * client.loader → server.loader → root loader
8
- *
9
- * - server runtime:
10
- * server.loader → root loader
11
- *
12
- * This allows the client runtime to inherit server behavior
13
- * when no explicit client loader is provided.
14
- *
15
- * Notes:
16
- * - Static `messages` are intentionally NOT handled here.
17
- * - Returning `undefined` indicates that no loader is enabled
18
- * for the given runtime.
19
- */
20
1
  const resolveLoaderOptions = (config, runtime) => {
21
- // ------------------------------------------------
22
- // runtime: client
23
- // ------------------------------------------------
24
- {
25
- const client = config.client?.loader;
26
- if (client) {
27
- // Client loader is always remote by design
28
- return { mode: "remote", ...client };
29
- }
30
- return config.server?.loader ?? config.loader;
2
+ {
3
+ const client = config.client?.loader;
4
+ if (client) {
5
+ return { mode: "remote", ...client };
31
6
  }
7
+ return config.server?.loader ?? config.loader;
8
+ }
32
9
  };
33
10
 
34
11
  export { resolveLoaderOptions };
@@ -3,12 +3,9 @@ import 'logry';
3
3
  import 'p-limit';
4
4
  import 'intor-translator';
5
5
 
6
- /**
7
- * Determine whether client-side navigation must be forced to reload.
8
- */
9
6
  function shouldFullReload(config) {
10
- const loader = resolveLoaderOptions(config);
11
- return (loader?.mode === "local" || config.routing.outbound.forceFullReload === true);
7
+ const loader = resolveLoaderOptions(config);
8
+ return loader?.mode === "local" || config.routing.outbound.forceFullReload === true;
12
9
  }
13
10
 
14
11
  export { shouldFullReload };
@@ -1,8 +1,5 @@
1
- /**
2
- * Determine whether locale synchronization is required.
3
- */
4
1
  function shouldSyncLocale(currentLocale, targetLocale) {
5
- return currentLocale !== targetLocale;
2
+ return currentLocale !== targetLocale;
6
3
  }
7
4
 
8
5
  export { shouldSyncLocale };
@@ -4,46 +4,31 @@ import { getLocaleFromQuery } from '../locale/get-locale-from-query.js';
4
4
  import { resolveLocale } from './resolve-locale/resolve-locale.js';
5
5
  import { resolvePathname } from './resolve-pathname/resolve-pathname.js';
6
6
 
7
- /**
8
- * Resolves inbound routing state.
9
- *
10
- * - Resolves the effective locale from inbound inputs
11
- * - Localizes the pathname based on the resolved locale
12
- * - Indicates whether a redirect is required
13
- *
14
- * No side effects. No navigation.
15
- */
16
7
  function resolveInbound(config, rawPathname, localeInputs, options) {
17
- const { queryKey } = config.routing.inbound;
18
- const { host, query, cookie, detected } = localeInputs;
19
- // ------------------------------------------------------
20
- // Resolve locale from inbound inputs
21
- // ------------------------------------------------------
22
- const pathLocale = getLocaleFromPathname(rawPathname, config);
23
- const hostLocale = getLocaleFromHost(host);
24
- const queryLocale = getLocaleFromQuery(query, queryKey);
25
- const { locale, localeSource } = resolveLocale(config, {
26
- ...(pathLocale !== undefined && { path: { locale: pathLocale } }),
27
- ...(hostLocale !== undefined && { host: { locale: hostLocale } }),
28
- ...(queryLocale !== undefined && { query: { locale: queryLocale } }),
29
- ...(cookie !== undefined && { cookie: { locale: cookie } }),
30
- ...(detected !== undefined && { detected: { locale: detected } }),
31
- });
32
- // ------------------------------------------------------
33
- // Resolve localized pathname and redirect requirement
34
- // ------------------------------------------------------
35
- const { pathname, shouldRedirect } = resolvePathname(config, rawPathname, {
36
- locale,
37
- hasPathLocale: !!pathLocale,
38
- hasPersisted: !!cookie,
39
- hasRedirected: !!options?.hasRedirected,
40
- });
41
- return {
42
- locale,
43
- localeSource,
44
- pathname,
45
- shouldRedirect,
46
- };
8
+ const { queryKey } = config.routing.inbound;
9
+ const { host, query, cookie, detected } = localeInputs;
10
+ const pathLocale = getLocaleFromPathname(rawPathname, config);
11
+ const hostLocale = getLocaleFromHost(host);
12
+ const queryLocale = getLocaleFromQuery(query, queryKey);
13
+ const { locale, localeSource } = resolveLocale(config, {
14
+ ...pathLocale !== void 0 && { path: { locale: pathLocale } },
15
+ ...hostLocale !== void 0 && { host: { locale: hostLocale } },
16
+ ...queryLocale !== void 0 && { query: { locale: queryLocale } },
17
+ ...cookie !== void 0 && { cookie: { locale: cookie } },
18
+ ...detected !== void 0 && { detected: { locale: detected } }
19
+ });
20
+ const { pathname, shouldRedirect } = resolvePathname(config, rawPathname, {
21
+ locale,
22
+ hasPathLocale: !!pathLocale,
23
+ hasPersisted: !!cookie,
24
+ hasRedirected: !!options?.hasRedirected
25
+ });
26
+ return {
27
+ locale,
28
+ localeSource,
29
+ pathname,
30
+ shouldRedirect
31
+ };
47
32
  }
48
33
 
49
34
  export { resolveInbound };
@@ -3,48 +3,31 @@ import 'logry';
3
3
  import 'p-limit';
4
4
  import 'intor-translator';
5
5
 
6
- /**
7
- * Resolves the active locale from inbound routing configuration.
8
- *
9
- * Resolution order:
10
- * 1. Configured locale signals (path / query / host / cookie)
11
- * 2. Runtime detection signal ("detected")
12
- * 3. Invariant fallback ("default")
13
- *
14
- * Always returns a supported locale.
15
- */
16
6
  function resolveLocale(config, context) {
17
- const { localeSources } = config.routing.inbound;
18
- // ------------------------------------------------------
19
- // 1. Configured resolution signals (policy-ordered)
20
- // ------------------------------------------------------
21
- for (const source of localeSources) {
22
- const locale = context[source]?.locale;
23
- const normalized = matchLocale(locale, config.supportedLocales);
24
- if (!normalized)
25
- continue;
26
- return {
27
- locale: normalized,
28
- localeSource: source,
29
- };
30
- }
31
- // ------------------------------------------------------
32
- // 2. Detection fallback (runtime signal)
33
- // ------------------------------------------------------
34
- const detected = matchLocale(context.detected?.locale, config.supportedLocales);
35
- if (detected) {
36
- return {
37
- locale: detected,
38
- localeSource: "detected",
39
- };
40
- }
41
- // ------------------------------------------------------
42
- // 3. Final invariant fallback (guaranteed)
43
- // ------------------------------------------------------
7
+ const { localeSources } = config.routing.inbound;
8
+ for (const source of localeSources) {
9
+ const locale = context[source]?.locale;
10
+ const normalized = matchLocale(locale, config.supportedLocales);
11
+ if (!normalized) continue;
44
12
  return {
45
- locale: config.defaultLocale,
46
- localeSource: "default",
13
+ locale: normalized,
14
+ localeSource: source
47
15
  };
16
+ }
17
+ const detected = matchLocale(
18
+ context.detected?.locale,
19
+ config.supportedLocales
20
+ );
21
+ if (detected) {
22
+ return {
23
+ locale: detected,
24
+ localeSource: "detected"
25
+ };
26
+ }
27
+ return {
28
+ locale: config.defaultLocale,
29
+ localeSource: "default"
30
+ };
48
31
  }
49
32
 
50
33
  export { resolveLocale };
@@ -4,39 +4,33 @@ import { exceptDefault } from './strategies/except-default.js';
4
4
  import { none } from './strategies/none.js';
5
5
 
6
6
  const assertNever = (x) => {
7
- throw new Error(`Unhandled prefix strategy: ${String(x)}`);
7
+ throw new Error(`Unhandled prefix strategy: ${String(x)}`);
8
8
  };
9
- /**
10
- * Resolves the canonical pathname based on locale prefix behavior.
11
- *
12
- * The resolved pathname represents the final, normalized form
13
- * used for routing and navigation.
14
- */
15
9
  const resolvePathname = (config, rawPathname, context) => {
16
- const { localePrefix } = config.routing;
17
- let directive;
18
- switch (localePrefix) {
19
- case "all": {
20
- directive = all(config, context);
21
- break;
22
- }
23
- case "except-default": {
24
- directive = exceptDefault(config, context);
25
- break;
26
- }
27
- case "none": {
28
- directive = none();
29
- break;
30
- }
31
- default: {
32
- return assertNever(localePrefix);
33
- }
10
+ const { localePrefix } = config.routing;
11
+ let directive;
12
+ switch (localePrefix) {
13
+ case "all": {
14
+ directive = all(config, context);
15
+ break;
34
16
  }
35
- const { pathname } = localizePathname(rawPathname, config, context.locale);
36
- return {
37
- pathname,
38
- shouldRedirect: directive.type === "redirect",
39
- };
17
+ case "except-default": {
18
+ directive = exceptDefault(config, context);
19
+ break;
20
+ }
21
+ case "none": {
22
+ directive = none();
23
+ break;
24
+ }
25
+ default: {
26
+ return assertNever(localePrefix);
27
+ }
28
+ }
29
+ const { pathname } = localizePathname(rawPathname, config, context.locale);
30
+ return {
31
+ pathname,
32
+ shouldRedirect: directive.type === "redirect"
33
+ };
40
34
  };
41
35
 
42
36
  export { resolvePathname };