@intlayer/core 8.1.2 → 8.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs +1 -212
  3. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs +1 -94
  5. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs +1 -45
  7. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs +1 -33
  9. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs +1 -27
  11. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  12. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs +1 -82
  13. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  14. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs +1 -87
  15. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  16. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs +1 -60
  17. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  18. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs +1 -122
  19. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  20. package/dist/cjs/deepTransformPlugins/index.cjs +1 -32
  21. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs +1 -106
  22. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  23. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs +1 -64
  24. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  25. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs +1 -18
  26. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  27. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs +1 -55
  28. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  29. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs +1 -26
  30. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  31. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs +1 -23
  32. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  33. package/dist/cjs/dictionaryManipulator/getNodeType.cjs +1 -36
  34. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  35. package/dist/cjs/dictionaryManipulator/index.cjs +1 -27
  36. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs +1 -69
  37. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  38. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs +1 -30
  39. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  40. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs +1 -48
  41. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  42. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs +1 -31
  43. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  44. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs +1 -39
  45. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  46. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs +1 -38
  47. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  48. package/dist/cjs/formatters/compact.cjs +1 -25
  49. package/dist/cjs/formatters/compact.cjs.map +1 -1
  50. package/dist/cjs/formatters/currency.cjs +1 -29
  51. package/dist/cjs/formatters/currency.cjs.map +1 -1
  52. package/dist/cjs/formatters/date.cjs +1 -60
  53. package/dist/cjs/formatters/date.cjs.map +1 -1
  54. package/dist/cjs/formatters/index.cjs +1 -18
  55. package/dist/cjs/formatters/list.cjs +1 -30
  56. package/dist/cjs/formatters/list.cjs.map +1 -1
  57. package/dist/cjs/formatters/number.cjs +1 -18
  58. package/dist/cjs/formatters/number.cjs.map +1 -1
  59. package/dist/cjs/formatters/percentage.cjs +1 -25
  60. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  61. package/dist/cjs/formatters/relativeTime.cjs +1 -33
  62. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  63. package/dist/cjs/formatters/units.cjs +1 -23
  64. package/dist/cjs/formatters/units.cjs.map +1 -1
  65. package/dist/cjs/getStorageAttributes.cjs +1 -134
  66. package/dist/cjs/getStorageAttributes.cjs.map +1 -1
  67. package/dist/cjs/index.cjs +1 -300
  68. package/dist/cjs/interpreter/getCondition.cjs +1 -27
  69. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  70. package/dist/cjs/interpreter/getContent/deepTransform.cjs +1 -41
  71. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  72. package/dist/cjs/interpreter/getContent/getContent.cjs +1 -34
  73. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  74. package/dist/cjs/interpreter/getContent/index.cjs +1 -14
  75. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -161
  76. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  77. package/dist/cjs/interpreter/getDictionary.cjs +1 -24
  78. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  79. package/dist/cjs/interpreter/getEnumeration.cjs +1 -72
  80. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  81. package/dist/cjs/interpreter/getGender.cjs +1 -38
  82. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  83. package/dist/cjs/interpreter/getHTML.cjs +1 -121
  84. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  85. package/dist/cjs/interpreter/getInsertion.cjs +1 -22
  86. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  87. package/dist/cjs/interpreter/getIntlayer.cjs +1 -40
  88. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  89. package/dist/cjs/interpreter/getNesting.cjs +1 -36
  90. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  91. package/dist/cjs/interpreter/getTranslation.cjs +1 -112
  92. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  93. package/dist/cjs/interpreter/index.cjs +1 -31
  94. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs +1 -55
  95. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  96. package/dist/cjs/localization/getBrowserLocale.cjs +1 -143
  97. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  98. package/dist/cjs/localization/getHTMLTextDir.cjs +1 -64
  99. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  100. package/dist/cjs/localization/getLocale.cjs +1 -27
  101. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  102. package/dist/cjs/localization/getLocaleFromPath.cjs +1 -45
  103. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  104. package/dist/cjs/localization/getLocaleLang.cjs +1 -20
  105. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  106. package/dist/cjs/localization/getLocaleName.cjs +1 -10
  107. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  108. package/dist/cjs/localization/getLocalizedUrl.cjs +1 -82
  109. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  110. package/dist/cjs/localization/getMultilingualUrls.cjs +1 -63
  111. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  112. package/dist/cjs/localization/getPathWithoutLocale.cjs +1 -55
  113. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  114. package/dist/cjs/localization/getPrefix.cjs +1 -63
  115. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  116. package/dist/cjs/localization/index.cjs +1 -39
  117. package/dist/cjs/localization/localeDetector.cjs +1 -133
  118. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  119. package/dist/cjs/localization/localeMapper.cjs +1 -119
  120. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  121. package/dist/cjs/localization/localeResolver.cjs +1 -28
  122. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  123. package/dist/cjs/localization/rewriteUtils.cjs +1 -110
  124. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  125. package/dist/cjs/localization/validatePrefix.cjs +1 -54
  126. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  127. package/dist/cjs/markdown/compiler.cjs +10 -810
  128. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  129. package/dist/cjs/markdown/constants.cjs +1 -328
  130. package/dist/cjs/markdown/constants.cjs.map +1 -1
  131. package/dist/cjs/markdown/index.cjs +1 -120
  132. package/dist/cjs/markdown/parser.cjs +1 -66
  133. package/dist/cjs/markdown/parser.cjs.map +1 -1
  134. package/dist/cjs/markdown/renderer.cjs +1 -61
  135. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  136. package/dist/cjs/markdown/utils.cjs +6 -391
  137. package/dist/cjs/markdown/utils.cjs.map +1 -1
  138. package/dist/cjs/messageFormat/ICU.cjs +1 -319
  139. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  140. package/dist/cjs/messageFormat/i18next.cjs +1 -330
  141. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  142. package/dist/cjs/messageFormat/index.cjs +1 -11
  143. package/dist/cjs/messageFormat/verify-icu-format.cjs +2 -64
  144. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  145. package/dist/cjs/messageFormat/vue-i18n.cjs +1 -166
  146. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  147. package/dist/cjs/transpiler/condition/condition.cjs +1 -26
  148. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  149. package/dist/cjs/transpiler/condition/index.cjs +1 -4
  150. package/dist/cjs/transpiler/enumeration/enumeration.cjs +1 -28
  151. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  152. package/dist/cjs/transpiler/enumeration/index.cjs +1 -4
  153. package/dist/cjs/transpiler/file/file.cjs +1 -52
  154. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  155. package/dist/cjs/transpiler/file/fileBrowser.cjs +1 -25
  156. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  157. package/dist/cjs/transpiler/file/index.cjs +1 -5
  158. package/dist/cjs/transpiler/gender/gender.cjs +1 -26
  159. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  160. package/dist/cjs/transpiler/gender/index.cjs +1 -4
  161. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs +1 -44
  162. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  163. package/dist/cjs/transpiler/html/html.cjs +1 -37
  164. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  165. package/dist/cjs/transpiler/html/htmlTags.cjs +1 -116
  166. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  167. package/dist/cjs/transpiler/html/index.cjs +1 -6
  168. package/dist/cjs/transpiler/index.cjs +1 -24
  169. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs +1 -11
  170. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  171. package/dist/cjs/transpiler/insertion/index.cjs +1 -6
  172. package/dist/cjs/transpiler/insertion/insertion.cjs +1 -36
  173. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  174. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs +2 -23
  175. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  176. package/dist/cjs/transpiler/markdown/index.cjs +1 -6
  177. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -54
  178. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  179. package/dist/cjs/transpiler/nesting/index.cjs +1 -4
  180. package/dist/cjs/transpiler/nesting/nesting.cjs +1 -27
  181. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  182. package/dist/cjs/transpiler/translation/index.cjs +1 -4
  183. package/dist/cjs/transpiler/translation/translation.cjs +1 -29
  184. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  185. package/dist/cjs/utils/checkIsURLAbsolute.cjs +1 -7
  186. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  187. package/dist/cjs/utils/getCookie.cjs +1 -32
  188. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  189. package/dist/cjs/utils/index.cjs +1 -0
  190. package/dist/cjs/utils/intl.cjs +1 -91
  191. package/dist/cjs/utils/intl.cjs.map +1 -1
  192. package/dist/cjs/utils/isSameKeyPath.cjs +1 -7
  193. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  194. package/dist/cjs/utils/isValidReactElement.cjs +1 -14
  195. package/dist/cjs/utils/isValidReactElement.cjs.map +1 -1
  196. package/dist/cjs/utils/localeStorage.cjs +1 -140
  197. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  198. package/dist/cjs/utils/parseYaml.cjs +16 -322
  199. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  200. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs +1 -207
  201. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  202. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs +1 -89
  203. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  204. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs +1 -42
  205. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  206. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs +1 -31
  207. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  208. package/dist/esm/deepTransformPlugins/getMaskContent.mjs +1 -25
  209. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  210. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs +1 -77
  211. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  212. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs +1 -86
  213. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  214. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs +1 -59
  215. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  216. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs +1 -119
  217. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  218. package/dist/esm/deepTransformPlugins/index.mjs +1 -12
  219. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs +1 -104
  220. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  221. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs +1 -62
  222. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  223. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs +1 -16
  224. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  225. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs +1 -53
  226. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  227. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs +1 -24
  228. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  229. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs +1 -21
  230. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  231. package/dist/esm/dictionaryManipulator/getNodeType.mjs +1 -34
  232. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  233. package/dist/esm/dictionaryManipulator/index.mjs +1 -14
  234. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs +1 -66
  235. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  236. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs +1 -28
  237. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  238. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs +1 -45
  239. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  240. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs +1 -29
  241. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  242. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs +1 -37
  243. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  244. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs +1 -36
  245. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  246. package/dist/esm/formatters/compact.mjs +1 -22
  247. package/dist/esm/formatters/compact.mjs.map +1 -1
  248. package/dist/esm/formatters/currency.mjs +1 -26
  249. package/dist/esm/formatters/currency.mjs.map +1 -1
  250. package/dist/esm/formatters/date.mjs +1 -57
  251. package/dist/esm/formatters/date.mjs.map +1 -1
  252. package/dist/esm/formatters/index.mjs +1 -10
  253. package/dist/esm/formatters/list.mjs +1 -27
  254. package/dist/esm/formatters/list.mjs.map +1 -1
  255. package/dist/esm/formatters/number.mjs +1 -15
  256. package/dist/esm/formatters/number.mjs.map +1 -1
  257. package/dist/esm/formatters/percentage.mjs +1 -22
  258. package/dist/esm/formatters/percentage.mjs.map +1 -1
  259. package/dist/esm/formatters/relativeTime.mjs +1 -30
  260. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  261. package/dist/esm/formatters/units.mjs +1 -20
  262. package/dist/esm/formatters/units.mjs.map +1 -1
  263. package/dist/esm/getStorageAttributes.mjs +1 -132
  264. package/dist/esm/getStorageAttributes.mjs.map +1 -1
  265. package/dist/esm/index.mjs +1 -82
  266. package/dist/esm/interpreter/getCondition.mjs +1 -25
  267. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  268. package/dist/esm/interpreter/getContent/deepTransform.mjs +1 -39
  269. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  270. package/dist/esm/interpreter/getContent/getContent.mjs +1 -31
  271. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  272. package/dist/esm/interpreter/getContent/index.mjs +1 -5
  273. package/dist/esm/interpreter/getContent/plugins.mjs +1 -153
  274. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  275. package/dist/esm/interpreter/getDictionary.mjs +1 -23
  276. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  277. package/dist/esm/interpreter/getEnumeration.mjs +1 -69
  278. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  279. package/dist/esm/interpreter/getGender.mjs +1 -36
  280. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  281. package/dist/esm/interpreter/getHTML.mjs +1 -119
  282. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  283. package/dist/esm/interpreter/getInsertion.mjs +1 -20
  284. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  285. package/dist/esm/interpreter/getIntlayer.mjs +1 -36
  286. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  287. package/dist/esm/interpreter/getNesting.mjs +1 -35
  288. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  289. package/dist/esm/interpreter/getTranslation.mjs +1 -110
  290. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  291. package/dist/esm/interpreter/index.mjs +1 -13
  292. package/dist/esm/interpreter/splitAndJoinInsertion.mjs +1 -53
  293. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  294. package/dist/esm/localization/getBrowserLocale.mjs +1 -138
  295. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  296. package/dist/esm/localization/getHTMLTextDir.mjs +1 -62
  297. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  298. package/dist/esm/localization/getLocale.mjs +1 -24
  299. package/dist/esm/localization/getLocale.mjs.map +1 -1
  300. package/dist/esm/localization/getLocaleFromPath.mjs +1 -42
  301. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  302. package/dist/esm/localization/getLocaleLang.mjs +1 -18
  303. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  304. package/dist/esm/localization/getLocaleName.mjs +1 -9
  305. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  306. package/dist/esm/localization/getLocalizedUrl.mjs +1 -79
  307. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  308. package/dist/esm/localization/getMultilingualUrls.mjs +1 -60
  309. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  310. package/dist/esm/localization/getPathWithoutLocale.mjs +1 -52
  311. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  312. package/dist/esm/localization/getPrefix.mjs +1 -60
  313. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  314. package/dist/esm/localization/index.mjs +1 -17
  315. package/dist/esm/localization/localeDetector.mjs +1 -131
  316. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  317. package/dist/esm/localization/localeMapper.mjs +1 -114
  318. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  319. package/dist/esm/localization/localeResolver.mjs +1 -25
  320. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  321. package/dist/esm/localization/rewriteUtils.mjs +1 -104
  322. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  323. package/dist/esm/localization/validatePrefix.mjs +1 -51
  324. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  325. package/dist/esm/markdown/compiler.mjs +10 -786
  326. package/dist/esm/markdown/compiler.mjs.map +1 -1
  327. package/dist/esm/markdown/constants.mjs +1 -247
  328. package/dist/esm/markdown/constants.mjs.map +1 -1
  329. package/dist/esm/markdown/index.mjs +1 -7
  330. package/dist/esm/markdown/parser.mjs +1 -65
  331. package/dist/esm/markdown/parser.mjs.map +1 -1
  332. package/dist/esm/markdown/renderer.mjs +1 -59
  333. package/dist/esm/markdown/renderer.mjs.map +1 -1
  334. package/dist/esm/markdown/utils.mjs +6 -361
  335. package/dist/esm/markdown/utils.mjs.map +1 -1
  336. package/dist/esm/messageFormat/ICU.mjs +1 -316
  337. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  338. package/dist/esm/messageFormat/i18next.mjs +1 -327
  339. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  340. package/dist/esm/messageFormat/index.mjs +1 -5
  341. package/dist/esm/messageFormat/verify-icu-format.mjs +2 -64
  342. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  343. package/dist/esm/messageFormat/vue-i18n.mjs +1 -163
  344. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  345. package/dist/esm/transpiler/condition/condition.mjs +1 -24
  346. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  347. package/dist/esm/transpiler/condition/index.mjs +1 -3
  348. package/dist/esm/transpiler/enumeration/enumeration.mjs +1 -26
  349. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  350. package/dist/esm/transpiler/enumeration/index.mjs +1 -3
  351. package/dist/esm/transpiler/file/file.mjs +1 -49
  352. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  353. package/dist/esm/transpiler/file/fileBrowser.mjs +1 -24
  354. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  355. package/dist/esm/transpiler/file/index.mjs +1 -3
  356. package/dist/esm/transpiler/gender/gender.mjs +1 -24
  357. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  358. package/dist/esm/transpiler/gender/index.mjs +1 -3
  359. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -43
  360. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  361. package/dist/esm/transpiler/html/html.mjs +1 -35
  362. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  363. package/dist/esm/transpiler/html/htmlTags.mjs +1 -114
  364. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  365. package/dist/esm/transpiler/html/index.mjs +1 -4
  366. package/dist/esm/transpiler/index.mjs +1 -13
  367. package/dist/esm/transpiler/insertion/getInsertionValues.mjs +1 -9
  368. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  369. package/dist/esm/transpiler/insertion/index.mjs +1 -4
  370. package/dist/esm/transpiler/insertion/insertion.mjs +1 -34
  371. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  372. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs +2 -22
  373. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  374. package/dist/esm/transpiler/markdown/index.mjs +1 -4
  375. package/dist/esm/transpiler/markdown/markdown.mjs +1 -52
  376. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  377. package/dist/esm/transpiler/nesting/index.mjs +1 -3
  378. package/dist/esm/transpiler/nesting/nesting.mjs +1 -25
  379. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  380. package/dist/esm/transpiler/translation/index.mjs +1 -3
  381. package/dist/esm/transpiler/translation/translation.mjs +1 -27
  382. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  383. package/dist/esm/utils/checkIsURLAbsolute.mjs +1 -5
  384. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  385. package/dist/esm/utils/getCookie.mjs +1 -30
  386. package/dist/esm/utils/getCookie.mjs.map +1 -1
  387. package/dist/esm/utils/index.mjs +1 -0
  388. package/dist/esm/utils/intl.mjs +1 -86
  389. package/dist/esm/utils/intl.mjs.map +1 -1
  390. package/dist/esm/utils/isSameKeyPath.mjs +1 -5
  391. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  392. package/dist/esm/utils/isValidReactElement.mjs +1 -12
  393. package/dist/esm/utils/isValidReactElement.mjs.map +1 -1
  394. package/dist/esm/utils/localeStorage.mjs +1 -135
  395. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  396. package/dist/esm/utils/parseYaml.mjs +16 -320
  397. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  398. package/dist/types/formatters/index.d.ts +2 -1
  399. package/dist/types/index.d.ts +8 -2
  400. package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
  401. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  402. package/dist/types/localization/index.d.ts +2 -1
  403. package/dist/types/markdown/index.d.ts +4 -1
  404. package/dist/types/markdown/types.d.ts +1 -1
  405. package/dist/types/markdown/types.d.ts.map +1 -1
  406. package/dist/types/transpiler/translation/translation.d.ts +1 -1
  407. package/dist/types/utils/index.d.ts +8 -0
  408. package/package.json +65 -11
