@intlayer/core 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -212
  3. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -94
  5. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -45
  7. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -33
  9. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +1 -27
  11. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  12. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -82
  13. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  14. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +1 -87
  15. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  16. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +1 -60
  17. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  18. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -122
  19. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  20. package/dist/cjs/deepTransformPlugins/index.cjs +1 -32
  21. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -106
  22. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -64
  24. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -18
  26. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -55
  28. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -26
  30. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -23
  32. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  33. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -36
  34. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  35. package/dist/cjs/dictionaryManipulator/index.cjs +1 -27
  36. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -69
  37. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  38. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +1 -30
  39. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  40. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -48
  41. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  42. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -31
  43. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  44. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -39
  45. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  46. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -38
  47. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  48. package/dist/cjs/formatters/compact.cjs +1 -25
  49. package/dist/cjs/formatters/compact.cjs.map +1 -1
  50. package/dist/cjs/formatters/currency.cjs +1 -29
  51. package/dist/cjs/formatters/currency.cjs.map +1 -1
  52. package/dist/cjs/formatters/date.cjs +1 -60
  53. package/dist/cjs/formatters/date.cjs.map +1 -1
  54. package/dist/cjs/formatters/index.cjs +1 -18
  55. package/dist/cjs/formatters/list.cjs +1 -30
  56. package/dist/cjs/formatters/list.cjs.map +1 -1
  57. package/dist/cjs/formatters/number.cjs +1 -18
  58. package/dist/cjs/formatters/number.cjs.map +1 -1
  59. package/dist/cjs/formatters/percentage.cjs +1 -25
  60. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  61. package/dist/cjs/formatters/relativeTime.cjs +1 -33
  62. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  63. package/dist/cjs/formatters/units.cjs +1 -23
  64. package/dist/cjs/formatters/units.cjs.map +1 -1
  65. package/dist/cjs/getStorageAttributes.cjs +1 -134
  66. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  67. package/dist/cjs/index.cjs +1 -300
  68. package/dist/cjs/interpreter/getCondition.cjs +1 -27
  69. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  70. package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -41
  71. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  72. package/dist/cjs/interpreter/getContent/getContent.cjs +1 -34
  73. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  74. package/dist/cjs/interpreter/getContent/index.cjs +1 -14
  75. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -161
  76. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  77. package/dist/cjs/interpreter/getDictionary.cjs +1 -24
  78. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  79. package/dist/cjs/interpreter/getEnumeration.cjs +1 -72
  80. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  81. package/dist/cjs/interpreter/getGender.cjs +1 -38
  82. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  83. package/dist/cjs/interpreter/getHTML.cjs +1 -121
  84. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  85. package/dist/cjs/interpreter/getInsertion.cjs +1 -22
  86. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  87. package/dist/cjs/interpreter/getIntlayer.cjs +1 -40
  88. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  89. package/dist/cjs/interpreter/getNesting.cjs +1 -36
  90. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  91. package/dist/cjs/interpreter/getTranslation.cjs +1 -112
  92. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  93. package/dist/cjs/interpreter/index.cjs +1 -31
  94. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +1 -55
  95. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  96. package/dist/cjs/localization/getBrowserLocale.cjs +1 -143
  97. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  98. package/dist/cjs/localization/getHTMLTextDir.cjs +1 -64
  99. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  100. package/dist/cjs/localization/getLocale.cjs +1 -27
  101. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  102. package/dist/cjs/localization/getLocaleFromPath.cjs +1 -45
  103. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  104. package/dist/cjs/localization/getLocaleLang.cjs +1 -20
  105. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  106. package/dist/cjs/localization/getLocaleName.cjs +1 -10
  107. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  108. package/dist/cjs/localization/getLocalizedUrl.cjs +1 -82
  109. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  110. package/dist/cjs/localization/getMultilingualUrls.cjs +1 -63
  111. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  112. package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -55
  113. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  114. package/dist/cjs/localization/getPrefix.cjs +1 -63
  115. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  116. package/dist/cjs/localization/index.cjs +1 -39
  117. package/dist/cjs/localization/localeDetector.cjs +1 -133
  118. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  119. package/dist/cjs/localization/localeMapper.cjs +1 -119
  120. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  121. package/dist/cjs/localization/localeResolver.cjs +1 -28
  122. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  123. package/dist/cjs/localization/rewriteUtils.cjs +1 -110
  124. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  125. package/dist/cjs/localization/validatePrefix.cjs +1 -54
  126. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  127. package/dist/cjs/markdown/compiler.cjs +10 -810
  128. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  129. package/dist/cjs/markdown/constants.cjs +1 -328
  130. package/dist/cjs/markdown/constants.cjs.map +1 -1
  131. package/dist/cjs/markdown/index.cjs +1 -120
  132. package/dist/cjs/markdown/parser.cjs +1 -66
  133. package/dist/cjs/markdown/parser.cjs.map +1 -1
  134. package/dist/cjs/markdown/renderer.cjs +1 -61
  135. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  136. package/dist/cjs/markdown/utils.cjs +6 -391
  137. package/dist/cjs/markdown/utils.cjs.map +1 -1
  138. package/dist/cjs/messageFormat/ICU.cjs +1 -319
  139. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  140. package/dist/cjs/messageFormat/i18next.cjs +1 -330
  141. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  142. package/dist/cjs/messageFormat/index.cjs +1 -11
  143. package/dist/cjs/messageFormat/verify-icu-format.cjs +2 -64
  144. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  145. package/dist/cjs/messageFormat/vue-i18n.cjs +1 -166
  146. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  147. package/dist/cjs/transpiler/condition/condition.cjs +1 -26
  148. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  149. package/dist/cjs/transpiler/condition/index.cjs +1 -4
  150. package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -28
  151. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  152. package/dist/cjs/transpiler/enumeration/index.cjs +1 -4
  153. package/dist/cjs/transpiler/file/file.cjs +1 -52
  154. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  155. package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -25
  156. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  157. package/dist/cjs/transpiler/file/index.cjs +1 -5
  158. package/dist/cjs/transpiler/gender/gender.cjs +1 -26
  159. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  160. package/dist/cjs/transpiler/gender/index.cjs +1 -4
  161. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -44
  162. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  163. package/dist/cjs/transpiler/html/html.cjs +1 -37
  164. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  165. package/dist/cjs/transpiler/html/htmlTags.cjs +1 -116
  166. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  167. package/dist/cjs/transpiler/html/index.cjs +1 -6
  168. package/dist/cjs/transpiler/index.cjs +1 -24
  169. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +1 -11
  170. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  171. package/dist/cjs/transpiler/insertion/index.cjs +1 -6
  172. package/dist/cjs/transpiler/insertion/insertion.cjs +1 -36
  173. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  174. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +2 -23
  175. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  176. package/dist/cjs/transpiler/markdown/index.cjs +1 -6
  177. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -54
  178. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  179. package/dist/cjs/transpiler/nesting/index.cjs +1 -4
  180. package/dist/cjs/transpiler/nesting/nesting.cjs +1 -27
  181. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  182. package/dist/cjs/transpiler/translation/index.cjs +1 -4
  183. package/dist/cjs/transpiler/translation/translation.cjs +1 -29
  184. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  185. package/dist/cjs/utils/checkIsURLAbsolute.cjs +1 -7
  186. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  187. package/dist/cjs/utils/getCookie.cjs +1 -32
  188. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  189. package/dist/cjs/utils/index.cjs +1 -0
  190. package/dist/cjs/utils/intl.cjs +1 -91
  191. package/dist/cjs/utils/intl.cjs.map +1 -1
  192. package/dist/cjs/utils/isSameKeyPath.cjs +1 -7
  193. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  194. package/dist/cjs/utils/isValidReactElement.cjs +1 -14
  195. package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
  196. package/dist/cjs/utils/localeStorage.cjs +1 -140
  197. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  198. package/dist/cjs/utils/parseYaml.cjs +16 -322
  199. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  200. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -207
  201. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  202. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -89
  203. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  204. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -42
  205. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  206. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -31
  207. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  208. package/dist/esm/deepTransformPlugins/getMaskContent.mjs +1 -25
  209. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  210. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -77
  211. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  212. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +1 -86
  213. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  214. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +1 -59
  215. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  216. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -119
  217. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  218. package/dist/esm/deepTransformPlugins/index.mjs +1 -12
  219. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -104
  220. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  221. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -62
  222. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  223. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -16
  224. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  225. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -53
  226. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  227. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -24
  228. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  229. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -21
  230. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  231. package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -34
  232. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  233. package/dist/esm/dictionaryManipulator/index.mjs +1 -14
  234. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -66
  235. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  236. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +1 -28
  237. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  238. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +1 -45
  239. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  240. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -29
  241. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  242. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -37
  243. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  244. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -36
  245. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  246. package/dist/esm/formatters/compact.mjs +1 -22
  247. package/dist/esm/formatters/compact.mjs.map +1 -1
  248. package/dist/esm/formatters/currency.mjs +1 -26
  249. package/dist/esm/formatters/currency.mjs.map +1 -1
  250. package/dist/esm/formatters/date.mjs +1 -57
  251. package/dist/esm/formatters/date.mjs.map +1 -1
  252. package/dist/esm/formatters/index.mjs +1 -10
  253. package/dist/esm/formatters/list.mjs +1 -27
  254. package/dist/esm/formatters/list.mjs.map +1 -1
  255. package/dist/esm/formatters/number.mjs +1 -15
  256. package/dist/esm/formatters/number.mjs.map +1 -1
  257. package/dist/esm/formatters/percentage.mjs +1 -22
  258. package/dist/esm/formatters/percentage.mjs.map +1 -1
  259. package/dist/esm/formatters/relativeTime.mjs +1 -30
  260. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  261. package/dist/esm/formatters/units.mjs +1 -20
  262. package/dist/esm/formatters/units.mjs.map +1 -1
  263. package/dist/esm/getStorageAttributes.mjs +1 -132
  264. package/dist/esm/getStorageAttributes.mjs.map +1 -1
  265. package/dist/esm/index.mjs +1 -82
  266. package/dist/esm/interpreter/getCondition.mjs +1 -25
  267. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  268. package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -39
  269. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  270. package/dist/esm/interpreter/getContent/getContent.mjs +1 -31
  271. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  272. package/dist/esm/interpreter/getContent/index.mjs +1 -5
  273. package/dist/esm/interpreter/getContent/plugins.mjs +1 -153
  274. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  275. package/dist/esm/interpreter/getDictionary.mjs +1 -23
  276. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  277. package/dist/esm/interpreter/getEnumeration.mjs +1 -69
  278. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  279. package/dist/esm/interpreter/getGender.mjs +1 -36
  280. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  281. package/dist/esm/interpreter/getHTML.mjs +1 -119
  282. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  283. package/dist/esm/interpreter/getInsertion.mjs +1 -20
  284. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  285. package/dist/esm/interpreter/getIntlayer.mjs +1 -36
  286. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  287. package/dist/esm/interpreter/getNesting.mjs +1 -35
  288. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  289. package/dist/esm/interpreter/getTranslation.mjs +1 -110
  290. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  291. package/dist/esm/interpreter/index.mjs +1 -13
  292. package/dist/esm/interpreter/splitAndJoinInsertion.mjs +1 -53
  293. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  294. package/dist/esm/localization/getBrowserLocale.mjs +1 -138
  295. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  296. package/dist/esm/localization/getHTMLTextDir.mjs +1 -62
  297. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  298. package/dist/esm/localization/getLocale.mjs +1 -24
  299. package/dist/esm/localization/getLocale.mjs.map +1 -1
  300. package/dist/esm/localization/getLocaleFromPath.mjs +1 -42
  301. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  302. package/dist/esm/localization/getLocaleLang.mjs +1 -18
  303. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  304. package/dist/esm/localization/getLocaleName.mjs +1 -9
  305. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  306. package/dist/esm/localization/getLocalizedUrl.mjs +1 -79
  307. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  308. package/dist/esm/localization/getMultilingualUrls.mjs +1 -60
  309. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  310. package/dist/esm/localization/getPathWithoutLocale.mjs +1 -52
  311. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  312. package/dist/esm/localization/getPrefix.mjs +1 -60
  313. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  314. package/dist/esm/localization/index.mjs +1 -17
  315. package/dist/esm/localization/localeDetector.mjs +1 -131
  316. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  317. package/dist/esm/localization/localeMapper.mjs +1 -114
  318. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  319. package/dist/esm/localization/localeResolver.mjs +1 -25
  320. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  321. package/dist/esm/localization/rewriteUtils.mjs +1 -104
  322. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  323. package/dist/esm/localization/validatePrefix.mjs +1 -51
  324. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  325. package/dist/esm/markdown/compiler.mjs +10 -786
  326. package/dist/esm/markdown/compiler.mjs.map +1 -1
  327. package/dist/esm/markdown/constants.mjs +1 -247
  328. package/dist/esm/markdown/constants.mjs.map +1 -1
  329. package/dist/esm/markdown/index.mjs +1 -7
  330. package/dist/esm/markdown/parser.mjs +1 -65
  331. package/dist/esm/markdown/parser.mjs.map +1 -1
  332. package/dist/esm/markdown/renderer.mjs +1 -59
  333. package/dist/esm/markdown/renderer.mjs.map +1 -1
  334. package/dist/esm/markdown/utils.mjs +6 -361
  335. package/dist/esm/markdown/utils.mjs.map +1 -1
  336. package/dist/esm/messageFormat/ICU.mjs +1 -316
  337. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  338. package/dist/esm/messageFormat/i18next.mjs +1 -327
  339. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  340. package/dist/esm/messageFormat/index.mjs +1 -5
  341. package/dist/esm/messageFormat/verify-icu-format.mjs +2 -64
  342. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  343. package/dist/esm/messageFormat/vue-i18n.mjs +1 -163
  344. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  345. package/dist/esm/transpiler/condition/condition.mjs +1 -24
  346. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  347. package/dist/esm/transpiler/condition/index.mjs +1 -3
  348. package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -26
  349. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  350. package/dist/esm/transpiler/enumeration/index.mjs +1 -3
  351. package/dist/esm/transpiler/file/file.mjs +1 -49
  352. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  353. package/dist/esm/transpiler/file/fileBrowser.mjs +1 -24
  354. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  355. package/dist/esm/transpiler/file/index.mjs +1 -3
  356. package/dist/esm/transpiler/gender/gender.mjs +1 -24
  357. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  358. package/dist/esm/transpiler/gender/index.mjs +1 -3
  359. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -43
  360. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  361. package/dist/esm/transpiler/html/html.mjs +1 -35
  362. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  363. package/dist/esm/transpiler/html/htmlTags.mjs +1 -114
  364. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  365. package/dist/esm/transpiler/html/index.mjs +1 -4
  366. package/dist/esm/transpiler/index.mjs +1 -13
  367. package/dist/esm/transpiler/insertion/getInsertionValues.mjs +1 -9
  368. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  369. package/dist/esm/transpiler/insertion/index.mjs +1 -4
  370. package/dist/esm/transpiler/insertion/insertion.mjs +1 -34
  371. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  372. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +2 -22
  373. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  374. package/dist/esm/transpiler/markdown/index.mjs +1 -4
  375. package/dist/esm/transpiler/markdown/markdown.mjs +1 -52
  376. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  377. package/dist/esm/transpiler/nesting/index.mjs +1 -3
  378. package/dist/esm/transpiler/nesting/nesting.mjs +1 -25
  379. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  380. package/dist/esm/transpiler/translation/index.mjs +1 -3
  381. package/dist/esm/transpiler/translation/translation.mjs +1 -27
  382. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  383. package/dist/esm/utils/checkIsURLAbsolute.mjs +1 -5
  384. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  385. package/dist/esm/utils/getCookie.mjs +1 -30
  386. package/dist/esm/utils/getCookie.mjs.map +1 -1
  387. package/dist/esm/utils/index.mjs +1 -0
  388. package/dist/esm/utils/intl.mjs +1 -86
  389. package/dist/esm/utils/intl.mjs.map +1 -1
  390. package/dist/esm/utils/isSameKeyPath.mjs +1 -5
  391. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  392. package/dist/esm/utils/isValidReactElement.mjs +1 -12
  393. package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
  394. package/dist/esm/utils/localeStorage.mjs +1 -135
  395. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  396. package/dist/esm/utils/parseYaml.mjs +16 -320
  397. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  398. package/dist/types/formatters/index.d.ts +2 -1
  399. package/dist/types/index.d.ts +8 -2
  400. package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
  401. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  402. package/dist/types/localization/index.d.ts +2 -1
  403. package/dist/types/markdown/index.d.ts +4 -1
  404. package/dist/types/markdown/types.d.ts +1 -1
  405. package/dist/types/markdown/types.d.ts.map +1 -1
  406. package/dist/types/transpiler/translation/translation.d.ts +1 -1
  407. package/dist/types/utils/index.d.ts +8 -0
  408. package/package.json +65 -11
