@intlayer/core 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -212
  3. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -94
  5. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -45
  7. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -33
  9. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +1 -27
  11. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  12. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -82
  13. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  14. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +1 -87
  15. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  16. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +1 -60
  17. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  18. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -122
  19. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  20. package/dist/cjs/deepTransformPlugins/index.cjs +1 -32
  21. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -106
  22. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -64
  24. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -18
  26. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -55
  28. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -26
  30. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -23
  32. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  33. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -36
  34. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  35. package/dist/cjs/dictionaryManipulator/index.cjs +1 -27
  36. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -69
  37. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  38. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +1 -30
  39. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  40. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -48
  41. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  42. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -31
  43. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  44. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -39
  45. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  46. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -38
  47. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  48. package/dist/cjs/formatters/compact.cjs +1 -25
  49. package/dist/cjs/formatters/compact.cjs.map +1 -1
  50. package/dist/cjs/formatters/currency.cjs +1 -29
  51. package/dist/cjs/formatters/currency.cjs.map +1 -1
  52. package/dist/cjs/formatters/date.cjs +1 -60
  53. package/dist/cjs/formatters/date.cjs.map +1 -1
  54. package/dist/cjs/formatters/index.cjs +1 -18
  55. package/dist/cjs/formatters/list.cjs +1 -30
  56. package/dist/cjs/formatters/list.cjs.map +1 -1
  57. package/dist/cjs/formatters/number.cjs +1 -18
  58. package/dist/cjs/formatters/number.cjs.map +1 -1
  59. package/dist/cjs/formatters/percentage.cjs +1 -25
  60. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  61. package/dist/cjs/formatters/relativeTime.cjs +1 -33
  62. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  63. package/dist/cjs/formatters/units.cjs +1 -23
  64. package/dist/cjs/formatters/units.cjs.map +1 -1
  65. package/dist/cjs/getStorageAttributes.cjs +1 -134
  66. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  67. package/dist/cjs/index.cjs +1 -300
  68. package/dist/cjs/interpreter/getCondition.cjs +1 -27
  69. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  70. package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -41
  71. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  72. package/dist/cjs/interpreter/getContent/getContent.cjs +1 -34
  73. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  74. package/dist/cjs/interpreter/getContent/index.cjs +1 -14
  75. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -161
  76. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  77. package/dist/cjs/interpreter/getDictionary.cjs +1 -24
  78. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  79. package/dist/cjs/interpreter/getEnumeration.cjs +1 -72
  80. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  81. package/dist/cjs/interpreter/getGender.cjs +1 -38
  82. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  83. package/dist/cjs/interpreter/getHTML.cjs +1 -121
  84. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  85. package/dist/cjs/interpreter/getInsertion.cjs +1 -22
  86. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  87. package/dist/cjs/interpreter/getIntlayer.cjs +1 -40
  88. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  89. package/dist/cjs/interpreter/getNesting.cjs +1 -36
  90. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  91. package/dist/cjs/interpreter/getTranslation.cjs +1 -112
  92. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  93. package/dist/cjs/interpreter/index.cjs +1 -31
  94. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +1 -55
  95. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  96. package/dist/cjs/localization/getBrowserLocale.cjs +1 -143
  97. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  98. package/dist/cjs/localization/getHTMLTextDir.cjs +1 -64
  99. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  100. package/dist/cjs/localization/getLocale.cjs +1 -27
  101. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  102. package/dist/cjs/localization/getLocaleFromPath.cjs +1 -45
  103. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  104. package/dist/cjs/localization/getLocaleLang.cjs +1 -20
  105. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  106. package/dist/cjs/localization/getLocaleName.cjs +1 -10
  107. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  108. package/dist/cjs/localization/getLocalizedUrl.cjs +1 -82
  109. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  110. package/dist/cjs/localization/getMultilingualUrls.cjs +1 -63
  111. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  112. package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -55
  113. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  114. package/dist/cjs/localization/getPrefix.cjs +1 -63
  115. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  116. package/dist/cjs/localization/index.cjs +1 -39
  117. package/dist/cjs/localization/localeDetector.cjs +1 -133
  118. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  119. package/dist/cjs/localization/localeMapper.cjs +1 -119
  120. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  121. package/dist/cjs/localization/localeResolver.cjs +1 -28
  122. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  123. package/dist/cjs/localization/rewriteUtils.cjs +1 -110
  124. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  125. package/dist/cjs/localization/validatePrefix.cjs +1 -54
  126. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  127. package/dist/cjs/markdown/compiler.cjs +10 -810
  128. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  129. package/dist/cjs/markdown/constants.cjs +1 -328
  130. package/dist/cjs/markdown/constants.cjs.map +1 -1
  131. package/dist/cjs/markdown/index.cjs +1 -120
  132. package/dist/cjs/markdown/parser.cjs +1 -66
  133. package/dist/cjs/markdown/parser.cjs.map +1 -1
  134. package/dist/cjs/markdown/renderer.cjs +1 -61
  135. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  136. package/dist/cjs/markdown/utils.cjs +6 -391
  137. package/dist/cjs/markdown/utils.cjs.map +1 -1
  138. package/dist/cjs/messageFormat/ICU.cjs +1 -319
  139. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  140. package/dist/cjs/messageFormat/i18next.cjs +1 -330
  141. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  142. package/dist/cjs/messageFormat/index.cjs +1 -11
  143. package/dist/cjs/messageFormat/verify-icu-format.cjs +2 -64
  144. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  145. package/dist/cjs/messageFormat/vue-i18n.cjs +1 -166
  146. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  147. package/dist/cjs/transpiler/condition/condition.cjs +1 -26
  148. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  149. package/dist/cjs/transpiler/condition/index.cjs +1 -4
  150. package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -28
  151. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  152. package/dist/cjs/transpiler/enumeration/index.cjs +1 -4
  153. package/dist/cjs/transpiler/file/file.cjs +1 -52
  154. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  155. package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -25
  156. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  157. package/dist/cjs/transpiler/file/index.cjs +1 -5
  158. package/dist/cjs/transpiler/gender/gender.cjs +1 -26
  159. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  160. package/dist/cjs/transpiler/gender/index.cjs +1 -4
  161. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -44
  162. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  163. package/dist/cjs/transpiler/html/html.cjs +1 -37
  164. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  165. package/dist/cjs/transpiler/html/htmlTags.cjs +1 -116
  166. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  167. package/dist/cjs/transpiler/html/index.cjs +1 -6
  168. package/dist/cjs/transpiler/index.cjs +1 -24
  169. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +1 -11
  170. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  171. package/dist/cjs/transpiler/insertion/index.cjs +1 -6
  172. package/dist/cjs/transpiler/insertion/insertion.cjs +1 -36
  173. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  174. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +2 -23
  175. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  176. package/dist/cjs/transpiler/markdown/index.cjs +1 -6
  177. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -54
  178. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  179. package/dist/cjs/transpiler/nesting/index.cjs +1 -4
  180. package/dist/cjs/transpiler/nesting/nesting.cjs +1 -27
  181. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  182. package/dist/cjs/transpiler/translation/index.cjs +1 -4
  183. package/dist/cjs/transpiler/translation/translation.cjs +1 -29
  184. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  185. package/dist/cjs/utils/checkIsURLAbsolute.cjs +1 -7
  186. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  187. package/dist/cjs/utils/getCookie.cjs +1 -32
  188. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  189. package/dist/cjs/utils/index.cjs +1 -0
  190. package/dist/cjs/utils/intl.cjs +1 -91
  191. package/dist/cjs/utils/intl.cjs.map +1 -1
  192. package/dist/cjs/utils/isSameKeyPath.cjs +1 -7
  193. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  194. package/dist/cjs/utils/isValidReactElement.cjs +1 -14
  195. package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
  196. package/dist/cjs/utils/localeStorage.cjs +1 -140
  197. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  198. package/dist/cjs/utils/parseYaml.cjs +16 -322
  199. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  200. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -207
  201. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  202. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -89
  203. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  204. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -42
  205. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  206. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -31
  207. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  208. package/dist/esm/deepTransformPlugins/getMaskContent.mjs +1 -25
  209. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  210. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -77
  211. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  212. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +1 -86
  213. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  214. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +1 -59
  215. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  216. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -119
  217. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  218. package/dist/esm/deepTransformPlugins/index.mjs +1 -12
  219. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -104
  220. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  221. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -62
  222. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  223. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -16
  224. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  225. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -53
  226. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  227. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -24
  228. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  229. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -21
  230. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  231. package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -34
  232. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  233. package/dist/esm/dictionaryManipulator/index.mjs +1 -14
  234. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -66
  235. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  236. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +1 -28
  237. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  238. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +1 -45
  239. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  240. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -29
  241. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  242. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -37
  243. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  244. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -36
  245. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  246. package/dist/esm/formatters/compact.mjs +1 -22
  247. package/dist/esm/formatters/compact.mjs.map +1 -1
  248. package/dist/esm/formatters/currency.mjs +1 -26
  249. package/dist/esm/formatters/currency.mjs.map +1 -1
  250. package/dist/esm/formatters/date.mjs +1 -57
  251. package/dist/esm/formatters/date.mjs.map +1 -1
  252. package/dist/esm/formatters/index.mjs +1 -10
  253. package/dist/esm/formatters/list.mjs +1 -27
  254. package/dist/esm/formatters/list.mjs.map +1 -1
  255. package/dist/esm/formatters/number.mjs +1 -15
  256. package/dist/esm/formatters/number.mjs.map +1 -1
  257. package/dist/esm/formatters/percentage.mjs +1 -22
  258. package/dist/esm/formatters/percentage.mjs.map +1 -1
  259. package/dist/esm/formatters/relativeTime.mjs +1 -30
  260. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  261. package/dist/esm/formatters/units.mjs +1 -20
  262. package/dist/esm/formatters/units.mjs.map +1 -1
  263. package/dist/esm/getStorageAttributes.mjs +1 -132
  264. package/dist/esm/getStorageAttributes.mjs.map +1 -1
  265. package/dist/esm/index.mjs +1 -82
  266. package/dist/esm/interpreter/getCondition.mjs +1 -25
  267. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  268. package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -39
  269. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  270. package/dist/esm/interpreter/getContent/getContent.mjs +1 -31
  271. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  272. package/dist/esm/interpreter/getContent/index.mjs +1 -5
  273. package/dist/esm/interpreter/getContent/plugins.mjs +1 -153
  274. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  275. package/dist/esm/interpreter/getDictionary.mjs +1 -23
  276. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  277. package/dist/esm/interpreter/getEnumeration.mjs +1 -69
  278. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  279. package/dist/esm/interpreter/getGender.mjs +1 -36
  280. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  281. package/dist/esm/interpreter/getHTML.mjs +1 -119
  282. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  283. package/dist/esm/interpreter/getInsertion.mjs +1 -20
  284. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  285. package/dist/esm/interpreter/getIntlayer.mjs +1 -36
  286. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  287. package/dist/esm/interpreter/getNesting.mjs +1 -35
  288. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  289. package/dist/esm/interpreter/getTranslation.mjs +1 -110
  290. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  291. package/dist/esm/interpreter/index.mjs +1 -13
  292. package/dist/esm/interpreter/splitAndJoinInsertion.mjs +1 -53
  293. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  294. package/dist/esm/localization/getBrowserLocale.mjs +1 -138
  295. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  296. package/dist/esm/localization/getHTMLTextDir.mjs +1 -62
  297. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  298. package/dist/esm/localization/getLocale.mjs +1 -24
  299. package/dist/esm/localization/getLocale.mjs.map +1 -1
  300. package/dist/esm/localization/getLocaleFromPath.mjs +1 -42
  301. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  302. package/dist/esm/localization/getLocaleLang.mjs +1 -18
  303. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  304. package/dist/esm/localization/getLocaleName.mjs +1 -9
  305. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  306. package/dist/esm/localization/getLocalizedUrl.mjs +1 -79
  307. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  308. package/dist/esm/localization/getMultilingualUrls.mjs +1 -60
  309. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  310. package/dist/esm/localization/getPathWithoutLocale.mjs +1 -52
  311. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  312. package/dist/esm/localization/getPrefix.mjs +1 -60
  313. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  314. package/dist/esm/localization/index.mjs +1 -17
  315. package/dist/esm/localization/localeDetector.mjs +1 -131
  316. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  317. package/dist/esm/localization/localeMapper.mjs +1 -114
  318. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  319. package/dist/esm/localization/localeResolver.mjs +1 -25
  320. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  321. package/dist/esm/localization/rewriteUtils.mjs +1 -104
  322. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  323. package/dist/esm/localization/validatePrefix.mjs +1 -51
  324. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  325. package/dist/esm/markdown/compiler.mjs +10 -786
  326. package/dist/esm/markdown/compiler.mjs.map +1 -1
  327. package/dist/esm/markdown/constants.mjs +1 -247
  328. package/dist/esm/markdown/constants.mjs.map +1 -1
  329. package/dist/esm/markdown/index.mjs +1 -7
  330. package/dist/esm/markdown/parser.mjs +1 -65
  331. package/dist/esm/markdown/parser.mjs.map +1 -1
  332. package/dist/esm/markdown/renderer.mjs +1 -59
  333. package/dist/esm/markdown/renderer.mjs.map +1 -1
  334. package/dist/esm/markdown/utils.mjs +6 -361
  335. package/dist/esm/markdown/utils.mjs.map +1 -1
  336. package/dist/esm/messageFormat/ICU.mjs +1 -316
  337. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  338. package/dist/esm/messageFormat/i18next.mjs +1 -327
  339. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  340. package/dist/esm/messageFormat/index.mjs +1 -5
  341. package/dist/esm/messageFormat/verify-icu-format.mjs +2 -64
  342. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  343. package/dist/esm/messageFormat/vue-i18n.mjs +1 -163
  344. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  345. package/dist/esm/transpiler/condition/condition.mjs +1 -24
  346. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  347. package/dist/esm/transpiler/condition/index.mjs +1 -3
  348. package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -26
  349. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  350. package/dist/esm/transpiler/enumeration/index.mjs +1 -3
  351. package/dist/esm/transpiler/file/file.mjs +1 -49
  352. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  353. package/dist/esm/transpiler/file/fileBrowser.mjs +1 -24
  354. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  355. package/dist/esm/transpiler/file/index.mjs +1 -3
  356. package/dist/esm/transpiler/gender/gender.mjs +1 -24
  357. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  358. package/dist/esm/transpiler/gender/index.mjs +1 -3
  359. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -43
  360. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  361. package/dist/esm/transpiler/html/html.mjs +1 -35
  362. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  363. package/dist/esm/transpiler/html/htmlTags.mjs +1 -114
  364. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  365. package/dist/esm/transpiler/html/index.mjs +1 -4
  366. package/dist/esm/transpiler/index.mjs +1 -13
  367. package/dist/esm/transpiler/insertion/getInsertionValues.mjs +1 -9
  368. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  369. package/dist/esm/transpiler/insertion/index.mjs +1 -4
  370. package/dist/esm/transpiler/insertion/insertion.mjs +1 -34
  371. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  372. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +2 -22
  373. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  374. package/dist/esm/transpiler/markdown/index.mjs +1 -4
  375. package/dist/esm/transpiler/markdown/markdown.mjs +1 -52
  376. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  377. package/dist/esm/transpiler/nesting/index.mjs +1 -3
  378. package/dist/esm/transpiler/nesting/nesting.mjs +1 -25
  379. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  380. package/dist/esm/transpiler/translation/index.mjs +1 -3
  381. package/dist/esm/transpiler/translation/translation.mjs +1 -27
  382. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  383. package/dist/esm/utils/checkIsURLAbsolute.mjs +1 -5
  384. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  385. package/dist/esm/utils/getCookie.mjs +1 -30
  386. package/dist/esm/utils/getCookie.mjs.map +1 -1
  387. package/dist/esm/utils/index.mjs +1 -0
  388. package/dist/esm/utils/intl.mjs +1 -86
  389. package/dist/esm/utils/intl.mjs.map +1 -1
  390. package/dist/esm/utils/isSameKeyPath.mjs +1 -5
  391. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  392. package/dist/esm/utils/isValidReactElement.mjs +1 -12
  393. package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
  394. package/dist/esm/utils/localeStorage.mjs +1 -135
  395. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  396. package/dist/esm/utils/parseYaml.mjs +16 -320
  397. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  398. package/dist/types/formatters/index.d.ts +2 -1
  399. package/dist/types/index.d.ts +8 -2
  400. package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
  401. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  402. package/dist/types/localization/index.d.ts +2 -1
  403. package/dist/types/markdown/index.d.ts +4 -1
  404. package/dist/types/markdown/types.d.ts +1 -1
  405. package/dist/types/markdown/types.d.ts.map +1 -1
  406. package/dist/types/transpiler/translation/translation.d.ts +1 -1
  407. package/dist/types/utils/index.d.ts +8 -0
  408. package/package.json +65 -11
