@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,82 +1 @@
1
- import { getStorageAttributes } from "./getStorageAttributes.mjs";
2
- import { getCondition } from "./interpreter/getCondition.mjs";
3
- import { deepTransformNode } from "./interpreter/getContent/deepTransform.mjs";
4
- import { findMatchingCondition, getEnumeration } from "./interpreter/getEnumeration.mjs";
5
- import { getDictionary } from "./interpreter/getDictionary.mjs";
6
- import { getIntlayer } from "./interpreter/getIntlayer.mjs";
7
- import { getNesting } from "./interpreter/getNesting.mjs";
8
- import { getTranslation } from "./interpreter/getTranslation.mjs";
9
- import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, translationPlugin } from "./interpreter/getContent/plugins.mjs";
10
- import { getContent } from "./interpreter/getContent/getContent.mjs";
11
- import { getHTML } from "./interpreter/getHTML.mjs";
12
- import { splitInsertionTemplate } from "./interpreter/splitAndJoinInsertion.mjs";
13
- import { getFilteredLocalesContent, getFilteredLocalesDictionary } from "./deepTransformPlugins/getFilteredLocalesContent.mjs";
14
- import { cond as condition } from "./transpiler/condition/condition.mjs";
15
- import { enu as enumeration } from "./transpiler/enumeration/enumeration.mjs";
16
- import { gender } from "./transpiler/gender/gender.mjs";
17
- import { html } from "./transpiler/html/html.mjs";
18
- import { HTML_TAGS } from "./transpiler/html/htmlTags.mjs";
19
- import { getInsertionValues } from "./transpiler/insertion/getInsertionValues.mjs";
20
- import { insert as insertion } from "./transpiler/insertion/insertion.mjs";
21
- import { parseYaml } from "./utils/parseYaml.mjs";
22
- import { getMarkdownMetadata } from "./transpiler/markdown/getMarkdownMetadata.mjs";
23
- import { md as markdown } from "./transpiler/markdown/markdown.mjs";
24
- import { nest as nesting } from "./transpiler/nesting/nesting.mjs";
25
- import { t as translation } from "./transpiler/translation/translation.mjs";
26
- import { filterMissingTranslationsOnlyPlugin, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary } from "./deepTransformPlugins/getFilterMissingTranslationsContent.mjs";
27
- import { filterTranslationsOnlyPlugin, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary } from "./deepTransformPlugins/getFilterTranslationsOnlyContent.mjs";
28
- import { getLocalizedContent, getPerLocaleDictionary } from "./deepTransformPlugins/getLocalizedContent.mjs";
29
- import { buildMaskPlugin, getMaskContent } from "./deepTransformPlugins/getMaskContent.mjs";
30
- import { checkMissingLocalesPlugin, getMissingLocalesContent, getMissingLocalesContentFromDictionary } from "./deepTransformPlugins/getMissingLocalesContent.mjs";
31
- import { getMultilingualDictionary } from "./deepTransformPlugins/getMultilingualDictionary.mjs";
32
- import { getReplacedValuesContent } from "./deepTransformPlugins/getReplacedValuesContent.mjs";
33
- import { getSplittedContent, getSplittedDictionaryContent } from "./deepTransformPlugins/getSplittedContent.mjs";
34
- import { insertContentInDictionary } from "./deepTransformPlugins/insertContentInDictionary.mjs";
35
- import { editDictionaryByKeyPath } from "./dictionaryManipulator/editDictionaryByKeyPath.mjs";
36
- import { getContentNodeByKeyPath } from "./dictionaryManipulator/getContentNodeByKeyPath.mjs";
37
- import { getDefaultNode } from "./dictionaryManipulator/getDefaultNode.mjs";
38
- import { getEmptyNode } from "./dictionaryManipulator/getEmptyNode.mjs";
39
- import { getNodeChildren } from "./dictionaryManipulator/getNodeChildren.mjs";
40
- import { isValidElement } from "./utils/isValidReactElement.mjs";
41
- import { getNodeType } from "./dictionaryManipulator/getNodeType.mjs";
42
- import { mergeDictionaries } from "./dictionaryManipulator/mergeDictionaries.mjs";
43
- import { orderDictionaries } from "./dictionaryManipulator/orderDictionaries.mjs";
44
- import { normalizeDictionaries, normalizeDictionary } from "./dictionaryManipulator/normalizeDictionary.mjs";
45
- import { removeContentNodeByKeyPath } from "./dictionaryManipulator/removeContentNodeByKeyPath.mjs";
46
- import { renameContentNodeByKeyPath } from "./dictionaryManipulator/renameContentNodeByKeyPath.mjs";
47
- import { updateNodeChildren } from "./dictionaryManipulator/updateNodeChildren.mjs";
48
- import { CachedIntl, bindIntl, createCachedIntl } from "./utils/intl.mjs";
49
- import { compact } from "./formatters/compact.mjs";
50
- import { currency } from "./formatters/currency.mjs";
51
- import { date } from "./formatters/date.mjs";
52
- import { list } from "./formatters/list.mjs";
53
- import { number } from "./formatters/number.mjs";
54
- import { percentage } from "./formatters/percentage.mjs";
55
- import { relativeTime } from "./formatters/relativeTime.mjs";
56
- import { units } from "./formatters/units.mjs";
57
- import { getCookie } from "./utils/getCookie.mjs";
58
- import { LocaleStorage, getLocaleFromStorage, setLocaleInStorage } from "./utils/localeStorage.mjs";
59
- import { localeResolver } from "./localization/localeResolver.mjs";
60
- import { localeDetector } from "./localization/localeDetector.mjs";
61
- import { getBrowserLocale, localeStorageOptions } from "./localization/getBrowserLocale.mjs";
62
- import { getHTMLTextDir } from "./localization/getHTMLTextDir.mjs";
63
- import { getLocale } from "./localization/getLocale.mjs";
64
- import { checkIsURLAbsolute } from "./utils/checkIsURLAbsolute.mjs";
65
- import { getLocaleFromPath } from "./localization/getLocaleFromPath.mjs";
66
- import { getLocaleLang } from "./localization/getLocaleLang.mjs";
67
- import { getLocaleName } from "./localization/getLocaleName.mjs";
68
- import { getPathWithoutLocale } from "./localization/getPathWithoutLocale.mjs";
69
- import { getPrefix } from "./localization/getPrefix.mjs";
70
- import { getCanonicalPath, getInternalPath, getLocalizedPath, getRewritePath, getRewriteRules } from "./localization/rewriteUtils.mjs";
71
- import { getLocalizedUrl } from "./localization/getLocalizedUrl.mjs";
72
- import { getMultilingualUrls } from "./localization/getMultilingualUrls.mjs";
73
- import { localeFlatMap, localeMap, localeRecord } from "./localization/localeMapper.mjs";
74
- import { validatePrefix } from "./localization/validatePrefix.mjs";
75
- import { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, Priority, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex } from "./markdown/constants.mjs";
76
- import { allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, cx, get, inlineRegex, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, qualifies, renderNothing, sanitizer, simpleInlineRegex, slugify, some, startsWith, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote } from "./markdown/utils.mjs";
77
- import { parserFor } from "./markdown/parser.mjs";
78
- import { createRenderer, renderFor } from "./markdown/renderer.mjs";
79
- import { compile, compileWithOptions, createCompiler } from "./markdown/compiler.mjs";
80
- import { isSameKeyPath } from "./utils/isSameKeyPath.mjs";
81
-
82
- export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, LocaleStorage, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, Priority, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, compile, compileWithOptions, condition as cond, conditionPlugin, createCachedIntl, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, get, getBrowserLocale, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTML, getHTMLTextDir, getInsertionValues, getInternalPath, getIntlayer, getLocale, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, html, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseYaml, parserFor, percentage, qualifies, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderNothing, sanitizer, setLocaleInStorage, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, translation as t, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validatePrefix };
1
+ import{getStorageAttributes as ee}from"./getStorageAttributes.mjs";import{getCondition as te}from"./interpreter/getCondition.mjs";import{deepTransformNode as ne}from"./interpreter/getContent/deepTransform.mjs";import{findMatchingCondition as e,getEnumeration as t}from"./interpreter/getEnumeration.mjs";import{getDictionary as n}from"./interpreter/getDictionary.mjs";import{getIntlayer as r}from"./interpreter/getIntlayer.mjs";import{getNesting as i}from"./interpreter/getNesting.mjs";import{getTranslation as a}from"./interpreter/getTranslation.mjs";import{conditionPlugin as o,enumerationPlugin as s,filePlugin as c,genderPlugin as l,insertionPlugin as u,nestedPlugin as d,translationPlugin as f}from"./interpreter/getContent/plugins.mjs";import{getContent as p}from"./interpreter/getContent/getContent.mjs";import{getHTML as m}from"./interpreter/getHTML.mjs";import{splitInsertionTemplate as h}from"./interpreter/splitAndJoinInsertion.mjs";import{getFilteredLocalesContent as g,getFilteredLocalesDictionary as _}from"./deepTransformPlugins/getFilteredLocalesContent.mjs";import{cond as v}from"./transpiler/condition/condition.mjs";import{enu as y}from"./transpiler/enumeration/enumeration.mjs";import{gender as b}from"./transpiler/gender/gender.mjs";import{html as x}from"./transpiler/html/html.mjs";import{HTML_TAGS as S}from"./transpiler/html/htmlTags.mjs";import{getInsertionValues as C}from"./transpiler/insertion/getInsertionValues.mjs";import{insert as w}from"./transpiler/insertion/insertion.mjs";import{parseYaml as T}from"./utils/parseYaml.mjs";import{getMarkdownMetadata as E}from"./transpiler/markdown/getMarkdownMetadata.mjs";import{md as D}from"./transpiler/markdown/markdown.mjs";import{nest as O}from"./transpiler/nesting/nesting.mjs";import{t as k}from"./transpiler/translation/translation.mjs";import{filterMissingTranslationsOnlyPlugin as A,getFilterMissingTranslationsContent as j,getFilterMissingTranslationsDictionary as M}from"./deepTransformPlugins/getFilterMissingTranslationsContent.mjs";import{filterTranslationsOnlyPlugin as N,getFilterTranslationsOnlyContent as P,getFilterTranslationsOnlyDictionary as F}from"./deepTransformPlugins/getFilterTranslationsOnlyContent.mjs";import{getLocalizedContent as I,getPerLocaleDictionary as L}from"./deepTransformPlugins/getLocalizedContent.mjs";import{buildMaskPlugin as R,getMaskContent as z}from"./deepTransformPlugins/getMaskContent.mjs";import{checkMissingLocalesPlugin as B,getMissingLocalesContent as V,getMissingLocalesContentFromDictionary as H}from"./deepTransformPlugins/getMissingLocalesContent.mjs";import{getMultilingualDictionary as U}from"./deepTransformPlugins/getMultilingualDictionary.mjs";import{getReplacedValuesContent as W}from"./deepTransformPlugins/getReplacedValuesContent.mjs";import{getSplittedContent as G,getSplittedDictionaryContent as K}from"./deepTransformPlugins/getSplittedContent.mjs";import{insertContentInDictionary as q}from"./deepTransformPlugins/insertContentInDictionary.mjs";import{editDictionaryByKeyPath as J}from"./dictionaryManipulator/editDictionaryByKeyPath.mjs";import{getContentNodeByKeyPath as Y}from"./dictionaryManipulator/getContentNodeByKeyPath.mjs";import{getDefaultNode as X}from"./dictionaryManipulator/getDefaultNode.mjs";import{getEmptyNode as Z}from"./dictionaryManipulator/getEmptyNode.mjs";import{getNodeChildren as re}from"./dictionaryManipulator/getNodeChildren.mjs";import{isValidElement as ie}from"./utils/isValidReactElement.mjs";import{getNodeType as ae}from"./dictionaryManipulator/getNodeType.mjs";import{mergeDictionaries as oe}from"./dictionaryManipulator/mergeDictionaries.mjs";import{orderDictionaries as se}from"./dictionaryManipulator/orderDictionaries.mjs";import{normalizeDictionaries as ce,normalizeDictionary as le}from"./dictionaryManipulator/normalizeDictionary.mjs";import{removeContentNodeByKeyPath as ue}from"./dictionaryManipulator/removeContentNodeByKeyPath.mjs";import{renameContentNodeByKeyPath as de}from"./dictionaryManipulator/renameContentNodeByKeyPath.mjs";import{updateNodeChildren as fe}from"./dictionaryManipulator/updateNodeChildren.mjs";import{CachedIntl as Q,bindIntl as pe,createCachedIntl as me}from"./utils/intl.mjs";import{compact as he}from"./formatters/compact.mjs";import{currency as ge}from"./formatters/currency.mjs";import{date as _e}from"./formatters/date.mjs";import{list as ve}from"./formatters/list.mjs";import{number as ye}from"./formatters/number.mjs";import{percentage as be}from"./formatters/percentage.mjs";import{relativeTime as xe}from"./formatters/relativeTime.mjs";import{units as Se}from"./formatters/units.mjs";import{getCookie as Ce}from"./utils/getCookie.mjs";import{LocaleStorage as we,getLocaleFromStorage as Te,setLocaleInStorage as Ee}from"./utils/localeStorage.mjs";import{localeResolver as De}from"./localization/localeResolver.mjs";import{localeDetector as Oe}from"./localization/localeDetector.mjs";import{getBrowserLocale as ke,localeStorageOptions as Ae}from"./localization/getBrowserLocale.mjs";import{getHTMLTextDir as je}from"./localization/getHTMLTextDir.mjs";import{getLocale as Me}from"./localization/getLocale.mjs";import{checkIsURLAbsolute as Ne}from"./utils/checkIsURLAbsolute.mjs";import{getLocaleFromPath as Pe}from"./localization/getLocaleFromPath.mjs";import{getLocaleLang as Fe}from"./localization/getLocaleLang.mjs";import{getLocaleName as Ie}from"./localization/getLocaleName.mjs";import{getPathWithoutLocale as Le}from"./localization/getPathWithoutLocale.mjs";import{getPrefix as Re}from"./localization/getPrefix.mjs";import{getCanonicalPath as ze,getInternalPath as Be,getLocalizedPath as Ve,getRewritePath as He,getRewriteRules as Ue}from"./localization/rewriteUtils.mjs";import{getLocalizedUrl as We}from"./localization/getLocalizedUrl.mjs";import{getMultilingualUrls as Ge}from"./localization/getMultilingualUrls.mjs";import{localeFlatMap as Ke,localeMap as qe,localeRecord as Je}from"./localization/localeMapper.mjs";import{validatePrefix as Ye}from"./localization/validatePrefix.mjs";import{ATTRIBUTES_TO_SANITIZE as Xe,ATTRIBUTE_TO_NODE_PROP_MAP as Ze,ATTR_EXTRACTOR_R as Qe,BLOCKQUOTE_ALERT_R as $e,BLOCKQUOTE_R as et,BLOCKQUOTE_TRIM_LEFT_MULTILINE_R as tt,BLOCK_END_R as nt,BREAK_LINE_R as rt,BREAK_THEMATIC_R as it,CAPTURE_LETTER_AFTER_HYPHEN as at,CODE_BLOCK_FENCED_R as ot,CODE_BLOCK_R as st,CODE_INLINE_R as ct,CONSECUTIVE_NEWLINE_R as lt,CR_NEWLINE_R as ut,CUSTOM_COMPONENT_R as dt,DO_NOT_PROCESS_HTML_ELEMENTS as ft,DURATION_DELAY_TRIGGER as $,FOOTNOTE_R as pt,FOOTNOTE_REFERENCE_R as mt,FORMFEED_R as ht,FRONT_MATTER_R as gt,GFM_TASK_R as _t,HEADING_ATX_COMPLIANT_R as vt,HEADING_R as yt,HEADING_SETEXT_R as bt,HTML_BLOCK_ELEMENT_R as xt,HTML_CHAR_CODE_R as St,HTML_COMMENT_R as Ct,HTML_CUSTOM_ATTR_R as wt,HTML_LEFT_TRIM_AMOUNT_R as Tt,HTML_SELF_CLOSING_ELEMENT_R as Et,INLINE_SKIP_R as Dt,INTERPOLATION_R as Ot,LINK_AUTOLINK_BARE_URL_R as kt,LINK_AUTOLINK_R as At,LIST_LOOKBEHIND_R as jt,LOOKAHEAD as Mt,NAMED_CODES_TO_UNICODE as Nt,NP_TABLE_R as Pt,ORDERED as Ft,ORDERED_LIST_BULLET as It,ORDERED_LIST_ITEM_PREFIX as Lt,ORDERED_LIST_ITEM_PREFIX_R as Rt,ORDERED_LIST_ITEM_R as zt,ORDERED_LIST_R as Bt,PARAGRAPH_R as Vt,Priority as Ht,REFERENCE_IMAGE_OR_LINK as Ut,REFERENCE_IMAGE_R as Wt,REFERENCE_LINK_R as Gt,RuleType as Kt,SHORTCODE_R as qt,SHOULD_RENDER_AS_BLOCK_R as Jt,TABLE_CENTER_ALIGN as Yt,TABLE_LEFT_ALIGN as Xt,TABLE_RIGHT_ALIGN as Zt,TABLE_TRIM_PIPES as Qt,TAB_R as $t,TEXT_BOLD_R as en,TEXT_EMPHASIZED_R as tn,TEXT_ESCAPED_R as nn,TEXT_MARKED_R as rn,TEXT_PLAIN_R as an,TEXT_STRIKETHROUGHED_R as on,TRIM_STARTING_NEWLINES as sn,UNESCAPE_R as cn,UNORDERED as ln,UNORDERED_LIST_BULLET as un,UNORDERED_LIST_ITEM_PREFIX as dn,UNORDERED_LIST_ITEM_PREFIX_R as fn,UNORDERED_LIST_ITEM_R as pn,UNORDERED_LIST_R as mn,generateListItemPrefix as hn,generateListItemPrefixRegex as gn,generateListItemRegex as _n,generateListRegex as vn}from"./markdown/constants.mjs";import{allowInline as yn,anyScopeRegex as bn,attributeValueToNodePropValue as xn,blockRegex as Sn,captureNothing as Cn,cx as wn,get as Tn,inlineRegex as En,normalizeAttributeKey as Dn,normalizeWhitespace as On,parseBlock as kn,parseCaptureInline as An,parseInline as jn,parseSimpleInline as Mn,parseStyleAttribute as Nn,parseTableAlign as Pn,parseTableAlignCapture as Fn,parseTableCells as In,parseTableRow as Ln,qualifies as Rn,renderNothing as zn,sanitizer as Bn,simpleInlineRegex as Vn,slugify as Hn,some as Un,startsWith as Wn,trimEnd as Gn,trimLeadingWhitespaceOutsideFences as Kn,unescapeString as qn,unquote as Jn}from"./markdown/utils.mjs";import{parserFor as Yn}from"./markdown/parser.mjs";import{createRenderer as Xn,renderFor as Zn}from"./markdown/renderer.mjs";import{compile as Qn,compileWithOptions as $n,createCompiler as er}from"./markdown/compiler.mjs";import{icuToIntlayerFormatter as tr,intlayerToICUFormatter as nr}from"./messageFormat/ICU.mjs";import{i18nextToIntlayerFormatter as rr,intlayerToI18nextFormatter as ir}from"./messageFormat/i18next.mjs";import{intlayerToVueI18nFormatter as ar,vueI18nToIntlayerFormatter as or}from"./messageFormat/vue-i18n.mjs";import{isSameKeyPath as sr}from"./utils/isSameKeyPath.mjs";export{Xe as ATTRIBUTES_TO_SANITIZE,Ze as ATTRIBUTE_TO_NODE_PROP_MAP,Qe as ATTR_EXTRACTOR_R,$e as BLOCKQUOTE_ALERT_R,et as BLOCKQUOTE_R,tt as BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,nt as BLOCK_END_R,rt as BREAK_LINE_R,it as BREAK_THEMATIC_R,at as CAPTURE_LETTER_AFTER_HYPHEN,ot as CODE_BLOCK_FENCED_R,st as CODE_BLOCK_R,ct as CODE_INLINE_R,lt as CONSECUTIVE_NEWLINE_R,ut as CR_NEWLINE_R,dt as CUSTOM_COMPONENT_R,Q as CachedIntl,Q as Intl,ft as DO_NOT_PROCESS_HTML_ELEMENTS,$ as DURATION_DELAY_TRIGGER,pt as FOOTNOTE_R,mt as FOOTNOTE_REFERENCE_R,ht as FORMFEED_R,gt as FRONT_MATTER_R,_t as GFM_TASK_R,vt as HEADING_ATX_COMPLIANT_R,yt as HEADING_R,bt as HEADING_SETEXT_R,xt as HTML_BLOCK_ELEMENT_R,St as HTML_CHAR_CODE_R,Ct as HTML_COMMENT_R,wt as HTML_CUSTOM_ATTR_R,Tt as HTML_LEFT_TRIM_AMOUNT_R,Et as HTML_SELF_CLOSING_ELEMENT_R,S as HTML_TAGS,Dt as INLINE_SKIP_R,Ot as INTERPOLATION_R,kt as LINK_AUTOLINK_BARE_URL_R,At as LINK_AUTOLINK_R,jt as LIST_LOOKBEHIND_R,Mt as LOOKAHEAD,we as LocaleStorage,Nt as NAMED_CODES_TO_UNICODE,Pt as NP_TABLE_R,Ft as ORDERED,It as ORDERED_LIST_BULLET,Lt as ORDERED_LIST_ITEM_PREFIX,Rt as ORDERED_LIST_ITEM_PREFIX_R,zt as ORDERED_LIST_ITEM_R,Bt as ORDERED_LIST_R,Vt as PARAGRAPH_R,Ht as Priority,Ut as REFERENCE_IMAGE_OR_LINK,Wt as REFERENCE_IMAGE_R,Gt as REFERENCE_LINK_R,Kt as RuleType,qt as SHORTCODE_R,Jt as SHOULD_RENDER_AS_BLOCK_R,Yt as TABLE_CENTER_ALIGN,Xt as TABLE_LEFT_ALIGN,Zt as TABLE_RIGHT_ALIGN,Qt as TABLE_TRIM_PIPES,$t as TAB_R,en as TEXT_BOLD_R,tn as TEXT_EMPHASIZED_R,nn as TEXT_ESCAPED_R,rn as TEXT_MARKED_R,an as TEXT_PLAIN_R,on as TEXT_STRIKETHROUGHED_R,sn as TRIM_STARTING_NEWLINES,cn as UNESCAPE_R,ln as UNORDERED,un as UNORDERED_LIST_BULLET,dn as UNORDERED_LIST_ITEM_PREFIX,fn as UNORDERED_LIST_ITEM_PREFIX_R,pn as UNORDERED_LIST_ITEM_R,mn as UNORDERED_LIST_R,yn as allowInline,bn as anyScopeRegex,xn as attributeValueToNodePropValue,pe as bindIntl,Sn as blockRegex,R as buildMaskPlugin,Cn as captureNothing,Ne as checkIsURLAbsolute,B as checkMissingLocalesPlugin,he as compact,Qn as compile,$n as compileWithOptions,v as cond,o as conditionPlugin,me as createCachedIntl,er as createCompiler,Xn as createRenderer,ge as currency,wn as cx,_e as date,ne as deepTransformNode,J as editDictionaryByKeyPath,y as enu,s as enumerationPlugin,c as filePlugin,A as filterMissingTranslationsOnlyPlugin,N as filterTranslationsOnlyPlugin,e as findMatchingCondition,b as gender,l as genderPlugin,hn as generateListItemPrefix,gn as generateListItemPrefixRegex,_n as generateListItemRegex,vn as generateListRegex,Tn as get,ke as getBrowserLocale,ze as getCanonicalPath,te as getCondition,p as getContent,Y as getContentNodeByKeyPath,Ce as getCookie,X as getDefaultNode,n as getDictionary,Z as getEmptyNode,t as getEnumeration,j as getFilterMissingTranslationsContent,M as getFilterMissingTranslationsDictionary,P as getFilterTranslationsOnlyContent,F as getFilterTranslationsOnlyDictionary,g as getFilteredLocalesContent,_ as getFilteredLocalesDictionary,m as getHTML,je as getHTMLTextDir,C as getInsertionValues,Be as getInternalPath,r as getIntlayer,Me as getLocale,Pe as getLocaleFromPath,Te as getLocaleFromStorage,Fe as getLocaleLang,Ie as getLocaleName,I as getLocalizedContent,Ve as getLocalizedPath,We as getLocalizedUrl,E as getMarkdownMetadata,z as getMaskContent,V as getMissingLocalesContent,H as getMissingLocalesContentFromDictionary,U as getMultilingualDictionary,Ge as getMultilingualUrls,i as getNesting,re as getNodeChildren,ae as getNodeType,Le as getPathWithoutLocale,L as getPerLocaleDictionary,Re as getPrefix,W as getReplacedValuesContent,He as getRewritePath,Ue as getRewriteRules,G as getSplittedContent,K as getSplittedDictionaryContent,ee as getStorageAttributes,a as getTranslation,x as html,rr as i18nextToIntlayerFormatter,tr as icuToIntlayerFormatter,En as inlineRegex,w as insert,q as insertContentInDictionary,u as insertionPlugin,ir as intlayerToI18nextFormatter,nr as intlayerToICUFormatter,ar as intlayerToVueI18nFormatter,sr as isSameKeyPath,ie as isValidElement,ve as list,Oe as localeDetector,Ke as localeFlatMap,qe as localeMap,Je as localeRecord,De as localeResolver,Ae as localeStorageOptions,D as md,oe as mergeDictionaries,O as nest,d as nestedPlugin,Dn as normalizeAttributeKey,ce as normalizeDictionaries,le as normalizeDictionary,On as normalizeWhitespace,ye as number,se as orderDictionaries,kn as parseBlock,An as parseCaptureInline,jn as parseInline,Mn as parseSimpleInline,Nn as parseStyleAttribute,Pn as parseTableAlign,Fn as parseTableAlignCapture,In as parseTableCells,Ln as parseTableRow,T as parseYaml,Yn as parserFor,be as percentage,Rn as qualifies,xe as relativeTime,ue as removeContentNodeByKeyPath,de as renameContentNodeByKeyPath,Zn as renderFor,zn as renderNothing,Bn as sanitizer,Ee as setLocaleInStorage,Vn as simpleInlineRegex,Hn as slugify,Un as some,h as splitInsertionTemplate,Wn as startsWith,k as t,f as translationPlugin,Gn as trimEnd,Kn as trimLeadingWhitespaceOutsideFences,qn as unescapeString,Se as units,Jn as unquote,fe as updateNodeChildren,Ye as validatePrefix,or as vueI18nToIntlayerFormatter};
@@ -1,26 +1,2 @@
1
- //#region src/interpreter/getCondition.ts
2
- /**
3
- * Picks content based on a boolean condition.
4
- *
5
- * @param conditionContent - A map with 'true', 'false', and optionally 'fallback' keys.
6
- * @param state - The boolean state to match.
7
- * @returns The matching content.
8
- *
9
- * @example
10
- * ```ts
11
- * const content = getCondition({
12
- * 'true': 'The condition is validated',
13
- * 'false': 'The condition is not validated',
14
- * }, true);
15
- * // 'The condition is validated'
16
- * ```
17
- */
18
- const getCondition = (conditionContent, state) => {
19
- const stateList = Object.keys(conditionContent);
20
- const fallbackState = stateList[stateList.length - 1];
21
- return conditionContent[`${state}`] ?? conditionContent.fallback ?? conditionContent[fallbackState];
22
- };
23
-
24
- //#endregion
25
- export { getCondition };
1
+ const e=(e,t)=>{let n=Object.keys(e),r=n[n.length-1];return e[`${t}`]??e.fallback??e[r]};export{e as getCondition};
26
2
  //# sourceMappingURL=getCondition.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getCondition.mjs","names":[],"sources":["../../../src/interpreter/getCondition.ts"],"sourcesContent":["import type { ConditionContentStates } from '../transpiler';\n\n/**\n * Picks content based on a boolean condition.\n *\n * @param conditionContent - A map with 'true', 'false', and optionally 'fallback' keys.\n * @param state - The boolean state to match.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getCondition({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * }, true);\n * // 'The condition is validated'\n * ```\n */\nexport const getCondition = <Content>(\n conditionContent: ConditionContentStates<Content>,\n state?: boolean\n): Content => {\n const stateList = Object.keys(conditionContent);\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof conditionContent;\n\n // Default or error handling if no keys match\n return (\n conditionContent[`${state}` as keyof typeof conditionContent] ??\n conditionContent.fallback ??\n (conditionContent[fallbackState] as Content)\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAa,gBACX,kBACA,UACY;CACZ,MAAM,YAAY,OAAO,KAAK,iBAAiB;CAC/C,MAAM,gBAAgB,UACpB,UAAU,SAAS;AAIrB,QACE,iBAAiB,GAAG,YACpB,iBAAiB,YAChB,iBAAiB"}