@@ -1,107 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/deepTransformPlugins/insertContentInDictionary.ts
6
- /**
7
- * Deep merge helper that handles translation blocks
8
- * @param target - The target object (dictionary content)
9
- * @param source - The source object (new content to merge)
10
- * @param locale - Optional locale to target specific translation
11
- * @returns Merged content
12
- */
13
- const deepMergeContent = (target, source, locale) => {
14
- if (source === null || source === void 0) return target;
15
- if (target === null || target === void 0) if (Array.isArray(source)) target = [];
16
- else if (typeof source === "object") target = {};
17
- else return source;
18
- if (target && typeof target === "object" && target.nodeType === _intlayer_types.NodeType.Translation) if (locale) {
19
- const existingLocaleContent = target.translation[locale];
20
- let newLocaleContent;
21
- if (typeof source === "object" && !Array.isArray(source)) newLocaleContent = deepMergeContent(existingLocaleContent, source, void 0);
22
- else if (Array.isArray(source)) newLocaleContent = source;
23
- else newLocaleContent = source;
24
- return {
25
- ...target,
26
- translation: {
27
- ...target.translation,
28
- [locale]: newLocaleContent
29
- }
30
- };
31
- } else if (typeof source === "object" && !Array.isArray(source) && source.nodeType === _intlayer_types.NodeType.Translation) return {
32
- ...target,
33
- translation: {
34
- ...target.translation,
35
- ...source.translation
36
- }
37
- };
38
- else return processNewContent(source, locale);
39
- if (Array.isArray(source)) if (locale && Array.isArray(target)) {
40
- const result = [];
41
- const maxLength = Math.max(source.length, target.length);
42
- for (let i = 0; i < maxLength; i++) if (i < source.length) if (i < target.length && target[i] !== void 0) result[i] = deepMergeContent(target[i], source[i], locale);
43
- else result[i] = processNewContent(source[i], locale);
44
- else result[i] = target[i];
45
- return result;
46
- } else return source.map((item) => {
47
- if (item && typeof item === "object" && item.nodeType === _intlayer_types.NodeType.Translation) return item;
48
- return processNewContent(item, locale);
49
- });
50
- if (typeof source === "object" && !Array.isArray(source)) {
51
- if (typeof target !== "object" || Array.isArray(target)) target = {};
52
- const result = { ...target };
53
- for (const key in source) if (Object.hasOwn(source, key)) if (target[key] !== void 0) result[key] = deepMergeContent(target[key], source[key], locale);
54
- else result[key] = processNewContent(source[key], locale);
55
- return result;
56
- }
57
- return source;
58
- };
59
- /**
60
- * Process new content that doesn't exist in target
61
- * @param content - New content to process
62
- * @param locale - Optional locale
63
- * @returns Processed content
64
- */
65
- const processNewContent = (content, locale) => {
66
- if (content === null || content === void 0) return content;
67
- if (content && typeof content === "object" && content.nodeType === _intlayer_types.NodeType.Translation) return content;
68
- if (Array.isArray(content)) return content.map((item) => processNewContent(item, locale));
69
- if (content && typeof content === "object") {
70
- const result = {};
71
- for (const key in content) if (Object.hasOwn(content, key)) result[key] = processNewContent(content[key], locale);
72
- return result;
73
- }
74
- if (locale) return {
75
- nodeType: _intlayer_types.NodeType.Translation,
76
- translation: { [locale]: content }
77
- };
78
- else return content;
79
- };
80
- /**
81
- * Insert content into a dictionary with deep merge support
82
- * Handles translation blocks and nested structures
83
- *
84
- * @param dictionary - The dictionary to insert content into
85
- * @param content - The content to insert
86
- * @param locale - Optional locale to target specific translation
87
- * @returns Updated dictionary
88
- *
89
- * @example
90
- * // Without locale - deep merge all content
91
- * insertContentInDictionary(dictionary, { title: 'New Title' })
92
- *
93
- * @example
94
- * // With locale - insert content for specific locale
95
- * insertContentInDictionary(dictionary, { title: 'このページ' }, 'ja')
96
- */
97
- const insertContentInDictionary = (dictionary, content, locale) => {
98
- const mergedContent = deepMergeContent(Array.isArray(dictionary.content) ? [...dictionary.content] : { ...dictionary.content }, content, locale);
99
- return {
100
- ...dictionary,
101
- content: mergedContent
102
- };
103
- };
104
-
105
- //#endregion
106
- exports.insertContentInDictionary = insertContentInDictionary;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=(r,i,a)=>{if(i==null)return r;if(r==null)if(Array.isArray(i))r=[];else if(typeof i==`object`)r={};else return i;if(r&&typeof r==`object`&&r.nodeType===e.NodeType.Translation)if(a){let e=r.translation[a],n;return n=typeof i==`object`&&!Array.isArray(i)?t(e,i,void 0):i,{...r,translation:{...r.translation,[a]:n}}}else if(typeof i==`object`&&!Array.isArray(i)&&i.nodeType===e.NodeType.Translation)return{...r,translation:{...r.translation,...i.translation}};else return n(i,a);if(Array.isArray(i))if(a&&Array.isArray(r)){let e=[],o=Math.max(i.length,r.length);for(let s=0;s<o;s++)s<i.length?s<r.length&&r[s]!==void 0?e[s]=t(r[s],i[s],a):e[s]=n(i[s],a):e[s]=r[s];return e}else return i.map(t=>t&&typeof t==`object`&&t.nodeType===e.NodeType.Translation?t:n(t,a));if(typeof i==`object`&&!Array.isArray(i)){(typeof r!=`object`||Array.isArray(r))&&(r={});let e={...r};for(let o in i)Object.hasOwn(i,o)&&(r[o]===void 0?e[o]=n(i[o],a):e[o]=t(r[o],i[o],a));return e}return i},n=(t,r)=>{if(t==null||t&&typeof t==`object`&&t.nodeType===e.NodeType.Translation)return t;if(Array.isArray(t))return t.map(e=>n(e,r));if(t&&typeof t==`object`){let e={};for(let i in t)Object.hasOwn(t,i)&&(e[i]=n(t[i],r));return e}return r?{nodeType:e.NodeType.Translation,translation:{[r]:t}}:t},r=(e,n,r)=>{let i=t(Array.isArray(e.content)?[...e.content]:{...e.content},n,r);return{...e,content:i}};exports.insertContentInDictionary=r;
107
2
  //# sourceMappingURL=insertContentInDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"insertContentInDictionary.cjs","names":["NodeType"],"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":";;;;;;;;;;;;AAqFA,MAAM,oBACJ,QACA,QACA,WACQ;AAER,KAAI,WAAW,QAAQ,WAAW,OAAW,QAAO;AAGpD,KAAI,WAAW,QAAQ,WAAW,OAChC,KAAI,MAAM,QAAQ,OAAO,CACvB,UAAS,EAAE;UACF,OAAO,WAAW,SAC3B,UAAS,EAAE;KAEX,QAAO;AAKX,KACE,UACA,OAAO,WAAW,YAClB,OAAO,aAAaA,yBAAS,YAG7B,KAAI,QAAQ;EAEV,MAAM,wBAAwB,OAAO,YAAY;EACjD,IAAI;AAEJ,MAAI,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,CAEtD,oBAAmB,iBACjB,uBACA,QACA,OACD;WACQ,MAAM,QAAQ,OAAO,CAE9B,oBAAmB;MAGnB,oBAAmB;AAIrB,SAAO;GACL,GAAG;GACH,aAAa;IACX,GAAG,OAAO;KACT,SAAS;IACX;GACF;YAIC,OAAO,WAAW,YAClB,CAAC,MAAM,QAAQ,OAAO,IACtB,OAAO,aAAaA,yBAAS,YAG7B,QAAO;EACL,GAAG;EACH,aAAa;GACX,GAAG,OAAO;GACV,GAAG,OAAO;GACX;EACF;KAGD,QAAO,kBAAkB,QAAQ,OAAO;AAM9C,KAAI,MAAM,QAAQ,OAAO,CACvB,KAAI,UAAU,MAAM,QAAQ,OAAO,EAAE;EAEnC,MAAM,SAAS,EAAE;EACjB,MAAM,YAAY,KAAK,IAAI,OAAO,QAAQ,OAAO,OAAO;AAExD,OAAK,IAAI,IAAI,GAAG,IAAI,WAAW,IAC7B,KAAI,IAAI,OAAO,OACb,KAAI,IAAI,OAAO,UAAU,OAAO,OAAO,OAErC,QAAO,KAAK,iBAAiB,OAAO,IAAI,OAAO,IAAI,OAAO;MAG1D,QAAO,KAAK,kBAAkB,OAAO,IAAI,OAAO;MAIlD,QAAO,KAAK,OAAO;AAIvB,SAAO;OAGP,QAAO,OAAO,KAAK,SAAS;AAE1B,MACE,QACA,OAAO,SAAS,YAChB,KAAK,aAAaA,yBAAS,YAE3B,QAAO;AAET,SAAO,kBAAkB,MAAM,OAAO;GACtC;AAKN,KAAI,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,OAAO,EAAE;AACxD,MAAI,OAAO,WAAW,YAAY,MAAM,QAAQ,OAAO,CACrD,UAAS,EAAE;EAIb,MAAM,SAAc,EAAE,GAAG,QAAQ;AAEjC,OAAK,MAAM,OAAO,OAChB,KAAI,OAAO,OAAO,QAAQ,IAAI,CAC5B,KAAI,OAAO,SAAS,OAClB,QAAO,OAAO,iBAAiB,OAAO,MAAM,OAAO,MAAM,OAAO;MAEhE,QAAO,OAAO,kBAAkB,OAAO,MAAM,OAAO;AAK1D,SAAO;;AAIT,QAAO;;;;;;;;AAST,MAAM,qBAAqB,SAAc,WAAgC;AAEvE,KAAI,YAAY,QAAQ,YAAY,OAClC,QAAO;AAIT,KACE,WACA,OAAO,YAAY,YACnB,QAAQ,aAAaA,yBAAS,YAE9B,QAAO;AAIT,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAO,QAAQ,KAAK,SAAS,kBAAkB,MAAM,OAAO,CAAC;AAI/D,KAAI,WAAW,OAAO,YAAY,UAAU;EAC1C,MAAM,SAAc,EAAE;AAEtB,OAAK,MAAM,OAAO,QAChB,KAAI,OAAO,OAAO,SAAS,IAAI,CAC7B,QAAO,OAAO,kBAAkB,QAAQ,MAAM,OAAO;AAGzD,SAAO;;AAIT,KAAI,OAEF,QAAO;EACL,UAAUA,yBAAS;EACnB,aAAa,GACV,SAAS,SACX;EACF;KAGD,QAAO;;;;;;;;;;;;;;;;;;;AAqBX,MAAa,6BACX,YACA,SACA,WACe;CACf,MAAM,gBAAgB,iBACpB,MAAM,QAAQ,WAAW,QAAQ,GAC7B,CAAC,GAAG,WAAW,QAAQ,GACvB,EAAE,GAAG,WAAW,SAAS,EAC7B,SACA,OACD;AAED,QAAO;EACL,GAAG;EACH,SAAS;EACV"}