@@ -1,70 +1,2 @@
1
- //#region src/interpreter/getEnumeration.ts
2
- /**
3
- * Find the matching condition for a quantity.
4
- *
5
- * Usage:
6
- *
7
- * ```ts
8
- * const key = findMatchingCondition({
9
- * '<=-2.3': 'You have less than -2.3',
10
- * '<1': 'You have less than one',
11
- * '2': 'You have two',
12
- * '>=3': 'You have three or more',
13
- * }, 2);
14
- * // '2'
15
- * ```
16
- *
17
- * The order of the keys will define the priority of the content.
18
- *
19
- * ```ts
20
- * const key = findMatchingCondition({
21
- * '<4': 'You have less than four',
22
- * '2': 'You have two',
23
- * }, 2);
24
- * // '<4'
25
- * ```
26
- *
27
- * If no keys match, the default key is '1'.
28
- */
29
- const findMatchingCondition = (enumerationContent, quantity) => {
30
- const numericKeys = Object.keys(enumerationContent);
31
- for (const key of numericKeys) {
32
- const isEqual = !key.startsWith(">") && !key.startsWith("<") && !key.startsWith("=") && parseFloat(key) === quantity || key.startsWith("=") && parseFloat(key.slice(1)) === quantity;
33
- const isSuperior = key.startsWith(">") && quantity > parseFloat(key.slice(1));
34
- const isSuperiorOrEqual = key.startsWith(">=") && quantity >= parseFloat(key.slice(2));
35
- const isInferior = key.startsWith("<") && quantity < parseFloat(key.slice(1));
36
- const isInferiorOrEqual = key.startsWith("<=") && quantity <= parseFloat(key.slice(2));
37
- if (isEqual || isSuperior || isSuperiorOrEqual || isInferior || isInferiorOrEqual) return key;
38
- }
39
- };
40
- /**
41
- * Picks content from an enumeration map based on a provided quantity.
42
- *
43
- * Supported keys in the enumeration map:
44
- * - Specific numbers: '0', '1', '2'
45
- * - Comparison operators: '<5', '>=10', '<=2'
46
- * - Fallback: 'fallback'
47
- *
48
- * The first matching key in the object's iteration order will be selected.
49
- *
50
- * @param enumerationContent - A map of conditions/quantities to content.
51
- * @param quantity - The number to match against the conditions.
52
- * @returns The matching content.
53
- *
54
- * @example
55
- * ```ts
56
- * const content = getEnumeration({
57
- * '0': 'No items',
58
- * '1': 'One item',
59
- * '>1': 'Many items',
60
- * }, 5);
61
- * // 'Many items'
62
- * ```
63
- */
64
- const getEnumeration = (enumerationContent, quantity) => {
65
- return enumerationContent[findMatchingCondition(enumerationContent, quantity) ?? "fallback"];
66
- };
67
-
68
- //#endregion
69
- export { findMatchingCondition, getEnumeration };
1
+ const e=(e,t)=>{let n=Object.keys(e);for(let e of n){let n=!e.startsWith(`>`)&&!e.startsWith(`<`)&&!e.startsWith(`=`)&&parseFloat(e)===t||e.startsWith(`=`)&&parseFloat(e.slice(1))===t,r=e.startsWith(`>`)&&t>parseFloat(e.slice(1)),i=e.startsWith(`>=`)&&t>=parseFloat(e.slice(2)),a=e.startsWith(`<`)&&t<parseFloat(e.slice(1)),o=e.startsWith(`<=`)&&t<=parseFloat(e.slice(2));if(n||r||i||a||o)return e}},t=(t,n)=>t[e(t,n)??`fallback`];export{e as findMatchingCondition,t as getEnumeration};
70
2
  //# sourceMappingURL=getEnumeration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getEnumeration.mjs","names":[],"sources":["../../../src/interpreter/getEnumeration.ts"],"sourcesContent":["import type { EnterFormat, EnumerationContentState } from '../transpiler';\n\n/**\n * Find the matching condition for a quantity.\n *\n * Usage:\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // '2'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // '<4'\n * ```\n *\n * If no keys match, the default key is '1'.\n */\nexport const findMatchingCondition = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): EnterFormat | undefined => {\n const numericKeys = Object.keys(enumerationContent);\n\n for (const key of numericKeys) {\n const isEqual =\n (!key.startsWith('>') &&\n !key.startsWith('<') &&\n !key.startsWith('=') &&\n parseFloat(key) === quantity) ||\n (key.startsWith('=') && parseFloat(key.slice(1)) === quantity);\n const isSuperior =\n key.startsWith('>') && quantity > parseFloat(key.slice(1));\n const isSuperiorOrEqual =\n key.startsWith('>=') && quantity >= parseFloat(key.slice(2));\n const isInferior =\n key.startsWith('<') && quantity < parseFloat(key.slice(1));\n const isInferiorOrEqual =\n key.startsWith('<=') && quantity <= parseFloat(key.slice(2));\n\n if (\n isEqual ||\n isSuperior ||\n isSuperiorOrEqual ||\n isInferior ||\n isInferiorOrEqual\n ) {\n return key as EnterFormat;\n }\n }\n};\n\n/**\n * Picks content from an enumeration map based on a provided quantity.\n *\n * Supported keys in the enumeration map:\n * - Specific numbers: '0', '1', '2'\n * - Comparison operators: '<5', '>=10', '<=2'\n * - Fallback: 'fallback'\n *\n * The first matching key in the object's iteration order will be selected.\n *\n * @param enumerationContent - A map of conditions/quantities to content.\n * @param quantity - The number to match against the conditions.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getEnumeration({\n * '0': 'No items',\n * '1': 'One item',\n * '>1': 'Many items',\n * }, 5);\n * // 'Many items'\n * ```\n */\nexport const getEnumeration = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): Content => {\n const key =\n findMatchingCondition<Content>(enumerationContent, quantity) ?? 'fallback';\n\n // Default or error handling if no keys match\n return enumerationContent[key] as Content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,yBACX,oBACA,aAC4B;CAC5B,MAAM,cAAc,OAAO,KAAK,mBAAmB;AAEnD,MAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,UACH,CAAC,IAAI,WAAW,IAAI,IACnB,CAAC,IAAI,WAAW,IAAI,IACpB,CAAC,IAAI,WAAW,IAAI,IACpB,WAAW,IAAI,KAAK,YACrB,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC,KAAK;EACvD,MAAM,aACJ,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC5D,MAAM,oBACJ,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;EAC9D,MAAM,aACJ,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC5D,MAAM,oBACJ,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;AAE9D,MACE,WACA,cACA,qBACA,cACA,kBAEA,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6Bb,MAAa,kBACX,oBACA,aACY;AAKZ,QAAO,mBAHL,sBAA+B,oBAAoB,SAAS,IAAI"}