1
+ {"version":3,"file":"getCondition.mjs","names":[],"sources":["../../../src/interpreter/getCondition.ts"],"sourcesContent":["import type { ConditionContentStates } from '../transpiler';\n\n/**\n * Picks content based on a boolean condition.\n *\n * @param conditionContent - A map with 'true', 'false', and optionally 'fallback' keys.\n * @param state - The boolean state to match.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getCondition({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * }, true);\n * // 'The condition is validated'\n * ```\n */\nexport const getCondition = <Content>(\n conditionContent: ConditionContentStates<Content>,\n state?: boolean\n): Content => {\n const stateList = Object.keys(conditionContent);\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof conditionContent;\n\n // Default or error handling if no keys match\n return (\n conditionContent[`${state}` as keyof typeof conditionContent] ??\n conditionContent.fallback ??\n (conditionContent[fallbackState] as Content)\n );\n};\n"],"mappings":"AAkBA,MAAa,GACX,EACA,IACY,CACZ,IAAM,EAAY,OAAO,KAAK,EAAiB,CACzC,EAAgB,EACpB,EAAU,OAAS,GAIrB,OACE,EAAiB,GAAG,MACpB,EAAiB,UAChB,EAAiB"}
@@ -1,40 +1,2 @@
1
- import { NodeType } from "@intlayer/types";
2
-
3
- //#region src/interpreter/getContent/deepTransform.ts
4
- /**
5
- * Recursively traverses a node (object/array/primitive).
6
- * Applies the *first* plugin that can transform a node, then stops descending further.
7
- * If no plugin transforms it, it recurses into its children.
8
- */
9
- const deepTransformNode = (node, props) => {
10
- for (const plugin of props.plugins ?? []) if (plugin.canHandle(node)) return plugin.transform(node, props, (node, props) => deepTransformNode(node, props));
11
- if (node === null || typeof node !== "object") return node;
12
- if (node.$$typeof !== void 0 || node.__v_isVNode !== void 0 || node._isVNode !== void 0 || node.isJSX !== void 0 || typeof node === "function") return node;
13
- if (Array.isArray(node)) return node.map((child, index) => {
14
- return deepTransformNode(child, {
15
- ...props,
16
- children: child,
17
- keyPath: [...props.keyPath, {
18
- type: NodeType.Array,
19
- key: index
20
- }]
21
- });
22
- });
23
- const result = {};
24
- for (const key in node) {
25
- const childProps = {
26
- ...props,
27
- children: node[key],
28
- keyPath: [...props.keyPath, {
29
- type: NodeType.Object,
30
- key
31
- }]
32
- };
33
- result[key] = deepTransformNode(node[key], childProps);
34
- }
35
- return result;
36
- };
37
-
38
- //#endregion
39
- export { deepTransformNode };
1
+ import{NodeType as e}from"@intlayer/types";const t=(n,r)=>{for(let e of r.plugins??[])if(e.canHandle(n))return e.transform(n,r,(e,n)=>t(e,n));if(typeof n!=`object`||!n||n.$$typeof!==void 0||n.__v_isVNode!==void 0||n._isVNode!==void 0||n.isJSX!==void 0||typeof n==`function`)return n;if(Array.isArray(n))return n.map((n,i)=>t(n,{...r,children:n,keyPath:[...r.keyPath,{type:e.Array,key:i}]}));let i={};for(let a in n){let o={...r,children:n[a],keyPath:[...r.keyPath,{type:e.Object,key:a}]};i[a]=t(n[a],o)}return i};export{t as deepTransformNode};
40
2
  //# sourceMappingURL=deepTransform.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepTransform.mjs","names":[],"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '@intlayer/types';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's a framework-specific virtual node or already a transformed Proxy,\n // return it directly to avoid re-transforming its internal properties.\n if (\n (node as any).$$typeof !== undefined ||\n (node as any).__v_isVNode !== undefined ||\n (node as any)._isVNode !== undefined ||\n (node as any).isJSX !== undefined ||\n typeof node === 'function' // Proxies for html/markdown are functions\n ) {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n children: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":";;;;;;;;AAQA,MAAa,qBAAqB,MAAW,UAA0B;AAErE,MAAK,MAAM,UAAU,MAAM,WAAW,EAAE,CACtC,KAAI,OAAO,UAAU,KAAK,CAExB,QAAO,OAAO,UAAU,MAAM,QAAQ,MAAW,UAC/C,kBAAkB,MAAM,MAAM,CAC/B;AAKL,KAAI,SAAS,QAAQ,OAAO,SAAS,SACnC,QAAO;AAKT,KACG,KAAa,aAAa,UAC1B,KAAa,gBAAgB,UAC7B,KAAa,aAAa,UAC1B,KAAa,UAAU,UACxB,OAAO,SAAS,WAEhB,QAAO;AAIT,KAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,KAAK,KAAK,OAAO,UAAU;AAShC,SAAO,kBAAkB,OARN;GACjB,GAAG;GACH,UAAU;GACV,SAAS,CACP,GAAG,MAAM,SACT;IAAE,MAAM,SAAS;IAAO,KAAK;IAAO,CACrC;GACF,CAC0C;GAC3C;CAIJ,MAAM,SAA8B,EAAE;AACtC,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,aAAa;GACjB,GAAG;GACH,UAAU,KAAK;GACf,SAAS,CAAC,GAAG,MAAM,SAAS;IAAE,MAAM,SAAS;IAAQ;IAAK,CAAY;GACvE;AACD,SAAO,OAAO,kBAAkB,KAAK,MAAM,WAAW;;AAGxD,QAAO"}
