@intlayer/core 8.1.2 → 8.1.3

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 (408) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -212
  3. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -94
  5. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -45
  7. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -33
  9. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +1 -27
  11. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  12. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -82
  13. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  14. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +1 -87
  15. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  16. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +1 -60
  17. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  18. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -122
  19. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  20. package/dist/cjs/deepTransformPlugins/index.cjs +1 -32
  21. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -106
  22. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -64
  24. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -18
  26. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -55
  28. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -26
  30. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -23
  32. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  33. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -36
  34. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  35. package/dist/cjs/dictionaryManipulator/index.cjs +1 -27
  36. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -69
  37. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  38. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +1 -30
  39. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  40. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -48
  41. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  42. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -31
  43. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  44. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -39
  45. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  46. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -38
  47. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  48. package/dist/cjs/formatters/compact.cjs +1 -25
  49. package/dist/cjs/formatters/compact.cjs.map +1 -1
  50. package/dist/cjs/formatters/currency.cjs +1 -29
  51. package/dist/cjs/formatters/currency.cjs.map +1 -1
  52. package/dist/cjs/formatters/date.cjs +1 -60
  53. package/dist/cjs/formatters/date.cjs.map +1 -1
  54. package/dist/cjs/formatters/index.cjs +1 -18
  55. package/dist/cjs/formatters/list.cjs +1 -30
  56. package/dist/cjs/formatters/list.cjs.map +1 -1
  57. package/dist/cjs/formatters/number.cjs +1 -18
  58. package/dist/cjs/formatters/number.cjs.map +1 -1
  59. package/dist/cjs/formatters/percentage.cjs +1 -25
  60. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  61. package/dist/cjs/formatters/relativeTime.cjs +1 -33
  62. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  63. package/dist/cjs/formatters/units.cjs +1 -23
  64. package/dist/cjs/formatters/units.cjs.map +1 -1
  65. package/dist/cjs/getStorageAttributes.cjs +1 -134
  66. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  67. package/dist/cjs/index.cjs +1 -300
  68. package/dist/cjs/interpreter/getCondition.cjs +1 -27
  69. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  70. package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -41
  71. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  72. package/dist/cjs/interpreter/getContent/getContent.cjs +1 -34
  73. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  74. package/dist/cjs/interpreter/getContent/index.cjs +1 -14
  75. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -161
  76. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  77. package/dist/cjs/interpreter/getDictionary.cjs +1 -24
  78. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  79. package/dist/cjs/interpreter/getEnumeration.cjs +1 -72
  80. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  81. package/dist/cjs/interpreter/getGender.cjs +1 -38
  82. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  83. package/dist/cjs/interpreter/getHTML.cjs +1 -121
  84. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  85. package/dist/cjs/interpreter/getInsertion.cjs +1 -22
  86. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  87. package/dist/cjs/interpreter/getIntlayer.cjs +1 -40
  88. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  89. package/dist/cjs/interpreter/getNesting.cjs +1 -36
  90. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  91. package/dist/cjs/interpreter/getTranslation.cjs +1 -112
  92. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  93. package/dist/cjs/interpreter/index.cjs +1 -31
  94. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +1 -55
  95. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  96. package/dist/cjs/localization/getBrowserLocale.cjs +1 -143
  97. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  98. package/dist/cjs/localization/getHTMLTextDir.cjs +1 -64
  99. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  100. package/dist/cjs/localization/getLocale.cjs +1 -27
  101. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  102. package/dist/cjs/localization/getLocaleFromPath.cjs +1 -45
  103. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  104. package/dist/cjs/localization/getLocaleLang.cjs +1 -20
  105. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  106. package/dist/cjs/localization/getLocaleName.cjs +1 -10
  107. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  108. package/dist/cjs/localization/getLocalizedUrl.cjs +1 -82
  109. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  110. package/dist/cjs/localization/getMultilingualUrls.cjs +1 -63
  111. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  112. package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -55
  113. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  114. package/dist/cjs/localization/getPrefix.cjs +1 -63
  115. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  116. package/dist/cjs/localization/index.cjs +1 -39
  117. package/dist/cjs/localization/localeDetector.cjs +1 -133
  118. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  119. package/dist/cjs/localization/localeMapper.cjs +1 -119
  120. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  121. package/dist/cjs/localization/localeResolver.cjs +1 -28
  122. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  123. package/dist/cjs/localization/rewriteUtils.cjs +1 -110
  124. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  125. package/dist/cjs/localization/validatePrefix.cjs +1 -54
  126. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  127. package/dist/cjs/markdown/compiler.cjs +10 -810
  128. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  129. package/dist/cjs/markdown/constants.cjs +1 -328
  130. package/dist/cjs/markdown/constants.cjs.map +1 -1
  131. package/dist/cjs/markdown/index.cjs +1 -120
  132. package/dist/cjs/markdown/parser.cjs +1 -66
  133. package/dist/cjs/markdown/parser.cjs.map +1 -1
  134. package/dist/cjs/markdown/renderer.cjs +1 -61
  135. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  136. package/dist/cjs/markdown/utils.cjs +6 -391
  137. package/dist/cjs/markdown/utils.cjs.map +1 -1
  138. package/dist/cjs/messageFormat/ICU.cjs +1 -319
  139. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  140. package/dist/cjs/messageFormat/i18next.cjs +1 -330
  141. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  142. package/dist/cjs/messageFormat/index.cjs +1 -11
  143. package/dist/cjs/messageFormat/verify-icu-format.cjs +2 -64
  144. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  145. package/dist/cjs/messageFormat/vue-i18n.cjs +1 -166
  146. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  147. package/dist/cjs/transpiler/condition/condition.cjs +1 -26
  148. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  149. package/dist/cjs/transpiler/condition/index.cjs +1 -4
  150. package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -28
  151. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  152. package/dist/cjs/transpiler/enumeration/index.cjs +1 -4
  153. package/dist/cjs/transpiler/file/file.cjs +1 -52
  154. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  155. package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -25
  156. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  157. package/dist/cjs/transpiler/file/index.cjs +1 -5
  158. package/dist/cjs/transpiler/gender/gender.cjs +1 -26
  159. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  160. package/dist/cjs/transpiler/gender/index.cjs +1 -4
  161. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -44
  162. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  163. package/dist/cjs/transpiler/html/html.cjs +1 -37
  164. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  165. package/dist/cjs/transpiler/html/htmlTags.cjs +1 -116
  166. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  167. package/dist/cjs/transpiler/html/index.cjs +1 -6
  168. package/dist/cjs/transpiler/index.cjs +1 -24
  169. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +1 -11
  170. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  171. package/dist/cjs/transpiler/insertion/index.cjs +1 -6
  172. package/dist/cjs/transpiler/insertion/insertion.cjs +1 -36
  173. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  174. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +2 -23
  175. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  176. package/dist/cjs/transpiler/markdown/index.cjs +1 -6
  177. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -54
  178. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  179. package/dist/cjs/transpiler/nesting/index.cjs +1 -4
  180. package/dist/cjs/transpiler/nesting/nesting.cjs +1 -27
  181. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  182. package/dist/cjs/transpiler/translation/index.cjs +1 -4
  183. package/dist/cjs/transpiler/translation/translation.cjs +1 -29
  184. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  185. package/dist/cjs/utils/checkIsURLAbsolute.cjs +1 -7
  186. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  187. package/dist/cjs/utils/getCookie.cjs +1 -32
  188. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  189. package/dist/cjs/utils/index.cjs +1 -0
  190. package/dist/cjs/utils/intl.cjs +1 -91
  191. package/dist/cjs/utils/intl.cjs.map +1 -1
  192. package/dist/cjs/utils/isSameKeyPath.cjs +1 -7
  193. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  194. package/dist/cjs/utils/isValidReactElement.cjs +1 -14
  195. package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
  196. package/dist/cjs/utils/localeStorage.cjs +1 -140
  197. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  198. package/dist/cjs/utils/parseYaml.cjs +16 -322
  199. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  200. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -207
  201. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  202. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -89
  203. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  204. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -42
  205. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  206. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -31
  207. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  208. package/dist/esm/deepTransformPlugins/getMaskContent.mjs +1 -25
  209. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  210. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -77
  211. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  212. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +1 -86
  213. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  214. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +1 -59
  215. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  216. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -119
  217. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  218. package/dist/esm/deepTransformPlugins/index.mjs +1 -12
  219. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -104
  220. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  221. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -62
  222. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  223. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -16
  224. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  225. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -53
  226. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  227. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -24
  228. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  229. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -21
  230. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  231. package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -34
  232. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  233. package/dist/esm/dictionaryManipulator/index.mjs +1 -14
  234. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -66
  235. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  236. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +1 -28
  237. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  238. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +1 -45
  239. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  240. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -29
  241. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  242. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -37
  243. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  244. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -36
  245. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  246. package/dist/esm/formatters/compact.mjs +1 -22
  247. package/dist/esm/formatters/compact.mjs.map +1 -1
  248. package/dist/esm/formatters/currency.mjs +1 -26
  249. package/dist/esm/formatters/currency.mjs.map +1 -1
  250. package/dist/esm/formatters/date.mjs +1 -57
  251. package/dist/esm/formatters/date.mjs.map +1 -1
  252. package/dist/esm/formatters/index.mjs +1 -10
  253. package/dist/esm/formatters/list.mjs +1 -27
  254. package/dist/esm/formatters/list.mjs.map +1 -1
  255. package/dist/esm/formatters/number.mjs +1 -15
  256. package/dist/esm/formatters/number.mjs.map +1 -1
  257. package/dist/esm/formatters/percentage.mjs +1 -22
  258. package/dist/esm/formatters/percentage.mjs.map +1 -1
  259. package/dist/esm/formatters/relativeTime.mjs +1 -30
  260. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  261. package/dist/esm/formatters/units.mjs +1 -20
  262. package/dist/esm/formatters/units.mjs.map +1 -1
  263. package/dist/esm/getStorageAttributes.mjs +1 -132
  264. package/dist/esm/getStorageAttributes.mjs.map +1 -1
  265. package/dist/esm/index.mjs +1 -82
  266. package/dist/esm/interpreter/getCondition.mjs +1 -25
  267. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  268. package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -39
  269. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  270. package/dist/esm/interpreter/getContent/getContent.mjs +1 -31
  271. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  272. package/dist/esm/interpreter/getContent/index.mjs +1 -5
  273. package/dist/esm/interpreter/getContent/plugins.mjs +1 -153
  274. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  275. package/dist/esm/interpreter/getDictionary.mjs +1 -23
  276. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  277. package/dist/esm/interpreter/getEnumeration.mjs +1 -69
  278. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  279. package/dist/esm/interpreter/getGender.mjs +1 -36
  280. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  281. package/dist/esm/interpreter/getHTML.mjs +1 -119
  282. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  283. package/dist/esm/interpreter/getInsertion.mjs +1 -20
  284. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  285. package/dist/esm/interpreter/getIntlayer.mjs +1 -36
  286. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  287. package/dist/esm/interpreter/getNesting.mjs +1 -35
  288. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  289. package/dist/esm/interpreter/getTranslation.mjs +1 -110
  290. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  291. package/dist/esm/interpreter/index.mjs +1 -13
  292. package/dist/esm/interpreter/splitAndJoinInsertion.mjs +1 -53
  293. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  294. package/dist/esm/localization/getBrowserLocale.mjs +1 -138
  295. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  296. package/dist/esm/localization/getHTMLTextDir.mjs +1 -62
  297. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  298. package/dist/esm/localization/getLocale.mjs +1 -24
  299. package/dist/esm/localization/getLocale.mjs.map +1 -1
  300. package/dist/esm/localization/getLocaleFromPath.mjs +1 -42
  301. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  302. package/dist/esm/localization/getLocaleLang.mjs +1 -18
  303. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  304. package/dist/esm/localization/getLocaleName.mjs +1 -9
  305. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  306. package/dist/esm/localization/getLocalizedUrl.mjs +1 -79
  307. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  308. package/dist/esm/localization/getMultilingualUrls.mjs +1 -60
  309. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  310. package/dist/esm/localization/getPathWithoutLocale.mjs +1 -52
  311. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  312. package/dist/esm/localization/getPrefix.mjs +1 -60
  313. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  314. package/dist/esm/localization/index.mjs +1 -17
  315. package/dist/esm/localization/localeDetector.mjs +1 -131
  316. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  317. package/dist/esm/localization/localeMapper.mjs +1 -114
  318. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  319. package/dist/esm/localization/localeResolver.mjs +1 -25
  320. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  321. package/dist/esm/localization/rewriteUtils.mjs +1 -104
  322. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  323. package/dist/esm/localization/validatePrefix.mjs +1 -51
  324. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  325. package/dist/esm/markdown/compiler.mjs +10 -786
  326. package/dist/esm/markdown/compiler.mjs.map +1 -1
  327. package/dist/esm/markdown/constants.mjs +1 -247
  328. package/dist/esm/markdown/constants.mjs.map +1 -1
  329. package/dist/esm/markdown/index.mjs +1 -7
  330. package/dist/esm/markdown/parser.mjs +1 -65
  331. package/dist/esm/markdown/parser.mjs.map +1 -1
  332. package/dist/esm/markdown/renderer.mjs +1 -59
  333. package/dist/esm/markdown/renderer.mjs.map +1 -1
  334. package/dist/esm/markdown/utils.mjs +6 -361
  335. package/dist/esm/markdown/utils.mjs.map +1 -1
  336. package/dist/esm/messageFormat/ICU.mjs +1 -316
  337. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  338. package/dist/esm/messageFormat/i18next.mjs +1 -327
  339. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  340. package/dist/esm/messageFormat/index.mjs +1 -5
  341. package/dist/esm/messageFormat/verify-icu-format.mjs +2 -64
  342. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  343. package/dist/esm/messageFormat/vue-i18n.mjs +1 -163
  344. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  345. package/dist/esm/transpiler/condition/condition.mjs +1 -24
  346. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  347. package/dist/esm/transpiler/condition/index.mjs +1 -3
  348. package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -26
  349. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  350. package/dist/esm/transpiler/enumeration/index.mjs +1 -3
  351. package/dist/esm/transpiler/file/file.mjs +1 -49
  352. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  353. package/dist/esm/transpiler/file/fileBrowser.mjs +1 -24
  354. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  355. package/dist/esm/transpiler/file/index.mjs +1 -3
  356. package/dist/esm/transpiler/gender/gender.mjs +1 -24
  357. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  358. package/dist/esm/transpiler/gender/index.mjs +1 -3
  359. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -43
  360. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  361. package/dist/esm/transpiler/html/html.mjs +1 -35
  362. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  363. package/dist/esm/transpiler/html/htmlTags.mjs +1 -114
  364. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  365. package/dist/esm/transpiler/html/index.mjs +1 -4
  366. package/dist/esm/transpiler/index.mjs +1 -13
  367. package/dist/esm/transpiler/insertion/getInsertionValues.mjs +1 -9
  368. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  369. package/dist/esm/transpiler/insertion/index.mjs +1 -4
  370. package/dist/esm/transpiler/insertion/insertion.mjs +1 -34
  371. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  372. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +2 -22
  373. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  374. package/dist/esm/transpiler/markdown/index.mjs +1 -4
  375. package/dist/esm/transpiler/markdown/markdown.mjs +1 -52
  376. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  377. package/dist/esm/transpiler/nesting/index.mjs +1 -3
  378. package/dist/esm/transpiler/nesting/nesting.mjs +1 -25
  379. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  380. package/dist/esm/transpiler/translation/index.mjs +1 -3
  381. package/dist/esm/transpiler/translation/translation.mjs +1 -27
  382. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  383. package/dist/esm/utils/checkIsURLAbsolute.mjs +1 -5
  384. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  385. package/dist/esm/utils/getCookie.mjs +1 -30
  386. package/dist/esm/utils/getCookie.mjs.map +1 -1
  387. package/dist/esm/utils/index.mjs +1 -0
  388. package/dist/esm/utils/intl.mjs +1 -86
  389. package/dist/esm/utils/intl.mjs.map +1 -1
  390. package/dist/esm/utils/isSameKeyPath.mjs +1 -5
  391. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  392. package/dist/esm/utils/isValidReactElement.mjs +1 -12
  393. package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
  394. package/dist/esm/utils/localeStorage.mjs +1 -135
  395. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  396. package/dist/esm/utils/parseYaml.mjs +16 -320
  397. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  398. package/dist/types/formatters/index.d.ts +2 -1
  399. package/dist/types/index.d.ts +8 -2
  400. package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
  401. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  402. package/dist/types/localization/index.d.ts +2 -1
  403. package/dist/types/markdown/index.d.ts +4 -1
  404. package/dist/types/markdown/types.d.ts +1 -1
  405. package/dist/types/markdown/types.d.ts.map +1 -1
  406. package/dist/types/transpiler/translation/translation.d.ts +1 -1
  407. package/dist/types/utils/index.d.ts +8 -0
  408. package/package.json +65 -11
