@intlayer/core 8.3.0 → 8.3.2

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 (71) 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 +1 -1
  16. package/dist/cjs/transpiler/html/getHTMLCustomComponents.cjs.map +1 -1
  17. package/dist/cjs/transpiler/html/index.cjs +1 -1
  18. package/dist/cjs/transpiler/html/validateHTML.cjs +2 -0
  19. package/dist/cjs/transpiler/html/validateHTML.cjs.map +1 -0
  20. package/dist/cjs/transpiler/index.cjs +1 -1
  21. package/dist/cjs/transpiler/markdown/index.cjs +1 -1
  22. package/dist/cjs/transpiler/markdown/markdown.cjs +1 -1
  23. package/dist/cjs/transpiler/markdown/markdown.cjs.map +1 -1
  24. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs +5 -0
  25. package/dist/cjs/transpiler/markdown/validateMarkdown.cjs.map +1 -0
  26. package/dist/esm/index.mjs +1 -1
  27. package/dist/esm/interpreter/getContent/getContent.mjs +1 -1
  28. package/dist/esm/interpreter/getContent/getContent.mjs.map +1 -1
  29. package/dist/esm/interpreter/getContent/index.mjs +1 -1
  30. package/dist/esm/interpreter/getContent/plugins.mjs +1 -1
  31. package/dist/esm/interpreter/getContent/plugins.mjs.map +1 -1
  32. package/dist/esm/interpreter/getDictionary.mjs +1 -1
  33. package/dist/esm/interpreter/getDictionary.mjs.map +1 -1
  34. package/dist/esm/interpreter/getHTML.mjs +1 -1
  35. package/dist/esm/interpreter/getHTML.mjs.map +1 -1
  36. package/dist/esm/interpreter/getIntlayer.mjs.map +1 -1
  37. package/dist/esm/interpreter/index.mjs +1 -1
  38. package/dist/esm/markdown/index.mjs +1 -1
  39. package/dist/esm/transpiler/enumeration/enumeration.mjs.map +1 -1
  40. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs +1 -1
  41. package/dist/esm/transpiler/html/getHTMLCustomComponents.mjs.map +1 -1
  42. package/dist/esm/transpiler/html/index.mjs +1 -1
  43. package/dist/esm/transpiler/html/validateHTML.mjs +2 -0
  44. package/dist/esm/transpiler/html/validateHTML.mjs.map +1 -0
  45. package/dist/esm/transpiler/index.mjs +1 -1
  46. package/dist/esm/transpiler/markdown/index.mjs +1 -1
  47. package/dist/esm/transpiler/markdown/markdown.mjs.map +1 -1
  48. package/dist/esm/transpiler/markdown/validateMarkdown.mjs +5 -0
  49. package/dist/esm/transpiler/markdown/validateMarkdown.mjs.map +1 -0
  50. package/dist/types/index.d.ts +4 -2
  51. package/dist/types/interpreter/getContent/getContent.d.ts +4 -3
  52. package/dist/types/interpreter/getContent/getContent.d.ts.map +1 -1
  53. package/dist/types/interpreter/getContent/index.d.ts +2 -2
  54. package/dist/types/interpreter/getContent/plugins.d.ts.map +1 -1
  55. package/dist/types/interpreter/getDictionary.d.ts.map +1 -1
  56. package/dist/types/interpreter/getHTML.d.ts.map +1 -1
  57. package/dist/types/interpreter/getIntlayer.d.ts.map +1 -1
  58. package/dist/types/interpreter/index.d.ts +2 -2
  59. package/dist/types/markdown/index.d.ts +3 -1
  60. package/dist/types/transpiler/enumeration/enumeration.d.ts +1 -1
  61. package/dist/types/transpiler/enumeration/enumeration.d.ts.map +1 -1
  62. package/dist/types/transpiler/html/getHTMLCustomComponents.d.ts.map +1 -1
  63. package/dist/types/transpiler/html/index.d.ts +2 -1
  64. package/dist/types/transpiler/html/validateHTML.d.ts +21 -0
  65. package/dist/types/transpiler/html/validateHTML.d.ts.map +1 -0
  66. package/dist/types/transpiler/index.d.ts +3 -1
  67. package/dist/types/transpiler/markdown/index.d.ts +3 -1
  68. package/dist/types/transpiler/markdown/markdown.d.ts.map +1 -1
  69. package/dist/types/transpiler/markdown/validateMarkdown.d.ts +18 -0
  70. package/dist/types/transpiler/markdown/validateMarkdown.d.ts.map +1 -0
  71. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"getContent.mjs","names":[],"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":"qQAwBA,MAAa,GAIX,EACA,EACA,EACA,IACG,CACH,IAAM,EAAgB,GAAe,sBAAsB,cAErD,EAAqB,CACzB,EACE,GAAU,EACV,EAAW,EAAgB,IAAA,GAC5B,CACD,EACA,EACA,EAAa,GAAU,EAAc,CACrC,EACA,EACA,EACA,GAAI,EAAU,SAAW,EAAE,CAC5B,CAED,OAAO,EAAkB,EAAM,CAC7B,GAAG,EACH,UACD,CAAC"}
