@intlayer/core 8.3.1 → 8.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/interpreter/getContent/getContent.cjs +1 -1
  3. package/dist/cjs/interpreter/getContent/getContent.cjs.map +1 -1
  4. package/dist/cjs/interpreter/getContent/index.cjs +1 -1
  5. package/dist/cjs/interpreter/getContent/plugins.cjs +1 -1
  6. package/dist/cjs/interpreter/getContent/plugins.cjs.map +1 -1
  7. package/dist/cjs/interpreter/getDictionary.cjs +1 -1
  8. package/dist/cjs/interpreter/getDictionary.cjs.map +1 -1
  9. package/dist/cjs/interpreter/getHTML.cjs +1 -1
  10. package/dist/cjs/interpreter/getHTML.cjs.map +1 -1
  11. package/dist/cjs/interpreter/getIntlayer.cjs.map +1 -1
  12. package/dist/cjs/interpreter/index.cjs +1 -1
  13. package/dist/cjs/markdown/index.cjs +1 -1
  14. package/dist/cjs/transpiler/enumeration/enumeration.cjs.map +1 -1
  15. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  16. package/dist/cjs/transpiler/html/html.cjs +1 -1
  17. package/dist/cjs/transpiler/html/html.cjs.map +1 -1
  18. package/dist/cjs/transpiler/html/index.cjs +1 -1
  19. package/dist/cjs/transpiler/html/validateHTML.cjs +2 -0
  20. package/dist/cjs/transpiler/html/validateHTML.cjs.map +1 -0
  21. package/dist/cjs/transpiler/index.cjs +1 -1
  22. package/dist/cjs/transpiler/markdown/index.cjs +1 -1
  23. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -1
  24. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  25. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs +5 -0
  26. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs.map +1 -0
  27. package/dist/esm/index.mjs +1 -1
  28. package/dist/esm/interpreter/getContent/getContent.mjs +1 -1
  29. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  30. package/dist/esm/interpreter/getContent/index.mjs +1 -1
  31. package/dist/esm/interpreter/getContent/plugins.mjs +1 -1
  32. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  33. package/dist/esm/interpreter/getDictionary.mjs +1 -1
  34. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  35. package/dist/esm/interpreter/getHTML.mjs +1 -1
  36. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  37. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  38. package/dist/esm/interpreter/index.mjs +1 -1
  39. package/dist/esm/markdown/index.mjs +1 -1
  40. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  41. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  42. package/dist/esm/transpiler/html/html.mjs +1 -1
  43. package/dist/esm/transpiler/html/html.mjs.map +1 -1
  44. package/dist/esm/transpiler/html/index.mjs +1 -1
  45. package/dist/esm/transpiler/html/validateHTML.mjs +2 -0
  46. package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -0
  47. package/dist/esm/transpiler/index.mjs +1 -1
  48. package/dist/esm/transpiler/markdown/index.mjs +1 -1
  49. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  50. package/dist/esm/transpiler/markdown/validateMarkdown.mjs +5 -0
  51. package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -0
  52. package/dist/types/index.d.ts +4 -2
  53. package/dist/types/interpreter/getContent/getContent.d.ts +4 -3
  54. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  55. package/dist/types/interpreter/getContent/index.d.ts +2 -2
  56. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  57. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  58. package/dist/types/interpreter/getHTML.d.ts.map +1 -1
  59. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  60. package/dist/types/interpreter/index.d.ts +2 -2
  61. package/dist/types/markdown/index.d.ts +3 -1
  62. package/dist/types/transpiler/enumeration/enumeration.d.ts +1 -1
  63. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  64. package/dist/types/transpiler/html/html.d.ts.map +1 -1
  65. package/dist/types/transpiler/html/index.d.ts +2 -1
  66. package/dist/types/transpiler/html/validateHTML.d.ts +21 -0
  67. package/dist/types/transpiler/html/validateHTML.d.ts.map +1 -0
  68. package/dist/types/transpiler/index.d.ts +3 -1
  69. package/dist/types/transpiler/markdown/index.d.ts +3 -1
  70. package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
  71. package/dist/types/transpiler/markdown/validateMarkdown.d.ts +18 -0
  72. package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +1 -0
  73. package/package.json +8 -8
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getStorageAttributes.cjs`),t=require(`./interpreter/getCondition.cjs`),n=require(`./interpreter/getContent/deepTransform.cjs`),r=require(`./interpreter/getEnumeration.cjs`),i=require(`./interpreter/getDictionary.cjs`),a=require(`./interpreter/getIntlayer.cjs`),o=require(`./interpreter/getNesting.cjs`),s=require(`./interpreter/getTranslation.cjs`),c=require(`./interpreter/getContent/plugins.cjs`),l=require(`./interpreter/getContent/getContent.cjs`),u=require(`./interpreter/getHTML.cjs`),d=require(`./interpreter/splitAndJoinInsertion.cjs`),f=require(`./deepTransformPlugins/getFilteredLocalesContent.cjs`),ee=require(`./transpiler/condition/condition.cjs`),te=require(`./transpiler/enumeration/enumeration.cjs`),ne=require(`./transpiler/gender/gender.cjs`),re=require(`./transpiler/html/html.cjs`),ie=require(`./transpiler/html/htmlTags.cjs`),ae=require(`./transpiler/insertion/getInsertionValues.cjs`),oe=require(`./transpiler/insertion/insertion.cjs`),se=require(`./utils/parseYaml.cjs`),ce=require(`./transpiler/markdown/getMarkdownMetadata.cjs`),le=require(`./transpiler/markdown/markdown.cjs`),ue=require(`./transpiler/nesting/nesting.cjs`),p=require(`./transpiler/translation/translation.cjs`),m=require(`./deepTransformPlugins/getFilterMissingTranslationsContent.cjs`),h=require(`./deepTransformPlugins/getFilterTranslationsOnlyContent.cjs`),g=require(`./deepTransformPlugins/getLocalizedContent.cjs`),_=require(`./deepTransformPlugins/getMaskContent.cjs`),v=require(`./deepTransformPlugins/getMissingLocalesContent.cjs`),y=require(`./deepTransformPlugins/getMultilingualDictionary.cjs`),b=require(`./deepTransformPlugins/getReplacedValuesContent.cjs`),x=require(`./deepTransformPlugins/getSplittedContent.cjs`),S=require(`./deepTransformPlugins/insertContentInDictionary.cjs`),C=require(`./dictionaryManipulator/editDictionaryByKeyPath.cjs`),w=require(`./dictionaryManipulator/getContentNodeByKeyPath.cjs`),T=require(`./dictionaryManipulator/getDefaultNode.cjs`),E=require(`./dictionaryManipulator/getEmptyNode.cjs`),D=require(`./dictionaryManipulator/getNodeChildren.cjs`),O=require(`./utils/isValidReactElement.cjs`),k=require(`./dictionaryManipulator/getNodeType.cjs`),A=require(`./dictionaryManipulator/mergeDictionaries.cjs`),j=require(`./dictionaryManipulator/orderDictionaries.cjs`),M=require(`./dictionaryManipulator/normalizeDictionary.cjs`),N=require(`./dictionaryManipulator/removeContentNodeByKeyPath.cjs`),P=require(`./dictionaryManipulator/renameContentNodeByKeyPath.cjs`),F=require(`./dictionaryManipulator/updateNodeChildren.cjs`),I=require(`./utils/intl.cjs`),L=require(`./formatters/compact.cjs`),R=require(`./formatters/currency.cjs`),z=require(`./formatters/date.cjs`),de=require(`./formatters/list.cjs`),B=require(`./formatters/number.cjs`),V=require(`./formatters/percentage.cjs`),H=require(`./formatters/relativeTime.cjs`),fe=require(`./formatters/units.cjs`),pe=require(`./utils/getCookie.cjs`),U=require(`./utils/localeStorage.cjs`),me=require(`./localization/localeResolver.cjs`),he=require(`./localization/localeDetector.cjs`),W=require(`./localization/getBrowserLocale.cjs`),ge=require(`./localization/getHTMLTextDir.cjs`),_e=require(`./localization/getLocale.cjs`),ve=require(`./utils/checkIsURLAbsolute.cjs`),ye=require(`./localization/getLocaleFromPath.cjs`),be=require(`./localization/getLocaleLang.cjs`),xe=require(`./localization/getLocaleName.cjs`),Se=require(`./localization/getPathWithoutLocale.cjs`),Ce=require(`./localization/getPrefix.cjs`),G=require(`./localization/rewriteUtils.cjs`),we=require(`./localization/getLocalizedUrl.cjs`),Te=require(`./localization/getMultilingualUrls.cjs`),K=require(`./localization/localeMapper.cjs`),Ee=require(`./localization/validatePrefix.cjs`),q=require(`./markdown/constants.cjs`),J=require(`./markdown/utils.cjs`),De=require(`./markdown/parser.cjs`),Y=require(`./markdown/renderer.cjs`),X=require(`./markdown/compiler.cjs`),Z=require(`./messageFormat/ICU.cjs`),Q=require(`./messageFormat/i18next.cjs`),$=require(`./messageFormat/vue-i18n.cjs`),Oe=require(`./utils/isSameKeyPath.cjs`);exports.ATTRIBUTES_TO_SANITIZE=q.ATTRIBUTES_TO_SANITIZE,exports.ATTRIBUTE_TO_NODE_PROP_MAP=q.ATTRIBUTE_TO_NODE_PROP_MAP,exports.ATTR_EXTRACTOR_R=q.ATTR_EXTRACTOR_R,exports.BLOCKQUOTE_ALERT_R=q.BLOCKQUOTE_ALERT_R,exports.BLOCKQUOTE_R=q.BLOCKQUOTE_R,exports.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R=q.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,exports.BLOCK_END_R=q.BLOCK_END_R,exports.BREAK_LINE_R=q.BREAK_LINE_R,exports.BREAK_THEMATIC_R=q.BREAK_THEMATIC_R,exports.CAPTURE_LETTER_AFTER_HYPHEN=q.CAPTURE_LETTER_AFTER_HYPHEN,exports.CODE_BLOCK_FENCED_R=q.CODE_BLOCK_FENCED_R,exports.CODE_BLOCK_R=q.CODE_BLOCK_R,exports.CODE_INLINE_R=q.CODE_INLINE_R,exports.CONSECUTIVE_NEWLINE_R=q.CONSECUTIVE_NEWLINE_R,exports.CR_NEWLINE_R=q.CR_NEWLINE_R,exports.CUSTOM_COMPONENT_R=q.CUSTOM_COMPONENT_R,exports.CachedIntl=I.CachedIntl,exports.Intl=I.CachedIntl,exports.DO_NOT_PROCESS_HTML_ELEMENTS=q.DO_NOT_PROCESS_HTML_ELEMENTS,exports.DURATION_DELAY_TRIGGER=q.DURATION_DELAY_TRIGGER,exports.FOOTNOTE_R=q.FOOTNOTE_R,exports.FOOTNOTE_REFERENCE_R=q.FOOTNOTE_REFERENCE_R,exports.FORMFEED_R=q.FORMFEED_R,exports.FRONT_MATTER_R=q.FRONT_MATTER_R,exports.GFM_TASK_R=q.GFM_TASK_R,exports.HEADING_ATX_COMPLIANT_R=q.HEADING_ATX_COMPLIANT_R,exports.HEADING_R=q.HEADING_R,exports.HEADING_SETEXT_R=q.HEADING_SETEXT_R,exports.HTML_BLOCK_ELEMENT_R=q.HTML_BLOCK_ELEMENT_R,exports.HTML_CHAR_CODE_R=q.HTML_CHAR_CODE_R,exports.HTML_COMMENT_R=q.HTML_COMMENT_R,exports.HTML_CUSTOM_ATTR_R=q.HTML_CUSTOM_ATTR_R,exports.HTML_LEFT_TRIM_AMOUNT_R=q.HTML_LEFT_TRIM_AMOUNT_R,exports.HTML_SELF_CLOSING_ELEMENT_R=q.HTML_SELF_CLOSING_ELEMENT_R,exports.HTML_TAGS=ie.HTML_TAGS,exports.INLINE_SKIP_R=q.INLINE_SKIP_R,exports.INTERPOLATION_R=q.INTERPOLATION_R,exports.LINK_AUTOLINK_BARE_URL_R=q.LINK_AUTOLINK_BARE_URL_R,exports.LINK_AUTOLINK_R=q.LINK_AUTOLINK_R,exports.LIST_LOOKBEHIND_R=q.LIST_LOOKBEHIND_R,exports.LOOKAHEAD=q.LOOKAHEAD,exports.LocaleStorage=U.LocaleStorage,exports.NAMED_CODES_TO_UNICODE=q.NAMED_CODES_TO_UNICODE,exports.NP_TABLE_R=q.NP_TABLE_R,exports.ORDERED=q.ORDERED,exports.ORDERED_LIST_BULLET=q.ORDERED_LIST_BULLET,exports.ORDERED_LIST_ITEM_PREFIX=q.ORDERED_LIST_ITEM_PREFIX,exports.ORDERED_LIST_ITEM_PREFIX_R=q.ORDERED_LIST_ITEM_PREFIX_R,exports.ORDERED_LIST_ITEM_R=q.ORDERED_LIST_ITEM_R,exports.ORDERED_LIST_R=q.ORDERED_LIST_R,exports.PARAGRAPH_R=q.PARAGRAPH_R,exports.Priority=q.Priority,exports.REFERENCE_IMAGE_OR_LINK=q.REFERENCE_IMAGE_OR_LINK,exports.REFERENCE_IMAGE_R=q.REFERENCE_IMAGE_R,exports.REFERENCE_LINK_R=q.REFERENCE_LINK_R,exports.RuleType=q.RuleType,exports.SHORTCODE_R=q.SHORTCODE_R,exports.SHOULD_RENDER_AS_BLOCK_R=q.SHOULD_RENDER_AS_BLOCK_R,exports.TABLE_CENTER_ALIGN=q.TABLE_CENTER_ALIGN,exports.TABLE_LEFT_ALIGN=q.TABLE_LEFT_ALIGN,exports.TABLE_RIGHT_ALIGN=q.TABLE_RIGHT_ALIGN,exports.TABLE_TRIM_PIPES=q.TABLE_TRIM_PIPES,exports.TAB_R=q.TAB_R,exports.TEXT_BOLD_R=q.TEXT_BOLD_R,exports.TEXT_EMPHASIZED_R=q.TEXT_EMPHASIZED_R,exports.TEXT_ESCAPED_R=q.TEXT_ESCAPED_R,exports.TEXT_MARKED_R=q.TEXT_MARKED_R,exports.TEXT_PLAIN_R=q.TEXT_PLAIN_R,exports.TEXT_STRIKETHROUGHED_R=q.TEXT_STRIKETHROUGHED_R,exports.TRIM_STARTING_NEWLINES=q.TRIM_STARTING_NEWLINES,exports.UNESCAPE_R=q.UNESCAPE_R,exports.UNORDERED=q.UNORDERED,exports.UNORDERED_LIST_BULLET=q.UNORDERED_LIST_BULLET,exports.UNORDERED_LIST_ITEM_PREFIX=q.UNORDERED_LIST_ITEM_PREFIX,exports.UNORDERED_LIST_ITEM_PREFIX_R=q.UNORDERED_LIST_ITEM_PREFIX_R,exports.UNORDERED_LIST_ITEM_R=q.UNORDERED_LIST_ITEM_R,exports.UNORDERED_LIST_R=q.UNORDERED_LIST_R,exports.allowInline=J.allowInline,exports.anyScopeRegex=J.anyScopeRegex,exports.attributeValueToNodePropValue=J.attributeValueToNodePropValue,exports.bindIntl=I.bindIntl,exports.blockRegex=J.blockRegex,exports.buildMaskPlugin=_.buildMaskPlugin,exports.captureNothing=J.captureNothing,exports.checkIsURLAbsolute=ve.checkIsURLAbsolute,exports.checkMissingLocalesPlugin=v.checkMissingLocalesPlugin,exports.compact=L.compact,exports.compile=X.compile,exports.compileWithOptions=X.compileWithOptions,exports.cond=ee.cond,exports.conditionPlugin=c.conditionPlugin,exports.createCachedIntl=I.createCachedIntl,exports.createCompiler=X.createCompiler,exports.createRenderer=Y.createRenderer,exports.currency=R.currency,exports.cx=J.cx,exports.date=z.date,exports.deepTransformNode=n.deepTransformNode,exports.editDictionaryByKeyPath=C.editDictionaryByKeyPath,exports.enu=te.enu,exports.enumerationPlugin=c.enumerationPlugin,exports.filePlugin=c.filePlugin,exports.filterMissingTranslationsOnlyPlugin=m.filterMissingTranslationsOnlyPlugin,exports.filterTranslationsOnlyPlugin=h.filterTranslationsOnlyPlugin,exports.findMatchingCondition=r.findMatchingCondition,exports.gender=ne.gender,exports.genderPlugin=c.genderPlugin,exports.generateListItemPrefix=q.generateListItemPrefix,exports.generateListItemPrefixRegex=q.generateListItemPrefixRegex,exports.generateListItemRegex=q.generateListItemRegex,exports.generateListRegex=q.generateListRegex,exports.get=J.get,exports.getBrowserLocale=W.getBrowserLocale,exports.getCanonicalPath=G.getCanonicalPath,exports.getCondition=t.getCondition,exports.getContent=l.getContent,exports.getContentNodeByKeyPath=w.getContentNodeByKeyPath,exports.getCookie=pe.getCookie,exports.getDefaultNode=T.getDefaultNode,exports.getDictionary=i.getDictionary,exports.getEmptyNode=E.getEmptyNode,exports.getEnumeration=r.getEnumeration,exports.getFilterMissingTranslationsContent=m.getFilterMissingTranslationsContent,exports.getFilterMissingTranslationsDictionary=m.getFilterMissingTranslationsDictionary,exports.getFilterTranslationsOnlyContent=h.getFilterTranslationsOnlyContent,exports.getFilterTranslationsOnlyDictionary=h.getFilterTranslationsOnlyDictionary,exports.getFilteredLocalesContent=f.getFilteredLocalesContent,exports.getFilteredLocalesDictionary=f.getFilteredLocalesDictionary,exports.getHTML=u.getHTML,exports.getHTMLTextDir=ge.getHTMLTextDir,exports.getInsertionValues=ae.getInsertionValues,exports.getInternalPath=G.getInternalPath,exports.getIntlayer=a.getIntlayer,exports.getLocale=_e.getLocale,exports.getLocaleFromPath=ye.getLocaleFromPath,exports.getLocaleFromStorage=U.getLocaleFromStorage,exports.getLocaleLang=be.getLocaleLang,exports.getLocaleName=xe.getLocaleName,exports.getLocalizedContent=g.getLocalizedContent,exports.getLocalizedPath=G.getLocalizedPath,exports.getLocalizedUrl=we.getLocalizedUrl,exports.getMarkdownMetadata=ce.getMarkdownMetadata,exports.getMaskContent=_.getMaskContent,exports.getMissingLocalesContent=v.getMissingLocalesContent,exports.getMissingLocalesContentFromDictionary=v.getMissingLocalesContentFromDictionary,exports.getMultilingualDictionary=y.getMultilingualDictionary,exports.getMultilingualUrls=Te.getMultilingualUrls,exports.getNesting=o.getNesting,exports.getNodeChildren=D.getNodeChildren,exports.getNodeType=k.getNodeType,exports.getPathWithoutLocale=Se.getPathWithoutLocale,exports.getPerLocaleDictionary=g.getPerLocaleDictionary,exports.getPrefix=Ce.getPrefix,exports.getReplacedValuesContent=b.getReplacedValuesContent,exports.getRewritePath=G.getRewritePath,exports.getRewriteRules=G.getRewriteRules,exports.getSplittedContent=x.getSplittedContent,exports.getSplittedDictionaryContent=x.getSplittedDictionaryContent,exports.getStorageAttributes=e.getStorageAttributes,exports.getTranslation=s.getTranslation,exports.html=re.html,exports.i18nextToIntlayerFormatter=Q.i18nextToIntlayerFormatter,exports.icuToIntlayerFormatter=Z.icuToIntlayerFormatter,exports.inlineRegex=J.inlineRegex,exports.insert=oe.insert,exports.insertContentInDictionary=S.insertContentInDictionary,exports.insertionPlugin=c.insertionPlugin,exports.intlayerToI18nextFormatter=Q.intlayerToI18nextFormatter,exports.intlayerToICUFormatter=Z.intlayerToICUFormatter,exports.intlayerToVueI18nFormatter=$.intlayerToVueI18nFormatter,exports.isSameKeyPath=Oe.isSameKeyPath,exports.isValidElement=O.isValidElement,exports.list=de.list,exports.localeDetector=he.localeDetector,exports.localeFlatMap=K.localeFlatMap,exports.localeMap=K.localeMap,exports.localeRecord=K.localeRecord,exports.localeResolver=me.localeResolver,exports.localeStorageOptions=W.localeStorageOptions,exports.md=le.md,exports.mergeDictionaries=A.mergeDictionaries,exports.nest=ue.nest,exports.nestedPlugin=c.nestedPlugin,exports.normalizeAttributeKey=J.normalizeAttributeKey,exports.normalizeDictionaries=M.normalizeDictionaries,exports.normalizeDictionary=M.normalizeDictionary,exports.normalizeWhitespace=J.normalizeWhitespace,exports.number=B.number,exports.orderDictionaries=j.orderDictionaries,exports.parseBlock=J.parseBlock,exports.parseCaptureInline=J.parseCaptureInline,exports.parseInline=J.parseInline,exports.parseSimpleInline=J.parseSimpleInline,exports.parseStyleAttribute=J.parseStyleAttribute,exports.parseTableAlign=J.parseTableAlign,exports.parseTableAlignCapture=J.parseTableAlignCapture,exports.parseTableCells=J.parseTableCells,exports.parseTableRow=J.parseTableRow,exports.parseYaml=se.parseYaml,exports.parserFor=De.parserFor,exports.percentage=V.percentage,exports.qualifies=J.qualifies,exports.relativeTime=H.relativeTime,exports.removeContentNodeByKeyPath=N.removeContentNodeByKeyPath,exports.renameContentNodeByKeyPath=P.renameContentNodeByKeyPath,exports.renderFor=Y.renderFor,exports.renderNothing=J.renderNothing,exports.sanitizer=J.sanitizer,exports.setLocaleInStorage=U.setLocaleInStorage,exports.simpleInlineRegex=J.simpleInlineRegex,exports.slugify=J.slugify,exports.some=J.some,exports.splitInsertionTemplate=d.splitInsertionTemplate,exports.startsWith=J.startsWith,exports.t=p.t,exports.translationPlugin=c.translationPlugin,exports.trimEnd=J.trimEnd,exports.trimLeadingWhitespaceOutsideFences=J.trimLeadingWhitespaceOutsideFences,exports.unescapeString=J.unescapeString,exports.units=fe.units,exports.unquote=J.unquote,exports.updateNodeChildren=F.updateNodeChildren,exports.validatePrefix=Ee.validatePrefix,exports.vueI18nToIntlayerFormatter=$.vueI18nToIntlayerFormatter;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getStorageAttributes.cjs`),t=require(`./interpreter/getCondition.cjs`),n=require(`./interpreter/getContent/deepTransform.cjs`),r=require(`./interpreter/getEnumeration.cjs`),i=require(`./interpreter/getDictionary.cjs`),a=require(`./interpreter/getIntlayer.cjs`),ee=require(`./interpreter/getNesting.cjs`),o=require(`./interpreter/getTranslation.cjs`),s=require(`./interpreter/getContent/plugins.cjs`),c=require(`./interpreter/getContent/getContent.cjs`),l=require(`./interpreter/getHTML.cjs`),u=require(`./interpreter/splitAndJoinInsertion.cjs`),d=require(`./deepTransformPlugins/getFilteredLocalesContent.cjs`),f=require(`./transpiler/condition/condition.cjs`),p=require(`./transpiler/enumeration/enumeration.cjs`),te=require(`./transpiler/gender/gender.cjs`),m=require(`./transpiler/html/validateHTML.cjs`),ne=require(`./transpiler/html/html.cjs`),re=require(`./transpiler/html/htmlTags.cjs`),ie=require(`./transpiler/insertion/getInsertionValues.cjs`),ae=require(`./transpiler/insertion/insertion.cjs`),oe=require(`./utils/parseYaml.cjs`),se=require(`./transpiler/markdown/getMarkdownMetadata.cjs`),ce=require(`./transpiler/markdown/validateMarkdown.cjs`),le=require(`./transpiler/markdown/markdown.cjs`),ue=require(`./transpiler/nesting/nesting.cjs`),h=require(`./transpiler/translation/translation.cjs`),g=require(`./deepTransformPlugins/getFilterMissingTranslationsContent.cjs`),_=require(`./deepTransformPlugins/getFilterTranslationsOnlyContent.cjs`),v=require(`./deepTransformPlugins/getLocalizedContent.cjs`),y=require(`./deepTransformPlugins/getMaskContent.cjs`),b=require(`./deepTransformPlugins/getMissingLocalesContent.cjs`),x=require(`./deepTransformPlugins/getMultilingualDictionary.cjs`),S=require(`./deepTransformPlugins/getReplacedValuesContent.cjs`),C=require(`./deepTransformPlugins/getSplittedContent.cjs`),w=require(`./deepTransformPlugins/insertContentInDictionary.cjs`),T=require(`./dictionaryManipulator/editDictionaryByKeyPath.cjs`),E=require(`./dictionaryManipulator/getContentNodeByKeyPath.cjs`),D=require(`./dictionaryManipulator/getDefaultNode.cjs`),O=require(`./dictionaryManipulator/getEmptyNode.cjs`),k=require(`./dictionaryManipulator/getNodeChildren.cjs`),A=require(`./utils/isValidReactElement.cjs`),j=require(`./dictionaryManipulator/getNodeType.cjs`),M=require(`./dictionaryManipulator/mergeDictionaries.cjs`),N=require(`./dictionaryManipulator/orderDictionaries.cjs`),P=require(`./dictionaryManipulator/normalizeDictionary.cjs`),F=require(`./dictionaryManipulator/removeContentNodeByKeyPath.cjs`),I=require(`./dictionaryManipulator/renameContentNodeByKeyPath.cjs`),L=require(`./dictionaryManipulator/updateNodeChildren.cjs`),R=require(`./utils/intl.cjs`),z=require(`./formatters/compact.cjs`),B=require(`./formatters/currency.cjs`),V=require(`./formatters/date.cjs`),de=require(`./formatters/list.cjs`),H=require(`./formatters/number.cjs`),fe=require(`./formatters/percentage.cjs`),pe=require(`./formatters/relativeTime.cjs`),me=require(`./formatters/units.cjs`),he=require(`./utils/getCookie.cjs`),U=require(`./utils/localeStorage.cjs`),ge=require(`./localization/localeResolver.cjs`),_e=require(`./localization/localeDetector.cjs`),W=require(`./localization/getBrowserLocale.cjs`),ve=require(`./localization/getHTMLTextDir.cjs`),ye=require(`./localization/getLocale.cjs`),be=require(`./utils/checkIsURLAbsolute.cjs`),xe=require(`./localization/getLocaleFromPath.cjs`),Se=require(`./localization/getLocaleLang.cjs`),Ce=require(`./localization/getLocaleName.cjs`),we=require(`./localization/getPathWithoutLocale.cjs`),Te=require(`./localization/getPrefix.cjs`),G=require(`./localization/rewriteUtils.cjs`),Ee=require(`./localization/getLocalizedUrl.cjs`),De=require(`./localization/getMultilingualUrls.cjs`),K=require(`./localization/localeMapper.cjs`),Oe=require(`./localization/validatePrefix.cjs`),q=require(`./markdown/constants.cjs`),J=require(`./markdown/utils.cjs`),ke=require(`./markdown/parser.cjs`),Y=require(`./markdown/renderer.cjs`),X=require(`./markdown/compiler.cjs`),Z=require(`./messageFormat/ICU.cjs`),Q=require(`./messageFormat/i18next.cjs`),$=require(`./messageFormat/vue-i18n.cjs`),Ae=require(`./utils/isSameKeyPath.cjs`);exports.ATTRIBUTES_TO_SANITIZE=q.ATTRIBUTES_TO_SANITIZE,exports.ATTRIBUTE_TO_NODE_PROP_MAP=q.ATTRIBUTE_TO_NODE_PROP_MAP,exports.ATTR_EXTRACTOR_R=q.ATTR_EXTRACTOR_R,exports.BLOCKQUOTE_ALERT_R=q.BLOCKQUOTE_ALERT_R,exports.BLOCKQUOTE_R=q.BLOCKQUOTE_R,exports.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R=q.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,exports.BLOCK_END_R=q.BLOCK_END_R,exports.BREAK_LINE_R=q.BREAK_LINE_R,exports.BREAK_THEMATIC_R=q.BREAK_THEMATIC_R,exports.CAPTURE_LETTER_AFTER_HYPHEN=q.CAPTURE_LETTER_AFTER_HYPHEN,exports.CODE_BLOCK_FENCED_R=q.CODE_BLOCK_FENCED_R,exports.CODE_BLOCK_R=q.CODE_BLOCK_R,exports.CODE_INLINE_R=q.CODE_INLINE_R,exports.CONSECUTIVE_NEWLINE_R=q.CONSECUTIVE_NEWLINE_R,exports.CR_NEWLINE_R=q.CR_NEWLINE_R,exports.CUSTOM_COMPONENT_R=q.CUSTOM_COMPONENT_R,exports.CachedIntl=R.CachedIntl,exports.Intl=R.CachedIntl,exports.DO_NOT_PROCESS_HTML_ELEMENTS=q.DO_NOT_PROCESS_HTML_ELEMENTS,exports.DURATION_DELAY_TRIGGER=q.DURATION_DELAY_TRIGGER,exports.FOOTNOTE_R=q.FOOTNOTE_R,exports.FOOTNOTE_REFERENCE_R=q.FOOTNOTE_REFERENCE_R,exports.FORMFEED_R=q.FORMFEED_R,exports.FRONT_MATTER_R=q.FRONT_MATTER_R,exports.GFM_TASK_R=q.GFM_TASK_R,exports.HEADING_ATX_COMPLIANT_R=q.HEADING_ATX_COMPLIANT_R,exports.HEADING_R=q.HEADING_R,exports.HEADING_SETEXT_R=q.HEADING_SETEXT_R,exports.HTML_BLOCK_ELEMENT_R=q.HTML_BLOCK_ELEMENT_R,exports.HTML_CHAR_CODE_R=q.HTML_CHAR_CODE_R,exports.HTML_COMMENT_R=q.HTML_COMMENT_R,exports.HTML_CUSTOM_ATTR_R=q.HTML_CUSTOM_ATTR_R,exports.HTML_LEFT_TRIM_AMOUNT_R=q.HTML_LEFT_TRIM_AMOUNT_R,exports.HTML_SELF_CLOSING_ELEMENT_R=q.HTML_SELF_CLOSING_ELEMENT_R,exports.HTML_TAGS=re.HTML_TAGS,exports.INLINE_SKIP_R=q.INLINE_SKIP_R,exports.INTERPOLATION_R=q.INTERPOLATION_R,exports.LINK_AUTOLINK_BARE_URL_R=q.LINK_AUTOLINK_BARE_URL_R,exports.LINK_AUTOLINK_R=q.LINK_AUTOLINK_R,exports.LIST_LOOKBEHIND_R=q.LIST_LOOKBEHIND_R,exports.LOOKAHEAD=q.LOOKAHEAD,exports.LocaleStorage=U.LocaleStorage,exports.NAMED_CODES_TO_UNICODE=q.NAMED_CODES_TO_UNICODE,exports.NP_TABLE_R=q.NP_TABLE_R,exports.ORDERED=q.ORDERED,exports.ORDERED_LIST_BULLET=q.ORDERED_LIST_BULLET,exports.ORDERED_LIST_ITEM_PREFIX=q.ORDERED_LIST_ITEM_PREFIX,exports.ORDERED_LIST_ITEM_PREFIX_R=q.ORDERED_LIST_ITEM_PREFIX_R,exports.ORDERED_LIST_ITEM_R=q.ORDERED_LIST_ITEM_R,exports.ORDERED_LIST_R=q.ORDERED_LIST_R,exports.PARAGRAPH_R=q.PARAGRAPH_R,exports.Priority=q.Priority,exports.REFERENCE_IMAGE_OR_LINK=q.REFERENCE_IMAGE_OR_LINK,exports.REFERENCE_IMAGE_R=q.REFERENCE_IMAGE_R,exports.REFERENCE_LINK_R=q.REFERENCE_LINK_R,exports.RuleType=q.RuleType,exports.SHORTCODE_R=q.SHORTCODE_R,exports.SHOULD_RENDER_AS_BLOCK_R=q.SHOULD_RENDER_AS_BLOCK_R,exports.TABLE_CENTER_ALIGN=q.TABLE_CENTER_ALIGN,exports.TABLE_LEFT_ALIGN=q.TABLE_LEFT_ALIGN,exports.TABLE_RIGHT_ALIGN=q.TABLE_RIGHT_ALIGN,exports.TABLE_TRIM_PIPES=q.TABLE_TRIM_PIPES,exports.TAB_R=q.TAB_R,exports.TEXT_BOLD_R=q.TEXT_BOLD_R,exports.TEXT_EMPHASIZED_R=q.TEXT_EMPHASIZED_R,exports.TEXT_ESCAPED_R=q.TEXT_ESCAPED_R,exports.TEXT_MARKED_R=q.TEXT_MARKED_R,exports.TEXT_PLAIN_R=q.TEXT_PLAIN_R,exports.TEXT_STRIKETHROUGHED_R=q.TEXT_STRIKETHROUGHED_R,exports.TRIM_STARTING_NEWLINES=q.TRIM_STARTING_NEWLINES,exports.UNESCAPE_R=q.UNESCAPE_R,exports.UNORDERED=q.UNORDERED,exports.UNORDERED_LIST_BULLET=q.UNORDERED_LIST_BULLET,exports.UNORDERED_LIST_ITEM_PREFIX=q.UNORDERED_LIST_ITEM_PREFIX,exports.UNORDERED_LIST_ITEM_PREFIX_R=q.UNORDERED_LIST_ITEM_PREFIX_R,exports.UNORDERED_LIST_ITEM_R=q.UNORDERED_LIST_ITEM_R,exports.UNORDERED_LIST_R=q.UNORDERED_LIST_R,exports.VOID_ELEMENTS=m.VOID_ELEMENTS,exports.allowInline=J.allowInline,exports.anyScopeRegex=J.anyScopeRegex,exports.attributeValueToNodePropValue=J.attributeValueToNodePropValue,exports.bindIntl=R.bindIntl,exports.blockRegex=J.blockRegex,exports.buildMaskPlugin=y.buildMaskPlugin,exports.captureNothing=J.captureNothing,exports.checkIsURLAbsolute=be.checkIsURLAbsolute,exports.checkMissingLocalesPlugin=b.checkMissingLocalesPlugin,exports.compact=z.compact,exports.compile=X.compile,exports.compileWithOptions=X.compileWithOptions,exports.cond=f.cond,exports.conditionPlugin=s.conditionPlugin,exports.createCachedIntl=R.createCachedIntl,exports.createCompiler=X.createCompiler,exports.createRenderer=Y.createRenderer,exports.currency=B.currency,exports.cx=J.cx,exports.date=V.date,exports.deepTransformNode=n.deepTransformNode,exports.editDictionaryByKeyPath=T.editDictionaryByKeyPath,exports.enu=p.enu,exports.enumerationPlugin=s.enumerationPlugin,exports.filePlugin=s.filePlugin,exports.filterMissingTranslationsOnlyPlugin=g.filterMissingTranslationsOnlyPlugin,exports.filterTranslationsOnlyPlugin=_.filterTranslationsOnlyPlugin,exports.findMatchingCondition=r.findMatchingCondition,exports.gender=te.gender,exports.genderPlugin=s.genderPlugin,exports.generateListItemPrefix=q.generateListItemPrefix,exports.generateListItemPrefixRegex=q.generateListItemPrefixRegex,exports.generateListItemRegex=q.generateListItemRegex,exports.generateListRegex=q.generateListRegex,exports.get=J.get,exports.getBasePlugins=c.getBasePlugins,exports.getBrowserLocale=W.getBrowserLocale,exports.getCanonicalPath=G.getCanonicalPath,exports.getCondition=t.getCondition,exports.getContent=c.getContent,exports.getContentNodeByKeyPath=E.getContentNodeByKeyPath,exports.getCookie=he.getCookie,exports.getDefaultNode=D.getDefaultNode,exports.getDictionary=i.getDictionary,exports.getEmptyNode=O.getEmptyNode,exports.getEnumeration=r.getEnumeration,exports.getFilterMissingTranslationsContent=g.getFilterMissingTranslationsContent,exports.getFilterMissingTranslationsDictionary=g.getFilterMissingTranslationsDictionary,exports.getFilterTranslationsOnlyContent=_.getFilterTranslationsOnlyContent,exports.getFilterTranslationsOnlyDictionary=_.getFilterTranslationsOnlyDictionary,exports.getFilteredLocalesContent=d.getFilteredLocalesContent,exports.getFilteredLocalesDictionary=d.getFilteredLocalesDictionary,exports.getHTML=l.getHTML,exports.getHTMLTextDir=ve.getHTMLTextDir,exports.getInsertionValues=ie.getInsertionValues,exports.getInternalPath=G.getInternalPath,exports.getIntlayer=a.getIntlayer,exports.getLocale=ye.getLocale,exports.getLocaleFromPath=xe.getLocaleFromPath,exports.getLocaleFromStorage=U.getLocaleFromStorage,exports.getLocaleLang=Se.getLocaleLang,exports.getLocaleName=Ce.getLocaleName,exports.getLocalizedContent=v.getLocalizedContent,exports.getLocalizedPath=G.getLocalizedPath,exports.getLocalizedUrl=Ee.getLocalizedUrl,exports.getMarkdownMetadata=se.getMarkdownMetadata,exports.getMaskContent=y.getMaskContent,exports.getMissingLocalesContent=b.getMissingLocalesContent,exports.getMissingLocalesContentFromDictionary=b.getMissingLocalesContentFromDictionary,exports.getMultilingualDictionary=x.getMultilingualDictionary,exports.getMultilingualUrls=De.getMultilingualUrls,exports.getNesting=ee.getNesting,exports.getNodeChildren=k.getNodeChildren,exports.getNodeType=j.getNodeType,exports.getPathWithoutLocale=we.getPathWithoutLocale,exports.getPerLocaleDictionary=v.getPerLocaleDictionary,exports.getPrefix=Te.getPrefix,exports.getReplacedValuesContent=S.getReplacedValuesContent,exports.getRewritePath=G.getRewritePath,exports.getRewriteRules=G.getRewriteRules,exports.getSplittedContent=C.getSplittedContent,exports.getSplittedDictionaryContent=C.getSplittedDictionaryContent,exports.getStorageAttributes=e.getStorageAttributes,exports.getTranslation=o.getTranslation,exports.html=ne.html,exports.i18nextToIntlayerFormatter=Q.i18nextToIntlayerFormatter,exports.icuToIntlayerFormatter=Z.icuToIntlayerFormatter,exports.inlineRegex=J.inlineRegex,exports.insert=ae.insert,exports.insertContentInDictionary=w.insertContentInDictionary,exports.insertionPlugin=s.insertionPlugin,exports.intlayerToI18nextFormatter=Q.intlayerToI18nextFormatter,exports.intlayerToICUFormatter=Z.intlayerToICUFormatter,exports.intlayerToVueI18nFormatter=$.intlayerToVueI18nFormatter,exports.isSameKeyPath=Ae.isSameKeyPath,exports.isValidElement=A.isValidElement,exports.list=de.list,exports.localeDetector=_e.localeDetector,exports.localeFlatMap=K.localeFlatMap,exports.localeMap=K.localeMap,exports.localeRecord=K.localeRecord,exports.localeResolver=ge.localeResolver,exports.localeStorageOptions=W.localeStorageOptions,exports.md=le.md,exports.mergeDictionaries=M.mergeDictionaries,exports.nest=ue.nest,exports.nestedPlugin=s.nestedPlugin,exports.normalizeAttributeKey=J.normalizeAttributeKey,exports.normalizeDictionaries=P.normalizeDictionaries,exports.normalizeDictionary=P.normalizeDictionary,exports.normalizeWhitespace=J.normalizeWhitespace,exports.number=H.number,exports.orderDictionaries=N.orderDictionaries,exports.parseBlock=J.parseBlock,exports.parseCaptureInline=J.parseCaptureInline,exports.parseInline=J.parseInline,exports.parseSimpleInline=J.parseSimpleInline,exports.parseStyleAttribute=J.parseStyleAttribute,exports.parseTableAlign=J.parseTableAlign,exports.parseTableAlignCapture=J.parseTableAlignCapture,exports.parseTableCells=J.parseTableCells,exports.parseTableRow=J.parseTableRow,exports.parseYaml=oe.parseYaml,exports.parserFor=ke.parserFor,exports.percentage=fe.percentage,exports.qualifies=J.qualifies,exports.relativeTime=pe.relativeTime,exports.removeContentNodeByKeyPath=F.removeContentNodeByKeyPath,exports.renameContentNodeByKeyPath=I.renameContentNodeByKeyPath,exports.renderFor=Y.renderFor,exports.renderNothing=J.renderNothing,exports.sanitizer=J.sanitizer,exports.setLocaleInStorage=U.setLocaleInStorage,exports.simpleInlineRegex=J.simpleInlineRegex,exports.slugify=J.slugify,exports.some=J.some,exports.splitInsertionTemplate=u.splitInsertionTemplate,exports.startsWith=J.startsWith,exports.t=h.t,exports.translationPlugin=s.translationPlugin,exports.trimEnd=J.trimEnd,exports.trimLeadingWhitespaceOutsideFences=J.trimLeadingWhitespaceOutsideFences,exports.unescapeString=J.unescapeString,exports.units=me.units,exports.unquote=J.unquote,exports.updateNodeChildren=L.updateNodeChildren,exports.validateHTML=m.validateHTML,exports.validateMarkdown=ce.validateMarkdown,exports.validatePrefix=Oe.validatePrefix,exports.vueI18nToIntlayerFormatter=$.vueI18nToIntlayerFormatter;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`./deepTransform.cjs`),n=require(`./plugins.cjs`);let r=require(`@intlayer/config/built`);r=e.__toESM(r);const i=(e,i,a,o)=>{let s=r.default?.internationalization?.defaultLocale,c=[n.translationPlugin(a??s,o?s:void 0),n.enumerationPlugin,n.conditionPlugin,n.nestedPlugin(a??s),n.filePlugin,n.insertionPlugin,n.genderPlugin,...i.plugins??[]];return t.deepTransformNode(e,{...i,plugins:c})};exports.getContent=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`./deepTransform.cjs`),n=require(`./plugins.cjs`);let r=require(`@intlayer/config/built`);r=e.__toESM(r);const i=(e,t=!0)=>[n.translationPlugin(e??r.default.internationalization.defaultLocale,t?r.default.internationalization.defaultLocale:void 0),n.enumerationPlugin,n.conditionPlugin,n.insertionPlugin,n.nestedPlugin(e??r.default.internationalization.defaultLocale),n.filePlugin,n.genderPlugin],a=(e,n,r=[])=>t.deepTransformNode(e,{...n,plugins:r});exports.getBasePlugins=i,exports.getContent=a;
2
2
  //# sourceMappingURL=getContent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getContent.cjs","names":["configuration","translationPlugin","enumerationPlugin","conditionPlugin","nestedPlugin","filePlugin","insertionPlugin","genderPlugin","deepTransformNode"],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\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 getContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n locale?: L,\n fallback?: boolean\n) => {\n const defaultLocale = configuration?.internationalization?.defaultLocale;\n\n const plugins: Plugins[] = [\n translationPlugin(\n locale ?? defaultLocale,\n fallback ? defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? defaultLocale),\n filePlugin,\n insertionPlugin,\n genderPlugin,\n ...(nodeProps.plugins ?? []),\n ];\n\n return deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n};\n"],"mappings":"8OAwBA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EAAgBA,EAAAA,SAAe,sBAAsB,cAErD,EAAqB,CACzBC,EAAAA,kBACE,GAAU,EACV,EAAW,EAAgB,IAAA,GAC5B,CACDC,EAAAA,kBACAC,EAAAA,gBACAC,EAAAA,aAAa,GAAU,EAAc,CACrCC,EAAAA,WACAC,EAAAA,gBACAC,EAAAA,aACA,GAAI,EAAU,SAAW,EAAE,CAC5B,CAED,OAAOC,EAAAA,kBAAkB,EAAM,CAC7B,GAAG,EACH,UACD,CAAC"}
