@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,70 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_deepTransformPlugins_getMultilingualDictionary = require('../deepTransformPlugins/getMultilingualDictionary.cjs');
4
- const require_dictionaryManipulator_getNodeType = require('./getNodeType.cjs');
5
- let _intlayer_config_client = require("@intlayer/config/client");
6
- let _intlayer_config_built = require("@intlayer/config/built");
7
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
8
-
9
- //#region src/dictionaryManipulator/mergeDictionaries.ts
10
- const checkTypesMatch = (object1, object2, object2LocalId, dictionaryKey, path = []) => {
11
- const appLogger = (0, _intlayer_config_client.getAppLogger)(_intlayer_config_built.default);
12
- if (object1 === void 0 || object1 === null || object2 === void 0 || object2 === null) return;
13
- const type1 = require_dictionaryManipulator_getNodeType.getNodeType(object1);
14
- const type2 = require_dictionaryManipulator_getNodeType.getNodeType(object2);
15
- if (type1 === "unknown" || type2 === "unknown") return;
16
- if (type1 !== type2) {
17
- appLogger([`Error: Dictionary ${(0, _intlayer_config_client.colorizeKey)(dictionaryKey)} has a multiple content files with type mismatch at path "${path.join(".")}": Cannot merge ${type1} with ${type2} while merging ${object2LocalId}`], { level: "error" });
18
- return;
19
- }
20
- };
21
- const customMerge = (destination, source) => {
22
- if (destination === void 0 || destination === null) return source;
23
- if (source === void 0 || source === null) return destination;
24
- if (typeof destination !== "object" || typeof source !== "object") return destination;
25
- if (Array.isArray(destination) && Array.isArray(source)) return arrayMerge(destination, source);
26
- if (typeof destination === "object" && typeof source === "object") {
27
- const result = {};
28
- const allKeys = new Set([...Object.keys(destination), ...Object.keys(source)]);
29
- for (const key of allKeys) result[key] = customMerge(destination[key], source[key]);
30
- return result;
31
- }
32
- return destination;
33
- };
34
- const arrayMerge = (destinationArray, sourceArray) => {
35
- const destHasOnlyPrimitives = destinationArray.every((item) => typeof item !== "object" || item === null);
36
- const sourceHasOnlyPrimitives = sourceArray.every((item) => typeof item !== "object" || item === null);
37
- if (destHasOnlyPrimitives && sourceHasOnlyPrimitives) return sourceArray;
38
- const result = [];
39
- const maxLength = Math.max(destinationArray.length, sourceArray.length);
40
- for (let i = 0; i < maxLength; i++) {
41
- const destItem = destinationArray[i];
42
- const sourceItem = sourceArray[i];
43
- if (destItem === void 0 && sourceItem === void 0) {} else if (destItem === void 0) result.push(sourceItem);
44
- else if (sourceItem === void 0) result.push(destItem);
45
- else if (typeof destItem === "object" && typeof sourceItem === "object" && destItem !== null && sourceItem !== null) if ("key" in destItem && "key" in sourceItem && destItem.key === sourceItem.key) result.push(customMerge(destItem, sourceItem));
46
- else result.push(customMerge(destItem, sourceItem));
47
- else result.push(destItem);
48
- }
49
- return result;
50
- };
51
- const mergeDictionaries = (dictionaries) => {
52
- const localIds = Array.from(new Set(dictionaries.filter((dict) => dict.localId).map((dict) => dict.localId)));
53
- const dictionariesKeys = dictionaries.map((dict) => dict.key);
54
- if (new Set(dictionariesKeys).size !== 1) throw new Error("All dictionaries must have the same key");
55
- let mergedContent = dictionaries[0].content;
56
- for (let i = 1; i < dictionaries.length; i++) {
57
- const currentDictionary = require_deepTransformPlugins_getMultilingualDictionary.getMultilingualDictionary(dictionaries[i]);
58
- checkTypesMatch(mergedContent, currentDictionary.content, currentDictionary.localId, currentDictionary.key, []);
59
- mergedContent = customMerge(mergedContent, currentDictionary.content);
60
- }
61
- return {
62
- key: dictionaries[0].key,
63
- content: mergedContent,
64
- localIds
65
- };
66
- };
67
-
68
- //#endregion
69
- exports.mergeDictionaries = mergeDictionaries;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../deepTransformPlugins/getMultilingualDictionary.cjs`),n=require(`./getNodeType.cjs`);let r=require(`@intlayer/config/client`),i=require(`@intlayer/config/built`);i=e.__toESM(i);const a=(e,t,a,o,s=[])=>{let c=(0,r.getAppLogger)(i.default);if(e==null||t==null)return;let l=n.getNodeType(e),u=n.getNodeType(t);if(!(l===`unknown`||u===`unknown`)&&l!==u){c([`Error: Dictionary ${(0,r.colorizeKey)(o)} has a multiple content files with type mismatch at path "${s.join(`.`)}": Cannot merge ${l} with ${u} while merging ${a}`],{level:`error`});return}},o=(e,t)=>{if(e==null)return t;if(t==null||typeof e!=`object`||typeof t!=`object`)return e;if(Array.isArray(e)&&Array.isArray(t))return s(e,t);if(typeof e==`object`&&typeof t==`object`){let n={},r=new Set([...Object.keys(e),...Object.keys(t)]);for(let i of r)n[i]=o(e[i],t[i]);return n}return e},s=(e,t)=>{let n=e.every(e=>typeof e!=`object`||!e),r=t.every(e=>typeof e!=`object`||!e);if(n&&r)return t;let i=[],a=Math.max(e.length,t.length);for(let n=0;n<a;n++){let r=e[n],a=t[n];r===void 0&&a===void 0||(r===void 0?i.push(a):a===void 0?i.push(r):typeof r==`object`&&typeof a==`object`&&r!==null&&a!==null?(`key`in r&&`key`in a&&(r.key,a.key),i.push(o(r,a))):i.push(r))}return i},c=e=>{let n=Array.from(new Set(e.filter(e=>e.localId).map(e=>e.localId))),r=e.map(e=>e.key);if(new Set(r).size!==1)throw Error(`All dictionaries must have the same key`);let i=e[0].content;for(let n=1;n<e.length;n++){let r=t.getMultilingualDictionary(e[n]);a(i,r.content,r.localId,r.key,[]),i=o(i,r.content)}return{key:e[0].key,content:i,localIds:n}};exports.mergeDictionaries=c;
70
2
  //# sourceMappingURL=mergeDictionaries.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDictionaries.cjs","names":["configuration","getNodeType","getMultilingualDictionary"],"sources":["../../../src/dictionaryManipulator/mergeDictionaries.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types';\nimport { getMultilingualDictionary } from '../deepTransformPlugins';\nimport { getNodeType } from './getNodeType';\n\n// Extended type that includes arrays for internal merge operations\ntype MergeableContent = ContentNode | ContentNode[];\n\nconst checkTypesMatch = (\n object1: ContentNode,\n object2: ContentNode,\n object2LocalId: LocalDictionaryId | undefined,\n dictionaryKey: string,\n path: string[] = []\n): void => {\n const appLogger = getAppLogger(configuration);\n\n // If either side is missing/undefined, allow merge without error\n if (\n object1 === undefined ||\n object1 === null ||\n object2 === undefined ||\n object2 === null\n )\n return;\n\n const type1 = getNodeType(object1);\n const type2 = getNodeType(object2);\n\n // Unknown types are treated as flexible; skip strict mismatch reporting\n if (type1 === 'unknown' || type2 === 'unknown') return;\n\n if (type1 !== type2) {\n appLogger(\n [\n `Error: Dictionary ${colorizeKey(dictionaryKey)} has a multiple content files with type mismatch at path \"${path.join('.')}\": Cannot merge ${type1} with ${type2} while merging ${object2LocalId}`,\n ],\n {\n level: 'error',\n }\n );\n\n return;\n }\n};\n\n// Custom merge function that prefers destination (first dictionary) values\nconst customMerge = (\n destination: ContentNode,\n source: ContentNode\n): MergeableContent => {\n // If destination is undefined/null, use source\n if (destination === undefined || destination === null) {\n return source;\n }\n\n // If source is undefined/null, use destination\n if (source === undefined || source === null) {\n return destination;\n }\n\n // For primitive values, prefer destination (first dictionary)\n if (typeof destination !== 'object' || typeof source !== 'object') {\n return destination;\n }\n\n // For arrays, use our custom array merge\n if (Array.isArray(destination) && Array.isArray(source)) {\n return arrayMerge(\n destination as ContentNode[],\n source as ContentNode[]\n ) as MergeableContent;\n }\n\n // For objects, recursively merge with our custom logic\n if (typeof destination === 'object' && typeof source === 'object') {\n const result: Record<string, MergeableContent> = {};\n const allKeys = new Set([\n ...Object.keys(destination as unknown as Record<string, ContentNode>),\n ...Object.keys(source as unknown as Record<string, ContentNode>),\n ]);\n\n for (const key of allKeys) {\n result[key] = customMerge(\n (destination as unknown as Record<string, ContentNode>)[key],\n (source as unknown as Record<string, ContentNode>)[key]\n );\n }\n\n return result as unknown as MergeableContent;\n }\n\n // Fallback to destination\n return destination;\n};\n\n// Custom array merge strategy that merges arrays by key when present, otherwise by index\nconst arrayMerge = (\n destinationArray: ContentNode[],\n sourceArray: ContentNode[]\n): MergeableContent[] => {\n // Check if both arrays contain only primitives\n const destHasOnlyPrimitives = destinationArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n const sourceHasOnlyPrimitives = sourceArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n\n // If both arrays contain only primitives, use the source array (second dictionary)\n if (destHasOnlyPrimitives && sourceHasOnlyPrimitives) {\n return sourceArray;\n }\n\n // Otherwise, merge by index with object merging logic\n const result: MergeableContent[] = [];\n const maxLength = Math.max(destinationArray.length, sourceArray.length);\n\n for (let i = 0; i < maxLength; i++) {\n const destItem = destinationArray[i];\n const sourceItem = sourceArray[i];\n\n if (destItem === undefined && sourceItem === undefined) {\n } else if (destItem === undefined) {\n // Only source exists, add it\n result.push(sourceItem);\n } else if (sourceItem === undefined) {\n // Only destination exists, add it\n result.push(destItem);\n } else {\n // Both exist, merge them\n if (\n typeof destItem === 'object' &&\n typeof sourceItem === 'object' &&\n destItem !== null &&\n sourceItem !== null\n ) {\n // Check if both objects have a 'key' property for keyed merging\n if (\n 'key' in destItem &&\n 'key' in sourceItem &&\n (destItem as Record<string, string>).key ===\n (sourceItem as Record<string, string>).key\n ) {\n // Merge objects with same key, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n } else {\n // Merge objects by index, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n }\n } else {\n // For primitives or non-objects, use destination value (first dictionary)\n result.push(destItem);\n }\n }\n }\n\n return result;\n};\n\nexport const mergeDictionaries = (dictionaries: Dictionary[]): Dictionary => {\n const localIds = Array.from(\n new Set<LocalDictionaryId>(\n dictionaries.filter((dict) => dict.localId).map((dict) => dict.localId!)\n )\n );\n\n const dictionariesKeys = dictionaries.map((dict) => dict.key);\n\n // Check if all dictionaries have the same key\n if (new Set(dictionariesKeys).size !== 1) {\n throw new Error('All dictionaries must have the same key');\n }\n\n let mergedContent: Dictionary['content'] = dictionaries[0].content;\n\n for (let i = 1; i < dictionaries.length; i++) {\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n const currentDictionary = getMultilingualDictionary(dictionaries[i]);\n\n // Check types before merging\n checkTypesMatch(\n mergedContent,\n currentDictionary.content,\n currentDictionary.localId,\n currentDictionary.key,\n []\n );\n\n mergedContent = customMerge(\n mergedContent,\n currentDictionary.content\n ) as ContentNode;\n }\n\n const mergedDictionary: Dictionary = {\n key: dictionaries[0].key,\n content: mergedContent,\n localIds,\n };\n\n return mergedDictionary;\n};\n"],"mappings":";;;;;;;;;AAaA,MAAM,mBACJ,SACA,SACA,gBACA,eACA,OAAiB,EAAE,KACV;CACT,MAAM,sDAAyBA,+BAAc;AAG7C,KACE,YAAY,UACZ,YAAY,QACZ,YAAY,UACZ,YAAY,KAEZ;CAEF,MAAM,QAAQC,sDAAY,QAAQ;CAClC,MAAM,QAAQA,sDAAY,QAAQ;AAGlC,KAAI,UAAU,aAAa,UAAU,UAAW;AAEhD,KAAI,UAAU,OAAO;AACnB,YACE,CACE,8DAAiC,cAAc,CAAC,4DAA4D,KAAK,KAAK,IAAI,CAAC,kBAAkB,MAAM,QAAQ,MAAM,iBAAiB,iBACnL,EACD,EACE,OAAO,SACR,CACF;AAED;;;AAKJ,MAAM,eACJ,aACA,WACqB;AAErB,KAAI,gBAAgB,UAAa,gBAAgB,KAC/C,QAAO;AAIT,KAAI,WAAW,UAAa,WAAW,KACrC,QAAO;AAIT,KAAI,OAAO,gBAAgB,YAAY,OAAO,WAAW,SACvD,QAAO;AAIT,KAAI,MAAM,QAAQ,YAAY,IAAI,MAAM,QAAQ,OAAO,CACrD,QAAO,WACL,aACA,OACD;AAIH,KAAI,OAAO,gBAAgB,YAAY,OAAO,WAAW,UAAU;EACjE,MAAM,SAA2C,EAAE;EACnD,MAAM,UAAU,IAAI,IAAI,CACtB,GAAG,OAAO,KAAK,YAAsD,EACrE,GAAG,OAAO,KAAK,OAAiD,CACjE,CAAC;AAEF,OAAK,MAAM,OAAO,QAChB,QAAO,OAAO,YACX,YAAuD,MACvD,OAAkD,KACpD;AAGH,SAAO;;AAIT,QAAO;;AAIT,MAAM,cACJ,kBACA,gBACuB;CAEvB,MAAM,wBAAwB,iBAAiB,OAC5C,SAAS,OAAO,SAAS,YAAY,SAAS,KAChD;CACD,MAAM,0BAA0B,YAAY,OACzC,SAAS,OAAO,SAAS,YAAY,SAAS,KAChD;AAGD,KAAI,yBAAyB,wBAC3B,QAAO;CAIT,MAAM,SAA6B,EAAE;CACrC,MAAM,YAAY,KAAK,IAAI,iBAAiB,QAAQ,YAAY,OAAO;AAEvE,MAAK,IAAI,IAAI,GAAG,IAAI,WAAW,KAAK;EAClC,MAAM,WAAW,iBAAiB;EAClC,MAAM,aAAa,YAAY;AAE/B,MAAI,aAAa,UAAa,eAAe,QAAW,YAC7C,aAAa,OAEtB,QAAO,KAAK,WAAW;WACd,eAAe,OAExB,QAAO,KAAK,SAAS;WAInB,OAAO,aAAa,YACpB,OAAO,eAAe,YACtB,aAAa,QACb,eAAe,KAGf,KACE,SAAS,YACT,SAAS,cACR,SAAoC,QAClC,WAAsC,IAGzC,QAAO,KAAK,YAAY,UAAU,WAAW,CAAC;MAG9C,QAAO,KAAK,YAAY,UAAU,WAAW,CAAC;MAIhD,QAAO,KAAK,SAAS;;AAK3B,QAAO;;AAGT,MAAa,qBAAqB,iBAA2C;CAC3E,MAAM,WAAW,MAAM,KACrB,IAAI,IACF,aAAa,QAAQ,SAAS,KAAK,QAAQ,CAAC,KAAK,SAAS,KAAK,QAAS,CACzE,CACF;CAED,MAAM,mBAAmB,aAAa,KAAK,SAAS,KAAK,IAAI;AAG7D,KAAI,IAAI,IAAI,iBAAiB,CAAC,SAAS,EACrC,OAAM,IAAI,MAAM,0CAA0C;CAG5D,IAAI,gBAAuC,aAAa,GAAG;AAE3D,MAAK,IAAI,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK;EAE5C,MAAM,oBAAoBC,iFAA0B,aAAa,GAAG;AAGpE,kBACE,eACA,kBAAkB,SAClB,kBAAkB,SAClB,kBAAkB,KAClB,EAAE,CACH;AAED,kBAAgB,YACd,eACA,kBAAkB,QACnB;;AASH,QANqC;EACnC,KAAK,aAAa,GAAG;EACrB,SAAS;EACT;EACD"}
