/**
* Value printers: how <%= %> renders an OBJECT.
*
* Primitives never come here - the generated template code routes only
* non-null, non-array objects to print_object(), so a hundred-row list of
* strings costs exactly what it did before. An object reaching an
* interpolation is walked through the printer chain in registration order;
* the first printer to return anything but undefined handles it. A printer
* returns a string (escaped or not according to the construct, exactly as a
* string literal at that site) or a component descriptor:
*
* { component: { name: 'Rich_Text_Display', args: { value }, attrs: { class: 'x' } } }
*
* which jqhtml mounts as if the template had written the tag - live in the
* browser, server-rendered under SSR - with no environment awareness on the
* printer's side. A descriptor carries no content.
*
* Attribute position (
) compiles through a different
* path and never consults printers.
*/
export type Print_Mode = 'escape' | 'raw' | 'nl2br';
export interface Component_Descriptor {
component: {
name: string;
args?: Record;
attrs?: Record;
};
}
export type Object_Printer = (value: object) => undefined | string | Component_Descriptor;
/** A mounted descriptor, in the instruction form the runtime already understands. */
export type Component_Instruction = {
comp: [string, Record];
};
/**
* Register a printer at the end of the chain. Printers run in registration
* order; return undefined to decline, a string, or a component descriptor.
*/
export declare function add_object_printer(printer: Object_Printer): void;
/** The registered printers, in order. Read-only view for diagnostics. */
export declare function get_object_printers(): readonly Object_Printer[];
/**
* Render an object at an interpolation site. Called by compiled templates for
* every non-null, non-array object reaching <%= %>, <%!= %> or <%br= %>.
* Throws when nothing handles the value or a printer returns garbage.
*/
export declare function print_object(value: object, mode: Print_Mode): string | Component_Instruction;
//# sourceMappingURL=value-printers.d.ts.map