@@ -1,87 +1,2 @@
1
- import { Locales } from "@intlayer/types";
2
-
3
- //#region src/utils/intl.ts
4
- /**
5
- * Optimized Cache Key Generator
6
- * 1. Fast path: If no options, just use the locale string.
7
- * 2. Normal path: JSON.stringify for deterministic object comparison.
8
- */
9
- const getCacheKey = (locales, options) => {
10
- const localeKey = locales ? String(locales) : Locales.ENGLISH;
11
- if (!options) return localeKey;
12
- return `${localeKey}|${JSON.stringify(options)}`;
13
- };
14
- /**
15
- * Generic wrapper for any `new Intl.*()` constructor.
16
- */
17
- const createCachedConstructor = (Ctor) => {
18
- const cache = /* @__PURE__ */ new Map();
19
- const MAX_CACHE_SIZE = 50;
20
- function Wrapped(locales, options) {
21
- let resolvedLocales = locales;
22
- let resolvedOptions = options;
23
- if (typeof locales === "object" && !Array.isArray(locales) && locales !== null) {
24
- resolvedOptions = locales;
25
- resolvedLocales = locales.locale;
26
- }
27
- if (Ctor.name === "DisplayNames" && typeof Intl?.DisplayNames !== "function") {}
28
- const key = getCacheKey(resolvedLocales, resolvedOptions);
29
- let instance = cache.get(key);
30
- if (instance) return instance;
31
- instance = new Ctor(resolvedLocales, resolvedOptions);
32
- if (cache.size >= MAX_CACHE_SIZE) {
33
- const oldestKey = cache.keys().next().value;
34
- if (oldestKey) cache.delete(oldestKey);
35
- }
36
- cache.set(key, instance);
37
- return instance;
38
- }
39
- Wrapped.prototype = Ctor.prototype;
40
- return Wrapped;
41
- };
42
- /**
43
- * Factory that turns the global `Intl` into a cached clone.
44
- */
45
- const createCachedIntl = () => {
46
- const constructorCache = /* @__PURE__ */ new Map();
47
- return new Proxy(Intl, { get: (target, prop, receiver) => {
48
- if (constructorCache.has(prop)) return constructorCache.get(prop);
49
- const value = Reflect.get(target, prop, receiver);
50
- if (typeof value === "function" && typeof prop === "string" && /^[A-Z]/.test(prop)) {
51
- const wrapped = createCachedConstructor(value);
52
- constructorCache.set(prop, wrapped);
53
- return wrapped;
54
- }
55
- return value;
56
- } });
57
- };
58
- const CachedIntl = createCachedIntl();
59
- /**
60
- * Creates a proxied Intl object with a preset locale.
61
- *
62
- * @example
63
- * const intl = bindIntl(Locales.FRENCH);
64
- * new intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' }).format(10);
65
- * // Uses 'fr' automatically
66
- */
67
- const bindIntl = (locale) => {
68
- return new Proxy(CachedIntl, { get: (target, prop) => {
69
- const value = Reflect.get(target, prop);
70
- if (typeof value === "function" && typeof prop === "string" && /^[A-Z]/.test(prop)) return new Proxy(value, {
71
- construct: (Ctor, args) => {
72
- let [locales, options] = args;
73
- if (typeof locales === "object" && !Array.isArray(locales) && locales !== null) {
74
- options = locales;
75
- locales = options.locale ?? locale;
76
- } else if (locales === void 0) locales = locale;
77
- return new Ctor(locales, options);
78
- },
79
- get: (Ctor, key) => Reflect.get(Ctor, key)
80
- });
81
- return value;
82
- } });
83
- };
84
-
85
- //#endregion
86
- export { CachedIntl, CachedIntl as Intl, bindIntl, createCachedIntl };
1
+ import{Locales as e}from"@intlayer/types";const t=(t,n)=>{let r=t?String(t):e.ENGLISH;return n?`${r}|${JSON.stringify(n)}`:r},n=e=>{let n=new Map;function r(r,i){let a=r,o=i;typeof r==`object`&&!Array.isArray(r)&&r!==null&&(o=r,a=r.locale),e.name===`DisplayNames`&&Intl?.DisplayNames;let s=t(a,o),c=n.get(s);if(c)return c;if(c=new e(a,o),n.size>=50){let e=n.keys().next().value;e&&n.delete(e)}return n.set(s,c),c}return r.prototype=e.prototype,r},r=()=>{let e=new Map;return new Proxy(Intl,{get:(t,r,i)=>{if(e.has(r))return e.get(r);let a=Reflect.get(t,r,i);if(typeof a==`function`&&typeof r==`string`&&/^[A-Z]/.test(r)){let t=n(a);return e.set(r,t),t}return a}})},i=r(),a=e=>new Proxy(i,{get:(t,n)=>{let r=Reflect.get(t,n);return typeof r==`function`&&typeof n==`string`&&/^[A-Z]/.test(n)?new Proxy(r,{construct:(t,n)=>{let[r,i]=n;return typeof r==`object`&&!Array.isArray(r)&&r!==null?(i=r,r=i.locale??e):r===void 0&&(r=e),new t(r,i)},get:(e,t)=>Reflect.get(e,t)}):r}});export{i as CachedIntl,i as Intl,a as bindIntl,r as createCachedIntl};
87
2
  //# sourceMappingURL=intl.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"intl.mjs","names":[],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["// Cached Intl helper – drop‑in replacement for the global `Intl` object.\n// ‑‑‑\n// • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n// • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n// reuse the same heavy instance instead of reparsing CLDR data every time.\n// • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n// • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n// you can treat `CachedIntl` just like the built‑in `Intl`.\n//\n// Usage examples:\n// ---------------\n// import { CachedIntl } from \"./cached-intl\";\n//\n// const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n// console.log(nf.format(1234));\n//\n// const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n// console.log(dn.of(\"en\")); // → \"anglais\"\n//\n// You can also spin up an isolated instance with its own caches (handy in test suites):\n// const TestIntl = createCachedIntl();\n//\n// ---------------------------------------------------------------------\n\nimport { Locales, type LocalesValues } from '@intlayer/types';\n\n// Helper type that picks just the constructor members off `typeof Intl`.\n// The \"capital‑letter\" heuristic is 100 % accurate today and keeps the\n// mapping short‑lived, so we don't have to manually list every constructor.\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\n// Type wrapper to replace locale arguments with LocalesValues\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\n// Wrapped Intl type with LocalesValues\ntype WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n// ... (Keep your Type Helper definitions here: IntlConstructors, ReplaceLocaleWithLocalesValues, WrappedIntl) ...\n\n/**\n * Optimized Cache Key Generator\n * 1. Fast path: If no options, just use the locale string.\n * 2. Normal path: JSON.stringify for deterministic object comparison.\n */\nconst getCacheKey = (\n locales: LocalesValues | undefined,\n options: unknown\n): string => {\n const localeKey = locales ? String(locales) : Locales.ENGLISH;\n\n if (!options) return localeKey;\n\n // JSON.stringify is the most robust way to handle nested options objects\n // without a heavy custom hashing function.\n return `${localeKey}|${JSON.stringify(options)}`;\n};\n\n/**\n * Generic wrapper for any `new Intl.*()` constructor.\n */\nconst createCachedConstructor = <T extends new (...args: any[]) => any>(\n Ctor: T\n) => {\n // The cache lives here, inside the closure of the wrapped constructor.\n const cache = new Map<string, InstanceType<T>>();\n const MAX_CACHE_SIZE = 50;\n\n function Wrapped(locales?: LocalesValues | any, options?: any) {\n let resolvedLocales = locales;\n let resolvedOptions = options;\n\n // Handle case where first argument is an options object instead of locales\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n resolvedOptions = locales;\n resolvedLocales = locales.locale;\n }\n\n // Handle DisplayNames Polyfill warning\n if (\n Ctor.name === 'DisplayNames' &&\n typeof (Intl as any)?.DisplayNames !== 'function'\n ) {\n // ... (Existing polyfill logic would go here if needed, but let's keep it simple for now as it was empty in the read output)\n // Actually the read output had \"// ... (Your existing polyfill warning logic) ...\"\n // I should check what was there before or just preserve it.\n }\n\n // Generate Key\n const key = getCacheKey(resolvedLocales, resolvedOptions);\n\n // Check Cache\n let instance = cache.get(key);\n if (instance) return instance;\n\n // Create New Instance\n instance = new Ctor(resolvedLocales as never, resolvedOptions as never);\n\n // Smart Eviction (LRU-ish)\n // Map iterates in insertion order. Deleting the first key removes the \"oldest\".\n if (cache.size >= MAX_CACHE_SIZE) {\n const oldestKey = cache.keys().next().value;\n if (oldestKey) cache.delete(oldestKey);\n }\n\n cache.set(key, instance as InstanceType<T>);\n return instance as InstanceType<T>;\n }\n\n // Preserve prototype for `instanceof` checks\n (Wrapped as any).prototype = (Ctor as any).prototype;\n\n return Wrapped as unknown as ReplaceLocaleWithLocalesValues<T>;\n};\n\n/**\n * Factory that turns the global `Intl` into a cached clone.\n */\nexport const createCachedIntl = (): WrappedIntl => {\n // We must cache the *wrapped constructors* themselves.\n // Otherwise, the Proxy creates a new `Wrapped` function (and a new empty Map)\n // on every single property access.\n const constructorCache = new Map<string | symbol, any>();\n\n return new Proxy(Intl as IntlConstructors, {\n get: (target, prop, receiver) => {\n // Fast return if we already wrapped this constructor\n if (constructorCache.has(prop)) {\n return constructorCache.get(prop);\n }\n\n const value = Reflect.get(target, prop, receiver);\n\n // Wrap only Constructors (Heuristic: Function + starts with Uppercase)\n // This prevents wrapping static methods like `Intl.getCanonicalLocales`\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n const wrapped = createCachedConstructor(value);\n constructorCache.set(prop, wrapped);\n return wrapped;\n }\n\n // Pass through everything else (static methods, constants)\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\nexport const CachedIntl = createCachedIntl();\n\n/**\n * Creates a proxied Intl object with a preset locale.\n *\n * @example\n * const intl = bindIntl(Locales.FRENCH);\n * new intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' }).format(10);\n * // Uses 'fr' automatically\n */\nexport const bindIntl = (locale: LocalesValues): WrappedIntl => {\n return new Proxy(CachedIntl, {\n get: (target, prop) => {\n const value = Reflect.get(target, prop);\n\n // We only want to intercept Constructors (e.g., NumberFormat, DateTimeFormat)\n // to inject the locale into their arguments.\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n return new Proxy(value, {\n construct: (Ctor, args) => {\n let [locales, options] = args;\n\n // If the user provided a locale (args[0]), respect it.\n // If args[0] is undefined, inject the bound locale.\n // If args[0] is an object (not array), it's the options object.\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n options = locales;\n locales = options.locale ?? locale;\n } else if (locales === undefined) {\n locales = locale;\n }\n\n // We pass it to `CachedIntl` which handles caching logic.\n return new Ctor(locales, options);\n },\n // Ensure static methods (like supportedLocalesOf) still work\n get: (Ctor, key) => Reflect.get(Ctor, key),\n });\n }\n\n // Return constants or static methods as-is\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\n// new CachedIntl.DisplayNames(Locales.FRENCH, { type: 'language' });\n// new CachedIntl.DisplayNames('fr', { type: 'language' });\n// new CachedIntl.DateTimeFormat('fr', {\n// year: 'numeric',\n// month: 'long',\n// day: 'numeric',\n// });\n// new CachedIntl.NumberFormat('fr', {\n// style: 'currency',\n// currency: 'EUR',\n// });\n// new CachedIntl.Collator('fr', { sensitivity: 'base' });\n// new CachedIntl.PluralRules('fr');\n// new CachedIntl.RelativeTimeFormat('fr', { numeric: 'auto' });\n// new CachedIntl.ListFormat('fr', { type: 'conjunction' });\nexport { CachedIntl as Intl };\n"],"mappings":";;;;;;;;AAqEA,MAAM,eACJ,SACA,YACW;CACX,MAAM,YAAY,UAAU,OAAO,QAAQ,GAAG,QAAQ;AAEtD,KAAI,CAAC,QAAS,QAAO;AAIrB,QAAO,GAAG,UAAU,GAAG,KAAK,UAAU,QAAQ;;;;;AAMhD,MAAM,2BACJ,SACG;CAEH,MAAM,wBAAQ,IAAI,KAA8B;CAChD,MAAM,iBAAiB;CAEvB,SAAS,QAAQ,SAA+B,SAAe;EAC7D,IAAI,kBAAkB;EACtB,IAAI,kBAAkB;AAGtB,MACE,OAAO,YAAY,YACnB,CAAC,MAAM,QAAQ,QAAQ,IACvB,YAAY,MACZ;AACA,qBAAkB;AAClB,qBAAkB,QAAQ;;AAI5B,MACE,KAAK,SAAS,kBACd,OAAQ,MAAc,iBAAiB,YACvC;EAOF,MAAM,MAAM,YAAY,iBAAiB,gBAAgB;EAGzD,IAAI,WAAW,MAAM,IAAI,IAAI;AAC7B,MAAI,SAAU,QAAO;AAGrB,aAAW,IAAI,KAAK,iBAA0B,gBAAyB;AAIvE,MAAI,MAAM,QAAQ,gBAAgB;GAChC,MAAM,YAAY,MAAM,MAAM,CAAC,MAAM,CAAC;AACtC,OAAI,UAAW,OAAM,OAAO,UAAU;;AAGxC,QAAM,IAAI,KAAK,SAA4B;AAC3C,SAAO;;AAIT,CAAC,QAAgB,YAAa,KAAa;AAE3C,QAAO;;;;;AAMT,MAAa,yBAAsC;CAIjD,MAAM,mCAAmB,IAAI,KAA2B;AAExD,QAAO,IAAI,MAAM,MAA0B,EACzC,MAAM,QAAQ,MAAM,aAAa;AAE/B,MAAI,iBAAiB,IAAI,KAAK,CAC5B,QAAO,iBAAiB,IAAI,KAAK;EAGnC,MAAM,QAAQ,QAAQ,IAAI,QAAQ,MAAM,SAAS;AAIjD,MACE,OAAO,UAAU,cACjB,OAAO,SAAS,YAChB,SAAS,KAAK,KAAK,EACnB;GACA,MAAM,UAAU,wBAAwB,MAAM;AAC9C,oBAAiB,IAAI,MAAM,QAAQ;AACnC,UAAO;;AAIT,SAAO;IAEV,CAAC;;AAGJ,MAAa,aAAa,kBAAkB;;;;;;;;;AAU5C,MAAa,YAAY,WAAuC;AAC9D,QAAO,IAAI,MAAM,YAAY,EAC3B,MAAM,QAAQ,SAAS;EACrB,MAAM,QAAQ,QAAQ,IAAI,QAAQ,KAAK;AAIvC,MACE,OAAO,UAAU,cACjB,OAAO,SAAS,YAChB,SAAS,KAAK,KAAK,CAEnB,QAAO,IAAI,MAAM,OAAO;GACtB,YAAY,MAAM,SAAS;IACzB,IAAI,CAAC,SAAS,WAAW;AAKzB,QACE,OAAO,YAAY,YACnB,CAAC,MAAM,QAAQ,QAAQ,IACvB,YAAY,MACZ;AACA,eAAU;AACV,eAAU,QAAQ,UAAU;eACnB,YAAY,OACrB,WAAU;AAIZ,WAAO,IAAI,KAAK,SAAS,QAAQ;;GAGnC,MAAM,MAAM,QAAQ,QAAQ,IAAI,MAAM,IAAI;GAC3C,CAAC;AAIJ,SAAO;IAEV,CAAC"}
