@intlayer/core 8.1.2 → 8.1.3-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (407) 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/utils/index.d.ts +8 -0
  407. package/package.json +65 -11
@@ -1 +1 @@
1
- {"version":3,"file":"getMaskContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getMaskContent.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport { deepTransformNode, type Plugins } from '../interpreter';\n\nconst passTypedNodePlugin: Plugins = {\n id: 'pass-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node, props, deepTransformNode) =>\n deepTransformNode(node[node.nodeType], props),\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const buildMaskPlugin: Plugins = {\n id: 'build-mask-plugin',\n canHandle: (node) => typeof node === 'string' || typeof node === 'number',\n transform: () => true,\n};\n\nexport const getMaskContent = (source: Dictionary): any => ({\n ...source,\n content: deepTransformNode(source.content, {\n dictionaryKey: source.key,\n keyPath: [],\n plugins: [passTypedNodePlugin, buildMaskPlugin],\n }),\n});\n"],"mappings":";;;;AAGA,MAAM,sBAA+B;CACnC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,OAAO,MAAM,aAAa;CACxD,YAAY,MAAM,OAAO,sBACvB,kBAAkB,KAAK,KAAK,WAAW,MAAM;CAChD;;AAGD,MAAa,kBAA2B;CACtC,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,OAAO,SAAS;CACjE,iBAAiB;CAClB;AAED,MAAa,kBAAkB,YAA6B;CAC1D,GAAG;CACH,SAASA,+DAAkB,OAAO,SAAS;EACzC,eAAe,OAAO;EACtB,SAAS,EAAE;EACX,SAAS,CAAC,qBAAqB,gBAAgB;EAChD,CAAC;CACH"}
1
+ {"version":3,"file":"getMaskContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getMaskContent.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types';\nimport { deepTransformNode, type Plugins } from '../interpreter';\n\nconst passTypedNodePlugin: Plugins = {\n id: 'pass-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node, props, deepTransformNode) =>\n deepTransformNode(node[node.nodeType], props),\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const buildMaskPlugin: Plugins = {\n id: 'build-mask-plugin',\n canHandle: (node) => typeof node === 'string' || typeof node === 'number',\n transform: () => true,\n};\n\nexport const getMaskContent = (source: Dictionary): any => ({\n ...source,\n content: deepTransformNode(source.content, {\n dictionaryKey: source.key,\n keyPath: [],\n plugins: [passTypedNodePlugin, buildMaskPlugin],\n }),\n});\n"],"mappings":"kIAGM,EAA+B,CACnC,GAAI,yBACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAO,GAAM,UAAa,SACxD,WAAY,EAAM,EAAO,IACvB,EAAkB,EAAK,EAAK,UAAW,EAAM,CAChD,CAGY,EAA2B,CACtC,GAAI,oBACJ,UAAY,GAAS,OAAO,GAAS,UAAY,OAAO,GAAS,SACjE,cAAiB,GAClB,CAEY,EAAkB,IAA6B,CAC1D,GAAG,EACH,QAASA,EAAAA,kBAAkB,EAAO,QAAS,CACzC,cAAe,EAAO,IACtB,QAAS,EAAE,CACX,QAAS,CAAC,EAAqB,EAAgB,CAChD,CAAC,CACH"}
@@ -1,83 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_interpreter_getContent_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
4
- let _intlayer_types = require("@intlayer/types");
5
- let _intlayer_config_built = require("@intlayer/config/built");
6
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
7
-
8
- //#region src/deepTransformPlugins/getMissingLocalesContent.ts
9
- const getDeepKeyPaths = (obj, prefix = []) => {
10
- if (typeof obj !== "object" || obj === null) return [];
11
- if (Array.isArray(obj)) return [];
12
- return Object.keys(obj).flatMap((key) => {
13
- const newPath = [...prefix, key];
14
- return [newPath, ...getDeepKeyPaths(obj[key], newPath)];
15
- });
16
- };
17
- const hasDeepKeyPath = (obj, keyPath) => {
18
- let current = obj;
19
- for (const key of keyPath) {
20
- if (current === void 0 || current === null || typeof current !== "object") return false;
21
- if (!(key in current)) return false;
22
- current = current[key];
23
- }
24
- return true;
25
- };
26
- /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
27
- const checkMissingLocalesPlugin = (locales, onMissingLocale) => ({
28
- id: "check-missing-locales-plugin",
29
- canHandle: (node) => typeof node === "object" && node?.nodeType === _intlayer_types.NodeType.Translation,
30
- transform: (node, props, deepTransformNode) => {
31
- const translations = node[_intlayer_types.NodeType.Translation];
32
- const allKeys = /* @__PURE__ */ new Set();
33
- for (const locale of locales) if (translations[locale]) getDeepKeyPaths(translations[locale]).forEach((path) => {
34
- allKeys.add(JSON.stringify(path));
35
- });
36
- for (const locale of locales) {
37
- if (!translations[locale]) {
38
- onMissingLocale(locale);
39
- continue;
40
- }
41
- for (const pathStr of allKeys) {
42
- const path = JSON.parse(pathStr);
43
- if (!hasDeepKeyPath(translations[locale], path)) {
44
- onMissingLocale(locale);
45
- break;
46
- }
47
- }
48
- }
49
- for (const key in translations) {
50
- const child = translations[key];
51
- deepTransformNode(child, {
52
- ...props,
53
- children: child
54
- });
55
- }
56
- return node;
57
- }
58
- });
59
- /**
60
- * Return the content of a node with only the translation plugin.
61
- *
62
- * @param node The node to transform.
63
- * @param locales The locales to check for missing translations.
64
- */
65
- const getMissingLocalesContent = (node, locales = _intlayer_config_built.default?.internationalization?.locales, nodeProps) => {
66
- const missingLocales = /* @__PURE__ */ new Set();
67
- const plugins = [checkMissingLocalesPlugin(locales, (locale) => missingLocales.add(locale)), ...nodeProps.plugins ?? []];
68
- require_interpreter_getContent_deepTransform.deepTransformNode(node, {
69
- ...nodeProps,
70
- plugins
71
- });
72
- return Array.from(missingLocales);
73
- };
74
- const getMissingLocalesContentFromDictionary = (dictionary, locales = _intlayer_config_built.default?.internationalization?.locales) => getMissingLocalesContent(dictionary.content, locales, {
75
- dictionaryKey: dictionary.key,
76
- keyPath: []
77
- });
78
-
79
- //#endregion
80
- exports.checkMissingLocalesPlugin = checkMissingLocalesPlugin;
81
- exports.getMissingLocalesContent = getMissingLocalesContent;
82
- exports.getMissingLocalesContentFromDictionary = getMissingLocalesContentFromDictionary;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../interpreter/getContent/deepTransform.cjs`);let n=require(`@intlayer/types`),r=require(`@intlayer/config/built`);r=e.__toESM(r);const i=(e,t=[])=>typeof e!=`object`||!e||Array.isArray(e)?[]:Object.keys(e).flatMap(n=>{let r=[...t,n];return[r,...i(e[n],r)]}),a=(e,t)=>{let n=e;for(let e of t){if(typeof n!=`object`||!n||!(e in n))return!1;n=n[e]}return!0},o=(e,t)=>({id:`check-missing-locales-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===n.NodeType.Translation,transform:(r,o,s)=>{let c=r[n.NodeType.Translation],l=new Set;for(let t of e)c[t]&&i(c[t]).forEach(e=>{l.add(JSON.stringify(e))});for(let n of e){if(!c[n]){t(n);continue}for(let e of l){let r=JSON.parse(e);if(!a(c[n],r)){t(n);break}}}for(let e in c){let t=c[e];s(t,{...o,children:t})}return r}}),s=(e,n=r.default?.internationalization?.locales,i)=>{let a=new Set,s=[o(n,e=>a.add(e)),...i.plugins??[]];return t.deepTransformNode(e,{...i,plugins:s}),Array.from(a)},c=(e,t=r.default?.internationalization?.locales)=>s(e.content,t,{dictionaryKey:e.key,keyPath:[]});exports.checkMissingLocalesPlugin=o,exports.getMissingLocalesContent=s,exports.getMissingLocalesContentFromDictionary=c;
83
2
  //# sourceMappingURL=getMissingLocalesContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMissingLocalesContent.cjs","names":["NodeType","configuration"],"sources":["../../../src/deepTransformPlugins/getMissingLocalesContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types';\nimport {\n type ContentNode,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport type { DeepTransformContent, NodeProps, Plugins } from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\nconst getDeepKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null) {\n return [];\n }\n\n // Skip array indices - arrays of different lengths shouldn't trigger missing translations\n // Each locale can have arrays with different numbers of elements (e.g., keywords)\n if (Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n return [newPath, ...getDeepKeyPaths(obj[key], newPath)];\n });\n};\n\nconst hasDeepKeyPath = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n\n return true;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const checkMissingLocalesPlugin = (\n locales: Locale[],\n onMissingLocale: (locale: Locale) => void\n): Plugins => ({\n id: 'check-missing-locales-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const translations = node[NodeType.Translation] as Record<string, any>;\n const allKeys = new Set<string>();\n\n for (const locale of locales) {\n if (translations[locale]) {\n getDeepKeyPaths(translations[locale]).forEach((path) => {\n allKeys.add(JSON.stringify(path));\n });\n }\n }\n\n for (const locale of locales) {\n if (!translations[locale]) {\n onMissingLocale(locale);\n continue;\n }\n\n for (const pathStr of allKeys) {\n const path = JSON.parse(pathStr);\n if (!hasDeepKeyPath(translations[locale], path)) {\n onMissingLocale(locale);\n break;\n }\n }\n }\n\n // Continue traversal inside the translation values, but avoid re-applying this plugin on the same node\n for (const key in translations) {\n const child = translations[key];\n deepTransformNode(child, {\n ...props,\n children: child,\n });\n }\n\n // Return the original node; the return value is ignored by the caller\n return node;\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locales The locales to check for missing translations.\n */\nexport const getMissingLocalesContent = <T extends ContentNode>(\n node: T,\n locales: LocalesValues[] = configuration?.internationalization?.locales,\n nodeProps: NodeProps\n): Locale[] => {\n const missingLocales = new Set<Locale>();\n\n const plugins: Plugins[] = [\n checkMissingLocalesPlugin(locales as Locale[], (locale) =>\n missingLocales.add(locale)\n ),\n ...(nodeProps.plugins ?? []),\n ];\n\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n return Array.from(missingLocales);\n};\n\nexport const getMissingLocalesContentFromDictionary = (\n dictionary: Dictionary,\n locales: LocalesValues[] = configuration?.internationalization?.locales\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Q,aAAa;AAC3B,qBAAkB,OAAO;IACvB,GAAG;IACH,UAAU;IACX,CAAC;;AAIJ,SAAO;;CAEV;;;;;;;AAQD,MAAa,4BACX,MACA,UAA2BC,gCAAe,sBAAsB,SAChE,cACa;CACb,MAAM,iCAAiB,IAAI,KAAa;CAExC,MAAM,UAAqB,CACzB,0BAA0B,UAAsB,WAC9C,eAAe,IAAI,OAAO,CAC3B,EACD,GAAI,UAAU,WAAW,EAAE,CAC5B;AAED,gEAAkB,MAAM;EACtB,GAAG;EACH;EACD,CAAC;AAEF,QAAO,MAAM,KAAK,eAAe;;AAGnC,MAAa,0CACX,YACA,UAA2BA,gCAAe,sBAAsB,YAEhE,yBAAyB,WAAW,SAAS,SAAS;CACpD,eAAe,WAAW;CAC1B,SAAS,EAAE;CACZ,CAAC"}