1
+ {"version":3,"file":"deepTransform.mjs","names":[],"sources":["../../../../src/interpreter/getContent/deepTransform.ts"],"sourcesContent":["import { type KeyPath, NodeType } from '@intlayer/types';\nimport type { NodeProps } from './plugins';\n\n/**\n * Recursively traverses a node (object/array/primitive).\n * Applies the *first* plugin that can transform a node, then stops descending further.\n * If no plugin transforms it, it recurses into its children.\n */\nexport const deepTransformNode = (node: any, props: NodeProps): any => {\n // Otherwise, if it's an object, check if any plugin can handle it:\n for (const plugin of props.plugins ?? []) {\n if (plugin.canHandle(node)) {\n // Return the transformed node => do NOT recurse further\n return plugin.transform(node, props, (node: any, props: any) =>\n deepTransformNode(node, props)\n );\n }\n }\n\n // If it's null/undefined or not an object, just return it directly:\n if (node === null || typeof node !== 'object') {\n return node;\n }\n\n // If it's a framework-specific virtual node or already a transformed Proxy,\n // return it directly to avoid re-transforming its internal properties.\n if (\n (node as any).$$typeof !== undefined ||\n (node as any).__v_isVNode !== undefined ||\n (node as any)._isVNode !== undefined ||\n (node as any).isJSX !== undefined ||\n typeof node === 'function' // Proxies for html/markdown are functions\n ) {\n return node;\n }\n\n // If it's an array, transform each element:\n if (Array.isArray(node)) {\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Array, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n // If no plugin transforms it, we keep traversing its properties.\n const result: Record<string, any> = {};\n for (const key in node) {\n const childProps = {\n ...props,\n children: node[key],\n keyPath: [...props.keyPath, { type: NodeType.Object, key } as KeyPath],\n };\n result[key] = deepTransformNode(node[key], childProps);\n }\n\n return result;\n};\n"],"mappings":"2CAQA,MAAa,GAAqB,EAAW,IAA0B,CAErE,IAAK,IAAM,KAAU,EAAM,SAAW,EAAE,CACtC,GAAI,EAAO,UAAU,EAAK,CAExB,OAAO,EAAO,UAAU,EAAM,GAAQ,EAAW,IAC/C,EAAkB,EAAM,EAAM,CAC/B,CAWL,GANqB,OAAO,GAAS,WAAjC,GAOD,EAAa,WAAa,IAAA,IAC1B,EAAa,cAAgB,IAAA,IAC7B,EAAa,WAAa,IAAA,IAC1B,EAAa,QAAU,IAAA,IACxB,OAAO,GAAS,WAEhB,OAAO,EAIT,GAAI,MAAM,QAAQ,EAAK,CACrB,OAAO,EAAK,KAAK,EAAO,IASf,EAAkB,EARN,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,MAAO,IAAK,EAAO,CACrC,CACF,CAC0C,CAC3C,CAIJ,IAAM,EAA8B,EAAE,CACtC,IAAK,IAAM,KAAO,EAAM,CACtB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAK,GACf,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAS,OAAQ,MAAK,CAAY,CACvE,CACD,EAAO,GAAO,EAAkB,EAAK,GAAM,EAAW,CAGxD,OAAO"}
@@ -1,32 +1,2 @@
1
- import { deepTransformNode } from "./deepTransform.mjs";
2
- import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, translationPlugin } from "./plugins.mjs";
3
- import configuration from "@intlayer/config/built";
4
-
5
- //#region src/interpreter/getContent/getContent.ts
6
- /**
7
- * Transforms a node in a single pass, applying each plugin as needed.
8
- *
9
- * @param node The node to transform.
10
- * @param locale The locale to use if your transformers need it (e.g. for translations).
11
- */
12
- const getContent = (node, nodeProps, locale, fallback) => {
13
- const defaultLocale = configuration?.internationalization?.defaultLocale;
14
- const plugins = [
15
- translationPlugin(locale ?? defaultLocale, fallback ? defaultLocale : void 0),
16
- enumerationPlugin,
17
- conditionPlugin,
18
- nestedPlugin(locale ?? defaultLocale),
19
- filePlugin,
20
- insertionPlugin,
21
- genderPlugin,
22
- ...nodeProps.plugins ?? []
23
- ];
24
- return deepTransformNode(node, {
25
- ...nodeProps,
26
- plugins
27
- });
28
- };
29
-
30
- //#endregion
31
- export { getContent };
1
+ import{deepTransformNode as e}from"./deepTransform.mjs";import{conditionPlugin as t,enumerationPlugin as n,filePlugin as r,genderPlugin as i,insertionPlugin as a,nestedPlugin as o,translationPlugin as s}from"./plugins.mjs";import c from"@intlayer/config/built";const l=(l,u,d,f)=>{let p=c?.internationalization?.defaultLocale,m=[s(d??p,f?p:void 0),n,t,o(d??p),r,a,i,...u.plugins??[]];return e(l,{...u,plugins:m})};export{l as getContent};
32
2
  //# sourceMappingURL=getContent.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getContent.mjs","names":[],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {\n ContentNode,\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n locale?: L,\n fallback?: boolean\n) => {\n const defaultLocale = configuration?.internationalization?.defaultLocale;\n\n const plugins: Plugins[] = [\n translationPlugin(\n locale ?? defaultLocale,\n fallback ? defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? defaultLocale),\n filePlugin,\n insertionPlugin,\n genderPlugin,\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n};\n"],"mappings":";;;;;;;;;;;AA2BA,MAAa,cAIX,MACA,WACA,QACA,aACG;CACH,MAAM,gBAAgB,eAAe,sBAAsB;CAE3D,MAAM,UAAqB;EACzB,kBACE,UAAU,eACV,WAAW,gBAAgB,OAC5B;EACD;EACA;EACA,aAAa,UAAU,cAAc;EACrC;EACA;EACA;EACA,GAAI,UAAU,WAAW,EAAE;EAC5B;AAED,QAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;EACD,CAAC"}
