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
@@ -5,27 +5,12 @@ import 'intor-translator';
5
5
  import { detectBrowserLocale } from '../utils/locale/detect-browser-locale.js';
6
6
  import { getLocaleFromCookie } from '../utils/locale/get-locale-from-cookie.js';
7
7
 
8
- /**
9
- * Resolve the active locale in a browser-only environment.
10
- *
11
- * This helper is intended for pure client-side setups where
12
- * no server-side locale resolution is involved.
13
- *
14
- * Resolution order:
15
- * 1. Locale from cookie
16
- * 2. Locale from browser preference
17
- * 3. Fallback to `defaultLocale`
18
- *
19
- * @public
20
- */
21
8
  function getClientLocale(config) {
22
- const { defaultLocale, supportedLocales, cookie } = config;
23
- // Locale from browser cookie
24
- const cookieLocale = getLocaleFromCookie(cookie.name);
25
- // Locale from browser preference
26
- const browserLocale = detectBrowserLocale();
27
- const localeCandidate = cookieLocale || browserLocale;
28
- return matchLocale(localeCandidate, supportedLocales) || defaultLocale;
9
+ const { defaultLocale, supportedLocales, cookie } = config;
10
+ const cookieLocale = getLocaleFromCookie(cookie.name);
11
+ const browserLocale = detectBrowserLocale();
12
+ const localeCandidate = cookieLocale || browserLocale;
13
+ return matchLocale(localeCandidate, supportedLocales) || defaultLocale;
29
14
  }
30
15
 
31
16
  export { getClientLocale };
@@ -1,12 +1,6 @@
1
- /**
2
- * Detect the preferred locale from the browser.
3
- *
4
- * This function relies on `navigator.languages` and `navigator.language`.
5
- */
6
1
  function detectBrowserLocale() {
7
- if (typeof navigator === "undefined")
8
- return undefined;
9
- return navigator.languages?.[0] || navigator.language || undefined;
2
+ if (typeof navigator === "undefined") return void 0;
3
+ return navigator.languages?.[0] || navigator.language || void 0;
10
4
  }
11
5
 
12
6
  export { detectBrowserLocale };
@@ -1,16 +1,9 @@
1
- /**
2
- * Gets the locale value from the browser cookie.
3
- *
4
- * This function relies on `document.cookie`.
5
- */
6
1
  function getLocaleFromCookie(cookieName) {
7
- if (typeof document === "undefined")
8
- return undefined;
9
- const cookies = document.cookie.split(";").map((c) => c.trim());
10
- const entry = cookies.find((c) => c.startsWith(`${cookieName}=`));
11
- if (!entry)
12
- return undefined;
13
- return decodeURIComponent(entry.slice(cookieName.length + 1));
2
+ if (typeof document === "undefined") return void 0;
3
+ const cookies = document.cookie.split(";").map((c) => c.trim());
4
+ const entry = cookies.find((c) => c.startsWith(`${cookieName}=`));
5
+ if (!entry) return void 0;
6
+ return decodeURIComponent(entry.slice(cookieName.length + 1));
14
7
  }
15
8
 
16
9
  export { getLocaleFromCookie };
@@ -1,13 +1,13 @@
1
- // Default cookie options
2
1
  const DEFAULT_COOKIE_OPTIONS = {
3
- persist: true,
4
- name: "intor.locale",
5
- domain: undefined,
6
- path: "/",
7
- maxAge: 60 * 60 * 24 * 365, // 365 days
8
- httpOnly: false,
9
- secure: process.env["NODE_ENV"] !== "development",
10
- sameSite: "lax",
2
+ persist: true,
3
+ name: "intor.locale",
4
+ domain: void 0,
5
+ path: "/",
6
+ maxAge: 60 * 60 * 24 * 365,
7
+ // 365 days
8
+ httpOnly: false,
9
+ secure: process.env["NODE_ENV"] !== "development",
10
+ sameSite: "lax"
11
11
  };
12
12
 
13
13
  export { DEFAULT_COOKIE_OPTIONS };