1
+ {"version":3,"file":"intl.mjs","names":[],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["// Cached Intl helper – drop‑in replacement for the global `Intl` object.\n// ‑‑‑\n// • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n// • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n// reuse the same heavy instance instead of reparsing CLDR data every time.\n// • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n// • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n// you can treat `CachedIntl` just like the built‑in `Intl`.\n//\n// Usage examples:\n// ---------------\n// import { CachedIntl } from \"./cached-intl\";\n//\n// const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n// console.log(nf.format(1234));\n//\n// const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n// console.log(dn.of(\"en\")); // → \"anglais\"\n//\n// You can also spin up an isolated instance with its own caches (handy in test suites):\n// const TestIntl = createCachedIntl();\n//\n// ---------------------------------------------------------------------\n\nimport { Locales, type LocalesValues } from '@intlayer/types';\n\n// Helper type that picks just the constructor members off `typeof Intl`.\n// The \"capital‑letter\" heuristic is 100 % accurate today and keeps the\n// mapping short‑lived, so we don't have to manually list every constructor.\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\n// Type wrapper to replace locale arguments with LocalesValues\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\n// Wrapped Intl type with LocalesValues\ntype WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n// ... (Keep your Type Helper definitions here: IntlConstructors, ReplaceLocaleWithLocalesValues, WrappedIntl) ...\n\n/**\n * Optimized Cache Key Generator\n * 1. Fast path: If no options, just use the locale string.\n * 2. Normal path: JSON.stringify for deterministic object comparison.\n */\nconst getCacheKey = (\n locales: LocalesValues | undefined,\n options: unknown\n): string => {\n const localeKey = locales ? String(locales) : Locales.ENGLISH;\n\n if (!options) return localeKey;\n\n // JSON.stringify is the most robust way to handle nested options objects\n // without a heavy custom hashing function.\n return `${localeKey}|${JSON.stringify(options)}`;\n};\n\n/**\n * Generic wrapper for any `new Intl.*()` constructor.\n */\nconst createCachedConstructor = <T extends new (...args: any[]) => any>(\n Ctor: T\n) => {\n // The cache lives here, inside the closure of the wrapped constructor.\n const cache = new Map<string, InstanceType<T>>();\n const MAX_CACHE_SIZE = 50;\n\n function Wrapped(locales?: LocalesValues | any, options?: any) {\n let resolvedLocales = locales;\n let resolvedOptions = options;\n\n // Handle case where first argument is an options object instead of locales\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n resolvedOptions = locales;\n resolvedLocales = locales.locale;\n }\n\n // Handle DisplayNames Polyfill warning\n if (\n Ctor.name === 'DisplayNames' &&\n typeof (Intl as any)?.DisplayNames !== 'function'\n ) {\n // ... (Existing polyfill logic would go here if needed, but let's keep it simple for now as it was empty in the read output)\n // Actually the read output had \"// ... (Your existing polyfill warning logic) ...\"\n // I should check what was there before or just preserve it.\n }\n\n // Generate Key\n const key = getCacheKey(resolvedLocales, resolvedOptions);\n\n // Check Cache\n let instance = cache.get(key);\n if (instance) return instance;\n\n // Create New Instance\n instance = new Ctor(resolvedLocales as never, resolvedOptions as never);\n\n // Smart Eviction (LRU-ish)\n // Map iterates in insertion order. Deleting the first key removes the \"oldest\".\n if (cache.size >= MAX_CACHE_SIZE) {\n const oldestKey = cache.keys().next().value;\n if (oldestKey) cache.delete(oldestKey);\n }\n\n cache.set(key, instance as InstanceType<T>);\n return instance as InstanceType<T>;\n }\n\n // Preserve prototype for `instanceof` checks\n (Wrapped as any).prototype = (Ctor as any).prototype;\n\n return Wrapped as unknown as ReplaceLocaleWithLocalesValues<T>;\n};\n\n/**\n * Factory that turns the global `Intl` into a cached clone.\n */\nexport const createCachedIntl = (): WrappedIntl => {\n // We must cache the *wrapped constructors* themselves.\n // Otherwise, the Proxy creates a new `Wrapped` function (and a new empty Map)\n // on every single property access.\n const constructorCache = new Map<string | symbol, any>();\n\n return new Proxy(Intl as IntlConstructors, {\n get: (target, prop, receiver) => {\n // Fast return if we already wrapped this constructor\n if (constructorCache.has(prop)) {\n return constructorCache.get(prop);\n }\n\n const value = Reflect.get(target, prop, receiver);\n\n // Wrap only Constructors (Heuristic: Function + starts with Uppercase)\n // This prevents wrapping static methods like `Intl.getCanonicalLocales`\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n const wrapped = createCachedConstructor(value);\n constructorCache.set(prop, wrapped);\n return wrapped;\n }\n\n // Pass through everything else (static methods, constants)\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\nexport const CachedIntl = createCachedIntl();\n\n/**\n * Creates a proxied Intl object with a preset locale.\n *\n * @example\n * const intl = bindIntl(Locales.FRENCH);\n * new intl.NumberFormat(undefined, { style: 'currency', currency: 'EUR' }).format(10);\n * // Uses 'fr' automatically\n */\nexport const bindIntl = (locale: LocalesValues): WrappedIntl => {\n return new Proxy(CachedIntl, {\n get: (target, prop) => {\n const value = Reflect.get(target, prop);\n\n // We only want to intercept Constructors (e.g., NumberFormat, DateTimeFormat)\n // to inject the locale into their arguments.\n if (\n typeof value === 'function' &&\n typeof prop === 'string' &&\n /^[A-Z]/.test(prop)\n ) {\n return new Proxy(value, {\n construct: (Ctor, args) => {\n let [locales, options] = args;\n\n // If the user provided a locale (args[0]), respect it.\n // If args[0] is undefined, inject the bound locale.\n // If args[0] is an object (not array), it's the options object.\n if (\n typeof locales === 'object' &&\n !Array.isArray(locales) &&\n locales !== null\n ) {\n options = locales;\n locales = options.locale ?? locale;\n } else if (locales === undefined) {\n locales = locale;\n }\n\n // We pass it to `CachedIntl` which handles caching logic.\n return new Ctor(locales, options);\n },\n // Ensure static methods (like supportedLocalesOf) still work\n get: (Ctor, key) => Reflect.get(Ctor, key),\n });\n }\n\n // Return constants or static methods as-is\n return value;\n },\n }) as unknown as WrappedIntl;\n};\n\n// new CachedIntl.DisplayNames(Locales.FRENCH, { type: 'language' });\n// new CachedIntl.DisplayNames('fr', { type: 'language' });\n// new CachedIntl.DateTimeFormat('fr', {\n// year: 'numeric',\n// month: 'long',\n// day: 'numeric',\n// });\n// new CachedIntl.NumberFormat('fr', {\n// style: 'currency',\n// currency: 'EUR',\n// });\n// new CachedIntl.Collator('fr', { sensitivity: 'base' });\n// new CachedIntl.PluralRules('fr');\n// new CachedIntl.RelativeTimeFormat('fr', { numeric: 'auto' });\n// new CachedIntl.ListFormat('fr', { type: 'conjunction' });\nexport { CachedIntl as Intl };\n"],"mappings":"0CAqEA,MAAM,GACJ,EACA,IACW,CACX,IAAM,EAAY,EAAU,OAAO,EAAQ,CAAG,EAAQ,QAMtD,OAJK,EAIE,GAAG,EAAU,GAAG,KAAK,UAAU,EAAQ,GAJzB,GAUjB,EACJ,GACG,CAEH,IAAM,EAAQ,IAAI,IAGlB,SAAS,EAAQ,EAA+B,EAAe,CAC7D,IAAI,EAAkB,EAClB,EAAkB,EAIpB,OAAO,GAAY,UACnB,CAAC,MAAM,QAAQ,EAAQ,EACvB,IAAY,OAEZ,EAAkB,EAClB,EAAkB,EAAQ,QAK1B,EAAK,OAAS,gBACN,MAAc,aAQxB,IAAM,EAAM,EAAY,EAAiB,EAAgB,CAGrD,EAAW,EAAM,IAAI,EAAI,CAC7B,GAAI,EAAU,OAAO,EAOrB,GAJA,EAAW,IAAI,EAAK,EAA0B,EAAyB,CAInE,EAAM,MAAQ,GAAgB,CAChC,IAAM,EAAY,EAAM,MAAM,CAAC,MAAM,CAAC,MAClC,GAAW,EAAM,OAAO,EAAU,CAIxC,OADA,EAAM,IAAI,EAAK,EAA4B,CACpC,EAMT,MAFC,GAAgB,UAAa,EAAa,UAEpC,GAMI,MAAsC,CAIjD,IAAM,EAAmB,IAAI,IAE7B,OAAO,IAAI,MAAM,KAA0B,CACzC,KAAM,EAAQ,EAAM,IAAa,CAE/B,GAAI,EAAiB,IAAI,EAAK,CAC5B,OAAO,EAAiB,IAAI,EAAK,CAGnC,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAM,EAAS,CAIjD,GACE,OAAO,GAAU,YACjB,OAAO,GAAS,UAChB,SAAS,KAAK,EAAK,CACnB,CACA,IAAM,EAAU,EAAwB,EAAM,CAE9C,OADA,EAAiB,IAAI,EAAM,EAAQ,CAC5B,EAIT,OAAO,GAEV,CAAC,EAGS,EAAa,GAAkB,CAU/B,EAAY,GAChB,IAAI,MAAM,EAAY,CAC3B,KAAM,EAAQ,IAAS,CACrB,IAAM,EAAQ,QAAQ,IAAI,EAAQ,EAAK,CAoCvC,OA/BE,OAAO,GAAU,YACjB,OAAO,GAAS,UAChB,SAAS,KAAK,EAAK,CAEZ,IAAI,MAAM,EAAO,CACtB,WAAY,EAAM,IAAS,CACzB,GAAI,CAAC,EAAS,GAAW,EAiBzB,OAXE,OAAO,GAAY,UACnB,CAAC,MAAM,QAAQ,EAAQ,EACvB,IAAY,MAEZ,EAAU,EACV,EAAU,EAAQ,QAAU,GACnB,IAAY,IAAA,KACrB,EAAU,GAIL,IAAI,EAAK,EAAS,EAAQ,EAGnC,KAAM,EAAM,IAAQ,QAAQ,IAAI,EAAM,EAAI,CAC3C,CAAC,CAIG,GAEV,CAAC"}
@@ -1,6 +1,2 @@
1
- //#region src/utils/isSameKeyPath.ts
2
- const isSameKeyPath = (keyPath1, keyPath2) => keyPath1.every((element, index) => keyPath2[index] && keyPath2[index].key === element.key && keyPath2[index].type === element.type);
3
-
4
- //#endregion
5
- export { isSameKeyPath };
1
+ const e=(e,t)=>e.every((e,n)=>t[n]&&t[n].key===e.key&&t[n].type===e.type);export{e as isSameKeyPath};
6
2
  //# sourceMappingURL=isSameKeyPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"isSameKeyPath.mjs","names":[],"sources":["../../../src/utils/isSameKeyPath.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types';\n\ntype KeyPathWithKey = KeyPath & { key: string };\n\nexport const isSameKeyPath = (keyPath1: KeyPath[], keyPath2: KeyPath[]) =>\n keyPath1.every(\n (element, index) =>\n keyPath2[index] &&\n (keyPath2[index] as KeyPathWithKey).key ===\n (element as KeyPathWithKey).key &&\n keyPath2[index].type === element.type\n );\n"],"mappings":";AAIA,MAAa,iBAAiB,UAAqB,aACjD,SAAS,OACN,SAAS,UACR,SAAS,UACR,SAAS,OAA0B,QACjC,QAA2B,OAC9B,SAAS,OAAO,SAAS,QAAQ,KACpC"}