1
+ {"version":3,"file":"getMissingLocalesContent.cjs","names":["NodeType","configuration"],"sources":["../../../src/deepTransformPlugins/getMissingLocalesContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types';\nimport {\n type ContentNode,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport type { DeepTransformContent, NodeProps, Plugins } from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\nconst getDeepKeyPaths = (obj: any, prefix: string[] = []): string[][] => {\n if (typeof obj !== 'object' || obj === null) {\n return [];\n }\n\n // Skip array indices - arrays of different lengths shouldn't trigger missing translations\n // Each locale can have arrays with different numbers of elements (e.g., keywords)\n if (Array.isArray(obj)) {\n return [];\n }\n\n return Object.keys(obj).flatMap((key) => {\n const newPath = [...prefix, key];\n return [newPath, ...getDeepKeyPaths(obj[key], newPath)];\n });\n};\n\nconst hasDeepKeyPath = (obj: any, keyPath: string[]): boolean => {\n let current = obj;\n for (const key of keyPath) {\n if (\n current === undefined ||\n current === null ||\n typeof current !== 'object'\n ) {\n return false;\n }\n if (!(key in current)) {\n return false;\n }\n current = current[key];\n }\n\n return true;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const checkMissingLocalesPlugin = (\n locales: Locale[],\n onMissingLocale: (locale: Locale) => void\n): Plugins => ({\n id: 'check-missing-locales-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const translations = node[NodeType.Translation] as Record<string, any>;\n const allKeys = new Set<string>();\n\n for (const locale of locales) {\n if (translations[locale]) {\n getDeepKeyPaths(translations[locale]).forEach((path) => {\n allKeys.add(JSON.stringify(path));\n });\n }\n }\n\n for (const locale of locales) {\n if (!translations[locale]) {\n onMissingLocale(locale);\n continue;\n }\n\n for (const pathStr of allKeys) {\n const path = JSON.parse(pathStr);\n if (!hasDeepKeyPath(translations[locale], path)) {\n onMissingLocale(locale);\n break;\n }\n }\n }\n\n // Continue traversal inside the translation values, but avoid re-applying this plugin on the same node\n for (const key in translations) {\n const child = translations[key];\n deepTransformNode(child, {\n ...props,\n children: child,\n });\n }\n\n // Return the original node; the return value is ignored by the caller\n return node;\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locales The locales to check for missing translations.\n */\nexport const getMissingLocalesContent = <T extends ContentNode>(\n node: T,\n locales: LocalesValues[] = configuration?.internationalization?.locales,\n nodeProps: NodeProps\n): Locale[] => {\n const missingLocales = new Set<Locale>();\n\n const plugins: Plugins[] = [\n checkMissingLocalesPlugin(locales as Locale[], (locale) =>\n missingLocales.add(locale)\n ),\n ...(nodeProps.plugins ?? []),\n ];\n\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n return Array.from(missingLocales);\n};\n\nexport const getMissingLocalesContentFromDictionary = (\n dictionary: Dictionary,\n locales: LocalesValues[] = configuration?.internationalization?.locales\n) =>\n getMissingLocalesContent(dictionary.content, locales, {\n dictionaryKey: dictionary.key,\n keyPath: [],\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,EAAe,IAAI,EAAO,CAC3B,CACD,GAAI,EAAU,SAAW,EAAE,CAC5B,CAOD,OALA,EAAA,kBAAkB,EAAM,CACtB,GAAG,EACH,UACD,CAAC,CAEK,MAAM,KAAK,EAAe,EAGtB,GACX,EACA,EAA2BA,EAAAA,SAAe,sBAAsB,UAEhE,EAAyB,EAAW,QAAS,EAAS,CACpD,cAAe,EAAW,IAC1B,QAAS,EAAE,CACZ,CAAC"}
@@ -1,88 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_interpreter_getContent_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
3
- const require_transpiler_translation_translation = require('../transpiler/translation/translation.cjs');
4
-
5
- //#region src/deepTransformPlugins/getMultilingualDictionary.ts
6
- /**
7
- * Transform a per-locale dictionary into a multilingual dictionary.
8
- *
9
- * Example:
10
- * ```json
11
- * {
12
- * "key": "about-page",
13
- * "locale": "en",
14
- * "content": {
15
- * "myContent": "English content"
16
- * }
17
- * }
18
- * ```
19
- *
20
- * ```json
21
- * {
22
- * "key": "about-page",
23
- * "content": {
24
- * "myContent": t({
25
- * "en": "English content",
26
- * })
27
- * }
28
- * }
29
- * ```
30
- */
31
- const getMultilingualDictionary = (dictionary) => {
32
- if (!dictionary.locale) return dictionary;
33
- const locale = dictionary.locale;
34
- const transformedContent = require_interpreter_getContent_deepTransform.deepTransformNode(JSON.parse(JSON.stringify(dictionary.content)), {
35
- dictionaryKey: dictionary.key,
36
- keyPath: [],
37
- plugins: [{
38
- id: "traverse-typed-node-plugin",
39
- canHandle: (node) => typeof node === "object" && typeof node?.nodeType === "string",
40
- transform: (node, props, transformFn) => {
41
- const nodeType = node.nodeType;
42
- const inner = structuredClone(node[nodeType]);
43
- if (typeof inner !== "object" || inner === null) {
44
- const transformed = transformFn(inner, {
45
- ...props,
46
- children: inner,
47
- keyPath: [...props.keyPath, {
48
- type: nodeType,
49
- key: nodeType
50
- }]
51
- });
52
- return {
53
- ...node,
54
- [nodeType]: transformed
55
- };
56
- }
57
- for (const key in inner) {
58
- const childProps = {
59
- ...props,
60
- children: inner[key],
61
- keyPath: [...props.keyPath, {
62
- type: nodeType,
63
- key
64
- }]
65
- };
66
- inner[key] = transformFn(inner[key], childProps);
67
- }
68
- return {
69
- ...node,
70
- [nodeType]: inner
71
- };
72
- }
73
- }, {
74
- id: "wrap-primitive-in-translation",
75
- canHandle: (node) => typeof node === "string" || typeof node === "number" || typeof node === "boolean",
76
- transform: (node) => require_transpiler_translation_translation.t({ [locale]: node })
77
- }]
78
- });
79
- const { locale: _omitLocale, ...rest } = dictionary;
80
- return {
81
- ...rest,
82
- content: transformedContent
83
- };
84
- };
85
-
86
- //#endregion
87
- exports.getMultilingualDictionary = getMultilingualDictionary;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../interpreter/getContent/deepTransform.cjs`),t=require(`../transpiler/translation/translation.cjs`),n=n=>{if(!n.locale)return n;let r=n.locale,i=e.deepTransformNode(JSON.parse(JSON.stringify(n.content)),{dictionaryKey:n.key,keyPath:[],plugins:[{id:`traverse-typed-node-plugin`,canHandle:e=>typeof e==`object`&&typeof e?.nodeType==`string`,transform:(e,t,n)=>{let r=e.nodeType,i=structuredClone(e[r]);if(typeof i!=`object`||!i){let a=n(i,{...t,children:i,keyPath:[...t.keyPath,{type:r,key:r}]});return{...e,[r]:a}}for(let e in i){let a={...t,children:i[e],keyPath:[...t.keyPath,{type:r,key:e}]};i[e]=n(i[e],a)}return{...e,[r]:i}}},{id:`wrap-primitive-in-translation`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,transform:e=>t.t({[r]:e})}]}),{locale:a,...o}=n;return{...o,content:i}};exports.getMultilingualDictionary=n;
88
2
  //# sourceMappingURL=getMultilingualDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getMultilingualDictionary.cjs","names":["deepTransformNode","t"],"sources":["../../../src/deepTransformPlugins/getMultilingualDictionary.ts"],"sourcesContent":["import type { Dictionary, KeyPath, NodeType, TypedNode } from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { t } from '../transpiler';\n\n/**\n * Transform a per-locale dictionary into a multilingual dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"myContent\": \"English content\"\n * }\n * }\n * ```\n *\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"content\": {\n * \"myContent\": t({\n * \"en\": \"English content\",\n * })\n * }\n * }\n * ```\n */\nexport const getMultilingualDictionary = (\n dictionary: Dictionary\n): Dictionary => {\n if (!dictionary.locale) {\n return dictionary;\n }\n\n const locale = dictionary.locale;\n\n const wrapPrimitiveInTranslationPlugin: Plugins = {\n id: 'wrap-primitive-in-translation',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: (node) => t({ [locale]: node } as Record<string, unknown>),\n };\n\n const traverseTypedNodePlugin: Plugins = {\n id: 'traverse-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof (node as any)?.nodeType === 'string',\n transform: (node: TypedNode, props, transformFn) => {\n const nodeType = (node as any).nodeType as NodeType;\n const inner = structuredClone(\n (node as any)[nodeType as unknown as keyof TypedNode] as any\n );\n\n if (typeof inner !== 'object' || inner === null) {\n const transformed = transformFn(inner, {\n ...props,\n children: inner,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformed,\n };\n }\n\n for (const key in inner) {\n const childProps: NodeProps = {\n ...props,\n children: inner[key as unknown as keyof typeof inner],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n inner[key as unknown as keyof typeof inner] = transformFn(\n inner[key as unknown as keyof typeof inner],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: inner };\n },\n };\n\n const transformedContent = deepTransformNode(\n JSON.parse(JSON.stringify(dictionary.content)),\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [traverseTypedNodePlugin, wrapPrimitiveInTranslationPlugin],\n }\n );\n\n const { locale: _omitLocale, ...rest } = dictionary as any;\n return {\n ...rest,\n content: transformedContent,\n } as Dictionary;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,6BACX,eACe;AACf,KAAI,CAAC,WAAW,OACd,QAAO;CAGT,MAAM,SAAS,WAAW;CAoD1B,MAAM,qBAAqBA,+DACzB,KAAK,MAAM,KAAK,UAAU,WAAW,QAAQ,CAAC,EAC9C;EACE,eAAe,WAAW;EAC1B,SAAS,EAAE;EACX,SAAS,CA9C4B;GACvC,IAAI;GACJ,YAAY,SACV,OAAO,SAAS,YAAY,OAAQ,MAAc,aAAa;GACjE,YAAY,MAAiB,OAAO,gBAAgB;IAClD,MAAM,WAAY,KAAa;IAC/B,MAAM,QAAQ,gBACX,KAAa,UACf;AAED,QAAI,OAAO,UAAU,YAAY,UAAU,MAAM;KAC/C,MAAM,cAAc,YAAY,OAAO;MACrC,GAAG;MACH,UAAU;MACV,SAAS,CACP,GAAG,MAAM,SACT;OAAE,MAAM;OAAU,KAAK;OAAU,CAClC;MACF,CAAC;AACF,YAAO;MACL,GAAG;OACF,WAAyC;MAC3C;;AAGH,SAAK,MAAM,OAAO,OAAO;KACvB,MAAM,aAAwB;MAC5B,GAAG;MACH,UAAU,MAAM;MAChB,SAAS,CAAC,GAAG,MAAM,SAAS;OAAE,MAAM;OAAU;OAAK,CAAY;MAChE;AACD,WAAM,OAAwC,YAC5C,MAAM,MACN,WACD;;AAGH,WAAO;KAAE,GAAG;MAAO,WAAyC;KAAO;;GAEtE,EAhDiD;GAChD,IAAI;GACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;GAClB,YAAY,SAASC,6CAAE,GAAG,SAAS,MAAM,CAA4B;GACtE,CAgDuE;EACrE,CACF;CAED,MAAM,EAAE,QAAQ,aAAa,GAAG,SAAS;AACzC,QAAO;EACL,GAAG;EACH,SAAS;EACV"}
