import { IObject, NodeType } from './pview.model'; import { IVnode, IComponent, IReferenceNode } from './component.model'; import { Component } from './component'; /** * pview.js * @CreatedOn: 20-Sep-2017 * @author: Kausik Dey * @version: 1.0.0 * @description:This will create a View Engin Aka - pView, for render JSX virtual DOM to a real DOM. * 'virtual DOM'? It's just JSON - each 'VNode' is an object with 3 properties. nodeName, Attributes, children * The whole process (JSX -> VDOM -> DOM) in one step * * TODO: If the first element in jsx is a component type then behave incorrectly, Need to fix this. */ /** * MountTo will render virtual DOM Into Real DOM and add append element into the real DOM * @param {IVnode} node - It will be a real DOM node or Virtual node which can be mount. * @param {HTMLElement | SVGElement} targetNode - This will be the target DOM where actually mount will done. * @param {NodeType} nodeType - This flag decide node variable having real node or virtual node ['vnode' | 'rnode']. * @param {HTMLElement | null} oldNode - This is a optional param. It is used to replace a node without removing other child of parent node. * @param {IObject} ctx Pass the existing context. * @param {Boolean} emptyBeforeMount Empty the target node before mount when true. * @returns {SVGElement} A component object. * */ export declare function mountTo(node: IVnode, targetNode: HTMLElement | SVGElement, nodeType?: NodeType, oldNode?: HTMLElement | null, ctx?: IObject, emptyBeforeMount?: boolean): IComponent; /** * Render virtual node into real DOM node in memory. * @param {IVnode} vnode Virtual Node object. * @returns {IComponent} Real DOM node. */ export declare function renderDOM(vnode: IVnode): IComponent; /** * Method will recursively replace the virtual class with real object which previously constructed to avoid constructor call during * component update. * @param {Object} subNodes Virtual nodes with component class. * @param {Object} refs Real object that previously constructed. * @param {Object} replaceChildren Replace all classes of its children recursively. */ export declare function _replaceClassWithObject(subNodes: IVnode, refs: IReferenceNode, replaceChildren: boolean): void; export declare function _rearrangeOldVNodes(oldVNode: IVnode, newVNode: IVnode, ref: IReferenceNode): void; /** * Hyperscript generator, gets called by transpile JSX. * @param {String} nodeName Name of the element like: rect, path or * @param {Array} attributes Array of attribute of the element * @param {any[]} args Children of the element that passed as args. * @returns {IVnode} virtual dom object of element */ export declare function __h__(nodeName: string, attributes: IObject, ...args: any[]): IVnode; /** * Merges the enumerable properties of two or more objects deeply. * It will modify the destination object. * Ref: https://www.npmjs.com/package/deepmerge. * @param {any} dest Destination object which will be extends by rest of the paramter objects. * @param {...any} args Array of source object. * @return {Object} Merged object. */ export declare function _extends(dest: IObject, ...args: IObject[]): IObject; /** * Convert style JSON into string, gets called by transpile JSX * @param {string | IObject} objStyle style json object * @returns {string} return string of css */ export declare function parseStyleProps(objStyle: string | IObject): string; /** * Attach events with real DOM. * @param {IObject} events JSON List of events. * @param {SVGElement | HTMLElement | Text} node Real DOM Element. * @returns {string} Returns List of attached events as string. */ export declare function parseEventsProps(events: IObject, node: SVGElement | HTMLElement | Text): string; /** * This will return true if instance is es6 class type. * @param {any} _class Object of a class to test. * @returns {boolean} true if it's a class instance otherwise returns false. */ export declare function isNativeClass(_class: any): boolean; export { Component };