1
+ {"version":3,"file":"mergeDictionaries.cjs","names":["configuration","getNodeType","getMultilingualDictionary"],"sources":["../../../src/dictionaryManipulator/mergeDictionaries.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport type {\n ContentNode,\n Dictionary,\n LocalDictionaryId,\n} from '@intlayer/types';\nimport { getMultilingualDictionary } from '../deepTransformPlugins';\nimport { getNodeType } from './getNodeType';\n\n// Extended type that includes arrays for internal merge operations\ntype MergeableContent = ContentNode | ContentNode[];\n\nconst checkTypesMatch = (\n object1: ContentNode,\n object2: ContentNode,\n object2LocalId: LocalDictionaryId | undefined,\n dictionaryKey: string,\n path: string[] = []\n): void => {\n const appLogger = getAppLogger(configuration);\n\n // If either side is missing/undefined, allow merge without error\n if (\n object1 === undefined ||\n object1 === null ||\n object2 === undefined ||\n object2 === null\n )\n return;\n\n const type1 = getNodeType(object1);\n const type2 = getNodeType(object2);\n\n // Unknown types are treated as flexible; skip strict mismatch reporting\n if (type1 === 'unknown' || type2 === 'unknown') return;\n\n if (type1 !== type2) {\n appLogger(\n [\n `Error: Dictionary ${colorizeKey(dictionaryKey)} has a multiple content files with type mismatch at path \"${path.join('.')}\": Cannot merge ${type1} with ${type2} while merging ${object2LocalId}`,\n ],\n {\n level: 'error',\n }\n );\n\n return;\n }\n};\n\n// Custom merge function that prefers destination (first dictionary) values\nconst customMerge = (\n destination: ContentNode,\n source: ContentNode\n): MergeableContent => {\n // If destination is undefined/null, use source\n if (destination === undefined || destination === null) {\n return source;\n }\n\n // If source is undefined/null, use destination\n if (source === undefined || source === null) {\n return destination;\n }\n\n // For primitive values, prefer destination (first dictionary)\n if (typeof destination !== 'object' || typeof source !== 'object') {\n return destination;\n }\n\n // For arrays, use our custom array merge\n if (Array.isArray(destination) && Array.isArray(source)) {\n return arrayMerge(\n destination as ContentNode[],\n source as ContentNode[]\n ) as MergeableContent;\n }\n\n // For objects, recursively merge with our custom logic\n if (typeof destination === 'object' && typeof source === 'object') {\n const result: Record<string, MergeableContent> = {};\n const allKeys = new Set([\n ...Object.keys(destination as unknown as Record<string, ContentNode>),\n ...Object.keys(source as unknown as Record<string, ContentNode>),\n ]);\n\n for (const key of allKeys) {\n result[key] = customMerge(\n (destination as unknown as Record<string, ContentNode>)[key],\n (source as unknown as Record<string, ContentNode>)[key]\n );\n }\n\n return result as unknown as MergeableContent;\n }\n\n // Fallback to destination\n return destination;\n};\n\n// Custom array merge strategy that merges arrays by key when present, otherwise by index\nconst arrayMerge = (\n destinationArray: ContentNode[],\n sourceArray: ContentNode[]\n): MergeableContent[] => {\n // Check if both arrays contain only primitives\n const destHasOnlyPrimitives = destinationArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n const sourceHasOnlyPrimitives = sourceArray.every(\n (item) => typeof item !== 'object' || item === null\n );\n\n // If both arrays contain only primitives, use the source array (second dictionary)\n if (destHasOnlyPrimitives && sourceHasOnlyPrimitives) {\n return sourceArray;\n }\n\n // Otherwise, merge by index with object merging logic\n const result: MergeableContent[] = [];\n const maxLength = Math.max(destinationArray.length, sourceArray.length);\n\n for (let i = 0; i < maxLength; i++) {\n const destItem = destinationArray[i];\n const sourceItem = sourceArray[i];\n\n if (destItem === undefined && sourceItem === undefined) {\n } else if (destItem === undefined) {\n // Only source exists, add it\n result.push(sourceItem);\n } else if (sourceItem === undefined) {\n // Only destination exists, add it\n result.push(destItem);\n } else {\n // Both exist, merge them\n if (\n typeof destItem === 'object' &&\n typeof sourceItem === 'object' &&\n destItem !== null &&\n sourceItem !== null\n ) {\n // Check if both objects have a 'key' property for keyed merging\n if (\n 'key' in destItem &&\n 'key' in sourceItem &&\n (destItem as Record<string, string>).key ===\n (sourceItem as Record<string, string>).key\n ) {\n // Merge objects with same key, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n } else {\n // Merge objects by index, preferring destination (first dictionary) values\n result.push(customMerge(destItem, sourceItem));\n }\n } else {\n // For primitives or non-objects, use destination value (first dictionary)\n result.push(destItem);\n }\n }\n }\n\n return result;\n};\n\nexport const mergeDictionaries = (dictionaries: Dictionary[]): Dictionary => {\n const localIds = Array.from(\n new Set<LocalDictionaryId>(\n dictionaries.filter((dict) => dict.localId).map((dict) => dict.localId!)\n )\n );\n\n const dictionariesKeys = dictionaries.map((dict) => dict.key);\n\n // Check if all dictionaries have the same key\n if (new Set(dictionariesKeys).size !== 1) {\n throw new Error('All dictionaries must have the same key');\n }\n\n let mergedContent: Dictionary['content'] = dictionaries[0].content;\n\n for (let i = 1; i < dictionaries.length; i++) {\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n const currentDictionary = getMultilingualDictionary(dictionaries[i]);\n\n // Check types before merging\n checkTypesMatch(\n mergedContent,\n currentDictionary.content,\n currentDictionary.localId,\n currentDictionary.key,\n []\n );\n\n mergedContent = customMerge(\n mergedContent,\n currentDictionary.content\n ) as ContentNode;\n }\n\n const mergedDictionary: Dictionary = {\n key: dictionaries[0].key,\n content: mergedContent,\n localIds,\n };\n\n return mergedDictionary;\n};\n"],"mappings":"sTAaA,MAAM,GACJ,EACA,EACA,EACA,EACA,EAAiB,EAAE,GACV,CACT,IAAM,GAAA,EAAA,EAAA,cAAyBA,EAAAA,QAAc,CAG7C,GACE,GACY,MACZ,GACY,KAEZ,OAEF,IAAM,EAAQC,EAAAA,YAAY,EAAQ,CAC5B,EAAQA,EAAAA,YAAY,EAAQ,CAG9B,SAAU,WAAa,IAAU,YAEjC,IAAU,EAAO,CACnB,EACE,CACE,sBAAA,EAAA,EAAA,aAAiC,EAAc,CAAC,4DAA4D,EAAK,KAAK,IAAI,CAAC,kBAAkB,EAAM,QAAQ,EAAM,iBAAiB,IACnL,CACD,CACE,MAAO,QACR,CACF,CAED,SAKE,GACJ,EACA,IACqB,CAErB,GAAI,GAA6C,KAC/C,OAAO,EAST,GALI,GAAmC,MAKnC,OAAO,GAAgB,UAAY,OAAO,GAAW,SACvD,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAY,EAAI,MAAM,QAAQ,EAAO,CACrD,OAAO,EACL,EACA,EACD,CAIH,GAAI,OAAO,GAAgB,UAAY,OAAO,GAAW,SAAU,CACjE,IAAM,EAA2C,EAAE,CAC7C,EAAU,IAAI,IAAI,CACtB,GAAG,OAAO,KAAK,EAAsD,CACrE,GAAG,OAAO,KAAK,EAAiD,CACjE,CAAC,CAEF,IAAK,IAAM,KAAO,EAChB,EAAO,GAAO,EACX,EAAuD,GACvD,EAAkD,GACpD,CAGH,OAAO,EAIT,OAAO,GAIH,GACJ,EACA,IACuB,CAEvB,IAAM,EAAwB,EAAiB,MAC5C,GAAS,OAAO,GAAS,WAAY,EACvC,CACK,EAA0B,EAAY,MACzC,GAAS,OAAO,GAAS,WAAY,EACvC,CAGD,GAAI,GAAyB,EAC3B,OAAO,EAIT,IAAM,EAA6B,EAAE,CAC/B,EAAY,KAAK,IAAI,EAAiB,OAAQ,EAAY,OAAO,CAEvE,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,IAAK,CAClC,IAAM,EAAW,EAAiB,GAC5B,EAAa,EAAY,GAE3B,IAAa,IAAA,IAAa,IAAe,IAAA,KAClC,IAAa,IAAA,GAEtB,EAAO,KAAK,EAAW,CACd,IAAe,IAAA,GAExB,EAAO,KAAK,EAAS,CAInB,OAAO,GAAa,UACpB,OAAO,GAAe,UACtB,IAAa,MACb,IAAe,MAIb,QAAS,GACT,QAAS,IACR,EAAoC,IAClC,EAAsC,KAGzC,EAAO,KAAK,EAAY,EAAU,EAAW,CAAC,EAOhD,EAAO,KAAK,EAAS,EAK3B,OAAO,GAGI,EAAqB,GAA2C,CAC3E,IAAM,EAAW,MAAM,KACrB,IAAI,IACF,EAAa,OAAQ,GAAS,EAAK,QAAQ,CAAC,IAAK,GAAS,EAAK,QAAS,CACzE,CACF,CAEK,EAAmB,EAAa,IAAK,GAAS,EAAK,IAAI,CAG7D,GAAI,IAAI,IAAI,EAAiB,CAAC,OAAS,EACrC,MAAU,MAAM,0CAA0C,CAG5D,IAAI,EAAuC,EAAa,GAAG,QAE3D,IAAK,IAAI,EAAI,EAAG,EAAI,EAAa,OAAQ,IAAK,CAE5C,IAAM,EAAoBC,EAAAA,0BAA0B,EAAa,GAAG,CAGpE,EACE,EACA,EAAkB,QAClB,EAAkB,QAClB,EAAkB,IAClB,EAAE,CACH,CAED,EAAgB,EACd,EACA,EAAkB,QACnB,CASH,MANqC,CACnC,IAAK,EAAa,GAAG,IACrB,QAAS,EACT,WACD"}
@@ -1,31 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_transpiler_translation_translation = require('../transpiler/translation/translation.cjs');
3
- const require_deepTransformPlugins_getLocalizedContent = require('../deepTransformPlugins/getLocalizedContent.cjs');
4
- const require_dictionaryManipulator_orderDictionaries = require('./orderDictionaries.cjs');
5
-
6
- //#region src/dictionaryManipulator/normalizeDictionary.ts
7
- const normalizeDictionary = (dictionary, configuration) => {
8
- const { locales } = configuration.internationalization;
9
- const parsedDictionary = JSON.parse(JSON.stringify(dictionary));
10
- if (dictionary.locale) return {
11
- ...dictionary,
12
- locale: void 0,
13
- content: require_transpiler_translation_translation.t({ [dictionary.locale]: dictionary.content })
14
- };
15
- const perLocaleContent = locales.reduce((acc, locale) => {
16
- acc[locale] = require_deepTransformPlugins_getLocalizedContent.getPerLocaleDictionary(parsedDictionary, locale).content;
17
- return acc;
18
- }, {});
19
- return {
20
- ...dictionary,
21
- content: require_transpiler_translation_translation.t(perLocaleContent)
22
- };
23
- };
24
- const normalizeDictionaries = (dictionaries, configuration) => {
25
- return require_dictionaryManipulator_orderDictionaries.orderDictionaries(dictionaries, configuration).map((dictionary) => normalizeDictionary(dictionary, configuration));
26
- };
27
-
28
- //#endregion
29
- exports.normalizeDictionaries = normalizeDictionaries;
30
- exports.normalizeDictionary = normalizeDictionary;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../transpiler/translation/translation.cjs`),t=require(`../deepTransformPlugins/getLocalizedContent.cjs`),n=require(`./orderDictionaries.cjs`),r=(n,r)=>{let{locales:i}=r.internationalization,a=JSON.parse(JSON.stringify(n));if(n.locale)return{...n,locale:void 0,content:e.t({[n.locale]:n.content})};let o=i.reduce((e,n)=>(e[n]=t.getPerLocaleDictionary(a,n).content,e),{});return{...n,content:e.t(o)}},i=(e,t)=>n.orderDictionaries(e,t).map(e=>r(e,t));exports.normalizeDictionaries=i,exports.normalizeDictionary=r;
31
2
  //# sourceMappingURL=normalizeDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeDictionary.cjs","names":["t","getPerLocaleDictionary","orderDictionaries"],"sources":["../../../src/dictionaryManipulator/normalizeDictionary.ts"],"sourcesContent":["import type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getPerLocaleDictionary } from '../deepTransformPlugins';\nimport { t } from '../transpiler/translation';\nimport { orderDictionaries } from './orderDictionaries';\n\nexport const normalizeDictionary = (\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Dictionary => {\n const { locales } = configuration.internationalization;\n\n const parsedDictionary = JSON.parse(JSON.stringify(dictionary));\n\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n if (dictionary.locale) {\n return {\n ...dictionary,\n locale: undefined,\n content: t({\n [dictionary.locale]: dictionary.content,\n }),\n };\n }\n\n const perLocaleContent = locales.reduce(\n (acc, locale) => {\n const perLocaleDictionary = getPerLocaleDictionary(\n parsedDictionary,\n locale\n );\n\n acc[locale] = perLocaleDictionary.content;\n return acc;\n },\n {} as Record<Locale, Dictionary['content']>\n );\n\n return {\n ...dictionary,\n content: t(perLocaleContent),\n };\n};\n\nexport const normalizeDictionaries = (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Dictionary[] => {\n const orderedDictionaries = orderDictionaries(dictionaries, configuration);\n\n const structuredDictionaries = orderedDictionaries.map((dictionary) =>\n normalizeDictionary(dictionary, configuration)\n );\n\n return structuredDictionaries;\n};\n"],"mappings":";;;;;;AAKA,MAAa,uBACX,YACA,kBACe;CACf,MAAM,EAAE,YAAY,cAAc;CAElC,MAAM,mBAAmB,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC;AAG/D,KAAI,WAAW,OACb,QAAO;EACL,GAAG;EACH,QAAQ;EACR,SAASA,6CAAE,GACR,WAAW,SAAS,WAAW,SACjC,CAAC;EACH;CAGH,MAAM,mBAAmB,QAAQ,QAC9B,KAAK,WAAW;AAMf,MAAI,UALwBC,wEAC1B,kBACA,OACD,CAEiC;AAClC,SAAO;IAET,EAAE,CACH;AAED,QAAO;EACL,GAAG;EACH,SAASD,6CAAE,iBAAiB;EAC7B;;AAGH,MAAa,yBACX,cACA,kBACiB;AAOjB,QAN4BE,kEAAkB,cAAc,cAAc,CAEvB,KAAK,eACtD,oBAAoB,YAAY,cAAc,CAC/C"}
1
+ {"version":3,"file":"normalizeDictionary.cjs","names":["t","getPerLocaleDictionary","orderDictionaries"],"sources":["../../../src/dictionaryManipulator/normalizeDictionary.ts"],"sourcesContent":["import type { Dictionary, IntlayerConfig, Locale } from '@intlayer/types';\nimport { getPerLocaleDictionary } from '../deepTransformPlugins';\nimport { t } from '../transpiler/translation';\nimport { orderDictionaries } from './orderDictionaries';\n\nexport const normalizeDictionary = (\n dictionary: Dictionary,\n configuration: IntlayerConfig\n): Dictionary => {\n const { locales } = configuration.internationalization;\n\n const parsedDictionary = JSON.parse(JSON.stringify(dictionary));\n\n // If the dictionary is a per-locale dictionary, transform it to a partial multilingual dictionary\n if (dictionary.locale) {\n return {\n ...dictionary,\n locale: undefined,\n content: t({\n [dictionary.locale]: dictionary.content,\n }),\n };\n }\n\n const perLocaleContent = locales.reduce(\n (acc, locale) => {\n const perLocaleDictionary = getPerLocaleDictionary(\n parsedDictionary,\n locale\n );\n\n acc[locale] = perLocaleDictionary.content;\n return acc;\n },\n {} as Record<Locale, Dictionary['content']>\n );\n\n return {\n ...dictionary,\n content: t(perLocaleContent),\n };\n};\n\nexport const normalizeDictionaries = (\n dictionaries: Dictionary[],\n configuration: IntlayerConfig\n): Dictionary[] => {\n const orderedDictionaries = orderDictionaries(dictionaries, configuration);\n\n const structuredDictionaries = orderedDictionaries.map((dictionary) =>\n normalizeDictionary(dictionary, configuration)\n );\n\n return structuredDictionaries;\n};\n"],"mappings":"kOAKa,GACX,EACA,IACe,CACf,GAAM,CAAE,WAAY,EAAc,qBAE5B,EAAmB,KAAK,MAAM,KAAK,UAAU,EAAW,CAAC,CAG/D,GAAI,EAAW,OACb,MAAO,CACL,GAAG,EACH,OAAQ,IAAA,GACR,QAASA,EAAAA,EAAE,EACR,EAAW,QAAS,EAAW,QACjC,CAAC,CACH,CAGH,IAAM,EAAmB,EAAQ,QAC9B,EAAK,KAMJ,EAAI,GALwBC,EAAAA,uBAC1B,EACA,EACD,CAEiC,QAC3B,GAET,EAAE,CACH,CAED,MAAO,CACL,GAAG,EACH,QAASD,EAAAA,EAAE,EAAiB,CAC7B,EAGU,GACX,EACA,IAE4BE,EAAAA,kBAAkB,EAAc,EAAc,CAEvB,IAAK,GACtD,EAAoB,EAAY,EAAc,CAC/C"}
@@ -1,49 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_config_built = require("@intlayer/config/built");
4
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
5
-
6
- //#region src/dictionaryManipulator/orderDictionaries.ts
7
- /**
8
- * Orders dictionaries based on the dictionary priority strategy.
9
- *
10
- * @param dictionaries - Array of dictionaries to order
11
- * @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')
12
- * @returns Ordered array of dictionaries
13
- */
14
- const orderDictionaries = (dictionaries, configuration = _intlayer_config_built.default) => {
15
- const { editor } = configuration;
16
- const { dictionaryPriorityStrategy } = editor;
17
- if (dictionaries.length <= 1) return dictionaries;
18
- const withIndex = dictionaries.map((dictionary, index) => ({
19
- dictionary,
20
- index
21
- }));
22
- const getPriority = (dictionary) => {
23
- const p = dictionary.priority ?? 0;
24
- return Number.isFinite(p) ? p : 0;
25
- };
26
- const getLocationWeight = (d) => {
27
- const location = d.location;
28
- if (location === void 0) return 2;
29
- if (dictionaryPriorityStrategy === "distant_first") return location === "remote" ? 0 : 1;
30
- return location === "local" ? 0 : 1;
31
- };
32
- withIndex.sort((a, b) => {
33
- const aAuto = a.dictionary.filled ? 1 : 0;
34
- const bAuto = b.dictionary.filled ? 1 : 0;
35
- if (aAuto !== bAuto) return aAuto - bAuto;
36
- const aP = getPriority(a.dictionary);
37
- const bP = getPriority(b.dictionary);
38
- if (aP !== bP) return bP - aP;
39
- const aLocation = getLocationWeight(a.dictionary);
40
- const bLocation = getLocationWeight(b.dictionary);
41
- if (aLocation !== bLocation) return aLocation - bLocation;
42
- return a.index - b.index;
43
- });
44
- return withIndex.map(({ dictionary }) => dictionary);
45
- };
46
-
47
- //#endregion
48
- exports.orderDictionaries = orderDictionaries;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`);let t=require(`@intlayer/config/built`);t=e.__toESM(t);const n=(e,n=t.default)=>{let{editor:r}=n,{dictionaryPriorityStrategy:i}=r;if(e.length<=1)return e;let a=e.map((e,t)=>({dictionary:e,index:t})),o=e=>{let t=e.priority??0;return Number.isFinite(t)?t:0},s=e=>{let t=e.location;return t===void 0?2:i===`distant_first`?t===`remote`?0:1:t===`local`?0:1};return a.sort((e,t)=>{let n=e.dictionary.filled?1:0,r=t.dictionary.filled?1:0;if(n!==r)return n-r;let i=o(e.dictionary),a=o(t.dictionary);if(i!==a)return a-i;let c=s(e.dictionary),l=s(t.dictionary);return c===l?e.index-t.index:c-l}),a.map(({dictionary:e})=>e)};exports.orderDictionaries=n;
49
2
  //# sourceMappingURL=orderDictionaries.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"orderDictionaries.cjs","names":["intlayerConfig"],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"sourcesContent":["import intlayerConfig from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types';\n\n/**\n * Orders dictionaries based on the dictionary priority strategy.\n *\n * @param dictionaries - Array of dictionaries to order\n * @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')\n * @returns Ordered array of dictionaries\n */\nexport const orderDictionaries = (\n dictionaries: Dictionary[],\n configuration = intlayerConfig\n): Dictionary[] => {\n const { editor } = configuration;\n const { dictionaryPriorityStrategy } = editor;\n\n if (dictionaries.length <= 1) {\n return dictionaries;\n }\n\n // Stabilize original indices to preserve relative order for complete ties\n const withIndex = dictionaries.map((dictionary, index) => ({\n dictionary,\n index,\n }));\n\n const getPriority = (dictionary: Dictionary): number => {\n const p = dictionary.priority ?? 0;\n\n return Number.isFinite(p) ? p : 0;\n };\n\n const getLocationWeight = (d: Dictionary): number => {\n const location = d.location;\n\n // undefined location should always be last\n if (location === undefined) {\n return 2;\n }\n\n if (dictionaryPriorityStrategy === 'distant_first') {\n // distant should come first\n return location === 'remote' ? 0 : 1;\n }\n // default: local_first\n return location === 'local' ? 0 : 1;\n };\n\n withIndex.sort((a, b) => {\n // 1) Non-autoFilled before autoFilled (autoFilled have lower precedence)\n const aAuto = a.dictionary.filled ? 1 : 0;\n const bAuto = b.dictionary.filled ? 1 : 0;\n if (aAuto !== bAuto) return aAuto - bAuto; // 0 before 1\n\n // 2) Higher priority first (larger number wins)\n const aP = getPriority(a.dictionary);\n const bP = getPriority(b.dictionary);\n if (aP !== bP) return bP - aP; // descending\n\n // 3) Location according to strategy\n const aLocation = getLocationWeight(a.dictionary);\n const bLocation = getLocationWeight(b.dictionary);\n if (aLocation !== bLocation) return aLocation - bLocation;\n\n // 4) Stable fallback by original index\n return a.index - b.index;\n });\n\n return withIndex.map(({ dictionary }) => dictionary);\n};\n"],"mappings":";;;;;;;;;;;;;AAUA,MAAa,qBACX,cACA,gBAAgBA,mCACC;CACjB,MAAM,EAAE,WAAW;CACnB,MAAM,EAAE,+BAA+B;AAEvC,KAAI,aAAa,UAAU,EACzB,QAAO;CAIT,MAAM,YAAY,aAAa,KAAK,YAAY,WAAW;EACzD;EACA;EACD,EAAE;CAEH,MAAM,eAAe,eAAmC;EACtD,MAAM,IAAI,WAAW,YAAY;AAEjC,SAAO,OAAO,SAAS,EAAE,GAAG,IAAI;;CAGlC,MAAM,qBAAqB,MAA0B;EACnD,MAAM,WAAW,EAAE;AAGnB,MAAI,aAAa,OACf,QAAO;AAGT,MAAI,+BAA+B,gBAEjC,QAAO,aAAa,WAAW,IAAI;AAGrC,SAAO,aAAa,UAAU,IAAI;;AAGpC,WAAU,MAAM,GAAG,MAAM;EAEvB,MAAM,QAAQ,EAAE,WAAW,SAAS,IAAI;EACxC,MAAM,QAAQ,EAAE,WAAW,SAAS,IAAI;AACxC,MAAI,UAAU,MAAO,QAAO,QAAQ;EAGpC,MAAM,KAAK,YAAY,EAAE,WAAW;EACpC,MAAM,KAAK,YAAY,EAAE,WAAW;AACpC,MAAI,OAAO,GAAI,QAAO,KAAK;EAG3B,MAAM,YAAY,kBAAkB,EAAE,WAAW;EACjD,MAAM,YAAY,kBAAkB,EAAE,WAAW;AACjD,MAAI,cAAc,UAAW,QAAO,YAAY;AAGhD,SAAO,EAAE,QAAQ,EAAE;GACnB;AAEF,QAAO,UAAU,KAAK,EAAE,iBAAiB,WAAW"}