@@ -1,18 +1,17 @@
1
- // Default routing options
2
1
  const DEFAULT_ROUTING_OPTIONS = {
3
- basePath: "/",
4
- localePrefix: "none",
5
- inbound: {
6
- localeSources: ["path", "query", "cookie", "detected"],
7
- queryKey: "locale",
8
- firstVisit: { localeSource: "browser", persist: true, redirect: true },
9
- },
10
- outbound: {
11
- localeCarrier: "path",
12
- queryKey: "locale",
13
- host: { map: {} },
14
- forceFullReload: false,
15
- },
2
+ basePath: "/",
3
+ localePrefix: "none",
4
+ inbound: {
5
+ localeSources: ["path", "query", "cookie", "detected"],
6
+ queryKey: "locale",
7
+ firstVisit: { localeSource: "browser", persist: true, redirect: true }
8
+ },
9
+ outbound: {
10
+ localeCarrier: "path",
11
+ queryKey: "locale",
12
+ host: { map: {} },
13
+ forceFullReload: false
14
+ }
16
15
  };
17
16
 
18
17
  export { DEFAULT_ROUTING_OPTIONS };
@@ -5,51 +5,35 @@ import { validateDefaultLocale } from './validators/validate-default-locale.js';
5
5
  import { validateId } from './validators/validate-id.js';
6
6
  import { validateSupportedLocales } from './validators/validate-supported-locales.js';
7
7
 
8
- /**
9
- * Defines the canonical Intor configuration.
10
- *
11
- * This is the primary entry point for creating a validated,
12
- * runtime-ready Intor configuration.
13
- *
14
- * It transforms a user-provided raw config into a normalized form by:
15
- * - enforcing required invariants
16
- * - resolving derived options
17
- * - applying stable defaults
18
- *
19
- * This function is pure and side-effect free.
20
- *
21
- * @public
22
- */
23
8
  const defineIntorConfig = (config) => {
24
- // -----------------------------------------------------------------------------
25
- // Validators
26
- // -----------------------------------------------------------------------------
27
- const id = validateId(config.id ?? "default");
28
- const supportedLocales = validateSupportedLocales(id, config.supportedLocales);
29
- const supportedSet = new Set(supportedLocales);
30
- const defaultLocale = validateDefaultLocale(id, config.defaultLocale, supportedSet);
31
- // -----------------------------------------------------------------------------
32
- // Resolvers
33
- // -----------------------------------------------------------------------------
34
- const fallbackLocales = resolveFallbackLocales(config, id, supportedSet);
35
- const cookie = resolveCookieOptions(config.cookie);
36
- const routing = resolveRoutingOptions(config.routing);
37
- return {
38
- id,
39
- ...(config.messages !== undefined ? { messages: config.messages } : {}),
40
- ...(config.loader !== undefined ? { loader: config.loader } : {}),
41
- defaultLocale,
42
- supportedLocales,
43
- fallbackLocales,
44
- ...(config.translator !== undefined
45
- ? { translator: config.translator }
46
- : {}),
47
- cookie,
48
- routing,
49
- logger: { id, ...config.logger },
50
- ...(config.client !== undefined ? { client: config.client } : {}),
51
- ...(config.server !== undefined ? { server: config.server } : {}),
52
- };
9
+ const id = validateId(config.id ?? "default");
10
+ const supportedLocales = validateSupportedLocales(
11
+ id,
12
+ config.supportedLocales
13
+ );
14
+ const supportedSet = new Set(supportedLocales);
15
+ const defaultLocale = validateDefaultLocale(
16
+ id,
17
+ config.defaultLocale,
18
+ supportedSet
19
+ );
20
+ const fallbackLocales = resolveFallbackLocales(config, id, supportedSet);
21
+ const cookie = resolveCookieOptions(config.cookie);
22
+ const routing = resolveRoutingOptions(config.routing);
23
+ return {
24
+ id,
25
+ ...config.messages !== void 0 ? { messages: config.messages } : {},
26
+ ...config.loader !== void 0 ? { loader: config.loader } : {},
27
+ defaultLocale,
28
+ supportedLocales,
29
+ fallbackLocales,
30
+ ...config.translator !== void 0 ? { translator: config.translator } : {},
31
+ cookie,
32
+ routing,
33
+ logger: { id, ...config.logger },
34
+ ...config.client !== void 0 ? { client: config.client } : {},
35
+ ...config.server !== void 0 ? { server: config.server } : {}
36
+ };
53
37
  };