1
+ {"version":3,"file":"getEnumeration.mjs","names":[],"sources":["../../../src/interpreter/getEnumeration.ts"],"sourcesContent":["import type { EnterFormat, EnumerationContentState } from '../transpiler';\n\n/**\n * Find the matching condition for a quantity.\n *\n * Usage:\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // '2'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // '<4'\n * ```\n *\n * If no keys match, the default key is '1'.\n */\nexport const findMatchingCondition = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): EnterFormat | undefined => {\n const numericKeys = Object.keys(enumerationContent);\n\n for (const key of numericKeys) {\n const isEqual =\n (!key.startsWith('>') &&\n !key.startsWith('<') &&\n !key.startsWith('=') &&\n parseFloat(key) === quantity) ||\n (key.startsWith('=') && parseFloat(key.slice(1)) === quantity);\n const isSuperior =\n key.startsWith('>') && quantity > parseFloat(key.slice(1));\n const isSuperiorOrEqual =\n key.startsWith('>=') && quantity >= parseFloat(key.slice(2));\n const isInferior =\n key.startsWith('<') && quantity < parseFloat(key.slice(1));\n const isInferiorOrEqual =\n key.startsWith('<=') && quantity <= parseFloat(key.slice(2));\n\n if (\n isEqual ||\n isSuperior ||\n isSuperiorOrEqual ||\n isInferior ||\n isInferiorOrEqual\n ) {\n return key as EnterFormat;\n }\n }\n};\n\n/**\n * Picks content from an enumeration map based on a provided quantity.\n *\n * Supported keys in the enumeration map:\n * - Specific numbers: '0', '1', '2'\n * - Comparison operators: '<5', '>=10', '<=2'\n * - Fallback: 'fallback'\n *\n * The first matching key in the object's iteration order will be selected.\n *\n * @param enumerationContent - A map of conditions/quantities to content.\n * @param quantity - The number to match against the conditions.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getEnumeration({\n * '0': 'No items',\n * '1': 'One item',\n * '>1': 'Many items',\n * }, 5);\n * // 'Many items'\n * ```\n */\nexport const getEnumeration = <Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): Content => {\n const key =\n findMatchingCondition<Content>(enumerationContent, quantity) ?? 'fallback';\n\n // Default or error handling if no keys match\n return enumerationContent[key] as Content;\n};\n"],"mappings":"AA6BA,MAAa,GACX,EACA,IAC4B,CAC5B,IAAM,EAAc,OAAO,KAAK,EAAmB,CAEnD,IAAK,IAAM,KAAO,EAAa,CAC7B,IAAM,EACH,CAAC,EAAI,WAAW,IAAI,EACnB,CAAC,EAAI,WAAW,IAAI,EACpB,CAAC,EAAI,WAAW,IAAI,EACpB,WAAW,EAAI,GAAK,GACrB,EAAI,WAAW,IAAI,EAAI,WAAW,EAAI,MAAM,EAAE,CAAC,GAAK,EACjD,EACJ,EAAI,WAAW,IAAI,EAAI,EAAW,WAAW,EAAI,MAAM,EAAE,CAAC,CACtD,EACJ,EAAI,WAAW,KAAK,EAAI,GAAY,WAAW,EAAI,MAAM,EAAE,CAAC,CACxD,EACJ,EAAI,WAAW,IAAI,EAAI,EAAW,WAAW,EAAI,MAAM,EAAE,CAAC,CACtD,EACJ,EAAI,WAAW,KAAK,EAAI,GAAY,WAAW,EAAI,MAAM,EAAE,CAAC,CAE9D,GACE,GACA,GACA,GACA,GACA,EAEA,OAAO,IA6BA,GACX,EACA,IAMO,EAHL,EAA+B,EAAoB,EAAS,EAAI"}
@@ -1,37 +1,2 @@
1
- //#region src/interpreter/getGender.ts
2
- const getGenderEntry = (gender) => {
3
- if (gender === "m" || gender === "male") return "male";
4
- if (gender === "f" || gender === "female") return "female";
5
- return "fallback";
6
- };
7
- /**
8
- * Allow to pick a content based on a gender.
9
- *
10
- * Usage:
11
- *
12
- * ```ts
13
- * const content = getGender({
14
- * 'true': 'The gender is validated',
15
- * 'false': 'The gender is not validated',
16
- * }, true);
17
- * // 'The gender is validated'
18
- * ```
19
- *
20
- * The last key provided will be used as the fallback value.
21
- *
22
- * ```ts
23
- * const content = getGender({
24
- * 'false': 'The gender is not validated',
25
- * 'true': 'The gender is validated',
26
- * }, undefined);
27
- * // 'The gender is validated'
28
- */
29
- const getGender = (genderContent, gender) => {
30
- const stateList = Object.keys(genderContent);
31
- const fallbackState = stateList[stateList.length - 1];
32
- return genderContent[getGenderEntry(gender)] ?? genderContent.fallback ?? genderContent[fallbackState];
33
- };
34
-
35
- //#endregion
36
- export { getGender };
1
+ const e=e=>e===`m`||e===`male`?`male`:e===`f`||e===`female`?`female`:`fallback`,t=(t,n)=>{let r=Object.keys(t),i=r[r.length-1];return t[e(n)]??t.fallback??t[i]};export{t as getGender};
37
2
  //# sourceMappingURL=getGender.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getGender.mjs","names":[],"sources":["../../../src/interpreter/getGender.ts"],"sourcesContent":["import type { Gender, GenderContentStates } from '../transpiler';\n\ntype GenderEntry = Gender | 'm' | 'f';\n\nconst getGenderEntry = (gender: GenderEntry): Gender => {\n if (gender === 'm' || gender === 'male') return 'male';\n if (gender === 'f' || gender === 'female') return 'female';\n return 'fallback';\n};\n\n/**\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * const content = getGender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * }, true);\n * // 'The gender is validated'\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n * ```ts\n * const content = getGender({\n * 'false': 'The gender is not validated',\n * 'true': 'The gender is validated',\n * }, undefined);\n * // 'The gender is validated'\n */\nexport const getGender = <Content>(\n genderContent: GenderContentStates<Content>,\n gender: GenderEntry\n): Content => {\n const stateList = Object.keys(genderContent);\n\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof genderContent;\n\n const genderEntry = getGenderEntry(gender);\n\n // Default or error handling if no keys match\n return (\n genderContent[genderEntry as keyof typeof genderContent] ??\n genderContent.fallback ??\n (genderContent[fallbackState] as Content)\n );\n};\n"],"mappings":";AAIA,MAAM,kBAAkB,WAAgC;AACtD,KAAI,WAAW,OAAO,WAAW,OAAQ,QAAO;AAChD,KAAI,WAAW,OAAO,WAAW,SAAU,QAAO;AAClD,QAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBT,MAAa,aACX,eACA,WACY;CACZ,MAAM,YAAY,OAAO,KAAK,cAAc;CAE5C,MAAM,gBAAgB,UACpB,UAAU,SAAS;AAMrB,QACE,cAJkB,eAAe,OAAO,KAKxC,cAAc,YACb,cAAc"}
