@intlayer/core 8.2.4 → 8.3.0-canary.0

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 (326) hide show
  1. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -1
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  3. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  5. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -1
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  7. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  9. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -1
  10. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  11. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  12. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  13. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -1
  14. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  15. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -1
  16. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  17. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -1
  18. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  19. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -1
  20. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  21. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -1
  22. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -1
  24. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -1
  26. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -1
  28. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  30. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  32. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -1
  33. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  34. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -1
  35. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  36. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -1
  37. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  38. package/dist/cjs/formatters/compact.cjs.map +1 -1
  39. package/dist/cjs/formatters/currency.cjs.map +1 -1
  40. package/dist/cjs/formatters/date.cjs.map +1 -1
  41. package/dist/cjs/formatters/list.cjs.map +1 -1
  42. package/dist/cjs/formatters/number.cjs.map +1 -1
  43. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  44. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  45. package/dist/cjs/formatters/units.cjs.map +1 -1
  46. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  47. package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -1
  48. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  49. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  50. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -1
  51. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  52. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  53. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  54. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  55. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  56. package/dist/cjs/localization/getBrowserLocale.cjs +1 -1
  57. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  58. package/dist/cjs/localization/getHTMLTextDir.cjs +1 -1
  59. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  60. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  61. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  62. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  63. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  64. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  65. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  66. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  67. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  68. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  69. package/dist/cjs/localization/localeMapper.cjs +1 -1
  70. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  71. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  72. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  73. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  74. package/dist/cjs/messageFormat/ICU.cjs +1 -1
  75. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  76. package/dist/cjs/messageFormat/i18next.cjs +1 -1
  77. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  78. package/dist/cjs/messageFormat/vue-i18n.cjs +1 -1
  79. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  80. package/dist/cjs/transpiler/condition/condition.cjs +1 -1
  81. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  82. package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -1
  83. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  84. package/dist/cjs/transpiler/file/file.cjs +1 -1
  85. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  86. package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -1
  87. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  88. package/dist/cjs/transpiler/gender/gender.cjs +1 -1
  89. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  90. package/dist/cjs/transpiler/html/html.cjs +1 -1
  91. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  92. package/dist/cjs/transpiler/insertion/insertion.cjs +1 -1
  93. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  94. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -1
  95. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  96. package/dist/cjs/transpiler/nesting/nesting.cjs +1 -1
  97. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  98. package/dist/cjs/transpiler/translation/translation.cjs +1 -1
  99. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  100. package/dist/cjs/utils/intl.cjs +1 -1
  101. package/dist/cjs/utils/intl.cjs.map +1 -1
  102. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  103. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  104. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -1
  105. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  106. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -1
  107. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  108. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -1
  109. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  110. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  111. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  112. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -1
  113. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  114. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  115. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  116. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -1
  117. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  118. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -1
  119. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  120. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -1
  121. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  122. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -1
  123. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  124. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -1
  125. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  126. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -1
  127. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  128. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -1
  129. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  130. package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -1
  131. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  132. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  133. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  134. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  135. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -1
  136. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  137. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -1
  138. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  139. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -1
  140. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  141. package/dist/esm/formatters/compact.mjs.map +1 -1
  142. package/dist/esm/formatters/currency.mjs.map +1 -1
  143. package/dist/esm/formatters/date.mjs.map +1 -1
  144. package/dist/esm/formatters/list.mjs.map +1 -1
  145. package/dist/esm/formatters/number.mjs.map +1 -1
  146. package/dist/esm/formatters/percentage.mjs.map +1 -1
  147. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  148. package/dist/esm/formatters/units.mjs.map +1 -1
  149. package/dist/esm/getStorageAttributes.mjs.map +1 -1
  150. package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -1
  151. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  152. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  153. package/dist/esm/interpreter/getContent/plugins.mjs +1 -1
  154. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  155. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  156. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  157. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  158. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  159. package/dist/esm/localization/getBrowserLocale.mjs +1 -1
  160. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  161. package/dist/esm/localization/getHTMLTextDir.mjs +1 -1
  162. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  163. package/dist/esm/localization/getLocale.mjs.map +1 -1
  164. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  165. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  166. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  167. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  168. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  169. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  170. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  171. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  172. package/dist/esm/localization/localeMapper.mjs +1 -1
  173. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  174. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  175. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  176. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  177. package/dist/esm/messageFormat/ICU.mjs +1 -1
  178. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  179. package/dist/esm/messageFormat/i18next.mjs +1 -1
  180. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  181. package/dist/esm/messageFormat/vue-i18n.mjs +1 -1
  182. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  183. package/dist/esm/transpiler/condition/condition.mjs +1 -1
  184. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  185. package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -1
  186. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  187. package/dist/esm/transpiler/file/file.mjs +1 -1
  188. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  189. package/dist/esm/transpiler/file/fileBrowser.mjs +1 -1
  190. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  191. package/dist/esm/transpiler/gender/gender.mjs +1 -1
  192. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  193. package/dist/esm/transpiler/html/html.mjs +1 -1
  194. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  195. package/dist/esm/transpiler/insertion/insertion.mjs +1 -1
  196. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  197. package/dist/esm/transpiler/markdown/markdown.mjs +1 -1
  198. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  199. package/dist/esm/transpiler/nesting/nesting.mjs +1 -1
  200. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  201. package/dist/esm/transpiler/translation/translation.mjs +1 -1
  202. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  203. package/dist/esm/utils/intl.mjs +1 -1
  204. package/dist/esm/utils/intl.mjs.map +1 -1
  205. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  206. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  207. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +12 -11
  208. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
  209. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +12 -11
  210. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  211. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +12 -11
  212. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  213. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +2 -1
  214. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -1
  215. package/dist/types/deepTransformPlugins/getMaskContent.d.ts +1 -1
  216. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +3 -1
  217. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +1 -1
  218. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +1 -1
  219. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +1 -1
  220. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +1 -1
  221. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +1 -1
  222. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +2 -1
  223. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -1
  224. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +2 -1
  225. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +1 -1
  226. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +2 -1
  227. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -1
  228. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +3 -1
  229. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -1
  230. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +3 -1
  231. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -1
  232. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +1 -1
  233. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -1
  234. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +1 -1
  235. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -1
  236. package/dist/types/dictionaryManipulator/getNodeType.d.ts +2 -1
  237. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
  238. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +1 -1
  239. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +1 -1
  240. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +2 -1
  241. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +1 -1
  242. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +3 -3
  243. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
  244. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +2 -1
  245. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -1
  246. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +2 -1
  247. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -1
  248. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +1 -1
  249. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -1
  250. package/dist/types/formatters/compact.d.ts +1 -1
  251. package/dist/types/formatters/currency.d.ts +1 -1
  252. package/dist/types/formatters/date.d.ts +1 -1
  253. package/dist/types/formatters/list.d.ts +1 -1
  254. package/dist/types/formatters/number.d.ts +1 -1
  255. package/dist/types/formatters/percentage.d.ts +1 -1
  256. package/dist/types/formatters/relativeTime.d.ts +1 -1
  257. package/dist/types/formatters/units.d.ts +1 -1
  258. package/dist/types/getStorageAttributes.d.ts +1 -1
  259. package/dist/types/getStorageAttributes.d.ts.map +1 -1
  260. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -1
  261. package/dist/types/interpreter/getContent/getContent.d.ts +2 -1
  262. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  263. package/dist/types/interpreter/getContent/plugins.d.ts +4 -1
  264. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  265. package/dist/types/interpreter/getDictionary.d.ts +2 -1
  266. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  267. package/dist/types/interpreter/getIntlayer.d.ts +1 -1
  268. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  269. package/dist/types/interpreter/getNesting.d.ts +2 -1
  270. package/dist/types/interpreter/getNesting.d.ts.map +1 -1
  271. package/dist/types/interpreter/getTranslation.d.ts +1 -1
  272. package/dist/types/localization/getBrowserLocale.d.ts +1 -1
  273. package/dist/types/localization/getBrowserLocale.d.ts.map +1 -1
  274. package/dist/types/localization/getHTMLTextDir.d.ts +1 -1
  275. package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -1
  276. package/dist/types/localization/getLocale.d.ts +1 -1
  277. package/dist/types/localization/getLocaleFromPath.d.ts +3 -1
  278. package/dist/types/localization/getLocaleFromPath.d.ts.map +1 -1
  279. package/dist/types/localization/getLocaleLang.d.ts +1 -1
  280. package/dist/types/localization/getLocaleName.d.ts +1 -1
  281. package/dist/types/localization/getLocalizedUrl.d.ts +2 -1
  282. package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
  283. package/dist/types/localization/getMultilingualUrls.d.ts +2 -1
  284. package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -1
  285. package/dist/types/localization/getPathWithoutLocale.d.ts +1 -1
  286. package/dist/types/localization/getPrefix.d.ts +3 -1
  287. package/dist/types/localization/getPrefix.d.ts.map +1 -1
  288. package/dist/types/localization/localeDetector.d.ts +1 -1
  289. package/dist/types/localization/localeMapper.d.ts +2 -1
  290. package/dist/types/localization/localeMapper.d.ts.map +1 -1
  291. package/dist/types/localization/localeResolver.d.ts +2 -1
  292. package/dist/types/localization/localeResolver.d.ts.map +1 -1
  293. package/dist/types/localization/rewriteUtils.d.ts +3 -1
  294. package/dist/types/localization/rewriteUtils.d.ts.map +1 -1
  295. package/dist/types/localization/validatePrefix.d.ts +1 -1
  296. package/dist/types/messageFormat/ICU.d.ts +1 -1
  297. package/dist/types/messageFormat/ICU.d.ts.map +1 -1
  298. package/dist/types/messageFormat/i18next.d.ts +1 -1
  299. package/dist/types/messageFormat/vue-i18n.d.ts +1 -1
  300. package/dist/types/messageFormat/vue-i18n.d.ts.map +1 -1
  301. package/dist/types/transpiler/condition/condition.d.ts +1 -1
  302. package/dist/types/transpiler/condition/condition.d.ts.map +1 -1
  303. package/dist/types/transpiler/enumeration/enumeration.d.ts +1 -1
  304. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  305. package/dist/types/transpiler/file/file.d.ts +1 -1
  306. package/dist/types/transpiler/file/file.d.ts.map +1 -1
  307. package/dist/types/transpiler/file/fileBrowser.d.ts +1 -1
  308. package/dist/types/transpiler/file/fileBrowser.d.ts.map +1 -1
  309. package/dist/types/transpiler/gender/gender.d.ts +1 -1
  310. package/dist/types/transpiler/gender/gender.d.ts.map +1 -1
  311. package/dist/types/transpiler/html/html.d.ts +1 -1
  312. package/dist/types/transpiler/html/html.d.ts.map +1 -1
  313. package/dist/types/transpiler/insertion/insertion.d.ts +1 -1
  314. package/dist/types/transpiler/insertion/insertion.d.ts.map +1 -1
  315. package/dist/types/transpiler/markdown/markdown.d.ts +1 -1
  316. package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
  317. package/dist/types/transpiler/nesting/nesting.d.ts +2 -1
  318. package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
  319. package/dist/types/transpiler/translation/translation.d.ts +3 -2
  320. package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
  321. package/dist/types/utils/intl.d.ts +1 -1
  322. package/dist/types/utils/intl.d.ts.map +1 -1
  323. package/dist/types/utils/isSameKeyPath.d.ts +1 -1
  324. package/dist/types/utils/localeStorage.d.ts +2 -1
  325. package/dist/types/utils/localeStorage.d.ts.map +1 -1
  326. package/package.json +17 -17
