@finapi/finapi-js-loader
Version:
finAPI JS Loader
33 lines (32 loc) • 1.93 kB
TypeScript
import { Callbacks, Properties } from './types';
export declare abstract class Widget<PROPERTIES extends Properties, CALLBACKS extends Callbacks> {
private ownerDocument;
private scriptId;
private container;
private webComponentId;
private source;
private internalProps?;
/**
* @param id - unique identifier of the widget used for injecting HTML nodes
* @param container - parent HTML element where the widget will be injected
* @param target - URL of the environment from which the widget's JS bundle will be fetched. Use this, for example, when testing features that are only released to the sandbox environment. By default, `https://widget-library-finapi-general-live.finapi.io` is used.
* @param ownerDocument - parent Document where the widget will be injected. For example, shadow root or document fragment. By default, the default top-level document is used.
* @param customBundleFileName - allows modifying the filename of the widget's JS bundle that will be fetched. By default, bundle filenames are determined from the supplied `id`. This property is useful during dev mode when widgets are generated together into one `main.js` file.
* @param internalProps - internal properties that will be passed to the widget.
*/
constructor(id: string, container: HTMLElement, target?: string, ownerDocument?: Document, customBundleFileName?: string, internalProps?: Record<string, unknown>);
/**
* Loads the web component into the container element.
*
* @param properties - Optional properties to be passed to the web component.
* @param callbacks - Optional callbacks to be passed to the web component.
*/
load(properties?: PROPERTIES, callbacks?: CALLBACKS): void;
/**
* Removes the web component from the DOM.
*/
unload(): void;
private getSource;
private createScript;
private createWebComponent;
}