1
+ {"version":3,"file":"getGender.mjs","names":[],"sources":["../../../src/interpreter/getGender.ts"],"sourcesContent":["import type { Gender, GenderContentStates } from '../transpiler';\n\ntype GenderEntry = Gender | 'm' | 'f';\n\nconst getGenderEntry = (gender: GenderEntry): Gender => {\n if (gender === 'm' || gender === 'male') return 'male';\n if (gender === 'f' || gender === 'female') return 'female';\n return 'fallback';\n};\n\n/**\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * const content = getGender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * }, true);\n * // 'The gender is validated'\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n * ```ts\n * const content = getGender({\n * 'false': 'The gender is not validated',\n * 'true': 'The gender is validated',\n * }, undefined);\n * // 'The gender is validated'\n */\nexport const getGender = <Content>(\n genderContent: GenderContentStates<Content>,\n gender: GenderEntry\n): Content => {\n const stateList = Object.keys(genderContent);\n\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof genderContent;\n\n const genderEntry = getGenderEntry(gender);\n\n // Default or error handling if no keys match\n return (\n genderContent[genderEntry as keyof typeof genderContent] ??\n genderContent.fallback ??\n (genderContent[fallbackState] as Content)\n );\n};\n"],"mappings":"AAIA,MAAM,EAAkB,GAClB,IAAW,KAAO,IAAW,OAAe,OAC5C,IAAW,KAAO,IAAW,SAAiB,SAC3C,WAyBI,GACX,EACA,IACY,CACZ,IAAM,EAAY,OAAO,KAAK,EAAc,CAEtC,EAAgB,EACpB,EAAU,OAAS,GAMrB,OACE,EAJkB,EAAe,EAAO,GAKxC,EAAc,UACb,EAAc"}
@@ -1,120 +1,2 @@
1
- //#region src/interpreter/getHTML.ts
2
- /**
3
- * Helper to parse attributes from a tag string.
4
- */
5
- const parseAttributes = (attributes) => {
6
- const props = {};
7
- const attrRegex = /([a-zA-Z0-9-]+)="([^"]*)"/g;
8
- let match = attrRegex.exec(attributes);
9
- while (match !== null) {
10
- props[match[1]] = match[2];
11
- match = attrRegex.exec(attributes);
12
- }
13
- return props;
14
- };
15
- const astCache = /* @__PURE__ */ new Map();
16
- const parseHTML = (content) => {
17
- if (astCache.has(content)) return astCache.get(content);
18
- if (typeof content !== "string") return [];
19
- const tagRegex = /<(\/)?([a-zA-Z0-9.-]+)([\s\S]*?)(\/?)>/g;
20
- const elements = [];
21
- const stack = [];
22
- let lastIndex = 0;
23
- let match = tagRegex.exec(content);
24
- const appendChild = (child) => {
25
- (stack.length > 0 ? stack[stack.length - 1].children : elements).push(child);
26
- };
27
- while (match !== null) {
28
- const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] = match;
29
- const matchIndex = match.index;
30
- if (matchIndex > lastIndex) appendChild(content.slice(lastIndex, matchIndex));
31
- const isClosing = isClosingRaw === "/";
32
- const isSelfClosing = isSelfClosingRaw === "/" || attributesRaw.trim().endsWith("/") || fullMatch.endsWith("/>");
33
- const cleanedAttributes = attributesRaw.trim().replace(/\/$/, "").trim();
34
- if (isClosing) {
35
- const last = stack.pop();
36
- if (last) appendChild({
37
- tagName: last.tagName,
38
- props: last.props,
39
- children: last.children
40
- });
41
- } else if (isSelfClosing) appendChild({
42
- tagName,
43
- props: parseAttributes(cleanedAttributes),
44
- children: []
45
- });
46
- else {
47
- const tagProps = parseAttributes(cleanedAttributes);
48
- stack.push({
49
- tagName,
50
- children: [],
51
- props: tagProps
52
- });
53
- }
54
- lastIndex = matchIndex + fullMatch.length;
55
- match = tagRegex.exec(content);
56
- }
57
- if (lastIndex < content.length) appendChild(content.slice(lastIndex));
58
- while (stack.length > 0) {
59
- const last = stack.pop();
60
- if (last) appendChild({
61
- tagName: last.tagName,
62
- props: last.props,
63
- children: last.children
64
- });
65
- }
66
- astCache.set(content, elements);
67
- return elements;
68
- };
69
- /**
70
- * Interprets a string containing HTML-like tags and replaces them with provided components or strings.
71
- */
72
- const getHTML = (content, values) => {
73
- const ast = parseHTML(content);
74
- let keyCounter = 0;
75
- const renderASTNode = (node) => {
76
- if (typeof node === "string") return node;
77
- const { tagName, props, children } = node;
78
- const renderedChildren = children.flatMap(renderASTNode);
79
- const index = keyCounter++;
80
- let override = values[tagName];
81
- if (!override) {
82
- const lowerTagName = tagName.toLowerCase();
83
- const foundKey = Object.keys(values).find((key) => key.toLowerCase() === lowerTagName);
84
- if (foundKey) override = values[foundKey];
85
- }
86
- const key = `html-tag-${tagName}-${index}`;
87
- if (typeof override === "function") return override({
88
- ...props,
89
- children: renderedChildren,
90
- key
91
- });
92
- if (typeof override === "string") {
93
- const component = values[override];
94
- if (typeof component === "function") return component({
95
- ...props,
96
- children: renderedChildren,
97
- key
98
- });
99
- return renderedChildren;
100
- }
101
- if (typeof override === "object" && override !== null && "tag" in override) {
102
- const { tag: targetTag, props: extraProps } = override;
103
- const component = values[targetTag];
104
- if (typeof component === "function") return component({
105
- ...props,
106
- ...extraProps,
107
- children: renderedChildren,
108
- key
109
- });
110
- return renderedChildren;
111
- }
112
- return renderedChildren;
113
- };
114
- const result = ast.flatMap(renderASTNode);
115
- return result.length === 1 ? result[0] : result;
116
- };
117
-
118
- //#endregion
119
- export { getHTML };
1
+ const e=e=>{let t={},n=/([a-zA-Z0-9-]+)="([^"]*)"/g,r=n.exec(e);for(;r!==null;)t[r[1]]=r[2],r=n.exec(e);return t},t=new Map,n=n=>{if(t.has(n))return t.get(n);if(typeof n!=`string`)return[];let r=/<(\/)?([a-zA-Z0-9.-]+)([\s\S]*?)(\/?)>/g,i=[],a=[],o=0,s=r.exec(n),c=e=>{(a.length>0?a[a.length-1].children:i).push(e)};for(;s!==null;){let[t,i,l,u,d]=s,f=s.index;f>o&&c(n.slice(o,f));let p=i===`/`,m=d===`/`||u.trim().endsWith(`/`)||t.endsWith(`/>`),h=u.trim().replace(/\/$/,``).trim();if(p){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}else if(m)c({tagName:l,props:e(h),children:[]});else{let t=e(h);a.push({tagName:l,children:[],props:t})}o=f+t.length,s=r.exec(n)}for(o<n.length&&c(n.slice(o));a.length>0;){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}return t.set(n,i),i},r=(e,t)=>{let r=n(e),i=0,a=e=>{if(typeof e==`string`)return e;let{tagName:n,props:r,children:o}=e,s=o.flatMap(a),c=i++,l=t[n];if(!l){let e=n.toLowerCase(),r=Object.keys(t).find(t=>t.toLowerCase()===e);r&&(l=t[r])}let u=`html-tag-${n}-${c}`;if(typeof l==`function`)return l({...r,children:s,key:u});if(typeof l==`string`){let e=t[l];return typeof e==`function`?e({...r,children:s,key:u}):s}if(typeof l==`object`&&l&&`tag`in l){let{tag:e,props:n}=l,i=t[e];return typeof i==`function`?i({...r,...n,children:s,key:u}):s}return s},o=r.flatMap(a);return o.length===1?o[0]:o};export{r as getHTML};
120
2
  //# sourceMappingURL=getHTML.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getHTML.mjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack.pop();\n\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"getHTML.mjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack.pop();\n\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":"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"}