@@ -1 +1 @@
1
- {"version":3,"file":"insertContentInDictionary.mjs","names":[],"sources":["../../../src/deepTransformPlugins/insertContentInDictionary.ts"],"sourcesContent":["import { type Dictionary, type LocalesValues, NodeType } from '@intlayer/types';\n\n// {\n// {\n// title: 'このページ',\n// linkLabel: 'セクションへ移動',\n// collapseButton: { label: '折りたたむ' }\n// },\n// }\n// {\n// dictionary: {\n// key: 'aside-navigation',\n// content: {\n// title: {\n// nodeType: 'translation',\n// translation: {\n// ar: 'في هذه الصفحة',\n// de: 'Auf dieser Seite',\n// en: 'In this page',\n// 'en-GB': 'On this page',\n// es: 'En esta página',\n// fr: 'Dans cette page',\n// hi: 'इस पृष्ठ में',\n// it: 'In questa pagina',\n// ko: '이 페이지에서',\n// pt: 'Nesta página',\n// ru: 'На этой странице',\n// tr: 'Bu sayfada',\n// zh: '在此页面'\n// }\n// },\n// linkLabel: {\n// nodeType: 'translation',\n// translation: {\n// ar: 'اذهب إلى القسم',\n// de: 'Gehe zur Sektion',\n// en: 'Go to section',\n// 'en-GB': 'Go to section',\n// es: 'Ir a la sección',\n// fr: 'Aller à la section',\n// hi: 'सेक्शन पर जाएं',\n// it: 'Vai alla sezione',\n// ja: 'セクションへ行く',\n// ko: '섹션으로 이동',\n// pt: 'Ir para a seção',\n// ru: 'Перейти к разделу',\n// tr: 'Bölüme git',\n// zh: '转到节'\n// }\n// },\n// collapseButton: {\n// label: {\n// nodeType: 'translation',\n// translation: {\n// en: 'Collapse',\n// fr: 'Réduire',\n// es: 'Colapsar',\n// 'en-GB': 'Collapse',\n// de: 'Zuklappen',\n// ja: '折りたたむ',\n// ko: '접기',\n// zh: '折叠',\n// it: 'Comprimi',\n// pt: 'Recolher',\n// hi: 'संकुचित करें',\n// ar: 'اطوي التوسيع',\n// ru: 'Свернуть',\n// tr: 'Daralt'\n// }\n// }\n// }\n// },\n// localId: 'aside-navigation::local::src/components/AsideNavigation/asideNavigation.content.ts',\n// location: 'local',\n// filePath: 'src/components/AsideNavigation/asideNavigation.content.ts'\n// }\n// }\n\n/**\n * Deep merge helper that handles translation blocks\n * @param target - The target object (dictionary content)\n * @param source - The source object (new content to merge)\n * @param locale - Optional locale to target specific translation\n * @returns Merged content\n */\nconst deepMergeContent = (\n target: any,\n source: any,\n locale?: LocalesValues\n): any => {\n // If source is null or undefined, return target\n if (source === null || source === undefined) return target;\n\n // If target is null or undefined, initialize based on source type\n if (target === null || target === undefined) {\n if (Array.isArray(source)) {\n target = [];\n } else if (typeof source === 'object') {\n target = {};\n } else {\n return source;\n }\n }\n\n // Handle translation nodes FIRST (before arrays) to support arrays within translations\n if (\n target &&\n typeof target === 'object' &&\n target.nodeType === NodeType.Translation\n ) {\n // Target is a translation block\n if (locale) {\n // Update only the specific locale - create new object to preserve order\n const existingLocaleContent = target.translation[locale];\n let newLocaleContent: any;\n\n if (typeof source === 'object' && !Array.isArray(source)) {\n // Source is an object, need to deep merge for this locale\n newLocaleContent = deepMergeContent(\n existingLocaleContent,\n source,\n undefined // Don't pass locale down for nested content\n );\n } else if (Array.isArray(source)) {\n // Source is an array, set it directly for this locale\n newLocaleContent = source;\n } else {\n // Source is a primitive, directly set it\n newLocaleContent = source;\n }\n\n // Return new object with locale appended at the end (preserve insertion order)\n return {\n ...target,\n translation: {\n ...target.translation,\n [locale]: newLocaleContent,\n },\n };\n } else {\n // No locale specified, replace/merge the entire translation\n if (\n typeof source === 'object' &&\n !Array.isArray(source) &&\n source.nodeType === NodeType.Translation\n ) {\n // Source is also a translation node, merge translations\n return {\n ...target,\n translation: {\n ...target.translation,\n ...source.translation,\n },\n };\n } else {\n // Source is not a translation node, wrap it\n return processNewContent(source, locale);\n }\n }\n }\n\n // Handle arrays\n if (Array.isArray(source)) {\n if (locale && Array.isArray(target)) {\n // When locale is specified and target is also an array, merge element by element\n const result = [];\n const maxLength = Math.max(source.length, target.length);\n\n for (let i = 0; i < maxLength; i++) {\n if (i < source.length) {\n if (i < target.length && target[i] !== undefined) {\n // Both source and target have element at this index - merge them\n result[i] = deepMergeContent(target[i], source[i], locale);\n } else {\n // Only source has element at this index - process new content\n result[i] = processNewContent(source[i], locale);\n }\n } else {\n // Only target has element at this index - keep it\n result[i] = target[i];\n }\n }\n\n return result;\n } else {\n // No locale or target is not an array - replace entirely\n return source.map((item) => {\n // Process each item in case it needs locale wrapping\n if (\n item &&\n typeof item === 'object' &&\n item.nodeType === NodeType.Translation\n ) {\n return item;\n }\n return processNewContent(item, locale);\n });\n }\n }\n\n // Handle objects\n if (typeof source === 'object' && !Array.isArray(source)) {\n if (typeof target !== 'object' || Array.isArray(target)) {\n target = {};\n }\n\n // Create new object to preserve key order and avoid mutation\n const result: any = { ...target };\n\n for (const key in source) {\n if (Object.hasOwn(source, key)) {\n if (target[key] !== undefined) {\n result[key] = deepMergeContent(target[key], source[key], locale);\n } else {\n result[key] = processNewContent(source[key], locale);\n }\n }\n }\n\n return result;\n }\n\n // For primitives, just return the source\n return source;\n};\n\n/**\n * Process new content that doesn't exist in target\n * @param content - New content to process\n * @param locale - Optional locale\n * @returns Processed content\n */\nconst processNewContent = (content: any, locale?: LocalesValues): any => {\n // Handle null and undefined\n if (content === null || content === undefined) {\n return content;\n }\n\n // If content is already a translation node, return as-is\n if (\n content &&\n typeof content === 'object' &&\n content.nodeType === NodeType.Translation\n ) {\n return content;\n }\n\n // Handle arrays\n if (Array.isArray(content)) {\n return content.map((item) => processNewContent(item, locale));\n }\n\n // Handle objects\n if (content && typeof content === 'object') {\n const result: any = {};\n\n for (const key in content) {\n if (Object.hasOwn(content, key)) {\n result[key] = processNewContent(content[key], locale);\n }\n }\n return result;\n }\n\n // Handle primitives\n if (locale) {\n // Wrap in translation node with the specific locale\n return {\n nodeType: NodeType.Translation,\n translation: {\n [locale]: content,\n },\n };\n } else {\n // If no locale, just return the content as-is (don't wrap)\n return content;\n }\n};\n\n/**\n * Insert content into a dictionary with deep merge support\n * Handles translation blocks and nested structures\n *\n * @param dictionary - The dictionary to insert content into\n * @param content - The content to insert\n * @param locale - Optional locale to target specific translation\n * @returns Updated dictionary\n *\n * @example\n * // Without locale - deep merge all content\n * insertContentInDictionary(dictionary, { title: 'New Title' })\n *\n * @example\n * // With locale - insert content for specific locale\n * insertContentInDictionary(dictionary, { title: 'このページ' }, 'ja')\n */\nexport const insertContentInDictionary = (\n dictionary: Dictionary,\n content: Dictionary['content'],\n locale?: LocalesValues\n): Dictionary => {\n const mergedContent = deepMergeContent(\n Array.isArray(dictionary.content)\n ? [...dictionary.content]\n : { ...dictionary.content },\n content,\n locale\n );\n\n return {\n ...dictionary,\n content: mergedContent,\n };\n};\n"],"mappings":"2CAqFA,MAAM,GACJ,EACA,EACA,IACQ,CAER,GAAI,GAAW,KAA8B,OAAO,EAGpD,GAAI,GAAW,KACb,GAAI,MAAM,QAAQ,EAAO,CACvB,EAAS,EAAE,SACF,OAAO,GAAW,SAC3B,EAAS,EAAE,MAEX,OAAO,EAKX,GACE,GACA,OAAO,GAAW,UAClB,EAAO,WAAa,EAAS,YAG7B,GAAI,EAAQ,CAEV,IAAM,EAAwB,EAAO,YAAY,GAC7C,EAkBJ,MAhBA,CAYE,EAZE,OAAO,GAAW,UAAY,CAAC,MAAM,QAAQ,EAAO,CAEnC,EACjB,EACA,EACA,IAAA,GACD,CAGkB,EAOd,CACL,GAAG,EACH,YAAa,CACX,GAAG,EAAO,aACT,GAAS,EACX,CACF,SAIC,OAAO,GAAW,UAClB,CAAC,MAAM,QAAQ,EAAO,EACtB,EAAO,WAAa,EAAS,YAG7B,MAAO,CACL,GAAG,EACH,YAAa,CACX,GAAG,EAAO,YACV,GAAG,EAAO,YACX,CACF,MAGD,OAAO,EAAkB,EAAQ,EAAO,CAM9C,GAAI,MAAM,QAAQ,EAAO,CACvB,GAAI,GAAU,MAAM,QAAQ,EAAO,CAAE,CAEnC,IAAM,EAAS,EAAE,CACX,EAAY,KAAK,IAAI,EAAO,OAAQ,EAAO,OAAO,CAExD,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,IACzB,EAAI,EAAO,OACT,EAAI,EAAO,QAAU,EAAO,KAAO,IAAA,GAErC,EAAO,GAAK,EAAiB,EAAO,GAAI,EAAO,GAAI,EAAO,CAG1D,EAAO,GAAK,EAAkB,EAAO,GAAI,EAAO,CAIlD,EAAO,GAAK,EAAO,GAIvB,OAAO,OAGP,OAAO,EAAO,IAAK,GAGf,GACA,OAAO,GAAS,UAChB,EAAK,WAAa,EAAS,YAEpB,EAEF,EAAkB,EAAM,EAAO,CACtC,CAKN,GAAI,OAAO,GAAW,UAAY,CAAC,MAAM,QAAQ,EAAO,CAAE,EACpD,OAAO,GAAW,UAAY,MAAM,QAAQ,EAAO,IACrD,EAAS,EAAE,EAIb,IAAM,EAAc,CAAE,GAAG,EAAQ,CAEjC,IAAK,IAAM,KAAO,EACZ,OAAO,OAAO,EAAQ,EAAI,GACxB,EAAO,KAAS,IAAA,GAGlB,EAAO,GAAO,EAAkB,EAAO,GAAM,EAAO,CAFpD,EAAO,GAAO,EAAiB,EAAO,GAAM,EAAO,GAAM,EAAO,EAOtE,OAAO,EAIT,OAAO,GASH,GAAqB,EAAc,IAAgC,CAOvE,GALI,GAAY,MAMd,GACA,OAAO,GAAY,UACnB,EAAQ,WAAa,EAAS,YAE9B,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAQ,CACxB,OAAO,EAAQ,IAAK,GAAS,EAAkB,EAAM,EAAO,CAAC,CAI/D,GAAI,GAAW,OAAO,GAAY,SAAU,CAC1C,IAAM,EAAc,EAAE,CAEtB,IAAK,IAAM,KAAO,EACZ,OAAO,OAAO,EAAS,EAAI,GAC7B,EAAO,GAAO,EAAkB,EAAQ,GAAM,EAAO,EAGzD,OAAO,EAcP,OAVE,EAEK,CACL,SAAU,EAAS,YACnB,YAAa,EACV,GAAS,EACX,CACF,CAGM,GAqBE,GACX,EACA,EACA,IACe,CACf,IAAM,EAAgB,EACpB,MAAM,QAAQ,EAAW,QAAQ,CAC7B,CAAC,GAAG,EAAW,QAAQ,CACvB,CAAE,GAAG,EAAW,QAAS,CAC7B,EACA,EACD,CAED,MAAO,CACL,GAAG,EACH,QAAS,EACV"}
1
+ {"version":3,"file":"insertContentInDictionary.mjs","names":[],"sources":["../../../src/deepTransformPlugins/insertContentInDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\n\n// {\n// {\n// title: 'このページ',\n// linkLabel: 'セクションへ移動',\n// collapseButton: { label: '折りたたむ' }\n// },\n// }\n// {\n// dictionary: {\n// key: 'aside-navigation',\n// content: {\n// title: {\n// nodeType: 'translation',\n// translation: {\n// ar: 'في هذه الصفحة',\n// de: 'Auf dieser Seite',\n// en: 'In this page',\n// 'en-GB': 'On this page',\n// es: 'En esta página',\n// fr: 'Dans cette page',\n// hi: 'इस पृष्ठ में',\n// it: 'In questa pagina',\n// ko: '이 페이지에서',\n// pt: 'Nesta página',\n// ru: 'На этой странице',\n// tr: 'Bu sayfada',\n// zh: '在此页面'\n// }\n// },\n// linkLabel: {\n// nodeType: 'translation',\n// translation: {\n// ar: 'اذهب إلى القسم',\n// de: 'Gehe zur Sektion',\n// en: 'Go to section',\n// 'en-GB': 'Go to section',\n// es: 'Ir a la sección',\n// fr: 'Aller à la section',\n// hi: 'सेक्शन पर जाएं',\n// it: 'Vai alla sezione',\n// ja: 'セクションへ行く',\n// ko: '섹션으로 이동',\n// pt: 'Ir para a seção',\n// ru: 'Перейти к разделу',\n// tr: 'Bölüme git',\n// zh: '转到节'\n// }\n// },\n// collapseButton: {\n// label: {\n// nodeType: 'translation',\n// translation: {\n// en: 'Collapse',\n// fr: 'Réduire',\n// es: 'Colapsar',\n// 'en-GB': 'Collapse',\n// de: 'Zuklappen',\n// ja: '折りたたむ',\n// ko: '접기',\n// zh: '折叠',\n// it: 'Comprimi',\n// pt: 'Recolher',\n// hi: 'संकुचित करें',\n// ar: 'اطوي التوسيع',\n// ru: 'Свернуть',\n// tr: 'Daralt'\n// }\n// }\n// }\n// },\n// localId: 'aside-navigation::local::src/components/AsideNavigation/asideNavigation.content.ts',\n// location: 'local',\n// filePath: 'src/components/AsideNavigation/asideNavigation.content.ts'\n// }\n// }\n\n/**\n * Deep merge helper that handles translation blocks\n * @param target - The target object (dictionary content)\n * @param source - The source object (new content to merge)\n * @param locale - Optional locale to target specific translation\n * @returns Merged content\n */\nconst deepMergeContent = (\n target: any,\n source: any,\n locale?: LocalesValues\n): any => {\n // If source is null or undefined, return target\n if (source === null || source === undefined) return target;\n\n // If target is null or undefined, initialize based on source type\n if (target === null || target === undefined) {\n if (Array.isArray(source)) {\n target = [];\n } else if (typeof source === 'object') {\n target = {};\n } else {\n return source;\n }\n }\n\n // Handle translation nodes FIRST (before arrays) to support arrays within translations\n if (\n target &&\n typeof target === 'object' &&\n target.nodeType === NodeType.Translation\n ) {\n // Target is a translation block\n if (locale) {\n // Update only the specific locale - create new object to preserve order\n const existingLocaleContent = target.translation[locale];\n let newLocaleContent: any;\n\n if (typeof source === 'object' && !Array.isArray(source)) {\n // Source is an object, need to deep merge for this locale\n newLocaleContent = deepMergeContent(\n existingLocaleContent,\n source,\n undefined // Don't pass locale down for nested content\n );\n } else if (Array.isArray(source)) {\n // Source is an array, set it directly for this locale\n newLocaleContent = source;\n } else {\n // Source is a primitive, directly set it\n newLocaleContent = source;\n }\n\n // Return new object with locale appended at the end (preserve insertion order)\n return {\n ...target,\n translation: {\n ...target.translation,\n [locale]: newLocaleContent,\n },\n };\n } else {\n // No locale specified, replace/merge the entire translation\n if (\n typeof source === 'object' &&\n !Array.isArray(source) &&\n source.nodeType === NodeType.Translation\n ) {\n // Source is also a translation node, merge translations\n return {\n ...target,\n translation: {\n ...target.translation,\n ...source.translation,\n },\n };\n } else {\n // Source is not a translation node, wrap it\n return processNewContent(source, locale);\n }\n }\n }\n\n // Handle arrays\n if (Array.isArray(source)) {\n if (locale && Array.isArray(target)) {\n // When locale is specified and target is also an array, merge element by element\n const result = [];\n const maxLength = Math.max(source.length, target.length);\n\n for (let i = 0; i < maxLength; i++) {\n if (i < source.length) {\n if (i < target.length && target[i] !== undefined) {\n // Both source and target have element at this index - merge them\n result[i] = deepMergeContent(target[i], source[i], locale);\n } else {\n // Only source has element at this index - process new content\n result[i] = processNewContent(source[i], locale);\n }\n } else {\n // Only target has element at this index - keep it\n result[i] = target[i];\n }\n }\n\n return result;\n } else {\n // No locale or target is not an array - replace entirely\n return source.map((item) => {\n // Process each item in case it needs locale wrapping\n if (\n item &&\n typeof item === 'object' &&\n item.nodeType === NodeType.Translation\n ) {\n return item;\n }\n return processNewContent(item, locale);\n });\n }\n }\n\n // Handle objects\n if (typeof source === 'object' && !Array.isArray(source)) {\n if (typeof target !== 'object' || Array.isArray(target)) {\n target = {};\n }\n\n // Create new object to preserve key order and avoid mutation\n const result: any = { ...target };\n\n for (const key in source) {\n if (Object.hasOwn(source, key)) {\n if (target[key] !== undefined) {\n result[key] = deepMergeContent(target[key], source[key], locale);\n } else {\n result[key] = processNewContent(source[key], locale);\n }\n }\n }\n\n return result;\n }\n\n // For primitives, just return the source\n return source;\n};\n\n/**\n * Process new content that doesn't exist in target\n * @param content - New content to process\n * @param locale - Optional locale\n * @returns Processed content\n */\nconst processNewContent = (content: any, locale?: LocalesValues): any => {\n // Handle null and undefined\n if (content === null || content === undefined) {\n return content;\n }\n\n // If content is already a translation node, return as-is\n if (\n content &&\n typeof content === 'object' &&\n content.nodeType === NodeType.Translation\n ) {\n return content;\n }\n\n // Handle arrays\n if (Array.isArray(content)) {\n return content.map((item) => processNewContent(item, locale));\n }\n\n // Handle objects\n if (content && typeof content === 'object') {\n const result: any = {};\n\n for (const key in content) {\n if (Object.hasOwn(content, key)) {\n result[key] = processNewContent(content[key], locale);\n }\n }\n return result;\n }\n\n // Handle primitives\n if (locale) {\n // Wrap in translation node with the specific locale\n return {\n nodeType: NodeType.Translation,\n translation: {\n [locale]: content,\n },\n };\n } else {\n // If no locale, just return the content as-is (don't wrap)\n return content;\n }\n};\n\n/**\n * Insert content into a dictionary with deep merge support\n * Handles translation blocks and nested structures\n *\n * @param dictionary - The dictionary to insert content into\n * @param content - The content to insert\n * @param locale - Optional locale to target specific translation\n * @returns Updated dictionary\n *\n * @example\n * // Without locale - deep merge all content\n * insertContentInDictionary(dictionary, { title: 'New Title' })\n *\n * @example\n * // With locale - insert content for specific locale\n * insertContentInDictionary(dictionary, { title: 'このページ' }, 'ja')\n */\nexport const insertContentInDictionary = (\n dictionary: Dictionary,\n content: Dictionary['content'],\n locale?: LocalesValues\n): Dictionary => {\n const mergedContent = deepMergeContent(\n Array.isArray(dictionary.content)\n ? [...dictionary.content]\n : { ...dictionary.content },\n content,\n locale\n );\n\n return {\n ...dictionary,\n content: mergedContent,\n };\n};\n"],"mappings":"oDAuFA,MAAM,GACJ,EACA,EACA,IACQ,CAER,GAAI,GAAW,KAA8B,OAAO,EAGpD,GAAI,GAAW,KACb,GAAI,MAAM,QAAQ,EAAO,CACvB,EAAS,EAAE,SACF,OAAO,GAAW,SAC3B,EAAS,EAAE,MAEX,OAAO,EAKX,GACE,GACA,OAAO,GAAW,UAClB,EAAO,WAAa,EAAS,YAG7B,GAAI,EAAQ,CAEV,IAAM,EAAwB,EAAO,YAAY,GAC7C,EAkBJ,MAhBA,CAYE,EAZE,OAAO,GAAW,UAAY,CAAC,MAAM,QAAQ,EAAO,CAEnC,EACjB,EACA,EACA,IAAA,GACD,CAGkB,EAOd,CACL,GAAG,EACH,YAAa,CACX,GAAG,EAAO,aACT,GAAS,EACX,CACF,SAIC,OAAO,GAAW,UAClB,CAAC,MAAM,QAAQ,EAAO,EACtB,EAAO,WAAa,EAAS,YAG7B,MAAO,CACL,GAAG,EACH,YAAa,CACX,GAAG,EAAO,YACV,GAAG,EAAO,YACX,CACF,MAGD,OAAO,EAAkB,EAAQ,EAAO,CAM9C,GAAI,MAAM,QAAQ,EAAO,CACvB,GAAI,GAAU,MAAM,QAAQ,EAAO,CAAE,CAEnC,IAAM,EAAS,EAAE,CACX,EAAY,KAAK,IAAI,EAAO,OAAQ,EAAO,OAAO,CAExD,IAAK,IAAI,EAAI,EAAG,EAAI,EAAW,IACzB,EAAI,EAAO,OACT,EAAI,EAAO,QAAU,EAAO,KAAO,IAAA,GAErC,EAAO,GAAK,EAAiB,EAAO,GAAI,EAAO,GAAI,EAAO,CAG1D,EAAO,GAAK,EAAkB,EAAO,GAAI,EAAO,CAIlD,EAAO,GAAK,EAAO,GAIvB,OAAO,OAGP,OAAO,EAAO,IAAK,GAGf,GACA,OAAO,GAAS,UAChB,EAAK,WAAa,EAAS,YAEpB,EAEF,EAAkB,EAAM,EAAO,CACtC,CAKN,GAAI,OAAO,GAAW,UAAY,CAAC,MAAM,QAAQ,EAAO,CAAE,EACpD,OAAO,GAAW,UAAY,MAAM,QAAQ,EAAO,IACrD,EAAS,EAAE,EAIb,IAAM,EAAc,CAAE,GAAG,EAAQ,CAEjC,IAAK,IAAM,KAAO,EACZ,OAAO,OAAO,EAAQ,EAAI,GACxB,EAAO,KAAS,IAAA,GAGlB,EAAO,GAAO,EAAkB,EAAO,GAAM,EAAO,CAFpD,EAAO,GAAO,EAAiB,EAAO,GAAM,EAAO,GAAM,EAAO,EAOtE,OAAO,EAIT,OAAO,GASH,GAAqB,EAAc,IAAgC,CAOvE,GALI,GAAY,MAMd,GACA,OAAO,GAAY,UACnB,EAAQ,WAAa,EAAS,YAE9B,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAQ,CACxB,OAAO,EAAQ,IAAK,GAAS,EAAkB,EAAM,EAAO,CAAC,CAI/D,GAAI,GAAW,OAAO,GAAY,SAAU,CAC1C,IAAM,EAAc,EAAE,CAEtB,IAAK,IAAM,KAAO,EACZ,OAAO,OAAO,EAAS,EAAI,GAC7B,EAAO,GAAO,EAAkB,EAAQ,GAAM,EAAO,EAGzD,OAAO,EAcP,OAVE,EAEK,CACL,SAAU,EAAS,YACnB,YAAa,EACV,GAAS,EACX,CACF,CAGM,GAqBE,GACX,EACA,EACA,IACe,CACf,IAAM,EAAgB,EACpB,MAAM,QAAQ,EAAW,QAAQ,CAC7B,CAAC,GAAG,EAAW,QAAQ,CACvB,CAAE,GAAG,EAAW,QAAS,CAC7B,EACA,EACD,CAED,MAAO,CACL,GAAG,EACH,QAAS,EACV"}
@@ -1,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=(t,n,r)=>{let i=t,a=null,o=[];if(n.length===0)return r;try{for(let t=0;t<n.length;t++){let s=n[t];if(a=i,(s.type===e.Object||s.type===e.Array)&&(o=[s.key],(!i[s.key]||typeof i[s.key]!=`object`)&&(i[s.key]={}),i=i[s.key]),(s.type===e.Translation||s.type===e.Enumeration)&&(o=[s.type,s.key],(!i[s.type]||typeof i[s.type]!=`object`)&&(i[s.type]={}),(!i[s.type][s.key]||typeof i[s.type][s.key]!=`object`)&&(i[s.type][s.key]={}),i=i[s.type][s.key]),(s.type===e.Enumeration||s.type===e.Condition)&&s.type!==e.Enumeration&&(o=[s.type,s.key],i=i[s.type][s.key]),(s.type===e.Markdown||s.type===e.HTML||s.type===e.Insertion)&&(o=[s.type],(!i[s.type]||typeof i[s.type]!=`object`)&&(i[s.type]=``),i=i[s.type]),s.type===e.File&&(o=[`content`],i=i.content),t===n.length-1&&a&&o.length>0){let e=a;for(let t of o.slice(0,-1))e=e[t];let t=o[o.length-1];if(r===void 0)if(Array.isArray(e)){let n=Number(t);!isNaN(n)&&n>=0&&n<e.length&&e.splice(n,1)}else delete e[t];else e[t]=r}}return t}catch(e){return console.error(`Cannot edit dictionary by key path`,{dictionaryContent:t,keyPath:n,newValue:r},e),t}};export{t as editDictionaryByKeyPath};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=(t,n,r)=>{let i=t,a=null,o=[];if(n.length===0)return r;try{for(let t=0;t<n.length;t++){let s=n[t];if(a=i,(s.type===e.Object||s.type===e.Array)&&(o=[s.key],(!i[s.key]||typeof i[s.key]!=`object`)&&(i[s.key]={}),i=i[s.key]),(s.type===e.Translation||s.type===e.Enumeration)&&(o=[s.type,s.key],(!i[s.type]||typeof i[s.type]!=`object`)&&(i[s.type]={}),(!i[s.type][s.key]||typeof i[s.type][s.key]!=`object`)&&(i[s.type][s.key]={}),i=i[s.type][s.key]),(s.type===e.Enumeration||s.type===e.Condition)&&s.type!==e.Enumeration&&(o=[s.type,s.key],i=i[s.type][s.key]),(s.type===e.Markdown||s.type===e.HTML||s.type===e.Insertion)&&(o=[s.type],(!i[s.type]||typeof i[s.type]!=`object`)&&(i[s.type]=``),i=i[s.type]),s.type===e.File&&(o=[`content`],i=i.content),t===n.length-1&&a&&o.length>0){let e=a;for(let t of o.slice(0,-1))e=e[t];let t=o[o.length-1];if(r===void 0)if(Array.isArray(e)){let n=Number(t);!Number.isNaN(n)&&n>=0&&n<e.length&&e.splice(n,1)}else delete e[t];else e[t]=r}}return t}catch(e){return console.error(`Cannot edit dictionary by key path`,{dictionaryContent:t,keyPath:n,newValue:r},e),t}};export{t as editDictionaryByKeyPath};
2
2
  //# sourceMappingURL=editDictionaryByKeyPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"editDictionaryByKeyPath.mjs","names":[],"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import { type ContentNode, type KeyPath, NodeType } from '@intlayer/types';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n try {\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKeys = [keyObj.key];\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n // Note: Logic above already handles Enumeration, ensure no duplication in your actual file\n // or keep the specific block if your logic differs.\n // The important part is below in the final update block.\n\n // Assuming this block runs for Condition/Gender/etc:\n if (keyObj.type !== NodeType.Enumeration) {\n lastKeys = [keyObj.type, keyObj.key];\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion\n ) {\n lastKeys = [keyObj.type];\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj.type === NodeType.File) {\n lastKeys = ['content'];\n currentValue = currentValue.content;\n }\n\n // Only update the value when processing the last key in the keyPath.\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n\n // Drill down to the container holding the value to be changed\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n\n const finalKey = lastKeys[lastKeys.length - 1];\n\n if (typeof newValue === 'undefined') {\n // Use splice for arrays to re-index the list, use delete for objects\n if (Array.isArray(target)) {\n const index = Number(finalKey);\n if (!isNaN(index) && index >= 0 && index < target.length) {\n target.splice(index, 1);\n }\n } else {\n delete target[finalKey];\n }\n } else {\n target[finalKey] = newValue;\n }\n }\n }\n\n return dictionaryContent;\n } catch (error) {\n console.error(\n 'Cannot edit dictionary by key path',\n { dictionaryContent, keyPath, newValue },\n error\n );\n return dictionaryContent;\n }\n};\n"],"mappings":"2CAIA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAA0B,EAAE,CAEhC,GAAI,EAAQ,SAAW,EACrB,OAAO,EAGT,GAAI,CACF,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAM,EAAS,EAAQ,GAsEvB,GArEA,EAAc,GAEV,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAW,CAAC,EAAO,IAAI,EAErB,CAAC,EAAa,EAAO,MACrB,OAAO,EAAa,EAAO,MAAS,YAEpC,EAAa,EAAO,KAAO,EAAE,EAE/B,EAAe,EAAa,EAAO,OAInC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,eAEzB,EAAW,CAAC,EAAO,KAAM,EAAO,IAAI,EAElC,CAAC,EAAa,EAAO,OACrB,OAAO,EAAa,EAAO,OAAU,YAErC,EAAa,EAAO,MAAQ,EAAE,GAG9B,CAAC,EAAa,EAAO,MAAM,EAAO,MAClC,OAAO,EAAa,EAAO,MAAM,EAAO,MAAS,YAEjD,EAAa,EAAO,MAAM,EAAO,KAAO,EAAE,EAE5C,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,YAOrB,EAAO,OAAS,EAAS,cAC3B,EAAW,CAAC,EAAO,KAAM,EAAO,IAAI,CACpC,EAAe,EAAa,EAAO,MAAM,EAAO,OAKlD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,aAEzB,EAAW,CAAC,EAAO,KAAK,EAEtB,CAAC,EAAa,EAAO,OACrB,OAAO,EAAa,EAAO,OAAU,YAErC,EAAa,EAAO,MAAQ,IAE9B,EAAe,EAAa,EAAO,OAGjC,EAAO,OAAS,EAAS,OAC3B,EAAW,CAAC,UAAU,CACtB,EAAe,EAAa,SAI1B,IAAM,EAAQ,OAAS,GAAK,GAAe,EAAS,OAAS,EAAG,CAClE,IAAI,EAAS,EAGb,IAAK,IAAM,KAAO,EAAS,MAAM,EAAG,GAAG,CACrC,EAAS,EAAO,GAGlB,IAAM,EAAW,EAAS,EAAS,OAAS,GAE5C,GAAW,IAAa,OAEtB,GAAI,MAAM,QAAQ,EAAO,CAAE,CACzB,IAAM,EAAQ,OAAO,EAAS,CAC1B,CAAC,MAAM,EAAM,EAAI,GAAS,GAAK,EAAQ,EAAO,QAChD,EAAO,OAAO,EAAO,EAAE,MAGzB,OAAO,EAAO,QAGhB,EAAO,GAAY,GAKzB,OAAO,QACA,EAAO,CAMd,OALA,QAAQ,MACN,qCACA,CAAE,oBAAmB,UAAS,WAAU,CACxC,EACD,CACM"}