1
+ {"version":3,"file":"getContent.mjs","names":[],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type {\n ContentNode,\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n locale?: L,\n fallback?: boolean\n) => {\n const defaultLocale = configuration?.internationalization?.defaultLocale;\n\n const plugins: Plugins[] = [\n translationPlugin(\n locale ?? defaultLocale,\n fallback ? defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? defaultLocale),\n filePlugin,\n insertionPlugin,\n genderPlugin,\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n};\n"],"mappings":"qQA2BA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EAAgB,GAAe,sBAAsB,cAErD,EAAqB,CACzB,EACE,GAAU,EACV,EAAW,EAAgB,IAAA,GAC5B,CACD,EACA,EACA,EAAa,GAAU,EAAc,CACrC,EACA,EACA,EACA,GAAI,EAAU,SAAW,EAAE,CAC5B,CAED,OAAO,EAAkB,EAAM,CAC7B,GAAG,EACH,UACD,CAAC"}
@@ -1,5 +1 @@
1
- import { deepTransformNode } from "./deepTransform.mjs";
2
- import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, translationPlugin } from "./plugins.mjs";
3
- import { getContent } from "./getContent.mjs";
4
-
5
- export { conditionPlugin, deepTransformNode, enumerationPlugin, filePlugin, genderPlugin, getContent, insertionPlugin, nestedPlugin, translationPlugin };
1
+ import{deepTransformNode as e}from"./deepTransform.mjs";import{conditionPlugin as t,enumerationPlugin as n,filePlugin as r,genderPlugin as i,insertionPlugin as a,nestedPlugin as o,translationPlugin as s}from"./plugins.mjs";import{getContent as c}from"./getContent.mjs";export{t as conditionPlugin,e as deepTransformNode,n as enumerationPlugin,r as filePlugin,i as genderPlugin,c as getContent,a as insertionPlugin,o as nestedPlugin,s as translationPlugin};
@@ -1,154 +1,2 @@
1
- import { getCondition } from "../getCondition.mjs";
2
- import { getEnumeration } from "../getEnumeration.mjs";
3
- import { getGender } from "../getGender.mjs";
4
- import { getInsertion } from "../getInsertion.mjs";
5
- import { getNesting } from "../getNesting.mjs";
6
- import { getTranslation } from "../getTranslation.mjs";
7
- import { NodeType } from "@intlayer/types";
8
-
9
- //#region src/interpreter/getContent/plugins.ts
10
- /** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
11
- const translationPlugin = (locale, fallback) => ({
12
- id: "translation-plugin",
13
- canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Translation,
14
- transform: (node, props, deepTransformNode) => {
15
- const result = structuredClone(node[NodeType.Translation]);
16
- for (const key in result) {
17
- const childProps = {
18
- ...props,
19
- children: result[key],
20
- keyPath: [...props.keyPath, {
21
- type: NodeType.Translation,
22
- key
23
- }]
24
- };
25
- result[key] = deepTransformNode(result[key], childProps);
26
- }
27
- return getTranslation(result, locale, fallback);
28
- }
29
- });
30
- /** Enumeration plugin. Replaces node with a function that takes quantity => string. */
31
- const enumerationPlugin = {
32
- id: "enumeration-plugin",
33
- canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Enumeration,
34
- transform: (node, props, deepTransformNode) => {
35
- const result = structuredClone(node[NodeType.Enumeration]);
36
- for (const key in result) {
37
- const child = result[key];
38
- result[key] = deepTransformNode(child, {
39
- ...props,
40
- children: child,
41
- keyPath: [...props.keyPath, {
42
- type: NodeType.Enumeration,
43
- key
44
- }]
45
- });
46
- }
47
- return (arg) => {
48
- const subResult = getEnumeration(result, typeof arg === "number" ? arg : arg.count);
49
- if (typeof subResult === "function" && typeof arg === "object") return subResult(arg);
50
- return subResult;
51
- };
52
- }
53
- };
54
- /** Condition plugin. Replaces node with a function that takes boolean => string. */
55
- const conditionPlugin = {
56
- id: "condition-plugin",
57
- canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Condition,
58
- transform: (node, props, deepTransformNode) => {
59
- const result = structuredClone(node[NodeType.Condition]);
60
- for (const key in result) {
61
- const child = result[key];
62
- result[key] = deepTransformNode(child, {
63
- ...props,
64
- children: child,
65
- keyPath: [...props.keyPath, {
66
- type: NodeType.Condition,
67
- key
68
- }]
69
- });
70
- }
71
- return (arg) => {
72
- const subResult = getCondition(result, typeof arg === "boolean" ? arg : arg.value);
73
- if (typeof subResult === "function" && typeof arg === "object") return subResult(arg);
74
- return subResult;
75
- };
76
- }
77
- };
78
- /** Insertion plugin. Replaces node with a function that takes quantity => string. */
79
- const insertionPlugin = {
80
- id: "insertion-plugin",
81
- canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Insertion,
82
- transform: (node, props, deepTransformNode) => {
83
- const newKeyPath = [...props.keyPath, { type: NodeType.Insertion }];
84
- const children = node[NodeType.Insertion];
85
- /** Insertion string plugin. Replaces string node with a component that render the insertion. */
86
- const insertionStringPlugin = {
87
- id: "insertion-string-plugin",
88
- canHandle: (node) => typeof node === "string",
89
- transform: (node, subProps, deepTransformNode) => {
90
- const transformedResult = deepTransformNode(node, {
91
- ...subProps,
92
- children: node,
93
- plugins: [...(props.plugins ?? []).filter((plugin) => plugin.id !== "intlayer-node-plugin")]
94
- });
95
- return (values) => {
96
- const children = getInsertion(transformedResult, values);
97
- return deepTransformNode(children, {
98
- ...subProps,
99
- plugins: props.plugins,
100
- children
101
- });
102
- };
103
- }
104
- };
105
- return deepTransformNode(children, {
106
- ...props,
107
- children,
108
- keyPath: newKeyPath,
109
- plugins: [insertionStringPlugin, ...props.plugins ?? []]
110
- });
111
- }
112
- };
113
- /** Gender plugin. Replaces node with a function that takes gender => string. */
114
- const genderPlugin = {
115
- id: "gender-plugin",
116
- canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.Gender,
117
- transform: (node, props, deepTransformNode) => {
118
- const result = structuredClone(node[NodeType.Gender]);
119
- for (const key in result) {
120
- const child = result[key];
121
- result[key] = deepTransformNode(child, {
122
- ...props,
123
- children: child,
124
- keyPath: [...props.keyPath, {
125
- type: NodeType.Gender,
126
- key
127
- }]
128
- });
129
- }
130
- return (value) => getGender(result, value);
131
- }
132
- };
133
- /** Nested plugin. Replaces node with the result of `getNesting`. */
134
- const nestedPlugin = (locale) => ({
135
- id: "nested-plugin",
136
- canHandle: (node) => typeof node === "object" && (node?.nodeType === NodeType.Nested || node?.nodeType === "nested"),
137
- transform: (node, props) => getNesting(node.nested.dictionaryKey, node.nested.path, {
138
- ...props,
139
- locale: locale ?? props.locale
140
- })
141
- });
142
- /** File plugin. Replaces node with the result of `getNesting`. */
143
- const filePlugin = {
144
- id: "file-plugin",
145
- canHandle: (node) => typeof node === "object" && node?.nodeType === NodeType.File,
146
- transform: (node, props, deepTransform) => deepTransform(node.content, {
147
- ...props,
148
- children: node.content
149
- })
150
- };
151
-
152
- //#endregion
153
- export { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, translationPlugin };
1
+ import{getCondition as e}from"../getCondition.mjs";import{getEnumeration as t}from"../getEnumeration.mjs";import{getGender as n}from"../getGender.mjs";import{getInsertion as r}from"../getInsertion.mjs";import{getNesting as i}from"../getNesting.mjs";import{getTranslation as a}from"../getTranslation.mjs";import{NodeType as o}from"@intlayer/types";const s=(e,t)=>({id:`translation-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Translation,transform:(n,r,i)=>{let s=structuredClone(n[o.Translation]);for(let e in s){let t={...r,children:s[e],keyPath:[...r.keyPath,{type:o.Translation,key:e}]};s[e]=i(s[e],t)}return a(s,e,t)}}),c={id:`enumeration-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Enumeration,transform:(e,n,r)=>{let i=structuredClone(e[o.Enumeration]);for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.Enumeration,key:e}]})}return e=>{let n=t(i,typeof e==`number`?e:e.count);return typeof n==`function`&&typeof e==`object`?n(e):n}}},l={id:`condition-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Condition,transform:(t,n,r)=>{let i=structuredClone(t[o.Condition]);for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.Condition,key:e}]})}return t=>{let n=e(i,typeof t==`boolean`?t:t.value);return typeof n==`function`&&typeof t==`object`?n(t):n}}},u={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Insertion,transform:(e,t,n)=>{let i=[...t.keyPath,{type:o.Insertion}],a=e[o.Insertion],s={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,i)=>{let a=i(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let o=r(a,e);return i(o,{...n,plugins:t.plugins,children:o})}}};return n(a,{...t,children:a,keyPath:i,plugins:[s,...t.plugins??[]]})}},d={id:`gender-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Gender,transform:(e,t,r)=>{let i=structuredClone(e[o.Gender]);for(let e in i){let n=i[e];i[e]=r(n,{...t,children:n,keyPath:[...t.keyPath,{type:o.Gender,key:e}]})}return e=>n(i,e)}},f=e=>({id:`nested-plugin`,canHandle:e=>typeof e==`object`&&(e?.nodeType===o.Nested||e?.nodeType===`nested`),transform:(t,n)=>i(t.nested.dictionaryKey,t.nested.path,{...n,locale:e??n.locale})}),p={id:`file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.File,transform:(e,t,n)=>n(e.content,{...t,children:e.content})};export{l as conditionPlugin,c as enumerationPlugin,p as filePlugin,d as genderPlugin,u as insertionPlugin,f as nestedPlugin,s as translationPlugin};
154
2
  //# sourceMappingURL=plugins.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import {\n type DeclaredLocales,\n type DictionaryKeys,\n type KeyPath,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins => ({\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Translation]);\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as keyof typeof result] = deepTransformNode(\n result[key as keyof typeof result],\n childProps\n );\n }\n\n return getTranslation(result, locale, fallback);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Enumeration]);\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Condition]);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result, value);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? (\n values: {\n [K in T['fields'][number]]: string | number;\n }\n ) => DeepTransformContent<string, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Gender]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<T[NodeType.Gender][keyof T[NodeType.Gender]], S>\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins = {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Gender,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Gender]);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [...props.keyPath, { type: NodeType.Gender, key } as KeyPath],\n };\n result[key as keyof typeof result] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins => ({\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeType.Nested || node?.nodeType === 'nested'),\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }),\n});\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.File]: string;\n content?: string;\n}\n ? string\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins = {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n insertion: true;\n gender: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<\n T,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> = IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin’s transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":"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"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import {\n type DeclaredLocales,\n type DictionaryKeys,\n type KeyPath,\n type Locale,\n type LocalesValues,\n NodeType,\n} from '@intlayer/types';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins => ({\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Translation]);\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as keyof typeof result] = deepTransformNode(\n result[key as keyof typeof result],\n childProps\n );\n }\n\n return getTranslation(result, locale, fallback);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Enumeration]);\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Condition]);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result, value);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? (\n values: {\n [K in T['fields'][number]]: string | number;\n }\n ) => DeepTransformContent<string, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Gender]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<T[NodeType.Gender][keyof T[NodeType.Gender]], S>\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins = {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Gender,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Gender]);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [...props.keyPath, { type: NodeType.Gender, key } as KeyPath],\n };\n result[key as keyof typeof result] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins => ({\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeType.Nested || node?.nodeType === 'nested'),\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }),\n});\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.File]: string;\n content?: string;\n}\n ? string\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins = {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n insertion: true;\n gender: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin’s transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":"2VA+EA,MAAa,GACX,EACA,KACa,CACb,GAAI,qBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAS,gBAAgB,EAAK,EAAS,aAAa,CAE1D,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAO,GACjB,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,YAAa,MAAK,CACpC,CACF,CACD,EAAO,GAA8B,EACnC,EAAO,GACP,EACD,CAGH,OAAO,EAAe,EAAQ,EAAQ,EAAS,EAElD,EAmBY,EAA6B,CACxC,GAAI,qBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAS,gBAAgB,EAAK,EAAS,aAAa,CAE1D,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAQ,EAAO,GASrB,EAAO,GAAyC,EAC9C,EATiB,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,YAAa,MAAK,CACpC,CACF,CAIA,CAGH,MAAQ,IAAoC,CAE1C,IAAM,EAAY,EAAe,EADhB,OAAO,GAAQ,SAAW,EAAM,EAAI,MACH,CAMlD,OAJI,OAAO,GAAc,YAAc,OAAO,GAAQ,SAC7C,EAAU,EAAI,CAGhB,IAGZ,CAmBY,EAA2B,CACtC,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,UAC1D,WAAY,EAAwB,EAAO,IAAsB,CAC/D,IAAM,EAAS,gBAAgB,EAAK,EAAS,WAAW,CAExD,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAQ,EAAO,GASrB,EAAO,GAAyC,EAC9C,EATiB,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,UAAW,MAAK,CAClC,CACF,CAIA,CAGH,MAAQ,IAAsC,CAE5C,IAAM,EAAY,EAAa,EADjB,OAAO,GAAQ,UAAY,EAAM,EAAI,MACN,CAM7C,OAJI,OAAO,GAAc,YAAc,OAAO,GAAQ,SAC7C,EAAU,EAAI,CAGhB,IAGZ,CAmBY,EAA2B,CACtC,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,UAC1D,WAAY,EAAwB,EAAO,IAAsB,CAC/D,IAAM,EAAwB,CAC5B,GAAG,EAAM,QACT,CACE,KAAM,EAAS,UAChB,CACF,CAEK,EAAW,EAAK,EAAS,WAGzB,EAAiC,CACrC,GAAI,0BACJ,UAAY,GAAS,OAAO,GAAS,SACrC,WAAY,EAAc,EAAU,IAAsB,CACxD,IAAM,EAAoB,EAAkB,EAAM,CAChD,GAAG,EACH,SAAU,EACV,QAAS,CACP,IAAI,EAAM,SAAY,EAAE,EAAgB,OACrC,GAAW,EAAO,KAAO,uBAC3B,CACF,CACF,CAAC,CAEF,MACE,IAGG,CACH,IAAM,EAAW,EAAa,EAAmB,EAAO,CAExD,OAAO,EAAkB,EAAU,CACjC,GAAG,EACH,QAAS,EAAM,QACf,WACD,CAAC,GAGP,CAED,OAAO,EAAkB,EAAU,CACjC,GAAG,EACH,WACA,QAAS,EACT,QAAS,CAAC,EAAuB,GAAI,EAAM,SAAW,EAAE,CAAE,CAC3D,CAAC,EAEL,CAgBY,EAAwB,CACnC,GAAI,gBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,OAC1D,WAAY,EAAqB,EAAO,IAAsB,CAC5D,IAAM,EAAS,gBAAgB,EAAK,EAAS,QAAQ,CAErD,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAQ,EAAO,GAMrB,EAAO,GAA8B,EAAkB,EALpC,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAS,OAAQ,MAAK,CAAY,CACvE,CACwE,CAG3E,MAAQ,IAAkB,EAAU,EAAQ,EAAM,EAErD,CAmBY,EAAgB,IAAqC,CAChE,GAAI,gBACJ,UAAY,GACV,OAAO,GAAS,WACf,GAAM,WAAa,EAAS,QAAU,GAAM,WAAa,UAC5D,WAAY,EAAqB,IAC/B,EAAW,EAAK,OAAO,cAAe,EAAK,OAAO,KAAM,CACtD,GAAG,EACH,OAAS,GAAU,EAAM,OAC1B,CAAC,CACL,EAeY,EAAsB,CACjC,GAAI,cACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,KAC1D,WAAY,EAAmB,EAAO,IACpC,EAAc,EAAK,QAAS,CAC1B,GAAG,EACH,SAAU,EAAK,QAChB,CAAC,CACL"}
@@ -1,24 +1,2 @@
1
- import { getContent } from "./getContent/getContent.mjs";
2
-
3
- //#region src/interpreter/getDictionary.ts
4
- /**
5
- * Transforms a dictionary in a single pass, applying each plugin as needed.
6
- *
7
- * @param dictionary The dictionary to transform.
8
- * @param locale The locale to use if your transformers need it (e.g. for translations).
9
- * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.
10
- * If omitted, we’ll use a default set of plugins.
11
- */
12
- const getDictionary = (dictionary, locale, plugins) => {
13
- const props = {
14
- dictionaryKey: dictionary.key,
15
- dictionaryPath: dictionary.filePath,
16
- keyPath: [],
17
- plugins
18
- };
19
- return getContent(dictionary.content, props, locale);
20
- };
21
-
22
- //#endregion
23
- export { getDictionary };
1
+ import{getContent as e}from"./getContent/getContent.mjs";const t=(t,n,r)=>{let i={dictionaryKey:t.key,dictionaryPath:t.filePath,keyPath:[],plugins:r};return e(t.content,i,n)};export{t as getDictionary};
24
2
  //# sourceMappingURL=getDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.mjs","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<T['content'], IInterpreterPluginState, L> => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n return getContent(dictionary.content, props, locale);\n};\n"],"mappings":";;;;;;;;;;;AAqBA,MAAa,iBAIX,YACA,QACA,YACmE;CACnE,MAAM,QAAmB;EACvB,eAAe,WAAW;EAC1B,gBAAgB,WAAW;EAC3B,SAAS,EAAE;EACX;EACD;AAED,QAAO,WAAW,WAAW,SAAS,OAAO,OAAO"}
1
+ {"version":3,"file":"getDictionary.mjs","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n Dictionary,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<T['content'], IInterpreterPluginState, L> => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n return getContent(dictionary.content, props, locale);\n};\n"],"mappings":"yDAqBA,MAAa,GAIX,EACA,EACA,IACmE,CACnE,IAAM,EAAmB,CACvB,cAAe,EAAW,IAC1B,eAAgB,EAAW,SAC3B,QAAS,EAAE,CACX,UACD,CAED,OAAO,EAAW,EAAW,QAAS,EAAO,EAAO"}