UNPKG

bona

Version:

Super lightweight microframework focused on static websites and landing pages.

176 lines 5.79 kB
export default class Core extends Base { /** * @typedef {Object} BonaOptions * @property {boolean} [init] Initialize an app immediately. * @property {Object[]} [define] Array of components to define. */ /** * Initializes the core. * * @param {BonaOptions} [options] Options. */ constructor(options?: { /** * Initialize an app immediately. */ init?: boolean; /** * Array of components to define. */ define?: any[]; }); /** @type {BonaOptions} **/ options: { /** * Initialize an app immediately. */ init?: boolean; /** * Array of components to define. */ define?: any[]; }; store: Map<any, any>; registry: Map<any, any>; isFullyLoaded: boolean; /** * Performs basic hooks. * * @return {Promise} */ init(): Promise<any>; /** * Refresh component store. * * @param {boolean} [fireRefresh] Fire refresh hook in instances. * @param {boolean} [fireDestroy] Fire destroy hook when detach non-existent nodes. * @param {boolean} [detachNodes] Detach non-existent nodes from store. * @return {Promise} */ refresh(fireRefresh?: boolean, fireDestroy?: boolean, detachNodes?: boolean): Promise<any>; /** * Execute hooks in all instances. * * @param {string} [hook] Hook name. * @return {Promise} */ executeAll(hook?: string): Promise<any>; /** * Execute hook in an instance. * * @param {Component} instance Component instance. * @param {string} [hook] Hook name. * @return {Promise} */ executeInstance(instance: Component, hook?: string): Promise<any>; /** * Wait until the component hook is completed. * * @param {string} namespace Namespace. * @param {string} [hook] Hook name. * @param {number} [index] Instance index. * @return {Promise} */ wait(namespace: string, hook?: string, index?: number): Promise<any>; /** * Wait until hooks are completed in all instances. * * @param {string} namespace Namespace. * @param {string} [hook] Hook name. * @return {Promise} */ waitAll(namespace: string, hook?: string): Promise<any>; /** * Wait until the hook is completed in an instance. * * @param {Component} instance Component instance. * @param {string} [hook] Hook name. * @return {Promise} */ waitInstance(instance: Component, hook?: string): Promise<any>; /** * Wait until the page has fully loaded. * * @return {Promise} */ waitFullLoad(): Promise<any>; /** * Create component instance in the store. * * @param {string} namespace Namespace. * @param {HTMLElement} [el] Element. * @param {Object} [options] Options that will pass to instance. * @param {boolean} [fireInit] Fire init hook. * @return {Component} Component instance. */ attach(namespace: string, el?: HTMLElement, options?: any, fireInit?: boolean): Component; /** * Remove component instance from store. * * @param {Component} instance Component instance. * @param {boolean} [fireDestroy] Fire destroy hook. * @return {Component} Component instance. */ detach(instance: Component, fireDestroy?: boolean): Component; /** * Register component. * * @param {string} namespace Namespace. * @param {Object} component Component class. * @param {string} [assign] Assigned DOM selector. * @param {Object} [options] The options object that will be passed to each instance. */ define(namespace: string, component: any, assign?: string, options?: any): void; /** * Register array of components. */ defineAll(arr: any): void; /** * Return component instance. * * @param {string} namespace Namespace. * @param {number} [index] Instance index. * @return {Component|*} Component instance. */ get(namespace: string, index?: number): Component | any; /** * Return all component instances. * * @param {string} namespace Namespace. * @return {Component[]|*[]} Array of component instances. */ getAll(namespace: string): Component[] | any[]; /** * Find component instance that matches a CSS selector. * * @param {string|Element} selector Selector or node. * @param {string} [namespace] Namespace. * @param {number} [index] Instance index. * @return {Component|*} Component instance. */ find(selector: string | Element, namespace?: string, index?: number): Component | any; /** * Find all component instances that match a CSS selector. * * @param {string|Element} selector Selector or node. * @param {string} [namespace] Namespace. * @return {Component[]|*[]} Array of component instances. */ findAll(selector: string | Element, namespace?: string): Component[] | any[]; /** * Returns the first element that matches a CSS selector. * * @param {string|Object} selector Selector. * @return {null|Element|Object} */ query(selector: string | any): null | Element | any; /** * Returns all elements that match a CSS selector. * * @param {string|Object} selector Selector. * @return {Element[]|Object} */ queryAll(selector: string | any): Element[] | any; } import Base from "../base"; //# sourceMappingURL=index.d.ts.map