@@ -1,21 +1,2 @@
1
- //#region src/interpreter/getInsertion.ts
2
- /**
3
- * Allow to insert values in a string.
4
- *
5
- * Usage:
6
- *
7
- * ```ts
8
- * const content = getInsertion('Hello {{name}}!', {
9
- * name: 'John',
10
- * });
11
- * // 'Hello John!'
12
- * ```
13
- *
14
- */
15
- const getInsertion = (content, values) => content.replace(/\{\{\s*(.*?)\s*\}\}/g, (_, key) => {
16
- return (values[key.trim()] ?? "").toString();
17
- });
18
-
19
- //#endregion
20
- export { getInsertion };
1
+ const e=(e,t)=>e.replace(/\{\{\s*(.*?)\s*\}\}/g,(e,n)=>(t[n.trim()]??``).toString());export{e as getInsertion};
21
2
  //# sourceMappingURL=getInsertion.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getInsertion.mjs","names":[],"sources":["../../../src/interpreter/getInsertion.ts"],"sourcesContent":["import type { InsertionContent } from '../transpiler';\n\n/**\n * Allow to insert values in a string.\n *\n * Usage:\n *\n * ```ts\n * const content = getInsertion('Hello {{name}}!', {\n * name: 'John',\n * });\n * // 'Hello John!'\n * ```\n *\n */\nexport const getInsertion = (\n content: string,\n values: { [K in InsertionContent['fields'][number]]: string | number }\n) =>\n content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n });\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,gBACX,SACA,WAEA,QAAQ,QAAQ,yBAAyB,GAAG,QAAQ;AAElD,SAAQ,OADW,IAAI,MAAM,KACC,IAAI,UAAU;EAC5C"}