@@ -1,23 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/interpreter/getInsertion.ts
4
- /**
5
- * Allow to insert values in a string.
6
- *
7
- * Usage:
8
- *
9
- * ```ts
10
- * const content = getInsertion('Hello {{name}}!', {
11
- * name: 'John',
12
- * });
13
- * // 'Hello John!'
14
- * ```
15
- *
16
- */
17
- const getInsertion = (content, values) => content.replace(/\{\{\s*(.*?)\s*\}\}/g, (_, key) => {
18
- return (values[key.trim()] ?? "").toString();
19
- });
20
-
21
- //#endregion
22
- exports.getInsertion = getInsertion;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=(e,t)=>e.replace(/\{\{\s*(.*?)\s*\}\}/g,(e,n)=>(t[n.trim()]??``).toString());exports.getInsertion=e;
23
2
  //# sourceMappingURL=getInsertion.cjs.map
@@ -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,MAAM,KACC,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":"mEAeA,MAAa,GACX,EACA,IAEA,EAAQ,QAAQ,wBAAyB,EAAG,KAElC,EADW,EAAI,MAAM,GACC,IAAI,UAAU,CAC5C"}
@@ -1,41 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_interpreter_getDictionary = require('./getDictionary.cjs');
4
- let _intlayer_config_client = require("@intlayer/config/client");
5
- let _intlayer_config_built = require("@intlayer/config/built");
6
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
7
- let _intlayer_dictionaries_entry = require("@intlayer/dictionaries-entry");
8
-
9
- //#region src/interpreter/getIntlayer.ts
10
- /**
11
- * Creates a Recursive Proxy that returns the path of the accessed key
12
- * stringified. This prevents the app from crashing on undefined access.
13
- */
14
- const createSafeFallback = (path = "") => {
15
- return new Proxy(() => path, {
16
- get: (_target, prop) => {
17
- if (prop === "toJSON" || prop === Symbol.toPrimitive || prop === "toString") return () => path;
18
- if (prop === "then") return;
19
- return createSafeFallback(path ? `${path}.${String(prop)}` : String(prop));
20
- },
21
- apply: () => {
22
- return path;
23
- }
24
- });
25
- };
26
- const getIntlayer = (key, locale, plugins) => {
27
- const dictionary = (0, _intlayer_dictionaries_entry.getDictionaries)()[key];
28
- if (!dictionary) {
29
- (0, _intlayer_config_client.getAppLogger)(_intlayer_config_built.default)(`Dictionary ${(0, _intlayer_config_client.colorizeKey)(key)} was not found. Using fallback proxy.`, {
30
- level: "warn",
31
- isVerbose: true
32
- });
33
- if (process.env.NODE_ENV === "development") return createSafeFallback(key);
34
- return createSafeFallback(key);
35
- }
36
- return require_interpreter_getDictionary.getDictionary(dictionary, locale, plugins);
37
- };
38
-
39
- //#endregion
40
- exports.getIntlayer = getIntlayer;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./getDictionary.cjs`);let n=require(`@intlayer/config/client`),r=require(`@intlayer/config/built`);r=e.__toESM(r);let i=require(`@intlayer/dictionaries-entry`);const a=(e=``)=>new Proxy(()=>e,{get:(t,n)=>{if(n===`toJSON`||n===Symbol.toPrimitive||n===`toString`)return()=>e;if(n!==`then`)return a(e?`${e}.${String(n)}`:String(n))},apply:()=>e}),o=(e,o,s)=>{let c=(0,i.getDictionaries)()[e];return c?t.getDictionary(c,o,s):((0,n.getAppLogger)(r.default)(`Dictionary ${(0,n.colorizeKey)(e)} was not found. Using fallback proxy.`,{level:`warn`,isVerbose:!0}),process.env.NODE_ENV,a(e))};exports.getIntlayer=o;
41
2
  //# sourceMappingURL=getIntlayer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.cjs","names":["configuration","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["// packages/@intlayer/core/src/interpreter/getIntlayer.ts\n\nimport configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAM,sBAAsB,OAAO,OAAY;AAC7C,QAAO,IAAI,YAEH,MACN;EACE,MAAM,SAAS,SAAS;AAEtB,OACE,SAAS,YACT,SAAS,OAAO,eAChB,SAAS,WAET,cAAa;AAEf,OAAI,SAAS,OACX;AAKF,UAAO,mBADU,OAAO,GAAG,KAAK,GAAG,OAAO,KAAK,KAAK,OAAO,KAAK,CAC7B;;EAGrC,aAAa;AACX,UAAO;;EAEV,CACF;;AAGH,MAAa,eAIX,KACA,QACA,YAKG;CAEH,MAAM,gEADgC,CACN;AAEhC,KAAI,CAAC,YAAY;AAGf,4CAD4BA,+BAAc,CAExC,uDAA0B,IAAc,CAAC,wCACzC;GACE,OAAO;GACP,WAAW;GACZ,CACF;AAED,MAAI,QAAQ,IAAI,aAAa,cAG3B,QAAO,mBAAmB,IAAc;AAG1C,SAAO,mBAAmB,IAAc;;AAG1C,QAAOC,gDACL,YACA,QACA,QACD"}
1
+ {"version":3,"file":"getIntlayer.cjs","names":["configuration","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["// packages/@intlayer/core/src/interpreter/getIntlayer.ts\n\nimport configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/client';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":"mSAuBA,MAAM,GAAsB,EAAO,KAC1B,IAAI,UAEH,EACN,CACE,KAAM,EAAS,IAAS,CAEtB,GACE,IAAS,UACT,IAAS,OAAO,aAChB,IAAS,WAET,UAAa,EAEX,OAAS,OAMb,OAAO,EADU,EAAO,GAAG,EAAK,GAAG,OAAO,EAAK,GAAK,OAAO,EAAK,CAC7B,EAGrC,UACS,EAEV,CACF,CAGU,GAIX,EACA,EACA,IAKG,CAEH,IAAM,GAAA,EAAA,EAAA,kBADgC,CACN,GAsBhC,OApBK,EAoBEC,EAAAA,cACL,EACA,EACA,EACD,GArBC,EAAA,EAAA,cAD4BD,EAAAA,QAAc,CAExC,eAAA,EAAA,EAAA,aAA0B,EAAc,CAAC,uCACzC,CACE,MAAO,OACP,UAAW,GACZ,CACF,CAEG,QAAQ,IAAI,SAGP,EAAmB,EAAc"}
@@ -1,37 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_interpreter_getIntlayer = require('./getIntlayer.cjs');
3
-
4
- //#region src/interpreter/getNesting.ts
5
- /**
6
- * Extracts content from another dictionary by its key and an optional path.
7
- *
8
- * This allows for reusing content across different dictionaries.
9
- *
10
- * @param dictionaryKey - The key of the dictionary to nest.
11
- * @param path - Optional dot-separated path to a specific field within the nested dictionary.
12
- * @param props - Optional properties like locale and plugins.
13
- * @returns The nested content.
14
- *
15
- * @example
16
- * ```ts
17
- * const content = getNesting("common", "buttons.save");
18
- * // 'Save'
19
- * ```
20
- */
21
- const getNesting = (dictionaryKey, path, props) => {
22
- const dictionary = require_interpreter_getIntlayer.getIntlayer(dictionaryKey, props?.locale, props?.plugins);
23
- if (typeof path === "string") {
24
- const pathArray = path.split(".");
25
- let current = dictionary;
26
- for (const key of pathArray) {
27
- current = current?.[key];
28
- if (current === void 0) return dictionary;
29
- }
30
- return current;
31
- }
32
- return dictionary;
33
- };
34
-
35
- //#endregion
36
- exports.getNesting = getNesting;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getIntlayer.cjs`),t=(t,n,r)=>{let i=e.getIntlayer(t,r?.locale,r?.plugins);if(typeof n==`string`){let e=n.split(`.`),t=i;for(let n of e)if(t=t?.[n],t===void 0)return i;return t}return i};exports.getNesting=t;
37
2
  //# sourceMappingURL=getNesting.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getNesting.cjs","names":["getIntlayer"],"sources":["../../../src/interpreter/getNesting.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n} from '@intlayer/types';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,cACX,eACA,MACA,UAC2B;CAC3B,MAAM,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 {\n DictionaryKeys,\n DictionaryRegistryContent,\n GetSubPath,\n} from '@intlayer/types';\nimport type { ValidDotPathsFor } from '../transpiler';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n} from './getContent';\nimport { getIntlayer } from './getIntlayer';\n\nexport type GetNestingResult<\n K extends DictionaryKeys,\n P = undefined,\n S = IInterpreterPluginState,\n> = GetSubPath<DeepTransformContent<DictionaryRegistryContent<K>, S>, P>;\n\n/**\n * Extracts content from another dictionary by its key and an optional path.\n *\n * This allows for reusing content across different dictionaries.\n *\n * @param dictionaryKey - The key of the dictionary to nest.\n * @param path - Optional dot-separated path to a specific field within the nested dictionary.\n * @param props - Optional properties like locale and plugins.\n * @returns The nested content.\n *\n * @example\n * ```ts\n * const content = getNesting(\"common\", \"buttons.save\");\n * // 'Save'\n * ```\n */\nexport const getNesting = <K extends DictionaryKeys, P>(\n dictionaryKey: K,\n path?: P extends ValidDotPathsFor<K> ? P : never,\n props?: NodeProps\n): GetNestingResult<K, P> => {\n const dictionary = getIntlayer(dictionaryKey, props?.locale, props?.plugins);\n\n if (typeof path === 'string') {\n const pathArray = (path as string).split('.');\n let current: any = dictionary;\n\n for (const key of pathArray) {\n // Safely traverse down the object using the path\n current = current?.[key];\n // If we cannot find the path, return the whole dictionary as a fallback\n if (current === undefined) {\n return dictionary as any;\n }\n }\n\n return current;\n }\n\n // Default or error handling if path is not a string or otherwise undefined\n return dictionary as any;\n};\n"],"mappings":"wGAmCa,GACX,EACA,EACA,IAC2B,CAC3B,IAAM,EAAaA,EAAAA,YAAY,EAAe,GAAO,OAAQ,GAAO,QAAQ,CAE5E,GAAI,OAAO,GAAS,SAAU,CAC5B,IAAM,EAAa,EAAgB,MAAM,IAAI,CACzC,EAAe,EAEnB,IAAK,IAAM,KAAO,EAIhB,GAFA,EAAU,IAAU,GAEhB,IAAY,IAAA,GACd,OAAO,EAIX,OAAO,EAIT,OAAO"}
