import { SlotBindingData, AttributeExpressionData } from '@riotjs/dom-bindings' // This interface is only exposed and any Riot component will receive the following properties export interface RiotCoreComponent { // automatically generated on any component instance readonly props: Props readonly root: HTMLElement readonly name?: string // TODO: add the @riotjs/dom-bindings types readonly slots: SlotBindingData[] mount( element: HTMLElement, initialState?: State, parentScope?: object ): RiotComponent update( newState?: Partial, parentScope?: object ): RiotComponent unmount(keepRootElement: boolean): RiotComponent // Helpers $(selector: string): HTMLElement $$(selector: string): [HTMLElement] } // Riot Pure Component interface that should be used together with riot.pure export interface RiotPureComponent { mount( element: HTMLElement, context?: Context, ): RiotPureComponent update( context?: Context, ): RiotPureComponent unmount(keepRootElement: boolean): RiotPureComponent } export interface PureComponentFactoryFunction { ({slots, attributes, props}:{ slots?: SlotBindingData[], attributes?: AttributeExpressionData[], props?: InitialProps; }): RiotPureComponent } // This object interface is created anytime a riot file will be compiled into javascript export interface RiotComponentShell { readonly css?: string readonly exports?: () => RiotComponentExport|object readonly name?: string // TODO: add the @riotjs/dom-bindings types template(): any } // Interface that can be used when creating the components export export interface RiotComponentExport { // optional on the component object state?: State // optional alias to map the children component names components?: { [key: string]: RiotComponentShell } // state handling methods shouldUpdate?(newProps: Props, currentProps: Props): boolean // lifecycle methods onBeforeMount?(currentProps: Props, currentState: State): void onMounted?(currentProps: Props, currentState: State): void onBeforeUpdate?(currentProps: Props, currentState: State): void onUpdated?(currentProps: Props, currentState: State): void onBeforeUnmount?(currentProps: Props, currentState: State): void onUnmounted?(currentProps: Props, currentState: State): void [key: string]: any } // All the RiotComponent Public interface properties are optional export interface RiotComponent extends RiotCoreComponent, RiotComponentExport {} export type RegisteredComponentsMap = Map RiotComponent> export type ComponentEnhancer = (component: RiotComponent) => RiotComponent export type InstalledPluginsSet = Set export function register(componentName: string, shell: RiotComponentShell): RegisteredComponentsMap export function unregister(componentName: string): RegisteredComponentsMap export function mount(selector: string, initialProps?: Props, componentName?: string): RiotComponent[] export function unmount(selector: string, keepRootElement: boolean):HTMLElement[] export function install(plugin: ComponentEnhancer):InstalledPluginsSet export function uninstall(plugin: ComponentEnhancer):InstalledPluginsSet export function component(shell: RiotComponentShell):( el: HTMLElement, initialProps?: Props, meta?: { slots: SlotBindingData[]; attributes: AttributeExpressionData[]; } ) => RiotComponent export function pure>(func: FactoryFunction): FactoryFunction export const version: string