1
+ {"version":3,"file":"getInsertion.mjs","names":[],"sources":["../../../src/interpreter/getInsertion.ts"],"sourcesContent":["import type { InsertionContent } from '../transpiler';\n\n/**\n * Allow to insert values in a string.\n *\n * Usage:\n *\n * ```ts\n * const content = getInsertion('Hello {{name}}!', {\n * name: 'John',\n * });\n * // 'Hello John!'\n * ```\n *\n */\nexport const getInsertion = (\n content: string,\n values: { [K in InsertionContent['fields'][number]]: string | number }\n) =>\n content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n });\n"],"mappings":"AAeA,MAAa,GACX,EACA,IAEA,EAAQ,QAAQ,wBAAyB,EAAG,KAElC,EADW,EAAI,MAAM,GACC,IAAI,UAAU,CAC5C"}
@@ -1,37 +1,2 @@
1
- import { getDictionary } from "./getDictionary.mjs";
2
- import { colorizeKey, getAppLogger } from "@intlayer/config/client";
3
- import configuration from "@intlayer/config/built";
4
- import { getDictionaries } from "@intlayer/dictionaries-entry";
5
-
6
- //#region src/interpreter/getIntlayer.ts
7
- /**
8
- * Creates a Recursive Proxy that returns the path of the accessed key
9
- * stringified. This prevents the app from crashing on undefined access.
10
- */
11
- const createSafeFallback = (path = "") => {
12
- return new Proxy(() => path, {
13
- get: (_target, prop) => {
14
- if (prop === "toJSON" || prop === Symbol.toPrimitive || prop === "toString") return () => path;
15
- if (prop === "then") return;
16
- return createSafeFallback(path ? `${path}.${String(prop)}` : String(prop));
17
- },
18
- apply: () => {
19
- return path;
20
- }
21
- });
22
- };
23
- const getIntlayer = (key, locale, plugins) => {
24
- const dictionary = getDictionaries()[key];
25
- if (!dictionary) {
26
- getAppLogger(configuration)(`Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`, {
27
- level: "warn",
28
- isVerbose: true
29
- });
30
- return createSafeFallback(key);
31
- }
32
- return getDictionary(dictionary, locale, plugins);
33
- };
34
-
35
- //#endregion
36
- export { getIntlayer };
1
+ import{getDictionary as e}from"./getDictionary.mjs";import{colorizeKey as t,getAppLogger as n}from"@intlayer/config/client";import r from"@intlayer/config/built";import{getDictionaries as i}from"@intlayer/dictionaries-entry";const a=(e=``)=>new Proxy(()=>e,{get:(t,n)=>{if(n===`toJSON`||n===Symbol.toPrimitive||n===`toString`)return()=>e;if(n!==`then`)return a(e?`${e}.${String(n)}`:String(n))},apply:()=>e}),o=(o,s,c)=>{let l=i()[o];return l?e(l,s,c):(n(r)(`Dictionary ${t(o)} was not found. Using fallback proxy.`,{level:`warn`,isVerbose:!0}),a(o))};export{o as getIntlayer};
37
2
  //# sourceMappingURL=getIntlayer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.mjs","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["// packages/@intlayer/core/src/interpreter/getIntlayer.ts\n\nimport configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,sBAAsB,OAAO,OAAY;AAC7C,QAAO,IAAI,YAEH,MACN;EACE,MAAM,SAAS,SAAS;AAEtB,OACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,WAET,cAAa;AAEf,OAAI,SAAS,OACX;AAKF,UAAO,mBADU,OAAO,GAAG,KAAK,GAAG,OAAO,KAAK,KAAK,OAAO,KAAK,CAC7B;;EAGrC,aAAa;AACX,UAAO;;EAEV,CACF;;AAGH,MAAa,eAIX,KACA,QACA,YAKG;CAEH,MAAM,aADe,iBAAiB,CACN;AAEhC,KAAI,CAAC,YAAY;AAGf,EADe,aAAa,cAAc,CAExC,cAAc,YAAY,IAAc,CAAC,wCACzC;GACE,OAAO;GACP,WAAW;GACZ,CACF;AAKC,SAAO,mBAAmB,IAAc;;AAM5C,QAAO,cACL,YACA,QACA,QACD"}
