use-intl 2.17.0 → 2.17.2-alpha.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 (490) hide show
  1. package/dist/core/AbstractIntlMessages.d.mts +10 -0
  2. package/dist/core/AbstractIntlMessages.d.ts +10 -9
  3. package/dist/core/AbstractIntlMessages.js +2 -0
  4. package/dist/core/AbstractIntlMessages.js.map +1 -0
  5. package/dist/core/AbstractIntlMessages.mjs +1 -0
  6. package/dist/core/AbstractIntlMessages.mjs.map +1 -0
  7. package/dist/core/DateTimeFormatOptions.d.mts +75 -0
  8. package/dist/core/DateTimeFormatOptions.d.ts +75 -73
  9. package/dist/core/DateTimeFormatOptions.js +2 -0
  10. package/dist/core/DateTimeFormatOptions.js.map +1 -0
  11. package/dist/core/DateTimeFormatOptions.mjs +1 -0
  12. package/dist/core/DateTimeFormatOptions.mjs.map +1 -0
  13. package/dist/core/Formats.d.mts +11 -0
  14. package/dist/core/Formats.d.ts +11 -8
  15. package/dist/core/Formats.js +2 -0
  16. package/dist/core/Formats.js.map +1 -0
  17. package/dist/core/Formats.mjs +1 -0
  18. package/dist/core/Formats.mjs.map +1 -0
  19. package/dist/core/IntlConfig.d.mts +60 -0
  20. package/dist/core/IntlConfig.d.ts +60 -54
  21. package/dist/core/IntlConfig.js +2 -0
  22. package/dist/core/IntlConfig.js.map +1 -0
  23. package/dist/core/IntlConfig.mjs +1 -0
  24. package/dist/core/IntlConfig.mjs.map +1 -0
  25. package/dist/core/IntlError.d.mts +15 -0
  26. package/dist/core/IntlError.d.ts +15 -13
  27. package/dist/core/IntlError.js +2 -0
  28. package/dist/core/IntlError.js.map +1 -0
  29. package/dist/core/IntlError.mjs +2 -0
  30. package/dist/core/IntlError.mjs.map +1 -0
  31. package/dist/core/NumberFormatOptions.d.mts +2 -0
  32. package/dist/core/NumberFormatOptions.d.ts +2 -2
  33. package/dist/core/NumberFormatOptions.js +2 -0
  34. package/dist/core/NumberFormatOptions.js.map +1 -0
  35. package/dist/core/NumberFormatOptions.mjs +2 -0
  36. package/dist/core/NumberFormatOptions.mjs.map +1 -0
  37. package/dist/core/TimeZone.d.mts +3 -0
  38. package/dist/core/TimeZone.d.ts +3 -2
  39. package/dist/core/TimeZone.js +2 -0
  40. package/dist/core/TimeZone.js.map +1 -0
  41. package/dist/core/TimeZone.mjs +1 -0
  42. package/dist/core/TimeZone.mjs.map +1 -0
  43. package/dist/core/TranslationValues.d.mts +7 -0
  44. package/dist/core/TranslationValues.d.ts +7 -5
  45. package/dist/core/TranslationValues.js +2 -0
  46. package/dist/core/TranslationValues.js.map +1 -0
  47. package/dist/core/TranslationValues.mjs +1 -0
  48. package/dist/core/TranslationValues.mjs.map +1 -0
  49. package/dist/core/convertFormatsToIntlMessageFormat.d.mts +16 -0
  50. package/dist/core/convertFormatsToIntlMessageFormat.d.ts +16 -11
  51. package/dist/core/convertFormatsToIntlMessageFormat.js +2 -0
  52. package/dist/core/convertFormatsToIntlMessageFormat.js.map +1 -0
  53. package/dist/core/convertFormatsToIntlMessageFormat.mjs +2 -0
  54. package/dist/core/convertFormatsToIntlMessageFormat.mjs.map +1 -0
  55. package/dist/core/createBaseTranslator.d.mts +32 -0
  56. package/dist/core/createBaseTranslator.d.ts +32 -26
  57. package/dist/core/createBaseTranslator.js +2 -0
  58. package/dist/core/createBaseTranslator.js.map +1 -0
  59. package/dist/core/createBaseTranslator.mjs +2 -0
  60. package/dist/core/createBaseTranslator.mjs.map +1 -0
  61. package/dist/core/createFormatter.d.mts +21 -0
  62. package/dist/core/createFormatter.d.ts +21 -19
  63. package/dist/core/createFormatter.js +2 -0
  64. package/dist/core/createFormatter.js.map +1 -0
  65. package/dist/core/createFormatter.mjs +2 -0
  66. package/dist/core/createFormatter.mjs.map +1 -0
  67. package/dist/core/createIntl.d.mts +15 -0
  68. package/dist/core/createIntl.d.ts +15 -7
  69. package/dist/core/createIntl.js +2 -0
  70. package/dist/core/createIntl.js.map +1 -0
  71. package/dist/core/createIntl.mjs +2 -0
  72. package/dist/core/createIntl.mjs.map +1 -0
  73. package/dist/core/createTranslator.d.mts +57 -0
  74. package/dist/core/createTranslator.d.ts +57 -48
  75. package/dist/core/createTranslator.js +2 -0
  76. package/dist/core/createTranslator.js.map +1 -0
  77. package/dist/core/createTranslator.mjs +2 -0
  78. package/dist/core/createTranslator.mjs.map +1 -0
  79. package/dist/core/createTranslatorImpl.d.mts +25 -0
  80. package/dist/core/createTranslatorImpl.d.ts +25 -14
  81. package/dist/core/createTranslatorImpl.js +2 -0
  82. package/dist/core/createTranslatorImpl.js.map +1 -0
  83. package/dist/core/createTranslatorImpl.mjs +2 -0
  84. package/dist/core/createTranslatorImpl.mjs.map +1 -0
  85. package/dist/core/defaults.d.mts +14 -0
  86. package/dist/core/defaults.d.ts +14 -11
  87. package/dist/core/defaults.js +2 -0
  88. package/dist/core/defaults.js.map +1 -0
  89. package/dist/core/defaults.mjs +2 -0
  90. package/dist/core/defaults.mjs.map +1 -0
  91. package/dist/core/index.d.mts +17 -0
  92. package/dist/core/index.d.ts +17 -9
  93. package/dist/core/index.js +2 -0
  94. package/dist/core/index.js.map +1 -0
  95. package/dist/core/index.mjs +2 -0
  96. package/dist/core/index.mjs.map +1 -0
  97. package/dist/core/resolveNamespace.d.mts +7 -0
  98. package/dist/core/resolveNamespace.d.ts +7 -5
  99. package/dist/core/resolveNamespace.js +2 -0
  100. package/dist/core/resolveNamespace.js.map +1 -0
  101. package/dist/core/resolveNamespace.mjs +2 -0
  102. package/dist/core/resolveNamespace.mjs.map +1 -0
  103. package/dist/core/utils/MessageKeys.d.mts +7 -0
  104. package/dist/core/utils/MessageKeys.d.ts +7 -5
  105. package/dist/core/utils/MessageKeys.js +2 -0
  106. package/dist/core/utils/MessageKeys.js.map +1 -0
  107. package/dist/core/utils/MessageKeys.mjs +1 -0
  108. package/dist/core/utils/MessageKeys.mjs.map +1 -0
  109. package/dist/core/utils/NamespaceKeys.d.mts +7 -0
  110. package/dist/core/utils/NamespaceKeys.d.ts +7 -5
  111. package/dist/core/utils/NamespaceKeys.js +2 -0
  112. package/dist/core/utils/NamespaceKeys.js.map +1 -0
  113. package/dist/core/utils/NamespaceKeys.mjs +1 -0
  114. package/dist/core/utils/NamespaceKeys.mjs.map +1 -0
  115. package/dist/core/utils/NestedKeyOf.d.mts +5 -0
  116. package/dist/core/utils/NestedKeyOf.d.ts +5 -4
  117. package/dist/core/utils/NestedKeyOf.js +2 -0
  118. package/dist/core/utils/NestedKeyOf.js.map +1 -0
  119. package/dist/core/utils/NestedKeyOf.mjs +1 -0
  120. package/dist/core/utils/NestedKeyOf.mjs.map +1 -0
  121. package/dist/core/utils/NestedValueOf.d.mts +3 -0
  122. package/dist/core/utils/NestedValueOf.d.ts +3 -2
  123. package/dist/core/utils/NestedValueOf.js +2 -0
  124. package/dist/core/utils/NestedValueOf.js.map +1 -0
  125. package/dist/core/utils/NestedValueOf.mjs +1 -0
  126. package/dist/core/utils/NestedValueOf.mjs.map +1 -0
  127. package/dist/core/validateMessages.d.mts +6 -0
  128. package/dist/core/validateMessages.d.ts +6 -3
  129. package/dist/core/validateMessages.js +34 -0
  130. package/dist/core/validateMessages.js.map +1 -0
  131. package/dist/core/validateMessages.mjs +34 -0
  132. package/dist/core/validateMessages.mjs.map +1 -0
  133. package/dist/index.d.mts +25 -0
  134. package/dist/index.d.ts +25 -2
  135. package/dist/index.js +2 -8
  136. package/dist/index.js.map +1 -0
  137. package/dist/index.mjs +2 -0
  138. package/dist/index.mjs.map +1 -0
  139. package/dist/react/IntlContext.d.mts +13 -0
  140. package/dist/react/IntlContext.d.ts +13 -4
  141. package/dist/react/IntlContext.js +2 -0
  142. package/dist/react/IntlContext.js.map +1 -0
  143. package/dist/react/IntlContext.mjs +2 -0
  144. package/dist/react/IntlContext.mjs.map +1 -0
  145. package/dist/react/IntlProvider.d.mts +16 -0
  146. package/dist/react/IntlProvider.d.ts +16 -7
  147. package/dist/react/IntlProvider.js +2 -0
  148. package/dist/react/IntlProvider.js.map +1 -0
  149. package/dist/react/IntlProvider.mjs +2 -0
  150. package/dist/react/IntlProvider.mjs.map +1 -0
  151. package/dist/react/getInitializedConfig.d.mts +24 -0
  152. package/dist/react/getInitializedConfig.d.ts +24 -13
  153. package/dist/react/getInitializedConfig.js +2 -0
  154. package/dist/react/getInitializedConfig.js.map +1 -0
  155. package/dist/react/getInitializedConfig.mjs +2 -0
  156. package/dist/react/getInitializedConfig.mjs.map +1 -0
  157. package/dist/react/index.d.mts +21 -0
  158. package/dist/react/index.d.ts +21 -8
  159. package/dist/react/index.js +2 -0
  160. package/dist/react/index.js.map +1 -0
  161. package/dist/react/index.mjs +2 -0
  162. package/dist/react/index.mjs.map +1 -0
  163. package/dist/react/useFormatter.d.mts +12 -0
  164. package/dist/react/useFormatter.d.ts +12 -6
  165. package/dist/react/useFormatter.js +2 -0
  166. package/dist/react/useFormatter.js.map +1 -0
  167. package/dist/react/useFormatter.mjs +2 -0
  168. package/dist/react/useFormatter.mjs.map +1 -0
  169. package/dist/react/useIntl.d.mts +12 -0
  170. package/dist/react/useIntl.d.ts +12 -6
  171. package/dist/react/useIntl.js +2 -0
  172. package/dist/react/useIntl.js.map +1 -0
  173. package/dist/react/useIntl.mjs +2 -0
  174. package/dist/react/useIntl.mjs.map +1 -0
  175. package/dist/react/useIntlContext.d.mts +13 -0
  176. package/dist/react/useIntlContext.d.ts +13 -1
  177. package/dist/react/useIntlContext.js +2 -0
  178. package/dist/react/useIntlContext.js.map +1 -0
  179. package/dist/react/useIntlContext.mjs +2 -0
  180. package/dist/react/useIntlContext.mjs.map +1 -0
  181. package/dist/react/useLocale.d.mts +3 -0
  182. package/dist/react/useLocale.d.ts +3 -1
  183. package/dist/react/useLocale.js +2 -0
  184. package/dist/react/useLocale.js.map +1 -0
  185. package/dist/react/useLocale.mjs +2 -0
  186. package/dist/react/useLocale.mjs.map +1 -0
  187. package/dist/react/useMessages.d.mts +5 -0
  188. package/dist/react/useMessages.d.ts +5 -1
  189. package/dist/react/useMessages.js +2 -0
  190. package/dist/react/useMessages.js.map +1 -0
  191. package/dist/react/useMessages.mjs +2 -0
  192. package/dist/react/useMessages.mjs.map +1 -0
  193. package/dist/react/{use-intl.esm4.js → useNow.d.mts} +21 -42
  194. package/dist/react/useNow.d.ts +24 -23
  195. package/dist/react/useNow.js +2 -0
  196. package/dist/react/useNow.js.map +1 -0
  197. package/dist/react/useNow.mjs +2 -0
  198. package/dist/react/useNow.mjs.map +1 -0
  199. package/dist/react/useTimeZone.d.mts +5 -0
  200. package/dist/react/useTimeZone.d.ts +5 -1
  201. package/dist/react/useTimeZone.js +2 -0
  202. package/dist/react/useTimeZone.js.map +1 -0
  203. package/dist/react/useTimeZone.mjs +2 -0
  204. package/dist/react/useTimeZone.mjs.map +1 -0
  205. package/dist/react/useTranslations.d.mts +50 -0
  206. package/dist/react/useTranslations.d.ts +50 -44
  207. package/dist/react/useTranslations.js +2 -0
  208. package/dist/react/useTranslations.js.map +1 -0
  209. package/dist/react/useTranslations.mjs +2 -0
  210. package/dist/react/useTranslations.mjs.map +1 -0
  211. package/dist/react/useTranslationsImpl.d.mts +16 -0
  212. package/dist/react/useTranslationsImpl.d.ts +16 -8
  213. package/dist/react/useTranslationsImpl.js +2 -0
  214. package/dist/react/useTranslationsImpl.js.map +1 -0
  215. package/dist/react/useTranslationsImpl.mjs +2 -0
  216. package/dist/react/useTranslationsImpl.mjs.map +1 -0
  217. package/dist/src/core/AbstractIntlMessages.d.mts +10 -0
  218. package/dist/src/core/AbstractIntlMessages.d.ts +2 -1
  219. package/dist/src/core/AbstractIntlMessages.js +1 -1
  220. package/dist/src/core/AbstractIntlMessages.js.map +1 -1
  221. package/dist/src/core/AbstractIntlMessages.mjs +1 -0
  222. package/dist/src/core/AbstractIntlMessages.mjs.map +1 -0
  223. package/dist/src/core/DateTimeFormatOptions.d.mts +75 -0
  224. package/dist/src/core/DateTimeFormatOptions.d.ts +4 -2
  225. package/dist/src/core/DateTimeFormatOptions.js +1 -2
  226. package/dist/src/core/DateTimeFormatOptions.js.map +1 -1
  227. package/dist/src/core/DateTimeFormatOptions.mjs +1 -0
  228. package/dist/src/core/DateTimeFormatOptions.mjs.map +1 -0
  229. package/dist/src/core/Formats.d.mts +11 -0
  230. package/dist/src/core/Formats.d.ts +6 -3
  231. package/dist/src/core/Formats.js +1 -1
  232. package/dist/src/core/Formats.js.map +1 -1
  233. package/dist/src/core/Formats.mjs +1 -0
  234. package/dist/src/core/Formats.mjs.map +1 -0
  235. package/dist/src/core/IntlConfig.d.mts +60 -0
  236. package/dist/src/core/IntlConfig.d.ts +12 -6
  237. package/dist/src/core/IntlConfig.js +1 -1
  238. package/dist/src/core/IntlConfig.js.map +1 -1
  239. package/dist/src/core/IntlConfig.mjs +1 -0
  240. package/dist/src/core/IntlConfig.mjs.map +1 -0
  241. package/dist/src/core/IntlError.d.mts +15 -0
  242. package/dist/src/core/IntlError.d.ts +4 -2
  243. package/dist/src/core/IntlError.js +1 -22
  244. package/dist/src/core/IntlError.js.map +1 -1
  245. package/dist/src/core/IntlError.mjs +2 -0
  246. package/dist/src/core/IntlError.mjs.map +1 -0
  247. package/dist/src/core/NumberFormatOptions.d.mts +2 -0
  248. package/dist/src/core/NumberFormatOptions.d.ts +2 -2
  249. package/dist/src/core/NumberFormatOptions.js +1 -1
  250. package/dist/src/core/NumberFormatOptions.js.map +1 -1
  251. package/dist/src/core/NumberFormatOptions.mjs +2 -0
  252. package/dist/src/core/NumberFormatOptions.mjs.map +1 -0
  253. package/dist/src/core/TimeZone.d.mts +3 -0
  254. package/dist/src/core/TimeZone.d.ts +2 -1
  255. package/dist/src/core/TimeZone.js +1 -1
  256. package/dist/src/core/TimeZone.js.map +1 -1
  257. package/dist/src/core/TimeZone.mjs +1 -0
  258. package/dist/src/core/TimeZone.mjs.map +1 -0
  259. package/dist/src/core/TranslationValues.d.mts +7 -0
  260. package/dist/src/core/TranslationValues.d.ts +5 -3
  261. package/dist/src/core/TranslationValues.js +1 -1
  262. package/dist/src/core/TranslationValues.js.map +1 -1
  263. package/dist/src/core/TranslationValues.mjs +1 -0
  264. package/dist/src/core/TranslationValues.mjs.map +1 -0
  265. package/dist/src/core/convertFormatsToIntlMessageFormat.d.mts +16 -0
  266. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +9 -4
  267. package/dist/src/core/convertFormatsToIntlMessageFormat.js +1 -30
  268. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +1 -1
  269. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs +2 -0
  270. package/dist/src/core/convertFormatsToIntlMessageFormat.mjs.map +1 -0
  271. package/dist/src/core/createBaseTranslator.d.mts +32 -0
  272. package/dist/src/core/createBaseTranslator.d.ts +17 -11
  273. package/dist/src/core/createBaseTranslator.js +1 -205
  274. package/dist/src/core/createBaseTranslator.js.map +1 -1
  275. package/dist/src/core/createBaseTranslator.mjs +2 -0
  276. package/dist/src/core/createBaseTranslator.mjs.map +1 -0
  277. package/dist/src/core/createFormatter.d.mts +21 -0
  278. package/dist/src/core/createFormatter.d.ts +9 -7
  279. package/dist/src/core/createFormatter.js +1 -128
  280. package/dist/src/core/createFormatter.js.map +1 -1
  281. package/dist/src/core/createFormatter.mjs +2 -0
  282. package/dist/src/core/createFormatter.mjs.map +1 -0
  283. package/dist/src/core/createIntl.d.mts +15 -0
  284. package/dist/src/core/createIntl.d.ts +12 -4
  285. package/dist/src/core/createIntl.js +1 -10
  286. package/dist/src/core/createIntl.js.map +1 -1
  287. package/dist/src/core/createIntl.mjs +2 -0
  288. package/dist/src/core/createIntl.mjs.map +1 -0
  289. package/dist/src/core/createTranslator.d.mts +57 -0
  290. package/dist/src/core/createTranslator.d.ts +18 -9
  291. package/dist/src/core/createTranslator.js +1 -23
  292. package/dist/src/core/createTranslator.js.map +1 -1
  293. package/dist/src/core/createTranslator.mjs +2 -0
  294. package/dist/src/core/createTranslator.mjs.map +1 -0
  295. package/dist/src/core/createTranslatorImpl.d.mts +25 -0
  296. package/dist/src/core/createTranslatorImpl.d.ts +20 -9
  297. package/dist/src/core/createTranslatorImpl.js +1 -42
  298. package/dist/src/core/createTranslatorImpl.js.map +1 -1
  299. package/dist/src/core/createTranslatorImpl.mjs +2 -0
  300. package/dist/src/core/createTranslatorImpl.mjs.map +1 -0
  301. package/dist/src/core/defaults.d.mts +14 -0
  302. package/dist/src/core/defaults.d.ts +6 -3
  303. package/dist/src/core/defaults.js +1 -10
  304. package/dist/src/core/defaults.js.map +1 -1
  305. package/dist/src/core/defaults.mjs +2 -0
  306. package/dist/src/core/defaults.mjs.map +1 -0
  307. package/dist/src/core/index.d.mts +17 -0
  308. package/dist/src/core/index.d.ts +17 -9
  309. package/dist/src/core/index.js +1 -5
  310. package/dist/src/core/index.js.map +1 -1
  311. package/dist/src/core/index.mjs +2 -0
  312. package/dist/src/core/index.mjs.map +1 -0
  313. package/dist/src/core/resolveNamespace.d.mts +7 -0
  314. package/dist/src/core/resolveNamespace.d.ts +3 -1
  315. package/dist/src/core/resolveNamespace.js +1 -9
  316. package/dist/src/core/resolveNamespace.js.map +1 -1
  317. package/dist/src/core/resolveNamespace.mjs +2 -0
  318. package/dist/src/core/resolveNamespace.mjs.map +1 -0
  319. package/dist/src/core/utils/MessageKeys.d.mts +7 -0
  320. package/dist/src/core/utils/MessageKeys.d.ts +4 -2
  321. package/dist/src/core/utils/MessageKeys.js +1 -1
  322. package/dist/src/core/utils/MessageKeys.js.map +1 -1
  323. package/dist/src/core/utils/MessageKeys.mjs +1 -0
  324. package/dist/src/core/utils/MessageKeys.mjs.map +1 -0
  325. package/dist/src/core/utils/NamespaceKeys.d.mts +7 -0
  326. package/dist/src/core/utils/NamespaceKeys.d.ts +4 -2
  327. package/dist/src/core/utils/NamespaceKeys.js +1 -1
  328. package/dist/src/core/utils/NamespaceKeys.js.map +1 -1
  329. package/dist/src/core/utils/NamespaceKeys.mjs +1 -0
  330. package/dist/src/core/utils/NamespaceKeys.mjs.map +1 -0
  331. package/dist/src/core/utils/NestedKeyOf.d.mts +5 -0
  332. package/dist/src/core/utils/NestedKeyOf.d.ts +2 -1
  333. package/dist/src/core/utils/NestedKeyOf.js +1 -1
  334. package/dist/src/core/utils/NestedKeyOf.js.map +1 -1
  335. package/dist/src/core/utils/NestedKeyOf.mjs +1 -0
  336. package/dist/src/core/utils/NestedKeyOf.mjs.map +1 -0
  337. package/dist/src/core/utils/NestedValueOf.d.mts +3 -0
  338. package/dist/src/core/utils/NestedValueOf.d.ts +2 -1
  339. package/dist/src/core/utils/NestedValueOf.js +1 -1
  340. package/dist/src/core/utils/NestedValueOf.js.map +1 -1
  341. package/dist/src/core/utils/NestedValueOf.mjs +1 -0
  342. package/dist/src/core/utils/NestedValueOf.mjs.map +1 -0
  343. package/dist/src/core/validateMessages.d.mts +6 -0
  344. package/dist/src/core/validateMessages.d.ts +6 -3
  345. package/dist/src/core/validateMessages.js +3 -25
  346. package/dist/src/core/validateMessages.js.map +1 -1
  347. package/dist/src/core/validateMessages.mjs +34 -0
  348. package/dist/src/core/validateMessages.mjs.map +1 -0
  349. package/dist/src/index.d.mts +25 -0
  350. package/dist/src/index.d.ts +25 -2
  351. package/dist/src/index.js +1 -2
  352. package/dist/src/index.js.map +1 -1
  353. package/dist/src/index.mjs +2 -0
  354. package/dist/src/index.mjs.map +1 -0
  355. package/dist/src/react/IntlContext.d.mts +13 -0
  356. package/dist/src/react/IntlContext.d.ts +13 -4
  357. package/dist/src/react/IntlContext.js +1 -3
  358. package/dist/src/react/IntlContext.js.map +1 -1
  359. package/dist/src/react/IntlContext.mjs +2 -0
  360. package/dist/src/react/IntlContext.mjs.map +1 -0
  361. package/dist/src/react/IntlProvider.d.mts +16 -0
  362. package/dist/src/react/IntlProvider.d.ts +12 -3
  363. package/dist/src/react/IntlProvider.js +1 -6
  364. package/dist/src/react/IntlProvider.js.map +1 -1
  365. package/dist/src/react/IntlProvider.mjs +2 -0
  366. package/dist/src/react/IntlProvider.mjs.map +1 -0
  367. package/dist/src/react/getInitializedConfig.d.mts +24 -0
  368. package/dist/src/react/getInitializedConfig.d.ts +16 -5
  369. package/dist/src/react/getInitializedConfig.js +1 -20
  370. package/dist/src/react/getInitializedConfig.js.map +1 -1
  371. package/dist/src/react/getInitializedConfig.mjs +2 -0
  372. package/dist/src/react/getInitializedConfig.mjs.map +1 -0
  373. package/dist/src/react/index.d.mts +21 -0
  374. package/dist/src/react/index.d.ts +21 -8
  375. package/dist/src/react/index.js +1 -9
  376. package/dist/src/react/index.js.map +1 -1
  377. package/dist/src/react/index.mjs +2 -0
  378. package/dist/src/react/index.mjs.map +1 -0
  379. package/dist/src/react/useFormatter.d.mts +12 -0
  380. package/dist/src/react/useFormatter.d.ts +9 -3
  381. package/dist/src/react/useFormatter.js +1 -13
  382. package/dist/src/react/useFormatter.js.map +1 -1
  383. package/dist/src/react/useFormatter.mjs +2 -0
  384. package/dist/src/react/useFormatter.mjs.map +1 -0
  385. package/dist/src/react/useIntl.d.mts +12 -0
  386. package/dist/src/react/useIntl.d.ts +9 -3
  387. package/dist/src/react/useIntl.js +1 -19
  388. package/dist/src/react/useIntl.js.map +1 -1
  389. package/dist/src/react/useIntl.mjs +2 -0
  390. package/dist/src/react/useIntl.mjs.map +1 -0
  391. package/dist/src/react/useIntlContext.d.mts +13 -0
  392. package/dist/src/react/useIntlContext.d.ts +13 -1
  393. package/dist/src/react/useIntlContext.js +1 -11
  394. package/dist/src/react/useIntlContext.js.map +1 -1
  395. package/dist/src/react/useIntlContext.mjs +2 -0
  396. package/dist/src/react/useIntlContext.mjs.map +1 -0
  397. package/dist/src/react/useLocale.d.mts +3 -0
  398. package/dist/src/react/useLocale.d.ts +3 -1
  399. package/dist/src/react/useLocale.js +1 -4
  400. package/dist/src/react/useLocale.js.map +1 -1
  401. package/dist/src/react/useLocale.mjs +2 -0
  402. package/dist/src/react/useLocale.mjs.map +1 -0
  403. package/dist/src/react/useMessages.d.mts +5 -0
  404. package/dist/src/react/useMessages.d.ts +5 -1
  405. package/dist/src/react/useMessages.js +1 -4
  406. package/dist/src/react/useMessages.js.map +1 -1
  407. package/dist/src/react/useMessages.mjs +2 -0
  408. package/dist/src/react/useMessages.mjs.map +1 -0
  409. package/dist/src/react/useNow.d.mts +24 -0
  410. package/dist/src/react/useNow.d.ts +3 -2
  411. package/dist/src/react/useNow.js +1 -39
  412. package/dist/src/react/useNow.js.map +1 -1
  413. package/dist/src/react/useNow.mjs +2 -0
  414. package/dist/src/react/useNow.mjs.map +1 -0
  415. package/dist/src/react/useTimeZone.d.mts +5 -0
  416. package/dist/src/react/useTimeZone.d.ts +5 -1
  417. package/dist/src/react/useTimeZone.js +1 -4
  418. package/dist/src/react/useTimeZone.js.map +1 -1
  419. package/dist/src/react/useTimeZone.mjs +2 -0
  420. package/dist/src/react/useTimeZone.mjs.map +1 -0
  421. package/dist/src/react/useTranslations.d.mts +50 -0
  422. package/dist/src/react/useTranslations.d.ts +13 -7
  423. package/dist/src/react/useTranslations.js +1 -20
  424. package/dist/src/react/useTranslations.js.map +1 -1
  425. package/dist/src/react/useTranslations.mjs +2 -0
  426. package/dist/src/react/useTranslations.mjs.map +1 -0
  427. package/dist/src/react/useTranslationsImpl.d.mts +16 -0
  428. package/dist/src/react/useTranslationsImpl.d.ts +14 -6
  429. package/dist/src/react/useTranslationsImpl.js +1 -34
  430. package/dist/src/react/useTranslationsImpl.js.map +1 -1
  431. package/dist/src/react/useTranslationsImpl.mjs +2 -0
  432. package/dist/src/react/useTranslationsImpl.mjs.map +1 -0
  433. package/package.json +11 -21
  434. package/src/core/index.tsx +5 -5
  435. package/dist/_virtual/use-intl.esm.js +0 -102
  436. package/dist/_virtual/use-intl.esm.js.map +0 -1
  437. package/dist/core/IntlMessages.d.ts +0 -2
  438. package/dist/core/use-intl.esm.js +0 -33
  439. package/dist/core/use-intl.esm.js.map +0 -1
  440. package/dist/core/use-intl.esm10.js +0 -32
  441. package/dist/core/use-intl.esm10.js.map +0 -1
  442. package/dist/core/use-intl.esm2.js +0 -37
  443. package/dist/core/use-intl.esm2.js.map +0 -1
  444. package/dist/core/use-intl.esm3.js +0 -138
  445. package/dist/core/use-intl.esm3.js.map +0 -1
  446. package/dist/core/use-intl.esm4.js +0 -14
  447. package/dist/core/use-intl.esm4.js.map +0 -1
  448. package/dist/core/use-intl.esm5.js +0 -53
  449. package/dist/core/use-intl.esm5.js.map +0 -1
  450. package/dist/core/use-intl.esm6.js +0 -15
  451. package/dist/core/use-intl.esm6.js.map +0 -1
  452. package/dist/core/use-intl.esm7.js +0 -191
  453. package/dist/core/use-intl.esm7.js.map +0 -1
  454. package/dist/core/use-intl.esm8.js +0 -10
  455. package/dist/core/use-intl.esm8.js.map +0 -1
  456. package/dist/core/use-intl.esm9.js +0 -28
  457. package/dist/core/use-intl.esm9.js.map +0 -1
  458. package/dist/react/use-intl.esm.js +0 -16
  459. package/dist/react/use-intl.esm.js.map +0 -1
  460. package/dist/react/use-intl.esm10.js +0 -29
  461. package/dist/react/use-intl.esm10.js.map +0 -1
  462. package/dist/react/use-intl.esm11.js +0 -13
  463. package/dist/react/use-intl.esm11.js.map +0 -1
  464. package/dist/react/use-intl.esm12.js +0 -43
  465. package/dist/react/use-intl.esm12.js.map +0 -1
  466. package/dist/react/use-intl.esm2.js +0 -26
  467. package/dist/react/use-intl.esm2.js.map +0 -1
  468. package/dist/react/use-intl.esm3.js +0 -8
  469. package/dist/react/use-intl.esm3.js.map +0 -1
  470. package/dist/react/use-intl.esm4.js.map +0 -1
  471. package/dist/react/use-intl.esm5.js +0 -8
  472. package/dist/react/use-intl.esm5.js.map +0 -1
  473. package/dist/react/use-intl.esm6.js +0 -8
  474. package/dist/react/use-intl.esm6.js.map +0 -1
  475. package/dist/react/use-intl.esm7.js +0 -24
  476. package/dist/react/use-intl.esm7.js.map +0 -1
  477. package/dist/react/use-intl.esm8.js +0 -30
  478. package/dist/react/use-intl.esm8.js.map +0 -1
  479. package/dist/react/use-intl.esm9.js +0 -6
  480. package/dist/react/use-intl.esm9.js.map +0 -1
  481. package/dist/src/core/IntlMessages.d.ts +0 -2
  482. package/dist/src/core/IntlMessages.js +0 -4
  483. package/dist/src/core/IntlMessages.js.map +0 -1
  484. package/dist/use-intl.cjs.development.js +0 -821
  485. package/dist/use-intl.cjs.development.js.map +0 -1
  486. package/dist/use-intl.cjs.production.min.js +0 -2
  487. package/dist/use-intl.cjs.production.min.js.map +0 -1
  488. package/dist/use-intl.esm.js +0 -13
  489. package/dist/use-intl.esm.js.map +0 -1
  490. package/src/core/IntlMessages.tsx +0 -5
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createFormatter.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n"],"mappings":"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","names":["createFormatter_exports","__export","createFormatter","__toCommonJS","import_IntlError","import_defaults","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","value","unit","formats","locale","globalNow","onError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","IntlError","getFormattedValue","formatter","dateTime","number","relativeTime","date","now","dateDate","nowDate","list"]}
@@ -0,0 +1,2 @@
1
+ import l,{IntlErrorCode as p}from"./IntlError.mjs";import{defaultOnError as M}from"./defaults.mjs";const d=60,g=d*60,u=g*24,F=u*7,O=u*(365/12),h=u*365;function N(n){const i=Math.abs(n);let a,o;return i<d?(o="second",a=Math.round(n)):i<g?(o="minute",a=Math.round(n/d)):i<u?(o="hour",a=Math.round(n/g)):i<F?(o="day",a=Math.round(n/u)):i<O?(o="week",a=Math.round(n/F)):i<h?(o="month",a=Math.round(n/O)):(o="year",a=Math.round(n/h)),{value:a,unit:o}}function v({formats:n,locale:i,now:a,onError:o=M,timeZone:T}){function b(r,e){let t;if(typeof e=="string"){const s=e;if(t=r?.[s],!t){const m=new l(p.MISSING_FORMAT,process.env.NODE_ENV!=="production"?`Format \`${s}\` is not available. You can configure it on the provider or provide custom options.`:void 0);throw (o(m), m)}}else t=e;return t}function c(r,e,t,s){let m;try{m=b(t,e)}catch{return String(r)}try{return s(m)}catch(f){return o(new l(p.FORMATTING_ERROR,f.message)),String(r)}}function D(r,e){return c(r,e,n?.dateTime,t=>(T&&!t?.timeZone&&(t={...t,timeZone:T}),new Intl.DateTimeFormat(i,t).format(r)))}function E(r,e){return c(r,e,n?.number,t=>new Intl.NumberFormat(i,t).format(r))}function R(r,e){try{if(!e)if(a)e=a;else throw new Error(process.env.NODE_ENV!=="production"?"The `now` parameter wasn't provided and there was no global fallback configured on the provider.":void 0);const t=r instanceof Date?r:new Date(r),s=e instanceof Date?e:new Date(e),m=(t.getTime()-s.getTime())/1e3,{unit:f,value:w}=N(m);return new Intl.RelativeTimeFormat(i,{numeric:"auto"}).format(w,f)}catch(t){return o(new l(p.FORMATTING_ERROR,t.message)),String(r)}}function I(r,e){return c(r,e,n?.list,t=>new Intl.ListFormat(i,t).format(r))}return{dateTime:D,number:E,relativeTime:R,list:I}}export{v as default};
2
+ //# sourceMappingURL=createFormatter.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createFormatter.tsx"],"sourcesContent":["import DateTimeFormatOptions from './DateTimeFormatOptions';\nimport Formats from './Formats';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport NumberFormatOptions from './NumberFormatOptions';\nimport TimeZone from './TimeZone';\nimport {defaultOnError} from './defaults';\n\nconst MINUTE = 60;\nconst HOUR = MINUTE * 60;\nconst DAY = HOUR * 24;\nconst WEEK = DAY * 7;\nconst MONTH = DAY * (365 / 12); // Approximation\nconst YEAR = DAY * 365;\n\nfunction getRelativeTimeFormatConfig(seconds: number) {\n const absValue = Math.abs(seconds);\n let value, unit: Intl.RelativeTimeFormatUnit;\n\n // We have to round the resulting values, as `Intl.RelativeTimeFormat`\n // will include fractions like '2.1 hours ago'.\n\n if (absValue < MINUTE) {\n unit = 'second';\n value = Math.round(seconds);\n } else if (absValue < HOUR) {\n unit = 'minute';\n value = Math.round(seconds / MINUTE);\n } else if (absValue < DAY) {\n unit = 'hour';\n value = Math.round(seconds / HOUR);\n } else if (absValue < WEEK) {\n unit = 'day';\n value = Math.round(seconds / DAY);\n } else if (absValue < MONTH) {\n unit = 'week';\n value = Math.round(seconds / WEEK);\n } else if (absValue < YEAR) {\n unit = 'month';\n value = Math.round(seconds / MONTH);\n } else {\n unit = 'year';\n value = Math.round(seconds / YEAR);\n }\n\n return {value, unit};\n}\n\ntype Props = {\n locale: string;\n timeZone?: TimeZone;\n onError?(error: IntlError): void;\n formats?: Partial<Formats>;\n now?: Date;\n};\n\nexport default function createFormatter({\n formats,\n locale,\n now: globalNow,\n onError = defaultOnError,\n timeZone\n}: Props) {\n function resolveFormatOrOptions<Options>(\n typeFormats: Record<string, Options> | undefined,\n formatOrOptions?: string | Options\n ) {\n let options;\n if (typeof formatOrOptions === 'string') {\n const formatName = formatOrOptions;\n options = typeFormats?.[formatName];\n\n if (!options) {\n const error = new IntlError(\n IntlErrorCode.MISSING_FORMAT,\n process.env.NODE_ENV !== 'production'\n ? `Format \\`${formatName}\\` is not available. You can configure it on the provider or provide custom options.`\n : undefined\n );\n onError(error);\n throw error;\n }\n } else {\n options = formatOrOptions;\n }\n\n return options;\n }\n\n function getFormattedValue<Value, Options>(\n value: Value,\n formatOrOptions: string | Options | undefined,\n typeFormats: Record<string, Options> | undefined,\n formatter: (options?: Options) => string\n ) {\n let options;\n try {\n options = resolveFormatOrOptions(typeFormats, formatOrOptions);\n } catch (error) {\n return String(value);\n }\n\n try {\n return formatter(options);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(value);\n }\n }\n\n function dateTime(\n /** If a number is supplied, this is interpreted as a UTC timestamp. */\n value: Date | number,\n /** If a time zone is supplied, the `value` is converted to that time zone.\n * Otherwise the user time zone will be used. */\n formatOrOptions?: string | DateTimeFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.dateTime,\n (options) => {\n if (timeZone && !options?.timeZone) {\n options = {...options, timeZone};\n }\n\n return new Intl.DateTimeFormat(locale, options).format(value);\n }\n );\n }\n\n function number(\n value: number | bigint,\n formatOrOptions?: string | NumberFormatOptions\n ) {\n return getFormattedValue(\n value,\n formatOrOptions,\n formats?.number,\n (options) => new Intl.NumberFormat(locale, options).format(value)\n );\n }\n\n function relativeTime(\n /** The date time that needs to be formatted. */\n date: number | Date,\n /** The reference point in time to which `date` will be formatted in relation to. */\n now?: number | Date\n ) {\n try {\n if (!now) {\n if (globalNow) {\n now = globalNow;\n } else {\n throw new Error(\n process.env.NODE_ENV !== 'production'\n ? `The \\`now\\` parameter wasn't provided and there was no global fallback configured on the provider.`\n : undefined\n );\n }\n }\n\n const dateDate = date instanceof Date ? date : new Date(date);\n const nowDate = now instanceof Date ? now : new Date(now);\n\n const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;\n const {unit, value} = getRelativeTimeFormatConfig(seconds);\n\n return new Intl.RelativeTimeFormat(locale, {\n numeric: 'auto'\n }).format(value, unit);\n } catch (error) {\n onError(\n new IntlError(IntlErrorCode.FORMATTING_ERROR, (error as Error).message)\n );\n return String(date);\n }\n }\n\n function list(\n value: Iterable<string>,\n formatOrOptions?: string | Intl.ListFormatOptions\n ) {\n return getFormattedValue(value, formatOrOptions, formats?.list, (options) =>\n new Intl.ListFormat(locale, options).format(value)\n );\n }\n\n return {dateTime, number, relativeTime, list};\n}\n"],"mappings":"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","names":["IntlError","IntlErrorCode","defaultOnError","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","getRelativeTimeFormatConfig","seconds","absValue","value","unit","createFormatter","formats","locale","globalNow","onError","timeZone","resolveFormatOrOptions","typeFormats","formatOrOptions","options","formatName","error","getFormattedValue","formatter","dateTime","number","relativeTime","date","now","dateDate","nowDate","list"]}
@@ -0,0 +1,15 @@
1
+ import * as _formatjs_ecma402_abstract_types_number from '@formatjs/ecma402-abstract/types/number';
2
+ import DateTimeFormatOptions from './DateTimeFormatOptions.mjs';
3
+ import createFormatter from './createFormatter.mjs';
4
+ import './TimeZone.mjs';
5
+ import './Formats.mjs';
6
+ import './IntlError.mjs';
7
+
8
+ /** @deprecated Switch to `createFormatter` */
9
+ declare function createIntl(...args: Parameters<typeof createFormatter>): {
10
+ formatDateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
11
+ formatNumber: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
12
+ formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
13
+ };
14
+
15
+ export { createIntl as default };
@@ -1,7 +1,15 @@
1
- import createFormatter from './createFormatter';
2
- /** @deprecated Switch to `createFormatter` */
3
- export default function createIntl(...args: Parameters<typeof createFormatter>): {
4
- formatDateTime: (value: number | Date, formatOrOptions?: string | import("./DateTimeFormatOptions").default | undefined) => string;
5
- formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract/types/number").NumberFormatOptions | undefined) => string;
6
- formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
7
- };
1
+ import * as _formatjs_ecma402_abstract_types_number from '@formatjs/ecma402-abstract/types/number';
2
+ import DateTimeFormatOptions from './DateTimeFormatOptions.js';
3
+ import createFormatter from './createFormatter.js';
4
+ import './TimeZone.js';
5
+ import './Formats.js';
6
+ import './IntlError.js';
7
+
8
+ /** @deprecated Switch to `createFormatter` */
9
+ declare function createIntl(...args: Parameters<typeof createFormatter>): {
10
+ formatDateTime: (value: number | Date, formatOrOptions?: string | DateTimeFormatOptions | undefined) => string;
11
+ formatNumber: (value: number | bigint, formatOrOptions?: string | _formatjs_ecma402_abstract_types_number.NumberFormatOptions | undefined) => string;
12
+ formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
13
+ };
14
+
15
+ export { createIntl as default };
@@ -0,0 +1,2 @@
1
+ "use strict";var c=Object.create;var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty;var b=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},f=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of l(t))!p.call(e,a)&&a!==r&&m(e,a,{get:()=>t[a],enumerable:!(o=u(t,a))||o.enumerable});return e};var d=(e,t,r)=>(r=e!=null?c(T(e)):{},f(t||!e||!e.__esModule?m(r,"default",{value:e,enumerable:!0}):r,e)),s=e=>f(m({},"__esModule",{value:!0}),e);var v={};b(v,{default:()=>n});module.exports=s(v);var i=d(require("./createFormatter"));function n(...e){const t=(0,i.default)(...e);return{formatDateTime:t.dateTime,formatNumber:t.number,formatRelativeTime:t.relativeTime}}
2
+ //# sourceMappingURL=createIntl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4B,gCAGb,SAARF,KACFG,EACH,CACA,MAAMC,KAAY,EAAAC,SAAgB,GAAGF,CAAI,EACzC,MAAO,CACL,eAAgBC,EAAU,SAC1B,aAAcA,EAAU,OACxB,mBAAoBA,EAAU,YAChC,CACF","names":["createIntl_exports","__export","createIntl","__toCommonJS","import_createFormatter","args","formatter","createFormatter"]}
@@ -0,0 +1,2 @@
1
+ import r from"./createFormatter.mjs";function a(...t){const e=r(...t);return{formatDateTime:e.dateTime,formatNumber:e.number,formatRelativeTime:e.relativeTime}}export{a as default};
2
+ //# sourceMappingURL=createIntl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createIntl.tsx"],"sourcesContent":["import createFormatter from './createFormatter';\n\n/** @deprecated Switch to `createFormatter` */\nexport default function createIntl(\n ...args: Parameters<typeof createFormatter>\n) {\n const formatter = createFormatter(...args);\n return {\n formatDateTime: formatter.dateTime,\n formatNumber: formatter.number,\n formatRelativeTime: formatter.relativeTime\n };\n}\n"],"mappings":"AAAA,OAAOA,MAAqB,oBAGb,SAARC,KACFC,EACH,CACA,MAAMC,EAAYH,EAAgB,GAAGE,CAAI,EACzC,MAAO,CACL,eAAgBC,EAAU,SAC1B,aAAcA,EAAU,OACxB,mBAAoBA,EAAU,YAChC,CACF","names":["createFormatter","createIntl","args","formatter"]}
@@ -0,0 +1,57 @@
1
+ import Formats from './Formats.mjs';
2
+ import IntlConfig from './IntlConfig.mjs';
3
+ import TranslationValues from './TranslationValues.mjs';
4
+ import { CoreRichTranslationValues } from './createTranslatorImpl.mjs';
5
+ import MessageKeys from './utils/MessageKeys.mjs';
6
+ import NamespaceKeys from './utils/NamespaceKeys.mjs';
7
+ import NestedKeyOf from './utils/NestedKeyOf.mjs';
8
+ import NestedValueOf from './utils/NestedValueOf.mjs';
9
+ import './DateTimeFormatOptions.mjs';
10
+ import './TimeZone.mjs';
11
+ import '@formatjs/ecma402-abstract/types/number';
12
+ import './IntlError.mjs';
13
+ import './AbstractIntlMessages.mjs';
14
+ import 'react';
15
+
16
+ /**
17
+ * Translates messages from the given namespace by using the ICU syntax.
18
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
19
+ *
20
+ * If no namespace is provided, all available messages are returned.
21
+ * The namespace can also indicate nesting by using a dot
22
+ * (e.g. `namespace.Component`).
23
+ */
24
+ declare function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
25
+ messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
26
+ namespace?: NestedKey;
27
+ }): {
28
+ <TargetKey extends MessageKeys<NestedValueOf<{
29
+ '!': IntlMessages;
30
+ }, [
31
+ NestedKey
32
+ ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
33
+ '!': IntlMessages;
34
+ }, [
35
+ NestedKey
36
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
37
+ rich<TargetKey extends MessageKeys<NestedValueOf<{
38
+ '!': IntlMessages;
39
+ }, [
40
+ NestedKey
41
+ ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
42
+ '!': IntlMessages;
43
+ }, [
44
+ NestedKey
45
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
46
+ raw<TargetKey extends MessageKeys<NestedValueOf<{
47
+ '!': IntlMessages;
48
+ }, [
49
+ NestedKey
50
+ ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
51
+ '!': IntlMessages;
52
+ }, [
53
+ NestedKey
54
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
55
+ };
56
+
57
+ export { createTranslator as default };
@@ -1,48 +1,57 @@
1
- import Formats from './Formats';
2
- import IntlConfig from './IntlConfig';
3
- import TranslationValues from './TranslationValues';
4
- import { CoreRichTranslationValues } from './createTranslatorImpl';
5
- import MessageKeys from './utils/MessageKeys';
6
- import NamespaceKeys from './utils/NamespaceKeys';
7
- import NestedKeyOf from './utils/NestedKeyOf';
8
- import NestedValueOf from './utils/NestedValueOf';
9
- /**
10
- * Translates messages from the given namespace by using the ICU syntax.
11
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
12
- *
13
- * If no namespace is provided, all available messages are returned.
14
- * The namespace can also indicate nesting by using a dot
15
- * (e.g. `namespace.Component`).
16
- */
17
- export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
18
- messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
19
- namespace?: NestedKey;
20
- }): {
21
- <TargetKey extends MessageKeys<NestedValueOf<{
22
- '!': IntlMessages;
23
- }, [
24
- NestedKey
25
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
26
- '!': IntlMessages;
27
- }, [
28
- NestedKey
29
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
30
- rich<TargetKey extends MessageKeys<NestedValueOf<{
31
- '!': IntlMessages;
32
- }, [
33
- NestedKey
34
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
35
- '!': IntlMessages;
36
- }, [
37
- NestedKey
38
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
39
- raw<TargetKey extends MessageKeys<NestedValueOf<{
40
- '!': IntlMessages;
41
- }, [
42
- NestedKey
43
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
44
- '!': IntlMessages;
45
- }, [
46
- NestedKey
47
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
48
- };
1
+ import Formats from './Formats.js';
2
+ import IntlConfig from './IntlConfig.js';
3
+ import TranslationValues from './TranslationValues.js';
4
+ import { CoreRichTranslationValues } from './createTranslatorImpl.js';
5
+ import MessageKeys from './utils/MessageKeys.js';
6
+ import NamespaceKeys from './utils/NamespaceKeys.js';
7
+ import NestedKeyOf from './utils/NestedKeyOf.js';
8
+ import NestedValueOf from './utils/NestedValueOf.js';
9
+ import './DateTimeFormatOptions.js';
10
+ import './TimeZone.js';
11
+ import '@formatjs/ecma402-abstract/types/number';
12
+ import './IntlError.js';
13
+ import './AbstractIntlMessages.js';
14
+ import 'react';
15
+
16
+ /**
17
+ * Translates messages from the given namespace by using the ICU syntax.
18
+ * See https://formatjs.io/docs/core-concepts/icu-syntax.
19
+ *
20
+ * If no namespace is provided, all available messages are returned.
21
+ * The namespace can also indicate nesting by using a dot
22
+ * (e.g. `namespace.Component`).
23
+ */
24
+ declare function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
25
+ messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
26
+ namespace?: NestedKey;
27
+ }): {
28
+ <TargetKey extends MessageKeys<NestedValueOf<{
29
+ '!': IntlMessages;
30
+ }, [
31
+ NestedKey
32
+ ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
33
+ '!': IntlMessages;
34
+ }, [
35
+ NestedKey
36
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
37
+ rich<TargetKey extends MessageKeys<NestedValueOf<{
38
+ '!': IntlMessages;
39
+ }, [
40
+ NestedKey
41
+ ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
42
+ '!': IntlMessages;
43
+ }, [
44
+ NestedKey
45
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
46
+ raw<TargetKey extends MessageKeys<NestedValueOf<{
47
+ '!': IntlMessages;
48
+ }, [
49
+ NestedKey
50
+ ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
51
+ '!': IntlMessages;
52
+ }, [
53
+ NestedKey
54
+ ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
55
+ };
56
+
57
+ export { createTranslator as default };
@@ -0,0 +1,2 @@
1
+ "use strict";var K=Object.create;var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;var i=(e,s)=>{for(var t in s)n(e,t,{get:s[t],enumerable:!0})},d=(e,s,t,r)=>{if(s&&typeof s=="object"||typeof s=="function")for(let a of N(s))!g.call(e,a)&&a!==t&&n(e,a,{get:()=>s[a],enumerable:!(r=m(s,a))||r.enumerable});return e};var u=(e,s,t)=>(t=e!=null?K(f(e)):{},d(s||!e||!e.__esModule?n(t,"default",{value:e,enumerable:!0}):t,e)),M=e=>d(n({},"__esModule",{value:!0}),e);var I={};i(I,{default:()=>y});module.exports=M(I);var o=u(require("./createTranslatorImpl")),l=require("./defaults");function y({getMessageFallback:e=l.defaultGetMessageFallback,messages:s,namespace:t,onError:r=l.defaultOnError,...a}){return(0,o.default)({...a,onError:r,getMessageFallback:e,messages:{"!":s},namespace:t?`!.${t}`:"!"},"!")}
2
+ //# sourceMappingURL=createTranslator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createTranslator.tsx"],"sourcesContent":["import Formats from './Formats';\nimport IntlConfig from './IntlConfig';\nimport TranslationValues from './TranslationValues';\nimport createTranslatorImpl, {\n CoreRichTranslationValues\n} from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n onError = defaultOnError,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: NonNullable<IntlConfig<IntlMessages>['messages']>;\n namespace?: NestedKey;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: CoreRichTranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAGA,IAAAI,EAEO,qCACPC,EAAwD,sBAczC,SAARH,EAKL,CACA,mBAAAI,EAAqB,4BACrB,SAAAC,EACA,UAAAC,EACA,QAAAC,EAAU,iBACV,GAAGC,CACL,EA8DE,CAIA,SAAO,EAAAC,SAIL,CACE,GAAGD,EACH,QAAAD,EACA,mBAAAH,EACA,SAAU,CAAC,IAAKC,CAAQ,EAExB,UAAWC,EAAY,KAAKA,CAAS,GAAK,GAC5C,EACA,GACF,CACF","names":["createTranslator_exports","__export","createTranslator","__toCommonJS","import_createTranslatorImpl","import_defaults","getMessageFallback","messages","namespace","onError","rest","createTranslatorImpl"]}
@@ -0,0 +1,2 @@
1
+ import n from"./createTranslatorImpl.mjs";import{defaultGetMessageFallback as l,defaultOnError as d}from"./defaults.mjs";function o({getMessageFallback:s=l,messages:t,namespace:e,onError:a=d,...r}){return n({...r,onError:a,getMessageFallback:s,messages:{"!":t},namespace:e?`!.${e}`:"!"},"!")}export{o as default};
2
+ //# sourceMappingURL=createTranslator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createTranslator.tsx"],"sourcesContent":["import Formats from './Formats';\nimport IntlConfig from './IntlConfig';\nimport TranslationValues from './TranslationValues';\nimport createTranslatorImpl, {\n CoreRichTranslationValues\n} from './createTranslatorImpl';\nimport {defaultGetMessageFallback, defaultOnError} from './defaults';\nimport MessageKeys from './utils/MessageKeys';\nimport NamespaceKeys from './utils/NamespaceKeys';\nimport NestedKeyOf from './utils/NestedKeyOf';\nimport NestedValueOf from './utils/NestedValueOf';\n\n/**\n * Translates messages from the given namespace by using the ICU syntax.\n * See https://formatjs.io/docs/core-concepts/icu-syntax.\n *\n * If no namespace is provided, all available messages are returned.\n * The namespace can also indicate nesting by using a dot\n * (e.g. `namespace.Component`).\n */\nexport default function createTranslator<\n NestedKey extends NamespaceKeys<\n IntlMessages,\n NestedKeyOf<IntlMessages>\n > = never\n>({\n getMessageFallback = defaultGetMessageFallback,\n messages,\n namespace,\n onError = defaultOnError,\n ...rest\n}: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {\n messages: NonNullable<IntlConfig<IntlMessages>['messages']>;\n namespace?: NestedKey;\n}): // Explicitly defining the return type is necessary as TypeScript would get it wrong\n{\n // Default invocation\n <\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: TranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `rich`\n rich<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey,\n values?: CoreRichTranslationValues,\n formats?: Partial<Formats>\n ): string;\n\n // `raw`\n raw<\n TargetKey extends MessageKeys<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >,\n NestedKeyOf<\n NestedValueOf<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >\n >\n >\n >(\n key: TargetKey\n ): any;\n} {\n // We have to wrap the actual function so the type inference for the optional\n // namespace works correctly. See https://stackoverflow.com/a/71529575/343045\n // The prefix (\"!\") is arbitrary.\n return createTranslatorImpl<\n {'!': IntlMessages},\n [NestedKey] extends [never] ? '!' : `!.${NestedKey}`\n >(\n {\n ...rest,\n onError,\n getMessageFallback,\n messages: {'!': messages},\n // @ts-ignore\n namespace: namespace ? `!.${namespace}` : '!'\n },\n '!'\n );\n}\n"],"mappings":"AAGA,OAAOA,MAEA,yBACP,OAAQ,6BAAAC,EAA2B,kBAAAC,MAAqB,aAczC,SAARC,EAKL,CACA,mBAAAC,EAAqBH,EACrB,SAAAI,EACA,UAAAC,EACA,QAAAC,EAAUL,EACV,GAAGM,CACL,EA8DE,CAIA,OAAOR,EAIL,CACE,GAAGQ,EACH,QAAAD,EACA,mBAAAH,EACA,SAAU,CAAC,IAAKC,CAAQ,EAExB,UAAWC,EAAY,KAAKA,CAAS,GAAK,GAC5C,EACA,GACF,CACF","names":["createTranslatorImpl","defaultGetMessageFallback","defaultOnError","createTranslator","getMessageFallback","messages","namespace","onError","rest"]}
@@ -0,0 +1,25 @@
1
+ import Formats from './Formats.mjs';
2
+ import TranslationValues, { TranslationValue } from './TranslationValues.mjs';
3
+ import MessageKeys from './utils/MessageKeys.mjs';
4
+ import NestedValueOf from './utils/NestedValueOf.mjs';
5
+ import AbstractIntlMessages from './AbstractIntlMessages.mjs';
6
+ import { InitializedIntlConfig } from './IntlConfig.mjs';
7
+ import NestedKeyOf from './utils/NestedKeyOf.mjs';
8
+ import './DateTimeFormatOptions.mjs';
9
+ import './TimeZone.mjs';
10
+ import '@formatjs/ecma402-abstract/types/number';
11
+ import 'react';
12
+ import './IntlError.mjs';
13
+
14
+ type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
15
+ type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
16
+ namespace: string;
17
+ messages: Messages;
18
+ };
19
+ declare function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
20
+ (key: MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>, values?: TranslationValues | undefined, formats?: Partial<Formats> | undefined): string;
21
+ rich(key: string, values: CoreRichTranslationValues, formats?: Partial<Formats> | undefined): string;
22
+ raw: (key: string) => any;
23
+ };
24
+
25
+ export { CoreRichTranslationValues, CreateTranslatorImplProps, createTranslatorImpl as default };
@@ -1,14 +1,25 @@
1
- import AbstractIntlMessages from './AbstractIntlMessages';
2
- import { InitializedIntlConfig } from './IntlConfig';
3
- import { TranslationValue } from './TranslationValues';
4
- import NestedKeyOf from './utils/NestedKeyOf';
5
- export type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
6
- export type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
7
- namespace: string;
8
- messages: Messages;
9
- };
10
- export default function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
11
- (key: import("./utils/MessageKeys").default<import("./utils/NestedValueOf").default<Messages, NestedKey>, NestedKeyOf<import("./utils/NestedValueOf").default<Messages, NestedKey>>>, values?: import("./TranslationValues").default | undefined, formats?: Partial<import("./Formats").default> | undefined): string;
12
- rich(key: string, values: CoreRichTranslationValues, formats?: Partial<import("./Formats").default> | undefined): string;
13
- raw: (key: string) => any;
14
- };
1
+ import Formats from './Formats.js';
2
+ import TranslationValues, { TranslationValue } from './TranslationValues.js';
3
+ import MessageKeys from './utils/MessageKeys.js';
4
+ import NestedValueOf from './utils/NestedValueOf.js';
5
+ import AbstractIntlMessages from './AbstractIntlMessages.js';
6
+ import { InitializedIntlConfig } from './IntlConfig.js';
7
+ import NestedKeyOf from './utils/NestedKeyOf.js';
8
+ import './DateTimeFormatOptions.js';
9
+ import './TimeZone.js';
10
+ import '@formatjs/ecma402-abstract/types/number';
11
+ import 'react';
12
+ import './IntlError.js';
13
+
14
+ type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
15
+ type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
16
+ namespace: string;
17
+ messages: Messages;
18
+ };
19
+ declare function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
20
+ (key: MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>, values?: TranslationValues | undefined, formats?: Partial<Formats> | undefined): string;
21
+ rich(key: string, values: CoreRichTranslationValues, formats?: Partial<Formats> | undefined): string;
22
+ raw: (key: string) => any;
23
+ };
24
+
25
+ export { CoreRichTranslationValues, CreateTranslatorImplProps, createTranslatorImpl as default };
@@ -0,0 +1,2 @@
1
+ "use strict";var M=Object.create;var o=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var V=(r,e)=>{for(var s in e)o(r,s,{get:e[s],enumerable:!0})},d=(r,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of O(e))!E.call(r,t)&&t!==s&&o(r,t,{get:()=>e[t],enumerable:!(a=N(e,t))||a.enumerable});return r};var f=(r,e,s)=>(s=r!=null?M(C(r)):{},d(e||!r||!r.__esModule?o(s,"default",{value:r,enumerable:!0}):s,r)),b=r=>d(o({},"__esModule",{value:!0}),r);var x={};V(x,{default:()=>I});module.exports=b(x);var i=f(require("./IntlError")),l=f(require("./createBaseTranslator")),h=f(require("./resolveNamespace"));function I({getMessageFallback:r,messages:e,namespace:s,onError:a,...t},p){e=e[p],s=(0,h.default)(s,p);const c=(0,l.default)({...t,onError:a,getMessageFallback:r,messagesOrError:(0,l.getMessagesOrError)({messages:e,namespace:s,onError:a})}),T=c.rich;function g(...n){return c(...n)}return g.rich=(n,R,y)=>{const m=T(n,R,y);if(typeof m!="string"){const u=new i.default(i.IntlErrorCode.FORMATTING_ERROR,process.env.NODE_ENV!=="production"?"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})":void 0);return a(u),r({error:u,key:n,namespace:s})}return m},g.raw=c.raw,g}
2
+ //# sourceMappingURL=createTranslatorImpl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createTranslatorImpl.tsx"],"sourcesContent":["import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {RichTranslationValues, TranslationValue} from './TranslationValues';\nimport createBaseTranslator, {getMessagesOrError} from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CoreRichTranslationValues = Record<\n string,\n TranslationValue | ((chunks: string) => string)\n>;\n\nexport type CreateTranslatorImplProps<Messages> = Omit<\n InitializedIntlConfig,\n 'messages'\n> & {\n namespace: string;\n messages: Messages;\n};\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messagesOrError: getMessagesOrError({\n messages,\n namespace,\n onError\n }) as Messages | IntlError\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: CoreRichTranslationValues,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n process.env.NODE_ENV !== 'production'\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAEA,IAAAI,EAAuC,0BAEvCC,EAAuD,qCACvDC,EAA6B,iCAgBd,SAARJ,EAIL,CACE,mBAAAK,EACA,SAAAC,EACA,UAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EACAC,EACA,CAGAJ,EAAWA,EAASI,CAAe,EACnCH,KAAY,EAAAI,SAAiBJ,EAAWG,CAAe,EAEvD,MAAME,KAAa,EAAAC,SAA0C,CAC3D,GAAGJ,EACH,QAAAD,EACA,mBAAAH,EACA,mBAAiB,sBAAmB,CAClC,SAAAC,EACA,UAAAC,EACA,QAAAC,CACF,CAAC,CACH,CAAC,EAEKM,EAAeF,EAAW,KAEhC,SAASG,KAAQC,EAAqC,CACpD,OAAOJ,EAAW,GAAGI,CAAI,CAC3B,CAGA,OAAAD,EAAK,KAAO,CACVE,EAEAC,EACAC,IACW,CAGX,MAAMC,EAASN,EAAaG,EAAKC,EAAiCC,CAAO,EAGzE,GAAI,OAAOC,GAAW,SAAU,CAC9B,MAAMC,EAAQ,IAAI,EAAAC,QAChB,gBAAc,iBACd,QAAQ,IAAI,WAAa,aACrB,kKACA,MACN,EAEA,OAAAd,EAAQa,CAAK,EACNhB,EAAmB,CAAC,MAAAgB,EAAO,IAAAJ,EAAK,UAAAV,CAAS,CAAC,CACnD,CAEA,OAAOa,CACT,EAEAL,EAAK,IAAMH,EAAW,IAEfG,CACT","names":["createTranslatorImpl_exports","__export","createTranslatorImpl","__toCommonJS","import_IntlError","import_createBaseTranslator","import_resolveNamespace","getMessageFallback","messages","namespace","onError","rest","namespacePrefix","resolveNamespace","translator","createBaseTranslator","originalRich","base","args","key","values","formats","result","error","IntlError"]}
@@ -0,0 +1,2 @@
1
+ import u,{IntlErrorCode as d}from"./IntlError.mjs";import h,{getMessagesOrError as I}from"./createBaseTranslator.mjs";import T from"./resolveNamespace.mjs";function R({getMessageFallback:o,messages:s,namespace:r,onError:t,...g},i){s=s[i],r=T(r,i);const a=h({...g,onError:t,getMessageFallback:o,messagesOrError:I({messages:s,namespace:r,onError:t})}),f=a.rich;function n(...e){return a(...e)}return n.rich=(e,p,m)=>{const l=f(e,p,m);if(typeof l!="string"){const c=new u(d.FORMATTING_ERROR,process.env.NODE_ENV!=="production"?"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\n\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})":void 0);return t(c),o({error:c,key:e,namespace:r})}return l},n.raw=a.raw,n}export{R as default};
2
+ //# sourceMappingURL=createTranslatorImpl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/createTranslatorImpl.tsx"],"sourcesContent":["import AbstractIntlMessages from './AbstractIntlMessages';\nimport {InitializedIntlConfig} from './IntlConfig';\nimport IntlError, {IntlErrorCode} from './IntlError';\nimport {RichTranslationValues, TranslationValue} from './TranslationValues';\nimport createBaseTranslator, {getMessagesOrError} from './createBaseTranslator';\nimport resolveNamespace from './resolveNamespace';\nimport NestedKeyOf from './utils/NestedKeyOf';\n\nexport type CoreRichTranslationValues = Record<\n string,\n TranslationValue | ((chunks: string) => string)\n>;\n\nexport type CreateTranslatorImplProps<Messages> = Omit<\n InitializedIntlConfig,\n 'messages'\n> & {\n namespace: string;\n messages: Messages;\n};\n\nexport default function createTranslatorImpl<\n Messages extends AbstractIntlMessages,\n NestedKey extends NestedKeyOf<Messages>\n>(\n {\n getMessageFallback,\n messages,\n namespace,\n onError,\n ...rest\n }: CreateTranslatorImplProps<Messages>,\n namespacePrefix: string\n) {\n // The `namespacePrefix` is part of the type system.\n // See the comment in the function invocation.\n messages = messages[namespacePrefix] as Messages;\n namespace = resolveNamespace(namespace, namespacePrefix) as NestedKey;\n\n const translator = createBaseTranslator<Messages, NestedKey>({\n ...rest,\n onError,\n getMessageFallback,\n messagesOrError: getMessagesOrError({\n messages,\n namespace,\n onError\n }) as Messages | IntlError\n });\n\n const originalRich = translator.rich;\n\n function base(...args: Parameters<typeof translator>) {\n return translator(...args);\n }\n\n // Augment `t.rich` to return plain strings\n base.rich = (\n key: Parameters<typeof originalRich>[0],\n /** Key value pairs for values to interpolate into the message. */\n values: CoreRichTranslationValues,\n formats?: Parameters<typeof originalRich>[2]\n ): string => {\n // `chunks` is returned as a string when no React element\n // is used, therefore it's safe to cast this type.\n const result = originalRich(key, values as RichTranslationValues, formats);\n\n // When only string chunks are provided to the parser, only strings should be returned here.\n if (typeof result !== 'string') {\n const error = new IntlError(\n IntlErrorCode.FORMATTING_ERROR,\n process.env.NODE_ENV !== 'production'\n ? \"`createTranslator` only accepts functions for rich text formatting that receive and return strings.\\n\\nE.g. t.rich('rich', {b: (chunks) => `<b>${chunks}</b>`})\"\n : undefined\n );\n\n onError(error);\n return getMessageFallback({error, key, namespace});\n }\n\n return result;\n };\n\n base.raw = translator.raw;\n\n return base;\n}\n"],"mappings":"AAEA,OAAOA,GAAY,iBAAAC,MAAoB,cAEvC,OAAOC,GAAuB,sBAAAC,MAAyB,yBACvD,OAAOC,MAAsB,qBAgBd,SAARC,EAIL,CACE,mBAAAC,EACA,SAAAC,EACA,UAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EACAC,EACA,CAGAJ,EAAWA,EAASI,CAAe,EACnCH,EAAYJ,EAAiBI,EAAWG,CAAe,EAEvD,MAAMC,EAAaV,EAA0C,CAC3D,GAAGQ,EACH,QAAAD,EACA,mBAAAH,EACA,gBAAiBH,EAAmB,CAClC,SAAAI,EACA,UAAAC,EACA,QAAAC,CACF,CAAC,CACH,CAAC,EAEKI,EAAeD,EAAW,KAEhC,SAASE,KAAQC,EAAqC,CACpD,OAAOH,EAAW,GAAGG,CAAI,CAC3B,CAGA,OAAAD,EAAK,KAAO,CACVE,EAEAC,EACAC,IACW,CAGX,MAAMC,EAASN,EAAaG,EAAKC,EAAiCC,CAAO,EAGzE,GAAI,OAAOC,GAAW,SAAU,CAC9B,MAAMC,EAAQ,IAAIpB,EAChBC,EAAc,iBACd,QAAQ,IAAI,WAAa,aACrB,kKACA,MACN,EAEA,OAAAQ,EAAQW,CAAK,EACNd,EAAmB,CAAC,MAAAc,EAAO,IAAAJ,EAAK,UAAAR,CAAS,CAAC,CACnD,CAEA,OAAOW,CACT,EAEAL,EAAK,IAAMF,EAAW,IAEfE,CACT","names":["IntlError","IntlErrorCode","createBaseTranslator","getMessagesOrError","resolveNamespace","createTranslatorImpl","getMessageFallback","messages","namespace","onError","rest","namespacePrefix","translator","originalRich","base","args","key","values","formats","result","error"]}
@@ -0,0 +1,14 @@
1
+ import IntlError from './IntlError.mjs';
2
+
3
+ /**
4
+ * Contains defaults that are used for all entry points into the core.
5
+ * See also `InitializedIntlConfiguration`.
6
+ */
7
+ declare function defaultGetMessageFallback(props: {
8
+ error: IntlError;
9
+ key: string;
10
+ namespace?: string;
11
+ }): string;
12
+ declare function defaultOnError(error: IntlError): void;
13
+
14
+ export { defaultGetMessageFallback, defaultOnError };
@@ -1,11 +1,14 @@
1
- import IntlError from './IntlError';
2
- /**
3
- * Contains defaults that are used for all entry points into the core.
4
- * See also `InitializedIntlConfiguration`.
5
- */
6
- export declare function defaultGetMessageFallback(props: {
7
- error: IntlError;
8
- key: string;
9
- namespace?: string;
10
- }): string;
11
- export declare function defaultOnError(error: IntlError): void;
1
+ import IntlError from './IntlError.js';
2
+
3
+ /**
4
+ * Contains defaults that are used for all entry points into the core.
5
+ * See also `InitializedIntlConfiguration`.
6
+ */
7
+ declare function defaultGetMessageFallback(props: {
8
+ error: IntlError;
9
+ key: string;
10
+ namespace?: string;
11
+ }): string;
12
+ declare function defaultOnError(error: IntlError): void;
13
+
14
+ export { defaultGetMessageFallback, defaultOnError };
@@ -0,0 +1,2 @@
1
+ "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var f=(r,e)=>{for(var t in e)o(r,t,{get:e[t],enumerable:!0})},s=(r,e,t,l)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i(e))!c.call(r,n)&&n!==t&&o(r,n,{get:()=>e[n],enumerable:!(l=a(e,n))||l.enumerable});return r};var u=r=>s(o({},"__esModule",{value:!0}),r);var g={};f(g,{defaultGetMessageFallback:()=>m,defaultOnError:()=>E});module.exports=u(g);function m(r){return[r.namespace,r.key].filter(e=>e!=null).join(".")}function E(r){console.error(r)}0&&(module.exports={defaultGetMessageFallback,defaultOnError});
2
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/defaults.tsx"],"sourcesContent":["import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAOO,SAASE,EAA0BG,EAIvC,CACD,MAAO,CAACA,EAAM,UAAWA,EAAM,GAAG,EAAE,OAAQC,GAASA,GAAQ,IAAI,EAAE,KAAK,GAAG,CAC7E,CAEO,SAASH,EAAeI,EAAkB,CAC/C,QAAQ,MAAMA,CAAK,CACrB","names":["defaults_exports","__export","defaultGetMessageFallback","defaultOnError","__toCommonJS","props","part","error"]}
@@ -0,0 +1,2 @@
1
+ function o(r){return[r.namespace,r.key].filter(e=>e!=null).join(".")}function l(r){console.error(r)}export{o as defaultGetMessageFallback,l as defaultOnError};
2
+ //# sourceMappingURL=defaults.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/defaults.tsx"],"sourcesContent":["import IntlError from './IntlError';\n\n/**\n * Contains defaults that are used for all entry points into the core.\n * See also `InitializedIntlConfiguration`.\n */\n\nexport function defaultGetMessageFallback(props: {\n error: IntlError;\n key: string;\n namespace?: string;\n}) {\n return [props.namespace, props.key].filter((part) => part != null).join('.');\n}\n\nexport function defaultOnError(error: IntlError) {\n console.error(error);\n}\n"],"mappings":"AAOO,SAASA,EAA0BC,EAIvC,CACD,MAAO,CAACA,EAAM,UAAWA,EAAM,GAAG,EAAE,OAAQC,GAASA,GAAQ,IAAI,EAAE,KAAK,GAAG,CAC7E,CAEO,SAASC,EAAeC,EAAkB,CAC/C,QAAQ,MAAMA,CAAK,CACrB","names":["defaultGetMessageFallback","props","part","defaultOnError","error"]}
@@ -0,0 +1,17 @@
1
+ export { default as AbstractIntlMessages } from './AbstractIntlMessages.mjs';
2
+ export { RichTranslationValues, default as TranslationValues } from './TranslationValues.mjs';
3
+ export { default as Formats } from './Formats.mjs';
4
+ export { default as DateTimeFormatOptions } from './DateTimeFormatOptions.mjs';
5
+ export { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
6
+ export { default as IntlError, IntlErrorCode } from './IntlError.mjs';
7
+ export { default as createTranslator } from './createTranslator.mjs';
8
+ export { default as createFormatter } from './createFormatter.mjs';
9
+ export { default as createIntl } from './createIntl.mjs';
10
+ import 'react';
11
+ import './TimeZone.mjs';
12
+ import './IntlConfig.mjs';
13
+ import './createTranslatorImpl.mjs';
14
+ import './utils/MessageKeys.mjs';
15
+ import './utils/NestedValueOf.mjs';
16
+ import './utils/NestedKeyOf.mjs';
17
+ import './utils/NamespaceKeys.mjs';
@@ -1,9 +1,17 @@
1
- export { default as AbstractIntlMessages } from './AbstractIntlMessages';
2
- export { default as TranslationValues, RichTranslationValues } from './TranslationValues';
3
- export { default as Formats } from './Formats';
4
- export { default as DateTimeFormatOptions } from './DateTimeFormatOptions';
5
- export { default as NumberFormatOptions } from './NumberFormatOptions';
6
- export { default as IntlError, IntlErrorCode } from './IntlError';
7
- export { default as createTranslator } from './createTranslator';
8
- export { default as createFormatter } from './createFormatter';
9
- export { default as createIntl } from './createIntl';
1
+ export { default as AbstractIntlMessages } from './AbstractIntlMessages.js';
2
+ export { RichTranslationValues, default as TranslationValues } from './TranslationValues.js';
3
+ export { default as Formats } from './Formats.js';
4
+ export { default as DateTimeFormatOptions } from './DateTimeFormatOptions.js';
5
+ export { NumberFormatOptions } from '@formatjs/ecma402-abstract/types/number';
6
+ export { default as IntlError, IntlErrorCode } from './IntlError.js';
7
+ export { default as createTranslator } from './createTranslator.js';
8
+ export { default as createFormatter } from './createFormatter.js';
9
+ export { default as createIntl } from './createIntl.js';
10
+ import 'react';
11
+ import './TimeZone.js';
12
+ import './IntlConfig.js';
13
+ import './createTranslatorImpl.js';
14
+ import './utils/MessageKeys.js';
15
+ import './utils/NestedValueOf.js';
16
+ import './utils/NestedKeyOf.js';
17
+ import './utils/NamespaceKeys.js';
@@ -0,0 +1,2 @@
1
+ "use strict";var d=Object.create;var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var T=(t,a)=>{for(var e in a)o(t,e,{get:a[e],enumerable:!0})},f=(t,a,e,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of x(a))!c.call(t,r)&&r!==e&&o(t,r,{get:()=>a[r],enumerable:!(m=i(a,r))||m.enumerable});return t};var s=(t,a,e)=>(e=t!=null?d(F(t)):{},f(a||!t||!t.__esModule?o(e,"default",{value:t,enumerable:!0}):e,t)),y=t=>f(o({},"__esModule",{value:!0}),t);var I={};T(I,{IntlError:()=>l.default,IntlErrorCode:()=>l.IntlErrorCode,createFormatter:()=>n.default,createIntl:()=>u.default,createTranslator:()=>p.default});module.exports=y(I);var l=s(require("./IntlError")),p=s(require("./createTranslator")),n=s(require("./createFormatter")),u=s(require("./createIntl"));0&&(module.exports={IntlError,IntlErrorCode,createFormatter,createIntl,createTranslator});
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/index.tsx"],"sourcesContent":["export type {default as AbstractIntlMessages} from './AbstractIntlMessages';\nexport type {\n default as TranslationValues,\n RichTranslationValues\n} from './TranslationValues';\nexport type {default as Formats} from './Formats';\nexport type {default as DateTimeFormatOptions} from './DateTimeFormatOptions';\nexport type {default as NumberFormatOptions} from './NumberFormatOptions';\nexport {default as IntlError, IntlErrorCode} from './IntlError';\nexport {default as createTranslator} from './createTranslator';\nexport {default as createFormatter} from './createFormatter';\n\n// TODO: Remove in next major version\nexport {default as createIntl} from './createIntl';\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kKAAAE,EAAAF,GAQA,IAAAG,EAAkD,0BAClDC,EAA0C,iCAC1CC,EAAyC,gCAGzCC,EAAoC","names":["core_exports","__export","__toCommonJS","import_IntlError","import_createTranslator","import_createFormatter","import_createIntl"]}
@@ -0,0 +1,2 @@
1
+ import{default as e,IntlErrorCode as r}from"./IntlError.mjs";import{default as s}from"./createTranslator.mjs";import{default as m}from"./createFormatter.mjs";import{default as p}from"./createIntl.mjs";export{e as IntlError,r as IntlErrorCode,m as createFormatter,p as createIntl,s as createTranslator};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/index.tsx"],"sourcesContent":["export type {default as AbstractIntlMessages} from './AbstractIntlMessages';\nexport type {\n default as TranslationValues,\n RichTranslationValues\n} from './TranslationValues';\nexport type {default as Formats} from './Formats';\nexport type {default as DateTimeFormatOptions} from './DateTimeFormatOptions';\nexport type {default as NumberFormatOptions} from './NumberFormatOptions';\nexport {default as IntlError, IntlErrorCode} from './IntlError';\nexport {default as createTranslator} from './createTranslator';\nexport {default as createFormatter} from './createFormatter';\n\n// TODO: Remove in next major version\nexport {default as createIntl} from './createIntl';\n"],"mappings":"AAQA,OAAmB,WAAXA,EAAsB,iBAAAC,MAAoB,cAClD,OAAmB,WAAXD,MAAkC,qBAC1C,OAAmB,WAAXA,MAAiC,oBAGzC,OAAmB,WAAXA,MAA4B","names":["default","IntlErrorCode"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * For the strictly typed messages to work we have to wrap the namespace into
3
+ * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045
4
+ */
5
+ declare function resolveNamespace(namespace: string, namespacePrefix: string): string | undefined;
6
+
7
+ export { resolveNamespace as default };
@@ -1,5 +1,7 @@
1
- /**
2
- * For the strictly typed messages to work we have to wrap the namespace into
3
- * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045
4
- */
5
- export default function resolveNamespace(namespace: string, namespacePrefix: string): string | undefined;
1
+ /**
2
+ * For the strictly typed messages to work we have to wrap the namespace into
3
+ * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045
4
+ */
5
+ declare function resolveNamespace(namespace: string, namespacePrefix: string): string | undefined;
6
+
7
+ export { resolveNamespace as default };
@@ -0,0 +1,2 @@
1
+ "use strict";var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var s=(e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},f=(e,t,r,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of g(t))!o.call(e,n)&&n!==r&&i(e,n,{get:()=>t[n],enumerable:!(l=d(t,n))||l.enumerable});return e};var c=e=>f(i({},"__esModule",{value:!0}),e);var h={};s(h,{default:()=>u});module.exports=c(h);function u(e,t){return e===t?void 0:e.slice((t+".").length)}
2
+ //# sourceMappingURL=resolveNamespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/resolveNamespace.tsx"],"sourcesContent":["/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAIe,SAARE,EACLE,EACAC,EACA,CACA,OAAOD,IAAcC,EACjB,OACAD,EAAU,OAAOC,EAAkB,KAAK,MAAM,CACpD","names":["resolveNamespace_exports","__export","resolveNamespace","__toCommonJS","namespace","namespacePrefix"]}
@@ -0,0 +1,2 @@
1
+ function n(t,e){return t===e?void 0:t.slice((e+".").length)}export{n as default};
2
+ //# sourceMappingURL=resolveNamespace.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/resolveNamespace.tsx"],"sourcesContent":["/**\n * For the strictly typed messages to work we have to wrap the namespace into\n * a mandatory prefix. See https://stackoverflow.com/a/71529575/343045\n */\nexport default function resolveNamespace(\n namespace: string,\n namespacePrefix: string\n) {\n return namespace === namespacePrefix\n ? undefined\n : namespace.slice((namespacePrefix + '.').length);\n}\n"],"mappings":"AAIe,SAARA,EACLC,EACAC,EACA,CACA,OAAOD,IAAcC,EACjB,OACAD,EAAU,OAAOC,EAAkB,KAAK,MAAM,CACpD","names":["resolveNamespace","namespace","namespacePrefix"]}