1
+ {"version":3,"file":"getContent.cjs","names":["translationPlugin","configuration","enumerationPlugin","conditionPlugin","insertionPlugin","nestedPlugin","filePlugin","genderPlugin","deepTransformNode"],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { deepTransformNode } from './deepTransform';\nimport {\n conditionPlugin,\n type DeepTransformContent,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState,\n insertionPlugin,\n type NodeProps,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from './plugins';\n\nexport const getBasePlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n insertionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n];\n\n/**\n * Transforms a node in a single pass, applying each plugin as needed.\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 getContent = <\n T extends ContentNode,\n L extends LocalesValues = DeclaredLocales,\n>(\n node: T,\n nodeProps: NodeProps,\n plugins: Plugins[] = []\n) =>\n deepTransformNode(node, {\n ...nodeProps,\n plugins,\n }) as DeepTransformContent<T, IInterpreterPluginState, L>;\n"],"mappings":"8OAqBA,MAAa,GACX,EACA,EAAoB,KACN,CACdA,EAAAA,kBACE,GAAUC,EAAAA,QAAc,qBAAqB,cAC7C,EAAWA,EAAAA,QAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACDC,EAAAA,kBACAC,EAAAA,gBACAC,EAAAA,gBACAC,EAAAA,aAAa,GAAUJ,EAAAA,QAAc,qBAAqB,cAAc,CACxEK,EAAAA,WACAC,EAAAA,aACD,CAQY,GAIX,EACA,EACA,EAAqB,EAAE,GAEvBC,EAAAA,kBAAkB,EAAM,CACtB,GAAG,EACH,UACD,CAAC"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./deepTransform.cjs`),t=require(`./plugins.cjs`),n=require(`./getContent.cjs`);exports.conditionPlugin=t.conditionPlugin,exports.deepTransformNode=e.deepTransformNode,exports.enumerationPlugin=t.enumerationPlugin,exports.filePlugin=t.filePlugin,exports.genderPlugin=t.genderPlugin,exports.getContent=n.getContent,exports.insertionPlugin=t.insertionPlugin,exports.nestedPlugin=t.nestedPlugin,exports.translationPlugin=t.translationPlugin;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./deepTransform.cjs`),t=require(`./plugins.cjs`),n=require(`./getContent.cjs`);exports.conditionPlugin=t.conditionPlugin,exports.deepTransformNode=e.deepTransformNode,exports.enumerationPlugin=t.enumerationPlugin,exports.filePlugin=t.filePlugin,exports.genderPlugin=t.genderPlugin,exports.getBasePlugins=n.getBasePlugins,exports.getContent=n.getContent,exports.insertionPlugin=t.insertionPlugin,exports.nestedPlugin=t.nestedPlugin,exports.translationPlugin=t.translationPlugin;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../getCondition.cjs`),t=require(`../getEnumeration.cjs`),n=require(`../getGender.cjs`),r=require(`../getInsertion.cjs`),i=require(`../getNesting.cjs`),a=require(`../getTranslation.cjs`);let o=require(`@intlayer/types/nodeType`);const s=(e,t)=>({id:`translation-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Translation,transform:(n,r,i)=>{let s=structuredClone(n[o.NodeType.Translation]);for(let e in s){let t={...r,children:s[e],keyPath:[...r.keyPath,{type:o.NodeType.Translation,key:e}]};s[e]=i(s[e],t)}return a.getTranslation(s,e,t)}}),c={id:`enumeration-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Enumeration,transform:(e,n,r)=>{let i=structuredClone(e[o.NodeType.Enumeration]);for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.NodeType.Enumeration,key:e}]})}return e=>{let n=t.getEnumeration(i,typeof e==`number`?e:e.count);return typeof n==`function`&&typeof e==`object`?n(e):n}}},l={id:`condition-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Condition,transform:(t,n,r)=>{let i=structuredClone(t[o.NodeType.Condition]);for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.NodeType.Condition,key:e}]})}return t=>{let n=e.getCondition(i,typeof t==`boolean`?t:t.value);return typeof n==`function`&&typeof t==`object`?n(t):n}}},u={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Insertion,transform:(e,t,n)=>{let i=[...t.keyPath,{type:o.NodeType.Insertion}],a=e[o.NodeType.Insertion],s={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,i)=>{let a=i(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let o=r.getInsertion(a,e);return i(o,{...n,plugins:t.plugins,children:o})}}};return n(a,{...t,children:a,keyPath:i,plugins:[s,...t.plugins??[]]})}},d={id:`gender-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Gender,transform:(e,t,r)=>{let i=structuredClone(e[o.NodeType.Gender]);for(let e in i){let n=i[e];i[e]=r(n,{...t,children:n,keyPath:[...t.keyPath,{type:o.NodeType.Gender,key:e}]})}return e=>n.getGender(i,e)}},f=e=>({id:`nested-plugin`,canHandle:e=>typeof e==`object`&&(e?.nodeType===o.NodeType.Nested||e?.nodeType===`nested`),transform:(t,n)=>i.getNesting(t.nested.dictionaryKey,t.nested.path,{...n,locale:e??n.locale})}),p={id:`file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.File,transform:(e,t,n)=>n(e.content,{...t,children:e.content})};exports.conditionPlugin=l,exports.enumerationPlugin=c,exports.filePlugin=p,exports.genderPlugin=d,exports.insertionPlugin=u,exports.nestedPlugin=f,exports.translationPlugin=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../getCondition.cjs`),t=require(`../getEnumeration.cjs`),n=require(`../getGender.cjs`),r=require(`../getInsertion.cjs`),i=require(`../getNesting.cjs`),a=require(`../getTranslation.cjs`);let o=require(`@intlayer/types/nodeType`);const s=(e,t)=>({id:`translation-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Translation,transform:(n,r,i)=>{let s={...n[o.NodeType.Translation]??{}};for(let e in s){let t={...r,children:s[e],keyPath:[...r.keyPath,{type:o.NodeType.Translation,key:e}]};s[e]=i(s[e],t)}return a.getTranslation(s,e,t)}}),c={id:`enumeration-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Enumeration,transform:(e,n,r)=>{let i={...e[o.NodeType.Enumeration]};for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.NodeType.Enumeration,key:e}]})}return e=>{let n=t.getEnumeration(i,typeof e==`number`?e:e.count);return typeof n==`function`&&typeof e==`object`?n(e):n}}},l={id:`condition-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Condition,transform:(t,n,r)=>{let i={...t[o.NodeType.Condition]};for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.NodeType.Condition,key:e}]})}return t=>{let n=e.getCondition(i,typeof t==`boolean`?t:t.value);return typeof n==`function`&&typeof t==`object`?n(t):n}}},u={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Insertion,transform:(e,t,n)=>{let i=[...t.keyPath,{type:o.NodeType.Insertion}],a=e[o.NodeType.Insertion],s={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,i)=>{let a=i(e,{...n,children:e,plugins:[...(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)]});return e=>{let o=r.getInsertion(a,e);return i(o,{...n,plugins:t.plugins,children:o})}}};return n(a,{...t,children:a,keyPath:i,plugins:[s,...t.plugins??[]]})}},d={id:`gender-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.Gender,transform:(e,t,r)=>{let i={...e[o.NodeType.Gender]};for(let e in i){let n=i[e];i[e]=r(n,{...t,children:n,keyPath:[...t.keyPath,{type:o.NodeType.Gender,key:e}]})}return e=>n.getGender(i,e)}},f=e=>({id:`nested-plugin`,canHandle:e=>typeof e==`object`&&(e?.nodeType===o.NodeType.Nested||e?.nodeType===`nested`),transform:(t,n)=>i.getNesting(t.nested.dictionaryKey,t.nested.path,{...n,locale:e??n.locale})}),p={id:`file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.NodeType.File,transform:(e,t,n)=>n(e.content,{...t,children:e.content})};exports.conditionPlugin=l,exports.enumerationPlugin=c,exports.filePlugin=p,exports.genderPlugin=d,exports.insertionPlugin=u,exports.nestedPlugin=f,exports.translationPlugin=s;
2
2
  //# sourceMappingURL=plugins.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["NodeType","getTranslation","getEnumeration","getCondition","getInsertion","getGender","getNesting"],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins => ({\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Translation]);\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as keyof typeof result] = deepTransformNode(\n result[key as keyof typeof result],\n childProps\n );\n }\n\n return getTranslation(result, locale, fallback);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Enumeration]);\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Condition]);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result, value);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? (\n values: {\n [K in T['fields'][number]]: string | number;\n }\n ) => DeepTransformContent<string, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Gender]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<T[NodeType.Gender][keyof T[NodeType.Gender]], S>\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins = {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Gender,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const result = structuredClone(node[NodeType.Gender]);\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [...props.keyPath, { type: NodeType.Gender, key } as KeyPath],\n };\n result[key as keyof typeof result] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins => ({\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeType.Nested || node?.nodeType === 'nested'),\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }),\n});\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.File]: string;\n content?: string;\n}\n ? string\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins = {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n insertion: true;\n gender: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin’s transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":"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"}
1
+ {"version":3,"file":"plugins.cjs","names":["NodeType","getTranslation","getEnumeration","getCondition","getInsertion","getGender","getNesting"],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport type {\n ConditionContent,\n EnumerationContent,\n FileContent,\n Gender,\n GenderContent,\n InsertionContent,\n NestedContent,\n TranslationContent,\n} from '../../transpiler';\nimport { getCondition } from '../getCondition';\nimport { getEnumeration } from '../getEnumeration';\nimport { getGender } from '../getGender';\nimport { getInsertion } from '../getInsertion';\nimport { type GetNestingResult, getNesting } from '../getNesting';\nimport { getTranslation } from '../getTranslation';\n\n/** ---------------------------------------------\n * PLUGIN DEFINITION\n * --------------------------------------------- */\n\n/**\n * A plugin/transformer that can optionally transform a node during a single DFS pass.\n * - `canHandle` decides if the node is transformable by this plugin.\n * - `transform` returns the transformed node (and does not recurse further).\n *\n * > `transformFn` is a function that can be used to deeply transform inside the plugin.\n */\nexport type Plugins = {\n id: string;\n canHandle: (node: any) => boolean;\n transform: (\n node: any,\n props: NodeProps,\n transformFn: (node: any, props: NodeProps) => any\n ) => any;\n};\n\n/** ---------------------------------------------\n * TRANSLATION PLUGIN\n * --------------------------------------------- */\n\nexport type UnionKeys<T> = T extends unknown ? keyof T : never;\nexport type ValueAtKey<T, K> = T extends unknown\n ? K extends keyof T\n ? T[K]\n : never\n : never;\n\nexport type TranslationCond<T, S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Translation]: infer U;\n}\n ? U extends Record<PropertyKey, unknown>\n ? U[keyof U] extends Record<PropertyKey, unknown>\n ? {\n [K in UnionKeys<U[keyof U]>]: L extends keyof U\n ? K extends keyof U[L]\n ? U[L][K]\n : ValueAtKey<U[keyof U], K>\n : ValueAtKey<U[keyof U], K>;\n } extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : (L extends keyof U ? U[L] : U[keyof U]) extends infer Content\n ? DeepTransformContent<Content, S>\n : never\n : never\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const translationPlugin = (\n locale: LocalesValues,\n fallback?: LocalesValues\n): Plugins => ({\n id: 'translation-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Translation,\n transform: (node: TranslationContent, props, deepTransformNode) => {\n const result = {\n ...(node[NodeType.Translation] ?? {}),\n };\n\n for (const key in result) {\n const childProps = {\n ...props,\n children: result[key as keyof typeof result],\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Translation, key } as KeyPath,\n ],\n };\n result[key as keyof typeof result] = deepTransformNode(\n result[key as keyof typeof result],\n childProps\n );\n }\n\n return getTranslation(result, locale, fallback);\n },\n});\n\n/** ---------------------------------------------\n * ENUMERATION PLUGIN\n * --------------------------------------------- */\n\nexport type EnumerationCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Enumeration]: object;\n}\n ? (\n quantity: number\n ) => DeepTransformContent<\n T[NodeType.Enumeration][keyof T[NodeType.Enumeration]],\n S\n >\n : never;\n\n/** Enumeration plugin. Replaces node with a function that takes quantity => string. */\nexport const enumerationPlugin: Plugins = {\n id: 'enumeration-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Enumeration,\n transform: (node: EnumerationContent, props, deepTransformNode) => {\n const result = { ...node[NodeType.Enumeration] };\n\n for (const key in result) {\n const child = result[key as unknown as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Enumeration, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: number | { count: number }) => {\n const quantity = typeof arg === 'number' ? arg : arg.count;\n const subResult = getEnumeration(result, quantity);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * CONDITION PLUGIN\n * --------------------------------------------- */\n\nexport type ConditionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Condition]: object;\n}\n ? (\n value: boolean | { value: boolean }\n ) => DeepTransformContent<\n T[NodeType.Condition][keyof T[NodeType.Condition]],\n S\n >\n : never;\n\n/** Condition plugin. Replaces node with a function that takes boolean => string. */\nexport const conditionPlugin: Plugins = {\n id: 'condition-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Condition,\n transform: (node: ConditionContent, props, deepTransformNode) => {\n const result = { ...node[NodeType.Condition] };\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [\n ...props.keyPath,\n { type: NodeType.Condition, key } as KeyPath,\n ],\n };\n result[key as unknown as keyof typeof result] = deepTransformNode(\n child,\n childProps\n );\n }\n\n return (arg: boolean | { value: boolean }) => {\n const value = typeof arg === 'boolean' ? arg : arg.value;\n const subResult = getCondition(result, value);\n\n if (typeof subResult === 'function' && typeof arg === 'object') {\n return subResult(arg);\n }\n\n return subResult;\n };\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: string;\n fields: readonly string[];\n}\n ? (\n values: {\n [K in T['fields'][number]]: string | number;\n }\n ) => DeepTransformContent<string, S>\n : never;\n\n/** Insertion plugin. Replaces node with a function that takes quantity => string. */\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Insertion,\n },\n ];\n\n const children = node[NodeType.Insertion];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const children = getInsertion(transformedResult, values);\n\n return deepTransformNode(children, {\n ...subProps,\n plugins: props.plugins,\n children,\n });\n };\n },\n };\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * GENDER PLUGIN\n * --------------------------------------------- */\n\nexport type GenderCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Gender]: object;\n}\n ? (\n value: Gender\n ) => DeepTransformContent<T[NodeType.Gender][keyof T[NodeType.Gender]], S>\n : never;\n\n/** Gender plugin. Replaces node with a function that takes gender => string. */\nexport const genderPlugin: Plugins = {\n id: 'gender-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Gender,\n transform: (node: GenderContent, props, deepTransformNode) => {\n const result = { ...node[NodeType.Gender] };\n\n for (const key in result) {\n const child = result[key as keyof typeof result];\n const childProps = {\n ...props,\n children: child,\n keyPath: [...props.keyPath, { type: NodeType.Gender, key } as KeyPath],\n };\n result[key as keyof typeof result] = deepTransformNode(child, childProps);\n }\n\n return (value: Gender) => getGender(result, value);\n },\n};\n\n/** ---------------------------------------------\n * NESTED PLUGIN\n * --------------------------------------------- */\n\nexport type NestedCond<T, S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.Nested]: infer U;\n}\n ? U extends {\n dictionaryKey: infer K extends DictionaryKeys;\n path?: infer P;\n }\n ? GetNestingResult<K, P, S>\n : never\n : never;\n\n/** Nested plugin. Replaces node with the result of `getNesting`. */\nexport const nestedPlugin = (locale?: LocalesValues): Plugins => ({\n id: 'nested-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n (node?.nodeType === NodeType.Nested || node?.nodeType === 'nested'),\n transform: (node: NestedContent, props) =>\n getNesting(node.nested.dictionaryKey, node.nested.path, {\n ...props,\n locale: (locale ?? props.locale) as Locale,\n }),\n});\n\n/** ---------------------------------------------\n * FILE PLUGIN\n * --------------------------------------------- */\n\nexport type FileCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.File]: string;\n content?: string;\n}\n ? string\n : never;\n\n/** File plugin. Replaces node with the result of `getNesting`. */\nexport const filePlugin: Plugins = {\n id: 'file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent, props, deepTransform) =>\n deepTransform(node.content, {\n ...props,\n children: node.content,\n }),\n};\n\n/**\n * PLUGIN RESULT\n */\n\n/**\n * Interface that defines the properties of a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface NodeProps {\n dictionaryKey: string;\n keyPath: KeyPath[];\n plugins?: Plugins[];\n locale?: Locale;\n dictionaryPath?: string;\n children?: any;\n}\n\n/**\n * Interface that defines the plugins that can be used to transform a node.\n * This interface can be augmented in other packages, such as `react-intlayer`.\n */\nexport interface IInterpreterPlugin<T, S, L extends LocalesValues> {\n translation: TranslationCond<T, S, L>;\n enumeration: EnumerationCond<T, S, L>;\n condition: ConditionCond<T, S, L>;\n insertion: InsertionCond<T, S, L>;\n gender: GenderCond<T, S, L>;\n nested: NestedCond<T, S, L>;\n file: FileCond<T>;\n}\n\n/**\n * Allow to avoid overwriting import from `intlayer` package when `IInterpreterPlugin<T>` interface is augmented in another package, such as `react-intlayer`.\n */\nexport type IInterpreterPluginState = {\n translation: true;\n enumeration: true;\n condition: true;\n insertion: true;\n gender: true;\n nested: true;\n file: true;\n};\n\n/**\n * Utility type to check if a plugin can be applied to a node.\n */\ntype CheckApplyPlugin<\n T,\n K extends keyof IInterpreterPlugin<T, S, L>,\n S,\n L extends LocalesValues = DeclaredLocales,\n> = K extends keyof S // Test if the key is a key of S.\n ? // Test if the key of S is true. Then the plugin can be applied.\n S[K] extends true\n ? // Test if the key of S exist\n IInterpreterPlugin<T, S, L>[K] extends never\n ? never\n : // Test if the plugin condition is true (if it's not, the plugin is skipped for this node)\n IInterpreterPlugin<T, S, L>[K]\n : never\n : never;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\ntype Traverse<T, S, L extends LocalesValues = DeclaredLocales> =\n T extends ReadonlyArray<infer U> // Turn any read-only array into a plain mutable array\n ? Array<DeepTransformContent<U, S, L>>\n : T extends object\n ? { [K in keyof T]: DeepTransformContent<T[K], S, L> }\n : T;\n\nexport type IsAny<T> = 0 extends 1 & T ? true : false;\n\n/**\n * Traverse recursively through an object or array, applying each plugin as needed.\n */\nexport type DeepTransformContent<\n T,\n S = IInterpreterPluginState,\n L extends LocalesValues = DeclaredLocales,\n> =\n IsAny<T> extends true\n ? T\n : CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L> extends never // Check if there is a plugin for T:\n ? // No plugin was found, so try to transform T recursively:\n Traverse<T, S, L>\n : // A plugin was found – use the plugin’s transformation.\n CheckApplyPlugin<T, keyof IInterpreterPlugin<T, S, L>, S, L>;\n"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getContent/getContent.cjs`),t=(t,n,r)=>{let i={dictionaryKey:t.key,dictionaryPath:t.filePath,keyPath:[],plugins:r};return e.getContent(t.content,i,n,!0)};exports.getDictionary=t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getContent/getContent.cjs`),t=(t,n,r=e.getBasePlugins(n))=>{let i={dictionaryKey:t.key,dictionaryPath:t.filePath,keyPath:[],plugins:r};return e.getContent(t.content,i,r)};exports.getDictionary=t;
2
2
  //# sourceMappingURL=getDictionary.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.cjs","names":["getContent"],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<T['content'], IInterpreterPluginState, L> => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n return getContent(dictionary.content, props, locale, true);\n};\n"],"mappings":"kHAkBa,GAIX,EACA,EACA,IACmE,CACnE,IAAM,EAAmB,CACvB,cAAe,EAAW,IAC1B,eAAgB,EAAW,SAC3B,QAAS,EAAE,CACX,UACD,CAED,OAAOA,EAAAA,WAAW,EAAW,QAAS,EAAO,EAAQ,GAAK"}
1
+ {"version":3,"file":"getDictionary.cjs","names":["getBasePlugins","getContent"],"sources":["../../../src/interpreter/getDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n NodeProps,\n Plugins,\n} from './getContent';\nimport { getBasePlugins, getContent } from './getContent/getContent';\n\n/**\n * Transforms a dictionary in a single pass, applying each plugin as needed.\n *\n * @param dictionary The dictionary to transform.\n * @param locale The locale to use if your transformers need it (e.g. for translations).\n * @param additionalPlugins An array of NodeTransformer that define how to transform recognized nodes.\n * If omitted, we’ll use a default set of plugins.\n */\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L,\n plugins: Plugins[] = getBasePlugins(locale)\n): DeepTransformContent<T['content'], IInterpreterPluginState, L> => {\n const props: NodeProps = {\n dictionaryKey: dictionary.key,\n dictionaryPath: dictionary.filePath,\n keyPath: [],\n plugins,\n };\n\n return getContent(dictionary.content, props, plugins);\n};\n"],"mappings":"kHAqBa,GAIX,EACA,EACA,EAAqBA,EAAAA,eAAe,EAAO,GACwB,CACnE,IAAM,EAAmB,CACvB,cAAe,EAAW,IAC1B,eAAgB,EAAW,SAC3B,QAAS,EAAE,CACX,UACD,CAED,OAAOC,EAAAA,WAAW,EAAW,QAAS,EAAO,EAAQ"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{let t={},n=/([a-zA-Z0-9-]+)="([^"]*)"/g,r=n.exec(e);for(;r!==null;)t[r[1]]=r[2],r=n.exec(e);return t},t=new Map,n=n=>{if(t.has(n))return t.get(n);if(typeof n!=`string`)return[];let r=/<(\/)?([a-zA-Z0-9.-]+)([\s\S]*?)(\/?)>/g,i=[],a=[],o=0,s=r.exec(n),c=e=>{(a.length>0?a[a.length-1].children:i).push(e)};for(;s!==null;){let[t,i,l,u,d]=s,f=s.index;f>o&&c(n.slice(o,f));let p=i===`/`,m=d===`/`||u.trim().endsWith(`/`)||t.endsWith(`/>`),h=u.trim().replace(/\/$/,``).trim();if(p){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}else if(m)c({tagName:l,props:e(h),children:[]});else{let t=e(h);a.push({tagName:l,children:[],props:t})}o=f+t.length,s=r.exec(n)}for(o<n.length&&c(n.slice(o));a.length>0;){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}return t.set(n,i),i},r=(e,t)=>{let r=n(e),i=0,a=e=>{if(typeof e==`string`)return e;let{tagName:n,props:r,children:o}=e,s=o.flatMap(a),c=i++,l=t[n];if(!l){let e=n.toLowerCase(),r=Object.keys(t).find(t=>t.toLowerCase()===e);r&&(l=t[r])}let u=`html-tag-${n}-${c}`;if(typeof l==`function`)return l({...r,children:s,key:u});if(typeof l==`string`){let e=t[l];return typeof e==`function`?e({...r,children:s,key:u}):s}if(typeof l==`object`&&l&&`tag`in l){let{tag:e,props:n}=l,i=t[e];return typeof i==`function`?i({...r,...n,children:s,key:u}):s}return s},o=r.flatMap(a);return o.length===1?o[0]:o};exports.getHTML=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>{let t={},n=/([a-zA-Z0-9-]+)="([^"]*)"/g,r=n.exec(e);for(;r!==null;)t[r[1]]=r[2],r=n.exec(e);return t},t=new Map,n=n=>{if(t.has(n))return t.get(n);if(typeof n!=`string`)return[];let r=/<(\/)?([a-zA-Z0-9.-]+)([\s\S]*?)(\/?)>/g,i=[],a=[],o=0,s=r.exec(n),c=e=>{(a.length>0?a[a.length-1].children:i).push(e)};for(;s!==null;){let[t,i,l,u,d]=s,f=s.index;f>o&&c(n.slice(o,f));let p=i===`/`,m=d===`/`||u.trim().endsWith(`/`)||t.endsWith(`/>`),h=u.trim().replace(/\/$/,``).trim();if(p){let e=a[a.length-1];if(e&&e.tagName===l){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}}else if(m)c({tagName:l,props:e(h),children:[]});else{let t=e(h);a.push({tagName:l,children:[],props:t})}o=f+t.length,s=r.exec(n)}for(o<n.length&&c(n.slice(o));a.length>0;){let e=a.pop();e&&c({tagName:e.tagName,props:e.props,children:e.children})}return t.set(n,i),i},r=(e,t)=>{let r=n(e),i=0,a=e=>{if(typeof e==`string`)return e;let{tagName:n,props:r,children:o}=e,s=o.flatMap(a),c=i++,l=t[n];if(!l){let e=n.toLowerCase(),r=Object.keys(t).find(t=>t.toLowerCase()===e);r&&(l=t[r])}let u=`html-tag-${n}-${c}`;if(typeof l==`function`)return l({...r,children:s,key:u});if(typeof l==`string`){let e=t[l];return typeof e==`function`?e({...r,children:s,key:u}):s}if(typeof l==`object`&&l&&`tag`in l){let{tag:e,props:n}=l,i=t[e];return typeof i==`function`?i({...r,...n,children:s,key:u}):s}return s},o=r.flatMap(a);return o.length===1?o[0]:o};exports.getHTML=r;
2
2
  //# sourceMappingURL=getHTML.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getHTML.cjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack.pop();\n\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"getHTML.cjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack[stack.length - 1];\n\n // Only pop if the tag names match\n if (last && last.tagName === tagName) {\n const popped = stack.pop();\n if (popped) {\n appendChild({\n tagName: popped.tagName,\n props: popped.props,\n children: popped.children,\n });\n }\n }\n // If tags don't match or no open tag, silently ignore the closing tag\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.cjs","names":["configuration","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { DeclaredLocales, DictionaryKeys, DictionaryRegistryContent, DictionaryRegistryElement, LocalesValues } from '@intlayer/types/module_augmentation';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":"mSAeA,MAAM,GAAsB,EAAO,KAC1B,IAAI,UAEH,EACN,CACE,KAAM,EAAS,IAAS,CAEtB,GACE,IAAS,UACT,IAAS,OAAO,aAChB,IAAS,WAET,UAAa,EAEX,OAAS,OAMb,OAAO,EADU,EAAO,GAAG,EAAK,GAAG,OAAO,EAAK,GAAK,OAAO,EAAK,CAC7B,EAGrC,UACS,EAEV,CACF,CAGU,GAIX,EACA,EACA,IAKG,CAEH,IAAM,GAAA,EAAA,EAAA,kBADgC,CACN,GAsBhC,OApBK,EAoBEC,EAAAA,cACL,EACA,EACA,EACD,GArBC,EAAA,EAAA,cAD4BD,EAAAA,QAAc,CAExC,eAAA,EAAA,EAAA,aAA0B,EAAc,CAAC,uCACzC,CACE,MAAO,OACP,UAAW,GACZ,CACF,CAEG,QAAQ,IAAI,SAGP,EAAmB,EAAc"}
1
+ {"version":3,"file":"getIntlayer.cjs","names":["configuration","getDictionary"],"sources":["../../../src/interpreter/getIntlayer.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport { colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n DictionaryRegistryElement,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type {\n DeepTransformContent,\n IInterpreterPluginState,\n Plugins,\n} from './getContent';\nimport { getDictionary } from './getDictionary';\n\n/**\n * Creates a Recursive Proxy that returns the path of the accessed key\n * stringified. This prevents the app from crashing on undefined access.\n */\nconst createSafeFallback = (path = ''): any => {\n return new Proxy(\n // Target is a function so it can be called if the dictionary expects a function\n () => path,\n {\n get: (_target, prop) => {\n // Handle common object methods to prevent infinite recursion or weird behavior\n if (\n prop === 'toJSON' ||\n prop === Symbol.toPrimitive ||\n prop === 'toString'\n ) {\n return () => path;\n }\n if (prop === 'then') {\n return undefined; // Prevent it from being treated as a Promise\n }\n\n // Recursively build the path (e.g., \"myDictionary.home.title\")\n const nextPath = path ? `${path}.${String(prop)}` : String(prop);\n return createSafeFallback(nextPath);\n },\n // If the code tries to execute the missing key as a function: t.title()\n apply: () => {\n return path;\n },\n }\n );\n};\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L,\n plugins?: Plugins[]\n): DeepTransformContent<\n DictionaryRegistryContent<T>,\n IInterpreterPluginState,\n L\n> => {\n const dictionaries = getDictionaries();\n const dictionary = dictionaries[key as T] as DictionaryRegistryElement<T>;\n\n if (!dictionary) {\n // Log a warning instead of throwing (so developers know it's missing)\n const logger = getAppLogger(configuration);\n logger(\n `Dictionary ${colorizeKey(key as string)} was not found. Using fallback proxy.`,\n {\n level: 'warn',\n isVerbose: true,\n }\n );\n\n if (process.env.NODE_ENV === 'development') {\n // Return the Safe Proxy\n // We initialize it with the dictionary key name so the UI shows \"my-dictionary.someKey\"\n return createSafeFallback(key as string);\n }\n\n return createSafeFallback(key as string);\n }\n\n return getDictionary<DictionaryRegistryElement<T>, L>(\n dictionary,\n locale,\n plugins\n );\n};\n"],"mappings":"mSAqBA,MAAM,GAAsB,EAAO,KAC1B,IAAI,UAEH,EACN,CACE,KAAM,EAAS,IAAS,CAEtB,GACE,IAAS,UACT,IAAS,OAAO,aAChB,IAAS,WAET,UAAa,EAEX,OAAS,OAMb,OAAO,EADU,EAAO,GAAG,EAAK,GAAG,OAAO,EAAK,GAAK,OAAO,EAAK,CAC7B,EAGrC,UACS,EAEV,CACF,CAGU,GAIX,EACA,EACA,IAKG,CAEH,IAAM,GAAA,EAAA,EAAA,kBADgC,CACN,GAsBhC,OApBK,EAoBEC,EAAAA,cACL,EACA,EACA,EACD,GArBC,EAAA,EAAA,cAD4BD,EAAAA,QAAc,CAExC,eAAA,EAAA,EAAA,aAA0B,EAAc,CAAC,uCACzC,CACE,MAAO,OACP,UAAW,GACZ,CACF,CAEG,QAAQ,IAAI,SAGP,EAAmB,EAAc"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getCondition.cjs`),t=require(`./getContent/deepTransform.cjs`),n=require(`./getEnumeration.cjs`),r=require(`./getDictionary.cjs`),i=require(`./getIntlayer.cjs`),a=require(`./getNesting.cjs`),o=require(`./getTranslation.cjs`),s=require(`./getContent/plugins.cjs`),c=require(`./getContent/getContent.cjs`),l=require(`./getHTML.cjs`),u=require(`./splitAndJoinInsertion.cjs`);exports.conditionPlugin=s.conditionPlugin,exports.deepTransformNode=t.deepTransformNode,exports.enumerationPlugin=s.enumerationPlugin,exports.filePlugin=s.filePlugin,exports.findMatchingCondition=n.findMatchingCondition,exports.genderPlugin=s.genderPlugin,exports.getCondition=e.getCondition,exports.getContent=c.getContent,exports.getDictionary=r.getDictionary,exports.getEnumeration=n.getEnumeration,exports.getHTML=l.getHTML,exports.getIntlayer=i.getIntlayer,exports.getNesting=a.getNesting,exports.getTranslation=o.getTranslation,exports.insertionPlugin=s.insertionPlugin,exports.nestedPlugin=s.nestedPlugin,exports.splitInsertionTemplate=u.splitInsertionTemplate,exports.translationPlugin=s.translationPlugin;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getCondition.cjs`),t=require(`./getContent/deepTransform.cjs`),n=require(`./getEnumeration.cjs`),r=require(`./getDictionary.cjs`),i=require(`./getIntlayer.cjs`),a=require(`./getNesting.cjs`),o=require(`./getTranslation.cjs`),s=require(`./getContent/plugins.cjs`),c=require(`./getContent/getContent.cjs`),l=require(`./getHTML.cjs`),u=require(`./splitAndJoinInsertion.cjs`);exports.conditionPlugin=s.conditionPlugin,exports.deepTransformNode=t.deepTransformNode,exports.enumerationPlugin=s.enumerationPlugin,exports.filePlugin=s.filePlugin,exports.findMatchingCondition=n.findMatchingCondition,exports.genderPlugin=s.genderPlugin,exports.getBasePlugins=c.getBasePlugins,exports.getCondition=e.getCondition,exports.getContent=c.getContent,exports.getDictionary=r.getDictionary,exports.getEnumeration=n.getEnumeration,exports.getHTML=l.getHTML,exports.getIntlayer=i.getIntlayer,exports.getNesting=a.getNesting,exports.getTranslation=o.getTranslation,exports.insertionPlugin=s.insertionPlugin,exports.nestedPlugin=s.nestedPlugin,exports.splitInsertionTemplate=u.splitInsertionTemplate,exports.translationPlugin=s.translationPlugin;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../transpiler/markdown/getMarkdownMetadata.cjs`),t=require(`../transpiler/markdown/markdown.cjs`),n=require(`./constants.cjs`),r=require(`./utils.cjs`),i=require(`./parser.cjs`),a=require(`./renderer.cjs`),o=require(`./compiler.cjs`);exports.ATTRIBUTES_TO_SANITIZE=n.ATTRIBUTES_TO_SANITIZE,exports.ATTRIBUTE_TO_NODE_PROP_MAP=n.ATTRIBUTE_TO_NODE_PROP_MAP,exports.ATTR_EXTRACTOR_R=n.ATTR_EXTRACTOR_R,exports.BLOCKQUOTE_ALERT_R=n.BLOCKQUOTE_ALERT_R,exports.BLOCKQUOTE_R=n.BLOCKQUOTE_R,exports.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R=n.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,exports.BLOCK_END_R=n.BLOCK_END_R,exports.BREAK_LINE_R=n.BREAK_LINE_R,exports.BREAK_THEMATIC_R=n.BREAK_THEMATIC_R,exports.CAPTURE_LETTER_AFTER_HYPHEN=n.CAPTURE_LETTER_AFTER_HYPHEN,exports.CODE_BLOCK_FENCED_R=n.CODE_BLOCK_FENCED_R,exports.CODE_BLOCK_R=n.CODE_BLOCK_R,exports.CODE_INLINE_R=n.CODE_INLINE_R,exports.CONSECUTIVE_NEWLINE_R=n.CONSECUTIVE_NEWLINE_R,exports.CR_NEWLINE_R=n.CR_NEWLINE_R,exports.CUSTOM_COMPONENT_R=n.CUSTOM_COMPONENT_R,exports.DO_NOT_PROCESS_HTML_ELEMENTS=n.DO_NOT_PROCESS_HTML_ELEMENTS,exports.DURATION_DELAY_TRIGGER=n.DURATION_DELAY_TRIGGER,exports.FOOTNOTE_R=n.FOOTNOTE_R,exports.FOOTNOTE_REFERENCE_R=n.FOOTNOTE_REFERENCE_R,exports.FORMFEED_R=n.FORMFEED_R,exports.FRONT_MATTER_R=n.FRONT_MATTER_R,exports.GFM_TASK_R=n.GFM_TASK_R,exports.HEADING_ATX_COMPLIANT_R=n.HEADING_ATX_COMPLIANT_R,exports.HEADING_R=n.HEADING_R,exports.HEADING_SETEXT_R=n.HEADING_SETEXT_R,exports.HTML_BLOCK_ELEMENT_R=n.HTML_BLOCK_ELEMENT_R,exports.HTML_CHAR_CODE_R=n.HTML_CHAR_CODE_R,exports.HTML_COMMENT_R=n.HTML_COMMENT_R,exports.HTML_CUSTOM_ATTR_R=n.HTML_CUSTOM_ATTR_R,exports.HTML_LEFT_TRIM_AMOUNT_R=n.HTML_LEFT_TRIM_AMOUNT_R,exports.HTML_SELF_CLOSING_ELEMENT_R=n.HTML_SELF_CLOSING_ELEMENT_R,exports.INLINE_SKIP_R=n.INLINE_SKIP_R,exports.INTERPOLATION_R=n.INTERPOLATION_R,exports.LINK_AUTOLINK_BARE_URL_R=n.LINK_AUTOLINK_BARE_URL_R,exports.LINK_AUTOLINK_R=n.LINK_AUTOLINK_R,exports.LIST_LOOKBEHIND_R=n.LIST_LOOKBEHIND_R,exports.LOOKAHEAD=n.LOOKAHEAD,exports.NAMED_CODES_TO_UNICODE=n.NAMED_CODES_TO_UNICODE,exports.NP_TABLE_R=n.NP_TABLE_R,exports.ORDERED=n.ORDERED,exports.ORDERED_LIST_BULLET=n.ORDERED_LIST_BULLET,exports.ORDERED_LIST_ITEM_PREFIX=n.ORDERED_LIST_ITEM_PREFIX,exports.ORDERED_LIST_ITEM_PREFIX_R=n.ORDERED_LIST_ITEM_PREFIX_R,exports.ORDERED_LIST_ITEM_R=n.ORDERED_LIST_ITEM_R,exports.ORDERED_LIST_R=n.ORDERED_LIST_R,exports.PARAGRAPH_R=n.PARAGRAPH_R,exports.Priority=n.Priority,exports.REFERENCE_IMAGE_OR_LINK=n.REFERENCE_IMAGE_OR_LINK,exports.REFERENCE_IMAGE_R=n.REFERENCE_IMAGE_R,exports.REFERENCE_LINK_R=n.REFERENCE_LINK_R,exports.RuleType=n.RuleType,exports.SHORTCODE_R=n.SHORTCODE_R,exports.SHOULD_RENDER_AS_BLOCK_R=n.SHOULD_RENDER_AS_BLOCK_R,exports.TABLE_CENTER_ALIGN=n.TABLE_CENTER_ALIGN,exports.TABLE_LEFT_ALIGN=n.TABLE_LEFT_ALIGN,exports.TABLE_RIGHT_ALIGN=n.TABLE_RIGHT_ALIGN,exports.TABLE_TRIM_PIPES=n.TABLE_TRIM_PIPES,exports.TAB_R=n.TAB_R,exports.TEXT_BOLD_R=n.TEXT_BOLD_R,exports.TEXT_EMPHASIZED_R=n.TEXT_EMPHASIZED_R,exports.TEXT_ESCAPED_R=n.TEXT_ESCAPED_R,exports.TEXT_MARKED_R=n.TEXT_MARKED_R,exports.TEXT_PLAIN_R=n.TEXT_PLAIN_R,exports.TEXT_STRIKETHROUGHED_R=n.TEXT_STRIKETHROUGHED_R,exports.TRIM_STARTING_NEWLINES=n.TRIM_STARTING_NEWLINES,exports.UNESCAPE_R=n.UNESCAPE_R,exports.UNORDERED=n.UNORDERED,exports.UNORDERED_LIST_BULLET=n.UNORDERED_LIST_BULLET,exports.UNORDERED_LIST_ITEM_PREFIX=n.UNORDERED_LIST_ITEM_PREFIX,exports.UNORDERED_LIST_ITEM_PREFIX_R=n.UNORDERED_LIST_ITEM_PREFIX_R,exports.UNORDERED_LIST_ITEM_R=n.UNORDERED_LIST_ITEM_R,exports.UNORDERED_LIST_R=n.UNORDERED_LIST_R,exports.allowInline=r.allowInline,exports.anyScopeRegex=r.anyScopeRegex,exports.attributeValueToNodePropValue=r.attributeValueToNodePropValue,exports.blockRegex=r.blockRegex,exports.captureNothing=r.captureNothing,exports.compile=o.compile,exports.compileWithOptions=o.compileWithOptions,exports.createCompiler=o.createCompiler,exports.createRenderer=a.createRenderer,exports.cx=r.cx,exports.generateListItemPrefix=n.generateListItemPrefix,exports.generateListItemPrefixRegex=n.generateListItemPrefixRegex,exports.generateListItemRegex=n.generateListItemRegex,exports.generateListRegex=n.generateListRegex,exports.get=r.get,exports.getMarkdownMetadata=e.getMarkdownMetadata,exports.inlineRegex=r.inlineRegex,exports.md=t.md,exports.normalizeAttributeKey=r.normalizeAttributeKey,exports.normalizeWhitespace=r.normalizeWhitespace,exports.parseBlock=r.parseBlock,exports.parseCaptureInline=r.parseCaptureInline,exports.parseInline=r.parseInline,exports.parseSimpleInline=r.parseSimpleInline,exports.parseStyleAttribute=r.parseStyleAttribute,exports.parseTableAlign=r.parseTableAlign,exports.parseTableAlignCapture=r.parseTableAlignCapture,exports.parseTableCells=r.parseTableCells,exports.parseTableRow=r.parseTableRow,exports.parserFor=i.parserFor,exports.qualifies=r.qualifies,exports.renderFor=a.renderFor,exports.renderNothing=r.renderNothing,exports.sanitizer=r.sanitizer,exports.simpleInlineRegex=r.simpleInlineRegex,exports.slugify=r.slugify,exports.some=r.some,exports.startsWith=r.startsWith,exports.trimEnd=r.trimEnd,exports.trimLeadingWhitespaceOutsideFences=r.trimLeadingWhitespaceOutsideFences,exports.unescapeString=r.unescapeString,exports.unquote=r.unquote;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../transpiler/markdown/getMarkdownMetadata.cjs`),t=require(`../transpiler/markdown/validateMarkdown.cjs`),n=require(`../transpiler/markdown/markdown.cjs`),r=require(`./constants.cjs`),i=require(`./utils.cjs`),a=require(`./parser.cjs`),o=require(`./renderer.cjs`),s=require(`./compiler.cjs`);exports.ATTRIBUTES_TO_SANITIZE=r.ATTRIBUTES_TO_SANITIZE,exports.ATTRIBUTE_TO_NODE_PROP_MAP=r.ATTRIBUTE_TO_NODE_PROP_MAP,exports.ATTR_EXTRACTOR_R=r.ATTR_EXTRACTOR_R,exports.BLOCKQUOTE_ALERT_R=r.BLOCKQUOTE_ALERT_R,exports.BLOCKQUOTE_R=r.BLOCKQUOTE_R,exports.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R=r.BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,exports.BLOCK_END_R=r.BLOCK_END_R,exports.BREAK_LINE_R=r.BREAK_LINE_R,exports.BREAK_THEMATIC_R=r.BREAK_THEMATIC_R,exports.CAPTURE_LETTER_AFTER_HYPHEN=r.CAPTURE_LETTER_AFTER_HYPHEN,exports.CODE_BLOCK_FENCED_R=r.CODE_BLOCK_FENCED_R,exports.CODE_BLOCK_R=r.CODE_BLOCK_R,exports.CODE_INLINE_R=r.CODE_INLINE_R,exports.CONSECUTIVE_NEWLINE_R=r.CONSECUTIVE_NEWLINE_R,exports.CR_NEWLINE_R=r.CR_NEWLINE_R,exports.CUSTOM_COMPONENT_R=r.CUSTOM_COMPONENT_R,exports.DO_NOT_PROCESS_HTML_ELEMENTS=r.DO_NOT_PROCESS_HTML_ELEMENTS,exports.DURATION_DELAY_TRIGGER=r.DURATION_DELAY_TRIGGER,exports.FOOTNOTE_R=r.FOOTNOTE_R,exports.FOOTNOTE_REFERENCE_R=r.FOOTNOTE_REFERENCE_R,exports.FORMFEED_R=r.FORMFEED_R,exports.FRONT_MATTER_R=r.FRONT_MATTER_R,exports.GFM_TASK_R=r.GFM_TASK_R,exports.HEADING_ATX_COMPLIANT_R=r.HEADING_ATX_COMPLIANT_R,exports.HEADING_R=r.HEADING_R,exports.HEADING_SETEXT_R=r.HEADING_SETEXT_R,exports.HTML_BLOCK_ELEMENT_R=r.HTML_BLOCK_ELEMENT_R,exports.HTML_CHAR_CODE_R=r.HTML_CHAR_CODE_R,exports.HTML_COMMENT_R=r.HTML_COMMENT_R,exports.HTML_CUSTOM_ATTR_R=r.HTML_CUSTOM_ATTR_R,exports.HTML_LEFT_TRIM_AMOUNT_R=r.HTML_LEFT_TRIM_AMOUNT_R,exports.HTML_SELF_CLOSING_ELEMENT_R=r.HTML_SELF_CLOSING_ELEMENT_R,exports.INLINE_SKIP_R=r.INLINE_SKIP_R,exports.INTERPOLATION_R=r.INTERPOLATION_R,exports.LINK_AUTOLINK_BARE_URL_R=r.LINK_AUTOLINK_BARE_URL_R,exports.LINK_AUTOLINK_R=r.LINK_AUTOLINK_R,exports.LIST_LOOKBEHIND_R=r.LIST_LOOKBEHIND_R,exports.LOOKAHEAD=r.LOOKAHEAD,exports.NAMED_CODES_TO_UNICODE=r.NAMED_CODES_TO_UNICODE,exports.NP_TABLE_R=r.NP_TABLE_R,exports.ORDERED=r.ORDERED,exports.ORDERED_LIST_BULLET=r.ORDERED_LIST_BULLET,exports.ORDERED_LIST_ITEM_PREFIX=r.ORDERED_LIST_ITEM_PREFIX,exports.ORDERED_LIST_ITEM_PREFIX_R=r.ORDERED_LIST_ITEM_PREFIX_R,exports.ORDERED_LIST_ITEM_R=r.ORDERED_LIST_ITEM_R,exports.ORDERED_LIST_R=r.ORDERED_LIST_R,exports.PARAGRAPH_R=r.PARAGRAPH_R,exports.Priority=r.Priority,exports.REFERENCE_IMAGE_OR_LINK=r.REFERENCE_IMAGE_OR_LINK,exports.REFERENCE_IMAGE_R=r.REFERENCE_IMAGE_R,exports.REFERENCE_LINK_R=r.REFERENCE_LINK_R,exports.RuleType=r.RuleType,exports.SHORTCODE_R=r.SHORTCODE_R,exports.SHOULD_RENDER_AS_BLOCK_R=r.SHOULD_RENDER_AS_BLOCK_R,exports.TABLE_CENTER_ALIGN=r.TABLE_CENTER_ALIGN,exports.TABLE_LEFT_ALIGN=r.TABLE_LEFT_ALIGN,exports.TABLE_RIGHT_ALIGN=r.TABLE_RIGHT_ALIGN,exports.TABLE_TRIM_PIPES=r.TABLE_TRIM_PIPES,exports.TAB_R=r.TAB_R,exports.TEXT_BOLD_R=r.TEXT_BOLD_R,exports.TEXT_EMPHASIZED_R=r.TEXT_EMPHASIZED_R,exports.TEXT_ESCAPED_R=r.TEXT_ESCAPED_R,exports.TEXT_MARKED_R=r.TEXT_MARKED_R,exports.TEXT_PLAIN_R=r.TEXT_PLAIN_R,exports.TEXT_STRIKETHROUGHED_R=r.TEXT_STRIKETHROUGHED_R,exports.TRIM_STARTING_NEWLINES=r.TRIM_STARTING_NEWLINES,exports.UNESCAPE_R=r.UNESCAPE_R,exports.UNORDERED=r.UNORDERED,exports.UNORDERED_LIST_BULLET=r.UNORDERED_LIST_BULLET,exports.UNORDERED_LIST_ITEM_PREFIX=r.UNORDERED_LIST_ITEM_PREFIX,exports.UNORDERED_LIST_ITEM_PREFIX_R=r.UNORDERED_LIST_ITEM_PREFIX_R,exports.UNORDERED_LIST_ITEM_R=r.UNORDERED_LIST_ITEM_R,exports.UNORDERED_LIST_R=r.UNORDERED_LIST_R,exports.allowInline=i.allowInline,exports.anyScopeRegex=i.anyScopeRegex,exports.attributeValueToNodePropValue=i.attributeValueToNodePropValue,exports.blockRegex=i.blockRegex,exports.captureNothing=i.captureNothing,exports.compile=s.compile,exports.compileWithOptions=s.compileWithOptions,exports.createCompiler=s.createCompiler,exports.createRenderer=o.createRenderer,exports.cx=i.cx,exports.generateListItemPrefix=r.generateListItemPrefix,exports.generateListItemPrefixRegex=r.generateListItemPrefixRegex,exports.generateListItemRegex=r.generateListItemRegex,exports.generateListRegex=r.generateListRegex,exports.get=i.get,exports.getMarkdownMetadata=e.getMarkdownMetadata,exports.inlineRegex=i.inlineRegex,exports.md=n.md,exports.normalizeAttributeKey=i.normalizeAttributeKey,exports.normalizeWhitespace=i.normalizeWhitespace,exports.parseBlock=i.parseBlock,exports.parseCaptureInline=i.parseCaptureInline,exports.parseInline=i.parseInline,exports.parseSimpleInline=i.parseSimpleInline,exports.parseStyleAttribute=i.parseStyleAttribute,exports.parseTableAlign=i.parseTableAlign,exports.parseTableAlignCapture=i.parseTableAlignCapture,exports.parseTableCells=i.parseTableCells,exports.parseTableRow=i.parseTableRow,exports.parserFor=a.parserFor,exports.qualifies=i.qualifies,exports.renderFor=o.renderFor,exports.renderNothing=i.renderNothing,exports.sanitizer=i.sanitizer,exports.simpleInlineRegex=i.simpleInlineRegex,exports.slugify=i.slugify,exports.some=i.some,exports.startsWith=i.startsWith,exports.trimEnd=i.trimEnd,exports.trimLeadingWhitespaceOutsideFences=i.trimLeadingWhitespaceOutsideFences,exports.unescapeString=i.unescapeString,exports.unquote=i.unquote,exports.validateMarkdown=t.validateMarkdown;
@@ -1 +1 @@
1
- {"version":3,"file":"enumeration.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport type { TypedNodeModel } from '@intlayer/types/nodeType';;\n\ntype Positive = number | `${number}`;\ntype Negative = `-${number}`;\ntype Numbers = Positive | Negative;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content>(content?: EnumerationContentState<Content>) =>\n formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":"6JAoDA,MAAM,EAAwB,IAAA,EAAA,EAAA,gBACbA,EAAAA,SAAS,YAAa,EAAQ"}
1
+ {"version":3,"file":"enumeration.cjs","names":["NodeType"],"sources":["../../../../src/transpiler/enumeration/enumeration.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\n\ntype Positive = number | `${number}`;\ntype Negative = `-${number}`;\ntype Numbers = Positive | Negative;\n\ntype Equal = Numbers;\ntype EqualString = `=${Numbers}`;\ntype Superior = `>${Numbers}`;\ntype SuperiorOrEqual = `>=${Numbers}`;\ntype Inferior = `<${Numbers}`;\ntype InferiorOrEqual = `<=${Numbers}`;\n\nexport type EnterFormat =\n | Equal\n | EqualString\n | Superior\n | SuperiorOrEqual\n | Inferior\n | InferiorOrEqual;\n\nexport type EnumerationContentState<Content> = Partial<\n Record<EnterFormat, Content>\n> & {\n fallback?: Content;\n};\n\nexport type EnumerationContent<Content = unknown> = TypedNodeModel<\n NodeType.Enumeration,\n EnumerationContentState<Content>\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to pick a content based on a quantity.\n *\n * Usage:\n *\n * ```ts\n * enu({\n * '<=-2.3': 'You have less than -2.3',\n * '<1': 'You have less than one',\n * '2': 'You have two',\n * '>=3': 'You have three or more',\n * });\n * ```\n *\n * > The order of the keys will define the priority of the content.\n *\n */\nconst enumeration = <Content = unknown>(\n content?: EnumerationContentState<Content>\n) => formatNodeType(NodeType.Enumeration, content);\n\nexport { enumeration as enu };\n"],"mappings":"6JAoDA,MAAM,EACJ,IAAA,EAAA,EAAA,gBACkBA,EAAAA,SAAS,YAAa,EAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"getHTMLCustomComponents.cjs","names":["HTML_TAGS"],"sources":["../../../../src/transpiler/html/getHTMLCustomComponents.ts"],"sourcesContent":["import { HTML_TAGS } from './index';\n\nconst parseAttributes = (attributesString: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n\n if (!attributesString || !attributesString.trim()) {\n return attributes;\n }\n\n // Regex to match attribute names\n // Matches: name=\"value\", name='value', name=value, or just name\n const attrRegex =\n /([a-zA-Z0-9-:_@]+)(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?/g;\n\n const matches = [...attributesString.matchAll(attrRegex)];\n\n matches.forEach((match) => {\n const attrName = match[1];\n attributes[attrName] = 'string';\n });\n\n return attributes;\n};\n\n/**\n * Extracts component names from an HTML string.\n * - Standard HTML tags are set to `true`.\n * - Custom components are parsed to extract their attributes/props.\n */\nexport const getHTMLCustomComponents = (\n content: string\n): Record<string, Record<string, string> | true> => {\n if (typeof content !== 'string') {\n throw new Error('content must be a string');\n }\n\n // Regex to match tags: <Tag ...>, </Tag>, or <Tag ... />\n // Captures: 1: Closing slash (if any), 2: Tag Name, 3: Attributes, 4: Self-closing slash (if any)\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)\\s*([\\s\\S]*?)(\\/?)>/g;\n const matches = [...content.matchAll(tagRegex)];\n\n const components: Record<string, Record<string, string> | true> = {};\n\n matches.forEach((match) => {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attributesString = match[3];\n const isSelfClosing = !!match[4];\n\n // If it's a standard HTML tag, mark it as true and skip prop parsing\n if ((HTML_TAGS as readonly string[]).includes(tagName.toLowerCase())) {\n components[tagName] = true;\n return;\n }\n\n if (!components[tagName]) {\n components[tagName] = {};\n }\n\n // Safety check if we somehow have a collision or logic issue, though loop order handles it\n if (components[tagName] === true) {\n return;\n }\n\n if (isClosing) {\n return;\n }\n\n // Parse attributes for custom components\n const attributes = parseAttributes(attributesString);\n const componentDef = components[tagName] as Record<string, string>;\n Object.assign(componentDef, attributes);\n\n // If not self-closing, assume it has children\n if (!isSelfClosing) {\n componentDef.children = 'string';\n }\n });\n\n return components;\n};\n"],"mappings":"qGAEM,EAAmB,GAAqD,CAC5E,IAAM,EAAqC,EAAE,CAkB7C,MAhBI,CAAC,GAAoB,CAAC,EAAiB,MAAM,EASjC,CAAC,GAAG,EAAiB,SAFnC,6DAEsD,CAAC,CAEjD,QAAS,GAAU,CACzB,IAAM,EAAW,EAAM,GACvB,EAAW,GAAY,UACvB,CAbO,GAuBE,EACX,GACkD,CAClD,GAAI,OAAO,GAAY,SACrB,MAAU,MAAM,2BAA2B,CAM7C,IAAM,EAAU,CAAC,GAAG,EAAQ,SADX,6CAC6B,CAAC,CAEzC,EAA4D,EAAE,CAsCpE,OApCA,EAAQ,QAAS,GAAU,CACzB,IAAM,EAAY,CAAC,CAAC,EAAM,GACpB,EAAU,EAAM,GAChB,EAAmB,EAAM,GACzB,EAAgB,CAAC,CAAC,EAAM,GAG9B,GAAKA,EAAAA,UAAgC,SAAS,EAAQ,aAAa,CAAC,CAAE,CACpE,EAAW,GAAW,GACtB,OAYF,GATK,EAAW,KACd,EAAW,GAAW,EAAE,EAItB,EAAW,KAAa,IAIxB,EACF,OAIF,IAAM,EAAa,EAAgB,EAAiB,CAC9C,EAAe,EAAW,GAChC,OAAO,OAAO,EAAc,EAAW,CAGlC,IACH,EAAa,SAAW,WAE1B,CAEK"}
1
+ {"version":3,"file":"getHTMLCustomComponents.cjs","names":["HTML_TAGS"],"sources":["../../../../src/transpiler/html/getHTMLCustomComponents.ts"],"sourcesContent":["import { HTML_TAGS } from './index';\n\nconst parseAttributes = (attributesString: string): Record<string, string> => {\n const attributes: Record<string, string> = {};\n\n if (!attributesString || !attributesString.trim()) {\n return attributes;\n }\n\n // Regex to match attribute names\n // Matches: name=\"value\", name='value', name=value, or just name\n const attrRegex =\n /([a-zA-Z0-9-:_@]+)(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?/g;\n\n const matches = [...attributesString.matchAll(attrRegex)];\n\n matches.forEach((match) => {\n const attrName = match[1];\n attributes[attrName] = 'string';\n });\n\n return attributes;\n};\n\n/**\n * Extracts component names from an HTML string.\n * - Standard HTML tags are set to `true`.\n * - Custom components are parsed to extract their attributes/props.\n */\nexport const getHTMLCustomComponents = (\n content: string\n): Record<string, Record<string, string> | true> => {\n if (typeof content !== 'string') {\n throw new Error('content must be a string');\n }\n\n // Regex to match tags: <Tag ...>, </Tag>, or <Tag ... />\n // Captures: 1: Closing slash (if any), 2: Tag Name, 3: Attributes, 4: Self-closing slash (if any)\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)\\s*([\\s\\S]*?)(\\/?)>/g;\n const matches = [...content.matchAll(tagRegex)];\n\n const components: Record<string, Record<string, string> | true> = {};\n\n matches.forEach((match) => {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attributesString = match[3];\n const isSelfClosing = !!match[4];\n\n // Component extraction logic\n if ((HTML_TAGS as readonly string[]).includes(tagName.toLowerCase())) {\n components[tagName] = true;\n return;\n }\n\n if (!components[tagName]) {\n components[tagName] = {};\n }\n\n // Safety check if we somehow have a collision or logic issue, though loop order handles it\n if (components[tagName] === true) {\n return;\n }\n\n if (isClosing) {\n return;\n }\n\n // Parse attributes for custom components\n const attributes = parseAttributes(attributesString);\n const componentDef = components[tagName] as Record<string, string>;\n Object.assign(componentDef, attributes);\n\n // If not self-closing, assume it has children\n if (!isSelfClosing) {\n componentDef.children = 'string';\n }\n });\n\n return components;\n};\n"],"mappings":"qGAEM,EAAmB,GAAqD,CAC5E,IAAM,EAAqC,EAAE,CAkB7C,MAhBI,CAAC,GAAoB,CAAC,EAAiB,MAAM,EASjC,CAAC,GAAG,EAAiB,SAFnC,6DAEsD,CAAC,CAEjD,QAAS,GAAU,CACzB,IAAM,EAAW,EAAM,GACvB,EAAW,GAAY,UACvB,CAbO,GAuBE,EACX,GACkD,CAClD,GAAI,OAAO,GAAY,SACrB,MAAU,MAAM,2BAA2B,CAM7C,IAAM,EAAU,CAAC,GAAG,EAAQ,SADX,6CAC6B,CAAC,CAEzC,EAA4D,EAAE,CAsCpE,OApCA,EAAQ,QAAS,GAAU,CACzB,IAAM,EAAY,CAAC,CAAC,EAAM,GACpB,EAAU,EAAM,GAChB,EAAmB,EAAM,GACzB,EAAgB,CAAC,CAAC,EAAM,GAG9B,GAAKA,EAAAA,UAAgC,SAAS,EAAQ,aAAa,CAAC,CAAE,CACpE,EAAW,GAAW,GACtB,OAYF,GATK,EAAW,KACd,EAAW,GAAW,EAAE,EAItB,EAAW,KAAa,IAIxB,EACF,OAIF,IAAM,EAAa,EAAgB,EAAiB,CAC9C,EAAe,EAAW,GAChC,OAAO,OAAO,EAAc,EAAW,CAGlC,IACH,EAAa,SAAW,WAE1B,CAEK"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./getHTMLCustomComponents.cjs`);let t=require(`@intlayer/types/nodeType`);const n=(n,r)=>(0,t.formatNodeType)(t.NodeType.HTML,n,{tags:(()=>{if(r)return r;if(typeof n==`string`)return e.getHTMLCustomComponents(n);let t;if(typeof n==`function`?t=n():typeof n.then==`function`&&(t=async()=>e.getHTMLCustomComponents(await n)),typeof t==`string`)return e.getHTMLCustomComponents(t);try{return e.getHTMLCustomComponents(JSON.stringify(n))}catch{return[]}})()});exports.html=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`./getHTMLCustomComponents.cjs`),t=require(`./validateHTML.cjs`);let n=require(`@intlayer/types/nodeType`);const r=(r,i)=>(0,n.formatNodeType)(n.NodeType.HTML,r,{tags:(()=>{if(i)return i;if(typeof r==`string`){let{issues:n}=t.validateHTML(r);for(let e of n)e.type===`error`?console.error(`[intlayer/html] ${e.message}`):console.warn(`[intlayer/html] ${e.message}`);return e.getHTMLCustomComponents(r)}let n;if(typeof r==`function`?n=r():typeof r.then==`function`&&(n=async()=>e.getHTMLCustomComponents(await r)),typeof n==`string`)return e.getHTMLCustomComponents(n);try{return e.getHTMLCustomComponents(JSON.stringify(r))}catch{return[]}})()});exports.html=r;
2
2
  //# sourceMappingURL=html.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"html.cjs","names":["getHTMLCustomComponents","NodeType"],"sources":["../../../../src/transpiler/html/html.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getHTMLCustomComponents } from './getHTMLCustomComponents';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type HTMLContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<NodeType.HTML, Content, T>;\n\nexport type HTMLContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = HTMLContentConstructor<\n Content,\n {\n tags: string[] | Components;\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to parse HTML/JSX-like strings and replace tags with components during interpretation.\n *\n * Usage:\n *\n * ```ts\n * html('Hello <b>World</b>')\n * ```\n *\n */\nexport const html = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): HTMLContent<Content, Components> => {\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n 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(NodeType.HTML, content, {\n tags: getComponents(),\n });\n};\n"],"mappings":"8MAsCA,MAAa,GAIX,EACA,KA+BA,EAAA,EAAA,gBAAsBC,EAAAA,SAAS,KAAM,EAAS,CAC5C,UA9B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,OAAOD,EAAAA,wBAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,wBAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,wBAAwB,EAAc,CAG/C,GAAI,CACF,OAAOA,EAAAA,wBAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAKU,CACtB,CAAC"}
1
+ {"version":3,"file":"html.cjs","names":["validateHTML","getHTMLCustomComponents","NodeType"],"sources":["../../../../src/transpiler/html/html.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getHTMLCustomComponents } from './getHTMLCustomComponents';\nimport { validateHTML } from './validateHTML';\n\ntype PropsType = 'number' | 'string' | 'node';\n\ntype ComponentName = string;\n\nexport type HTMLContentConstructor<\n Content = unknown,\n T extends Record<string, any> = {},\n> = TypedNodeModel<NodeType.HTML, Content, T>;\n\nexport type HTMLContent<\n Content = unknown,\n Components extends Record<ComponentName, PropsType> = Record<\n ComponentName,\n PropsType\n >,\n> = HTMLContentConstructor<\n Content,\n {\n tags: string[] | Components;\n }\n>;\n\n/**\n * Function intended to be used to build intlayer dictionaries.\n *\n * Allow to parse HTML/JSX-like strings and replace tags with components during interpretation.\n *\n * Usage:\n *\n * ```ts\n * html('Hello <b>World</b>')\n * ```\n *\n */\nexport const html = <\n Components extends Record<string, any> = Record<string, any>,\n Content = unknown,\n>(\n content: Content,\n components?: Components\n): HTMLContent<Content, Components> => {\n const getComponents = () => {\n if (components) {\n return components;\n }\n\n if (typeof content === 'string') {\n const { issues } = validateHTML(content);\n\n for (const issue of issues) {\n if (issue.type === 'error') {\n console.error(`[intlayer/html] ${issue.message}`);\n } else {\n console.warn(`[intlayer/html] ${issue.message}`);\n }\n }\n\n return getHTMLCustomComponents(content);\n }\n\n let stringContent: any;\n\n if (typeof content === 'function') {\n stringContent = content();\n } else if (typeof (content as Promise<string>).then === 'function') {\n stringContent = async () =>\n getHTMLCustomComponents((await (content as Promise<string>)) as string);\n }\n\n if (typeof stringContent === 'string') {\n return getHTMLCustomComponents(stringContent);\n }\n\n try {\n return getHTMLCustomComponents(JSON.stringify(content));\n } catch (_e) {\n return [];\n }\n };\n\n return formatNodeType(NodeType.HTML, content, {\n tags: getComponents(),\n });\n};\n"],"mappings":"8OAuCA,MAAa,GAIX,EACA,KAyCA,EAAA,EAAA,gBAAsBE,EAAAA,SAAS,KAAM,EAAS,CAC5C,UAxC0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SAAU,CAC/B,GAAM,CAAE,UAAWF,EAAAA,aAAa,EAAQ,CAExC,IAAK,IAAM,KAAS,EACd,EAAM,OAAS,QACjB,QAAQ,MAAM,mBAAmB,EAAM,UAAU,CAEjD,QAAQ,KAAK,mBAAmB,EAAM,UAAU,CAIpD,OAAOC,EAAAA,wBAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,wBAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,wBAAwB,EAAc,CAG/C,GAAI,CACF,OAAOA,EAAAA,wBAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAKU,CACtB,CAAC"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./html.cjs`),t=require(`./htmlTags.cjs`);exports.HTML_TAGS=t.HTML_TAGS,exports.html=e.html;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./validateHTML.cjs`),t=require(`./html.cjs`),n=require(`./htmlTags.cjs`);exports.HTML_TAGS=n.HTML_TAGS,exports.VOID_ELEMENTS=e.VOID_ELEMENTS,exports.html=t.html,exports.validateHTML=e.validateHTML;
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`source`,`track`,`wbr`]),t=/<(\/)?([a-zA-Z][a-zA-Z0-9.-]*)\s*((?:[^\n]|\n(?!\n))*?)(\/?)>/g,n=n=>{let r=[],i=[];for(let a of n.matchAll(t)){let t=!!a[1],n=a[2],o=a[3],s=!!a[4];if(!(o.trimStart().startsWith(`://`)||o.trimStart().startsWith(`:`)))if(t)if(i.length===0)r.push({type:`error`,message:`Closing tag </${n}> has no matching opening tag`});else{let e=i[i.length-1];e.tag.toLowerCase()!==n.toLowerCase()&&r.push({type:`error`,message:`Mismatched closing tag: expected </${e.tag}> but found </${n}>`}),i.pop()}else{let t=e.has(n.toLowerCase());!s&&!t&&i.push({tag:n})}}for(let e of i)r.push({type:`error`,message:`Unclosed HTML tag: <${e.tag}>`});return{valid:r.filter(e=>e.type===`error`).length===0,issues:r}};exports.VOID_ELEMENTS=e,exports.validateHTML=n;
2
+ //# sourceMappingURL=validateHTML.cjs.map
@@ -0,0 +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":"mEAAA,MAAa,EAAgB,IAAI,IAAI,CACnC,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,OACA,OACA,SACA,QACA,MACD,CAAC,CAgBI,EACJ,iEASW,EAAgB,GAA0C,CACrE,IAAM,EAAgC,EAAE,CAClC,EAAgC,EAAE,CAExC,IAAK,IAAM,KAAS,EAAQ,SAAS,EAAU,CAAE,CAC/C,IAAM,EAAY,CAAC,CAAC,EAAM,GACpB,EAAU,EAAM,GAChB,EAAQ,EAAM,GACd,EAAgB,CAAC,CAAC,EAAM,GAI5B,OAAM,WAAW,CAAC,WAAW,MAAM,EACnC,EAAM,WAAW,CAAC,WAAW,IAAI,EAKnC,GAAI,EACF,GAAI,EAAM,SAAW,EACnB,EAAO,KAAK,CACV,KAAM,QACN,QAAS,iBAAiB,EAAQ,+BACnC,CAAC,KACG,CACL,IAAM,EAAO,EAAM,EAAM,OAAS,GAC9B,EAAK,IAAI,aAAa,GAAK,EAAQ,aAAa,EAClD,EAAO,KAAK,CACV,KAAM,QACN,QAAS,sCAAsC,EAAK,IAAI,gBAAgB,EAAQ,GACjF,CAAC,CAEJ,EAAM,KAAK,KAER,CACL,IAAM,EAAgB,EAAc,IAAI,EAAQ,aAAa,CAAC,CAC1D,CAAC,GAAiB,CAAC,GACrB,EAAM,KAAK,CAAE,IAAK,EAAS,CAAC,EAKlC,IAAK,IAAM,KAAY,EACrB,EAAO,KAAK,CACV,KAAM,QACN,QAAS,uBAAuB,EAAS,IAAI,GAC9C,CAAC,CAGJ,MAAO,CACL,MAAO,EAAO,OAAQ,GAAM,EAAE,OAAS,QAAQ,CAAC,SAAW,EAC3D,SACD"}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./condition/condition.cjs`),t=require(`./enumeration/enumeration.cjs`),n=require(`./gender/gender.cjs`),r=require(`./html/html.cjs`),i=require(`./html/htmlTags.cjs`),a=require(`./insertion/getInsertionValues.cjs`),o=require(`./insertion/insertion.cjs`),s=require(`./markdown/getMarkdownMetadata.cjs`),c=require(`./markdown/markdown.cjs`),l=require(`./nesting/nesting.cjs`),u=require(`./translation/translation.cjs`);exports.HTML_TAGS=i.HTML_TAGS,exports.cond=e.cond,exports.enu=t.enu,exports.gender=n.gender,exports.getInsertionValues=a.getInsertionValues,exports.getMarkdownMetadata=s.getMarkdownMetadata,exports.html=r.html,exports.insert=o.insert,exports.md=c.md,exports.nest=l.nest,exports.t=u.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./condition/condition.cjs`),t=require(`./enumeration/enumeration.cjs`),n=require(`./gender/gender.cjs`),r=require(`./html/validateHTML.cjs`),i=require(`./html/html.cjs`),a=require(`./html/htmlTags.cjs`),o=require(`./insertion/getInsertionValues.cjs`),s=require(`./insertion/insertion.cjs`),c=require(`./markdown/getMarkdownMetadata.cjs`),l=require(`./markdown/validateMarkdown.cjs`),u=require(`./markdown/markdown.cjs`),d=require(`./nesting/nesting.cjs`),f=require(`./translation/translation.cjs`);exports.HTML_TAGS=a.HTML_TAGS,exports.VOID_ELEMENTS=r.VOID_ELEMENTS,exports.cond=e.cond,exports.enu=t.enu,exports.gender=n.gender,exports.getInsertionValues=o.getInsertionValues,exports.getMarkdownMetadata=c.getMarkdownMetadata,exports.html=i.html,exports.insert=s.insert,exports.md=u.md,exports.nest=d.nest,exports.t=f.t,exports.validateHTML=r.validateHTML,exports.validateMarkdown=l.validateMarkdown;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getMarkdownMetadata.cjs`),t=require(`./markdown.cjs`);exports.getMarkdownMetadata=e.getMarkdownMetadata,exports.md=t.md;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./getMarkdownMetadata.cjs`),t=require(`./validateMarkdown.cjs`),n=require(`./markdown.cjs`);exports.getMarkdownMetadata=e.getMarkdownMetadata,exports.md=n.md,exports.validateMarkdown=t.validateMarkdown;
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../interpreter/getContent/getContent.cjs`),t=require(`../html/getHTMLCustomComponents.cjs`),n=require(`./getMarkdownMetadata.cjs`);let r=require(`@intlayer/types/nodeType`);const i=async e=>{if(typeof e==`string`||typeof e==`object`)return e;if(typeof e==`function`)return e();if(typeof e.then==`function`)return await e},a=(a,o)=>(0,r.formatNodeType)(r.NodeType.Markdown,a,{metadata:async()=>{let t=e.getContent(await i(a),{dictionaryKey:``,keyPath:[]});if(typeof t==`string`)return n.getMarkdownMetadata(t)},tags:(()=>{if(o)return o;if(typeof a==`string`)return t.getHTMLCustomComponents(a);let e;if(typeof a==`function`?e=a():typeof a.then==`function`&&(e=async()=>t.getHTMLCustomComponents(await a)),typeof e==`string`)return t.getHTMLCustomComponents(e);try{return t.getHTMLCustomComponents(JSON.stringify(a))}catch{return[]}})()});exports.md=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../interpreter/getContent/getContent.cjs`),t=require(`../html/getHTMLCustomComponents.cjs`),n=require(`./getMarkdownMetadata.cjs`),r=require(`./validateMarkdown.cjs`);let i=require(`@intlayer/types/nodeType`);const a=async e=>{if(typeof e==`string`||typeof e==`object`)return e;if(typeof e==`function`)return e();if(typeof e.then==`function`)return await e},o=(o,s)=>(0,i.formatNodeType)(i.NodeType.Markdown,o,{metadata:async()=>{let t=e.getContent(await a(o),{dictionaryKey:``,keyPath:[]});if(typeof t==`string`){if(process.env.NODE_ENV!==`production`){let{issues:e}=r.validateMarkdown(t);for(let t of e)t.type===`error`?console.error(`[intlayer/markdown] ${t.message}`):console.warn(`[intlayer/markdown] ${t.message}`)}return n.getMarkdownMetadata(t)}},tags:(()=>{if(s)return s;if(typeof o==`string`)return t.getHTMLCustomComponents(o);let e;if(typeof o==`function`?e=o():typeof o.then==`function`&&(e=async()=>t.getHTMLCustomComponents(await o)),typeof e==`string`)return t.getHTMLCustomComponents(e);try{return t.getHTMLCustomComponents(JSON.stringify(o))}catch{return[]}})()});exports.md=o;
2
2
  //# sourceMappingURL=markdown.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.cjs","names":["getContent","getMarkdownMetadata","getHTMLCustomComponents","NodeType"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } from '@intlayer/types/nodeType';\nimport { getContent } from '../../interpreter/getContent/getContent';\nimport { getHTMLCustomComponents } from '../html/getHTMLCustomComponents';\nimport { getMarkdownMetadata } from './getMarkdownMetadata';\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<NodeType.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 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(NodeType.Markdown, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":"oTA6BA,MAAM,EAAe,KAAO,IAAiB,CAC3C,GAAI,OAAO,GAAY,UAAY,OAAO,GAAY,SACpD,OAAO,EAGT,GAAI,OAAO,GAAY,WACrB,OAAO,GAAS,CAElB,GAAI,OAAO,EAAQ,MAAS,WAC1B,OAAO,MAAM,GAgBX,GAIJ,EACA,KA4CA,EAAA,EAAA,gBAAsBG,EAAAA,SAAS,SAAU,EAAS,CAChD,SA3Ce,SAAY,CAG3B,IAAM,EAAcH,EAAAA,WAFG,MAAM,EAAa,EAAQ,CAEH,CAC7C,cAAe,GACf,QAAS,EAAE,CACZ,CAAC,CAEF,GAAI,OAAO,GAAgB,SACzB,OAAOC,EAAAA,oBAAoB,EAAY,EAmCzC,UA/B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,OAAOC,EAAAA,wBAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,wBAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,wBAAwB,EAAc,CAG/C,GAAI,CACF,OAAOA,EAAAA,wBAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAMU,CACtB,CAAC"}
1
+ {"version":3,"file":"markdown.cjs","names":["getContent","validateMarkdown","getMarkdownMetadata","getHTMLCustomComponents","NodeType"],"sources":["../../../../src/transpiler/markdown/markdown.ts"],"sourcesContent":["import type { TypedNodeModel } from '@intlayer/types/nodeType';\nimport { formatNodeType, NodeType } 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<NodeType.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(NodeType.Markdown, content, {\n metadata,\n tags: getComponents(),\n });\n};\n\nexport { markdown as md };\n"],"mappings":"wVA8BA,MAAM,EAAe,KAAO,IAAiB,CAC3C,GAAI,OAAO,GAAY,UAAY,OAAO,GAAY,SACpD,OAAO,EAGT,GAAI,OAAO,GAAY,WACrB,OAAO,GAAS,CAElB,GAAI,OAAO,EAAQ,MAAS,WAC1B,OAAO,MAAM,GAgBX,GAIJ,EACA,KAuDA,EAAA,EAAA,gBAAsBI,EAAAA,SAAS,SAAU,EAAS,CAChD,SAtDe,SAAY,CAG3B,IAAM,EAAcJ,EAAAA,WAFG,MAAM,EAAa,EAAQ,CAEH,CAC7C,cAAe,GACf,QAAS,EAAE,CACZ,CAAC,CAEF,GAAI,OAAO,GAAgB,SAAU,CACnC,GAAI,QAAQ,IAAI,WAAa,aAAc,CACzC,GAAM,CAAE,UAAWC,EAAAA,iBAAiB,EAAY,CAChD,IAAK,IAAM,KAAS,EACd,EAAM,OAAS,QACjB,QAAQ,MAAM,uBAAuB,EAAM,UAAU,CAErD,QAAQ,KAAK,uBAAuB,EAAM,UAAU,CAK1D,OAAOC,EAAAA,oBAAoB,EAAY,GAmCzC,UA/B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,OAAOC,EAAAA,wBAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACdA,EAAAA,wBAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAOA,EAAAA,wBAAwB,EAAc,CAG/C,GAAI,CACF,OAAOA,EAAAA,wBAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAMU,CACtB,CAAC"}
@@ -0,0 +1,5 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../html/validateHTML.cjs`),t=e=>{let t=e.split(`
2
+ `),n=[],r=!1,i=null;for(let e of t){let t=e.match(/^[\s>]*(`{3,}|~{3,})/);r?(t&&t[1][0]===i[0]&&t[1].length>=i.length&&(r=!1,i=null),n.push(``)):t?(r=!0,i=t[1],n.push(``)):n.push(e.replace(/`[^`\n]+`/g,e=>` `.repeat(e.length)))}return n.join(`
3
+ `)},n=e=>{let t=[],n=e.split(`
4
+ `),r=!1,i=null,a=-1;for(let e=0;e<n.length;e++){let t=n[e].match(/^[\s>]*(`{3,}|~{3,})/);r?t&&t[1][0]===i[0]&&t[1].length>=i.length&&(r=!1,i=null):t&&(r=!0,i=t[1],a=e+1)}return r&&t.push({type:`error`,message:`Unclosed code block (opened at line ${a})`}),t},r=r=>{let i=n(r),a=e.validateHTML(t(r)).issues,o=[...i,...a];return{valid:o.filter(e=>e.type===`error`).length===0,issues:o}};exports.validateMarkdown=r;
5
+ //# sourceMappingURL=validateMarkdown.cjs.map
@@ -0,0 +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":"+GAaM,EAAa,GAA4B,CAC7C,IAAM,EAAQ,EAAQ,MAAM;EAAK,CAC3B,EAAmB,EAAE,CACvB,EAAc,GACd,EAA2B,KAE/B,IAAK,IAAM,KAAQ,EAAO,CAExB,IAAM,EAAQ,EAAK,MAAM,uBAAuB,CAC3C,GAWD,GACA,EAAM,GAAG,KAAO,EAAW,IAC3B,EAAM,GAAG,QAAU,EAAW,SAE9B,EAAc,GACd,EAAY,MAEd,EAAO,KAAK,GAAG,EAjBX,GACF,EAAc,GACd,EAAY,EAAM,GAClB,EAAO,KAAK,GAAG,EAGf,EAAO,KAAK,EAAK,QAAQ,aAAe,GAAM,IAAI,OAAO,EAAE,OAAO,CAAC,CAAC,CAe1E,OAAO,EAAO,KAAK;EAAK,EAGpB,EAAsB,GAA2C,CACrE,IAAM,EAAgC,EAAE,CAClC,EAAQ,EAAQ,MAAM;EAAK,CAC7B,EAAc,GACd,EAA2B,KAC3B,EAAiB,GAErB,IAAK,IAAI,EAAI,EAAG,EAAI,EAAM,OAAQ,IAAK,CAGrC,IAAM,EAFO,EAAM,GAEA,MAAM,uBAAuB,CAE3C,EAQD,GACA,EAAM,GAAG,KAAO,EAAW,IAC3B,EAAM,GAAG,QAAU,EAAW,SAE9B,EAAc,GACd,EAAY,MAZV,IACF,EAAc,GACd,EAAY,EAAM,GAClB,EAAiB,EAAI,GAqB3B,OAPI,GACF,EAAO,KAAK,CACV,KAAM,QACN,QAAS,uCAAuC,EAAe,GAChE,CAAC,CAGG,GAUI,EAAoB,GAA8C,CAC7E,IAAM,EAAa,EAAmB,EAAQ,CACxC,EAAaA,EAAAA,aAAa,EAAU,EAAQ,CAAC,CAAC,OAC9C,EAAS,CAAC,GAAG,EAAY,GAAG,EAAW,CAE7C,MAAO,CACL,MAAO,EAAO,OAAQ,GAAM,EAAE,OAAS,QAAQ,CAAC,SAAW,EAC3D,SACD"}