1
+ {"version":3,"file":"getContent.mjs","names":[],"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":"qQAqBA,MAAa,GACX,EACA,EAAoB,KACN,CACd,EACE,GAAU,EAAc,qBAAqB,cAC7C,EAAW,EAAc,qBAAqB,cAAgB,IAAA,GAC/D,CACD,EACA,EACA,EACA,EAAa,GAAU,EAAc,qBAAqB,cAAc,CACxE,EACA,EACD,CAQY,GAIX,EACA,EACA,EAAqB,EAAE,GAEvB,EAAkB,EAAM,CACtB,GAAG,EACH,UACD,CAAC"}
@@ -1 +1 @@
1
- import{deepTransformNode as e}from"./deepTransform.mjs";import{conditionPlugin as t,enumerationPlugin as n,filePlugin as r,genderPlugin as i,insertionPlugin as a,nestedPlugin as o,translationPlugin as s}from"./plugins.mjs";import{getContent as c}from"./getContent.mjs";export{t as conditionPlugin,e as deepTransformNode,n as enumerationPlugin,r as filePlugin,i as genderPlugin,c as getContent,a as insertionPlugin,o as nestedPlugin,s as translationPlugin};
1
+ import{deepTransformNode as e}from"./deepTransform.mjs";import{conditionPlugin as t,enumerationPlugin as n,filePlugin as r,genderPlugin as i,insertionPlugin as a,nestedPlugin as o,translationPlugin as s}from"./plugins.mjs";import{getBasePlugins as c,getContent as l}from"./getContent.mjs";export{t as conditionPlugin,e as deepTransformNode,n as enumerationPlugin,r as filePlugin,i as genderPlugin,c as getBasePlugins,l as getContent,a as insertionPlugin,o as nestedPlugin,s as translationPlugin};
@@ -1,2 +1,2 @@
1
- import{getCondition as e}from"../getCondition.mjs";import{getEnumeration as t}from"../getEnumeration.mjs";import{getGender as n}from"../getGender.mjs";import{getInsertion as r}from"../getInsertion.mjs";import{getNesting as i}from"../getNesting.mjs";import{getTranslation as a}from"../getTranslation.mjs";import{NodeType as o}from"@intlayer/types/nodeType";const s=(e,t)=>({id:`translation-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Translation,transform:(n,r,i)=>{let s=structuredClone(n[o.Translation]);for(let e in s){let t={...r,children:s[e],keyPath:[...r.keyPath,{type:o.Translation,key:e}]};s[e]=i(s[e],t)}return a(s,e,t)}}),c={id:`enumeration-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Enumeration,transform:(e,n,r)=>{let i=structuredClone(e[o.Enumeration]);for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.Enumeration,key:e}]})}return e=>{let n=t(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.Condition,transform:(t,n,r)=>{let i=structuredClone(t[o.Condition]);for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.Condition,key:e}]})}return t=>{let n=e(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.Insertion,transform:(e,t,n)=>{let i=[...t.keyPath,{type:o.Insertion}],a=e[o.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(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.Gender,transform:(e,t,r)=>{let i=structuredClone(e[o.Gender]);for(let e in i){let n=i[e];i[e]=r(n,{...t,children:n,keyPath:[...t.keyPath,{type:o.Gender,key:e}]})}return e=>n(i,e)}},f=e=>({id:`nested-plugin`,canHandle:e=>typeof e==`object`&&(e?.nodeType===o.Nested||e?.nodeType===`nested`),transform:(t,n)=>i(t.nested.dictionaryKey,t.nested.path,{...n,locale:e??n.locale})}),p={id:`file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.File,transform:(e,t,n)=>n(e.content,{...t,children:e.content})};export{l as conditionPlugin,c as enumerationPlugin,p as filePlugin,d as genderPlugin,u as insertionPlugin,f as nestedPlugin,s as translationPlugin};
1
+ import{getCondition as e}from"../getCondition.mjs";import{getEnumeration as t}from"../getEnumeration.mjs";import{getGender as n}from"../getGender.mjs";import{getInsertion as r}from"../getInsertion.mjs";import{getNesting as i}from"../getNesting.mjs";import{getTranslation as a}from"../getTranslation.mjs";import{NodeType as o}from"@intlayer/types/nodeType";const s=(e,t)=>({id:`translation-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Translation,transform:(n,r,i)=>{let s={...n[o.Translation]??{}};for(let e in s){let t={...r,children:s[e],keyPath:[...r.keyPath,{type:o.Translation,key:e}]};s[e]=i(s[e],t)}return a(s,e,t)}}),c={id:`enumeration-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.Enumeration,transform:(e,n,r)=>{let i={...e[o.Enumeration]};for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.Enumeration,key:e}]})}return e=>{let n=t(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.Condition,transform:(t,n,r)=>{let i={...t[o.Condition]};for(let e in i){let t=i[e];i[e]=r(t,{...n,children:t,keyPath:[...n.keyPath,{type:o.Condition,key:e}]})}return t=>{let n=e(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.Insertion,transform:(e,t,n)=>{let i=[...t.keyPath,{type:o.Insertion}],a=e[o.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(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.Gender,transform:(e,t,r)=>{let i={...e[o.Gender]};for(let e in i){let n=i[e];i[e]=r(n,{...t,children:n,keyPath:[...t.keyPath,{type:o.Gender,key:e}]})}return e=>n(i,e)}},f=e=>({id:`nested-plugin`,canHandle:e=>typeof e==`object`&&(e?.nodeType===o.Nested||e?.nodeType===`nested`),transform:(t,n)=>i(t.nested.dictionaryKey,t.nested.path,{...n,locale:e??n.locale})}),p={id:`file-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===o.File,transform:(e,t,n)=>n(e.content,{...t,children:e.content})};export{l as conditionPlugin,c as enumerationPlugin,p as filePlugin,d as genderPlugin,u as insertionPlugin,f as nestedPlugin,s as translationPlugin};
2
2
  //# sourceMappingURL=plugins.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"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":"oWA+EA,MAAa,GACX,EACA,KACa,CACb,GAAI,qBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAS,gBAAgB,EAAK,EAAS,aAAa,CAE1D,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAO,GACjB,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,YAAa,MAAK,CACpC,CACF,CACD,EAAO,GAA8B,EACnC,EAAO,GACP,EACD,CAGH,OAAO,EAAe,EAAQ,EAAQ,EAAS,EAElD,EAmBY,EAA6B,CACxC,GAAI,qBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAS,gBAAgB,EAAK,EAAS,aAAa,CAE1D,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAQ,EAAO,GASrB,EAAO,GAAyC,EAC9C,EATiB,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,YAAa,MAAK,CACpC,CACF,CAIA,CAGH,MAAQ,IAAoC,CAE1C,IAAM,EAAY,EAAe,EADhB,OAAO,GAAQ,SAAW,EAAM,EAAI,MACH,CAMlD,OAJI,OAAO,GAAc,YAAc,OAAO,GAAQ,SAC7C,EAAU,EAAI,CAGhB,IAGZ,CAmBY,EAA2B,CACtC,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,UAC1D,WAAY,EAAwB,EAAO,IAAsB,CAC/D,IAAM,EAAS,gBAAgB,EAAK,EAAS,WAAW,CAExD,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,E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O,GAMrB,EAAO,GAA8B,EAAkB,EALpC,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAS,OAAQ,MAAK,CAAY,CACvE,CACwE,CAG3E,MAAQ,IAAkB,EAAU,EAAQ,EAAM,EAErD,CAmBY,EAAgB,IAAqC,CAChE,GAAI,gBACJ,UAAY,GACV,OAAO,GAAS,WACf,GAAM,WAAa,EAAS,QAAU,GAAM,WAAa,UAC5D,WAAY,EAAqB,IAC/B,EAAW,EAAK,OAAO,cAAe,EAAK,OAAO,KAAM,CACtD,GAAG,EACH,OAAS,GAAU,EAAM,OAC1B,CAAC,CACL,EAeY,EAAsB,CACjC,GAAI,cACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,KAC1D,WAAY,EAAmB,EAAO,IACpC,EAAc,EAAK,QAAS,CAC1B,GAAG,EACH,SAAU,EAAK,QAChB,CAAC,CACL"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"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":"oWA+EA,MAAa,GACX,EACA,KACa,CACb,GAAI,qBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAS,CACb,GAAI,EAAK,EAAS,cAAgB,EAAE,CACrC,CAED,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAa,CACjB,GAAG,EACH,SAAU,EAAO,GACjB,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,YAAa,MAAK,CACpC,CACF,CACD,EAAO,GAA8B,EACnC,EAAO,GACP,EACD,CAGH,OAAO,EAAe,EAAQ,EAAQ,EAAS,EAElD,EAmBY,EAA6B,CACxC,GAAI,qBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,YAC1D,WAAY,EAA0B,EAAO,IAAsB,CACjE,IAAM,EAAS,CAAE,GAAG,EAAK,EAAS,aAAc,CAEhD,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAQ,EAAO,GASrB,EAAO,GAAyC,EAC9C,EATiB,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CACP,GAAG,EAAM,QACT,CAAE,KAAM,EAAS,YAAa,MAAK,CACpC,CACF,CAIA,CAGH,MAAQ,IAAoC,CAE1C,IAAM,EAAY,EAAe,EADhB,OAAO,GAAQ,SAAW,EAAM,EAAI,MACH,CAMlD,OAJI,OAAO,GAAc,YAAc,OAAO,GAAQ,SAC7C,EAAU,EAAI,CAGhB,IAGZ,CAmBY,EAA2B,CACtC,GAAI,mBACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,UAC1D,WAAY,EAAwB,EAAO,IAAsB,CA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AAM,EAAS,CAAE,GAAG,EAAK,EAAS,QAAS,CAE3C,IAAK,IAAM,KAAO,EAAQ,CACxB,IAAM,EAAQ,EAAO,GAMrB,EAAO,GAA8B,EAAkB,EALpC,CACjB,GAAG,EACH,SAAU,EACV,QAAS,CAAC,GAAG,EAAM,QAAS,CAAE,KAAM,EAAS,OAAQ,MAAK,CAAY,CACvE,CACwE,CAG3E,MAAQ,IAAkB,EAAU,EAAQ,EAAM,EAErD,CAmBY,EAAgB,IAAqC,CAChE,GAAI,gBACJ,UAAY,GACV,OAAO,GAAS,WACf,GAAM,WAAa,EAAS,QAAU,GAAM,WAAa,UAC5D,WAAY,EAAqB,IAC/B,EAAW,EAAK,OAAO,cAAe,EAAK,OAAO,KAAM,CACtD,GAAG,EACH,OAAS,GAAU,EAAM,OAC1B,CAAC,CACL,EAeY,EAAsB,CACjC,GAAI,cACJ,UAAY,GACV,OAAO,GAAS,UAAY,GAAM,WAAa,EAAS,KAC1D,WAAY,EAAmB,EAAO,IACpC,EAAc,EAAK,QAAS,CAC1B,GAAG,EACH,SAAU,EAAK,QAChB,CAAC,CACL"}
@@ -1,2 +1,2 @@
1
- import{getContent as e}from"./getContent/getContent.mjs";const t=(t,n,r)=>{let i={dictionaryKey:t.key,dictionaryPath:t.filePath,keyPath:[],plugins:r};return e(t.content,i,n,!0)};export{t as getDictionary};
1
+ import{getBasePlugins as e,getContent as t}from"./getContent/getContent.mjs";const n=(n,r,i=e(r))=>{let a={dictionaryKey:n.key,dictionaryPath:n.filePath,keyPath:[],plugins:i};return t(n.content,a,i)};export{n as getDictionary};
2
2
  //# sourceMappingURL=getDictionary.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.mjs","names":[],"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":"yDAkBA,MAAa,GAIX,EACA,EACA,IACmE,CACnE,IAAM,EAAmB,CACvB,cAAe,EAAW,IAC1B,eAAgB,EAAW,SAC3B,QAAS,EAAE,CACX,UACD,CAED,OAAO,EAAW,EAAW,QAAS,EAAO,EAAQ,GAAK"}
1
+ {"version":3,"file":"getDictionary.mjs","names":[],"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":"6EAqBA,MAAa,GAIX,EACA,EACA,EAAqB,EAAe,EAAO,GACwB,CACnE,IAAM,EAAmB,CACvB,cAAe,EAAW,IAC1B,eAAgB,EAAW,SAC3B,QAAS,EAAE,CACX,UACD,CAED,OAAO,EAAW,EAAW,QAAS,EAAO,EAAQ"}
@@ -1,2 +1,2 @@
1
- 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};export{r as getHTML};
1
+ 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};export{r as getHTML};
2
2
  //# sourceMappingURL=getHTML.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getHTML.mjs","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":"AA2BA,MAAM,EAAmB,GAA+C,CACtE,IAAM,EAAgC,EAAE,CAClC,EAAY,6BAEd,EAAQ,EAAU,KAAK,EAAW,CACtC,KAAO,IAAU,MACf,EAAM,EAAM,IAAM,EAAM,GACxB,EAAQ,EAAU,KAAK,EAAW,CAEpC,OAAO,GAWH,EAAW,IAAI,IAEf,EAAa,GAA+B,CAChD,GAAI,EAAS,IAAI,EAAQ,CACvB,OAAO,EAAS,IAAI,EAAQ,CAG9B,GAAI,OAAO,GAAY,SACrB,MAAO,EAAE,CAGX,IAAM,EAAW,0CACX,EAAsB,EAAE,CACxB,EAIA,EAAE,CAEJ,EAAY,EACZ,EAAQ,EAAS,KAAK,EAAQ,CAE5B,EAAe,GAAmB,EAEpC,EAAM,OAAS,EAAI,EAAM,EAAM,OAAS,GAAG,SAAW,GACjD,KAAK,EAAM,EAGpB,KAAO,IAAU,MAAM,CACrB,GAAM,CAAC,EAAW,EAAc,EAAS,EAAe,GACtD,EACI,EAAa,EAAM,MAErB,EAAa,GACf,EAAY,EAAQ,MAAM,EAAW,EAAW,CAAC,CAGnD,IAAM,EAAY,IAAiB,IAC7B,EACJ,IAAqB,KACrB,EAAc,MAAM,CAAC,SAAS,IAAI,EAClC,EAAU,SAAS,KAAK,CAEpB,EAAoB,EAAc,MAAM,CAAC,QAAQ,MAAO,GAAG,CAAC,MAAM,CAExE,GAAI,EAAW,CACb,IAAM,EAAO,EAAM,KAAK,CAEpB,GACF,EAAY,CACV,QAAS,EAAK,QACd,MAAO,EAAK,MACZ,SAAU,EAAK,SAChB,CAAC,SAEK,EAET,EAAY,CACV,UACA,MAHe,EAAgB,EAAkB,CAIjD,SAAU,EAAE,CACb,CAAC,KACG,CACL,IAAM,EAAW,EAAgB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GH,EAAS,EAAI,QAAQ,EAAc,CACzC,OAAO,EAAO,SAAW,EAAI,EAAO,GAAK"}
1
+ {"version":3,"file":"getHTML.mjs","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"sourcesContent":["/**\n * Component function that receives properly typed props\n * Props include:\n * - children?: any[] - Array of child elements (ReactNode[], VNode[], etc.)\n * - [key: string]: any - Any HTML attributes (className, style, href, etc.)\n */\ntype Component = (props: { children?: any[]; [key: string]: any }) => any;\n\n/**\n * Component object that delegates to another component\n */\ntype ComponentObject = {\n tag: string;\n props?: Record<string, any>;\n};\n\n/**\n * Components map:\n * - Function components receive typed props\n * - String components delegate to another tag\n * - Object components delegate with additional props\n */\ntype Components = Record<string, Component | string | ComponentObject>;\n\n/**\n * Helper to parse attributes from a tag string.\n */\nconst parseAttributes = (attributes: string): Record<string, string> => {\n const props: Record<string, string> = {};\n const attrRegex = /([a-zA-Z0-9-]+)=\"([^\"]*)\"/g;\n\n let match = attrRegex.exec(attributes);\n while (match !== null) {\n props[match[1]] = match[2];\n match = attrRegex.exec(attributes);\n }\n return props;\n};\n\ntype ASTNode =\n | string\n | {\n tagName: string;\n props: Record<string, string>;\n children: ASTNode[];\n };\n\nconst astCache = new Map<string, ASTNode[]>();\n\nconst parseHTML = (content: string): ASTNode[] => {\n if (astCache.has(content)) {\n return astCache.get(content)!;\n }\n\n if (typeof content !== 'string') {\n return [];\n }\n\n const tagRegex = /<(\\/)?([a-zA-Z0-9.-]+)([\\s\\S]*?)(\\/?)>/g;\n const elements: ASTNode[] = [];\n const stack: {\n tagName: string;\n children: ASTNode[];\n props: Record<string, string>;\n }[] = [];\n\n let lastIndex = 0;\n let match = tagRegex.exec(content);\n\n const appendChild = (child: ASTNode) => {\n const target =\n stack.length > 0 ? stack[stack.length - 1].children : elements;\n target.push(child);\n };\n\n while (match !== null) {\n const [fullMatch, isClosingRaw, tagName, attributesRaw, isSelfClosingRaw] =\n match;\n const matchIndex = match.index;\n\n if (matchIndex > lastIndex) {\n appendChild(content.slice(lastIndex, matchIndex));\n }\n\n const isClosing = isClosingRaw === '/';\n const isSelfClosing =\n isSelfClosingRaw === '/' ||\n attributesRaw.trim().endsWith('/') ||\n fullMatch.endsWith('/>');\n\n const cleanedAttributes = attributesRaw.trim().replace(/\\/$/, '').trim();\n\n if (isClosing) {\n const last = stack[stack.length - 1];\n\n // Only pop if the tag names match\n if (last && last.tagName === tagName) {\n const popped = stack.pop();\n if (popped) {\n appendChild({\n tagName: popped.tagName,\n props: popped.props,\n children: popped.children,\n });\n }\n }\n // If tags don't match or no open tag, silently ignore the closing tag\n } else if (isSelfClosing) {\n const tagProps = parseAttributes(cleanedAttributes);\n appendChild({\n tagName,\n props: tagProps,\n children: [],\n });\n } else {\n const tagProps = parseAttributes(cleanedAttributes);\n stack.push({ tagName, children: [], props: tagProps });\n }\n\n lastIndex = matchIndex + fullMatch.length;\n match = tagRegex.exec(content);\n }\n\n if (lastIndex < content.length) {\n appendChild(content.slice(lastIndex));\n }\n\n // Handle unclosed tags by appending them to the root or parent\n while (stack.length > 0) {\n const last = stack.pop();\n if (last) {\n appendChild({\n tagName: last.tagName,\n props: last.props,\n children: last.children,\n });\n }\n }\n\n astCache.set(content, elements);\n return elements;\n};\n\n/**\n * Interprets a string containing HTML-like tags and replaces them with provided components or strings.\n */\nexport const getHTML = (content: string, values: Components): any => {\n // Parse into AST (cached)\n const ast = parseHTML(content);\n\n // Render AST\n let keyCounter = 0;\n\n const renderASTNode = (node: ASTNode): any => {\n if (typeof node === 'string') {\n return node;\n }\n\n const { tagName, props, children } = node;\n const renderedChildren = children.flatMap(renderASTNode);\n const index = keyCounter++;\n\n let override = values[tagName];\n\n if (!override) {\n const lowerTagName = tagName.toLowerCase();\n const foundKey = Object.keys(values).find(\n (key) => key.toLowerCase() === lowerTagName\n );\n\n if (foundKey) override = values[foundKey];\n }\n\n const key = `html-tag-${tagName}-${index}`;\n\n if (typeof override === 'function') {\n return override({ ...props, children: renderedChildren, key });\n }\n\n if (typeof override === 'string') {\n const component = values[override];\n\n if (typeof component === 'function') {\n return component({ ...props, children: renderedChildren, key });\n }\n return renderedChildren;\n }\n\n if (\n typeof override === 'object' &&\n override !== null &&\n 'tag' in override\n ) {\n const { tag: targetTag, props: extraProps } = override as ComponentObject;\n const component = values[targetTag];\n\n if (typeof component === 'function') {\n return component({\n ...props,\n ...extraProps,\n children: renderedChildren,\n key,\n });\n }\n return renderedChildren;\n }\n\n // Default: Skip tag, render children\n return renderedChildren;\n };\n\n const result = ast.flatMap(renderASTNode);\n return result.length === 1 ? result[0] : result;\n};\n"],"mappings":"AA2BA,MAAM,EAAmB,GAA+C,CACtE,IAAM,EAAgC,EAAE,CAClC,EAAY,6BAEd,EAAQ,EAAU,KAAK,EAAW,CACtC,KAAO,IAAU,MACf,EAAM,EAAM,IAAM,EAAM,GACxB,EAAQ,EAAU,KAAK,EAAW,CAEpC,OAAO,GAWH,EAAW,IAAI,IAEf,EAAa,GAA+B,CAChD,GAAI,EAAS,IAAI,EAAQ,CACvB,OAAO,EAAS,IAAI,EAAQ,CAG9B,GAAI,OAAO,GAAY,SACrB,MAAO,EAAE,CAGX,IAAM,EAAW,0CACX,EAAsB,EAAE,CACxB,EAIA,EAAE,CAEJ,EAAY,EACZ,EAAQ,EAAS,KAAK,EAAQ,CAE5B,EAAe,GAAmB,EAEpC,EAAM,OAAS,EAAI,EAAM,EAAM,OAAS,GAAG,SAAW,GACjD,KAAK,EAAM,EAGpB,KAAO,IAAU,MAAM,CACrB,GAAM,CAAC,EAAW,EAAc,EAAS,EAAe,GACtD,EACI,EAAa,EAAM,MAErB,EAAa,GACf,EAAY,EAAQ,MAAM,EAAW,EAAW,CAAC,CAGnD,IAAM,EAAY,IAAiB,IAC7B,EACJ,IAAqB,KACrB,EAAc,MAAM,CAAC,SAAS,IAAI,EAClC,EAAU,SAAS,KAAK,CAEpB,EAAoB,EAAc,MAAM,CAAC,QAAQ,MAAO,GAAG,CAAC,MAAM,CAExE,GAAI,EAAW,CACb,I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OAAO,GAAc,WAChB,EAAU,CAAE,GAAG,EAAO,SAAU,EAAkB,MAAK,CAAC,CAE1D,EAGT,GACE,OAAO,GAAa,UACpB,GACA,QAAS,EACT,CACA,GAAM,CAAE,IAAK,EAAW,MAAO,GAAe,EACxC,EAAY,EAAO,GAUzB,OARI,OAAO,GAAc,WAChB,EAAU,CACf,GAAG,EACH,GAAG,EACH,SAAU,EACV,MACD,CAAC,CAEG,EAIT,OAAO,GAGH,EAAS,EAAI,QAAQ,EAAc,CACzC,OAAO,EAAO,SAAW,EAAI,EAAO,GAAK"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.mjs","names":[],"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":"iOAeA,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,EADe,GAAiB,CACN,GAsBhC,OApBK,EAoBE,EACL,EACA,EACA,EACD,EAtBgB,EAAa,EAAc,CAExC,cAAc,EAAY,EAAc,CAAC,uCACzC,CACE,MAAO,OACP,UAAW,GACZ,CACF,CAQM,EAAmB,EAAc"}
1
+ {"version":3,"file":"getIntlayer.mjs","names":[],"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":"iOAqBA,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,EADe,GAAiB,CACN,GAsBhC,OApBK,EAoBE,EACL,EACA,EACA,EACD,EAtBgB,EAAa,EAAc,CAExC,cAAc,EAAY,EAAc,CAAC,uCACzC,CACE,MAAO,OACP,UAAW,GACZ,CACF,CAQM,EAAmB,EAAc"}
@@ -1 +1 @@
1
- import{getCondition as e}from"./getCondition.mjs";import{deepTransformNode as t}from"./getContent/deepTransform.mjs";import{findMatchingCondition as n,getEnumeration as r}from"./getEnumeration.mjs";import{getDictionary as i}from"./getDictionary.mjs";import{getIntlayer as a}from"./getIntlayer.mjs";import{getNesting as o}from"./getNesting.mjs";import{getTranslation as s}from"./getTranslation.mjs";import{conditionPlugin as c,enumerationPlugin as l,filePlugin as u,genderPlugin as d,insertionPlugin as f,nestedPlugin as p,translationPlugin as m}from"./getContent/plugins.mjs";import{getContent as h}from"./getContent/getContent.mjs";import{getHTML as g}from"./getHTML.mjs";import{splitInsertionTemplate as _}from"./splitAndJoinInsertion.mjs";export{c as conditionPlugin,t as deepTransformNode,l as enumerationPlugin,u as filePlugin,n as findMatchingCondition,d as genderPlugin,e as getCondition,h as getContent,i as getDictionary,r as getEnumeration,g as getHTML,a as getIntlayer,o as getNesting,s as getTranslation,f as insertionPlugin,p as nestedPlugin,_ as splitInsertionTemplate,m as translationPlugin};
1
+ import{getCondition as e}from"./getCondition.mjs";import{deepTransformNode as t}from"./getContent/deepTransform.mjs";import{findMatchingCondition as n,getEnumeration as r}from"./getEnumeration.mjs";import{getDictionary as i}from"./getDictionary.mjs";import{getIntlayer as a}from"./getIntlayer.mjs";import{getNesting as o}from"./getNesting.mjs";import{getTranslation as s}from"./getTranslation.mjs";import{conditionPlugin as c,enumerationPlugin as l,filePlugin as u,genderPlugin as d,insertionPlugin as f,nestedPlugin as p,translationPlugin as m}from"./getContent/plugins.mjs";import{getBasePlugins as h,getContent as g}from"./getContent/getContent.mjs";import{getHTML as _}from"./getHTML.mjs";import{splitInsertionTemplate as v}from"./splitAndJoinInsertion.mjs";export{c as conditionPlugin,t as deepTransformNode,l as enumerationPlugin,u as filePlugin,n as findMatchingCondition,d as genderPlugin,h as getBasePlugins,e as getCondition,g as getContent,i as getDictionary,r as getEnumeration,_ as getHTML,a as getIntlayer,o as getNesting,s as getTranslation,f as insertionPlugin,p as nestedPlugin,v as splitInsertionTemplate,m as translationPlugin};
@@ -1 +1 @@
1
- import{getMarkdownMetadata as e}from"../transpiler/markdown/getMarkdownMetadata.mjs";import{md as t}from"../transpiler/markdown/markdown.mjs";import{ATTRIBUTES_TO_SANITIZE as n,ATTRIBUTE_TO_NODE_PROP_MAP as r,ATTR_EXTRACTOR_R as i,BLOCKQUOTE_ALERT_R as a,BLOCKQUOTE_R as o,BLOCKQUOTE_TRIM_LEFT_MULTILINE_R as s,BLOCK_END_R as c,BREAK_LINE_R as l,BREAK_THEMATIC_R as u,CAPTURE_LETTER_AFTER_HYPHEN as d,CODE_BLOCK_FENCED_R as f,CODE_BLOCK_R as p,CODE_INLINE_R as m,CONSECUTIVE_NEWLINE_R as h,CR_NEWLINE_R as g,CUSTOM_COMPONENT_R as _,DO_NOT_PROCESS_HTML_ELEMENTS as v,DURATION_DELAY_TRIGGER as y,FOOTNOTE_R as b,FOOTNOTE_REFERENCE_R as x,FORMFEED_R as S,FRONT_MATTER_R as C,GFM_TASK_R as w,HEADING_ATX_COMPLIANT_R as T,HEADING_R as E,HEADING_SETEXT_R as D,HTML_BLOCK_ELEMENT_R as O,HTML_CHAR_CODE_R as k,HTML_COMMENT_R as A,HTML_CUSTOM_ATTR_R as j,HTML_LEFT_TRIM_AMOUNT_R as M,HTML_SELF_CLOSING_ELEMENT_R as N,INLINE_SKIP_R as P,INTERPOLATION_R as F,LINK_AUTOLINK_BARE_URL_R as I,LINK_AUTOLINK_R as L,LIST_LOOKBEHIND_R as R,LOOKAHEAD as z,NAMED_CODES_TO_UNICODE as B,NP_TABLE_R as V,ORDERED as H,ORDERED_LIST_BULLET as U,ORDERED_LIST_ITEM_PREFIX as W,ORDERED_LIST_ITEM_PREFIX_R as G,ORDERED_LIST_ITEM_R as K,ORDERED_LIST_R as q,PARAGRAPH_R as J,Priority as Y,REFERENCE_IMAGE_OR_LINK as X,REFERENCE_IMAGE_R as Z,REFERENCE_LINK_R as Q,RuleType as $,SHORTCODE_R as ee,SHOULD_RENDER_AS_BLOCK_R as te,TABLE_CENTER_ALIGN as ne,TABLE_LEFT_ALIGN as re,TABLE_RIGHT_ALIGN as ie,TABLE_TRIM_PIPES as ae,TAB_R as oe,TEXT_BOLD_R as se,TEXT_EMPHASIZED_R as ce,TEXT_ESCAPED_R as le,TEXT_MARKED_R as ue,TEXT_PLAIN_R as de,TEXT_STRIKETHROUGHED_R as fe,TRIM_STARTING_NEWLINES as pe,UNESCAPE_R as me,UNORDERED as he,UNORDERED_LIST_BULLET as ge,UNORDERED_LIST_ITEM_PREFIX as _e,UNORDERED_LIST_ITEM_PREFIX_R as ve,UNORDERED_LIST_ITEM_R as ye,UNORDERED_LIST_R as be,generateListItemPrefix as xe,generateListItemPrefixRegex as Se,generateListItemRegex as Ce,generateListRegex as we}from"./constants.mjs";import{allowInline as Te,anyScopeRegex as Ee,attributeValueToNodePropValue as De,blockRegex as Oe,captureNothing as ke,cx as Ae,get as je,inlineRegex as Me,normalizeAttributeKey as Ne,normalizeWhitespace as Pe,parseBlock as Fe,parseCaptureInline as Ie,parseInline as Le,parseSimpleInline as Re,parseStyleAttribute as ze,parseTableAlign as Be,parseTableAlignCapture as Ve,parseTableCells as He,parseTableRow as Ue,qualifies as We,renderNothing as Ge,sanitizer as Ke,simpleInlineRegex as qe,slugify as Je,some as Ye,startsWith as Xe,trimEnd as Ze,trimLeadingWhitespaceOutsideFences as Qe,unescapeString as $e,unquote as et}from"./utils.mjs";import{parserFor as tt}from"./parser.mjs";import{createRenderer as nt,renderFor as rt}from"./renderer.mjs";import{compile as it,compileWithOptions as at,createCompiler as ot}from"./compiler.mjs";export{n as ATTRIBUTES_TO_SANITIZE,r as ATTRIBUTE_TO_NODE_PROP_MAP,i as ATTR_EXTRACTOR_R,a as BLOCKQUOTE_ALERT_R,o as BLOCKQUOTE_R,s as BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,c as BLOCK_END_R,l as BREAK_LINE_R,u as BREAK_THEMATIC_R,d as CAPTURE_LETTER_AFTER_HYPHEN,f as CODE_BLOCK_FENCED_R,p as CODE_BLOCK_R,m as CODE_INLINE_R,h as CONSECUTIVE_NEWLINE_R,g as CR_NEWLINE_R,_ as CUSTOM_COMPONENT_R,v as DO_NOT_PROCESS_HTML_ELEMENTS,y as DURATION_DELAY_TRIGGER,b as FOOTNOTE_R,x as FOOTNOTE_REFERENCE_R,S as FORMFEED_R,C as FRONT_MATTER_R,w as GFM_TASK_R,T as HEADING_ATX_COMPLIANT_R,E as HEADING_R,D as HEADING_SETEXT_R,O as HTML_BLOCK_ELEMENT_R,k as HTML_CHAR_CODE_R,A as HTML_COMMENT_R,j as HTML_CUSTOM_ATTR_R,M as HTML_LEFT_TRIM_AMOUNT_R,N as HTML_SELF_CLOSING_ELEMENT_R,P as INLINE_SKIP_R,F as INTERPOLATION_R,I as LINK_AUTOLINK_BARE_URL_R,L as LINK_AUTOLINK_R,R as LIST_LOOKBEHIND_R,z as LOOKAHEAD,B as NAMED_CODES_TO_UNICODE,V as NP_TABLE_R,H as ORDERED,U as ORDERED_LIST_BULLET,W as ORDERED_LIST_ITEM_PREFIX,G as ORDERED_LIST_ITEM_PREFIX_R,K as ORDERED_LIST_ITEM_R,q as ORDERED_LIST_R,J as PARAGRAPH_R,Y as Priority,X as REFERENCE_IMAGE_OR_LINK,Z as REFERENCE_IMAGE_R,Q as REFERENCE_LINK_R,$ as RuleType,ee as SHORTCODE_R,te as SHOULD_RENDER_AS_BLOCK_R,ne as TABLE_CENTER_ALIGN,re as TABLE_LEFT_ALIGN,ie as TABLE_RIGHT_ALIGN,ae as TABLE_TRIM_PIPES,oe as TAB_R,se as TEXT_BOLD_R,ce as TEXT_EMPHASIZED_R,le as TEXT_ESCAPED_R,ue as TEXT_MARKED_R,de as TEXT_PLAIN_R,fe as TEXT_STRIKETHROUGHED_R,pe as TRIM_STARTING_NEWLINES,me as UNESCAPE_R,he as UNORDERED,ge as UNORDERED_LIST_BULLET,_e as UNORDERED_LIST_ITEM_PREFIX,ve as UNORDERED_LIST_ITEM_PREFIX_R,ye as UNORDERED_LIST_ITEM_R,be as UNORDERED_LIST_R,Te as allowInline,Ee as anyScopeRegex,De as attributeValueToNodePropValue,Oe as blockRegex,ke as captureNothing,it as compile,at as compileWithOptions,ot as createCompiler,nt as createRenderer,Ae as cx,xe as generateListItemPrefix,Se as generateListItemPrefixRegex,Ce as generateListItemRegex,we as generateListRegex,je as get,e as getMarkdownMetadata,Me as inlineRegex,t as md,Ne as normalizeAttributeKey,Pe as normalizeWhitespace,Fe as parseBlock,Ie as parseCaptureInline,Le as parseInline,Re as parseSimpleInline,ze as parseStyleAttribute,Be as parseTableAlign,Ve as parseTableAlignCapture,He as parseTableCells,Ue as parseTableRow,tt as parserFor,We as qualifies,rt as renderFor,Ge as renderNothing,Ke as sanitizer,qe as simpleInlineRegex,Je as slugify,Ye as some,Xe as startsWith,Ze as trimEnd,Qe as trimLeadingWhitespaceOutsideFences,$e as unescapeString,et as unquote};
1
+ import{getMarkdownMetadata as e}from"../transpiler/markdown/getMarkdownMetadata.mjs";import{validateMarkdown as t}from"../transpiler/markdown/validateMarkdown.mjs";import{md as n}from"../transpiler/markdown/markdown.mjs";import{ATTRIBUTES_TO_SANITIZE as r,ATTRIBUTE_TO_NODE_PROP_MAP as i,ATTR_EXTRACTOR_R as a,BLOCKQUOTE_ALERT_R as o,BLOCKQUOTE_R as s,BLOCKQUOTE_TRIM_LEFT_MULTILINE_R as c,BLOCK_END_R as l,BREAK_LINE_R as u,BREAK_THEMATIC_R as d,CAPTURE_LETTER_AFTER_HYPHEN as f,CODE_BLOCK_FENCED_R as p,CODE_BLOCK_R as m,CODE_INLINE_R as h,CONSECUTIVE_NEWLINE_R as g,CR_NEWLINE_R as _,CUSTOM_COMPONENT_R as v,DO_NOT_PROCESS_HTML_ELEMENTS as y,DURATION_DELAY_TRIGGER as b,FOOTNOTE_R as x,FOOTNOTE_REFERENCE_R as S,FORMFEED_R as C,FRONT_MATTER_R as w,GFM_TASK_R as T,HEADING_ATX_COMPLIANT_R as E,HEADING_R as D,HEADING_SETEXT_R as O,HTML_BLOCK_ELEMENT_R as k,HTML_CHAR_CODE_R as A,HTML_COMMENT_R as j,HTML_CUSTOM_ATTR_R as M,HTML_LEFT_TRIM_AMOUNT_R as N,HTML_SELF_CLOSING_ELEMENT_R as P,INLINE_SKIP_R as F,INTERPOLATION_R as I,LINK_AUTOLINK_BARE_URL_R as L,LINK_AUTOLINK_R as R,LIST_LOOKBEHIND_R as z,LOOKAHEAD as B,NAMED_CODES_TO_UNICODE as V,NP_TABLE_R as H,ORDERED as U,ORDERED_LIST_BULLET as W,ORDERED_LIST_ITEM_PREFIX as G,ORDERED_LIST_ITEM_PREFIX_R as K,ORDERED_LIST_ITEM_R as q,ORDERED_LIST_R as J,PARAGRAPH_R as Y,Priority as X,REFERENCE_IMAGE_OR_LINK as Z,REFERENCE_IMAGE_R as Q,REFERENCE_LINK_R as $,RuleType as ee,SHORTCODE_R as te,SHOULD_RENDER_AS_BLOCK_R as ne,TABLE_CENTER_ALIGN as re,TABLE_LEFT_ALIGN as ie,TABLE_RIGHT_ALIGN as ae,TABLE_TRIM_PIPES as oe,TAB_R as se,TEXT_BOLD_R as ce,TEXT_EMPHASIZED_R as le,TEXT_ESCAPED_R as ue,TEXT_MARKED_R as de,TEXT_PLAIN_R as fe,TEXT_STRIKETHROUGHED_R as pe,TRIM_STARTING_NEWLINES as me,UNESCAPE_R as he,UNORDERED as ge,UNORDERED_LIST_BULLET as _e,UNORDERED_LIST_ITEM_PREFIX as ve,UNORDERED_LIST_ITEM_PREFIX_R as ye,UNORDERED_LIST_ITEM_R as be,UNORDERED_LIST_R as xe,generateListItemPrefix as Se,generateListItemPrefixRegex as Ce,generateListItemRegex as we,generateListRegex as Te}from"./constants.mjs";import{allowInline as Ee,anyScopeRegex as De,attributeValueToNodePropValue as Oe,blockRegex as ke,captureNothing as Ae,cx as je,get as Me,inlineRegex as Ne,normalizeAttributeKey as Pe,normalizeWhitespace as Fe,parseBlock as Ie,parseCaptureInline as Le,parseInline as Re,parseSimpleInline as ze,parseStyleAttribute as Be,parseTableAlign as Ve,parseTableAlignCapture as He,parseTableCells as Ue,parseTableRow as We,qualifies as Ge,renderNothing as Ke,sanitizer as qe,simpleInlineRegex as Je,slugify as Ye,some as Xe,startsWith as Ze,trimEnd as Qe,trimLeadingWhitespaceOutsideFences as $e,unescapeString as et,unquote as tt}from"./utils.mjs";import{parserFor as nt}from"./parser.mjs";import{createRenderer as rt,renderFor as it}from"./renderer.mjs";import{compile as at,compileWithOptions as ot,createCompiler as st}from"./compiler.mjs";export{r as ATTRIBUTES_TO_SANITIZE,i as ATTRIBUTE_TO_NODE_PROP_MAP,a as ATTR_EXTRACTOR_R,o as BLOCKQUOTE_ALERT_R,s as BLOCKQUOTE_R,c as BLOCKQUOTE_TRIM_LEFT_MULTILINE_R,l as BLOCK_END_R,u as BREAK_LINE_R,d as BREAK_THEMATIC_R,f as CAPTURE_LETTER_AFTER_HYPHEN,p as CODE_BLOCK_FENCED_R,m as CODE_BLOCK_R,h as CODE_INLINE_R,g as CONSECUTIVE_NEWLINE_R,_ as CR_NEWLINE_R,v as CUSTOM_COMPONENT_R,y as DO_NOT_PROCESS_HTML_ELEMENTS,b as DURATION_DELAY_TRIGGER,x as FOOTNOTE_R,S as FOOTNOTE_REFERENCE_R,C as FORMFEED_R,w as FRONT_MATTER_R,T as GFM_TASK_R,E as HEADING_ATX_COMPLIANT_R,D as HEADING_R,O as HEADING_SETEXT_R,k as HTML_BLOCK_ELEMENT_R,A as HTML_CHAR_CODE_R,j as HTML_COMMENT_R,M as HTML_CUSTOM_ATTR_R,N as HTML_LEFT_TRIM_AMOUNT_R,P as HTML_SELF_CLOSING_ELEMENT_R,F as INLINE_SKIP_R,I as INTERPOLATION_R,L as LINK_AUTOLINK_BARE_URL_R,R as LINK_AUTOLINK_R,z as LIST_LOOKBEHIND_R,B as LOOKAHEAD,V as NAMED_CODES_TO_UNICODE,H as NP_TABLE_R,U as ORDERED,W as ORDERED_LIST_BULLET,G as ORDERED_LIST_ITEM_PREFIX,K as ORDERED_LIST_ITEM_PREFIX_R,q as ORDERED_LIST_ITEM_R,J as ORDERED_LIST_R,Y as PARAGRAPH_R,X as Priority,Z as REFERENCE_IMAGE_OR_LINK,Q as REFERENCE_IMAGE_R,$ as REFERENCE_LINK_R,ee as RuleType,te as SHORTCODE_R,ne as SHOULD_RENDER_AS_BLOCK_R,re as TABLE_CENTER_ALIGN,ie as TABLE_LEFT_ALIGN,ae as TABLE_RIGHT_ALIGN,oe as TABLE_TRIM_PIPES,se as TAB_R,ce as TEXT_BOLD_R,le as TEXT_EMPHASIZED_R,ue as TEXT_ESCAPED_R,de as TEXT_MARKED_R,fe as TEXT_PLAIN_R,pe as TEXT_STRIKETHROUGHED_R,me as TRIM_STARTING_NEWLINES,he as UNESCAPE_R,ge as UNORDERED,_e as UNORDERED_LIST_BULLET,ve as UNORDERED_LIST_ITEM_PREFIX,ye as UNORDERED_LIST_ITEM_PREFIX_R,be as UNORDERED_LIST_ITEM_R,xe as UNORDERED_LIST_R,Ee as allowInline,De as anyScopeRegex,Oe as attributeValueToNodePropValue,ke as blockRegex,Ae as captureNothing,at as compile,ot as compileWithOptions,st as createCompiler,rt as createRenderer,je as cx,Se as generateListItemPrefix,Ce as generateListItemPrefixRegex,we as generateListItemRegex,Te as generateListRegex,Me as get,e as getMarkdownMetadata,Ne as inlineRegex,n as md,Pe as normalizeAttributeKey,Fe as normalizeWhitespace,Ie as parseBlock,Le as parseCaptureInline,Re as parseInline,ze as parseSimpleInline,Be as parseStyleAttribute,Ve as parseTableAlign,He as parseTableAlignCapture,Ue as parseTableCells,We as parseTableRow,nt as parserFor,Ge as qualifies,it as renderFor,Ke as renderNothing,qe as sanitizer,Je as simpleInlineRegex,Ye as slugify,Xe as some,Ze as startsWith,Qe as trimEnd,$e as trimLeadingWhitespaceOutsideFences,et as unescapeString,tt as unquote,t as validateMarkdown};
@@ -1 +1 @@
1
- {"version":3,"file":"enumeration.mjs","names":[],"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":"wEAoDA,MAAM,EAAwB,GAC5B,EAAe,EAAS,YAAa,EAAQ"}
1
+ {"version":3,"file":"enumeration.mjs","names":[],"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":"wEAoDA,MAAM,EACJ,GACG,EAAe,EAAS,YAAa,EAAQ"}
@@ -1,2 +1,2 @@
1
- import{HTML_TAGS as e}from"./htmlTags.mjs";const t=e=>{let t={};return!e||!e.trim()||[...e.matchAll(/([a-zA-Z0-9-:_@]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?/g)].forEach(e=>{let n=e[1];t[n]=`string`}),t},n=n=>{if(typeof n!=`string`)throw Error(`content must be a string`);let r=[...n.matchAll(/<(\/)?([a-zA-Z0-9.-]+)\s*([\s\S]*?)(\/?)>/g)],i={};return r.forEach(n=>{let r=!!n[1],a=n[2],o=n[3],s=!!n[4];if(e.includes(a.toLowerCase())){i[a]=!0;return}if(i[a]||(i[a]={}),i[a]===!0||r)return;let c=t(o),l=i[a];Object.assign(l,c),s||(l.children=`string`)}),i};export{n as getHTMLCustomComponents};
1
+ import{validateHTML as e}from"./validateHTML.mjs";import{HTML_TAGS as t}from"./htmlTags.mjs";const n=e=>{let t={};return!e||!e.trim()||[...e.matchAll(/([a-zA-Z0-9-:_@]+)(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^>\s]+))?/g)].forEach(e=>{let n=e[1];t[n]=`string`}),t},r=r=>{if(typeof r!=`string`)throw Error(`content must be a string`);let i=[...r.matchAll(/<(\/)?([a-zA-Z0-9.-]+)\s*([\s\S]*?)(\/?)>/g)],{issues:a}=e(r);for(let e of a)console.error(`HTML Validation Error: ${e.message}`);let o={};return i.forEach(e=>{let r=!!e[1],i=e[2],a=e[3],s=!!e[4];if(t.includes(i.toLowerCase())){o[i]=!0;return}if(o[i]||(o[i]={}),o[i]===!0||r)return;let c=n(a),l=o[i];Object.assign(l,c),s||(l.children=`string`)}),o};export{r as getHTMLCustomComponents};
2
2
  //# sourceMappingURL=getHTMLCustomComponents.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"getHTMLCustomComponents.mjs","names":[],"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":"2CAEA,MAAM,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,GAAK,EAAgC,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.mjs","names":[],"sources":["../../../../src/transpiler/html/getHTMLCustomComponents.ts"],"sourcesContent":["import { HTML_TAGS } from './index';\nimport { validateHTML } from './validateHTML';\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 // Validate HTML structure and report issues to console\n const { issues } = validateHTML(content);\n for (const issue of issues) {\n console.error(`HTML Validation Error: ${issue.message}`);\n }\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":"6FAGA,MAAM,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,CAGzC,CAAE,UAAW,EAAa,EAAQ,CACxC,IAAK,IAAM,KAAS,EAClB,QAAQ,MAAM,0BAA0B,EAAM,UAAU,CAG1D,IAAM,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,GAAK,EAAgC,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 +1 @@
1
- import{html as e}from"./html.mjs";import{HTML_TAGS as t}from"./htmlTags.mjs";export{t as HTML_TAGS,e as html};
1
+ import{VOID_ELEMENTS as e,validateHTML as t}from"./validateHTML.mjs";import{html as n}from"./html.mjs";import{HTML_TAGS as r}from"./htmlTags.mjs";export{r as HTML_TAGS,e as VOID_ELEMENTS,n as html,t as validateHTML};
@@ -0,0 +1,2 @@
1
+ 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}};export{e as VOID_ELEMENTS,n as validateHTML};
2
+ //# sourceMappingURL=validateHTML.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateHTML.mjs","names":[],"sources":["../../../../src/transpiler/html/validateHTML.ts"],"sourcesContent":["export const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'source',\n 'track',\n 'wbr',\n]);\n\nexport type HTMLValidationIssue = {\n type: 'error' | 'warning';\n message: string;\n};\n\nexport type HTMLValidationResult = {\n valid: boolean;\n issues: HTMLValidationIssue[];\n};\n\n// Matches HTML tags: <Tag ...>, </Tag>, or <Tag ... />\n// Attributes may span multiple lines but NOT blank lines (two consecutive newlines),\n// which prevents matching blockquote `>` markers as tag closers.\n// Groups: 1: closing slash, 2: tag name, 3: attributes, 4: self-closing slash\nconst TAG_REGEX =\n /<(\\/)?([a-zA-Z][a-zA-Z0-9.-]*)\\s*((?:[^\\n]|\\n(?!\\n))*?)(\\/?)>/g;\n\n/**\n * Validates that HTML tags in `content` are properly opened, nested, and closed.\n * Returns structured issues instead of logging to the console.\n *\n * False-positive exclusions:\n * - Tags whose attribute string starts with `://` are URL autolinks (e.g. `<https://…>`).\n */\nexport const validateHTML = (content: string): HTMLValidationResult => {\n const issues: HTMLValidationIssue[] = [];\n const stack: Array<{ tag: string }> = [];\n\n for (const match of content.matchAll(TAG_REGEX)) {\n const isClosing = !!match[1];\n const tagName = match[2];\n const attrs = match[3];\n const isSelfClosing = !!match[4];\n\n // Skip URL autolinks like <https://example.com> or <mailto:user@example.com>\n if (\n attrs.trimStart().startsWith('://') ||\n attrs.trimStart().startsWith(':')\n ) {\n continue;\n }\n\n if (isClosing) {\n if (stack.length === 0) {\n issues.push({\n type: 'error',\n message: `Closing tag </${tagName}> has no matching opening tag`,\n });\n } else {\n const last = stack[stack.length - 1];\n if (last.tag.toLowerCase() !== tagName.toLowerCase()) {\n issues.push({\n type: 'error',\n message: `Mismatched closing tag: expected </${last.tag}> but found </${tagName}>`,\n });\n }\n stack.pop();\n }\n } else {\n const isVoidElement = VOID_ELEMENTS.has(tagName.toLowerCase());\n if (!isSelfClosing && !isVoidElement) {\n stack.push({ tag: tagName });\n }\n }\n }\n\n for (const unclosed of stack) {\n issues.push({\n type: 'error',\n message: `Unclosed HTML tag: <${unclosed.tag}>`,\n });\n }\n\n return {\n valid: issues.filter((i) => i.type === 'error').length === 0,\n issues,\n };\n};\n"],"mappings":"AAAA,MAAa,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
- import{cond as e}from"./condition/condition.mjs";import{enu as t}from"./enumeration/enumeration.mjs";import{gender as n}from"./gender/gender.mjs";import{html as r}from"./html/html.mjs";import{HTML_TAGS as i}from"./html/htmlTags.mjs";import{getInsertionValues as a}from"./insertion/getInsertionValues.mjs";import{insert as o}from"./insertion/insertion.mjs";import{getMarkdownMetadata as s}from"./markdown/getMarkdownMetadata.mjs";import{md as c}from"./markdown/markdown.mjs";import{nest as l}from"./nesting/nesting.mjs";import{t as u}from"./translation/translation.mjs";export{i as HTML_TAGS,e as cond,t as enu,n as gender,a as getInsertionValues,s as getMarkdownMetadata,r as html,o as insert,c as md,l as nest,u as t};
1
+ import{cond as e}from"./condition/condition.mjs";import{enu as t}from"./enumeration/enumeration.mjs";import{gender as n}from"./gender/gender.mjs";import{VOID_ELEMENTS as r,validateHTML as i}from"./html/validateHTML.mjs";import{html as a}from"./html/html.mjs";import{HTML_TAGS as o}from"./html/htmlTags.mjs";import{getInsertionValues as s}from"./insertion/getInsertionValues.mjs";import{insert as c}from"./insertion/insertion.mjs";import{getMarkdownMetadata as l}from"./markdown/getMarkdownMetadata.mjs";import{validateMarkdown as u}from"./markdown/validateMarkdown.mjs";import{md as d}from"./markdown/markdown.mjs";import{nest as f}from"./nesting/nesting.mjs";import{t as p}from"./translation/translation.mjs";export{o as HTML_TAGS,r as VOID_ELEMENTS,e as cond,t as enu,n as gender,s as getInsertionValues,l as getMarkdownMetadata,a as html,c as insert,d as md,f as nest,p as t,i as validateHTML,u as validateMarkdown};
@@ -1 +1 @@
1
- import{getMarkdownMetadata as e}from"./getMarkdownMetadata.mjs";import{md as t}from"./markdown.mjs";export{e as getMarkdownMetadata,t as md};
1
+ import{getMarkdownMetadata as e}from"./getMarkdownMetadata.mjs";import{validateMarkdown as t}from"./validateMarkdown.mjs";import{md as n}from"./markdown.mjs";export{e as getMarkdownMetadata,n as md,t as validateMarkdown};
@@ -1 +1 @@
1
- {"version":3,"file":"markdown.mjs","names":[],"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":"+RA6BA,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,IA4CO,EAAe,EAAS,SAAU,EAAS,CAChD,SA3Ce,SAAY,CAG3B,IAAM,EAAc,EAFG,MAAM,EAAa,EAAQ,CAEH,CAC7C,cAAe,GACf,QAAS,EAAE,CACZ,CAAC,CAEF,GAAI,OAAO,GAAgB,SACzB,OAAO,EAAoB,EAAY,EAmCzC,UA/B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,OAAO,EAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACd,EAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAO,EAAwB,EAAc,CAG/C,GAAI,CACF,OAAO,EAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAMU,CACtB,CAAC"}
1
+ {"version":3,"file":"markdown.mjs","names":[],"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":"+RA8BA,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,IAuDO,EAAe,EAAS,SAAU,EAAS,CAChD,SAtDe,SAAY,CAG3B,IAAM,EAAc,EAFG,MAAM,EAAa,EAAQ,CAEH,CAC7C,cAAe,GACf,QAAS,EAAE,CACZ,CAAC,CAEF,GAAI,OAAO,GAAgB,SAYzB,OAAO,EAAoB,EAAY,EAmCzC,UA/B0B,CAC1B,GAAI,EACF,OAAO,EAGT,GAAI,OAAO,GAAY,SACrB,OAAO,EAAwB,EAAQ,CAGzC,IAAI,EASJ,GAPI,OAAO,GAAY,WACrB,EAAgB,GAAS,CAChB,OAAQ,EAA4B,MAAS,aACtD,EAAgB,SACd,EAAyB,MAAO,EAAuC,EAGvE,OAAO,GAAkB,SAC3B,OAAO,EAAwB,EAAc,CAG/C,GAAI,CACF,OAAO,EAAwB,KAAK,UAAU,EAAQ,CAAC,MAC5C,CACX,MAAO,EAAE,KAMU,CACtB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import{validateHTML as e}from"../html/validateHTML.mjs";const 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(t(r)).issues,o=[...i,...a];return{valid:o.filter(e=>e.type===`error`).length===0,issues:o}};export{r as validateMarkdown};
5
+ //# sourceMappingURL=validateMarkdown.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateMarkdown.mjs","names":[],"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":"wDAaA,MAAM,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,EAAa,EAAa,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"}
@@ -4,17 +4,19 @@ import { FileContent, FileContentConstructor, file, fileContent } from "./transp
4
4
  import { Gender, GenderContent, GenderContentStates, gender } from "./transpiler/gender/gender.js";
5
5
  import { HTMLContent, HTMLContentConstructor, html } from "./transpiler/html/html.js";
6
6
  import { HTMLTagsType, HTML_TAGS } from "./transpiler/html/htmlTags.js";
7
+ import { HTMLValidationIssue, HTMLValidationResult, VOID_ELEMENTS, validateHTML } from "./transpiler/html/validateHTML.js";
7
8
  import { getInsertionValues } from "./transpiler/insertion/getInsertionValues.js";
8
9
  import { InsertionContent, InsertionContentConstructor, insert as insertion } from "./transpiler/insertion/insertion.js";
9
10
  import { getMarkdownMetadata } from "./transpiler/markdown/getMarkdownMetadata.js";
10
11
  import { MarkdownContent, MarkdownContentConstructor, md as markdown } from "./transpiler/markdown/markdown.js";
12
+ import { MarkdownValidationResult, validateMarkdown } from "./transpiler/markdown/validateMarkdown.js";
11
13
  import { DotPath, NestedContent, NestedContentState, ValidDotPathsFor, nest as nesting } from "./transpiler/nesting/nesting.js";
12
14
  import { TranslationContent, t as translation } from "./transpiler/translation/translation.js";
13
15
  import { getCondition } from "./interpreter/getCondition.js";
14
16
  import { GetNestingResult, getNesting } from "./interpreter/getNesting.js";
15
17
  import { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, IsAny, NestedCond, NodeProps, Plugins, TranslationCond, UnionKeys, ValueAtKey, conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, translationPlugin } from "./interpreter/getContent/plugins.js";
16
18
  import { deepTransformNode } from "./interpreter/getContent/deepTransform.js";
17
- import { getContent } from "./interpreter/getContent/getContent.js";
19
+ import { getBasePlugins, getContent } from "./interpreter/getContent/getContent.js";
18
20
  import { getDictionary } from "./interpreter/getDictionary.js";
19
21
  import { findMatchingCondition, getEnumeration } from "./interpreter/getEnumeration.js";
20
22
  import { getHTML } from "./interpreter/getHTML.js";
@@ -83,4 +85,4 @@ import { getCookie } from "./utils/getCookie.js";
83
85
  import { isSameKeyPath } from "./utils/isSameKeyPath.js";
84
86
  import { isValidElement } from "./utils/isValidReactElement.js";
85
87
  import { parseYaml } from "./utils/parseYaml.js";
86
- export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, CodeBlockNode, CodeFencedNode, CodeInlineNode, CompileOptions, ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CustomComponentNode, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, DeepTransformContent, DotPath, ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, EscapedTextNode, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, FileContent, FileContentConstructor, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, GetNestingResult, GetPrefixOptions, GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTMLCommentNode, HTMLContent, HTMLContentConstructor, HTMLNode, HTMLSelfClosingNode, HTMLTag, HTMLTagsType, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, HeadingNode, HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, IsAny, ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, LinkAngleBraceNode, LinkBareURLNode, LinkNode, ListType, LocaleStorage, LocaleStorageOptions, LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, MarkdownContext, MarkdownOptions, MarkdownRuntime, MarkedTextNode, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, NestedParser, NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, OrderedListNode, PARAGRAPH_R, ParagraphNode, ParseState, Parser, ParserResult, Plugins, Priority, PriorityValue, ProcessedStorageAttributes, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, RuleType, RuleTypeValue, Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, TableNode, TableSeparatorNode, TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, UnorderedListNode, ValidDotPathsFor, ValueAtKey, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, compile, compileWithOptions, condition as cond, conditionPlugin, createCachedIntl, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, file, fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, get, getBrowserLocale, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTML, getHTMLTextDir, getInsertionValues, getInternalPath, getIntlayer, getLocale, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToVueI18nFormatter, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseYaml, parserFor, percentage, qualifies, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderNothing, sanitizer, setLocaleInStorage, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, translation as t, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validatePrefix, vueI18nToIntlayerFormatter };
88
+ export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CachedIntl, CachedIntl as Intl, CodeBlockNode, CodeFencedNode, CodeInlineNode, CompileOptions, ComponentOverrides, ConditionCond, ConditionContent, ConditionContentStates, CustomComponentNode, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, DeepTransformContent, DotPath, ElementType, EnterFormat, EnumerationCond, EnumerationContent, EnumerationContentState, EscapedTextNode, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FileCond, FileContent, FileContentConstructor, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, GFM_TASK_R, Gender, GenderCond, GenderContent, GenderContentStates, GetNestingResult, GetPrefixOptions, GetPrefixResult, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTMLCommentNode, HTMLContent, HTMLContentConstructor, HTMLNode, HTMLSelfClosingNode, HTMLTag, HTMLTagsType, HTMLValidationIssue, HTMLValidationResult, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HTML_TAGS, HeadingNode, HeadingSetextNode, IInterpreterPlugin, IInterpreterPluginState, INLINE_SKIP_R, INTERPOLATION_R, ImageNode, InsertionCond, InsertionContent, InsertionContentConstructor, IsAny, ItalicTextNode, JsonValue, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, LinkAngleBraceNode, LinkBareURLNode, LinkNode, ListType, LocaleStorage, LocaleStorageOptions, LocalizedPathResult, MarkdownContent, MarkdownContentConstructor, MarkdownContext, MarkdownOptions, MarkdownRuntime, HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, MarkedTextNode, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedCond, NestedContent, NestedContentState, NestedParser, NewlineNode, NodeProps, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, OrderedListNode, PARAGRAPH_R, ParagraphNode, ParseState, Parser, ParserResult, Plugins, Priority, PriorityValue, ProcessedStorageAttributes, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, RuleType, RuleTypeValue, Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, TableNode, TableSeparatorNode, TextNode, TranslationCond, TranslationContent, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnionKeys, UnorderedListNode, VOID_ELEMENTS, ValidDotPathsFor, ValueAtKey, allowInline, anyScopeRegex, attributeValueToNodePropValue, bindIntl, blockRegex, buildMaskPlugin, captureNothing, checkIsURLAbsolute, checkMissingLocalesPlugin, compact, compile, compileWithOptions, condition as cond, conditionPlugin, createCachedIntl, createCompiler, createRenderer, currency, cx, date, deepTransformNode, editDictionaryByKeyPath, enumeration as enu, enumerationPlugin, file, fileContent, filePlugin, filterMissingTranslationsOnlyPlugin, filterTranslationsOnlyPlugin, findMatchingCondition, gender, genderPlugin, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, get, getBasePlugins, getBrowserLocale, getCanonicalPath, getCondition, getContent, getContentNodeByKeyPath, getCookie, getDefaultNode, getDictionary, getEmptyNode, getEnumeration, getFilterMissingTranslationsContent, getFilterMissingTranslationsDictionary, getFilterTranslationsOnlyContent, getFilterTranslationsOnlyDictionary, getFilteredLocalesContent, getFilteredLocalesDictionary, getHTML, getHTMLTextDir, getInsertionValues, getInternalPath, getIntlayer, getLocale, getLocaleFromPath, getLocaleFromStorage, getLocaleLang, getLocaleName, getLocalizedContent, getLocalizedPath, getLocalizedUrl, getMarkdownMetadata, getMaskContent, getMissingLocalesContent, getMissingLocalesContentFromDictionary, getMultilingualDictionary, getMultilingualUrls, getNesting, getNodeChildren, getNodeType, getPathWithoutLocale, getPerLocaleDictionary, getPrefix, getReplacedValuesContent, getRewritePath, getRewriteRules, getSplittedContent, getSplittedDictionaryContent, getStorageAttributes, getTranslation, html, i18nextToIntlayerFormatter, icuToIntlayerFormatter, inlineRegex, insertion as insert, insertContentInDictionary, insertionPlugin, intlayerToI18nextFormatter, intlayerToICUFormatter, intlayerToVueI18nFormatter, isSameKeyPath, isValidElement, list, localeDetector, localeFlatMap, localeMap, localeRecord, localeResolver, localeStorageOptions, markdown as md, mergeDictionaries, nesting as nest, nestedPlugin, normalizeAttributeKey, normalizeDictionaries, normalizeDictionary, normalizeWhitespace, number, orderDictionaries, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parseYaml, parserFor, percentage, qualifies, relativeTime, removeContentNodeByKeyPath, renameContentNodeByKeyPath, renderFor, renderNothing, sanitizer, setLocaleInStorage, simpleInlineRegex, slugify, some, splitInsertionTemplate, startsWith, translation as t, translationPlugin, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, units, unquote, updateNodeChildren, validateHTML, validateMarkdown, validatePrefix, vueI18nToIntlayerFormatter };
@@ -1,15 +1,16 @@
1
- import { DeepTransformContent, IInterpreterPluginState, NodeProps } from "./plugins.js";
1
+ import { DeepTransformContent, IInterpreterPluginState, NodeProps, Plugins } from "./plugins.js";
2
2
  import { ContentNode } from "@intlayer/types/dictionary";