54
38
 
55
39
  export { defineIntorConfig };
@@ -1,10 +1,10 @@
1
1
  import { DEFAULT_COOKIE_OPTIONS } from '../constants/cookie.js';
2
2
 
3
3
  const resolveCookieOptions = (cookie = {}) => {
4
- return {
5
- ...DEFAULT_COOKIE_OPTIONS,
6
- ...cookie,
7
- };
4
+ return {
5
+ ...DEFAULT_COOKIE_OPTIONS,
6
+ ...cookie
7
+ };
8
8
  };
9
9
 
10
10
  export { resolveCookieOptions };
@@ -2,59 +2,42 @@ import { getLogger } from '../../core/logger/get-logger.js';
2
2
  import 'p-limit';
3
3
  import 'intor-translator';
4
4
 
5
- /**
6
- * Resolves fallbackLocales into a runtime-safe mapping.
7
- *
8
- * Invalid entries are ignored and reported via warnings.
9
- */
10
5
  const resolveFallbackLocales = (config, id, supportedSet) => {
11
- const { defaultLocale, fallbackLocales } = config;
12
- // Fast exit: no fallback configuration provided
13
- if (!fallbackLocales || typeof fallbackLocales !== "object") {
14
- return {};
6
+ const { defaultLocale, fallbackLocales } = config;
7
+ if (!fallbackLocales || typeof fallbackLocales !== "object") {
8
+ return {};
9
+ }
10
+ const logger = getLogger({ ...config.logger, id }).child({
11
+ scope: "resolve-fallback-locales"
12
+ });
13
+ const resolvedMap = {};
14
+ const invalidMap = /* @__PURE__ */ new Map();
15
+ for (const [locale, fallbacks] of Object.entries(fallbackLocales)) {
16
+ if (!supportedSet.has(locale) && locale !== defaultLocale) {
17
+ logger.warn(
18
+ `Fallback locale "${locale}" is not listed in supportedLocales.`
19
+ );
20
+ continue;
15
21
  }
16
- const logger = getLogger({ ...config.logger, id }).child({
17
- scope: "resolve-fallback-locales",
18
- });
19
- const resolvedMap = {};
20
- const invalidMap = new Map();
21
- // ---------------------------------------------------------------------------
22
- // Normalize each fallback rule
23
- // ---------------------------------------------------------------------------
24
- for (const [locale, fallbacks] of Object.entries(fallbackLocales)) {
25
- // Guard: fallback rules for unreachable locales are ignored.
26
- if (!supportedSet.has(locale) && locale !== defaultLocale) {
27
- logger.warn(`Fallback locale "${locale}" is not listed in supportedLocales.`);
28
- continue;
29
- }
30
- const fallbackArray = Array.isArray(fallbacks) ? fallbacks : [];
31
- const validFallbacks = [];
32
- const invalidFallbacks = [];
33
- for (const fallback of fallbackArray) {
34
- // A fallback target is considered valid if:
35
- // - It exists in `supportedLocales`
36
- // - It is the literal value "default"
37
- if (fallback === "default" || supportedSet.has(fallback)) {
38
- validFallbacks.push(fallback);
39
- }
40
- else {
41
- invalidFallbacks.push(fallback);
42
- }
43
- }
44
- if (invalidFallbacks.length > 0)
45
- invalidMap.set(locale, invalidFallbacks);
46
- if (validFallbacks.length > 0)
47
- resolvedMap[locale] = validFallbacks;
48
- }
49
- // ---------------------------------------------------------------------------
50
- // Diagnostics: report ignored fallback entries
51
- // ---------------------------------------------------------------------------
52
- for (const [locale, invalids] of invalidMap.entries()) {
53
- logger.warn(`Invalid fallback locales for "${locale}".`, {
54
- invalids: invalids.join(", "),
55
- });
22
+ const fallbackArray = Array.isArray(fallbacks) ? fallbacks : [];
23
+ const validFallbacks = [];
24
+ const invalidFallbacks = [];
25
+ for (const fallback of fallbackArray) {
26
+ if (fallback === "default" || supportedSet.has(fallback)) {
27
+ validFallbacks.push(fallback);
28
+ } else {
29
+ invalidFallbacks.push(fallback);
30
+ }
56
31
  }
57
- return resolvedMap;
32
+ if (invalidFallbacks.length > 0) invalidMap.set(locale, invalidFallbacks);
33
+ if (validFallbacks.length > 0) resolvedMap[locale] = validFallbacks;
34
+ }
35
+ for (const [locale, invalids] of invalidMap.entries()) {
36
+ logger.warn(`Invalid fallback locales for "${locale}".`, {
37
+ invalids: invalids.join(", ")
38
+ });
39
+ }
40
+ return resolvedMap;
58
41
  };
59
42
 
60
43
  export { resolveFallbackLocales };
@@ -6,76 +6,47 @@ import 'intor-translator';
6
6
  import { DEFAULT_ROUTING_OPTIONS } from '../constants/routing.js';
7
7
  import '../constants/cookie.js';
8
8
 
9
- /**
10
- * Resolves routing configuration into a fully normalized form.
11
- *
12
- * - Flat shortcuts are projected into structured options.
13
- * - Structured options override projected values.
14
- * - Defaults are applied last.
15
- */
16
9
  function resolveRoutingOptions(raw) {
17
- if (!raw) {
18
- return enforceRoutingInvariants(DEFAULT_ROUTING_OPTIONS);
19
- }
20
- const projectedFromFlat = projectFlatToStructured(raw);
21
- const structuredOverrides = stripFlatShortcuts(raw);
22
- const defined = deepMerge(projectedFromFlat, structuredOverrides);
23
- const merged = deepMerge(DEFAULT_ROUTING_OPTIONS, defined);
24
- return enforceRoutingInvariants(merged);
10
+ if (!raw) {
11
+ return enforceRoutingInvariants(DEFAULT_ROUTING_OPTIONS);
12
+ }
13
+ const projectedFromFlat = projectFlatToStructured(raw);
14
+ const structuredOverrides = stripFlatShortcuts(raw);
15
+ const defined = deepMerge(projectedFromFlat, structuredOverrides);
16
+ const merged = deepMerge(DEFAULT_ROUTING_OPTIONS, defined);
17
+ return enforceRoutingInvariants(merged);
25
18
  }
26
- /**
27
- * Enforces runtime invariants for routing configuration.
28
- *
29
- * Invariants:
30
- * - basePath is normalized
31
- * - basePath always starts with "/"
32
- * - root basePath is represented as "/"
33
- */
34
19
  function enforceRoutingInvariants(routing) {
35
- const normalizedBase = routing.basePath && routing.basePath !== "/"
36
- ? normalizePathname(routing.basePath)
37
- : "/";
38
- return { ...routing, basePath: normalizedBase };
20
+ const normalizedBase = routing.basePath && routing.basePath !== "/" ? normalizePathname(routing.basePath) : "/";
21
+ return { ...routing, basePath: normalizedBase };
39
22
  }
40
- /** Assigns a value to the target only if it is explicitly defined. */
41
23
  function assignIfDefined(target, key, value) {
42
- if (value !== undefined)
43
- target[key] = value;
24
+ if (value !== void 0) target[key] = value;
44
25
  }
45
- /** Projects flat routing shortcuts into structured options. */
46
26
  function projectFlatToStructured(flat) {
47
- const structured = {};
48
- assignIfDefined(structured, "basePath", flat.basePath);
49
- assignIfDefined(structured, "localePrefix", flat.localePrefix);
50
- // inbound
51
- const inbound = {};
52
- assignIfDefined(inbound, "localeSources", flat.localeSources);
53
- assignIfDefined(inbound, "queryKey", flat.queryKey);
54
- assignIfDefined(inbound, "firstVisit", flat.firstVisit);
55
- if (Object.keys(inbound).length > 0)
56
- structured.inbound = inbound;
57
- // outbound
58
- const outbound = {};
59
- assignIfDefined(outbound, "localeCarrier", flat.localeCarrier);
60
- assignIfDefined(outbound, "queryKey", flat.queryKey);
61
- assignIfDefined(outbound, "host", flat.host);
62
- assignIfDefined(outbound, "forceFullReload", flat.forceFullReload);
63
- if (Object.keys(outbound).length > 0)
64
- structured.outbound = outbound;
65
- return structured;
27
+ const structured = {};
28
+ assignIfDefined(structured, "basePath", flat.basePath);
29
+ assignIfDefined(structured, "localePrefix", flat.localePrefix);
30
+ const inbound = {};
31
+ assignIfDefined(inbound, "localeSources", flat.localeSources);
32
+ assignIfDefined(inbound, "queryKey", flat.queryKey);
33
+ assignIfDefined(inbound, "firstVisit", flat.firstVisit);
34
+ if (Object.keys(inbound).length > 0) structured.inbound = inbound;
35
+ const outbound = {};
36
+ assignIfDefined(outbound, "localeCarrier", flat.localeCarrier);
37
+ assignIfDefined(outbound, "queryKey", flat.queryKey);
38
+ assignIfDefined(outbound, "host", flat.host);
39
+ assignIfDefined(outbound, "forceFullReload", flat.forceFullReload);
40
+ if (Object.keys(outbound).length > 0) structured.outbound = outbound;
41
+ return structured;
66
42
  }
67
- /** Removes flat shortcuts, preserving structured overrides only. */
68
43
  function stripFlatShortcuts(raw) {
69
- const structured = {};
70
- if ("basePath" in raw)
71
- structured.basePath = raw.basePath;
72
- if ("localePrefix" in raw)
73
- structured.localePrefix = raw.localePrefix;
74
- if ("inbound" in raw)
75
- structured.inbound = raw.inbound;
76
- if ("outbound" in raw)
77
- structured.outbound = raw.outbound;
78
- return structured;
44
+ const structured = {};
45
+ if ("basePath" in raw) structured.basePath = raw.basePath;
46
+ if ("localePrefix" in raw) structured.localePrefix = raw.localePrefix;
47
+ if ("inbound" in raw) structured.inbound = raw.inbound;
48
+ if ("outbound" in raw) structured.outbound = raw.outbound;
49
+ return structured;
79
50
  }
80
51
 
81
52
  export { resolveRoutingOptions };
@@ -3,20 +3,15 @@ import 'logry';
3
3
  import 'p-limit';
4
4
  import 'intor-translator';
5
5
 
6
- /**
7
- * Validates that the configured defaultLocale is supported.
8
- *
9
- * Fails fast if `defaultLocale` is not included in `supportedLocales`.
10
- */
11
6
  const validateDefaultLocale = (id, defaultLocale, supportedSet) => {
12
- if (!supportedSet.has(defaultLocale)) {
13
- throw new IntorError({
14
- id,
15
- code: INTOR_ERROR_CODE.CONFIG_UNSUPPORTED_DEFAULT_LOCALE,
16
- message: `"defaultLocale" must be included in "supportedLocales".`,
17
- });
18
- }
19
- return defaultLocale;
7
+ if (!supportedSet.has(defaultLocale)) {
8
+ throw new IntorError({
9
+ id,
10
+ code: INTOR_ERROR_CODE.CONFIG_UNSUPPORTED_DEFAULT_LOCALE,
11
+ message: `"defaultLocale" must be included in "supportedLocales".`
12
+ });
13
+ }
14
+ return defaultLocale;
20
15
  };
21
16
 
22
17
  export { validateDefaultLocale };
@@ -3,20 +3,15 @@ import 'logry';
3
3
  import 'p-limit';
4
4
  import 'intor-translator';
5
5
 
6
- /**
7
- * Validates that the given id is a non-empty string.
8
- *
9
- * Fails fast if the id is empty or whitespace-only.
10
- */
11
6
  const validateId = (id) => {
12
- if (id.trim() === "") {
13
- throw new IntorError({
14
- id,
15
- code: INTOR_ERROR_CODE.CONFIG_INVALID_ID,
16
- message: `"id" must be a non-empty string.`,
17
- });
18
- }
19
- return id;
7
+ if (id.trim() === "") {
8
+ throw new IntorError({
9
+ id,
10
+ code: INTOR_ERROR_CODE.CONFIG_INVALID_ID,
11
+ message: `"id" must be a non-empty string.`
12
+ });
13
+ }
14
+ return id;
20
15
  };
21
16
 
22
17
  export { validateId };
@@ -3,20 +3,15 @@ import 'logry';
3
3
  import 'p-limit';
4
4
  import 'intor-translator';
5
5
 
6
- /**
7
- * Validates that supportedLocales is provided and non-empty.
8
- *
9
- * Fails fast when missing.
10
- */
11
6
  const validateSupportedLocales = (id, supportedLocales) => {
12
- if (!supportedLocales || supportedLocales.length === 0) {
13
- throw new IntorError({
14
- id,
15
- code: INTOR_ERROR_CODE.CONFIG_MISSING_SUPPORTED_LOCALES,
16
- message: `"supportedLocales" must be specified.`,
17
- });
18
- }
19
- return supportedLocales;
7
+ if (!supportedLocales || supportedLocales.length === 0) {
8
+ throw new IntorError({
9
+ id,
10
+ code: INTOR_ERROR_CODE.CONFIG_MISSING_SUPPORTED_LOCALES,
11
+ message: `"supportedLocales" must be specified.`
12
+ });
13
+ }
14
+ return supportedLocales;
20
15
  };
21
16
 
22
17
  export { validateSupportedLocales };
@@ -1,4 +1,3 @@
1
- // Default locale placeholder
2
1
  const LOCALE_PLACEHOLDER = "{locale}";
3
2
 
4
3
  export { LOCALE_PLACEHOLDER };
@@ -1,35 +1,20 @@
1
- /**
2
- * Framework-level error used by Intor.
3
- *
4
- * Extends the native Error with optional structured metadata.
5
- *
6
- * @public
7
- */
8
1
  class IntorError extends Error {
9
- code;
10
- id;
11
- constructor({ message, code, id }) {
12
- const fullMessage = id ? `[${id}] ${message}` : message;
13
- super(fullMessage);
14
- this.name = "IntorError";
15
- if (id)
16
- this.id = id;
17
- if (code)
18
- this.code = code;
19
- Object.setPrototypeOf(this, new.target.prototype); // Fix prototype
20
- if (Error.captureStackTrace)
21
- Error.captureStackTrace(this, IntorError);
22
- }
2
+ code;
3
+ id;
4
+ constructor({ message, code, id }) {
5
+ const fullMessage = id ? `[${id}] ${message}` : message;
6
+ super(fullMessage);
7
+ this.name = "IntorError";
8
+ if (id) this.id = id;
9
+ if (code) this.code = code;
10
+ Object.setPrototypeOf(this, new.target.prototype);
11
+ if (Error.captureStackTrace) Error.captureStackTrace(this, IntorError);
12
+ }
23
13
  }
24
- /**
25
- * Built-in error codes used by Intor.
26
- *
27
- * @public
28
- */
29
14
  const INTOR_ERROR_CODE = {
30
- CONFIG_INVALID_ID: "INTOR_CONFIG_INVALID_ID",
31
- CONFIG_MISSING_SUPPORTED_LOCALES: "INTOR_CONFIG_MISSING_SUPPORTED_LOCALES",
32
- CONFIG_UNSUPPORTED_DEFAULT_LOCALE: "INTOR_CONFIG_UNSUPPORTED_DEFAULT_LOCALE",
15
+ CONFIG_INVALID_ID: "INTOR_CONFIG_INVALID_ID",
16
+ CONFIG_MISSING_SUPPORTED_LOCALES: "INTOR_CONFIG_MISSING_SUPPORTED_LOCALES",
17
+ CONFIG_UNSUPPORTED_DEFAULT_LOCALE: "INTOR_CONFIG_UNSUPPORTED_DEFAULT_LOCALE"
33
18
  };
34
19
 
35
20
  export { INTOR_ERROR_CODE, IntorError };
@@ -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 };