@@ -1,113 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/interpreter/getTranslation.ts
4
- /**
5
- * Check if a value is a plain object that can be safely processed.
6
- * Returns false for Promises, React elements, class instances, etc.
7
- */
8
- const isPlainObject = (value) => {
9
- if (value === null || typeof value !== "object") return false;
10
- if (value instanceof Promise || typeof value.then === "function") return false;
11
- if (value.$$typeof !== void 0 || value.__v_isVNode !== void 0 || value._isVNode !== void 0 || value.isJSX !== void 0) return false;
12
- const proto = Object.getPrototypeOf(value);
13
- return proto === Object.prototype || proto === null || Array.isArray(value);
14
- };
15
- /**
16
- * Recursively merges two objects.
17
- * Resembles the behavior of `defu` but respects `isPlainObject` to avoid merging React elements.
18
- * Arrays are replaced, not merged.
19
- */
20
- const deepMergeObjects = (target, source) => {
21
- if (target === void 0) return source;
22
- if (source === void 0) return target;
23
- if (Array.isArray(target)) return target;
24
- if (isPlainObject(target) && isPlainObject(source)) {
25
- const result = { ...target };
26
- for (const key of Object.keys(source)) {
27
- if (key === "__proto__" || key === "constructor") continue;
28
- if (Object.hasOwn(target, key)) result[key] = deepMergeObjects(target[key], source[key]);
29
- else result[key] = source[key];
30
- }
31
- return result;
32
- }
33
- return target;
34
- };
35
- /**
36
- * Recursively removes undefined values from an object.
37
- * Handles circular references by tracking visited objects.
38
- */
39
- const removeUndefinedValues = (object, visited = /* @__PURE__ */ new WeakSet()) => {
40
- if (typeof object !== "object" || object === null) return object;
41
- if (visited.has(object)) return object;
42
- visited.add(object);
43
- if (!isPlainObject(object)) return object;
44
- if (Array.isArray(object)) return object.map((item) => removeUndefinedValues(item, visited));
45
- const result = {};
46
- for (const [key, value] of Object.entries(object)) if (value !== void 0) result[key] = removeUndefinedValues(value, visited);
47
- return result;
48
- };
49
- /**
50
- * Picks the appropriate content from a locale map based on the provided locale.
51
- *
52
- * It handles:
53
- * 1. Exact locale match (e.g., 'en-US').
54
- * 2. Generic locale fallback (e.g., 'en' if 'en-US' is not found).
55
- * 3. Explicit fallback locale.
56
- * 4. Deep merging of objects to ensure partial translations are complemented by fallbacks.
57
- *
58
- * @param languageContent - A map of locales to content.
59
- * @param locale - The target locale to retrieve.
60
- * @param fallback - Optional fallback locale if the target is not found.
61
- * @returns The translated content.
62
- *
63
- * @example
64
- * ```ts
65
- * const content = getTranslation({
66
- * en: 'Hello',
67
- * fr: 'Bonjour',
68
- * }, 'fr');
69
- * // 'Bonjour'
70
- * ```
71
- */
72
- const getTranslation = (languageContent, locale, fallback) => {
73
- const results = [];
74
- const getContent = (loc) => languageContent[loc];
75
- const content = getContent(locale);
76
- if (typeof content === "string") return content;
77
- else if (content !== void 0) results.push(content);
78
- if (locale.includes("-")) {
79
- const genericLocale = locale.split("-")[0];
80
- if (genericLocale in languageContent) {
81
- const genericContent = getContent(genericLocale);
82
- if (typeof genericContent === "string") {
83
- if (results.length === 0) return genericContent;
84
- } else if (genericContent !== void 0) results.push(genericContent);
85
- }
86
- }
87
- if (fallback !== void 0 && fallback !== locale) {
88
- if (fallback in languageContent) {
89
- const fallbackContent = getContent(fallback);
90
- if (typeof fallbackContent === "string") {
91
- if (results.length === 0) return fallbackContent;
92
- } else if (fallbackContent !== void 0) results.push(fallbackContent);
93
- }
94
- if (fallback.includes("-")) {
95
- const genericFallback = fallback.split("-")[0];
96
- if (genericFallback !== locale.split("-")[0] && genericFallback in languageContent) {
97
- const genericFallbackContent = getContent(genericFallback);
98
- if (typeof genericFallbackContent === "string") {
99
- if (results.length === 0) return genericFallbackContent;
100
- } else if (genericFallbackContent !== void 0) results.push(genericFallbackContent);
101
- }
102
- }
103
- }
104
- if (results.length === 0) return;
105
- const cleanResults = results.filter((item) => typeof item !== "undefined").map((item) => removeUndefinedValues(item));
106
- if (cleanResults.length === 1) return cleanResults[0];
107
- if (Array.isArray(cleanResults[0])) return cleanResults[0];
108
- return cleanResults.reduce((acc, curr) => deepMergeObjects(acc, curr));
109
- };
110
-
111
- //#endregion
112
- exports.getTranslation = getTranslation;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{if(typeof e!=`object`||!e||e instanceof Promise||typeof e.then==`function`||e.$$typeof!==void 0||e.__v_isVNode!==void 0||e._isVNode!==void 0||e.isJSX!==void 0)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Array.isArray(e)},t=(n,r)=>{if(n===void 0)return r;if(r===void 0||Array.isArray(n))return n;if(e(n)&&e(r)){let e={...n};for(let i of Object.keys(r))i===`__proto__`||i===`constructor`||(Object.hasOwn(n,i)?e[i]=t(n[i],r[i]):e[i]=r[i]);return e}return n},n=(t,r=new WeakSet)=>{if(typeof t!=`object`||!t||r.has(t)||(r.add(t),!e(t)))return t;if(Array.isArray(t))return t.map(e=>n(e,r));let i={};for(let[e,a]of Object.entries(t))a!==void 0&&(i[e]=n(a,r));return i},r=(e,r,i)=>{let a=[],o=t=>e[t],s=o(r);if(typeof s==`string`)return s;if(s!==void 0&&a.push(s),r.includes(`-`)){let t=r.split(`-`)[0];if(t in e){let e=o(t);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}}if(i!==void 0&&i!==r){if(i in e){let e=o(i);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}if(i.includes(`-`)){let t=i.split(`-`)[0];if(t!==r.split(`-`)[0]&&t in e){let e=o(t);if(typeof e==`string`){if(a.length===0)return e}else e!==void 0&&a.push(e)}}}if(a.length===0)return;let c=a.filter(e=>e!==void 0).map(e=>n(e));return c.length===1||Array.isArray(c[0])?c[0]:c.reduce((e,n)=>t(e,n))};exports.getTranslation=r;
113
2
  //# sourceMappingURL=getTranslation.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getTranslation.cjs","names":[],"sources":["../../../src/interpreter/getTranslation.ts"],"sourcesContent":["import type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\n\n/**\n * Check if a value is a plain object that can be safely processed.\n * Returns false for Promises, React elements, class instances, etc.\n */\nconst isPlainObject = (value: unknown): boolean => {\n if (value === null || typeof value !== 'object') {\n return false;\n }\n\n // Don't process Promises (e.g., Next.js 15+ params)\n if (value instanceof Promise || typeof (value as any).then === 'function') {\n return false;\n }\n\n // Don't process React elements or other framework VNodes\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\n // Only process plain objects and arrays\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null || Array.isArray(value);\n};\n\n/**\n * Recursively merges two objects.\n * Resembles the behavior of `defu` but respects `isPlainObject` to avoid merging React elements.\n * Arrays are replaced, not merged.\n */\nconst deepMergeObjects = (target: any, source: any): any => {\n if (target === undefined) return source;\n if (source === undefined) return target;\n\n if (Array.isArray(target)) return target;\n\n if (isPlainObject(target) && isPlainObject(source)) {\n const result = { ...target };\n for (const key of Object.keys(source)) {\n if (key === '__proto__' || key === 'constructor') continue;\n\n if (Object.hasOwn(target, key)) {\n result[key] = deepMergeObjects(target[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n }\n\n return target;\n};\n\n/**\n * Recursively removes undefined values from an object.\n * Handles circular references by tracking visited objects.\n */\nconst removeUndefinedValues = <T>(\n object: T,\n visited = new WeakSet<object>()\n): T => {\n if (typeof object !== 'object' || object === null) {\n return object;\n }\n\n // Handle circular references - return original to avoid infinite recursion\n if (visited.has(object)) {\n return object;\n }\n visited.add(object);\n\n // Don't process non-plain objects (Promises, React elements, etc.)\n if (!isPlainObject(object)) {\n return object;\n }\n\n if (Array.isArray(object)) {\n return object.map((item) => removeUndefinedValues(item, visited)) as T;\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(object)) {\n if (value !== undefined) {\n result[key] = removeUndefinedValues(value, visited);\n }\n }\n return result as T;\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 = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>,\n locale: LocalesValues,\n fallback?: LocalesValues\n): Content => {\n const results: Content[] = [];\n\n const getContent = (loc: string) =>\n languageContent[loc as keyof typeof languageContent];\n\n // Get Target Content\n const content = getContent(locale);\n if (typeof content === 'string') {\n return content;\n } else if (content !== undefined) {\n results.push(content);\n }\n\n // Get Target Generic Content (e.g. 'en' from 'en-US')\n if (locale.includes('-')) {\n const genericLocale = locale.split('-')[0];\n if (genericLocale in languageContent) {\n const genericContent = getContent(genericLocale);\n\n if (typeof genericContent === 'string') {\n // If we haven't found specific content yet, return generic string\n if (results.length === 0) return genericContent;\n } else if (genericContent !== undefined) {\n results.push(genericContent);\n }\n }\n }\n\n // Get Fallback Content\n if (fallback !== undefined && fallback !== locale) {\n // 3a. Fallback Specific\n if (fallback in languageContent) {\n const fallbackContent = getContent(fallback);\n\n if (typeof fallbackContent === 'string') {\n if (results.length === 0) return fallbackContent;\n } else if (fallbackContent !== undefined) {\n results.push(fallbackContent);\n }\n }\n\n // Fallback Generic (The missing piece: e.g. 'en' from 'en-GB' fallback)\n if (fallback.includes('-')) {\n const genericFallback = fallback.split('-')[0];\n const genericLocale = locale.split('-')[0];\n\n // Only add if it's different from the target generic (to avoid duplication)\n // and exists in the dictionary\n if (\n genericFallback !== genericLocale &&\n genericFallback in languageContent\n ) {\n const genericFallbackContent = getContent(genericFallback);\n\n if (typeof genericFallbackContent === 'string') {\n if (results.length === 0) return genericFallbackContent;\n } else if (genericFallbackContent !== undefined) {\n results.push(genericFallbackContent);\n }\n }\n }\n }\n\n if (results.length === 0) {\n return undefined as Content;\n }\n\n // Clean undefined values so they don't overwrite fallbacks\n // Order: [Target, Generic, Fallback, FallbackGeneric]\n // defu first argument takes precedence, so Target wins\n const cleanResults = results\n .filter((item) => typeof item !== 'undefined')\n .map((item) => removeUndefinedValues(item));\n\n // If only one result, return it directly (no merging needed)\n if (cleanResults.length === 1) {\n return cleanResults[0];\n }\n\n // If the first result is an array, return it directly (arrays replace, don't merge)\n // defu would incorrectly convert arrays to objects with numeric keys\n if (Array.isArray(cleanResults[0])) {\n return cleanResults[0];\n }\n\n // Merge objects with custom merge - first argument takes precedence\n // Cast to object[] since by this point we've already returned early for strings, arrays, and single results\n return (cleanResults as object[]).reduce((acc, curr) =>\n deepMergeObjects(acc, curr)\n ) as Content;\n};\n"],"mappings":";;;;;;;AAMA,MAAM,iBAAiB,UAA4B;AACjD,KAAI,UAAU,QAAQ,OAAO,UAAU,SACrC,QAAO;AAIT,KAAI,iBAAiB,WAAW,OAAQ,MAAc,SAAS,WAC7D,QAAO;AAIT,KACG,MAAc,aAAa,UAC3B,MAAc,gBAAgB,UAC9B,MAAc,aAAa,UAC3B,MAAc,UAAU,OAEzB,QAAO;CAIT,MAAM,QAAQ,OAAO,eAAe,MAAM;AAC1C,QAAO,UAAU,OAAO,aAAa,UAAU,QAAQ,MAAM,QAAQ,MAAM;;;;;;;AAQ7E,MAAM,oBAAoB,QAAa,WAAqB;AAC1D,KAAI,WAAW,OAAW,QAAO;AACjC,KAAI,WAAW,OAAW,QAAO;AAEjC,KAAI,MAAM,QAAQ,OAAO,CAAE,QAAO;AAElC,KAAI,cAAc,OAAO,IAAI,cAAc,OAAO,EAAE;EAClD,MAAM,SAAS,EAAE,GAAG,QAAQ;AAC5B,OAAK,MAAM,OAAO,OAAO,KAAK,OAAO,EAAE;AACrC,OAAI,QAAQ,eAAe,QAAQ,cAAe;AAElD,OAAI,OAAO,OAAO,QAAQ,IAAI,CAC5B,QAAO,OAAO,iBAAiB,OAAO,MAAM,OAAO,KAAK;OAExD,QAAO,OAAO,OAAO;;AAGzB,SAAO;;AAGT,QAAO;;;;;;AAOT,MAAM,yBACJ,QACA,0BAAU,IAAI,SAAiB,KACzB;AACN,KAAI,OAAO,WAAW,YAAY,WAAW,KAC3C,QAAO;AAIT,KAAI,QAAQ,IAAI,OAAO,CACrB,QAAO;AAET,SAAQ,IAAI,OAAO;AAGnB,KAAI,CAAC,cAAc,OAAO,CACxB,QAAO;AAGT,KAAI,MAAM,QAAQ,OAAO,CACvB,QAAO,OAAO,KAAK,SAAS,sBAAsB,MAAM,QAAQ,CAAC;CAGnE,MAAM,SAAkC,EAAE;AAC1C,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,OAAO,CAC/C,KAAI,UAAU,OACZ,QAAO,OAAO,sBAAsB,OAAO,QAAQ;AAGvD,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;AA0BT,MAAa,kBACX,iBACA,QACA,aACY;CACZ,MAAM,UAAqB,EAAE;CAE7B,MAAM,cAAc,QAClB,gBAAgB;CAGlB,MAAM,UAAU,WAAW,OAAO;AAClC,KAAI,OAAO,YAAY,SACrB,QAAO;UACE,YAAY,OACrB,SAAQ,KAAK,QAAQ;AAIvB,KAAI,OAAO,SAAS,IAAI,EAAE;EACxB,MAAM,gBAAgB,OAAO,MAAM,IAAI,CAAC;AACxC,MAAI,iBAAiB,iBAAiB;GACpC,MAAM,iBAAiB,WAAW,cAAc;AAEhD,OAAI,OAAO,mBAAmB,UAE5B;QAAI,QAAQ,WAAW,EAAG,QAAO;cACxB,mBAAmB,OAC5B,SAAQ,KAAK,eAAe;;;AAMlC,KAAI,aAAa,UAAa,aAAa,QAAQ;AAEjD,MAAI,YAAY,iBAAiB;GAC/B,MAAM,kBAAkB,WAAW,SAAS;AAE5C,OAAI,OAAO,oBAAoB,UAC7B;QAAI,QAAQ,WAAW,EAAG,QAAO;cACxB,oBAAoB,OAC7B,SAAQ,KAAK,gBAAgB;;AAKjC,MAAI,SAAS,SAAS,IAAI,EAAE;GAC1B,MAAM,kBAAkB,SAAS,MAAM,IAAI,CAAC;AAK5C,OACE,oBALoB,OAAO,MAAM,IAAI,CAAC,MAMtC,mBAAmB,iBACnB;IACA,MAAM,yBAAyB,WAAW,gBAAgB;AAE1D,QAAI,OAAO,2BAA2B,UACpC;SAAI,QAAQ,WAAW,EAAG,QAAO;eACxB,2BAA2B,OACpC,SAAQ,KAAK,uBAAuB;;;;AAM5C,KAAI,QAAQ,WAAW,EACrB;CAMF,MAAM,eAAe,QAClB,QAAQ,SAAS,OAAO,SAAS,YAAY,CAC7C,KAAK,SAAS,sBAAsB,KAAK,CAAC;AAG7C,KAAI,aAAa,WAAW,EAC1B,QAAO,aAAa;AAKtB,KAAI,MAAM,QAAQ,aAAa,GAAG,CAChC,QAAO,aAAa;AAKtB,QAAQ,aAA0B,QAAQ,KAAK,SAC7C,iBAAiB,KAAK,KAAK,CAC5B"}