1
+ {"version":3,"file":"orderDictionaries.cjs","names":["intlayerConfig"],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"sourcesContent":["import intlayerConfig from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types';\n\n/**\n * Orders dictionaries based on the dictionary priority strategy.\n *\n * @param dictionaries - Array of dictionaries to order\n * @param priorityStrategy - The priority strategy ('local_first' or 'distant_first')\n * @returns Ordered array of dictionaries\n */\nexport const orderDictionaries = (\n dictionaries: Dictionary[],\n configuration = intlayerConfig\n): Dictionary[] => {\n const { editor } = configuration;\n const { dictionaryPriorityStrategy } = editor;\n\n if (dictionaries.length <= 1) {\n return dictionaries;\n }\n\n // Stabilize original indices to preserve relative order for complete ties\n const withIndex = dictionaries.map((dictionary, index) => ({\n dictionary,\n index,\n }));\n\n const getPriority = (dictionary: Dictionary): number => {\n const p = dictionary.priority ?? 0;\n\n return Number.isFinite(p) ? p : 0;\n };\n\n const getLocationWeight = (d: Dictionary): number => {\n const location = d.location;\n\n // undefined location should always be last\n if (location === undefined) {\n return 2;\n }\n\n if (dictionaryPriorityStrategy === 'distant_first') {\n // distant should come first\n return location === 'remote' ? 0 : 1;\n }\n // default: local_first\n return location === 'local' ? 0 : 1;\n };\n\n withIndex.sort((a, b) => {\n // 1) Non-autoFilled before autoFilled (autoFilled have lower precedence)\n const aAuto = a.dictionary.filled ? 1 : 0;\n const bAuto = b.dictionary.filled ? 1 : 0;\n if (aAuto !== bAuto) return aAuto - bAuto; // 0 before 1\n\n // 2) Higher priority first (larger number wins)\n const aP = getPriority(a.dictionary);\n const bP = getPriority(b.dictionary);\n if (aP !== bP) return bP - aP; // descending\n\n // 3) Location according to strategy\n const aLocation = getLocationWeight(a.dictionary);\n const bLocation = getLocationWeight(b.dictionary);\n if (aLocation !== bLocation) return aLocation - bLocation;\n\n // 4) Stable fallback by original index\n return a.index - b.index;\n });\n\n return withIndex.map(({ dictionary }) => dictionary);\n};\n"],"mappings":"+KAUA,MAAa,GACX,EACA,EAAgBA,EAAAA,UACC,CACjB,GAAM,CAAE,UAAW,EACb,CAAE,8BAA+B,EAEvC,GAAI,EAAa,QAAU,EACzB,OAAO,EAIT,IAAM,EAAY,EAAa,KAAK,EAAY,KAAW,CACzD,aACA,QACD,EAAE,CAEG,EAAe,GAAmC,CACtD,IAAM,EAAI,EAAW,UAAY,EAEjC,OAAO,OAAO,SAAS,EAAE,CAAG,EAAI,GAG5B,EAAqB,GAA0B,CACnD,IAAM,EAAW,EAAE,SAYnB,OATI,IAAa,IAAA,GACR,EAGL,IAA+B,gBAE1B,IAAa,SAAW,EAAI,EAG9B,IAAa,QAAU,EAAI,GAuBpC,OApBA,EAAU,MAAM,EAAG,IAAM,CAEvB,IAAM,EAAQ,EAAE,WAAW,OAAS,EAAI,EAClC,EAAQ,EAAE,WAAW,OAAS,EAAI,EACxC,GAAI,IAAU,EAAO,OAAO,EAAQ,EAGpC,IAAM,EAAK,EAAY,EAAE,WAAW,CAC9B,EAAK,EAAY,EAAE,WAAW,CACpC,GAAI,IAAO,EAAI,OAAO,EAAK,EAG3B,IAAM,EAAY,EAAkB,EAAE,WAAW,CAC3C,EAAY,EAAkB,EAAE,WAAW,CAIjD,OAHI,IAAc,EAGX,EAAE,MAAQ,EAAE,MAHiB,EAAY,GAIhD,CAEK,EAAU,KAAK,CAAE,gBAAiB,EAAW"}
@@ -1,32 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/removeContentNodeByKeyPath.ts
6
- const removeContentNodeByKeyPath = (dictionaryContent, keyPath) => {
7
- let currentValue = dictionaryContent;
8
- let parentValue = null;
9
- let lastKey = null;
10
- for (const keyObj of keyPath) {
11
- parentValue = currentValue;
12
- if (keyObj.type === _intlayer_types.NodeType.Object || keyObj.type === _intlayer_types.NodeType.Array) {
13
- lastKey = keyObj.key;
14
- currentValue = currentValue[keyObj.key];
15
- }
16
- if (keyObj.type === _intlayer_types.NodeType.Translation || keyObj.type === _intlayer_types.NodeType.Enumeration || keyObj.type === _intlayer_types.NodeType.Condition) {
17
- lastKey = keyObj.type;
18
- currentValue = currentValue[keyObj.type][keyObj.key];
19
- }
20
- if (keyObj.type === _intlayer_types.NodeType.Markdown || keyObj.type === _intlayer_types.NodeType.ReactNode || keyObj.type === _intlayer_types.NodeType.HTML || keyObj.type === _intlayer_types.NodeType.Insertion || keyObj.type === _intlayer_types.NodeType.File) {
21
- lastKey = keyObj.type;
22
- currentValue = currentValue[keyObj.type];
23
- }
24
- }
25
- if (parentValue && lastKey !== null) if (Array.isArray(parentValue)) parentValue.splice(lastKey, 1);
26
- else delete parentValue[lastKey];
27
- return dictionaryContent;
28
- };
29
-
30
- //#endregion
31
- exports.removeContentNodeByKeyPath = removeContentNodeByKeyPath;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=(t,n)=>{let r=t,i=null,a=null;for(let t of n)i=r,(t.type===e.NodeType.Object||t.type===e.NodeType.Array)&&(a=t.key,r=r[t.key]),(t.type===e.NodeType.Translation||t.type===e.NodeType.Enumeration||t.type===e.NodeType.Condition)&&(a=t.type,r=r[t.type][t.key]),(t.type===e.NodeType.Markdown||t.type===e.NodeType.ReactNode||t.type===e.NodeType.HTML||t.type===e.NodeType.Insertion||t.type===e.NodeType.File)&&(a=t.type,r=r[t.type]);return i&&a!==null&&(Array.isArray(i)?i.splice(a,1):delete i[a]),t};exports.removeContentNodeByKeyPath=t;
32
2
  //# sourceMappingURL=removeContentNodeByKeyPath.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"removeContentNodeByKeyPath.cjs","names":["NodeType"],"sources":["../../../src/dictionaryManipulator/removeContentNodeByKeyPath.ts"],"sourcesContent":["import { type ContentNode, type KeyPath, NodeType } from '@intlayer/types';\n\nexport const removeContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.ReactNode ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue.splice(lastKey as unknown as number, 1);\n } else {\n delete parentValue[lastKey];\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;AAEA,MAAa,8BACX,mBACA,YACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,UAAkC;AAEtC,MAAK,MAAM,UAAU,SAAS;AAC5B,gBAAc;AAEd,MAAI,OAAO,SAASA,yBAAS,UAAU,OAAO,SAASA,yBAAS,OAAO;AACrE,aAAU,OAAO;AACjB,kBAAe,aAAa,OAAO;;AAGrC,MACE,OAAO,SAASA,yBAAS,eACzB,OAAO,SAASA,yBAAS,eACzB,OAAO,SAASA,yBAAS,WACzB;AACA,aAAU,OAAO;AACjB,kBAAe,aAAa,OAAO,MAAM,OAAO;;AAGlD,MACE,OAAO,SAASA,yBAAS,YACzB,OAAO,SAASA,yBAAS,aACzB,OAAO,SAASA,yBAAS,QACzB,OAAO,SAASA,yBAAS,aACzB,OAAO,SAASA,yBAAS,MACzB;AACA,aAAU,OAAO;AACjB,kBAAe,aAAa,OAAO;;;AAIvC,KAAI,eAAe,YAAY,KAC7B,KAAI,MAAM,QAAQ,YAAY,CAC5B,aAAY,OAAO,SAA8B,EAAE;KAEnD,QAAO,YAAY;AAIvB,QAAO"}