3
3
  import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
4
4
 
5
5
  //#region src/interpreter/getContent/getContent.d.ts
6
+ declare const getBasePlugins: (locale?: LocalesValues, fallback?: boolean) => Plugins[];
6
7
  /**
7
8
  * Transforms a node in a single pass, applying each plugin as needed.
8
9
  *
9
10
  * @param node The node to transform.
10
11
  * @param locale The locale to use if your transformers need it (e.g. for translations).
11
12
  */
12
- declare const getContent: <T extends ContentNode, L extends LocalesValues = DeclaredLocales>(node: T, nodeProps: NodeProps, locale?: L, fallback?: boolean) => DeepTransformContent<T, IInterpreterPluginState, L>;
13
+ declare const getContent: <T extends ContentNode, L extends LocalesValues = DeclaredLocales>(node: T, nodeProps: NodeProps, plugins?: Plugins[]) => DeepTransformContent<T, IInterpreterPluginState, L>;
13
14
  //#endregion
14
- export { getContent };
15
+ export { getBasePlugins, getContent };
15
16
  //# sourceMappingURL=getContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getContent.d.ts","names":[],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"mappings":";;;;;;;AAwBA;;;;cAAa,UAAA,aACD,WAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,IAAA,EAAM,CAAA,EACN,SAAA,EAAW,SAAA,EACX,MAAA,GAAS,CAAA,EACT,QAAA,eAqBM,oBAAA,CAAqB,CAAA,EAAG,uBAAA,EAAyB,CAAA"}