1
+ {"version":3,"file":"editDictionaryByKeyPath.mjs","names":[],"sources":["../../../src/dictionaryManipulator/editDictionaryByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\n\nimport { NodeType } from '@intlayer/types/nodeType';\n\ntype LastKeyType = string | number;\n\nexport const editDictionaryByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n newValue: ContentNode\n): ContentNode => {\n let currentValue: any = dictionaryContent;\n let parentValue: any = null;\n let lastKeys: LastKeyType[] = [];\n\n if (keyPath.length === 0) {\n return newValue;\n }\n\n try {\n for (let i = 0; i < keyPath.length; i++) {\n const keyObj = keyPath[i];\n parentValue = currentValue;\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n lastKeys = [keyObj.key];\n\n if (\n !currentValue[keyObj.key] ||\n typeof currentValue[keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Enumeration\n ) {\n lastKeys = [keyObj.type, keyObj.key];\n\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = {};\n }\n\n if (\n !currentValue[keyObj.type][keyObj.key] ||\n typeof currentValue[keyObj.type][keyObj.key] !== 'object'\n ) {\n currentValue[keyObj.type][keyObj.key] = {};\n }\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Enumeration ||\n keyObj.type === NodeType.Condition\n ) {\n // Note: Logic above already handles Enumeration, ensure no duplication in your actual file\n // or keep the specific block if your logic differs.\n // The important part is below in the final update block.\n\n // Assuming this block runs for Condition/Gender/etc:\n\n if (keyObj.type !== NodeType.Enumeration) {\n lastKeys = [keyObj.type, keyObj.key];\n currentValue = currentValue[keyObj.type][keyObj.key];\n }\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion\n ) {\n lastKeys = [keyObj.type];\n\n if (\n !currentValue[keyObj.type] ||\n typeof currentValue[keyObj.type] !== 'object'\n ) {\n currentValue[keyObj.type] = '';\n }\n currentValue = currentValue[keyObj.type];\n }\n\n if (keyObj.type === NodeType.File) {\n lastKeys = ['content'];\n currentValue = currentValue.content;\n }\n\n // Only update the value when processing the last key in the keyPath.\n\n if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {\n let target = parentValue;\n\n // Drill down to the container holding the value to be changed\n for (const key of lastKeys.slice(0, -1)) {\n target = target[key];\n }\n\n const finalKey = lastKeys[lastKeys.length - 1];\n\n if (typeof newValue === 'undefined') {\n // Use splice for arrays to re-index the list, use delete for objects\n\n if (Array.isArray(target)) {\n const index = Number(finalKey);\n\n if (!Number.isNaN(index) && index >= 0 && index < target.length) {\n target.splice(index, 1);\n }\n } else {\n delete target[finalKey];\n }\n } else {\n target[finalKey] = newValue;\n }\n }\n }\n\n return dictionaryContent;\n } catch (error) {\n console.error(\n 'Cannot edit dictionary by key path',\n { dictionaryContent, keyPath, newValue },\n error\n );\n return dictionaryContent;\n }\n};\n"],"mappings":"oDAOA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAA0B,EAAE,CAEhC,GAAI,EAAQ,SAAW,EACrB,OAAO,EAGT,GAAI,CACF,IAAK,IAAI,EAAI,EAAG,EAAI,EAAQ,OAAQ,IAAK,CACvC,IAAM,EAAS,EAAQ,GA4EvB,GA3EA,EAAc,GAEV,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAW,CAAC,EAAO,IAAI,EAGrB,CAAC,EAAa,EAAO,MACrB,OAAO,EAAa,EAAO,MAAS,YAEpC,EAAa,EAAO,KAAO,EAAE,EAE/B,EAAe,EAAa,EAAO,OAInC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,eAEzB,EAAW,CAAC,EAAO,KAAM,EAAO,IAAI,EAGlC,CAAC,EAAa,EAAO,OACrB,OAAO,EAAa,EAAO,OAAU,YAErC,EAAa,EAAO,MAAQ,EAAE,GAI9B,CAAC,EAAa,EAAO,MAAM,EAAO,MAClC,OAAO,EAAa,EAAO,MAAM,EAAO,MAAS,YAEjD,EAAa,EAAO,MAAM,EAAO,KAAO,EAAE,EAE5C,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,YAQrB,EAAO,OAAS,EAAS,cAC3B,EAAW,CAAC,EAAO,KAAM,EAAO,IAAI,CACpC,EAAe,EAAa,EAAO,MAAM,EAAO,OAKlD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,aAEzB,EAAW,CAAC,EAAO,KAAK,EAGtB,CAAC,EAAa,EAAO,OACrB,OAAO,EAAa,EAAO,OAAU,YAErC,EAAa,EAAO,MAAQ,IAE9B,EAAe,EAAa,EAAO,OAGjC,EAAO,OAAS,EAAS,OAC3B,EAAW,CAAC,UAAU,CACtB,EAAe,EAAa,SAK1B,IAAM,EAAQ,OAAS,GAAK,GAAe,EAAS,OAAS,EAAG,CAClE,IAAI,EAAS,EAGb,IAAK,IAAM,KAAO,EAAS,MAAM,EAAG,GAAG,CACrC,EAAS,EAAO,GAGlB,IAAM,EAAW,EAAS,EAAS,OAAS,GAE5C,GAAW,IAAa,OAGtB,GAAI,MAAM,QAAQ,EAAO,CAAE,CACzB,IAAM,EAAQ,OAAO,EAAS,CAE1B,CAAC,OAAO,MAAM,EAAM,EAAI,GAAS,GAAK,EAAQ,EAAO,QACvD,EAAO,OAAO,EAAO,EAAE,MAGzB,OAAO,EAAO,QAGhB,EAAO,GAAY,GAKzB,OAAO,QACA,EAAO,CAMd,OALA,QAAQ,MACN,qCACA,CAAE,oBAAmB,UAAS,WAAU,CACxC,EACD,CACM"}
@@ -1,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=(t,n,r)=>{let i=structuredClone(t);for(let t of n)r&&i?.nodeType===e.Translation&&(i=i?.[e.Translation]?.[r]),(t.type===e.Object||t.type===e.Array)&&(i=i?.[t.key]),(t.type===e.Translation||t.type===e.Condition||t.type===e.Enumeration)&&(i=i?.[t.type]?.[t.key]),(t.type===e.Markdown||t.type===e.HTML||t.type===e.Insertion||t.type===e.File)&&(i=i?.[t.type]);return i};export{t as getContentNodeByKeyPath};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=(t,n,r)=>{let i=structuredClone(t);for(let t of n)r&&i?.nodeType===e.Translation&&(i=i?.[e.Translation]?.[r]),(t.type===e.Object||t.type===e.Array)&&(i=i?.[t.key]),(t.type===e.Translation||t.type===e.Condition||t.type===e.Enumeration)&&(i=i?.[t.type]?.[t.key]),(t.type===e.Markdown||t.type===e.HTML||t.type===e.Insertion||t.type===e.File)&&(i=i?.[t.type]);return i};export{t as getContentNodeByKeyPath};
2
2
  //# sourceMappingURL=getContentNodeByKeyPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getContentNodeByKeyPath.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import {\n type ContentNode,\n type KeyPath,\n type Locale,\n NodeType,\n} from '@intlayer/types';\n\nexport const getContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n fallbackLocale?: Locale\n): ContentNode => {\n let currentValue: any = structuredClone(dictionaryContent);\n\n for (const keyObj of keyPath) {\n // Auto-resolve translation nodes when fallbackLocale is provided\n if (fallbackLocale && currentValue?.nodeType === NodeType.Translation) {\n currentValue = currentValue?.[NodeType.Translation]?.[fallbackLocale];\n }\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n currentValue = currentValue?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Condition ||\n keyObj.type === NodeType.Enumeration\n ) {\n currentValue = currentValue?.[keyObj.type]?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n currentValue = currentValue?.[keyObj.type];\n }\n }\n\n return currentValue as ContentNode;\n};\n"],"mappings":"2CAOA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,gBAAgB,EAAkB,CAE1D,IAAK,IAAM,KAAU,EAEf,GAAkB,GAAc,WAAa,EAAS,cACxD,EAAe,IAAe,EAAS,eAAe,KAGpD,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAe,IAAe,EAAO,OAIrC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,eAEzB,EAAe,IAAe,EAAO,QAAQ,EAAO,OAIpD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,QAEzB,EAAe,IAAe,EAAO,OAIzC,OAAO"}