1
+ {"version":3,"file":"removeContentNodeByKeyPath.cjs","names":["NodeType"],"sources":["../../../src/dictionaryManipulator/removeContentNodeByKeyPath.ts"],"sourcesContent":["import { type ContentNode, type KeyPath, NodeType } from '@intlayer/types';\n\nexport const removeContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.ReactNode ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue.splice(lastKey as unknown as number, 1);\n } else {\n delete parentValue[lastKey];\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":"iJAEA,MAAa,GACX,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAAkC,KAEtC,IAAK,IAAM,KAAU,EACnB,EAAc,GAEV,EAAO,OAASA,EAAAA,SAAS,QAAU,EAAO,OAASA,EAAAA,SAAS,SAC9D,EAAU,EAAO,IACjB,EAAe,EAAa,EAAO,OAInC,EAAO,OAASA,EAAAA,SAAS,aACzB,EAAO,OAASA,EAAAA,SAAS,aACzB,EAAO,OAASA,EAAAA,SAAS,aAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAASA,EAAAA,SAAS,UACzB,EAAO,OAASA,EAAAA,SAAS,WACzB,EAAO,OAASA,EAAAA,SAAS,MACzB,EAAO,OAASA,EAAAA,SAAS,WACzB,EAAO,OAASA,EAAAA,SAAS,QAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,OAYvC,OARI,GAAe,IAAY,OACzB,MAAM,QAAQ,EAAY,CAC5B,EAAY,OAAO,EAA8B,EAAE,CAEnD,OAAO,EAAY,IAIhB"}
@@ -1,40 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/renameContentNodeByKeyPath.ts
6
- const renameContentNodeByKeyPath = (dictionaryContent, newKey, keyPath) => {
7
- let currentValue = dictionaryContent;
8
- let parentValue = null;
9
- let lastKey = null;
10
- for (const keyObj of keyPath) {
11
- parentValue = currentValue;
12
- if (keyObj.type === _intlayer_types.NodeType.Object || keyObj.type === _intlayer_types.NodeType.Array) {
13
- lastKey = keyObj.key;
14
- currentValue = currentValue[keyObj.key];
15
- }
16
- if (keyObj.type === _intlayer_types.NodeType.Translation || keyObj.type === _intlayer_types.NodeType.Enumeration || keyObj.type === _intlayer_types.NodeType.Condition) {
17
- lastKey = keyObj.type;
18
- currentValue = currentValue[keyObj.type][keyObj.key];
19
- }
20
- if (keyObj.type === _intlayer_types.NodeType.Markdown || keyObj.type === _intlayer_types.NodeType.ReactNode || keyObj.type === _intlayer_types.NodeType.HTML || keyObj.type === _intlayer_types.NodeType.Insertion || keyObj.type === _intlayer_types.NodeType.File) {
21
- lastKey = keyObj.type;
22
- currentValue = currentValue[keyObj.type];
23
- }
24
- }
25
- if (parentValue && lastKey !== null) if (Array.isArray(parentValue)) parentValue[lastKey] = currentValue;
26
- else {
27
- const newParentValue = {};
28
- for (const key of Object.keys(parentValue)) if (key === lastKey && typeof newKey !== "undefined") newParentValue[newKey] = currentValue;
29
- else newParentValue[key] = parentValue[key];
30
- Object.keys(parentValue).forEach((key) => {
31
- delete parentValue[key];
32
- });
33
- Object.assign(parentValue, newParentValue);
34
- }
35
- return dictionaryContent;
36
- };
37
-
38
- //#endregion
39
- exports.renameContentNodeByKeyPath = renameContentNodeByKeyPath;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=(t,n,r)=>{let i=t,a=null,o=null;for(let t of r)a=i,(t.type===e.NodeType.Object||t.type===e.NodeType.Array)&&(o=t.key,i=i[t.key]),(t.type===e.NodeType.Translation||t.type===e.NodeType.Enumeration||t.type===e.NodeType.Condition)&&(o=t.type,i=i[t.type][t.key]),(t.type===e.NodeType.Markdown||t.type===e.NodeType.ReactNode||t.type===e.NodeType.HTML||t.type===e.NodeType.Insertion||t.type===e.NodeType.File)&&(o=t.type,i=i[t.type]);if(a&&o!==null)if(Array.isArray(a))a[o]=i;else{let e={};for(let t of Object.keys(a))t===o&&n!==void 0?e[n]=i:e[t]=a[t];Object.keys(a).forEach(e=>{delete a[e]}),Object.assign(a,e)}return t};exports.renameContentNodeByKeyPath=t;
40
2
  //# sourceMappingURL=renameContentNodeByKeyPath.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renameContentNodeByKeyPath.cjs","names":["NodeType"],"sources":["../../../src/dictionaryManipulator/renameContentNodeByKeyPath.ts"],"sourcesContent":["import { type ContentNode, type KeyPath, NodeType } from '@intlayer/types';\n\nexport const renameContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n newKey: KeyPath['key'],\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.ReactNode ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n // Assign the new value to the last key of the parent while preserving the order\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue[lastKey as number] = currentValue;\n } else {\n const newParentValue: any = {};\n for (const key of Object.keys(parentValue)) {\n if (key === lastKey && typeof newKey !== 'undefined') {\n newParentValue[newKey] = currentValue;\n } else {\n newParentValue[key] = parentValue[key];\n }\n }\n // Replace the contents of parentValue with newParentValue\n Object.keys(parentValue).forEach((key) => {\n delete parentValue[key];\n });\n Object.assign(parentValue, newParentValue);\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":";;;;;AAEA,MAAa,8BACX,mBACA,QACA,YACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,UAAkC;AAEtC,MAAK,MAAM,UAAU,SAAS;AAC5B,gBAAc;AAEd,MAAI,OAAO,SAASA,yBAAS,UAAU,OAAO,SAASA,yBAAS,OAAO;AACrE,aAAU,OAAO;AACjB,kBAAe,aAAa,OAAO;;AAGrC,MACE,OAAO,SAASA,yBAAS,eACzB,OAAO,SAASA,yBAAS,eACzB,OAAO,SAASA,yBAAS,WACzB;AACA,aAAU,OAAO;AACjB,kBAAe,aAAa,OAAO,MAAM,OAAO;;AAGlD,MACE,OAAO,SAASA,yBAAS,YACzB,OAAO,SAASA,yBAAS,aACzB,OAAO,SAASA,yBAAS,QACzB,OAAO,SAASA,yBAAS,aACzB,OAAO,SAASA,yBAAS,MACzB;AACA,aAAU,OAAO;AACjB,kBAAe,aAAa,OAAO;;;AAKvC,KAAI,eAAe,YAAY,KAC7B,KAAI,MAAM,QAAQ,YAAY,CAC5B,aAAY,WAAqB;MAC5B;EACL,MAAM,iBAAsB,EAAE;AAC9B,OAAK,MAAM,OAAO,OAAO,KAAK,YAAY,CACxC,KAAI,QAAQ,WAAW,OAAO,WAAW,YACvC,gBAAe,UAAU;MAEzB,gBAAe,OAAO,YAAY;AAItC,SAAO,KAAK,YAAY,CAAC,SAAS,QAAQ;AACxC,UAAO,YAAY;IACnB;AACF,SAAO,OAAO,aAAa,eAAe;;AAI9C,QAAO"}
1
+ {"version":3,"file":"renameContentNodeByKeyPath.cjs","names":["NodeType"],"sources":["../../../src/dictionaryManipulator/renameContentNodeByKeyPath.ts"],"sourcesContent":["import { type ContentNode, type KeyPath, NodeType } from '@intlayer/types';\n\nexport const renameContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n newKey: KeyPath['key'],\n keyPath: KeyPath[]\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKey: string | number | null = null;\n\n for (const keyObj of keyPath) {\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKey = keyObj.key;\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.ReactNode ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n lastKey = keyObj.type;\n currentValue = currentValue[keyObj.type];\n }\n }\n\n // Assign the new value to the last key of the parent while preserving the order\n if (parentValue && lastKey !== null) {\n if (Array.isArray(parentValue)) {\n parentValue[lastKey as number] = currentValue;\n } else {\n const newParentValue: any = {};\n for (const key of Object.keys(parentValue)) {\n if (key === lastKey && typeof newKey !== 'undefined') {\n newParentValue[newKey] = currentValue;\n } else {\n newParentValue[key] = parentValue[key];\n }\n }\n // Replace the contents of parentValue with newParentValue\n Object.keys(parentValue).forEach((key) => {\n delete parentValue[key];\n });\n Object.assign(parentValue, newParentValue);\n }\n }\n\n return dictionaryContent;\n};\n"],"mappings":"iJAEA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAAkC,KAEtC,IAAK,IAAM,KAAU,EACnB,EAAc,GAEV,EAAO,OAASA,EAAAA,SAAS,QAAU,EAAO,OAASA,EAAAA,SAAS,SAC9D,EAAU,EAAO,IACjB,EAAe,EAAa,EAAO,OAInC,EAAO,OAASA,EAAAA,SAAS,aACzB,EAAO,OAASA,EAAAA,SAAS,aACzB,EAAO,OAASA,EAAAA,SAAS,aAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAASA,EAAAA,SAAS,UACzB,EAAO,OAASA,EAAAA,SAAS,WACzB,EAAO,OAASA,EAAAA,SAAS,MACzB,EAAO,OAASA,EAAAA,SAAS,WACzB,EAAO,OAASA,EAAAA,SAAS,QAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,OAKvC,GAAI,GAAe,IAAY,KAC7B,GAAI,MAAM,QAAQ,EAAY,CAC5B,EAAY,GAAqB,MAC5B,CACL,IAAM,EAAsB,EAAE,CAC9B,IAAK,IAAM,KAAO,OAAO,KAAK,EAAY,CACpC,IAAQ,GAAkB,IAAW,OACvC,EAAe,GAAU,EAEzB,EAAe,GAAO,EAAY,GAItC,OAAO,KAAK,EAAY,CAAC,QAAS,GAAQ,CACxC,OAAO,EAAY,IACnB,CACF,OAAO,OAAO,EAAa,EAAe,CAI9C,OAAO"}
@@ -1,39 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/updateNodeChildren.ts
6
- const updateNodeChildren = (section, newChildren) => {
7
- if (typeof section === "string") return newChildren;
8
- if (typeof section === "number") return newChildren;
9
- if (typeof section === "boolean") return newChildren;
10
- if (typeof section?.nodeType === "string") {
11
- const typedNode = section;
12
- const content = typedNode[typedNode.nodeType];
13
- if (typedNode.nodeType === _intlayer_types.NodeType.Translation || typedNode.nodeType === _intlayer_types.NodeType.Enumeration || typedNode.nodeType === _intlayer_types.NodeType.Condition) {
14
- const newContent = Object.entries(content).reduce((acc, [key]) => {
15
- acc[key] = newChildren;
16
- return acc;
17
- }, {});
18
- return {
19
- ...typedNode,
20
- [typedNode.nodeType]: newContent
21
- };
22
- }
23
- if (typedNode.nodeType === _intlayer_types.NodeType.Nested) return typedNode;
24
- return {
25
- ...typedNode,
26
- [typedNode.nodeType]: newChildren
27
- };
28
- }
29
- if (!section || typeof section !== "object") return newChildren;
30
- if (Array.isArray(section)) return section.map(() => newChildren);
31
- return Object.entries(section).reduce((acc, [key]) => ({
32
- ...acc,
33
- [key]: newChildren
34
- }), {});
35
- };
36
-
37
- //#endregion
38
- exports.updateNodeChildren = updateNodeChildren;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=(t,n)=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return n;if(typeof t?.nodeType==`string`){let r=t,i=r[r.nodeType];if(r.nodeType===e.NodeType.Translation||r.nodeType===e.NodeType.Enumeration||r.nodeType===e.NodeType.Condition){let e=Object.entries(i).reduce((e,[t])=>(e[t]=n,e),{});return{...r,[r.nodeType]:e}}return r.nodeType===e.NodeType.Nested?r:{...r,[r.nodeType]:n}}return!t||typeof t!=`object`?n:Array.isArray(t)?t.map(()=>n):Object.entries(t).reduce((e,[t])=>({...e,[t]:n}),{})};exports.updateNodeChildren=t;
39
2
  //# sourceMappingURL=updateNodeChildren.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateNodeChildren.cjs","names":["NodeType"],"sources":["../../../src/dictionaryManipulator/updateNodeChildren.ts"],"sourcesContent":["import { type ContentNode, NodeType, type TypedNode } from '@intlayer/types';\n\nexport const updateNodeChildren = <\n T extends ContentNode,\n U extends ContentNode,\n>(\n section: T,\n newChildren: U\n): ContentNode => {\n if (typeof section === 'string') {\n return newChildren;\n }\n if (typeof section === 'number') {\n return newChildren;\n }\n if (typeof section === 'boolean') {\n return newChildren;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeType.Translation ||\n typedNode.nodeType === NodeType.Enumeration ||\n typedNode.nodeType === NodeType.Condition\n ) {\n const newContent = Object.entries(content).reduce(\n (acc, [key]) => {\n acc[key] = newChildren;\n return acc;\n },\n {} as Record<string, ContentNode>\n );\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newContent,\n };\n }\n\n if (typedNode.nodeType === NodeType.Nested) {\n return typedNode;\n }\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newChildren,\n };\n }\n\n if (!section || typeof section !== 'object') {\n return newChildren;\n }\n\n if (Array.isArray(section)) {\n return section.map(() => newChildren) as unknown as ContentNode;\n }\n\n return Object.entries(\n section as unknown as Record<string, ContentNode>\n ).reduce(\n (acc, [key]) => ({\n ...acc,\n [key]: newChildren,\n }),\n {} as Record<string, ContentNode>\n ) as unknown as ContentNode;\n};\n"],"mappings":";;;;;AAEA,MAAa,sBAIX,SACA,gBACgB;AAChB,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,UACrB,QAAO;AAET,KAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;AAEtB,MACE,UAAU,aAAaA,yBAAS,eAChC,UAAU,aAAaA,yBAAS,eAChC,UAAU,aAAaA,yBAAS,WAChC;GACA,MAAM,aAAa,OAAO,QAAQ,QAAQ,CAAC,QACxC,KAAK,CAAC,SAAS;AACd,QAAI,OAAO;AACX,WAAO;MAET,EAAE,CACH;AAED,UAAO;IACL,GAAG;KACF,UAAU,WAAW;IACvB;;AAGH,MAAI,UAAU,aAAaA,yBAAS,OAClC,QAAO;AAGT,SAAO;GACL,GAAG;IACF,UAAU,WAAW;GACvB;;AAGH,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,QAAO;AAGT,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAO,QAAQ,UAAU,YAAY;AAGvC,QAAO,OAAO,QACZ,QACD,CAAC,QACC,KAAK,CAAC,UAAU;EACf,GAAG;GACF,MAAM;EACR,GACD,EAAE,CACH"}
