@intlayer/core 9.0.0-canary.9 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (513) 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/index.cjs +3 -3
  21. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -2
  22. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs +8 -7
  24. package/dist/cjs/dictionaryManipulator/mergeQualifiedDictionaries.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  26. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +0 -1
  27. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  28. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs +81 -40
  29. package/dist/cjs/dictionaryManipulator/qualifiedDictionary.cjs.map +1 -1
  30. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  32. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  33. package/dist/cjs/formatters/compact.cjs +1 -2
  34. package/dist/cjs/formatters/compact.cjs.map +1 -1
  35. package/dist/cjs/formatters/currency.cjs +1 -2
  36. package/dist/cjs/formatters/currency.cjs.map +1 -1
  37. package/dist/cjs/formatters/date.cjs +1 -3
  38. package/dist/cjs/formatters/date.cjs.map +1 -1
  39. package/dist/cjs/formatters/list.cjs +1 -2
  40. package/dist/cjs/formatters/list.cjs.map +1 -1
  41. package/dist/cjs/formatters/number.cjs +1 -2
  42. package/dist/cjs/formatters/number.cjs.map +1 -1
  43. package/dist/cjs/formatters/percentage.cjs +1 -2
  44. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  45. package/dist/cjs/formatters/relativeTime.cjs +1 -2
  46. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  47. package/dist/cjs/formatters/units.cjs +1 -2
  48. package/dist/cjs/formatters/units.cjs.map +1 -1
  49. package/dist/cjs/index.cjs +17 -3
  50. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  51. package/dist/cjs/interpreter/getContent/deepTransform.cjs +3 -2
  52. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  53. package/dist/cjs/interpreter/getContent/getContent.cjs +0 -1
  54. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  55. package/dist/cjs/interpreter/getContent/plugins.cjs +9 -4
  56. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  57. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  58. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  59. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  60. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  61. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  62. package/dist/cjs/interpreter/getIntlayer.cjs +2 -2
  63. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  64. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  65. package/dist/cjs/interpreter/getPlural.cjs +1 -1
  66. package/dist/cjs/interpreter/getPlural.cjs.map +1 -1
  67. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  68. package/dist/cjs/interpreter/index.cjs +7 -0
  69. package/dist/cjs/interpreter/interpolableNode.cjs +83 -0
  70. package/dist/cjs/interpreter/interpolableNode.cjs.map +1 -0
  71. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  72. package/dist/cjs/localization/comparePaths.cjs.map +1 -1
  73. package/dist/cjs/localization/domainUtils.cjs +82 -0
  74. package/dist/cjs/localization/domainUtils.cjs.map +1 -0
  75. package/dist/cjs/localization/generateSitemap.cjs +2 -1
  76. package/dist/cjs/localization/generateSitemap.cjs.map +1 -1
  77. package/dist/cjs/localization/getBrowserLocale.cjs +7 -4
  78. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  79. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  80. package/dist/cjs/localization/getLocale.cjs +0 -1
  81. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  82. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  83. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  84. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  85. package/dist/cjs/localization/getLocalizedUrl.cjs +4 -12
  86. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  87. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  88. package/dist/cjs/localization/getPathWithoutLocale.cjs +0 -1
  89. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  90. package/dist/cjs/localization/getPrefix.cjs +5 -10
  91. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  92. package/dist/cjs/localization/index.cjs +5 -0
  93. package/dist/cjs/localization/localeDetector.cjs +2 -1
  94. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  95. package/dist/cjs/localization/localeMapper.cjs +0 -1
  96. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  97. package/dist/cjs/localization/localeResolver.cjs +0 -1
  98. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  99. package/dist/cjs/localization/rewriteUtils.cjs +2 -1
  100. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  101. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  102. package/dist/cjs/markdown/compiler.cjs +2 -1
  103. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  104. package/dist/cjs/markdown/constants.cjs.map +1 -1
  105. package/dist/cjs/markdown/parser.cjs.map +1 -1
  106. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  107. package/dist/cjs/markdown/utils.cjs.map +1 -1
  108. package/dist/cjs/messageFormat/ICU.cjs +15 -9
  109. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  110. package/dist/cjs/messageFormat/i18next.cjs +12 -7
  111. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  112. package/dist/cjs/messageFormat/index.cjs +2 -0
  113. package/dist/cjs/messageFormat/navigatePath.cjs +38 -0
  114. package/dist/cjs/messageFormat/navigatePath.cjs.map +1 -0
  115. package/dist/cjs/messageFormat/po.cjs.map +1 -1
  116. package/dist/cjs/messageFormat/resolveMessage.cjs +11 -8
  117. package/dist/cjs/messageFormat/resolveMessage.cjs.map +1 -1
  118. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  119. package/dist/cjs/messageFormat/vue-i18n.cjs +2 -1
  120. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  121. package/dist/cjs/transpiler/condition/condition.cjs +0 -1
  122. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  123. package/dist/cjs/transpiler/enumeration/enumeration.cjs +0 -1
  124. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  125. package/dist/cjs/transpiler/file/file.cjs +2 -2
  126. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  127. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  128. package/dist/cjs/transpiler/gender/gender.cjs +0 -1
  129. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  130. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  131. package/dist/cjs/transpiler/html/html.cjs +0 -1
  132. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  133. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  134. package/dist/cjs/transpiler/html/validateHTML.cjs +1 -1
  135. package/dist/cjs/transpiler/html/validateHTML.cjs.map +1 -1
  136. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  137. package/dist/cjs/transpiler/insertion/insertion.cjs +0 -1
  138. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  139. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  140. package/dist/cjs/transpiler/markdown/markdown.cjs +0 -1
  141. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  142. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs.map +1 -1
  143. package/dist/cjs/transpiler/nesting/nesting.cjs +0 -1
  144. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  145. package/dist/cjs/transpiler/plural/plural.cjs +0 -1
  146. package/dist/cjs/transpiler/plural/plural.cjs.map +1 -1
  147. package/dist/cjs/transpiler/translation/translation.cjs +0 -1
  148. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  149. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  150. package/dist/cjs/utils/cookieExpiry.cjs.map +1 -1
  151. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  152. package/dist/cjs/utils/intl.cjs +101 -26
  153. package/dist/cjs/utils/intl.cjs.map +1 -1
  154. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  155. package/dist/cjs/utils/localeStorage.cjs +0 -1
  156. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  157. package/dist/cjs/utils/parseYaml.cjs +1 -1
  158. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  159. package/dist/cjs/utils/stringifyYaml.cjs +1 -1
  160. package/dist/cjs/utils/stringifyYaml.cjs.map +1 -1
  161. package/dist/esm/deepTransformPlugins/getEditedContent.mjs +2 -1
  162. package/dist/esm/deepTransformPlugins/getEditedContent.mjs.map +1 -1
  163. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  164. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  165. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  166. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  167. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  168. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  169. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  170. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  171. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -1
  172. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  173. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  174. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  175. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  176. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  177. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  178. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  179. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  180. package/dist/esm/dictionaryManipulator/index.mjs +2 -2
  181. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -1
  182. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  183. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs +9 -7
  184. package/dist/esm/dictionaryManipulator/mergeQualifiedDictionaries.mjs.map +1 -1
  185. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  186. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  187. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs +79 -38
  188. package/dist/esm/dictionaryManipulator/qualifiedDictionary.mjs.map +1 -1
  189. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  190. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  191. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  192. package/dist/esm/formatters/compact.mjs +1 -1
  193. package/dist/esm/formatters/compact.mjs.map +1 -1
  194. package/dist/esm/formatters/currency.mjs +1 -1
  195. package/dist/esm/formatters/currency.mjs.map +1 -1
  196. package/dist/esm/formatters/date.mjs +1 -2
  197. package/dist/esm/formatters/date.mjs.map +1 -1
  198. package/dist/esm/formatters/list.mjs +1 -1
  199. package/dist/esm/formatters/list.mjs.map +1 -1
  200. package/dist/esm/formatters/number.mjs +1 -1
  201. package/dist/esm/formatters/number.mjs.map +1 -1
  202. package/dist/esm/formatters/percentage.mjs +1 -1
  203. package/dist/esm/formatters/percentage.mjs.map +1 -1
  204. package/dist/esm/formatters/relativeTime.mjs +1 -1
  205. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  206. package/dist/esm/formatters/units.mjs +1 -1
  207. package/dist/esm/formatters/units.mjs.map +1 -1
  208. package/dist/esm/index.mjs +6 -2
  209. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  210. package/dist/esm/interpreter/getContent/deepTransform.mjs +3 -2
  211. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  212. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  213. package/dist/esm/interpreter/getContent/plugins.mjs +9 -4
  214. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  215. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  216. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  217. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  218. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  219. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  220. package/dist/esm/interpreter/getIntlayer.mjs +2 -1
  221. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  222. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  223. package/dist/esm/interpreter/getPlural.mjs +1 -1
  224. package/dist/esm/interpreter/getPlural.mjs.map +1 -1
  225. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  226. package/dist/esm/interpreter/index.mjs +3 -1
  227. package/dist/esm/interpreter/interpolableNode.mjs +77 -0
  228. package/dist/esm/interpreter/interpolableNode.mjs.map +1 -0
  229. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  230. package/dist/esm/localization/comparePaths.mjs.map +1 -1
  231. package/dist/esm/localization/domainUtils.mjs +77 -0
  232. package/dist/esm/localization/domainUtils.mjs.map +1 -0
  233. package/dist/esm/localization/generateSitemap.mjs +2 -1
  234. package/dist/esm/localization/generateSitemap.mjs.map +1 -1
  235. package/dist/esm/localization/getBrowserLocale.mjs +7 -3
  236. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  237. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  238. package/dist/esm/localization/getLocale.mjs.map +1 -1
  239. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  240. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  241. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  242. package/dist/esm/localization/getLocalizedUrl.mjs +4 -11
  243. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  244. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  245. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  246. package/dist/esm/localization/getPrefix.mjs +5 -9
  247. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  248. package/dist/esm/localization/index.mjs +2 -1
  249. package/dist/esm/localization/localeDetector.mjs +2 -1
  250. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  251. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  252. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  253. package/dist/esm/localization/rewriteUtils.mjs +2 -1
  254. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  255. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  256. package/dist/esm/markdown/compiler.mjs +2 -1
  257. package/dist/esm/markdown/compiler.mjs.map +1 -1
  258. package/dist/esm/markdown/constants.mjs.map +1 -1
  259. package/dist/esm/markdown/parser.mjs.map +1 -1
  260. package/dist/esm/markdown/renderer.mjs.map +1 -1
  261. package/dist/esm/markdown/utils.mjs.map +1 -1
  262. package/dist/esm/messageFormat/ICU.mjs +15 -9
  263. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  264. package/dist/esm/messageFormat/i18next.mjs +12 -7
  265. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  266. package/dist/esm/messageFormat/index.mjs +2 -1
  267. package/dist/esm/messageFormat/navigatePath.mjs +36 -0
  268. package/dist/esm/messageFormat/navigatePath.mjs.map +1 -0
  269. package/dist/esm/messageFormat/po.mjs.map +1 -1
  270. package/dist/esm/messageFormat/resolveMessage.mjs +11 -8
  271. package/dist/esm/messageFormat/resolveMessage.mjs.map +1 -1
  272. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  273. package/dist/esm/messageFormat/vue-i18n.mjs +2 -1
  274. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  275. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  276. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  277. package/dist/esm/transpiler/file/file.mjs +2 -1
  278. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  279. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  280. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  281. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  282. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  283. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  284. package/dist/esm/transpiler/html/validateHTML.mjs +1 -1
  285. package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -1
  286. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  287. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  288. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  289. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  290. package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -1
  291. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  292. package/dist/esm/transpiler/plural/plural.mjs.map +1 -1
  293. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  294. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  295. package/dist/esm/utils/cookieExpiry.mjs.map +1 -1
  296. package/dist/esm/utils/getCookie.mjs.map +1 -1
  297. package/dist/esm/utils/intl.mjs +100 -25
  298. package/dist/esm/utils/intl.mjs.map +1 -1
  299. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  300. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  301. package/dist/esm/utils/parseYaml.mjs +1 -1
  302. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  303. package/dist/esm/utils/stringifyYaml.mjs +1 -1
  304. package/dist/esm/utils/stringifyYaml.mjs.map +1 -1
  305. package/dist/types/deepTransformPlugins/getEditedContent.d.ts +0 -1
  306. package/dist/types/deepTransformPlugins/getEditedContent.d.ts.map +1 -1
  307. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +12 -13
  308. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
  309. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +12 -13
  310. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  311. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +12 -13
  312. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  313. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +1 -1
  314. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -1
  315. package/dist/types/deepTransformPlugins/getMaskContent.d.ts +1 -1
  316. package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +1 -1
  317. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +1 -1
  318. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +1 -1
  319. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +0 -1
  320. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +1 -1
  321. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +1 -1
  322. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +1 -1
  323. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +1 -2
  324. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -1
  325. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +1 -2
  326. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +1 -1
  327. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +0 -1
  328. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -1
  329. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +0 -1
  330. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -1
  331. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +0 -1
  332. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -1
  333. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +0 -1
  334. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -1
  335. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +0 -1
  336. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -1
  337. package/dist/types/dictionaryManipulator/getNodeType.d.ts +0 -1
  338. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
  339. package/dist/types/dictionaryManipulator/index.d.ts +2 -2
  340. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +0 -1
  341. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +1 -1
  342. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts +0 -1
  343. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts.map +1 -1
  344. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +0 -1
  345. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +1 -1
  346. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +1 -2
  347. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
  348. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts +33 -23
  349. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts.map +1 -1
  350. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +0 -1
  351. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -1
  352. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +1 -2
  353. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -1
  354. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +0 -1
  355. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -1
  356. package/dist/types/formatters/compact.d.ts +0 -1
  357. package/dist/types/formatters/compact.d.ts.map +1 -1
  358. package/dist/types/formatters/currency.d.ts +0 -1
  359. package/dist/types/formatters/currency.d.ts.map +1 -1
  360. package/dist/types/formatters/date.d.ts +0 -1
  361. package/dist/types/formatters/date.d.ts.map +1 -1
  362. package/dist/types/formatters/index.d.ts +2 -2
  363. package/dist/types/formatters/list.d.ts +0 -1
  364. package/dist/types/formatters/list.d.ts.map +1 -1
  365. package/dist/types/formatters/number.d.ts +1 -5
  366. package/dist/types/formatters/number.d.ts.map +1 -1
  367. package/dist/types/formatters/percentage.d.ts +1 -5
  368. package/dist/types/formatters/percentage.d.ts.map +1 -1
  369. package/dist/types/formatters/relativeTime.d.ts +0 -1
  370. package/dist/types/formatters/relativeTime.d.ts.map +1 -1
  371. package/dist/types/formatters/units.d.ts +0 -1
  372. package/dist/types/formatters/units.d.ts.map +1 -1
  373. package/dist/types/index.d.ts +16 -3
  374. package/dist/types/interpreter/getCondition.d.ts +1 -0
  375. package/dist/types/interpreter/getCondition.d.ts.map +1 -1
  376. package/dist/types/interpreter/getContent/deepTransform.d.ts +0 -1
  377. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -1
  378. package/dist/types/interpreter/getContent/getContent.d.ts +0 -1
  379. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  380. package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
  381. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  382. package/dist/types/interpreter/getDictionary.d.ts +1 -1
  383. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  384. package/dist/types/interpreter/getEnumeration.d.ts +1 -0
  385. package/dist/types/interpreter/getEnumeration.d.ts.map +1 -1
  386. package/dist/types/interpreter/getGender.d.ts +1 -0
  387. package/dist/types/interpreter/getGender.d.ts.map +1 -1
  388. package/dist/types/interpreter/getHTML.d.ts.map +1 -1
  389. package/dist/types/interpreter/getInsertion.d.ts +2 -1
  390. package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
  391. package/dist/types/interpreter/getIntlayer.d.ts +1 -1
  392. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  393. package/dist/types/interpreter/getNesting.d.ts +2 -1
  394. package/dist/types/interpreter/getNesting.d.ts.map +1 -1
  395. package/dist/types/interpreter/getPlural.d.ts +0 -1
  396. package/dist/types/interpreter/getPlural.d.ts.map +1 -1
  397. package/dist/types/interpreter/getTranslation.d.ts +0 -1
  398. package/dist/types/interpreter/getTranslation.d.ts.map +1 -1
  399. package/dist/types/interpreter/index.d.ts +4 -1
  400. package/dist/types/interpreter/interpolableNode.d.ts +66 -0
  401. package/dist/types/interpreter/interpolableNode.d.ts.map +1 -0
  402. package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +1 -1
  403. package/dist/types/localization/comparePaths.d.ts +0 -1
  404. package/dist/types/localization/comparePaths.d.ts.map +1 -1
  405. package/dist/types/localization/domainUtils.d.ts +69 -0
  406. package/dist/types/localization/domainUtils.d.ts.map +1 -0
  407. package/dist/types/localization/generateSitemap.d.ts +6 -4
  408. package/dist/types/localization/generateSitemap.d.ts.map +1 -1
  409. package/dist/types/localization/getBrowserLocale.d.ts +0 -1
  410. package/dist/types/localization/getBrowserLocale.d.ts.map +1 -1
  411. package/dist/types/localization/getHTMLTextDir.d.ts +0 -1
  412. package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -1
  413. package/dist/types/localization/getLocale.d.ts +0 -1
  414. package/dist/types/localization/getLocale.d.ts.map +1 -1
  415. package/dist/types/localization/getLocaleFromPath.d.ts +0 -1
  416. package/dist/types/localization/getLocaleFromPath.d.ts.map +1 -1
  417. package/dist/types/localization/getLocaleLang.d.ts +0 -1
  418. package/dist/types/localization/getLocaleLang.d.ts.map +1 -1
  419. package/dist/types/localization/getLocaleName.d.ts +0 -1
  420. package/dist/types/localization/getLocaleName.d.ts.map +1 -1
  421. package/dist/types/localization/getLocalizedUrl.d.ts +0 -1
  422. package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
  423. package/dist/types/localization/getMultilingualUrls.d.ts +0 -1
  424. package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -1
  425. package/dist/types/localization/getPathWithoutLocale.d.ts +0 -1
  426. package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -1
  427. package/dist/types/localization/getPrefix.d.ts +2 -3
  428. package/dist/types/localization/getPrefix.d.ts.map +1 -1
  429. package/dist/types/localization/index.d.ts +2 -1
  430. package/dist/types/localization/localeDetector.d.ts +0 -1
  431. package/dist/types/localization/localeDetector.d.ts.map +1 -1
  432. package/dist/types/localization/localeMapper.d.ts +3 -4
  433. package/dist/types/localization/localeMapper.d.ts.map +1 -1
  434. package/dist/types/localization/localeResolver.d.ts +0 -1
  435. package/dist/types/localization/localeResolver.d.ts.map +1 -1
  436. package/dist/types/localization/rewriteUtils.d.ts +2 -3
  437. package/dist/types/localization/rewriteUtils.d.ts.map +1 -1
  438. package/dist/types/localization/validatePrefix.d.ts +0 -1
  439. package/dist/types/localization/validatePrefix.d.ts.map +1 -1
  440. package/dist/types/markdown/compiler.d.ts +0 -1
  441. package/dist/types/markdown/compiler.d.ts.map +1 -1
  442. package/dist/types/markdown/constants.d.ts +48 -38
  443. package/dist/types/markdown/constants.d.ts.map +1 -1
  444. package/dist/types/markdown/index.d.ts +2 -1
  445. package/dist/types/markdown/parser.d.ts +0 -1
  446. package/dist/types/markdown/parser.d.ts.map +1 -1
  447. package/dist/types/markdown/renderer.d.ts +0 -1
  448. package/dist/types/markdown/renderer.d.ts.map +1 -1
  449. package/dist/types/markdown/types.d.ts +44 -24
  450. package/dist/types/markdown/types.d.ts.map +1 -1
  451. package/dist/types/markdown/utils.d.ts +3 -4
  452. package/dist/types/markdown/utils.d.ts.map +1 -1
  453. package/dist/types/messageFormat/ICU.d.ts +2 -3
  454. package/dist/types/messageFormat/ICU.d.ts.map +1 -1
  455. package/dist/types/messageFormat/i18next.d.ts +2 -3
  456. package/dist/types/messageFormat/i18next.d.ts.map +1 -1
  457. package/dist/types/messageFormat/index.d.ts +2 -1
  458. package/dist/types/messageFormat/navigatePath.d.ts +22 -0
  459. package/dist/types/messageFormat/navigatePath.d.ts.map +1 -0
  460. package/dist/types/messageFormat/po.d.ts +2 -3
  461. package/dist/types/messageFormat/po.d.ts.map +1 -1
  462. package/dist/types/messageFormat/resolveMessage.d.ts +0 -1
  463. package/dist/types/messageFormat/resolveMessage.d.ts.map +1 -1
  464. package/dist/types/messageFormat/verify-icu-format.d.ts +1 -1
  465. package/dist/types/messageFormat/vue-i18n.d.ts +2 -3
  466. package/dist/types/messageFormat/vue-i18n.d.ts.map +1 -1
  467. package/dist/types/transpiler/condition/condition.d.ts +0 -1
  468. package/dist/types/transpiler/condition/condition.d.ts.map +1 -1
  469. package/dist/types/transpiler/enumeration/enumeration.d.ts +0 -1
  470. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  471. package/dist/types/transpiler/file/file.d.ts +0 -1
  472. package/dist/types/transpiler/file/file.d.ts.map +1 -1
  473. package/dist/types/transpiler/file/fileBrowser.d.ts +0 -1
  474. package/dist/types/transpiler/file/fileBrowser.d.ts.map +1 -1
  475. package/dist/types/transpiler/gender/gender.d.ts +0 -1
  476. package/dist/types/transpiler/gender/gender.d.ts.map +1 -1
  477. package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -1
  478. package/dist/types/transpiler/html/html.d.ts +0 -1
  479. package/dist/types/transpiler/html/html.d.ts.map +1 -1
  480. package/dist/types/transpiler/html/htmlTags.d.ts +1 -1
  481. package/dist/types/transpiler/html/htmlTags.d.ts.map +1 -1
  482. package/dist/types/transpiler/html/validateHTML.d.ts.map +1 -1
  483. package/dist/types/transpiler/index.d.ts +11 -1
  484. package/dist/types/transpiler/insertion/getInsertionValues.d.ts.map +1 -1
  485. package/dist/types/transpiler/insertion/insertion.d.ts +0 -1
  486. package/dist/types/transpiler/insertion/insertion.d.ts.map +1 -1
  487. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +1 -1
  488. package/dist/types/transpiler/markdown/index.d.ts +1 -1
  489. package/dist/types/transpiler/markdown/markdown.d.ts +0 -1
  490. package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
  491. package/dist/types/transpiler/markdown/validateMarkdown.d.ts +0 -1
  492. package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +1 -1
  493. package/dist/types/transpiler/nesting/nesting.d.ts +4 -4
  494. package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
  495. package/dist/types/transpiler/plural/plural.d.ts +0 -1
  496. package/dist/types/transpiler/plural/plural.d.ts.map +1 -1
  497. package/dist/types/transpiler/translation/translation.d.ts +0 -1
  498. package/dist/types/transpiler/translation/translation.d.ts.map +1 -1
  499. package/dist/types/utils/checkIsURLAbsolute.d.ts.map +1 -1
  500. package/dist/types/utils/cookieExpiry.d.ts +1 -2
  501. package/dist/types/utils/cookieExpiry.d.ts.map +1 -1
  502. package/dist/types/utils/getCookie.d.ts.map +1 -1
  503. package/dist/types/utils/index.d.ts +2 -2
  504. package/dist/types/utils/intl.d.ts +49 -5
  505. package/dist/types/utils/intl.d.ts.map +1 -1
  506. package/dist/types/utils/isSameKeyPath.d.ts +0 -1
  507. package/dist/types/utils/isSameKeyPath.d.ts.map +1 -1
  508. package/dist/types/utils/isValidReactElement.d.ts.map +1 -1
  509. package/dist/types/utils/localeStorage.d.ts +1 -2
  510. package/dist/types/utils/localeStorage.d.ts.map +1 -1
  511. package/dist/types/utils/parseYaml.d.ts.map +1 -1
  512. package/dist/types/utils/stringifyYaml.d.ts.map +1 -1
  513. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.cjs","names":["parseDictionarySelector","getBasePlugins","resolveQualifiedDictionary","getContent"],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * Also accepts a `QualifiedDictionaryGroup` (collections, variants) together\n * with a selector as second argument — the group is resolved to a single entry\n * (or an ordered array of entries for collections without an `item` selector)\n * before transformation.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const { locale, selector } = parseDictionarySelector(localeOrSelector);\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved = resolveQualifiedDictionary(dictionary, selector);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n };\n\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n };\n\n if (resolved === null) return null as any;\n\n if (Array.isArray(resolved)) {\n return resolved.map(transformDictionary) as any;\n }\n\n return transformDictionary(resolved) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAa,iBAIX,YACA,kBACA,YAKG;CACH,MAAM,EAAE,QAAQ,aAAaA,0EAAwB,iBAAiB;CACtE,MAAM,iBAAiB,WAAWC,yDAAe,OAAO;CAExD,MAAM,WAAWC,6EAA2B,YAAY,SAAS;CAEjE,MAAM,uBAAuB,uBAAmC;EAC9D,MAAM,QAAmB;GACvB,eAAe,mBAAmB;GAClC,gBAAgB,mBAAmB;GACnC,SAAS,EAAE;GACX,SAAS;GACV;AAED,SAAOC,qDAAW,mBAAmB,SAAS,OAAO,eAAe;;AAGtE,KAAI,aAAa,KAAM,QAAO;AAE9B,KAAI,MAAM,QAAQ,SAAS,CACzB,QAAO,SAAS,IAAI,oBAAoB;AAG1C,QAAO,oBAAoB,SAAS"}