1
+ {"version":3,"file":"insertContentInDictionary.cjs","names":["NodeType"],"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":"iJAqFA,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,WAAaA,EAAAA,SAAS,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,WAAaA,EAAAA,SAAS,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,WAAaA,EAAAA,SAAS,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,WAAaA,EAAAA,SAAS,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,SAAUA,EAAAA,SAAS,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,65 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/editDictionaryByKeyPath.ts
6
- const editDictionaryByKeyPath = (dictionaryContent, keyPath, newValue) => {
7
- let currentValue = dictionaryContent;
8
- let parentValue = null;
9
- let lastKeys = [];
10
- if (keyPath.length === 0) return newValue;
11
- try {
12
- for (let i = 0; i < keyPath.length; i++) {
13
- const keyObj = keyPath[i];
14
- parentValue = currentValue;
15
- if (keyObj.type === _intlayer_types.NodeType.Object || keyObj.type === _intlayer_types.NodeType.Array) {
16
- lastKeys = [keyObj.key];
17
- if (!currentValue[keyObj.key] || typeof currentValue[keyObj.key] !== "object") currentValue[keyObj.key] = {};
18
- currentValue = currentValue[keyObj.key];
19
- }
20
- if (keyObj.type === _intlayer_types.NodeType.Translation || keyObj.type === _intlayer_types.NodeType.Enumeration) {
21
- lastKeys = [keyObj.type, keyObj.key];
22
- if (!currentValue[keyObj.type] || typeof currentValue[keyObj.type] !== "object") currentValue[keyObj.type] = {};
23
- if (!currentValue[keyObj.type][keyObj.key] || typeof currentValue[keyObj.type][keyObj.key] !== "object") currentValue[keyObj.type][keyObj.key] = {};
24
- currentValue = currentValue[keyObj.type][keyObj.key];
25
- }
26
- if (keyObj.type === _intlayer_types.NodeType.Enumeration || keyObj.type === _intlayer_types.NodeType.Condition) {
27
- if (keyObj.type !== _intlayer_types.NodeType.Enumeration) {
28
- lastKeys = [keyObj.type, keyObj.key];
29
- currentValue = currentValue[keyObj.type][keyObj.key];
30
- }
31
- }
32
- if (keyObj.type === _intlayer_types.NodeType.Markdown || keyObj.type === _intlayer_types.NodeType.HTML || keyObj.type === _intlayer_types.NodeType.Insertion) {
33
- lastKeys = [keyObj.type];
34
- if (!currentValue[keyObj.type] || typeof currentValue[keyObj.type] !== "object") currentValue[keyObj.type] = "";
35
- currentValue = currentValue[keyObj.type];
36
- }
37
- if (keyObj.type === _intlayer_types.NodeType.File) {
38
- lastKeys = ["content"];
39
- currentValue = currentValue.content;
40
- }
41
- if (i === keyPath.length - 1 && parentValue && lastKeys.length > 0) {
42
- let target = parentValue;
43
- for (const key of lastKeys.slice(0, -1)) target = target[key];
44
- const finalKey = lastKeys[lastKeys.length - 1];
45
- if (typeof newValue === "undefined") if (Array.isArray(target)) {
46
- const index = Number(finalKey);
47
- if (!isNaN(index) && index >= 0 && index < target.length) target.splice(index, 1);
48
- } else delete target[finalKey];
49
- else target[finalKey] = newValue;
50
- }
51
- }
52
- return dictionaryContent;
53
- } catch (error) {
54
- console.error("Cannot edit dictionary by key path", {
55
- dictionaryContent,
56
- keyPath,
57
- newValue
58
- }, error);
59
- return dictionaryContent;
60
- }
61
- };
62
-
63
- //#endregion
64
- exports.editDictionaryByKeyPath = editDictionaryByKeyPath;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=(t,n,r)=>{let i=t,a=null,o=[];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.NodeType.Object||s.type===e.NodeType.Array)&&(o=[s.key],(!i[s.key]||typeof i[s.key]!=`object`)&&(i[s.key]={}),i=i[s.key]),(s.type===e.NodeType.Translation||s.type===e.NodeType.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.NodeType.Enumeration||s.type===e.NodeType.Condition)&&s.type!==e.NodeType.Enumeration&&(o=[s.type,s.key],i=i[s.type][s.key]),(s.type===e.NodeType.Markdown||s.type===e.NodeType.HTML||s.type===e.NodeType.Insertion)&&(o=[s.type],(!i[s.type]||typeof i[s.type]!=`object`)&&(i[s.type]=``),i=i[s.type]),s.type===e.NodeType.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}};exports.editDictionaryByKeyPath=t;
65
2
  //# sourceMappingURL=editDictionaryByKeyPath.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"editDictionaryByKeyPath.cjs","names":["NodeType"],"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":";;;;;AAIA,MAAa,2BACX,mBACA,SACA,aACgB;CAChB,IAAI,eAAoB;CACxB,IAAI,cAAmB;CACvB,IAAI,WAA0B,EAAE;AAEhC,KAAI,QAAQ,WAAW,EACrB,QAAO;AAGT,KAAI;AACF,OAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;GACvC,MAAM,SAAS,QAAQ;AACvB,iBAAc;AAEd,OAAI,OAAO,SAASA,yBAAS,UAAU,OAAO,SAASA,yBAAS,OAAO;AACrE,eAAW,CAAC,OAAO,IAAI;AACvB,QACE,CAAC,aAAa,OAAO,QACrB,OAAO,aAAa,OAAO,SAAS,SAEpC,cAAa,OAAO,OAAO,EAAE;AAE/B,mBAAe,aAAa,OAAO;;AAGrC,OACE,OAAO,SAASA,yBAAS,eACzB,OAAO,SAASA,yBAAS,aACzB;AACA,eAAW,CAAC,OAAO,MAAM,OAAO,IAAI;AACpC,QACE,CAAC,aAAa,OAAO,SACrB,OAAO,aAAa,OAAO,UAAU,SAErC,cAAa,OAAO,QAAQ,EAAE;AAEhC,QACE,CAAC,aAAa,OAAO,MAAM,OAAO,QAClC,OAAO,aAAa,OAAO,MAAM,OAAO,SAAS,SAEjD,cAAa,OAAO,MAAM,OAAO,OAAO,EAAE;AAE5C,mBAAe,aAAa,OAAO,MAAM,OAAO;;AAGlD,OACE,OAAO,SAASA,yBAAS,eACzB,OAAO,SAASA,yBAAS,WAOzB;QAAI,OAAO,SAASA,yBAAS,aAAa;AACxC,gBAAW,CAAC,OAAO,MAAM,OAAO,IAAI;AACpC,oBAAe,aAAa,OAAO,MAAM,OAAO;;;AAIpD,OACE,OAAO,SAASA,yBAAS,YACzB,OAAO,SAASA,yBAAS,QACzB,OAAO,SAASA,yBAAS,WACzB;AACA,eAAW,CAAC,OAAO,KAAK;AACxB,QACE,CAAC,aAAa,OAAO,SACrB,OAAO,aAAa,OAAO,UAAU,SAErC,cAAa,OAAO,QAAQ;AAE9B,mBAAe,aAAa,OAAO;;AAGrC,OAAI,OAAO,SAASA,yBAAS,MAAM;AACjC,eAAW,CAAC,UAAU;AACtB,mBAAe,aAAa;;AAI9B,OAAI,MAAM,QAAQ,SAAS,KAAK,eAAe,SAAS,SAAS,GAAG;IAClE,IAAI,SAAS;AAGb,SAAK,MAAM,OAAO,SAAS,MAAM,GAAG,GAAG,CACrC,UAAS,OAAO;IAGlB,MAAM,WAAW,SAAS,SAAS,SAAS;AAE5C,QAAI,OAAO,aAAa,YAEtB,KAAI,MAAM,QAAQ,OAAO,EAAE;KACzB,MAAM,QAAQ,OAAO,SAAS;AAC9B,SAAI,CAAC,MAAM,MAAM,IAAI,SAAS,KAAK,QAAQ,OAAO,OAChD,QAAO,OAAO,OAAO,EAAE;UAGzB,QAAO,OAAO;QAGhB,QAAO,YAAY;;;AAKzB,SAAO;UACA,OAAO;AACd,UAAQ,MACN,sCACA;GAAE;GAAmB;GAAS;GAAU,EACxC,MACD;AACD,SAAO"}