1
+ {"version":3,"file":"getContentNodeByKeyPath.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getContentNodeByKeyPath.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { NodeType } from '@intlayer/types/nodeType';\n\nexport const getContentNodeByKeyPath = (\n dictionaryContent: ContentNode,\n keyPath: KeyPath[],\n fallbackLocale?: Locale\n): ContentNode => {\n let currentValue: any = structuredClone(dictionaryContent);\n\n for (const keyObj of keyPath) {\n // Auto-resolve translation nodes when fallbackLocale is provided\n if (fallbackLocale && currentValue?.nodeType === NodeType.Translation) {\n currentValue = currentValue?.[NodeType.Translation]?.[fallbackLocale];\n }\n\n if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) {\n currentValue = currentValue?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Translation ||\n keyObj.type === NodeType.Condition ||\n keyObj.type === NodeType.Enumeration\n ) {\n currentValue = currentValue?.[keyObj.type]?.[keyObj.key];\n }\n\n if (\n keyObj.type === NodeType.Markdown ||\n keyObj.type === NodeType.HTML ||\n keyObj.type === NodeType.Insertion ||\n keyObj.type === NodeType.File\n ) {\n currentValue = currentValue?.[keyObj.type];\n }\n }\n\n return currentValue as ContentNode;\n};\n"],"mappings":"oDAKA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,gBAAgB,EAAkB,CAE1D,IAAK,IAAM,KAAU,EAEf,GAAkB,GAAc,WAAa,EAAS,cACxD,EAAe,IAAe,EAAS,eAAe,KAGpD,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAe,IAAe,EAAO,OAIrC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,eAEzB,EAAe,IAAe,EAAO,QAAQ,EAAO,OAIpD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,QAEzB,EAAe,IAAe,EAAO,OAIzC,OAAO"}
@@ -1,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=(t,n,r)=>{let i=structuredClone(r);switch(t){case e.Translation:return{nodeType:e.Translation,[e.Translation]:Object.assign({},...n.map(e=>({[e]:structuredClone(i)??``})))};case e.Enumeration:return{nodeType:e.Enumeration,[e.Enumeration]:{1:i??``}};case e.Condition:return{nodeType:e.Condition,[e.Condition]:{true:i??``,false:i??``}};case e.Insertion:return{nodeType:e.Insertion,[e.Insertion]:{insertion:i??``}};case e.Nested:return{nodeType:e.Nested,[e.Nested]:{dictionaryKey:``}};case e.Markdown:return{nodeType:e.Markdown,[e.Markdown]:i??``};case e.HTML:return{nodeType:e.HTML,[e.HTML]:i??``,customComponents:[]};case e.File:return{nodeType:e.File,[e.File]:i??``};case e.Object:return{newKey:i??``};case e.Array:return[i??``];case e.Text:return i??``;case e.Number:return i??0;case e.Boolean:return i??!0;default:return i??``}};export{t as getDefaultNode};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=(t,n,r)=>{let i=structuredClone(r);switch(t){case e.Translation:return{nodeType:e.Translation,[e.Translation]:Object.assign({},...n.map(e=>({[e]:structuredClone(i)??``})))};case e.Enumeration:return{nodeType:e.Enumeration,[e.Enumeration]:{1:i??``}};case e.Condition:return{nodeType:e.Condition,[e.Condition]:{true:i??``,false:i??``}};case e.Insertion:return{nodeType:e.Insertion,[e.Insertion]:{insertion:i??``}};case e.Nested:return{nodeType:e.Nested,[e.Nested]:{dictionaryKey:``}};case e.Markdown:return{nodeType:e.Markdown,[e.Markdown]:i??``};case e.HTML:return{nodeType:e.HTML,[e.HTML]:i??``,customComponents:[]};case e.File:return{nodeType:e.File,[e.File]:i??``};case e.Object:return{newKey:i??``};case e.Array:return[i??``];case e.Text:return i??``;case e.Number:return i??0;case e.Boolean:return i??!0;default:return i??``}};export{t as getDefaultNode};
2
2
  //# sourceMappingURL=getDefaultNode.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultNode.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import {\n type ContentNode,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\n\nexport const getDefaultNode = (\n nodeType: NodeType,\n locales: LocalesValues[],\n content?: ContentNode\n): ContentNode => {\n const clonedContent = structuredClone(content);\n switch (nodeType) {\n case NodeType.Translation:\n return {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: structuredClone(clonedContent) ?? '',\n }))\n ),\n } as ContentNode;\n\n case NodeType.Enumeration:\n return {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeType.Condition:\n return {\n nodeType: NodeType.Condition,\n [NodeType.Condition]: {\n true: clonedContent ?? '',\n false: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeType.Insertion:\n return {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: {\n insertion: clonedContent ?? '',\n },\n } as unknown as ContentNode;\n\n case NodeType.Nested:\n return {\n nodeType: NodeType.Nested,\n [NodeType.Nested]: {\n dictionaryKey: '',\n },\n } as ContentNode;\n\n case NodeType.Markdown:\n return {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeType.HTML:\n return {\n nodeType: NodeType.HTML,\n [NodeType.HTML]: clonedContent ?? '',\n customComponents: [],\n } as ContentNode;\n\n case NodeType.File:\n return {\n nodeType: NodeType.File,\n [NodeType.File]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeType.Object:\n return {\n newKey: clonedContent ?? '',\n } as unknown as ContentNode;\n\n case NodeType.Array:\n return [clonedContent ?? ''] as unknown as ContentNode;\n\n case NodeType.Text:\n return clonedContent ?? '';\n\n case NodeType.Number:\n return clonedContent ?? 0;\n\n case NodeType.Boolean:\n return clonedContent ?? true;\n\n default:\n return clonedContent ?? '';\n }\n};\n"],"mappings":"2CAMA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAM,EAAgB,gBAAgB,EAAQ,CAC9C,OAAQ,EAAR,CACE,KAAK,EAAS,YACZ,MAAO,CACL,SAAU,EAAS,aAClB,EAAS,aAAc,OAAO,OAC7B,EAAE,CACF,GAAG,EAAQ,IAAK,IAAY,EACzB,GAAS,gBAAgB,EAAc,EAAI,GAC7C,EAAE,CACJ,CACF,CAEH,KAAK,EAAS,YACZ,MAAO,CACL,SAAU,EAAS,aAClB,EAAS,aAAc,CACtB,EAAK,GAAiB,GACvB,CACF,CAEH,KAAK,EAAS,UACZ,MAAO,CACL,SAAU,EAAS,WAClB,EAAS,WAAY,CACpB,KAAM,GAAiB,GACvB,MAAO,GAAiB,GACzB,CACF,CAEH,KAAK,EAAS,UACZ,MAAO,CACL,SAAU,EAAS,WAClB,EAAS,WAAY,CACpB,UAAW,GAAiB,GAC7B,CACF,CAEH,KAAK,EAAS,OACZ,MAAO,CACL,SAAU,EAAS,QAClB,EAAS,QAAS,CACjB,cAAe,GAChB,CACF,CAEH,KAAK,EAAS,SACZ,MAAO,CACL,SAAU,EAAS,UAClB,EAAS,UAAW,GAAiB,GACvC,CAEH,KAAK,EAAS,KACZ,MAAO,CACL,SAAU,EAAS,MAClB,EAAS,MAAO,GAAiB,GAClC,iBAAkB,EAAE,CACrB,CAEH,KAAK,EAAS,KACZ,MAAO,CACL,SAAU,EAAS,MAClB,EAAS,MAAO,GAAiB,GACnC,CAEH,KAAK,EAAS,OACZ,MAAO,CACL,OAAQ,GAAiB,GAC1B,CAEH,KAAK,EAAS,MACZ,MAAO,CAAC,GAAiB,GAAG,CAE9B,KAAK,EAAS,KACZ,OAAO,GAAiB,GAE1B,KAAK,EAAS,OACZ,OAAO,GAAiB,EAE1B,KAAK,EAAS,QACZ,OAAO,GAAiB,GAE1B,QACE,OAAO,GAAiB"}