1
+ {"version":3,"file":"getDictionary.cjs","names":["parseDictionarySelector","getBasePlugins","resolveQualifiedDictionary","getContent"],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type {\n Dictionary,\n DictionarySelector,\n QualifiedDictionaryGroup,\n ResolveQualifiedDictionaryContent,\n} from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n parseDictionarySelector,\n resolveQualifiedDictionary,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * Also accepts a `QualifiedDictionaryGroup` (collections, variants) together\n * with a selector as second argument — the group is resolved to a single entry\n * (or an ordered array of entries for collections without an `item` selector)\n * before transformation.\n *\n * @param dictionary The dictionary (or qualified dictionary group) to transform.\n * @param localeOrSelector The locale, or a selector object (`{ item }`,\n * `{ variant }`, optionally with `locale`).\n * @param plugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n const T extends Dictionary | QualifiedDictionaryGroup,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n dictionary: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n ResolveQualifiedDictionaryContent<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const { locale, selector } = parseDictionarySelector(localeOrSelector);\n const appliedPlugins = plugins ?? getBasePlugins(locale);\n\n const resolved = resolveQualifiedDictionary(dictionary, selector);\n\n const transformDictionary = (resolvedDictionary: Dictionary) => {\n const props: NodeProps = {\n dictionaryKey: resolvedDictionary.key,\n dictionaryPath: resolvedDictionary.filePath,\n keyPath: [],\n plugins: appliedPlugins,\n };\n\n return getContent(resolvedDictionary.content, props, appliedPlugins);\n };\n\n if (resolved === null) return null as any;\n\n if (Array.isArray(resolved)) {\n return resolved.map(transformDictionary) as any;\n }\n\n return transformDictionary(resolved) as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAa,iBAIX,YACA,kBACA,YAKG;CACH,MAAM,EAAE,QAAQ,aAAaA,0EAAwB,gBAAgB;CACrE,MAAM,iBAAiB,WAAWC,yDAAe,MAAM;CAEvD,MAAM,WAAWC,6EAA2B,YAAY,QAAQ;CAEhE,MAAM,uBAAuB,uBAAmC;EAC9D,MAAM,QAAmB;GACvB,eAAe,mBAAmB;GAClC,gBAAgB,mBAAmB;GACnC,SAAS,CAAC;GACV,SAAS;EACX;EAEA,OAAOC,qDAAW,mBAAmB,SAAS,OAAO,cAAc;CACrE;CAEA,IAAI,aAAa,MAAM,OAAO;CAE9B,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,SAAS,IAAI,mBAAmB;CAGzC,OAAO,oBAAoB,QAAQ;AACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getEnumeration.cjs","names":[],"sources":["../../../src/interpreter/getEnumeration.ts"],"sourcesContent":["import type { EnterFormat, EnumerationContentState } from '../transpiler';\n\n/**\n * Find the matching condition for a quantity.\n *\n * Usage:\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // '2'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // '<4'\n * ```\n *\n * If no keys match, the default key is '1'.\n */\nexport const findMatchingCondition = <const Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): EnterFormat | undefined => {\n const numericKeys = Object.keys(enumerationContent);\n\n for (const key of numericKeys) {\n const isEqual =\n (!key.startsWith('>') &&\n !key.startsWith('<') &&\n !key.startsWith('=') &&\n parseFloat(key) === quantity) ||\n (key.startsWith('=') && parseFloat(key.slice(1)) === quantity);\n const isSuperior =\n key.startsWith('>') && quantity > parseFloat(key.slice(1));\n const isSuperiorOrEqual =\n key.startsWith('>=') && quantity >= parseFloat(key.slice(2));\n const isInferior =\n key.startsWith('<') && quantity < parseFloat(key.slice(1));\n const isInferiorOrEqual =\n key.startsWith('<=') && quantity <= parseFloat(key.slice(2));\n\n if (\n isEqual ||\n isSuperior ||\n isSuperiorOrEqual ||\n isInferior ||\n isInferiorOrEqual\n ) {\n return key as EnterFormat;\n }\n }\n};\n\n/**\n * Picks content from an enumeration map based on a provided quantity.\n *\n * Supported keys in the enumeration map:\n * - Specific numbers: '0', '1', '2'\n * - Comparison operators: '<5', '>=10', '<=2'\n * - Fallback: 'fallback'\n *\n * The first matching key in the object's iteration order will be selected.\n *\n * @param enumerationContent - A map of conditions/quantities to content.\n * @param quantity - The number to match against the conditions.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getEnumeration({\n * '0': 'No items',\n * '1': 'One item',\n * '>1': 'Many items',\n * }, 5);\n * // 'Many items'\n * ```\n */\nexport const getEnumeration = <const Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): Content => {\n const key =\n findMatchingCondition<Content>(enumerationContent, quantity) ?? 'fallback';\n\n // Default or error handling if no keys match\n return enumerationContent[key] as Content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,yBACX,oBACA,aAC4B;CAC5B,MAAM,cAAc,OAAO,KAAK,mBAAmB;AAEnD,MAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,UACH,CAAC,IAAI,WAAW,IAAI,IACnB,CAAC,IAAI,WAAW,IAAI,IACpB,CAAC,IAAI,WAAW,IAAI,IACpB,WAAW,IAAI,KAAK,YACrB,IAAI,WAAW,IAAI,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC,KAAK;EACvD,MAAM,aACJ,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC5D,MAAM,oBACJ,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;EAC9D,MAAM,aACJ,IAAI,WAAW,IAAI,IAAI,WAAW,WAAW,IAAI,MAAM,EAAE,CAAC;EAC5D,MAAM,oBACJ,IAAI,WAAW,KAAK,IAAI,YAAY,WAAW,IAAI,MAAM,EAAE,CAAC;AAE9D,MACE,WACA,cACA,qBACA,cACA,kBAEA,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6Bb,MAAa,kBACX,oBACA,aACY;AAKZ,QAAO,mBAHL,sBAA+B,oBAAoB,SAAS,IAAI"}
1
+ {"version":3,"file":"getEnumeration.cjs","names":[],"sources":["../../../src/interpreter/getEnumeration.ts"],"sourcesContent":["import type { EnterFormat, EnumerationContentState } from '../transpiler';\n\n/**\n * Find the matching condition for a quantity.\n *\n * Usage:\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * }, 2);\n * // '2'\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n * ```ts\n * const key = findMatchingCondition({\n * '<4': 'You have less than four',\n * '2': 'You have two',\n * }, 2);\n * // '<4'\n * ```\n *\n * If no keys match, the default key is '1'.\n */\nexport const findMatchingCondition = <const Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): EnterFormat | undefined => {\n const numericKeys = Object.keys(enumerationContent);\n\n for (const key of numericKeys) {\n const isEqual =\n (!key.startsWith('>') &&\n !key.startsWith('<') &&\n !key.startsWith('=') &&\n parseFloat(key) === quantity) ||\n (key.startsWith('=') && parseFloat(key.slice(1)) === quantity);\n const isSuperior =\n key.startsWith('>') && quantity > parseFloat(key.slice(1));\n const isSuperiorOrEqual =\n key.startsWith('>=') && quantity >= parseFloat(key.slice(2));\n const isInferior =\n key.startsWith('<') && quantity < parseFloat(key.slice(1));\n const isInferiorOrEqual =\n key.startsWith('<=') && quantity <= parseFloat(key.slice(2));\n\n if (\n isEqual ||\n isSuperior ||\n isSuperiorOrEqual ||\n isInferior ||\n isInferiorOrEqual\n ) {\n return key as EnterFormat;\n }\n }\n};\n\n/**\n * Picks content from an enumeration map based on a provided quantity.\n *\n * Supported keys in the enumeration map:\n * - Specific numbers: '0', '1', '2'\n * - Comparison operators: '<5', '>=10', '<=2'\n * - Fallback: 'fallback'\n *\n * The first matching key in the object's iteration order will be selected.\n *\n * @param enumerationContent - A map of conditions/quantities to content.\n * @param quantity - The number to match against the conditions.\n * @returns The matching content.\n *\n * @example\n * ```ts\n * const content = getEnumeration({\n * '0': 'No items',\n * '1': 'One item',\n * '>1': 'Many items',\n * }, 5);\n * // 'Many items'\n * ```\n */\nexport const getEnumeration = <const Content>(\n enumerationContent: EnumerationContentState<Content>,\n quantity: number\n): Content => {\n const key =\n findMatchingCondition<Content>(enumerationContent, quantity) ?? 'fallback';\n\n // Default or error handling if no keys match\n return enumerationContent[key] as Content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,yBACX,oBACA,aAC4B;CAC5B,MAAM,cAAc,OAAO,KAAK,kBAAkB;CAElD,KAAK,MAAM,OAAO,aAAa;EAC7B,MAAM,UACH,CAAC,IAAI,WAAW,GAAG,KAClB,CAAC,IAAI,WAAW,GAAG,KACnB,CAAC,IAAI,WAAW,GAAG,KACnB,WAAW,GAAG,MAAM,YACrB,IAAI,WAAW,GAAG,KAAK,WAAW,IAAI,MAAM,CAAC,CAAC,MAAM;EACvD,MAAM,aACJ,IAAI,WAAW,GAAG,KAAK,WAAW,WAAW,IAAI,MAAM,CAAC,CAAC;EAC3D,MAAM,oBACJ,IAAI,WAAW,IAAI,KAAK,YAAY,WAAW,IAAI,MAAM,CAAC,CAAC;EAC7D,MAAM,aACJ,IAAI,WAAW,GAAG,KAAK,WAAW,WAAW,IAAI,MAAM,CAAC,CAAC;EAC3D,MAAM,oBACJ,IAAI,WAAW,IAAI,KAAK,YAAY,WAAW,IAAI,MAAM,CAAC,CAAC;EAE7D,IACE,WACA,cACA,qBACA,cACA,mBAEA,OAAO;CAEX;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACA,aACY;CAKZ,OAAO,mBAHL,sBAA+B,oBAAoB,QAAQ,KAAK;AAIpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"getGender.cjs","names":[],"sources":["../../../src/interpreter/getGender.ts"],"sourcesContent":["import type { Gender, GenderContentStates } from '../transpiler';\n\ntype GenderEntry = Gender | 'm' | 'f';\n\nconst getGenderEntry = (gender: GenderEntry): Gender => {\n if (gender === 'm' || gender === 'male') return 'male';\n if (gender === 'f' || gender === 'female') return 'female';\n return 'fallback';\n};\n\n/**\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * const content = getGender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * }, true);\n * // 'The gender is validated'\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n * ```ts\n * const content = getGender({\n * 'false': 'The gender is not validated',\n * 'true': 'The gender is validated',\n * }, undefined);\n * // 'The gender is validated'\n */\nexport const getGender = <const Content>(\n genderContent: GenderContentStates<Content>,\n gender: GenderEntry\n): Content => {\n const stateList = Object.keys(genderContent);\n\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof genderContent;\n\n const genderEntry = getGenderEntry(gender);\n\n // Default or error handling if no keys match\n return (\n genderContent[genderEntry as keyof typeof genderContent] ??\n genderContent.fallback ??\n (genderContent[fallbackState] as Content)\n );\n};\n"],"mappings":";;;AAIA,MAAM,kBAAkB,WAAgC;AACtD,KAAI,WAAW,OAAO,WAAW,OAAQ,QAAO;AAChD,KAAI,WAAW,OAAO,WAAW,SAAU,QAAO;AAClD,QAAO;;;;;;;;;;;;;;;;;;;;;;;;AAyBT,MAAa,aACX,eACA,WACY;CACZ,MAAM,YAAY,OAAO,KAAK,cAAc;CAE5C,MAAM,gBAAgB,UACpB,UAAU,SAAS;AAMrB,QACE,cAJkB,eAAe,OAIR,KACzB,cAAc,YACb,cAAc"}
1
+ {"version":3,"file":"getGender.cjs","names":[],"sources":["../../../src/interpreter/getGender.ts"],"sourcesContent":["import type { Gender, GenderContentStates } from '../transpiler';\n\ntype GenderEntry = Gender | 'm' | 'f';\n\nconst getGenderEntry = (gender: GenderEntry): Gender => {\n if (gender === 'm' || gender === 'male') return 'male';\n if (gender === 'f' || gender === 'female') return 'female';\n return 'fallback';\n};\n\n/**\n * Allow to pick a content based on a gender.\n *\n * Usage:\n *\n * ```ts\n * const content = getGender({\n * 'true': 'The gender is validated',\n * 'false': 'The gender is not validated',\n * }, true);\n * // 'The gender is validated'\n * ```\n *\n * The last key provided will be used as the fallback value.\n *\n * ```ts\n * const content = getGender({\n * 'false': 'The gender is not validated',\n * 'true': 'The gender is validated',\n * }, undefined);\n * // 'The gender is validated'\n */\nexport const getGender = <const Content>(\n genderContent: GenderContentStates<Content>,\n gender: GenderEntry\n): Content => {\n const stateList = Object.keys(genderContent);\n\n const fallbackState = stateList[\n stateList.length - 1\n ] as keyof typeof genderContent;\n\n const genderEntry = getGenderEntry(gender);\n\n // Default or error handling if no keys match\n return (\n genderContent[genderEntry as keyof typeof genderContent] ??\n genderContent.fallback ??\n (genderContent[fallbackState] as Content)\n );\n};\n"],"mappings":";;;AAIA,MAAM,kBAAkB,WAAgC;CACtD,IAAI,WAAW,OAAO,WAAW,QAAQ,OAAO;CAChD,IAAI,WAAW,OAAO,WAAW,UAAU,OAAO;CAClD,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,aACX,eACA,WACY;CACZ,MAAM,YAAY,OAAO,KAAK,aAAa;CAE3C,MAAM,gBAAgB,UACpB,UAAU,SAAS;CAMrB,OACE,cAJkB,eAAe,MAIT,MACxB,cAAc,YACb,cAAc;AAEnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"getHTML.cjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack[stack.length - 1];\n\n // Only pop if the tag names match\n if (last && last.tagName === tagName) {\n const popped = stack.pop();\n if (popped) {\n appendChild({\n tagName: popped.tagName,\n props: popped.props,\n children: popped.children,\n });\n }\n }\n // If tags don't match or no open tag, silently ignore the closing tag\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":";;;;;;AA2BA,MAAM,mBAAmB,eAA+C;CACtE,MAAM,QAAgC,EAAE;CACxC,MAAM,YAAY;CAElB,IAAI,QAAQ,UAAU,KAAK,WAAW;AACtC,QAAO,UAAU,MAAM;AACrB,QAAM,MAAM,MAAM,MAAM;AACxB,UAAQ,UAAU,KAAK,WAAW;;AAEpC,QAAO;;AAWT,MAAM,2BAAW,IAAI,KAAwB;AAE7C,MAAM,aAAa,YAA+B;AAChD,KAAI,SAAS,IAAI,QAAQ,CACvB,QAAO,SAAS,IAAI,QAAQ;AAG9B,KAAI,OAAO,YAAY,SACrB,QAAO,EAAE;CAGX,MAAM,WAAW;CACjB,MAAM,WAAsB,EAAE;CAC9B,MAAM,QAIA,EAAE;CAER,IAAI,YAAY;CAChB,IAAI,QAAQ,SAAS,KAAK,QAAQ;CAElC,MAAM,eAAe,UAAmB;AAGtC,GADE,MAAM,SAAS,IAAI,MAAM,MAAM,SAAS,GAAG,WAAW,UACjD,KAAK,MAAM;;AAGpB,QAAO,UAAU,MAAM;EACrB,MAAM,CAAC,WAAW,cAAc,SAAS,eAAe,oBACtD;EACF,MAAM,aAAa,MAAM;AAEzB,MAAI,aAAa,UACf,aAAY,QAAQ,MAAM,WAAW,WAAW,CAAC;EAGnD,MAAM,YAAY,iBAAiB;EACnC,MAAM,gBACJ,qBAAqB,OACrB,cAAc,MAAM,CAAC,SAAS,IAAI,IAClC,UAAU,SAAS,KAAK;EAE1B,MAAM,oBAAoB,cAAc,MAAM,CAAC,QAAQ,OAAO,GAAG,CAAC,MAAM;AAExE,MAAI,WAAW;GACb,MAAM,OAAO,MAAM,MAAM,SAAS;AAGlC,OAAI,QAAQ,KAAK,YAAY,SAAS;IACpC,MAAM,SAAS,MAAM,KAAK;AAC1B,QAAI,OACF,aAAY;KACV,SAAS,OAAO;KAChB,OAAO,OAAO;KACd,UAAU,OAAO;KAClB,CAAC;;aAIG,cAET,aAAY;GACV;GACA,OAHe,gBAAgB,kBAGhB;GACf,UAAU,EAAE;GACb,CAAC;OACG;GACL,MAAM,WAAW,gBAAgB,kBAAkB;AACnD,SAAM,KAAK;IAAE;IAAS,UAAU,EAAE;IAAE,OAAO;IAAU,CAAC;;AAGxD,cAAY,aAAa,UAAU;AACnC,UAAQ,SAAS,KAAK,QAAQ;;AAGhC,KAAI,YAAY,QAAQ,OACtB,aAAY,QAAQ,MAAM,UAAU,CAAC;AAIvC,QAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,KAAK;AACxB,MAAI,KACF,aAAY;GACV,SAAS,KAAK;GACd,OAAO,KAAK;GACZ,UAAU,KAAK;GAChB,CAAC;;AAIN,UAAS,IAAI,SAAS,SAAS;AAC/B,QAAO;;;;;AAMT,MAAa,WAAW,SAAiB,WAA4B;CAEnE,MAAM,MAAM,UAAU,QAAQ;CAG9B,IAAI,aAAa;CAEjB,MAAM,iBAAiB,SAAuB;AAC5C,MAAI,OAAO,SAAS,SAClB,QAAO;EAGT,MAAM,EAAE,SAAS,OAAO,aAAa;EACrC,MAAM,mBAAmB,SAAS,QAAQ,cAAc;EACxD,MAAM,QAAQ;EAEd,IAAI,WAAW,OAAO;AAEtB,MAAI,CAAC,UAAU;GACb,MAAM,eAAe,QAAQ,aAAa;GAC1C,MAAM,WAAW,OAAO,KAAK,OAAO,CAAC,MAClC,QAAQ,IAAI,aAAa,KAAK,aAChC;AAED,OAAI,SAAU,YAAW,OAAO;;EAGlC,MAAM,MAAM,YAAY,QAAQ,GAAG;AAEnC,MAAI,OAAO,aAAa,WACtB,QAAO,SAAS;GAAE,GAAG;GAAO,UAAU;GAAkB;GAAK,CAAC;AAGhE,MAAI,OAAO,aAAa,UAAU;GAChC,MAAM,YAAY,OAAO;AAEzB,OAAI,OAAO,cAAc,WACvB,QAAO,UAAU;IAAE,GAAG;IAAO,UAAU;IAAkB;IAAK,CAAC;AAEjE,UAAO;;AAGT,MACE,OAAO,aAAa,YACpB,aAAa,QACb,SAAS,UACT;GACA,MAAM,EAAE,KAAK,WAAW,OAAO,eAAe;GAC9C,MAAM,YAAY,OAAO;AAEzB,OAAI,OAAO,cAAc,WACvB,QAAO,UAAU;IACf,GAAG;IACH,GAAG;IACH,UAAU;IACV;IACD,CAAC;AAEJ,UAAO;;AAIT,SAAO;;CAGT,MAAM,SAAS,IAAI,QAAQ,cAAc;AACzC,QAAO,OAAO,WAAW,IAAI,OAAO,KAAK"}
1
+ {"version":3,"file":"getHTML.cjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack[stack.length - 1];\n\n // Only pop if the tag names match\n if (last && last.tagName === tagName) {\n const popped = stack.pop();\n if (popped) {\n appendChild({\n tagName: popped.tagName,\n props: popped.props,\n children: popped.children,\n });\n }\n }\n // If tags don't match or no open tag, silently ignore the closing tag\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":";;;;;;AA2BA,MAAM,mBAAmB,eAA+C;CACtE,MAAM,QAAgC,CAAC;CACvC,MAAM,YAAY;CAElB,IAAI,QAAQ,UAAU,KAAK,UAAU;CACrC,OAAO,UAAU,MAAM;EACrB,MAAM,MAAM,MAAM,MAAM;EACxB,QAAQ,UAAU,KAAK,UAAU;CACnC;CACA,OAAO;AACT;AAUA,MAAM,2BAAW,IAAI,IAAuB;AAE5C,MAAM,aAAa,YAA+B;CAChD,IAAI,SAAS,IAAI,OAAO,GACtB,OAAO,SAAS,IAAI,OAAO;CAG7B,IAAI,OAAO,YAAY,UACrB,OAAO,CAAC;CAGV,MAAM,WAAW;CACjB,MAAM,WAAsB,CAAC;CAC7B,MAAM,QAIA,CAAC;CAEP,IAAI,YAAY;CAChB,IAAI,QAAQ,SAAS,KAAK,OAAO;CAEjC,MAAM,eAAe,UAAmB;EAGtC,CADE,MAAM,SAAS,IAAI,MAAM,MAAM,SAAS,EAAE,CAAC,WAAW,SAClD,CAAC,KAAK,KAAK;CACnB;CAEA,OAAO,UAAU,MAAM;EACrB,MAAM,CAAC,WAAW,cAAc,SAAS,eAAe,oBACtD;EACF,MAAM,aAAa,MAAM;EAEzB,IAAI,aAAa,WACf,YAAY,QAAQ,MAAM,WAAW,UAAU,CAAC;EAGlD,MAAM,YAAY,iBAAiB;EACnC,MAAM,gBACJ,qBAAqB,OACrB,cAAc,KAAK,CAAC,CAAC,SAAS,GAAG,KACjC,UAAU,SAAS,IAAI;EAEzB,MAAM,oBAAoB,cAAc,KAAK,CAAC,CAAC,QAAQ,OAAO,EAAE,CAAC,CAAC,KAAK;EAEvE,IAAI,WAAW;GACb,MAAM,OAAO,MAAM,MAAM,SAAS;GAGlC,IAAI,QAAQ,KAAK,YAAY,SAAS;IACpC,MAAM,SAAS,MAAM,IAAI;IACzB,IAAI,QACF,YAAY;KACV,SAAS,OAAO;KAChB,OAAO,OAAO;KACd,UAAU,OAAO;IACnB,CAAC;GAEL;EAEF,OAAO,IAAI,eAET,YAAY;GACV;GACA,OAHe,gBAAgB,iBAGjB;GACd,UAAU,CAAC;EACb,CAAC;OACI;GACL,MAAM,WAAW,gBAAgB,iBAAiB;GAClD,MAAM,KAAK;IAAE;IAAS,UAAU,CAAC;IAAG,OAAO;GAAS,CAAC;EACvD;EAEA,YAAY,aAAa,UAAU;EACnC,QAAQ,SAAS,KAAK,OAAO;CAC/B;CAEA,IAAI,YAAY,QAAQ,QACtB,YAAY,QAAQ,MAAM,SAAS,CAAC;CAItC,OAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,IAAI;EACvB,IAAI,MACF,YAAY;GACV,SAAS,KAAK;GACd,OAAO,KAAK;GACZ,UAAU,KAAK;EACjB,CAAC;CAEL;CAEA,SAAS,IAAI,SAAS,QAAQ;CAC9B,OAAO;AACT;;;;AAKA,MAAa,WAAW,SAAiB,WAA4B;CAEnE,MAAM,MAAM,UAAU,OAAO;CAG7B,IAAI,aAAa;CAEjB,MAAM,iBAAiB,SAAuB;EAC5C,IAAI,OAAO,SAAS,UAClB,OAAO;EAGT,MAAM,EAAE,SAAS,OAAO,aAAa;EACrC,MAAM,mBAAmB,SAAS,QAAQ,aAAa;EACvD,MAAM,QAAQ;EAEd,IAAI,WAAW,OAAO;EAEtB,IAAI,CAAC,UAAU;GACb,MAAM,eAAe,QAAQ,YAAY;GACzC,MAAM,WAAW,OAAO,KAAK,MAAM,CAAC,CAAC,MAClC,QAAQ,IAAI,YAAY,MAAM,YACjC;GAEA,IAAI,UAAU,WAAW,OAAO;EAClC;EAEA,MAAM,MAAM,YAAY,QAAQ,GAAG;EAEnC,IAAI,OAAO,aAAa,YACtB,OAAO,SAAS;GAAE,GAAG;GAAO,UAAU;GAAkB;EAAI,CAAC;EAG/D,IAAI,OAAO,aAAa,UAAU;GAChC,MAAM,YAAY,OAAO;GAEzB,IAAI,OAAO,cAAc,YACvB,OAAO,UAAU;IAAE,GAAG;IAAO,UAAU;IAAkB;GAAI,CAAC;GAEhE,OAAO;EACT;EAEA,IACE,OAAO,aAAa,YACpB,aAAa,QACb,SAAS,UACT;GACA,MAAM,EAAE,KAAK,WAAW,OAAO,eAAe;GAC9C,MAAM,YAAY,OAAO;GAEzB,IAAI,OAAO,cAAc,YACvB,OAAO,UAAU;IACf,GAAG;IACH,GAAG;IACH,UAAU;IACV;GACF,CAAC;GAEH,OAAO;EACT;EAGA,OAAO;CACT;CAEA,MAAM,SAAS,IAAI,QAAQ,aAAa;CACxC,OAAO,OAAO,WAAW,IAAI,OAAO,KAAK;AAC3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"getInsertion.cjs","names":[],"sources":["../../../src/interpreter/getInsertion.ts"],"sourcesContent":["import type { InsertionContent } from '../transpiler';\n\n/**\n * Allow to insert values in a string.\n *\n * Usage:\n *\n * ```ts\n * const content = getInsertion('Hello {{name}}!', {\n * name: 'John',\n * });\n * // 'Hello John!'\n * ```\n *\n */\nexport const getInsertion = (\n content: string,\n values: { [K in InsertionContent['fields'][number]]: string | number }\n) =>\n content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n });\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,gBACX,SACA,WAEA,QAAQ,QAAQ,yBAAyB,GAAG,QAAQ;AAElD,SAAQ,OADW,IAAI,MACE,KAAK,IAAI,UAAU;EAC5C"}
1
+ {"version":3,"file":"getInsertion.cjs","names":[],"sources":["../../../src/interpreter/getInsertion.ts"],"sourcesContent":["import type { InsertionContent } from '../transpiler';\n\n/**\n * Allow to insert values in a string.\n *\n * Usage:\n *\n * ```ts\n * const content = getInsertion('Hello {{name}}!', {\n * name: 'John',\n * });\n * // 'Hello John!'\n * ```\n *\n */\nexport const getInsertion = (\n content: string,\n values: { [K in InsertionContent['fields'][number]]: string | number }\n) =>\n content.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n });\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,MAAa,gBACX,SACA,WAEA,QAAQ,QAAQ,yBAAyB,GAAG,QAAQ;CAElD,QAAQ,OADW,IAAI,KACC,MAAM,GAAE,CAAE,SAAS;AAC7C,CAAC"}
@@ -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_dictionaryManipulator_qualifiedDictionary = require('../dictionaryManipulator/qualifiedDictionary.cjs');
4
3
  const require_interpreter_getDictionary = require('./getDictionary.cjs');
5
4
  let _intlayer_config_built = require("@intlayer/config/built");
@@ -18,7 +17,8 @@ const createSafeFallback = (path = "") => {
18
17
  if (prop === Symbol.iterator) return function* () {
19
18
  yield path;
20
19
  };
21
- return createSafeFallback(path ? `${path}.${String(prop)}` : String(prop));
20
+ const nextPath = path ? `${path}.${String(prop)}` : String(prop);
21
+ return createSafeFallback(nextPath);
22
22
  } });
23
23
  };
24
24
  const dictionaryCache = /* @__PURE__ */ new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.cjs","names":["parseDictionarySelector","getDictionarySelectorCacheKey","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy({} as Record<string | symbol, unknown>, {\n get: (_target, prop) => {\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString' ||\n prop === 'valueOf'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n if (prop === Symbol.iterator) {\n return function* () {\n yield path;\n };\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n });\n};\n\nconst dictionaryCache = new Map<string, any>();\nconst warnedMissingDictionaries = new Set<string>();\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector.\n *\n * The second argument is either a locale (`'fr'`) or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: { id: 'prod_abc', userId: '123' } }` — structured variant\n * - `locale` can be combined with any selector: `{ item: 2, locale: 'fr' }`\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T];\n\n if (!dictionary && process.env.NODE_ENV === 'development') {\n if (!warnedMissingDictionaries.has(key as string)) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger({ log });\n logger(\n typeof window === 'undefined'\n ? `Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`\n : `Dictionary ${key} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n }\n );\n warnedMissingDictionaries.add(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n let locale: LocalesValues | undefined;\n let selectorCacheKey = '';\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector(localeOrSelector);\n locale = parsed.locale;\n selectorCacheKey = getDictionarySelectorCacheKey(parsed.selector);\n } else {\n // Selectors are unused in this project (build-time flag): the second\n // argument can only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const cacheKey = `${key}_${locale ?? 'default'}_${selectorCacheKey}_${plugins ? 'custom_plugins' : 'default_plugins'}`;\n\n if (dictionaryCache.has(cacheKey)) {\n return dictionaryCache.get(cacheKey);\n }\n\n const result = getDictionary(dictionary, localeOrSelector, plugins);\n\n dictionaryCache.set(cacheKey, result);\n\n return result as any;\n};\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAM,sBAAsB,OAAO,OAAY;AAC7C,QAAO,IAAI,MAAM,EAAE,EAAsC,EACvD,MAAM,SAAS,SAAS;AACtB,MACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,cACT,SAAS,UAET,cAAa;AAEf,MAAI,SAAS,OACX;AAEF,MAAI,SAAS,OAAO,SAClB,QAAO,aAAa;AAClB,SAAM;;AAMV,SAAO,mBADU,OAAO,GAAG,KAAK,GAAG,OAAO,KAAK,KAAK,OAAO,KAAK,CAC7B;IAEtC,CAAC;;AAGJ,MAAM,kCAAkB,IAAI,KAAkB;AAC9C,MAAM,4CAA4B,IAAI,KAAa;;;;;;;;;;;AAYnD,MAAa,eAIX,KACA,kBACA,YAKG;CAEH,MAAM,gEAAyB,CAAC;AAEhC,KAAI,CAAC,cAAc,QAAQ,IAAI,aAAa,eAAe;AACzD,MAAI,CAAC,0BAA0B,IAAI,IAAc,EAAE;AAGjD,6CAD4B,EAAE,iCAAK,CAC7B,CACJ,OAAO,WAAW,cACd,uDAA0B,IAAI,CAAC,yCAC/B,cAAc,IAAI,wCACtB,EACE,OAAO,QACR,CACF;AACD,6BAA0B,IAAI,IAAc;;AAG9C,SAAO,mBAAmB,IAAc;;CAG1C,IAAI;CACJ,IAAI,mBAAmB;AAEvB,KAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAASA,0EAAwB,iBAAiB;AACxD,WAAS,OAAO;AAChB,qBAAmBC,gFAA8B,OAAO,SAAS;OAIjE,UAAS;CAGX,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,UAAU,GAAG,iBAAiB,GAAG,UAAU,mBAAmB;AAEnG,KAAI,gBAAgB,IAAI,SAAS,CAC/B,QAAO,gBAAgB,IAAI,SAAS;CAGtC,MAAM,SAASC,gDAAc,YAAY,kBAAkB,QAAQ;AAEnE,iBAAgB,IAAI,UAAU,OAAO;AAErC,QAAO"}
1
+ {"version":3,"file":"getIntlayer.cjs","names":["parseDictionarySelector","getDictionarySelectorCacheKey","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import { log } from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { DictionarySelector } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryResult,\n ExtractSelectorLocale,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n getDictionarySelectorCacheKey,\n parseDictionarySelector,\n} from '../dictionaryManipulator/qualifiedDictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy({} as Record<string | symbol, unknown>, {\n get: (_target, prop) => {\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString' ||\n prop === 'valueOf'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n if (prop === Symbol.iterator) {\n return function* () {\n yield path;\n };\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n });\n};\n\nconst dictionaryCache = new Map<string, any>();\nconst warnedMissingDictionaries = new Set<string>();\n\n/**\n * Picks one dictionary by its key and returns its content for the given\n * locale or selector.\n *\n * The second argument is either a locale (`'fr'`) or a selector object:\n * - `{ item: 2 }` — collection item (omit `item` to get every item as array)\n * - `{ variant: 'black-friday' }` — named variant (omit for the `default` one)\n * - `{ variant: { id: 'prod_abc', userId: '123' } }` — structured variant\n * - `locale` can be combined with any selector: `{ item: 2, locale: 'fr' }`\n */\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelector = DeclaredLocales,\n>(\n key: T,\n localeOrSelector?: A,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryResult<T, A>,\n IInterpreterPluginState,\n ExtractSelectorLocale<A>\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T];\n\n if (!dictionary && process.env.NODE_ENV === 'development') {\n if (!warnedMissingDictionaries.has(key as string)) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger({ log });\n logger(\n typeof window === 'undefined'\n ? `Dictionary ${colorizeKey(key)} was not found. Using fallback proxy.`\n : `Dictionary ${key} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n }\n );\n warnedMissingDictionaries.add(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n let locale: LocalesValues | undefined;\n let selectorCacheKey = '';\n\n if (process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false') {\n const parsed = parseDictionarySelector(localeOrSelector);\n locale = parsed.locale;\n selectorCacheKey = getDictionarySelectorCacheKey(parsed.selector);\n } else {\n // Selectors are unused in this project (build-time flag): the second\n // argument can only be a locale, so the selector parsing is dead code.\n locale = localeOrSelector as LocalesValues | undefined;\n }\n\n const cacheKey = `${key}_${locale ?? 'default'}_${selectorCacheKey}_${plugins ? 'custom_plugins' : 'default_plugins'}`;\n\n if (dictionaryCache.has(cacheKey)) {\n return dictionaryCache.get(cacheKey);\n }\n\n const result = getDictionary(dictionary, localeOrSelector, plugins);\n\n dictionaryCache.set(cacheKey, result);\n\n return result as any;\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,MAAM,sBAAsB,OAAO,OAAY;CAC7C,OAAO,IAAI,MAAM,CAAC,GAAuC,EACvD,MAAM,SAAS,SAAS;EACtB,IACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,cACT,SAAS,WAET,aAAa;EAEf,IAAI,SAAS,QACX;EAEF,IAAI,SAAS,OAAO,UAClB,OAAO,aAAa;GAClB,MAAM;EACR;EAIF,MAAM,WAAW,OAAO,GAAG,KAAK,GAAG,OAAO,IAAI,MAAM,OAAO,IAAI;EAC/D,OAAO,mBAAmB,QAAQ;CACpC,EACF,CAAC;AACH;AAEA,MAAM,kCAAkB,IAAI,IAAiB;AAC7C,MAAM,4CAA4B,IAAI,IAAY;;;;;;;;;;;AAYlD,MAAa,eAIX,KACA,kBACA,YAKG;CAEH,MAAM,+DAAwB,CAAC,CAAC;CAEhC,IAAI,CAAC,cAAc,QAAQ,IAAI,aAAa,eAAe;EACzD,IAAI,CAAC,0BAA0B,IAAI,GAAa,GAAG;GAGjD,0CAD4B,EAAE,gCAAI,CAC7B,CAAC,CACJ,OAAO,WAAW,cACd,uDAA0B,GAAG,EAAE,yCAC/B,cAAc,IAAI,wCACtB,EACE,OAAO,OACT,CACF;GACA,0BAA0B,IAAI,GAAa;EAC7C;EAEA,OAAO,mBAAmB,GAAa;CACzC;CAEA,IAAI;CACJ,IAAI,mBAAmB;CAEvB,IAAI,QAAQ,IAAI,iCAAiC,SAAS;EACxD,MAAM,SAASA,0EAAwB,gBAAgB;EACvD,SAAS,OAAO;EAChB,mBAAmBC,gFAA8B,OAAO,QAAQ;CAClE,OAGE,SAAS;CAGX,MAAM,WAAW,GAAG,IAAI,GAAG,UAAU,UAAU,GAAG,iBAAiB,GAAG,UAAU,mBAAmB;CAEnG,IAAI,gBAAgB,IAAI,QAAQ,GAC9B,OAAO,gBAAgB,IAAI,QAAQ;CAGrC,MAAM,SAASC,gDAAc,YAAY,kBAAkB,OAAO;CAElE,gBAAgB,IAAI,UAAU,MAAM;CAEpC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"getNesting.cjs","names":["getIntlayer"],"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["import type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n} from '@intlayer/types/module_augmentation';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <const K extends DictionaryKeys, const P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,cACX,eACA,MACA,UAC2B;CAC3B,MAAM,aAAaA,4CAAY,eAAe,OAAO,QAAQ,OAAO,QAAQ;AAE5E,KAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,YAAa,KAAgB,MAAM,IAAI;EAC7C,IAAI,UAAe;AAEnB,OAAK,MAAM,OAAO,WAAW;AAE3B,aAAU,UAAU;AAEpB,OAAI,YAAY,OACd,QAAO;;AAIX,SAAO;;AAIT,QAAO"}
1
+ {"version":3,"file":"getNesting.cjs","names":["getIntlayer"],"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["import type { GetSubPath } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n DictionaryRegistryContent,\n} from '@intlayer/types/module_augmentation';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <const K extends DictionaryKeys, const P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,cACX,eACA,MACA,UAC2B;CAC3B,MAAM,aAAaA,4CAAY,eAAe,OAAO,QAAQ,OAAO,OAAO;CAE3E,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,YAAa,KAAgB,MAAM,GAAG;EAC5C,IAAI,UAAe;EAEnB,KAAK,MAAM,OAAO,WAAW;GAE3B,UAAU,UAAU;GAEpB,IAAI,YAAY,QACd,OAAO;EAEX;EAEA,OAAO;CACT;CAGA,OAAO;AACT"}
@@ -18,7 +18,7 @@ const require_utils_intl = require('../utils/intl.cjs');
18
18
  * ```
19
19
  */
20
20
  const getPlural = (pluralContent, count, locale) => {
21
- return pluralContent[require_utils_intl.getCachedIntl(Intl.PluralRules, locale).select(count)] ?? pluralContent.other;
21
+ return pluralContent[require_utils_intl.getCachedIntl("PluralRules", locale).select(count)] ?? pluralContent.other;
22
22
  };
23
23
 
24
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getPlural.cjs","names":["getCachedIntl"],"sources":["../../../src/interpreter/getPlural.ts"],"sourcesContent":["import type { DeclaredLocales } from '@intlayer/types';\nimport type { LocalesValues } from 'intlayer';\nimport { getCachedIntl } from '../formatters';\nimport type {\n PluralCategory,\n PluralContentState,\n} from '../transpiler/plural/plural';\n\n/**\n * Picks content from a plural map based on a count and locale, using CLDR\n * pluralization rules (`Intl.PluralRules`).\n *\n * Falls back to the `other` category when no specific category matches.\n *\n * @example\n * ```ts\n * getPlural({\n * one: 'one item',\n * other: '{{count}} items',\n * }, 5, 'en');\n * // '{{count}} items'\n * ```\n */\nexport const getPlural = <const L extends LocalesValues = DeclaredLocales>(\n pluralContent: PluralContentState<string>,\n count: number,\n locale: L\n): string => {\n const category = getCachedIntl(Intl.PluralRules, locale).select(\n count\n ) as PluralCategory;\n\n return pluralContent[category] ?? pluralContent.other;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAa,aACX,eACA,OACA,WACW;AAKX,QAAO,cAJUA,iCAAc,KAAK,aAAa,OAAO,CAAC,OACvD,MAG2B,KAAK,cAAc"}
1
+ {"version":3,"file":"getPlural.cjs","names":["getCachedIntl"],"sources":["../../../src/interpreter/getPlural.ts"],"sourcesContent":["import type { DeclaredLocales } from '@intlayer/types';\nimport type { LocalesValues } from 'intlayer';\nimport { getCachedIntl } from '../formatters';\nimport type {\n PluralCategory,\n PluralContentState,\n} from '../transpiler/plural/plural';\n\n/**\n * Picks content from a plural map based on a count and locale, using CLDR\n * pluralization rules (`Intl.PluralRules`).\n *\n * Falls back to the `other` category when no specific category matches.\n *\n * @example\n * ```ts\n * getPlural({\n * one: 'one item',\n * other: '{{count}} items',\n * }, 5, 'en');\n * // '{{count}} items'\n * ```\n */\nexport const getPlural = <const L extends LocalesValues = DeclaredLocales>(\n pluralContent: PluralContentState<string>,\n count: number,\n locale: L\n): string => {\n const category = getCachedIntl('PluralRules', locale).select(\n count\n ) as PluralCategory;\n\n return pluralContent[category] ?? pluralContent.other;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,MAAa,aACX,eACA,OACA,WACW;CAKX,OAAO,cAJUA,iCAAc,eAAe,MAAM,CAAC,CAAC,OACpD,KAG0B,MAAM,cAAc;AAClD"}
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslation.cjs","names":[],"sources":["../../../src/interpreter/getTranslation.ts"],"sourcesContent":["import type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\n/**\n * Check if a value is a plain object that can be safely merged.\n * Returns false for Promises, React elements, class instances, etc.\n */\nconst isPlainObject = (value: unknown): boolean => {\n if (value === null || typeof value !== 'object') return false;\n if (typeof (value as any).then === 'function') return false;\n if (\n (value as any).$$typeof !== undefined ||\n (value as any).__v_isVNode !== undefined ||\n (value as any)._isVNode !== undefined ||\n (value as any).isJSX !== undefined\n ) {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null || Array.isArray(value);\n};\n\n/**\n * Recursively merges two objects, skipping undefined source values.\n * First argument takes precedence. Arrays replace rather than merge.\n */\nconst deepMerge = (target: any, source: any): any => {\n if (target === undefined) return source;\n if (source === undefined) return target;\n if (Array.isArray(target)) return target;\n if (isPlainObject(target) && isPlainObject(source)) {\n const result = { ...target };\n\n for (const key of Object.keys(source)) {\n if (\n key === '__proto__' ||\n key === 'constructor' ||\n source[key] === undefined\n )\n continue;\n result[key] =\n target[key] !== undefined\n ? deepMerge(target[key], source[key])\n : source[key];\n }\n return result;\n }\n return target;\n};\n\n/**\n * Picks the appropriate content from a locale map based on the provided locale.\n *\n * It handles:\n * 1. Exact locale match (e.g., 'en-US').\n * 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).\n * 3. Explicit fallback locale.\n * 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.\n *\n * @param languageContent - A map of locales to content.\n * @param locale - The target locale to retrieve.\n * @param fallback - Optional fallback locale if the target is not found.\n * @returns The translated content.\n *\n * @example\n * ```ts\n * const content = getTranslation({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n */\nexport const getTranslation = <const Content = string>(\n languageContent: StrictModeLocaleMap<Content>,\n locale: LocalesValues,\n fallback?: LocalesValues\n): Content => {\n const get = (loc: string): Content | undefined =>\n languageContent[loc as keyof typeof languageContent];\n\n // Build priority-ordered locale candidates (most specific first), deduped\n const seen = new Set<string>();\n const locales: string[] = [];\n const addLocale = (loc: string | undefined) => {\n if (loc && !seen.has(loc)) {\n seen.add(loc);\n locales.push(loc);\n }\n };\n\n addLocale(locale);\n if (locale.includes('-')) addLocale(locale.split('-')[0]);\n\n addLocale(fallback);\n if (fallback?.includes('-')) addLocale(fallback.split('-')[0]);\n\n // Collect results: strings exit early (if no higher-priority object was found),\n // objects are accumulated for deep merging.\n const results: Content[] = [];\n\n for (const loc of locales) {\n const val = get(loc);\n\n if (val === undefined) continue;\n if (typeof val === 'string') {\n if (results.length === 0) return val;\n continue; // an object at higher priority takes precedence\n }\n\n results.push(val);\n }\n\n if (results.length === 0) return undefined as Content;\n if (results.length === 1) return results[0];\n if (Array.isArray(results[0])) return results[0];\n\n // Merge objects: first result (most specific) takes precedence\n return (results as object[]).reduce((acc, curr) =>\n deepMerge(acc, curr)\n ) as Content;\n};\n"],"mappings":";;;;;;;AASA,MAAM,iBAAiB,UAA4B;AACjD,KAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,KAAI,OAAQ,MAAc,SAAS,WAAY,QAAO;AACtD,KACG,MAAc,aAAa,UAC3B,MAAc,gBAAgB,UAC9B,MAAc,aAAa,UAC3B,MAAc,UAAU,OAEzB,QAAO;CAET,MAAM,QAAQ,OAAO,eAAe,MAAM;AAC1C,QAAO,UAAU,OAAO,aAAa,UAAU,QAAQ,MAAM,QAAQ,MAAM;;;;;;AAO7E,MAAM,aAAa,QAAa,WAAqB;AACnD,KAAI,WAAW,OAAW,QAAO;AACjC,KAAI,WAAW,OAAW,QAAO;AACjC,KAAI,MAAM,QAAQ,OAAO,CAAE,QAAO;AAClC,KAAI,cAAc,OAAO,IAAI,cAAc,OAAO,EAAE;EAClD,MAAM,SAAS,EAAE,GAAG,QAAQ;AAE5B,OAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;AACrC,OACE,QAAQ,eACR,QAAQ,iBACR,OAAO,SAAS,OAEhB;AACF,UAAO,OACL,OAAO,SAAS,SACZ,UAAU,OAAO,MAAM,OAAO,KAAK,GACnC,OAAO;;AAEf,SAAO;;AAET,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,kBACX,iBACA,QACA,aACY;CACZ,MAAM,OAAO,QACX,gBAAgB;CAGlB,MAAM,uBAAO,IAAI,KAAa;CAC9B,MAAM,UAAoB,EAAE;CAC5B,MAAM,aAAa,QAA4B;AAC7C,MAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;AACzB,QAAK,IAAI,IAAI;AACb,WAAQ,KAAK,IAAI;;;AAIrB,WAAU,OAAO;AACjB,KAAI,OAAO,SAAS,IAAI,CAAE,WAAU,OAAO,MAAM,IAAI,CAAC,GAAG;AAEzD,WAAU,SAAS;AACnB,KAAI,UAAU,SAAS,IAAI,CAAE,WAAU,SAAS,MAAM,IAAI,CAAC,GAAG;CAI9D,MAAM,UAAqB,EAAE;AAE7B,MAAK,MAAM,OAAO,SAAS;EACzB,MAAM,MAAM,IAAI,IAAI;AAEpB,MAAI,QAAQ,OAAW;AACvB,MAAI,OAAO,QAAQ,UAAU;AAC3B,OAAI,QAAQ,WAAW,EAAG,QAAO;AACjC;;AAGF,UAAQ,KAAK,IAAI;;AAGnB,KAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,KAAI,QAAQ,WAAW,EAAG,QAAO,QAAQ;AACzC,KAAI,MAAM,QAAQ,QAAQ,GAAG,CAAE,QAAO,QAAQ;AAG9C,QAAQ,QAAqB,QAAQ,KAAK,SACxC,UAAU,KAAK,KAAK,CACrB"}
1
+ {"version":3,"file":"getTranslation.cjs","names":[],"sources":["../../../src/interpreter/getTranslation.ts"],"sourcesContent":["import type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\n\n/**\n * Check if a value is a plain object that can be safely merged.\n * Returns false for Promises, React elements, class instances, etc.\n */\nconst isPlainObject = (value: unknown): boolean => {\n if (value === null || typeof value !== 'object') return false;\n if (typeof (value as any).then === 'function') return false;\n if (\n (value as any).$$typeof !== undefined ||\n (value as any).__v_isVNode !== undefined ||\n (value as any)._isVNode !== undefined ||\n (value as any).isJSX !== undefined\n ) {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null || Array.isArray(value);\n};\n\n/**\n * Recursively merges two objects, skipping undefined source values.\n * First argument takes precedence. Arrays replace rather than merge.\n */\nconst deepMerge = (target: any, source: any): any => {\n if (target === undefined) return source;\n if (source === undefined) return target;\n if (Array.isArray(target)) return target;\n if (isPlainObject(target) && isPlainObject(source)) {\n const result = { ...target };\n\n for (const key of Object.keys(source)) {\n if (\n key === '__proto__' ||\n key === 'constructor' ||\n source[key] === undefined\n )\n continue;\n result[key] =\n target[key] !== undefined\n ? deepMerge(target[key], source[key])\n : source[key];\n }\n return result;\n }\n return target;\n};\n\n/**\n * Picks the appropriate content from a locale map based on the provided locale.\n *\n * It handles:\n * 1. Exact locale match (e.g., 'en-US').\n * 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).\n * 3. Explicit fallback locale.\n * 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.\n *\n * @param languageContent - A map of locales to content.\n * @param locale - The target locale to retrieve.\n * @param fallback - Optional fallback locale if the target is not found.\n * @returns The translated content.\n *\n * @example\n * ```ts\n * const content = getTranslation({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n */\nexport const getTranslation = <const Content = string>(\n languageContent: StrictModeLocaleMap<Content>,\n locale: LocalesValues,\n fallback?: LocalesValues\n): Content => {\n const get = (loc: string): Content | undefined =>\n languageContent[loc as keyof typeof languageContent];\n\n // Build priority-ordered locale candidates (most specific first), deduped\n const seen = new Set<string>();\n const locales: string[] = [];\n const addLocale = (loc: string | undefined) => {\n if (loc && !seen.has(loc)) {\n seen.add(loc);\n locales.push(loc);\n }\n };\n\n addLocale(locale);\n if (locale.includes('-')) addLocale(locale.split('-')[0]);\n\n addLocale(fallback);\n if (fallback?.includes('-')) addLocale(fallback.split('-')[0]);\n\n // Collect results: strings exit early (if no higher-priority object was found),\n // objects are accumulated for deep merging.\n const results: Content[] = [];\n\n for (const loc of locales) {\n const val = get(loc);\n\n if (val === undefined) continue;\n if (typeof val === 'string') {\n if (results.length === 0) return val;\n continue; // an object at higher priority takes precedence\n }\n\n results.push(val);\n }\n\n if (results.length === 0) return undefined as Content;\n if (results.length === 1) return results[0];\n if (Array.isArray(results[0])) return results[0];\n\n // Merge objects: first result (most specific) takes precedence\n return (results as object[]).reduce((acc, curr) =>\n deepMerge(acc, curr)\n ) as Content;\n};\n"],"mappings":";;;;;;;AASA,MAAM,iBAAiB,UAA4B;CACjD,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU,OAAO;CACxD,IAAI,OAAQ,MAAc,SAAS,YAAY,OAAO;CACtD,IACG,MAAc,aAAa,UAC3B,MAAc,gBAAgB,UAC9B,MAAc,aAAa,UAC3B,MAAc,UAAU,QAEzB,OAAO;CAET,MAAM,QAAQ,OAAO,eAAe,KAAK;CACzC,OAAO,UAAU,OAAO,aAAa,UAAU,QAAQ,MAAM,QAAQ,KAAK;AAC5E;;;;;AAMA,MAAM,aAAa,QAAa,WAAqB;CACnD,IAAI,WAAW,QAAW,OAAO;CACjC,IAAI,WAAW,QAAW,OAAO;CACjC,IAAI,MAAM,QAAQ,MAAM,GAAG,OAAO;CAClC,IAAI,cAAc,MAAM,KAAK,cAAc,MAAM,GAAG;EAClD,MAAM,SAAS,EAAE,GAAG,OAAO;EAE3B,KAAK,MAAM,OAAO,OAAO,KAAK,MAAM,GAAG;GACrC,IACE,QAAQ,eACR,QAAQ,iBACR,OAAO,SAAS,QAEhB;GACF,OAAO,OACL,OAAO,SAAS,SACZ,UAAU,OAAO,MAAM,OAAO,IAAI,IAClC,OAAO;EACf;EACA,OAAO;CACT;CACA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,kBACX,iBACA,QACA,aACY;CACZ,MAAM,OAAO,QACX,gBAAgB;CAGlB,MAAM,uBAAO,IAAI,IAAY;CAC7B,MAAM,UAAoB,CAAC;CAC3B,MAAM,aAAa,QAA4B;EAC7C,IAAI,OAAO,CAAC,KAAK,IAAI,GAAG,GAAG;GACzB,KAAK,IAAI,GAAG;GACZ,QAAQ,KAAK,GAAG;EAClB;CACF;CAEA,UAAU,MAAM;CAChB,IAAI,OAAO,SAAS,GAAG,GAAG,UAAU,OAAO,MAAM,GAAG,CAAC,CAAC,EAAE;CAExD,UAAU,QAAQ;CAClB,IAAI,UAAU,SAAS,GAAG,GAAG,UAAU,SAAS,MAAM,GAAG,CAAC,CAAC,EAAE;CAI7D,MAAM,UAAqB,CAAC;CAE5B,KAAK,MAAM,OAAO,SAAS;EACzB,MAAM,MAAM,IAAI,GAAG;EAEnB,IAAI,QAAQ,QAAW;EACvB,IAAI,OAAO,QAAQ,UAAU;GAC3B,IAAI,QAAQ,WAAW,GAAG,OAAO;GACjC;EACF;EAEA,QAAQ,KAAK,GAAG;CAClB;CAEA,IAAI,QAAQ,WAAW,GAAG,OAAO;CACjC,IAAI,QAAQ,WAAW,GAAG,OAAO,QAAQ;CACzC,IAAI,MAAM,QAAQ,QAAQ,EAAE,GAAG,OAAO,QAAQ;CAG9C,OAAQ,QAAqB,QAAQ,KAAK,SACxC,UAAU,KAAK,IAAI,CACrB;AACF"}
@@ -2,11 +2,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_interpreter_getCondition = require('./getCondition.cjs');
3
3
  const require_interpreter_getContent_deepTransform = require('./getContent/deepTransform.cjs');
4
4
  const require_interpreter_getEnumeration = require('./getEnumeration.cjs');
5
+ const require_interpreter_getInsertion = require('./getInsertion.cjs');
5
6
  const require_interpreter_getDictionary = require('./getDictionary.cjs');
6
7
  const require_interpreter_getIntlayer = require('./getIntlayer.cjs');
7
8
  const require_interpreter_getNesting = require('./getNesting.cjs');
8
9
  const require_interpreter_getPlural = require('./getPlural.cjs');
9
10
  const require_interpreter_getTranslation = require('./getTranslation.cjs');
11
+ const require_interpreter_interpolableNode = require('./interpolableNode.cjs');
10
12
  const require_interpreter_getContent_plugins = require('./getContent/plugins.cjs');
11
13
  const require_interpreter_getContent_getContent = require('./getContent/getContent.cjs');
12
14
  const require_interpreter_getHTML = require('./getHTML.cjs');
@@ -25,12 +27,17 @@ exports.getContent = require_interpreter_getContent_getContent.getContent;
25
27
  exports.getDictionary = require_interpreter_getDictionary.getDictionary;
26
28
  exports.getEnumeration = require_interpreter_getEnumeration.getEnumeration;
27
29
  exports.getHTML = require_interpreter_getHTML.getHTML;
30
+ exports.getInsertion = require_interpreter_getInsertion.getInsertion;
31
+ exports.getInterpolableContent = require_interpreter_interpolableNode.getInterpolableContent;
28
32
  exports.getIntlayer = require_interpreter_getIntlayer.getIntlayer;
29
33
  exports.getNesting = require_interpreter_getNesting.getNesting;
30
34
  exports.getPlural = require_interpreter_getPlural.getPlural;
31
35
  exports.getTranslation = require_interpreter_getTranslation.getTranslation;
32
36
  exports.insertionPlugin = require_interpreter_getContent_plugins.insertionPlugin;
37
+ exports.isInterpolableWrapperNode = require_interpreter_interpolableNode.isInterpolableWrapperNode;
33
38
  exports.nestedPlugin = require_interpreter_getContent_plugins.nestedPlugin;
34
39
  exports.pluralPlugin = require_interpreter_getContent_plugins.pluralPlugin;
40
+ exports.rebuildInterpolableContent = require_interpreter_interpolableNode.rebuildInterpolableContent;
35
41
  exports.splitInsertionTemplate = require_interpreter_splitAndJoinInsertion.splitInsertionTemplate;
42
+ exports.transformInterpolableNode = require_interpreter_interpolableNode.transformInterpolableNode;
36
43
  exports.translationPlugin = require_interpreter_getContent_plugins.translationPlugin;
@@ -0,0 +1,83 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_interpreter_getInsertion = require('./getInsertion.cjs');
4
+ let _intlayer_types_nodeType = require("@intlayer/types/nodeType");
5
+ _intlayer_types_nodeType = require_runtime.__toESM(_intlayer_types_nodeType);
6
+
7
+ //#region src/interpreter/interpolableNode.ts
8
+ /**
9
+ * Returns `true` when the node is an `html()` or `markdown()` node whose inner
10
+ * content is a raw string eligible for `{{ … }}` interpolation.
11
+ *
12
+ * Each check is guarded by the corresponding `INTLAYER_NODE_TYPE_*` env flag
13
+ * so bundlers can eliminate the branch (and downstream handling code) when the
14
+ * html/markdown node types are tree-shaken out of the user bundle.
15
+ */
16
+ const isInterpolableWrapperNode = (node) => {
17
+ if (typeof node !== "object" || node === null || !("nodeType" in node)) return false;
18
+ const { nodeType } = node;
19
+ return process.env.INTLAYER_NODE_TYPE_HTML !== "false" && nodeType === _intlayer_types_nodeType.HTML || process.env.INTLAYER_NODE_TYPE_MARKDOWN !== "false" && nodeType === _intlayer_types_nodeType.MARKDOWN;
20
+ };
21
+ /**
22
+ * Extracts the raw interpolable string from a string, `html()` or `markdown()`
23
+ * node. Returns `undefined` for any other node so callers can fall back to
24
+ * their default handling.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * getInterpolableContent('{{count}} days'); // '{{count}} days'
29
+ * getInterpolableContent(html('<b>{{count}}</b>')); // '<b>{{count}}</b>'
30
+ * getInterpolableContent({ nodeType: 'translation' }); // undefined
31
+ * ```
32
+ */
33
+ const getInterpolableContent = (node) => {
34
+ if (typeof node === "string") return node;
35
+ if (isInterpolableWrapperNode(node)) return node.nodeType === _intlayer_types_nodeType.HTML ? node[_intlayer_types_nodeType.HTML] : node[_intlayer_types_nodeType.MARKDOWN];
36
+ };
37
+ /**
38
+ * Rebuilds an interpolable node from its interpolated raw string, preserving
39
+ * the original node shape (plain string stays a string, `html()`/`markdown()`
40
+ * nodes keep their `nodeType` and sibling fields so the renderer still applies).
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * rebuildInterpolableContent(html('<b>{{count}}</b>'), '<b>1</b>');
45
+ * // { nodeType: 'html', html: '<b>1</b>', … }
46
+ * ```
47
+ */
48
+ const rebuildInterpolableContent = (node, interpolated) => {
49
+ if (typeof node === "string") return interpolated;
50
+ if (isInterpolableWrapperNode(node)) {
51
+ const key = node.nodeType === _intlayer_types_nodeType.HTML ? _intlayer_types_nodeType.HTML : _intlayer_types_nodeType.MARKDOWN;
52
+ return {
53
+ ...node,
54
+ [key]: interpolated
55
+ };
56
+ }
57
+ return node;
58
+ };
59
+ /**
60
+ * Interpolates `{{ … }}` values into an `html()`/`markdown()` wrapper node,
61
+ * then re-runs the transform with the parent plugin list so the html/markdown
62
+ * renderer applies to the interpolated content.
63
+ *
64
+ * Shared by the plural/insertion string plugins of `@intlayer/core` and every
65
+ * framework package — framework nodes (React elements, VNodes…) cannot be
66
+ * injected into a raw markup string, so plain string interpolation is used.
67
+ */
68
+ const transformInterpolableNode = (node, values, subProps, parentPlugins, deepTransformNode) => {
69
+ const interpolated = require_interpreter_getInsertion.getInsertion(getInterpolableContent(node), values);
70
+ const children = rebuildInterpolableContent(node, interpolated);
71
+ return deepTransformNode(children, {
72
+ ...subProps,
73
+ plugins: parentPlugins,
74
+ children
75
+ });
76
+ };
77
+
78
+ //#endregion
79
+ exports.getInterpolableContent = getInterpolableContent;
80
+ exports.isInterpolableWrapperNode = isInterpolableWrapperNode;
81
+ exports.rebuildInterpolableContent = rebuildInterpolableContent;
82
+ exports.transformInterpolableNode = transformInterpolableNode;
83
+ //# sourceMappingURL=interpolableNode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interpolableNode.cjs","names":["NodeTypes","getInsertion"],"sources":["../../../src/interpreter/interpolableNode.ts"],"sourcesContent":["import * as NodeTypes from '@intlayer/types/nodeType';\nimport type { NodeProps, Plugins } from './getContent/plugins';\nimport { getInsertion } from './getInsertion';\n\n/**\n * A node whose textual content can carry `{{ … }}` interpolation placeholders.\n *\n * Besides plain strings, this covers `html()` and `markdown()` nodes: their\n * inner content is a raw string that may itself hold placeholders (e.g.\n * `html('<b>{{count}}</b> days')`). Enumeration/plural/insertion wrappers must\n * be able to interpolate into that inner string before the html/markdown\n * renderer turns it into a component tree.\n */\nexport type InterpolableNode =\n | string\n | { nodeType: typeof NodeTypes.HTML; [NodeTypes.HTML]: string }\n | { nodeType: typeof NodeTypes.MARKDOWN; [NodeTypes.MARKDOWN]: string };\n\n/**\n * Returns `true` when the node is an `html()` or `markdown()` node whose inner\n * content is a raw string eligible for `{{ … }}` interpolation.\n *\n * Each check is guarded by the corresponding `INTLAYER_NODE_TYPE_*` env flag\n * so bundlers can eliminate the branch (and downstream handling code) when the\n * html/markdown node types are tree-shaken out of the user bundle.\n */\nexport const isInterpolableWrapperNode = (\n node: unknown\n): node is Exclude<InterpolableNode, string> => {\n if (typeof node !== 'object' || node === null || !('nodeType' in node)) {\n return false;\n }\n\n const { nodeType } = node as { nodeType?: unknown };\n\n return (\n (process.env.INTLAYER_NODE_TYPE_HTML !== 'false' &&\n nodeType === NodeTypes.HTML) ||\n (process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false' &&\n nodeType === NodeTypes.MARKDOWN)\n );\n};\n\n/**\n * Extracts the raw interpolable string from a string, `html()` or `markdown()`\n * node. Returns `undefined` for any other node so callers can fall back to\n * their default handling.\n *\n * @example\n * ```ts\n * getInterpolableContent('{{count}} days'); // '{{count}} days'\n * getInterpolableContent(html('<b>{{count}}</b>')); // '<b>{{count}}</b>'\n * getInterpolableContent({ nodeType: 'translation' }); // undefined\n * ```\n */\nexport const getInterpolableContent = (node: unknown): string | undefined => {\n if (typeof node === 'string') {\n return node;\n }\n\n if (isInterpolableWrapperNode(node)) {\n return node.nodeType === NodeTypes.HTML\n ? node[NodeTypes.HTML]\n : node[NodeTypes.MARKDOWN];\n }\n\n return undefined;\n};\n\n/**\n * Rebuilds an interpolable node from its interpolated raw string, preserving\n * the original node shape (plain string stays a string, `html()`/`markdown()`\n * nodes keep their `nodeType` and sibling fields so the renderer still applies).\n *\n * @example\n * ```ts\n * rebuildInterpolableContent(html('<b>{{count}}</b>'), '<b>1</b>');\n * // { nodeType: 'html', html: '<b>1</b>', … }\n * ```\n */\nexport const rebuildInterpolableContent = <T>(\n node: T,\n interpolated: string\n): T => {\n if (typeof node === 'string') {\n return interpolated as T;\n }\n\n if (isInterpolableWrapperNode(node)) {\n const key =\n node.nodeType === NodeTypes.HTML ? NodeTypes.HTML : NodeTypes.MARKDOWN;\n\n return { ...node, [key]: interpolated } as T;\n }\n\n return node;\n};\n\n/**\n * Interpolates `{{ … }}` values into an `html()`/`markdown()` wrapper node,\n * then re-runs the transform with the parent plugin list so the html/markdown\n * renderer applies to the interpolated content.\n *\n * Shared by the plural/insertion string plugins of `@intlayer/core` and every\n * framework package — framework nodes (React elements, VNodes…) cannot be\n * injected into a raw markup string, so plain string interpolation is used.\n */\nexport const transformInterpolableNode = (\n node: Exclude<InterpolableNode, string>,\n values: Record<string, string | number>,\n subProps: NodeProps,\n parentPlugins: Plugins[] | undefined,\n deepTransformNode: (node: unknown, props: NodeProps) => unknown\n): unknown => {\n const interpolated = getInsertion(getInterpolableContent(node)!, values);\n const children = rebuildInterpolableContent(node, interpolated);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: parentPlugins,\n children,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAa,6BACX,SAC8C;CAC9C,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,EAAE,cAAc,OAC/D,OAAO;CAGT,MAAM,EAAE,aAAa;CAErB,OACG,QAAQ,IAAI,4BAA4B,WACvC,aAAaA,yBAAU,QACxB,QAAQ,IAAI,gCAAgC,WAC3C,aAAaA,yBAAU;AAE7B;;;;;;;;;;;;;AAcA,MAAa,0BAA0B,SAAsC;CAC3E,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,IAAI,0BAA0B,IAAI,GAChC,OAAO,KAAK,aAAaA,yBAAU,OAC/B,KAAKA,yBAAU,QACf,KAAKA,yBAAU;AAIvB;;;;;;;;;;;;AAaA,MAAa,8BACX,MACA,iBACM;CACN,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,IAAI,0BAA0B,IAAI,GAAG;EACnC,MAAM,MACJ,KAAK,aAAaA,yBAAU,OAAOA,yBAAU,OAAOA,yBAAU;EAEhE,OAAO;GAAE,GAAG;IAAO,MAAM;EAAa;CACxC;CAEA,OAAO;AACT;;;;;;;;;;AAWA,MAAa,6BACX,MACA,QACA,UACA,eACA,sBACY;CACZ,MAAM,eAAeC,8CAAa,uBAAuB,IAAI,GAAI,MAAM;CACvE,MAAM,WAAW,2BAA2B,MAAM,YAAY;CAE9D,OAAO,kBAAkB,UAAU;EACjC,GAAG;EACH,SAAS;EACT;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"splitAndJoinInsertion.cjs","names":[],"sources":["../../../src/interpreter/splitAndJoinInsertion.ts"],"sourcesContent":["/**\n * Check if a value is a complex object (not a primitive)\n * Used to determine if values need to be wrapped in fragments\n */\nconst isComplexValue = (value: any): boolean =>\n value != null &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean';\n\n// Hoisted: replace/split do not suffer from the stateful lastIndex mutation of .exec()\nconst insertionRegex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\nexport const splitInsertionTemplate = <T = any>(\n template: string,\n values: Record<string, T> = {}\n): { isSimple: boolean; parts: string | T[] } => {\n if (!Object.values(values).some(isComplexValue)) {\n return {\n isSimple: true,\n parts: template.replace(insertionRegex, (_, key) =>\n (values[key.trim()] ?? '').toString()\n ),\n };\n }\n\n const chunks = template.split(insertionRegex);\n const parts: any[] = [];\n\n for (let i = 0; i < chunks.length; i++) {\n if (i % 2 === 0) {\n if (chunks[i]) parts.push(chunks[i]);\n } else {\n const val = values[chunks[i].trim()];\n if (val != null) parts.push(val);\n }\n }\n\n return { isSimple: false, parts };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,kBAAkB,UACtB,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAGnB,MAAM,iBAAiB;AAEvB,MAAa,0BACX,UACA,SAA4B,EAAE,KACiB;AAC/C,KAAI,CAAC,OAAO,OAAO,OAAO,CAAC,KAAK,eAAe,CAC7C,QAAO;EACL,UAAU;EACV,OAAO,SAAS,QAAQ,iBAAiB,GAAG,SACzC,OAAO,IAAI,MAAM,KAAK,IAAI,UAAU,CACtC;EACF;CAGH,MAAM,SAAS,SAAS,MAAM,eAAe;CAC7C,MAAM,QAAe,EAAE;AAEvB,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,IACjC,KAAI,IAAI,MAAM,GACZ;MAAI,OAAO,GAAI,OAAM,KAAK,OAAO,GAAG;QAC/B;EACL,MAAM,MAAM,OAAO,OAAO,GAAG,MAAM;AACnC,MAAI,OAAO,KAAM,OAAM,KAAK,IAAI;;AAIpC,QAAO;EAAE,UAAU;EAAO;EAAO"}
1
+ {"version":3,"file":"splitAndJoinInsertion.cjs","names":[],"sources":["../../../src/interpreter/splitAndJoinInsertion.ts"],"sourcesContent":["/**\n * Check if a value is a complex object (not a primitive)\n * Used to determine if values need to be wrapped in fragments\n */\nconst isComplexValue = (value: any): boolean =>\n value != null &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean';\n\n// Hoisted: replace/split do not suffer from the stateful lastIndex mutation of .exec()\nconst insertionRegex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n\nexport const splitInsertionTemplate = <T = any>(\n template: string,\n values: Record<string, T> = {}\n): { isSimple: boolean; parts: string | T[] } => {\n if (!Object.values(values).some(isComplexValue)) {\n return {\n isSimple: true,\n parts: template.replace(insertionRegex, (_, key) =>\n (values[key.trim()] ?? '').toString()\n ),\n };\n }\n\n const chunks = template.split(insertionRegex);\n const parts: any[] = [];\n\n for (let i = 0; i < chunks.length; i++) {\n if (i % 2 === 0) {\n if (chunks[i]) parts.push(chunks[i]);\n } else {\n const val = values[chunks[i].trim()];\n if (val != null) parts.push(val);\n }\n }\n\n return { isSimple: false, parts };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,kBAAkB,UACtB,SAAS,QACT,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAGnB,MAAM,iBAAiB;AAEvB,MAAa,0BACX,UACA,SAA4B,CAAC,MACkB;CAC/C,IAAI,CAAC,OAAO,OAAO,MAAM,CAAC,CAAC,KAAK,cAAc,GAC5C,OAAO;EACL,UAAU;EACV,OAAO,SAAS,QAAQ,iBAAiB,GAAG,SACzC,OAAO,IAAI,KAAK,MAAM,GAAE,CAAE,SAAS,CACtC;CACF;CAGF,MAAM,SAAS,SAAS,MAAM,cAAc;CAC5C,MAAM,QAAe,CAAC;CAEtB,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KACjC,IAAI,IAAI,MAAM,GACZ;MAAI,OAAO,IAAI,MAAM,KAAK,OAAO,EAAE;CAAC,OAC/B;EACL,MAAM,MAAM,OAAO,OAAO,EAAE,CAAC,KAAK;EAClC,IAAI,OAAO,MAAM,MAAM,KAAK,GAAG;CACjC;CAGF,OAAO;EAAE,UAAU;EAAO;CAAM;AAClC"}
@@ -1 +1 @@
1
- {"version":3,"file":"comparePaths.cjs","names":["getPathWithoutLocale","checkIsURLAbsolute"],"sources":["../../../src/localization/comparePaths.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\n\n/**\n * Normalizes a URL or pathname into a canonical, locale-agnostic pathname so\n * that two paths pointing to the same page compare equal — useful for\n * highlighting the active navigation link.\n *\n * The normalization:\n * - strips the locale segment (reusing {@link getPathWithoutLocale})\n * - strips the protocol/host so absolute and relative inputs compare equally\n * - drops the query string and hash\n * - ensures a single leading slash\n * - removes any trailing slash (except for the root path)\n * - falls back to `'/'` for empty values\n *\n * Example:\n *\n * ```ts\n * normalizePath('/ru/path') // '/path'\n * normalizePath('/ru/path/') // '/path'\n * normalizePath('ru/path') // '/path'\n * normalizePath('/ru/') // '/'\n * normalizePath('/ru') // '/'\n * normalizePath('') // '/'\n * normalizePath('https://example.com/ru/path') // '/path'\n * ```\n *\n * @param inputUrl - The URL string or pathname to normalize.\n * @param locales - Optional array of supported locales. Defaults to the\n * configured locales.\n * @returns The normalized, locale-agnostic pathname.\n */\nexport const normalizePath = <const L extends LocalesValues = DeclaredLocales>(\n inputUrl: string,\n locales?: L[]\n): string => {\n const withoutLocale = getPathWithoutLocale(inputUrl || '/', locales);\n\n // Reuse the URL API to isolate the pathname from any host/query/hash.\n const url = checkIsURLAbsolute(withoutLocale)\n ? new URL(withoutLocale)\n : new URL(withoutLocale, 'http://example.com');\n\n const { pathname } = url;\n\n // Remove a trailing slash, keeping the root path intact.\n if (pathname.length > 1 && pathname.endsWith('/')) {\n return pathname.slice(0, -1);\n }\n\n return pathname || '/';\n};\n\n/**\n * Compares two URLs or pathnames for equality, ignoring locale segment,\n * protocol/host, query string, hash and trailing slashes.\n *\n * Both inputs are normalized through {@link normalizePath} before comparison,\n * making this ideal for matching the current pathname against a navigation\n * link's `href`.\n *\n * Example:\n *\n * ```ts\n * comparePaths('/ru/path', '/path') // true\n * comparePaths('/ru/path/', '/path') // true\n * comparePaths('/ru/path', '/path/') // true\n * comparePaths('/ru/', '/') // true\n * comparePaths('/ru', '/') // true\n * comparePaths('ru/path', '/path') // true\n * comparePaths('', '/') // true\n * comparePaths('/ru', '') // true\n * comparePaths('/ru/path', '/other') // false\n * ```\n *\n * @param pathname - The first URL string or pathname to compare.\n * @param href - The second URL string or pathname to compare.\n * @param locales - Optional array of supported locales. Defaults to the\n * configured locales.\n * @returns `true` when both inputs resolve to the same locale-agnostic path.\n */\nexport const comparePaths = <const L extends LocalesValues = DeclaredLocales>(\n pathname: string,\n href: string,\n locales?: L[]\n): boolean => normalizePath(pathname, locales) === normalizePath(href, locales);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,iBACX,UACA,YACW;CACX,MAAM,gBAAgBA,+DAAqB,YAAY,KAAK,QAAQ;CAOpE,MAAM,EAAE,aAJIC,oDAAmB,cAAc,GACzC,IAAI,IAAI,cAAc,GACtB,IAAI,IAAI,eAAe,qBAAqB;AAKhD,KAAI,SAAS,SAAS,KAAK,SAAS,SAAS,IAAI,CAC/C,QAAO,SAAS,MAAM,GAAG,GAAG;AAG9B,QAAO,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BrB,MAAa,gBACX,UACA,MACA,YACY,cAAc,UAAU,QAAQ,KAAK,cAAc,MAAM,QAAQ"}
1
+ {"version":3,"file":"comparePaths.cjs","names":["getPathWithoutLocale","checkIsURLAbsolute"],"sources":["../../../src/localization/comparePaths.ts"],"sourcesContent":["import type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { checkIsURLAbsolute } from '../utils/checkIsURLAbsolute';\nimport { getPathWithoutLocale } from './getPathWithoutLocale';\n\n/**\n * Normalizes a URL or pathname into a canonical, locale-agnostic pathname so\n * that two paths pointing to the same page compare equal — useful for\n * highlighting the active navigation link.\n *\n * The normalization:\n * - strips the locale segment (reusing {@link getPathWithoutLocale})\n * - strips the protocol/host so absolute and relative inputs compare equally\n * - drops the query string and hash\n * - ensures a single leading slash\n * - removes any trailing slash (except for the root path)\n * - falls back to `'/'` for empty values\n *\n * Example:\n *\n * ```ts\n * normalizePath('/ru/path') // '/path'\n * normalizePath('/ru/path/') // '/path'\n * normalizePath('ru/path') // '/path'\n * normalizePath('/ru/') // '/'\n * normalizePath('/ru') // '/'\n * normalizePath('') // '/'\n * normalizePath('https://example.com/ru/path') // '/path'\n * ```\n *\n * @param inputUrl - The URL string or pathname to normalize.\n * @param locales - Optional array of supported locales. Defaults to the\n * configured locales.\n * @returns The normalized, locale-agnostic pathname.\n */\nexport const normalizePath = <const L extends LocalesValues = DeclaredLocales>(\n inputUrl: string,\n locales?: L[]\n): string => {\n const withoutLocale = getPathWithoutLocale(inputUrl || '/', locales);\n\n // Reuse the URL API to isolate the pathname from any host/query/hash.\n const url = checkIsURLAbsolute(withoutLocale)\n ? new URL(withoutLocale)\n : new URL(withoutLocale, 'http://example.com');\n\n const { pathname } = url;\n\n // Remove a trailing slash, keeping the root path intact.\n if (pathname.length > 1 && pathname.endsWith('/')) {\n return pathname.slice(0, -1);\n }\n\n return pathname || '/';\n};\n\n/**\n * Compares two URLs or pathnames for equality, ignoring locale segment,\n * protocol/host, query string, hash and trailing slashes.\n *\n * Both inputs are normalized through {@link normalizePath} before comparison,\n * making this ideal for matching the current pathname against a navigation\n * link's `href`.\n *\n * Example:\n *\n * ```ts\n * comparePaths('/ru/path', '/path') // true\n * comparePaths('/ru/path/', '/path') // true\n * comparePaths('/ru/path', '/path/') // true\n * comparePaths('/ru/', '/') // true\n * comparePaths('/ru', '/') // true\n * comparePaths('ru/path', '/path') // true\n * comparePaths('', '/') // true\n * comparePaths('/ru', '') // true\n * comparePaths('/ru/path', '/other') // false\n * ```\n *\n * @param pathname - The first URL string or pathname to compare.\n * @param href - The second URL string or pathname to compare.\n * @param locales - Optional array of supported locales. Defaults to the\n * configured locales.\n * @returns `true` when both inputs resolve to the same locale-agnostic path.\n */\nexport const comparePaths = <const L extends LocalesValues = DeclaredLocales>(\n pathname: string,\n href: string,\n locales?: L[]\n): boolean => normalizePath(pathname, locales) === normalizePath(href, locales);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAa,iBACX,UACA,YACW;CACX,MAAM,gBAAgBA,+DAAqB,YAAY,KAAK,OAAO;CAOnE,MAAM,EAAE,aAJIC,oDAAmB,aAAa,IACxC,IAAI,IAAI,aAAa,IACrB,IAAI,IAAI,eAAe,oBAAoB;CAK/C,IAAI,SAAS,SAAS,KAAK,SAAS,SAAS,GAAG,GAC9C,OAAO,SAAS,MAAM,GAAG,EAAE;CAG7B,OAAO,YAAY;AACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,gBACX,UACA,MACA,YACY,cAAc,UAAU,OAAO,MAAM,cAAc,MAAM,OAAO"}
@@ -0,0 +1,82 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+
3
+ //#region src/localization/domainUtils.ts
4
+ /**
5
+ * Strips the protocol from a domain string and returns only the hostname.
6
+ *
7
+ * Example:
8
+ *
9
+ * ```ts
10
+ * getDomainHostname('https://intlayer.cn') // 'intlayer.cn'
11
+ * getDomainHostname('intlayer.cn') // 'intlayer.cn'
12
+ * ```
13
+ *
14
+ * @param domain - A domain value from `routing.domains`, with or without protocol.
15
+ * @returns The bare hostname.
16
+ */
17
+ const getDomainHostname = (domain) => {
18
+ try {
19
+ return /^https?:\/\//.test(domain) ? new URL(domain).hostname : domain;
20
+ } catch {
21
+ return domain;
22
+ }
23
+ };
24
+ /**
25
+ * Returns the absolute origin for a domain value, prepending `https://`
26
+ * when no protocol is present.
27
+ *
28
+ * Example:
29
+ *
30
+ * ```ts
31
+ * getDomainOrigin('intlayer.cn') // 'https://intlayer.cn'
32
+ * getDomainOrigin('http://intlayer.cn') // 'http://intlayer.cn'
33
+ * ```
34
+ *
35
+ * @param domain - A domain value from `routing.domains`, with or without protocol.
36
+ * @returns The origin usable as a URL base.
37
+ */
38
+ const getDomainOrigin = (domain) => /^https?:\/\//.test(domain) ? domain : `https://${domain}`;
39
+ /**
40
+ * Returns the locale exclusively mapped to a given hostname via `routing.domains`,
41
+ * or `undefined` when zero or more than one locale share that hostname.
42
+ *
43
+ * Example: with `domains = { zh: 'intlayer.cn', en: 'intlayer.org', fr: 'intlayer.org' }`
44
+ *
45
+ * ```ts
46
+ * getLocaleFromDomain('intlayer.cn', domains) // 'zh'
47
+ * getLocaleFromDomain('intlayer.org', domains) // undefined (en and fr share it)
48
+ * getLocaleFromDomain('example.com', domains) // undefined (not mapped)
49
+ * ```
50
+ *
51
+ * @param hostname - The bare hostname of the incoming request.
52
+ * @param domains - The configured locale → domain map.
53
+ * @returns The exclusively mapped locale, or `undefined`.
54
+ */
55
+ const getLocaleFromDomain = (hostname, domains) => {
56
+ if (!domains) return void 0;
57
+ const matchingLocales = Object.entries(domains).filter(([, domain]) => typeof domain === "string" && getDomainHostname(domain) === hostname);
58
+ return matchingLocales.length === 1 ? matchingLocales[0]?.[0] : void 0;
59
+ };
60
+ /**
61
+ * Checks whether a locale is the only locale mapped to its configured domain.
62
+ * When true, the domain alone identifies the locale and no URL prefix is needed.
63
+ * Hostnames are compared after protocol stripping, so
64
+ * `{ en: 'https://intlayer.org', fr: 'intlayer.org' }` counts as a shared domain.
65
+ *
66
+ * @param locale - The locale to check.
67
+ * @param domains - The configured locale → domain map.
68
+ * @returns `true` when the locale has a domain shared with no other locale.
69
+ */
70
+ const isLocaleExclusiveOnDomain = (locale, domains) => {
71
+ const localeDomain = domains?.[locale];
72
+ if (!localeDomain) return false;
73
+ const localeHostname = getDomainHostname(localeDomain);
74
+ return Object.values(domains).filter((domain) => typeof domain === "string" && getDomainHostname(domain) === localeHostname).length === 1;
75
+ };
76
+
77
+ //#endregion
78
+ exports.getDomainHostname = getDomainHostname;
79
+ exports.getDomainOrigin = getDomainOrigin;
80
+ exports.getLocaleFromDomain = getLocaleFromDomain;
81
+ exports.isLocaleExclusiveOnDomain = isLocaleExclusiveOnDomain;
82
+ //# sourceMappingURL=domainUtils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domainUtils.cjs","names":[],"sources":["../../../src/localization/domainUtils.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { RoutingConfig } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * The locale → domain map configured under `routing.domains`\n * (e.g. `{ en: 'intlayer.org', zh: 'intlayer.cn' }`).\n */\nexport type LocaleDomainMap = RoutingConfig['domains'];\n\n/**\n * Strips the protocol from a domain string and returns only the hostname.\n *\n * Example:\n *\n * ```ts\n * getDomainHostname('https://intlayer.cn') // 'intlayer.cn'\n * getDomainHostname('intlayer.cn') // 'intlayer.cn'\n * ```\n *\n * @param domain - A domain value from `routing.domains`, with or without protocol.\n * @returns The bare hostname.\n */\nexport const getDomainHostname = (domain: string): string => {\n try {\n return /^https?:\\/\\//.test(domain) ? new URL(domain).hostname : domain;\n } catch {\n return domain;\n }\n};\n\n/**\n * Returns the absolute origin for a domain value, prepending `https://`\n * when no protocol is present.\n *\n * Example:\n *\n * ```ts\n * getDomainOrigin('intlayer.cn') // 'https://intlayer.cn'\n * getDomainOrigin('http://intlayer.cn') // 'http://intlayer.cn'\n * ```\n *\n * @param domain - A domain value from `routing.domains`, with or without protocol.\n * @returns The origin usable as a URL base.\n */\nexport const getDomainOrigin = (domain: string): string =>\n /^https?:\\/\\//.test(domain) ? domain : `https://${domain}`;\n\n/**\n * Returns the locale exclusively mapped to a given hostname via `routing.domains`,\n * or `undefined` when zero or more than one locale share that hostname.\n *\n * Example: with `domains = { zh: 'intlayer.cn', en: 'intlayer.org', fr: 'intlayer.org' }`\n *\n * ```ts\n * getLocaleFromDomain('intlayer.cn', domains) // 'zh'\n * getLocaleFromDomain('intlayer.org', domains) // undefined (en and fr share it)\n * getLocaleFromDomain('example.com', domains) // undefined (not mapped)\n * ```\n *\n * @param hostname - The bare hostname of the incoming request.\n * @param domains - The configured locale → domain map.\n * @returns The exclusively mapped locale, or `undefined`.\n */\nexport const getLocaleFromDomain = (\n hostname: string,\n domains: LocaleDomainMap\n): Locale | undefined => {\n if (!domains) return undefined;\n\n const matchingLocales = Object.entries(domains).filter(\n ([, domain]) =>\n typeof domain === 'string' && getDomainHostname(domain) === hostname\n );\n\n return matchingLocales.length === 1\n ? (matchingLocales[0]?.[0] as Locale)\n : undefined;\n};\n\n/**\n * Checks whether a locale is the only locale mapped to its configured domain.\n * When true, the domain alone identifies the locale and no URL prefix is needed.\n * Hostnames are compared after protocol stripping, so\n * `{ en: 'https://intlayer.org', fr: 'intlayer.org' }` counts as a shared domain.\n *\n * @param locale - The locale to check.\n * @param domains - The configured locale → domain map.\n * @returns `true` when the locale has a domain shared with no other locale.\n */\nexport const isLocaleExclusiveOnDomain = (\n locale: LocalesValues,\n domains: LocaleDomainMap\n): boolean => {\n const localeDomain = domains?.[locale];\n\n if (!localeDomain) return false;\n\n const localeHostname = getDomainHostname(localeDomain);\n\n const localesOnSameDomain = Object.values(domains).filter(\n (domain) =>\n typeof domain === 'string' && getDomainHostname(domain) === localeHostname\n ).length;\n\n return localesOnSameDomain === 1;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAa,qBAAqB,WAA2B;CAC3D,IAAI;EACF,OAAO,eAAe,KAAK,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,CAAC,WAAW;CAClE,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,mBAAmB,WAC9B,eAAe,KAAK,MAAM,IAAI,SAAS,WAAW;;;;;;;;;;;;;;;;;AAkBpD,MAAa,uBACX,UACA,YACuB;CACvB,IAAI,CAAC,SAAS,OAAO;CAErB,MAAM,kBAAkB,OAAO,QAAQ,OAAO,CAAC,CAAC,QAC7C,GAAG,YACF,OAAO,WAAW,YAAY,kBAAkB,MAAM,MAAM,QAChE;CAEA,OAAO,gBAAgB,WAAW,IAC7B,gBAAgB,EAAE,GAAG,KACtB;AACN;;;;;;;;;;;AAYA,MAAa,6BACX,QACA,YACY;CACZ,MAAM,eAAe,UAAU;CAE/B,IAAI,CAAC,cAAc,OAAO;CAE1B,MAAM,iBAAiB,kBAAkB,YAAY;CAOrD,OAL4B,OAAO,OAAO,OAAO,CAAC,CAAC,QAChD,WACC,OAAO,WAAW,YAAY,kBAAkB,MAAM,MAAM,cAChE,CAAC,CAAC,WAE6B;AACjC"}
@@ -91,7 +91,8 @@ const generateSitemapUrl = (path, options) => {
91
91
  */
92
92
  const generateSitemap = (entries, options) => {
93
93
  const { siteUrl, xhtmlLinks = true, ...routingOptions } = options;
94
- const includeAlternates = shouldIncludeAlternates(require_localization_getPrefix.resolveRoutingConfig(routingOptions).mode, xhtmlLinks);
94
+ const resolved = require_localization_getPrefix.resolveRoutingConfig(routingOptions);
95
+ const includeAlternates = shouldIncludeAlternates(resolved.mode, xhtmlLinks);
95
96
  const xmlEntries = entries.map((entry) => generateSitemapUrl(entry.path, {
96
97
  ...entry,
97
98
  siteUrl,
@@ -1 +1 @@
1
- {"version":3,"file":"generateSitemap.cjs","names":["resolveRoutingConfig","getMultilingualUrls"],"sources":["../../../src/localization/generateSitemap.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getMultilingualUrls } from './getMultilingualUrls';\nimport { type RoutingOptions, resolveRoutingConfig } from './getPrefix';\n\nexport type SitemapUrlEntry = {\n /** The canonical path, e.g. '/dashboard' */\n path: string;\n changefreq?: string;\n priority?: number;\n /** ISO date string, e.g. '2024-01-15' */\n lastmod?: string;\n};\n\nexport type GenerateSitemapOptions = {\n /** Base site URL without trailing slash, e.g. 'https://example.com' */\n siteUrl: string;\n /**\n * Whether to include xhtml:link alternate tags for multilingual support.\n *\n * When enabled, alternate links are only generated for modes where URLs\n * differ per locale:\n * - 'prefix-no-default': included\n * - 'prefix-all': included\n * - 'search-params': included\n * - 'no-prefix': excluded (all locales share the same URL)\n *\n * @default true\n */\n xhtmlLinks?: boolean;\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n rewrite?: RoutingConfig['rewrite'];\n};\n\n/**\n * Returns whether xhtml:link alternate tags should be generated for the given routing mode.\n *\n * Alternates are meaningful only when locale URLs are distinct:\n * - 'no-prefix' produces identical URLs for all locales → no alternates\n * - all other modes produce distinct URLs → alternates are generated\n */\nconst shouldIncludeAlternates = (\n mode: RoutingConfig['mode'],\n xhtmlLinks: boolean\n): boolean => xhtmlLinks && mode !== 'no-prefix';\n\n/**\n * Generates a single `<url>` sitemap entry for the given path.\n *\n * Example:\n *\n * ```ts\n * generateSitemapUrl('/dashboard', {\n * siteUrl: 'https://example.com',\n * changefreq: 'weekly',\n * priority: 0.8,\n * xhtmlLinks: true,\n * locales: ['en', 'fr'],\n * defaultLocale: 'en',\n * mode: 'prefix-no-default',\n * });\n * // Returns:\n * // <url>\n * // <loc>https://example.com/dashboard</loc>\n * // <changefreq>weekly</changefreq>\n * // <priority>0.8</priority>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"en\" href=\"https://example.com/dashboard\"/>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"fr\" href=\"https://example.com/fr/dashboard\"/>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"x-default\" href=\"https://example.com/dashboard\"/>\n * // </url>\n * ```\n *\n * @param path - The canonical path to generate the entry for.\n * @param options - Configuration options.\n * @returns A `<url>` XML string.\n */\nexport const generateSitemapUrl = (\n path: string,\n options: SitemapUrlEntry & GenerateSitemapOptions\n): string => {\n const {\n siteUrl,\n changefreq,\n priority,\n lastmod,\n xhtmlLinks = true,\n ...routingOptions\n } = options;\n\n const resolved = resolveRoutingConfig(routingOptions as RoutingOptions);\n const fullUrl = `${siteUrl}${path}`;\n\n const lines: (string | null)[] = [\n ' <url>',\n ` <loc>${fullUrl}</loc>`,\n lastmod ? ` <lastmod>${lastmod}</lastmod>` : null,\n changefreq ? ` <changefreq>${changefreq}</changefreq>` : null,\n priority !== undefined ? ` <priority>${priority}</priority>` : null,\n ];\n\n const hasFileExtension = /\\.[a-z0-9]+$/i.test(path);\n if (shouldIncludeAlternates(resolved.mode, xhtmlLinks) && !hasFileExtension) {\n const alternates = getMultilingualUrls(\n path,\n routingOptions as RoutingOptions\n );\n\n for (const [lang, localePath] of Object.entries(alternates)) {\n lines.push(\n ` <xhtml:link rel=\"alternate\" hreflang=\"${lang}\" href=\"${siteUrl}${localePath}\"/>`\n );\n }\n\n lines.push(\n ` <xhtml:link rel=\"alternate\" hreflang=\"x-default\" href=\"${fullUrl}\"/>`\n );\n }\n\n lines.push(' </url>');\n\n return lines.filter(Boolean).join('\\n');\n};\n\n/**\n * Generates a full XML sitemap string from an array of URL entries.\n *\n * Automatically adds `xmlns:xhtml` to the `<urlset>` declaration when\n * xhtml:link alternate tags are included.\n *\n * Example:\n *\n * ```ts\n * generateSitemap(\n * [\n * { path: '/', changefreq: 'daily', priority: 1.0 },\n * { path: '/about', changefreq: 'monthly', priority: 0.5 },\n * ],\n * {\n * siteUrl: 'https://example.com',\n * xhtmlLinks: true,\n * locales: ['en', 'fr'],\n * defaultLocale: 'en',\n * mode: 'prefix-no-default',\n * }\n * );\n * ```\n *\n * @param entries - Array of URL entries to include in the sitemap.\n * @param options - Sitemap generation options.\n * @returns A full XML sitemap string.\n */\nexport const generateSitemap = (\n entries: SitemapUrlEntry[],\n options: GenerateSitemapOptions\n): string => {\n const { siteUrl, xhtmlLinks = true, ...routingOptions } = options;\n\n const resolved = resolveRoutingConfig(routingOptions as RoutingOptions);\n const includeAlternates = shouldIncludeAlternates(resolved.mode, xhtmlLinks);\n\n const xmlEntries = entries.map((entry) =>\n generateSitemapUrl(entry.path, {\n ...entry,\n siteUrl,\n xhtmlLinks,\n ...routingOptions,\n })\n );\n\n const xmlns = includeAlternates\n ? '\\n xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"'\n : '';\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset\n xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"${xmlns}\n>\n${xmlEntries.join('\\n')}\n</urlset>`;\n};\n"],"mappings":";;;;;;;;;;;;AA2CA,MAAM,2BACJ,MACA,eACY,cAAc,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCrC,MAAa,sBACX,MACA,YACW;CACX,MAAM,EACJ,SACA,YACA,UACA,SACA,aAAa,MACb,GAAG,mBACD;CAEJ,MAAM,WAAWA,oDAAqB,eAAiC;CACvE,MAAM,UAAU,GAAG,UAAU;CAE7B,MAAM,QAA2B;EAC/B;EACA,YAAY,QAAQ;EACpB,UAAU,gBAAgB,QAAQ,cAAc;EAChD,aAAa,mBAAmB,WAAW,iBAAiB;EAC5D,aAAa,SAAY,iBAAiB,SAAS,eAAe;EACnE;CAED,MAAM,mBAAmB,gBAAgB,KAAK,KAAK;AACnD,KAAI,wBAAwB,SAAS,MAAM,WAAW,IAAI,CAAC,kBAAkB;EAC3E,MAAM,aAAaC,6DACjB,MACA,eACD;AAED,OAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,WAAW,CACzD,OAAM,KACJ,6CAA6C,KAAK,UAAU,UAAU,WAAW,KAClF;AAGH,QAAM,KACJ,8DAA8D,QAAQ,KACvE;;AAGH,OAAM,KAAK,WAAW;AAEtB,QAAO,MAAM,OAAO,QAAQ,CAAC,KAAK,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BzC,MAAa,mBACX,SACA,YACW;CACX,MAAM,EAAE,SAAS,aAAa,MAAM,GAAG,mBAAmB;CAG1D,MAAM,oBAAoB,wBADTD,oDAAqB,eACoB,CAAC,MAAM,WAAW;CAE5E,MAAM,aAAa,QAAQ,KAAK,UAC9B,mBAAmB,MAAM,MAAM;EAC7B,GAAG;EACH;EACA;EACA,GAAG;EACJ,CAAC,CACH;AAMD,QAAO;;uDAJO,oBACV,qDACA,GAIuD;;EAE3D,WAAW,KAAK,KAAK,CAAC"}
1
+ {"version":3,"file":"generateSitemap.cjs","names":["resolveRoutingConfig","getMultilingualUrls"],"sources":["../../../src/localization/generateSitemap.ts"],"sourcesContent":["import type { RoutingConfig } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getMultilingualUrls } from './getMultilingualUrls';\nimport { type RoutingOptions, resolveRoutingConfig } from './getPrefix';\n\nexport type SitemapUrlEntry = {\n /** The canonical path, e.g. '/dashboard' */\n path: string;\n changefreq?: string;\n priority?: number;\n /** ISO date string, e.g. '2024-01-15' */\n lastmod?: string;\n};\n\nexport type GenerateSitemapOptions = {\n /** Base site URL without trailing slash, e.g. 'https://example.com' */\n siteUrl: string;\n /**\n * Whether to include xhtml:link alternate tags for multilingual support.\n *\n * When enabled, alternate links are only generated for modes where URLs\n * differ per locale:\n * - 'prefix-no-default': included\n * - 'prefix-all': included\n * - 'search-params': included\n * - 'no-prefix': excluded (all locales share the same URL)\n *\n * @default true\n */\n xhtmlLinks?: boolean;\n locales?: LocalesValues[];\n defaultLocale?: LocalesValues;\n mode?: RoutingConfig['mode'];\n rewrite?: RoutingConfig['rewrite'];\n};\n\n/**\n * Returns whether xhtml:link alternate tags should be generated for the given routing mode.\n *\n * Alternates are meaningful only when locale URLs are distinct:\n * - 'no-prefix' produces identical URLs for all locales → no alternates\n * - all other modes produce distinct URLs → alternates are generated\n */\nconst shouldIncludeAlternates = (\n mode: RoutingConfig['mode'],\n xhtmlLinks: boolean\n): boolean => xhtmlLinks && mode !== 'no-prefix';\n\n/**\n * Generates a single `<url>` sitemap entry for the given path.\n *\n * Example:\n *\n * ```ts\n * generateSitemapUrl('/dashboard', {\n * siteUrl: 'https://example.com',\n * changefreq: 'weekly',\n * priority: 0.8,\n * xhtmlLinks: true,\n * locales: ['en', 'fr'],\n * defaultLocale: 'en',\n * mode: 'prefix-no-default',\n * });\n * // Returns:\n * // <url>\n * // <loc>https://example.com/dashboard</loc>\n * // <changefreq>weekly</changefreq>\n * // <priority>0.8</priority>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"en\" href=\"https://example.com/dashboard\"/>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"fr\" href=\"https://example.com/fr/dashboard\"/>\n * // <xhtml:link rel=\"alternate\" hrefLang=\"x-default\" href=\"https://example.com/dashboard\"/>\n * // </url>\n * ```\n *\n * @param path - The canonical path to generate the entry for.\n * @param options - Configuration options.\n * @returns A `<url>` XML string.\n */\nexport const generateSitemapUrl = (\n path: string,\n options: SitemapUrlEntry & GenerateSitemapOptions\n): string => {\n const {\n siteUrl,\n changefreq,\n priority,\n lastmod,\n xhtmlLinks = true,\n ...routingOptions\n } = options;\n\n const resolved = resolveRoutingConfig(routingOptions as RoutingOptions);\n const fullUrl = `${siteUrl}${path}`;\n\n const lines: (string | null)[] = [\n ' <url>',\n ` <loc>${fullUrl}</loc>`,\n lastmod ? ` <lastmod>${lastmod}</lastmod>` : null,\n changefreq ? ` <changefreq>${changefreq}</changefreq>` : null,\n priority !== undefined ? ` <priority>${priority}</priority>` : null,\n ];\n\n const hasFileExtension = /\\.[a-z0-9]+$/i.test(path);\n if (shouldIncludeAlternates(resolved.mode, xhtmlLinks) && !hasFileExtension) {\n const alternates = getMultilingualUrls(\n path,\n routingOptions as RoutingOptions\n );\n\n for (const [lang, localePath] of Object.entries(alternates)) {\n lines.push(\n ` <xhtml:link rel=\"alternate\" hreflang=\"${lang}\" href=\"${siteUrl}${localePath}\"/>`\n );\n }\n\n lines.push(\n ` <xhtml:link rel=\"alternate\" hreflang=\"x-default\" href=\"${fullUrl}\"/>`\n );\n }\n\n lines.push(' </url>');\n\n return lines.filter(Boolean).join('\\n');\n};\n\n/**\n * Generates a full XML sitemap string from an array of URL entries.\n *\n * Automatically adds `xmlns:xhtml` to the `<urlset>` declaration when\n * xhtml:link alternate tags are included.\n *\n * Example:\n *\n * ```ts\n * generateSitemap(\n * [\n * { path: '/', changefreq: 'daily', priority: 1.0 },\n * { path: '/about', changefreq: 'monthly', priority: 0.5 },\n * ],\n * {\n * siteUrl: 'https://example.com',\n * xhtmlLinks: true,\n * locales: ['en', 'fr'],\n * defaultLocale: 'en',\n * mode: 'prefix-no-default',\n * }\n * );\n * ```\n *\n * @param entries - Array of URL entries to include in the sitemap.\n * @param options - Sitemap generation options.\n * @returns A full XML sitemap string.\n */\nexport const generateSitemap = (\n entries: SitemapUrlEntry[],\n options: GenerateSitemapOptions\n): string => {\n const { siteUrl, xhtmlLinks = true, ...routingOptions } = options;\n\n const resolved = resolveRoutingConfig(routingOptions as RoutingOptions);\n const includeAlternates = shouldIncludeAlternates(resolved.mode, xhtmlLinks);\n\n const xmlEntries = entries.map((entry) =>\n generateSitemapUrl(entry.path, {\n ...entry,\n siteUrl,\n xhtmlLinks,\n ...routingOptions,\n })\n );\n\n const xmlns = includeAlternates\n ? '\\n xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"'\n : '';\n\n return `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset\n xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"${xmlns}\n>\n${xmlEntries.join('\\n')}\n</urlset>`;\n};\n"],"mappings":";;;;;;;;;;;;AA2CA,MAAM,2BACJ,MACA,eACY,cAAc,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCrC,MAAa,sBACX,MACA,YACW;CACX,MAAM,EACJ,SACA,YACA,UACA,SACA,aAAa,MACb,GAAG,mBACD;CAEJ,MAAM,WAAWA,oDAAqB,cAAgC;CACtE,MAAM,UAAU,GAAG,UAAU;CAE7B,MAAM,QAA2B;EAC/B;EACA,YAAY,QAAQ;EACpB,UAAU,gBAAgB,QAAQ,cAAc;EAChD,aAAa,mBAAmB,WAAW,iBAAiB;EAC5D,aAAa,SAAY,iBAAiB,SAAS,eAAe;CACpE;CAEA,MAAM,mBAAmB,gBAAgB,KAAK,IAAI;CAClD,IAAI,wBAAwB,SAAS,MAAM,UAAU,KAAK,CAAC,kBAAkB;EAC3E,MAAM,aAAaC,6DACjB,MACA,cACF;EAEA,KAAK,MAAM,CAAC,MAAM,eAAe,OAAO,QAAQ,UAAU,GACxD,MAAM,KACJ,6CAA6C,KAAK,UAAU,UAAU,WAAW,IACnF;EAGF,MAAM,KACJ,8DAA8D,QAAQ,IACxE;CACF;CAEA,MAAM,KAAK,UAAU;CAErB,OAAO,MAAM,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,mBACX,SACA,YACW;CACX,MAAM,EAAE,SAAS,aAAa,MAAM,GAAG,mBAAmB;CAE1D,MAAM,WAAWD,oDAAqB,cAAgC;CACtE,MAAM,oBAAoB,wBAAwB,SAAS,MAAM,UAAU;CAE3E,MAAM,aAAa,QAAQ,KAAK,UAC9B,mBAAmB,MAAM,MAAM;EAC7B,GAAG;EACH;EACA;EACA,GAAG;CACL,CAAC,CACH;CAMA,OAAO;;uDAJO,oBACV,qDACA,GAIuD;;EAE3D,WAAW,KAAK,IAAI,EAAE;;AAExB"}
@@ -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_utils_localeStorage = require('../utils/localeStorage.cjs');
4
3
  const require_localization_localeDetector = require('./localeDetector.cjs');
5
4
  let _intlayer_config_built = require("@intlayer/config/built");
@@ -28,7 +27,7 @@ const getDefaultsOptions = () => {
28
27
  const detectLanguage = (order, options) => {
29
28
  const detected = {};
30
29
  const queryStringDetector = () => {
31
- if (typeof window === "undefined") return;
30
+ if (typeof window === "undefined" || !window.location) return;
32
31
  const search = window.location.search || "";
33
32
  const value = new URLSearchParams(search).get(options.lookupQuerystring ?? "");
34
33
  if (value) detected["querystring"] = value;
@@ -66,7 +65,10 @@ const detectLanguage = (order, options) => {
66
65
  const htmlTag = options.htmlTag;
67
66
  if (htmlTag && typeof htmlTag.getAttribute === "function") {
68
67
  const lang = htmlTag.getAttribute("lang");
69
- if (lang) detected["htmlTag"] = require_localization_localeDetector.localeDetector({ "accept-language": lang }, _intlayer_config_built.internationalization.locales, _intlayer_config_built.internationalization.defaultLocale);
68
+ if (lang) {
69
+ const locale = require_localization_localeDetector.localeDetector({ "accept-language": lang }, _intlayer_config_built.internationalization.locales, _intlayer_config_built.internationalization.defaultLocale);
70
+ detected["htmlTag"] = locale;
71
+ }
70
72
  }
71
73
  };
72
74
  const detectors = {
@@ -107,7 +109,8 @@ const getBrowserLocale = (userOptions = {}) => {
107
109
  ...getDefaultsOptions(),
108
110
  ...userOptions
109
111
  };
110
- return getFirstAvailableLocale(detectLanguage(options.order ?? [], options), options.order ?? []);
112
+ const locales = detectLanguage(options.order ?? [], options);
113
+ return getFirstAvailableLocale(locales, options.order ?? []);
111
114
  };
112
115
 
113
116
  //#endregion