1
+ {"version":3,"file":"updateNodeChildren.cjs","names":["NodeType"],"sources":["../../../src/dictionaryManipulator/updateNodeChildren.ts"],"sourcesContent":["import { type ContentNode, NodeType, type TypedNode } from '@intlayer/types';\n\nexport const updateNodeChildren = <\n T extends ContentNode,\n U extends ContentNode,\n>(\n section: T,\n newChildren: U\n): ContentNode => {\n if (typeof section === 'string') {\n return newChildren;\n }\n if (typeof section === 'number') {\n return newChildren;\n }\n if (typeof section === 'boolean') {\n return newChildren;\n }\n if (typeof (section as TypedNode)?.nodeType === 'string') {\n const typedNode = section as TypedNode;\n const content =\n typedNode[typedNode.nodeType as unknown as keyof typeof typedNode];\n\n if (\n typedNode.nodeType === NodeType.Translation ||\n typedNode.nodeType === NodeType.Enumeration ||\n typedNode.nodeType === NodeType.Condition\n ) {\n const newContent = Object.entries(content).reduce(\n (acc, [key]) => {\n acc[key] = newChildren;\n return acc;\n },\n {} as Record<string, ContentNode>\n );\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newContent,\n };\n }\n\n if (typedNode.nodeType === NodeType.Nested) {\n return typedNode;\n }\n\n return {\n ...typedNode,\n [typedNode.nodeType]: newChildren,\n };\n }\n\n if (!section || typeof section !== 'object') {\n return newChildren;\n }\n\n if (Array.isArray(section)) {\n return section.map(() => newChildren) as unknown as ContentNode;\n }\n\n return Object.entries(\n section as unknown as Record<string, ContentNode>\n ).reduce(\n (acc, [key]) => ({\n ...acc,\n [key]: newChildren,\n }),\n {} as Record<string, ContentNode>\n ) as unknown as ContentNode;\n};\n"],"mappings":"iJAEA,MAAa,GAIX,EACA,IACgB,CAOhB,GANI,OAAO,GAAY,UAGnB,OAAO,GAAY,UAGnB,OAAO,GAAY,UACrB,OAAO,EAET,GAAI,OAAQ,GAAuB,UAAa,SAAU,CACxD,IAAM,EAAY,EACZ,EACJ,EAAU,EAAU,UAEtB,GACE,EAAU,WAAaA,EAAAA,SAAS,aAChC,EAAU,WAAaA,EAAAA,SAAS,aAChC,EAAU,WAAaA,EAAAA,SAAS,UAChC,CACA,IAAM,EAAa,OAAO,QAAQ,EAAQ,CAAC,QACxC,EAAK,CAAC,MACL,EAAI,GAAO,EACJ,GAET,EAAE,CACH,CAED,MAAO,CACL,GAAG,GACF,EAAU,UAAW,EACvB,CAOH,OAJI,EAAU,WAAaA,EAAAA,SAAS,OAC3B,EAGF,CACL,GAAG,GACF,EAAU,UAAW,EACvB,CAWH,MARI,CAAC,GAAW,OAAO,GAAY,SAC1B,EAGL,MAAM,QAAQ,EAAQ,CACjB,EAAQ,QAAU,EAAY,CAGhC,OAAO,QACZ,EACD,CAAC,QACC,EAAK,CAAC,MAAU,CACf,GAAG,GACF,GAAM,EACR,EACD,EAAE,CACH"}
@@ -1,26 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_utils_intl = require('../utils/intl.cjs');
4
- let _intlayer_config_built = require("@intlayer/config/built");
5
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
6
-
7
- //#region src/formatters/compact.ts
8
- /**
9
- * Formats a numeric value using compact notation (e.g., 1K, 1M, 1B)
10
- * based on locale and formatting options.
11
- *
12
- * @example
13
- * compact({ value: 1200 }); // "1.2K"
14
- *
15
- * @example
16
- * compact({ value: "1000000", locale: Locales.FRENCH, compactDisplay: "long" });
17
- * // "1 million"
18
- */
19
- const compact = (value, options) => new require_utils_intl.CachedIntl.NumberFormat(options?.locale ?? _intlayer_config_built.default?.internationalization?.defaultLocale, {
20
- ...options,
21
- notation: "compact"
22
- }).format(Number(value));
23
-
24
- //#endregion
25
- exports.compact = compact;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../utils/intl.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);const r=(e,r)=>new t.CachedIntl.NumberFormat(r?.locale??n.default?.internationalization?.defaultLocale,{...r,notation:`compact`}).format(Number(e));exports.compact=r;
26
2
  //# sourceMappingURL=compact.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"compact.cjs","names":["CachedIntl","configuration"],"sources":["../../../src/formatters/compact.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric value using compact notation (e.g., 1K, 1M, 1B)\n * based on locale and formatting options.\n *\n * @example\n * compact({ value: 1200 }); // \"1.2K\"\n *\n * @example\n * compact({ value: \"1000000\", locale: Locales.FRENCH, compactDisplay: \"long\" });\n * // \"1 million\"\n */\nexport const compact = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n ...options,\n notation: 'compact',\n }\n ).format(Number(value));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,MAAa,WACX,OACA,YAEA,IAAIA,8BAAW,aACb,SAAS,UAAUC,gCAAe,sBAAsB,eACxD;CACE,GAAG;CACH,UAAU;CACX,CACF,CAAC,OAAO,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"compact.cjs","names":["CachedIntl","configuration"],"sources":["../../../src/formatters/compact.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric value using compact notation (e.g., 1K, 1M, 1B)\n * based on locale and formatting options.\n *\n * @example\n * compact({ value: 1200 }); // \"1.2K\"\n *\n * @example\n * compact({ value: \"1000000\", locale: Locales.FRENCH, compactDisplay: \"long\" });\n * // \"1 million\"\n */\nexport const compact = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n ...options,\n notation: 'compact',\n }\n ).format(Number(value));\n"],"mappings":"8MAeA,MAAa,GACX,EACA,IAEA,IAAIA,EAAAA,WAAW,aACb,GAAS,QAAUC,EAAAA,SAAe,sBAAsB,cACxD,CACE,GAAG,EACH,SAAU,UACX,CACF,CAAC,OAAO,OAAO,EAAM,CAAC"}