1
+ {"version":3,"file":"getContent.d.ts","names":[],"sources":["../../../../src/interpreter/getContent/getContent.ts"],"mappings":";;;;;cAqBa,cAAA,GACX,MAAA,GAAS,aAAA,EACT,QAAA,eACC,OAAA;;AAHH;;;;;cAsBa,UAAA,aACD,WAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,IAAA,EAAM,CAAA,EACN,SAAA,EAAW,SAAA,EACX,OAAA,GAAS,OAAA,OAKH,oBAAA,CAAqB,CAAA,EAAG,uBAAA,EAAyB,CAAA"}
@@ -1,4 +1,4 @@
1
1
  import { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, IsAny, NestedCond, NodeProps, Plugins, TranslationCond, UnionKeys, ValueAtKey, conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, translationPlugin } from "./plugins.js";
2
2
  import { deepTransformNode } from "./deepTransform.js";
3
- import { getContent } from "./getContent.js";
4
- export { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, IsAny, NestedCond, NodeProps, Plugins, TranslationCond, UnionKeys, ValueAtKey, conditionPlugin, deepTransformNode, enumerationPlugin, filePlugin, genderPlugin, getContent, insertionPlugin, nestedPlugin, translationPlugin };
3
+ import { getBasePlugins, getContent } from "./getContent.js";
4
+ export { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, IsAny, NestedCond, NodeProps, Plugins, TranslationCond, UnionKeys, ValueAtKey, conditionPlugin, deepTransformNode, enumerationPlugin, filePlugin, genderPlugin, getBasePlugins, getContent, insertionPlugin, nestedPlugin, translationPlugin };
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../../../src/interpreter/getContent/plugins.ts"],"mappings":";;;;;;;;;;;AAoCA;;;;;;;AAAA,KAAY,OAAA;EACV,EAAA;EACA,SAAA,GAAY,IAAA;EACZ,SAAA,GACE,IAAA,OACA,KAAA,EAAO,SAAA,EACP,WAAA,GAAc,IAAA,OAAW,KAAA,EAAO,SAAA;AAAA;;;;KAQxB,SAAA,MAAe,CAAA,yBAA0B,CAAA;AAAA,KACzC,UAAA,SAAmB,CAAA,mBAC3B,CAAA,eAAgB,CAAA,GACd,CAAA,CAAE,CAAA;AAAA,KAII,eAAA,iBAAgC,aAAA,IAAiB,CAAA;EAC3D,QAAA,EAAU,QAAA;EAAA,CACT,QAAA,CAAS,WAAA;AAAA,IAER,CAAA,SAAU,MAAA,CAAO,WAAA,aACf,CAAA,OAAQ,CAAA,UAAW,MAAA,CAAO,WAAA,qBAEhB,SAAA,CAAU,CAAA,OAAQ,CAAA,KAAM,CAAA,eAAgB,CAAA,GAC1C,CAAA,eAAgB,CAAA,CAAE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A,MAAA;EACA,IAAA;AAAA;;;;KAMG,gBAAA,oBAEa,kBAAA,CAAmB,CAAA,EAAG,CAAA,EAAG,CAAA,gBAE/B,aAAA,GAAgB,eAAA,IACxB,CAAA,eAAgB,CAAA,GAEhB,CAAA,CAAE,CAAA,iBAEA,kBAAA,CAAmB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA,0BAG1B,kBAAA,CAAmB,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA;;;;KAO/B,QAAA,iBAAyB,aAAA,GAAgB,eAAA,IAC5C,CAAA,SAAU,aAAA,YACN,KAAA,CAAM,oBAAA,CAAqB,CAAA,EAAG,CAAA,EAAG,CAAA,KACjC,CAAA,gCACgB,CAAA,GAAI,oBAAA,CAAqB,CAAA,CAAE,CAAA,GAAI,CAAA,EAAG,CAAA,MAChD,CAAA;AAAA,KAEI,KAAA,oBAAyB,CAAA;;;;KAKzB,oBAAA,QAEN,uBAAA,YACM,aAAA,GAAgB,eAAA,IAE1B,KAAA,CAAM,CAAA,iBACF,CAAA,GACA,gBAAA,CAAiB,CAAA,QAAS,kBAAA,CAAmB,CAAA,EAAG,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,CAAA,kBAExD,QAAA,CAAS,CAAA,EAAG,CAAA,EAAG,CAAA,IAEf,gBAAA,CAAiB,CAAA,QAAS,kBAAA,CAAmB,CAAA,EAAG,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"mappings":";;;;;;;;AAkBA;;;;;cAAa,aAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,EACT,OAAA,GAAU,OAAA,OACT,oBAAA,CAAqB,CAAA,aAAc,uBAAA,EAAyB,CAAA"}
1
+ {"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../../src/interpreter/getDictionary.ts"],"mappings":";;;;;;;;AAqBA;;;;;cAAa,aAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,EACT,OAAA,GAAS,OAAA,OACR,oBAAA,CAAqB,CAAA,aAAc,uBAAA,EAAyB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getHTML.d.ts","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"mappings":";;;;;;;KAMK,SAAA,IAAa,KAAA;EAAS,QAAA;EAAA,CAAmB,GAAA;AAAA;AAAmB;;;AAAA,KAK5D,eAAA;EACH,GAAA;EACA,KAAA,GAAQ,MAAA;AAAA;;;AAAM;;;;KASX,UAAA,GAAa,MAAA,SAAe,SAAA,YAAqB,eAAA;;;;cAuHzC,OAAA,GAAW,OAAA,UAAiB,MAAA,EAAQ,UAAA"}
1
+ {"version":3,"file":"getHTML.d.ts","names":[],"sources":["../../../src/interpreter/getHTML.ts"],"mappings":";;;;;;;KAMK,SAAA,IAAa,KAAA;EAAS,QAAA;EAAA,CAAmB,GAAA;AAAA;AAAmB;;;AAAA,KAK5D,eAAA;EACH,GAAA;EACA,KAAA,GAAQ,MAAA;AAAA;;;AAAM;;;;KASX,UAAA,GAAa,MAAA,SAAe,SAAA,YAAqB,eAAA;;;;cA4HzC,OAAA,GAAW,OAAA,UAAiB,MAAA,EAAQ,UAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"mappings":";;;;cA6Ca,WAAA,aACD,cAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,EACT,OAAA,GAAU,OAAA,OACT,oBAAA,CACD,yBAAA,CAA0B,CAAA,GAC1B,uBAAA,EACA,CAAA"}
1
+ {"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../../src/interpreter/getIntlayer.ts"],"mappings":";;;;cAmDa,WAAA,aACD,cAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,EACT,OAAA,GAAU,OAAA,OACT,oBAAA,CACD,yBAAA,CAA0B,CAAA,GAC1B,uBAAA,EACA,CAAA"}
@@ -2,11 +2,11 @@ import { getCondition } from "./getCondition.js";
2
2
  import { GetNestingResult, getNesting } from "./getNesting.js";
