@intlayer/core 9.0.0-canary.17 → 9.0.0-canary.18

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 (484) hide show
  1. package/dist/cjs/deepTransformPlugins/getEditedContent.cjs +2 -1
  2. package/dist/cjs/deepTransformPlugins/getEditedContent.cjs.map +1 -1
  3. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  5. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  7. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  9. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  11. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -1
  12. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  13. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  14. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  15. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  16. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  17. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  18. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  19. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  20. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -2
  21. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  22. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs +0 -1
  23. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs.map +1 -1
  24. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +0 -1
  26. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs.map +1 -1
  28. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  30. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  31. package/dist/cjs/formatters/compact.cjs +1 -2
  32. package/dist/cjs/formatters/compact.cjs.map +1 -1
  33. package/dist/cjs/formatters/currency.cjs +1 -2
  34. package/dist/cjs/formatters/currency.cjs.map +1 -1
  35. package/dist/cjs/formatters/date.cjs +1 -3
  36. package/dist/cjs/formatters/date.cjs.map +1 -1
  37. package/dist/cjs/formatters/list.cjs +1 -2
  38. package/dist/cjs/formatters/list.cjs.map +1 -1
  39. package/dist/cjs/formatters/number.cjs +1 -2
  40. package/dist/cjs/formatters/number.cjs.map +1 -1
  41. package/dist/cjs/formatters/percentage.cjs +1 -2
  42. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  43. package/dist/cjs/formatters/relativeTime.cjs +1 -2
  44. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  45. package/dist/cjs/formatters/units.cjs +1 -2
  46. package/dist/cjs/formatters/units.cjs.map +1 -1
  47. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  48. package/dist/cjs/interpreter/getContent/deepTransform.cjs +3 -2
  49. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  50. package/dist/cjs/interpreter/getContent/getContent.cjs +0 -1
  51. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  52. package/dist/cjs/interpreter/getContent/plugins.cjs +4 -2
  53. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  54. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  55. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  56. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  57. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  58. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  59. package/dist/cjs/interpreter/getIntlayer.cjs +2 -2
  60. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  61. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  62. package/dist/cjs/interpreter/getPlural.cjs +1 -1
  63. package/dist/cjs/interpreter/getPlural.cjs.map +1 -1
  64. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  65. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  66. package/dist/cjs/localization/comparePaths.cjs.map +1 -1
  67. package/dist/cjs/localization/domainUtils.cjs.map +1 -1
  68. package/dist/cjs/localization/generateSitemap.cjs +2 -1
  69. package/dist/cjs/localization/generateSitemap.cjs.map +1 -1
  70. package/dist/cjs/localization/getBrowserLocale.cjs +7 -4
  71. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  72. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  73. package/dist/cjs/localization/getLocale.cjs +0 -1
  74. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  75. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  76. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  77. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  78. package/dist/cjs/localization/getLocalizedUrl.cjs +0 -1
  79. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  80. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  81. package/dist/cjs/localization/getPathWithoutLocale.cjs +0 -1
  82. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  83. package/dist/cjs/localization/getPrefix.cjs +0 -1
  84. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  85. package/dist/cjs/localization/localeDetector.cjs +2 -1
  86. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  87. package/dist/cjs/localization/localeMapper.cjs +0 -1
  88. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  89. package/dist/cjs/localization/localeResolver.cjs +0 -1
  90. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  91. package/dist/cjs/localization/rewriteUtils.cjs +2 -1
  92. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  93. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  94. package/dist/cjs/markdown/compiler.cjs +2 -1
  95. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  96. package/dist/cjs/markdown/constants.cjs.map +1 -1
  97. package/dist/cjs/markdown/parser.cjs.map +1 -1
  98. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  99. package/dist/cjs/markdown/utils.cjs.map +1 -1
  100. package/dist/cjs/messageFormat/ICU.cjs +15 -9
  101. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  102. package/dist/cjs/messageFormat/i18next.cjs +12 -7
  103. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  104. package/dist/cjs/messageFormat/navigatePath.cjs.map +1 -1
  105. package/dist/cjs/messageFormat/po.cjs.map +1 -1
  106. package/dist/cjs/messageFormat/resolveMessage.cjs +11 -8
  107. package/dist/cjs/messageFormat/resolveMessage.cjs.map +1 -1
  108. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  109. package/dist/cjs/messageFormat/vue-i18n.cjs +2 -1
  110. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  111. package/dist/cjs/transpiler/condition/condition.cjs +0 -1
  112. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  113. package/dist/cjs/transpiler/enumeration/enumeration.cjs +0 -1
  114. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  115. package/dist/cjs/transpiler/file/file.cjs +2 -2
  116. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  117. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  118. package/dist/cjs/transpiler/gender/gender.cjs +0 -1
  119. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  120. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  121. package/dist/cjs/transpiler/html/html.cjs +0 -1
  122. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  123. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  124. package/dist/cjs/transpiler/html/validateHTML.cjs +1 -1
  125. package/dist/cjs/transpiler/html/validateHTML.cjs.map +1 -1
  126. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  127. package/dist/cjs/transpiler/insertion/insertion.cjs +0 -1
  128. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  129. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  130. package/dist/cjs/transpiler/markdown/markdown.cjs +0 -1
  131. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  132. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs.map +1 -1
  133. package/dist/cjs/transpiler/nesting/nesting.cjs +0 -1
  134. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  135. package/dist/cjs/transpiler/plural/plural.cjs +0 -1
  136. package/dist/cjs/transpiler/plural/plural.cjs.map +1 -1
  137. package/dist/cjs/transpiler/translation/translation.cjs +0 -1
  138. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  139. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  140. package/dist/cjs/utils/cookieExpiry.cjs.map +1 -1
  141. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  142. package/dist/cjs/utils/intl.cjs +101 -26
  143. package/dist/cjs/utils/intl.cjs.map +1 -1
  144. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  145. package/dist/cjs/utils/localeStorage.cjs +0 -1
  146. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  147. package/dist/cjs/utils/parseYaml.cjs +1 -1
  148. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  149. package/dist/cjs/utils/stringifyYaml.cjs +1 -1
  150. package/dist/cjs/utils/stringifyYaml.cjs.map +1 -1
  151. package/dist/esm/deepTransformPlugins/getEditedContent.mjs +2 -1
  152. package/dist/esm/deepTransformPlugins/getEditedContent.mjs.map +1 -1
  153. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  154. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  155. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  156. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  157. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  158. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  159. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  160. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  161. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -1
  162. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  163. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  164. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  165. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  166. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  167. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  168. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  169. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  170. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -1
  171. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  172. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs.map +1 -1
  173. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  174. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  175. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs.map +1 -1
  176. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  177. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  178. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  179. package/dist/esm/formatters/compact.mjs +1 -1
  180. package/dist/esm/formatters/compact.mjs.map +1 -1
  181. package/dist/esm/formatters/currency.mjs +1 -1
  182. package/dist/esm/formatters/currency.mjs.map +1 -1
  183. package/dist/esm/formatters/date.mjs +1 -2
  184. package/dist/esm/formatters/date.mjs.map +1 -1
  185. package/dist/esm/formatters/list.mjs +1 -1
  186. package/dist/esm/formatters/list.mjs.map +1 -1
  187. package/dist/esm/formatters/number.mjs +1 -1
  188. package/dist/esm/formatters/number.mjs.map +1 -1
  189. package/dist/esm/formatters/percentage.mjs +1 -1
  190. package/dist/esm/formatters/percentage.mjs.map +1 -1
  191. package/dist/esm/formatters/relativeTime.mjs +1 -1
  192. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  193. package/dist/esm/formatters/units.mjs +1 -1
  194. package/dist/esm/formatters/units.mjs.map +1 -1
  195. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  196. package/dist/esm/interpreter/getContent/deepTransform.mjs +3 -2
  197. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  198. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  199. package/dist/esm/interpreter/getContent/plugins.mjs +4 -2
  200. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  201. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  202. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  203. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  204. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  205. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  206. package/dist/esm/interpreter/getIntlayer.mjs +2 -1
  207. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  208. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  209. package/dist/esm/interpreter/getPlural.mjs +1 -1
  210. package/dist/esm/interpreter/getPlural.mjs.map +1 -1
  211. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  212. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  213. package/dist/esm/localization/comparePaths.mjs.map +1 -1
  214. package/dist/esm/localization/domainUtils.mjs.map +1 -1
  215. package/dist/esm/localization/generateSitemap.mjs +2 -1
  216. package/dist/esm/localization/generateSitemap.mjs.map +1 -1
  217. package/dist/esm/localization/getBrowserLocale.mjs +7 -3
  218. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  219. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  220. package/dist/esm/localization/getLocale.mjs.map +1 -1
  221. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  222. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  223. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  224. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  225. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  226. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  227. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  228. package/dist/esm/localization/localeDetector.mjs +2 -1
  229. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  230. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  231. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  232. package/dist/esm/localization/rewriteUtils.mjs +2 -1
  233. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  234. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  235. package/dist/esm/markdown/compiler.mjs +2 -1
  236. package/dist/esm/markdown/compiler.mjs.map +1 -1
  237. package/dist/esm/markdown/constants.mjs.map +1 -1
  238. package/dist/esm/markdown/parser.mjs.map +1 -1
  239. package/dist/esm/markdown/renderer.mjs.map +1 -1
  240. package/dist/esm/markdown/utils.mjs.map +1 -1
  241. package/dist/esm/messageFormat/ICU.mjs +15 -9
  242. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  243. package/dist/esm/messageFormat/i18next.mjs +12 -7
  244. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  245. package/dist/esm/messageFormat/navigatePath.mjs.map +1 -1
  246. package/dist/esm/messageFormat/po.mjs.map +1 -1
  247. package/dist/esm/messageFormat/resolveMessage.mjs +11 -8
  248. package/dist/esm/messageFormat/resolveMessage.mjs.map +1 -1
  249. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  250. package/dist/esm/messageFormat/vue-i18n.mjs +2 -1
  251. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  252. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  253. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  254. package/dist/esm/transpiler/file/file.mjs +2 -1
  255. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  256. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  257. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  258. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  259. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  260. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  261. package/dist/esm/transpiler/html/validateHTML.mjs +1 -1
  262. package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -1
  263. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  264. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  265. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  266. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  267. package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -1
  268. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  269. package/dist/esm/transpiler/plural/plural.mjs.map +1 -1
  270. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  271. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  272. package/dist/esm/utils/cookieExpiry.mjs.map +1 -1
  273. package/dist/esm/utils/getCookie.mjs.map +1 -1
  274. package/dist/esm/utils/intl.mjs +100 -25
  275. package/dist/esm/utils/intl.mjs.map +1 -1
  276. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  277. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  278. package/dist/esm/utils/parseYaml.mjs +1 -1
  279. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  280. package/dist/esm/utils/stringifyYaml.mjs +1 -1
  281. package/dist/esm/utils/stringifyYaml.mjs.map +1 -1
  282. package/dist/types/deepTransformPlugins/getEditedContent.d.ts +0 -1
  283. package/dist/types/deepTransformPlugins/getEditedContent.d.ts.map +1 -1
  284. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +12 -13
  285. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
  286. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +12 -13
  287. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  288. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +12 -13
  289. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  290. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +1 -1
  291. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -1
  292. package/dist/types/deepTransformPlugins/getMaskContent.d.ts +1 -1
  293. package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +1 -1
  294. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +1 -1
  295. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +1 -1
  296. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +0 -1
  297. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +1 -1
  298. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +1 -1
  299. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +1 -1
  300. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +1 -2
  301. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -1
  302. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +1 -2
  303. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +1 -1
  304. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +0 -1
  305. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -1
  306. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +0 -1
  307. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -1
  308. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +0 -1
  309. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -1
  310. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +0 -1
  311. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -1
  312. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +0 -1
  313. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -1
  314. package/dist/types/dictionaryManipulator/getNodeType.d.ts +0 -1
  315. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
  316. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +0 -1
  317. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +1 -1
  318. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts +0 -1
  319. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts.map +1 -1
  320. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +0 -1
  321. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +1 -1
  322. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +1 -2
  323. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
  324. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts +1 -2
  325. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts.map +1 -1
  326. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +0 -1
  327. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -1
  328. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +1 -2
  329. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -1
  330. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +0 -1
  331. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -1
  332. package/dist/types/formatters/compact.d.ts +0 -1
  333. package/dist/types/formatters/compact.d.ts.map +1 -1
  334. package/dist/types/formatters/currency.d.ts +0 -1
  335. package/dist/types/formatters/currency.d.ts.map +1 -1
  336. package/dist/types/formatters/date.d.ts +0 -1
  337. package/dist/types/formatters/date.d.ts.map +1 -1
  338. package/dist/types/formatters/index.d.ts +2 -2
  339. package/dist/types/formatters/list.d.ts +0 -1
  340. package/dist/types/formatters/list.d.ts.map +1 -1
  341. package/dist/types/formatters/number.d.ts +1 -5
  342. package/dist/types/formatters/number.d.ts.map +1 -1
  343. package/dist/types/formatters/percentage.d.ts +1 -5
  344. package/dist/types/formatters/percentage.d.ts.map +1 -1
  345. package/dist/types/formatters/relativeTime.d.ts +0 -1
  346. package/dist/types/formatters/relativeTime.d.ts.map +1 -1
  347. package/dist/types/formatters/units.d.ts +0 -1
  348. package/dist/types/formatters/units.d.ts.map +1 -1
  349. package/dist/types/index.d.ts +11 -2
  350. package/dist/types/interpreter/getCondition.d.ts +1 -0
  351. package/dist/types/interpreter/getCondition.d.ts.map +1 -1
  352. package/dist/types/interpreter/getContent/deepTransform.d.ts +0 -1
  353. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -1
  354. package/dist/types/interpreter/getContent/getContent.d.ts +0 -1
  355. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  356. package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
  357. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  358. package/dist/types/interpreter/getDictionary.d.ts +1 -1
  359. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  360. package/dist/types/interpreter/getEnumeration.d.ts +1 -0
  361. package/dist/types/interpreter/getEnumeration.d.ts.map +1 -1
  362. package/dist/types/interpreter/getGender.d.ts +1 -0
  363. package/dist/types/interpreter/getGender.d.ts.map +1 -1
  364. package/dist/types/interpreter/getHTML.d.ts.map +1 -1
  365. package/dist/types/interpreter/getInsertion.d.ts +2 -1
  366. package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
  367. package/dist/types/interpreter/getIntlayer.d.ts +1 -1
  368. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  369. package/dist/types/interpreter/getNesting.d.ts +2 -1
  370. package/dist/types/interpreter/getNesting.d.ts.map +1 -1
  371. package/dist/types/interpreter/getPlural.d.ts +0 -1
  372. package/dist/types/interpreter/getPlural.d.ts.map +1 -1
  373. package/dist/types/interpreter/getTranslation.d.ts +0 -1
  374. package/dist/types/interpreter/getTranslation.d.ts.map +1 -1
  375. package/dist/types/interpreter/index.d.ts +1 -0
  376. package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +1 -1
  377. package/dist/types/localization/comparePaths.d.ts +0 -1
  378. package/dist/types/localization/comparePaths.d.ts.map +1 -1
  379. package/dist/types/localization/domainUtils.d.ts +0 -1
  380. package/dist/types/localization/domainUtils.d.ts.map +1 -1
  381. package/dist/types/localization/generateSitemap.d.ts +6 -4
  382. package/dist/types/localization/generateSitemap.d.ts.map +1 -1
  383. package/dist/types/localization/getBrowserLocale.d.ts +0 -1
  384. package/dist/types/localization/getBrowserLocale.d.ts.map +1 -1
  385. package/dist/types/localization/getHTMLTextDir.d.ts +0 -1
  386. package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -1
  387. package/dist/types/localization/getLocale.d.ts +0 -1
  388. package/dist/types/localization/getLocale.d.ts.map +1 -1
  389. package/dist/types/localization/getLocaleFromPath.d.ts +0 -1
  390. package/dist/types/localization/getLocaleFromPath.d.ts.map +1 -1
  391. package/dist/types/localization/getLocaleLang.d.ts +0 -1
  392. package/dist/types/localization/getLocaleLang.d.ts.map +1 -1
  393. package/dist/types/localization/getLocaleName.d.ts +0 -1
  394. package/dist/types/localization/getLocaleName.d.ts.map +1 -1
  395. package/dist/types/localization/getLocalizedUrl.d.ts +0 -1
  396. package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
  397. package/dist/types/localization/getMultilingualUrls.d.ts +0 -1
  398. package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -1
  399. package/dist/types/localization/getPathWithoutLocale.d.ts +0 -1
  400. package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -1
  401. package/dist/types/localization/getPrefix.d.ts +2 -3
  402. package/dist/types/localization/getPrefix.d.ts.map +1 -1
  403. package/dist/types/localization/localeDetector.d.ts +0 -1
  404. package/dist/types/localization/localeDetector.d.ts.map +1 -1
  405. package/dist/types/localization/localeMapper.d.ts +3 -4
  406. package/dist/types/localization/localeMapper.d.ts.map +1 -1
  407. package/dist/types/localization/localeResolver.d.ts +0 -1
  408. package/dist/types/localization/localeResolver.d.ts.map +1 -1
  409. package/dist/types/localization/rewriteUtils.d.ts +2 -3
  410. package/dist/types/localization/rewriteUtils.d.ts.map +1 -1
  411. package/dist/types/localization/validatePrefix.d.ts +0 -1
  412. package/dist/types/localization/validatePrefix.d.ts.map +1 -1
  413. package/dist/types/markdown/compiler.d.ts +0 -1
  414. package/dist/types/markdown/compiler.d.ts.map +1 -1
  415. package/dist/types/markdown/constants.d.ts +48 -38
  416. package/dist/types/markdown/constants.d.ts.map +1 -1
  417. package/dist/types/markdown/index.d.ts +2 -1
  418. package/dist/types/markdown/parser.d.ts +0 -1
  419. package/dist/types/markdown/parser.d.ts.map +1 -1
  420. package/dist/types/markdown/renderer.d.ts +0 -1
  421. package/dist/types/markdown/renderer.d.ts.map +1 -1
  422. package/dist/types/markdown/types.d.ts +44 -24
  423. package/dist/types/markdown/types.d.ts.map +1 -1
  424. package/dist/types/markdown/utils.d.ts +3 -4
  425. package/dist/types/markdown/utils.d.ts.map +1 -1
  426. package/dist/types/messageFormat/ICU.d.ts +2 -3
  427. package/dist/types/messageFormat/ICU.d.ts.map +1 -1
  428. package/dist/types/messageFormat/i18next.d.ts +2 -3
  429. package/dist/types/messageFormat/i18next.d.ts.map +1 -1
  430. package/dist/types/messageFormat/navigatePath.d.ts.map +1 -1
  431. package/dist/types/messageFormat/po.d.ts +2 -3
  432. package/dist/types/messageFormat/po.d.ts.map +1 -1
  433. package/dist/types/messageFormat/resolveMessage.d.ts +0 -1
  434. package/dist/types/messageFormat/resolveMessage.d.ts.map +1 -1
  435. package/dist/types/messageFormat/verify-icu-format.d.ts +1 -1
  436. package/dist/types/messageFormat/vue-i18n.d.ts +2 -3
  437. package/dist/types/messageFormat/vue-i18n.d.ts.map +1 -1
  438. package/dist/types/transpiler/condition/condition.d.ts +0 -1
  439. package/dist/types/transpiler/condition/condition.d.ts.map +1 -1
  440. package/dist/types/transpiler/enumeration/enumeration.d.ts +0 -1
  441. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  442. package/dist/types/transpiler/file/file.d.ts +0 -1
  443. package/dist/types/transpiler/file/file.d.ts.map +1 -1
  444. package/dist/types/transpiler/file/fileBrowser.d.ts +0 -1
  445. package/dist/types/transpiler/file/fileBrowser.d.ts.map +1 -1
  446. package/dist/types/transpiler/gender/gender.d.ts +0 -1
  447. package/dist/types/transpiler/gender/gender.d.ts.map +1 -1
  448. package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -1
  449. package/dist/types/transpiler/html/html.d.ts +0 -1
  450. package/dist/types/transpiler/html/html.d.ts.map +1 -1
  451. package/dist/types/transpiler/html/htmlTags.d.ts +1 -1
  452. package/dist/types/transpiler/html/htmlTags.d.ts.map +1 -1
  453. package/dist/types/transpiler/html/validateHTML.d.ts.map +1 -1
  454. package/dist/types/transpiler/index.d.ts +11 -1
  455. package/dist/types/transpiler/insertion/getInsertionValues.d.ts.map +1 -1
  456. package/dist/types/transpiler/insertion/insertion.d.ts +0 -1
  457. package/dist/types/transpiler/insertion/insertion.d.ts.map +1 -1
  458. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +1 -1
  459. package/dist/types/transpiler/markdown/index.d.ts +1 -1
  460. package/dist/types/transpiler/markdown/markdown.d.ts +0 -1
  461. package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
  462. package/dist/types/transpiler/markdown/validateMarkdown.d.ts +0 -1
  463. package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +1 -1
  464. package/dist/types/transpiler/nesting/nesting.d.ts +4 -4
  465. package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
  466. package/dist/types/transpiler/plural/plural.d.ts +0 -1
  467. package/dist/types/transpiler/plural/plural.d.ts.map +1 -1
  468. package/dist/types/transpiler/translation/translation.d.ts +0 -1
  469. package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
  470. package/dist/types/utils/checkIsURLAbsolute.d.ts.map +1 -1
  471. package/dist/types/utils/cookieExpiry.d.ts +1 -2
  472. package/dist/types/utils/cookieExpiry.d.ts.map +1 -1
  473. package/dist/types/utils/getCookie.d.ts.map +1 -1
  474. package/dist/types/utils/index.d.ts +2 -2
  475. package/dist/types/utils/intl.d.ts +49 -5
  476. package/dist/types/utils/intl.d.ts.map +1 -1
  477. package/dist/types/utils/isSameKeyPath.d.ts +0 -1
  478. package/dist/types/utils/isSameKeyPath.d.ts.map +1 -1
  479. package/dist/types/utils/isValidReactElement.d.ts.map +1 -1
  480. package/dist/types/utils/localeStorage.d.ts +1 -2
  481. package/dist/types/utils/localeStorage.d.ts.map +1 -1
  482. package/dist/types/utils/parseYaml.d.ts.map +1 -1
  483. package/dist/types/utils/stringifyYaml.d.ts.map +1 -1
  484. package/package.json +9 -9