@@ -1,30 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_utils_intl = require('../utils/intl.cjs');
4
- let _intlayer_config_built = require("@intlayer/config/built");
5
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
6
-
7
- //#region src/formatters/currency.ts
8
- /**
9
- * Formats a numeric or string value into a localized currency string using the Intl API.
10
- *
11
- * @example
12
- * currency({ value: 1234.5, currency: 'EUR' });
13
- * // "€1,234.50"
14
- *
15
- * @example
16
- * currency({ value: "5000", locale: Locales.FRENCH, currency: "CAD", currencyDisplay: "code" });
17
- * // "5 000,00 CAD"
18
- */
19
- const currency = (value, options) => new require_utils_intl.CachedIntl.NumberFormat(options?.locale ?? _intlayer_config_built.default?.internationalization?.defaultLocale, {
20
- style: "currency",
21
- currency: options?.currency ?? "USD",
22
- currencyDisplay: options?.currencyDisplay ?? "symbol",
23
- minimumFractionDigits: options?.minimumFractionDigits ?? 2,
24
- maximumFractionDigits: options?.maximumFractionDigits ?? 2,
25
- ...options
26
- }).format(Number(value));
27
-
28
- //#endregion
29
- exports.currency = currency;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../utils/intl.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);const r=(e,r)=>new t.CachedIntl.NumberFormat(r?.locale??n.default?.internationalization?.defaultLocale,{style:`currency`,currency:r?.currency??`USD`,currencyDisplay:r?.currencyDisplay??`symbol`,minimumFractionDigits:r?.minimumFractionDigits??2,maximumFractionDigits:r?.maximumFractionDigits??2,...r}).format(Number(e));exports.currency=r;
30
2
  //# sourceMappingURL=currency.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"currency.cjs","names":["CachedIntl","configuration"],"sources":["../../../src/formatters/currency.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric or string value into a localized currency string using the Intl API.\n *\n * @example\n * currency({ value: 1234.5, currency: 'EUR' });\n * // \"€1,234.50\"\n *\n * @example\n * currency({ value: \"5000\", locale: Locales.FRENCH, currency: \"CAD\", currencyDisplay: \"code\" });\n * // \"5 000,00 CAD\"\n */\nexport const currency = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n style: 'currency',\n currency: options?.currency ?? 'USD',\n currencyDisplay: options?.currencyDisplay ?? 'symbol',\n minimumFractionDigits: options?.minimumFractionDigits ?? 2,\n maximumFractionDigits: options?.maximumFractionDigits ?? 2,\n ...options,\n }\n ).format(Number(value));\n"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,MAAa,YACX,OACA,YAEA,IAAIA,8BAAW,aACb,SAAS,UAAUC,gCAAe,sBAAsB,eACxD;CACE,OAAO;CACP,UAAU,SAAS,YAAY;CAC/B,iBAAiB,SAAS,mBAAmB;CAC7C,uBAAuB,SAAS,yBAAyB;CACzD,uBAAuB,SAAS,yBAAyB;CACzD,GAAG;CACJ,CACF,CAAC,OAAO,OAAO,MAAM,CAAC"}