1
+ {"version":3,"file":"editDictionaryByKeyPath.cjs","names":["NodeType"],"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":"iJAIA,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,OAASA,EAAAA,SAAS,QAAU,EAAO,OAASA,EAAAA,SAAS,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,OAASA,EAAAA,SAAS,aACzB,EAAO,OAASA,EAAAA,SAAS,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,OAASA,EAAAA,SAAS,aACzB,EAAO,OAASA,EAAAA,SAAS,YAOrB,EAAO,OAASA,EAAAA,SAAS,cAC3B,EAAW,CAAC,EAAO,KAAM,EAAO,IAAI,CACpC,EAAe,EAAa,EAAO,MAAM,EAAO,OAKlD,EAAO,OAASA,EAAAA,SAAS,UACzB,EAAO,OAASA,EAAAA,SAAS,MACzB,EAAO,OAASA,EAAAA,SAAS,aAEzB,EAAW,CAAC,EAAO,KAAK,EAEtB,CAAC,EAAa,EAAO,OACrB,OAAO,EAAa,EAAO,OAAU,YAErC,EAAa,EAAO,MAAQ,IAE9B,EAAe,EAAa,EAAO,OAGjC,EAAO,OAASA,EAAAA,SAAS,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,19 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/getContentNodeByKeyPath.ts
6
- const getContentNodeByKeyPath = (dictionaryContent, keyPath, fallbackLocale) => {
7
- let currentValue = structuredClone(dictionaryContent);
8
- for (const keyObj of keyPath) {
9
- if (fallbackLocale && currentValue?.nodeType === _intlayer_types.NodeType.Translation) currentValue = currentValue?.[_intlayer_types.NodeType.Translation]?.[fallbackLocale];
10
- if (keyObj.type === _intlayer_types.NodeType.Object || keyObj.type === _intlayer_types.NodeType.Array) currentValue = currentValue?.[keyObj.key];
11
- if (keyObj.type === _intlayer_types.NodeType.Translation || keyObj.type === _intlayer_types.NodeType.Condition || keyObj.type === _intlayer_types.NodeType.Enumeration) currentValue = currentValue?.[keyObj.type]?.[keyObj.key];
12
- if (keyObj.type === _intlayer_types.NodeType.Markdown || keyObj.type === _intlayer_types.NodeType.HTML || keyObj.type === _intlayer_types.NodeType.Insertion || keyObj.type === _intlayer_types.NodeType.File) currentValue = currentValue?.[keyObj.type];
13
- }
14
- return currentValue;
15
- };
16
-
17
- //#endregion
18
- exports.getContentNodeByKeyPath = getContentNodeByKeyPath;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=(t,n,r)=>{let i=structuredClone(t);for(let t of n)r&&i?.nodeType===e.NodeType.Translation&&(i=i?.[e.NodeType.Translation]?.[r]),(t.type===e.NodeType.Object||t.type===e.NodeType.Array)&&(i=i?.[t.key]),(t.type===e.NodeType.Translation||t.type===e.NodeType.Condition||t.type===e.NodeType.Enumeration)&&(i=i?.[t.type]?.[t.key]),(t.type===e.NodeType.Markdown||t.type===e.NodeType.HTML||t.type===e.NodeType.Insertion||t.type===e.NodeType.File)&&(i=i?.[t.type]);return i};exports.getContentNodeByKeyPath=t;
19
2
  //# sourceMappingURL=getContentNodeByKeyPath.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getContentNodeByKeyPath.cjs","names":["NodeType"],"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":";;;;;AAOA,MAAa,2BACX,mBACA,SACA,mBACgB;CAChB,IAAI,eAAoB,gBAAgB,kBAAkB;AAE1D,MAAK,MAAM,UAAU,SAAS;AAE5B,MAAI,kBAAkB,cAAc,aAAaA,yBAAS,YACxD,gBAAe,eAAeA,yBAAS,eAAe;AAGxD,MAAI,OAAO,SAASA,yBAAS,UAAU,OAAO,SAASA,yBAAS,MAC9D,gBAAe,eAAe,OAAO;AAGvC,MACE,OAAO,SAASA,yBAAS,eACzB,OAAO,SAASA,yBAAS,aACzB,OAAO,SAASA,yBAAS,YAEzB,gBAAe,eAAe,OAAO,QAAQ,OAAO;AAGtD,MACE,OAAO,SAASA,yBAAS,YACzB,OAAO,SAASA,yBAAS,QACzB,OAAO,SAASA,yBAAS,aACzB,OAAO,SAASA,yBAAS,KAEzB,gBAAe,eAAe,OAAO;;AAIzC,QAAO"}
1
+ {"version":3,"file":"getContentNodeByKeyPath.cjs","names":["NodeType"],"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":"iJAOA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAI,EAAoB,gBAAgB,EAAkB,CAE1D,IAAK,IAAM,KAAU,EAEf,GAAkB,GAAc,WAAaA,EAAAA,SAAS,cACxD,EAAe,IAAeA,EAAAA,SAAS,eAAe,KAGpD,EAAO,OAASA,EAAAA,SAAS,QAAU,EAAO,OAASA,EAAAA,SAAS,SAC9D,EAAe,IAAe,EAAO,OAIrC,EAAO,OAASA,EAAAA,SAAS,aACzB,EAAO,OAASA,EAAAA,SAAS,WACzB,EAAO,OAASA,EAAAA,SAAS,eAEzB,EAAe,IAAe,EAAO,QAAQ,EAAO,OAIpD,EAAO,OAASA,EAAAA,SAAS,UACzB,EAAO,OAASA,EAAAA,SAAS,MACzB,EAAO,OAASA,EAAAA,SAAS,WACzB,EAAO,OAASA,EAAAA,SAAS,QAEzB,EAAe,IAAe,EAAO,OAIzC,OAAO"}
@@ -1,56 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/getDefaultNode.ts
6
- const getDefaultNode = (nodeType, locales, content) => {
7
- const clonedContent = structuredClone(content);
8
- switch (nodeType) {
9
- case _intlayer_types.NodeType.Translation: return {
10
- nodeType: _intlayer_types.NodeType.Translation,
11
- [_intlayer_types.NodeType.Translation]: Object.assign({}, ...locales.map((locale) => ({ [locale]: structuredClone(clonedContent) ?? "" })))
12
- };
13
- case _intlayer_types.NodeType.Enumeration: return {
14
- nodeType: _intlayer_types.NodeType.Enumeration,
15
- [_intlayer_types.NodeType.Enumeration]: { "1": clonedContent ?? "" }
16
- };
17
- case _intlayer_types.NodeType.Condition: return {
18
- nodeType: _intlayer_types.NodeType.Condition,
19
- [_intlayer_types.NodeType.Condition]: {
20
- true: clonedContent ?? "",
21
- false: clonedContent ?? ""
22
- }
23
- };
24
- case _intlayer_types.NodeType.Insertion: return {
25
- nodeType: _intlayer_types.NodeType.Insertion,
26
- [_intlayer_types.NodeType.Insertion]: { insertion: clonedContent ?? "" }
27
- };
28
- case _intlayer_types.NodeType.Nested: return {
29
- nodeType: _intlayer_types.NodeType.Nested,
30
- [_intlayer_types.NodeType.Nested]: { dictionaryKey: "" }
31
- };
32
- case _intlayer_types.NodeType.Markdown: return {
33
- nodeType: _intlayer_types.NodeType.Markdown,
34
- [_intlayer_types.NodeType.Markdown]: clonedContent ?? ""
35
- };
36
- case _intlayer_types.NodeType.HTML: return {
37
- nodeType: _intlayer_types.NodeType.HTML,
38
- [_intlayer_types.NodeType.HTML]: clonedContent ?? "",
39
- customComponents: []
40
- };
41
- case _intlayer_types.NodeType.File: return {
42
- nodeType: _intlayer_types.NodeType.File,
43
- [_intlayer_types.NodeType.File]: clonedContent ?? ""
44
- };
45
- case _intlayer_types.NodeType.Object: return { newKey: clonedContent ?? "" };
46
- case _intlayer_types.NodeType.Array: return [clonedContent ?? ""];
47
- case _intlayer_types.NodeType.Text: return clonedContent ?? "";
48
- case _intlayer_types.NodeType.Number: return clonedContent ?? 0;
49
- case _intlayer_types.NodeType.Boolean: return clonedContent ?? true;
50
- default: return clonedContent ?? "";
51
- }
52
- };
53
-
54
- //#endregion
55
- exports.getDefaultNode = getDefaultNode;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=(t,n,r)=>{let i=structuredClone(r);switch(t){case e.NodeType.Translation:return{nodeType:e.NodeType.Translation,[e.NodeType.Translation]:Object.assign({},...n.map(e=>({[e]:structuredClone(i)??``})))};case e.NodeType.Enumeration:return{nodeType:e.NodeType.Enumeration,[e.NodeType.Enumeration]:{1:i??``}};case e.NodeType.Condition:return{nodeType:e.NodeType.Condition,[e.NodeType.Condition]:{true:i??``,false:i??``}};case e.NodeType.Insertion:return{nodeType:e.NodeType.Insertion,[e.NodeType.Insertion]:{insertion:i??``}};case e.NodeType.Nested:return{nodeType:e.NodeType.Nested,[e.NodeType.Nested]:{dictionaryKey:``}};case e.NodeType.Markdown:return{nodeType:e.NodeType.Markdown,[e.NodeType.Markdown]:i??``};case e.NodeType.HTML:return{nodeType:e.NodeType.HTML,[e.NodeType.HTML]:i??``,customComponents:[]};case e.NodeType.File:return{nodeType:e.NodeType.File,[e.NodeType.File]:i??``};case e.NodeType.Object:return{newKey:i??``};case e.NodeType.Array:return[i??``];case e.NodeType.Text:return i??``;case e.NodeType.Number:return i??0;case e.NodeType.Boolean:return i??!0;default:return i??``}};exports.getDefaultNode=t;
56
2
  //# sourceMappingURL=getDefaultNode.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDefaultNode.cjs","names":["NodeType"],"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":";;;;;AAMA,MAAa,kBACX,UACA,SACA,YACgB;CAChB,MAAM,gBAAgB,gBAAgB,QAAQ;AAC9C,SAAQ,UAAR;EACE,KAAKA,yBAAS,YACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,cAAc,OAAO,OAC7B,EAAE,EACF,GAAG,QAAQ,KAAK,YAAY,GACzB,SAAS,gBAAgB,cAAc,IAAI,IAC7C,EAAE,CACJ;GACF;EAEH,KAAKA,yBAAS,YACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,cAAc,EACtB,KAAK,iBAAiB,IACvB;GACF;EAEH,KAAKA,yBAAS,UACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,YAAY;IACpB,MAAM,iBAAiB;IACvB,OAAO,iBAAiB;IACzB;GACF;EAEH,KAAKA,yBAAS,UACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,YAAY,EACpB,WAAW,iBAAiB,IAC7B;GACF;EAEH,KAAKA,yBAAS,OACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,SAAS,EACjB,eAAe,IAChB;GACF;EAEH,KAAKA,yBAAS,SACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,WAAW,iBAAiB;GACvC;EAEH,KAAKA,yBAAS,KACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,OAAO,iBAAiB;GAClC,kBAAkB,EAAE;GACrB;EAEH,KAAKA,yBAAS,KACZ,QAAO;GACL,UAAUA,yBAAS;IAClBA,yBAAS,OAAO,iBAAiB;GACnC;EAEH,KAAKA,yBAAS,OACZ,QAAO,EACL,QAAQ,iBAAiB,IAC1B;EAEH,KAAKA,yBAAS,MACZ,QAAO,CAAC,iBAAiB,GAAG;EAE9B,KAAKA,yBAAS,KACZ,QAAO,iBAAiB;EAE1B,KAAKA,yBAAS,OACZ,QAAO,iBAAiB;EAE1B,KAAKA,yBAAS,QACZ,QAAO,iBAAiB;EAE1B,QACE,QAAO,iBAAiB"}
1
+ {"version":3,"file":"getDefaultNode.cjs","names":["NodeType"],"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":"iJAMA,MAAa,GACX,EACA,EACA,IACgB,CAChB,IAAM,EAAgB,gBAAgB,EAAQ,CAC9C,OAAQ,EAAR,CACE,KAAKA,EAAAA,SAAS,YACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,aAClBA,EAAAA,SAAS,aAAc,OAAO,OAC7B,EAAE,CACF,GAAG,EAAQ,IAAK,IAAY,EACzB,GAAS,gBAAgB,EAAc,EAAI,GAC7C,EAAE,CACJ,CACF,CAEH,KAAKA,EAAAA,SAAS,YACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,aAClBA,EAAAA,SAAS,aAAc,CACtB,EAAK,GAAiB,GACvB,CACF,CAEH,KAAKA,EAAAA,SAAS,UACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,WAClBA,EAAAA,SAAS,WAAY,CACpB,KAAM,GAAiB,GACvB,MAAO,GAAiB,GACzB,CACF,CAEH,KAAKA,EAAAA,SAAS,UACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,WAClBA,EAAAA,SAAS,WAAY,CACpB,UAAW,GAAiB,GAC7B,CACF,CAEH,KAAKA,EAAAA,SAAS,OACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,QAClBA,EAAAA,SAAS,QAAS,CACjB,cAAe,GAChB,CACF,CAEH,KAAKA,EAAAA,SAAS,SACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,UAClBA,EAAAA,SAAS,UAAW,GAAiB,GACvC,CAEH,KAAKA,EAAAA,SAAS,KACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,MAClBA,EAAAA,SAAS,MAAO,GAAiB,GAClC,iBAAkB,EAAE,CACrB,CAEH,KAAKA,EAAAA,SAAS,KACZ,MAAO,CACL,SAAUA,EAAAA,SAAS,MAClBA,EAAAA,SAAS,MAAO,GAAiB,GACnC,CAEH,KAAKA,EAAAA,SAAS,OACZ,MAAO,CACL,OAAQ,GAAiB,GAC1B,CAEH,KAAKA,EAAAA,SAAS,MACZ,MAAO,CAAC,GAAiB,GAAG,CAE9B,KAAKA,EAAAA,SAAS,KACZ,OAAO,GAAiB,GAE1B,KAAKA,EAAAA,SAAS,OACZ,OAAO,GAAiB,EAE1B,KAAKA,EAAAA,SAAS,QACZ,OAAO,GAAiB,GAE1B,QACE,OAAO,GAAiB"}
@@ -1,27 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/getEmptyNode.ts
6
- const getEmptyNode = (section) => {
7
- if (typeof section === "string") return "";
8
- if (typeof section === "number") return 0;
9
- if (typeof section === "boolean") return true;
10
- if (typeof section?.nodeType === "string") {
11
- const typedNode = section;
12
- const content = typedNode[typedNode.nodeType];
13
- if (typedNode.nodeType === _intlayer_types.NodeType.Translation || typedNode.nodeType === _intlayer_types.NodeType.Enumeration || typedNode.nodeType === _intlayer_types.NodeType.Condition || typedNode.nodeType === _intlayer_types.NodeType.Insertion || typedNode.nodeType === _intlayer_types.NodeType.HTML) return getEmptyNode(content);
14
- if (typedNode.nodeType === _intlayer_types.NodeType.Nested) return "dictionary-key";
15
- if (typedNode.nodeType === _intlayer_types.NodeType.File) return "file/path";
16
- if (typedNode.nodeType === _intlayer_types.NodeType.Markdown) return getEmptyNode(typedNode);
17
- return content;
18
- }
19
- if (!section || typeof section !== "object") return section;
20
- if (Array.isArray(section)) return section.map(getEmptyNode);
21
- const mappedSectionObject = Object.entries(section).map(([key, value]) => [key, getEmptyNode(value)]);
22
- return Object.fromEntries(mappedSectionObject);
23
- };
24
-
25
- //#endregion
26
- exports.getEmptyNode = getEmptyNode;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@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.NodeType.Translation||r.nodeType===e.NodeType.Enumeration||r.nodeType===e.NodeType.Condition||r.nodeType===e.NodeType.Insertion||r.nodeType===e.NodeType.HTML?t(i):r.nodeType===e.NodeType.Nested?`dictionary-key`:r.nodeType===e.NodeType.File?`file/path`:r.nodeType===e.NodeType.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)};exports.getEmptyNode=t;
27
2
  //# sourceMappingURL=getEmptyNode.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEmptyNode.cjs","names":["NodeType"],"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":";;;;;AAEA,MAAa,gBAAgB,YAAsC;AACjE,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,UACrB,QAAO;AAET,KAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;AAEtB,MACE,UAAU,aAAaA,yBAAS,eAChC,UAAU,aAAaA,yBAAS,eAChC,UAAU,aAAaA,yBAAS,aAChC,UAAU,aAAaA,yBAAS,aAChC,UAAU,aAAaA,yBAAS,KAEhC,QAAO,aAAa,QAAuB;AAG7C,MAAI,UAAU,aAAaA,yBAAS,OAClC,QAAO;AAGT,MAAI,UAAU,aAAaA,yBAAS,KAClC,QAAO;AAGT,MAAI,UAAU,aAAaA,yBAAS,SAClC,QAAO,aAAa,UAAU;AAGhC,SAAO;;AAGT,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,QAAO;AAGT,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAQ,QAA0B,IAChC,aACD;CAGH,MAAM,sBAAsB,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,KAAK,WAAW,CACxE,KACA,aAAa,MAAqB,CACnC,CAAC;AAIF,QAF2B,OAAO,YAAY,oBAAoB"}
