@asimojs/lml
Version:
LML - List Markup Language
43 lines (42 loc) • 2.05 kB
TypeScript
/// <reference types="react" />
import { LML, JsxContent, LmlFormatter, LmlUpdate, LmlNode, LmlNodeType, LmlSanitizationRules } from "./types";
/**
* Return the type of an LML node
* @param node
* @returns
*/
export declare function nodeType(node: LML): LmlNodeType;
export declare const RX_NODE_NAME: RegExp;
/**
* Scan LML data and transform them to JSX thanks to the formatter passed as arguement
* @param v an LML value
* @param f the formatter (that will call the jsx runtime behinde the scenes)
* @returns
*/
export declare function processJSX(v: LML, f: LmlFormatter): JsxContent;
/**
* Default sanitization rules - rather aggressive to avoid unecessary complexity
* (can be overridden and tuned on the application side)
*/
export declare const defaultSanitizationRules: LmlSanitizationRules;
/**
* Convert an LML structure to a JSX tree through a createElement like function (argument).
* The JSX tree is also sanitized
* @param v the lml data to convert
* @param createElement the React.createElement function (or h function for preact)
* @param getComponent a function called when a component is found to retrieve an actual component reference [optional]
* @param error error handler that will be called in case of error [optional]
* @returns
*/
export declare function lml2jsx(v: LML, createElement: (type: any | Function, props: {
[key: string]: any;
}, ...children: any) => JSX.Element, getComponent?: ((name: string, namespace: string) => Function | null) | null, error?: ((msg: string) => void) | null, sanitizationRules?: LmlSanitizationRules): JsxContent;
/**
* In-place update of an LML data structure with instructions provided as arguments
* Return the new data structure (may be different if the original data is not a fragment)
* @param data
* @param instructions
* @returns
*/
export declare function updateLML(data: LML, instructions: LmlUpdate[]): LML;
export declare function scan(data: any, process: (nodeKey: string, node: LmlNode, parent: any, parentRef: string | number) => boolean): void;