3
3
  import { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, IsAny, NestedCond, NodeProps, Plugins, TranslationCond, UnionKeys, ValueAtKey, conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, insertionPlugin, nestedPlugin, translationPlugin } from "./getContent/plugins.js";
4
4
  import { deepTransformNode } from "./getContent/deepTransform.js";
5
- import { getContent } from "./getContent/getContent.js";
5
+ import { getBasePlugins, getContent } from "./getContent/getContent.js";
6
6
  import { getDictionary } from "./getDictionary.js";
7
7
  import { findMatchingCondition, getEnumeration } from "./getEnumeration.js";
8
8
  import { getHTML } from "./getHTML.js";
9
9
  import { getIntlayer } from "./getIntlayer.js";
10
10
  import { getTranslation } from "./getTranslation.js";
11
11
  import { splitInsertionTemplate } from "./splitAndJoinInsertion.js";
12
- export { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, IsAny, NestedCond, NodeProps, Plugins, TranslationCond, UnionKeys, ValueAtKey, conditionPlugin, deepTransformNode, enumerationPlugin, filePlugin, findMatchingCondition, genderPlugin, getCondition, getContent, getDictionary, getEnumeration, getHTML, getIntlayer, getNesting, getTranslation, insertionPlugin, nestedPlugin, splitInsertionTemplate, translationPlugin };
12
+ export { ConditionCond, DeepTransformContent, EnumerationCond, FileCond, GenderCond, GetNestingResult, IInterpreterPlugin, IInterpreterPluginState, InsertionCond, IsAny, NestedCond, NodeProps, Plugins, TranslationCond, UnionKeys, ValueAtKey, conditionPlugin, deepTransformNode, enumerationPlugin, filePlugin, findMatchingCondition, genderPlugin, getBasePlugins, getCondition, getContent, getDictionary, getEnumeration, getHTML, getIntlayer, getNesting, getTranslation, insertionPlugin, nestedPlugin, splitInsertionTemplate, translationPlugin };
@@ -1,9 +1,11 @@
1
+ import { HTMLValidationIssue } from "../transpiler/html/validateHTML.js";
1
2
  import { getMarkdownMetadata } from "../transpiler/markdown/getMarkdownMetadata.js";