1
+ {"version":3,"file":"isSameKeyPath.mjs","names":[],"sources":["../../../src/utils/isSameKeyPath.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types';\n\ntype KeyPathWithKey = KeyPath & { key: string };\n\nexport const isSameKeyPath = (keyPath1: KeyPath[], keyPath2: KeyPath[]) =>\n keyPath1.every(\n (element, index) =>\n keyPath2[index] &&\n (keyPath2[index] as KeyPathWithKey).key ===\n (element as KeyPathWithKey).key &&\n keyPath2[index].type === element.type\n );\n"],"mappings":"AAIA,MAAa,GAAiB,EAAqB,IACjD,EAAS,OACN,EAAS,IACR,EAAS,IACR,EAAS,GAA0B,MACjC,EAA2B,KAC9B,EAAS,GAAO,OAAS,EAAQ,KACpC"}
@@ -1,13 +1,2 @@
1
- //#region src/utils/isValidReactElement.ts
2
- /**
3
- * Verifies the object is a ReactElement.
4
- * See https://reactjs.org/docs/react-api.html#isvalidelement
5
- * @param object
6
- * @return True if `object` is a ReactElement.
7
- * @final
8
- */
9
- const isValidElement = (object) => typeof object === "object" && typeof object?.key !== "undefined" && typeof object?.props !== "undefined";
10
-
11
- //#endregion
12
- export { isValidElement };
1
+ const e=e=>typeof e==`object`&&e?.key!==void 0&&e?.props!==void 0;export{e as isValidElement};
13
2
  //# sourceMappingURL=isValidReactElement.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"isValidReactElement.mjs","names":[],"sources":["../../../src/utils/isValidReactElement.ts"],"sourcesContent":["/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param object\n * @return True if `object` is a ReactElement.\n * @final\n */\n\nexport const isValidElement = (object: any): boolean =>\n typeof object === 'object' &&\n typeof object?.key !== 'undefined' &&\n typeof object?.props !== 'undefined';\n"],"mappings":";;;;;;;;AAQA,MAAa,kBAAkB,WAC7B,OAAO,WAAW,YAClB,OAAO,QAAQ,QAAQ,eACvB,OAAO,QAAQ,UAAU"}
