import { ComponentUIDL, GeneratorOptions } from '@teleporthq/teleport-types'; /** * Makes the generated markup parse into the tree it was rendered as. * * Server-rendered HTML is re-parsed by the browser before React hydrates it, * and a handful of tag combinations make the parser rewrite the tree — closing * a `

` early, hoisting a `

` out of a ``, dropping a nested * ``. Whatever React rendered on the server no longer matches the DOM it * finds on the client, hydration fails, and the page is silently re-rendered * from scratch: styles flash, server-computed content is thrown away, and the * console fills with "Hydration failed because the initial UI does not match * what was rendered on the server". * * The pass runs after the element mapping, so every `elementType` is already * the tag that will be emitted (`text`+`p` has become `p`, a navlink has become * `Link` wrapping an `a`). It walks the resolved tree with the same * `ancestorInfo` bookkeeping react-dom's `validateDOMNesting` uses, so it flags * exactly what React would have flagged at runtime — only early enough to do * something about it. * * Paragraph content is repaired in place, because a rename is enough and costs * nothing (see `paragraph-repair`). The rest is reported: renaming a `` * or a `
` to make it parse would throw away the behaviour it was added for. * * Element types that are not HTML tags — `Link`, `Repeater`, `Fragment`, * `TqMotion`, custom elements — have no content model of their own. They are * walked THROUGH rather than treated as a boundary: `