1
+ {"version":3,"file":"getEmptyNode.cjs","names":["NodeType"],"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":"iJAEA,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,WAAaA,EAAAA,SAAS,aAChC,EAAU,WAAaA,EAAAA,SAAS,aAChC,EAAU,WAAaA,EAAAA,SAAS,WAChC,EAAU,WAAaA,EAAAA,SAAS,WAChC,EAAU,WAAaA,EAAAA,SAAS,KAEzB,EAAa,EAAuB,CAGzC,EAAU,WAAaA,EAAAA,SAAS,OAC3B,iBAGL,EAAU,WAAaA,EAAAA,SAAS,KAC3B,YAGL,EAAU,WAAaA,EAAAA,SAAS,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,24 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- let _intlayer_types = require("@intlayer/types");
4
-
5
- //#region src/dictionaryManipulator/getNodeChildren.ts
6
- const getNodeChildren = (section) => {
7
- if (typeof section === "string") return section;
8
- if (typeof section === "number") return section;
9
- if (typeof section === "boolean") return section;
10
- if (typeof section?.nodeType === "string") {
11
- const typedNode = section;
12
- const content = typedNode[typedNode.nodeType];
13
- if (typedNode.nodeType === _intlayer_types.NodeType.Translation || typedNode.nodeType === _intlayer_types.NodeType.Enumeration || typedNode.nodeType === _intlayer_types.NodeType.Condition || typedNode.nodeType === _intlayer_types.NodeType.Insertion || typedNode.nodeType === _intlayer_types.NodeType.Gender || typedNode.nodeType === _intlayer_types.NodeType.File || typedNode.nodeType === _intlayer_types.NodeType.Markdown || typedNode.nodeType === _intlayer_types.NodeType.HTML) return content[Object.keys(content)[0]];
14
- if (typedNode.nodeType === _intlayer_types.NodeType.Nested) return;
15
- return content;
16
- }
17
- if (!section || typeof section !== "object") return section;
18
- if (Array.isArray(section)) return section[0];
19
- return section;
20
- };
21
-
22
- //#endregion
23
- exports.getNodeChildren = getNodeChildren;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@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.NodeType.Translation||n.nodeType===e.NodeType.Enumeration||n.nodeType===e.NodeType.Condition||n.nodeType===e.NodeType.Insertion||n.nodeType===e.NodeType.Gender||n.nodeType===e.NodeType.File||n.nodeType===e.NodeType.Markdown||n.nodeType===e.NodeType.HTML?r[Object.keys(r)[0]]:n.nodeType===e.NodeType.Nested?void 0:r}return!t||typeof t!=`object`?t:Array.isArray(t)?t[0]:t};exports.getNodeChildren=t;
24
2
  //# sourceMappingURL=getNodeChildren.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNodeChildren.cjs","names":["NodeType"],"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":";;;;;AAEA,MAAa,mBAAmB,YAAsC;AACpE,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,SACrB,QAAO;AAET,KAAI,OAAO,YAAY,UACrB,QAAO;AAET,KAAI,OAAQ,SAAuB,aAAa,UAAU;EACxD,MAAM,YAAY;EAClB,MAAM,UACJ,UAAU,UAAU;AAEtB,MACE,UAAU,aAAaA,yBAAS,eAChC,UAAU,aAAaA,yBAAS,eAChC,UAAU,aAAaA,yBAAS,aAChC,UAAU,aAAaA,yBAAS,aAChC,UAAU,aAAaA,yBAAS,UAChC,UAAU,aAAaA,yBAAS,QAChC,UAAU,aAAaA,yBAAS,YAChC,UAAU,aAAaA,yBAAS,KAGhC,QAAO,QADU,OAAO,KAAK,QAAQ,CAAC;AAIxC,MAAI,UAAU,aAAaA,yBAAS,OAClC;AAGF,SAAO;;AAGT,KAAI,CAAC,WAAW,OAAO,YAAY,SACjC,QAAO;AAGT,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAQ,QAA0B;AAGpC,QAAO"}