1
+ {"version":3,"file":"isValidReactElement.mjs","names":[],"sources":["../../../src/utils/isValidReactElement.ts"],"sourcesContent":["/**\n * Verifies the object is a ReactElement.\n * See https://reactjs.org/docs/react-api.html#isvalidelement\n * @param object\n * @return True if `object` is a ReactElement.\n * @final\n */\n\nexport const isValidElement = (object: any): boolean =>\n typeof object === 'object' &&\n typeof object?.key !== 'undefined' &&\n typeof object?.props !== 'undefined';\n"],"mappings":"AAQA,MAAa,EAAkB,GAC7B,OAAO,GAAW,UACX,GAAQ,MAAQ,QAChB,GAAQ,QAAU"}
@@ -1,136 +1,2 @@
1
- import { getStorageAttributes } from "../getStorageAttributes.mjs";
2
- import { getCookie } from "./getCookie.mjs";
3
- import configuration from "@intlayer/config/built";
4
-
5
- //#region src/utils/localeStorage.ts
6
- const buildCookieString = (name, value, attributes) => {
7
- const parts = [`${name}=${encodeURIComponent(value)}`];
8
- if (attributes.path) parts.push(`Path=${attributes.path}`);
9
- if (attributes.domain) parts.push(`Domain=${attributes.domain}`);
10
- if (attributes.expires instanceof Date) parts.push(`Expires=${attributes.expires.toUTCString()}`);
11
- if (attributes.secure) parts.push("Secure");
12
- if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);
13
- return parts.join("; ");
14
- };
15
- /**
16
- * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
17
- * The function checks storage locations in order of priority as defined in the configuration.
18
- *
19
- * @returns The locale if found in any storage, or undefined if not found
20
- */
21
- const getLocaleFromStorage = (options) => {
22
- const { routing, internationalization } = configuration;
23
- const { locales } = internationalization;
24
- const { storage } = routing;
25
- if (storage === false || options?.isCookieEnabled === false) return void 0;
26
- const storageAttributes = getStorageAttributes(storage);
27
- const isValidLocale = (value) => {
28
- if (!value) return false;
29
- return locales.includes(value);
30
- };
31
- const readCookie = (name) => {
32
- try {
33
- const fromOption = options?.getCookie?.(name);
34
- if (fromOption !== null && fromOption !== void 0) return fromOption;
35
- } catch {}
36
- return getCookie(name);
37
- };
38
- for (let i = 0; i < storageAttributes.cookies.length; i++) {
39
- const { name } = storageAttributes.cookies[i];
40
- const value = readCookie(name);
41
- if (isValidLocale(value)) return value;
42
- }
43
- for (let i = 0; i < storageAttributes.localStorage.length; i++) {
44
- const { name } = storageAttributes.localStorage[i];
45
- try {
46
- const value = options?.getLocaleStorage?.(name);
47
- if (isValidLocale(value)) return value;
48
- } catch {}
49
- }
50
- for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
51
- const { name } = storageAttributes.sessionStorage[i];
52
- try {
53
- const value = options?.getSessionStorage?.(name);
54
- if (isValidLocale(value)) return value;
55
- } catch {}
56
- }
57
- for (let i = 0; i < storageAttributes.headers.length; i++) {
58
- const { name } = storageAttributes.headers[i];
59
- try {
60
- const value = options?.getHeader?.(name);
61
- if (isValidLocale(value)) return value;
62
- } catch {}
63
- }
64
- };
65
- /**
66
- * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).
67
- * The function writes to all configured storage locations according to their attributes.
68
- * Respects overwrite flags for localStorage and sessionStorage.
69
- *
70
- * @param locale - The locale to store
71
- */
72
- const setLocaleInStorage = (locale, options) => {
73
- if (configuration.routing.storage === false || options?.isCookieEnabled === false) return;
74
- const storageAttributes = getStorageAttributes(configuration.routing.storage);
75
- for (let i = 0; i < storageAttributes.cookies.length; i++) {
76
- const { name, attributes } = storageAttributes.cookies[i];
77
- try {
78
- if (options?.setCookieStore) options?.setCookieStore?.(name, locale, {
79
- ...attributes,
80
- expires: attributes.expires instanceof Date ? attributes.expires.getTime() : attributes.expires
81
- });
82
- } catch {
83
- try {
84
- if (options?.setCookieString) {
85
- const cookieString = buildCookieString(name, locale, attributes);
86
- options?.setCookieString?.(name, cookieString);
87
- }
88
- } catch {}
89
- }
90
- }
91
- if (options?.setLocaleStorage) for (let i = 0; i < storageAttributes.localStorage.length; i++) {
92
- const { name } = storageAttributes.localStorage[i];
93
- try {
94
- if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {
95
- if (options?.getLocaleStorage?.(name)) continue;
96
- }
97
- options?.setLocaleStorage?.(name, locale);
98
- } catch {}
99
- }
100
- if (options?.setSessionStorage) for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {
101
- const { name } = storageAttributes.sessionStorage[i];
102
- try {
103
- if (!(options?.overwrite ?? true) && options?.getSessionStorage) {
104
- if (options?.getSessionStorage?.(name)) continue;
105
- }
106
- options?.setSessionStorage?.(name, locale);
107
- } catch {}
108
- }
109
- if (options?.setHeader) for (let i = 0; i < storageAttributes.headers.length; i++) {
110
- const { name } = storageAttributes.headers[i];
111
- try {
112
- options?.setHeader?.(name, locale);
113
- } catch {}
114
- }
115
- };
116
- /**
117
- * Utility object to get and set the locale in the storage by considering the configuration
118
- *
119
- * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
120
- * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).
121
- * The function checks storage locations in order of priority as defined in the configuration.
122
- *
123
- * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).
124
- * The function writes to all configured storage locations according to their attributes.
125
- * Respects overwrite flags for localStorage and sessionStorage.
126
- *
127
- * @returns The locale if found in any storage, or undefined if not found
128
- */
129
- const LocaleStorage = (options) => ({
130
- getLocale: () => getLocaleFromStorage(options),
131
- setLocale: (locale) => setLocaleInStorage(locale, options)
132
- });
133
-
134
- //#endregion
135
- export { LocaleStorage, getLocaleFromStorage, setLocaleInStorage };
1
+ import{getStorageAttributes as e}from"../getStorageAttributes.mjs";import{getCookie as t}from"./getCookie.mjs";import n from"@intlayer/config/built";const r=(e,t,n)=>{let r=[`${e}=${encodeURIComponent(t)}`];return n.path&&r.push(`Path=${n.path}`),n.domain&&r.push(`Domain=${n.domain}`),n.expires instanceof Date&&r.push(`Expires=${n.expires.toUTCString()}`),n.secure&&r.push(`Secure`),n.sameSite&&r.push(`SameSite=${n.sameSite}`),r.join(`; `)},i=r=>{let{routing:i,internationalization:a}=n,{locales:o}=a,{storage:s}=i;if(s===!1||r?.isCookieEnabled===!1)return;let c=e(s),l=e=>e?o.includes(e):!1,u=e=>{try{let t=r?.getCookie?.(e);if(t!=null)return t}catch{}return t(e)};for(let e=0;e<c.cookies.length;e++){let{name:t}=c.cookies[e],n=u(t);if(l(n))return n}for(let e=0;e<c.localStorage.length;e++){let{name:t}=c.localStorage[e];try{let e=r?.getLocaleStorage?.(t);if(l(e))return e}catch{}}for(let e=0;e<c.sessionStorage.length;e++){let{name:t}=c.sessionStorage[e];try{let e=r?.getSessionStorage?.(t);if(l(e))return e}catch{}}for(let e=0;e<c.headers.length;e++){let{name:t}=c.headers[e];try{let e=r?.getHeader?.(t);if(l(e))return e}catch{}}},a=(t,i)=>{if(n.routing.storage===!1||i?.isCookieEnabled===!1)return;let a=e(n.routing.storage);for(let e=0;e<a.cookies.length;e++){let{name:n,attributes:o}=a.cookies[e];try{i?.setCookieStore&&i?.setCookieStore?.(n,t,{...o,expires:o.expires instanceof Date?o.expires.getTime():o.expires})}catch{try{if(i?.setCookieString){let e=r(n,t,o);i?.setCookieString?.(n,e)}}catch{}}}if(i?.setLocaleStorage)for(let e=0;e<a.localStorage.length;e++){let{name:n}=a.localStorage[e];try{if(!(i?.overwrite??!0)&&i?.getLocaleStorage&&i?.getLocaleStorage?.(n))continue;i?.setLocaleStorage?.(n,t)}catch{}}if(i?.setSessionStorage)for(let e=0;e<a.sessionStorage.length;e++){let{name:n}=a.sessionStorage[e];try{if(!(i?.overwrite??!0)&&i?.getSessionStorage&&i?.getSessionStorage?.(n))continue;i?.setSessionStorage?.(n,t)}catch{}}if(i?.setHeader)for(let e=0;e<a.headers.length;e++){let{name:n}=a.headers[e];try{i?.setHeader?.(n,t)}catch{}}},o=e=>({getLocale:()=>i(e),setLocale:t=>a(t,e)});export{o as LocaleStorage,i as getLocaleFromStorage,a as setLocaleInStorage};
136
2
  //# sourceMappingURL=localeStorage.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"localeStorage.mjs","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { CookiesAttributes, Locale, LocalesValues } from '@intlayer/types';\nimport { getStorageAttributes } from '../getStorageAttributes';\nimport { getCookie } from './getCookie';\n\ntype CookieBuildAttributes = {\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed. Value can be a Number\n * which will be interpreted as days from time of creation or a\n * Date instance. If omitted, the cookie becomes a session cookie.\n */\n expires?: number | undefined;\n};\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\nexport type LocaleStorageOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const { storage } = routing;\n\n // If storage is disabled, return undefined\n if (storage === false || options?.isCookieEnabled === false) return undefined;\n\n const storageAttributes = getStorageAttributes(storage);\n\n const isValidLocale = (value: string | null | undefined): value is Locale => {\n if (!value) return false;\n\n return locales.includes(value as Locale);\n };\n\n const readCookie = (name: string): string | undefined => {\n // Prefer provided getter (server or custom environment)\n try {\n const fromOption = options?.getCookie?.(name);\n\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n\n // Fallback to browser cookie parsing\n return getCookie(name);\n };\n\n // Check cookies first\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name } = storageAttributes.cookies[i];\n\n const value = readCookie(name);\n\n if (isValidLocale(value)) return value;\n }\n\n // Then check localStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const value = options?.getLocaleStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Check sessionStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const value = options?.getSessionStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Finally check header candidates (server only)\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n const value = options?.getHeader?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @param locale - The locale to store\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n // If storage is disabled, do nothing\n if (\n configuration.routing.storage === false ||\n options?.isCookieEnabled === false\n )\n return;\n\n const storageAttributes = getStorageAttributes(configuration.routing.storage);\n\n // Write to cookies (server via setCookie, client via cookieStore/document)\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n\n try {\n if (options?.setCookieStore) {\n options?.setCookieStore?.(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n const cookieString = buildCookieString(name, locale, attributes);\n\n options?.setCookieString?.(name, cookieString);\n }\n } catch {}\n }\n }\n\n // Write to localStorage (browser only)\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getLocaleStorage) {\n const existing = options?.getLocaleStorage?.(name);\n if (existing) continue;\n }\n options?.setLocaleStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to sessionStorage (browser only)\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getSessionStorage) {\n const existing = options?.getSessionStorage?.(name);\n if (existing) continue;\n }\n\n options?.setSessionStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to headers (server only)\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n options?.setHeader?.(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in the storage by considering the configuration\n *\n * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":"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"}