1
+ {"version":3,"file":"getTranslation.cjs","names":[],"sources":["../../../src/interpreter/getTranslation.ts"],"sourcesContent":["import type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types';\n\n/**\n * Check if a value is a plain object that can be safely processed.\n * Returns false for Promises, React elements, class instances, etc.\n */\nconst isPlainObject = (value: unknown): boolean => {\n if (value === null || typeof value !== 'object') {\n return false;\n }\n\n // Don't process Promises (e.g., Next.js 15+ params)\n if (value instanceof Promise || typeof (value as any).then === 'function') {\n return false;\n }\n\n // Don't process React elements or other framework VNodes\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\n // Only process plain objects and arrays\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null || Array.isArray(value);\n};\n\n/**\n * Recursively merges two objects.\n * Resembles the behavior of `defu` but respects `isPlainObject` to avoid merging React elements.\n * Arrays are replaced, not merged.\n */\nconst deepMergeObjects = (target: any, source: any): any => {\n if (target === undefined) return source;\n if (source === undefined) return target;\n\n if (Array.isArray(target)) return target;\n\n if (isPlainObject(target) && isPlainObject(source)) {\n const result = { ...target };\n for (const key of Object.keys(source)) {\n if (key === '__proto__' || key === 'constructor') continue;\n\n if (Object.hasOwn(target, key)) {\n result[key] = deepMergeObjects(target[key], source[key]);\n } else {\n result[key] = source[key];\n }\n }\n return result;\n }\n\n return target;\n};\n\n/**\n * Recursively removes undefined values from an object.\n * Handles circular references by tracking visited objects.\n */\nconst removeUndefinedValues = <T>(\n object: T,\n visited = new WeakSet<object>()\n): T => {\n if (typeof object !== 'object' || object === null) {\n return object;\n }\n\n // Handle circular references - return original to avoid infinite recursion\n if (visited.has(object)) {\n return object;\n }\n visited.add(object);\n\n // Don't process non-plain objects (Promises, React elements, etc.)\n if (!isPlainObject(object)) {\n return object;\n }\n\n if (Array.isArray(object)) {\n return object.map((item) => removeUndefinedValues(item, visited)) as T;\n }\n\n const result: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(object)) {\n if (value !== undefined) {\n result[key] = removeUndefinedValues(value, visited);\n }\n }\n return result as T;\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 = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>,\n locale: LocalesValues,\n fallback?: LocalesValues\n): Content => {\n const results: Content[] = [];\n\n const getContent = (loc: string) =>\n languageContent[loc as keyof typeof languageContent];\n\n // Get Target Content\n const content = getContent(locale);\n if (typeof content === 'string') {\n return content;\n } else if (content !== undefined) {\n results.push(content);\n }\n\n // Get Target Generic Content (e.g. 'en' from 'en-US')\n if (locale.includes('-')) {\n const genericLocale = locale.split('-')[0];\n if (genericLocale in languageContent) {\n const genericContent = getContent(genericLocale);\n\n if (typeof genericContent === 'string') {\n // If we haven't found specific content yet, return generic string\n if (results.length === 0) return genericContent;\n } else if (genericContent !== undefined) {\n results.push(genericContent);\n }\n }\n }\n\n // Get Fallback Content\n if (fallback !== undefined && fallback !== locale) {\n // 3a. Fallback Specific\n if (fallback in languageContent) {\n const fallbackContent = getContent(fallback);\n\n if (typeof fallbackContent === 'string') {\n if (results.length === 0) return fallbackContent;\n } else if (fallbackContent !== undefined) {\n results.push(fallbackContent);\n }\n }\n\n // Fallback Generic (The missing piece: e.g. 'en' from 'en-GB' fallback)\n if (fallback.includes('-')) {\n const genericFallback = fallback.split('-')[0];\n const genericLocale = locale.split('-')[0];\n\n // Only add if it's different from the target generic (to avoid duplication)\n // and exists in the dictionary\n if (\n genericFallback !== genericLocale &&\n genericFallback in languageContent\n ) {\n const genericFallbackContent = getContent(genericFallback);\n\n if (typeof genericFallbackContent === 'string') {\n if (results.length === 0) return genericFallbackContent;\n } else if (genericFallbackContent !== undefined) {\n results.push(genericFallbackContent);\n }\n }\n }\n }\n\n if (results.length === 0) {\n return undefined as Content;\n }\n\n // Clean undefined values so they don't overwrite fallbacks\n // Order: [Target, Generic, Fallback, FallbackGeneric]\n // defu first argument takes precedence, so Target wins\n const cleanResults = results\n .filter((item) => typeof item !== 'undefined')\n .map((item) => removeUndefinedValues(item));\n\n // If only one result, return it directly (no merging needed)\n if (cleanResults.length === 1) {\n return cleanResults[0];\n }\n\n // If the first result is an array, return it directly (arrays replace, don't merge)\n // defu would incorrectly convert arrays to objects with numeric keys\n if (Array.isArray(cleanResults[0])) {\n return cleanResults[0];\n }\n\n // Merge objects with custom merge - first argument takes precedence\n // Cast to object[] since by this point we've already returned early for strings, arrays, and single results\n return (cleanResults as object[]).reduce((acc, curr) =>\n deepMergeObjects(acc, curr)\n ) as Content;\n};\n"],"mappings":"mEAMA,MAAM,EAAiB,GAA4B,CAWjD,GAVsB,OAAO,GAAU,WAAnC,GAKA,aAAiB,SAAW,OAAQ,EAAc,MAAS,YAM5D,EAAc,WAAa,IAAA,IAC3B,EAAc,cAAgB,IAAA,IAC9B,EAAc,WAAa,IAAA,IAC3B,EAAc,QAAU,IAAA,GAEzB,MAAO,GAIT,IAAM,EAAQ,OAAO,eAAe,EAAM,CAC1C,OAAO,IAAU,OAAO,WAAa,IAAU,MAAQ,MAAM,QAAQ,EAAM,EAQvE,GAAoB,EAAa,IAAqB,CAC1D,GAAI,IAAW,IAAA,GAAW,OAAO,EAGjC,GAFI,IAAW,IAAA,IAEX,MAAM,QAAQ,EAAO,CAAE,OAAO,EAElC,GAAI,EAAc,EAAO,EAAI,EAAc,EAAO,CAAE,CAClD,IAAM,EAAS,CAAE,GAAG,EAAQ,CAC5B,IAAK,IAAM,KAAO,OAAO,KAAK,EAAO,CAC/B,IAAQ,aAAe,IAAQ,gBAE/B,OAAO,OAAO,EAAQ,EAAI,CAC5B,EAAO,GAAO,EAAiB,EAAO,GAAM,EAAO,GAAK,CAExD,EAAO,GAAO,EAAO,IAGzB,OAAO,EAGT,OAAO,GAOH,GACJ,EACA,EAAU,IAAI,UACR,CAYN,GAXI,OAAO,GAAW,WAAY,GAK9B,EAAQ,IAAI,EAAO,GAGvB,EAAQ,IAAI,EAAO,CAGf,CAAC,EAAc,EAAO,EACxB,OAAO,EAGT,GAAI,MAAM,QAAQ,EAAO,CACvB,OAAO,EAAO,IAAK,GAAS,EAAsB,EAAM,EAAQ,CAAC,CAGnE,IAAM,EAAkC,EAAE,CAC1C,IAAK,GAAM,CAAC,EAAK,KAAU,OAAO,QAAQ,EAAO,CAC3C,IAAU,IAAA,KACZ,EAAO,GAAO,EAAsB,EAAO,EAAQ,EAGvD,OAAO,GA0BI,GACX,EACA,EACA,IACY,CACZ,IAAM,EAAqB,EAAE,CAEvB,EAAc,GAClB,EAAgB,GAGZ,EAAU,EAAW,EAAO,CAClC,GAAI,OAAO,GAAY,SACrB,OAAO,EAMT,GALW,IAAY,IAAA,IACrB,EAAQ,KAAK,EAAQ,CAInB,EAAO,SAAS,IAAI,CAAE,CACxB,IAAM,EAAgB,EAAO,MAAM,IAAI,CAAC,GACxC,GAAI,KAAiB,EAAiB,CACpC,IAAM,EAAiB,EAAW,EAAc,CAEhD,GAAI,OAAO,GAAmB,aAExB,EAAQ,SAAW,EAAG,OAAO,OACxB,IAAmB,IAAA,IAC5B,EAAQ,KAAK,EAAe,EAMlC,GAAI,IAAa,IAAA,IAAa,IAAa,EAAQ,CAEjD,GAAI,KAAY,EAAiB,CAC/B,IAAM,EAAkB,EAAW,EAAS,CAE5C,GAAI,OAAO,GAAoB,aACzB,EAAQ,SAAW,EAAG,OAAO,OACxB,IAAoB,IAAA,IAC7B,EAAQ,KAAK,EAAgB,CAKjC,GAAI,EAAS,SAAS,IAAI,CAAE,CAC1B,IAAM,EAAkB,EAAS,MAAM,IAAI,CAAC,GAK5C,GACE,IALoB,EAAO,MAAM,IAAI,CAAC,IAMtC,KAAmB,EACnB,CACA,IAAM,EAAyB,EAAW,EAAgB,CAE1D,GAAI,OAAO,GAA2B,aAChC,EAAQ,SAAW,EAAG,OAAO,OACxB,IAA2B,IAAA,IACpC,EAAQ,KAAK,EAAuB,GAM5C,GAAI,EAAQ,SAAW,EACrB,OAMF,IAAM,EAAe,EAClB,OAAQ,GAAgB,IAAS,OAAY,CAC7C,IAAK,GAAS,EAAsB,EAAK,CAAC,CAe7C,OAZI,EAAa,SAAW,GAMxB,MAAM,QAAQ,EAAa,GAAG,CACzB,EAAa,GAKd,EAA0B,QAAQ,EAAK,IAC7C,EAAiB,EAAK,EAAK,CAC5B"}
@@ -1,31 +1 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_interpreter_getCondition = require('./getCondition.cjs');
3
- const require_interpreter_getContent_deepTransform = require('./getContent/deepTransform.cjs');
4
- const require_interpreter_getEnumeration = require('./getEnumeration.cjs');
5
- const require_interpreter_getDictionary = require('./getDictionary.cjs');
6
- const require_interpreter_getIntlayer = require('./getIntlayer.cjs');
7
- const require_interpreter_getNesting = require('./getNesting.cjs');
8
- const require_interpreter_getTranslation = require('./getTranslation.cjs');
9
- const require_interpreter_getContent_plugins = require('./getContent/plugins.cjs');
10
- const require_interpreter_getContent_getContent = require('./getContent/getContent.cjs');
11
- const require_interpreter_getHTML = require('./getHTML.cjs');
12
- const require_interpreter_splitAndJoinInsertion = require('./splitAndJoinInsertion.cjs');
13
-
14
- exports.conditionPlugin = require_interpreter_getContent_plugins.conditionPlugin;
15
- exports.deepTransformNode = require_interpreter_getContent_deepTransform.deepTransformNode;
16
- exports.enumerationPlugin = require_interpreter_getContent_plugins.enumerationPlugin;
17
- exports.filePlugin = require_interpreter_getContent_plugins.filePlugin;
18
- exports.findMatchingCondition = require_interpreter_getEnumeration.findMatchingCondition;
19
- exports.genderPlugin = require_interpreter_getContent_plugins.genderPlugin;
20
- exports.getCondition = require_interpreter_getCondition.getCondition;
21
- exports.getContent = require_interpreter_getContent_getContent.getContent;
22
- exports.getDictionary = require_interpreter_getDictionary.getDictionary;
23
- exports.getEnumeration = require_interpreter_getEnumeration.getEnumeration;
24
- exports.getHTML = require_interpreter_getHTML.getHTML;
25
- exports.getIntlayer = require_interpreter_getIntlayer.getIntlayer;
26
- exports.getNesting = require_interpreter_getNesting.getNesting;
27
- exports.getTranslation = require_interpreter_getTranslation.getTranslation;
28
- exports.insertionPlugin = require_interpreter_getContent_plugins.insertionPlugin;
29
- exports.nestedPlugin = require_interpreter_getContent_plugins.nestedPlugin;
30
- exports.splitInsertionTemplate = require_interpreter_splitAndJoinInsertion.splitInsertionTemplate;
31
- exports.translationPlugin = require_interpreter_getContent_plugins.translationPlugin;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getCondition.cjs`),t=require(`./getContent/deepTransform.cjs`),n=require(`./getEnumeration.cjs`),r=require(`./getDictionary.cjs`),i=require(`./getIntlayer.cjs`),a=require(`./getNesting.cjs`),o=require(`./getTranslation.cjs`),s=require(`./getContent/plugins.cjs`),c=require(`./getContent/getContent.cjs`),l=require(`./getHTML.cjs`),u=require(`./splitAndJoinInsertion.cjs`);exports.conditionPlugin=s.conditionPlugin,exports.deepTransformNode=t.deepTransformNode,exports.enumerationPlugin=s.enumerationPlugin,exports.filePlugin=s.filePlugin,exports.findMatchingCondition=n.findMatchingCondition,exports.genderPlugin=s.genderPlugin,exports.getCondition=e.getCondition,exports.getContent=c.getContent,exports.getDictionary=r.getDictionary,exports.getEnumeration=n.getEnumeration,exports.getHTML=l.getHTML,exports.getIntlayer=i.getIntlayer,exports.getNesting=a.getNesting,exports.getTranslation=o.getTranslation,exports.insertionPlugin=s.insertionPlugin,exports.nestedPlugin=s.nestedPlugin,exports.splitInsertionTemplate=u.splitInsertionTemplate,exports.translationPlugin=s.translationPlugin;
@@ -1,56 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- //#region src/interpreter/splitAndJoinInsertion.ts
4
- /**
5
- * Check if a value is a complex object (not a primitive)
6
- * Used to determine if values need to be wrapped in fragments
7
- */
8
- const isComplexValue = (value) => {
9
- return value !== null && value !== void 0 && typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean";
10
- };
11
- /**
12
- * Core logic for splitting insertion strings and joining with values.
13
- * Returns an array of parts that can be wrapped by framework-specific Fragment implementations.
14
- *
15
- * @param template - The template string with {{ placeholder }} syntax
16
- * @param values - Map of placeholder names to their replacement values
17
- * @returns Object with `isSimple` flag and `parts` array
18
- *
19
- * @example
20
- * ```ts
21
- * const result = splitInsertionTemplate('Hello {{ name }}!', { name: 'World' });
22
- * // { isSimple: true, parts: 'Hello World!' }
23
- *
24
- * const result = splitInsertionTemplate('Hello {{ name }}!', { name: <Component /> });
25
- * // { isSimple: false, parts: ['Hello ', <Component />, '!'] }
26
- * ```
27
- */
28
- const splitInsertionTemplate = (template, values = {}) => {
29
- const safeValues = values ?? {};
30
- if (!Object.values(safeValues).some(isComplexValue)) return {
31
- isSimple: true,
32
- parts: template.replace(/\{\{\s*(.*?)\s*\}\}/g, (_, key) => {
33
- return (safeValues[key.trim()] ?? "").toString();
34
- })
35
- };
36
- const parts = [];
37
- let lastIndex = 0;
38
- const regex = /\{\{\s*(.*?)\s*\}\}/g;
39
- let match = regex.exec(template);
40
- while (match !== null) {
41
- if (match.index > lastIndex) parts.push(template.substring(lastIndex, match.index));
42
- const value = safeValues[match[1].trim()];
43
- if (value !== void 0 && value !== null) parts.push(value);
44
- lastIndex = match.index + match[0].length;
45
- match = regex.exec(template);
46
- }
47
- if (lastIndex < template.length) parts.push(template.substring(lastIndex));
48
- return {
49
- isSimple: false,
50
- parts
51
- };
52
- };
53
-
54
- //#endregion
55
- exports.splitInsertionTemplate = splitInsertionTemplate;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>e!=null&&typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`,t=(t,n={})=>{let r=n??{};if(!Object.values(r).some(e))return{isSimple:!0,parts:t.replace(/\{\{\s*(.*?)\s*\}\}/g,(e,t)=>(r[t.trim()]??``).toString())};let i=[],a=0,o=/\{\{\s*(.*?)\s*\}\}/g,s=o.exec(t);for(;s!==null;){s.index>a&&i.push(t.substring(a,s.index));let e=r[s[1].trim()];e!=null&&i.push(e),a=s.index+s[0].length,s=o.exec(t)}return a<t.length&&i.push(t.substring(a)),{isSimple:!1,parts:i}};exports.splitInsertionTemplate=t;
56
2
  //# sourceMappingURL=splitAndJoinInsertion.cjs.map