1
+ {"version":3,"file":"getNodeChildren.cjs","names":["NodeType"],"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":"iJAEA,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,WAAaA,EAAAA,SAAS,aAChC,EAAU,WAAaA,EAAAA,SAAS,aAChC,EAAU,WAAaA,EAAAA,SAAS,WAChC,EAAU,WAAaA,EAAAA,SAAS,WAChC,EAAU,WAAaA,EAAAA,SAAS,QAChC,EAAU,WAAaA,EAAAA,SAAS,MAChC,EAAU,WAAaA,EAAAA,SAAS,UAChC,EAAU,WAAaA,EAAAA,SAAS,KAGzB,EADU,OAAO,KAAK,EAAQ,CAAC,IAIpC,EAAU,WAAaA,EAAAA,SAAS,OAClC,OAGK,EAWT,MARI,CAAC,GAAW,OAAO,GAAY,SAC1B,EAGL,MAAM,QAAQ,EAAQ,CAChB,EAA0B,GAG7B"}
@@ -1,37 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_utils_isValidReactElement = require('../utils/isValidReactElement.cjs');
4
- let _intlayer_types = require("@intlayer/types");
5
-
6
- //#region src/dictionaryManipulator/getNodeType.ts
7
- /**
8
- * Type guard to check if content is a TypedNode
9
- */
10
- const isTypedNode = (content) => {
11
- return typeof content === "object" && content !== null && "nodeType" in content && typeof content.nodeType === "string";
12
- };
13
- /**
14
- * Type guard to check if content is a valid NodeType
15
- */
16
- const isValidNodeType = (nodeType) => {
17
- return Object.values(_intlayer_types.NodeType).includes(nodeType);
18
- };
19
- const getNodeType = (content) => {
20
- if (typeof content === "string") return _intlayer_types.NodeType.Text;
21
- if (isTypedNode(content)) {
22
- const nodeType = content.nodeType;
23
- if (isValidNodeType(nodeType)) return nodeType;
24
- return _intlayer_types.NodeType.Unknown;
25
- }
26
- if (Array.isArray(content)) return _intlayer_types.NodeType.Array;
27
- if (require_utils_isValidReactElement.isValidElement(content)) return _intlayer_types.NodeType.ReactNode;
28
- if (typeof content === "number") return _intlayer_types.NodeType.Number;
29
- if (typeof content === "boolean") return _intlayer_types.NodeType.Boolean;
30
- if (content && typeof content === "object") return _intlayer_types.NodeType.Object;
31
- if (content === null) return _intlayer_types.NodeType.Null;
32
- return _intlayer_types.NodeType.Unknown;
33
- };
34
-
35
- //#endregion
36
- exports.getNodeType = getNodeType;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../utils/isValidReactElement.cjs`);let t=require(`@intlayer/types`);const n=e=>typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`string`,r=e=>Object.values(t.NodeType).includes(e),i=i=>{if(typeof i==`string`)return t.NodeType.Text;if(n(i)){let e=i.nodeType;return r(e)?e:t.NodeType.Unknown}return Array.isArray(i)?t.NodeType.Array:e.isValidElement(i)?t.NodeType.ReactNode:typeof i==`number`?t.NodeType.Number:typeof i==`boolean`?t.NodeType.Boolean:i&&typeof i==`object`?t.NodeType.Object:i===null?t.NodeType.Null:t.NodeType.Unknown};exports.getNodeType=i;
37
2
  //# sourceMappingURL=getNodeType.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNodeType.cjs","names":["NodeType","isValidElement"],"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":";;;;;;;;;AAMA,MAAM,eAAe,YAA2C;AAC9D,QACE,OAAO,YAAY,YACnB,YAAY,QACZ,cAAc,WACd,OAAQ,QAAsB,aAAa;;;;;AAO/C,MAAM,mBAAmB,aAA2C;AAClE,QAAO,OAAO,OAAOA,yBAAS,CAAC,SAAS,SAAqB;;AAG/D,MAAa,eAAe,YAAmC;AAC7D,KAAI,OAAO,YAAY,SACrB,QAAOA,yBAAS;AAGlB,KAAI,YAAY,QAAQ,EAAE;EACxB,MAAM,WAAW,QAAQ;AACzB,MAAI,gBAAgB,SAAS,CAC3B,QAAO;AAGT,SAAOA,yBAAS;;AAGlB,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAOA,yBAAS;AAGlB,KAAIC,iDAAe,QAAQ,CACzB,QAAOD,yBAAS;AAGlB,KAAI,OAAO,YAAY,SACrB,QAAOA,yBAAS;AAGlB,KAAI,OAAO,YAAY,UACrB,QAAOA,yBAAS;AAGlB,KAAI,WAAW,OAAO,YAAY,SAChC,QAAOA,yBAAS;AAGlB,KAAI,YAAY,KACd,QAAOA,yBAAS;AAGlB,QAAOA,yBAAS"}
1
+ {"version":3,"file":"getNodeType.cjs","names":["NodeType","isValidElement"],"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":"qMAMA,MAAM,EAAe,GAEjB,OAAO,GAAY,YACnB,GACA,aAAc,GACd,OAAQ,EAAsB,UAAa,SAOzC,EAAmB,GAChB,OAAO,OAAOA,EAAAA,SAAS,CAAC,SAAS,EAAqB,CAGlD,EAAe,GAAmC,CAC7D,GAAI,OAAO,GAAY,SACrB,OAAOA,EAAAA,SAAS,KAGlB,GAAI,EAAY,EAAQ,CAAE,CACxB,IAAM,EAAW,EAAQ,SAKzB,OAJI,EAAgB,EAAS,CACpB,EAGFA,EAAAA,SAAS,QA2BlB,OAxBI,MAAM,QAAQ,EAAQ,CACjBA,EAAAA,SAAS,MAGdC,EAAAA,eAAe,EAAQ,CAClBD,EAAAA,SAAS,UAGd,OAAO,GAAY,SACdA,EAAAA,SAAS,OAGd,OAAO,GAAY,UACdA,EAAAA,SAAS,QAGd,GAAW,OAAO,GAAY,SACzBA,EAAAA,SAAS,OAGd,IAAY,KACPA,EAAAA,SAAS,KAGXA,EAAAA,SAAS"}
@@ -1,27 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_dictionaryManipulator_editDictionaryByKeyPath = require('./editDictionaryByKeyPath.cjs');
3
- const require_dictionaryManipulator_getContentNodeByKeyPath = require('./getContentNodeByKeyPath.cjs');
4
- const require_dictionaryManipulator_getDefaultNode = require('./getDefaultNode.cjs');
5
- const require_dictionaryManipulator_getEmptyNode = require('./getEmptyNode.cjs');
6
- const require_dictionaryManipulator_getNodeChildren = require('./getNodeChildren.cjs');
7
- const require_dictionaryManipulator_getNodeType = require('./getNodeType.cjs');
8
- const require_dictionaryManipulator_mergeDictionaries = require('./mergeDictionaries.cjs');
9
- const require_dictionaryManipulator_orderDictionaries = require('./orderDictionaries.cjs');
10
- const require_dictionaryManipulator_normalizeDictionary = require('./normalizeDictionary.cjs');
11
- const require_dictionaryManipulator_removeContentNodeByKeyPath = require('./removeContentNodeByKeyPath.cjs');
12
- const require_dictionaryManipulator_renameContentNodeByKeyPath = require('./renameContentNodeByKeyPath.cjs');
13
- const require_dictionaryManipulator_updateNodeChildren = require('./updateNodeChildren.cjs');
14
-
15
- exports.editDictionaryByKeyPath = require_dictionaryManipulator_editDictionaryByKeyPath.editDictionaryByKeyPath;
16
- exports.getContentNodeByKeyPath = require_dictionaryManipulator_getContentNodeByKeyPath.getContentNodeByKeyPath;
17
- exports.getDefaultNode = require_dictionaryManipulator_getDefaultNode.getDefaultNode;
18
- exports.getEmptyNode = require_dictionaryManipulator_getEmptyNode.getEmptyNode;
19
- exports.getNodeChildren = require_dictionaryManipulator_getNodeChildren.getNodeChildren;
20
- exports.getNodeType = require_dictionaryManipulator_getNodeType.getNodeType;
21
- exports.mergeDictionaries = require_dictionaryManipulator_mergeDictionaries.mergeDictionaries;
22
- exports.normalizeDictionaries = require_dictionaryManipulator_normalizeDictionary.normalizeDictionaries;
23
- exports.normalizeDictionary = require_dictionaryManipulator_normalizeDictionary.normalizeDictionary;
24
- exports.orderDictionaries = require_dictionaryManipulator_orderDictionaries.orderDictionaries;
25
- exports.removeContentNodeByKeyPath = require_dictionaryManipulator_removeContentNodeByKeyPath.removeContentNodeByKeyPath;
26
- exports.renameContentNodeByKeyPath = require_dictionaryManipulator_renameContentNodeByKeyPath.renameContentNodeByKeyPath;
27
- exports.updateNodeChildren = require_dictionaryManipulator_updateNodeChildren.updateNodeChildren;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./editDictionaryByKeyPath.cjs`),t=require(`./getContentNodeByKeyPath.cjs`),n=require(`./getDefaultNode.cjs`),r=require(`./getEmptyNode.cjs`),i=require(`./getNodeChildren.cjs`),a=require(`./getNodeType.cjs`),o=require(`./mergeDictionaries.cjs`),s=require(`./orderDictionaries.cjs`),c=require(`./normalizeDictionary.cjs`),l=require(`./removeContentNodeByKeyPath.cjs`),u=require(`./renameContentNodeByKeyPath.cjs`),d=require(`./updateNodeChildren.cjs`);exports.editDictionaryByKeyPath=e.editDictionaryByKeyPath,exports.getContentNodeByKeyPath=t.getContentNodeByKeyPath,exports.getDefaultNode=n.getDefaultNode,exports.getEmptyNode=r.getEmptyNode,exports.getNodeChildren=i.getNodeChildren,exports.getNodeType=a.getNodeType,exports.mergeDictionaries=o.mergeDictionaries,exports.normalizeDictionaries=c.normalizeDictionaries,exports.normalizeDictionary=c.normalizeDictionary,exports.orderDictionaries=s.orderDictionaries,exports.removeContentNodeByKeyPath=l.removeContentNodeByKeyPath,exports.renameContentNodeByKeyPath=u.renameContentNodeByKeyPath,exports.updateNodeChildren=d.updateNodeChildren;