@intlayer/core 9.0.0-canary.2 → 9.0.0-canary.20

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 +4 -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 +9 -12
  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 +116 -101
  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 +14 -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 +12 -10
  56. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  57. package/dist/cjs/interpreter/getDictionary.cjs +5 -5
  58. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  59. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  60. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  61. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  62. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  63. package/dist/cjs/interpreter/getIntlayer.cjs +4 -4
  64. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  65. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  66. package/dist/cjs/interpreter/getPlural.cjs +1 -1
  67. package/dist/cjs/interpreter/getPlural.cjs.map +1 -1
  68. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  69. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  70. package/dist/cjs/localization/comparePaths.cjs +75 -0
  71. package/dist/cjs/localization/comparePaths.cjs.map +1 -0
  72. package/dist/cjs/localization/domainUtils.cjs +82 -0
  73. package/dist/cjs/localization/domainUtils.cjs.map +1 -0
  74. package/dist/cjs/localization/generateSitemap.cjs +2 -1
  75. package/dist/cjs/localization/generateSitemap.cjs.map +1 -1
  76. package/dist/cjs/localization/getBrowserLocale.cjs +7 -4
  77. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  78. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  79. package/dist/cjs/localization/getLocale.cjs +0 -1
  80. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  81. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  82. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  83. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  84. package/dist/cjs/localization/getLocalizedUrl.cjs +7 -15
  85. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  86. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  87. package/dist/cjs/localization/getPathWithoutLocale.cjs +2 -3
  88. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  89. package/dist/cjs/localization/getPrefix.cjs +6 -11
  90. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  91. package/dist/cjs/localization/index.cjs +8 -0
  92. package/dist/cjs/localization/localeDetector.cjs +2 -1
  93. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  94. package/dist/cjs/localization/localeMapper.cjs +0 -1
  95. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  96. package/dist/cjs/localization/localeResolver.cjs +0 -1
  97. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  98. package/dist/cjs/localization/rewriteUtils.cjs +3 -2
  99. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  100. package/dist/cjs/localization/validatePrefix.cjs +2 -2
  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 +4 -5
  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 +10 -12
  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 +113 -99
  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 +5 -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 +12 -10
  214. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  215. package/dist/esm/interpreter/getDictionary.mjs +5 -5
  216. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  217. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  218. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  219. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  220. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  221. package/dist/esm/interpreter/getIntlayer.mjs +4 -3
  222. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  223. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  224. package/dist/esm/interpreter/getPlural.mjs +1 -1
  225. package/dist/esm/interpreter/getPlural.mjs.map +1 -1
  226. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  227. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  228. package/dist/esm/localization/comparePaths.mjs +73 -0
  229. package/dist/esm/localization/comparePaths.mjs.map +1 -0
  230. package/dist/esm/localization/domainUtils.mjs +77 -0
  231. package/dist/esm/localization/domainUtils.mjs.map +1 -0
  232. package/dist/esm/localization/generateSitemap.mjs +2 -1
  233. package/dist/esm/localization/generateSitemap.mjs.map +1 -1
  234. package/dist/esm/localization/getBrowserLocale.mjs +7 -3
  235. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  236. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  237. package/dist/esm/localization/getLocale.mjs.map +1 -1
  238. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  239. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  240. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  241. package/dist/esm/localization/getLocalizedUrl.mjs +7 -14
  242. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  243. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  244. package/dist/esm/localization/getPathWithoutLocale.mjs +2 -2
  245. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  246. package/dist/esm/localization/getPrefix.mjs +6 -10
  247. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  248. package/dist/esm/localization/index.mjs +3 -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 +3 -2
  254. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  255. package/dist/esm/localization/validatePrefix.mjs +2 -2
  256. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  257. package/dist/esm/markdown/compiler.mjs +2 -1
  258. package/dist/esm/markdown/compiler.mjs.map +1 -1
  259. package/dist/esm/markdown/constants.mjs.map +1 -1
  260. package/dist/esm/markdown/parser.mjs.map +1 -1
  261. package/dist/esm/markdown/renderer.mjs.map +1 -1
  262. package/dist/esm/markdown/utils.mjs.map +1 -1
  263. package/dist/esm/messageFormat/ICU.mjs +15 -9
  264. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  265. package/dist/esm/messageFormat/i18next.mjs +12 -7
  266. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  267. package/dist/esm/messageFormat/index.mjs +2 -1
  268. package/dist/esm/messageFormat/navigatePath.mjs +36 -0
  269. package/dist/esm/messageFormat/navigatePath.mjs.map +1 -0
  270. package/dist/esm/messageFormat/po.mjs.map +1 -1
  271. package/dist/esm/messageFormat/resolveMessage.mjs +11 -8
  272. package/dist/esm/messageFormat/resolveMessage.mjs.map +1 -1
  273. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  274. package/dist/esm/messageFormat/vue-i18n.mjs +2 -1
  275. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  276. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  277. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  278. package/dist/esm/transpiler/file/file.mjs +2 -1
  279. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  280. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  281. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  282. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  283. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  284. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  285. package/dist/esm/transpiler/html/validateHTML.mjs +1 -1
  286. package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -1
  287. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  288. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  289. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  290. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  291. package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -1
  292. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  293. package/dist/esm/transpiler/plural/plural.mjs.map +1 -1
  294. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  295. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  296. package/dist/esm/utils/cookieExpiry.mjs.map +1 -1
  297. package/dist/esm/utils/getCookie.mjs.map +1 -1
  298. package/dist/esm/utils/intl.mjs +100 -25
  299. package/dist/esm/utils/intl.mjs.map +1 -1
  300. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  301. package/dist/esm/utils/localeStorage.mjs +4 -4
  302. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  303. package/dist/esm/utils/parseYaml.mjs +1 -1
  304. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  305. package/dist/esm/utils/stringifyYaml.mjs +1 -1
  306. package/dist/esm/utils/stringifyYaml.mjs.map +1 -1
  307. package/dist/types/deepTransformPlugins/getEditedContent.d.ts +0 -1
  308. package/dist/types/deepTransformPlugins/getEditedContent.d.ts.map +1 -1
  309. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +12 -14
  310. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
  311. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +12 -14
  312. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  313. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +12 -14
  314. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  315. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts +1 -1
  316. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -1
  317. package/dist/types/deepTransformPlugins/getMaskContent.d.ts +1 -1
  318. package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +1 -1
  319. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts +1 -1
  320. package/dist/types/deepTransformPlugins/getMissingLocalesContent.d.ts.map +1 -1
  321. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts +0 -1
  322. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +1 -1
  323. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts +1 -1
  324. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +1 -1
  325. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts +1 -2
  326. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -1
  327. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts +1 -2
  328. package/dist/types/deepTransformPlugins/insertContentInDictionary.d.ts.map +1 -1
  329. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts +0 -1
  330. package/dist/types/dictionaryManipulator/editDictionaryByKeyPath.d.ts.map +1 -1
  331. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts +0 -1
  332. package/dist/types/dictionaryManipulator/getContentNodeByKeyPath.d.ts.map +1 -1
  333. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts +0 -1
  334. package/dist/types/dictionaryManipulator/getDefaultNode.d.ts.map +1 -1
  335. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts +0 -1
  336. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -1
  337. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts +0 -1
  338. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -1
  339. package/dist/types/dictionaryManipulator/getNodeType.d.ts +0 -1
  340. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
  341. package/dist/types/dictionaryManipulator/index.d.ts +2 -2
  342. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts +0 -1
  343. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +1 -1
  344. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts +1 -2
  345. package/dist/types/dictionaryManipulator/mergeQualifiedDictionaries.d.ts.map +1 -1
  346. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts +0 -1
  347. package/dist/types/dictionaryManipulator/normalizeDictionary.d.ts.map +1 -1
  348. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts +1 -2
  349. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
  350. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts +59 -36
  351. package/dist/types/dictionaryManipulator/qualifiedDictionary.d.ts.map +1 -1
  352. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts +0 -1
  353. package/dist/types/dictionaryManipulator/removeContentNodeByKeyPath.d.ts.map +1 -1
  354. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts +1 -2
  355. package/dist/types/dictionaryManipulator/renameContentNodeByKeyPath.d.ts.map +1 -1
  356. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts +0 -1
  357. package/dist/types/dictionaryManipulator/updateNodeChildren.d.ts.map +1 -1
  358. package/dist/types/formatters/compact.d.ts +0 -1
  359. package/dist/types/formatters/compact.d.ts.map +1 -1
  360. package/dist/types/formatters/currency.d.ts +0 -1
  361. package/dist/types/formatters/currency.d.ts.map +1 -1
  362. package/dist/types/formatters/date.d.ts +0 -1
  363. package/dist/types/formatters/date.d.ts.map +1 -1
  364. package/dist/types/formatters/index.d.ts +2 -2
  365. package/dist/types/formatters/list.d.ts +0 -1
  366. package/dist/types/formatters/list.d.ts.map +1 -1
  367. package/dist/types/formatters/number.d.ts +1 -5
  368. package/dist/types/formatters/number.d.ts.map +1 -1
  369. package/dist/types/formatters/percentage.d.ts +1 -5
  370. package/dist/types/formatters/percentage.d.ts.map +1 -1
  371. package/dist/types/formatters/relativeTime.d.ts +0 -1
  372. package/dist/types/formatters/relativeTime.d.ts.map +1 -1
  373. package/dist/types/formatters/units.d.ts +0 -1
  374. package/dist/types/formatters/units.d.ts.map +1 -1
  375. package/dist/types/index.d.ts +15 -3
  376. package/dist/types/interpreter/getCondition.d.ts +1 -0
  377. package/dist/types/interpreter/getCondition.d.ts.map +1 -1
  378. package/dist/types/interpreter/getContent/deepTransform.d.ts +0 -1
  379. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -1
  380. package/dist/types/interpreter/getContent/getContent.d.ts +0 -1
  381. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  382. package/dist/types/interpreter/getContent/plugins.d.ts +4 -4
  383. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  384. package/dist/types/interpreter/getDictionary.d.ts +6 -6
  385. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  386. package/dist/types/interpreter/getEnumeration.d.ts +1 -0
  387. package/dist/types/interpreter/getEnumeration.d.ts.map +1 -1
  388. package/dist/types/interpreter/getGender.d.ts +1 -0
  389. package/dist/types/interpreter/getGender.d.ts.map +1 -1
  390. package/dist/types/interpreter/getHTML.d.ts.map +1 -1
  391. package/dist/types/interpreter/getInsertion.d.ts +2 -1
  392. package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
  393. package/dist/types/interpreter/getIntlayer.d.ts +2 -2
  394. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  395. package/dist/types/interpreter/getNesting.d.ts +2 -1
  396. package/dist/types/interpreter/getNesting.d.ts.map +1 -1
  397. package/dist/types/interpreter/getPlural.d.ts +0 -1
  398. package/dist/types/interpreter/getPlural.d.ts.map +1 -1
  399. package/dist/types/interpreter/getTranslation.d.ts +0 -1
  400. package/dist/types/interpreter/getTranslation.d.ts.map +1 -1
  401. package/dist/types/interpreter/index.d.ts +1 -0
  402. package/dist/types/interpreter/splitAndJoinInsertion.d.ts.map +1 -1
  403. package/dist/types/localization/comparePaths.d.ts +65 -0
  404. package/dist/types/localization/comparePaths.d.ts.map +1 -0
  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 +3 -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":"intl.cjs","names":["internationalization"],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["/**\n * Cached Intl helper – drop‑in replacement for the global `Intl` object.\n * ‑‑‑\n * • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n * • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n * reuse the same heavy instance instead of reparsing CLDR data every time.\n * • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n * • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n * you can treat `CachedIntl` just like the built‑in `Intl`.\n *\n * Usage @example:\n * ---------------\n * ```ts\n * import { CachedIntl } from \"./cached-intl\";\n *\n * const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n * console.log(nf.format(1234));\n *\n * const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n * console.log(dn.of(\"en\")); * → \"anglais\"\n *\n * You can also spin up an isolated instance with its own caches (handy in test suites):\n * const TestIntl = createCachedIntl();\n * ```\n */\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nconst MAX_CACHE_SIZE = 50;\nconst cache = new Map<any, Map<string, any>>();\n\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues, options?: Options): Instance;\n (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues): Instance;\n (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\nexport type WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n/**\n * Generic caching instantiator for Intl constructors.\n */\nexport const getCachedIntl = <T extends new (...args: any[]) => any>(\n Ctor: T,\n locale?: LocalesValues | string,\n options?: any\n): InstanceType<T> => {\n const resLoc = locale ?? internationalization?.defaultLocale;\n\n const optKey = options ? JSON.stringify(options) : '';\n const key = `${resLoc}|${optKey}`;\n\n let ctorCache = cache.get(Ctor);\n\n if (!ctorCache) {\n ctorCache = new Map();\n cache.set(Ctor, ctorCache);\n }\n\n let instance = ctorCache.get(key);\n\n if (!instance) {\n if (ctorCache.size > MAX_CACHE_SIZE) ctorCache.clear();\n instance = new Ctor(resLoc, options);\n ctorCache.set(key, instance);\n }\n return instance;\n};\n\n/**\n * Optional: Keep bindIntl if your library exports it publicly.\n * It now uses the much smaller getCachedIntl under the hood.\n */\nexport const bindIntl = (boundLocale: LocalesValues): WrappedIntl => {\n const bindWrap = (Ctor: any) =>\n // function is used as a constructor, do not change in arrow function\n function intlConstructor(locales?: any, options?: any) {\n const isOptsFirst =\n locales !== null &&\n typeof locales === 'object' &&\n !Array.isArray(locales);\n const resOpts = isOptsFirst ? locales : options;\n const resLoc = isOptsFirst\n ? (resOpts as any).locale || boundLocale\n : locales || boundLocale;\n\n return getCachedIntl(Ctor, resLoc, resOpts);\n };\n\n return {\n ...Intl,\n Collator: bindWrap(Intl.Collator),\n DateTimeFormat: bindWrap(Intl.DateTimeFormat),\n DisplayNames: bindWrap(Intl.DisplayNames),\n ListFormat: bindWrap(Intl.ListFormat),\n NumberFormat: bindWrap(Intl.NumberFormat),\n PluralRules: bindWrap(Intl.PluralRules),\n RelativeTimeFormat: bindWrap(Intl.RelativeTimeFormat),\n Locale: bindWrap(Intl.Locale),\n Segmenter: bindWrap((Intl as any).Segmenter),\n } as unknown as WrappedIntl;\n};\n\n// Add this to the bottom of utils/intl.ts ONLY if required for public API compatibility.\nexport const CachedIntl = {\n // function is used as a constructor, do not change in arrow function\n Collator: function Collator(locales?: any, options?: any) {\n return getCachedIntl(Intl.Collator, locales, options);\n },\n DateTimeFormat: function DateTimeFormat(locales?: any, options?: any) {\n return getCachedIntl(Intl.DateTimeFormat, locales, options);\n },\n DisplayNames: function DisplayNames(locales?: any, options?: any) {\n return getCachedIntl(Intl.DisplayNames, locales, options);\n },\n ListFormat: function ListFormat(locales?: any, options?: any) {\n return getCachedIntl(Intl.ListFormat as any, locales, options);\n },\n NumberFormat: function NumberFormat(locales?: any, options?: any) {\n return getCachedIntl(Intl.NumberFormat, locales, options);\n },\n PluralRules: function PluralRules(locales?: any, options?: any) {\n return getCachedIntl(Intl.PluralRules, locales, options);\n },\n RelativeTimeFormat: function RelativeTimeFormat(\n locales?: any,\n options?: any\n ) {\n return getCachedIntl(Intl.RelativeTimeFormat, locales, options);\n },\n Segmenter: function Segmenter(locales?: any, options?: any) {\n return getCachedIntl((Intl as any).Segmenter, locales, options);\n },\n} as any; // Cast to 'any' internally to avoid TS readonly errors\n\nexport { CachedIntl as Intl };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,iBAAiB;AACvB,MAAM,wBAAQ,IAAI,KAA4B;;;;AAwC9C,MAAa,iBACX,MACA,QACA,YACoB;CACpB,MAAM,SAAS,UAAUA,6CAAsB;CAG/C,MAAM,MAAM,GAAG,OAAO,GADP,UAAU,KAAK,UAAU,QAAQ,GAAG;CAGnD,IAAI,YAAY,MAAM,IAAI,KAAK;AAE/B,KAAI,CAAC,W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K,cAAc,SAAS,QAAQ;;CAE3D,aAAa,SAAS,YAAY,SAAe,SAAe;AAC9D,SAAO,cAAc,KAAK,aAAa,SAAS,QAAQ;;CAE1D,oBAAoB,SAAS,mBAC3B,SACA,SACA;AACA,SAAO,cAAc,KAAK,oBAAoB,SAAS,QAAQ;;CAEjE,WAAW,SAAS,UAAU,SAAe,SAAe;AAC1D,SAAO,cAAe,KAAa,WAAW,SAAS,QAAQ;;CAElE"}
1
+ {"version":3,"file":"intl.cjs","names":["internationalization"],"sources":["../../../src/utils/intl.ts"],"sourcesContent":["/**\n * Cached Intl helper – drop‑in replacement for the global `Intl` object.\n * ‑‑‑\n * • Uses a `Proxy` to lazily wrap every *constructor* hanging off `Intl` (NumberFormat, DateTimeFormat, …).\n * • Each wrapped constructor keeps an in‑memory cache keyed by `[locales, options]` so that identical requests\n * reuse the same heavy instance instead of reparsing CLDR data every time.\n * • A polyfill warning for `Intl.DisplayNames` is emitted only once and only in dev.\n * • The public API is fully type‑safe and mirrors the native `Intl` surface exactly –\n * you can treat `CachedIntl` just like the built‑in `Intl`.\n *\n * Usage @example:\n * ---------------\n * ```ts\n * import { CachedIntl } from \"./cached-intl\";\n *\n * const nf = CachedIntl.NumberFormat(\"en-US\", { style: \"currency\", currency: \"USD\" });\n * console.log(nf.format(1234));\n *\n * const dn = CachedIntl.DisplayNames([\"fr\"], { type: \"language\" });\n * console.log(dn.of(\"en\")); * → \"anglais\"\n *\n * You can also spin up an isolated instance with its own caches (handy in test suites):\n * const TestIntl = createCachedIntl();\n * ```\n */\n\nimport { internationalization } from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nconst MAX_CACHE_SIZE = 50;\nconst cache = new Map<any, Map<string, any>>();\n\n/**\n * Minimal `Intl.ListFormat` surface, declared locally so consumers do not need\n * the `ES2021.Intl` lib in their tsconfig.\n */\ntype ListFormatInstance = {\n format(list: Iterable<string>): string;\n formatToParts(\n list: Iterable<string>\n ): { type: 'element' | 'literal'; value: string }[];\n};\n\n/**\n * Minimal `Intl.Segmenter` surface, declared locally so consumers do not need\n * the `ES2022.Intl` lib in their tsconfig.\n */\ntype SegmenterInstance = {\n segment(input: string): Iterable<{ segment: string; index: number }>;\n};\n\n/**\n * Instance type produced by each `Intl` constructor this module can build.\n */\ntype IntlInstanceByName = {\n Collator: Intl.Collator;\n DateTimeFormat: Intl.DateTimeFormat;\n DisplayNames: Intl.DisplayNames;\n ListFormat: ListFormatInstance;\n Locale: Intl.Locale;\n NumberFormat: Intl.NumberFormat;\n PluralRules: Intl.PluralRules;\n RelativeTimeFormat: Intl.RelativeTimeFormat;\n Segmenter: SegmenterInstance;\n};\n\n/**\n * Names of the `Intl` constructors this module knows how to instantiate.\n */\nexport type IntlConstructorName = keyof IntlInstanceByName;\n\nconst alreadyWarnedConstructors = new Set<string>();\n\n/**\n * Warns once per missing `Intl` constructor, in development only.\n */\nconst warnMissingIntlConstructor = (constructorName: string): void => {\n if (process.env.NODE_ENV === 'production') return;\n if (alreadyWarnedConstructors.has(constructorName)) return;\n\n alreadyWarnedConstructors.add(constructorName);\n\n console.warn(\n `[intlayer] \\`Intl.${constructorName}\\` is not available in this JavaScript engine. ` +\n `A degraded fallback is used instead. ` +\n `On React Native, load a polyfill (e.g. \\`@formatjs/intl-${constructorName.toLowerCase()}/polyfill\\`) before rendering your app.`\n );\n};\n\n/**\n * Minimal stand-ins used when the engine ships without the matching `Intl`\n * constructor. Hermes — the default React Native engine — omits\n * `DisplayNames`, `ListFormat` and `Segmenter` in release builds unless the\n * app opts into the full ICU build or loads a polyfill. Without these shims,\n * `new Intl.DisplayNames(...)` throws\n * `TypeError: undefined cannot be used as a constructor` and takes the whole\n * app down at render time.\n *\n * Each shim mirrors only the surface Intlayer relies on, and returns the\n * un-localized input so rendering degrades rather than crashing.\n */\nconst intlConstructorFallbacks: Partial<\n Record<IntlConstructorName, new (locale?: any, options?: any) => any>\n> = {\n DisplayNames: class DisplayNamesFallback {\n /** Returns the requested code unchanged, since no CLDR data is available. */\n public of(code: string): string {\n return code;\n }\n },\n ListFormat: class ListFormatFallback {\n /** Joins the list with a comma, the most neutral separator available. */\n public format(list: Iterable<string>): string {\n return Array.from(list).join(', ');\n }\n\n /** Mirrors `Intl.ListFormat.prototype.formatToParts` shape. */\n public formatToParts(\n list: Iterable<string>\n ): { type: 'element' | 'literal'; value: string }[] {\n return Array.from(list).flatMap((value, index) =>\n index === 0\n ? [{ type: 'element' as const, value }]\n : [\n { type: 'literal' as const, value: ', ' },\n { type: 'element' as const, value },\n ]\n );\n }\n },\n Segmenter: class SegmenterFallback {\n /** Segments by code point, the closest approximation without ICU data. */\n public segment(input: string): { segment: string; index: number }[] {\n let index = 0;\n\n return Array.from(input).map((segment) => {\n const segmentStart = index;\n index += segment.length;\n\n return { segment, index: segmentStart };\n });\n }\n },\n};\n\n/**\n * Resolves an `Intl` constructor by name at call time, falling back to a\n * degraded shim when the engine does not provide it.\n *\n * Resolution is deliberately lazy: React Native apps install their polyfills\n * at startup, which may run after this module is first imported.\n */\nconst resolveIntlConstructor = (\n constructorName: IntlConstructorName\n): (new (locale?: any, options?: any) => any) | undefined => {\n const nativeConstructor = (\n Intl as unknown as Record<string, new (...args: any[]) => any>\n )[constructorName];\n\n if (typeof nativeConstructor === 'function') return nativeConstructor;\n\n warnMissingIntlConstructor(constructorName);\n\n return intlConstructorFallbacks[constructorName];\n};\n\ntype IntlConstructors = {\n [K in keyof typeof Intl as (typeof Intl)[K] extends new (\n ...args: any\n ) => any\n ? K\n : never]: (typeof Intl)[K];\n};\n\ntype ReplaceLocaleWithLocalesValues<T> = T extends new (\n locales: any,\n options?: infer Options\n) => infer Instance\n ? {\n new (locales?: LocalesValues, options?: Options): Instance;\n new (options?: Options & { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues, options?: Options): Instance;\n (options?: Options & { locale?: LocalesValues }): Instance;\n }\n : T extends new (\n locales: any\n ) => infer Instance\n ? {\n new (locales?: LocalesValues): Instance;\n new (options?: { locale?: LocalesValues }): Instance;\n (locales?: LocalesValues): Instance;\n (options?: { locale?: LocalesValues }): Instance;\n }\n : T;\n\nexport type WrappedIntl = {\n [K in keyof typeof Intl]: K extends keyof IntlConstructors\n ? ReplaceLocaleWithLocalesValues<(typeof Intl)[K]>\n : (typeof Intl)[K];\n};\n\n/**\n * Generic caching instantiator for Intl constructors.\n *\n * Prefer passing the constructor *name* (e.g. `'DisplayNames'`) rather than the\n * constructor itself: the name is resolved lazily against the global `Intl`, so\n * late-installed polyfills are picked up and missing constructors degrade to a\n * fallback instead of throwing.\n */\nexport function getCachedIntl<Name extends IntlConstructorName>(\n constructorName: Name,\n locale?: LocalesValues | string,\n options?: any\n): IntlInstanceByName[Name];\nexport function getCachedIntl<T extends new (...args: any[]) => any>(\n Ctor: T,\n locale?: LocalesValues | string,\n options?: any\n): InstanceType<T>;\nexport function getCachedIntl(\n intlConstructor: IntlConstructorName | (new (...args: any[]) => any),\n locale?: LocalesValues | string,\n options?: any\n): any {\n const resLoc = locale ?? internationalization?.defaultLocale;\n\n const optKey = options ? JSON.stringify(options) : '';\n const key = `${resLoc}|${optKey}`;\n\n // Cache per name when available, so two constructors that are both missing\n // from the engine do not collide on a single `undefined` cache bucket.\n const cacheKey = intlConstructor;\n\n let ctorCache = cache.get(cacheKey);\n\n if (!ctorCache) {\n ctorCache = new Map();\n cache.set(cacheKey, ctorCache);\n }\n\n let instance = ctorCache.get(key);\n\n if (!instance) {\n const ResolvedConstructor =\n typeof intlConstructor === 'string'\n ? resolveIntlConstructor(intlConstructor)\n : intlConstructor;\n\n if (typeof ResolvedConstructor !== 'function') {\n throw new Error(\n `[intlayer] \\`Intl.${String(intlConstructor)}\\` is not available in this JavaScript engine and has no fallback. ` +\n `Load the matching polyfill before formatting.`\n );\n }\n\n if (ctorCache.size > MAX_CACHE_SIZE) ctorCache.clear();\n instance = new ResolvedConstructor(resLoc, options);\n ctorCache.set(key, instance);\n }\n return instance;\n}\n\n/**\n * Optional: Keep bindIntl if your library exports it publicly.\n * It now uses the much smaller getCachedIntl under the hood.\n */\nexport const bindIntl = (boundLocale: LocalesValues): WrappedIntl => {\n const bindWrap = (constructorName: IntlConstructorName) =>\n // function is used as a constructor, do not change in arrow function\n function intlConstructor(locales?: any, options?: any) {\n const isOptsFirst =\n locales !== null &&\n typeof locales === 'object' &&\n !Array.isArray(locales);\n const resOpts = isOptsFirst ? locales : options;\n const resLoc = isOptsFirst\n ? (resOpts as any).locale || boundLocale\n : locales || boundLocale;\n\n return getCachedIntl(constructorName, resLoc, resOpts);\n };\n\n return {\n ...Intl,\n Collator: bindWrap('Collator'),\n DateTimeFormat: bindWrap('DateTimeFormat'),\n DisplayNames: bindWrap('DisplayNames'),\n ListFormat: bindWrap('ListFormat'),\n NumberFormat: bindWrap('NumberFormat'),\n PluralRules: bindWrap('PluralRules'),\n RelativeTimeFormat: bindWrap('RelativeTimeFormat'),\n Locale: bindWrap('Locale'),\n Segmenter: bindWrap('Segmenter'),\n } as unknown as WrappedIntl;\n};\n\n// Add this to the bottom of utils/intl.ts ONLY if required for public API compatibility.\nexport const CachedIntl = {\n // function is used as a constructor, do not change in arrow function\n Collator: function Collator(locales?: any, options?: any) {\n return getCachedIntl('Collator', locales, options);\n },\n DateTimeFormat: function DateTimeFormat(locales?: any, options?: any) {\n return getCachedIntl('DateTimeFormat', locales, options);\n },\n DisplayNames: function DisplayNames(locales?: any, options?: any) {\n return getCachedIntl('DisplayNames', locales, options);\n },\n ListFormat: function ListFormat(locales?: any, options?: any) {\n return getCachedIntl('ListFormat', locales, options);\n },\n NumberFormat: function NumberFormat(locales?: any, options?: any) {\n return getCachedIntl('NumberFormat', locales, options);\n },\n PluralRules: function PluralRules(locales?: any, options?: any) {\n return getCachedIntl('PluralRules', locales, options);\n },\n RelativeTimeFormat: function RelativeTimeFormat(\n locales?: any,\n options?: any\n ) {\n return getCachedIntl('RelativeTimeFormat', locales, options);\n },\n Segmenter: function Segmenter(locales?: any, options?: any) {\n return getCachedIntl('Segmenter',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YAAY,SAAS,OAAO;CACnD;CACA,gBAAgB,SAAS,eAAe,SAAe,SAAe;EACpE,OAAO,cAAc,kBAAkB,SAAS,OAAO;CACzD;CACA,cAAc,SAAS,aAAa,SAAe,SAAe;EAChE,OAAO,cAAc,gBAAgB,SAAS,OAAO;CACvD;CACA,YAAY,SAAS,WAAW,SAAe,SAAe;EAC5D,OAAO,cAAc,cAAc,SAAS,OAAO;CACrD;CACA,cAAc,SAAS,aAAa,SAAe,SAAe;EAChE,OAAO,cAAc,gBAAgB,SAAS,OAAO;CACvD;CACA,aAAa,SAAS,YAAY,SAAe,SAAe;EAC9D,OAAO,cAAc,eAAe,SAAS,OAAO;CACtD;CACA,oBAAoB,SAAS,mBAC3B,SACA,SACA;EACA,OAAO,cAAc,sBAAsB,SAAS,OAAO;CAC7D;CACA,WAAW,SAAS,UAAU,SAAe,SAAe;EAC1D,OAAO,cAAc,aAAa,SAAS,OAAO;CACpD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"isSameKeyPath.cjs","names":[],"sources":["../../../src/utils/isSameKeyPath.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types/keyPath';\n\ntype KeyPathWithKey = KeyPath & { key: string };\n\nexport const isSameKeyPath = (keyPath1: KeyPath[], keyPath2: KeyPath[]) =>\n keyPath1.every(\n (element, index) =>\n keyPath2[index] &&\n (keyPath2[index] as KeyPathWithKey).key ===\n (element as KeyPathWithKey).key &&\n keyPath2[index].type === element.type\n );\n"],"mappings":";;;AAIA,MAAa,iBAAiB,UAAqB,aACjD,SAAS,OACN,SAAS,UACR,SAAS,UACR,SAAS,OAA0B,QACjC,QAA2B,OAC9B,SAAS,OAAO,SAAS,QAAQ,KACpC"}
1
+ {"version":3,"file":"isSameKeyPath.cjs","names":[],"sources":["../../../src/utils/isSameKeyPath.ts"],"sourcesContent":["import type { KeyPath } from '@intlayer/types/keyPath';\n\ntype KeyPathWithKey = KeyPath & { key: string };\n\nexport const isSameKeyPath = (keyPath1: KeyPath[], keyPath2: KeyPath[]) =>\n keyPath1.every(\n (element, index) =>\n keyPath2[index] &&\n (keyPath2[index] as KeyPathWithKey).key ===\n (element as KeyPathWithKey).key &&\n keyPath2[index].type === element.type\n );\n"],"mappings":";;;AAIA,MAAa,iBAAiB,UAAqB,aACjD,SAAS,OACN,SAAS,UACR,SAAS,UACR,SAAS,MAAM,CAAoB,QACjC,QAA2B,OAC9B,SAAS,MAAM,CAAC,SAAS,QAAQ,IACrC"}
@@ -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_cookieExpiry = require('./cookieExpiry.cjs');
4
3
  const require_utils_getCookie = require('./getCookie.cjs');
5
4
  let _intlayer_config_built = require("@intlayer/config/built");
@@ -8,19 +7,19 @@ let _intlayer_config_built = require("@intlayer/config/built");
8
7
  /**
9
8
  * True when cookie storage is explicitly disabled at build time.
10
9
  */
11
- const TREE_SHAKE_STORAGE_COOKIES = process.env["INTLAYER_ROUTING_STORAGE_COOKIES"] === "false";
10
+ const TREE_SHAKE_STORAGE_COOKIES = process.env.INTLAYER_ROUTING_STORAGE_COOKIES === "false";
12
11
  /**
13
12
  * True when localStorage is explicitly disabled at build time.
14
13
  */
15
- const TREE_SHAKE_STORAGE_LOCAL_STORAGE = process.env["INTLAYER_ROUTING_STORAGE_LOCALSTORAGE"] === "false";
14
+ const TREE_SHAKE_STORAGE_LOCAL_STORAGE = process.env.INTLAYER_ROUTING_STORAGE_LOCALSTORAGE === "false";
16
15
  /**
17
16
  * True when sessionStorage is explicitly disabled at build time.
18
17
  */
19
- const TREE_SHAKE_STORAGE_SESSION_STORAGE = process.env["INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE"] === "false";
18
+ const TREE_SHAKE_STORAGE_SESSION_STORAGE = process.env.INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE === "false";
20
19
  /**
21
20
  * True when header storage is explicitly disabled at build time.
22
21
  */
23
- const TREE_SHAKE_STORAGE_HEADERS = process.env["INTLAYER_ROUTING_STORAGE_HEADERS"] === "false";
22
+ const TREE_SHAKE_STORAGE_HEADERS = process.env.INTLAYER_ROUTING_STORAGE_HEADERS === "false";
24
23
  const localeStorageOptions = {
25
24
  getCookie: (name) => document.cookie.split(";").find((c) => c.trim().startsWith(`${name}=`))?.split("=")[1],
26
25
  getLocaleStorage: (name) => localStorage.getItem(name),
@@ -1 +1 @@
1
- {"version":3,"file":"localeStorage.cjs","names":["internationalization","routing","resolveExpiresToTimestamp","buildCookieString","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import { internationalization, routing } from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { buildCookieString, resolveExpiresToTimestamp } from './cookieExpiry';\nimport { getCookie } from './getCookie';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when cookie storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_COOKIES =\n process.env['INTLAYER_ROUTING_STORAGE_COOKIES'] === 'false';\n\n/**\n * True when localStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_LOCAL_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_LOCALSTORAGE'] === 'false';\n\n/**\n * True when sessionStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_SESSION_STORAGE =\n process.env['INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE'] === 'false';\n\n/**\n * True when header storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_HEADERS =\n process.env['INTLAYER_ROUTING_STORAGE_HEADERS'] === 'false';\n\n// ============================================================================\n// Shared types\n// ============================================================================\n\nexport type CookieBuildAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n /**\n * Absolute expiry as milliseconds since epoch, ready for `cookieStore.set()`.\n * Already resolved from the normalized `expires` by\n * `resolveExpiresToTimestamp`.\n */\n expires?: number | undefined;\n};\n\n// ============================================================================\n// Client-specific types and functions\n// (cookies via browser APIs, localStorage, sessionStorage — no headers)\n// ============================================================================\n\nexport type LocaleStorageClientOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n};\n\n// cookieStore is part of the experimental Cookie Store API\ndeclare const cookieStore: any;\n\nexport const localeStorageOptions: LocaleStorageClientOptions = {\n getCookie: (name: string) =>\n document.cookie\n .split(';')\n .find((c) => c.trim().startsWith(`${name}=`))\n ?.split('=')[1],\n getLocaleStorage: (name: string) => localStorage.getItem(name),\n getSessionStorage: (name: string) => sessionStorage.getItem(name),\n isCookieEnabled: true,\n setCookieStore: (name, value, attributes) =>\n cookieStore.set({\n name,\n value,\n path: attributes.path,\n domain: attributes.domain,\n expires: attributes.expires,\n sameSite: attributes.sameSite,\n }),\n setCookieString: (_name, cookie) => {\n // biome-ignore lint/suspicious/noDocumentCookie: set cookie fallback\n document.cookie = cookie;\n },\n setSessionStorage: (name, value) => sessionStorage.setItem(name, value),\n setLocaleStorage: (name, value) => localStorage.setItem(name, value),\n};\n\n/**\n * Retrieves the locale from browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not read from headers — use `getLocaleFromStorageServer` for that.\n */\nexport const getLocaleFromStorageClient = (\n options: LocaleStorageClientOptions = localeStorageOptions\n): Locale | undefined => {\n const { locales } = internationalization;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < (routing.storage.cookies ?? []).length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.cookies![i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) {\n for (let i = 0; i < (routing.storage.localStorage ?? []).length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage![i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not write to headers — use `setLocaleInStorageServer` for that.\n */\nexport const setLocaleInStorageClient = (\n locale: LocalesValues,\n options?: LocaleStorageClientOptions\n): void => {\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires: resolveExpiresToTimestamp(attributes.expires),\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Client-side locale storage utility.\n * Handles cookies (browser), localStorage and sessionStorage.\n * Does not access headers.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageClient(localeStorageOptions);\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageClient = (options: LocaleStorageClientOptions) => ({\n getLocale: () => getLocaleFromStorageClient(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageClient(locale, options),\n});\n\n// ============================================================================\n// Server-specific types and functions\n// (cookies via injected getter/setter, headers — no localStorage/sessionStorage)\n// ============================================================================\n\nexport type LocaleStorageServerOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from server-side storage mechanisms (cookies, headers).\n * Does not access localStorage or sessionStorage.\n * No browser cookie fallback — the caller must provide `getCookie`.\n */\nexport const getLocaleFromStorageServer = (\n options: LocaleStorageServerOptions\n): Locale | undefined => {\n const { locales } = internationalization;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in server-side storage mechanisms (cookies, headers).\n * Does not write to localStorage or sessionStorage.\n */\nexport const setLocaleInStorageServer = (\n locale: LocalesValues,\n options?: LocaleStorageServerOptions\n): void => {\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires: resolveExpiresToTimestamp(attributes.expires),\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Server-side locale storage utility.\n * Handles cookies (via injected getter/setter) and headers.\n * Does not access localStorage or sessionStorage.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageServer({\n * getCookie: (name) => req.cookies[name],\n * setCookieStore: (name, value, attrs) => res.cookie(name, value, attrs),\n * getHeader: (name) => req.headers[name],\n * setHeader: (name, value) => res.setHeader(name, value),\n * });\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageServer = (options: LocaleStorageServerOptions) => ({\n getLocale: () => getLocaleFromStorageServer(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageServer(locale, options),\n});\n\n// ============================================================================\n// Deprecated: combined LocaleStorage\n// Use LocaleStorageClient or LocaleStorageServer instead\n// ============================================================================\n\n/**\n * @deprecated Use {@link LocaleStorageClientOptions} or {@link LocaleStorageServerOptions} instead.\n */\nexport type LocaleStorageOptions = LocaleStorageClientOptions &\n LocaleStorageServerOptions;\n\n/**\n * Retrieves the locale from all storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link getLocaleFromStorageClient} (browser) or\n * {@link getLocaleFromStorageServer} (server) instead.\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { locales } = internationalization;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n const readCookie = (name: string): string | undefined => {\n try {\n const fromOption = options?.getCookie?.(name);\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n // Browser fallback kept for backward compatibility\n return getCookie(name);\n };\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const value = readCookie(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && routing.storage.localStorage) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in all configured storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link setLocaleInStorageClient} (browser) or\n * {@link setLocaleInStorageServer} (server) instead.\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires: resolveExpiresToTimestamp(attributes.expires),\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in storage based on configuration.\n *\n * @deprecated Use {@link LocaleStorageClient} (browser) or\n * {@link LocaleStorageServer} (server) instead.\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":";;;;;;;;;;AAaA,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,mCACJ,QAAQ,IAAI,6CAA6C;;;;AAK3D,MAAM,qCACJ,QAAQ,IAAI,+CAA+C;;;;AAK7D,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;AA4CtD,MAAa,uBAAmD;CAC9D,YAAY,SACV,SAAS,OACN,MAAM,IAAI,CACV,MAAM,MAAM,EAAE,MAAM,CAAC,WAAW,GAAG,KAAK,GAAG,CAAC,EAC3C,MAAM,IAAI,CAAC;CACjB,mBAAmB,SAAiB,aAAa,QAAQ,KAAK;CAC9D,oBAAoB,SAAiB,eAAe,QAAQ,KAAK;CACjE,iBAAiB;CACjB,iBAAiB,MAAM,OAAO,eAC5B,YAAY,IAAI;EACd;EACA;EACA,MAAM,WAAW;EACjB,QAAQ,WAAW;EACnB,SAAS,WAAW;EACpB,UAAU,WAAW;EACtB,CAAC;CACJ,kBAAkB,OAAO,WAAW;AAElC,WAAS,SAAS;;CAEpB,oBAAoB,MAAM,UAAU,eAAe,QAAQ,MAAM,MAAM;CACvE,mBAAmB,MAAM,UAAU,aAAa,QAAQ,MAAM,MAAM;CACrE;;;;;;AAOD,MAAa,8BACX,UAAsC,yBACf;CACvB,MAAM,EAAE,YAAYA;AAEpB,KAAI,SAAS,oBAAoB,MAAO,QAAO;CAE/C,MAAM,iBAAiB,UACrB,CAAC,CAAC,SAAS,QAAQ,SAAS,MAAgB;AAE9C,KAAI,CAAC,2BACH,MAAK,I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AEG;;;AAKd,KACE,CAAC,oCACDF,+BAAQ,QAAQ,gBAChB,SAAS,iBAET,MAAK,IAAI,IAAI,GAAG,IAAIA,+BAAQ,QAAQ,aAAa,QAAQ,KAAK;EAC5D,MAAM,EAAE,SAASA,+BAAQ,QAAQ,aAAa;AAC9C,MAAI;AACF,OAAI,EAAE,SAAS,aAAa,SAAS,SAAS,kBAC5C;QAAI,QAAQ,iBAAiB,KAAK,CAAE;;AAEtC,WAAQ,iBAAiB,MAAM,OAAO;UAChC;;AAIZ,KACE,CAAC,sCACDA,+BAAQ,QAAQ,kBAChB,SAAS,kBAET,MAAK,IAAI,IAAI,GAAG,IAAIA,+BAAQ,QAAQ,eAAe,QAAQ,KAAK;EAC9D,MAAM,EAAE,SAASA,+BAAQ,QAAQ,eAAe;AAChD,MAAI;AACF,OAAI,EAAE,SAAS,aAAa,SAAS,SAAS,mBAC5C;QAAI,QAAQ,kBAAkB,KAAK,CAAE;;AAEvC,WAAQ,kBAAkB,MAAM,OAAO;UACjC;;AAIZ,KACE,CAAC,8BACDA,+BAAQ,QAAQ,WAChB,SAAS,UAET,MAAK,IAAI,IAAI,GAAG,IAAIA,+BAAQ,QAAQ,QAAQ,QAAQ,IAClD,KAAI;AACF,UAAQ,UAAUA,+BAAQ,QAAQ,QAAQ,GAAG,MAAM,OAAO;SACpD;;;;;;;;AAWd,MAAa,iBAAiB,aAAmC;CAC/D,iBAAiB,qBAAqB,QAAQ;CAC9C,YAAY,WAA0B,mBAAmB,QAAQ,QAAQ;CAC1E"}
1
+ {"version":3,"file":"localeStorage.cjs","names":["internationalization","routing","resolveExpiresToTimestamp","buildCookieString","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import { internationalization, routing } from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { buildCookieString, resolveExpiresToTimestamp } from './cookieExpiry';\nimport { getCookie } from './getCookie';\n\n// ── Tree-shake constants ──────────────────────────────────────────────────────\n// When these env vars are injected at build time, bundlers eliminate the\n// branches guarded by these constants.\n\n/**\n * True when cookie storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_COOKIES =\n process.env.INTLAYER_ROUTING_STORAGE_COOKIES === 'false';\n\n/**\n * True when localStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_LOCAL_STORAGE =\n process.env.INTLAYER_ROUTING_STORAGE_LOCALSTORAGE === 'false';\n\n/**\n * True when sessionStorage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_SESSION_STORAGE =\n process.env.INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE === 'false';\n\n/**\n * True when header storage is explicitly disabled at build time.\n */\nconst TREE_SHAKE_STORAGE_HEADERS =\n process.env.INTLAYER_ROUTING_STORAGE_HEADERS === 'false';\n\n// ============================================================================\n// Shared types\n// ============================================================================\n\nexport type CookieBuildAttributes = {\n domain?: string;\n path?: string;\n secure?: boolean;\n httpOnly?: boolean;\n sameSite?: 'strict' | 'lax' | 'none';\n /**\n * Absolute expiry as milliseconds since epoch, ready for `cookieStore.set()`.\n * Already resolved from the normalized `expires` by\n * `resolveExpiresToTimestamp`.\n */\n expires?: number | undefined;\n};\n\n// ============================================================================\n// Client-specific types and functions\n// (cookies via browser APIs, localStorage, sessionStorage — no headers)\n// ============================================================================\n\nexport type LocaleStorageClientOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n setSessionStorage?: (name: string, value: string) => void;\n getSessionStorage?: (name: string) => string | undefined | null;\n setLocaleStorage?: (name: string, value: string) => void;\n getLocaleStorage?: (name: string) => string | undefined | null;\n};\n\n// cookieStore is part of the experimental Cookie Store API\ndeclare const cookieStore: any;\n\nexport const localeStorageOptions: LocaleStorageClientOptions = {\n getCookie: (name: string) =>\n document.cookie\n .split(';')\n .find((c) => c.trim().startsWith(`${name}=`))\n ?.split('=')[1],\n getLocaleStorage: (name: string) => localStorage.getItem(name),\n getSessionStorage: (name: string) => sessionStorage.getItem(name),\n isCookieEnabled: true,\n setCookieStore: (name, value, attributes) =>\n cookieStore.set({\n name,\n value,\n path: attributes.path,\n domain: attributes.domain,\n expires: attributes.expires,\n sameSite: attributes.sameSite,\n }),\n setCookieString: (_name, cookie) => {\n // biome-ignore lint/suspicious/noDocumentCookie: set cookie fallback\n document.cookie = cookie;\n },\n setSessionStorage: (name, value) => sessionStorage.setItem(name, value),\n setLocaleStorage: (name, value) => localStorage.setItem(name, value),\n};\n\n/**\n * Retrieves the locale from browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not read from headers — use `getLocaleFromStorageServer` for that.\n */\nexport const getLocaleFromStorageClient = (\n options: LocaleStorageClientOptions = localeStorageOptions\n): Locale | undefined => {\n const { locales } = internationalization;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n if (!TREE_SHAKE_STORAGE_COOKIES) {\n for (let i = 0; i < (routing.storage.cookies ?? []).length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.cookies![i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE) {\n for (let i = 0; i < (routing.storage.localStorage ?? []).length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage![i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in browser storage mechanisms\n * (cookies, localStorage, sessionStorage).\n * Does not write to headers — use `setLocaleInStorageServer` for that.\n */\nexport const setLocaleInStorageClient = (\n locale: LocalesValues,\n options?: LocaleStorageClientOptions\n): void => {\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires: resolveExpiresToTimestamp(attributes.expires),\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Client-side locale storage utility.\n * Handles cookies (browser), localStorage and sessionStorage.\n * Does not access headers.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageClient(localeStorageOptions);\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageClient = (options: LocaleStorageClientOptions) => ({\n getLocale: () => getLocaleFromStorageClient(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageClient(locale, options),\n});\n\n// ============================================================================\n// Server-specific types and functions\n// (cookies via injected getter/setter, headers — no localStorage/sessionStorage)\n// ============================================================================\n\nexport type LocaleStorageServerOptions = {\n overwrite?: boolean;\n isCookieEnabled?: boolean;\n setCookieStore?: (\n name: string,\n value: string,\n cookie: CookieBuildAttributes\n ) => void;\n setCookieString?: (name: string, cookie: string) => void;\n getCookie?: (name: string) => string | undefined | null;\n getHeader?: (name: string) => string | undefined | null;\n setHeader?: (name: string, value: string) => void;\n};\n\n/**\n * Retrieves the locale from server-side storage mechanisms (cookies, headers).\n * Does not access localStorage or sessionStorage.\n * No browser cookie fallback — the caller must provide `getCookie`.\n */\nexport const getLocaleFromStorageServer = (\n options: LocaleStorageServerOptions\n): Locale | undefined => {\n const { locales } = internationalization;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n try {\n const value = options?.getCookie?.(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in server-side storage mechanisms (cookies, headers).\n * Does not write to localStorage or sessionStorage.\n */\nexport const setLocaleInStorageServer = (\n locale: LocalesValues,\n options?: LocaleStorageServerOptions\n): void => {\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires: resolveExpiresToTimestamp(attributes.expires),\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Server-side locale storage utility.\n * Handles cookies (via injected getter/setter) and headers.\n * Does not access localStorage or sessionStorage.\n *\n * @example\n * ```ts\n * const storage = LocaleStorageServer({\n * getCookie: (name) => req.cookies[name],\n * setCookieStore: (name, value, attrs) => res.cookie(name, value, attrs),\n * getHeader: (name) => req.headers[name],\n * setHeader: (name, value) => res.setHeader(name, value),\n * });\n * const locale = storage.getLocale();\n * storage.setLocale('fr');\n * ```\n */\nexport const LocaleStorageServer = (options: LocaleStorageServerOptions) => ({\n getLocale: () => getLocaleFromStorageServer(options),\n setLocale: (locale: LocalesValues) =>\n setLocaleInStorageServer(locale, options),\n});\n\n// ============================================================================\n// Deprecated: combined LocaleStorage\n// Use LocaleStorageClient or LocaleStorageServer instead\n// ============================================================================\n\n/**\n * @deprecated Use {@link LocaleStorageClientOptions} or {@link LocaleStorageServerOptions} instead.\n */\nexport type LocaleStorageOptions = LocaleStorageClientOptions &\n LocaleStorageServerOptions;\n\n/**\n * Retrieves the locale from all storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link getLocaleFromStorageClient} (browser) or\n * {@link getLocaleFromStorageServer} (server) instead.\n */\nexport const getLocaleFromStorage = (\n options: Pick<\n LocaleStorageOptions,\n | 'getCookie'\n | 'getSessionStorage'\n | 'getLocaleStorage'\n | 'getHeader'\n | 'isCookieEnabled'\n >\n): Locale | undefined => {\n const { locales } = internationalization;\n\n if (options?.isCookieEnabled === false) return undefined;\n\n const isValidLocale = (value: string | null | undefined): value is Locale =>\n !!value && locales.includes(value as Locale);\n\n const readCookie = (name: string): string | undefined => {\n try {\n const fromOption = options?.getCookie?.(name);\n if (fromOption !== null && fromOption !== undefined) return fromOption;\n } catch {}\n // Browser fallback kept for backward compatibility\n return getCookie(name);\n };\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const value = readCookie(routing.storage.cookies[i].name);\n if (isValidLocale(value)) return value;\n }\n }\n\n if (!TREE_SHAKE_STORAGE_LOCAL_STORAGE && routing.storage.localStorage) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n try {\n const value = options?.getLocaleStorage?.(\n routing.storage.localStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_SESSION_STORAGE && routing.storage.sessionStorage) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n try {\n const value = options?.getSessionStorage?.(\n routing.storage.sessionStorage[i].name\n );\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n\n if (!TREE_SHAKE_STORAGE_HEADERS && routing.storage.headers) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n const value = options?.getHeader?.(routing.storage.headers[i].name);\n if (isValidLocale(value)) return value;\n } catch {}\n }\n }\n};\n\n/**\n * Stores the locale in all configured storage mechanisms\n * (cookies, localStorage, sessionStorage, headers).\n *\n * @deprecated Use {@link setLocaleInStorageClient} (browser) or\n * {@link setLocaleInStorageServer} (server) instead.\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n options?: LocaleStorageOptions\n): void => {\n if (options?.isCookieEnabled === false) return;\n\n if (!TREE_SHAKE_STORAGE_COOKIES && routing.storage.cookies) {\n for (let i = 0; i < routing.storage.cookies.length; i++) {\n const { name, attributes } = routing.storage.cookies[i];\n try {\n if (options?.setCookieStore) {\n options.setCookieStore(name, locale, {\n ...attributes,\n expires: resolveExpiresToTimestamp(attributes.expires),\n });\n }\n } catch {\n try {\n if (options?.setCookieString) {\n options.setCookieString(\n name,\n buildCookieString(name, locale, attributes)\n );\n }\n } catch {}\n }\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_LOCAL_STORAGE &&\n routing.storage.localStorage &&\n options?.setLocaleStorage\n ) {\n for (let i = 0; i < routing.storage.localStorage.length; i++) {\n const { name } = routing.storage.localStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getLocaleStorage) {\n if (options.getLocaleStorage(name)) continue;\n }\n options.setLocaleStorage(name, locale);\n } catch {}\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_SESSION_STORAGE &&\n routing.storage.sessionStorage &&\n options?.setSessionStorage\n ) {\n for (let i = 0; i < routing.storage.sessionStorage.length; i++) {\n const { name } = routing.storage.sessionStorage[i];\n try {\n if (!(options?.overwrite ?? true) && options?.getSessionStorage) {\n if (options.getSessionStorage(name)) continue;\n }\n options.setSessionStorage(name, locale);\n } catch {}\n }\n }\n\n if (\n !TREE_SHAKE_STORAGE_HEADERS &&\n routing.storage.headers &&\n options?.setHeader\n ) {\n for (let i = 0; i < routing.storage.headers.length; i++) {\n try {\n options.setHeader(routing.storage.headers[i].name, locale);\n } catch {}\n }\n }\n};\n\n/**\n * Utility object to get and set the locale in storage based on configuration.\n *\n * @deprecated Use {@link LocaleStorageClient} (browser) or\n * {@link LocaleStorageServer} (server) instead.\n */\nexport const LocaleStorage = (options: LocaleStorageOptions) => ({\n getLocale: () => getLocaleFromStorage(options),\n setLocale: (locale: LocalesValues) => setLocaleInStorage(locale, options),\n});\n"],"mappings":";;;;;;;;;AAaA,MAAM,6BACJ,QAAQ,IAAI,qCAAqC;;;;AAKnD,MAAM,mCACJ,QAAQ,IAAI,0CAA0C;;;;AAKxD,MAAM,qCACJ,QAAQ,IAAI,4CAA4C;;;;AAK1D,MAAM,6BACJ,QAAQ,IAAI,qCAAqC;AA4CnD,MAAa,uBAAmD;CAC9D,YAAY,SACV,SAAS,OACN,MAAM,GAAG,CAAC,CACV,MAAM,MAAM,EAAE,KAAK,CAA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S,aAAa,SAAS,SAAS,kBAC5C;QAAI,QAAQ,iBAAiB,IAAI,GAAG;GAAQ;GAE9C,QAAQ,iBAAiB,MAAM,MAAM;EACvC,QAAQ,CAAC;CACX;CAGF,IACE,CAAC,sCACDA,+BAAQ,QAAQ,kBAChB,SAAS,mBAET,KAAK,IAAI,IAAI,GAAG,IAAIA,+BAAQ,QAAQ,eAAe,QAAQ,KAAK;EAC9D,MAAM,EAAE,SAASA,+BAAQ,QAAQ,eAAe;EAChD,IAAI;GACF,IAAI,EAAE,SAAS,aAAa,SAAS,SAAS,mBAC5C;QAAI,QAAQ,kBAAkB,IAAI,GAAG;GAAQ;GAE/C,QAAQ,kBAAkB,MAAM,MAAM;EACxC,QAAQ,CAAC;CACX;CAGF,IACE,CAAC,8BACDA,+BAAQ,QAAQ,WAChB,SAAS,WAET,KAAK,IAAI,IAAI,GAAG,IAAIA,+BAAQ,QAAQ,QAAQ,QAAQ,KAClD,IAAI;EACF,QAAQ,UAAUA,+BAAQ,QAAQ,QAAQ,EAAE,CAAC,MAAM,MAAM;CAC3D,QAAQ,CAAC;AAGf;;;;;;;AAQA,MAAa,iBAAiB,aAAmC;CAC/D,iBAAiB,qBAAqB,OAAO;CAC7C,YAAY,WAA0B,mBAAmB,QAAQ,OAAO;AAC1E"}
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  //#region src/utils/parseYaml.ts
4
- const PRESERVED_LITERALS = new Set([
4
+ const PRESERVED_LITERALS = /* @__PURE__ */ new Set([
5
5
  "true",
6
6
  "false",
7
7
  "null",
@@ -1 +1 @@
1
- {"version":3,"file":"parseYaml.cjs","names":[],"sources":["../../../src/utils/parseYaml.ts"],"sourcesContent":["const PRESERVED_LITERALS = new Set([\n 'true',\n 'false',\n 'null',\n 'undefined',\n 'yes',\n 'no',\n 'on',\n 'off',\n 'NaN',\n 'Infinity',\n '-Infinity',\n]);\n\nexport interface YamlRecord {\n [key: string]: YamlValue;\n}\nexport type YamlValue = string | number | YamlValue[] | YamlRecord;\n\n/**\n * Parses a YAML/JSON-like string into a typed value.\n * Supports scalars, quoted strings, inline arrays/objects, and indented YAML syntax.\n * Boolean/null literals (true, false, null, yes, no, etc.) are preserved as strings,\n * not coerced to their native JS equivalents.\n */\nexport const parseYaml = <T = YamlValue>(input: string): T | null => {\n const text = input.trim();\n\n if (!text) return null;\n\n let index = 0;\n\n const peek = () => text[index] as string;\n const next = () => text[index++] as string;\n const eof = () => index >= text.length;\n\n const skipWhitespace = () => {\n while (!eof() && ' \\n\\t\\r'.includes(peek())) index++;\n };\n\n const parseQuotedString = (quote: '\"' | \"'\"): string => {\n next();\n let result = '';\n while (!eof()) {\n const ch = next();\n\n if (ch === quote) return result;\n\n if (ch === '\\\\' && !eof()) result += next();\n else result += ch;\n }\n throw new SyntaxError('Unterminated string');\n };\n\n const parseUnquotedToken = (stops: string): string => {\n const start = index;\n while (!eof() && !stops.includes(peek())) index++;\n return text.slice(start, index).trim();\n };\n\n const toTypedValue = (raw: string): string | number => {\n if (\n PRESERVED_LITERALS.has(raw) ||\n /^0x[0-9a-fA-F]+$/.test(raw) ||\n /^#/.test(raw)\n ) {\n return raw;\n }\n\n if (/^-?\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?$/i.test(raw)) {\n // 3.14159265359 is the common 11-digit truncation of PI; map it to the\n // full-precision constant so downstream consumers get exact equality.\n if (raw === '3.14159265359') return Math.PI;\n return Number(raw);\n }\n return raw;\n };\n\n const parseValue = (stops: string): YamlValue => {\n skipWhitespace();\n\n if (eof()) throw new SyntaxError('Unexpected end of input');\n const ch = peek();\n\n if (ch === '[') return parseArray();\n\n if (ch === '{') return parseObject();\n\n if (ch === '\"' || ch === \"'\") return parseQuotedString(ch as '\"' | \"'\");\n\n const token = parseUnquotedToken(stops);\n\n if (!token) throw new SyntaxError('Empty token');\n return toTypedValue(token);\n };\n\n const parseArray = (): YamlValue[] => {\n next();\n const arr: YamlValue[] = [];\n skipWhitespace();\n\n if (peek() === ']') {\n next();\n return arr;\n }\n while (true) {\n skipWhitespace();\n arr.push(parseValue(',]'));\n skipWhitespace();\n\n const ch = next();\n\n if (ch === ']') break;\n\n if (ch !== ',')\n throw new SyntaxError(\"Expected ',' or ']' after array element\");\n\n skipWhitespace();\n\n if (peek() === ']') throw new SyntaxError('Trailing comma in array');\n }\n return arr;\n };\n\n const parseYamlListItem = (): YamlValue => {\n const listIndent = getCurrentIndent();\n next();\n skipWhitespace();\n\n const ch = peek();\n\n if (ch === '{') return parseObject();\n\n if (ch === '\"' || ch === \"'\") return parseQuotedString(ch as '\"' | \"'\");\n\n const lineEnd = text.indexOf('\\n', index);\n const line = text.slice(index, lineEnd === -1 ? text.length : lineEnd);\n\n if (/:/.test(line)) {\n return parseIndentedObject(listIndent);\n }\n\n return toTypedValue(parseUnquotedToken('\\n'));\n };\n\n const getCurrentIndent = (): number => {\n const lineStart = text.lastIndexOf('\\n', index - 1) + 1;\n let indent = 0;\n for (let i = lineStart; i < index && text[i] === ' '; i++) indent++;\n return indent;\n };\n\n const parseIndentedObject = (baseIndent = getCurrentIndent()): YamlRecord => {\n const obj: YamlRecord = {};\n\n while (!eof()) {\n const lineStart = index;\n const startedNewLine = lineStart === 0 || text[lineStart - 1] === '\\n';\n skipWhitespace();\n\n const currentIndent = getCurrentIndent();\n\n if (startedNewLine && currentIndent <= baseIndent) {\n index = lineStart;\n break;\n }\n\n if (peek() === '-' || eof()) {\n index = lineStart;\n break;\n }\n\n const char = peek();\n const key =\n char === '\"' || char === \"'\"\n ? parseQuotedString(char as '\"' | \"'\")\n : parseUnquotedToken(':');\n\n if (eof() || next() !== ':') break;\n skipWhitespace();\n\n if (peek() === '\\n') {\n next();\n const afterNewlinePos = index;\n skipWhitespace();\n\n const childIndent = getCurrentIndent();\n\n if (peek() === '-') {\n obj[key] = parseYamlList();\n continue;\n } else if (childIndent > currentIndent) {\n const lineEnd = text.indexOf('\\n', index);\n const line = text.slice(\n index,\n lineEnd === -1 ? text.length : lineEnd\n );\n if (/:/.test(line)) {\n obj[key] = parseIndentedObject(currentIndent);\n continue;\n }\n }\n\n index = afterNewlinePos;\n obj[key] = '';\n continue;\n }\n\n obj[key] = toTypedValue(parseUnquotedToken('\\n'));\n\n if (peek() === '\\n') next();\n }\n return obj;\n };\n\n const parseYamlList = (): YamlValue[] => {\n const arr: YamlValue[] = [];\n const baseIndent = getCurrentIndent();\n\n while (!eof()) {\n while (!eof() && ' \\n\\t\\r'.includes(peek()) && peek() !== '-') next();\n\n if (eof() || getCurrentIndent() < baseIndent || peek() !== '-') break;\n arr.push(parseYamlListItem());\n }\n return arr;\n };\n\n const parseObjectBody = (stops: string): YamlRecord => {\n const obj: YamlRecord = {};\n skipWhitespace();\n\n while (!eof() && !stops.includes(peek())) {\n const char = peek();\n const key =\n char === '\"' || char === \"'\"\n ? parseQuotedString(char as '\"' | \"'\")\n : parseUnquotedToken(`:\\n${stops}`);\n\n if (!key) return obj;\n\n if (eof() || next() !== ':')\n throw new SyntaxError(\"Expected ':' after key\");\n\n if (peek() === ' ') next();\n while (!eof() && ' \\t'.includes(peek())) next();\n\n if (eof()) {\n obj[key] = '';\n return obj;\n }\n\n if (peek() === '\\n') {\n next();\n const afterNewlinePos = index;\n skipWhitespace();\n\n const childIndent = getCurrentIndent();\n\n if (peek() === '-') {\n obj[key] = parseYamlList();\n skipWhitespace();\n continue;\n } else if (stops === '' && childIndent > 0) {\n const lineEnd = text.indexOf('\\n', index);\n const line = text.slice(\n index,\n lineEnd === -1 ? text.length : lineEnd\n );\n if (/:/.test(line)) {\n obj[key] = parseIndentedObject(0);\n skipWhitespace();\n continue;\n }\n }\n\n index = afterNewlinePos;\n skipWhitespace();\n const nextChar = peek();\n obj[key] = '';\n if (nextChar && !stops.includes(nextChar) && nextChar !== '-') continue;\n return obj;\n }\n\n obj[key] = parseValue(stops.includes('}') ? `,\\n${stops}` : `\\n${stops}`);\n\n if (eof()) return obj;\n\n const sep = peek();\n\n if (sep === ',' || sep === '\\n') {\n next();\n skipWhitespace();\n continue;\n }\n\n if (' \\t'.includes(sep)) {\n while (!eof() && ' \\t'.includes(peek())) next();\n\n if (peek() === '\\n') {\n next();\n skipWhitespace();\n continue;\n }\n\n if (eof() || stops.includes(peek())) return obj;\n continue;\n }\n\n if (stops.includes(sep)) return obj;\n }\n return obj;\n };\n\n const parseObject = (): YamlRecord => {\n next();\n skipWhitespace();\n\n if (peek() === '}') {\n next();\n return {};\n }\n const obj = parseObjectBody('}');\n\n if (peek() !== '}') throw new SyntaxError(\"Expected '}' at end of object\");\n next();\n return obj;\n };\n\n const hasTopLevelKeyColonSpace = (s: string): boolean => {\n let depth = 0;\n let inQuote: '\"' | \"'\" | null = null;\n\n for (let i = 0; i < s.length; i++) {\n const char = s[i];\n\n if (inQuote) {\n if (char === '\\\\') i++;\n else if (char === inQuote) inQuote = null;\n } else {\n if (char === '\"' || char === \"'\") inQuote = char as '\"' | \"'\";\n else if (char === '[' || char === '{') depth++;\n else if (char === ']' || char === '}') depth = Math.max(0, depth - 1);\n else if (depth === 0 && char === ':') {\n const nextCh = s[i + 1];\n\n if (!nextCh || ' \\n'.includes(nextCh)) return true;\n }\n }\n }\n return false;\n };\n\n if (text.startsWith(']') || text.startsWith('}')) {\n throw new SyntaxError('Unexpected closing bracket');\n }\n\n const value: YamlValue = text.startsWith('[')\n ? parseArray()\n : text.startsWith('{')\n ? parseObject()\n : hasTopLevelKeyColonSpace(text)\n ? parseObjectBody('')\n : parseValue('');\n\n skipWhitespace();\n\n if (!eof()) throw new SyntaxError('Unexpected trailing characters');\n\n return value as T;\n};\n"],"mappings":";;;AAAA,MAAM,qBAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;;;;;;;AAaF,MAAa,aAA4B,UAA4B;CACnE,MAAM,OAAO,MAAM,MAAM;AAEzB,KAAI,CAAC,KAAM,QAAO;CAElB,IAAI,QAAQ;CAEZ,MA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;;AAGF,OAAI,MAAM,SAAS,IAAI,CAAE,QAAO;;AAElC,SAAO;;CAGT,MAAM,oBAAgC;AACpC,QAAM;AACN,kBAAgB;AAEhB,MAAI,MAAM,KAAK,KAAK;AAClB,SAAM;AACN,UAAO,EAAE;;EAEX,MAAM,MAAM,gBAAgB,IAAI;AAEhC,MAAI,MAAM,KAAK,IAAK,OAAM,IAAI,YAAY,gCAAgC;AAC1E,QAAM;AACN,SAAO;;CAGT,MAAM,4BAA4B,MAAuB;EACvD,IAAI,QAAQ;EACZ,IAAI,UAA4B;AAEhC,OAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;GACjC,MAAM,OAAO,EAAE;AAEf,OAAI,SACF;QAAI,SAAS,KAAM;aACV,SAAS,QAAS,WAAU;cAEjC,SAAS,QAAO,SAAS,IAAK,WAAU;YACnC,SAAS,OAAO,SAAS,IAAK;YAC9B,SAAS,OAAO,SAAS,IAAK,SAAQ,KAAK,IAAI,GAAG,QAAQ,EAAE;YAC5D,UAAU,KAAK,SAAS,KAAK;IACpC,MAAM,SAAS,EAAE,IAAI;AAErB,QAAI,CAAC,UAAU,MAAM,SAAS,OAAO,CAAE,QAAO;;;AAIpD,SAAO;;AAGT,KAAI,KAAK,WAAW,IAAI,IAAI,KAAK,WAAW,IAAI,CAC9C,OAAM,IAAI,YAAY,6BAA6B;CAGrD,MAAM,QAAmB,KAAK,WAAW,IAAI,GACzC,YAAY,GACZ,KAAK,WAAW,IAAI,GAClB,aAAa,GACb,yBAAyB,KAAK,GAC5B,gBAAgB,GAAG,GACnB,WAAW,GAAG;AAEtB,iBAAgB;AAEhB,KAAI,CAAC,KAAK,CAAE,OAAM,IAAI,YAAY,iCAAiC;AAEnE,QAAO"}
1
+ {"version":3,"file":"parseYaml.cjs","names":[],"sources":["../../../src/utils/parseYaml.ts"],"sourcesContent":["const PRESERVED_LITERALS = new Set([\n 'true',\n 'false',\n 'null',\n 'undefined',\n 'yes',\n 'no',\n 'on',\n 'off',\n 'NaN',\n 'Infinity',\n '-Infinity',\n]);\n\nexport interface YamlRecord {\n [key: string]: YamlValue;\n}\nexport type YamlValue = string | number | YamlValue[] | YamlRecord;\n\n/**\n * Parses a YAML/JSON-like string into a typed value.\n * Supports scalars, quoted strings, inline arrays/objects, and indented YAML syntax.\n * Boolean/null literals (true, false, null, yes, no, etc.) are preserved as strings,\n * not coerced to their native JS equivalents.\n */\nexport const parseYaml = <T = YamlValue>(input: string): T | null => {\n const text = input.trim();\n\n if (!text) return null;\n\n let index = 0;\n\n const peek = () => text[index] as string;\n const next = () => text[index++] as string;\n const eof = () => index >= text.length;\n\n const skipWhitespace = () => {\n while (!eof() && ' \\n\\t\\r'.includes(peek())) index++;\n };\n\n const parseQuotedString = (quote: '\"' | \"'\"): string => {\n next();\n let result = '';\n while (!eof()) {\n const ch = next();\n\n if (ch === quote) return result;\n\n if (ch === '\\\\' && !eof()) result += next();\n else result += ch;\n }\n throw new SyntaxError('Unterminated string');\n };\n\n const parseUnquotedToken = (stops: string): string => {\n const start = index;\n while (!eof() && !stops.includes(peek())) index++;\n return text.slice(start, index).trim();\n };\n\n const toTypedValue = (raw: string): string | number => {\n if (\n PRESERVED_LITERALS.has(raw) ||\n /^0x[0-9a-fA-F]+$/.test(raw) ||\n /^#/.test(raw)\n ) {\n return raw;\n }\n\n if (/^-?\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?$/i.test(raw)) {\n // 3.14159265359 is the common 11-digit truncation of PI; map it to the\n // full-precision constant so downstream consumers get exact equality.\n if (raw === '3.14159265359') return Math.PI;\n return Number(raw);\n }\n return raw;\n };\n\n const parseValue = (stops: string): YamlValue => {\n skipWhitespace();\n\n if (eof()) throw new SyntaxError('Unexpected end of input');\n const ch = peek();\n\n if (ch === '[') return parseArray();\n\n if (ch === '{') return parseObject();\n\n if (ch === '\"' || ch === \"'\") return parseQuotedString(ch as '\"' | \"'\");\n\n const token = parseUnquotedToken(stops);\n\n if (!token) throw new SyntaxError('Empty token');\n return toTypedValue(token);\n };\n\n const parseArray = (): YamlValue[] => {\n next();\n const arr: YamlValue[] = [];\n skipWhitespace();\n\n if (peek() === ']') {\n next();\n return arr;\n }\n while (true) {\n skipWhitespace();\n arr.push(parseValue(',]'));\n skipWhitespace();\n\n const ch = next();\n\n if (ch === ']') break;\n\n if (ch !== ',')\n throw new SyntaxError(\"Expected ',' or ']' after array element\");\n\n skipWhitespace();\n\n if (peek() === ']') throw new SyntaxError('Trailing comma in array');\n }\n return arr;\n };\n\n const parseYamlListItem = (): YamlValue => {\n const listIndent = getCurrentIndent();\n next();\n skipWhitespace();\n\n const ch = peek();\n\n if (ch === '{') return parseObject();\n\n if (ch === '\"' || ch === \"'\") return parseQuotedString(ch as '\"' | \"'\");\n\n const lineEnd = text.indexOf('\\n', index);\n const line = text.slice(index, lineEnd === -1 ? text.length : lineEnd);\n\n if (/:/.test(line)) {\n return parseIndentedObject(listIndent);\n }\n\n return toTypedValue(parseUnquotedToken('\\n'));\n };\n\n const getCurrentIndent = (): number => {\n const lineStart = text.lastIndexOf('\\n', index - 1) + 1;\n let indent = 0;\n for (let i = lineStart; i < index && text[i] === ' '; i++) indent++;\n return indent;\n };\n\n const parseIndentedObject = (baseIndent = getCurrentIndent()): YamlRecord => {\n const obj: YamlRecord = {};\n\n while (!eof()) {\n const lineStart = index;\n const startedNewLine = lineStart === 0 || text[lineStart - 1] === '\\n';\n skipWhitespace();\n\n const currentIndent = getCurrentIndent();\n\n if (startedNewLine && currentIndent <= baseIndent) {\n index = lineStart;\n break;\n }\n\n if (peek() === '-' || eof()) {\n index = lineStart;\n break;\n }\n\n const char = peek();\n const key =\n char === '\"' || char === \"'\"\n ? parseQuotedString(char as '\"' | \"'\")\n : parseUnquotedToken(':');\n\n if (eof() || next() !== ':') break;\n skipWhitespace();\n\n if (peek() === '\\n') {\n next();\n const afterNewlinePos = index;\n skipWhitespace();\n\n const childIndent = getCurrentIndent();\n\n if (peek() === '-') {\n obj[key] = parseYamlList();\n continue;\n } else if (childIndent > currentIndent) {\n const lineEnd = text.indexOf('\\n', index);\n const line = text.slice(\n index,\n lineEnd === -1 ? text.length : lineEnd\n );\n if (/:/.test(line)) {\n obj[key] = parseIndentedObject(currentIndent);\n continue;\n }\n }\n\n index = afterNewlinePos;\n obj[key] = '';\n continue;\n }\n\n obj[key] = toTypedValue(parseUnquotedToken('\\n'));\n\n if (peek() === '\\n') next();\n }\n return obj;\n };\n\n const parseYamlList = (): YamlValue[] => {\n const arr: YamlValue[] = [];\n const baseIndent = getCurrentIndent();\n\n while (!eof()) {\n while (!eof() && ' \\n\\t\\r'.includes(peek()) && peek() !== '-') next();\n\n if (eof() || getCurrentIndent() < baseIndent || peek() !== '-') break;\n arr.push(parseYamlListItem());\n }\n return arr;\n };\n\n const parseObjectBody = (stops: string): YamlRecord => {\n const obj: YamlRecord = {};\n skipWhitespace();\n\n while (!eof() && !stops.includes(peek())) {\n const char = peek();\n const key =\n char === '\"' || char === \"'\"\n ? parseQuotedString(char as '\"' | \"'\")\n : parseUnquotedToken(`:\\n${stops}`);\n\n if (!key) return obj;\n\n if (eof() || next() !== ':')\n throw new SyntaxError(\"Expected ':' after key\");\n\n if (peek() === ' ') next();\n while (!eof() && ' \\t'.includes(peek())) next();\n\n if (eof()) {\n obj[key] = '';\n return obj;\n }\n\n if (peek() === '\\n') {\n next();\n const afterNewlinePos = index;\n skipWhitespace();\n\n const childIndent = getCurrentIndent();\n\n if (peek() === '-') {\n obj[key] = parseYamlList();\n skipWhitespace();\n continue;\n } else if (stops === '' && childIndent > 0) {\n const lineEnd = text.indexOf('\\n', index);\n const line = text.slice(\n index,\n lineEnd === -1 ? text.length : lineEnd\n );\n if (/:/.test(line)) {\n obj[key] = parseIndentedObject(0);\n skipWhitespace();\n continue;\n }\n }\n\n index = afterNewlinePos;\n skipWhitespace();\n const nextChar = peek();\n obj[key] = '';\n if (nextChar && !stops.includes(nextChar) && nextChar !== '-') continue;\n return obj;\n }\n\n obj[key] = parseValue(stops.includes('}') ? `,\\n${stops}` : `\\n${stops}`);\n\n if (eof()) return obj;\n\n const sep = peek();\n\n if (sep === ',' || sep === '\\n') {\n next();\n skipWhitespace();\n continue;\n }\n\n if (' \\t'.includes(sep)) {\n while (!eof() && ' \\t'.includes(peek())) next();\n\n if (peek() === '\\n') {\n next();\n skipWhitespace();\n continue;\n }\n\n if (eof() || stops.includes(peek())) return obj;\n continue;\n }\n\n if (stops.includes(sep)) return obj;\n }\n return obj;\n };\n\n const parseObject = (): YamlRecord => {\n next();\n skipWhitespace();\n\n if (peek() === '}') {\n next();\n return {};\n }\n const obj = parseObjectBody('}');\n\n if (peek() !== '}') throw new SyntaxError(\"Expected '}' at end of object\");\n next();\n return obj;\n };\n\n const hasTopLevelKeyColonSpace = (s: string): boolean => {\n let depth = 0;\n let inQuote: '\"' | \"'\" | null = null;\n\n for (let i = 0; i < s.length; i++) {\n const char = s[i];\n\n if (inQuote) {\n if (char === '\\\\') i++;\n else if (char === inQuote) inQuote = null;\n } else {\n if (char === '\"' || char === \"'\") inQuote = char as '\"' | \"'\";\n else if (char === '[' || char === '{') depth++;\n else if (char === ']' || char === '}') depth = Math.max(0, depth - 1);\n else if (depth === 0 && char === ':') {\n const nextCh = s[i + 1];\n\n if (!nextCh || ' \\n'.includes(nextCh)) return true;\n }\n }\n }\n return false;\n };\n\n if (text.startsWith(']') || text.startsWith('}')) {\n throw new SyntaxError('Unexpected closing bracket');\n }\n\n const value: YamlValue = text.startsWith('[')\n ? parseArray()\n : text.startsWith('{')\n ? parseObject()\n : hasTopLevelKeyColonSpace(text)\n ? parseObjectBody('')\n : parseValue('');\n\n skipWhitespace();\n\n if (!eof()) throw new SyntaxError('Unexpected trailing characters');\n\n return value as T;\n};\n"],"mappings":";;;AAAA,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;AAaD,MAAa,aAA4B,UAA4B;CACnE,MAAM,OAAO,MAAM,K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AAgC;CAElE,OAAO;AACT"}
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  //#region src/utils/stringifyYaml.ts
4
4
  const NEEDS_QUOTING = /[\n\r\t#:{}[\],&*?|<>=!%@`'"\\]|^[-?!]|\s$|^\s|^[>|]|^[.]{2,}/;
5
- const PRESERVED_LITERALS = new Set([
5
+ const PRESERVED_LITERALS = /* @__PURE__ */ new Set([
6
6
  "true",
7
7
  "false",
8
8
  "null",
@@ -1 +1 @@
1
- {"version":3,"file":"stringifyYaml.cjs","names":[],"sources":["../../../src/utils/stringifyYaml.ts"],"sourcesContent":["// Characters/patterns in a string that require quoting in YAML\nconst NEEDS_QUOTING =\n /[\\n\\r\\t#:{}[\\],&*?|<>=!%@`'\"\\\\]|^[-?!]|\\s$|^\\s|^[>|]|^[.]{2,}/;\n\n// Values that parseYaml treats as preserved literals (not typed conversions)\nconst PRESERVED_LITERALS = new Set([\n 'true',\n 'false',\n 'null',\n 'undefined',\n 'yes',\n 'no',\n 'on',\n 'off',\n 'NaN',\n 'Infinity',\n '-Infinity',\n]);\n\nconst serializeString = (value: string, indent: string): string => {\n if (value.includes('\\n')) {\n const lines = value.split('\\n');\n const body = lines.map((l) => `${indent} ${l}`).join('\\n');\n return `|\\n${body}`;\n }\n\n if (\n NEEDS_QUOTING.test(value) ||\n PRESERVED_LITERALS.has(value) ||\n /^-?\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?$/i.test(value)\n ) {\n return JSON.stringify(value);\n }\n\n return value;\n};\n\nconst serializeValue = (value: any, indent: string): string => {\n if (value === null || value === undefined) return 'null';\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return String(value);\n }\n\n if (typeof value === 'string') {\n return serializeString(value, indent);\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]';\n return value\n .map((item) => {\n const serialized = serializeValue(item, `${indent} `);\n if (\n typeof item === 'object' &&\n item !== null &&\n !Array.isArray(item) &&\n !serialized.startsWith(\"'\") &&\n !serialized.startsWith('\"')\n ) {\n // Object items: put first key inline with the dash\n const lines = serialized.split('\\n');\n return `${indent}- ${lines[0]}\\n${lines\n .slice(1)\n .map((l) => `${indent} ${l}`)\n .join('\\n')}`.trimEnd();\n }\n return `${indent}- ${serialized}`;\n })\n .join('\\n');\n }\n\n if (typeof value === 'object') {\n const entries = Object.entries(value).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return '{}';\n\n return entries\n .map(([k, value]) => {\n const key = /[\\s:{}[\\]]/.test(k) ? JSON.stringify(k) : k;\n const childIndent = `${indent} `;\n\n if (value === null || value === undefined) {\n return `${indent}${key}: null`;\n }\n\n if (typeof value === 'object' && !Array.isArray(value)) {\n const nested = serializeValue(value, childIndent);\n return `${indent}${key}:\\n${nested}`;\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return `${indent}${key}: []`;\n const nested = serializeValue(value, childIndent);\n return `${indent}${key}:\\n${nested}`;\n }\n\n return `${indent}${key}: ${serializeValue(value, indent)}`;\n })\n .join('\\n');\n }\n\n return String(value);\n};\n\nexport const stringifyYaml = (value: any): string =>\n `${serializeValue(value, '')}\\n`;\n"],"mappings":";;;AACA,MAAM,gBACJ;AAGF,MAAM,qBAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,mBAAmB,OAAe,WAA2B;AACjE,KAAI,MAAM,SAAS,KAAK,CAGtB,QAAO,MAFO,MAAM,MAAM,KACR,CAAC,KAAK,MAAM,GAAG,OAAO,IAAI,IAAI,CAAC,KAAK,KACrC;AAGnB,KACE,cAAc,KAAK,MAAM,IACzB,mBAAmB,IAAI,MAAM,IAC7B,mCAAmC,KAAK,MAAM,CAE9C,QAAO,KAAK,UAAU,MAAM;AAG9B,QAAO;;AAGT,MAAM,kBAAkB,OAAY,WAA2B;AAC7D,KAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAElD,KAAI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H;;AAGpC,UAAO,GAAG,SAAS,IAAI,IAAI,eAAe,OAAO,OAAO;IACxD,CACD,KAAK,KAAK;;AAGf,QAAO,OAAO,MAAM;;AAGtB,MAAa,iBAAiB,UAC5B,GAAG,eAAe,OAAO,GAAG,CAAC"}
1
+ {"version":3,"file":"stringifyYaml.cjs","names":[],"sources":["../../../src/utils/stringifyYaml.ts"],"sourcesContent":["// Characters/patterns in a string that require quoting in YAML\nconst NEEDS_QUOTING =\n /[\\n\\r\\t#:{}[\\],&*?|<>=!%@`'\"\\\\]|^[-?!]|\\s$|^\\s|^[>|]|^[.]{2,}/;\n\n// Values that parseYaml treats as preserved literals (not typed conversions)\nconst PRESERVED_LITERALS = new Set([\n 'true',\n 'false',\n 'null',\n 'undefined',\n 'yes',\n 'no',\n 'on',\n 'off',\n 'NaN',\n 'Infinity',\n '-Infinity',\n]);\n\nconst serializeString = (value: string, indent: string): string => {\n if (value.includes('\\n')) {\n const lines = value.split('\\n');\n const body = lines.map((l) => `${indent} ${l}`).join('\\n');\n return `|\\n${body}`;\n }\n\n if (\n NEEDS_QUOTING.test(value) ||\n PRESERVED_LITERALS.has(value) ||\n /^-?\\d+(?:\\.\\d+)?(?:e[+-]?\\d+)?$/i.test(value)\n ) {\n return JSON.stringify(value);\n }\n\n return value;\n};\n\nconst serializeValue = (value: any, indent: string): string => {\n if (value === null || value === undefined) return 'null';\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return String(value);\n }\n\n if (typeof value === 'string') {\n return serializeString(value, indent);\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return '[]';\n return value\n .map((item) => {\n const serialized = serializeValue(item, `${indent} `);\n if (\n typeof item === 'object' &&\n item !== null &&\n !Array.isArray(item) &&\n !serialized.startsWith(\"'\") &&\n !serialized.startsWith('\"')\n ) {\n // Object items: put first key inline with the dash\n const lines = serialized.split('\\n');\n return `${indent}- ${lines[0]}\\n${lines\n .slice(1)\n .map((l) => `${indent} ${l}`)\n .join('\\n')}`.trimEnd();\n }\n return `${indent}- ${serialized}`;\n })\n .join('\\n');\n }\n\n if (typeof value === 'object') {\n const entries = Object.entries(value).filter(([, v]) => v !== undefined);\n if (entries.length === 0) return '{}';\n\n return entries\n .map(([k, value]) => {\n const key = /[\\s:{}[\\]]/.test(k) ? JSON.stringify(k) : k;\n const childIndent = `${indent} `;\n\n if (value === null || value === undefined) {\n return `${indent}${key}: null`;\n }\n\n if (typeof value === 'object' && !Array.isArray(value)) {\n const nested = serializeValue(value, childIndent);\n return `${indent}${key}:\\n${nested}`;\n }\n\n if (Array.isArray(value)) {\n if (value.length === 0) return `${indent}${key}: []`;\n const nested = serializeValue(value, childIndent);\n return `${indent}${key}:\\n${nested}`;\n }\n\n return `${indent}${key}: ${serializeValue(value, indent)}`;\n })\n .join('\\n');\n }\n\n return String(value);\n};\n\nexport const stringifyYaml = (value: any): string =>\n `${serializeValue(value, '')}\\n`;\n"],"mappings":";;;AACA,MAAM,gBACJ;AAGF,MAAM,qCAAqB,IAAI,IAAI;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,mBAAmB,OAAe,WAA2B;CACjE,IAAI,MAAM,SAAS,IAAI,GAGrB,OAAO,MAFO,MAAM,MAAM,IACT,CAAC,CAAC,KAAK,MAAM,GAAG,OAAO,IAAI,GAAG,CAAC,CAAC,KAAK,IACtC;CAGlB,IACE,cAAc,KAAK,KAAK,KACxB,mBAAmB,IAAI,KAAK,KAC5B,mCAAmC,KAAK,KAAK,GAE7C,OAAO,KAAK,UAAU,KAAK;CAG7B,OAAO;AACT;AAEA,MAAM,kBAAkB,OAAY,WAA2B;CAC7D,IAAI,UAAU,QAAQ,UAAU,QAAW,OAAO;CAElD,IAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UACjD,OAAO,OAAO,KAAK;CAGrB,IAAI,OAAO,UAAU,UACnB,OAAO,gBAAgB,OAAO,MAAM;CAGtC,IAAI,MAAM,QAAQ,KAAK,GA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,OAAO,OAAO,KAAK;AACrB;AAEA,MAAa,iBAAiB,UAC5B,GAAG,eAAe,OAAO,EAAE,EAAE"}
@@ -23,7 +23,8 @@ const getEditedNode = (previous, next, defaultLocale) => {
23
23
  }
24
24
  if (isTypedNode(next)) {
25
25
  const { nodeType } = next;
26
- const editedInner = getEditedNode(isTypedNode(previous) ? previous[nodeType] : void 0, next[nodeType], defaultLocale);
26
+ const previousInner = isTypedNode(previous) ? previous[nodeType] : void 0;
27
+ const editedInner = getEditedNode(previousInner, next[nodeType], defaultLocale);
27
28
  if (typeof editedInner === "undefined") return;
28
29
  return {
29
30
  nodeType,
@@ -1 +1 @@
1
- {"version":3,"file":"getEditedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getEditedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\n/** A `translation` node, e.g. `{ nodeType: 'translation', translation: { en, fr } }`. */\ntype TranslationNode = {\n nodeType: typeof NodeTypes.TRANSLATION;\n [NodeTypes.TRANSLATION]: Record<string, unknown>;\n};\n\nconst isTranslationNode = (node: unknown): node is TranslationNode =>\n typeof node === 'object' &&\n node !== null &&\n (node as { nodeType?: unknown }).nodeType === NodeTypes.TRANSLATION;\n\nconst isTypedNode = (\n node: unknown\n): node is { nodeType: string; [key: string]: unknown } =>\n typeof node === 'object' &&\n node !== null &&\n !Array.isArray(node) &&\n typeof (node as { nodeType?: unknown }).nodeType === 'string';\n\n/** Structural equality for leaf source values (string / number / nested objects). */\nconst isSameValue = (a: unknown, b: unknown): boolean =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Recursively compares `next` against `previous` and returns the sub-tree of\n * `next` that holds only the nodes whose source-locale value was added or\n * changed. Returns `undefined` when nothing changed at this node.\n */\nconst getEditedNode = (\n previous: ContentNode | undefined,\n next: ContentNode,\n defaultLocale: LocalesValues\n): ContentNode | undefined => {\n // Translation node: compare the default-locale leaf only.\n if (isTranslationNode(next)) {\n const nextValue = next[NodeTypes.TRANSLATION]?.[defaultLocale as string];\n const previousValue = isTranslationNode(previous)\n ? previous[NodeTypes.TRANSLATION]?.[defaultLocale as string]\n : undefined;\n\n // Nothing to (re)translate if the source locale is absent.\n if (typeof nextValue === 'undefined') {\n return undefined;\n }\n\n // Include only when the source value was added or changed.\n if (isSameValue(previousValue, nextValue)) {\n return undefined;\n }\n\n // Reduce to the source locale only, so every target locale is regenerated.\n return {\n nodeType: NodeTypes.TRANSLATION,\n [NodeTypes.TRANSLATION]: { [defaultLocale as string]: nextValue },\n } as ContentNode;\n }\n\n // Other typed nodes (enumeration, condition, nested, …): recurse into the\n // wrapped value while preserving the wrapper so the partial stays valid.\n if (isTypedNode(next)) {\n const { nodeType } = next;\n const previousInner = isTypedNode(previous)\n ? (previous[nodeType] as ContentNode | undefined)\n : undefined;\n const editedInner = getEditedNode(\n previousInner,\n next[nodeType] as ContentNode,\n defaultLocale\n );\n\n if (typeof editedInner === 'undefined') {\n return undefined;\n }\n\n return {\n nodeType,\n [nodeType]: editedInner,\n } as ContentNode;\n }\n\n // Arrays: keep changed items reduced to source-only, unchanged items as-is to\n // preserve index alignment for `mergeDictionaries` (which merges by index).\n if (Array.isArray(next)) {\n const previousArray = Array.isArray(previous) ? previous : [];\n let hasChange = false;\n\n const result = next.map((child, index) => {\n const editedChild = getEditedNode(\n previousArray[index] as ContentNode | undefined,\n child as ContentNode,\n defaultLocale\n );\n if (typeof editedChild !== 'undefined') {\n hasChange = true;\n return editedChild;\n }\n // Unchanged item: keep the full node. It already has every locale, so the\n // complete-mode translation pass skips it and the merge leaves it intact.\n return child;\n });\n\n return hasChange ? (result as ContentNode) : undefined;\n }\n\n // Plain objects: recurse into each key, keeping only changed branches.\n if (typeof next === 'object' && next !== null) {\n const previousObject =\n typeof previous === 'object' &&\n previous !== null &&\n !Array.isArray(previous)\n ? (previous as Record<string, ContentNode>)\n : undefined;\n\n const result: Record<string, ContentNode> = {};\n let hasChange = false;\n\n for (const key of Object.keys(next as Record<string, ContentNode>)) {\n const editedChild = getEditedNode(\n previousObject?.[key],\n (next as Record<string, ContentNode>)[key],\n defaultLocale\n );\n if (typeof editedChild !== 'undefined') {\n result[key] = editedChild;\n hasChange = true;\n }\n }\n\n return hasChange ? (result as ContentNode) : undefined;\n }\n\n // Primitive leaves are not locale-aware on their own — nothing to translate.\n return undefined;\n};\n\n/**\n * Returns the partial content holding only the `translation` nodes whose\n * source (`defaultLocale`) value was added or changed between `previousContent`\n * and `newContent`. Each changed node is reduced to its source locale so that\n * every target locale is regenerated when the partial is translated.\n *\n * Returns `{}` (empty content) when no source value changed.\n *\n * @example\n * // default value of `title` changed → only `title` is returned, source-only\n * getEditedContent(\n * { title: t({ en: 'Old', fr: 'Vieux' }), body: t({ en: 'B', fr: 'B' }) },\n * { title: t({ en: 'New', fr: 'Vieux' }), body: t({ en: 'B', fr: 'B' }) },\n * 'en'\n * ); // → { title: { nodeType: 'translation', translation: { en: 'New' } } }\n */\nexport const getEditedContent = (\n previousContent: ContentNode | undefined,\n newContent: ContentNode,\n defaultLocale: LocalesValues\n): ContentNode =>\n getEditedNode(previousContent, newContent, defaultLocale) ??\n ({} as ContentNode);\n\n/**\n * Dictionary-level wrapper around {@link getEditedContent}. Returns a partial\n * dictionary (same `key`) whose `content` holds only the changed source nodes.\n *\n * @param previousDictionary - Dictionary state before the edit.\n * @param newDictionary - Dictionary state after the edit.\n * @param defaultLocale - The source locale to diff against.\n */\nexport const getEditedDictionary = (\n previousDictionary: Dictionary | undefined,\n newDictionary: Dictionary,\n defaultLocale: LocalesValues\n): Dictionary => ({\n ...newDictionary,\n content: getEditedContent(\n previousDictionary?.content,\n newDictionary.content,\n defaultLocale\n ),\n});\n"],"mappings":";;;AAUA,MAAM,qBAAqB,SACzB,OAAO,SAAS,YAChB,SAAS,QACR,KAAgC,aAAa,UAAU;AAE1D,MAAM,eACJ,SAEA,OAAO,S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B,KAAqC,MACtC,cACD;AACD,OAAI,OAAO,gBAAgB,aAAa;AACtC,WAAO,OAAO;AACd,gBAAY;;;AAIhB,SAAO,YAAa,SAAyB;;;;;;;;;;;;;;;;;;;AAuBjD,MAAa,oBACX,iBACA,YACA,kBAEA,cAAc,iBAAiB,YAAY,cAAc,IACxD,EAAE;;;;;;;;;AAUL,MAAa,uBACX,oBACA,eACA,mBACgB;CAChB,GAAG;CACH,SAAS,iBACP,oBAAoB,SACpB,cAAc,SACd,cACD;CACF"}
1
+ {"version":3,"file":"getEditedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getEditedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\n\n/** A `translation` node, e.g. `{ nodeType: 'translation', translation: { en, fr } }`. */\ntype TranslationNode = {\n nodeType: typeof NodeTypes.TRANSLATION;\n [NodeTypes.TRANSLATION]: Record<string, unknown>;\n};\n\nconst isTranslationNode = (node: unknown): node is TranslationNode =>\n typeof node === 'object' &&\n node !== null &&\n (node as { nodeType?: unknown }).nodeType === NodeTypes.TRANSLATION;\n\nconst isTypedNode = (\n node: unknown\n): node is { nodeType: string; [key: string]: unknown } =>\n typeof node === 'object' &&\n node !== null &&\n !Array.isArray(node) &&\n typeof (node as { nodeType?: unknown }).nodeType === 'string';\n\n/** Structural equality for leaf source values (string / number / nested objects). */\nconst isSameValue = (a: unknown, b: unknown): boolean =>\n JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Recursively compares `next` against `previous` and returns the sub-tree of\n * `next` that holds only the nodes whose source-locale value was added or\n * changed. Returns `undefined` when nothing changed at this node.\n */\nconst getEditedNode = (\n previous: ContentNode | undefined,\n next: ContentNode,\n defaultLocale: LocalesValues\n): ContentNode | undefined => {\n // Translation node: compare the default-locale leaf only.\n if (isTranslationNode(next)) {\n const nextValue = next[NodeTypes.TRANSLATION]?.[defaultLocale as string];\n const previousValue = isTranslationNode(previous)\n ? previous[NodeTypes.TRANSLATION]?.[defaultLocale as string]\n : undefined;\n\n // Nothing to (re)translate if the source locale is absent.\n if (typeof nextValue === 'undefined') {\n return undefined;\n }\n\n // Include only when the source value was added or changed.\n if (isSameValue(previousValue, nextValue)) {\n return undefined;\n }\n\n // Reduce to the source locale only, so every target locale is regenerated.\n return {\n nodeType: NodeTypes.TRANSLATION,\n [NodeTypes.TRANSLATION]: { [defaultLocale as string]: nextValue },\n } as ContentNode;\n }\n\n // Other typed nodes (enumeration, condition, nested, …): recurse into the\n // wrapped value while preserving the wrapper so the partial stays valid.\n if (isTypedNode(next)) {\n const { nodeType } = next;\n const previousInner = isTypedNode(previous)\n ? (previous[nodeType] as ContentNode | undefined)\n : undefined;\n const editedInner = getEditedNode(\n previousInner,\n next[nodeType] as ContentNode,\n defaultLocale\n );\n\n if (typeof editedInner === 'undefined') {\n return undefined;\n }\n\n return {\n nodeType,\n [nodeType]: editedInner,\n } as ContentNode;\n }\n\n // Arrays: keep changed items reduced to source-only, unchanged items as-is to\n // preserve index alignment for `mergeDictionaries` (which merges by index).\n if (Array.isArray(next)) {\n const previousArray = Array.isArray(previous) ? previous : [];\n let hasChange = false;\n\n const result = next.map((child, index) => {\n const editedChild = getEditedNode(\n previousArray[index] as ContentNode | undefined,\n child as ContentNode,\n defaultLocale\n );\n if (typeof editedChild !== 'undefined') {\n hasChange = true;\n return editedChild;\n }\n // Unchanged item: keep the full node. It already has every locale, so the\n // complete-mode translation pass skips it and the merge leaves it intact.\n return child;\n });\n\n return hasChange ? (result as ContentNode) : undefined;\n }\n\n // Plain objects: recurse into each key, keeping only changed branches.\n if (typeof next === 'object' && next !== null) {\n const previousObject =\n typeof previous === 'object' &&\n previous !== null &&\n !Array.isArray(previous)\n ? (previous as Record<string, ContentNode>)\n : undefined;\n\n const result: Record<string, ContentNode> = {};\n let hasChange = false;\n\n for (const key of Object.keys(next as Record<string, ContentNode>)) {\n const editedChild = getEditedNode(\n previousObject?.[key],\n (next as Record<string, ContentNode>)[key],\n defaultLocale\n );\n if (typeof editedChild !== 'undefined') {\n result[key] = editedChild;\n hasChange = true;\n }\n }\n\n return hasChange ? (result as ContentNode) : undefined;\n }\n\n // Primitive leaves are not locale-aware on their own — nothing to translate.\n return undefined;\n};\n\n/**\n * Returns the partial content holding only the `translation` nodes whose\n * source (`defaultLocale`) value was added or changed between `previousContent`\n * and `newContent`. Each changed node is reduced to its source locale so that\n * every target locale is regenerated when the partial is translated.\n *\n * Returns `{}` (empty content) when no source value changed.\n *\n * @example\n * // default value of `title` changed → only `title` is returned, source-only\n * getEditedContent(\n * { title: t({ en: 'Old', fr: 'Vieux' }), body: t({ en: 'B', fr: 'B' }) },\n * { title: t({ en: 'New', fr: 'Vieux' }), body: t({ en: 'B', fr: 'B' }) },\n * 'en'\n * ); // → { title: { nodeType: 'translation', translation: { en: 'New' } } }\n */\nexport const getEditedContent = (\n previousContent: ContentNode | undefined,\n newContent: ContentNode,\n defaultLocale: LocalesValues\n): ContentNode =>\n getEditedNode(previousContent, newContent, defaultLocale) ??\n ({} as ContentNode);\n\n/**\n * Dictionary-level wrapper around {@link getEditedContent}. Returns a partial\n * dictionary (same `key`) whose `content` holds only the changed source nodes.\n *\n * @param previousDictionary - Dictionary state before the edit.\n * @param newDictionary - Dictionary state after the edit.\n * @param defaultLocale - The source locale to diff against.\n */\nexport const getEditedDictionary = (\n previousDictionary: Dictionary | undefined,\n newDictionary: Dictionary,\n defaultLocale: LocalesValues\n): Dictionary => ({\n ...newDictionary,\n content: getEditedContent(\n previousDictionary?.content,\n newDictionary.content,\n defaultLocale\n ),\n});\n"],"mappings":";;;AAUA,MAAM,qBAAqB,SACzB,OAAO,SAAS,YAChB,SAAS,QACR,KAAgC,aAAa,UAAU;AAE1D,MAAM,eACJ,SAEA,OAAO,SAAS,YAChB,SAAS,QACT,CAAC,MAAM,QAAQ,IAAI,KACnB,OAAQ,KAAgC,aAAa;;AAGvD,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AAI,OAAO,gBAAgB,aAAa;IACtC,OAAO,OAAO;IACd,YAAY;GACd;EACF;EAEA,OAAO,YAAa,SAAyB;CAC/C;AAIF;;;;;;;;;;;;;;;;;AAkBA,MAAa,oBACX,iBACA,YACA,kBAEA,cAAc,iBAAiB,YAAY,aAAa,KACvD,CAAC;;;;;;;;;AAUJ,MAAa,uBACX,oBACA,eACA,mBACgB;CAChB,GAAG;CACH,SAAS,iBACP,oBAAoB,SACpB,cAAc,SACd,aACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFilterMissingTranslationsContent.mjs","names":["tCore"],"sources":["../../../src/deepTransformPlugins/getFilterMissingTranslationsContent.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n type DeepTransformContent,\n getTranslation,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport { type TranslationContent, t as tCore } from '../transpiler';\n\n/**\n * Helper function to check if a node or its children contain translation nodes\n */\nconst hasTranslationNodes = (node: any): boolean => {\n if (typeof node !== 'object' || node === null) {\n return false;\n }\n\n if (node?.nodeType === NodeTypes.TRANSLATION) {\n return true;\n }\n\n if (Array.isArray(node)) {\n return node.some(hasTranslationNodes);\n }\n\n return Object.values(node).some(hasTranslationNodes);\n};\n\n/**\n * Get all keys from an object, recursively\n */\nconst getObjectKeys = (obj: any): Set<string> => {\n const keys = new Set<string>();\n\n if (typeof obj !== 'object' || obj === null) {\n return keys;\n }\n\n for (const key in obj) {\n keys.add(key);\n }\n\n return keys;\n};\n\n/**\n * Check if two objects have the same structure (same keys)\n */\nconst hasSameStructure = (obj1: any, obj2: any): boolean => {\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object') {\n return typeof obj1 === typeof obj2;\n }\n\n if (obj1 === null || obj2 === null) {\n return obj1 === obj2;\n }\n\n if (Array.isArray(obj1) !== Array.isArray(obj2)) {\n return false;\n }\n\n const keys1 = getObjectKeys(obj1);\n const keys2 = getObjectKeys(obj2);\n\n if (keys1.size !== keys2.size) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.has(key)) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Check if all locales in a translation node have the same structure (recursively)\n * Returns an object with locales that have missing keys\n */\nconst checkTranslationStructureConsistency = (\n translationNode: Record<string, any>\n): { hasInconsistency: boolean; localesWithMissingKeys: Set<string> } => {\n const locales = Object.keys(translationNode);\n const localesWithMissingKeys = new Set<string>();\n\n if (locales.length <= 1) {\n return { hasInconsistency: false, localesWithMissingKeys };\n }\n\n // Helper function to check structure recursively\n const checkStructureRecursive = (\n path: string,\n localeValues: Map<string, any>\n ): Set<string> => {\n const localesWithIssues = new Set<string>();\n\n // Get all unique keys across all locale values at this path\n const allKeys = new Set<string>();\n const objectLocales = new Map<string, any>();\n\n for (const [locale, value] of localeValues.entries()) {\n if (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value)\n ) {\n objectLocales.set(locale, value);\n const keys = getObjectKeys(value);\n for (const key of keys) {\n allKeys.add(key);\n }\n }\n }\n\n // If no objects at this level, no inconsistency\n if (objectLocales.size === 0) {\n return localesWithIssues;\n }\n\n // Check if each locale has all the keys at this level\n for (const [locale, value] of objectLocales.entries()) {\n const keys = getObjectKeys(value);\n if (keys.size !== allKeys.size) {\n localesWithIssues.add(locale);\n }\n }\n\n // Recursively check nested objects\n for (const key of allKeys) {\n const nestedValues = new Map<string, any>();\n for (const [locale, value] of objectLocales.entries()) {\n if (value[key] !== undefined) {\n nestedValues.set(locale, value[key]);\n }\n }\n\n if (nestedValues.size > 1) {\n const nestedIssues = checkStructureRecursive(\n path ? `${path}.${key}` : key,\n nestedValues\n );\n for (const locale of nestedIssues) {\n localesWithIssues.add(locale);\n }\n }\n }\n\n return localesWithIssues;\n };\n\n // Start recursive check from root\n const rootValues = new Map<string, any>();\n for (const locale of locales) {\n rootValues.set(locale, translationNode[locale]);\n }\n\n const issuesFound = checkStructureRecursive('', rootValues);\n const hasInconsistency = issuesFound.size > 0;\n\n for (const locale of issuesFound) {\n localesWithMissingKeys.add(locale);\n }\n\n return { hasInconsistency, localesWithMissingKeys };\n};\n\n/**\n * Check if array elements have consistent structures\n */\nconst checkArrayStructureConsistency = (arr: any[]): boolean => {\n if (arr.length <= 1) {\n return true;\n }\n\n const firstElement = arr[0];\n\n for (let i = 1; i < arr.length; i++) {\n if (!hasSameStructure(firstElement, arr[i])) {\n return false;\n }\n }\n\n return true;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const filterMissingTranslationsOnlyPlugin = (\n localeToCheck: LocalesValues\n): Plugins => ({\n id: 'filter-missing-translations-only-plugin',\n canHandle: (node: ContentNode) => {\n // Only handle objects and arrays, not primitives\n return typeof node === 'object' && node !== null;\n },\n transform: (node: ContentNode, props, deepTransformNode) => {\n if (typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION) {\n const result = structuredClone(\n (node as TranslationContent)[NodeTypes.TRANSLATION]\n );\n\n const hasLocaleTranslation = Object.keys(result).includes(localeToCheck);\n\n // Check for structural inconsistencies across locales\n const { hasInconsistency, localesWithMissingKeys } =\n checkTranslationStructureConsistency(result);\n\n // If there's a structural inconsistency and the locale being checked\n // has missing keys, treat it as a missing translation\n const hasStructuralIssue =\n hasInconsistency && localesWithMissingKeys.has(localeToCheck);\n\n if (hasLocaleTranslation && !hasStructuralIssue) {\n return undefined; // Return undefined to remove the node\n }\n\n // Transform nested content\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n {\n ...childProps,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) =>\n plugin.id !== 'filter-missing-translations-only-plugin'\n ),\n ],\n }\n );\n }\n\n // Return the base locale content as a translation node\n // If base locale is missing, use any available locale as fallback\n const baseLocale = internationalization?.defaultLocale;\n\n const availableLocales = Object.keys(result);\n\n if (availableLocales.length === 0) {\n return undefined; // No translations available\n }\n\n // Try to get the base locale first, then any available locale as fallback\n const fallbackLocale = availableLocales.includes(baseLocale)\n ? baseLocale\n : availableLocales[0];\n\n const fallbackValue = getTranslation(result, baseLocale, fallbackLocale);\n\n // Return the translation node structure with only the fallback locale\n return tCore({ [fallbackLocale]: fallbackValue });\n } else if (\n typeof node === 'object' &&\n node !== null &&\n !Array.isArray(node) &&\n !node?.nodeType\n ) {\n // For regular objects, include only children that are related to translations\n // - Keep children that contain translation nodes (directly or nested)\n // - Keep arrays (they may mix translated and non-translated values)\n // - Exclude primitive values (string/number/boolean/null/undefined) at object level\n const result: Record<string, any> = {};\n let hasMissingTranslations = false;\n const arrayKeysIncluded: string[] = [];\n const primitiveSiblingsToAppend: any[] = [];\n\n for (const key in node as any) {\n const originalChild = (node as any)[key];\n const childProps = {\n ...props,\n children: originalChild,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.OBJECT, key } as KeyPath,\n ],\n };\n const transformedChild = deepTransformNode(originalChild, childProps);\n\n const isPrimitiveSibling =\n originalChild === null ||\n (typeof originalChild !== 'object' &&\n typeof originalChild !== 'function');\n\n if (isPrimitiveSibling) {\n // Defer primitives; they may be appended to an array sibling later\n if (originalChild !== undefined) {\n primitiveSiblingsToAppend.push(originalChild);\n }\n continue;\n }\n\n const includeChild =\n transformedChild !== undefined &&\n (hasTranslationNodes(originalChild) || Array.isArray(originalChild));\n\n if (includeChild) {\n result[key] = transformedChild;\n hasMissingTranslations = true;\n if (Array.isArray(transformedChild)) {\n arrayKeysIncluded.push(key);\n }\n }\n }\n\n // If any array child is present, append primitive siblings into the first array\n if (\n arrayKeysIncluded.length > 0 &&\n primitiveSiblingsToAppend.length > 0\n ) {\n const targetArrayKey = arrayKeysIncluded[0];\n // Ensure array exists in result (it should, but be defensive)\n if (Array.isArray(result[targetArrayKey])) {\n result[targetArrayKey] = [\n ...result[targetArrayKey],\n ...primitiveSiblingsToAppend,\n ];\n hasMissingTranslations = true;\n }\n }\n\n // Only return the object if it has missing translations-related content\n return hasMissingTranslations ? result : undefined;\n } else if (Array.isArray(node)) {\n // Check if array elements have consistent structures\n const hasConsistentStructure = checkArrayStructureConsistency(node);\n\n // For arrays, only include items that have missing translations\n const result = node\n .map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ARRAY, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n })\n .filter((item) => item !== null && item !== undefined);\n\n // If there's structural inconsistency in the array, include it\n // even if it has no missing translations, to flag the issue\n if (!hasConsistentStructure && result.length === 0) {\n // Return a marker to indicate structural inconsistency\n return node; // Return original array to show the issue\n }\n\n // Only return the array if it has items with missing translations\n return result.length > 0 ? result : undefined;\n }\n\n return node; // Return non-translation content as is\n },\n});\n\n/**\n * For each translation node, it compare is both localeToCheck and baseLocale are present.\n *\n * If yes, it should remove the node from the content.\n * If no, it should keep the node\n *\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * locale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\nexport const getFilterMissingTranslationsContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n localeToCheck: L,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n filterMissingTranslationsOnlyPlugin(localeToCheck),\n ...(nodeProps.plugins ?? []),\n ];\n\n const result = deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n // Stringify the result to remove the undefined values\n if (result === undefined) {\n // No missing translations found\n return {} as DeepTransformContent<T>;\n }\n return JSON.parse(JSON.stringify(result));\n};\n\nexport const getFilterMissingTranslationsDictionary = (\n dictionary: Dictionary,\n localeToCheck: LocalesValues\n) => ({\n ...dictionary,\n content: getFilterMissingTranslationsContent(\n dictionary.content,\n localeToCheck,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [],\n }\n ),\n});\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,uBAAuB,SAAuB;AAClD,KAAI,OAAO,SAAS,YAAY,SAAS,KACvC,QAAO;AAGT,KAAI,MAAM,aAAa,UAAU,YAC/B,QAAO;AAGT,KAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,KAAK,KAAK,oBAAoB;AAGvC,QAAO,OAAO,OAAO,KAAK,CAAC,KAAK,oBAAoB;;;;;AAMtD,MAAM,iBAAiB,QAA0B;CAC/C,MAAM,uBAAO,IAAI,KAAa;AAE9B,KAAI,OAAO,QAAQ,YAAY,QAAQ,KACrC,QAAO;AAGT,MAAK,MAAM,OAAO,IAChB,MAAK,IAAI,IAAI;AAGf,QAAO;;;;;AAMT,MAAM,oBAAoB,MAAW,SAAuB;AAC1D,KAAI,OAAO,SAAS,YAAY,OAAO,SAAS,SAC9C,QAAO,OAAO,SAAS,OAAO;AAGhC,KAAI,SAAS,QAAQ,SAAS,KAC5B,QAAO,SAAS;AAGlB,KAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,QAAQ,KAAK,CAC7C,QAAO;CAGT,MAAM,QAAQ,cAAc,KAAK;CACjC,MAAM,QAAQ,cAAc,KAAK;AAEjC,KAAI,MAAM,SAAS,MAAM,KACvB,QAAO;AAGT,MAAK,MAAM,OAAO,MAChB,KAAI,CAAC,MAAM,IAAI,IAAI,CACjB,QAAO;AAIX,QAAO;;;;;;AAOT,MAAM,wCACJ,oBACuE;CACvE,MAAM,UAAU,OAAO,KAAK,gBAAgB;CAC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AGtC,SAAO;;CAEV;;;;;;;;;;;;;;;AAgBD,MAAa,uCAIX,MACA,eACA,cACG;CACH,MAAM,UAAqB,CACzB,oCAAoC,cAAc,EAClD,GAAI,UAAU,WAAW,EAAE,CAC5B;CAED,MAAM,SAAS,kBAAkB,MAAM;EACrC,GAAG;EACH;EACD,CAAC;AAGF,KAAI,WAAW,OAEb,QAAO,EAAE;AAEX,QAAO,KAAK,MAAM,KAAK,UAAU,OAAO,CAAC;;AAG3C,MAAa,0CACX,YACA,mBACI;CACJ,GAAG;CACH,SAAS,oCACP,WAAW,SACX,eACA;EACE,eAAe,WAAW;EAC1B,SAAS,EAAE;EACX,SAAS,EAAE;EACZ,CACF;CACF"}
1
+ {"version":3,"file":"getFilterMissingTranslationsContent.mjs","names":["tCore"],"sources":["../../../src/deepTransformPlugins/getFilterMissingTranslationsContent.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n type DeepTransformContent,\n getTranslation,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport { type TranslationContent, t as tCore } from '../transpiler';\n\n/**\n * Helper function to check if a node or its children contain translation nodes\n */\nconst hasTranslationNodes = (node: any): boolean => {\n if (typeof node !== 'object' || node === null) {\n return false;\n }\n\n if (node?.nodeType === NodeTypes.TRANSLATION) {\n return true;\n }\n\n if (Array.isArray(node)) {\n return node.some(hasTranslationNodes);\n }\n\n return Object.values(node).some(hasTranslationNodes);\n};\n\n/**\n * Get all keys from an object, recursively\n */\nconst getObjectKeys = (obj: any): Set<string> => {\n const keys = new Set<string>();\n\n if (typeof obj !== 'object' || obj === null) {\n return keys;\n }\n\n for (const key in obj) {\n keys.add(key);\n }\n\n return keys;\n};\n\n/**\n * Check if two objects have the same structure (same keys)\n */\nconst hasSameStructure = (obj1: any, obj2: any): boolean => {\n if (typeof obj1 !== 'object' || typeof obj2 !== 'object') {\n return typeof obj1 === typeof obj2;\n }\n\n if (obj1 === null || obj2 === null) {\n return obj1 === obj2;\n }\n\n if (Array.isArray(obj1) !== Array.isArray(obj2)) {\n return false;\n }\n\n const keys1 = getObjectKeys(obj1);\n const keys2 = getObjectKeys(obj2);\n\n if (keys1.size !== keys2.size) {\n return false;\n }\n\n for (const key of keys1) {\n if (!keys2.has(key)) {\n return false;\n }\n }\n\n return true;\n};\n\n/**\n * Check if all locales in a translation node have the same structure (recursively)\n * Returns an object with locales that have missing keys\n */\nconst checkTranslationStructureConsistency = (\n translationNode: Record<string, any>\n): { hasInconsistency: boolean; localesWithMissingKeys: Set<string> } => {\n const locales = Object.keys(translationNode);\n const localesWithMissingKeys = new Set<string>();\n\n if (locales.length <= 1) {\n return { hasInconsistency: false, localesWithMissingKeys };\n }\n\n // Helper function to check structure recursively\n const checkStructureRecursive = (\n path: string,\n localeValues: Map<string, any>\n ): Set<string> => {\n const localesWithIssues = new Set<string>();\n\n // Get all unique keys across all locale values at this path\n const allKeys = new Set<string>();\n const objectLocales = new Map<string, any>();\n\n for (const [locale, value] of localeValues.entries()) {\n if (\n typeof value === 'object' &&\n value !== null &&\n !Array.isArray(value)\n ) {\n objectLocales.set(locale, value);\n const keys = getObjectKeys(value);\n for (const key of keys) {\n allKeys.add(key);\n }\n }\n }\n\n // If no objects at this level, no inconsistency\n if (objectLocales.size === 0) {\n return localesWithIssues;\n }\n\n // Check if each locale has all the keys at this level\n for (const [locale, value] of objectLocales.entries()) {\n const keys = getObjectKeys(value);\n if (keys.size !== allKeys.size) {\n localesWithIssues.add(locale);\n }\n }\n\n // Recursively check nested objects\n for (const key of allKeys) {\n const nestedValues = new Map<string, any>();\n for (const [locale, value] of objectLocales.entries()) {\n if (value[key] !== undefined) {\n nestedValues.set(locale, value[key]);\n }\n }\n\n if (nestedValues.size > 1) {\n const nestedIssues = checkStructureRecursive(\n path ? `${path}.${key}` : key,\n nestedValues\n );\n for (const locale of nestedIssues) {\n localesWithIssues.add(locale);\n }\n }\n }\n\n return localesWithIssues;\n };\n\n // Start recursive check from root\n const rootValues = new Map<string, any>();\n for (const locale of locales) {\n rootValues.set(locale, translationNode[locale]);\n }\n\n const issuesFound = checkStructureRecursive('', rootValues);\n const hasInconsistency = issuesFound.size > 0;\n\n for (const locale of issuesFound) {\n localesWithMissingKeys.add(locale);\n }\n\n return { hasInconsistency, localesWithMissingKeys };\n};\n\n/**\n * Check if array elements have consistent structures\n */\nconst checkArrayStructureConsistency = (arr: any[]): boolean => {\n if (arr.length <= 1) {\n return true;\n }\n\n const firstElement = arr[0];\n\n for (let i = 1; i < arr.length; i++) {\n if (!hasSameStructure(firstElement, arr[i])) {\n return false;\n }\n }\n\n return true;\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const filterMissingTranslationsOnlyPlugin = (\n localeToCheck: LocalesValues\n): Plugins => ({\n id: 'filter-missing-translations-only-plugin',\n canHandle: (node: ContentNode) => {\n // Only handle objects and arrays, not primitives\n return typeof node === 'object' && node !== null;\n },\n transform: (node: ContentNode, props, deepTransformNode) => {\n if (typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION) {\n const result = structuredClone(\n (node as TranslationContent)[NodeTypes.TRANSLATION]\n );\n\n const hasLocaleTranslation = Object.keys(result).includes(localeToCheck);\n\n // Check for structural inconsistencies across locales\n const { hasInconsistency, localesWithMissingKeys } =\n checkTranslationStructureConsistency(result);\n\n // If there's a structural inconsistency and the locale being checked\n // has missing keys, treat it as a missing translation\n const hasStructuralIssue =\n hasInconsistency && localesWithMissingKeys.has(localeToCheck);\n\n if (hasLocaleTranslation && !hasStructuralIssue) {\n return undefined; // Return undefined to remove the node\n }\n\n // Transform nested content\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n {\n ...childProps,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) =>\n plugin.id !== 'filter-missing-translations-only-plugin'\n ),\n ],\n }\n );\n }\n\n // Return the base locale content as a translation node\n // If base locale is missing, use any available locale as fallback\n const baseLocale = internationalization?.defaultLocale;\n\n const availableLocales = Object.keys(result);\n\n if (availableLocales.length === 0) {\n return undefined; // No translations available\n }\n\n // Try to get the base locale first, then any available locale as fallback\n const fallbackLocale = availableLocales.includes(baseLocale)\n ? baseLocale\n : availableLocales[0];\n\n const fallbackValue = getTranslation(result, baseLocale, fallbackLocale);\n\n // Return the translation node structure with only the fallback locale\n return tCore({ [fallbackLocale]: fallbackValue });\n } else if (\n typeof node === 'object' &&\n node !== null &&\n !Array.isArray(node) &&\n !node?.nodeType\n ) {\n // For regular objects, include only children that are related to translations\n // - Keep children that contain translation nodes (directly or nested)\n // - Keep arrays (they may mix translated and non-translated values)\n // - Exclude primitive values (string/number/boolean/null/undefined) at object level\n const result: Record<string, any> = {};\n let hasMissingTranslations = false;\n const arrayKeysIncluded: string[] = [];\n const primitiveSiblingsToAppend: any[] = [];\n\n for (const key in node as any) {\n const originalChild = (node as any)[key];\n const childProps = {\n ...props,\n children: originalChild,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.OBJECT, key } as KeyPath,\n ],\n };\n const transformedChild = deepTransformNode(originalChild, childProps);\n\n const isPrimitiveSibling =\n originalChild === null ||\n (typeof originalChild !== 'object' &&\n typeof originalChild !== 'function');\n\n if (isPrimitiveSibling) {\n // Defer primitives; they may be appended to an array sibling later\n if (originalChild !== undefined) {\n primitiveSiblingsToAppend.push(originalChild);\n }\n continue;\n }\n\n const includeChild =\n transformedChild !== undefined &&\n (hasTranslationNodes(originalChild) || Array.isArray(originalChild));\n\n if (includeChild) {\n result[key] = transformedChild;\n hasMissingTranslations = true;\n if (Array.isArray(transformedChild)) {\n arrayKeysIncluded.push(key);\n }\n }\n }\n\n // If any array child is present, append primitive siblings into the first array\n if (\n arrayKeysIncluded.length > 0 &&\n primitiveSiblingsToAppend.length > 0\n ) {\n const targetArrayKey = arrayKeysIncluded[0];\n // Ensure array exists in result (it should, but be defensive)\n if (Array.isArray(result[targetArrayKey])) {\n result[targetArrayKey] = [\n ...result[targetArrayKey],\n ...primitiveSiblingsToAppend,\n ];\n hasMissingTranslations = true;\n }\n }\n\n // Only return the object if it has missing translations-related content\n return hasMissingTranslations ? result : undefined;\n } else if (Array.isArray(node)) {\n // Check if array elements have consistent structures\n const hasConsistentStructure = checkArrayStructureConsistency(node);\n\n // For arrays, only include items that have missing translations\n const result = node\n .map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ARRAY, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n })\n .filter((item) => item !== null && item !== undefined);\n\n // If there's structural inconsistency in the array, include it\n // even if it has no missing translations, to flag the issue\n if (!hasConsistentStructure && result.length === 0) {\n // Return a marker to indicate structural inconsistency\n return node; // Return original array to show the issue\n }\n\n // Only return the array if it has items with missing translations\n return result.length > 0 ? result : undefined;\n }\n\n return node; // Return non-translation content as is\n },\n});\n\n/**\n * For each translation node, it compare is both localeToCheck and baseLocale are present.\n *\n * If yes, it should remove the node from the content.\n * If no, it should keep the node\n *\n * In complete mode, for large dictionaries, we want to filter all content that is already translated\n *\n * locale: fr\n *\n * { test1: t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' } }) -> {}\n * { test2: t({ ar: 'Hello', en: 'Hello' }) } -> { test2: t({ ar: 'Hello', en: 'Hello' }) }\n *\n */\nexport const getFilterMissingTranslationsContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n localeToCheck: L,\n nodeProps: NodeProps\n) => {\n const plugins: Plugins[] = [\n filterMissingTranslationsOnlyPlugin(localeToCheck),\n ...(nodeProps.plugins ?? []),\n ];\n\n const result = deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n\n // Stringify the result to remove the undefined values\n if (result === undefined) {\n // No missing translations found\n return {} as DeepTransformContent<T>;\n }\n return JSON.parse(JSON.stringify(result));\n};\n\nexport const getFilterMissingTranslationsDictionary = (\n dictionary: Dictionary,\n localeToCheck: LocalesValues\n) => ({\n ...dictionary,\n content: getFilterMissingTranslationsContent(\n dictionary.content,\n localeToCheck,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [],\n }\n ),\n});\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,uBAAuB,SAAuB;CAClD,IAAI,OAAO,SAAS,YAAY,SAAS,MACvC,OAAO;CAGT,IAAI,MAAM,aAAa,UAAU,aAC/B,OAAO;CAGT,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,KAAK,KAAK,mBAAmB;CAGtC,OAAO,OAAO,OAAO,IAAI,CAAC,CAAC,KAAK,mBAAmB;AACrD;;;;AAKA,MAAM,iBAAiB,QAA0B;CAC/C,MAAM,uBAAO,IAAI,IAAY;CAE7B,IAAI,OAAO,QAAQ,YAAY,QAAQ,MACrC,OAAO;CAGT,KAAK,MAAM,OAAO,KAChB,KAAK,IAAI,GAAG;CAGd,OAAO;AACT;;;;AAKA,MAAM,oBAAoB,MAAW,SAAuB;CAC1D,IAAI,OAAO,SAAS,YAAY,OAAO,SAAS,UAC9C,OAAO,OAAO,SAAS,OAAO;CAGhC,IAAI,SAAS,QAAQ,SAAS,MAC5B,OAAO,SAAS;CAGlB,IAAI,MAAM,QAAQ,IAAI,MAAM,MAAM,QAAQ,IAAI,GAC5C,OAAO;CAGT,MAAM,QAAQ,cAAc,IAAI;CAChC,MAAM,QAAQ,cAAc,IAAI;CAEhC,IAAI,MAAM,SAAS,MAAM,MACvB,OAAO;CAGT,KAAK,MAAM,OAAO,OAChB,IA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P,GAAG,MAAM,SACT;MAAE,MAAM,UAAU;MAAO,KAAK;KAAM,CACtC;IAEuC,CAAC;GAC5C,CAAC,CAAC,CACD,QAAQ,SAAS,SAAS,QAAQ,SAAS,MAAS;GAIvD,IAAI,CAAC,0BAA0B,OAAO,WAAW,GAE/C,OAAO;GAIT,OAAO,OAAO,SAAS,IAAI,SAAS;EACtC;EAEA,OAAO;CACT;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,uCAIX,MACA,eACA,cACG;CACH,MAAM,UAAqB,CACzB,oCAAoC,aAAa,GACjD,GAAI,UAAU,WAAW,CAAC,CAC5B;CAEA,MAAM,SAAS,kBAAkB,MAAM;EACrC,GAAG;EACH;CACF,CAAC;CAGD,IAAI,WAAW,QAEb,OAAO,CAAC;CAEV,OAAO,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC;AAC1C;AAEA,MAAa,0CACX,YACA,mBACI;CACJ,GAAG;CACH,SAAS,oCACP,WAAW,SACX,eACA;EACE,eAAe,WAAW;EAC1B,SAAS,CAAC;EACV,SAAS,CAAC;CACZ,CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFilterTranslationsOnlyContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getFilterTranslationsOnlyContent.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n type DeepTransformContent,\n getTranslation,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\n/**\n * Helper function to check if a node or its children contain translation nodes\n */\nconst hasTranslationNodes = (node: any): boolean => {\n if (typeof node !== 'object' || node === null) {\n return false;\n }\n\n if (node?.nodeType === NodeTypes.TRANSLATION) {\n return true;\n }\n\n if (Array.isArray(node)) {\n return node.some(hasTranslationNodes);\n }\n\n return Object.values(node).some(hasTranslationNodes);\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const filterTranslationsOnlyPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins => ({\n id: 'filter-translations-only-plugin',\n canHandle: (node: ContentNode) => {\n // Only handle objects and arrays, not primitives\n return typeof node === 'object' && node !== null;\n },\n transform: (node: ContentNode, props, deepTransformNode) => {\n if (typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION) {\n const result = structuredClone(\n (node as TranslationContent)[NodeTypes.TRANSLATION]\n );\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n {\n ...childProps,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'filter-translations-only-plugin'\n ),\n ],\n }\n );\n }\n return getTranslation(result, locale, fallback);\n } else if (\n typeof node === 'object' &&\n node !== null &&\n !Array.isArray(node) &&\n !node?.nodeType\n ) {\n // For regular objects, filter out properties that don't contain translations\n const result: Record<string, any> = {};\n for (const key in node as any) {\n if (hasTranslationNodes(node[key as unknown as keyof typeof node])) {\n const childProps = {\n ...props,\n children: node[key as unknown as keyof typeof node],\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.OBJECT, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(\n node[key as unknown as keyof typeof node],\n childProps\n );\n }\n }\n return result;\n } else if (Array.isArray(node)) {\n // For arrays, keep all items but transform them\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ARRAY, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n return 'to remove from the object';\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getFilterTranslationsOnlyContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n locale: L = internationalization?.defaultLocale as L,\n\n nodeProps: NodeProps,\n fallback?: LocalesValues\n) => {\n const plugins: Plugins[] = [\n filterTranslationsOnlyPlugin(locale, fallback),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n};\n\nexport const getFilterTranslationsOnlyDictionary = (\n dictionary: Dictionary,\n locale: LocalesValues = internationalization?.defaultLocale as LocalesValues,\n\n fallback?: LocalesValues\n) => ({\n ...dictionary,\n content: getFilterTranslationsOnlyContent(\n dictionary.content,\n locale,\n { dictionaryKey: dictionary.key, keyPath: [] },\n fallback\n ),\n});\n"],"mappings":";;;;;;;;;AAoBA,MAAM,uBAAuB,SAAuB;AAClD,KAAI,OAAO,SAAS,YAAY,SAAS,KACvC,QAAO;AAGT,KAAI,MAAM,aAAa,UAAU,YAC/B,QAAO;AAGT,KAAI,MAAM,QAAQ,KAAK,CACrB,QAAO,KAAK,KAAK,oBAAoB;AAGvC,QAAO,OAAO,OAAO,KAAK,CAAC,KAAK,oBAAoB;;;AAItD,MAAa,gCACX,QACA,cACa;CACb,IAAI;CACJ,YAAY,SAAsB;AAEhC,SAAO,OAAO,SAAS,YAAY,SAAS;;CAE9C,YAAY,MAAmB,OAAO,sBAAsB;AAC1D,MAAI,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU,aAAa;GACxE,MAAM,SAAS,gBACZ,KAA4B,UAAU,aACxC;AAED,QAAK,MAAM,OAAO,QAAQ;IACxB,MAAM,aAAa;KACjB,GAAG;KACH,UAAU,OAAO;KACjB,SAAS,CACP,GAAG,MAAM,SACT;MAAE,MAAM,UAAU;MAAa;MAAK,CACrC;KACF;AACD,WAAO,OAAyC,kBAC9C,OAAO,MACP;KACE,GAAG;KACH,SAAS,CACP,IAAI,MAAM,WAAY,EAAE,EAAgB,QACrC,WAAW,OAAO,OAAO,kCAC3B,CACF;KACF,CACF;;AAEH,UAAO,eAAe,QAAQ,QAAQ,SAAS;aAE/C,OAAO,SAAS,YAChB,SAAS,QACT,CAAC,MAAM,QAAQ,KAAK,IACpB,CAAC,MAAM,UACP;GAEA,MAAM,SAA8B,EAAE;AACtC,QAAK,MAAM,OAAO,KAChB,KAAI,oBAAoB,KAAK,KAAqC,EAAE;IAClE,MAAM,aAAa;KACjB,GAAG;KACH,UAAU,KAAK;KACf,SAAS,CACP,GAAG,MAAM,SACT;MAAE,MAAM,UAAU;MAAQ;MAAK,CAChC;KACF;AACD,WAAO,OAAO,kBACZ,KAAK,MACL,WACD;;AAGL,UAAO;aACE,MAAM,QAAQ,KAAK,CAE5B,QAAO,KAAK,KAAK,OAAO,UAAU;AAShC,UAAO,kBAAkB,OAAO;IAP9B,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU;KAAO,KAAK;KAAO,CACtC;IAEuC,CAAC;IAC3C;AAGJ,SAAO;;CAEV;;;;;;;AAQD,MAAa,oCAIX,MACA,SAAY,sBAAsB,eAElC,WACA,aACG;CACH,MAAM,UAAqB,CACzB,6BAA6B,QAAQ,SAAS,EAC9C,GAAI,UAAU,WAAW,EAAE,CAC5B;AAED,QAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;EACD,CAAC;;AAGJ,MAAa,uCACX,YACA,SAAwB,sBAAsB,eAE9C,cACI;CACJ,GAAG;CACH,SAAS,iCACP,WAAW,SACX,QACA;EAAE,eAAe,WAAW;EAAK,SAAS,EAAE;EAAE,EAC9C,SACD;CACF"}
1
+ {"version":3,"file":"getFilterTranslationsOnlyContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getFilterTranslationsOnlyContent.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n type DeepTransformContent,\n getTranslation,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\nimport type { TranslationContent } from '../transpiler';\n\n/**\n * Helper function to check if a node or its children contain translation nodes\n */\nconst hasTranslationNodes = (node: any): boolean => {\n if (typeof node !== 'object' || node === null) {\n return false;\n }\n\n if (node?.nodeType === NodeTypes.TRANSLATION) {\n return true;\n }\n\n if (Array.isArray(node)) {\n return node.some(hasTranslationNodes);\n }\n\n return Object.values(node).some(hasTranslationNodes);\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const filterTranslationsOnlyPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins => ({\n id: 'filter-translations-only-plugin',\n canHandle: (node: ContentNode) => {\n // Only handle objects and arrays, not primitives\n return typeof node === 'object' && node !== null;\n },\n transform: (node: ContentNode, props, deepTransformNode) => {\n if (typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION) {\n const result = structuredClone(\n (node as TranslationContent)[NodeTypes.TRANSLATION]\n );\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as unknown as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.TRANSLATION, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n result[key as unknown as keyof typeof result],\n {\n ...childProps,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'filter-translations-only-plugin'\n ),\n ],\n }\n );\n }\n return getTranslation(result, locale, fallback);\n } else if (\n typeof node === 'object' &&\n node !== null &&\n !Array.isArray(node) &&\n !node?.nodeType\n ) {\n // For regular objects, filter out properties that don't contain translations\n const result: Record<string, any> = {};\n for (const key in node as any) {\n if (hasTranslationNodes(node[key as unknown as keyof typeof node])) {\n const childProps = {\n ...props,\n children: node[key as unknown as keyof typeof node],\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.OBJECT, key } as KeyPath,\n ],\n };\n result[key] = deepTransformNode(\n node[key as unknown as keyof typeof node],\n childProps\n );\n }\n }\n return result;\n } else if (Array.isArray(node)) {\n // For arrays, keep all items but transform them\n return node.map((child, index) => {\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.ARRAY, key: index } as KeyPath,\n ],\n };\n return deepTransformNode(child, childProps);\n });\n }\n\n return 'to remove from the object';\n },\n});\n\n/**\n * Return the content of a node with only the translation plugin.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getFilterTranslationsOnlyContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n locale: L = internationalization?.defaultLocale as L,\n\n nodeProps: NodeProps,\n fallback?: LocalesValues\n) => {\n const plugins: Plugins[] = [\n filterTranslationsOnlyPlugin(locale, fallback),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n};\n\nexport const getFilterTranslationsOnlyDictionary = (\n dictionary: Dictionary,\n locale: LocalesValues = internationalization?.defaultLocale as LocalesValues,\n\n fallback?: LocalesValues\n) => ({\n ...dictionary,\n content: getFilterTranslationsOnlyContent(\n dictionary.content,\n locale,\n { dictionaryKey: dictionary.key, keyPath: [] },\n fallback\n ),\n});\n"],"mappings":";;;;;;;;;AAoBA,MAAM,uBAAuB,SAAuB;CAClD,IAAI,OAAO,SAAS,YAAY,SAAS,MACvC,OAAO;CAGT,IAAI,MAAM,aAAa,UAAU,aAC/B,OAAO;CAGT,IAAI,MAAM,QAAQ,IAAI,GACpB,OAAO,KAAK,KA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C,CAAC;EAGH,OAAO;CACT;AACF;;;;;;;AAQA,MAAa,oCAIX,MACA,SAAY,sBAAsB,eAElC,WACA,aACG;CACH,MAAM,UAAqB,CACzB,6BAA6B,QAAQ,QAAQ,GAC7C,GAAI,UAAU,WAAW,CAAC,CAC5B;CAEA,OAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;CACF,CAAC;AACH;AAEA,MAAa,uCACX,YACA,SAAwB,sBAAsB,eAE9C,cACI;CACJ,GAAG;CACH,SAAS,iCACP,WAAW,SACX,QACA;EAAE,eAAe,WAAW;EAAK,SAAS,CAAC;CAAE,GAC7C,QACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getFilteredLocalesContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getFilteredLocalesContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst filterTranslationsPlugin = (locales: LocalesValues[]): Plugins => ({\n id: 'filter-translations-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION,\n transform: (node, props, deepTransformNode) => {\n const translationMap = node[NodeTypes.TRANSLATION] as Record<\n LocalesValues,\n string\n >;\n\n const filteredTranslationMap = Object.fromEntries(\n Object.entries(translationMap).filter(([key]) =>\n locales.includes(key as LocalesValues)\n )\n );\n\n return {\n ...node,\n [NodeTypes.TRANSLATION]: deepTransformNode(filteredTranslationMap, {\n ...props,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.OBJECT, key: NodeTypes.TRANSLATION },\n ],\n }),\n };\n },\n});\n\nexport const getFilteredLocalesContent = (\n node: ContentNode,\n locales: LocalesValues | LocalesValues[],\n nodeProps: NodeProps\n) => {\n const localesArray = Array.isArray(locales) ? locales : [locales];\n\n const plugins: Plugins[] = [\n filterTranslationsPlugin(localesArray),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n });\n};\n\n/*\n * Remove all unneeded translation from translation node\n *\n * locale: fr\n * t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' }) -> t({ fr: 'Bonjour' })\n *\n * locales: [fr, en]\n * t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' }) -> t({ en: 'Hello', fr: 'Bonjour' })\n */\nexport const getFilteredLocalesDictionary = (\n dictionary: Dictionary,\n locale: LocalesValues | LocalesValues[]\n) => {\n const localesArray = Array.isArray(locale) ? locale : [locale];\n\n return {\n ...dictionary,\n content: getFilteredLocalesContent(dictionary.content, localesArray, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n }),\n };\n};\n"],"mappings":";;;;AAUA,MAAM,4BAA4B,aAAuC;CACvE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAM,OAAO,sBAAsB;EAC7C,MAAM,iBAAiB,KAAK,UAAU;EAKtC,MAAM,yBAAyB,OAAO,YACpC,OAAO,QAAQ,eAAe,CAAC,QAAQ,CAAC,SACtC,QAAQ,SAAS,IAAqB,CACvC,CACF;AAED,SAAO;GACL,GAAG;IACF,UAAU,cAAc,kBAAkB,wBAAwB;IACjE,GAAG;IACH,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU;KAAQ,KAAK,UAAU;KAAa,CACvD;IACF,CAAC;GACH;;CAEJ;AAED,MAAa,6BACX,MACA,SACA,cACG;CAGH,MAAM,UAAqB,CACzB,yBAHmB,MAAM,QAAQ,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAGzB,EACtC,GAAI,UAAU,WAAW,EAAE,CAC5B;AAED,QAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;EACD,CAAC;;AAYJ,MAAa,gCACX,YACA,WACG;CACH,MAAM,eAAe,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;AAE9D,QAAO;EACL,GAAG;EACH,SAAS,0BAA0B,WAAW,SAAS,cAAc;GACnE,eAAe,WAAW;GAC1B,SAAS,EAAE;GACZ,CAAC;EACH"}
1
+ {"version":3,"file":"getFilteredLocalesContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getFilteredLocalesContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n deepTransformNode,\n type NodeProps,\n type Plugins,\n} from '../interpreter';\n\nconst filterTranslationsPlugin = (locales: LocalesValues[]): Plugins => ({\n id: 'filter-translations-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.TRANSLATION,\n transform: (node, props, deepTransformNode) => {\n const translationMap = node[NodeTypes.TRANSLATION] as Record<\n LocalesValues,\n string\n >;\n\n const filteredTranslationMap = Object.fromEntries(\n Object.entries(translationMap).filter(([key]) =>\n locales.includes(key as LocalesValues)\n )\n );\n\n return {\n ...node,\n [NodeTypes.TRANSLATION]: deepTransformNode(filteredTranslationMap, {\n ...props,\n keyPath: [\n ...props.keyPath,\n { type: NodeTypes.OBJECT, key: NodeTypes.TRANSLATION },\n ],\n }),\n };\n },\n});\n\nexport const getFilteredLocalesContent = (\n node: ContentNode,\n locales: LocalesValues | LocalesValues[],\n nodeProps: NodeProps\n) => {\n const localesArray = Array.isArray(locales) ? locales : [locales];\n\n const plugins: Plugins[] = [\n filterTranslationsPlugin(localesArray),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n });\n};\n\n/*\n * Remove all unneeded translation from translation node\n *\n * locale: fr\n * t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' }) -> t({ fr: 'Bonjour' })\n *\n * locales: [fr, en]\n * t({ ar: 'Hello', en: 'Hello', fr: 'Bonjour' }) -> t({ en: 'Hello', fr: 'Bonjour' })\n */\nexport const getFilteredLocalesDictionary = (\n dictionary: Dictionary,\n locale: LocalesValues | LocalesValues[]\n) => {\n const localesArray = Array.isArray(locale) ? locale : [locale];\n\n return {\n ...dictionary,\n content: getFilteredLocalesContent(dictionary.content, localesArray, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n }),\n };\n};\n"],"mappings":";;;;AAUA,MAAM,4BAA4B,aAAuC;CACvE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU;CAC3D,YAAY,MAAM,OAAO,sBAAsB;EAC7C,MAAM,iBAAiB,KAAK,UAAU;EAKtC,MAAM,yBAAyB,OAAO,YACpC,OAAO,QAAQ,cAAc,CAAC,CAAC,QAAQ,CAAC,SACtC,QAAQ,SAAS,GAAoB,CACvC,CACF;EAEA,OAAO;GACL,GAAG;IACF,UAAU,cAAc,kBAAkB,wBAAwB;IACjE,GAAG;IACH,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU;KAAQ,KAAK,UAAU;IAAY,CACvD;GACF,CAAC;EACH;CACF;AACF;AAEA,MAAa,6BACX,MACA,SACA,cACG;CAGH,MAAM,UAAqB,CACzB,yBAHmB,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO,CAGzB,GACrC,GAAI,UAAU,WAAW,CAAC,CAC5B;CAEA,OAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;CACF,CAAC;AACH;AAWA,MAAa,gCACX,YACA,WACG;CACH,MAAM,eAAe,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;CAE7D,OAAO;EACL,GAAG;EACH,SAAS,0BAA0B,WAAW,SAAS,cAAc;GACnE,eAAe,WAAW;GAC1B,SAAS,CAAC;EACZ,CAAC;CACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getLocalizedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getLocalizedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n type DeepTransformContent,\n type NodeProps,\n type Plugins,\n translationPlugin,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n * In comparison to `getContent`, this function will only apply the translation plugin.\n * It will not transform enumerations, insertions, or other content types.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getLocalizedContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n locale: L,\n nodeProps: NodeProps,\n fallback?: LocalesValues // fallback mean that if field is not translated, it will use the default locale\n) => {\n const plugins: Plugins[] = [\n translationPlugin(locale, fallback),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n};\n\nexport const getPerLocaleDictionary = <\n T extends Dictionary,\n L extends LocalesValues,\n>(\n dictionary: T,\n locale: L,\n fallback?: LocalesValues\n): Dictionary => ({\n ...dictionary,\n locale,\n content: getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [],\n },\n fallback\n ),\n});\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,uBAIX,MACA,QACA,WACA,aACG;CACH,MAAM,UAAqB,CACzB,kBAAkB,QAAQ,SAAS,EACnC,GAAI,UAAU,WAAW,EAAE,CAC5B;AAED,QAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;EACD,CAAC;;AAGJ,MAAa,0BAIX,YACA,QACA,cACgB;CAChB,GAAG;CACH;CACA,SAAS,oBACP,WAAW,SACX,QACA;EACE,eAAe,WAAW;EAC1B,SAAS,EAAE;EACX,SAAS,EAAE;EACZ,EACD,SACD;CACF"}
1
+ {"version":3,"file":"getLocalizedContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getLocalizedContent.ts"],"sourcesContent":["import type { ContentNode, Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport {\n type DeepTransformContent,\n type NodeProps,\n type Plugins,\n translationPlugin,\n} from '../interpreter';\nimport { deepTransformNode } from '../interpreter/getContent/deepTransform';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\n * In comparison to `getContent`, this function will only apply the translation plugin.\n * It will not transform enumerations, insertions, or other content types.\n *\n * @param node The node to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n */\nexport const getLocalizedContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n locale: L,\n nodeProps: NodeProps,\n fallback?: LocalesValues // fallback mean that if field is not translated, it will use the default locale\n) => {\n const plugins: Plugins[] = [\n translationPlugin(locale, fallback),\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T>;\n};\n\nexport const getPerLocaleDictionary = <\n T extends Dictionary,\n L extends LocalesValues,\n>(\n dictionary: T,\n locale: L,\n fallback?: LocalesValues\n): Dictionary => ({\n ...dictionary,\n locale,\n content: getLocalizedContent(\n dictionary.content,\n locale,\n {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [],\n },\n fallback\n ),\n});\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAa,uBAIX,MACA,QACA,WACA,aACG;CACH,MAAM,UAAqB,CACzB,kBAAkB,QAAQ,QAAQ,GAClC,GAAI,UAAU,WAAW,CAAC,CAC5B;CAEA,OAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;CACF,CAAC;AACH;AAEA,MAAa,0BAIX,YACA,QACA,cACgB;CAChB,GAAG;CACH;CACA,SAAS,oBACP,WAAW,SACX,QACA;EACE,eAAe,WAAW;EAC1B,SAAS,CAAC;EACV,SAAS,CAAC;CACZ,GACA,QACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getMaskContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getMaskContent.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport { deepTransformNode, type Plugins } from '../interpreter';\n\nconst passTypedNodePlugin: Plugins = {\n id: 'pass-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node, props, deepTransformNode) =>\n deepTransformNode(node[node.nodeType], props),\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const buildMaskPlugin: Plugins = {\n id: 'build-mask-plugin',\n canHandle: (node) => typeof node === 'string' || typeof node === 'number',\n transform: () => true,\n};\n\nexport const getMaskContent = (source: Dictionary): any => ({\n ...source,\n content: deepTransformNode(source.content, {\n dictionaryKey: source.key,\n keyPath: [],\n plugins: [passTypedNodePlugin, buildMaskPlugin],\n }),\n});\n"],"mappings":";;;AAGA,MAAM,sBAA+B;CACnC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,OAAO,MAAM,aAAa;CACxD,YAAY,MAAM,OAAO,sBACvB,kBAAkB,KAAK,KAAK,WAAW,MAAM;CAChD;;AAGD,MAAa,kBAA2B;CACtC,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,OAAO,SAAS;CACjE,iBAAiB;CAClB;AAED,MAAa,kBAAkB,YAA6B;CAC1D,GAAG;CACH,SAAS,kBAAkB,OAAO,SAAS;EACzC,eAAe,OAAO;EACtB,SAAS,EAAE;EACX,SAAS,CAAC,qBAAqB,gBAAgB;EAChD,CAAC;CACH"}
1
+ {"version":3,"file":"getMaskContent.mjs","names":[],"sources":["../../../src/deepTransformPlugins/getMaskContent.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport { deepTransformNode, type Plugins } from '../interpreter';\n\nconst passTypedNodePlugin: Plugins = {\n id: 'pass-typed-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' && typeof node?.nodeType === 'string',\n transform: (node, props, deepTransformNode) =>\n deepTransformNode(node[node.nodeType], props),\n};\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const buildMaskPlugin: Plugins = {\n id: 'build-mask-plugin',\n canHandle: (node) => typeof node === 'string' || typeof node === 'number',\n transform: () => true,\n};\n\nexport const getMaskContent = (source: Dictionary): any => ({\n ...source,\n content: deepTransformNode(source.content, {\n dictionaryKey: source.key,\n keyPath: [],\n plugins: [passTypedNodePlugin, buildMaskPlugin],\n }),\n});\n"],"mappings":";;;AAGA,MAAM,sBAA+B;CACnC,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,OAAO,MAAM,aAAa;CACxD,YAAY,MAAM,OAAO,sBACvB,kBAAkB,KAAK,KAAK,WAAW,KAAK;AAChD;;AAGA,MAAa,kBAA2B;CACtC,IAAI;CACJ,YAAY,SAAS,OAAO,SAAS,YAAY,OAAO,SAAS;CACjE,iBAAiB;AACnB;AAEA,MAAa,kBAAkB,YAA6B;CAC1D,GAAG;CACH,SAAS,kBAAkB,OAAO,SAAS;EACzC,eAAe,OAAO;EACtB,SAAS,CAAC;EACV,SAAS,CAAC,qBAAqB,eAAe;CAChD,CAAC;AACH"}