1
+ {"version":3,"file":"currency.cjs","names":["CachedIntl","configuration"],"sources":["../../../src/formatters/currency.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric or string value into a localized currency string using the Intl API.\n *\n * @example\n * currency({ value: 1234.5, currency: 'EUR' });\n * // \"€1,234.50\"\n *\n * @example\n * currency({ value: \"5000\", locale: Locales.FRENCH, currency: \"CAD\", currencyDisplay: \"code\" });\n * // \"5 000,00 CAD\"\n */\nexport const currency = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n style: 'currency',\n currency: options?.currency ?? 'USD',\n currencyDisplay: options?.currencyDisplay ?? 'symbol',\n minimumFractionDigits: options?.minimumFractionDigits ?? 2,\n maximumFractionDigits: options?.maximumFractionDigits ?? 2,\n ...options,\n }\n ).format(Number(value));\n"],"mappings":"8MAeA,MAAa,GACX,EACA,IAEA,IAAIA,EAAAA,WAAW,aACb,GAAS,QAAUC,EAAAA,SAAe,sBAAsB,cACxD,CACE,MAAO,WACP,SAAU,GAAS,UAAY,MAC/B,gBAAiB,GAAS,iBAAmB,SAC7C,sBAAuB,GAAS,uBAAyB,EACzD,sBAAuB,GAAS,uBAAyB,EACzD,GAAG,EACJ,CACF,CAAC,OAAO,OAAO,EAAM,CAAC"}
@@ -1,61 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_utils_intl = require('../utils/intl.cjs');
4
- let _intlayer_config_built = require("@intlayer/config/built");
5
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
6
-
7
- //#region src/formatters/date.ts
8
- const presets = {
9
- short: {
10
- year: "2-digit",
11
- month: "2-digit",
12
- day: "2-digit",
13
- hour: "2-digit",
14
- minute: "2-digit"
15
- },
16
- long: {
17
- year: "numeric",
18
- month: "long",
19
- day: "numeric",
20
- hour: "numeric",
21
- minute: "numeric"
22
- },
23
- full: {
24
- year: "numeric",
25
- month: "long",
26
- day: "numeric",
27
- hour: "numeric",
28
- minute: "numeric",
29
- hour12: false
30
- },
31
- dateOnly: {
32
- year: "numeric",
33
- month: "short",
34
- day: "numeric"
35
- },
36
- timeOnly: {
37
- hour: "numeric",
38
- minute: "numeric",
39
- second: "numeric"
40
- }
41
- };
42
- /**
43
- * Formats a date/time value into a localized string using Intl.DateTimeFormat.
44
- *
45
- * @example
46
- * date({ date: new Date(), options: "short" });
47
- * // "08/02/25, 14:30"
48
- *
49
- * @example
50
- * date({ date: "2025-08-02T14:30:00Z", locale: Locales.FRENCH, options: { month: "long", day: "numeric" } });
51
- * // "2 août"
52
- */
53
- const date = (date, options) => {
54
- const dateTime = new Date(date);
55
- const resolvedOptions = typeof options === "string" ? presets[options] ?? {} : options;
56
- return new require_utils_intl.CachedIntl.DateTimeFormat(options?.locale ?? _intlayer_config_built.default?.internationalization?.defaultLocale, resolvedOptions).format(dateTime);
57
- };
58
-
59
- //#endregion
60
- exports.date = date;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../utils/intl.cjs`);let n=require(`@intlayer/config/built`);n=e.__toESM(n);const r={short:{year:`2-digit`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`},long:{year:`numeric`,month:`long`,day:`numeric`,hour:`numeric`,minute:`numeric`},full:{year:`numeric`,month:`long`,day:`numeric`,hour:`numeric`,minute:`numeric`,hour12:!1},dateOnly:{year:`numeric`,month:`short`,day:`numeric`},timeOnly:{hour:`numeric`,minute:`numeric`,second:`numeric`}},i=(e,i)=>{let a=new Date(e),o=typeof i==`string`?r[i]??{}:i;return new t.CachedIntl.DateTimeFormat(i?.locale??n.default?.internationalization?.defaultLocale,o).format(a)};exports.date=i;
61
2
  //# sourceMappingURL=date.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"date.cjs","names":["CachedIntl","configuration"],"sources":["../../../src/formatters/date.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\ntype DateTimePreset = 'short' | 'long' | 'dateOnly' | 'timeOnly' | 'full';\n\nconst presets: Record<DateTimePreset, Intl.DateTimeFormatOptions> = {\n short: {\n year: '2-digit',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n },\n long: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n },\n full: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n hour12: false,\n },\n dateOnly: {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n },\n timeOnly: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n },\n};\n\n/**\n * Formats a date/time value into a localized string using Intl.DateTimeFormat.\n *\n * @example\n * date({ date: new Date(), options: \"short\" });\n * // \"08/02/25, 14:30\"\n *\n * @example\n * date({ date: \"2025-08-02T14:30:00Z\", locale: Locales.FRENCH, options: { month: \"long\", day: \"numeric\" } });\n * // \"2 août\"\n */\nexport const date = (\n date: Date | string | number,\n options?: Intl.DateTimeFormatOptions & { locale?: LocalesValues }\n): string => {\n const dateTime = new Date(date);\n\n const resolvedOptions =\n typeof options === 'string' ? (presets[options] ?? {}) : options;\n\n const formatter = new CachedIntl.DateTimeFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n resolvedOptions\n );\n\n return formatter.format(dateTime);\n};\n"],"mappings":";;;;;;;AAMA,MAAM,UAA8D;CAClE,OAAO;EACL,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;EACT;CACD,MAAM;EACJ,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;EACT;CACD,MAAM;EACJ,MAAM;EACN,OAAO;EACP,KAAK;EACL,MAAM;EACN,QAAQ;EACR,QAAQ;EACT;CACD,UAAU;EACR,MAAM;EACN,OAAO;EACP,KAAK;EACN;CACD,UAAU;EACR,MAAM;EACN,QAAQ;EACR,QAAQ;EACT;CACF;;;;;;;;;;;;AAaD,MAAa,QACX,MACA,YACW;CACX,MAAM,WAAW,IAAI,KAAK,KAAK;CAE/B,MAAM,kBACJ,OAAO,YAAY,WAAY,QAAQ,YAAY,EAAE,GAAI;AAO3D,QALkB,IAAIA,8BAAW,eAC/B,SAAS,UAAUC,gCAAe,sBAAsB,eACxD,gBACD,CAEgB,OAAO,SAAS"}