1
+ {"version":3,"file":"getMultilingualDictionary.cjs","names":["deepTransformNode","t"],"sources":["../../../src/deepTransformPlugins/getMultilingualDictionary.ts"],"sourcesContent":["import type { Dictionary, KeyPath, NodeType, TypedNode } from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { t } from '../transpiler';\n\n/**\n * Transform a per-locale dictionary into a multilingual dictionary.\n *\n * Example:\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"locale\": \"en\",\n * \"content\": {\n * \"myContent\": \"English content\"\n * }\n * }\n * ```\n *\n * ```json\n * {\n * \"key\": \"about-page\",\n * \"content\": {\n * \"myContent\": t({\n * \"en\": \"English content\",\n * })\n * }\n * }\n * ```\n */\nexport const getMultilingualDictionary = (\n dictionary: Dictionary\n): Dictionary => {\n if (!dictionary.locale) {\n return dictionary;\n }\n\n const locale = dictionary.locale;\n\n const wrapPrimitiveInTranslationPlugin: Plugins = {\n id: 'wrap-primitive-in-translation',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: (node) => t({ [locale]: node } as Record<string, unknown>),\n };\n\n const traverseTypedNodePlugin: Plugins = {\n id: 'traverse-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof (node as any)?.nodeType === 'string',\n transform: (node: TypedNode, props, transformFn) => {\n const nodeType = (node as any).nodeType as NodeType;\n const inner = structuredClone(\n (node as any)[nodeType as unknown as keyof TypedNode] as any\n );\n\n if (typeof inner !== 'object' || inner === null) {\n const transformed = transformFn(inner, {\n ...props,\n children: inner,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformed,\n };\n }\n\n for (const key in inner) {\n const childProps: NodeProps = {\n ...props,\n children: inner[key as unknown as keyof typeof inner],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n inner[key as unknown as keyof typeof inner] = transformFn(\n inner[key as unknown as keyof typeof inner],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: inner };\n },\n };\n\n const transformedContent = deepTransformNode(\n JSON.parse(JSON.stringify(dictionary.content)),\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [traverseTypedNodePlugin, wrapPrimitiveInTranslationPlugin],\n }\n );\n\n const { locale: _omitLocale, ...rest } = dictionary as any;\n return {\n ...rest,\n content: transformedContent,\n } as Dictionary;\n};\n"],"mappings":"yLAiCa,EACX,GACe,CACf,GAAI,CAAC,EAAW,OACd,OAAO,EAGT,IAAM,EAAS,EAAW,OAoDpB,EAAqBA,EAAAA,kBACzB,KAAK,MAAM,KAAK,UAAU,EAAW,QAAQ,CAAC,CAC9C,CACE,cAAe,EAAW,IAC1B,QAAS,EAAE,CACX,QAAS,CA9C4B,CACvC,GAAI,6BACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAQ,GAAc,UAAa,SACjE,WAAY,EAAiB,EAAO,IAAgB,CAClD,IAAM,EAAY,EAAa,SACzB,EAAQ,gBACX,EAAa,GACf,CAED,GAAI,OAAO,GAAU,WAAY,EAAgB,CAC/C,IAAM,EAAc,EAAY,EAAO,CACrC,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAU,IAAK,EAAU,CAClC,CACF,CAAC,CACF,MAAO,CACL,GAAG,GACF,GAAyC,EAC3C,CAGH,IAAK,IAAM,KAAO,EAAO,CACvB,IAAM,EAAwB,CAC5B,GAAG,EACH,SAAU,EAAM,GAChB,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAU,MAAK,CAAY,CAChE,CACD,EAAM,GAAwC,EAC5C,EAAM,GACN,EACD,CAGH,MAAO,CAAE,GAAG,GAAO,GAAyC,EAAO,EAEtE,CAhDiD,CAChD,GAAI,gCACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,UAClB,UAAY,GAASC,EAAAA,EAAE,EAAG,GAAS,EAAM,CAA4B,CACtE,CAgDuE,CACrE,CACF,CAEK,CAAE,OAAQ,EAAa,GAAG,GAAS,EACzC,MAAO,CACL,GAAG,EACH,QAAS,EACV"}
@@ -1,61 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_interpreter_getContent_deepTransform = require('../interpreter/getContent/deepTransform.cjs');
3
-
4
- //#region src/deepTransformPlugins/getReplacedValuesContent.ts
5
- const replaceValuesPlugin = (value) => ({
6
- id: "replace-values-plugin",
7
- canHandle: (node) => typeof node === "string" || typeof node === "number" || typeof node === "boolean",
8
- transform: () => value
9
- });
10
- const skipTypedNodePlugin = {
11
- id: "skip-typed-node-plugin",
12
- canHandle: (node) => typeof node === "object" && typeof node?.nodeType === "string",
13
- transform: (node, props, deepTransformNode) => {
14
- const nodeType = node.nodeType;
15
- const result = structuredClone(node[nodeType]);
16
- if (typeof result !== "object" || result === null) {
17
- const transformedResult = deepTransformNode(result, {
18
- ...props,
19
- children: result,
20
- keyPath: [...props.keyPath, {
21
- type: nodeType,
22
- key: nodeType
23
- }]
24
- });
25
- return {
26
- ...node,
27
- [nodeType]: transformedResult
28
- };
29
- }
30
- for (const key in result) {
31
- const childProps = {
32
- ...props,
33
- children: result[key],
34
- keyPath: [...props.keyPath, {
35
- type: nodeType,
36
- key
37
- }]
38
- };
39
- result[key] = deepTransformNode(result[key], childProps);
40
- }
41
- return {
42
- ...node,
43
- [nodeType]: result
44
- };
45
- }
46
- };
47
- const getReplacedValuesContent = (node, value, nodeProps) => {
48
- const plugins = [
49
- skipTypedNodePlugin,
50
- replaceValuesPlugin(value),
51
- ...nodeProps.plugins ?? []
52
- ];
53
- return require_interpreter_getContent_deepTransform.deepTransformNode(JSON.parse(JSON.stringify(node)), {
54
- ...nodeProps,
55
- plugins
56
- });
57
- };
58
-
59
- //#endregion
60
- exports.getReplacedValuesContent = getReplacedValuesContent;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../interpreter/getContent/deepTransform.cjs`),t=e=>({id:`replace-values-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`,transform:()=>e}),n={id:`skip-typed-node-plugin`,canHandle:e=>typeof e==`object`&&typeof e?.nodeType==`string`,transform:(e,t,n)=>{let r=e.nodeType,i=structuredClone(e[r]);if(typeof i!=`object`||!i){let a=n(i,{...t,children:i,keyPath:[...t.keyPath,{type:r,key:r}]});return{...e,[r]:a}}for(let e in i){let a={...t,children:i[e],keyPath:[...t.keyPath,{type:r,key:e}]};i[e]=n(i[e],a)}return{...e,[r]:i}}},r=(r,i,a)=>{let o=[n,t(i),...a.plugins??[]];return e.deepTransformNode(JSON.parse(JSON.stringify(r)),{...a,plugins:o})};exports.getReplacedValuesContent=r;
61
2
  //# sourceMappingURL=getReplacedValuesContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getReplacedValuesContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getReplacedValuesContent.ts"],"sourcesContent":["import type {\n ContentNode,\n KeyPath,\n NodeType,\n TypedNode,\n} from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst replaceValuesPlugin = (value: string | number | boolean): Plugins => ({\n id: 'replace-values-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: () => value,\n});\n\nconst skipTypedNodePlugin: Plugins = {\n id: 'skip-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node: TypedNode, props, deepTransformNode) => {\n const nodeType = node.nodeType as NodeType;\n const result = structuredClone(\n node[nodeType as unknown as keyof TypedNode] as any\n );\n\n // If the result is a primitive value (string, number, boolean),\n // we need to transform it directly instead of iterating over its properties\n if (typeof result !== 'object' || result === null) {\n const transformedResult = deepTransformNode(result, {\n ...props,\n children: result,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformedResult,\n };\n }\n\n // For objects and arrays, iterate over their properties\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: result };\n },\n};\n\nexport const getReplacedValuesContent = (\n node: ContentNode,\n value: string | number | boolean,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n skipTypedNodePlugin,\n replaceValuesPlugin(value),\n ...(nodeProps.plugins ?? []),\n ];\n\n const JSONNode = JSON.parse(JSON.stringify(node));\n\n return deepTransformNode(JSONNode, {\n ...nodeProps,\n plugins,\n });\n};\n"],"mappings":";;;;AAYA,MAAM,uBAAuB,WAA+C;CAC1E,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,iBAAiB;CAClB;AAED,MAAM,sBAA+B;CACnC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,OAAO,MAAM,aAAa;CACxD,YAAY,MAAiB,OAAO,sBAAsB;EACxD,MAAM,WAAW,KAAK;EACtB,MAAM,SAAS,gBACb,KAAK,UACN;AAID,MAAI,OAAO,WAAW,YAAY,WAAW,MAAM;GACjD,MAAM,oBAAoB,kBAAkB,QAAQ;IAClD,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM;KAAU,KAAK;KAAU,CAClC;IACF,CAAC;AACF,UAAO;IACL,GAAG;KACF,WAAyC;IAC3C;;AAIH,OAAK,MAAM,OAAO,QAAQ;GACxB,MAAM,aAAa;IACjB,GAAG;IACH,UAAU,OAAO;IACjB,SAAS,CAAC,GAAG,MAAM,SAAS;KAAE,MAAM;KAAU;KAAK,CAAY;IAChE;AACD,UAAO,OAAyC,kBAC9C,OAAO,MACP,WACD;;AAGH,SAAO;GAAE,GAAG;IAAO,WAAyC;GAAQ;;CAEvE;AAED,MAAa,4BACX,MACA,OACA,cACG;CACH,MAAM,UAAqB;EACzB;EACA,oBAAoB,MAAM;EAC1B,GAAI,UAAU,WAAW,EAAE;EAC5B;AAID,QAAOA,+DAFU,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,EAEd;EACjC,GAAG;EACH;EACD,CAAC"}
1
+ {"version":3,"file":"getReplacedValuesContent.cjs","names":["deepTransformNode"],"sources":["../../../src/deepTransformPlugins/getReplacedValuesContent.ts"],"sourcesContent":["import type {\n ContentNode,\n KeyPath,\n NodeType,\n TypedNode,\n} from '@intlayer/types';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst replaceValuesPlugin = (value: string | number | boolean): Plugins => ({\n id: 'replace-values-plugin',\n canHandle: (node) =>\n typeof node === 'string' ||\n typeof node === 'number' ||\n typeof node === 'boolean',\n transform: () => value,\n});\n\nconst skipTypedNodePlugin: Plugins = {\n id: 'skip-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node: TypedNode, props, deepTransformNode) => {\n const nodeType = node.nodeType as NodeType;\n const result = structuredClone(\n node[nodeType as unknown as keyof TypedNode] as any\n );\n\n // If the result is a primitive value (string, number, boolean),\n // we need to transform it directly instead of iterating over its properties\n if (typeof result !== 'object' || result === null) {\n const transformedResult = deepTransformNode(result, {\n ...props,\n children: result,\n keyPath: [\n ...props.keyPath,\n { type: nodeType, key: nodeType } as KeyPath,\n ],\n });\n return {\n ...node,\n [nodeType as unknown as keyof TypedNode]: transformedResult,\n };\n }\n\n // For objects and arrays, iterate over their properties\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [...props.keyPath, { type: nodeType, key } as KeyPath],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n childProps\n );\n }\n\n return { ...node, [nodeType as unknown as keyof TypedNode]: result };\n },\n};\n\nexport const getReplacedValuesContent = (\n node: ContentNode,\n value: string | number | boolean,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n skipTypedNodePlugin,\n replaceValuesPlugin(value),\n ...(nodeProps.plugins ?? []),\n ];\n\n const JSONNode = JSON.parse(JSON.stringify(node));\n\n return deepTransformNode(JSONNode, {\n ...nodeProps,\n plugins,\n });\n};\n"],"mappings":"kIAYM,EAAuB,IAA+C,CAC1E,GAAI,wBACJ,UAAY,GACV,OAAO,GAAS,UAChB,OAAO,GAAS,UAChB,OAAO,GAAS,UAClB,cAAiB,EAClB,EAEK,EAA+B,CACnC,GAAI,yBACJ,UAAY,GACV,OAAO,GAAS,UAAY,OAAO,GAAM,UAAa,SACxD,WAAY,EAAiB,EAAO,IAAsB,CACxD,IAAM,EAAW,EAAK,SAChB,EAAS,gBACb,EAAK,GACN,CAID,GAAI,OAAO,GAAW,WAAY,EAAiB,CACjD,IAAM,EAAoB,EAAkB,EAAQ,CAClD,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAU,IAAK,EAAU,CAClC,CACF,CAAC,CACF,MAAO,CACL,GAAG,GACF,GAAyC,EAC3C,CAIH,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAO,GACjB,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAU,MAAK,CAAY,CAChE,CACD,EAAO,GAAyC,EAC9C,EAAO,GACP,EACD,CAGH,MAAO,CAAE,GAAG,GAAO,GAAyC,EAAQ,EAEvE,CAEY,GACX,EACA,EACA,IACG,CACH,IAAM,EAAqB,CACzB,EACA,EAAoB,EAAM,CAC1B,GAAI,EAAU,SAAW,EAAE,CAC5B,CAID,OAAOA,EAAAA,kBAFU,KAAK,MAAM,KAAK,UAAU,EAAK,CAAC,CAEd,CACjC,GAAG,EACH,UACD,CAAC"}
@@ -1,123 +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/getSplittedContent.ts
6
- const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
7
- const hasNodeType = (value) => isObject(value) && typeof value.nodeType === "string";
8
- const mergeValues = (a, b) => {
9
- if (a === void 0) return b;
10
- if (b === void 0) return a;
11
- if (Array.isArray(a) && Array.isArray(b)) return [...a, ...b];
12
- if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {
13
- const result = { ...a };
14
- for (const key of Object.keys(b)) result[key] = mergeValues(result[key], b[key]);
15
- return result;
16
- }
17
- return b;
18
- };
19
- const mergeSplitResults = (base, addition) => {
20
- const result = { ...base };
21
- result.common = mergeValues(base.common, addition.common);
22
- const localeKeys = new Set([...Object.keys(base).filter((k) => k !== "common"), ...Object.keys(addition).filter((k) => k !== "common")]);
23
- for (const key of localeKeys) result[key] = mergeValues(base[key], addition[key]);
24
- return result;
25
- };
26
- const splitNode = (node) => {
27
- if (isObject(node) && node?.nodeType === _intlayer_types.NodeType.Translation) {
28
- const translations = node[_intlayer_types.NodeType.Translation];
29
- const result = {};
30
- for (const locale of Object.keys(translations)) {
31
- const child = translations[locale];
32
- const childSplit = splitNode(child);
33
- const mergedForLocale = mergeValues(childSplit.common, void 0);
34
- let recomposed;
35
- for (const key of Object.keys(childSplit)) {
36
- if (key === "common") continue;
37
- recomposed = mergeValues(recomposed, childSplit[key]);
38
- }
39
- const finalLocaleNode = mergeValues(mergedForLocale, recomposed);
40
- if (finalLocaleNode !== void 0) result[locale] = finalLocaleNode;
41
- }
42
- return result;
43
- }
44
- if (Array.isArray(node)) {
45
- const commonArray = [];
46
- const perLocaleArrays = {};
47
- node.forEach((child) => {
48
- const childSplit = splitNode(child);
49
- if (childSplit.common !== void 0) commonArray.push(childSplit.common);
50
- for (const key of Object.keys(childSplit)) {
51
- if (key === "common") continue;
52
- if (!perLocaleArrays[key]) perLocaleArrays[key] = [];
53
- const value = childSplit[key];
54
- if (value !== void 0) perLocaleArrays[key].push(value);
55
- }
56
- });
57
- const result = {};
58
- if (commonArray.length > 0) result.common = commonArray;
59
- for (const key of Object.keys(perLocaleArrays)) result[key] = perLocaleArrays[key];
60
- return result;
61
- }
62
- if (isObject(node) && !hasNodeType(node)) {
63
- let accumulated = {};
64
- for (const key of Object.keys(node)) {
65
- const childSplit = splitNode(node[key]);
66
- if (childSplit.common !== void 0) accumulated = mergeSplitResults(accumulated, { common: { [key]: childSplit.common } });
67
- for (const locale of Object.keys(childSplit)) {
68
- if (locale === "common") continue;
69
- accumulated = mergeSplitResults(accumulated, { [locale]: { [key]: childSplit[locale] } });
70
- }
71
- }
72
- return accumulated;
73
- }
74
- return { common: node };
75
- };
76
- const getSplittedContent = (content) => {
77
- const split = splitNode(content);
78
- const output = {};
79
- if (split.common !== void 0) output.common = split.common;
80
- for (const key of Object.keys(split)) {
81
- if (key === "common") continue;
82
- const value = split[key];
83
- if (value !== void 0) output[key] = value;
84
- }
85
- return output;
86
- };
87
- /**
88
- * Splits the `content` field of a Dictionary into "common" and per-locale buckets.
89
- *
90
- * Given a dictionary like:
91
- * ```js
92
- * {
93
- * key: "my-key",
94
- * content: {
95
- * commonContent: "common content",
96
- * multilingualContent: t({
97
- * en: "english content",
98
- * fr: "french content",
99
- * de: "german content",
100
- * }),
101
- * },
102
- * }
103
- * ```
104
- *
105
- * It produces:
106
- * ```js
107
- * {
108
- * common: { commonContent: "common content" },
109
- * en: { multilingualContent: "english content" },
110
- * fr: { multilingualContent: "french content" },
111
- * de: { multilingualContent: "german content" },
112
- * }
113
- * ```
114
- *
115
- * @param dictionary - The input dictionary object with possible multilingual or common content.
116
- * @returns An object mapping "common" and each locale to their corresponding content subtrees.
117
- */
118
- const getSplittedDictionaryContent = (dictionary) => getSplittedContent(dictionary.content);
119
-
120
- //#endregion
121
- exports.getSplittedContent = getSplittedContent;
122
- exports.getSplittedDictionaryContent = getSplittedDictionaryContent;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@intlayer/types`);const t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=e=>t(e)&&typeof e.nodeType==`string`,r=(e,i)=>{if(e===void 0)return i;if(i===void 0)return e;if(Array.isArray(e)&&Array.isArray(i))return[...e,...i];if(t(e)&&t(i)&&!n(e)&&!n(i)){let t={...e};for(let e of Object.keys(i))t[e]=r(t[e],i[e]);return t}return i},i=(e,t)=>{let n={...e};n.common=r(e.common,t.common);let i=new Set([...Object.keys(e).filter(e=>e!==`common`),...Object.keys(t).filter(e=>e!==`common`)]);for(let a of i)n[a]=r(e[a],t[a]);return n},a=o=>{if(t(o)&&o?.nodeType===e.NodeType.Translation){let t=o[e.NodeType.Translation],n={};for(let e of Object.keys(t)){let i=t[e],o=a(i),s=r(o.common,void 0),c;for(let e of Object.keys(o))e!==`common`&&(c=r(c,o[e]));let l=r(s,c);l!==void 0&&(n[e]=l)}return n}if(Array.isArray(o)){let e=[],t={};o.forEach(n=>{let r=a(n);r.common!==void 0&&e.push(r.common);for(let e of Object.keys(r)){if(e===`common`)continue;t[e]||(t[e]=[]);let n=r[e];n!==void 0&&t[e].push(n)}});let n={};e.length>0&&(n.common=e);for(let e of Object.keys(t))n[e]=t[e];return n}if(t(o)&&!n(o)){let e={};for(let t of Object.keys(o)){let n=a(o[t]);n.common!==void 0&&(e=i(e,{common:{[t]:n.common}}));for(let r of Object.keys(n))r!==`common`&&(e=i(e,{[r]:{[t]:n[r]}}))}return e}return{common:o}},o=e=>{let t=a(e),n={};t.common!==void 0&&(n.common=t.common);for(let e of Object.keys(t)){if(e===`common`)continue;let r=t[e];r!==void 0&&(n[e]=r)}return n},s=e=>o(e.content);exports.getSplittedContent=o,exports.getSplittedDictionaryContent=s;
123
2
  //# sourceMappingURL=getSplittedContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getSplittedContent.cjs","names":["NodeType"],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import {\n type ContentNode,\n type DeclaredLocales,\n type Dictionary,\n NodeType,\n} from '@intlayer/types';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeType.Translation) {\n const translations = (node as any)[NodeType.Translation] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.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W,SAAS,EACxC,CAAC;;;AAIN,SAAO;;AAIT,QAAO,EAAE,QAAQ,MAAM;;AAGzB,MAAa,sBACX,YAC0B;CAC1B,MAAM,QAAQ,UAAU,QAAQ;CAGhC,MAAM,SAAsC,EAAE;AAC9C,KAAI,MAAM,WAAW,OACnB,QAAO,SAAS,MAAM;AAExB,MAAK,MAAM,OAAO,OAAO,KAAK,MAAM,EAAE;AACpC,MAAI,QAAQ,SAAU;EACtB,MAAM,QAAQ,MAAM;AACpB,MAAI,UAAU,OACZ,QAAO,OAAO;;AAIlB,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCT,MAAa,gCACX,eAEA,mBAAmB,WAAW,QAAQ"}