1
+ {"version":3,"file":"getIntlayer.mjs","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["// packages/@intlayer/core/src/interpreter/getIntlayer.ts\n\nimport configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":"iOAuBA,MAAM,GAAsB,EAAO,KAC1B,IAAI,UAEH,EACN,CACE,KAAM,EAAS,IAAS,CAEtB,GACE,IAAS,UACT,IAAS,OAAO,aAChB,IAAS,WAET,UAAa,EAEX,OAAS,OAMb,OAAO,EADU,EAAO,GAAG,EAAK,GAAG,OAAO,EAAK,GAAK,OAAO,EAAK,CAC7B,EAGrC,UACS,EAEV,CACF,CAGU,GAIX,EACA,EACA,IAKG,CAEH,IAAM,EADe,GAAiB,CACN,GAsBhC,OApBK,EAoBE,EACL,EACA,EACA,EACD,EAtBgB,EAAa,EAAc,CAExC,cAAc,EAAY,EAAc,CAAC,uCACzC,CACE,MAAO,OACP,UAAW,GACZ,CACF,CAQM,EAAmB,EAAc"}
@@ -1,36 +1,2 @@
1
- import { getIntlayer } from "./getIntlayer.mjs";
2
-
3
- //#region src/interpreter/getNesting.ts
4
- /**
5
- * Extracts content from another dictionary by its key and an optional path.
6
- *
7
- * This allows for reusing content across different dictionaries.
8
- *
9
- * @param dictionaryKey - The key of the dictionary to nest.
10
- * @param path - Optional dot-separated path to a specific field within the nested dictionary.
11
- * @param props - Optional properties like locale and plugins.
12
- * @returns The nested content.
13
- *
14
- * @example
15
- * ```ts
16
- * const content = getNesting("common", "buttons.save");
17
- * // 'Save'
18
- * ```
19
- */
20
- const getNesting = (dictionaryKey, path, props) => {
21
- const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);
22
- if (typeof path === "string") {
23
- const pathArray = path.split(".");
24
- let current = dictionary;
25
- for (const key of pathArray) {
26
- current = current?.[key];
27
- if (current === void 0) return dictionary;
28
- }
29
- return current;
30
- }
31
- return dictionary;
32
- };
33
-
34
- //#endregion
35
- export { getNesting };
1
+ import{getIntlayer as e}from"./getIntlayer.mjs";const t=(t,n,r)=>{let i=e(t,r?.locale,r?.plugins);if(typeof n==`string`){let e=n.split(`.`),t=i;for(let n of e)if(t=t?.[n],t===void 0)return i;return t}return i};export{t as getNesting};
36
2
  //# sourceMappingURL=getNesting.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNesting.mjs","names":[],"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n} from '@intlayer/types';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,MAAa,cACX,eACA,MACA,UAC2B;CAC3B,MAAM,aAAa,YAAY,eAAe,OAAO,QAAQ,OAAO,QAAQ;AAE5E,KAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,YAAa,KAAgB,MAAM,IAAI;EAC7C,IAAI,UAAe;AAEnB,OAAK,MAAM,OAAO,WAAW;AAE3B,aAAU,UAAU;AAEpB,OAAI,YAAY,OACd,QAAO;;AAIX,SAAO;;AAIT,QAAO"}