1
+ {"version":3,"file":"date.cjs","names":["CachedIntl","configuration"],"sources":["../../../src/formatters/date.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\ntype DateTimePreset = 'short' | 'long' | 'dateOnly' | 'timeOnly' | 'full';\n\nconst presets: Record<DateTimePreset, Intl.DateTimeFormatOptions> = {\n short: {\n year: '2-digit',\n month: '2-digit',\n day: '2-digit',\n hour: '2-digit',\n minute: '2-digit',\n },\n long: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n },\n full: {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n hour12: false,\n },\n dateOnly: {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n },\n timeOnly: {\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n },\n};\n\n/**\n * Formats a date/time value into a localized string using Intl.DateTimeFormat.\n *\n * @example\n * date({ date: new Date(), options: \"short\" });\n * // \"08/02/25, 14:30\"\n *\n * @example\n * date({ date: \"2025-08-02T14:30:00Z\", locale: Locales.FRENCH, options: { month: \"long\", day: \"numeric\" } });\n * // \"2 août\"\n */\nexport const date = (\n date: Date | string | number,\n options?: Intl.DateTimeFormatOptions & { locale?: LocalesValues }\n): string => {\n const dateTime = new Date(date);\n\n const resolvedOptions =\n typeof options === 'string' ? (presets[options] ?? {}) : options;\n\n const formatter = new CachedIntl.DateTimeFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n resolvedOptions\n );\n\n return formatter.format(dateTime);\n};\n"],"mappings":"8MAMA,MAAM,EAA8D,CAClE,MAAO,CACL,KAAM,UACN,MAAO,UACP,IAAK,UACL,KAAM,UACN,OAAQ,UACT,CACD,KAAM,CACJ,KAAM,UACN,MAAO,OACP,IAAK,UACL,KAAM,UACN,OAAQ,UACT,CACD,KAAM,CACJ,KAAM,UACN,MAAO,OACP,IAAK,UACL,KAAM,UACN,OAAQ,UACR,OAAQ,GACT,CACD,SAAU,CACR,KAAM,UACN,MAAO,QACP,IAAK,UACN,CACD,SAAU,CACR,KAAM,UACN,OAAQ,UACR,OAAQ,UACT,CACF,CAaY,GACX,EACA,IACW,CACX,IAAM,EAAW,IAAI,KAAK,EAAK,CAEzB,EACJ,OAAO,GAAY,SAAY,EAAQ,IAAY,EAAE,CAAI,EAO3D,OALkB,IAAIA,EAAAA,WAAW,eAC/B,GAAS,QAAUC,EAAAA,SAAe,sBAAsB,cACxD,EACD,CAEgB,OAAO,EAAS"}