@@ -33,9 +33,9 @@ const formatArgument = (value, type, style, locale) => {
33
33
  try {
34
34
  if (type === "number") {
35
35
  const numberValue = Number(value);
36
- if (style === "percent") return require_utils_intl.getCachedIntl(Intl.NumberFormat, locale, { style: "percent" }).format(numberValue);
37
- if (style === "integer") return require_utils_intl.getCachedIntl(Intl.NumberFormat, locale, { maximumFractionDigits: 0 }).format(numberValue);
38
- return require_utils_intl.getCachedIntl(Intl.NumberFormat, locale).format(numberValue);
36
+ if (style === "percent") return require_utils_intl.getCachedIntl("NumberFormat", locale, { style: "percent" }).format(numberValue);
37
+ if (style === "integer") return require_utils_intl.getCachedIntl("NumberFormat", locale, { maximumFractionDigits: 0 }).format(numberValue);
38
+ return require_utils_intl.getCachedIntl("NumberFormat", locale).format(numberValue);
39
39
  }
40
40
  if (type === "date" || type === "time") {
41
41
  const dateValue = value instanceof Date ? value : new Date(value);
@@ -45,7 +45,7 @@ const formatArgument = (value, type, style, locale) => {
45
45
  "long",
46
46
  "full"
47
47
  ].includes(style ?? "") ? style : type === "date" ? "medium" : "short";
48
- return require_utils_intl.getCachedIntl(Intl.DateTimeFormat, locale, type === "date" ? { dateStyle: dateTimeStyle } : { timeStyle: dateTimeStyle }).format(dateValue);
48
+ return require_utils_intl.getCachedIntl("DateTimeFormat", locale, type === "date" ? { dateStyle: dateTimeStyle } : { timeStyle: dateTimeStyle }).format(dateValue);
49
49
  }
50
50
  } catch {}
51
51
  return String(value);
@@ -94,7 +94,8 @@ const resolveMessageNode = (node, values = {}, locale = "en") => {
94
94
  if (typedNode.nodeType === _intlayer_types_nodeType.HTML) return resolveMessageNode(typedNode[_intlayer_types_nodeType.HTML], values, locale);
95
95
  if (typedNode.nodeType === _intlayer_types_nodeType.PLURAL) {
96
96
  const pluralState = typedNode[_intlayer_types_nodeType.PLURAL];
97
- return resolveMessageNode(require_interpreter_getPlural.getPlural(pluralState, Number(getSelectorValue(values, "count") ?? 1), locale), values, locale);
97
+ const selected = require_interpreter_getPlural.getPlural(pluralState, Number(getSelectorValue(values, "count") ?? 1), locale);
98
+ return resolveMessageNode(selected, values, locale);
98
99
  }
99
100
  if (typedNode.nodeType === _intlayer_types_nodeType.ENUMERATION) {
100
101
  const enumerationState = typedNode[_intlayer_types_nodeType.ENUMERATION];
@@ -106,7 +107,7 @@ const resolveMessageNode = (node, values = {}, locale = "en") => {
106
107
  let selected;
107
108
  if (isOrdinal && !Number.isNaN(Number(selector))) {
108
109
  const ordinalCount = Number(selector);
109
- const ordinalCategory = require_utils_intl.getCachedIntl(Intl.PluralRules, locale, { type: "ordinal" }).select(ordinalCount);
110
+ const ordinalCategory = require_utils_intl.getCachedIntl("PluralRules", locale, { type: "ordinal" }).select(ordinalCount);
110
111
  selected = options[String(ordinalCount)] ?? options[ordinalCategory] ?? options.fallback ?? options.other;
111
112
  } else if (typeof selector === "number" || !Number.isNaN(Number(selector))) selected = require_interpreter_getEnumeration.getEnumeration(options, Number(selector));
112
113
  else selected = options[String(selector)] ?? options.fallback ?? options.other;
@@ -114,7 +115,8 @@ const resolveMessageNode = (node, values = {}, locale = "en") => {
114
115
  }
115
116
  if (typedNode.nodeType === _intlayer_types_nodeType.GENDER) {
116
117
  const genderState = typedNode[_intlayer_types_nodeType.GENDER];
117
- return resolveMessageNode(genderState[String(values.gender ?? "")] ?? genderState.fallback ?? genderState.other, values, locale);
118
+ const selected = genderState[String(values.gender ?? "")] ?? genderState.fallback ?? genderState.other;
119
+ return resolveMessageNode(selected, values, locale);
118
120
  }
119
121
  return node;
120
122
  };
@@ -142,7 +144,8 @@ const DIALECT_FORMATTERS = {
142
144
  * ```
143
145
  */
144
146
  const resolveMessage = (message, values = {}, locale = "en", dialect = "icu") => {
145
- const resolved = resolveMessageNode(typeof message === "string" ? DIALECT_FORMATTERS[dialect](message) : message, values, locale);
147
+ const node = typeof message === "string" ? DIALECT_FORMATTERS[dialect](message) : message;
148
+ const resolved = resolveMessageNode(node, values, locale);
146
149
  return typeof resolved === "string" ? resolved : String(resolved ?? "");
147
150
  };
148
151
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"resolveMessage.cjs","names":["getCachedIntl","NodeTypes","getPlural","getEnumeration","icuToIntlayerFormatter","i18nextToIntlayerFormatter","vueI18nToIntlayerFormatter"],"sources":["../../../src/messageFormat/resolveMessage.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { getCachedIntl } from '../formatters';\nimport { getEnumeration } from '../interpreter/getEnumeration';\nimport { getPlural } from '../interpreter/getPlural';\nimport type { PluralContentState } from '../transpiler/plural/plural';\nimport { icuToIntlayerFormatter } from './ICU';\nimport { i18nextToIntlayerFormatter } from './i18next';\nimport { vueI18nToIntlayerFormatter } from './vue-i18n';\n\n/**\n * Runtime counterpart of the `messageFormat` converters.\n *\n * The converters (`icuToIntlayerFormatter`, `i18nextToIntlayerFormatter`,\n * `vueI18nToIntlayerFormatter`) turn library-specific message syntax into\n * intlayer nodes (`insert`, `plural`, `enu`, `gender`, `html`). This module\n * resolves those nodes — or raw message strings — into a final string using\n * the provided interpolation values and locale.\n *\n * It is the mutualized resolution engine used by the compat adapter packages\n * (`@intlayer/i18next`, `@intlayer/next-intl`, `@intlayer/vue-i18n`, …).\n */\n\n/** Message syntax dialect of the source i18n library. */\nexport type MessageFormatDialect = 'icu' | 'i18next' | 'vue-i18n';\n\n/** Interpolation values passed alongside a translation lookup. */\nexport type MessageValues = Record<string, unknown>;\n\n/** Internal enumeration metadata keys injected by the converters. */\nconst ENUMERATION_METADATA_KEYS = [\n '__intlayer_icu_var',\n '__intlayer_icu_ordinal',\n '__intlayer_vue_i18n_var',\n] as const;\n\n/**\n * Resolves a possibly-dotted path (`user.name`) inside the values object.\n */\nconst resolveValuePath = (values: MessageValues, path: string): unknown => {\n if (path in values) return values[path];\n\n let current: unknown = values;\n for (const part of path.split('.')) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/** Formats an ICU-style formatted argument (`{value, number, percent}`). */\nconst formatArgument = (\n value: unknown,\n type: string,\n style: string | undefined,\n locale: LocalesValues\n): string => {\n try {\n if (type === 'number') {\n const numberValue = Number(value);\n if (style === 'percent') {\n return getCachedIntl(Intl.NumberFormat, locale, {\n style: 'percent',\n }).format(numberValue);\n }\n if (style === 'integer') {\n return getCachedIntl(Intl.NumberFormat, locale, {\n maximumFractionDigits: 0,\n }).format(numberValue);\n }\n return getCachedIntl(Intl.NumberFormat, locale).format(numberValue);\n }\n\n if (type === 'date' || type === 'time') {\n const dateValue =\n value instanceof Date ? value : new Date(value as string | number);\n const dateTimeStyle = (\n ['short', 'medium', 'long', 'full'].includes(style ?? '')\n ? style\n : type === 'date'\n ? 'medium'\n : 'short'\n ) as 'short' | 'medium' | 'long' | 'full';\n\n return getCachedIntl(\n Intl.DateTimeFormat,\n locale,\n type === 'date'\n ? { dateStyle: dateTimeStyle }\n : { timeStyle: dateTimeStyle }\n ).format(dateValue);\n }\n } catch {\n // Fall through to the raw string representation below\n }\n\n return String(value);\n};\n\n/**\n * Interpolates a message template with values.\n *\n * Handles, in order:\n * 1. Intlayer insertions `{{name}}` (whitespace-tolerant, dotted paths)\n * 2. ICU formatted arguments `{value, number}` / `{ts, date, long}`\n * 3. Bare single-brace arguments `{name}` (ICU / vue-i18n simple args)\n */\nexport const interpolateMessage = (\n template: string,\n values: MessageValues = {},\n locale: LocalesValues = 'en' as LocalesValues\n): string =>\n template\n .replace(/\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g, (match, path: string) => {\n const value = resolveValuePath(values, path);\n return value === undefined ? match : String(value);\n })\n .replace(\n /\\{\\s*([\\w.]+)\\s*,\\s*(\\w+)\\s*(?:,\\s*([^}]+?)\\s*)?\\}/g,\n (match, path: string, type: string, style: string | undefined) => {\n const value = resolveValuePath(values, path);\n if (value === undefined) return match;\n return formatArgument(value, type, style, locale);\n }\n )\n .replace(/\\{\\s*([\\w.]+)\\s*\\}/g, (match, path: string) => {\n const value = resolveValuePath(values, path);\n return value === undefined ? match : String(value);\n });\n\n/** Reads the selector value of an enumeration/plural node from the values. */\nconst getSelectorValue = (\n values: MessageValues,\n variableName: string\n): unknown => values[variableName] ?? values.count ?? values.n;\n\n/**\n * Resolves an intlayer message node tree (as produced by the\n * `*ToIntlayerFormatter` converters, or already present in a built\n * dictionary) into its final value using interpolation values and locale.\n *\n * Function nodes (produced by the interpreter plugins for `insertion`,\n * `enumeration` and `plural` content) are invoked with the values.\n */\nexport const resolveMessageNode = (\n node: unknown,\n values: MessageValues = {},\n locale: LocalesValues = 'en' as LocalesValues\n): unknown => {\n if (node === null || node === undefined) return node;\n\n if (typeof node === 'string') {\n return interpolateMessage(node, values, locale);\n }\n\n if (typeof node === 'number' || typeof node === 'boolean') {\n return String(node);\n }\n\n // Interpreter-transformed nodes (insertion/enumeration/plural plugins)\n // are exposed as callables taking the interpolation values.\n if (typeof node === 'function') {\n try {\n return resolveMessageNode(\n (node as (arg: MessageValues) => unknown)(values),\n values,\n locale\n );\n } catch {\n return undefined;\n }\n }\n\n if (Array.isArray(node)) {\n return node\n .map((item) => String(resolveMessageNode(item, values, locale) ?? ''))\n .join('');\n }\n\n const typedNode = node as Record<string, unknown> & { nodeType?: string };\n\n if (typedNode.nodeType === NodeTypes.INSERTION) {\n return resolveMessageNode(typedNode[NodeTypes.INSERTION], values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.HTML) {\n // Tags are kept intact — rich rendering is handled by the caller\n return resolveMessageNode(typedNode[NodeTypes.HTML], values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.PLURAL) {\n const pluralState = typedNode[\n NodeTypes.PLURAL\n ] as PluralContentState<unknown>;\n const count = Number(getSelectorValue(values, 'count') ?? 1);\n const selected = getPlural(\n pluralState as PluralContentState<string>,\n count,\n locale\n );\n return resolveMessageNode(selected, values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.ENUMERATION) {\n const enumerationState = typedNode[NodeTypes.ENUMERATION] as Record<\n string,\n unknown\n >;\n\n const variableName = (ENUMERATION_METADATA_KEYS.map(\n (metadataKey) => enumerationState[metadataKey]\n ).find((name) => typeof name === 'string') ?? 'count') as string;\n\n const isOrdinal = enumerationState.__intlayer_icu_ordinal === true;\n\n const options: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(enumerationState)) {\n if (!(ENUMERATION_METADATA_KEYS as readonly string[]).includes(key)) {\n options[key] = value;\n }\n }\n\n const selector = getSelectorValue(values, variableName);\n\n let selected: unknown;\n if (isOrdinal && !Number.isNaN(Number(selector))) {\n // ICU `selectordinal` — exact numeric match first, then the CLDR\n // ordinal category, then the fallback\n const ordinalCount = Number(selector);\n const ordinalCategory = getCachedIntl(Intl.PluralRules, locale, {\n type: 'ordinal',\n }).select(ordinalCount);\n selected =\n options[String(ordinalCount)] ??\n options[ordinalCategory] ??\n options.fallback ??\n options.other;\n } else if (\n typeof selector === 'number' ||\n !Number.isNaN(Number(selector))\n ) {\n selected = getEnumeration(options, Number(selector));\n } else {\n // String selector — ICU `select` converted to an enumeration\n selected = options[String(selector)] ?? options.fallback ?? options.other;\n }\n\n return resolveMessageNode(selected, values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.GENDER) {\n const genderState = typedNode[NodeTypes.GENDER] as Record<string, unknown>;\n const genderValue = String(values.gender ?? '');\n const selected =\n genderState[genderValue] ?? genderState.fallback ?? genderState.other;\n return resolveMessageNode(selected, values, locale);\n }\n\n return node;\n};\n\nconst DIALECT_FORMATTERS: Record<\n MessageFormatDialect,\n (message: string) => unknown\n> = {\n icu: (message) => icuToIntlayerFormatter(message),\n i18next: (message) => i18nextToIntlayerFormatter(message),\n 'vue-i18n': (message) => vueI18nToIntlayerFormatter(message),\n};\n\n/**\n * Resolves a raw message — string in a library dialect, or an intlayer node\n * tree — into a final string using interpolation values and locale.\n *\n * @example\n * ```ts\n * resolveMessage('Hello {name}', { name: 'John' }, 'en', 'icu');\n * // 'Hello John'\n *\n * resolveMessage(\n * '{count, plural, one {# item} other {# items}}',\n * { count: 3 },\n * 'en',\n * 'icu'\n * );\n * // '3 items'\n * ```\n */\nexport const resolveMessage = (\n message: unknown,\n values: MessageValues = {},\n locale: LocalesValues = 'en' as LocalesValues,\n dialect: MessageFormatDialect = 'icu'\n): string => {\n const node =\n typeof message === 'string'\n ? DIALECT_FORMATTERS[dialect](message)\n : message;\n\n const resolved = resolveMessageNode(node, values, locale);\n\n return typeof resolved === 'string' ? resolved : String(resolved ?? '');\n};\n\n/** A parsed token of a tagged message: plain text or a tag with children. */\nexport type TaggedMessageToken =\n | string\n | { tag: string; children: TaggedMessageToken[] };\n\n/**\n * Tokenizes a message containing XML-like tags (`'Visit <link>the docs</link>'`,\n * `'hello <1>{{name}}</1>'`, `'line<br/>break'`) into a token tree.\n *\n * Used by rich-text renderers (`t.rich`, `<Trans components>`,\n * `<i18n-t>` slots) to map tags to framework elements.\n */\nexport const parseTaggedMessage = (message: string): TaggedMessageToken[] => {\n const tokens: TaggedMessageToken[] = [];\n const tagRegex = /<([\\w-]+)\\s*\\/>|<([\\w-]+)[^>]*>([\\s\\S]*?)<\\/\\2>/g;\n let lastIndex = 0;\n let match = tagRegex.exec(message);\n\n while (match !== null) {\n if (match.index > lastIndex) {\n tokens.push(message.slice(lastIndex, match.index));\n }\n\n const [, selfClosingTag, tag, inner] = match;\n\n if (selfClosingTag) {\n tokens.push({ tag: selfClosingTag, children: [] });\n } else {\n tokens.push({ tag, children: parseTaggedMessage(inner) });\n }\n\n lastIndex = match.index + match[0].length;\n match = tagRegex.exec(message);\n }\n\n if (lastIndex < message.length) {\n tokens.push(message.slice(lastIndex));\n }\n\n return tokens;\n};\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAM,4BAA4B;CAChC;CACA;CACA;CACD;;;;AAKD,MAAM,oBAAoB,QAAuB,SAA0B;AACzE,KAAI,QAAQ,OAAQ,QAAO,OAAO;CAElC,IAAI,UAAmB;AACvB,MAAK,MAAM,QAAQ,KAAK,MAAM,IAAI,EAAE;AAClC,MACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,SAEnB;AAEF,YAAW,QAAoC;;AAEjD,QAAO;;;AAIT,MAAM,kBACJ,OACA,MACA,OACA,WACW;AACX,KAAI;AACF,MAAI,SAAS,UAAU;GACrB,MAAM,cAAc,OAAO,MAAM;AACjC,OAAI,UAAU,UACZ,QAAOA,iCAAc,KAAK,cAAc,QAAQ,EAC9C,OAAO,WACR,CAAC,CAAC,OAAO,YAAY;AAExB,OAAI,UAAU,UACZ,QAAOA,iCAAc,KAAK,cAAc,QAAQ,EAC9C,uBAAuB,GACxB,CAAC,CAAC,OAAO,YAAY;AAExB,UAAOA,iCAAc,KAAK,cAAc,OAAO,CAAC,OAAO,YAAY;;AAGrE,MAAI,SAAS,UAAU,SAAS,QAAQ;GACtC,MAAM,YACJ,iBAAiB,OAAO,QAAQ,IAAI,KAAK,MAAyB;GACpE,MAAM,gBACJ;IAAC;IAAS;IAAU;IAAQ;IAAO,CAAC,SAAS,SAAS,GAAG,GACrD,QACA,SAAS,SACP,WACA;AAGR,UAAOA,iCACL,KAAK,gBACL,QACA,SAAS,SACL,EAAE,WAAW,eAAe,GAC5B,EAAE,WAAW,eAAe,CACjC,CAAC,OAAO,UAAU;;SAEf;AAIR,QAAO,OAAO,MAAM;;;;;;;;;;AAWtB,MAAa,sBACX,UACA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;CACjD,UAAU,YAAYC,yDAA2B,QAAQ;CACzD,aAAa,YAAYC,0DAA2B,QAAQ;CAC7D;;;;;;;;;;;;;;;;;;;AAoBD,MAAa,kBACX,SACA,SAAwB,EAAE,EAC1B,SAAwB,MACxB,UAAgC,UACrB;CAMX,MAAM,WAAW,mBAJf,OAAO,YAAY,WACf,mBAAmB,SAAS,QAAQ,GACpC,SAEoC,QAAQ,OAAO;AAEzD,QAAO,OAAO,aAAa,WAAW,WAAW,OAAO,YAAY,GAAG;;;;;;;;;AAezE,MAAa,sBAAsB,YAA0C;CAC3E,MAAM,SAA+B,EAAE;CACvC,MAAM,WAAW;CACjB,IAAI,YAAY;CAChB,IAAI,QAAQ,SAAS,KAAK,QAAQ;AAElC,QAAO,UAAU,MAAM;AACrB,MAAI,MAAM,QAAQ,UAChB,QAAO,KAAK,QAAQ,MAAM,WAAW,MAAM,MAAM,CAAC;EAGpD,MAAM,GAAG,gBAAgB,KAAK,SAAS;AAEvC,MAAI,eACF,QAAO,KAAK;GAAE,KAAK;GAAgB,UAAU,EAAE;GAAE,CAAC;MAElD,QAAO,KAAK;GAAE;GAAK,UAAU,mBAAmB,MAAM;GAAE,CAAC;AAG3D,cAAY,MAAM,QAAQ,MAAM,GAAG;AACnC,UAAQ,SAAS,KAAK,QAAQ;;AAGhC,KAAI,YAAY,QAAQ,OACtB,QAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAGvC,QAAO"}
1
+ {"version":3,"file":"resolveMessage.cjs","names":["getCachedIntl","NodeTypes","getPlural","getEnumeration","icuToIntlayerFormatter","i18nextToIntlayerFormatter","vueI18nToIntlayerFormatter"],"sources":["../../../src/messageFormat/resolveMessage.ts"],"sourcesContent":["import type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { getCachedIntl } from '../formatters';\nimport { getEnumeration } from '../interpreter/getEnumeration';\nimport { getPlural } from '../interpreter/getPlural';\nimport type { PluralContentState } from '../transpiler/plural/plural';\nimport { icuToIntlayerFormatter } from './ICU';\nimport { i18nextToIntlayerFormatter } from './i18next';\nimport { vueI18nToIntlayerFormatter } from './vue-i18n';\n\n/**\n * Runtime counterpart of the `messageFormat` converters.\n *\n * The converters (`icuToIntlayerFormatter`, `i18nextToIntlayerFormatter`,\n * `vueI18nToIntlayerFormatter`) turn library-specific message syntax into\n * intlayer nodes (`insert`, `plural`, `enu`, `gender`, `html`). This module\n * resolves those nodes — or raw message strings — into a final string using\n * the provided interpolation values and locale.\n *\n * It is the mutualized resolution engine used by the compat adapter packages\n * (`@intlayer/i18next`, `@intlayer/next-intl`, `@intlayer/vue-i18n`, …).\n */\n\n/** Message syntax dialect of the source i18n library. */\nexport type MessageFormatDialect = 'icu' | 'i18next' | 'vue-i18n';\n\n/** Interpolation values passed alongside a translation lookup. */\nexport type MessageValues = Record<string, unknown>;\n\n/** Internal enumeration metadata keys injected by the converters. */\nconst ENUMERATION_METADATA_KEYS = [\n '__intlayer_icu_var',\n '__intlayer_icu_ordinal',\n '__intlayer_vue_i18n_var',\n] as const;\n\n/**\n * Resolves a possibly-dotted path (`user.name`) inside the values object.\n */\nconst resolveValuePath = (values: MessageValues, path: string): unknown => {\n if (path in values) return values[path];\n\n let current: unknown = values;\n for (const part of path.split('.')) {\n if (\n current === null ||\n current === undefined ||\n typeof current !== 'object'\n ) {\n return undefined;\n }\n current = (current as Record<string, unknown>)[part];\n }\n return current;\n};\n\n/** Formats an ICU-style formatted argument (`{value, number, percent}`). */\nconst formatArgument = (\n value: unknown,\n type: string,\n style: string | undefined,\n locale: LocalesValues\n): string => {\n try {\n if (type === 'number') {\n const numberValue = Number(value);\n if (style === 'percent') {\n return getCachedIntl('NumberFormat', locale, {\n style: 'percent',\n }).format(numberValue);\n }\n if (style === 'integer') {\n return getCachedIntl('NumberFormat', locale, {\n maximumFractionDigits: 0,\n }).format(numberValue);\n }\n return getCachedIntl('NumberFormat', locale).format(numberValue);\n }\n\n if (type === 'date' || type === 'time') {\n const dateValue =\n value instanceof Date ? value : new Date(value as string | number);\n const dateTimeStyle = (\n ['short', 'medium', 'long', 'full'].includes(style ?? '')\n ? style\n : type === 'date'\n ? 'medium'\n : 'short'\n ) as 'short' | 'medium' | 'long' | 'full';\n\n return getCachedIntl(\n 'DateTimeFormat',\n locale,\n type === 'date'\n ? { dateStyle: dateTimeStyle }\n : { timeStyle: dateTimeStyle }\n ).format(dateValue);\n }\n } catch {\n // Fall through to the raw string representation below\n }\n\n return String(value);\n};\n\n/**\n * Interpolates a message template with values.\n *\n * Handles, in order:\n * 1. Intlayer insertions `{{name}}` (whitespace-tolerant, dotted paths)\n * 2. ICU formatted arguments `{value, number}` / `{ts, date, long}`\n * 3. Bare single-brace arguments `{name}` (ICU / vue-i18n simple args)\n */\nexport const interpolateMessage = (\n template: string,\n values: MessageValues = {},\n locale: LocalesValues = 'en' as LocalesValues\n): string =>\n template\n .replace(/\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g, (match, path: string) => {\n const value = resolveValuePath(values, path);\n return value === undefined ? match : String(value);\n })\n .replace(\n /\\{\\s*([\\w.]+)\\s*,\\s*(\\w+)\\s*(?:,\\s*([^}]+?)\\s*)?\\}/g,\n (match, path: string, type: string, style: string | undefined) => {\n const value = resolveValuePath(values, path);\n if (value === undefined) return match;\n return formatArgument(value, type, style, locale);\n }\n )\n .replace(/\\{\\s*([\\w.]+)\\s*\\}/g, (match, path: string) => {\n const value = resolveValuePath(values, path);\n return value === undefined ? match : String(value);\n });\n\n/** Reads the selector value of an enumeration/plural node from the values. */\nconst getSelectorValue = (\n values: MessageValues,\n variableName: string\n): unknown => values[variableName] ?? values.count ?? values.n;\n\n/**\n * Resolves an intlayer message node tree (as produced by the\n * `*ToIntlayerFormatter` converters, or already present in a built\n * dictionary) into its final value using interpolation values and locale.\n *\n * Function nodes (produced by the interpreter plugins for `insertion`,\n * `enumeration` and `plural` content) are invoked with the values.\n */\nexport const resolveMessageNode = (\n node: unknown,\n values: MessageValues = {},\n locale: LocalesValues = 'en' as LocalesValues\n): unknown => {\n if (node === null || node === undefined) return node;\n\n if (typeof node === 'string') {\n return interpolateMessage(node, values, locale);\n }\n\n if (typeof node === 'number' || typeof node === 'boolean') {\n return String(node);\n }\n\n // Interpreter-transformed nodes (insertion/enumeration/plural plugins)\n // are exposed as callables taking the interpolation values.\n if (typeof node === 'function') {\n try {\n return resolveMessageNode(\n (node as (arg: MessageValues) => unknown)(values),\n values,\n locale\n );\n } catch {\n return undefined;\n }\n }\n\n if (Array.isArray(node)) {\n return node\n .map((item) => String(resolveMessageNode(item, values, locale) ?? ''))\n .join('');\n }\n\n const typedNode = node as Record<string, unknown> & { nodeType?: string };\n\n if (typedNode.nodeType === NodeTypes.INSERTION) {\n return resolveMessageNode(typedNode[NodeTypes.INSERTION], values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.HTML) {\n // Tags are kept intact — rich rendering is handled by the caller\n return resolveMessageNode(typedNode[NodeTypes.HTML], values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.PLURAL) {\n const pluralState = typedNode[\n NodeTypes.PLURAL\n ] as PluralContentState<unknown>;\n const count = Number(getSelectorValue(values, 'count') ?? 1);\n const selected = getPlural(\n pluralState as PluralContentState<string>,\n count,\n locale\n );\n return resolveMessageNode(selected, values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.ENUMERATION) {\n const enumerationState = typedNode[NodeTypes.ENUMERATION] as Record<\n string,\n unknown\n >;\n\n const variableName = (ENUMERATION_METADATA_KEYS.map(\n (metadataKey) => enumerationState[metadataKey]\n ).find((name) => typeof name === 'string') ?? 'count') as string;\n\n const isOrdinal = enumerationState.__intlayer_icu_ordinal === true;\n\n const options: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(enumerationState)) {\n if (!(ENUMERATION_METADATA_KEYS as readonly string[]).includes(key)) {\n options[key] = value;\n }\n }\n\n const selector = getSelectorValue(values, variableName);\n\n let selected: unknown;\n if (isOrdinal && !Number.isNaN(Number(selector))) {\n // ICU `selectordinal` — exact numeric match first, then the CLDR\n // ordinal category, then the fallback\n const ordinalCount = Number(selector);\n const ordinalCategory = getCachedIntl('PluralRules', locale, {\n type: 'ordinal',\n }).select(ordinalCount);\n selected =\n options[String(ordinalCount)] ??\n options[ordinalCategory] ??\n options.fallback ??\n options.other;\n } else if (\n typeof selector === 'number' ||\n !Number.isNaN(Number(selector))\n ) {\n selected = getEnumeration(options, Number(selector));\n } else {\n // String selector — ICU `select` converted to an enumeration\n selected = options[String(selector)] ?? options.fallback ?? options.other;\n }\n\n return resolveMessageNode(selected, values, locale);\n }\n\n if (typedNode.nodeType === NodeTypes.GENDER) {\n const genderState = typedNode[NodeTypes.GENDER] as Record<string, unknown>;\n const genderValue = String(values.gender ?? '');\n const selected =\n genderState[genderValue] ?? genderState.fallback ?? genderState.other;\n return resolveMessageNode(selected, values, locale);\n }\n\n return node;\n};\n\nconst DIALECT_FORMATTERS: Record<\n MessageFormatDialect,\n (message: string) => unknown\n> = {\n icu: (message) => icuToIntlayerFormatter(message),\n i18next: (message) => i18nextToIntlayerFormatter(message),\n 'vue-i18n': (message) => vueI18nToIntlayerFormatter(message),\n};\n\n/**\n * Resolves a raw message — string in a library dialect, or an intlayer node\n * tree — into a final string using interpolation values and locale.\n *\n * @example\n * ```ts\n * resolveMessage('Hello {name}', { name: 'John' }, 'en', 'icu');\n * // 'Hello John'\n *\n * resolveMessage(\n * '{count, plural, one {# item} other {# items}}',\n * { count: 3 },\n * 'en',\n * 'icu'\n * );\n * // '3 items'\n * ```\n */\nexport const resolveMessage = (\n message: unknown,\n values: MessageValues = {},\n locale: LocalesValues = 'en' as LocalesValues,\n dialect: MessageFormatDialect = 'icu'\n): string => {\n const node =\n typeof message === 'string'\n ? DIALECT_FORMATTERS[dialect](message)\n : message;\n\n const resolved = resolveMessageNode(node, values, locale);\n\n return typeof resolved === 'string' ? resolved : String(resolved ?? '');\n};\n\n/** A parsed token of a tagged message: plain text or a tag with children. */\nexport type TaggedMessageToken =\n | string\n | { tag: string; children: TaggedMessageToken[] };\n\n/**\n * Tokenizes a message containing XML-like tags (`'Visit <link>the docs</link>'`,\n * `'hello <1>{{name}}</1>'`, `'line<br/>break'`) into a token tree.\n *\n * Used by rich-text renderers (`t.rich`, `<Trans components>`,\n * `<i18n-t>` slots) to map tags to framework elements.\n */\nexport const parseTaggedMessage = (message: string): TaggedMessageToken[] => {\n const tokens: TaggedMessageToken[] = [];\n const tagRegex = /<([\\w-]+)\\s*\\/>|<([\\w-]+)[^>]*>([\\s\\S]*?)<\\/\\2>/g;\n let lastIndex = 0;\n let match = tagRegex.exec(message);\n\n while (match !== null) {\n if (match.index > lastIndex) {\n tokens.push(message.slice(lastIndex, match.index));\n }\n\n const [, selfClosingTag, tag, inner] = match;\n\n if (selfClosingTag) {\n tokens.push({ tag: selfClosingTag, children: [] });\n } else {\n tokens.push({ tag, children: parseTaggedMessage(inner) });\n }\n\n lastIndex = match.index + match[0].length;\n match = tagRegex.exec(message);\n }\n\n if (lastIndex < message.length) {\n tokens.push(message.slice(lastIndex));\n }\n\n return tokens;\n};\n"],"mappings":";;;;;;;;;;;;;AA8BA,MAAM,4BAA4B;CAChC;CACA;CACA;AACF;;;;AAKA,MAAM,oBAAoB,QAAuB,SAA0B;CACzE,IAAI,QAAQ,QAAQ,OAAO,OAAO;CAElC,IAAI,UAAmB;CACvB,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;EAClC,IACE,YAAY,QACZ,YAAY,UACZ,OAAO,YAAY,UAEnB;EAEF,UAAW,QAAoC;CACjD;CACA,OAAO;AACT;;AAGA,MAAM,kBACJ,OACA,MACA,OACA,WACW;CACX,IAAI;EACF,IAAI,SAAS,UAAU;GACrB,MAAM,cAAc,OAAO,KAAK;GAChC,IAAI,UAAU,WACZ,OAAOA,iCAAc,gBAAgB,QAAQ,EAC3C,OAAO,UACT,CAAC,CAAC,CAAC,OAAO,WAAW;GAEvB,IAAI,UAAU,WACZ,OAAOA,iCAAc,gBAAgB,QAAQ,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AG,gBAAgB,KAAK,SAAS;EAEvC,IAAI,gBACF,OAAO,KAAK;GAAE,KAAK;GAAgB,UAAU,CAAC;EAAE,CAAC;OAEjD,OAAO,KAAK;GAAE;GAAK,UAAU,mBAAmB,KAAK;EAAE,CAAC;EAG1D,YAAY,MAAM,QAAQ,MAAM,EAAE,CAAC;EACnC,QAAQ,SAAS,KAAK,OAAO;CAC/B;CAEA,IAAI,YAAY,QAAQ,QACtB,OAAO,KAAK,QAAQ,MAAM,SAAS,CAAC;CAGtC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"verify-icu-format.cjs","names":["insert","intlayerToICUFormatter","enu","icuToIntlayerFormatter","gender"],"sources":["../../../src/messageFormat/verify-icu-format.ts"],"sourcesContent":["/**\n * Verification script to demonstrate ICU format conversion\n * This script shows that Intlayer correctly converts {{var}} (internal format)\n * to {var} (ICU format) when outputting.\n */\n\nimport { enu, gender, insert } from '../transpiler';\nimport { icuToIntlayerFormatter, intlayerToICUFormatter } from './ICU';\n\nconsole.log('=== ICU Format Verification ===\\n');\n\n// Test 1: Simple interpolation\nconsole.log('Test 1: Simple Interpolation');\nconsole.log('Intlayer input:', insert('Hello {{name}}'));\nconst test1 = intlayerToICUFormatter(insert('Hello {{name}}'));\nconsole.log('ICU output:', test1);\nconsole.log('✓ Expected: Single braces {name}');\nconsole.log(\n '✓ Result:',\n test1.includes('{name}') && !test1.includes('{{name}}') ? 'PASS' : 'FAIL'\n);\nconsole.log();\n\n// Test 2: Formatted variable\nconsole.log('Test 2: Formatted Variable');\nconsole.log('Intlayer input:', insert('Price: {amount, number, currency}'));\nconst test2 = intlayerToICUFormatter(\n insert('Price: {amount, number, currency}')\n);\nconsole.log('ICU output:', test2);\nconsole.log('✓ Expected: Single braces {amount, number, currency}');\nconsole.log(\n '✓ Result:',\n test2.includes('{amount, number, currency}') ? 'PASS' : 'FAIL'\n);\nconsole.log();\n\n// Test 3: Plural with variable\nconsole.log('Test 3: Plural with Variable');\nconst pluralInput = enu({\n '0': 'No items',\n '1': 'One item',\n fallback: '{{count}} items',\n});\nconsole.log('Intlayer input:', JSON.stringify(pluralInput, null, 2));\nconst test3 = intlayerToICUFormatter(pluralInput);\nconsole.log('ICU output:', test3);\nconsole.log('✓ Expected: {count, plural, ...} with # for count');\nconsole.log(\n '✓ Result:',\n test3.includes('{count, plural,') &&\n test3.includes('# items') &&\n !test3.includes('{{')\n ? 'PASS'\n : 'FAIL'\n);\nconsole.log();\n\n// Test 4: Roundtrip conversion\nconsole.log('Test 4: Roundtrip Conversion (ICU → Intlayer → ICU)');\nconst original =\n 'Hello {name}, you have {count, plural, =0 {no messages} =1 {one message} other {# messages}}';\nconsole.log('Original ICU:', original);\nconst toIntlayer = icuToIntlayerFormatter(original);\nconsole.log('Converted to Intlayer:', JSON.stringify(toIntlayer, null, 2));\nconst backToICU = intlayerToICUFormatter(toIntlayer);\nconsole.log('Back to ICU:', backToICU);\nconsole.log('✓ Expected: No {{...}} in output');\nconsole.log('✓ Result:', !String(backToICU).includes('{{') ? 'PASS' : 'FAIL');\nconsole.log();\n\n// Test 5: Gender with nested plural\nconsole.log('Test 5: Gender with Nested Structures');\nconst genderInput = gender({\n male: 'He has items',\n female: 'She has items',\n fallback: 'They have items',\n});\nconst test5 = intlayerToICUFormatter(genderInput);\nconsole.log('ICU output:', test5);\nconsole.log('✓ Expected: Single braces only');\nconsole.log('✓ Result:', !test5.includes('{{') ? 'PASS' : 'FAIL');\nconsole.log();\n\nconsole.log('=== Summary ===');\nconsole.log('ICU MessageFormat uses single braces: {var}');\nconsole.log('Intlayer internal format uses double braces: {{var}}');\nconsole.log('The conversion between these formats is handled automatically.');\n"],"mappings":";;;;;;;;;;;AASA,QAAQ,IAAI,oCAAoC;AAGhD,QAAQ,IAAI,+BAA+B;AAC3C,QAAQ,IAAI,mBAAmBA,8CAAO,iBAAiB,CAAC;AACxD,MAAM,QAAQC,iDAAuBD,8CAAO,iBAAiB,CAAC;AAC9D,QAAQ,IAAI,eAAe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CACzB,MAAM;CACN,QAAQ;CACR,UAAU;CACX,CAC+C,CAAC;AACjD,QAAQ,IAAI,eAAe,MAAM;AACjC,QAAQ,IAAI,iCAAiC;AAC7C,QAAQ,IAAI,aAAa,CAAC,MAAM,SAAS,KAAK,GAAG,SAAS,OAAO;AACjE,QAAQ,KAAK;AAEb,QAAQ,IAAI,kBAAkB;AAC9B,QAAQ,IAAI,8CAA8C;AAC1D,QAAQ,IAAI,uDAAuD;AACnE,QAAQ,IAAI,iEAAiE"}
1
+ {"version":3,"file":"verify-icu-format.cjs","names":["insert","intlayerToICUFormatter","enu","icuToIntlayerFormatter","gender"],"sources":["../../../src/messageFormat/verify-icu-format.ts"],"sourcesContent":["/**\n * Verification script to demonstrate ICU format conversion\n * This script shows that Intlayer correctly converts {{var}} (internal format)\n * to {var} (ICU format) when outputting.\n */\n\nimport { enu, gender, insert } from '../transpiler';\nimport { icuToIntlayerFormatter, intlayerToICUFormatter } from './ICU';\n\nconsole.log('=== ICU Format Verification ===\\n');\n\n// Test 1: Simple interpolation\nconsole.log('Test 1: Simple Interpolation');\nconsole.log('Intlayer input:', insert('Hello {{name}}'));\nconst test1 = intlayerToICUFormatter(insert('Hello {{name}}'));\nconsole.log('ICU output:', test1);\nconsole.log('✓ Expected: Single braces {name}');\nconsole.log(\n '✓ Result:',\n test1.includes('{name}') && !test1.includes('{{name}}') ? 'PASS' : 'FAIL'\n);\nconsole.log();\n\n// Test 2: Formatted variable\nconsole.log('Test 2: Formatted Variable');\nconsole.log('Intlayer input:', insert('Price: {amount, number, currency}'));\nconst test2 = intlayerToICUFormatter(\n insert('Price: {amount, number, currency}')\n);\nconsole.log('ICU output:', test2);\nconsole.log('✓ Expected: Single braces {amount, number, currency}');\nconsole.log(\n '✓ Result:',\n test2.includes('{amount, number, currency}') ? 'PASS' : 'FAIL'\n);\nconsole.log();\n\n// Test 3: Plural with variable\nconsole.log('Test 3: Plural with Variable');\nconst pluralInput = enu({\n '0': 'No items',\n '1': 'One item',\n fallback: '{{count}} items',\n});\nconsole.log('Intlayer input:', JSON.stringify(pluralInput, null, 2));\nconst test3 = intlayerToICUFormatter(pluralInput);\nconsole.log('ICU output:', test3);\nconsole.log('✓ Expected: {count, plural, ...} with # for count');\nconsole.log(\n '✓ Result:',\n test3.includes('{count, plural,') &&\n test3.includes('# items') &&\n !test3.includes('{{')\n ? 'PASS'\n : 'FAIL'\n);\nconsole.log();\n\n// Test 4: Roundtrip conversion\nconsole.log('Test 4: Roundtrip Conversion (ICU → Intlayer → ICU)');\nconst original =\n 'Hello {name}, you have {count, plural, =0 {no messages} =1 {one message} other {# messages}}';\nconsole.log('Original ICU:', original);\nconst toIntlayer = icuToIntlayerFormatter(original);\nconsole.log('Converted to Intlayer:', JSON.stringify(toIntlayer, null, 2));\nconst backToICU = intlayerToICUFormatter(toIntlayer);\nconsole.log('Back to ICU:', backToICU);\nconsole.log('✓ Expected: No {{...}} in output');\nconsole.log('✓ Result:', !String(backToICU).includes('{{') ? 'PASS' : 'FAIL');\nconsole.log();\n\n// Test 5: Gender with nested plural\nconsole.log('Test 5: Gender with Nested Structures');\nconst genderInput = gender({\n male: 'He has items',\n female: 'She has items',\n fallback: 'They have items',\n});\nconst test5 = intlayerToICUFormatter(genderInput);\nconsole.log('ICU output:', test5);\nconsole.log('✓ Expected: Single braces only');\nconsole.log('✓ Result:', !test5.includes('{{') ? 'PASS' : 'FAIL');\nconsole.log();\n\nconsole.log('=== Summary ===');\nconsole.log('ICU MessageFormat uses single braces: {var}');\nconsole.log('Intlayer internal format uses double braces: {{var}}');\nconsole.log('The conversion between these formats is handled automatically.');\n"],"mappings":";;;;;;;;;;;AASA,QAAQ,IAAI,mCAAmC;AAG/C,QAAQ,IAAI,8BAA8B;AAC1C,QAAQ,IAAI,mBAAmBA,8CAAO,gBAAgB,CAAC;AACvD,MAAM,QAAQC,iDAAuBD,8CAAO,gBAAgB,CAAC;AAC7D,QAAQ,IAAI,eAAe,KAAK;AAChC,QAAQ,IAAI,kCAAk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,QAAQ;CACR,UAAU;AACZ,CAC+C,CAAC;AAChD,QAAQ,IAAI,eAAe,KAAK;AAChC,QAAQ,IAAI,gCAAgC;AAC5C,QAAQ,IAAI,aAAa,CAAC,MAAM,SAAS,IAAI,IAAI,SAAS,MAAM;AAChE,QAAQ,IAAI;AAEZ,QAAQ,IAAI,iBAAiB;AAC7B,QAAQ,IAAI,6CAA6C;AACzD,QAAQ,IAAI,sDAAsD;AAClE,QAAQ,IAAI,gEAAgE"}
@@ -90,7 +90,8 @@ const vueI18nToIntlayerPlugin = {
90
90
  canHandle: (node) => typeof node === "string" && (node.includes("{") || node.includes("|")),
91
91
  transform: (node) => {
92
92
  try {
93
- return vueI18nNodesToIntlayer(parseVueI18n(node));
93
+ const ast = parseVueI18n(node);
94
+ return vueI18nNodesToIntlayer(ast);
94
95
  } catch {
95
96
  return node;
96
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"vue-i18n.cjs","names":["insert","enu","NodeTypes","deepTransformNode"],"sources":["../../../src/messageFormat/vue-i18n.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype VueI18nNode =\n | string\n | {\n type: 'argument';\n name: string;\n };\n\nconst parseVueI18nPart = (text: string): VueI18nNode[] => {\n let index = 0;\n const nodes: VueI18nNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n let name = '';\n while (index < text.length && text[index] !== '}') {\n name += text[index];\n index++;\n }\n if (index < text.length) {\n index++; // skip }\n }\n nodes.push({ type: 'argument', name: name.trim() });\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n\n return nodes;\n};\n\nconst parseVueI18n = (text: string): VueI18nNode[][] => {\n // Split by | but handle escaped \\|\n const parts: string[] = [];\n let currentPart = '';\n let index = 0;\n\n while (index < text.length) {\n const char = text[index];\n if (char === '\\\\' && index + 1 < text.length && text[index + 1] === '|') {\n currentPart += '|';\n index += 2;\n } else if (char === '|') {\n parts.push(currentPart.trim()); // Trim to remove surrounding spaces\n currentPart = '';\n index++;\n } else {\n currentPart += char;\n index++;\n }\n }\n parts.push(currentPart.trim()); // Trim last part too\n\n return parts.map(parseVueI18nPart);\n};\n\nconst vueI18nPartToIntlayer = (nodes: VueI18nNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') return nodes[0];\n\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else {\n str += `{{${node.name}}}`;\n }\n }\n return insert(str);\n};\n\nconst vueI18nNodesToIntlayer = (parts: VueI18nNode[][]): any => {\n if (parts.length === 1) {\n return vueI18nPartToIntlayer(parts[0]);\n }\n\n // Handle pluralization (choice).\n // vue-i18n's choice rule is POSITIONAL (0 | 1 | other), not CLDR-based:\n // an enumeration node preserves those semantics in every locale, whereas\n // a plural node would select by CLDR category (e.g. count 0 resolves to\n // 'one' in French, 'other' in English — never 'zero').\n const options: Record<string, any> = {};\n const varName = 'count'; // Default variable for vue-i18n choices\n\n if (parts.length === 2) {\n // 2 choices: 1 | other\n return enu({\n '1': vueI18nPartToIntlayer(parts[0]),\n fallback: vueI18nPartToIntlayer(parts[1]),\n });\n }\n\n if (parts.length === 3) {\n // 3 choices: 0 | 1 | other\n return enu({\n '0': vueI18nPartToIntlayer(parts[0]),\n '1': vueI18nPartToIntlayer(parts[1]),\n fallback: vueI18nPartToIntlayer(parts[2]),\n });\n }\n\n // > 3 choices: 0 | 1 | 2 | ... | other\n parts.forEach((part, index) => {\n if (index === parts.length - 1) {\n options.fallback = vueI18nPartToIntlayer(part);\n } else {\n options[index.toString()] = vueI18nPartToIntlayer(part);\n }\n });\n\n // Preserve variable name\n options.__intlayer_vue_i18n_var = varName;\n\n return enu(options);\n};\n\nconst vueI18nToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' && (node.includes('{') || node.includes('|')),\n transform: (node: any) => {\n try {\n const ast = parseVueI18n(node);\n return vueI18nNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToVueI18nPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeTypes.INSERTION ||\n node.nodeType === NodeTypes.ENUMERATION ||\n node.nodeType === NodeTypes.PLURAL ||\n node.nodeType === NodeTypes.GENDER ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeTypes.INSERTION ||\n item.nodeType === NodeTypes.ENUMERATION ||\n item.nodeType === NodeTypes.GENDER ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n // replace {{...}} with {...} even in strings\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeTypes.INSERTION) {\n // {{name}} -> {name}\n return node[NodeTypes.INSERTION].replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeTypes.PLURAL) {\n const options = node[NodeTypes.PLURAL];\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n if (\n transformedOptions.zero &&\n transformedOptions.one &&\n transformedOptions.other\n ) {\n return `${transformedOptions.zero} | ${transformedOptions.one} | ${transformedOptions.other}`;\n }\n\n if (transformedOptions.one && transformedOptions.other) {\n return `${transformedOptions.one} | ${transformedOptions.other}`;\n }\n\n return transformedOptions.other || Object.values(transformedOptions)[0];\n }\n\n if (node.nodeType === NodeTypes.ENUMERATION) {\n const options = node[NodeTypes.ENUMERATION];\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (\n key === '__intlayer_vue_i18n_var' ||\n key === '__intlayer_icu_var' ||\n key === '__intlayer_icu_ordinal'\n )\n continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n const keys = Object.keys(transformedOptions);\n\n if (keys.includes('0')) {\n const indices = keys.filter((key) => /^\\d+$/.test(key)).map(Number);\n const maxIndex = Math.max(...indices);\n\n const fallback =\n transformedOptions.fallback || transformedOptions.other;\n const resultParts = [];\n\n if (maxIndex <= 1 && !keys.includes('2')) {\n const zero = transformedOptions['0'] || '';\n const one = transformedOptions['1'] || '';\n return `${zero} | ${one} | ${fallback}`;\n }\n\n const limit = Math.max(1, maxIndex);\n\n for (let i = 0; i <= limit; i++) {\n const key = i.toString();\n if (transformedOptions[key]) {\n resultParts.push(transformedOptions[key]);\n } else {\n resultParts.push('');\n }\n }\n resultParts.push(fallback);\n return resultParts.join(' | ').replace(/ \\| {2}\\| /g, ' | | ');\n }\n\n if (\n keys.includes('1') &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return `${transformedOptions['1']} | ${transformedOptions.fallback || transformedOptions.other}`;\n }\n\n if (\n keys.length === 1 &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return transformedOptions.fallback || transformedOptions.other;\n }\n\n return (\n transformedOptions.fallback || Object.values(transformedOptions)[0]\n );\n }\n\n if (node.nodeType === NodeTypes.GENDER) {\n const options = node[NodeTypes.GENDER];\n const transformedOptions: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(options)) {\n let newKey = key;\n if (key === 'fallback') newKey = 'other';\n\n const childVal = next(val, props);\n transformedOptions[newKey] = childVal;\n }\n return transformedOptions;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToVueI18nFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...intlayerToVueI18nPlugin }],\n });\n};\n\nexport const vueI18nToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...vueI18nToIntlayerPlugin }],\n });\n};\n"],"mappings":";;;;;;;;;AAcA,MAAM,oBAAoB,SAAgC;CACxD,IAAI,QAAQ;CACZ,MAAM,QAAuB,EAAE;CAC/B,IAAI,cAAc;AAElB,QAAO,QAAQ,KAAK,QAAQ;EAC1B,MAAM,OAAO,KAAK;AAElB,MAAI,SAAS,KAAK;AAChB,OAAI,aAAa;AACf,UAAM,KAAK,YAAY;AACvB,kBAAc;;AAEhB;GACA,IAAI,OAAO;AACX,UAAO,QAAQ,KAAK,UAAU,KAAK,WAAW,KAAK;AACjD,YAAQ,KAAK;AACb;;AAEF,OAAI,QAAQ,KAAK,OACf;AAEF,SAAM,KAAK;IAAE,MAAM;IAAY,MAAM,KAAK,MAAM;IAAE,CAAC;SAC9C;AACL,kBAAe;AACf;;;AAIJ,KAAI,YACF,OAAM,KAAK,YAAY;AAGzB,QAAO;;AAGT,MAAM,gBAAgB,SAAkC;CAEtD,MAAM,QAAkB,EAAE;CAC1B,IAAI,cAAc;CACl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],"sources":["../../../src/messageFormat/vue-i18n.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { deepTransformNode } from '../interpreter';\nimport { enu, insert } from '../transpiler';\nimport type { JsonValue } from './ICU';\n\n// Types for our AST\ntype VueI18nNode =\n | string\n | {\n type: 'argument';\n name: string;\n };\n\nconst parseVueI18nPart = (text: string): VueI18nNode[] => {\n let index = 0;\n const nodes: VueI18nNode[] = [];\n let currentText = '';\n\n while (index < text.length) {\n const char = text[index];\n\n if (char === '{') {\n if (currentText) {\n nodes.push(currentText);\n currentText = '';\n }\n index++; // skip {\n let name = '';\n while (index < text.length && text[index] !== '}') {\n name += text[index];\n index++;\n }\n if (index < text.length) {\n index++; // skip }\n }\n nodes.push({ type: 'argument', name: name.trim() });\n } else {\n currentText += char;\n index++;\n }\n }\n\n if (currentText) {\n nodes.push(currentText);\n }\n\n return nodes;\n};\n\nconst parseVueI18n = (text: string): VueI18nNode[][] => {\n // Split by | but handle escaped \\|\n const parts: string[] = [];\n let currentPart = '';\n let index = 0;\n\n while (index < text.length) {\n const char = text[index];\n if (char === '\\\\' && index + 1 < text.length && text[index + 1] === '|') {\n currentPart += '|';\n index += 2;\n } else if (char === '|') {\n parts.push(currentPart.trim()); // Trim to remove surrounding spaces\n currentPart = '';\n index++;\n } else {\n currentPart += char;\n index++;\n }\n }\n parts.push(currentPart.trim()); // Trim last part too\n\n return parts.map(parseVueI18nPart);\n};\n\nconst vueI18nPartToIntlayer = (nodes: VueI18nNode[]): any => {\n if (nodes.length === 0) return '';\n if (nodes.length === 1 && typeof nodes[0] === 'string') return nodes[0];\n\n let str = '';\n for (const node of nodes) {\n if (typeof node === 'string') {\n str += node;\n } else {\n str += `{{${node.name}}}`;\n }\n }\n return insert(str);\n};\n\nconst vueI18nNodesToIntlayer = (parts: VueI18nNode[][]): any => {\n if (parts.length === 1) {\n return vueI18nPartToIntlayer(parts[0]);\n }\n\n // Handle pluralization (choice).\n // vue-i18n's choice rule is POSITIONAL (0 | 1 | other), not CLDR-based:\n // an enumeration node preserves those semantics in every locale, whereas\n // a plural node would select by CLDR category (e.g. count 0 resolves to\n // 'one' in French, 'other' in English — never 'zero').\n const options: Record<string, any> = {};\n const varName = 'count'; // Default variable for vue-i18n choices\n\n if (parts.length === 2) {\n // 2 choices: 1 | other\n return enu({\n '1': vueI18nPartToIntlayer(parts[0]),\n fallback: vueI18nPartToIntlayer(parts[1]),\n });\n }\n\n if (parts.length === 3) {\n // 3 choices: 0 | 1 | other\n return enu({\n '0': vueI18nPartToIntlayer(parts[0]),\n '1': vueI18nPartToIntlayer(parts[1]),\n fallback: vueI18nPartToIntlayer(parts[2]),\n });\n }\n\n // > 3 choices: 0 | 1 | 2 | ... | other\n parts.forEach((part, index) => {\n if (index === parts.length - 1) {\n options.fallback = vueI18nPartToIntlayer(part);\n } else {\n options[index.toString()] = vueI18nPartToIntlayer(part);\n }\n });\n\n // Preserve variable name\n options.__intlayer_vue_i18n_var = varName;\n\n return enu(options);\n};\n\nconst vueI18nToIntlayerPlugin = {\n canHandle: (node: any) =>\n typeof node === 'string' && (node.includes('{') || node.includes('|')),\n transform: (node: any) => {\n try {\n const ast = parseVueI18n(node);\n return vueI18nNodesToIntlayer(ast);\n } catch {\n return node;\n }\n },\n};\n\nconst intlayerToVueI18nPlugin = {\n canHandle: (node: any) => {\n if (typeof node === 'string') return true;\n\n if (\n node &&\n typeof node === 'object' &&\n (node.nodeType === NodeTypes.INSERTION ||\n node.nodeType === NodeTypes.ENUMERATION ||\n node.nodeType === NodeTypes.PLURAL ||\n node.nodeType === NodeTypes.GENDER ||\n node.nodeType === 'composite')\n ) {\n return true;\n }\n\n if (Array.isArray(node)) {\n if (node.length === 0) return false;\n\n let hasNode = false;\n let hasPlainObjectOrArray = false;\n\n for (const item of node) {\n if (typeof item === 'string') {\n } else if (\n item &&\n typeof item === 'object' &&\n (item.nodeType === NodeTypes.INSERTION ||\n item.nodeType === NodeTypes.ENUMERATION ||\n item.nodeType === NodeTypes.GENDER ||\n item.nodeType === 'composite')\n ) {\n hasNode = true;\n } else {\n hasPlainObjectOrArray = true;\n }\n }\n\n // If it contains plain objects or nested arrays, it's a structural array\n if (hasPlainObjectOrArray) return false;\n // If it contains ONLY strings, it's a structural array, not a composite string\n if (!hasNode) return false;\n\n return true;\n }\n\n return false;\n },\n transform: (node: any, props: any, next: any) => {\n if (typeof node === 'string') {\n // replace {{...}} with {...} even in strings\n return node.replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeTypes.INSERTION) {\n // {{name}} -> {name}\n return node[NodeTypes.INSERTION].replace(/\\{\\{([^}]+)\\}\\}/g, '{$1}');\n }\n\n if (node.nodeType === NodeTypes.PLURAL) {\n const options = node[NodeTypes.PLURAL];\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n if (\n transformedOptions.zero &&\n transformedOptions.one &&\n transformedOptions.other\n ) {\n return `${transformedOptions.zero} | ${transformedOptions.one} | ${transformedOptions.other}`;\n }\n\n if (transformedOptions.one && transformedOptions.other) {\n return `${transformedOptions.one} | ${transformedOptions.other}`;\n }\n\n return transformedOptions.other || Object.values(transformedOptions)[0];\n }\n\n if (node.nodeType === NodeTypes.ENUMERATION) {\n const options = node[NodeTypes.ENUMERATION];\n\n const transformedOptions: Record<string, string> = {};\n for (const [key, val] of Object.entries(options)) {\n if (\n key === '__intlayer_vue_i18n_var' ||\n key === '__intlayer_icu_var' ||\n key === '__intlayer_icu_ordinal'\n )\n continue;\n const childVal = next(val, props);\n transformedOptions[key] =\n typeof childVal === 'string' ? childVal : JSON.stringify(childVal);\n }\n\n const keys = Object.keys(transformedOptions);\n\n if (keys.includes('0')) {\n const indices = keys.filter((key) => /^\\d+$/.test(key)).map(Number);\n const maxIndex = Math.max(...indices);\n\n const fallback =\n transformedOptions.fallback || transformedOptions.other;\n const resultParts = [];\n\n if (maxIndex <= 1 && !keys.includes('2')) {\n const zero = transformedOptions['0'] || '';\n const one = transformedOptions['1'] || '';\n return `${zero} | ${one} | ${fallback}`;\n }\n\n const limit = Math.max(1, maxIndex);\n\n for (let i = 0; i <= limit; i++) {\n const key = i.toString();\n if (transformedOptions[key]) {\n resultParts.push(transformedOptions[key]);\n } else {\n resultParts.push('');\n }\n }\n resultParts.push(fallback);\n return resultParts.join(' | ').replace(/ \\| {2}\\| /g, ' | | ');\n }\n\n if (\n keys.includes('1') &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return `${transformedOptions['1']} | ${transformedOptions.fallback || transformedOptions.other}`;\n }\n\n if (\n keys.length === 1 &&\n (keys.includes('fallback') || keys.includes('other'))\n ) {\n return transformedOptions.fallback || transformedOptions.other;\n }\n\n return (\n transformedOptions.fallback || Object.values(transformedOptions)[0]\n );\n }\n\n if (node.nodeType === NodeTypes.GENDER) {\n const options = node[NodeTypes.GENDER];\n const transformedOptions: Record<string, any> = {};\n\n for (const [key, val] of Object.entries(options)) {\n let newKey = key;\n if (key === 'fallback') newKey = 'other';\n\n const childVal = next(val, props);\n transformedOptions[newKey] = childVal;\n }\n return transformedOptions;\n }\n\n if (\n Array.isArray(node) ||\n (node.nodeType === 'composite' && Array.isArray(node.composite))\n ) {\n const arr = Array.isArray(node) ? node : node.composite;\n const items = arr.map((item: any) => next(item, props));\n return items.join('');\n }\n\n return next(node, props);\n },\n};\n\nexport const intlayerToVueI18nFormatter = (\n message: Dictionary['content']\n): JsonValue => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...intlayerToVueI18nPlugin }],\n });\n};\n\nexport const vueI18nToIntlayerFormatter = (\n message: JsonValue\n): Dictionary['content'] => {\n return deepTransformNode(message, {\n dictionaryKey: 'vue-i18n',\n keyPath: [],\n plugins: [{ id: 'vue-i18n', ...vueI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A0C,CAAC;GAEjD,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,OAAO,GAAG;IAChD,IAAI,SAAS;IACb,IAAI,QAAQ,YAAY,SAAS;IAGjC,mBAAmB,UADF,KAAK,KAAK,KACS;GACtC;GACA,OAAO;EACT;EAEA,IACE,MAAM,QAAQ,IAAI,KACjB,KAAK,aAAa,eAAe,MAAM,QAAQ,KAAK,SAAS,GAI9D,QAFY,MAAM,QAAQ,IAAI,IAAI,OAAO,KAAK,UAC7B,CAAC,KAAK,SAAc,KAAK,MAAM,KAAK,CAC1C,CAAC,CAAC,KAAK,EAAE;EAGtB,OAAO,KAAK,MAAM,KAAK;CACzB;AACF;AAEA,MAAa,8BACX,YACc;CACd,OAAOC,+DAAkB,SAAS;EAChC,eAAe;EACf,SAAS,CAAC;EACV,SAAS,CAAC;GAAE,IAAI;GAAY,GAAG;EAAwB,CAAC;CAC1D,CAAC;AACH;AAEA,MAAa,8BACX,YAC0B;CAC1B,OAAOA,+DAAkB,SAAS;EAChC,eAAe;EACf,SAAS,CAAC;EACV,SAAS,CAAC;GAAE,IAAI;GAAY,GAAG;EAAwB,CAAC;CAC1D,CAAC;AACH"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
4
3
 
5
4
  //#region src/transpiler/condition/condition.ts
@@ -1 +1 @@
1
- {"version":3,"file":"condition.cjs","names":["CONDITION"],"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { CONDITION, formatNodeType } from '@intlayer/types/nodeType';\n\nexport type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {\n fallback?: Content;\n};\n\nexport type ConditionContent<Content = unknown> = TypedNodeModel<\n typeof CONDITION,\n ConditionContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * cond({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst condition = <Content>(\n content?: ConditionContentStates<Content>\n): ConditionContent<Content> => formatNodeType(CONDITION, content);\n\nexport { condition as cond };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,aACJ,yDAC6CA,oCAAW,QAAQ"}
1
+ {"version":3,"file":"condition.cjs","names":["CONDITION"],"sources":["../../../../src/transpiler/condition/condition.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { CONDITION, formatNodeType } from '@intlayer/types/nodeType';\n\nexport type ConditionContentStates<Content> = Record<`${boolean}`, Content> & {\n fallback?: Content;\n};\n\nexport type ConditionContent<Content = unknown> = TypedNodeModel<\n typeof CONDITION,\n ConditionContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a condition.\n *\n * Usage:\n *\n * ```ts\n * cond({\n * 'true': 'The condition is validated',\n * 'false': 'The condition is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst condition = <Content>(\n content?: ConditionContentStates<Content>\n): ConditionContent<Content> => formatNodeType(CONDITION, content);\n\nexport { condition as cond };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,aACJ,yDAC6CA,oCAAW,OAAO"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
4
3
 
5
4
  //#region src/transpiler/enumeration/enumeration.ts
@@ -1 +1 @@
1
- {"version":3,"file":"enumeration.cjs","names":["ENUMERATION"],"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { ENUMERATION, formatNodeType } from '@intlayer/types/nodeType';\n\ntype Positive = number | `${number}`;\ntype Negative = `-${number}`;\ntype Numbers = Positive | Negative;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n typeof ENUMERATION,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\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 * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content = unknown>(\n content?: EnumerationContentState<Content>\n): EnumerationContent<Content> => formatNodeType(ENUMERATION, content);\n\nexport { enumeration as enu };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,eACJ,yDAC+CA,sCAAa,QAAQ"}
1
+ {"version":3,"file":"enumeration.cjs","names":["ENUMERATION"],"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { ENUMERATION, formatNodeType } from '@intlayer/types/nodeType';\n\ntype Positive = number | `${number}`;\ntype Negative = `-${number}`;\ntype Numbers = Positive | Negative;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n typeof ENUMERATION,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\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 * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content = unknown>(\n content?: EnumerationContentState<Content>\n): EnumerationContent<Content> => formatNodeType(ENUMERATION, content);\n\nexport { enumeration as enu };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,eACJ,yDAC+CA,sCAAa,OAAO"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
4
3
  let _intlayer_config_logger = require("@intlayer/config/logger");
5
4
  let node_fs = require("node:fs");
@@ -42,7 +41,8 @@ const fileContent = (path, callerDir, baseDir) => {
42
41
  */
43
42
  const file = (path) => {
44
43
  const { INTLAYER_FILE_PATH, INTLAYER_BASE_DIR } = globalThis;
45
- return fileContent(path, (0, node_path.dirname)(INTLAYER_FILE_PATH), INTLAYER_BASE_DIR);
44
+ const callerDir = (0, node_path.dirname)(INTLAYER_FILE_PATH);
45
+ return fileContent(path, callerDir, INTLAYER_BASE_DIR);
46
46
  };
47
47
 
48
48
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"file.cjs","names":["FILE","baseDir"],"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, relative, resolve } from 'node:path';\nimport { colorizePath, getAppLogger } from '@intlayer/config/logger';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { FILE, formatNodeType } from '@intlayer/types/nodeType';\n\nexport type FileContentConstructor<T extends Record<string, any> = {}> =\n TypedNodeModel<typeof FILE, string, T>;\n\nexport type FileContent = FileContentConstructor<{\n content: string;\n fixedPath?: string;\n}>;\n\nexport const fileContent = (\n path: string,\n callerDir: string,\n baseDir: string\n): FileContent => {\n const isRelativePath = path.startsWith('./') || path.startsWith('../');\n const appLogger = getAppLogger();\n\n let filePath: string;\n if (isAbsolute(path)) {\n appLogger(\n `Using absolute path for file is not recommended. Use relative paths instead. Path: ${path}, imported from: ${callerDir}`,\n { level: 'warn' }\n );\n filePath = path;\n } else if (isRelativePath) {\n filePath = resolve(callerDir, path);\n } else {\n filePath = resolve(baseDir, path);\n }\n\n if (existsSync(filePath) && statSync(filePath).isFile()) {\n try {\n const content = readFileSync(filePath, 'utf8');\n\n return formatNodeType(FILE, path, {\n content,\n fixedPath: relative(baseDir, filePath),\n });\n } catch {\n throw new Error(\n `Unable to read path: ${colorizePath(relative(baseDir, filePath))}`\n );\n }\n } else {\n throw new Error(\n `File not found: ${colorizePath(relative(baseDir, filePath))}`\n );\n }\n};\n\ntype GlobalIntlayerFilePath = {\n INTLAYER_FILE_PATH: string;\n INTLAYER_BASE_DIR: string;\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (path: string): FileContent => {\n const { INTLAYER_FILE_PATH, INTLAYER_BASE_DIR } =\n globalThis as unknown as GlobalIntlayerFilePath;\n\n const callerDir = dirname(INTLAYER_FILE_PATH);\n const baseDir = INTLAYER_BASE_DIR;\n\n return fileContent(path, callerDir, baseDir);\n};\n"],"mappings":";;;;;;;;AAcA,MAAa,eACX,MACA,WACA,YACgB;CAChB,MAAM,iBAAiB,KAAK,WAAW,KAAK,IAAI,KAAK,WAAW,MAAM;CACtE,MAAM,uDAA0B;CAEhC,IAAI;AACJ,+BAAe,KAAK,EAAE;AACpB,YACE,sFAAsF,KAAK,mBAAmB,aAC9G,EAAE,OAAO,QAAQ,CAClB;AACD,aAAW;YACF,eACT,mCAAmB,WAAW,KAAK;KAEnC,mCAAmB,SAAS,KAAK;AAGnC,6BAAe,SAAS,0BAAa,SAAS,CAAC,QAAQ,CACrD,KAAI;AAGF,sDAAsBA,+BAAM,MAAM;GAChC,mCAH2B,UAAU,OAG9B;GACP,mCAAoB,SAAS,SAAS;GACvC,CAAC;SACI;AACN,QAAM,IAAI,MACR,0FAA8C,SAAS,SAAS,CAAC,GAClE;;KAGH,OAAM,IAAI,MACR,qFAAyC,SAAS,SAAS,CAAC,GAC7D;;;;;;;;;;;;;;;;;AAwBL,MAAa,QAAQ,SAA8B;CACjD,MAAM,EAAE,oBAAoB,sBAC1B;AAKF,QAAO,YAAY,6BAHO,mBAGQ,EAAEC,kBAAQ"}
1
+ {"version":3,"file":"file.cjs","names":["FILE","baseDir"],"sources":["../../../../src/transpiler/file/file.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, isAbsolute, relative, resolve } from 'node:path';\nimport { colorizePath, getAppLogger } from '@intlayer/config/logger';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { FILE, formatNodeType } from '@intlayer/types/nodeType';\n\nexport type FileContentConstructor<T extends Record<string, any> = {}> =\n TypedNodeModel<typeof FILE, string, T>;\n\nexport type FileContent = FileContentConstructor<{\n content: string;\n fixedPath?: string;\n}>;\n\nexport const fileContent = (\n path: string,\n callerDir: string,\n baseDir: string\n): FileContent => {\n const isRelativePath = path.startsWith('./') || path.startsWith('../');\n const appLogger = getAppLogger();\n\n let filePath: string;\n if (isAbsolute(path)) {\n appLogger(\n `Using absolute path for file is not recommended. Use relative paths instead. Path: ${path}, imported from: ${callerDir}`,\n { level: 'warn' }\n );\n filePath = path;\n } else if (isRelativePath) {\n filePath = resolve(callerDir, path);\n } else {\n filePath = resolve(baseDir, path);\n }\n\n if (existsSync(filePath) && statSync(filePath).isFile()) {\n try {\n const content = readFileSync(filePath, 'utf8');\n\n return formatNodeType(FILE, path, {\n content,\n fixedPath: relative(baseDir, filePath),\n });\n } catch {\n throw new Error(\n `Unable to read path: ${colorizePath(relative(baseDir, filePath))}`\n );\n }\n } else {\n throw new Error(\n `File not found: ${colorizePath(relative(baseDir, filePath))}`\n );\n }\n};\n\ntype GlobalIntlayerFilePath = {\n INTLAYER_FILE_PATH: string;\n INTLAYER_BASE_DIR: string;\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (path: string): FileContent => {\n const { INTLAYER_FILE_PATH, INTLAYER_BASE_DIR } =\n globalThis as unknown as GlobalIntlayerFilePath;\n\n const callerDir = dirname(INTLAYER_FILE_PATH);\n const baseDir = INTLAYER_BASE_DIR;\n\n return fileContent(path, callerDir, baseDir);\n};\n"],"mappings":";;;;;;;AAcA,MAAa,eACX,MACA,WACA,YACgB;CAChB,MAAM,iBAAiB,KAAK,WAAW,IAAI,KAAK,KAAK,WAAW,KAAK;CACrE,MAAM,sDAAyB;CAE/B,IAAI;CACJ,8BAAe,IAAI,GAAG;EACpB,UACE,sFAAsF,KAAK,mBAAmB,aAC9G,EAAE,OAAO,OAAO,CAClB;EACA,WAAW;CACb,OAAO,IAAI,gBACT,kCAAmB,WAAW,IAAI;MAElC,kCAAmB,SAAS,IAAI;CAGlC,4BAAe,QAAQ,2BAAc,QAAQ,CAAC,CAAC,OAAO,GACpD,IAAI;EAGF,oDAAsBA,+BAAM,MAAM;GAChC,mCAH2B,UAAU,MAG/B;GACN,mCAAoB,SAAS,QAAQ;EACvC,CAAC;CACH,QAAQ;EACN,MAAM,IAAI,MACR,0FAA8C,SAAS,QAAQ,CAAC,GAClE;CACF;MAEA,MAAM,IAAI,MACR,qFAAyC,SAAS,QAAQ,CAAC,GAC7D;AAEJ;;;;;;;;;;;;;;;;AAsBA,MAAa,QAAQ,SAA8B;CACjD,MAAM,EAAE,oBAAoB,sBAC1B;CAEF,MAAM,mCAAoB,kBAAkB;CAG5C,OAAO,YAAY,MAAM,WAAWC,iBAAO;AAC7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"fileBrowser.cjs","names":[],"sources":["../../../../src/transpiler/file/fileBrowser.ts"],"sourcesContent":["import type { FileContent } from './file';\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (_path: string): FileContent => {\n throw new Error('file is not available in browser');\n\n // return formatNodeType(NodeTypes.File, path, {\n // content: '',\n // fixedPath: '',\n // });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,QAAQ,UAA+B;AAClD,OAAM,IAAI,MAAM,mCAAmC"}
1
+ {"version":3,"file":"fileBrowser.cjs","names":[],"sources":["../../../../src/transpiler/file/fileBrowser.ts"],"sourcesContent":["import type { FileContent } from './file';\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow identify the usage of an external resource.\n *\n * Usage:\n *\n * ```ts\n * file('/path/to/file.md') // absolute path\n *\n * // or\n *\n * file('path/to/file.md') // relative path\n * ```\n */\nexport const file = (_path: string): FileContent => {\n throw new Error('file is not available in browser');\n\n // return formatNodeType(NodeTypes.File, path, {\n // content: '',\n // fixedPath: '',\n // });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,MAAa,QAAQ,UAA+B;CAClD,MAAM,IAAI,MAAM,kCAAkC;AAMpD"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
4
3
 
5
4
  //#region src/transpiler/gender/gender.ts
@@ -1 +1 @@
1
- {"version":3,"file":"gender.cjs","names":["GENDER"],"sources":["../../../../src/transpiler/gender/gender.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, GENDER } from '@intlayer/types/nodeType';\n\nexport type Gender = 'male' | 'female' | 'fallback';\n\nexport type GenderContentStates<Content> = Record<`${Gender}`, Content> & {\n fallback?: Content;\n};\n\nexport type GenderContent<Content = unknown> = TypedNodeModel<\n typeof GENDER,\n GenderContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * gender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst gender = <Content>(\n content?: GenderContentStates<Content>\n): GenderContent<Content> => formatNodeType(GENDER, content);\n\nexport { gender };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,UACJ,yDAC0CA,iCAAQ,QAAQ"}
1
+ {"version":3,"file":"gender.cjs","names":["GENDER"],"sources":["../../../../src/transpiler/gender/gender.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, GENDER } from '@intlayer/types/nodeType';\n\nexport type Gender = 'male' | 'female' | 'fallback';\n\nexport type GenderContentStates<Content> = Record<`${Gender}`, Content> & {\n fallback?: Content;\n};\n\nexport type GenderContent<Content = unknown> = TypedNodeModel<\n typeof GENDER,\n GenderContentStates<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * gender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * });\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n */\nconst gender = <Content>(\n content?: GenderContentStates<Content>\n): GenderContent<Content> => formatNodeType(GENDER, content);\n\nexport { gender };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,UACJ,yDAC0CA,iCAAQ,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"getHTMLCustomComponents.cjs","names":[],"sources":["../../../../src/transpiler/html/getHTMLCustomComponents.ts"],"sourcesContent":["const parseAttributes = (attributesString: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n\n if (!attributesString?.trim()) {\n return attributes;\n }\n\n // Regex to match attribute names\n // Matches: name=\"value\", name='value', name=value, or just name\n const attrRegex =\n /([a-zA-Z0-9-:_@]+)(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?/g;\n\n const matches = [...attributesString.matchAll(attrRegex)];\n\n matches.forEach((match) => {\n const attrName = match[1];\n attributes[attrName] = 'string';\n });\n\n return attributes;\n};\n\n/**\n * Extracts component names from an HTML string.\n * - Standard HTML tags are set to `true`.\n * - Custom components are parsed to extract their attributes/props.\n */\nexport const getHTMLCustomComponents = (\n content: string\n): Record<string, Record<string, string> | true> => {\n if (typeof content !== 'string') {\n throw new Error('content must be a string');\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)\\s*([\\s\\S]*?)(\\/?)>/g;\n const matches = [...content.matchAll(tagRegex)];\n\n const components: Record<string, Record<string, string> | true> = {};\n\n matches.forEach((match) => {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attributesString = match[3];\n const isSelfClosing = !!match[4];\n\n // Matches any tag that is entirely lowercase letters and numbers (e.g., div, h1)\n const isStandardHTMLTag = /^[a-z][a-z0-9]*$/.test(tagName);\n\n if (isStandardHTMLTag) {\n components[tagName] = true;\n return;\n }\n\n if (!components[tagName]) {\n components[tagName] = {};\n }\n\n if (components[tagName] === true) {\n return;\n }\n\n if (isClosing) {\n return;\n }\n\n const attributes = parseAttributes(attributesString);\n const componentDef = components[tagName] as Record<string, string>;\n Object.assign(componentDef, attributes);\n\n if (!isSelfClosing) {\n componentDef.children = 'string';\n }\n });\n\n return components;\n};\n"],"mappings":";;;AAAA,MAAM,mBAAmB,qBAAqD;CAC5E,MAAM,aAAqC,EAAE;AAE7C,KAAI,CAAC,kBAAkB,MAAM,CAC3B,QAAO;AAUT,EAFiB,GAAG,iBAAiB,SAAS,6DAAU,CAEjD,CAAC,SAAS,UAAU;EACzB,MAAM,WAAW,MAAM;AACvB,aAAW,YAAY;GACvB;AAEF,QAAO;;;;;;;AAQT,MAAa,2BACX,YACkD;AAClD,KAAI,OAAO,YAAY,SACrB,OAAM,IAAI,MAAM,2BAA2B;CAI7C,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,6CAAS,CAAC;CAE/C,MAAM,aAA4D,EAAE;AAEpE,SAAQ,SAAS,UAAU;EACzB,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,mBAAmB,MAAM;EAC/B,MAAM,gBAAgB,CAAC,CAAC,MAAM;AAK9B,MAF0B,mBAAmB,KAAK,QAE7B,EAAE;AACrB,cAAW,WAAW;AACtB;;AAGF,MAAI,CAAC,WAAW,SACd,YAAW,WAAW,EAAE;AAG1B,MAAI,WAAW,aAAa,KAC1B;AAGF,MAAI,UACF;EAGF,MAAM,aAAa,gBAAgB,iBAAiB;EACpD,MAAM,eAAe,WAAW;AAChC,SAAO,OAAO,cAAc,WAAW;AAEvC,MAAI,CAAC,cACH,cAAa,WAAW;GAE1B;AAEF,QAAO"}
1
+ {"version":3,"file":"getHTMLCustomComponents.cjs","names":[],"sources":["../../../../src/transpiler/html/getHTMLCustomComponents.ts"],"sourcesContent":["const parseAttributes = (attributesString: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n\n if (!attributesString?.trim()) {\n return attributes;\n }\n\n // Regex to match attribute names\n // Matches: name=\"value\", name='value', name=value, or just name\n const attrRegex =\n /([a-zA-Z0-9-:_@]+)(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?/g;\n\n const matches = [...attributesString.matchAll(attrRegex)];\n\n matches.forEach((match) => {\n const attrName = match[1];\n attributes[attrName] = 'string';\n });\n\n return attributes;\n};\n\n/**\n * Extracts component names from an HTML string.\n * - Standard HTML tags are set to `true`.\n * - Custom components are parsed to extract their attributes/props.\n */\nexport const getHTMLCustomComponents = (\n content: string\n): Record<string, Record<string, string> | true> => {\n if (typeof content !== 'string') {\n throw new Error('content must be a string');\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)\\s*([\\s\\S]*?)(\\/?)>/g;\n const matches = [...content.matchAll(tagRegex)];\n\n const components: Record<string, Record<string, string> | true> = {};\n\n matches.forEach((match) => {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attributesString = match[3];\n const isSelfClosing = !!match[4];\n\n // Matches any tag that is entirely lowercase letters and numbers (e.g., div, h1)\n const isStandardHTMLTag = /^[a-z][a-z0-9]*$/.test(tagName);\n\n if (isStandardHTMLTag) {\n components[tagName] = true;\n return;\n }\n\n if (!components[tagName]) {\n components[tagName] = {};\n }\n\n if (components[tagName] === true) {\n return;\n }\n\n if (isClosing) {\n return;\n }\n\n const attributes = parseAttributes(attributesString);\n const componentDef = components[tagName] as Record<string, string>;\n Object.assign(componentDef, attributes);\n\n if (!isSelfClosing) {\n componentDef.children = 'string';\n }\n });\n\n return components;\n};\n"],"mappings":";;;AAAA,MAAM,mBAAmB,qBAAqD;CAC5E,MAAM,aAAqC,CAAC;CAE5C,IAAI,CAAC,kBAAkB,KAAK,GAC1B,OAAO;CAUT,CAFiB,GAAG,iBAAiB,SAAS,4DAAS,CAEjD,CAAC,CAAC,SAAS,UAAU;EACzB,MAAM,WAAW,MAAM;EACvB,WAAW,YAAY;CACzB,CAAC;CAED,OAAO;AACT;;;;;;AAOA,MAAa,2BACX,YACkD;CAClD,IAAI,OAAO,YAAY,UACrB,MAAM,IAAI,MAAM,0BAA0B;CAI5C,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,4CAAQ,CAAC;CAE9C,MAAM,aAA4D,CAAC;CAEnE,QAAQ,SAAS,UAAU;EACzB,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,mBAAmB,MAAM;EAC/B,MAAM,gBAAgB,CAAC,CAAC,MAAM;EAK9B,IAF0B,mBAAmB,KAAK,OAE9B,GAAG;GACrB,WAAW,WAAW;GACtB;EACF;EAEA,IAAI,CAAC,WAAW,UACd,WAAW,WAAW,CAAC;EAGzB,IAAI,WAAW,aAAa,MAC1B;EAGF,IAAI,WACF;EAGF,MAAM,aAAa,gBAAgB,gBAAgB;EACnD,MAAM,eAAe,WAAW;EAChC,OAAO,OAAO,cAAc,UAAU;EAEtC,IAAI,CAAC,eACH,aAAa,WAAW;CAE5B,CAAC;CAED,OAAO;AACT"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  const require_transpiler_html_getHTMLCustomComponents = require('./getHTMLCustomComponents.cjs');
4
3
  const require_transpiler_html_validateHTML = require('./validateHTML.cjs');
5
4
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
@@ -1 +1 @@
1
- {"version":3,"file":"html.cjs","names":["validateHTML","getHTMLCustomComponents","HTML"],"sources":["../../../../src/transpiler/html/html.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, HTML } from '@intlayer/types/nodeType';\nimport { getHTMLCustomComponents } from './getHTMLCustomComponents';\nimport { validateHTML } from './validateHTML';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type HTMLContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<typeof HTML, Content, T>;\n\nexport type HTMLContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = HTMLContentConstructor<\n Content,\n {\n tags: string[] | Components;\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to parse HTML/JSX-like strings and replace tags with components during interpretation.\n *\n * Usage:\n *\n * ```ts\n * html('Hello <b>World</b>')\n * ```\n *\n */\nexport const html = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): HTMLContent<Content, Components> => {\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n const { issues } = validateHTML(content);\n\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/html] ${issue.message}`);\n } else {\n console.warn(`[intlayer/html] ${issue.message}`);\n }\n }\n\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(HTML, content, {\n tags: getComponents(),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuCA,MAAa,QAIX,SACA,eACqC;CACrC,MAAM,sBAAsB;AAC1B,MAAI,WACF,QAAO;AAGT,MAAI,OAAO,YAAY,UAAU;GAC/B,MAAM,EAAE,WAAWA,kDAAa,QAAQ;AAExC,QAAK,MAAM,SAAS,OAClB,KAAI,MAAM,SAAS,QACjB,SAAQ,MAAM,mBAAmB,MAAM,UAAU;OAEjD,SAAQ,KAAK,mBAAmB,MAAM,UAAU;AAIpD,UAAOC,wEAAwB,QAAQ;;EAGzC,IAAI;AAEJ,MAAI,OAAO,YAAY,WACrB,iBAAgB,SAAS;WAChB,OAAQ,QAA4B,SAAS,WACtD,iBAAgB,YACdA,wEAAyB,MAAO,QAAuC;AAG3E,MAAI,OAAO,kBAAkB,SAC3B,QAAOA,wEAAwB,cAAc;AAG/C,MAAI;AACF,UAAOA,wEAAwB,KAAK,UAAU,QAAQ,CAAC;WAChD,IAAI;AACX,UAAO,EAAE;;;AAIb,qDAAsBC,+BAAM,SAAS,EACnC,MAAM,eAAe,EACtB,CAAC"}
1
+ {"version":3,"file":"html.cjs","names":["validateHTML","getHTMLCustomComponents","HTML"],"sources":["../../../../src/transpiler/html/html.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, HTML } from '@intlayer/types/nodeType';\nimport { getHTMLCustomComponents } from './getHTMLCustomComponents';\nimport { validateHTML } from './validateHTML';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type HTMLContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<typeof HTML, Content, T>;\n\nexport type HTMLContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = HTMLContentConstructor<\n Content,\n {\n tags: string[] | Components;\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to parse HTML/JSX-like strings and replace tags with components during interpretation.\n *\n * Usage:\n *\n * ```ts\n * html('Hello <b>World</b>')\n * ```\n *\n */\nexport const html = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): HTMLContent<Content, Components> => {\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n const { issues } = validateHTML(content);\n\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/html] ${issue.message}`);\n } else {\n console.warn(`[intlayer/html] ${issue.message}`);\n }\n }\n\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(HTML, content, {\n tags: getComponents(),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAuCA,MAAa,QAIX,SACA,eACqC;CACrC,MAAM,sBAAsB;EAC1B,IAAI,YACF,OAAO;EAGT,IAAI,OAAO,YAAY,UAAU;GAC/B,MAAM,EAAE,WAAWA,kDAAa,OAAO;GAEvC,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,SACjB,QAAQ,MAAM,mBAAmB,MAAM,SAAS;QAEhD,QAAQ,KAAK,mBAAmB,MAAM,SAAS;GAInD,OAAOC,wEAAwB,OAAO;EACxC;EAEA,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,QAAQ;OACnB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACdA,wEAAyB,MAAO,OAAsC;EAG1E,IAAI,OAAO,kBAAkB,UAC3B,OAAOA,wEAAwB,aAAa;EAG9C,IAAI;GACF,OAAOA,wEAAwB,KAAK,UAAU,OAAO,CAAC;EACxD,SAAS,IAAI;GACX,OAAO,CAAC;EACV;CACF;CAEA,oDAAsBC,+BAAM,SAAS,EACnC,MAAM,cAAc,EACtB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"htmlTags.cjs","names":[],"sources":["../../../../src/transpiler/html/htmlTags.ts"],"sourcesContent":["/**\n * List of standard HTML tags to provide as default components.\n * These allow users to use standard HTML tags in their html() content\n * without having to pass them explicitly.\n *\n * Used by framework-specific plugins (react-intlayer, vue-intlayer, etc.)\n * to create default HTML tag components.\n */\nexport const HTML_TAGS = [\n // Document structure\n 'html',\n 'head',\n 'body',\n 'main',\n 'header',\n 'footer',\n 'nav',\n 'aside',\n 'article',\n 'section',\n 'div',\n 'span',\n // Headings\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // Text content\n 'p',\n 'a',\n 'strong',\n 'b',\n 'em',\n 'i',\n 'u',\n 's',\n 'del',\n 'ins',\n 'mark',\n 'small',\n 'sub',\n 'sup',\n 'code',\n 'pre',\n 'blockquote',\n 'q',\n 'cite',\n 'abbr',\n 'address',\n 'time',\n 'kbd',\n 'samp',\n 'var',\n // Lists\n 'ul',\n 'ol',\n 'li',\n 'dl',\n 'dt',\n 'dd',\n // Tables\n 'table',\n 'thead',\n 'tbody',\n 'tfoot',\n 'tr',\n 'th',\n 'td',\n 'caption',\n 'colgroup',\n 'col',\n // Forms\n 'form',\n 'input',\n 'textarea',\n 'button',\n 'select',\n 'option',\n 'optgroup',\n 'label',\n 'fieldset',\n 'legend',\n 'datalist',\n 'output',\n 'progress',\n 'meter',\n // Media\n 'img',\n 'video',\n 'audio',\n 'source',\n 'track',\n 'picture',\n 'figure',\n 'figcaption',\n 'iframe',\n 'embed',\n 'object',\n 'canvas',\n 'svg',\n // Interactive\n 'details',\n 'summary',\n 'dialog',\n // Other\n 'br',\n 'hr',\n 'wbr',\n 'ruby',\n 'rt',\n 'rp',\n 'bdi',\n 'bdo',\n 'data',\n 'template',\n 'slot',\n] as const;\n\nexport type HTMLTagsType = {\n // Document structure\n html: HTMLHtmlElement;\n head: HTMLHeadElement;\n body: HTMLBodyElement;\n main: HTMLElement;\n header: HTMLElement;\n footer: HTMLElement;\n nav: HTMLElement;\n aside: HTMLElement;\n article: HTMLElement;\n section: HTMLElement;\n div: HTMLDivElement;\n span: HTMLSpanElement;\n\n // Headings\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n\n // Text content\n p: HTMLParagraphElement;\n a: HTMLAnchorElement;\n strong: HTMLElement;\n b: HTMLElement;\n em: HTMLElement;\n i: HTMLElement;\n u: HTMLElement;\n s: HTMLElement;\n del: HTMLModElement;\n ins: HTMLModElement;\n mark: HTMLElement;\n small: HTMLElement;\n sub: HTMLElement;\n sup: HTMLElement;\n code: HTMLElement;\n pre: HTMLPreElement;\n blockquote: HTMLQuoteElement;\n q: HTMLQuoteElement;\n cite: HTMLElement;\n abbr: HTMLElement;\n address: HTMLElement;\n time: HTMLTimeElement;\n kbd: HTMLElement;\n samp: HTMLElement;\n var: HTMLElement;\n\n // Lists\n ul: HTMLUListElement;\n ol: HTMLOListElement;\n li: HTMLLIElement;\n dl: HTMLDListElement;\n dt: HTMLElement;\n dd: HTMLElement;\n\n // Tables\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n tfoot: HTMLTableSectionElement;\n tr: HTMLTableRowElement;\n th: HTMLTableCellElement;\n td: HTMLTableCellElement;\n caption: HTMLTableCaptionElement;\n colgroup: HTMLTableColElement;\n col: HTMLTableColElement;\n\n // Forms\n form: HTMLFormElement;\n input: HTMLInputElement;\n textarea: HTMLTextAreaElement;\n button: HTMLButtonElement;\n select: HTMLSelectElement;\n option: HTMLOptionElement;\n optgroup: HTMLOptGroupElement;\n label: HTMLLabelElement;\n fieldset: HTMLFieldSetElement;\n legend: HTMLLegendElement;\n datalist: HTMLDataListElement;\n output: HTMLOutputElement;\n progress: HTMLProgressElement;\n meter: HTMLMeterElement;\n\n // Media\n img: HTMLImageElement;\n video: HTMLVideoElement;\n audio: HTMLAudioElement;\n source: HTMLSourceElement;\n track: HTMLTrackElement;\n picture: HTMLPictureElement;\n figure: HTMLElement;\n figcaption: HTMLElement;\n iframe: HTMLIFrameElement;\n embed: HTMLEmbedElement;\n object: HTMLObjectElement;\n canvas: HTMLCanvasElement;\n svg: SVGSVGElement;\n\n // Interactive\n details: HTMLDetailsElement;\n summary: HTMLElement;\n dialog: HTMLDialogElement;\n\n // Other\n br: HTMLBRElement;\n hr: HTMLHRElement;\n wbr: HTMLElement;\n ruby: HTMLElement;\n rt: HTMLElement;\n rp: HTMLElement;\n bdi: HTMLElement;\n bdo: HTMLElement;\n data: HTMLDataElement;\n template: HTMLTemplateElement;\n slot: HTMLSlotElement;\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,YAAY;CAEvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
1
+ {"version":3,"file":"htmlTags.cjs","names":[],"sources":["../../../../src/transpiler/html/htmlTags.ts"],"sourcesContent":["/**\n * List of standard HTML tags to provide as default components.\n * These allow users to use standard HTML tags in their html() content\n * without having to pass them explicitly.\n *\n * Used by framework-specific plugins (react-intlayer, vue-intlayer, etc.)\n * to create default HTML tag components.\n */\nexport const HTML_TAGS = [\n // Document structure\n 'html',\n 'head',\n 'body',\n 'main',\n 'header',\n 'footer',\n 'nav',\n 'aside',\n 'article',\n 'section',\n 'div',\n 'span',\n // Headings\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n // Text content\n 'p',\n 'a',\n 'strong',\n 'b',\n 'em',\n 'i',\n 'u',\n 's',\n 'del',\n 'ins',\n 'mark',\n 'small',\n 'sub',\n 'sup',\n 'code',\n 'pre',\n 'blockquote',\n 'q',\n 'cite',\n 'abbr',\n 'address',\n 'time',\n 'kbd',\n 'samp',\n 'var',\n // Lists\n 'ul',\n 'ol',\n 'li',\n 'dl',\n 'dt',\n 'dd',\n // Tables\n 'table',\n 'thead',\n 'tbody',\n 'tfoot',\n 'tr',\n 'th',\n 'td',\n 'caption',\n 'colgroup',\n 'col',\n // Forms\n 'form',\n 'input',\n 'textarea',\n 'button',\n 'select',\n 'option',\n 'optgroup',\n 'label',\n 'fieldset',\n 'legend',\n 'datalist',\n 'output',\n 'progress',\n 'meter',\n // Media\n 'img',\n 'video',\n 'audio',\n 'source',\n 'track',\n 'picture',\n 'figure',\n 'figcaption',\n 'iframe',\n 'embed',\n 'object',\n 'canvas',\n 'svg',\n // Interactive\n 'details',\n 'summary',\n 'dialog',\n // Other\n 'br',\n 'hr',\n 'wbr',\n 'ruby',\n 'rt',\n 'rp',\n 'bdi',\n 'bdo',\n 'data',\n 'template',\n 'slot',\n] as const;\n\nexport type HTMLTagsType = {\n // Document structure\n html: HTMLHtmlElement;\n head: HTMLHeadElement;\n body: HTMLBodyElement;\n main: HTMLElement;\n header: HTMLElement;\n footer: HTMLElement;\n nav: HTMLElement;\n aside: HTMLElement;\n article: HTMLElement;\n section: HTMLElement;\n div: HTMLDivElement;\n span: HTMLSpanElement;\n\n // Headings\n h1: HTMLHeadingElement;\n h2: HTMLHeadingElement;\n h3: HTMLHeadingElement;\n h4: HTMLHeadingElement;\n h5: HTMLHeadingElement;\n h6: HTMLHeadingElement;\n\n // Text content\n p: HTMLParagraphElement;\n a: HTMLAnchorElement;\n strong: HTMLElement;\n b: HTMLElement;\n em: HTMLElement;\n i: HTMLElement;\n u: HTMLElement;\n s: HTMLElement;\n del: HTMLModElement;\n ins: HTMLModElement;\n mark: HTMLElement;\n small: HTMLElement;\n sub: HTMLElement;\n sup: HTMLElement;\n code: HTMLElement;\n pre: HTMLPreElement;\n blockquote: HTMLQuoteElement;\n q: HTMLQuoteElement;\n cite: HTMLElement;\n abbr: HTMLElement;\n address: HTMLElement;\n time: HTMLTimeElement;\n kbd: HTMLElement;\n samp: HTMLElement;\n var: HTMLElement;\n\n // Lists\n ul: HTMLUListElement;\n ol: HTMLOListElement;\n li: HTMLLIElement;\n dl: HTMLDListElement;\n dt: HTMLElement;\n dd: HTMLElement;\n\n // Tables\n table: HTMLTableElement;\n thead: HTMLTableSectionElement;\n tbody: HTMLTableSectionElement;\n tfoot: HTMLTableSectionElement;\n tr: HTMLTableRowElement;\n th: HTMLTableCellElement;\n td: HTMLTableCellElement;\n caption: HTMLTableCaptionElement;\n colgroup: HTMLTableColElement;\n col: HTMLTableColElement;\n\n // Forms\n form: HTMLFormElement;\n input: HTMLInputElement;\n textarea: HTMLTextAreaElement;\n button: HTMLButtonElement;\n select: HTMLSelectElement;\n option: HTMLOptionElement;\n optgroup: HTMLOptGroupElement;\n label: HTMLLabelElement;\n fieldset: HTMLFieldSetElement;\n legend: HTMLLegendElement;\n datalist: HTMLDataListElement;\n output: HTMLOutputElement;\n progress: HTMLProgressElement;\n meter: HTMLMeterElement;\n\n // Media\n img: HTMLImageElement;\n video: HTMLVideoElement;\n audio: HTMLAudioElement;\n source: HTMLSourceElement;\n track: HTMLTrackElement;\n picture: HTMLPictureElement;\n figure: HTMLElement;\n figcaption: HTMLElement;\n iframe: HTMLIFrameElement;\n embed: HTMLEmbedElement;\n object: HTMLObjectElement;\n canvas: HTMLCanvasElement;\n svg: SVGSVGElement;\n\n // Interactive\n details: HTMLDetailsElement;\n summary: HTMLElement;\n dialog: HTMLDialogElement;\n\n // Other\n br: HTMLBRElement;\n hr: HTMLHRElement;\n wbr: HTMLElement;\n ruby: HTMLElement;\n rt: HTMLElement;\n rp: HTMLElement;\n bdi: HTMLElement;\n bdo: HTMLElement;\n data: HTMLDataElement;\n template: HTMLTemplateElement;\n slot: HTMLSlotElement;\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,YAAY;CAEvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  //#region src/transpiler/html/validateHTML.ts
4
- const VOID_HTML_ELEMENTS = new Set([
4
+ const VOID_HTML_ELEMENTS = /* @__PURE__ */ new Set([
5
5
  "area",
6
6
  "base",
7
7
  "br",
@@ -1 +1 @@
1
- {"version":3,"file":"validateHTML.cjs","names":[],"sources":["../../../../src/transpiler/html/validateHTML.ts"],"sourcesContent":["export const VOID_HTML_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport type HTMLValidationIssue = {\n type: 'error' | 'warning';\n message: string;\n};\n\nexport type HTMLValidationResult = {\n valid: boolean;\n issues: HTMLValidationIssue[];\n};\n\n// Matches HTML tags: <Tag ...>, </Tag>, or <Tag ... />\n// Attributes may span multiple lines but NOT blank lines (two consecutive newlines),\n// which prevents matching blockquote `>` markers as tag closers.\n// Groups: 1: closing slash, 2: tag name, 3: attributes, 4: self-closing slash\nconst TAG_REGEX =\n /<(\\/)?([a-zA-Z][a-zA-Z0-9.-]*)\\s*((?:[^\\n]|\\n(?!\\n))*?)(\\/?)>/g;\n\n/**\n * Validates that HTML tags in `content` are properly opened, nested, and closed.\n * Returns structured issues instead of logging to the console.\n *\n * False-positive exclusions:\n * - Tags whose attribute string starts with `://` are URL autolinks (e.g. `<https://…>`).\n */\nexport const validateHTML = (content: string): HTMLValidationResult => {\n const issues: HTMLValidationIssue[] = [];\n const stack: Array<{ tag: string }> = [];\n\n for (const match of content.matchAll(TAG_REGEX)) {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attrs = match[3];\n const isSelfClosing = !!match[4];\n\n // Skip URL autolinks like <https://example.com> or <mailto:user@example.com>\n if (\n attrs.trimStart().startsWith('://') ||\n attrs.trimStart().startsWith(':')\n ) {\n continue;\n }\n\n if (isClosing) {\n if (stack.length === 0) {\n issues.push({\n type: 'error',\n message: `Closing tag </${tagName}> has no matching opening tag`,\n });\n } else {\n const last = stack[stack.length - 1];\n if (last.tag.toLowerCase() !== tagName.toLowerCase()) {\n issues.push({\n type: 'error',\n message: `Mismatched closing tag: expected </${last.tag}> but found </${tagName}>`,\n });\n }\n stack.pop();\n }\n } else {\n const isVoidElement = VOID_HTML_ELEMENTS.has(tagName.toLowerCase());\n if (!isSelfClosing && !isVoidElement) {\n stack.push({ tag: tagName });\n }\n }\n }\n\n for (const unclosed of stack) {\n issues.push({\n type: 'error',\n message: `Unclosed HTML tag: <${unclosed.tag}>`,\n });\n }\n\n return {\n valid: issues.filter((i) => i.type === 'error').length === 0,\n issues,\n };\n};\n"],"mappings":";;;AAAA,MAAa,qBAAqB,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAgBF,MAAM,YACJ;;;;;;;;AASF,MAAa,gBAAgB,YAA0C;CACrE,MAAM,SAAgC,EAAE;CACxC,MAAM,QAAgC,EAAE;AAExC,MAAK,MAAM,SAAS,QAAQ,SAAS,UAAU,EAAE;EAC/C,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,MAAM,gBAAgB,CAAC,CAAC,MAAM;AAG9B,MACE,MAAM,WAAW,CAAC,WAAW,MAAM,IACnC,MAAM,WAAW,CAAC,WAAW,IAAI,CAEjC;AAGF,MAAI,UACF,KAAI,MAAM,WAAW,EACnB,QAAO,KAAK;GACV,MAAM;GACN,SAAS,iBAAiB,QAAQ;GACnC,CAAC;OACG;GACL,MAAM,OAAO,MAAM,MAAM,SAAS;AAClC,OAAI,KAAK,IAAI,aAAa,KAAK,QAAQ,aAAa,CAClD,QAAO,KAAK;IACV,MAAM;IACN,SAAS,sCAAsC,KAAK,IAAI,gBAAgB,QAAQ;IACjF,CAAC;AAEJ,SAAM,KAAK;;OAER;GACL,MAAM,gBAAgB,mBAAmB,IAAI,QAAQ,aAAa,CAAC;AACnE,OAAI,CAAC,iBAAiB,CAAC,cACrB,OAAM,KAAK,EAAE,KAAK,SAAS,CAAC;;;AAKlC,MAAK,MAAM,YAAY,MACrB,QAAO,KAAK;EACV,MAAM;EACN,SAAS,uBAAuB,SAAS,IAAI;EAC9C,CAAC;AAGJ,QAAO;EACL,OAAO,OAAO,QAAQ,MAAM,EAAE,SAAS,QAAQ,CAAC,WAAW;EAC3D;EACD"}
1
+ {"version":3,"file":"validateHTML.cjs","names":[],"sources":["../../../../src/transpiler/html/validateHTML.ts"],"sourcesContent":["export const VOID_HTML_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport type HTMLValidationIssue = {\n type: 'error' | 'warning';\n message: string;\n};\n\nexport type HTMLValidationResult = {\n valid: boolean;\n issues: HTMLValidationIssue[];\n};\n\n// Matches HTML tags: <Tag ...>, </Tag>, or <Tag ... />\n// Attributes may span multiple lines but NOT blank lines (two consecutive newlines),\n// which prevents matching blockquote `>` markers as tag closers.\n// Groups: 1: closing slash, 2: tag name, 3: attributes, 4: self-closing slash\nconst TAG_REGEX =\n /<(\\/)?([a-zA-Z][a-zA-Z0-9.-]*)\\s*((?:[^\\n]|\\n(?!\\n))*?)(\\/?)>/g;\n\n/**\n * Validates that HTML tags in `content` are properly opened, nested, and closed.\n * Returns structured issues instead of logging to the console.\n *\n * False-positive exclusions:\n * - Tags whose attribute string starts with `://` are URL autolinks (e.g. `<https://…>`).\n */\nexport const validateHTML = (content: string): HTMLValidationResult => {\n const issues: HTMLValidationIssue[] = [];\n const stack: Array<{ tag: string }> = [];\n\n for (const match of content.matchAll(TAG_REGEX)) {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attrs = match[3];\n const isSelfClosing = !!match[4];\n\n // Skip URL autolinks like <https://example.com> or <mailto:user@example.com>\n if (\n attrs.trimStart().startsWith('://') ||\n attrs.trimStart().startsWith(':')\n ) {\n continue;\n }\n\n if (isClosing) {\n if (stack.length === 0) {\n issues.push({\n type: 'error',\n message: `Closing tag </${tagName}> has no matching opening tag`,\n });\n } else {\n const last = stack[stack.length - 1];\n if (last.tag.toLowerCase() !== tagName.toLowerCase()) {\n issues.push({\n type: 'error',\n message: `Mismatched closing tag: expected </${last.tag}> but found </${tagName}>`,\n });\n }\n stack.pop();\n }\n } else {\n const isVoidElement = VOID_HTML_ELEMENTS.has(tagName.toLowerCase());\n if (!isSelfClosing && !isVoidElement) {\n stack.push({ tag: tagName });\n }\n }\n }\n\n for (const unclosed of stack) {\n issues.push({\n type: 'error',\n message: `Unclosed HTML tag: <${unclosed.tag}>`,\n });\n }\n\n return {\n valid: issues.filter((i) => i.type === 'error').length === 0,\n issues,\n };\n};\n"],"mappings":";;;AAAA,MAAa,qCAAqB,IAAI,IAAI;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAgBD,MAAM,YACJ;;;;;;;;AASF,MAAa,gBAAgB,YAA0C;CACrE,MAAM,SAAgC,CAAC;CACvC,MAAM,QAAgC,CAAC;CAEvC,KAAK,MAAM,SAAS,QAAQ,SAAS,SAAS,GAAG;EAC/C,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,MAAM,gBAAgB,CAAC,CAAC,MAAM;EAG9B,IACE,MAAM,UAAU,CAAC,CAAC,WAAW,KAAK,KAClC,MAAM,UAAU,CAAC,CAAC,WAAW,GAAG,GAEhC;EAGF,IAAI,WACF,IAAI,MAAM,WAAW,GACnB,OAAO,KAAK;GACV,MAAM;GACN,SAAS,iBAAiB,QAAQ;EACpC,CAAC;OACI;GACL,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,IAAI,KAAK,IAAI,YAAY,MAAM,QAAQ,YAAY,GACjD,OAAO,KAAK;IACV,MAAM;IACN,SAAS,sCAAsC,KAAK,IAAI,gBAAgB,QAAQ;GAClF,CAAC;GAEH,MAAM,IAAI;EACZ;OACK;GACL,MAAM,gBAAgB,mBAAmB,IAAI,QAAQ,YAAY,CAAC;GAClE,IAAI,CAAC,iBAAiB,CAAC,eACrB,MAAM,KAAK,EAAE,KAAK,QAAQ,CAAC;EAE/B;CACF;CAEA,KAAK,MAAM,YAAY,OACrB,OAAO,KAAK;EACV,MAAM;EACN,SAAS,uBAAuB,SAAS,IAAI;CAC/C,CAAC;CAGH,OAAO;EACL,OAAO,OAAO,QAAQ,MAAM,EAAE,SAAS,OAAO,CAAC,CAAC,WAAW;EAC3D;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getInsertionValues.cjs","names":[],"sources":["../../../../src/transpiler/insertion/getInsertionValues.ts"],"sourcesContent":["export const getInsertionValues = (content: string): string[] => {\n // Regular expression to match {{field}} patterns\n const regex = /{{\\s*(.*?)\\s*}}/g;\n const matches = [...content.matchAll(regex)];\n\n // If no matches are found, return undefined\n if (matches.length === 0) return [];\n\n // Extract field names from matches and return as an object with the field names\n return [...new Set(matches.map((match) => match[1].trim()))].filter(Boolean);\n};\n"],"mappings":";;;AAAA,MAAa,sBAAsB,YAA8B;CAG/D,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,mBAAM,CAAC;AAG5C,KAAI,QAAQ,WAAW,EAAG,QAAO,EAAE;AAGnC,QAAO,CAAC,GAAG,IAAI,IAAI,QAAQ,KAAK,UAAU,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,QAAQ"}
1
+ {"version":3,"file":"getInsertionValues.cjs","names":[],"sources":["../../../../src/transpiler/insertion/getInsertionValues.ts"],"sourcesContent":["export const getInsertionValues = (content: string): string[] => {\n // Regular expression to match {{field}} patterns\n const regex = /{{\\s*(.*?)\\s*}}/g;\n const matches = [...content.matchAll(regex)];\n\n // If no matches are found, return undefined\n if (matches.length === 0) return [];\n\n // Extract field names from matches and return as an object with the field names\n return [...new Set(matches.map((match) => match[1].trim()))].filter(Boolean);\n};\n"],"mappings":";;;AAAA,MAAa,sBAAsB,YAA8B;CAG/D,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,kBAAK,CAAC;CAG3C,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC;CAGlC,OAAO,CAAC,GAAG,IAAI,IAAI,QAAQ,KAAK,UAAU,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO;AAC7E"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  const require_transpiler_insertion_getInsertionValues = require('./getInsertionValues.cjs');
4
3
  let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
5
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"insertion.cjs","names":["getInsertionValues","INSERTION"],"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, INSERTION } from '@intlayer/types/nodeType';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<typeof INSERTION, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(INSERTION, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,aACJ,YAC8B;CAC9B,MAAM,sBAAsB;AAC1B,MAAI,OAAO,YAAY,SACrB,QAAOA,mEAAmB,QAAQ;EAGpC,IAAI;AAEJ,MAAI,OAAO,YAAY,WACrB,iBAAgB,SAAS;WAChB,OAAQ,QAA4B,SAAS,WACtD,iBAAgB,YACdA,mEAAmB,MAAO,QAA4B;AAG1D,MAAI,OAAO,kBAAkB,SAC3B,QAAOA,mEAAmB,cAAc;AAG1C,MAAI;AACF,UAAOA,mEAAmB,KAAK,UAAU,QAAQ,CAAC;WAC3C,IAAI;AACX,UAAO,EAAE;;;AAIb,qDAAsBC,oCAAW,SAAS,EACxC,QAAQ,eAAe,EACxB,CAAC"}
1
+ {"version":3,"file":"insertion.cjs","names":["getInsertionValues","INSERTION"],"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, INSERTION } from '@intlayer/types/nodeType';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<typeof INSERTION, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(INSERTION, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAM,aACJ,YAC8B;CAC9B,MAAM,sBAAsB;EAC1B,IAAI,OAAO,YAAY,UACrB,OAAOA,mEAAmB,OAAO;EAGnC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,QAAQ;OACnB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACdA,mEAAmB,MAAO,OAA2B;EAGzD,IAAI,OAAO,kBAAkB,UAC3B,OAAOA,mEAAmB,aAAa;EAGzC,IAAI;GACF,OAAOA,mEAAmB,KAAK,UAAU,OAAO,CAAC;EACnD,SAAS,IAAI;GACX,OAAO,CAAC;EACV;CACF;CAEA,oDAAsBC,oCAAW,SAAS,EACxC,QAAQ,cAAc,EACxB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getMarkdownMetadata.cjs","names":["parseYaml"],"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"sourcesContent":["import { parseYaml } from '../../utils/parseYaml';\n\nexport const getMarkdownMetadata = <T extends Record<string, any>>(\n markdown: string\n): T => {\n try {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter.\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (firstNonEmptyLine?.trim() !== '---') {\n const result: T = {} as T;\n return result;\n }\n\n // Find the end of the metadata block\n let metadataEndIndex = -1;\n for (let i = 1; i < lines.length; i++) {\n if (lines[i]?.trim() === '---') {\n metadataEndIndex = i;\n break;\n }\n }\n\n if (metadataEndIndex === -1) {\n // No closing delimiter found\n const result: T = {} as T;\n return result;\n }\n\n // Extract the metadata content between the delimiters\n const metadataLines = lines.slice(1, metadataEndIndex);\n const metadataContent = metadataLines.join('\\n');\n\n // Use the improved parseYaml function to parse the entire metadata block\n const metadata = parseYaml<T>(metadataContent);\n\n return metadata ?? ({} as T);\n } catch {\n const result: T = {} as T;\n return result;\n }\n};\n"],"mappings":";;;;AAEA,MAAa,uBACX,aACM;AACN,KAAI;EACF,MAAM,QAAQ,SAAS,MAAM,QAAQ;AAKrC,MAF0B,MAAM,MAAM,SAAS,KAAK,MAAM,KAAK,GAE1C,EAAE,MAAM,KAAK,MAEhC,QAAO,EAAM;EAIf,IAAI,mBAAmB;AACvB,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,IAChC,KAAI,MAAM,IAAI,MAAM,KAAK,OAAO;AAC9B,sBAAmB;AACnB;;AAIJ,MAAI,qBAAqB,GAGvB,QAAO,EAAM;AAUf,SAFiBA,kCAJK,MAAM,MAAM,GAAG,iBACA,CAAC,KAAK,KAGE,CAE9B,IAAK,EAAE;SAChB;AAEN,SAAO,EAAM"}
1
+ {"version":3,"file":"getMarkdownMetadata.cjs","names":["parseYaml"],"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"sourcesContent":["import { parseYaml } from '../../utils/parseYaml';\n\nexport const getMarkdownMetadata = <T extends Record<string, any>>(\n markdown: string\n): T => {\n try {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter.\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (firstNonEmptyLine?.trim() !== '---') {\n const result: T = {} as T;\n return result;\n }\n\n // Find the end of the metadata block\n let metadataEndIndex = -1;\n for (let i = 1; i < lines.length; i++) {\n if (lines[i]?.trim() === '---') {\n metadataEndIndex = i;\n break;\n }\n }\n\n if (metadataEndIndex === -1) {\n // No closing delimiter found\n const result: T = {} as T;\n return result;\n }\n\n // Extract the metadata content between the delimiters\n const metadataLines = lines.slice(1, metadataEndIndex);\n const metadataContent = metadataLines.join('\\n');\n\n // Use the improved parseYaml function to parse the entire metadata block\n const metadata = parseYaml<T>(metadataContent);\n\n return metadata ?? ({} as T);\n } catch {\n const result: T = {} as T;\n return result;\n }\n};\n"],"mappings":";;;;AAEA,MAAa,uBACX,aACM;CACN,IAAI;EACF,MAAM,QAAQ,SAAS,MAAM,OAAO;EAKpC,IAF0B,MAAM,MAAM,SAAS,KAAK,KAAK,MAAM,EAE3C,CAAC,EAAE,KAAK,MAAM,OAEhC,OAAO,CAAK;EAId,IAAI,mBAAmB;EACvB,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,IAAI,MAAM,EAAE,EAAE,KAAK,MAAM,OAAO;GAC9B,mBAAmB;GACnB;EACF;EAGF,IAAI,qBAAqB,IAGvB,OAAO,CAAK;EAUd,OAFiBA,kCAJK,MAAM,MAAM,GAAG,gBACD,CAAC,CAAC,KAAK,IAGC,CAE9B,KAAM,CAAC;CACvB,QAAQ;EAEN,OAAO,CAAK;CACd;AACF"}
@@ -1,5 +1,4 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
3
2
  const require_interpreter_getContent_getContent = require('../../interpreter/getContent/getContent.cjs');
4
3
  const require_transpiler_html_getHTMLCustomComponents = require('../html/getHTMLCustomComponents.cjs');
5
4
  const require_transpiler_markdown_getMarkdownMetadata = require('./getMarkdownMetadata.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.cjs","names":["getContent","validateMarkdown","getMarkdownMetadata","getHTMLCustomComponents","MARKDOWN"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, MARKDOWN } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<typeof MARKDOWN, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(MARKDOWN, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":";;;;;;;;;AA8BA,MAAM,eAAe,OAAO,YAAiB;AAC3C,KAAI,OAAO,YAAY,YAAY,OAAO,YAAY,SACpD,QAAO;AAGT,KAAI,OAAO,YAAY,WACrB,QAAO,SAAS;AAElB,KAAI,OAAO,QAAQ,SAAS,WAC1B,QAAO,MAAM;;;;;;;;;;;;;;AAgBjB,MAAM,YAIJ,SACA,eACyC;CACzC,MAAM,WAAW,YAAY;EAG3B,MAAM,cAAcA,qDAAW,MAFF,aAAa,QAAQ,EAEH;GAC7C,eAAe;GACf,SAAS,EAAE;GACZ,CAAC;AAEF,MAAI,OAAO,gBAAgB,UAAU;AACnC,OAAI,QAAQ,IAAI,aAAa,cAAc;IACzC,MAAM,EAAE,WAAWC,8DAAiB,YAAY;AAChD,SAAK,MAAM,SAAS,OAClB,KAAI,MAAM,SAAS,QACjB,SAAQ,MAAM,uBAAuB,MAAM,UAAU;QAErD,SAAQ,KAAK,uBAAuB,MAAM,UAAU;;AAK1D,UAAOC,oEAAoB,YAAY;;;CAI3C,MAAM,sBAAsB;AAC1B,MAAI,WACF,QAAO;AAGT,MAAI,OAAO,YAAY,SACrB,QAAOC,wEAAwB,QAAQ;EAGzC,IAAI;AAEJ,MAAI,OAAO,YAAY,WACrB,iBAAgB,SAAS;WAChB,OAAQ,QAA4B,SAAS,WACtD,iBAAgB,YACdA,wEAAyB,MAAO,QAAuC;AAG3E,MAAI,OAAO,kBAAkB,SAC3B,QAAOA,wEAAwB,cAAc;AAG/C,MAAI;AACF,UAAOA,wEAAwB,KAAK,UAAU,QAAQ,CAAC;WAChD,IAAI;AACX,UAAO,EAAE;;;AAIb,qDAAsBC,mCAAU,SAAS;EACvC;EACA,MAAM,eAAe;EACtB,CAAC"}
1
+ {"version":3,"file":"markdown.cjs","names":["getContent","validateMarkdown","getMarkdownMetadata","getHTMLCustomComponents","MARKDOWN"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, MARKDOWN } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<typeof MARKDOWN, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(MARKDOWN, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":";;;;;;;;AA8BA,MAAM,eAAe,OAAO,YAAiB;CAC3C,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,OAAO;CAGT,IAAI,OAAO,YAAY,YACrB,OAAO,QAAQ;CAEjB,IAAI,OAAO,QAAQ,SAAS,YAC1B,OAAO,MAAM;AAEjB;;;;;;;;;;;;;AAcA,MAAM,YAIJ,SACA,eACyC;CACzC,MAAM,WAAW,YAAY;EAG3B,MAAM,cAAcA,qDAAW,MAFF,aAAa,OAAO,GAEF;GAC7C,eAAe;GACf,SAAS,CAAC;EACZ,CAAC;EAED,IAAI,OAAO,gBAAgB,UAAU;GACnC,IAAI,QAAQ,IAAI,aAAa,cAAc;IACzC,MAAM,EAAE,WAAWC,8DAAiB,WAAW;IAC/C,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,SACjB,QAAQ,MAAM,uBAAuB,MAAM,SAAS;SAEpD,QAAQ,KAAK,uBAAuB,MAAM,SAAS;GAGzD;GAEA,OAAOC,oEAAoB,WAAW;EACxC;CACF;CAEA,MAAM,sBAAsB;EAC1B,IAAI,YACF,OAAO;EAGT,IAAI,OAAO,YAAY,UACrB,OAAOC,wEAAwB,OAAO;EAGxC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,QAAQ;OACnB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACdA,wEAAyB,MAAO,OAAsC;EAG1E,IAAI,OAAO,kBAAkB,UAC3B,OAAOA,wEAAwB,aAAa;EAG9C,IAAI;GACF,OAAOA,wEAAwB,KAAK,UAAU,OAAO,CAAC;EACxD,SAAS,IAAI;GACX,OAAO,CAAC;EACV;CACF;CAEA,oDAAsBC,mCAAU,SAAS;EACvC;EACA,MAAM,cAAc;CACtB,CAAC;AACH"}