1
+ {"version":3,"file":"getNesting.mjs","names":[],"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n} from '@intlayer/types';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"gDAmCA,MAAa,GACX,EACA,EACA,IAC2B,CAC3B,IAAM,EAAa,EAAY,EAAe,GAAO,OAAQ,GAAO,QAAQ,CAE5E,GAAI,OAAO,GAAS,SAAU,CAC5B,IAAM,EAAa,EAAgB,MAAM,IAAI,CACzC,EAAe,EAEnB,IAAK,IAAM,KAAO,EAIhB,GAFA,EAAU,IAAU,GAEhB,IAAY,IAAA,GACd,OAAO,EAIX,OAAO,EAIT,OAAO"}
@@ -1,111 +1,2 @@
1
- //#region src/interpreter/getTranslation.ts
2
- /**
3
- * Check if a value is a plain object that can be safely processed.
4
- * Returns false for Promises, React elements, class instances, etc.
5
- */
6
- const isPlainObject = (value) => {
7
- if (value === null || typeof value !== "object") return false;
8
- if (value instanceof Promise || typeof value.then === "function") return false;
9
- if (value.$$typeof !== void 0 || value.__v_isVNode !== void 0 || value._isVNode !== void 0 || value.isJSX !== void 0) return false;
10
- const proto = Object.getPrototypeOf(value);
11
- return proto === Object.prototype || proto === null || Array.isArray(value);
12
- };
13
- /**
14
- * Recursively merges two objects.
15
- * Resembles the behavior of `defu` but respects `isPlainObject` to avoid merging React elements.
16
- * Arrays are replaced, not merged.
17
- */
18
- const deepMergeObjects = (target, source) => {
19
- if (target === void 0) return source;
20
- if (source === void 0) return target;
21
- if (Array.isArray(target)) return target;
22
- if (isPlainObject(target) && isPlainObject(source)) {
23
- const result = { ...target };
24
- for (const key of Object.keys(source)) {
25
- if (key === "__proto__" || key === "constructor") continue;
26
- if (Object.hasOwn(target, key)) result[key] = deepMergeObjects(target[key], source[key]);
27
- else result[key] = source[key];
28
- }
29
- return result;
30
- }
31
- return target;
32
- };
33
- /**
34
- * Recursively removes undefined values from an object.
35
- * Handles circular references by tracking visited objects.
36
- */
37
- const removeUndefinedValues = (object, visited = /* @__PURE__ */ new WeakSet()) => {
38
- if (typeof object !== "object" || object === null) return object;
39
- if (visited.has(object)) return object;
40
- visited.add(object);
41
- if (!isPlainObject(object)) return object;
42
- if (Array.isArray(object)) return object.map((item) => removeUndefinedValues(item, visited));
43
- const result = {};
44
- for (const [key, value] of Object.entries(object)) if (value !== void 0) result[key] = removeUndefinedValues(value, visited);
45
- return result;
46
- };
47
- /**
48
- * Picks the appropriate content from a locale map based on the provided locale.
49
- *
50
- * It handles:
51
- * 1. Exact locale match (e.g., 'en-US').
52
- * 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).
53
- * 3. Explicit fallback locale.
54
- * 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.
55
- *
56
- * @param languageContent - A map of locales to content.
57
- * @param locale - The target locale to retrieve.
58
- * @param fallback - Optional fallback locale if the target is not found.
59
- * @returns The translated content.
60
- *
61
- * @example
62
- * ```ts
63
- * const content = getTranslation({
64
- * en: 'Hello',
65
- * fr: 'Bonjour',
66
- * }, 'fr');
67
- * // 'Bonjour'
68
- * ```
69
- */
70
- const getTranslation = (languageContent, locale, fallback) => {
71
- const results = [];
72
- const getContent = (loc) => languageContent[loc];
73
- const content = getContent(locale);
74
- if (typeof content === "string") return content;
75
- else if (content !== void 0) results.push(content);
76
- if (locale.includes("-")) {
77
- const genericLocale = locale.split("-")[0];
78
- if (genericLocale in languageContent) {
79
- const genericContent = getContent(genericLocale);
80
- if (typeof genericContent === "string") {
81
- if (results.length === 0) return genericContent;
82
- } else if (genericContent !== void 0) results.push(genericContent);
83
- }
84
- }
85
- if (fallback !== void 0 && fallback !== locale) {
86
- if (fallback in languageContent) {
87
- const fallbackContent = getContent(fallback);
88
- if (typeof fallbackContent === "string") {
89
- if (results.length === 0) return fallbackContent;
90
- } else if (fallbackContent !== void 0) results.push(fallbackContent);
91
- }
92
- if (fallback.includes("-")) {
93
- const genericFallback = fallback.split("-")[0];
94
- if (genericFallback !== locale.split("-")[0] && genericFallback in languageContent) {
95
- const genericFallbackContent = getContent(genericFallback);
96
- if (typeof genericFallbackContent === "string") {
97
- if (results.length === 0) return genericFallbackContent;
98
- } else if (genericFallbackContent !== void 0) results.push(genericFallbackContent);
99
- }
100
- }
101
- }
102
- if (results.length === 0) return;
103
- const cleanResults = results.filter((item) => typeof item !== "undefined").map((item) => removeUndefinedValues(item));
104
- if (cleanResults.length === 1) return cleanResults[0];
105
- if (Array.isArray(cleanResults[0])) return cleanResults[0];
106
- return cleanResults.reduce((acc, curr) => deepMergeObjects(acc, curr));
107
- };
108
-
109
- //#endregion
110
- export { getTranslation };
1
+ const e=e=>{if(typeof e!=`object`||!e||e instanceof Promise||typeof e.then==`function`||e.$$typeof!==void 0||e.__v_isVNode!==void 0||e._isVNode!==void 0||e.isJSX!==void 0)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Array.isArray(e)},t=(n,r)=>{if(n===void 0)return r;if(r===void 0||Array.isArray(n))return n;if(e(n)&&e(r)){let e={...n};for(let i of Object.keys(r))i===`__proto__`||i===`constructor`||(Object.hasOwn(n,i)?e[i]=t(n[i],r[i]):e[i]=r[i]);return e}return n},n=(t,r=new WeakSet)=>{if(typeof t!=`object`||!t||r.has(t)||(r.add(t),!e(t)))return t;if(Array.isArray(t))return t.map(e=>n(e,r));let i={};for(let[e,a]of Object.entries(t))a!==void 0&&(i[e]=n(a,r));return i},r=(e,r,i)=>{let a=[],o=t=>e[t],s=o(r);if(typeof s==`string`)return s;if(s!==void 0&&a.push(s),r.includes(`-`)){let t=r.split(`-`)[0];if(t in e){let e=o(t);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}}if(i!==void 0&&i!==r){if(i in e){let e=o(i);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}if(i.includes(`-`)){let t=i.split(`-`)[0];if(t!==r.split(`-`)[0]&&t in e){let e=o(t);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}}}if(a.length===0)return;let c=a.filter(e=>e!==void 0).map(e=>n(e));return c.length===1||Array.isArray(c[0])?c[0]:c.reduce((e,n)=>t(e,n))};export{r as getTranslation};
111
2
  //# sourceMappingURL=getTranslation.mjs.map