import type { RenderHtml, WompoComponent, WompoProps } from '../wompo.js'; import type { SsrContext } from './types.js'; export declare class Serializer { private ctx; private rootBuf; private frames; /** Monotonic per-document counter backing each component's `data-wompo-ssr=""`. */ private ssrIdSeq; /** ssrId of the component whose template is currently being walked. `${children}` interps * emit `` so a parent's adopt() can find the region of the component it * bound (and not a region re-homed one level deeper, e.g. `<${A}>x` where `A` renders * `<${B}>${children}` — both regions end up in `B`'s output). */ private ownerSsrId; constructor(ctx: SsrContext); /** Top-level entry: render a root component and return its HTML. */ renderRoot(Component: WompoComponent, props: WompoProps): Promise; /** Where output is currently being written. Inside an open-tag of a component frame, output * goes to the parent buffer (the opening `` text); inside the children of a * frame, output goes to that frame's children buffer. */ private currentBuf; walkTemplate(tpl: RenderHtml): Promise; private processPart; /** When the parser sees `>` that ends an open tag, push the tag-close to the correct buffer * (parent for a component frame, current for native), inject island markers if applicable, * mark the frame's open tag closed, and switch to raw-text mode for raw-text elements. If * self-closing (`<${Comp} />`), immediately render+pop the frame. */ private closeOpenTag; /** Resolve the island hydration mode for a (Component, props) pair. A `client:*` directive on * the call site overrides the component's default `options.island`. Returns null when the * component should not be hydrated. */ private resolveIslandMode; /** Push ` data-wompo-island="N" data-wompo-mode="M"` to parentBuf BEFORE the open-tag '>' * is emitted. Stores the island in the SSR context registry. */ private injectIslandMarkers; /** Mark every wompo component emitted server-side with `data-wompo-ssr=""`. The client-side * `connectedCallback` reads this marker and skips its destructive `__initElement` re-render — * the SSR'd DOM IS the rendered output for non-island components, and islands handle their * own hydration via `_$hydrate()`. The id value pairs the element with its own re-homed * `${children}` region marker (``). */ private injectSsrMarker; /** After the open-tag '>' has been emitted, emit the JSON props payload as the first child * of the component (read by the hydration runtime). */ private emitIslandPropsTemplate; /** Strip server-only / non-serializable keys from the props payload before islanding. */ private sanitizePropsForIsland; /** Bare attribute (no `=`). For native open tags the chars are already in the buf via the * char walker; for an open component frame the walker suppressed them, so record the * boolean prop AND rebuild the bare attribute into parentBuf. The client upgrade reads * host attributes back as props (`'' → true`), so dropping the attribute here would flip * the prop to `undefined` after hydration. */ private flushBareAttrIfNeeded; /** Flush an attribute at its end (closing quote / whitespace / `>`). For component frames, * the attr chars were suppressed during emission; rebuild the full ` name="value"` (or * boolean form) into parentBuf. For native elements the chars streamed through already — * here we only handle the two interp-driven cases: `?bool="${v}"` (name suppressed → emit * the bare name iff truthy) and a fully-empty interpolated value (drop the attribute, * mirroring the client's removeAttribute for nullish values). Returns true when the * attribute was dropped and the caller must not emit the closing quote. */ private flushAccumulatedAttr; private processInterp; /** Emit a single attribute value. * * `inlineName=true` means the attribute name + `=` are already in the buffer (an interp at the * `name=` position). `inlineName=false` means we must emit ` name="value"` ourselves (used by * attrs() spread and component-frame open-tag rebuilds). */ private emitAttrValue; /** Push the context-provider's `value` prop onto the active SSR context stack. */ private maybePushProviderValue; private emitSpread; /** The topmost frame whose open tag is still being collected, or null. */ private openTagFrame; /** Innermost enclosing `` frame (set on `closeOpenTag` in streaming mode). */ private enclosingSuspenseFrame; private renderAndPop; /** Emit a component with its wrapping `` / `` — used by * the root entry where no caller has emitted the open tag yet. */ private emitComponent; /** Render a component's own template into the given buffer, with optional shadow wrapping. * `ssrId` is the id emitted on the component's `data-wompo-ssr` attribute; it becomes the * owner id of any `` children-region marker produced by this render. */ private emitComponentInto; /** Walk a template, routing all output into `targetBuf`. Saves/restores serializer state. */ private walkTemplateInto; /** Emit a single value (string, RenderHtml, component, ...) into `targetBuf`. */ private emitNodeInto; /** Push static-attr text (` k="v"`) into `targetBuf` for each serializable prop. */ private emitAttrsFromProps; private emitNode; } export declare function lookupComponent(tag: string): WompoComponent | undefined;