2
3
  import { MarkdownContent, MarkdownContentConstructor, md as markdown } from "../transpiler/markdown/markdown.js";
4
+ import { MarkdownValidationResult, validateMarkdown } from "../transpiler/markdown/validateMarkdown.js";
3
5
  import { BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CodeBlockNode, CodeFencedNode, CodeInlineNode, CompileOptions, ComponentOverrides, CustomComponentNode, ElementType, EscapedTextNode, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, HTMLCommentNode, HTMLNode, HTMLSelfClosingNode, HTMLTag, HeadingNode, HeadingSetextNode, ImageNode, ItalicTextNode, LinkAngleBraceNode, LinkBareURLNode, LinkNode, MarkdownContext, MarkdownOptions, MarkdownRuntime, MarkedTextNode, NestedParser, NewlineNode, OrderedListNode, ParagraphNode, ParseState, Parser, ParserResult, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, Rules, StrikethroughTextNode, TableNode, TableSeparatorNode, TextNode, UnorderedListNode } from "./types.js";
4
6
  import { compile, compileWithOptions, createCompiler } from "./compiler.js";
5
7
  import { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, INLINE_SKIP_R, INTERPOLATION_R, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, ListType, NAMED_CODES_TO_UNICODE, NP_TABLE_R, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, PARAGRAPH_R, Priority, PriorityValue, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, RuleType, RuleTypeValue, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex } from "./constants.js";
