119 lines
3.8 KiB
TypeScript
119 lines
3.8 KiB
TypeScript
import type AMSCheckout from '../../core/instance';
|
|
import type { eventPayload, eventPayloadContext, IappendIframeNodesParams, IMerchantAppointParam, Iselector } from '../../types';
|
|
import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
|
|
type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
|
|
export default class ComponentApp {
|
|
app: null | HTMLIFrameElement;
|
|
AMSSDK: AMSCheckout;
|
|
platform: platformEnum;
|
|
_performanceData: any[];
|
|
_loadAppPromiseResolve: ((value: boolean) => void) | null;
|
|
_isInitComponent: boolean;
|
|
private _globalData?;
|
|
private popupApp?;
|
|
private appDomain;
|
|
private createIframeNode;
|
|
private _selector;
|
|
private _appVersion;
|
|
private _isRetention;
|
|
private _actionQueryPromise;
|
|
private _actionSubmitPromise;
|
|
private _renderParams;
|
|
private _componentSign;
|
|
private _appLocationSearch;
|
|
private _renderDisplayType;
|
|
private _multipleCallbackEvents;
|
|
_merchantAppointParam: IMerchantAppointParam;
|
|
private _webAppHeartBeatTimeoutId;
|
|
private _webAppHeartBeatTimeoutFn;
|
|
constructor();
|
|
/**
|
|
* @description Cancel listening and destroy the dom
|
|
*/
|
|
logoutPlugin(): void;
|
|
/**
|
|
* @description When SDK registers plug-ins, it is a required function to receive SDK instances
|
|
*/
|
|
applyPlugin(AMSSDK: AMSCheckout): void;
|
|
private initLoggerMeta;
|
|
/**
|
|
* @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
|
|
*/
|
|
setRender(renderFunc: IrenderFuncParams): void;
|
|
private initSecurity;
|
|
private logDeviceId;
|
|
private getDeviceIdAndLog;
|
|
/**
|
|
* @description render iframe content
|
|
*/
|
|
appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void>;
|
|
private setParameterDefaultValues;
|
|
private renderInlineLoading;
|
|
private renderPopupLoading;
|
|
_createLoadAppPromise(loadTimeLimit?: number): Promise<unknown>;
|
|
/**
|
|
* @description Interface request
|
|
*/
|
|
private createActionQueryPromise;
|
|
private createSubmitPromise;
|
|
private cleanElement;
|
|
/**
|
|
* @description Create app
|
|
*/
|
|
private createApp;
|
|
private listener;
|
|
private resizeListener;
|
|
private createDialog;
|
|
private getDeviceIdAndCallback;
|
|
private getUserAgentAndCallback;
|
|
private returnDataAndCallback;
|
|
/**
|
|
* @description Initialize subscription iframe message
|
|
*/
|
|
private addEventListener;
|
|
private removeEventListener;
|
|
/**
|
|
* @description Processing messages from iframe
|
|
*/
|
|
_handleAppMessage(data: eventPayload): void;
|
|
private dismissLoadingFunc;
|
|
private handleSizeChanged;
|
|
private handleRedirect;
|
|
private handleDeclareInfo;
|
|
private handleDeclarePopWindowCallback;
|
|
private handleAppHeartBeat;
|
|
private isAppAttached;
|
|
private isWindowVisible;
|
|
private handleCloseBtnShow;
|
|
/**
|
|
* @description Send message to SDK
|
|
*/
|
|
dispatchToSDK(event: string, data: any, eventCallbackId?: string): void;
|
|
/**
|
|
* @description Send message to iframe
|
|
*/
|
|
dispatchToApp(payload: {
|
|
context: eventPayloadContext;
|
|
}, targetElement?: any): any;
|
|
/**
|
|
* @description Subscribe to messages from SDK
|
|
*/
|
|
private subscribeFromSDK;
|
|
/**
|
|
* @description Send rendering events to iframe
|
|
*/
|
|
private sendRenderEvent;
|
|
/**
|
|
* @description close cashier
|
|
*/
|
|
private cleanContainer;
|
|
private hideComponentAnimation;
|
|
private closeBtnFunc;
|
|
private retentionPopupLeaveFunc;
|
|
private removeRetentionPopup;
|
|
private showRetentionPopup;
|
|
private hideRetentionPopupFunc;
|
|
private submitForm;
|
|
}
|
|
export {};
|