1
+ {"version":3,"file":"getSplittedContent.cjs","names":["NodeType"],"sources":["../../../src/deepTransformPlugins/getSplittedContent.ts"],"sourcesContent":["import {\n type ContentNode,\n type DeclaredLocales,\n type Dictionary,\n NodeType,\n} from '@intlayer/types';\n\ntype SplittedContentOutput<T = ContentNode> = Record<DeclaredLocales, T> & {\n common: T;\n};\n\ntype SplitResult = Record<string, ContentNode | undefined> & {\n common?: ContentNode;\n};\n\nconst isObject = (value: unknown): value is Record<string, any> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst hasNodeType = (value: unknown): value is { nodeType: string } =>\n isObject(value) && typeof (value as any).nodeType === 'string';\n\nconst mergeValues = (\n a: ContentNode | undefined,\n b: ContentNode | undefined\n): ContentNode | undefined => {\n if (a === undefined) return b;\n if (b === undefined) return a;\n\n if (Array.isArray(a) && Array.isArray(b)) {\n // Concatenate arrays when merging sibling results\n return [...a, ...b] as unknown as ContentNode;\n }\n\n if (isObject(a) && isObject(b) && !hasNodeType(a) && !hasNodeType(b)) {\n const result: Record<string, any> = { ...a };\n for (const key of Object.keys(b)) {\n result[key] = mergeValues(\n result[key] as unknown as ContentNode | undefined,\n (b as Record<string, any>)[key] as unknown as ContentNode | undefined\n );\n }\n return result as ContentNode;\n }\n\n // For primitives or differing structures, prefer b (more recent)\n return b;\n};\n\nconst mergeSplitResults = (\n base: SplitResult,\n addition: SplitResult\n): SplitResult => {\n const result: SplitResult = { ...base };\n\n // Merge common\n result.common = mergeValues(base.common, addition.common);\n\n // Merge each locale key present in either side\n const localeKeys = new Set<string>([\n ...Object.keys(base).filter((k) => k !== 'common'),\n ...Object.keys(addition).filter((k) => k !== 'common'),\n ]);\n\n for (const key of localeKeys) {\n // @ts-ignore: dynamic keys for locales\n result[key] = mergeValues(\n base[key] as ContentNode | undefined,\n addition[key] as ContentNode | undefined\n );\n }\n\n return result;\n};\n\nconst splitNode = (node: ContentNode): SplitResult => {\n // Translation node: allocate entirely to per-locale buckets\n if (isObject(node) && (node as any)?.nodeType === NodeType.Translation) {\n const translations = (node as any)[NodeType.Translation] as Record<\n string,\n ContentNode\n >;\n\n const result: SplitResult = {};\n for (const locale of Object.keys(translations)) {\n const child = translations[locale];\n const childSplit = splitNode(child);\n\n // The content under a translation belongs to the locale, not common\n // Merge common portion of the child (if any) into the locale as well\n const mergedForLocale = mergeValues(childSplit.common, undefined);\n\n // Compose locale content: prefer the fully rebuilt child by resolving deeper translations recursively\n // which are already split inside childSplit. We need to recompose a single node for this locale.\n // Recompose by merging all keys in childSplit except 'common' into a single node, then merge child's common.\n let recomposed: ContentNode | undefined;\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n recomposed = mergeValues(\n recomposed,\n childSplit[key] as ContentNode | undefined\n );\n }\n const finalLocaleNode = mergeValues(mergedForLocale, recomposed);\n\n if (finalLocaleNode !== undefined) {\n // @ts-ignore dynamic locale key\n result[locale] = finalLocaleNode;\n }\n }\n\n return result;\n }\n\n // Arrays: split each element and merge results index-wise\n if (Array.isArray(node)) {\n const commonArray: any[] = [];\n const perLocaleArrays: Record<string, any[]> = {};\n\n node.forEach((child) => {\n const childSplit = splitNode(child as ContentNode);\n\n if (childSplit.common !== undefined) {\n commonArray.push(childSplit.common);\n }\n\n for (const key of Object.keys(childSplit)) {\n if (key === 'common') continue;\n if (!perLocaleArrays[key]) perLocaleArrays[key] = [];\n const value = childSplit[key];\n if (value !== undefined) perLocaleArrays[key].push(value);\n }\n });\n\n const result: SplitResult = {};\n if (commonArray.length > 0)\n result.common = commonArray as unknown as ContentNode;\n for (const key of Object.keys(perLocaleArrays)) {\n // @ts-ignore dynamic locale key\n result[key] = perLocaleArrays[key] as unknown as ContentNode;\n }\n return result;\n }\n\n // Objects (non-typed): recursively split properties\n if (isObject(node) && !hasNodeType(node)) {\n let accumulated: SplitResult = {};\n\n for (const key of Object.keys(node)) {\n const childSplit = splitNode((node as any)[key] as ContentNode);\n\n // Assign property into common\n if (childSplit.common !== undefined) {\n accumulated = mergeSplitResults(accumulated, {\n common: { [key]: childSplit.common } as unknown as ContentNode,\n });\n }\n\n // Assign property into each locale bucket\n for (const locale of Object.keys(childSplit)) {\n if (locale === 'common') continue;\n accumulated = mergeSplitResults(accumulated, {\n // @ts-ignore dynamic locale key\n [locale]: { [key]: childSplit[locale] } as unknown as ContentNode,\n });\n }\n }\n\n return accumulated;\n }\n\n // Primitives or typed nodes (non-translation): entirely common\n return { common: node } as SplitResult;\n};\n\nexport const getSplittedContent = (\n content: ContentNode\n): SplittedContentOutput => {\n const split = splitNode(content);\n\n // Build final output with only defined sections\n const output: Record<string, ContentNode> = {};\n if (split.common !== undefined) {\n output.common = split.common;\n }\n for (const key of Object.keys(split)) {\n if (key === 'common') continue;\n const value = split[key] as ContentNode | undefined;\n if (value !== undefined) {\n output[key] = value;\n }\n }\n\n return output as unknown as SplittedContentOutput;\n};\n\n/**\n * Splits the `content` field of a Dictionary into \"common\" and per-locale buckets.\n *\n * Given a dictionary like:\n * ```js\n * {\n * key: \"my-key\",\n * content: {\n * commonContent: \"common content\",\n * multilingualContent: t({\n * en: \"english content\",\n * fr: \"french content\",\n * de: \"german content\",\n * }),\n * },\n * }\n * ```\n *\n * It produces:\n * ```js\n * {\n * common: { commonContent: \"common content\" },\n * en: { multilingualContent: \"english content\" },\n * fr: { multilingualContent: \"french content\" },\n * de: { multilingualContent: \"german content\" },\n * }\n * ```\n *\n * @param dictionary - The input dictionary object with possible multilingual or common content.\n * @returns An object mapping \"common\" and each locale to their corresponding content subtrees.\n */\nexport const getSplittedDictionaryContent = (\n dictionary: Dictionary\n): SplittedContentOutput<Dictionary['content']> =>\n getSplittedContent(dictionary.content);\n"],"mappings":"iJAeA,MAAM,EAAY,GAChB,OAAO,GAAU,YAAY,GAAkB,CAAC,MAAM,QAAQ,EAAM,CAEhE,EAAe,GACnB,EAAS,EAAM,EAAI,OAAQ,EAAc,UAAa,SAElD,GACJ,EACA,IAC4B,CAC5B,GAAI,IAAM,IAAA,GAAW,OAAO,EAC5B,GAAI,IAAM,IAAA,GAAW,OAAO,EAE5B,GAAI,MAAM,QAAQ,EAAE,EAAI,MAAM,QAAQ,EAAE,CAEtC,MAAO,CAAC,GAAG,EAAG,GAAG,EAAE,CAGrB,GAAI,EAAS,EAAE,EAAI,EAAS,EAAE,EAAI,CAAC,EAAY,EAAE,EAAI,CAAC,EAAY,EAAE,CAAE,CACpE,IAAM,EAA8B,CAAE,GAAG,EAAG,CAC5C,IAAK,IAAM,KAAO,OAAO,KAAK,EAAE,CAC9B,EAAO,GAAO,EACZ,EAAO,GACN,EAA0B,GAC5B,CAEH,OAAO,EAIT,OAAO,GAGH,GACJ,EACA,IACgB,CAChB,IAAM,EAAsB,CAAE,GAAG,EAAM,CAGvC,EAAO,OAAS,EAAY,EAAK,OAAQ,EAAS,OAAO,CAGzD,IAAM,EAAa,IAAI,IAAY,CACjC,GAAG,OAAO,KAAK,EAAK,CAAC,OAAQ,GAAM,IAAM,SAAS,CAClD,GAAG,OAAO,KAAK,EAAS,CAAC,OAAQ,GAAM,IAAM,SAAS,CACvD,CAAC,CAEF,IAAK,IAAM,KAAO,EAEhB,EAAO,GAAO,EACZ,EAAK,GACL,EAAS,GACV,CAGH,OAAO,GAGH,EAAa,GAAmC,CAEpD,GAAI,EAAS,EAAK,EAAK,G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,IAAK,IAAM,KAAU,OAAO,KAAK,EAAW,CACtC,IAAW,WACf,EAAc,EAAkB,EAAa,EAE1C,GAAS,EAAG,GAAM,EAAW,GAAS,CACxC,CAAC,EAIN,OAAO,EAIT,MAAO,CAAE,OAAQ,EAAM,EAGZ,EACX,GAC0B,CAC1B,IAAM,EAAQ,EAAU,EAAQ,CAG1B,EAAsC,EAAE,CAC1C,EAAM,SAAW,IAAA,KACnB,EAAO,OAAS,EAAM,QAExB,IAAK,IAAM,KAAO,OAAO,KAAK,EAAM,CAAE,CACpC,GAAI,IAAQ,SAAU,SACtB,IAAM,EAAQ,EAAM,GAChB,IAAU,IAAA,KACZ,EAAO,GAAO,GAIlB,OAAO,GAkCI,EACX,GAEA,EAAmB,EAAW,QAAQ"}
@@ -1,32 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_deepTransformPlugins_getFilteredLocalesContent = require('./getFilteredLocalesContent.cjs');
3
- const require_deepTransformPlugins_getFilterMissingTranslationsContent = require('./getFilterMissingTranslationsContent.cjs');
4
- const require_deepTransformPlugins_getFilterTranslationsOnlyContent = require('./getFilterTranslationsOnlyContent.cjs');
5
- const require_deepTransformPlugins_getLocalizedContent = require('./getLocalizedContent.cjs');
6
- const require_deepTransformPlugins_getMaskContent = require('./getMaskContent.cjs');
7
- const require_deepTransformPlugins_getMissingLocalesContent = require('./getMissingLocalesContent.cjs');
8
- const require_deepTransformPlugins_getMultilingualDictionary = require('./getMultilingualDictionary.cjs');
9
- const require_deepTransformPlugins_getReplacedValuesContent = require('./getReplacedValuesContent.cjs');
10
- const require_deepTransformPlugins_getSplittedContent = require('./getSplittedContent.cjs');
11
- const require_deepTransformPlugins_insertContentInDictionary = require('./insertContentInDictionary.cjs');
12
-
13
- exports.buildMaskPlugin = require_deepTransformPlugins_getMaskContent.buildMaskPlugin;
14
- exports.checkMissingLocalesPlugin = require_deepTransformPlugins_getMissingLocalesContent.checkMissingLocalesPlugin;
15
- exports.filterMissingTranslationsOnlyPlugin = require_deepTransformPlugins_getFilterMissingTranslationsContent.filterMissingTranslationsOnlyPlugin;
16
- exports.filterTranslationsOnlyPlugin = require_deepTransformPlugins_getFilterTranslationsOnlyContent.filterTranslationsOnlyPlugin;
17
- exports.getFilterMissingTranslationsContent = require_deepTransformPlugins_getFilterMissingTranslationsContent.getFilterMissingTranslationsContent;
18
- exports.getFilterMissingTranslationsDictionary = require_deepTransformPlugins_getFilterMissingTranslationsContent.getFilterMissingTranslationsDictionary;
19
- exports.getFilterTranslationsOnlyContent = require_deepTransformPlugins_getFilterTranslationsOnlyContent.getFilterTranslationsOnlyContent;
20
- exports.getFilterTranslationsOnlyDictionary = require_deepTransformPlugins_getFilterTranslationsOnlyContent.getFilterTranslationsOnlyDictionary;
21
- exports.getFilteredLocalesContent = require_deepTransformPlugins_getFilteredLocalesContent.getFilteredLocalesContent;
22
- exports.getFilteredLocalesDictionary = require_deepTransformPlugins_getFilteredLocalesContent.getFilteredLocalesDictionary;
23
- exports.getLocalizedContent = require_deepTransformPlugins_getLocalizedContent.getLocalizedContent;
24
- exports.getMaskContent = require_deepTransformPlugins_getMaskContent.getMaskContent;
25
- exports.getMissingLocalesContent = require_deepTransformPlugins_getMissingLocalesContent.getMissingLocalesContent;
26
- exports.getMissingLocalesContentFromDictionary = require_deepTransformPlugins_getMissingLocalesContent.getMissingLocalesContentFromDictionary;
27
- exports.getMultilingualDictionary = require_deepTransformPlugins_getMultilingualDictionary.getMultilingualDictionary;
28
- exports.getPerLocaleDictionary = require_deepTransformPlugins_getLocalizedContent.getPerLocaleDictionary;
29
- exports.getReplacedValuesContent = require_deepTransformPlugins_getReplacedValuesContent.getReplacedValuesContent;
30
- exports.getSplittedContent = require_deepTransformPlugins_getSplittedContent.getSplittedContent;
31
- exports.getSplittedDictionaryContent = require_deepTransformPlugins_getSplittedContent.getSplittedDictionaryContent;
32
- exports.insertContentInDictionary = require_deepTransformPlugins_insertContentInDictionary.insertContentInDictionary;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getFilteredLocalesContent.cjs`),t=require(`./getFilterMissingTranslationsContent.cjs`),n=require(`./getFilterTranslationsOnlyContent.cjs`),r=require(`./getLocalizedContent.cjs`),i=require(`./getMaskContent.cjs`),a=require(`./getMissingLocalesContent.cjs`),o=require(`./getMultilingualDictionary.cjs`),s=require(`./getReplacedValuesContent.cjs`),c=require(`./getSplittedContent.cjs`),l=require(`./insertContentInDictionary.cjs`);exports.buildMaskPlugin=i.buildMaskPlugin,exports.checkMissingLocalesPlugin=a.checkMissingLocalesPlugin,exports.filterMissingTranslationsOnlyPlugin=t.filterMissingTranslationsOnlyPlugin,exports.filterTranslationsOnlyPlugin=n.filterTranslationsOnlyPlugin,exports.getFilterMissingTranslationsContent=t.getFilterMissingTranslationsContent,exports.getFilterMissingTranslationsDictionary=t.getFilterMissingTranslationsDictionary,exports.getFilterTranslationsOnlyContent=n.getFilterTranslationsOnlyContent,exports.getFilterTranslationsOnlyDictionary=n.getFilterTranslationsOnlyDictionary,exports.getFilteredLocalesContent=e.getFilteredLocalesContent,exports.getFilteredLocalesDictionary=e.getFilteredLocalesDictionary,exports.getLocalizedContent=r.getLocalizedContent,exports.getMaskContent=i.getMaskContent,exports.getMissingLocalesContent=a.getMissingLocalesContent,exports.getMissingLocalesContentFromDictionary=a.getMissingLocalesContentFromDictionary,exports.getMultilingualDictionary=o.getMultilingualDictionary,exports.getPerLocaleDictionary=r.getPerLocaleDictionary,exports.getReplacedValuesContent=s.getReplacedValuesContent,exports.getSplittedContent=c.getSplittedContent,exports.getSplittedDictionaryContent=c.getSplittedDictionaryContent,exports.insertContentInDictionary=l.insertContentInDictionary;