@intlayer/core 8.9.6 → 8.9.8

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 (270) hide show
  1. package/dist/cjs/deepTransformPlugins/getFilterMissingTranslationsContent.cjs.map +1 -1
  2. package/dist/cjs/deepTransformPlugins/getFilterTranslationsOnlyContent.cjs.map +1 -1
  3. package/dist/cjs/deepTransformPlugins/getFilteredLocalesContent.cjs.map +1 -1
  4. package/dist/cjs/deepTransformPlugins/getLocalizedContent.cjs.map +1 -1
  5. package/dist/cjs/deepTransformPlugins/getMaskContent.cjs.map +1 -1
  6. package/dist/cjs/deepTransformPlugins/getMissingLocalesContent.cjs.map +1 -1
  7. package/dist/cjs/deepTransformPlugins/getMultilingualDictionary.cjs.map +1 -1
  8. package/dist/cjs/deepTransformPlugins/getReplacedValuesContent.cjs.map +1 -1
  9. package/dist/cjs/deepTransformPlugins/getSplittedContent.cjs.map +1 -1
  10. package/dist/cjs/deepTransformPlugins/insertContentInDictionary.cjs.map +1 -1
  11. package/dist/cjs/dictionaryManipulator/editDictionaryByKeyPath.cjs.map +1 -1
  12. package/dist/cjs/dictionaryManipulator/getContentNodeByKeyPath.cjs.map +1 -1
  13. package/dist/cjs/dictionaryManipulator/getDefaultNode.cjs.map +1 -1
  14. package/dist/cjs/dictionaryManipulator/getEmptyNode.cjs.map +1 -1
  15. package/dist/cjs/dictionaryManipulator/getNodeChildren.cjs.map +1 -1
  16. package/dist/cjs/dictionaryManipulator/getNodeType.cjs.map +1 -1
  17. package/dist/cjs/dictionaryManipulator/mergeDictionaries.cjs.map +1 -1
  18. package/dist/cjs/dictionaryManipulator/normalizeDictionary.cjs.map +1 -1
  19. package/dist/cjs/dictionaryManipulator/orderDictionaries.cjs.map +1 -1
  20. package/dist/cjs/dictionaryManipulator/removeContentNodeByKeyPath.cjs.map +1 -1
  21. package/dist/cjs/dictionaryManipulator/renameContentNodeByKeyPath.cjs.map +1 -1
  22. package/dist/cjs/dictionaryManipulator/updateNodeChildren.cjs.map +1 -1
  23. package/dist/cjs/formatters/compact.cjs.map +1 -1
  24. package/dist/cjs/formatters/currency.cjs.map +1 -1
  25. package/dist/cjs/formatters/date.cjs.map +1 -1
  26. package/dist/cjs/formatters/list.cjs.map +1 -1
  27. package/dist/cjs/formatters/number.cjs.map +1 -1
  28. package/dist/cjs/formatters/percentage.cjs.map +1 -1
  29. package/dist/cjs/formatters/relativeTime.cjs.map +1 -1
  30. package/dist/cjs/formatters/units.cjs.map +1 -1
  31. package/dist/cjs/interpreter/getCondition.cjs.map +1 -1
  32. package/dist/cjs/interpreter/getContent/deepTransform.cjs.map +1 -1
  33. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  34. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -5
  35. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  36. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  37. package/dist/cjs/interpreter/getEnumeration.cjs.map +1 -1
  38. package/dist/cjs/interpreter/getGender.cjs.map +1 -1
  39. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  40. package/dist/cjs/interpreter/getInsertion.cjs.map +1 -1
  41. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  42. package/dist/cjs/interpreter/getNesting.cjs.map +1 -1
  43. package/dist/cjs/interpreter/getPlural.cjs.map +1 -1
  44. package/dist/cjs/interpreter/getTranslation.cjs.map +1 -1
  45. package/dist/cjs/interpreter/splitAndJoinInsertion.cjs.map +1 -1
  46. package/dist/cjs/localization/generateSitemap.cjs.map +1 -1
  47. package/dist/cjs/localization/getBrowserLocale.cjs.map +1 -1
  48. package/dist/cjs/localization/getHTMLTextDir.cjs.map +1 -1
  49. package/dist/cjs/localization/getLocale.cjs.map +1 -1
  50. package/dist/cjs/localization/getLocaleFromPath.cjs.map +1 -1
  51. package/dist/cjs/localization/getLocaleLang.cjs.map +1 -1
  52. package/dist/cjs/localization/getLocaleName.cjs.map +1 -1
  53. package/dist/cjs/localization/getLocalizedUrl.cjs.map +1 -1
  54. package/dist/cjs/localization/getMultilingualUrls.cjs.map +1 -1
  55. package/dist/cjs/localization/getPathWithoutLocale.cjs.map +1 -1
  56. package/dist/cjs/localization/getPrefix.cjs.map +1 -1
  57. package/dist/cjs/localization/localeDetector.cjs.map +1 -1
  58. package/dist/cjs/localization/localeMapper.cjs.map +1 -1
  59. package/dist/cjs/localization/localeResolver.cjs.map +1 -1
  60. package/dist/cjs/localization/rewriteUtils.cjs.map +1 -1
  61. package/dist/cjs/localization/validatePrefix.cjs.map +1 -1
  62. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  63. package/dist/cjs/markdown/constants.cjs.map +1 -1
  64. package/dist/cjs/markdown/parser.cjs.map +1 -1
  65. package/dist/cjs/markdown/renderer.cjs.map +1 -1
  66. package/dist/cjs/markdown/utils.cjs.map +1 -1
  67. package/dist/cjs/messageFormat/ICU.cjs.map +1 -1
  68. package/dist/cjs/messageFormat/i18next.cjs.map +1 -1
  69. package/dist/cjs/messageFormat/po.cjs.map +1 -1
  70. package/dist/cjs/messageFormat/verify-icu-format.cjs.map +1 -1
  71. package/dist/cjs/messageFormat/vue-i18n.cjs.map +1 -1
  72. package/dist/cjs/transpiler/condition/condition.cjs.map +1 -1
  73. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  74. package/dist/cjs/transpiler/file/file.cjs.map +1 -1
  75. package/dist/cjs/transpiler/file/fileBrowser.cjs.map +1 -1
  76. package/dist/cjs/transpiler/gender/gender.cjs.map +1 -1
  77. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  78. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  79. package/dist/cjs/transpiler/html/htmlTags.cjs.map +1 -1
  80. package/dist/cjs/transpiler/html/validateHTML.cjs.map +1 -1
  81. package/dist/cjs/transpiler/insertion/getInsertionValues.cjs.map +1 -1
  82. package/dist/cjs/transpiler/insertion/insertion.cjs.map +1 -1
  83. package/dist/cjs/transpiler/markdown/getMarkdownMetadata.cjs.map +1 -1
  84. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  85. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs.map +1 -1
  86. package/dist/cjs/transpiler/nesting/nesting.cjs.map +1 -1
  87. package/dist/cjs/transpiler/plural/plural.cjs.map +1 -1
  88. package/dist/cjs/transpiler/translation/translation.cjs.map +1 -1
  89. package/dist/cjs/utils/checkIsURLAbsolute.cjs.map +1 -1
  90. package/dist/cjs/utils/getCookie.cjs.map +1 -1
  91. package/dist/cjs/utils/intl.cjs.map +1 -1
  92. package/dist/cjs/utils/isSameKeyPath.cjs.map +1 -1
  93. package/dist/cjs/utils/localeStorage.cjs.map +1 -1
  94. package/dist/cjs/utils/parseYaml.cjs.map +1 -1
  95. package/dist/esm/deepTransformPlugins/getFilterMissingTranslationsContent.mjs.map +1 -1
  96. package/dist/esm/deepTransformPlugins/getFilterTranslationsOnlyContent.mjs.map +1 -1
  97. package/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs.map +1 -1
  98. package/dist/esm/deepTransformPlugins/getLocalizedContent.mjs.map +1 -1
  99. package/dist/esm/deepTransformPlugins/getMaskContent.mjs.map +1 -1
  100. package/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs.map +1 -1
  101. package/dist/esm/deepTransformPlugins/getMultilingualDictionary.mjs.map +1 -1
  102. package/dist/esm/deepTransformPlugins/getReplacedValuesContent.mjs.map +1 -1
  103. package/dist/esm/deepTransformPlugins/getSplittedContent.mjs.map +1 -1
  104. package/dist/esm/deepTransformPlugins/insertContentInDictionary.mjs.map +1 -1
  105. package/dist/esm/dictionaryManipulator/editDictionaryByKeyPath.mjs.map +1 -1
  106. package/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs.map +1 -1
  107. package/dist/esm/dictionaryManipulator/getDefaultNode.mjs.map +1 -1
  108. package/dist/esm/dictionaryManipulator/getEmptyNode.mjs.map +1 -1
  109. package/dist/esm/dictionaryManipulator/getNodeChildren.mjs.map +1 -1
  110. package/dist/esm/dictionaryManipulator/getNodeType.mjs.map +1 -1
  111. package/dist/esm/dictionaryManipulator/mergeDictionaries.mjs.map +1 -1
  112. package/dist/esm/dictionaryManipulator/normalizeDictionary.mjs.map +1 -1
  113. package/dist/esm/dictionaryManipulator/orderDictionaries.mjs.map +1 -1
  114. package/dist/esm/dictionaryManipulator/removeContentNodeByKeyPath.mjs.map +1 -1
  115. package/dist/esm/dictionaryManipulator/renameContentNodeByKeyPath.mjs.map +1 -1
  116. package/dist/esm/dictionaryManipulator/updateNodeChildren.mjs.map +1 -1
  117. package/dist/esm/formatters/compact.mjs.map +1 -1
  118. package/dist/esm/formatters/currency.mjs.map +1 -1
  119. package/dist/esm/formatters/date.mjs.map +1 -1
  120. package/dist/esm/formatters/list.mjs.map +1 -1
  121. package/dist/esm/formatters/number.mjs.map +1 -1
  122. package/dist/esm/formatters/percentage.mjs.map +1 -1
  123. package/dist/esm/formatters/relativeTime.mjs.map +1 -1
  124. package/dist/esm/formatters/units.mjs.map +1 -1
  125. package/dist/esm/interpreter/getCondition.mjs.map +1 -1
  126. package/dist/esm/interpreter/getContent/deepTransform.mjs.map +1 -1
  127. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  128. package/dist/esm/interpreter/getContent/plugins.mjs +1 -5
  129. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  130. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  131. package/dist/esm/interpreter/getEnumeration.mjs.map +1 -1
  132. package/dist/esm/interpreter/getGender.mjs.map +1 -1
  133. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  134. package/dist/esm/interpreter/getInsertion.mjs.map +1 -1
  135. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  136. package/dist/esm/interpreter/getNesting.mjs.map +1 -1
  137. package/dist/esm/interpreter/getPlural.mjs.map +1 -1
  138. package/dist/esm/interpreter/getTranslation.mjs.map +1 -1
  139. package/dist/esm/interpreter/splitAndJoinInsertion.mjs.map +1 -1
  140. package/dist/esm/localization/generateSitemap.mjs.map +1 -1
  141. package/dist/esm/localization/getBrowserLocale.mjs.map +1 -1
  142. package/dist/esm/localization/getHTMLTextDir.mjs.map +1 -1
  143. package/dist/esm/localization/getLocale.mjs.map +1 -1
  144. package/dist/esm/localization/getLocaleFromPath.mjs.map +1 -1
  145. package/dist/esm/localization/getLocaleLang.mjs.map +1 -1
  146. package/dist/esm/localization/getLocaleName.mjs.map +1 -1
  147. package/dist/esm/localization/getLocalizedUrl.mjs.map +1 -1
  148. package/dist/esm/localization/getMultilingualUrls.mjs.map +1 -1
  149. package/dist/esm/localization/getPathWithoutLocale.mjs.map +1 -1
  150. package/dist/esm/localization/getPrefix.mjs.map +1 -1
  151. package/dist/esm/localization/localeDetector.mjs.map +1 -1
  152. package/dist/esm/localization/localeMapper.mjs.map +1 -1
  153. package/dist/esm/localization/localeResolver.mjs.map +1 -1
  154. package/dist/esm/localization/rewriteUtils.mjs.map +1 -1
  155. package/dist/esm/localization/validatePrefix.mjs.map +1 -1
  156. package/dist/esm/markdown/compiler.mjs.map +1 -1
  157. package/dist/esm/markdown/constants.mjs.map +1 -1
  158. package/dist/esm/markdown/parser.mjs.map +1 -1
  159. package/dist/esm/markdown/renderer.mjs.map +1 -1
  160. package/dist/esm/markdown/utils.mjs.map +1 -1
  161. package/dist/esm/messageFormat/ICU.mjs.map +1 -1
  162. package/dist/esm/messageFormat/i18next.mjs.map +1 -1
  163. package/dist/esm/messageFormat/po.mjs.map +1 -1
  164. package/dist/esm/messageFormat/verify-icu-format.mjs.map +1 -1
  165. package/dist/esm/messageFormat/vue-i18n.mjs.map +1 -1
  166. package/dist/esm/transpiler/condition/condition.mjs.map +1 -1
  167. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  168. package/dist/esm/transpiler/file/file.mjs.map +1 -1
  169. package/dist/esm/transpiler/file/fileBrowser.mjs.map +1 -1
  170. package/dist/esm/transpiler/gender/gender.mjs.map +1 -1
  171. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  172. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  173. package/dist/esm/transpiler/html/htmlTags.mjs.map +1 -1
  174. package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -1
  175. package/dist/esm/transpiler/insertion/getInsertionValues.mjs.map +1 -1
  176. package/dist/esm/transpiler/insertion/insertion.mjs.map +1 -1
  177. package/dist/esm/transpiler/markdown/getMarkdownMetadata.mjs.map +1 -1
  178. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  179. package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -1
  180. package/dist/esm/transpiler/nesting/nesting.mjs.map +1 -1
  181. package/dist/esm/transpiler/plural/plural.mjs.map +1 -1
  182. package/dist/esm/transpiler/translation/translation.mjs.map +1 -1
  183. package/dist/esm/utils/checkIsURLAbsolute.mjs.map +1 -1
  184. package/dist/esm/utils/getCookie.mjs.map +1 -1
  185. package/dist/esm/utils/intl.mjs.map +1 -1
  186. package/dist/esm/utils/isSameKeyPath.mjs.map +1 -1
  187. package/dist/esm/utils/localeStorage.mjs.map +1 -1
  188. package/dist/esm/utils/parseYaml.mjs.map +1 -1
  189. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts +11 -12
  190. package/dist/types/deepTransformPlugins/getFilterMissingTranslationsContent.d.ts.map +1 -1
  191. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts +11 -12
  192. package/dist/types/deepTransformPlugins/getFilterTranslationsOnlyContent.d.ts.map +1 -1
  193. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts +9 -10
  194. package/dist/types/deepTransformPlugins/getFilteredLocalesContent.d.ts.map +1 -1
  195. package/dist/types/deepTransformPlugins/getLocalizedContent.d.ts.map +1 -1
  196. package/dist/types/deepTransformPlugins/getMaskContent.d.ts.map +1 -1
  197. package/dist/types/deepTransformPlugins/getMultilingualDictionary.d.ts.map +1 -1
  198. package/dist/types/deepTransformPlugins/getReplacedValuesContent.d.ts.map +1 -1
  199. package/dist/types/deepTransformPlugins/getSplittedContent.d.ts.map +1 -1
  200. package/dist/types/dictionaryManipulator/getEmptyNode.d.ts.map +1 -1
  201. package/dist/types/dictionaryManipulator/getNodeChildren.d.ts.map +1 -1
  202. package/dist/types/dictionaryManipulator/getNodeType.d.ts.map +1 -1
  203. package/dist/types/dictionaryManipulator/mergeDictionaries.d.ts.map +1 -1
  204. package/dist/types/dictionaryManipulator/orderDictionaries.d.ts.map +1 -1
  205. package/dist/types/formatters/compact.d.ts.map +1 -1
  206. package/dist/types/formatters/currency.d.ts.map +1 -1
  207. package/dist/types/formatters/date.d.ts.map +1 -1
  208. package/dist/types/formatters/list.d.ts.map +1 -1
  209. package/dist/types/formatters/relativeTime.d.ts.map +1 -1
  210. package/dist/types/formatters/units.d.ts.map +1 -1
  211. package/dist/types/index.d.ts +1 -1
  212. package/dist/types/interpreter/getContent/deepTransform.d.ts.map +1 -1
  213. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  214. package/dist/types/interpreter/getContent/plugins.d.ts +3 -3
  215. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  216. package/dist/types/interpreter/getEnumeration.d.ts.map +1 -1
  217. package/dist/types/interpreter/getGender.d.ts.map +1 -1
  218. package/dist/types/interpreter/getHTML.d.ts.map +1 -1
  219. package/dist/types/interpreter/getInsertion.d.ts.map +1 -1
  220. package/dist/types/interpreter/getNesting.d.ts.map +1 -1
  221. package/dist/types/interpreter/getTranslation.d.ts.map +1 -1
  222. package/dist/types/localization/generateSitemap.d.ts.map +1 -1
  223. package/dist/types/localization/getBrowserLocale.d.ts.map +1 -1
  224. package/dist/types/localization/getHTMLTextDir.d.ts.map +1 -1
  225. package/dist/types/localization/getLocaleFromPath.d.ts.map +1 -1
  226. package/dist/types/localization/getLocaleLang.d.ts.map +1 -1
  227. package/dist/types/localization/getLocaleName.d.ts.map +1 -1
  228. package/dist/types/localization/getLocalizedUrl.d.ts.map +1 -1
  229. package/dist/types/localization/getMultilingualUrls.d.ts.map +1 -1
  230. package/dist/types/localization/getPathWithoutLocale.d.ts.map +1 -1
  231. package/dist/types/localization/getPrefix.d.ts.map +1 -1
  232. package/dist/types/localization/localeDetector.d.ts.map +1 -1
  233. package/dist/types/localization/localeMapper.d.ts.map +1 -1
  234. package/dist/types/localization/rewriteUtils.d.ts.map +1 -1
  235. package/dist/types/localization/validatePrefix.d.ts.map +1 -1
  236. package/dist/types/markdown/compiler.d.ts.map +1 -1
  237. package/dist/types/markdown/constants.d.ts.map +1 -1
  238. package/dist/types/markdown/index.d.ts +1 -1
  239. package/dist/types/markdown/types.d.ts.map +1 -1
  240. package/dist/types/markdown/utils.d.ts.map +1 -1
  241. package/dist/types/messageFormat/ICU.d.ts.map +1 -1
  242. package/dist/types/messageFormat/i18next.d.ts.map +1 -1
  243. package/dist/types/messageFormat/po.d.ts.map +1 -1
  244. package/dist/types/messageFormat/vue-i18n.d.ts.map +1 -1
  245. package/dist/types/transpiler/condition/condition.d.ts.map +1 -1
  246. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  247. package/dist/types/transpiler/file/file.d.ts.map +1 -1
  248. package/dist/types/transpiler/file/fileBrowser.d.ts.map +1 -1
  249. package/dist/types/transpiler/gender/gender.d.ts.map +1 -1
  250. package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -1
  251. package/dist/types/transpiler/html/html.d.ts.map +1 -1
  252. package/dist/types/transpiler/html/htmlTags.d.ts.map +1 -1
  253. package/dist/types/transpiler/html/validateHTML.d.ts.map +1 -1
  254. package/dist/types/transpiler/index.d.ts +1 -1
  255. package/dist/types/transpiler/insertion/getInsertionValues.d.ts.map +1 -1
  256. package/dist/types/transpiler/insertion/insertion.d.ts.map +1 -1
  257. package/dist/types/transpiler/markdown/getMarkdownMetadata.d.ts.map +1 -1
  258. package/dist/types/transpiler/markdown/index.d.ts +1 -1
  259. package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
  260. package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +1 -1
  261. package/dist/types/transpiler/nesting/nesting.d.ts.map +1 -1
  262. package/dist/types/transpiler/plural/plural.d.ts.map +1 -1
  263. package/dist/types/utils/checkIsURLAbsolute.d.ts.map +1 -1
  264. package/dist/types/utils/getCookie.d.ts.map +1 -1
  265. package/dist/types/utils/intl.d.ts.map +1 -1
  266. package/dist/types/utils/isSameKeyPath.d.ts.map +1 -1
  267. package/dist/types/utils/isValidReactElement.d.ts.map +1 -1
  268. package/dist/types/utils/localeStorage.d.ts.map +1 -1
  269. package/dist/types/utils/parseYaml.d.ts.map +1 -1
  270. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"validateHTML.cjs","names":[],"sources":["../../../../src/transpiler/html/validateHTML.ts"],"sourcesContent":["export const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport type HTMLValidationIssue = {\n type: 'error' | 'warning';\n message: string;\n};\n\nexport type HTMLValidationResult = {\n valid: boolean;\n issues: HTMLValidationIssue[];\n};\n\n// Matches HTML tags: <Tag ...>, </Tag>, or <Tag ... />\n// Attributes may span multiple lines but NOT blank lines (two consecutive newlines),\n// which prevents matching blockquote `>` markers as tag closers.\n// Groups: 1: closing slash, 2: tag name, 3: attributes, 4: self-closing slash\nconst TAG_REGEX =\n /<(\\/)?([a-zA-Z][a-zA-Z0-9.-]*)\\s*((?:[^\\n]|\\n(?!\\n))*?)(\\/?)>/g;\n\n/**\n * Validates that HTML tags in `content` are properly opened, nested, and closed.\n * Returns structured issues instead of logging to the console.\n *\n * False-positive exclusions:\n * - Tags whose attribute string starts with `://` are URL autolinks (e.g. `<https://…>`).\n */\nexport const validateHTML = (content: string): HTMLValidationResult => {\n const issues: HTMLValidationIssue[] = [];\n const stack: Array<{ tag: string }> = [];\n\n for (const match of content.matchAll(TAG_REGEX)) {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attrs = match[3];\n const isSelfClosing = !!match[4];\n\n // Skip URL autolinks like <https://example.com> or <mailto:user@example.com>\n if (\n attrs.trimStart().startsWith('://') ||\n attrs.trimStart().startsWith(':')\n ) {\n continue;\n }\n\n if (isClosing) {\n if (stack.length === 0) {\n issues.push({\n type: 'error',\n message: `Closing tag </${tagName}> has no matching opening tag`,\n });\n } else {\n const last = stack[stack.length - 1];\n if (last.tag.toLowerCase() !== tagName.toLowerCase()) {\n issues.push({\n type: 'error',\n message: `Mismatched closing tag: expected </${last.tag}> but found </${tagName}>`,\n });\n }\n stack.pop();\n }\n } else {\n const isVoidElement = VOID_ELEMENTS.has(tagName.toLowerCase());\n if (!isSelfClosing && !isVoidElement) {\n stack.push({ tag: tagName });\n }\n }\n }\n\n for (const unclosed of stack) {\n issues.push({\n type: 'error',\n message: `Unclosed HTML tag: <${unclosed.tag}>`,\n });\n }\n\n return {\n valid: issues.filter((i) => i.type === 'error').length === 0,\n issues,\n };\n};\n"],"mappings":";;;AAAA,MAAa,gBAAgB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAgBF,MAAM,YACJ;;;;;;;;AASF,MAAa,gBAAgB,YAA0C;CACrE,MAAM,SAAgC,EAAE;CACxC,MAAM,QAAgC,EAAE;CAExC,KAAK,MAAM,SAAS,QAAQ,SAAS,UAAU,EAAE;EAC/C,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,MAAM,gBAAgB,CAAC,CAAC,MAAM;EAG9B,IACE,MAAM,WAAW,CAAC,WAAW,MAAM,IACnC,MAAM,WAAW,CAAC,WAAW,IAAI,EAEjC;EAGF,IAAI,WACF,IAAI,MAAM,WAAW,GACnB,OAAO,KAAK;GACV,MAAM;GACN,SAAS,iBAAiB,QAAQ;GACnC,CAAC;OACG;GACL,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,IAAI,KAAK,IAAI,aAAa,KAAK,QAAQ,aAAa,EAClD,OAAO,KAAK;IACV,MAAM;IACN,SAAS,sCAAsC,KAAK,IAAI,gBAAgB,QAAQ;IACjF,CAAC;GAEJ,MAAM,KAAK;;OAER;GACL,MAAM,gBAAgB,cAAc,IAAI,QAAQ,aAAa,CAAC;GAC9D,IAAI,CAAC,iBAAiB,CAAC,eACrB,MAAM,KAAK,EAAE,KAAK,SAAS,CAAC;;;CAKlC,KAAK,MAAM,YAAY,OACrB,OAAO,KAAK;EACV,MAAM;EACN,SAAS,uBAAuB,SAAS,IAAI;EAC9C,CAAC;CAGJ,OAAO;EACL,OAAO,OAAO,QAAQ,MAAM,EAAE,SAAS,QAAQ,CAAC,WAAW;EAC3D;EACD"}
