import { KLogger, API } from '@kustomer/apps-common'; import { KAppClientOptions, KAppModalOptions } from './options.cjs'; import { Context } from './context.cjs'; import { KAppModal } from './kapp-modal.cjs'; import './events.cjs'; declare class KAppClient { readonly options: KAppClientOptions; /** * the apps instance id */ readonly id: string; /** * the apps origin */ readonly origin: string; /** * app logger instance that can be used to log to stdout. * To view use `set DEBUG=kapp*` */ readonly log: KLogger; /** * the context passed from Kustomer */ get context(): Context | undefined; private _context?; /** * the visibility of the application */ get visibility(): "public" | "private" | undefined; private _visibility; /** * whether or not the app has been initialized */ get initialized(): boolean; private _initialized; /** * whether or not we should automatically fetch data */ get fetchData(): boolean; private _fetchData; /** * Kustomer API */ get api(): API; private _api?; /** * view height */ get height(): number; /** Hides when called from a modal, otherwise it is safely ignored */ hide(): void; private _subscriptions; private _modals; private _requests; private targetModal?; private modalToken?; /** * called anytime the apps context * data injected from `Kustomer` changes */ onContextChange?: (ctx: Context) => void; /** * called when the app is instantiated * @param options the apps options */ constructor(options: KAppClientOptions); /** * start and initialize the app client */ start(setContext?: (ctx: Context) => void): Promise; /** * resize the view */ resize(args?: { height?: number; width?: number; }): void; /** * open the view */ open(): void; /** * close the view */ close(): void; /** * create a new modal instance * @param options */ modal(options: KAppModalOptions): Promise; /** * get an active modal instance by id, * returns `undefined` when modal is not found * @param id modal id */ getModalById(id: string): KAppModal | undefined; /** * listen for events from the parent window * @param e the message event * @private */ private _onMessage; /** * called when the app's context is updated * @param ctx the app's context * @private */ private _onContextUpdate; /** * Gets the response form Kustomer and resolves the respective * request promise with the data or rejects it with the error. * @param response the response from Kustomer * @private */ private _onRequest; /** * parse and escape query params by name * @param name name of the parameter * @private */ private _parseQueryParam; /** * publish an event to the parent window * @param type unique event key * @param data event payload * @private */ private _publish; } export { KAppClient };