1
+ {"version":3,"file":"getDefaultNode.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getDefaultNode.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';;\nimport { NodeType } from '@intlayer/types/nodeType';\n\nexport const getDefaultNode = (\n nodeType: NodeType,\n locales: LocalesValues[],\n content?: ContentNode\n): ContentNode => {\n const clonedContent = structuredClone(content);\n switch (nodeType) {\n case NodeType.Translation:\n return {\n nodeType: NodeType.Translation,\n [NodeType.Translation]: Object.assign(\n {},\n ...locales.map((locale) => ({\n [locale]: structuredClone(clonedContent) ?? '',\n }))\n ),\n } as ContentNode;\n\n case NodeType.Enumeration:\n return {\n nodeType: NodeType.Enumeration,\n [NodeType.Enumeration]: {\n '1': clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeType.Condition:\n return {\n nodeType: NodeType.Condition,\n [NodeType.Condition]: {\n true: clonedContent ?? '',\n false: clonedContent ?? '',\n },\n } as ContentNode;\n\n case NodeType.Insertion:\n return {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: {\n insertion: clonedContent ?? '',\n },\n } as unknown as ContentNode;\n\n case NodeType.Nested:\n return {\n nodeType: NodeType.Nested,\n [NodeType.Nested]: {\n dictionaryKey: '',\n },\n } as ContentNode;\n\n case NodeType.Markdown:\n return {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeType.HTML:\n return {\n nodeType: NodeType.HTML,\n [NodeType.HTML]: clonedContent ?? '',\n customComponents: [],\n } as ContentNode;\n\n case NodeType.File:\n return {\n nodeType: NodeType.File,\n [NodeType.File]: clonedContent ?? '',\n } as ContentNode;\n\n case NodeType.Object:\n return {\n newKey: clonedContent ?? '',\n } as unknown as ContentNode;\n\n case NodeType.Array:\n return [clonedContent ?? ''] as unknown as ContentNode;\n\n case NodeType.Text:\n return clonedContent ?? '';\n\n case NodeType.Number:\n return clonedContent ?? 0;\n\n case NodeType.Boolean:\n return clonedContent ?? true;\n\n default:\n return clonedContent ?? '';\n }\n};\n"],"mappings":"oDAIA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAM,EAAgB,gBAAgB,EAAQ,CAC9C,OAAQ,EAAR,CACE,KAAK,EAAS,YACZ,MAAO,CACL,SAAU,EAAS,aAClB,EAAS,aAAc,OAAO,OAC7B,EAAE,CACF,GAAG,EAAQ,IAAK,IAAY,EACzB,GAAS,gBAAgB,EAAc,EAAI,GAC7C,EAAE,CACJ,CACF,CAEH,KAAK,EAAS,YACZ,MAAO,CACL,SAAU,EAAS,aAClB,EAAS,aAAc,CACtB,EAAK,GAAiB,GACvB,CACF,CAEH,KAAK,EAAS,UACZ,MAAO,CACL,SAAU,EAAS,WAClB,EAAS,WAAY,CACpB,KAAM,GAAiB,GACvB,MAAO,GAAiB,GACzB,CACF,CAEH,KAAK,EAAS,UACZ,MAAO,CACL,SAAU,EAAS,WAClB,EAAS,WAAY,CACpB,UAAW,GAAiB,GAC7B,CACF,CAEH,KAAK,EAAS,OACZ,MAAO,CACL,SAAU,EAAS,QAClB,EAAS,QAAS,CACjB,cAAe,GAChB,CACF,CAEH,KAAK,EAAS,SACZ,MAAO,CACL,SAAU,EAAS,UAClB,EAAS,UAAW,GAAiB,GACvC,CAEH,KAAK,EAAS,KACZ,MAAO,CACL,SAAU,EAAS,MAClB,EAAS,MAAO,GAAiB,GAClC,iBAAkB,EAAE,CACrB,CAEH,KAAK,EAAS,KACZ,MAAO,CACL,SAAU,EAAS,MAClB,EAAS,MAAO,GAAiB,GACnC,CAEH,KAAK,EAAS,OACZ,MAAO,CACL,OAAQ,GAAiB,GAC1B,CAEH,KAAK,EAAS,MACZ,MAAO,CAAC,GAAiB,GAAG,CAE9B,KAAK,EAAS,KACZ,OAAO,GAAiB,GAE1B,KAAK,EAAS,OACZ,OAAO,GAAiB,EAE1B,KAAK,EAAS,QACZ,OAAO,GAAiB,GAE1B,QACE,OAAO,GAAiB"}
@@ -1,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=n=>{if(typeof n==`string`)return``;if(typeof n==`number`)return 0;if(typeof n==`boolean`)return!0;if(typeof n?.nodeType==`string`){let r=n,i=r[r.nodeType];return r.nodeType===e.Translation||r.nodeType===e.Enumeration||r.nodeType===e.Condition||r.nodeType===e.Insertion||r.nodeType===e.HTML?t(i):r.nodeType===e.Nested?`dictionary-key`:r.nodeType===e.File?`file/path`:r.nodeType===e.Markdown?t(r):i}if(!n||typeof n!=`object`)return n;if(Array.isArray(n))return n.map(t);let r=Object.entries(n).map(([e,n])=>[e,t(n)]);return Object.fromEntries(r)};export{t as getEmptyNode};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=n=>{if(typeof n==`string`)return``;if(typeof n==`number`)return 0;if(typeof n==`boolean`)return!0;if(typeof n?.nodeType==`string`){let r=n,i=r[r.nodeType];return r.nodeType===e.Translation||r.nodeType===e.Enumeration||r.nodeType===e.Condition||r.nodeType===e.Insertion||r.nodeType===e.HTML?t(i):r.nodeType===e.Nested?`dictionary-key`:r.nodeType===e.File?`file/path`:r.nodeType===e.Markdown?t(r):i}if(!n||typeof n!=`object`)return n;if(Array.isArray(n))return n.map(t);let r=Object.entries(n).map(([e,n])=>[e,t(n)]);return Object.fromEntries(r)};export{t as getEmptyNode};
2
2
  //# sourceMappingURL=getEmptyNode.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEmptyNode.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getEmptyNode.ts"],"sourcesContent":["import { type ContentNode, NodeType, type TypedNode } from '@intlayer/types';\n\nexport const getEmptyNode = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return '';\n }\n if (typeof section === 'number') {\n return 0;\n }\n if (typeof section === 'boolean') {\n return true;\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 typedNode.nodeType === NodeType.Insertion ||\n typedNode.nodeType === NodeType.HTML\n ) {\n return getEmptyNode(content as ContentNode);\n }\n\n if (typedNode.nodeType === NodeType.Nested) {\n return 'dictionary-key';\n }\n\n if (typedNode.nodeType === NodeType.File) {\n return 'file/path';\n }\n\n if (typedNode.nodeType === NodeType.Markdown) {\n return getEmptyNode(typedNode);\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[]).map(\n getEmptyNode\n ) as unknown as ContentNode;\n }\n\n const mappedSectionObject = Object.entries(section).map(([key, value]) => [\n key,\n getEmptyNode(value as ContentNode),\n ]);\n\n const mappedSectionArray = Object.fromEntries(mappedSectionObject);\n\n return mappedSectionArray;\n};\n"],"mappings":"2CAEA,MAAa,EAAgB,GAAsC,CACjE,GAAI,OAAO,GAAY,SACrB,MAAO,GAET,GAAI,OAAO,GAAY,SACrB,MAAO,GAET,GAAI,OAAO,GAAY,UACrB,MAAO,GAET,GAAI,OAAQ,GAAuB,UAAa,SAAU,CACxD,IAAM,EAAY,EACZ,EACJ,EAAU,EAAU,UAwBtB,OArBE,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,KAEzB,EAAa,EAAuB,CAGzC,EAAU,WAAa,EAAS,OAC3B,iBAGL,EAAU,WAAa,EAAS,KAC3B,YAGL,EAAU,WAAa,EAAS,SAC3B,EAAa,EAAU,CAGzB,EAGT,GAAI,CAAC,GAAW,OAAO,GAAY,SACjC,OAAO,EAGT,GAAI,MAAM,QAAQ,EAAQ,CACxB,OAAQ,EAA0B,IAChC,EACD,CAGH,IAAM,EAAsB,OAAO,QAAQ,EAAQ,CAAC,KAAK,CAAC,EAAK,KAAW,CACxE,EACA,EAAa,EAAqB,CACnC,CAAC,CAIF,OAF2B,OAAO,YAAY,EAAoB"}
1
+ {"version":3,"file":"getEmptyNode.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getEmptyNode.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';;\nimport { NodeType } from '@intlayer/types/nodeType';\n\nexport const getEmptyNode = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return '';\n }\n if (typeof section === 'number') {\n return 0;\n }\n if (typeof section === 'boolean') {\n return true;\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 typedNode.nodeType === NodeType.Insertion ||\n typedNode.nodeType === NodeType.HTML\n ) {\n return getEmptyNode(content as ContentNode);\n }\n\n if (typedNode.nodeType === NodeType.Nested) {\n return 'dictionary-key';\n }\n\n if (typedNode.nodeType === NodeType.File) {\n return 'file/path';\n }\n\n if (typedNode.nodeType === NodeType.Markdown) {\n return getEmptyNode(typedNode);\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[]).map(\n getEmptyNode\n ) as unknown as ContentNode;\n }\n\n const mappedSectionObject = Object.entries(section).map(([key, value]) => [\n key,\n getEmptyNode(value as ContentNode),\n ]);\n\n const mappedSectionArray = Object.fromEntries(mappedSectionObject);\n\n return mappedSectionArray;\n};\n"],"mappings":"oDAGA,MAAa,EAAgB,GAAsC,CACjE,GAAI,OAAO,GAAY,SACrB,MAAO,GAET,GAAI,OAAO,GAAY,SACrB,MAAO,GAET,GAAI,OAAO,GAAY,UACrB,MAAO,GAET,GAAI,OAAQ,GAAuB,UAAa,SAAU,CACxD,IAAM,EAAY,EACZ,EACJ,EAAU,EAAU,UAwBtB,OArBE,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,KAEzB,EAAa,EAAuB,CAGzC,EAAU,WAAa,EAAS,OAC3B,iBAGL,EAAU,WAAa,EAAS,KAC3B,YAGL,EAAU,WAAa,EAAS,SAC3B,EAAa,EAAU,CAGzB,EAGT,GAAI,CAAC,GAAW,OAAO,GAAY,SACjC,OAAO,EAGT,GAAI,MAAM,QAAQ,EAAQ,CACxB,OAAQ,EAA0B,IAChC,EACD,CAGH,IAAM,EAAsB,OAAO,QAAQ,EAAQ,CAAC,KAAK,CAAC,EAAK,KAAW,CACxE,EACA,EAAa,EAAqB,CACnC,CAAC,CAIF,OAF2B,OAAO,YAAY,EAAoB"}
@@ -1,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=t=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return t;if(typeof t?.nodeType==`string`){let n=t,r=n[n.nodeType];return n.nodeType===e.Translation||n.nodeType===e.Enumeration||n.nodeType===e.Condition||n.nodeType===e.Insertion||n.nodeType===e.Gender||n.nodeType===e.File||n.nodeType===e.Markdown||n.nodeType===e.HTML?r[Object.keys(r)[0]]:n.nodeType===e.Nested?void 0:r}return!t||typeof t!=`object`?t:Array.isArray(t)?t[0]:t};export{t as getNodeChildren};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=t=>{if(typeof t==`string`||typeof t==`number`||typeof t==`boolean`)return t;if(typeof t?.nodeType==`string`){let n=t,r=n[n.nodeType];return n.nodeType===e.Translation||n.nodeType===e.Enumeration||n.nodeType===e.Condition||n.nodeType===e.Insertion||n.nodeType===e.Gender||n.nodeType===e.File||n.nodeType===e.Markdown||n.nodeType===e.HTML?r[Object.keys(r)[0]]:n.nodeType===e.Nested?void 0:r}return!t||typeof t!=`object`?t:Array.isArray(t)?t[0]:t};export{t as getNodeChildren};
2
2
  //# sourceMappingURL=getNodeChildren.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNodeChildren.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getNodeChildren.ts"],"sourcesContent":["import { type ContentNode, NodeType, type TypedNode } from '@intlayer/types';\n\nexport const getNodeChildren = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return section;\n }\n if (typeof section === 'number') {\n return section;\n }\n if (typeof section === 'boolean') {\n return section;\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 typedNode.nodeType === NodeType.Insertion ||\n typedNode.nodeType === NodeType.Gender ||\n typedNode.nodeType === NodeType.File ||\n typedNode.nodeType === NodeType.Markdown ||\n typedNode.nodeType === NodeType.HTML\n ) {\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n return content[firstKey] as ContentNode;\n }\n\n if (typedNode.nodeType === NodeType.Nested) {\n return undefined;\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[])[0];\n }\n\n return section;\n};\n"],"mappings":"2CAEA,MAAa,EAAmB,GAAsC,CAOpE,GANI,OAAO,GAAY,UAGnB,OAAO,GAAY,UAGnB,OAAO,GAAY,UACrB,OAAO,EAET,GAAI,OAAQ,GAAuB,UAAa,SAAU,CACxD,IAAM,EAAY,EACZ,EACJ,EAAU,EAAU,UAoBtB,OAjBE,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,QAChC,EAAU,WAAa,EAAS,MAChC,EAAU,WAAa,EAAS,UAChC,EAAU,WAAa,EAAS,KAGzB,EADU,OAAO,KAAK,EAAQ,CAAC,IAIpC,EAAU,WAAa,EAAS,OAClC,OAGK,EAWT,MARI,CAAC,GAAW,OAAO,GAAY,SAC1B,EAGL,MAAM,QAAQ,EAAQ,CAChB,EAA0B,GAG7B"}
1
+ {"version":3,"file":"getNodeChildren.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getNodeChildren.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';;\nimport { NodeType } from '@intlayer/types/nodeType';\n\nexport const getNodeChildren = (section: ContentNode): ContentNode => {\n if (typeof section === 'string') {\n return section;\n }\n if (typeof section === 'number') {\n return section;\n }\n if (typeof section === 'boolean') {\n return section;\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 typedNode.nodeType === NodeType.Insertion ||\n typedNode.nodeType === NodeType.Gender ||\n typedNode.nodeType === NodeType.File ||\n typedNode.nodeType === NodeType.Markdown ||\n typedNode.nodeType === NodeType.HTML\n ) {\n const firstKey = Object.keys(content)[0] as keyof typeof content;\n return content[firstKey] as ContentNode;\n }\n\n if (typedNode.nodeType === NodeType.Nested) {\n return undefined;\n }\n\n return content;\n }\n\n if (!section || typeof section !== 'object') {\n return section;\n }\n\n if (Array.isArray(section)) {\n return (section as ContentNode[])[0];\n }\n\n return section;\n};\n"],"mappings":"oDAGA,MAAa,EAAmB,GAAsC,CAOpE,GANI,OAAO,GAAY,UAGnB,OAAO,GAAY,UAGnB,OAAO,GAAY,UACrB,OAAO,EAET,GAAI,OAAQ,GAAuB,UAAa,SAAU,CACxD,IAAM,EAAY,EACZ,EACJ,EAAU,EAAU,UAoBtB,OAjBE,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,WAChC,EAAU,WAAa,EAAS,QAChC,EAAU,WAAa,EAAS,MAChC,EAAU,WAAa,EAAS,UAChC,EAAU,WAAa,EAAS,KAGzB,EADU,OAAO,KAAK,EAAQ,CAAC,IAIpC,EAAU,WAAa,EAAS,OAClC,OAGK,EAWT,MARI,CAAC,GAAW,OAAO,GAAY,SAC1B,EAGL,MAAM,QAAQ,EAAQ,CAChB,EAA0B,GAG7B"}
@@ -1,2 +1,2 @@
1
- import{isValidElement as e}from"../utils/isValidReactElement.mjs";import{NodeType as t}from"@intlayer/types";const n=e=>typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`string`,r=e=>Object.values(t).includes(e),i=i=>{if(typeof i==`string`)return t.Text;if(n(i)){let e=i.nodeType;return r(e)?e:t.Unknown}return Array.isArray(i)?t.Array:e(i)?t.ReactNode:typeof i==`number`?t.Number:typeof i==`boolean`?t.Boolean:i&&typeof i==`object`?t.Object:i===null?t.Null:t.Unknown};export{i as getNodeType};
1
+ import{isValidElement as e}from"../utils/isValidReactElement.mjs";import{NodeType as t}from"@intlayer/types/nodeType";const n=e=>typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`string`,r=e=>Object.values(t).includes(e),i=i=>{if(typeof i==`string`)return t.Text;if(n(i)){let e=i.nodeType;return r(e)?e:t.Unknown}return Array.isArray(i)?t.Array:e(i)?t.ReactNode:typeof i==`number`?t.Number:typeof i==`boolean`?t.Boolean:i&&typeof i==`object`?t.Object:i===null?t.Null:t.Unknown};export{i as getNodeType};
2
2
  //# sourceMappingURL=getNodeType.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNodeType.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getNodeType.ts"],"sourcesContent":["import { type ContentNode, NodeType, type TypedNode } from '@intlayer/types';\nimport { isValidElement } from '../utils/isValidReactElement';\n\n/**\n * Type guard to check if content is a TypedNode\n */\nconst isTypedNode = (content: unknown): content is TypedNode => {\n return (\n typeof content === 'object' &&\n content !== null &&\n 'nodeType' in content &&\n typeof (content as TypedNode).nodeType === 'string'\n );\n};\n\n/**\n * Type guard to check if content is a valid NodeType\n */\nconst isValidNodeType = (nodeType: string): nodeType is NodeType => {\n return Object.values(NodeType).includes(nodeType as NodeType);\n};\n\nexport const getNodeType = (content: ContentNode): NodeType => {\n if (typeof content === 'string') {\n return NodeType.Text;\n }\n\n if (isTypedNode(content)) {\n const nodeType = content.nodeType;\n if (isValidNodeType(nodeType)) {\n return nodeType;\n }\n // Fallback for unknown node types\n return NodeType.Unknown;\n }\n\n if (Array.isArray(content)) {\n return NodeType.Array;\n }\n\n if (isValidElement(content)) {\n return NodeType.ReactNode;\n }\n\n if (typeof content === 'number') {\n return NodeType.Number;\n }\n\n if (typeof content === 'boolean') {\n return NodeType.Boolean;\n }\n\n if (content && typeof content === 'object') {\n return NodeType.Object;\n }\n\n if (content === null) {\n return NodeType.Null;\n }\n\n return NodeType.Unknown;\n};\n"],"mappings":"6GAMA,MAAM,EAAe,GAEjB,OAAO,GAAY,YACnB,GACA,aAAc,GACd,OAAQ,EAAsB,UAAa,SAOzC,EAAmB,GAChB,OAAO,OAAO,EAAS,CAAC,SAAS,EAAqB,CAGlD,EAAe,GAAmC,CAC7D,GAAI,OAAO,GAAY,SACrB,OAAO,EAAS,KAGlB,GAAI,EAAY,EAAQ,CAAE,CACxB,IAAM,EAAW,EAAQ,SAKzB,OAJI,EAAgB,EAAS,CACpB,EAGF,EAAS,QA2BlB,OAxBI,MAAM,QAAQ,EAAQ,CACjB,EAAS,MAGd,EAAe,EAAQ,CAClB,EAAS,UAGd,OAAO,GAAY,SACd,EAAS,OAGd,OAAO,GAAY,UACd,EAAS,QAGd,GAAW,OAAO,GAAY,SACzB,EAAS,OAGd,IAAY,KACP,EAAS,KAGX,EAAS"}