@@ -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 return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Core logic for splitting insertion strings and joining with values.\n * Returns an array of parts that can be wrapped by framework-specific Fragment implementations.\n *\n * @param template - The template string with {{ placeholder }} syntax\n * @param values - Map of placeholder names to their replacement values\n * @returns Object with `isSimple` flag and `parts` array\n *\n * @example\n * ```ts\n * const result = splitInsertionTemplate('Hello {{ name }}!', { name: 'World' });\n * // { isSimple: true, parts: 'Hello World!' }\n *\n * const result = splitInsertionTemplate('Hello {{ name }}!', { name: <Component /> });\n * // { isSimple: false, parts: ['Hello ', <Component />, '!'] }\n * ```\n */\nexport const splitInsertionTemplate = <T = any>(\n template: string,\n values: Record<string, T> = {}\n): { isSimple: boolean; parts: string | T[] } => {\n const safeValues = values ?? {};\n\n // Check if any value is a complex object (React/Vue node, etc.)\n const hasComplexValue = Object.values(safeValues).some(isComplexValue);\n\n if (!hasComplexValue) {\n // Simple string replacement\n const result = template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (safeValues[trimmedKey] ?? '').toString();\n });\n return { isSimple: true, parts: result };\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: any[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = safeValues[key];\n if (value !== undefined && value !== null) {\n parts.push(value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n return { isSimple: false, parts };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,kBAAkB,UAAwB;AAC9C,QACE,UAAU,QACV,UAAU,UACV,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;;;;;;;;;;;;;;;;;;;AAqBrB,MAAa,0BACX,UACA,SAA4B,EAAE,KACiB;CAC/C,MAAM,aAAa,UAAU,EAAE;AAK/B,KAAI,CAFoB,OAAO,OAAO,WAAW,CAAC,KAAK,eAAe,CAQpE,QAAO;EAAE,UAAU;EAAM,OAJV,SAAS,QAAQ,yBAAyB,GAAG,QAAQ;AAElE,WAAQ,WADW,IAAI,MAAM,KACK,IAAI,UAAU;IAChD;EACsC;CAI1C,MAAM,QAAe,EAAE;CACvB,IAAI,YAAY;CAChB,MAAM,QAAQ;CACd,IAAI,QAAgC,MAAM,KAAK,SAAS;AAExD,QAAO,UAAU,MAAM;AAErB,MAAI,MAAM,QAAQ,UAChB,OAAM,KAAK,SAAS,UAAU,WAAW,MAAM,MAAM,CAAC;EAKxD,MAAM,QAAQ,WADF,MAAM,GAAG,MAAM;AAE3B,MAAI,UAAU,UAAa,UAAU,KACnC,OAAM,KAAK,MAAM;AAGnB,cAAY,MAAM,QAAQ,MAAM,GAAG;AACnC,UAAQ,MAAM,KAAK,SAAS;;AAI9B,KAAI,YAAY,SAAS,OACvB,OAAM,KAAK,SAAS,UAAU,UAAU,CAAC;AAG3C,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 return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Core logic for splitting insertion strings and joining with values.\n * Returns an array of parts that can be wrapped by framework-specific Fragment implementations.\n *\n * @param template - The template string with {{ placeholder }} syntax\n * @param values - Map of placeholder names to their replacement values\n * @returns Object with `isSimple` flag and `parts` array\n *\n * @example\n * ```ts\n * const result = splitInsertionTemplate('Hello {{ name }}!', { name: 'World' });\n * // { isSimple: true, parts: 'Hello World!' }\n *\n * const result = splitInsertionTemplate('Hello {{ name }}!', { name: <Component /> });\n * // { isSimple: false, parts: ['Hello ', <Component />, '!'] }\n * ```\n */\nexport const splitInsertionTemplate = <T = any>(\n template: string,\n values: Record<string, T> = {}\n): { isSimple: boolean; parts: string | T[] } => {\n const safeValues = values ?? {};\n\n // Check if any value is a complex object (React/Vue node, etc.)\n const hasComplexValue = Object.values(safeValues).some(isComplexValue);\n\n if (!hasComplexValue) {\n // Simple string replacement\n const result = template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (safeValues[trimmedKey] ?? '').toString();\n });\n return { isSimple: true, parts: result };\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: any[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = safeValues[key];\n if (value !== undefined && value !== null) {\n parts.push(value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n return { isSimple: false, parts };\n};\n"],"mappings":"mEAIA,MAAM,EAAkB,GAEpB,GAAU,MAEV,OAAO,GAAU,UACjB,OAAO,GAAU,UACjB,OAAO,GAAU,UAqBR,GACX,EACA,EAA4B,EAAE,GACiB,CAC/C,IAAM,EAAa,GAAU,EAAE,CAK/B,GAAI,CAFoB,OAAO,OAAO,EAAW,CAAC,KAAK,EAAe,CAQpE,MAAO,CAAE,SAAU,GAAM,MAJV,EAAS,QAAQ,wBAAyB,EAAG,KAElD,EADW,EAAI,MAAM,GACK,IAAI,UAAU,CAChD,CACsC,CAI1C,IAAM,EAAe,EAAE,CACnB,EAAY,EACV,EAAQ,uBACV,EAAgC,EAAM,KAAK,EAAS,CAExD,KAAO,IAAU,MAAM,CAEjB,EAAM,MAAQ,GAChB,EAAM,KAAK,EAAS,UAAU,EAAW,EAAM,MAAM,CAAC,CAKxD,IAAM,EAAQ,EADF,EAAM,GAAG,MAAM,EAEvB,GAAiC,MACnC,EAAM,KAAK,EAAM,CAGnB,EAAY,EAAM,MAAQ,EAAM,GAAG,OACnC,EAAQ,EAAM,KAAK,EAAS,CAQ9B,OAJI,EAAY,EAAS,QACvB,EAAM,KAAK,EAAS,UAAU,EAAU,CAAC,CAGpC,CAAE,SAAU,GAAO,QAAO"}
@@ -1,144 +1,2 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
- const require_utils_localeStorage = require('../utils/localeStorage.cjs');
4
- const require_localization_localeDetector = require('./localeDetector.cjs');
5
- let _intlayer_types = require("@intlayer/types");
6
- let _intlayer_config_built = require("@intlayer/config/built");
7
- _intlayer_config_built = require_runtime.__toESM(_intlayer_config_built);
8
-
9
- //#region src/localization/getBrowserLocale.tsx
10
- let LanguageDetector = /* @__PURE__ */ function(LanguageDetector) {
11
- LanguageDetector["Querystring"] = "querystring";
12
- LanguageDetector["Storage"] = "storage";
13
- LanguageDetector["Navigator"] = "navigator";
14
- LanguageDetector["HtmlTag"] = "htmlTag";
15
- return LanguageDetector;
16
- }({});
17
- const localeStorageOptions = {
18
- getCookie: (name) => document.cookie.split(";").find((c) => c.trim().startsWith(`${name}=`))?.split("=")[1],
19
- getLocaleStorage: (name) => localStorage.getItem(name),
20
- getSessionStorage: (name) => sessionStorage.getItem(name),
21
- isCookieEnabled: true,
22
- setCookieStore: (name, value, attributes) => cookieStore.set({
23
- name,
24
- value,
25
- path: attributes.path,
26
- domain: attributes.domain,
27
- expires: attributes.expires,
28
- sameSite: attributes.sameSite
29
- }),
30
- setCookieString: (cookie) => {
31
- document.cookie = cookie;
32
- },
33
- setSessionStorage: (name, value) => sessionStorage.setItem(name, value),
34
- setLocaleStorage: (name, value) => localStorage.setItem(name, value)
35
- };
36
- const getDefaultsOptions = () => {
37
- return {
38
- order: [
39
- LanguageDetector.Querystring,
40
- LanguageDetector.Storage,
41
- LanguageDetector.Navigator,
42
- LanguageDetector.HtmlTag
43
- ],
44
- lookupQuerystring: "locale",
45
- htmlTag: typeof document !== "undefined" ? document.documentElement : null
46
- };
47
- };
48
- const detectLanguage = (order, options) => {
49
- const detected = {};
50
- const queryStringDetector = () => {
51
- if (typeof window === "undefined") return;
52
- const search = window.location.search || "";
53
- const value = new URLSearchParams(search).get(options.lookupQuerystring ?? "");
54
- if (value) detected[LanguageDetector.Querystring] = value;
55
- };
56
- const storageDetector = () => {
57
- if (typeof window === "undefined") return;
58
- const locale = require_utils_localeStorage.getLocaleFromStorage({
59
- getCookie: (name) => {
60
- try {
61
- const cookies = document.cookie.split(";");
62
- const cookieName = `${name}=`;
63
- const cookie = cookies.find((c) => c.trim().startsWith(cookieName));
64
- if (cookie) return cookie.split("=")[1].trim();
65
- } catch {}
66
- },
67
- getSessionStorage: (name) => {
68
- try {
69
- return window.sessionStorage.getItem(name) ?? void 0;
70
- } catch {}
71
- },
72
- getLocaleStorage: (name) => {
73
- try {
74
- return window.localStorage.getItem(name) ?? void 0;
75
- } catch {}
76
- }
77
- });
78
- if (locale) detected[LanguageDetector.Storage] = locale;
79
- };
80
- const navigatorDetector = () => {
81
- if (typeof navigator === "undefined") return;
82
- const { internationalization } = _intlayer_config_built.default;
83
- const languages = navigator.languages ?? [navigator.language];
84
- const locale = require_localization_localeDetector.localeDetector({ "accept-language": languages.join(",") }, internationalization.locales, internationalization.defaultLocale);
85
- if (locale) detected[LanguageDetector.Navigator] = locale;
86
- };
87
- const htmlTagDetector = () => {
88
- const htmlTag = options.htmlTag;
89
- if (htmlTag && typeof htmlTag.getAttribute === "function") {
90
- const lang = htmlTag.getAttribute("lang");
91
- if (lang) {
92
- const { internationalization } = _intlayer_config_built.default;
93
- const locale = require_localization_localeDetector.localeDetector({ "accept-language": lang }, internationalization.locales, internationalization.defaultLocale);
94
- detected[LanguageDetector.HtmlTag] = locale;
95
- }
96
- }
97
- };
98
- const detectors = {
99
- [LanguageDetector.Querystring]: queryStringDetector,
100
- [LanguageDetector.Storage]: storageDetector,
101
- [LanguageDetector.Navigator]: navigatorDetector,
102
- [LanguageDetector.HtmlTag]: htmlTagDetector
103
- };
104
- order.forEach((detectorName) => {
105
- detectors[detectorName]?.();
106
- });
107
- return detected;
108
- };
109
- const getFirstAvailableLocale = (locales, order) => {
110
- const { internationalization } = _intlayer_config_built.default;
111
- for (const detector of order) {
112
- const locale = locales[detector];
113
- if (locale && internationalization.locales.includes(locale)) return locale;
114
- }
115
- return internationalization?.defaultLocale ?? _intlayer_types.Locales.ENGLISH;
116
- };
117
- /**
118
- * Core language detector function for browser environments.
119
- *
120
- * Detects the user's preferred locale by checking multiple sources in order:
121
- * 1. Query string parameter
122
- * 2. Storage (cookies, localStorage, sessionStorage) - uses getLocaleFromStorage
123
- * 3. Navigator languages - uses localeDetector
124
- * 4. HTML lang attribute - uses localeDetector
125
- *
126
- * @param userOptions - Optional configuration for detection order and lookup keys
127
- * @returns The detected locale or the default locale
128
- *
129
- * @example
130
- * const locale = getBrowserLocale({ order: [LanguageDetector.Storage, LanguageDetector.Navigator] });
131
- */
132
- const getBrowserLocale = (userOptions = {}) => {
133
- const options = {
134
- ...getDefaultsOptions(),
135
- ...userOptions
136
- };
137
- return getFirstAvailableLocale(detectLanguage(options.order ?? [], options), options.order ?? []);
138
- };
139
-
140
- //#endregion
141
- exports.LanguageDetector = LanguageDetector;
142
- exports.getBrowserLocale = getBrowserLocale;
143
- exports.localeStorageOptions = localeStorageOptions;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`../utils/localeStorage.cjs`),n=require(`./localeDetector.cjs`);let r=require(`@intlayer/types`),i=require(`@intlayer/config/built`);i=e.__toESM(i);let a=function(e){return e.Querystring=`querystring`,e.Storage=`storage`,e.Navigator=`navigator`,e.HtmlTag=`htmlTag`,e}({});const o={getCookie:e=>document.cookie.split(`;`).find(t=>t.trim().startsWith(`${e}=`))?.split(`=`)[1],getLocaleStorage:e=>localStorage.getItem(e),getSessionStorage:e=>sessionStorage.getItem(e),isCookieEnabled:!0,setCookieStore:(e,t,n)=>cookieStore.set({name:e,value:t,path:n.path,domain:n.domain,expires:n.expires,sameSite:n.sameSite}),setCookieString:e=>{document.cookie=e},setSessionStorage:(e,t)=>sessionStorage.setItem(e,t),setLocaleStorage:(e,t)=>localStorage.setItem(e,t)},s=()=>({order:[a.Querystring,a.Storage,a.Navigator,a.HtmlTag],lookupQuerystring:`locale`,htmlTag:typeof document<`u`?document.documentElement:null}),c=(e,r)=>{let o={},s=()=>{if(typeof window>`u`)return;let e=window.location.search||``,t=new URLSearchParams(e).get(r.lookupQuerystring??``);t&&(o[a.Querystring]=t)},c=()=>{if(typeof window>`u`)return;let e=t.getLocaleFromStorage({getCookie:e=>{try{let t=document.cookie.split(`;`),n=`${e}=`,r=t.find(e=>e.trim().startsWith(n));if(r)return r.split(`=`)[1].trim()}catch{}},getSessionStorage:e=>{try{return window.sessionStorage.getItem(e)??void 0}catch{}},getLocaleStorage:e=>{try{return window.localStorage.getItem(e)??void 0}catch{}}});e&&(o[a.Storage]=e)},l=()=>{if(typeof navigator>`u`)return;let{internationalization:e}=i.default,t=navigator.languages??[navigator.language],r=n.localeDetector({"accept-language":t.join(`,`)},e.locales,e.defaultLocale);r&&(o[a.Navigator]=r)},u=()=>{let e=r.htmlTag;if(e&&typeof e.getAttribute==`function`){let t=e.getAttribute(`lang`);if(t){let{internationalization:e}=i.default,r=n.localeDetector({"accept-language":t},e.locales,e.defaultLocale);o[a.HtmlTag]=r}}},d={[a.Querystring]:s,[a.Storage]:c,[a.Navigator]:l,[a.HtmlTag]:u};return e.forEach(e=>{d[e]?.()}),o},l=(e,t)=>{let{internationalization:n}=i.default;for(let r of t){let t=e[r];if(t&&n.locales.includes(t))return t}return n?.defaultLocale??r.Locales.ENGLISH},u=(e={})=>{let t={...s(),...e};return l(c(t.order??[],t),t.order??[])};exports.LanguageDetector=a,exports.getBrowserLocale=u,exports.localeStorageOptions=o;
144
2
  //# sourceMappingURL=getBrowserLocale.cjs.map