6
8
  import { parserFor } from "./parser.js";
7
9
  import { createRenderer, renderFor } from "./renderer.js";
8
10
  import { allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, cx, get, inlineRegex, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, qualifies, renderNothing, sanitizer, simpleInlineRegex, slugify, some, startsWith, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote } from "./utils.js";
9
- export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CodeBlockNode, CodeFencedNode, CodeInlineNode, CompileOptions, ComponentOverrides, CustomComponentNode, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, ElementType, EscapedTextNode, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTMLCommentNode, HTMLNode, HTMLSelfClosingNode, HTMLTag, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HeadingNode, HeadingSetextNode, INLINE_SKIP_R, INTERPOLATION_R, ImageNode, ItalicTextNode, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, LinkAngleBraceNode, LinkBareURLNode, LinkNode, ListType, MarkdownContent, MarkdownContentConstructor, MarkdownContext, MarkdownOptions, MarkdownRuntime, MarkedTextNode, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedParser, NewlineNode, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, OrderedListNode, PARAGRAPH_R, ParagraphNode, ParseState, Parser, ParserResult, Priority, PriorityValue, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, RuleType, RuleTypeValue, Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, TableNode, TableSeparatorNode, TextNode, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnorderedListNode, allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, compile, compileWithOptions, createCompiler, createRenderer, cx, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, get, getMarkdownMetadata, inlineRegex, markdown as md, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parserFor, qualifies, renderFor, renderNothing, sanitizer, simpleInlineRegex, slugify, some, startsWith, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote };
11
+ export { ATTRIBUTES_TO_SANITIZE, ATTRIBUTE_TO_NODE_PROP_MAP, ATTR_EXTRACTOR_R, BLOCKQUOTE_ALERT_R, BLOCKQUOTE_R, BLOCKQUOTE_TRIM_LEFT_MULTILINE_R, BLOCK_END_R, BREAK_LINE_R, BREAK_THEMATIC_R, BlockQuoteNode, BoldTextNode, BreakLineNode, BreakThematicNode, CAPTURE_LETTER_AFTER_HYPHEN, CODE_BLOCK_FENCED_R, CODE_BLOCK_R, CODE_INLINE_R, CONSECUTIVE_NEWLINE_R, CR_NEWLINE_R, CUSTOM_COMPONENT_R, CodeBlockNode, CodeFencedNode, CodeInlineNode, CompileOptions, ComponentOverrides, CustomComponentNode, DO_NOT_PROCESS_HTML_ELEMENTS, DURATION_DELAY_TRIGGER, ElementType, EscapedTextNode, FOOTNOTE_R, FOOTNOTE_REFERENCE_R, FORMFEED_R, FRONT_MATTER_R, FootnoteNode, FootnoteReferenceNode, GFMTaskNode, GFM_TASK_R, HEADING_ATX_COMPLIANT_R, HEADING_R, HEADING_SETEXT_R, HTMLCommentNode, HTMLNode, HTMLSelfClosingNode, HTMLTag, HTML_BLOCK_ELEMENT_R, HTML_CHAR_CODE_R, HTML_COMMENT_R, HTML_CUSTOM_ATTR_R, HTML_LEFT_TRIM_AMOUNT_R, HTML_SELF_CLOSING_ELEMENT_R, HeadingNode, HeadingSetextNode, INLINE_SKIP_R, INTERPOLATION_R, ImageNode, ItalicTextNode, LINK_AUTOLINK_BARE_URL_R, LINK_AUTOLINK_R, LIST_LOOKBEHIND_R, LOOKAHEAD, LinkAngleBraceNode, LinkBareURLNode, LinkNode, ListType, MarkdownContent, MarkdownContentConstructor, MarkdownContext, MarkdownOptions, MarkdownRuntime, HTMLValidationIssue as MarkdownValidationIssue, MarkdownValidationResult, MarkedTextNode, NAMED_CODES_TO_UNICODE, NP_TABLE_R, NestedParser, NewlineNode, ORDERED, ORDERED_LIST_BULLET, ORDERED_LIST_ITEM_PREFIX, ORDERED_LIST_ITEM_PREFIX_R, ORDERED_LIST_ITEM_R, ORDERED_LIST_R, OrderedListNode, PARAGRAPH_R, ParagraphNode, ParseState, Parser, ParserResult, Priority, PriorityValue, REFERENCE_IMAGE_OR_LINK, REFERENCE_IMAGE_R, REFERENCE_LINK_R, ReferenceImageNode, ReferenceLinkNode, ReferenceNode, RenderRuleHook, Rule, RuleOutput, RuleType, RuleTypeValue, Rules, SHORTCODE_R, SHOULD_RENDER_AS_BLOCK_R, StrikethroughTextNode, TABLE_CENTER_ALIGN, TABLE_LEFT_ALIGN, TABLE_RIGHT_ALIGN, TABLE_TRIM_PIPES, TAB_R, TEXT_BOLD_R, TEXT_EMPHASIZED_R, TEXT_ESCAPED_R, TEXT_MARKED_R, TEXT_PLAIN_R, TEXT_STRIKETHROUGHED_R, TRIM_STARTING_NEWLINES, TableNode, TableSeparatorNode, TextNode, UNESCAPE_R, UNORDERED, UNORDERED_LIST_BULLET, UNORDERED_LIST_ITEM_PREFIX, UNORDERED_LIST_ITEM_PREFIX_R, UNORDERED_LIST_ITEM_R, UNORDERED_LIST_R, UnorderedListNode, allowInline, anyScopeRegex, attributeValueToNodePropValue, blockRegex, captureNothing, compile, compileWithOptions, createCompiler, createRenderer, cx, generateListItemPrefix, generateListItemPrefixRegex, generateListItemRegex, generateListRegex, get, getMarkdownMetadata, inlineRegex, markdown as md, normalizeAttributeKey, normalizeWhitespace, parseBlock, parseCaptureInline, parseInline, parseSimpleInline, parseStyleAttribute, parseTableAlign, parseTableAlignCapture, parseTableCells, parseTableRow, parserFor, qualifies, renderFor, renderNothing, sanitizer, simpleInlineRegex, slugify, some, startsWith, trimEnd, trimLeadingWhitespaceOutsideFences, unescapeString, unquote, validateMarkdown };