1
+ {"version":3,"file":"getNodeType.mjs","names":[],"sources":["../../../src/dictionaryManipulator/getNodeType.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';;\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { isValidElement } from '../utils/isValidReactElement';\n\n/**\n * Type guard to check if content is a TypedNode\n */\nconst isTypedNode = (content: unknown): content is TypedNode => {\n return (\n typeof content === 'object' &&\n content !== null &&\n 'nodeType' in content &&\n typeof (content as TypedNode).nodeType === 'string'\n );\n};\n\n/**\n * Type guard to check if content is a valid NodeType\n */\nconst isValidNodeType = (nodeType: string): nodeType is NodeType => {\n return Object.values(NodeType).includes(nodeType as NodeType);\n};\n\nexport const getNodeType = (content: ContentNode): NodeType => {\n if (typeof content === 'string') {\n return NodeType.Text;\n }\n\n if (isTypedNode(content)) {\n const nodeType = content.nodeType;\n if (isValidNodeType(nodeType)) {\n return nodeType;\n }\n // Fallback for unknown node types\n return NodeType.Unknown;\n }\n\n if (Array.isArray(content)) {\n return NodeType.Array;\n }\n\n if (isValidElement(content)) {\n return NodeType.ReactNode;\n }\n\n if (typeof content === 'number') {\n return NodeType.Number;\n }\n\n if (typeof content === 'boolean') {\n return NodeType.Boolean;\n }\n\n if (content && typeof content === 'object') {\n return NodeType.Object;\n }\n\n if (content === null) {\n return NodeType.Null;\n }\n\n return NodeType.Unknown;\n};\n"],"mappings":"sHAOA,MAAM,EAAe,GAEjB,OAAO,GAAY,YACnB,GACA,aAAc,GACd,OAAQ,EAAsB,UAAa,SAOzC,EAAmB,GAChB,OAAO,OAAO,EAAS,CAAC,SAAS,EAAqB,CAGlD,EAAe,GAAmC,CAC7D,GAAI,OAAO,GAAY,SACrB,OAAO,EAAS,KAGlB,GAAI,EAAY,EAAQ,CAAE,CACxB,IAAM,EAAW,EAAQ,SAKzB,OAJI,EAAgB,EAAS,CACpB,EAGF,EAAS,QA2BlB,OAxBI,MAAM,QAAQ,EAAQ,CACjB,EAAS,MAGd,EAAe,EAAQ,CAClB,EAAS,UAGd,OAAO,GAAY,SACd,EAAS,OAGd,OAAO,GAAY,UACd,EAAS,QAGd,GAAW,OAAO,GAAY,SACzB,EAAS,OAGd,IAAY,KACP,EAAS,KAGX,EAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDictionaries.mjs","names":[],"sources":["../../../src/dictionaryManipulator/mergeDictionaries.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\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":"gQAaA,MAAM,GACJ,EACA,EACA,EACA,EACA,EAAiB,EAAE,GACV,CACT,IAAM,EAAY,EAAa,EAAc,CAG7C,GACE,GACY,MACZ,GACY,KAEZ,OAEF,IAAM,EAAQ,EAAY,EAAQ,CAC5B,EAAQ,EAAY,EAAQ,CAG9B,SAAU,WAAa,IAAU,YAEjC,IAAU,EAAO,CACnB,EACE,CACE,qBAAqB,EAAY,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,EAAoB,EAA0B,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
+ {"version":3,"file":"mergeDictionaries.mjs","names":[],"sources":["../../../src/dictionaryManipulator/mergeDictionaries.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport type { ContentNode, Dictionary, LocalDictionaryId } from '@intlayer/types/dictionary';\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":"gQASA,MAAM,GACJ,EACA,EACA,EACA,EACA,EAAiB,EAAE,GACV,CACT,IAAM,EAAY,EAAa,EAAc,CAG7C,GACE,GACY,MACZ,GACY,KAEZ,OAEF,IAAM,EAAQ,EAAY,EAAQ,CAC5B,EAAQ,EAAY,EAAQ,CAG9B,SAAU,WAAa,IAAU,YAEjC,IAAU,EAAO,CACnB,EACE,CACE,qBAAqB,EAAY,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,EAAoB,EAA0B,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 +1 @@
1
- {"version":3,"file":"normalizeDictionary.mjs","names":["t"],"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":"mNAKA,MAAa,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,EAAE,EACR,EAAW,QAAS,EAAW,QACjC,CAAC,CACH,CAGH,IAAM,EAAmB,EAAQ,QAC9B,EAAK,KAMJ,EAAI,GALwB,EAC1B,EACA,EACD,CAEiC,QAC3B,GAET,EAAE,CACH,CAED,MAAO,CACL,GAAG,EACH,QAASA,EAAE,EAAiB,CAC7B,EAGU,GACX,EACA,IAE4B,EAAkB,EAAc,EAAc,CAEvB,IAAK,GACtD,EAAoB,EAAY,EAAc,CAC/C"}
1
+ {"version":3,"file":"normalizeDictionary.mjs","names":["t"],"sources":["../../../src/dictionaryManipulator/normalizeDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Locale } from '@intlayer/types/allLocales';\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":"mNAOA,MAAa,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,EAAE,EACR,EAAW,QAAS,EAAW,QACjC,CAAC,CACH,CAGH,IAAM,EAAmB,EAAQ,QAC9B,EAAK,KAMJ,EAAI,GALwB,EAC1B,EACA,EACD,CAEiC,QAC3B,GAET,EAAE,CACH,CAED,MAAO,CACL,GAAG,EACH,QAASA,EAAE,EAAiB,CAC7B,EAGU,GACX,EACA,IAE4B,EAAkB,EAAc,EAAc,CAEvB,IAAK,GACtD,EAAoB,EAAY,EAAc,CAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"orderDictionaries.mjs","names":["intlayerConfig","configuration"],"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":"sCAUA,MAAa,GACX,EACA,EAAgBA,IACC,CACjB,GAAM,CAAE,UAAWC,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
+ {"version":3,"file":"orderDictionaries.mjs","names":["intlayerConfig","configuration"],"sources":["../../../src/dictionaryManipulator/orderDictionaries.ts"],"sourcesContent":["import intlayerConfig from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\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":"sCAUA,MAAa,GACX,EACA,EAAgBA,IACC,CACjB,GAAM,CAAE,UAAWC,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,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=(t,n)=>{let r=t,i=null,a=null;for(let t of n)i=r,(t.type===e.Object||t.type===e.Array)&&(a=t.key,r=r[t.key]),(t.type===e.Translation||t.type===e.Enumeration||t.type===e.Condition)&&(a=t.type,r=r[t.type][t.key]),(t.type===e.Markdown||t.type===e.ReactNode||t.type===e.HTML||t.type===e.Insertion||t.type===e.File)&&(a=t.type,r=r[t.type]);return i&&a!==null&&(Array.isArray(i)?i.splice(a,1):delete i[a]),t};export{t as removeContentNodeByKeyPath};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=(t,n)=>{let r=t,i=null,a=null;for(let t of n)i=r,(t.type===e.Object||t.type===e.Array)&&(a=t.key,r=r[t.key]),(t.type===e.Translation||t.type===e.Enumeration||t.type===e.Condition)&&(a=t.type,r=r[t.type][t.key]),(t.type===e.Markdown||t.type===e.ReactNode||t.type===e.HTML||t.type===e.Insertion||t.type===e.File)&&(a=t.type,r=r[t.type]);return i&&a!==null&&(Array.isArray(i)?i.splice(a,1):delete i[a]),t};export{t as removeContentNodeByKeyPath};
2
2
  //# sourceMappingURL=removeContentNodeByKeyPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"removeContentNodeByKeyPath.mjs","names":[],"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":"2CAEA,MAAa,GACX,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAAkC,KAEtC,IAAK,IAAM,KAAU,EACnB,EAAc,GAEV,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAU,EAAO,IACjB,EAAe,EAAa,EAAO,OAInC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,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
+ {"version":3,"file":"removeContentNodeByKeyPath.mjs","names":[],"sources":["../../../src/dictionaryManipulator/removeContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';;\nimport { NodeType } from '@intlayer/types/nodeType';\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":"oDAIA,MAAa,GACX,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAAkC,KAEtC,IAAK,IAAM,KAAU,EACnB,EAAc,GAEV,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAU,EAAO,IACjB,EAAe,EAAa,EAAO,OAInC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,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,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=(t,n,r)=>{let i=t,a=null,o=null;for(let t of r)a=i,(t.type===e.Object||t.type===e.Array)&&(o=t.key,i=i[t.key]),(t.type===e.Translation||t.type===e.Enumeration||t.type===e.Condition)&&(o=t.type,i=i[t.type][t.key]),(t.type===e.Markdown||t.type===e.ReactNode||t.type===e.HTML||t.type===e.Insertion||t.type===e.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};export{t as renameContentNodeByKeyPath};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=(t,n,r)=>{let i=t,a=null,o=null;for(let t of r)a=i,(t.type===e.Object||t.type===e.Array)&&(o=t.key,i=i[t.key]),(t.type===e.Translation||t.type===e.Enumeration||t.type===e.Condition)&&(o=t.type,i=i[t.type][t.key]),(t.type===e.Markdown||t.type===e.ReactNode||t.type===e.HTML||t.type===e.Insertion||t.type===e.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};export{t as renameContentNodeByKeyPath};
2
2
  //# sourceMappingURL=renameContentNodeByKeyPath.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"renameContentNodeByKeyPath.mjs","names":[],"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":"2CAEA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAAkC,KAEtC,IAAK,IAAM,KAAU,EACnB,EAAc,GAEV,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAU,EAAO,IACjB,EAAe,EAAa,EAAO,OAInC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,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
+ {"version":3,"file":"renameContentNodeByKeyPath.mjs","names":[],"sources":["../../../src/dictionaryManipulator/renameContentNodeByKeyPath.ts"],"sourcesContent":["import type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';;\nimport { NodeType } from '@intlayer/types/nodeType';\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":"oDAIA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,EACpB,EAAmB,KACnB,EAAkC,KAEtC,IAAK,IAAM,KAAU,EACnB,EAAc,GAEV,EAAO,OAAS,EAAS,QAAU,EAAO,OAAS,EAAS,SAC9D,EAAU,EAAO,IACjB,EAAe,EAAa,EAAO,OAInC,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aACzB,EAAO,OAAS,EAAS,aAEzB,EAAU,EAAO,KACjB,EAAe,EAAa,EAAO,MAAM,EAAO,OAIhD,EAAO,OAAS,EAAS,UACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,MACzB,EAAO,OAAS,EAAS,WACzB,EAAO,OAAS,EAAS,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,2 +1,2 @@
1
- import{NodeType as e}from"@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.Translation||r.nodeType===e.Enumeration||r.nodeType===e.Condition){let e=Object.entries(i).reduce((e,[t])=>(e[t]=n,e),{});return{...r,[r.nodeType]:e}}return r.nodeType===e.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}),{})};export{t as updateNodeChildren};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";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.Translation||r.nodeType===e.Enumeration||r.nodeType===e.Condition){let e=Object.entries(i).reduce((e,[t])=>(e[t]=n,e),{});return{...r,[r.nodeType]:e}}return r.nodeType===e.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}),{})};export{t as updateNodeChildren};
2
2
  //# sourceMappingURL=updateNodeChildren.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"updateNodeChildren.mjs","names":[],"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":"2CAEA,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,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,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,WAAa,EAAS,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
+ {"version":3,"file":"updateNodeChildren.mjs","names":[],"sources":["../../../src/dictionaryManipulator/updateNodeChildren.ts"],"sourcesContent":["import type { ContentNode, TypedNode } from '@intlayer/types/dictionary';;\nimport { NodeType } from '@intlayer/types/nodeType';\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":"oDAGA,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,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,aAChC,EAAU,WAAa,EAAS,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,WAAa,EAAS,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 +1 @@
1
- {"version":3,"file":"compact.mjs","names":[],"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":"qFAeA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,GAAG,EACH,SAAU,UACX,CACF,CAAC,OAAO,OAAO,EAAM,CAAC"}
1
+ {"version":3,"file":"compact.mjs","names":[],"sources":["../../../src/formatters/compact.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":"qFAeA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,GAAG,EACH,SAAU,UACX,CACF,CAAC,OAAO,OAAO,EAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"currency.mjs","names":[],"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":"qFAeA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,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
+ {"version":3,"file":"currency.mjs","names":[],"sources":["../../../src/formatters/currency.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":"qFAeA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,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 +1 @@
1
- {"version":3,"file":"date.mjs","names":[],"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":"qFAMA,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,IAAI,EAAW,eAC/B,GAAS,QAAU,GAAe,sBAAsB,cACxD,EACD,CAEgB,OAAO,EAAS"}
1
+ {"version":3,"file":"date.mjs","names":[],"sources":["../../../src/formatters/date.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\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":"qFAMA,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,IAAI,EAAW,eAC/B,GAAS,QAAU,GAAe,sBAAsB,cACxD,EACD,CAEgB,OAAO,EAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"list.mjs","names":[],"sources":["../../../src/formatters/list.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 an array of values into a localized list string using the Intl API.\n *\n * @example\n * list(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * @example\n * list(['red', 'green', 'blue'], { locale: Locales.FRENCH, type: 'disjunction' });\n * // \"rouge, vert ou bleu\"\n *\n * @example\n * list([1, 2, 3], { type: 'unit' });\n * // \"1, 2, 3\"\n */\nexport const list = (\n values: (string | number)[],\n // @ts-ignore Namespace 'Intl' has no exported member 'ListFormatOptions'\n options?: Intl.ListFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.ListFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n type: options?.type ?? 'conjunction',\n style: options?.style ?? 'long',\n ...options,\n }\n ).format(values.map(String));\n"],"mappings":"qFAmBA,MAAa,GACX,EAEA,IAEA,IAAI,EAAW,WACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,KAAM,GAAS,MAAQ,cACvB,MAAO,GAAS,OAAS,OACzB,GAAG,EACJ,CACF,CAAC,OAAO,EAAO,IAAI,OAAO,CAAC"}
1
+ {"version":3,"file":"list.mjs","names":[],"sources":["../../../src/formatters/list.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats an array of values into a localized list string using the Intl API.\n *\n * @example\n * list(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * @example\n * list(['red', 'green', 'blue'], { locale: Locales.FRENCH, type: 'disjunction' });\n * // \"rouge, vert ou bleu\"\n *\n * @example\n * list([1, 2, 3], { type: 'unit' });\n * // \"1, 2, 3\"\n */\nexport const list = (\n values: (string | number)[],\n // @ts-ignore Namespace 'Intl' has no exported member 'ListFormatOptions'\n options?: Intl.ListFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.ListFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n type: options?.type ?? 'conjunction',\n style: options?.style ?? 'long',\n ...options,\n }\n ).format(values.map(String));\n"],"mappings":"qFAmBA,MAAa,GACX,EAEA,IAEA,IAAI,EAAW,WACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,KAAM,GAAS,MAAQ,cACvB,MAAO,GAAS,OAAS,OACzB,GAAG,EACJ,CACF,CAAC,OAAO,EAAO,IAAI,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"number.mjs","names":[],"sources":["../../../src/formatters/number.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 locale-aware formatting.\n *\n * @example\n * number({ value: 123456.789 }); // \"123,456.789\"\n * number({ value: \"1000000\", locale: Locales.FRENCH }); // \"1 000 000\"\n */\nexport const number = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n options\n ).format(Number(value));\n"],"mappings":"qFAWA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,EACD,CAAC,OAAO,OAAO,EAAM,CAAC"}
1
+ {"version":3,"file":"number.mjs","names":[],"sources":["../../../src/formatters/number.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric value using locale-aware formatting.\n *\n * @example\n * number({ value: 123456.789 }); // \"123,456.789\"\n * number({ value: \"1000000\", locale: Locales.FRENCH }); // \"1 000 000\"\n */\nexport const number = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n options\n ).format(Number(value));\n"],"mappings":"qFAWA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,EACD,CAAC,OAAO,OAAO,EAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"percentage.mjs","names":[],"sources":["../../../src/formatters/percentage.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 number as a percentage string (e.g., 0.25 → \"25%\").\n *\n * @example\n * percentage({ value: 0.25 }) // \"25%\"\n * percentage({ value: 0.25, minimumFractionDigits: 2 }) // \"25.00%\"\n */\nexport const percentage = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string => {\n let numericValue = Number(value);\n\n // Normalize: if user passes 10, treat it as 10% instead of 1000%\n if (numericValue > 1) {\n numericValue /= 100;\n }\n\n const formatter = new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n style: 'percent',\n ...options,\n }\n );\n\n return formatter.format(Number(numericValue));\n};\n"],"mappings":"qFAWA,MAAa,GACX,EACA,IACW,CACX,IAAI,EAAe,OAAO,EAAM,CAehC,OAZI,EAAe,IACjB,GAAgB,KAGA,IAAI,EAAW,aAC/B,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,MAAO,UACP,GAAG,EACJ,CACF,CAEgB,OAAO,OAAO,EAAa,CAAC"}
1
+ {"version":3,"file":"percentage.mjs","names":[],"sources":["../../../src/formatters/percentage.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a number as a percentage string (e.g., 0.25 → \"25%\").\n *\n * @example\n * percentage({ value: 0.25 }) // \"25%\"\n * percentage({ value: 0.25, minimumFractionDigits: 2 }) // \"25.00%\"\n */\nexport const percentage = (\n value: string | number,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string => {\n let numericValue = Number(value);\n\n // Normalize: if user passes 10, treat it as 10% instead of 1000%\n if (numericValue > 1) {\n numericValue /= 100;\n }\n\n const formatter = new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n style: 'percent',\n ...options,\n }\n );\n\n return formatter.format(Number(numericValue));\n};\n"],"mappings":"qFAWA,MAAa,GACX,EACA,IACW,CACX,IAAI,EAAe,OAAO,EAAM,CAehC,OAZI,EAAe,IACjB,GAAgB,KAGA,IAAI,EAAW,aAC/B,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,MAAO,UACP,GAAG,EACJ,CACF,CAEgB,OAAO,OAAO,EAAa,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"relativeTime.mjs","names":[],"sources":["../../../src/formatters/relativeTime.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types';\nimport { Intl as CachedIntl } from '../utils/intl';\n\ntype RelativeTimeUnit = Intl.RelativeTimeFormatUnit;\n\n/**\n * Calculate the difference between 2 dates in the given unit.\n */\nconst diffInUnit = (from: Date, to: Date, unit: RelativeTimeUnit): number => {\n const msDiff = to.getTime() - from.getTime();\n const sec = msDiff / 1000;\n\n switch (unit) {\n case 'second':\n return sec;\n case 'minute':\n return sec / 60;\n case 'hour':\n return sec / 3600;\n case 'day':\n return sec / 86400;\n case 'month':\n return sec / (30 * 86400); // approx\n case 'quarter':\n return sec / (3 * 30 * 86400); // 3 months approx\n case 'year':\n return sec / (365 * 86400); // approx\n default:\n return sec;\n }\n};\n\nexport const relativeTime = (\n from: Date | string | number,\n to: Date | string | number = new Date(),\n options?: Intl.RelativeTimeFormatOptions & {\n locale?: LocalesValues;\n unit?: RelativeTimeUnit;\n }\n): string => {\n const fromDate = new Date(from);\n const toDate = new Date(to);\n const unit = options?.unit ?? 'second';\n\n const value = diffInUnit(fromDate, toDate, unit);\n\n return new CachedIntl.RelativeTimeFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n options\n ).format(Math.round(value), unit);\n};\n"],"mappings":"qFASA,MAAM,GAAc,EAAY,EAAU,IAAmC,CAE3E,IAAM,GADS,EAAG,SAAS,CAAG,EAAK,SAAS,EACvB,IAErB,OAAQ,EAAR,CACE,IAAK,SACH,OAAO,EACT,IAAK,SACH,OAAO,EAAM,GACf,IAAK,OACH,OAAO,EAAM,KACf,IAAK,MACH,OAAO,EAAM,MACf,IAAK,QACH,OAAO,GAAO,GAAK,OACrB,IAAK,UACH,OAAO,GAAO,GAAS,OACzB,IAAK,OACH,OAAO,GAAO,IAAM,OACtB,QACE,OAAO,IAIA,GACX,EACA,EAA6B,IAAI,KACjC,IAIW,CACX,IAAM,EAAW,IAAI,KAAK,EAAK,CACzB,EAAS,IAAI,KAAK,EAAG,CACrB,EAAO,GAAS,MAAQ,SAExB,EAAQ,EAAW,EAAU,EAAQ,EAAK,CAEhD,OAAO,IAAI,EAAW,mBACpB,GAAS,QAAU,GAAe,sBAAsB,cACxD,EACD,CAAC,OAAO,KAAK,MAAM,EAAM,CAAE,EAAK"}
1
+ {"version":3,"file":"relativeTime.mjs","names":[],"sources":["../../../src/formatters/relativeTime.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { Intl as CachedIntl } from '../utils/intl';\n\ntype RelativeTimeUnit = Intl.RelativeTimeFormatUnit;\n\n/**\n * Calculate the difference between 2 dates in the given unit.\n */\nconst diffInUnit = (from: Date, to: Date, unit: RelativeTimeUnit): number => {\n const msDiff = to.getTime() - from.getTime();\n const sec = msDiff / 1000;\n\n switch (unit) {\n case 'second':\n return sec;\n case 'minute':\n return sec / 60;\n case 'hour':\n return sec / 3600;\n case 'day':\n return sec / 86400;\n case 'month':\n return sec / (30 * 86400); // approx\n case 'quarter':\n return sec / (3 * 30 * 86400); // 3 months approx\n case 'year':\n return sec / (365 * 86400); // approx\n default:\n return sec;\n }\n};\n\nexport const relativeTime = (\n from: Date | string | number,\n to: Date | string | number = new Date(),\n options?: Intl.RelativeTimeFormatOptions & {\n locale?: LocalesValues;\n unit?: RelativeTimeUnit;\n }\n): string => {\n const fromDate = new Date(from);\n const toDate = new Date(to);\n const unit = options?.unit ?? 'second';\n\n const value = diffInUnit(fromDate, toDate, unit);\n\n return new CachedIntl.RelativeTimeFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n options\n ).format(Math.round(value), unit);\n};\n"],"mappings":"qFASA,MAAM,GAAc,EAAY,EAAU,IAAmC,CAE3E,IAAM,GADS,EAAG,SAAS,CAAG,EAAK,SAAS,EACvB,IAErB,OAAQ,EAAR,CACE,IAAK,SACH,OAAO,EACT,IAAK,SACH,OAAO,EAAM,GACf,IAAK,OACH,OAAO,EAAM,KACf,IAAK,MACH,OAAO,EAAM,MACf,IAAK,QACH,OAAO,GAAO,GAAK,OACrB,IAAK,UACH,OAAO,GAAO,GAAS,OACzB,IAAK,OACH,OAAO,GAAO,IAAM,OACtB,QACE,OAAO,IAIA,GACX,EACA,EAA6B,IAAI,KACjC,IAIW,CACX,IAAM,EAAW,IAAI,KAAK,EAAK,CACzB,EAAS,IAAI,KAAK,EAAG,CACrB,EAAO,GAAS,MAAQ,SAExB,EAAQ,EAAW,EAAU,EAAQ,EAAK,CAEhD,OAAO,IAAI,EAAW,mBACpB,GAAS,QAAU,GAAe,sBAAsB,cACxD,EACD,CAAC,OAAO,KAAK,MAAM,EAAM,CAAE,EAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"units.mjs","names":[],"sources":["../../../src/formatters/units.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 as a localized unit string.\n *\n * @example\n * units({ value: 5, unit: \"kilometer\", unitDisplay: \"long\", locale: \"en-GB\" })\n * // \"5 kilometers\"\n */\nexport const units = (\n value: number | string,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n style: 'unit',\n unit: options?.unit ?? 'day',\n unitDisplay: options?.unitDisplay ?? 'short',\n useGrouping: options?.useGrouping ?? false,\n }\n ).format(Number(value));\n"],"mappings":"qFAWA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,MAAO,OACP,KAAM,GAAS,MAAQ,MACvB,YAAa,GAAS,aAAe,QACrC,YAAa,GAAS,aAAe,GACtC,CACF,CAAC,OAAO,OAAO,EAAM,CAAC"}
1
+ {"version":3,"file":"units.mjs","names":[],"sources":["../../../src/formatters/units.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { Intl as CachedIntl } from '../utils/intl';\n\n/**\n * Formats a numeric value as a localized unit string.\n *\n * @example\n * units({ value: 5, unit: \"kilometer\", unitDisplay: \"long\", locale: \"en-GB\" })\n * // \"5 kilometers\"\n */\nexport const units = (\n value: number | string,\n options?: Intl.NumberFormatOptions & { locale?: LocalesValues }\n): string =>\n new CachedIntl.NumberFormat(\n options?.locale ?? configuration?.internationalization?.defaultLocale,\n {\n style: 'unit',\n unit: options?.unit ?? 'day',\n unitDisplay: options?.unitDisplay ?? 'short',\n useGrouping: options?.useGrouping ?? false,\n }\n ).format(Number(value));\n"],"mappings":"qFAWA,MAAa,GACX,EACA,IAEA,IAAI,EAAW,aACb,GAAS,QAAU,GAAe,sBAAsB,cACxD,CACE,MAAO,OACP,KAAM,GAAS,MAAQ,MACvB,YAAa,GAAS,aAAe,QACrC,YAAa,GAAS,aAAe,GACtC,CACF,CAAC,OAAO,OAAO,EAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getStorageAttributes.mjs","names":[],"sources":["../../src/getStorageAttributes.ts"],"sourcesContent":["import { DefaultValues } from '@intlayer/config/client';\nimport type {\n CookiesAttributes,\n IntlayerConfig,\n StorageAttributes,\n} from '@intlayer/types';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: Omit<CookiesAttributes, 'type' | 'name'>;\n};\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\nexport type ProcessedStorageAttributes = {\n cookies: CookieEntry[];\n localStorage: WebStorageEntry[];\n sessionStorage: WebStorageEntry[];\n headers: HeaderEntry[];\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Creates a cookie entry with default values for missing attributes\n */\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const { name, path, expires, domain, secure, sameSite, httpOnly } =\n options ?? {};\n\n return {\n name: name ?? DefaultValues.Routing.COOKIE_NAME,\n attributes: {\n path,\n expires,\n domain,\n secure,\n sameSite,\n httpOnly,\n },\n };\n};\n\n/**\n * Creates a web storage entry (localStorage or sessionStorage) with default name\n */\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => {\n const { name } = options ?? {};\n\n return {\n name: name ?? DefaultValues.Routing.LOCALE_STORAGE_NAME,\n };\n};\n\n/**\n * Creates a header entry with default name\n */\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => {\n const { name } = options ?? {};\n\n return {\n name: name ?? DefaultValues.Routing.HEADER_NAME,\n };\n};\n\n/**\n * Determines if a storage entry is a cookie based on its properties\n */\nconst isCookieEntry = (entry: any): boolean => {\n return (\n entry.type === 'cookie' ||\n 'sameSite' in entry ||\n 'httpOnly' in entry ||\n 'secure' in entry\n );\n};\n\n/**\n * Determines the storage type from a string literal\n */\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' => {\n return (\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header'\n );\n};\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\n/**\n * Processes a single storage entry and returns the appropriate storage attributes\n */\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n // Handle string literals\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n\n if (entry === 'cookie') {\n return { cookies: [createCookieEntry()] };\n }\n\n if (entry === 'localStorage') {\n return { localStorage: [createWebStorageEntry()] };\n }\n\n if (entry === 'sessionStorage') {\n return { sessionStorage: [createWebStorageEntry()] };\n }\n\n if (entry === 'header') {\n return { headers: [createHeaderEntry()] };\n }\n }\n\n // Handle object entries\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n\n // Handle localStorage\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n const { name, ...rest } = typedEntry as StorageAttributes;\n return { localStorage: [createWebStorageEntry({ name, ...rest })] };\n }\n\n // Handle sessionStorage\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n const { name, ...rest } = typedEntry as StorageAttributes;\n return { sessionStorage: [createWebStorageEntry({ name, ...rest })] };\n }\n\n // Handle header\n if ('type' in typedEntry && typedEntry.type === 'header') {\n const { name, ...rest } = typedEntry as StorageAttributes;\n return { headers: [createHeaderEntry({ name, ...rest })] };\n }\n\n // Default to localStorage for ambiguous objects\n const { name, ...rest } = typedEntry as Omit<StorageAttributes, 'type'>;\n return { localStorage: [createWebStorageEntry({ name, ...rest })] };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\n/**\n * Merges multiple partial storage attributes into a single result\n */\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => {\n return {\n cookies: [...accumulated.cookies, ...(partial.cookies ?? [])],\n localStorage: [\n ...accumulated.localStorage,\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...accumulated.sessionStorage,\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...accumulated.headers, ...(partial.headers ?? [])],\n };\n};\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, and sessionStorage\n */\nexport const getStorageAttributes = (\n options: IntlayerConfig['routing']['storage']\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n // Storage is disabled\n if (options === false || options === undefined) {\n return emptyResult;\n }\n\n // Handle array of storage entries\n if (Array.isArray(options)) {\n return options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult);\n }\n\n // Handle single storage entry\n const partial = processStorageEntry(options);\n\n return mergeStorageAttributes(emptyResult, partial);\n};\n"],"mappings":"wDA8CA,MAAM,EACJ,GACgB,CAChB,GAAM,CAAE,OAAM,OAAM,UAAS,SAAQ,SAAQ,WAAU,YACrD,GAAW,EAAE,CAEf,MAAO,CACL,KAAM,GAAQ,EAAc,QAAQ,YACpC,WAAY,CACV,OACA,UACA,SACA,SACA,WACA,WACD,CACF,EAMG,EACJ,GACoB,CACpB,GAAM,CAAE,QAAS,GAAW,EAAE,CAE9B,MAAO,CACL,KAAM,GAAQ,EAAc,QAAQ,oBACrC,EAMG,EACJ,GACgB,CAChB,GAAM,CAAE,QAAS,GAAW,EAAE,CAE9B,MAAO,CACL,KAAM,GAAQ,EAAc,QAAQ,YACrC,EAMG,EAAiB,GAEnB,EAAM,OAAS,UACf,aAAc,GACd,aAAc,GACd,WAAY,EAOV,EACJ,GAGE,IAAU,UACV,IAAU,gBACV,IAAU,kBACV,IAAU,SAWR,EACJ,GACwC,CAExC,GAAI,OAAO,GAAU,SAAU,CAC7B,GAAI,CAAC,EAAc,EAAM,CACvB,MAAO,CAAE,QAAS,EAAE,CAAE,aAAc,EAAE,CAAE,eAAgB,EAAE,CAAE,QAAS,EAAE,CAAE,CAG3E,GAAI,IAAU,SACZ,MAAO,CAAE,QAAS,CAAC,GAAmB,CAAC,CAAE,CAG3C,GAAI,IAAU,eACZ,MAAO,CAAE,aAAc,CAAC,GAAuB,CAAC,CAAE,CAGpD,GAAI,IAAU,iBACZ,MAAO,CAAE,eAAgB,CAAC,GAAuB,CAAC,CAAE,CAGtD,GAAI,IAAU,SACZ,MAAO,CAAE,QAAS,CAAC,GAAmB,CAAC,CAAE,CAK7C,GAAI,OAAO,GAAU,UAAY,EAAgB,CAC/C,IAAM,EAAa,EAEnB,GAAI,EAAc,EAAW,CAC3B,MAAO,CAAE,QAAS,CAAC,EAAkB,EAAgC,CAAC,CAAE,CAI1E,GAAI,SAAU,GAAc,EAAW,OAAS,eAAgB,CAC9D,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,aAAc,CAAC,EAAsB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAIrE,GAAI,SAAU,GAAc,EAAW,OAAS,iBAAkB,CAChE,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,eAAgB,CAAC,EAAsB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAIvE,GAAI,SAAU,GAAc,EAAW,OAAS,SAAU,CACxD,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,QAAS,CAAC,EAAkB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAI5D,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,aAAc,CAAC,EAAsB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAGrE,MAAO,CAAE,QAAS,EAAE,CAAE,aAAc,EAAE,CAAE,eAAgB,EAAE,CAAE,QAAS,EAAE,CAAE,EAMrE,GACJ,EACA,KAEO,CACL,QAAS,CAAC,GAAG,EAAY,QAAS,GAAI,EAAQ,SAAW,EAAE,CAAE,CAC7D,aAAc,CACZ,GAAG,EAAY,aACf,GAAI,EAAQ,cAAgB,EAAE,CAC/B,CACD,eAAgB,CACd,GAAG,EAAY,eACf,GAAI,EAAQ,gBAAkB,EAAE,CACjC,CACD,QAAS,CAAC,GAAG,EAAY,QAAS,GAAI,EAAQ,SAAW,EAAE,CAAE,CAC9D,EASU,EACX,GAC+B,CAC/B,IAAM,EAA0C,CAC9C,QAAS,EAAE,CACX,aAAc,EAAE,CAChB,eAAgB,EAAE,CAClB,QAAS,EAAE,CACZ,CAkBD,OAfI,IAAY,IAAS,IAAY,IAAA,GAC5B,EAIL,MAAM,QAAQ,EAAQ,CACjB,EAAQ,QAAoC,EAAK,IAE/C,EAAuB,EADd,EAAoB,EAAM,CACC,CAC1C,EAAY,CAMV,EAAuB,EAFd,EAAoB,EAAQ,CAEO"}
1
+ {"version":3,"file":"getStorageAttributes.mjs","names":[],"sources":["../../src/getStorageAttributes.ts"],"sourcesContent":["import { DefaultValues } from '@intlayer/config/client';\nimport type { CookiesAttributes, IntlayerConfig, StorageAttributes } from '@intlayer/types/config';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: Omit<CookiesAttributes, 'type' | 'name'>;\n};\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\nexport type ProcessedStorageAttributes = {\n cookies: CookieEntry[];\n localStorage: WebStorageEntry[];\n sessionStorage: WebStorageEntry[];\n headers: HeaderEntry[];\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Creates a cookie entry with default values for missing attributes\n */\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const { name, path, expires, domain, secure, sameSite, httpOnly } =\n options ?? {};\n\n return {\n name: name ?? DefaultValues.Routing.COOKIE_NAME,\n attributes: {\n path,\n expires,\n domain,\n secure,\n sameSite,\n httpOnly,\n },\n };\n};\n\n/**\n * Creates a web storage entry (localStorage or sessionStorage) with default name\n */\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => {\n const { name } = options ?? {};\n\n return {\n name: name ?? DefaultValues.Routing.LOCALE_STORAGE_NAME,\n };\n};\n\n/**\n * Creates a header entry with default name\n */\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => {\n const { name } = options ?? {};\n\n return {\n name: name ?? DefaultValues.Routing.HEADER_NAME,\n };\n};\n\n/**\n * Determines if a storage entry is a cookie based on its properties\n */\nconst isCookieEntry = (entry: any): boolean => {\n return (\n entry.type === 'cookie' ||\n 'sameSite' in entry ||\n 'httpOnly' in entry ||\n 'secure' in entry\n );\n};\n\n/**\n * Determines the storage type from a string literal\n */\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' => {\n return (\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header'\n );\n};\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\n/**\n * Processes a single storage entry and returns the appropriate storage attributes\n */\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n // Handle string literals\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n\n if (entry === 'cookie') {\n return { cookies: [createCookieEntry()] };\n }\n\n if (entry === 'localStorage') {\n return { localStorage: [createWebStorageEntry()] };\n }\n\n if (entry === 'sessionStorage') {\n return { sessionStorage: [createWebStorageEntry()] };\n }\n\n if (entry === 'header') {\n return { headers: [createHeaderEntry()] };\n }\n }\n\n // Handle object entries\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n\n // Handle localStorage\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n const { name, ...rest } = typedEntry as StorageAttributes;\n return { localStorage: [createWebStorageEntry({ name, ...rest })] };\n }\n\n // Handle sessionStorage\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n const { name, ...rest } = typedEntry as StorageAttributes;\n return { sessionStorage: [createWebStorageEntry({ name, ...rest })] };\n }\n\n // Handle header\n if ('type' in typedEntry && typedEntry.type === 'header') {\n const { name, ...rest } = typedEntry as StorageAttributes;\n return { headers: [createHeaderEntry({ name, ...rest })] };\n }\n\n // Default to localStorage for ambiguous objects\n const { name, ...rest } = typedEntry as Omit<StorageAttributes, 'type'>;\n return { localStorage: [createWebStorageEntry({ name, ...rest })] };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\n/**\n * Merges multiple partial storage attributes into a single result\n */\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => {\n return {\n cookies: [...accumulated.cookies, ...(partial.cookies ?? [])],\n localStorage: [\n ...accumulated.localStorage,\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...accumulated.sessionStorage,\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...accumulated.headers, ...(partial.headers ?? [])],\n };\n};\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, and sessionStorage\n */\nexport const getStorageAttributes = (\n options: IntlayerConfig['routing']['storage']\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n // Storage is disabled\n if (options === false || options === undefined) {\n return emptyResult;\n }\n\n // Handle array of storage entries\n if (Array.isArray(options)) {\n return options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult);\n }\n\n // Handle single storage entry\n const partial = processStorageEntry(options);\n\n return mergeStorageAttributes(emptyResult, partial);\n};\n"],"mappings":"wDA0CA,MAAM,EACJ,GACgB,CAChB,GAAM,CAAE,OAAM,OAAM,UAAS,SAAQ,SAAQ,WAAU,YACrD,GAAW,EAAE,CAEf,MAAO,CACL,KAAM,GAAQ,EAAc,QAAQ,YACpC,WAAY,CACV,OACA,UACA,SACA,SACA,WACA,WACD,CACF,EAMG,EACJ,GACoB,CACpB,GAAM,CAAE,QAAS,GAAW,EAAE,CAE9B,MAAO,CACL,KAAM,GAAQ,EAAc,QAAQ,oBACrC,EAMG,EACJ,GACgB,CAChB,GAAM,CAAE,QAAS,GAAW,EAAE,CAE9B,MAAO,CACL,KAAM,GAAQ,EAAc,QAAQ,YACrC,EAMG,EAAiB,GAEnB,EAAM,OAAS,UACf,aAAc,GACd,aAAc,GACd,WAAY,EAOV,EACJ,GAGE,IAAU,UACV,IAAU,gBACV,IAAU,kBACV,IAAU,SAWR,EACJ,GACwC,CAExC,GAAI,OAAO,GAAU,SAAU,CAC7B,GAAI,CAAC,EAAc,EAAM,CACvB,MAAO,CAAE,QAAS,EAAE,CAAE,aAAc,EAAE,CAAE,eAAgB,EAAE,CAAE,QAAS,EAAE,CAAE,CAG3E,GAAI,IAAU,SACZ,MAAO,CAAE,QAAS,CAAC,GAAmB,CAAC,CAAE,CAG3C,GAAI,IAAU,eACZ,MAAO,CAAE,aAAc,CAAC,GAAuB,CAAC,CAAE,CAGpD,GAAI,IAAU,iBACZ,MAAO,CAAE,eAAgB,CAAC,GAAuB,CAAC,CAAE,CAGtD,GAAI,IAAU,SACZ,MAAO,CAAE,QAAS,CAAC,GAAmB,CAAC,CAAE,CAK7C,GAAI,OAAO,GAAU,UAAY,EAAgB,CAC/C,IAAM,EAAa,EAEnB,GAAI,EAAc,EAAW,CAC3B,MAAO,CAAE,QAAS,CAAC,EAAkB,EAAgC,CAAC,CAAE,CAI1E,GAAI,SAAU,GAAc,EAAW,OAAS,eAAgB,CAC9D,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,aAAc,CAAC,EAAsB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAIrE,GAAI,SAAU,GAAc,EAAW,OAAS,iBAAkB,CAChE,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,eAAgB,CAAC,EAAsB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAIvE,GAAI,SAAU,GAAc,EAAW,OAAS,SAAU,CACxD,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,QAAS,CAAC,EAAkB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAI5D,GAAM,CAAE,OAAM,GAAG,GAAS,EAC1B,MAAO,CAAE,aAAc,CAAC,EAAsB,CAAE,OAAM,GAAG,EAAM,CAAC,CAAC,CAAE,CAGrE,MAAO,CAAE,QAAS,EAAE,CAAE,aAAc,EAAE,CAAE,eAAgB,EAAE,CAAE,QAAS,EAAE,CAAE,EAMrE,GACJ,EACA,KAEO,CACL,QAAS,CAAC,GAAG,EAAY,QAAS,GAAI,EAAQ,SAAW,EAAE,CAAE,CAC7D,aAAc,CACZ,GAAG,EAAY,aACf,GAAI,EAAQ,cAAgB,EAAE,CAC/B,CACD,eAAgB,CACd,GAAG,EAAY,eACf,GAAI,EAAQ,gBAAkB,EAAE,CACjC,CACD,QAAS,CAAC,GAAG,EAAY,QAAS,GAAI,EAAQ,SAAW,EAAE,CAAE,CAC9D,EASU,EACX,GAC+B,CAC/B,IAAM,EAA0C,CAC9C,QAAS,EAAE,CACX,aAAc,EAAE,CAChB,eAAgB,EAAE,CAClB,QAAS,EAAE,CACZ,CAkBD,OAfI,IAAY,IAAS,IAAY,IAAA,GAC5B,EAIL,MAAM,QAAQ,EAAQ,CACjB,EAAQ,QAAoC,EAAK,IAE/C,EAAuB,EADd,EAAoB,EAAM,CACC,CAC1C,EAAY,CAMV,EAAuB,EAFd,EAAoB,EAAQ,CAEO"}
@@ -1,2 +1,2 @@
1
- import{NodeType as e}from"@intlayer/types";const t=(n,r)=>{for(let e of r.plugins??[])if(e.canHandle(n))return e.transform(n,r,(e,n)=>t(e,n));if(typeof n!=`object`||!n||n.$$typeof!==void 0||n.__v_isVNode!==void 0||n._isVNode!==void 0||n.isJSX!==void 0||typeof n==`function`)return n;if(Array.isArray(n))return n.map((n,i)=>t(n,{...r,children:n,keyPath:[...r.keyPath,{type:e.Array,key:i}]}));let i={};for(let a in n){let o={...r,children:n[a],keyPath:[...r.keyPath,{type:e.Object,key:a}]};i[a]=t(n[a],o)}return i};export{t as deepTransformNode};
1
+ import{NodeType as e}from"@intlayer/types/nodeType";const t=(n,r)=>{for(let e of r.plugins??[])if(e.canHandle(n))return e.transform(n,r,(e,n)=>t(e,n));if(typeof n!=`object`||!n||n.$$typeof!==void 0||n.__v_isVNode!==void 0||n._isVNode!==void 0||n.isJSX!==void 0||typeof n==`function`)return n;if(Array.isArray(n))return n.map((n,i)=>t(n,{...r,children:n,keyPath:[...r.keyPath,{type:e.Array,key:i}]}));let i={};for(let a in n){let o={...r,children:n[a],keyPath:[...r.keyPath,{type:e.Object,key:a}]};i[a]=t(n[a],o)}return i};export{t as deepTransformNode};
2
2
  //# sourceMappingURL=deepTransform.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepTransform.mjs","names":[],"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '@intlayer/types';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's a framework-specific virtual node or already a transformed Proxy,\n // return it directly to avoid re-transforming its internal properties.\n if (\n (node as any).$$typeof !== undefined ||\n (node as any).__v_isVNode !== undefined ||\n (node as any)._isVNode !== undefined ||\n (node as any).isJSX !== undefined ||\n typeof node === 'function' // Proxies for html/markdown are functions\n ) {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n children: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":"2CAQA,MAAa,GAAqB,EAAW,IAA0B,CAErE,IAAK,IAAM,KAAU,EAAM,SAAW,EAAE,CACtC,GAAI,EAAO,UAAU,EAAK,CAExB,OAAO,EAAO,UAAU,EAAM,GAAQ,EAAW,IAC/C,EAAkB,EAAM,EAAM,CAC/B,CAWL,GANqB,OAAO,GAAS,WAAjC,GAOD,EAAa,WAAa,IAAA,IAC1B,EAAa,cAAgB,IAAA,IAC7B,EAAa,WAAa,IAAA,IAC1B,EAAa,QAAU,IAAA,IACxB,OAAO,GAAS,WAEhB,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAK,CACrB,OAAO,EAAK,KAAK,EAAO,IASf,EAAkB,EARN,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,MAAO,IAAK,EAAO,CACrC,CACF,CAC0C,CAC3C,CAIJ,IAAM,EAA8B,EAAE,CACtC,IAAK,IAAM,KAAO,EAAM,CACtB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAK,GACf,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAS,OAAQ,MAAK,CAAY,CACvE,CACD,EAAO,GAAO,EAAkB,EAAK,GAAM,EAAW,CAGxD,OAAO"}
1
+ {"version":3,"file":"deepTransform.mjs","names":[],"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types/keyPath';;\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's a framework-specific virtual node or already a transformed Proxy,\n // return it directly to avoid re-transforming its internal properties.\n if (\n (node as any).$$typeof !== undefined ||\n (node as any).__v_isVNode !== undefined ||\n (node as any)._isVNode !== undefined ||\n (node as any).isJSX !== undefined ||\n typeof node === 'function' // Proxies for html/markdown are functions\n ) {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n children: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":"oDASA,MAAa,GAAqB,EAAW,IAA0B,CAErE,IAAK,IAAM,KAAU,EAAM,SAAW,EAAE,CACtC,GAAI,EAAO,UAAU,EAAK,CAExB,OAAO,EAAO,UAAU,EAAM,GAAQ,EAAW,IAC/C,EAAkB,EAAM,EAAM,CAC/B,CAWL,GANqB,OAAO,GAAS,WAAjC,GAOD,EAAa,WAAa,IAAA,IAC1B,EAAa,cAAgB,IAAA,IAC7B,EAAa,WAAa,IAAA,IAC1B,EAAa,QAAU,IAAA,IACxB,OAAO,GAAS,WAEhB,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAK,CACrB,OAAO,EAAK,KAAK,EAAO,IASf,EAAkB,EARN,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,MAAO,IAAK,EAAO,CACrC,CACF,CAC0C,CAC3C,CAIJ,IAAM,EAA8B,EAAE,CACtC,IAAK,IAAM,KAAO,EAAM,CACtB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAK,GACf,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAS,OAAQ,MAAK,CAAY,CACvE,CACD,EAAO,GAAO,EAAkB,EAAK,GAAM,EAAW,CAGxD,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"getContent.mjs","names":[],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {\n ContentNode,\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n locale?: L,\n fallback?: boolean\n) => {\n const defaultLocale = configuration?.internationalization?.defaultLocale;\n\n const plugins: Plugins[] = [\n translationPlugin(\n locale ?? defaultLocale,\n fallback ? defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? defaultLocale),\n filePlugin,\n insertionPlugin,\n genderPlugin,\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n};\n"],"mappings":"qQA2BA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EAAgB,GAAe,sBAAsB,cAErD,EAAqB,CACzB,EACE,GAAU,EACV,EAAW,EAAgB,IAAA,GAC5B,CACD,EACA,EACA,EAAa,GAAU,EAAc,CACrC,EACA,EACA,EACA,GAAI,EAAU,SAAW,EAAE,CAC5B,CAED,OAAO,EAAkB,EAAM,CAC7B,GAAG,EACH,UACD,CAAC"}
1
+ {"version":3,"file":"getContent.mjs","names":[],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n locale?: L,\n fallback?: boolean\n) => {\n const defaultLocale = configuration?.internationalization?.defaultLocale;\n\n const plugins: Plugins[] = [\n translationPlugin(\n locale ?? defaultLocale,\n fallback ? defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? defaultLocale),\n filePlugin,\n insertionPlugin,\n genderPlugin,\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n};\n"],"mappings":"qQAwBA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EAAgB,GAAe,sBAAsB,cAErD,EAAqB,CACzB,EACE,GAAU,EACV,EAAW,EAAgB,IAAA,GAC5B,CACD,EACA,EACA,EAAa,GAAU,EAAc,CACrC,EACA,EACA,EACA,GAAI,EAAU,SAAW,EAAE,CAC5B,CAED,OAAO,EAAkB,EAAM,CAC7B,GAAG,EACH,UACD,CAAC"}