1
+ {"version":3,"file":"localeStorage.mjs","names":[],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { CookiesAttributes, Locale, LocalesValues } from '@intlayer/types';\nimport { getStorageAttributes } from '../getStorageAttributes';\nimport { getCookie } from './getCookie';\n\ntype CookieBuildAttributes = {\n /**\n * Cookie domain to store the locale information\n *\n * Default: undefined\n *\n * Define the domain where the cookie is available. Defaults to\n * the domain of the page where the cookie was created.\n */\n domain?: string;\n /**\n * Cookie path to store the locale information\n *\n * Default: undefined\n *\n * Define the path where the cookie is available. Defaults to '/'\n */\n path?: string;\n /**\n * Cookie secure to store the locale information\n *\n * Default: undefined\n *\n * A Boolean indicating if the cookie transmission requires a\n * secure protocol (https). Defaults to false.\n */\n secure?: boolean;\n /**\n * Cookie httpOnly to store the locale information\n *\n * Default: undefined\n *\n * The cookie httpOnly where the locale information is stored.\n */\n httpOnly?: boolean;\n /**\n * Cookie sameSite to store the locale information\n *\n * Default: undefined\n *\n * Asserts that a cookie must not be sent with cross-origin requests,\n * providing some protection against cross-site request forgery\n * attacks (CSRF)\n */\n sameSite?: 'strict' | 'lax' | 'none';\n\n /**\n * Cookie expires to store the locale information\n *\n * Default: undefined\n *\n * Define when the cookie will be removed. Value can be a Number\n * which will be interpreted as days from time of creation or a\n * Date instance. If omitted, the cookie becomes a session cookie.\n */\n expires?: number | undefined;\n};\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\n};\n\nexport type LocaleStorageOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { routing, internationalization } = configuration;\n const { locales } = internationalization;\n const { storage } = routing;\n\n // If storage is disabled, return undefined\n if (storage === false || options?.isCookieEnabled === false) return undefined;\n\n const storageAttributes = getStorageAttributes(storage);\n\n const isValidLocale = (value: string | null | undefined): value is Locale => {\n if (!value) return false;\n\n return locales.includes(value as Locale);\n };\n\n const readCookie = (name: string): string | undefined => {\n // Prefer provided getter (server or custom environment)\n try {\n const fromOption = options?.getCookie?.(name);\n\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n\n // Fallback to browser cookie parsing\n return getCookie(name);\n };\n\n // Check cookies first\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name } = storageAttributes.cookies[i];\n\n const value = readCookie(name);\n\n if (isValidLocale(value)) return value;\n }\n\n // Then check localStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const value = options?.getLocaleStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Check sessionStorage candidates (browser only)\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const value = options?.getSessionStorage?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n\n // Finally check header candidates (server only)\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n const value = options?.getHeader?.(name);\n\n if (isValidLocale(value)) return value;\n } catch {}\n }\n};\n\n/**\n * Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @param locale - The locale to store\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n // If storage is disabled, do nothing\n if (\n configuration.routing.storage === false ||\n options?.isCookieEnabled === false\n )\n return;\n\n const storageAttributes = getStorageAttributes(configuration.routing.storage);\n\n // Write to cookies (server via setCookie, client via cookieStore/document)\n for (let i = 0; i < storageAttributes.cookies.length; i++) {\n const { name, attributes } = storageAttributes.cookies[i];\n\n try {\n if (options?.setCookieStore) {\n options?.setCookieStore?.(name, locale, {\n ...attributes,\n expires:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : attributes.expires,\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n const cookieString = buildCookieString(name, locale, attributes);\n\n options?.setCookieString?.(name, cookieString);\n }\n } catch {}\n }\n }\n\n // Write to localStorage (browser only)\n if (options?.setLocaleStorage) {\n for (let i = 0; i < storageAttributes.localStorage.length; i++) {\n const { name } = storageAttributes.localStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getLocaleStorage) {\n const existing = options?.getLocaleStorage?.(name);\n if (existing) continue;\n }\n options?.setLocaleStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to sessionStorage (browser only)\n if (options?.setSessionStorage) {\n for (let i = 0; i < storageAttributes.sessionStorage.length; i++) {\n const { name } = storageAttributes.sessionStorage[i];\n\n try {\n const shouldOverwrite = options?.overwrite ?? true;\n\n if (!shouldOverwrite && options?.getSessionStorage) {\n const existing = options?.getSessionStorage?.(name);\n if (existing) continue;\n }\n\n options?.setSessionStorage?.(name, locale);\n } catch {}\n }\n }\n\n // Write to headers (server only)\n if (options?.setHeader) {\n for (let i = 0; i < storageAttributes.headers.length; i++) {\n const { name } = storageAttributes.headers[i];\n\n try {\n options?.setHeader?.(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in the storage by considering the configuration\n *\n * @property getLocale - Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * Retrieves the locale from various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function checks storage locations in order of priority as defined in the configuration.\n *\n * @property setLocale - Stores the locale in various storage mechanisms (cookies, localStorage, sessionStorage, headers).\n * The function writes to all configured storage locations according to their attributes.\n * Respects overwrite flags for localStorage and sessionStorage.\n *\n * @returns The locale if found in any storage, or undefined if not found\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":"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"}