1
+ {"version":3,"file":"validateHTML.cjs","names":[],"sources":["../../../../src/transpiler/html/validateHTML.ts"],"sourcesContent":["export const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport type HTMLValidationIssue = {\n type: 'error' | 'warning';\n message: string;\n};\n\nexport type HTMLValidationResult = {\n valid: boolean;\n issues: HTMLValidationIssue[];\n};\n\n// Matches HTML tags: <Tag ...>, </Tag>, or <Tag ... />\n// Attributes may span multiple lines but NOT blank lines (two consecutive newlines),\n// which prevents matching blockquote `>` markers as tag closers.\n// Groups: 1: closing slash, 2: tag name, 3: attributes, 4: self-closing slash\nconst TAG_REGEX =\n /<(\\/)?([a-zA-Z][a-zA-Z0-9.-]*)\\s*((?:[^\\n]|\\n(?!\\n))*?)(\\/?)>/g;\n\n/**\n * Validates that HTML tags in `content` are properly opened, nested, and closed.\n * Returns structured issues instead of logging to the console.\n *\n * False-positive exclusions:\n * - Tags whose attribute string starts with `://` are URL autolinks (e.g. `<https://…>`).\n */\nexport const validateHTML = (content: string): HTMLValidationResult => {\n const issues: HTMLValidationIssue[] = [];\n const stack: Array<{ tag: string }> = [];\n\n for (const match of content.matchAll(TAG_REGEX)) {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attrs = match[3];\n const isSelfClosing = !!match[4];\n\n // Skip URL autolinks like <https://example.com> or <mailto:user@example.com>\n if (\n attrs.trimStart().startsWith('://') ||\n attrs.trimStart().startsWith(':')\n ) {\n continue;\n }\n\n if (isClosing) {\n if (stack.length === 0) {\n issues.push({\n type: 'error',\n message: `Closing tag </${tagName}> has no matching opening tag`,\n });\n } else {\n const last = stack[stack.length - 1];\n if (last.tag.toLowerCase() !== tagName.toLowerCase()) {\n issues.push({\n type: 'error',\n message: `Mismatched closing tag: expected </${last.tag}> but found </${tagName}>`,\n });\n }\n stack.pop();\n }\n } else {\n const isVoidElement = VOID_ELEMENTS.has(tagName.toLowerCase());\n if (!isSelfClosing && !isVoidElement) {\n stack.push({ tag: tagName });\n }\n }\n }\n\n for (const unclosed of stack) {\n issues.push({\n type: 'error',\n message: `Unclosed HTML tag: <${unclosed.tag}>`,\n });\n }\n\n return {\n valid: issues.filter((i) => i.type === 'error').length === 0,\n issues,\n };\n};\n"],"mappings":";;;AAAA,MAAa,gBAAgB,IAAI,IAAI;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAgBD,MAAM,YACJ;;;;;;;;AASF,MAAa,gBAAgB,YAA0C;CACrE,MAAM,SAAgC,CAAC;CACvC,MAAM,QAAgC,CAAC;CAEvC,KAAK,MAAM,SAAS,QAAQ,SAAS,SAAS,GAAG;EAC/C,MAAM,YAAY,CAAC,CAAC,MAAM;EAC1B,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,MAAM,gBAAgB,CAAC,CAAC,MAAM;EAG9B,IACE,MAAM,UAAU,EAAE,WAAW,KAAK,KAClC,MAAM,UAAU,EAAE,WAAW,GAAG,GAEhC;EAGF,IAAI,WACF,IAAI,MAAM,WAAW,GACnB,OAAO,KAAK;GACV,MAAM;GACN,SAAS,iBAAiB,QAAQ;EACpC,CAAC;OACI;GACL,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,IAAI,KAAK,IAAI,YAAY,MAAM,QAAQ,YAAY,GACjD,OAAO,KAAK;IACV,MAAM;IACN,SAAS,sCAAsC,KAAK,IAAI,gBAAgB,QAAQ;GAClF,CAAC;GAEH,MAAM,IAAI;EACZ;OACK;GACL,MAAM,gBAAgB,cAAc,IAAI,QAAQ,YAAY,CAAC;GAC7D,IAAI,CAAC,iBAAiB,CAAC,eACrB,MAAM,KAAK,EAAE,KAAK,QAAQ,CAAC;EAE/B;CACF;CAEA,KAAK,MAAM,YAAY,OACrB,OAAO,KAAK;EACV,MAAM;EACN,SAAS,uBAAuB,SAAS,IAAI;CAC/C,CAAC;CAGH,OAAO;EACL,OAAO,OAAO,QAAQ,MAAM,EAAE,SAAS,OAAO,EAAE,WAAW;EAC3D;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getInsertionValues.cjs","names":[],"sources":["../../../../src/transpiler/insertion/getInsertionValues.ts"],"sourcesContent":["export const getInsertionValues = (content: string): string[] => {\n // Regular expression to match {{field}} patterns\n const regex = /{{\\s*(.*?)\\s*}}/g;\n const matches = [...content.matchAll(regex)];\n\n // If no matches are found, return undefined\n if (matches.length === 0) return [];\n\n // Extract field names from matches and return as an object with the field names\n return [...new Set(matches.map((match) => match[1].trim()))].filter(Boolean);\n};\n"],"mappings":";;;AAAA,MAAa,sBAAsB,YAA8B;CAG/D,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,mBAAM,CAAC;CAG5C,IAAI,QAAQ,WAAW,GAAG,OAAO,EAAE;CAGnC,OAAO,CAAC,GAAG,IAAI,IAAI,QAAQ,KAAK,UAAU,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,QAAQ"}
1
+ {"version":3,"file":"getInsertionValues.cjs","names":[],"sources":["../../../../src/transpiler/insertion/getInsertionValues.ts"],"sourcesContent":["export const getInsertionValues = (content: string): string[] => {\n // Regular expression to match {{field}} patterns\n const regex = /{{\\s*(.*?)\\s*}}/g;\n const matches = [...content.matchAll(regex)];\n\n // If no matches are found, return undefined\n if (matches.length === 0) return [];\n\n // Extract field names from matches and return as an object with the field names\n return [...new Set(matches.map((match) => match[1].trim()))].filter(Boolean);\n};\n"],"mappings":";;;AAAA,MAAa,sBAAsB,YAA8B;CAG/D,MAAM,UAAU,CAAC,GAAG,QAAQ,SAAS,kBAAK,CAAC;CAG3C,IAAI,QAAQ,WAAW,GAAG,OAAO,CAAC;CAGlC,OAAO,CAAC,GAAG,IAAI,IAAI,QAAQ,KAAK,UAAU,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,OAAO;AAC7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"insertion.cjs","names":["getInsertionValues","INSERTION"],"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, INSERTION } from '@intlayer/types/nodeType';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<typeof INSERTION, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(INSERTION, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,aACJ,YAC8B;CAC9B,MAAM,sBAAsB;EAC1B,IAAI,OAAO,YAAY,UACrB,OAAOA,mEAAmB,QAAQ;EAGpC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,SAAS;OACpB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACdA,mEAAmB,MAAO,QAA4B;EAG1D,IAAI,OAAO,kBAAkB,UAC3B,OAAOA,mEAAmB,cAAc;EAG1C,IAAI;GACF,OAAOA,mEAAmB,KAAK,UAAU,QAAQ,CAAC;WAC3C,IAAI;GACX,OAAO,EAAE;;;CAIb,oDAAsBC,oCAAW,SAAS,EACxC,QAAQ,eAAe,EACxB,CAAC"}
1
+ {"version":3,"file":"insertion.cjs","names":["getInsertionValues","INSERTION"],"sources":["../../../../src/transpiler/insertion/insertion.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, INSERTION } from '@intlayer/types/nodeType';\nimport { getInsertionValues } from './getInsertionValues';\n\nexport type InsertionContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<typeof INSERTION, Content, T>;\n\nexport type InsertionContent<Content = unknown> = InsertionContentConstructor<\n Content,\n {\n fields: string[];\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to identify insertions inside a content.\n *\n * Usage:\n *\n * ```ts\n * insertion('Hi, my name is {{name}} and I am {{age}} years old.')\n * ```\n *\n */\nconst insertion = <Content = unknown>(\n content: Content\n): InsertionContent<Content> => {\n const getInsertions = () => {\n if (typeof content === 'string') {\n return getInsertionValues(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getInsertionValues(await (content as Promise<string>));\n }\n\n if (typeof stringContent === 'string') {\n return getInsertionValues(stringContent);\n }\n\n try {\n return getInsertionValues(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(INSERTION, content, {\n fields: getInsertions(),\n });\n};\n\nexport { insertion as insert };\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,MAAM,aACJ,YAC8B;CAC9B,MAAM,sBAAsB;EAC1B,IAAI,OAAO,YAAY,UACrB,OAAOA,mEAAmB,OAAO;EAGnC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,QAAQ;OACnB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACdA,mEAAmB,MAAO,OAA2B;EAGzD,IAAI,OAAO,kBAAkB,UAC3B,OAAOA,mEAAmB,aAAa;EAGzC,IAAI;GACF,OAAOA,mEAAmB,KAAK,UAAU,OAAO,CAAC;EACnD,SAAS,IAAI;GACX,OAAO,CAAC;EACV;CACF;CAEA,oDAAsBC,oCAAW,SAAS,EACxC,QAAQ,cAAc,EACxB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"getMarkdownMetadata.cjs","names":["parseYaml"],"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"sourcesContent":["import { parseYaml } from '../../utils/parseYaml';\n\nexport const getMarkdownMetadata = <T extends Record<string, any>>(\n markdown: string\n): T => {\n try {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter.\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== '---') {\n const result: T = {} as T;\n return result;\n }\n\n // Find the end of the metadata block\n let metadataEndIndex = -1;\n for (let i = 1; i < lines.length; i++) {\n if (lines[i].trim() === '---') {\n metadataEndIndex = i;\n break;\n }\n }\n\n if (metadataEndIndex === -1) {\n // No closing delimiter found\n const result: T = {} as T;\n return result;\n }\n\n // Extract the metadata content between the delimiters\n const metadataLines = lines.slice(1, metadataEndIndex);\n const metadataContent = metadataLines.join('\\n');\n\n // Use the improved parseYaml function to parse the entire metadata block\n const metadata = parseYaml<T>(metadataContent);\n\n return metadata ?? ({} as T);\n } catch {\n const result: T = {} as T;\n return result;\n }\n};\n"],"mappings":";;;;AAEA,MAAa,uBACX,aACM;CACN,IAAI;EACF,MAAM,QAAQ,SAAS,MAAM,QAAQ;EAGrC,MAAM,oBAAoB,MAAM,MAAM,SAAS,KAAK,MAAM,KAAK,GAAG;EAElE,IAAI,CAAC,qBAAqB,kBAAkB,MAAM,KAAK,OAErD,OAAO,EAAM;EAIf,IAAI,mBAAmB;EACvB,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,IAAI,MAAM,GAAG,MAAM,KAAK,OAAO;GAC7B,mBAAmB;GACnB;;EAIJ,IAAI,qBAAqB,IAGvB,OAAO,EAAM;EAUf,OAFiBA,kCAJK,MAAM,MAAM,GAAG,iBACA,CAAC,KAAK,KAGE,CAE9B,IAAK,EAAE;SAChB;EAEN,OAAO,EAAM"}
1
+ {"version":3,"file":"getMarkdownMetadata.cjs","names":["parseYaml"],"sources":["../../../../src/transpiler/markdown/getMarkdownMetadata.ts"],"sourcesContent":["import { parseYaml } from '../../utils/parseYaml';\n\nexport const getMarkdownMetadata = <T extends Record<string, any>>(\n markdown: string\n): T => {\n try {\n const lines = markdown.split(/\\r?\\n/);\n\n // Check if the very first non-empty line is the metadata start delimiter.\n const firstNonEmptyLine = lines.find((line) => line.trim() !== '');\n\n if (!firstNonEmptyLine || firstNonEmptyLine.trim() !== '---') {\n const result: T = {} as T;\n return result;\n }\n\n // Find the end of the metadata block\n let metadataEndIndex = -1;\n for (let i = 1; i < lines.length; i++) {\n if (lines[i].trim() === '---') {\n metadataEndIndex = i;\n break;\n }\n }\n\n if (metadataEndIndex === -1) {\n // No closing delimiter found\n const result: T = {} as T;\n return result;\n }\n\n // Extract the metadata content between the delimiters\n const metadataLines = lines.slice(1, metadataEndIndex);\n const metadataContent = metadataLines.join('\\n');\n\n // Use the improved parseYaml function to parse the entire metadata block\n const metadata = parseYaml<T>(metadataContent);\n\n return metadata ?? ({} as T);\n } catch {\n const result: T = {} as T;\n return result;\n }\n};\n"],"mappings":";;;;AAEA,MAAa,uBACX,aACM;CACN,IAAI;EACF,MAAM,QAAQ,SAAS,MAAM,OAAO;EAGpC,MAAM,oBAAoB,MAAM,MAAM,SAAS,KAAK,KAAK,MAAM,EAAE;EAEjE,IAAI,CAAC,qBAAqB,kBAAkB,KAAK,MAAM,OAErD,OAAO,CAAK;EAId,IAAI,mBAAmB;EACvB,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,IAAI,MAAM,GAAG,KAAK,MAAM,OAAO;GAC7B,mBAAmB;GACnB;EACF;EAGF,IAAI,qBAAqB,IAGvB,OAAO,CAAK;EAUd,OAFiBA,kCAJK,MAAM,MAAM,GAAG,gBACD,EAAE,KAAK,IAGC,CAE9B,KAAM,CAAC;CACvB,QAAQ;EAEN,OAAO,CAAK;CACd;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.cjs","names":["getContent","validateMarkdown","getMarkdownMetadata","getHTMLCustomComponents","MARKDOWN"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, MARKDOWN } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<typeof MARKDOWN, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(MARKDOWN, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":";;;;;;;;;AA8BA,MAAM,eAAe,OAAO,YAAiB;CAC3C,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,OAAO;CAGT,IAAI,OAAO,YAAY,YACrB,OAAO,SAAS;CAElB,IAAI,OAAO,QAAQ,SAAS,YAC1B,OAAO,MAAM;;;;;;;;;;;;;;AAgBjB,MAAM,YAIJ,SACA,eACyC;CACzC,MAAM,WAAW,YAAY;EAG3B,MAAM,cAAcA,qDAAW,MAFF,aAAa,QAAQ,EAEH;GAC7C,eAAe;GACf,SAAS,EAAE;GACZ,CAAC;EAEF,IAAI,OAAO,gBAAgB,UAAU;GACnC,IAAI,QAAQ,IAAI,aAAa,cAAc;IACzC,MAAM,EAAE,WAAWC,8DAAiB,YAAY;IAChD,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,SACjB,QAAQ,MAAM,uBAAuB,MAAM,UAAU;SAErD,QAAQ,KAAK,uBAAuB,MAAM,UAAU;;GAK1D,OAAOC,oEAAoB,YAAY;;;CAI3C,MAAM,sBAAsB;EAC1B,IAAI,YACF,OAAO;EAGT,IAAI,OAAO,YAAY,UACrB,OAAOC,wEAAwB,QAAQ;EAGzC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,SAAS;OACpB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACdA,wEAAyB,MAAO,QAAuC;EAG3E,IAAI,OAAO,kBAAkB,UAC3B,OAAOA,wEAAwB,cAAc;EAG/C,IAAI;GACF,OAAOA,wEAAwB,KAAK,UAAU,QAAQ,CAAC;WAChD,IAAI;GACX,OAAO,EAAE;;;CAIb,oDAAsBC,mCAAU,SAAS;EACvC;EACA,MAAM,eAAe;EACtB,CAAC"}
1
+ {"version":3,"file":"markdown.cjs","names":["getContent","validateMarkdown","getMarkdownMetadata","getHTMLCustomComponents","MARKDOWN"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, MARKDOWN } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\nimport { validateMarkdown } from './validateMarkdown';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type MarkdownContentConstructor<\n T extends Record<string, any> = {},\n Content = unknown,\n> = TypedNodeModel<typeof MARKDOWN, Content, T>;\n\nexport type MarkdownContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = MarkdownContentConstructor<\n {\n metadata?: Record<string, any>;\n tags?: string[] | Components;\n },\n Content\n>;\n\nconst awaitContent = async (content: any) => {\n if (typeof content === 'string' || typeof content === 'object') {\n return content as any;\n }\n\n if (typeof content === 'function') {\n return content();\n }\n if (typeof content.then === 'function') {\n return await content;\n }\n};\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * markdown('## Hello world!');\n * ```\n *\n */\nconst markdown = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): MarkdownContent<Content, Components> => {\n const metadata = async () => {\n const awaitedContent = await awaitContent(content);\n\n const flatContent = getContent(awaitedContent, {\n dictionaryKey: '',\n keyPath: [],\n });\n\n if (typeof flatContent === 'string') {\n if (process.env.NODE_ENV !== 'production') {\n const { issues } = validateMarkdown(flatContent);\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/markdown] ${issue.message}`);\n } else {\n console.warn(`[intlayer/markdown] ${issue.message}`);\n }\n }\n }\n\n return getMarkdownMetadata(flatContent);\n }\n };\n\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(MARKDOWN, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":";;;;;;;;;AA8BA,MAAM,eAAe,OAAO,YAAiB;CAC3C,IAAI,OAAO,YAAY,YAAY,OAAO,YAAY,UACpD,OAAO;CAGT,IAAI,OAAO,YAAY,YACrB,OAAO,QAAQ;CAEjB,IAAI,OAAO,QAAQ,SAAS,YAC1B,OAAO,MAAM;AAEjB;;;;;;;;;;;;;AAcA,MAAM,YAIJ,SACA,eACyC;CACzC,MAAM,WAAW,YAAY;EAG3B,MAAM,cAAcA,qDAAW,MAFF,aAAa,OAAO,GAEF;GAC7C,eAAe;GACf,SAAS,CAAC;EACZ,CAAC;EAED,IAAI,OAAO,gBAAgB,UAAU;GACnC,IAAI,QAAQ,IAAI,aAAa,cAAc;IACzC,MAAM,EAAE,WAAWC,8DAAiB,WAAW;IAC/C,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,SACjB,QAAQ,MAAM,uBAAuB,MAAM,SAAS;SAEpD,QAAQ,KAAK,uBAAuB,MAAM,SAAS;GAGzD;GAEA,OAAOC,oEAAoB,WAAW;EACxC;CACF;CAEA,MAAM,sBAAsB;EAC1B,IAAI,YACF,OAAO;EAGT,IAAI,OAAO,YAAY,UACrB,OAAOC,wEAAwB,OAAO;EAGxC,IAAI;EAEJ,IAAI,OAAO,YAAY,YACrB,gBAAgB,QAAQ;OACnB,IAAI,OAAQ,QAA4B,SAAS,YACtD,gBAAgB,YACdA,wEAAyB,MAAO,OAAsC;EAG1E,IAAI,OAAO,kBAAkB,UAC3B,OAAOA,wEAAwB,aAAa;EAG9C,IAAI;GACF,OAAOA,wEAAwB,KAAK,UAAU,OAAO,CAAC;EACxD,SAAS,IAAI;GACX,OAAO,CAAC;EACV;CACF;CAEA,oDAAsBC,mCAAU,SAAS;EACvC;EACA,MAAM,cAAc;CACtB,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateMarkdown.cjs","names":["validateHTML"],"sources":["../../../../src/transpiler/markdown/validateMarkdown.ts"],"sourcesContent":["import { type HTMLValidationIssue, validateHTML } from '../html/validateHTML';\n\nexport type { HTMLValidationIssue as MarkdownValidationIssue } from '../html/validateHTML';\n\nexport type MarkdownValidationResult = {\n valid: boolean;\n issues: HTMLValidationIssue[];\n};\n\n/**\n * Strips fenced code blocks and inline code from markdown content so that\n * HTML-like syntax inside code is not mistakenly validated.\n */\nconst stripCode = (content: string): string => {\n const lines = content.split('\\n');\n const result: string[] = [];\n let inCodeBlock = false;\n let openFence: string | null = null;\n\n for (const line of lines) {\n // Allow leading whitespace and blockquote markers before the fence characters\n const fence = line.match(/^[\\s>]*(`{3,}|~{3,})/);\n if (!inCodeBlock) {\n if (fence) {\n inCodeBlock = true;\n openFence = fence[1];\n result.push('');\n } else {\n // Also strip inline code spans on this line\n result.push(line.replace(/`[^`\\n]+`/g, (m) => ' '.repeat(m.length)));\n }\n } else {\n if (\n fence &&\n fence[1][0] === openFence![0] &&\n fence[1].length >= openFence!.length\n ) {\n inCodeBlock = false;\n openFence = null;\n }\n result.push('');\n }\n }\n\n return result.join('\\n');\n};\n\nconst validateCodeBlocks = (content: string): HTMLValidationIssue[] => {\n const issues: HTMLValidationIssue[] = [];\n const lines = content.split('\\n');\n let inCodeBlock = false;\n let openFence: string | null = null;\n let openLineNumber = -1;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n // Allow leading whitespace and blockquote markers before the fence characters\n const fence = line.match(/^[\\s>]*(`{3,}|~{3,})/);\n\n if (!inCodeBlock) {\n if (fence) {\n inCodeBlock = true;\n openFence = fence[1];\n openLineNumber = i + 1;\n }\n } else {\n if (\n fence &&\n fence[1][0] === openFence![0] &&\n fence[1].length >= openFence!.length\n ) {\n inCodeBlock = false;\n openFence = null;\n }\n }\n }\n\n if (inCodeBlock) {\n issues.push({\n type: 'error',\n message: `Unclosed code block (opened at line ${openLineNumber})`,\n });\n }\n\n return issues;\n};\n\n/**\n * Validates markdown content for structural correctness:\n * - All fenced code blocks are properly closed\n * - HTML tags are properly nested and closed\n *\n * HTML inside code blocks is excluded from HTML validation.\n */\nexport const validateMarkdown = (content: string): MarkdownValidationResult => {\n const codeIssues = validateCodeBlocks(content);\n const htmlIssues = validateHTML(stripCode(content)).issues;\n const issues = [...codeIssues, ...htmlIssues];\n\n return {\n valid: issues.filter((i) => i.type === 'error').length === 0,\n issues,\n };\n};\n"],"mappings":";;;;;;;;AAaA,MAAM,aAAa,YAA4B;CAC7C,MAAM,QAAQ,QAAQ,MAAM,KAAK;CACjC,MAAM,SAAmB,EAAE;CAC3B,IAAI,cAAc;CAClB,IAAI,YAA2B;CAE/B,KAAK,MAAM,QAAQ,OAAO;EAExB,MAAM,QAAQ,KAAK,MAAM,uBAAuB;EAChD,IAAI,CAAC,aACH,IAAI,OAAO;GACT,cAAc;GACd,YAAY,MAAM;GAClB,OAAO,KAAK,GAAG;SAGf,OAAO,KAAK,KAAK,QAAQ,eAAe,MAAM,IAAI,OAAO,EAAE,OAAO,CAAC,CAAC;OAEjE;GACL,IACE,SACA,MAAM,GAAG,OAAO,UAAW,MAC3B,MAAM,GAAG,UAAU,UAAW,QAC9B;IACA,cAAc;IACd,YAAY;;GAEd,OAAO,KAAK,GAAG;;;CAInB,OAAO,OAAO,KAAK,KAAK;;AAG1B,MAAM,sBAAsB,YAA2C;CACrE,MAAM,SAAgC,EAAE;CACxC,MAAM,QAAQ,QAAQ,MAAM,KAAK;CACjC,IAAI,cAAc;CAClB,IAAI,YAA2B;CAC/B,IAAI,iBAAiB;CAErB,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EAGrC,MAAM,QAFO,MAAM,GAEA,MAAM,uBAAuB;EAEhD,IAAI,CAAC,aACH;OAAI,OAAO;IACT,cAAc;IACd,YAAY,MAAM;IAClB,iBAAiB,IAAI;;SAGvB,IACE,SACA,MAAM,GAAG,OAAO,UAAW,MAC3B,MAAM,GAAG,UAAU,UAAW,QAC9B;GACA,cAAc;GACd,YAAY;;;CAKlB,IAAI,aACF,OAAO,KAAK;EACV,MAAM;EACN,SAAS,uCAAuC,eAAe;EAChE,CAAC;CAGJ,OAAO;;;;;;;;;AAUT,MAAa,oBAAoB,YAA8C;CAC7E,MAAM,aAAa,mBAAmB,QAAQ;CAC9C,MAAM,aAAaA,kDAAa,UAAU,QAAQ,CAAC,CAAC;CACpD,MAAM,SAAS,CAAC,GAAG,YAAY,GAAG,WAAW;CAE7C,OAAO;EACL,OAAO,OAAO,QAAQ,MAAM,EAAE,SAAS,QAAQ,CAAC,WAAW;EAC3D;EACD"}
1
+ {"version":3,"file":"validateMarkdown.cjs","names":["validateHTML"],"sources":["../../../../src/transpiler/markdown/validateMarkdown.ts"],"sourcesContent":["import { type HTMLValidationIssue, validateHTML } from '../html/validateHTML';\n\nexport type { HTMLValidationIssue as MarkdownValidationIssue } from '../html/validateHTML';\n\nexport type MarkdownValidationResult = {\n valid: boolean;\n issues: HTMLValidationIssue[];\n};\n\n/**\n * Strips fenced code blocks and inline code from markdown content so that\n * HTML-like syntax inside code is not mistakenly validated.\n */\nconst stripCode = (content: string): string => {\n const lines = content.split('\\n');\n const result: string[] = [];\n let inCodeBlock = false;\n let openFence: string | null = null;\n\n for (const line of lines) {\n // Allow leading whitespace and blockquote markers before the fence characters\n const fence = line.match(/^[\\s>]*(`{3,}|~{3,})/);\n if (!inCodeBlock) {\n if (fence) {\n inCodeBlock = true;\n openFence = fence[1];\n result.push('');\n } else {\n // Also strip inline code spans on this line\n result.push(line.replace(/`[^`\\n]+`/g, (m) => ' '.repeat(m.length)));\n }\n } else {\n if (\n fence &&\n fence[1][0] === openFence![0] &&\n fence[1].length >= openFence!.length\n ) {\n inCodeBlock = false;\n openFence = null;\n }\n result.push('');\n }\n }\n\n return result.join('\\n');\n};\n\nconst validateCodeBlocks = (content: string): HTMLValidationIssue[] => {\n const issues: HTMLValidationIssue[] = [];\n const lines = content.split('\\n');\n let inCodeBlock = false;\n let openFence: string | null = null;\n let openLineNumber = -1;\n\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n // Allow leading whitespace and blockquote markers before the fence characters\n const fence = line.match(/^[\\s>]*(`{3,}|~{3,})/);\n\n if (!inCodeBlock) {\n if (fence) {\n inCodeBlock = true;\n openFence = fence[1];\n openLineNumber = i + 1;\n }\n } else {\n if (\n fence &&\n fence[1][0] === openFence![0] &&\n fence[1].length >= openFence!.length\n ) {\n inCodeBlock = false;\n openFence = null;\n }\n }\n }\n\n if (inCodeBlock) {\n issues.push({\n type: 'error',\n message: `Unclosed code block (opened at line ${openLineNumber})`,\n });\n }\n\n return issues;\n};\n\n/**\n * Validates markdown content for structural correctness:\n * - All fenced code blocks are properly closed\n * - HTML tags are properly nested and closed\n *\n * HTML inside code blocks is excluded from HTML validation.\n */\nexport const validateMarkdown = (content: string): MarkdownValidationResult => {\n const codeIssues = validateCodeBlocks(content);\n const htmlIssues = validateHTML(stripCode(content)).issues;\n const issues = [...codeIssues, ...htmlIssues];\n\n return {\n valid: issues.filter((i) => i.type === 'error').length === 0,\n issues,\n };\n};\n"],"mappings":";;;;;;;;AAaA,MAAM,aAAa,YAA4B;CAC7C,MAAM,QAAQ,QAAQ,MAAM,IAAI;CAChC,MAAM,SAAmB,CAAC;CAC1B,IAAI,cAAc;CAClB,IAAI,YAA2B;CAE/B,KAAK,MAAM,QAAQ,OAAO;EAExB,MAAM,QAAQ,KAAK,MAAM,sBAAsB;EAC/C,IAAI,CAAC,aACH,IAAI,OAAO;GACT,cAAc;GACd,YAAY,MAAM;GAClB,OAAO,KAAK,EAAE;EAChB,OAEE,OAAO,KAAK,KAAK,QAAQ,eAAe,MAAM,IAAI,OAAO,EAAE,MAAM,CAAC,CAAC;OAEhE;GACL,IACE,SACA,MAAM,GAAG,OAAO,UAAW,MAC3B,MAAM,GAAG,UAAU,UAAW,QAC9B;IACA,cAAc;IACd,YAAY;GACd;GACA,OAAO,KAAK,EAAE;EAChB;CACF;CAEA,OAAO,OAAO,KAAK,IAAI;AACzB;AAEA,MAAM,sBAAsB,YAA2C;CACrE,MAAM,SAAgC,CAAC;CACvC,MAAM,QAAQ,QAAQ,MAAM,IAAI;CAChC,IAAI,cAAc;CAClB,IAAI,YAA2B;CAC/B,IAAI,iBAAiB;CAErB,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EAGrC,MAAM,QAFO,MAAM,GAEA,MAAM,sBAAsB;EAE/C,IAAI,CAAC,aACH;OAAI,OAAO;IACT,cAAc;IACd,YAAY,MAAM;IAClB,iBAAiB,IAAI;GACvB;SAEA,IACE,SACA,MAAM,GAAG,OAAO,UAAW,MAC3B,MAAM,GAAG,UAAU,UAAW,QAC9B;GACA,cAAc;GACd,YAAY;EACd;CAEJ;CAEA,IAAI,aACF,OAAO,KAAK;EACV,MAAM;EACN,SAAS,uCAAuC,eAAe;CACjE,CAAC;CAGH,OAAO;AACT;;;;;;;;AASA,MAAa,oBAAoB,YAA8C;CAC7E,MAAM,aAAa,mBAAmB,OAAO;CAC7C,MAAM,aAAaA,kDAAa,UAAU,OAAO,CAAC,EAAE;CACpD,MAAM,SAAS,CAAC,GAAG,YAAY,GAAG,UAAU;CAE5C,OAAO;EACL,OAAO,OAAO,QAAQ,MAAM,EAAE,SAAS,OAAO,EAAE,WAAW;EAC3D;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"nesting.cjs","names":["NESTED"],"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n} from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NESTED } from '@intlayer/types/nodeType';\n\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<DictionaryRegistryContent<K>>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in DictionaryRegistryContent<K>.\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n typeof NESTED,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NESTED, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2EA,MAAM,WACJ,eACA,sDAEeA,iCAAQ;CACrB;CACA;CACD,CAAC"}
1
+ {"version":3,"file":"nesting.cjs","names":["NESTED"],"sources":["../../../../src/transpiler/nesting/nesting.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n} from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NESTED } from '@intlayer/types/nodeType';\n\nimport type { DeepTransformContent } from '../../interpreter';\n\n/**\n * Recursively builds dot-notation strings for all valid paths in T.\n * Example:\n * type X = { a: { b: { c: string }}, d: number };\n * DotPath<X> = \"a\" | \"a.b\" | \"a.b.c\" | \"d\"\n */\nexport type DotPath<T> = T extends object\n ? {\n [K in keyof T & (string | number)]: T[K] extends object\n ? // Either just K, or K + '.' + deeper path\n `${K}` | `${K}.${DotPath<T[K]>}`\n : `${K}`;\n }[keyof T & (string | number)]\n : never;\n\ntype DeepReplace<T, From, To> = T extends From\n ? To\n : T extends object\n ? { [K in keyof T]: DeepReplace<T[K], From, To> }\n : T;\n\n/** Build all valid dot-notation strings for a dictionary entry. */\nexport type ValidDotPathsFor<K extends DictionaryKeys> = DotPath<\n DeepReplace<\n DeepTransformContent<DictionaryRegistryContent<K>>,\n // Replace ReactElement type with string\n {\n type: any;\n props: any;\n key: any;\n },\n string\n >\n>;\n\nexport type NestedContentState<K extends DictionaryKeys> = {\n dictionaryKey: K;\n\n /**\n * Path must match existing keys in DictionaryRegistryContent<K>.\n * Can be either:\n * - \"dot.dot.dot\" format\n */\n path?: ValidDotPathsFor<K>;\n};\n\nexport type NestedContent<K extends DictionaryKeys = never> = TypedNodeModel<\n typeof NESTED,\n NestedContentState<K>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to extract the content of another dictionary and nest it in the current dictionary.\n *\n * Usage:\n *\n * ```ts\n * nest(\"dictionaryKey\");\n * nest(\"dictionaryKey\", \"path.to.content\");\n * ```\n *\n * The order of the keys will define the priority of the content.\n *\n */\nconst nesting = <K extends DictionaryKeys>(\n dictionaryKey: K,\n path?: ValidDotPathsFor<K>\n): NestedContent<K> =>\n formatNodeType(NESTED, {\n dictionaryKey,\n path,\n });\n\nexport { nesting as nest };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2EA,MAAM,WACJ,eACA,sDAEeA,iCAAQ;CACrB;CACA;AACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plural.cjs","names":["PLURAL"],"sources":["../../../../src/transpiler/plural/plural.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, PLURAL } from '@intlayer/types/nodeType';\n\nexport type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';\n\nexport type PluralContentState<Content> = Partial<\n Record<PluralCategory, Content>\n> & {\n other: Content;\n};\n\nexport type PluralContent<Content = unknown> = TypedNodeModel<\n typeof PLURAL,\n PluralContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity using CLDR pluralization rules\n * (`Intl.PluralRules`). The selected category depends on the active locale.\n *\n * Supported categories: `zero`, `one`, `two`, `few`, `many`, `other`.\n * `other` is required as the fallback.\n *\n * The string content can include a `{{count}}` placeholder, which is\n * automatically replaced with the provided count.\n *\n * Usage:\n *\n * ```ts\n * plural({\n * one: '{{count}} вакансия',\n * few: '{{count}} вакансии',\n * many: '{{count}} вакансий',\n * other: '{{count}} вакансий',\n * });\n * ```\n */\nconst plural = <Content = unknown>(\n content: PluralContentState<Content>\n): PluralContent<Content> => formatNodeType(PLURAL, content);\n\nexport { plural };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,UACJ,yDAC0CA,iCAAQ,QAAQ"}
1
+ {"version":3,"file":"plural.cjs","names":["PLURAL"],"sources":["../../../../src/transpiler/plural/plural.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, PLURAL } from '@intlayer/types/nodeType';\n\nexport type PluralCategory = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other';\n\nexport type PluralContentState<Content> = Partial<\n Record<PluralCategory, Content>\n> & {\n other: Content;\n};\n\nexport type PluralContent<Content = unknown> = TypedNodeModel<\n typeof PLURAL,\n PluralContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity using CLDR pluralization rules\n * (`Intl.PluralRules`). The selected category depends on the active locale.\n *\n * Supported categories: `zero`, `one`, `two`, `few`, `many`, `other`.\n * `other` is required as the fallback.\n *\n * The string content can include a `{{count}}` placeholder, which is\n * automatically replaced with the provided count.\n *\n * Usage:\n *\n * ```ts\n * plural({\n * one: '{{count}} вакансия',\n * few: '{{count}} вакансии',\n * many: '{{count}} вакансий',\n * other: '{{count}} вакансий',\n * });\n * ```\n */\nconst plural = <Content = unknown>(\n content: PluralContentState<Content>\n): PluralContent<Content> => formatNodeType(PLURAL, content);\n\nexport { plural };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,MAAM,UACJ,yDAC0CA,iCAAQ,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"translation.cjs","names":["TRANSLATION"],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, TRANSLATION } from '@intlayer/types/nodeType';\n\nexport type TranslationContent<\n Content = unknown,\n RecordContent extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n> = TypedNodeModel<typeof TRANSLATION, RecordContent>;\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <\n Content = unknown,\n ContentRecord extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n>(\n content: ContentRecord\n): TranslationContent<Content, ContentRecord> =>\n formatNodeType(TRANSLATION, content) satisfies TranslationContent<\n Content,\n ContentRecord\n >;\n\nexport { translation as t };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,eAKJ,yDAEeA,sCAAa,QAAQ"}
1
+ {"version":3,"file":"translation.cjs","names":["TRANSLATION"],"sources":["../../../../src/transpiler/translation/translation.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, TRANSLATION } from '@intlayer/types/nodeType';\n\nexport type TranslationContent<\n Content = unknown,\n RecordContent extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n> = TypedNodeModel<typeof TRANSLATION, RecordContent>;\n\n/**\n *\n * Function intended to be used to build intlayer dictionaries.\n *\n * Get the content of a translation based on the locale.\n *\n * Usage:\n *\n * ```ts\n * translation<string>({\n * \"en\": \"Hello\",\n * \"fr\": \"Bonjour\",\n * // ... any other available locale\n * })\n * ```\n *\n * Using TypeScript:\n * - this function require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nconst translation = <\n Content = unknown,\n ContentRecord extends\n StrictModeLocaleMap<Content> = StrictModeLocaleMap<Content>,\n>(\n content: ContentRecord\n): TranslationContent<Content, ContentRecord> =>\n formatNodeType(TRANSLATION, content) satisfies TranslationContent<\n Content,\n ContentRecord\n >;\n\nexport { translation as t };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,eAKJ,yDAEeA,sCAAa,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"checkIsURLAbsolute.cjs","names":[],"sources":["../../../src/utils/checkIsURLAbsolute.ts"],"sourcesContent":["export const checkIsURLAbsolute = (url: string): boolean =>\n /^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(url);\n"],"mappings":";;;AAAA,MAAa,sBAAsB,QACjC,4BAA4B,KAAK,IAAI"}
1
+ {"version":3,"file":"checkIsURLAbsolute.cjs","names":[],"sources":["../../../src/utils/checkIsURLAbsolute.ts"],"sourcesContent":["export const checkIsURLAbsolute = (url: string): boolean =>\n /^[a-zA-Z][a-zA-Z\\d+\\-.]*:/.test(url);\n"],"mappings":";;;AAAA,MAAa,sBAAsB,QACjC,4BAA4B,KAAK,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"file":"getCookie.cjs","names":[],"sources":["../../../src/utils/getCookie.ts"],"sourcesContent":["/**\n * Retrieves a cookie by name from a cookie string or document.cookie\n * @param name - The name of the cookie to retrieve\n * @param cookieString - Optional cookie string to parse (defaults to document.cookie in browser)\n * @returns The cookie value or undefined if not found\n */\nexport const getCookie = (\n name: string,\n cookieString?: string\n): string | undefined => {\n try {\n const str =\n cookieString ?? (typeof document !== 'undefined' ? document.cookie : '');\n\n if (!str) return undefined;\n\n const pairs = str.split(';');\n\n for (let i = 0; i < pairs.length; i++) {\n const part = pairs[i].trim();\n\n if (!part) continue;\n\n const equalIndex = part.indexOf('=');\n const key = equalIndex >= 0 ? part.substring(0, equalIndex) : part;\n\n if (key === name) {\n const rawValue = equalIndex >= 0 ? part.substring(equalIndex + 1) : '';\n\n try {\n return decodeURIComponent(rawValue);\n } catch {\n return rawValue;\n }\n }\n }\n } catch {}\n return undefined;\n};\n"],"mappings":";;;;;;;;;AAMA,MAAa,aACX,MACA,iBACuB;CACvB,IAAI;EACF,MAAM,MACJ,iBAAiB,OAAO,aAAa,cAAc,SAAS,SAAS;EAEvE,IAAI,CAAC,KAAK,OAAO;EAEjB,MAAM,QAAQ,IAAI,MAAM,IAAI;EAE5B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;GACrC,MAAM,OAAO,MAAM,GAAG,MAAM;GAE5B,IAAI,CAAC,MAAM;GAEX,MAAM,aAAa,KAAK,QAAQ,IAAI;GAGpC,KAFY,cAAc,IAAI,KAAK,UAAU,GAAG,WAAW,GAAG,UAElD,MAAM;IAChB,MAAM,WAAW,cAAc,IAAI,KAAK,UAAU,aAAa,EAAE,GAAG;IAEpE,IAAI;KACF,OAAO,mBAAmB,SAAS;YAC7B;KACN,OAAO;;;;SAIP"}
1
+ {"version":3,"file":"getCookie.cjs","names":[],"sources":["../../../src/utils/getCookie.ts"],"sourcesContent":["/**\n * Retrieves a cookie by name from a cookie string or document.cookie\n * @param name - The name of the cookie to retrieve\n * @param cookieString - Optional cookie string to parse (defaults to document.cookie in browser)\n * @returns The cookie value or undefined if not found\n */\nexport const getCookie = (\n name: string,\n cookieString?: string\n): string | undefined => {\n try {\n const str =\n cookieString ?? (typeof document !== 'undefined' ? document.cookie : '');\n\n if (!str) return undefined;\n\n const pairs = str.split(';');\n\n for (let i = 0; i < pairs.length; i++) {\n const part = pairs[i].trim();\n\n if (!part) continue;\n\n const equalIndex = part.indexOf('=');\n const key = equalIndex >= 0 ? part.substring(0, equalIndex) : part;\n\n if (key === name) {\n const rawValue = equalIndex >= 0 ? part.substring(equalIndex + 1) : '';\n\n try {\n return decodeURIComponent(rawValue);\n } catch {\n return rawValue;\n }\n }\n }\n } catch {}\n return undefined;\n};\n"],"mappings":";;;;;;;;;AAMA,MAAa,aACX,MACA,iBACuB;CACvB,IAAI;EACF,MAAM,MACJ,iBAAiB,OAAO,aAAa,cAAc,SAAS,SAAS;EAEvE,IAAI,CAAC,KAAK,OAAO;EAEjB,MAAM,QAAQ,IAAI,MAAM,GAAG;EAE3B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;GACrC,MAAM,OAAO,MAAM,GAAG,KAAK;GAE3B,IAAI,CAAC,MAAM;GAEX,MAAM,aAAa,KAAK,QAAQ,GAAG;GAGnC,KAFY,cAAc,IAAI,KAAK,UAAU,GAAG,UAAU,IAAI,UAElD,MAAM;IAChB,MAAM,WAAW,cAAc,IAAI,KAAK,UAAU,aAAa,CAAC,IAAI;IAEpE,IAAI;KACF,OAAO,mBAAmB,QAAQ;IACpC,QAAQ;KACN,OAAO;IACT;GACF;EACF;CACF,QAAQ,CAAC;AAEX"}
@@ -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;CAE/B,IAAI,CAAC,WAAW;EACd,4BAA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,QAAQ;;CAE3D,aAAa,SAAS,YAAY,SAAe,SAAe;EAC9D,OAAO,cAAc,KAAK,aAAa,SAAS,QAAQ;;CAE1D,oBAAoB,SAAS,mBAC3B,SACA,SACA;EACA,OAAO,cAAc,KAAK,oBAAoB,SAAS,QAAQ;;CAEjE,WAAW,SAAS,UAAU,SAAe,SAAe;EAC1D,OAAO,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\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,IAA2B;;;;AAwC7C,MAAa,iBACX,MACA,QACA,YACoB;CACpB,MAAM,SAAS,UAAUA,6CAAsB;CAG/C,MAAM,MAAM,GAAG,OAAO,GADP,UAAU,KAAK,UAAU,OAAO,IAAI;CAGnD,IAA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SAAS,OAAO;CAC/D;CACA,cAAc,SAAS,aAAa,SAAe,SAAe;EAChE,OAAO,cAAc,KAAK,cAAc,SAAS,OAAO;CAC1D;CACA,aAAa,SAAS,YAAY,SAAe,SAAe;EAC9D,OAAO,cAAc,KAAK,aAAa,SAAS,OAAO;CACzD;CACA,oBAAoB,SAAS,mBAC3B,SACA,SACA;EACA,OAAO,cAAc,KAAK,oBAAoB,SAAS,OAAO;CAChE;CACA,WAAW,SAAS,UAAU,SAAe,SAAe;EAC1D,OAAO,cAAe,KAAa,WAAW,SAAS,OAAO;CAChE;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,OAA0B,QACjC,QAA2B,OAC9B,SAAS,OAAO,SAAS,QAAQ,IACrC"}
@@ -1 +1 @@
1
- {"version":3,"file":"localeStorage.cjs","names":["localeStorageOptions","internationalization","routing","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import { internationalization, routing } from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { localeStorageOptions } from '../localization';\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 /** Expiry as milliseconds since epoch (Date.getTime()) or number of days */\n expires?: number | undefined;\n};\n\n// ============================================================================\n// Shared helpers\n// ============================================================================\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\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/**\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:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : 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:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : 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:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : 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":";;;;;;;;;;AAcA,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;;;;A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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,KAAK,EAAE;;GAEvC,QAAQ,kBAAkB,MAAM,OAAO;UACjC;;CAIZ,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,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":["localeStorageOptions","internationalization","routing","getCookie"],"sources":["../../../src/utils/localeStorage.ts"],"sourcesContent":["import { internationalization, routing } from '@intlayer/config/built';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { CookiesAttributes } from '@intlayer/types/config';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { localeStorageOptions } from '../localization';\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 /** Expiry as milliseconds since epoch (Date.getTime()) or number of days */\n expires?: number | undefined;\n};\n\n// ============================================================================\n// Shared helpers\n// ============================================================================\n\nconst buildCookieString = (\n name: string,\n value: string,\n attributes: Omit<CookiesAttributes, 'name' | 'type'>\n): string => {\n const encodedValue = encodeURIComponent(value);\n const parts: string[] = [`${name}=${encodedValue}`];\n\n if (attributes.path) parts.push(`Path=${attributes.path}`);\n if (attributes.domain) parts.push(`Domain=${attributes.domain}`);\n if (attributes.expires instanceof Date)\n parts.push(`Expires=${attributes.expires.toUTCString()}`);\n if (attributes.secure) parts.push('Secure');\n if (attributes.sameSite) parts.push(`SameSite=${attributes.sameSite}`);\n return parts.join('; ');\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/**\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:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : 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:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : 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:\n attributes.expires instanceof Date\n ? attributes.expires.getTime()\n : 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":";;;;;;;;;;AAcA,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;;;;AAKtD,MAAM,mCACJ,QAAQ,IAAI,6CAA6C;;;;AAK3D,MAAM,qCACJ,QAAQ,IAAI,+CAA+C;;;;AAK7D,MAAM,6BACJ,QAAQ,IAAI,wCAAwC;AAoBtD,MAAM,qBACJ,MACA,OACA,eACW;CAEX,MAAM,QAAkB,CAAC,GAAG,KAAK,GADZ,mBAAmB,KACO,GAAG;CAElD,IAAI,WAAW,MAAM,MAAM,KAAK,QAAQ,WAAW,MAAM;CACzD,IAAI,WAAW,QAAQ,MAAM,KAAK,UAAU,WAAW,QAAQ;CAC/D,IAAI,WAAW,mBAAmB,MAChC,MAAM,KAAK,WAAW,WAAW,QAAQ,YAAY,GAAG;CAC1D,IAAI,WAAW,QAAQ,MAAM,KAAK,QAAQ;CAC1C,IAAI,WAAW,UAAU,MAAM,KAAK,YAAY,WAAW,UAAU;CACrE,OAAO,MAAM,KAAK,IAAI;AACxB;;;;;;AA4BA,MAAa,8BACX,UAAsCA,+DACf;CACvB,MAAM,EAAE,YAAYC;CAEpB,IAAI,SAAS,oBAAoB,OAAO,OAAO;CAE/C,MAAM,iBAAiB,UACrB,CAAC,CAAC,SAAS,QAAQ,SAAS,KAAe;CAE7C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,QAAQ,QAAQ,GAAG,MAAM,MAAM;CAC3D,QAAQ,CAAC;AAGf;;;;;;;AAQA,MAAa,iBAAiB,aAAmC;CAC/D,iBAAiB,qBAAqB,OAAO;CAC7C,YAAY,WAA0B,mBAAmB,QAAQ,OAAO;AAC1E"}
@@ -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 const parseYaml = <T = any>(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];\n const next = () => text[index++];\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: '\"' | \"'\") => {\n next(); // consume quote\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) => {\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): any => {\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 if (raw === '3.14159265359') return Math.PI;\n return Number(raw);\n }\n return raw;\n };\n\n const parseValue = (stops: string): any => {\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 = (): any[] => {\n next(); // consume [\n const arr: any[] = [];\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 = (): any => {\n next(); // consume '-'\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();\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 = (): Record<string, any> => {\n const obj: Record<string, any> = {};\n const baseIndent = getCurrentIndent();\n\n while (!eof()) {\n const lineStart = index;\n const startedNewLine = lineStart === 0 || text[lineStart - 1] === '\\n';\n skipWhitespace();\n\n if (startedNewLine && getCurrentIndent() <= 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 skipWhitespace();\n\n if (peek() === '-') {\n obj[key] = parseYamlList();\n continue;\n }\n }\n\n obj[key] = toTypedValue(parseUnquotedToken('\\n'));\n\n if (peek() === '\\n') next();\n }\n return obj;\n };\n\n const parseYamlList = (): any[] => {\n const arr: any[] = [];\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): Record<string, any> => {\n const obj: Record<string, any> = {};\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 if (peek() === '-') {\n obj[key] = parseYamlList();\n skipWhitespace();\n continue;\n } else {\n index = afterNewlinePos;\n skipWhitespace();\n const nextChar = peek();\n\n if (nextChar && !stops.includes(nextChar) && nextChar !== '-') {\n obj[key] = '';\n continue;\n }\n obj[key] = '';\n return obj;\n }\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 = (): Record<string, any> => {\n next(); // consume {\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 // Entry points\n\n if (text.startsWith(']') || text.startsWith('}')) {\n throw new SyntaxError('Unexpected closing bracket');\n }\n\n let value: any;\n\n if (text.startsWith('[')) value = parseArray();\n else if (text.startsWith('{')) value = parseObject();\n else if (hasTopLevelKeyColonSpace(text)) value = parseObjectBody('');\n else value = 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;AAEF,MAAa,aAAsB,UAA4B;CAC7D,MAAM,OAAO,MAAM,MAAM;CAEzB,IAAI,CAAC,MAAM,OAAO;CAElB,IAAI,QAAQ;CAEZ,MAAM,aAAa,KAAK;CACxB,MAAM,aAAa,KAAK;CACxB,MAAM,YAAY,SAAS,KAAK;CAEhC,MAAM,uBAAuB;EAC3B,OAAO,CAAC,KAAK,IAAI,SAAU,SAAS,MAAM,CAAC,EAAE;;CAG/C,MAAM,qBAAqB,UAAqB;EAC9C,MAAM;EACN,IAAI,SAAS;EACb,OAAO,CAAC,KAAK,EAAE;GACb,MAAM,KAAK,MAAM;GAEjB,IAAI,OAAO,OAAO,OAAO;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BAA6B;CAGrD,IAAI;CAEJ,IAAI,KAAK,WAAW,IAAI,EAAE,QAAQ,YAAY;MACzC,IAAI,KAAK,WAAW,IAAI,EAAE,QAAQ,aAAa;MAC/C,IAAI,yBAAyB,KAAK,EAAE,QAAQ,gBAAgB,GAAG;MAC/D,QAAQ,WAAW,GAAG;CAE3B,gBAAgB;CAEhB,IAAI,CAAC,KAAK,EAAE,MAAM,IAAI,YAAY,iCAAiC;CAEnE,OAAO"}
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 const parseYaml = <T = any>(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];\n const next = () => text[index++];\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: '\"' | \"'\") => {\n next(); // consume quote\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) => {\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): any => {\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 if (raw === '3.14159265359') return Math.PI;\n return Number(raw);\n }\n return raw;\n };\n\n const parseValue = (stops: string): any => {\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 = (): any[] => {\n next(); // consume [\n const arr: any[] = [];\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 = (): any => {\n next(); // consume '-'\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();\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 = (): Record<string, any> => {\n const obj: Record<string, any> = {};\n const baseIndent = getCurrentIndent();\n\n while (!eof()) {\n const lineStart = index;\n const startedNewLine = lineStart === 0 || text[lineStart - 1] === '\\n';\n skipWhitespace();\n\n if (startedNewLine && getCurrentIndent() <= 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 skipWhitespace();\n\n if (peek() === '-') {\n obj[key] = parseYamlList();\n continue;\n }\n }\n\n obj[key] = toTypedValue(parseUnquotedToken('\\n'));\n\n if (peek() === '\\n') next();\n }\n return obj;\n };\n\n const parseYamlList = (): any[] => {\n const arr: any[] = [];\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): Record<string, any> => {\n const obj: Record<string, any> = {};\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 if (peek() === '-') {\n obj[key] = parseYamlList();\n skipWhitespace();\n continue;\n } else {\n index = afterNewlinePos;\n skipWhitespace();\n const nextChar = peek();\n\n if (nextChar && !stops.includes(nextChar) && nextChar !== '-') {\n obj[key] = '';\n continue;\n }\n obj[key] = '';\n return obj;\n }\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 = (): Record<string, any> => {\n next(); // consume {\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 // Entry points\n\n if (text.startsWith(']') || text.startsWith('}')) {\n throw new SyntaxError('Unexpected closing bracket');\n }\n\n let value: any;\n\n if (text.startsWith('[')) value = parseArray();\n else if (text.startsWith('{')) value = parseObject();\n else if (hasTopLevelKeyColonSpace(text)) value = parseObjectBody('');\n else value = 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;AACF,CAAC;AAED,MAAa,aAAsB,UAA4B;CAC7D,MAAM,OAAO,MAAM,KAAK;CAExB,IAAI,CAAC,MAAM,OAAO;CAElB,IAAI,QAAQ;CAEZ,MAAM,aAAa,KAAK;CACxB,MAAM,aAAa,KAAK;CACxB,MAAM,YAAY,SAAS,KAAK;CAEhC,MAAM,uBAAuB;EAC3B,OAAO,CAAC,IAAI,KAAK,SAAU,SAAS,KAAK,CAAC,GAAG;CAC/C;CAEA,MAAM,qBAAqB,UAAqB;EAC9C,KA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IAAI;IAErB,IAAI,CAAC,UAAU,MAAM,SAAS,MAAM,GAAG,OAAO;GAChD;EAEJ;EACA,OAAO;CACT;CAIA,IAAI,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,GAAG,GAC7C,MAAM,IAAI,YAAY,4BAA4B;CAGpD,IAAI;CAEJ,IAAI,KAAK,WAAW,GAAG,GAAG,QAAQ,WAAW;MACxC,IAAI,KAAK,WAAW,GAAG,GAAG,QAAQ,YAAY;MAC9C,IAAI,yBAAyB,IAAI,GAAG,QAAQ,gBAAgB,EAAE;MAC9D,QAAQ,WAAW,EAAE;CAE1B,eAAe;CAEf,IAAI,CAAC,IAAI,GAAG,MAAM,IAAI,YAAY,gCAAgC;CAElE,OAAO;AACT"}
@@ -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;CAClD,IAAI,OAAO,SAAS,YAAY,SAAS,MACvC,OAAO;CAGT,IAAI,MAAM,aAAa,UAAU,aAC/B,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,EACrB,OAAO,KAAK,KAAK,oBAAoB;CAGvC,OAAO,OAAO,OAAO,KAAK,CAAC,KAAK,oBAAoB;;;;;AAMtD,MAAM,iBAAiB,QAA0B;CAC/C,MAAM,uBAAO,IAAI,KAAa;CAE9B,IAAI,OAAO,QAAQ,YAAY,QAAQ,MACrC,OAAO;CAGT,KAAK,MAAM,OAAO,KAChB,KAAK,IAAI,IAAI;CAGf,OAAO;;;;;AAMT,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,KAAK,KAAK,MAAM,QAAQ,KAAK,EAC7C,OAAO;CAGT,MAAM,QAAQ,cAAc,KAAK;CACjC,MAAM,QAAQ,cAAc,KAAK;CAEjC,IAAI,MAAM,SAAS,MAAM,MACvB,OAAO;CAGT,KA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ACtC;KAEuC,CAAC;KAC3C,CACD,QAAQ,SAAS,SAAS,QAAQ,SAAS,OAAU;GAIxD,IAAI,CAAC,0BAA0B,OAAO,WAAW,GAE/C,OAAO;GAIT,OAAO,OAAO,SAAS,IAAI,SAAS;;EAGtC,OAAO;;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;CAGF,IAAI,WAAW,QAEb,OAAO,EAAE;CAEX,OAAO,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,EAAE,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,IAA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,MAAM,yBAAyB,+BAA+B,IAAI;GAGlE,MAAM,SAAS,KACZ,KAAK,OAAO,UAAU;IASrB,OAAO,kBAAkB,OAAO;KAP9B,GAAG;KACH,UAAU;KACV,SAAS,CACP,GAAG,MAAM,SACT;MAAE,MAAM,UAAU;MAAO,KAAK;KAAM,CACtC;IAEuC,CAAC;GAC5C,CAAC,EACA,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;CAClD,IAAI,OAAO,SAAS,YAAY,SAAS,MACvC,OAAO;CAGT,IAAI,MAAM,aAAa,UAAU,aAC/B,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,EACrB,OAAO,KAAK,KAAK,oBAAoB;CAGvC,OAAO,OAAO,OAAO,KAAK,CAAC,KAAK,oBAAoB;;;AAItD,MAAa,gCACX,QACA,cACa;CACb,IAAI;CACJ,YAAY,SAAsB;EAEhC,OAAO,OAAO,SAAS,YAAY,SAAS;;CAE9C,YAAY,MAAmB,OAAO,sBAAsB;EAC1D,IAAI,OAAO,SAAS,YAAY,MAAM,aAAa,UAAU,aAAa;GACxE,MAAM,SAAS,gBACZ,KAA4B,UAAU,aACxC;GAED,KAA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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;C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kBAAkB,OAAO;IAP9B,GAAG;IACH,UAAU;IACV,SAAS,CACP,GAAG,MAAM,SACT;KAAE,MAAM,UAAU;KAAO,KAAK;IAAM,CACtC;GAEuC,CAAC;EAC5C,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;EAED,OAAO;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;CAED,OAAO,kBAAkB,MAAM;EAC7B,GAAG;EACH;EACD,CAAC;;AAYJ,MAAa,gCACX,YACA,WACG;CACH,MAAM,eAAe,MAAM,QAAQ,OAAO,GAAG,SAAS,CAAC,OAAO;CAE9D,OAAO;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,EAAE,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 { DeclaredLocales, LocalesValues } 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":";;;;;;;;;;;;AAkBA,MAAa,uBAIX,MACA,QACA,WACA,aACG;CACH,MAAM,UAAqB,CACzB,kBAAkB,QAAQ,SAAS,EACnC,GAAI,UAAU,WAAW,EAAE,CAC5B;CAED,OAAO,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"}