Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@alipay/ams-checkout

Package Overview
Dependencies
Maintainers
2
Versions
447
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alipay/ams-checkout - npm Package Compare versions

Comparing version 0.0.1693189296-dev.0 to 0.0.1693912790-dev.0

73

esm/constant/index.d.ts

@@ -7,79 +7,70 @@ /**

*/
import { eventCodeEnum } from "../types";
export declare const ERRORMESSAGE: {
DOMAIN_NOT_IN_WHITE_LIST: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
NOT_JSON_FORMAT: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
SDK_COMPATIBILITY_ISSUES: {
code: eventCodeEnum;
errorCode: string;
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
FAILED_TO_CREATE_IFRAME: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
};
INIT_PARAMETER_ERROR: {
code: eventCodeEnum;
errorCode: string;
UI_MODE_NOT_SUPPORTED: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
ENVIRONMENT_ERROR: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
MODE_ERROR: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
LOCALE_ERROR: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
NET_MODE_NOT_SUPPORT: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
EVENT_ERROR: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
};
CREATEPAYMENT_PARAMETER_ERROR: {
code: eventCodeEnum;
errorCode: string;
};
CONFIRMPAYMENT_PARAMETER_ERROR: {
code: string;
errorCode: string;
};
CREATECOMPONENT_ERROR: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
SINGLETON_COMPONENT_ERROR: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
LOAD_APP_TIMEOUT: {
code: eventCodeEnum;
message: string;
};
};
SDK_CALL_URL_ERROR: {
code: eventCodeEnum;
errorCode: string;
REDIRECT_ERROR: {
code: eventCodeEnum;
message: string;
errorCode: string;
errorMessage: string;
};
};
SDK_SUBMIT_ERROR: {
code: eventCodeEnum;
message: string;
};
};

@@ -115,3 +106,3 @@ export declare const BASEPLUGINID = "CHECKOUT";

};
close: {
onClose: {
name: string;

@@ -118,0 +109,0 @@ uniqueKey: string;

@@ -7,78 +7,69 @@ /**

*/
import { eventCodeEnum } from "../types";
export var ERRORMESSAGE = {
DOMAIN_NOT_IN_WHITE_LIST: {
code: eventCodeEnum.SDK_INTERNAL_ERROR,
message: 'Origin of the message is not in the white list'
errorCode: 'SDK_INTERNAL_ERROR',
errorMessage: 'Origin of the message is not in the white list'
},
NOT_JSON_FORMAT: {
code: eventCodeEnum.SDK_INTERNAL_ERROR,
message: 'The message string should conform to the json format'
errorCode: 'SDK_INTERNAL_ERROR',
errorMessage: 'The message string should conform to the json format'
},
SDK_COMPATIBILITY_ISSUES: {
code: eventCodeEnum.SDK_INTERNAL_ERROR,
errorCode: 'SDK_INTERNAL_ERROR',
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
code: eventCodeEnum.SDK_INTERNAL_ERROR,
message: 'The browser does not support the postmessage communication mode'
errorCode: 'SDK_INTERNAL_ERROR',
errorMessage: 'The browser does not support the postmessage communication mode'
},
FAILED_TO_CREATE_IFRAME: {
code: eventCodeEnum.SDK_INTERNAL_ERROR,
message: 'Failed to create iframe'
errorCode: 'SDK_INTERNAL_ERROR',
errorMessage: 'Failed to create iframe'
}
},
INIT_PARAMETER_ERROR: {
code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR,
errorCode: 'SDK_INIT_PARAMETER_ERROR',
UI_MODE_NOT_SUPPORTED: {
code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR,
message: 'This UI mode is not supported'
errorCode: 'SDK_INIT_PARAMETER_ERROR',
errorMessage: 'This UI mode is not supported'
},
ENVIRONMENT_ERROR: {
code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR,
message: 'The current input environment does not support or is not in the standard enumeration'
errorCode: 'SDK_INIT_PARAMETER_ERROR',
errorMessage: 'The current input environment does not support or is not in the standard enumeration'
},
MODE_ERROR: {
code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR,
message: 'mode value not in enum'
errorCode: 'SDK_INIT_PARAMETER_ERROR',
errorMessage: 'mode value not in enum'
},
LOCALE_ERROR: {
code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR,
message: 'The current input language does not support or is not in the standard enumeration'
errorCode: 'SDK_INIT_PARAMETER_ERROR',
errorMessage: 'The current input language does not support or is not in the standard enumeration'
},
NET_MODE_NOT_SUPPORT: {
code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR,
message: 'The network mode is not supported'
errorCode: 'SDK_INIT_PARAMETER_ERROR',
errorMessage: 'The network mode is not supported'
},
EVENT_ERROR: {
code: eventCodeEnum.SDK_INIT_PARAMETER_ERROR,
message: 'Parameter type should be function'
errorCode: 'SDK_INIT_PARAMETER_ERROR',
errorMessage: 'Parameter type should be function'
}
},
CREATEPAYMENT_PARAMETER_ERROR: {
code: eventCodeEnum.SDK_CREATEPAYMENT_PARAMETER_ERROR
errorCode: 'SDK_CREATEPAYMENT_PARAMETER_ERROR'
},
CONFIRMPAYMENT_PARAMETER_ERROR: {
code: 'SDK_CONFIRMPAYMENT_PARAMETER_ERROR'
errorCode: 'SDK_CONFIRMPAYMENT_PARAMETER_ERROR'
},
CREATECOMPONENT_ERROR: {
code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR,
message: 'Failed to create component',
errorCode: 'SDK_CREATECOMPONENT_ERROR',
errorMessage: 'Failed to create component',
SINGLETON_COMPONENT_ERROR: {
code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR,
message: 'Only one component can be rendered simultaneously'
},
LOAD_APP_TIMEOUT: {
code: eventCodeEnum.SDK_CREATECOMPONENT_ERROR,
message: 'Load resource timeout'
errorCode: 'SDK_CREATECOMPONENT_ERROR',
errorMessage: 'Only one component can be rendered simultaneously'
}
},
SDK_CALL_URL_ERROR: {
code: eventCodeEnum.SDK_CALL_URL_ERROR,
errorCode: 'SDK_CALL_URL_ERROR',
REDIRECT_ERROR: {
code: eventCodeEnum.SDK_CALL_URL_ERROR,
message: 'Redirect data exception'
errorCode: 'SDK_CALL_URL_ERROR',
errorMessage: 'Redirect data exception'
}
},
SDK_SUBMIT_ERROR: {
code: eventCodeEnum.SDK_CALL_URL_ERROR,
message: 'Component not created or current browser compatibility issue, not supported'
}

@@ -115,3 +106,3 @@ };

},
close: {
onClose: {
name: 'onClose',

@@ -118,0 +109,0 @@ uniqueKey: 'userOnClose'

@@ -8,24 +8,11 @@ /**

*/
import { IcreateComponent, IoptionsParams, Iselector } from '../../types';
import CoreInstance from '../instance/index';
export declare class AMSComponent extends CoreInstance {
private componentApp;
constructor(options: IoptionsParams);
private parameterInitAndCheck;
private pluginAppendIframe;
/**
* @description Create component application
* @param params - The data source created by the component, necessary paymentSessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
*/
createComponent(params: IcreateComponent): Promise<void>;
/**
* @description Create and render components in the specified element area
* @param params - The data source created by the component, necessary paymentSessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
*/
mountComponent(params: IcreateComponent, selector: Iselector): Promise<void>;
/**
* @description Execute payment submission process
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
*/
submit(): void;
import { IcreateComponent, optionsParams } from '../../types';
export declare const mixinComponentConstructor: (options: optionsParams, context: any) => void;
/**
* @description Create component application
* @description component
*/
export declare const createComponent: (params: IcreateComponent) => Promise<void>;
export interface IcreateComponentFunc {
(params: IcreateComponent): Promise<void>;
}

@@ -1,15 +0,1 @@

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

@@ -29,8 +15,7 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
import { COMPONENTPLUGINID, ERRORMESSAGE } from "../../constant";
import ComponentApp from "../../plugin/component";
import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
import { componentSignEnum, mode, networkMode, productSceneEnum } from "../../types";
import { isPC } from "../../util";
import { createIframeNode } from "../../util/createIframeNode";
import CoreInstance from "../instance/index";
var getComponentSign = function getComponentSign(params) {

@@ -71,134 +56,47 @@ var _params$paymentSessio = params.paymentSessionConfig,

};
var handleParams = function handleParams(params) {
var _params = Object.assign({
paymentSessionMetaData: {},
renderDisplayType: renderDisplayTypeEnum.popup
}, params);
var _handlePaymentSession = handlePaymentSessionData(_params.paymentSessionData),
_handlePaymentSession2 = _slicedToArray(_handlePaymentSession, 2),
parseData = _handlePaymentSession2[0],
paymentSessionData = _handlePaymentSession2[1];
var componentSign = getComponentSign(parseData);
if (componentSign === componentSignEnum.NONE) {
// eslint-disable-next-line prefer-promise-reject-errors
return Promise.reject({
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
message: "Abnormal response data, interface failure, or unsupported payment method"
});
}
_params.paymentSessionData = paymentSessionData;
_params.paymentSessionMetaData = parseData;
return Promise.resolve({
iframeNodesParams: _params,
componentSign: componentSign
});
export var mixinComponentConstructor = function mixinComponentConstructor(options, context) {
// Instantiate the plug-in and set render
var ComponentPlugin = new ComponentApp();
ComponentPlugin.setRender(createIframeNode);
// Register Cashier Application Plug in
context._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
};
export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
_inherits(AMSComponent, _CoreInstance);
var _super = _createSuper(AMSComponent);
function AMSComponent(options) {
var _this;
_classCallCheck(this, AMSComponent);
_this = _super.call(this, options);
// Instantiate the plug-in and set render
_defineProperty(_assertThisInitialized(_this), "componentApp", void 0);
var ComponentPlugin = new ComponentApp();
ComponentPlugin.setRender(createIframeNode);
// Register Cashier Application Plug in
_this._registerPlugin(COMPONENTPLUGINID, ComponentPlugin);
_this.componentApp = _this._getPlugin(COMPONENTPLUGINID);
return _this;
/**
* @description Create component application
* @description component
*/
export var createComponent = function createComponent(params) {
var _this = this;
this.options.mode = mode.component;
this.options.networkMode = this.options.networkMode || networkMode.session;
var _params = params;
if (_params && !_params.paymentSessionData) {
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR);
}
_createClass(AMSComponent, [{
key: "parameterInitAndCheck",
value: function parameterInitAndCheck(_ref) {
var params = _ref.params,
selector = _ref.selector,
renderDisplayType = _ref.renderDisplayType;
this.options.mode = modeEnum.component;
this.options.networkMode = this.options.networkMode || networkModeEnum.session;
var _params = Object.assign({
selector: selector,
renderDisplayType: renderDisplayType
}, params);
if (_params && !_params.paymentSessionData) {
return Promise.reject(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR);
}
if (this.options.networkMode === networkModeEnum.proxy) {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
}
return Promise.resolve(_params);
if (this.options.networkMode === networkMode.proxy) {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
return Promise.reject(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT);
}
return new Promise(function (resolve, reject) {
var _handlePaymentSession = handlePaymentSessionData(_params.paymentSessionData),
_handlePaymentSession2 = _slicedToArray(_handlePaymentSession, 2),
parseData = _handlePaymentSession2[0],
paymentSessionData = _handlePaymentSession2[1];
var componentSign = getComponentSign(parseData);
if (componentSign === componentSignEnum.NONE) {
// eslint-disable-next-line prefer-promise-reject-errors
return reject("".concat(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.errorCode, "\uFF1AAbnormal response data, interface failure, or unsupported payment method"));
}
}, {
key: "pluginAppendIframe",
value: function pluginAppendIframe(appendParams) {
try {
return this.componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
} catch (error) {
return Promise.reject(error);
}
}
/**
* @description Create component application
* @param params - The data source created by the component, necessary paymentSessionData, optional appearance configuration, and refer to the documentation for other parameters and detailed information.
*/
}, {
key: "createComponent",
value: function createComponent(params) {
var _this2 = this;
return this.parameterInitAndCheck({
params: params,
renderDisplayType: renderDisplayTypeEnum.popup
}).then(function (_params) {
return handleParams(_params);
}).catch(function (error) {
_this2._eventCenter.emit(EVENT.error.name, error);
return Promise.reject(error);
}).then(function (appendParams) {
return _this2.pluginAppendIframe(appendParams);
_params.paymentSessionData = paymentSessionData;
_params.paymentSessionMetaData = parseData;
try {
var componentApp = _this._getPlugin(COMPONENTPLUGINID);
componentApp.appendIframeNodes(componentSign, _params).then(function () {
resolve();
});
} catch (error) {
reject(error);
}
/**
* @description Create and render components in the specified element area
* @param params - The data source created by the component, necessary paymentSessionData, necessary element selector IDs, optional appearance configurations, and refer to the documentation for other parameters and detailed information.
*/
}, {
key: "mountComponent",
value: function mountComponent(params, selector) {
var _this3 = this;
return this.parameterInitAndCheck({
params: params,
renderDisplayType: renderDisplayTypeEnum.inline,
selector: selector
}).then(function (_params) {
return handleParams(_params);
}).catch(function (error) {
_this3._eventCenter.emit(EVENT.error.name, error);
return Promise.reject(error);
}).then(function (appendParams) {
return _this3.pluginAppendIframe(appendParams);
});
}
/**
* @description Execute payment submission process
* @description - When using your own payment button, you can execute the submit payment process by actively calling this function.
*/
}, {
key: "submit",
value: function submit() {
try {
this.componentApp.dispatchToApp({
context: {
event: 'submitPay',
data: {}
}
});
} catch (error) {
console.error(error);
}
}
}]);
return AMSComponent;
}(CoreInstance);
});
};

@@ -8,3 +8,3 @@ /**

*/
import { createPaymentParams } from '../../types';
import { createPaymentParams, optionsParams } from '../../types';
export declare const mixinDropInConstructor: (options: optionsParams, context: any) => void;

@@ -11,0 +11,0 @@ /**

@@ -1,14 +0,14 @@

import type { AMSCheckoutOptions, IcheckoutState, IoptionsParams } from '../../types/index';
import type { AMSCheckoutOptions, callOnError, callOnLog, callOnSizeChanged, checkoutState, optionsParams } from '../../types/index';
import { EventCenter } from '../../util/index';
export default class AMSSDK {
options: AMSCheckoutOptions;
checkoutState: IcheckoutState;
_eventCenter: EventCenter;
checkoutState: checkoutState;
eventCenter: EventCenter;
protected plugins: Map<string, any>;
_instanceId: string;
constructor(options: IoptionsParams);
constructor(options: optionsParams);
/**
* @description Destroy and process some contents of the plug-in
*/
unmount(): void;
destroy(): void;
/**

@@ -37,3 +37,3 @@ * @description Set the sdk basic configuration

*/
protected _getPlugin(pluginId: string): any;
_getPlugin(pluginId: string): any;
/**

@@ -51,2 +51,11 @@ * @description Execute to open app or jump link

protected _overrideSubscription(name: string, func: any, funcKey: string): void;
/**
* @description Create an event handler, called when an error occurs in AMSCheckout.
*/
onError(event: callOnError): void;
/**
* @description Create an event handler
*/
onSizeChanged(event: callOnSizeChanged): void;
onLog(event: callOnLog): void;
}

@@ -20,3 +20,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

import { ERRORMESSAGE, EVENT } from "../../constant";
import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } from "../../types/index";
import { environment, mode, networkMode, osType, terminalType } from "../../types/index";
import { device, EventCenter, getType, queryParse } from "../../util/index";

@@ -29,3 +29,3 @@ import CallApp from "../../util/intl-callapp/es/main";

_defineProperty(this, "checkoutState", void 0);
_defineProperty(this, "_eventCenter", void 0);
_defineProperty(this, "eventCenter", void 0);
_defineProperty(this, "plugins", void 0);

@@ -36,3 +36,6 @@ _defineProperty(this, "_instanceId", void 0);

this.options = {};
this._eventCenter = new EventCenter();
this.eventCenter = new EventCenter();
this.checkoutState = {
paymentMethodType: ''
};
this._initEvent(options);

@@ -46,4 +49,4 @@ this._setOptions(options);

_createClass(AMSSDK, [{
key: "unmount",
value: function unmount() {
key: "destroy",
value: function destroy() {
var _iterator = _createForOfIteratorHelper(this.plugins.values()),

@@ -57,5 +60,3 @@ _step;

// eslint-disable-next-line no-empty
} catch (error) {
console.error(error);
}
} catch (error) {}
}

@@ -86,13 +87,13 @@ } catch (err) {

_moreEnv = _queryParse._moreEnv;
if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in environmentEnum) && _moreEnv !== 'true') {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.message);
if (options !== null && options !== void 0 && options.environment && !((options === null || options === void 0 ? void 0 : options.environment) in environment) && _moreEnv !== 'true') {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.ENVIRONMENT_ERROR.errorMessage);
options.environment = 'prod';
}
this.options.env = {
terminalType: device.isMobile ? terminalTypeEnum.WAP : terminalTypeEnum.WEB,
terminalType: device.isMobile ? terminalType.WAP : terminalType.WEB,
environment: (options === null || options === void 0 ? void 0 : options.environment) || 'prod'
};
if (this.options.env.terminalType === terminalTypeEnum.WAP) {
if (this.options.env.terminalType === terminalType.WAP) {
// eslint-disable-next-line no-nested-ternary
this.options.env.osType = device.iOS ? osTypeEnum.IOS : device.Android ? osTypeEnum.ANDROID : osTypeEnum.ELSE;
this.options.env.osType = device.iOS ? osType.IOS : device.Android ? osType.ANDROID : osType.ELSE;
}

@@ -106,11 +107,11 @@ }

value: function _setMode(options) {
this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) || modeEnum.component;
if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in modeEnum)) {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.message);
this.options.mode = modeEnum.component;
this.options.mode = (options === null || options === void 0 ? void 0 : options.mode) || mode.dropin;
if (options !== null && options !== void 0 && options.mode && !((options === null || options === void 0 ? void 0 : options.mode) in mode)) {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.MODE_ERROR.errorMessage);
this.options.mode = mode.component;
}
this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) || networkModeEnum.session;
if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in networkModeEnum)) {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.message);
this.options.networkMode = networkModeEnum.proxy;
this.options.networkMode = (options === null || options === void 0 ? void 0 : options.networkMode) || networkMode.session;
if (options !== null && options !== void 0 && options.networkMode && !((options === null || options === void 0 ? void 0 : options.networkMode) in networkMode)) {
console.warn(ERRORMESSAGE.INIT_PARAMETER_ERROR.NET_MODE_NOT_SUPPORT.errorMessage);
this.options.networkMode = networkMode.proxy;
}

@@ -125,24 +126,24 @@ }

if (options !== null && options !== void 0 && options.onError) {
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
this._overrideSubscription(EVENT.error.name, options.onError, EVENT.error.uniqueKey);
}
if (options !== null && options !== void 0 && options.onPaymentMethodSelected) {
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
this._overrideSubscription(EVENT.paymentMethodSelected.name, options.onPaymentMethodSelected, EVENT.paymentMethodSelected.uniqueKey);
}
if (options !== null && options !== void 0 && options.onSizeChanged) {
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
this._overrideSubscription(EVENT.sizeChanged.name, options.onSizeChanged, EVENT.sizeChanged.uniqueKey);
}
if (options !== null && options !== void 0 && options.onLog) {
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
this._overrideSubscription(EVENT.log.name, options.onLog, EVENT.log.uniqueKey);
}
if (options !== null && options !== void 0 && options.onEventCallback) {
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
this._overrideSubscription(EVENT.eventCallback.name, options.onEventCallback, EVENT.eventCallback.uniqueKey);
}
if (options !== null && options !== void 0 && options.onClose) {
if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
this._overrideSubscription(EVENT.close.name, options.onClose, EVENT.close.uniqueKey);
if (getType(options.onClose) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
this._overrideSubscription(EVENT.onClose.name, options.onClose, EVENT.onClose.uniqueKey);
}

@@ -185,3 +186,3 @@ }

return new Promise(function (resolve, reject) {
var isWeb = _this.options.env.terminalType === terminalTypeEnum.WEB;
var isWeb = _this.options.env.terminalType === terminalType.WEB;
var normalUrl = (data === null || data === void 0 ? void 0 : data.normalUrl) || '';

@@ -235,5 +236,26 @@ var schemeUrl = (data === null || data === void 0 ? void 0 : data.schemeUrl) || '';

value: function _overrideSubscription(name, func, funcKey) {
this._eventCenter.off(name, func, funcKey);
this._eventCenter.on(name, func, funcKey);
this.eventCenter.off(name, func, funcKey);
this.eventCenter.on(name, func, funcKey);
}
/**
* @description Create an event handler, called when an error occurs in AMSCheckout.
*/
}, {
key: "onError",
value: function onError(event) {
this._overrideSubscription(EVENT.error.name, event, EVENT.error.uniqueKey);
}
/**
* @description Create an event handler
*/
}, {
key: "onSizeChanged",
value: function onSizeChanged(event) {
this._overrideSubscription(EVENT.sizeChanged.name, event, EVENT.sizeChanged.uniqueKey);
}
}, {
key: "onLog",
value: function onLog(event) {
this._overrideSubscription(EVENT.log.name, event, EVENT.log.uniqueKey);
}
}]);

@@ -240,0 +262,0 @@ return AMSSDK;

@@ -8,10 +8,16 @@ /**

*/
import { AMSComponent } from './core/component/index';
import { IoptionsParams } from './types';
import { IcreateComponentFunc } from './core/component/index';
import { IconfirmPaymentFunc, IcreatePaymentFunc } from './core/drop-in/index';
import AMSSDK from './core/instance';
import { optionsParams } from './types';
export * from './types';
export declare class AMSCheckout extends AMSComponent {
export declare class AMSCheckout extends AMSSDK {
createComponent: IcreateComponentFunc;
createPayment: IcreatePaymentFunc;
confirmPayment: IconfirmPaymentFunc;
constructor(options: optionsParams);
}
export declare class AMSAutoDebit extends AMSCheckout {
constructor(options: IoptionsParams);
constructor(options: optionsParams);
}
export default AMSCheckout;
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -14,2 +12,5 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
/**

@@ -22,13 +23,34 @@ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.

*/
import { AMSComponent } from "./core/component/index";
import { createComponent, mixinComponentConstructor } from "./core/component/index";
import { confirmPayment, createPayment, mixinDropInConstructor, _subscribeFromCheckoutPlugin } from "./core/drop-in/index";
import AMSSDK from "./core/instance";
export * from "./types";
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
_inherits(AMSCheckout, _AMSComponent);
export var AMSCheckout = /*#__PURE__*/function (_AMSSDK) {
_inherits(AMSCheckout, _AMSSDK);
var _super = _createSuper(AMSCheckout);
function AMSCheckout() {
function AMSCheckout(options) {
var _this;
_classCallCheck(this, AMSCheckout);
return _super.apply(this, arguments);
_this = _super.call(this, options);
_defineProperty(_assertThisInitialized(_this), "createComponent", void 0);
_defineProperty(_assertThisInitialized(_this), "createPayment", void 0);
_defineProperty(_assertThisInitialized(_this), "confirmPayment", void 0);
Object.defineProperty(_assertThisInitialized(_this), 'createComponent', {
value: createComponent
});
Object.defineProperty(_assertThisInitialized(_this), 'createPayment', {
value: createPayment
});
Object.defineProperty(_assertThisInitialized(_this), 'confirmPayment', {
value: confirmPayment
});
Object.defineProperty(_assertThisInitialized(_this), '_subscribeFromCheckoutPlugin', {
value: _subscribeFromCheckoutPlugin
});
mixinComponentConstructor(options, _assertThisInitialized(_this));
mixinDropInConstructor(options, _assertThisInitialized(_this));
return _this;
}
return _createClass(AMSCheckout);
}(AMSComponent);
}(AMSSDK);
export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {

@@ -35,0 +57,0 @@ _inherits(AMSAutoDebit, _AMSCheckout);

@@ -23,2 +23,2 @@ import { componentSignEnum, Ianalytics } from '../../types';

*/
export declare const createIframe: (mode: string, platform: 'mobile' | 'desktop') => HTMLIFrameElement;
export declare const createIframe: (mode: string) => HTMLIFrameElement;

@@ -88,14 +88,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

instanceId: instanceId,
sandbox: environment === 'light_sandbox' || _light_sandbox === 'true' ? 'true' : 'false',
analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
sdkVersion: sdkVersion,
refUrl: window.location.href
refUrl: window.location.href,
shadow: environment === 'sandbox' || _sandbox === 'true' ? 'true' : 'false',
requestHost: requestHost,
groupId: groupId,
LOCAL_MOCK: LOCAL_MOCK
});
if (LOCAL_MOCK) urlParams.LOCAL_MOCK = LOCAL_MOCK;
if (requestHost) urlParams.requestHost = requestHost;
if (groupId) urlParams.groupId = groupId;
if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
var locationSearch = serialize(urlParams);
return "".concat(path, "?").concat(locationSearch);
};
var getIframeId = function getIframeId(UIMode) {
var IdMap = {
dropin: 'checkout-dropin',
component: 'checkout-component'
};
return IdMap[UIMode] || 'checkout-component';
};

@@ -105,12 +112,5 @@ /**

*/
export var createIframe = function createIframe(mode, platform) {
var getIframeId = function getIframeId() {
var IdMap = {
dropin: "ams-checkout-dropin-".concat(platform),
component: "ams-checkout-component-".concat(platform)
};
return IdMap[mode] || 'ams-checkout-component';
};
export var createIframe = function createIframe(mode) {
var iframe = document.createElement('iframe');
var iframeId = getIframeId();
var iframeId = getIframeId(mode);
var none = '0';

@@ -122,5 +122,4 @@ var width = '100%';

iframe.style.border = none;
iframe.style.opacity = none;
iframe.style.overflow = 'hidden';
return iframe;
};

@@ -8,5 +8,2 @@ /**

*/
import { platformEnum } from '../../types';
export declare const componentAddCSS: () => void;
export declare const inlineComponentAddCss: () => void;
export declare const showInlineLoading: (_selector: HTMLDivElement, platform: platformEnum) => void;
export declare function componentAddCSS(): void;

@@ -8,16 +8,5 @@ /**

*/
import { platformEnum } from "../../types";
import { amsSetSize } from "../../util";
var componentContainerId = 'ams-component-container';
var componentSectionId = 'ams-component-section';
var componentCloseBlockId = 'asm-component-close-block';
var componentRetentionId = 'ams-component-retention';
var mockupId = 'ams-component-mockup';
var loadingId = 'ams-component-loading';
var listenerPrefix = '_ams_sdk_component_listener';
var inlineBaseStyleId = 'ams-inline-component-style';
var inlineImgClassName = 'inline-loading';
var loadTimeLimit = 15000;
var componentCss = ".ams-component-container-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n}\n.ams-component-container-mobile-animation{\n animation: ams-component-container-slide-in 0.3s ease-in-out;\n}\n\n.ams-component-section-desktop {\n font-size: 0;\n}\n\n.ams-component-container-hidden-mobile {\n width: 100%;\n height: 0px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n background-color: transparent;\n border-radius: 12px 12px 0 0;\n animation: ams-component-container-slide-out 0.26s ease-in forwards;\n overflow: hidden;\n}\n\n.ams-component-section-mobile {\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n font-size: 0;\n}\n\n.ams-component-container-desktop {\n display: block;\n width: 672px;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n transform-origin: 50% 50%;\n}\n.ams-component-container-desktop-animation{\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n@keyframes ams-component-container-zoom-out {\n 0% {\n transform: translate(-50%, -50%) scale(1);\n opacity: 1\n }\n\n 100% {\n transform: translate(-50%, -50%) scale(0.4);\n opacity: 0\n }\n}\n\n@keyframes ams-component-container-zoom-in {\n 0% {\n transform: translate(-50%, -50%) scale(0.4);\n opacity: 0\n }\n\n 80% {\n opacity: 1\n }\n\n 100% {\n opacity: 1;\n transform: translate(-50%, -50%) scale(1);\n }\n}\n\n.ams-component-container-hidden-desktop {\n display: block;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n animation-fill-mode: forwards;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n transform-origin: 50% 50%;\n}\n\n.ams-component-loading {\n width: 0.8em;\n height:0.8em;\n background: rgba(0, 0, 0, 0.5);\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-loading .line div:before,\n.ams-component-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: #fcfcfc;\n border-radius: 5.3px;\n}\n.ams-component-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n\n}\n\n.ams-component-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n\n.asm-component-close-block-desktop {\n position: absolute;\n width: 40px;\n height: 40px;\n right: 0;\n top: 0;\n cursor: pointer;\n}\n.asm-component-close-block-btn-desktop {\n width: 11px;\n height: 11px;\n object-fit: fill;\n position: absolute;\n right: 18.7px;\n top: 26.7px;\n}\n.asm-component-close-block-hidden {\n width: 0px !important;\n height: 0px !important;\n visibility: hidden;\n}\n.asm-component-close-block-mobile {\n position: absolute;\n width: 0.4em;\n height: 0.4em;\n right: 0;\n top: 0;\n cursor: pointer;\n z-index: 1009;\n}\n\n.asm-component-close-block-btn-mobile {\n width: 0.11em;\n height: 0.11em;\n object-fit: fill;\n position: absolute;\n right: 0.147em;\n top: 0.167em;\n}\n\n\n.ams-component-container-opacity{\n opacity: 1;\n}\n\n.ams-component-container-opacity:after{\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n display: block;\n content: \"\";\n z-index: 1010;\n background-color: rgba(0, 0, 0, 0.35);\n}\n\n#ams-component-retention {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n transform-origin: 50%;\n height: auto;\n display: none;\n z-index: 1009;\n}\n\n.ams-component-retention-show {\n display: flex !important;\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-hidden {\n display: flex !important;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-mobile {\n width: 294px;\n border-radius: 12px;\n padding: 24px 0;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-desktop {\n width: 544px;\n border-radius: 12px;\n padding: 32px;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n@media screen and (max-width: 300px) {\n .ams-component-retention-mobile {\n transform: translate(-50%, -50%) scale(0.8);\n }\n}\n\n.ams-component-retention-title-mobile {\n width: 100%;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-title-desktop {\n text-align: left;\n width: 100%;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n}\n\n.ams-component-retention-sub-title-mobile {\n width: 100%;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 8px;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-sub-title-desktop {\n text-align: left;\n font-style: normal;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 10px;\n}\n\n.ams-component-retention-btn-block-mobile {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n margin-top: 24px;\n padding: 0 24px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-btn-block-desktop {\n width: 100%;\n margin-top: 24px;\n}\n\n#ams-component-retention-remain {\n background: #0079FF;\n border-radius: 100px;\n font-style: normal;\n font-weight: 500;\n text-align: center;\n box-sizing: border-box;\n color: #FFFFFF;\n}\n\n.ams-component-retention-remain-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n}\n\n.ams-component-retention-remain-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n display: inline-block;\n padding: 0 24px;\n float: right;\n cursor: pointer;\n}\n\n#ams-component-retention-leave {\n border-radius: 100px;\n border: 1px solid #0079FF;\n font-style: normal;\n font-weight: 500;\n text-align: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-leave-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n margin-top: 12px;\n}\n\n.ams-component-retention-leave-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n display: inline-block;\n padding: 0 24px;\n float: right;\n margin-right: 16px;\n cursor: pointer;\n}\n\n";
export var componentAddCSS = function componentAddCSS() {
var componentCss = ".ams-component-container-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n}\n.ams-component-container-mobile-animation{\n animation: ams-component-container-slide-in 0.3s ease-in-out;\n}\n\n.ams-component-section-desktop {\n font-size: 0;\n}\n\n.ams-component-container-hidden-mobile {\n width: 100%;\n height: 1px;\n position: fixed;\n bottom: -1px;\n left: 0;\n z-index: 1001;\n background-color: transparent;\n border-radius: 12px 12px 0 0;\n animation: ams-component-container-slide-out 0.26s ease-in forwards;\n overflow: hidden;\n}\n\n.ams-component-section-mobile {\n border-radius: 12px 12px 0 0;\n overflow: hidden;\n font-size: 0;\n}\n\n.ams-component-container-desktop {\n display: block;\n width: 672px;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n transform-origin: 50% 50%;\n}\n.ams-component-container-desktop-animation{\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n@keyframes ams-component-container-zoom-out {\n 0% {\n transform: translate(-50%, -50%) scale(1);\n -webkit-transform: translate(-50%, -50%) scale(1);\n opacity: 1\n }\n \n 100% {\n opacity: 0;\n transform: translate(-50%, -50%) scale(0.4);\n -webkit-transform: translate(-50%, -50%) scale(0.4);\n }\n}\n\n@keyframes ams-component-container-zoom-in {\n 0% {\n transform: translateX(-50%) translateY(-50%) scale(0.4);\n opacity: 0\n }\n\n 80% {\n opacity: 1\n }\n\n 100% {\n opacity: 1;\n transform: translateX(-50%) translateY(-50%) scale(1);\n }\n}\n\n.ams-component-container-hidden-desktop {\n display: block;\n position: fixed;\n top: 50%;\n left: 50%;\n z-index: 1001;\n border-radius: 8px;\n overflow: hidden;\n animation-fill-mode: forwards;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n transform-origin: 50% 50%;\n}\n\n.ams-component-loading {\n width: 0.8em;\n height:0.8em;\n background: rgba(0, 0, 0, 0.5);\n border-radius: 8px;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 1001;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.ams-component-loading .line {\n width: 40px;\n height: 40px;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n.ams-component-loading .line div {\n position: absolute;\n left: 17.67px;\n top: 0;\n width: 5.33px;\n height: 40px;\n}\n\n.ams-component-loading .line div:before,\n.ams-component-loading .line div:after {\n content: '';\n display: block;\n height: 13.33px;\n background: #fcfcfc;\n border-radius: 5.3px;\n}\n.ams-component-loading .line div:after {\n margin-top: 13.33px;\n}\n\n.ams-component-loading .line div:nth-child(2) {\n -webkit-transform: rotate(45deg);\n}\n\n.ams-component-loading .line div:nth-child(3) {\n -webkit-transform: rotate(90deg);\n}\n\n.ams-component-loading .line div:nth-child(4) {\n -webkit-transform: rotate(135deg);\n}\n\n/** \u52A0\u8F7D\u52A8\u753B **/\n@-webkit-keyframes load {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n\n}\n\n.ams-component-loading .line div:nth-child(1):before {\n -webkit-animation: load 1s linear 0s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):before {\n -webkit-animation: load 1s linear 0.125s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):before {\n -webkit-animation: load 1s linear 0.25s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):before {\n -webkit-animation: load 1s linear 0.375s infinite;\n}\n\n.ams-component-loading .line div:nth-child(1):after {\n -webkit-animation: load 1s linear 0.5s infinite;\n}\n\n.ams-component-loading .line div:nth-child(2):after {\n -webkit-animation: load 1s linear 0.675s infinite;\n}\n\n.ams-component-loading .line div:nth-child(3):after {\n -webkit-animation: load 1s linear 0.75s infinite;\n}\n\n.ams-component-loading .line div:nth-child(4):after {\n -webkit-animation: load 1s linear 0.875s infinite;\n}\n\n.ams-component-loading-logo {\n width: 0.44em;\n height: 0.44em;\n -webkit-transform:rotate(360deg);\n transform:rotate(360deg);\n -webkit-transition:-webkit-transform 1s linear;\n transition:transform 1s linear;\n animation: ams-component-loading-logo 1s linear infinite;\n}\n\n.asm-component-close-block-desktop {\n position: absolute;\n width: 40px;\n height: 40px;\n right: 0;\n top: 0;\n cursor: pointer;\n}\n.asm-component-close-btn-desktop {\n width: 11px;\n height: 11px;\n object-fit: fill;\n position: absolute;\n right: 18.7px;\n top: 26.7px;\n}\n.asm-component-close-block-hidden {\n width: 0px !important;\n height: 0px !important;\n visibility: hidden;\n}\n.asm-component-close-block-mobile {\n position: absolute;\n width: 0.4em;\n height: 0.4em;\n right: 0;\n top: 0;\n cursor: pointer;\n z-index: 1009;\n}\n\n.asm-component-close-btn-mobile {\n width: 0.11em;\n height: 0.11em;\n object-fit: fill;\n position: absolute;\n right: 0.147em;\n top: 0.167em;\n}\n\n\n.ams-component-container-opacity{\n opacity: 1;\n}\n\n.ams-component-container-opacity:after{\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n display: block;\n content: \"\";\n z-index: 1010;\n background-color: rgba(0, 0, 0, 0.35);\n}\n\n#ams-component-retention {\n position: fixed;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n transform-origin: 50%;\n height: auto;\n display: none;\n z-index: 1009;\n}\n\n.ams-component-retention-show {\n display: flex !important;\n animation: ams-component-container-zoom-in 0.3s ease-in-out;\n animation-fill-mode: forwards\n}\n\n.ams-component-retention-hidden {\n display: flex !important;\n animation: ams-component-container-zoom-out 0.3s ease-in-out;\n -webkit-animation: ams-component-container-zoom-out 0.3s ease-in-out;\n animation-fill-mode: forwards;\n -webkit-animation-fill-mode: forwards;\n}\n\n.ams-component-retention-mobile {\n width: 294px;\n border-radius: 12px;\n padding: 24px 0;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n.ams-component-retention-desktop {\n width: 544px;\n border-radius: 12px;\n padding: 32px;\n background-color: #fff;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n box-sizing: border-box;\n}\n\n@media screen and (max-width: 300px) {\n .ams-component-retention-mobile {\n transform: translate(-50%, -50%) scale(0.8);\n }\n}\n\n.ams-component-retention-title-mobile {\n width: 100%;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-title-desktop {\n text-align: left;\n width: 100%;\n font-style: normal;\n font-weight: 600;\n font-size: 16px;\n line-height: 24px;\n color: #2A3A52;\n}\n\n.ams-component-retention-sub-title-mobile {\n width: 100%;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 8px;\n text-align: center;\n padding: 0 16px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-sub-title-desktop {\n text-align: left;\n font-style: normal;\n font-weight: 400;\n font-size: 14px;\n line-height: 20px;\n color: #7C8CA3;\n margin-top: 10px;\n}\n\n.ams-component-retention-btn-block-mobile {\n width: 100%;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n justify-content: center;\n margin-top: 24px;\n padding: 0 24px;\n box-sizing: border-box;\n}\n\n.ams-component-retention-btn-block-desktop {\n width: 100%;\n margin-top: 24px;\n}\n\n#ams-component-retention-remain {\n background: #0079FF;\n border-radius: 100px;\n font-style: normal;\n font-weight: 600;\n text-align: center;\n box-sizing: border-box;\n color: #FFFFFF;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ams-component-retention-remain-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n padding: 0 6px;\n}\n\n.ams-component-retention-remain-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n display: inline-block;\n padding: 0 24px;\n float: right;\n cursor: pointer;\n padding: 0 8px;\n max-width: 225px;\n}\n\n#ams-component-retention-leave {\n border-radius: 100px;\n border: 1px solid #0079FF;\n font-style: normal;\n font-weight: 600;\n text-align: center;\n box-sizing: border-box;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.ams-component-retention-leave-mobile {\n width: 100%;\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n margin-top: 12px;\n padding: 0 6px;\n}\n\n.ams-component-retention-leave-desktop {\n height: 44px;\n font-size: 16px;\n line-height: 44px;\n color: #1677FF;\n display: inline-block;\n padding: 0 24px;\n float: right;\n margin-right: 16px;\n cursor: pointer;\n padding: 0 8px;\n max-width: 225px;\n}\n\n";
export function componentAddCSS() {
var style = document.createElement('style');

@@ -27,19 +16,2 @@ style.type = 'text/css';

document.head.appendChild(style);
};
var inlineComponentCss = "#ams-checkout-component-desktop{\n border-radius: 8px;\n position: absolute;\n top: 0;\n left: 0;\n}\n#ams-checkout-component-mobile{\n position: absolute;\n top: 0;\n left: 0;\n}\n.".concat(componentContainerId, "-inline{\n width: 100%;\n height: auto;\n position: relative;\n line-height: 0;\n display: flex;\n}\n#").concat(loadingId, "{\n width: 100%;\n flex: 1;\n}\n.").concat(inlineImgClassName, "{\n width: 100%;\n height: auto;\n object-fit: contain;\n box-sizing: border-box;\n}\n.").concat(inlineImgClassName, "-mobile{\n padding: 0 0.16em;\n}\n.").concat(inlineImgClassName, "-desktop{}\n");
export var inlineComponentAddCss = function inlineComponentAddCss() {
var style = document.createElement('style');
style.id = 'ams-inline-component-style';
style.type = 'text/css';
style.innerHTML = inlineComponentCss;
document.head.appendChild(style);
};
export var showInlineLoading = function showInlineLoading(_selector, platform) {
var loading = document.createElement('div');
loading.id = loadingId;
if (platform === platformEnum.desktop) loading.innerHTML = "<svg class=\"".concat(inlineImgClassName, " ").concat(inlineImgClassName, "-").concat(platform, "\" width=\"740\" height=\"360\" viewBox=\"0 0 740 360\" fill=\"none\" xmlns=\"\">\n <rect width=\"740\" height=\"360\" rx=\"12\" fill=\"#F6F6F6\"/>\n <rect opacity=\"0.7\" x=\"44\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"94\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"144\" y=\"44\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M136 100H48C43.5817 100 40 103.582 40 108C40 112.418 43.5817 116 48 116H136C140.418 116 144 112.418 144 108C144 103.582 140.418 100 136 100Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M682 126H58C48.0589 126 40 134.059 40 144C40 153.941 48.0589 162 58 162H682C691.941 162 700 153.941 700 144C700 134.059 691.941 126 682 126Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M682 182H58C48.0589 182 40 190.059 40 200C40 209.941 48.0589 218 58 218H682C691.941 218 700 209.941 700 200C700 190.059 691.941 182 682 182Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M504 274H64C52.9543 274 44 282.954 44 294C44 305.046 52.9543 314 64 314H504C515.046 314 524 305.046 524 294C524 282.954 515.046 274 504 274Z\" fill=\"#E1E6ED\"/>\n </g>\n </svg>");
if (platform === platformEnum.mobile) loading.innerHTML = "<svg class=\"".concat(inlineImgClassName, " ").concat(inlineImgClassName, "-").concat(platform, "\" width=\"358\" height=\"186\" viewBox=\"0 0 358 186\" fill=\"none\" xmlns=\"\">\n <g clip-path=\"url(#clip0_2543_91192)\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n <g clip-path=\"url(#clip1_2543_91192)\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n <rect width=\"358\" height=\"40\" fill=\"white\"/>\n <rect opacity=\"0.7\" x=\"4\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"54\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <rect opacity=\"0.7\" x=\"104\" y=\"4\" width=\"32\" height=\"32\" rx=\"4\" fill=\"#E1E6ED\"/>\n <g clip-path=\"url(#clip2_2543_91192)\">\n <rect width=\"358\" height=\"120\" transform=\"translate(0 66)\" fill=\"white\"/>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M95 66H9C4.02944 66 0 70.0294 0 75C0 79.9706 4.02943 84 9 84H95C99.9706 84 104 79.9706 104 75C104 70.0294 99.9706 66 95 66Z\" fill=\"#E1E6ED\"/>\n </g>\n <g clip-path=\"url(#clip3_2543_91192)\">\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M340 94H18C8.05888 94 0 102.059 0 112C0 121.941 8.05887 130 18 130H340C349.941 130 358 121.941 358 112C358 102.059 349.941 94 340 94Z\" fill=\"#E1E6ED\"/>\n </g>\n <g style=\"mix-blend-mode:multiply\" opacity=\"0.336007\">\n <path d=\"M340 150H18C8.05888 150 0 158.059 0 168C0 177.941 8.05887 186 18 186H340C349.941 186 358 177.941 358 168C358 158.059 349.941 150 340 150Z\" fill=\"#E1E6ED\"/>\n </g>\n </g>\n </g>\n </g>\n </g>\n <defs>\n <clipPath id=\"clip0_2543_91192\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n </clipPath>\n <clipPath id=\"clip1_2543_91192\">\n <rect width=\"358\" height=\"186\" fill=\"white\"/>\n </clipPath>\n <clipPath id=\"clip2_2543_91192\">\n <rect width=\"358\" height=\"120\" fill=\"white\" transform=\"translate(0 66)\"/>\n </clipPath>\n <clipPath id=\"clip3_2543_91192\">\n <rect width=\"358\" height=\"92\" fill=\"white\" transform=\"translate(0 94)\"/>\n </clipPath>\n </defs>\n </svg>\n ");
if (_selector) _selector.appendChild(loading);
var loadingDom = document.getElementById(loadingId);
amsSetSize(null, loadingDom);
};
}
import type AMSCheckout from '../../core/instance';
import type { IappendIframeNodesParams, Iselector } from '../../types';
import { componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
import type { IappendIframeNodesParams, IcreateComponent } from '../../types';
import { CashierSdkActionQueryResult, componentSignEnum } from '../../types';
export default class ComponentApp {

@@ -9,3 +8,3 @@ app: any;

AMSSDK: AMSCheckout;
platform: platformEnum;
platform: 'desktop' | 'mobile';
private createIframeNode;

@@ -16,3 +15,2 @@ private _selector;

private _actionQueryPromise;
private _loadAppPromiseResolve;
private _renderParams;

@@ -23,3 +21,2 @@ private _componentSign;

private _clickEventName;
private _renderDisplayType;
constructor();

@@ -37,9 +34,7 @@ /**

*/
setRender(renderFunc: IrenderFuncParams): void;
setRender(createIframeNode: (context: ComponentApp, params: IcreateComponent) => Promise<void>): void;
/**
* @description render iframe content
*/
appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void>;
private renderPopupLoading;
private createLoadAppPromise;
appendIframeNodes(componentSign: componentSignEnum, renderParams: IappendIframeNodesParams): Promise<void | [void, CashierSdkActionQueryResult | null]>;
/**

@@ -76,8 +71,3 @@ * @description Interface request

*/
dispatchToApp(payload: {
context: {
event: string;
data: any;
};
}): any;
private dispatchToApp;
/**

@@ -91,11 +81,11 @@ * @description Subscribe to messages from SDK

private sendRenderEvent;
private showPopupLoading;
private showLoading;
/**
* @description show cashier
*/
private setContainerClass;
private showCashier;
/**
* @description close cashier
*/
private cleanContainer;
private closeCashier;
private hideComponentAndCleanDom;

@@ -106,4 +96,3 @@ private closeBtnFunc;

*/
private createBaseElement;
private createInlineBaseElement;
private createMountElement;
private createCloseBtn;

@@ -121,2 +110,1 @@ private createRetentionPopup;

}
export {};

@@ -5,2 +5,4 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -21,18 +23,28 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }

import { queryPaymentInfo } from "../../service";
import { componentSignEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum, eventCodeEnum } from "../../types";
import { addSetFontSizeEvent, amsSetSize, getDesignFontSize, getType, isJsonString, isPC } from "../../util";
import { componentSignEnum, messageName, productSceneEnum, Target } from "../../types";
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
import { isLocalMock } from "../../util/mock";
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
import { componentAddCSS, inlineComponentAddCss, showInlineLoading } from "./component.style";
import { componentAddCSS } from "./component.style";
var _window = window,
innerHeight = _window.innerHeight;
var componentContainerId = 'ams-component-container';
var componentSectionId = 'ams-component-section';
var componentCloseBlockId = 'asm-component-close-block';
var componentRetentionId = 'ams-component-retention';
var amsSetSize = function amsSetSize(event, dom) {
try {
var _dom = dom || document.getElementById('ams-component-container');
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
innerHeight = window.innerHeight;
// eslint-disable-next-line no-empty
} catch (error) {}
};
var addEvent = function addEvent() {
window.removeEventListener('resize', amsSetSize);
window.removeEventListener('pageShow', amsSetSize);
window.removeEventListener('DOMContentLoaded', amsSetSize);
window.addEventListener('resize', amsSetSize);
window.addEventListener('pageShow', amsSetSize);
window.addEventListener('DOMContentLoaded', amsSetSize);
};
var mockupId = 'ams-component-mockup';
var loadingId = 'ams-component-loading';
var listenerPrefix = '_ams_sdk_component_listener';
var inlineBaseStyleId = 'ams-inline-component-style';
var loadTimeLimit = 15000;
var ComponentApp = /*#__PURE__*/function () {

@@ -50,3 +62,2 @@ function ComponentApp() {

_defineProperty(this, "_actionQueryPromise", null);
_defineProperty(this, "_loadAppPromiseResolve", null);
_defineProperty(this, "_renderParams", null);

@@ -57,12 +68,13 @@ _defineProperty(this, "_componentSign", componentSignEnum.NONE);

_defineProperty(this, "_clickEventName", void 0);
_defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
this._appVersion = '1.5.1';
this._appVersion = '1.5.3';
this._isInitComponent = false;
this._selector = "#".concat(componentSectionId);
this._selector = '#ams-component-section';
this.createIframeNode = function () {
return Promise.resolve();
};
this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
this._clickEventName = this.platform === platformEnum.mobile ? 'touchend' : 'click';
this.platform = isPC() ? 'desktop' : 'mobile';
this._clickEventName = this.platform === 'mobile' ? 'touchend' : 'click';
this._isRetention = true;
addEvent();
this.createMountElement();
this._performanceData.push({

@@ -80,3 +92,3 @@ key: 'sdk_init',

value: function logoutPlugin() {
this.cleanContainer(true);
this.closeCashier();
}

@@ -99,4 +111,4 @@

key: "setRender",
value: function setRender(renderFunc) {
this.createIframeNode = renderFunc;
value: function setRender(createIframeNode) {
this.createIframeNode = createIframeNode;
}

@@ -110,13 +122,8 @@

value: function appendIframeNodes(componentSign, renderParams) {
var _this = this;
if (this._isInitComponent) {
this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
}
var _renderParams$appeara,
_this = this;
if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
this._isInitComponent = true;
this._renderParams = renderParams;
this._componentSign = componentSign;
if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
this._renderDisplayType = renderParams.renderDisplayType;
var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(componentContainerId) : this._selector;
this._performanceData.push({

@@ -126,55 +133,20 @@ key: 'sdk_create_component',

});
this.dispatchToSDK(EVENT.eventCallback.name, {
code: eventCodeEnum.SDK_START_OF_LOADING
});
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
this.createInlineBaseElement(renderParams);
this.createRetentionPopup();
this.createMockup();
if ((renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading) !== false) {
var mockup = document.getElementById(mockupId);
if (mockup) {
mockup.style.display = 'block';
}
this.showLoading();
}
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
this.createBaseElement();
this.setContainerClass();
this.createRetentionPopup();
this.createMockup();
this.renderPopupLoading(renderParams);
}
this.showCashier();
this.createApp(renderParams);
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this.createLoadAppPromise()]).then(function () {
return Promise.resolve();
}).catch(function (error) {
this.createActionQueryPromise();
return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
selector: this._selector
})), this._actionQueryPromise]).catch(function () {
_this._isInitComponent = false;
_this.cleanContainer();
return Promise.reject(error);
});
}
}, {
key: "renderPopupLoading",
value: function renderPopupLoading(renderParams) {
var _renderParams$appeara;
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
if (!showLoading) return;
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
var mockup = document.getElementById(mockupId);
if (mockup) mockup.style.display = 'block';
return this.showPopupLoading();
}
}
}, {
key: "createLoadAppPromise",
value: function createLoadAppPromise() {
var _this2 = this;
return new Promise(function (resolve, reject) {
_this2._loadAppPromiseResolve = resolve;
setTimeout(function () {
reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
}, loadTimeLimit);
}).catch(function (error) {
_this2.dispatchToSDK(EVENT.error.name, {
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
});
return Promise.reject(error);
});
}
/**

@@ -186,3 +158,3 @@ * @description Interface request

value: function createActionQueryPromise() {
var _this3 = this;
var _this2 = this;
this._performanceData.push({

@@ -193,6 +165,6 @@ key: 'sdk_action_query_start',

this._actionQueryPromise = new Promise(function (resolve, reject) {
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
var params = {
paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
paymentSessionConfig: (_this3$_renderParams2 = _this3._renderParams) === null || _this3$_renderParams2 === void 0 ? void 0 : (_this3$_renderParams3 = _this3$_renderParams2.paymentSessionMetaData) === null || _this3$_renderParams3 === void 0 ? void 0 : _this3$_renderParams3.paymentSessionConfig
paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
paymentSessionConfig: (_this2$_renderParams2 = _this2._renderParams) === null || _this2$_renderParams2 === void 0 ? void 0 : (_this2$_renderParams3 = _this2$_renderParams2.paymentSessionMetaData) === null || _this2$_renderParams3 === void 0 ? void 0 : _this2$_renderParams3.paymentSessionConfig
};

@@ -202,3 +174,3 @@ /**

*/
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign) {
params.paymentMethodType = 'CARD';

@@ -209,4 +181,4 @@ }

*/
if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
var _this3$_renderParams4;
if (componentSignEnum.EASY_PAY_WALLET === _this2._componentSign) {
var _this2$_renderParams4;
var _ref = params.paymentSessionConfig || {},

@@ -217,3 +189,3 @@ _ref$productSceneVers = _ref.productSceneVersion,

productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
var _ref2 = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.paymentSessionMetaData) || {},
var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
_ref2$action = _ref2.action,

@@ -235,5 +207,5 @@ _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,

*/
if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
var _this3$_renderParams5, _this3$_renderParams6, _action$web, _action$wap;
var action = ((_this3$_renderParams5 = _this3._renderParams) === null || _this3$_renderParams5 === void 0 ? void 0 : (_this3$_renderParams6 = _this3$_renderParams5.paymentSessionMetaData) === null || _this3$_renderParams6 === void 0 ? void 0 : _this3$_renderParams6.action) || {};
if (componentSignEnum.AUTO_DEBIT_WALLET === _this2._componentSign) {
var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
var action = ((_this2$_renderParams5 = _this2._renderParams) === null || _this2$_renderParams5 === void 0 ? void 0 : (_this2$_renderParams6 = _this2$_renderParams5.paymentSessionMetaData) === null || _this2$_renderParams6 === void 0 ? void 0 : _this2$_renderParams6.action) || {};
var signType = isPC() ? action === null || action === void 0 ? void 0 : (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 ? void 0 : (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;

@@ -261,6 +233,6 @@ if (signType === 'SMS') {

queryPaymentInfo(params, {
env: _this3.AMSSDK.options.env.environment,
locale: _this3.AMSSDK.options.locale
env: _this2.AMSSDK.options.env.environment,
locale: _this2.AMSSDK.options.locale
}).then(function (res) {
_this3._performanceData.push({
_this2._performanceData.push({
key: 'sdk_action_query_end',

@@ -273,11 +245,9 @@ value: Date.now()

resolve(res);
_this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
}
}).catch(function (err) {
_this3.dispatchToSDK(EVENT.error.name, {
code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
});
reject(err);
_this2.closeCashier();
});
});
return this._actionQueryPromise;
}

@@ -291,9 +261,7 @@ }, {

if (getType(this._selector) === 'string') {
var selectorDom = document.querySelector(this._selector);
if (selectorDom) selectorDom.innerHTML = '';
var dorpinDom = document.querySelector(this._selector);
if (dorpinDom) dorpinDom.innerHTML = '';
}
// eslint-disable-next-line no-empty
} catch (error) {
console.error(error);
}
} catch (error) {}
}

@@ -327,3 +295,3 @@

});
this.app = createIframe(this.AMSSDK.options.mode, this.platform);
this.app = createIframe(this.AMSSDK.options.mode);
this.app.src = getIframeUrl({

@@ -369,3 +337,3 @@ componentSign: this._componentSign,

value: function resizeListener() {
var cashier = document.getElementById(componentContainerId);
var cashier = document.getElementById('ams-component-container');
cashier.style.transition = 'none';

@@ -408,3 +376,3 @@ this.dispatchToApp({

value: function _handleAppMessage(data) {
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.close.name, EVENT.error.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name];
var eventKeyMap = [EVENT.launch.name, EVENT.redirect.name, EVENT.sizeChanged.name, EVENT.log.name, EVENT.onClose.name, EVENT.eventCallback.name, EVENT.submitForm.name, EVENT.showCloseButton.name, EVENT.hideCloseButton.name, EVENT.setAllowRetention.name, EVENT.declareCheckoutInfo.name, EVENT.showPopup.name, EVENT.dismissLoading.name];
if (data.context.event === EVENT.dismissLoading.name) {

@@ -426,3 +394,2 @@ var _data$context$data;

});
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
this.sendRenderEvent();

@@ -434,3 +401,3 @@ return;

}
if (data.context.event === EVENT.close.name) {
if (data.context.event === EVENT.onClose.name) {
return this.closeBtnFunc();

@@ -470,6 +437,3 @@ }

var _data$context$data2;
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
var cashier = document.getElementById(componentContainerId);
cashier.style.height = "".concat(data.context.data.height, "px");
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) > 1) {
var _document$getElementB;

@@ -483,9 +447,11 @@ var mockup = document.getElementById(mockupId);

(_document$getElementB = document.getElementById(loadingId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
var cashier = document.getElementById('ams-component-container');
cashier.style.height = "".concat(data.context.data.height, "px");
if (this.platform === 'desktop') {
cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
cashier.classList.add('ams-component-container-desktop-animation');
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
}
if (this.platform === 'mobile') {
cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
var animationStyleId = "".concat(componentContainerId, "-").concat(this.platform, "-animation-style");
cashier.classList.add('ams-component-container-mobile-animation');
var animationStyleId = 'ams-component-container-mobile-animation-style';
var animationStyle = document.getElementById(animationStyleId);

@@ -495,3 +461,3 @@ if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();

// 弹出和弹入动画
var runkeyframes = "@keyframes ".concat(componentContainerId, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(data.context.data.height, "px;\n }\n }\n @keyframes ").concat(componentContainerId, "-slide-out {\n 0% {\n height: ").concat(data.context.data.height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
var runkeyframes = " @keyframes ams-component-container-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ".concat(data.context.data.height, "px;\n }\n }\n @keyframes ams-component-container-slide-out {\n 0% {\n height: ").concat(data.context.data.height, "px;\n opacity: 1;\n }\n 50% {\n opacity: 1;\n }\n 100% {\n height: 1px;\n opacity: 0;\n }\n }");
// 创建style标签

@@ -512,9 +478,7 @@ var style = document.createElement('style');

}
this.app.style.height = "".concat(data.context.data.height, "px");
this.app.style.width = '100%';
this.app.style.border = '0';
this.app.style.overflow = 'hidden';
}
if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
var _document$getElementB2;
(_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
}
this.app.style.height = "".concat(data.context.data.height, "px");
this.app.style.opacity = '1';
}

@@ -524,3 +488,4 @@ }, {

value: function handleRedirect(data) {
var _this4 = this;
var _this3 = this;
this.closeCashier();
var _data = typeof data === 'string' ? {

@@ -535,4 +500,4 @@ normalUrl: data

var successCallback = function successCallback(type, url) {
_this4.dispatchToSDK(EVENT.eventCallback.name, {
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
_this3.dispatchToSDK(EVENT.eventCallback.name, {
code: 'SDK_CALL_URL_SUCCESS',
message: "Successfully opened the app,".concat(type, ": ").concat(url)

@@ -542,4 +507,4 @@ });

var failCallback = function failCallback() {
_this4.dispatchToSDK(EVENT.eventCallback.name, {
code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
_this3.dispatchToSDK(EVENT.eventCallback.name, {
code: 'SDK_CALL_URL_ERROR',
message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)

@@ -550,3 +515,3 @@ });

// 支持 target: _blank,新开tab页打开
if (_data.target === targetEnum.BLANK) {
if (_data.target === Target.BLANK) {
if (!_data.normalUrl) return failCallback();

@@ -557,3 +522,2 @@ successCallback('normalUrl', _data.normalUrl);

}
this.cleanContainer();
this.AMSSDK._redirect({

@@ -564,3 +528,3 @@ applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl

}).catch(function () {
return _this4.AMSSDK._redirect({
return _this3.AMSSDK._redirect({
schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl

@@ -571,3 +535,3 @@ });

}).catch(function () {
return _this4.AMSSDK._redirect({
return _this3.AMSSDK._redirect({
normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl

@@ -588,3 +552,3 @@ });

if (closeDialogData) {
var retentionTitle = document.getElementById("".concat(componentRetentionId, "-title"));
var retentionTitle = document.getElementById('ams-component-retention-title');
if (retentionTitle) {

@@ -596,3 +560,3 @@ var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;

}
var retentionMessage = document.getElementById("".concat(componentRetentionId, "-sub-title"));
var retentionMessage = document.getElementById('ams-component-retention-sub-title');
if (retentionMessage) {

@@ -604,3 +568,3 @@ var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;

}
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
var remainBtn = document.getElementById('ams-component-retention-remain');
if (remainBtn) {

@@ -617,3 +581,3 @@ var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;

}
var leaveBrn = document.getElementById("".concat(componentRetentionId, "-leave"));
var leaveBrn = document.getElementById('ams-component-retention-leave');
if (leaveBrn) {

@@ -638,7 +602,7 @@ var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;

value: function handleCloseBtnShow(showClose) {
var closeBlock = document.getElementById(componentCloseBlockId);
var closeBlock = document.getElementById('asm-component-section-close-block');
if (showClose) {
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(componentCloseBlockId, "-hidden"));
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove('asm-component-close-block-hidden');
} else if (showClose === false) {
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(componentCloseBlockId, "-hidden"));
closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add('asm-component-close-block-hidden');
}

@@ -653,3 +617,3 @@ }

value: function dispatchToSDK(event, data) {
this.AMSSDK._eventCenter.emit(event, data);
this.AMSSDK.eventCenter.emit(event, data);
}

@@ -670,5 +634,4 @@

if (this.app && this.app.contentWindow) {
return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
}
throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
}

@@ -686,3 +649,3 @@

if (eventKeyMap.hasOwnProperty(key)) {
this.AMSSDK._eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
this.AMSSDK.eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
}

@@ -699,3 +662,3 @@ }

var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
var _this$_renderParams, _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, res;
var _this$_renderParams, _this$_renderParams2, res;
return _regeneratorRuntime().wrap(function _callee$(_context) {

@@ -727,4 +690,2 @@ while (1) switch (_context.prev = _context.next) {

heightOfVisible: Math.max(innerHeight, window.innerHeight),
renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
envInfo: {

@@ -763,4 +724,4 @@ screenHeight: screen.height,

}, {
key: "showPopupLoading",
value: function showPopupLoading() {
key: "showLoading",
value: function showLoading() {
var loading = document.createElement('div');

@@ -779,7 +740,7 @@ loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);

}, {
key: "setContainerClass",
value: function setContainerClass() {
var cashier = document.getElementById(componentContainerId);
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("".concat(componentContainerId, "-hidden-").concat(this.platform));
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform));
key: "showCashier",
value: function showCashier() {
var cashier = document.getElementById('ams-component-container');
cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("ams-component-container-hidden-".concat(this.platform));
cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("ams-component-container-".concat(this.platform));
}

@@ -791,10 +752,9 @@

}, {
key: "cleanContainer",
value: function cleanContainer() {
var _document$getElementB3;
key: "closeCashier",
value: function closeCashier() {
var _document$getElementB2;
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
this._performanceData = [];
this._isInitComponent = false;
(_document$getElementB3 = document.getElementById(loadingId)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
(_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
this.hideComponentAndCleanDom(immediately);

@@ -805,14 +765,12 @@ }

value: function hideComponentAndCleanDom() {
var _this5 = this;
var _this4 = this;
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var container = document.getElementById(componentContainerId);
if (container) {
// size变化动画取消
container.style.transition = '';
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-").concat(this.platform));
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
container === null || container === void 0 ? void 0 : container.classList.add("".concat(componentContainerId, "-hidden-").concat(this.platform));
}
var container = document.getElementById('ams-component-container');
// size变化动画取消
container.style.transition = '';
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform));
container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform, "-animation"));
container === null || container === void 0 ? void 0 : container.classList.add("ams-component-container-hidden-".concat(this.platform));
var removeMockupAndApp = function removeMockupAndApp() {
var _document$getElementB4;
var _document$getElementB3;
var body = document.getElementsByTagName('body')[0];

@@ -823,5 +781,5 @@ body.style.overflow = 'auto';

if (container) container.style.height = '';
(_document$getElementB4 = document.getElementById("".concat(componentContainerId, "-").concat(_this5.platform, "-animation-style"))) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
_this5.removeRetentionPopup();
_this5.cleanApp();
(_document$getElementB3 = document.getElementById('ams-component-container-mobile-animation-style')) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
_this4.removeRetentionPopup();
_this4.cleanApp();
};

@@ -839,4 +797,4 @@ if (immediately) removeMockupAndApp();else {

if (this._isRetention) this.showRetentionPopup();else {
this.cleanContainer();
this.dispatchToSDK(EVENT.close.name, {});
this.closeCashier();
this.dispatchToSDK(EVENT.onClose.name, {});
}

@@ -849,10 +807,8 @@ }

}, {
key: "createBaseElement",
value: function createBaseElement() {
if (document.getElementById(componentContainerId)) return;
key: "createMountElement",
value: function createMountElement() {
componentAddCSS();
addSetFontSizeEvent();
var amsComponentContainer = document.createElement('div');
amsComponentContainer.className = "".concat(componentContainerId, "-hidden-").concat(this.platform);
amsComponentContainer.id = componentContainerId;
amsComponentContainer.className = "ams-component-container-hidden-".concat(this.platform);
amsComponentContainer.id = 'ams-component-container';
amsSetSize(null, amsComponentContainer);

@@ -862,3 +818,3 @@ document.body.appendChild(amsComponentContainer);

amsComponentSection.className = "ams-component-section-".concat(this.platform);
amsComponentSection.id = componentSectionId;
amsComponentSection.id = this._selector.slice(1);
amsComponentContainer.appendChild(amsComponentSection);

@@ -868,30 +824,14 @@ this.createCloseBtn();

}, {
key: "createInlineBaseElement",
value: function createInlineBaseElement(renderParams) {
var _renderParams$appeara2;
var inlineBaseStyle = document.getElementById(inlineBaseStyleId);
if (!inlineBaseStyle) inlineComponentAddCss();
if (document.getElementById(componentContainerId)) return;
var amsComponentContainer = document.createElement('div');
amsComponentContainer.className = "".concat(componentContainerId, "-inline");
amsComponentContainer.id = componentContainerId;
var selectorDom = document.querySelector(this._selector);
if (selectorDom) selectorDom.appendChild(amsComponentContainer);
var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
showLoading = typeof showLoading === 'boolean' ? showLoading : true;
if (showLoading) showInlineLoading(amsComponentContainer, this.platform);
}
}, {
key: "createCloseBtn",
value: function createCloseBtn() {
var _this6 = this;
var container = document.getElementById(componentContainerId);
var _this5 = this;
var container = document.getElementById('ams-component-container');
// close btn
var closeBtnHTML = "<img class='".concat(componentCloseBlockId, "-btn-").concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
var closeBlock = document.createElement('div');
closeBlock.classList.add("".concat(componentCloseBlockId, "-").concat(this.platform), "".concat(componentCloseBlockId, "-hidden"));
closeBlock.id = componentCloseBlockId;
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
closeBlock.id = 'asm-component-section-close-block';
closeBlock.innerHTML = closeBtnHTML;
closeBlock.addEventListener(this._clickEventName, function () {
_this6.closeBtnFunc();
_this5.closeBtnFunc();
});

@@ -905,11 +845,11 @@ if (container) container.appendChild(closeBlock);

var retentionPopup = document.createElement('div');
retentionPopup.id = componentRetentionId;
retentionPopup.classList.add("".concat(componentRetentionId, "-").concat(this.platform));
retentionPopup.innerHTML = "\n <span id=\"".concat(componentRetentionId, "-title\" class=\"").concat(componentRetentionId, "-title-").concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"").concat(componentRetentionId, "-sub-title\"\n class=\"").concat(componentRetentionId, "-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"").concat(componentRetentionId, "-btn-block-").concat(this.platform, "\">\n <div id=\"").concat(componentRetentionId, "-remain\" class=\"").concat(componentRetentionId, "-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"").concat(componentRetentionId, "-leave\" class=\"").concat(componentRetentionId, "-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
retentionPopup.id = 'ams-component-retention';
retentionPopup.classList.add("ams-component-retention-".concat(this.platform));
retentionPopup.innerHTML = "\n <span id=\"ams-component-retention-title\" class=\"ams-component-retention-title-".concat(this.platform, "\">\n Are you sure you want to leave?\n </span>\n <span\n id=\"ams-component-retention-sub-title\"\n class=\"ams-component-retention-sub-title-").concat(this.platform, "\"\n >\n If you leave this page, you'll have to start over again.\n </span>\n <div class=\"ams-component-retention-btn-block-").concat(this.platform, "\">\n <div id=\"ams-component-retention-remain\" class=\"ams-component-retention-remain-").concat(this.platform, "\">\n Continue Payment\n </div>\n <div id=\"ams-component-retention-leave\" class=\"ams-component-retention-leave-").concat(this.platform, "\">\n Leave\n </div>\n </div>");
document.body.appendChild(retentionPopup);
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
var remainBtn = document.getElementById('ams-component-retention-remain');
if (remainBtn) {
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
}
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
var leaveBtn = document.getElementById('ams-component-retention-leave');
if (leaveBtn) {

@@ -922,5 +862,5 @@ leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));

value: function retentionPopupLeaveFunc() {
this.dispatchToSDK(EVENT.close.name, {});
this.dispatchToSDK(EVENT.onClose.name, {});
this.hideRetentionPopup();
this.cleanContainer();
this.closeCashier();
}

@@ -930,12 +870,12 @@ }, {

value: function removeRetentionPopup() {
var _document$getElementB5;
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
var _document$getElementB4;
var remainBtn = document.getElementById('ams-component-retention-remain');
if (remainBtn) {
remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
}
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
var leaveBtn = document.getElementById('ams-component-retention-leave');
if (leaveBtn) {
leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
}
(_document$getElementB5 = document.getElementById(componentRetentionId)) === null || _document$getElementB5 === void 0 ? void 0 : _document$getElementB5.remove();
(_document$getElementB4 = document.getElementById('ams-component-retention')) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
}

@@ -945,8 +885,8 @@ }, {

value: function showRetentionPopup() {
var retentionPopup = document.getElementById(componentRetentionId);
var container = document.getElementById(componentContainerId);
var retentionPopup = document.getElementById('ams-component-retention');
var container = document.getElementById('ams-component-container');
if (retentionPopup) {
container === null || container === void 0 ? void 0 : container.classList.add("".concat(componentContainerId, "-opacity"));
retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
retentionPopup.classList.add("".concat(componentRetentionId, "-show"));
container === null || container === void 0 ? void 0 : container.classList.add('ams-component-container-opacity');
retentionPopup.classList.remove('ams-component-retention-hidden');
retentionPopup.classList.add('ams-component-retention-show');
}

@@ -957,11 +897,11 @@ }

value: function hideRetentionPopup() {
var retentionPopup = document.getElementById(componentRetentionId);
var container = document.getElementById(componentContainerId);
var retentionPopup = document.getElementById('ams-component-retention');
var container = document.getElementById('ams-component-container');
if (retentionPopup) {
retentionPopup.classList.remove("".concat(componentRetentionId, "-show"));
retentionPopup.classList.add("".concat(componentRetentionId, "-hidden"));
retentionPopup.classList.remove('ams-component-retention-show');
retentionPopup.classList.add('ams-component-retention-hidden');
setTimeout(function () {
retentionPopup.classList.remove("".concat(componentRetentionId, "-hidden"));
container === null || container === void 0 ? void 0 : container.classList.remove("".concat(componentContainerId, "-opacity"));
}, 300);
retentionPopup.classList.remove('ams-component-retention-hidden');
container === null || container === void 0 ? void 0 : container.classList.remove('ams-component-container-opacity');
}, 250);
}

@@ -1009,2 +949,3 @@ }

body.appendChild(form);
this.closeCashier(true);
setTimeout(function () {

@@ -1011,0 +952,0 @@ form.submit();

@@ -188,3 +188,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

case 'COMPONENT':
id = 'ams-checkout-component';
id = 'checkout-component';
break;

@@ -191,0 +191,0 @@ }

@@ -8,3 +8,3 @@ /**

*/
import { IrequestConfig } from '../types';
import { RequestConfig } from '../types';
/**

@@ -16,2 +16,2 @@ *

*/
export declare function request<T>(requestData: Record<string, any> | undefined, options: IrequestConfig): Promise<T>;
export declare function request<T>(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<T>;

@@ -20,3 +20,3 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }

import { appId, hostSignMap, lightSandboxMap, requestHost, sofaId, tntInstId } from "../config/request";
import { errorEnum } from "../types";
import { ERROR } from "../types";
import { get } from "../util/get";

@@ -129,6 +129,6 @@ import axios from 'axios';

success: false,
errorCode: errorEnum.SYSTEM,
errorCode: ERROR.SYSTEM,
errorMessage: ''
});
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? ERROR.TIMEOUT : '';
errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;

@@ -135,0 +135,0 @@ return _context.abrupt("return", Promise.reject({

@@ -8,3 +8,3 @@ /**

*/
import { errorEnum } from '../types';
import { ERROR } from '../types';
export declare const safeJson: (data: any, obj: any) => any;

@@ -14,3 +14,3 @@ export declare const fomatGetwayError: (headers: Record<string, any>, traceId: string) => {

traceId: string;
errorCode: errorEnum;
errorCode: ERROR;
resultStatus: any;

@@ -22,3 +22,3 @@ errorMessage?: undefined;

traceId: string;
errorCode: errorEnum;
errorCode: ERROR;
errorMessage: string;

@@ -25,0 +25,0 @@ result: {

@@ -9,3 +9,3 @@ /**

import { errorEnum } from "../types";
import { ERROR } from "../types";
import { get } from "../util/get";

@@ -30,3 +30,3 @@ export var safeJson = function safeJson(data, obj) {

traceId: traceId,
errorCode: errorEnum.LOGIN,
errorCode: ERROR.LOGIN,
resultStatus: resultStatus

@@ -40,3 +40,3 @@ };

traceId: traceId,
errorCode: errorEnum.TIMEOUT,
errorCode: ERROR.TIMEOUT,
resultStatus: resultStatus

@@ -51,3 +51,3 @@ };

traceId: traceId,
errorCode: errorEnum.GATEWAY,
errorCode: ERROR.GATEWAY,
errorMessage: decodeURIComponent(tips || ''),

@@ -54,0 +54,0 @@ result: {

@@ -1,2 +0,2 @@

import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, IrequestConfig } from '../types';
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: IrequestConfig): Promise<CashierSdkActionQueryResult>;
import { CashierSdkActionQueryRequest, CashierSdkActionQueryResult, RequestConfig } from '../types';
export declare function queryPaymentInfo(params?: CashierSdkActionQueryRequest, options?: RequestConfig): Promise<CashierSdkActionQueryResult>;

@@ -11,3 +11,3 @@ /**

*/
export interface IoptionsParams {
export interface optionsParams {
environment?: string;

@@ -19,4 +19,4 @@ locale?: string;

onLog?: callOnLog;
onEventCallback?: callOnEventCallback;
onClose?: callOnClose;
onEventCallback?: (state: any) => void;
onClose?: () => void;
networkMode?: string;

@@ -28,13 +28,8 @@ mode?: string;

}
export type Iselector = string;
export declare enum renderDisplayTypeEnum {
'popup' = "popup",
'inline' = "inline"
}
export interface IcreatePaymentParams {
export interface createPaymentParams {
paymentMethodsResult?: any;
paymentSessionData?: string;
selector: Iselector;
selector: string | HTMLElement;
appearance?: {
displayType?: checkoutDisplayEnum;
displayType?: checkoutDisplay;
backgroundColor?: string;

@@ -62,8 +57,7 @@ };

paymentSessionData: string;
selector?: string | HTMLElement;
appearance?: Record<string, any>;
}
export interface IappendIframeNodesParams extends IcreateComponent {
paymentSessionMetaData: IpaymentSessionMetaData;
renderDisplayType: renderDisplayTypeEnum;
selector?: Iselector;
paymentSessionMetaData?: IpaymentSessionMetaData;
}

@@ -87,18 +81,18 @@ interface IpaymentSessionConfig {

}
export declare enum checkoutDisplayEnum {
export declare enum checkoutDisplay {
horizon = "horizon",
vertical = "vertical"
}
export declare enum modeEnum {
export declare enum mode {
dropin = "dropin",
component = "component"
}
export declare enum networkModeEnum {
export declare enum networkMode {
proxy = "proxy",
session = "session"
}
export interface IcheckoutState {
paymentMethodType?: string;
export interface checkoutState {
paymentMethodType: string;
}
export declare enum environmentEnum {
export declare enum environment {
sandbox = "sandbox",

@@ -108,3 +102,3 @@ prod = "prod",

}
export declare enum osTypeEnum {
export declare enum osType {
IOS = "IOS",

@@ -114,3 +108,3 @@ ANDROID = "ANDROID",

}
export declare enum terminalTypeEnum {
export declare enum terminalType {
WEB = "WEB",

@@ -121,33 +115,12 @@ WAP = "WAP",

}
export interface Ienv {
osType?: osTypeEnum;
terminalType: terminalTypeEnum;
export interface env {
osType?: osType;
terminalType: terminalType;
environment: string;
}
export declare enum platformEnum {
desktop = "desktop",
mobile = "mobile"
}
/**
* @description Create an event handler, called when an error occurs in AMSCheckout.
*/
export type callOnError = (state: {
code: string;
message: string;
errorMessage: string;
errorCode: string;
stack?: any;
}) => void;
/**
* @description Create an event handler, called when the general log triggers during the SDK runtime.
*/
export type callOnLog = (state: {
code: string;
message: string;
}) => void;
/**
* @description Create an event handler, during the running of the sdk, some events are called after execution, and the specific event code is returned.
*/
export type callOnEventCallback = (state: {
code: string;
message: string;
}) => void;
export type callonPaymentMethodSelected = (state: {

@@ -157,9 +130,9 @@ paymentMethodType: string;

export type callOnSizeChanged = (state: {
width: number;
height: number;
width: string;
height: string;
}) => void;
/**
* @description Create an event handler, In pop-up layer mode, the user clicks the semi floating layer close button and is called.
*/
export type callOnClose = () => void;
export type callOnLog = (state: {
code: string;
message: string;
}) => void;
export declare enum messageName {

@@ -181,3 +154,3 @@ SDK_TO_APP = "SDK_TO_APP",

export interface AMSCheckoutOptions {
env: Ienv;
env: env;
locale: string;

@@ -191,7 +164,3 @@ networkMode: string;

}
export declare enum targetEnum {
BLANK = "_blank",
SELF = "_self"
}
export declare enum errorEnum {
export declare enum ERROR {
PARAMS = "PARAMS",

@@ -211,3 +180,3 @@ TIMEOUT = "TIMEOUT",

}
export interface IrequestConfig {
export interface RequestConfig {
env?: string;

@@ -250,12 +219,2 @@ baseURL?: string;

}
export declare enum eventCodeEnum {
SDK_START_OF_LOADING = "SDK_START_OF_LOADING",
SDK_END_OF_LOADING = "SDK_END_OF_LOADING",
SDK_INTERNAL_ERROR = "SDK_INTERNAL_ERROR",
SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR",
SDK_INIT_PARAMETER_ERROR = "SDK_INIT_PARAMETER_ERROR",
SDK_CREATECOMPONENT_ERROR = "SDK_CREATECOMPONENT_ERROR",
SDK_CALL_URL_ERROR = "SDK_CALL_URL_ERROR",
SDK_CALL_URL_SUCCESS = "SDK_CALL_URL_SUCCESS"
}
declare global {

@@ -266,2 +225,6 @@ interface Window {

}
export declare enum Target {
BLANK = "_blank",
SELF = "_self"
}
export {};

@@ -13,7 +13,2 @@ /**

export var renderDisplayTypeEnum = /*#__PURE__*/function (renderDisplayTypeEnum) {
renderDisplayTypeEnum["popup"] = "popup";
renderDisplayTypeEnum["inline"] = "inline";
return renderDisplayTypeEnum;
}({});
export var componentSignEnum = /*#__PURE__*/function (componentSignEnum) {

@@ -43,57 +38,36 @@ componentSignEnum["EASY_PAY_WALLET"] = "EASY_PAY_WALLET";

}({});
export var checkoutDisplayEnum = /*#__PURE__*/function (checkoutDisplayEnum) {
checkoutDisplayEnum["horizon"] = "horizon";
checkoutDisplayEnum["vertical"] = "vertical";
return checkoutDisplayEnum;
export var checkoutDisplay = /*#__PURE__*/function (checkoutDisplay) {
checkoutDisplay["horizon"] = "horizon";
checkoutDisplay["vertical"] = "vertical";
return checkoutDisplay;
}({});
export var modeEnum = /*#__PURE__*/function (modeEnum) {
modeEnum["dropin"] = "dropin";
modeEnum["component"] = "component";
return modeEnum;
export var mode = /*#__PURE__*/function (mode) {
mode["dropin"] = "dropin";
mode["component"] = "component";
return mode;
}({});
export var networkModeEnum = /*#__PURE__*/function (networkModeEnum) {
networkModeEnum["proxy"] = "proxy";
networkModeEnum["session"] = "session";
return networkModeEnum;
export var networkMode = /*#__PURE__*/function (networkMode) {
networkMode["proxy"] = "proxy";
networkMode["session"] = "session";
return networkMode;
}({});
export var environmentEnum = /*#__PURE__*/function (environmentEnum) {
environmentEnum["sandbox"] = "sandbox";
environmentEnum["prod"] = "prod";
environmentEnum["light_sandbox"] = "light_sandbox";
return environmentEnum;
export var environment = /*#__PURE__*/function (environment) {
environment["sandbox"] = "sandbox";
environment["prod"] = "prod";
environment["light_sandbox"] = "light_sandbox";
return environment;
}({});
export var osTypeEnum = /*#__PURE__*/function (osTypeEnum) {
osTypeEnum["IOS"] = "IOS";
osTypeEnum["ANDROID"] = "ANDROID";
osTypeEnum["ELSE"] = "ELSE";
return osTypeEnum;
export var osType = /*#__PURE__*/function (osType) {
osType["IOS"] = "IOS";
osType["ANDROID"] = "ANDROID";
osType["ELSE"] = "ELSE";
return osType;
}({});
export var terminalTypeEnum = /*#__PURE__*/function (terminalTypeEnum) {
terminalTypeEnum["WEB"] = "WEB";
terminalTypeEnum["WAP"] = "WAP";
terminalTypeEnum["APP"] = "APP";
terminalTypeEnum["MINI_APP"] = "MINI_APP";
return terminalTypeEnum;
export var terminalType = /*#__PURE__*/function (terminalType) {
terminalType["WEB"] = "WEB";
terminalType["WAP"] = "WAP";
terminalType["APP"] = "APP";
terminalType["MINI_APP"] = "MINI_APP";
return terminalType;
}({});
export var platformEnum = /*#__PURE__*/function (platformEnum) {
platformEnum["desktop"] = "desktop";
platformEnum["mobile"] = "mobile";
return platformEnum;
}({});
/**
* @description Create an event handler, called when an error occurs in AMSCheckout.
*/
/**
* @description Create an event handler, called when the general log triggers during the SDK runtime.
*/
/**
* @description Create an event handler, during the running of the sdk, some events are called after execution, and the specific event code is returned.
*/
/**
* @description Create an event handler, In pop-up layer mode, the user clicks the semi floating layer close button and is called.
*/
export var messageName = /*#__PURE__*/function (messageName) {

@@ -105,33 +79,22 @@ messageName["SDK_TO_APP"] = "SDK_TO_APP";

}({});
export var targetEnum = /*#__PURE__*/function (targetEnum) {
targetEnum["BLANK"] = "_blank";
targetEnum["SELF"] = "_self";
return targetEnum;
export var ERROR = /*#__PURE__*/function (ERROR) {
ERROR["PARAMS"] = "PARAMS";
ERROR["TIMEOUT"] = "TIMEOUT";
ERROR["NETWORK"] = "NETWORK";
ERROR["SYSTEM"] = "SYSTEM";
ERROR["LOGIN"] = "LOGIN";
ERROR["GATEWAY"] = "GATEWAY";
ERROR["VALIDATION"] = "VALIDATION";
ERROR["TAOBAOBINDALIPAY"] = "TAOBAOBINDALIPAY";
ERROR["REGISTERWALLET"] = "REGISTERWALLET";
ERROR["NOALIPAYID"] = "NOALIPAYID";
ERROR["TRUSTLOGINERROR"] = "TRUSTLOGINERROR";
ERROR["SIGNIN"] = "SIGNIN";
ERROR["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
return ERROR;
}({});
export var errorEnum = /*#__PURE__*/function (errorEnum) {
errorEnum["PARAMS"] = "PARAMS";
errorEnum["TIMEOUT"] = "TIMEOUT";
errorEnum["NETWORK"] = "NETWORK";
errorEnum["SYSTEM"] = "SYSTEM";
errorEnum["LOGIN"] = "LOGIN";
errorEnum["GATEWAY"] = "GATEWAY";
errorEnum["VALIDATION"] = "VALIDATION";
errorEnum["TAOBAOBINDALIPAY"] = "TAOBAOBINDALIPAY";
errorEnum["REGISTERWALLET"] = "REGISTERWALLET";
errorEnum["NOALIPAYID"] = "NOALIPAYID";
errorEnum["TRUSTLOGINERROR"] = "TRUSTLOGINERROR";
errorEnum["SIGNIN"] = "SIGNIN";
errorEnum["GETSIGNPARAMSERROR"] = "GETSIGNPARAMSERROR";
return errorEnum;
}({});
export var eventCodeEnum = /*#__PURE__*/function (eventCodeEnum) {
eventCodeEnum["SDK_START_OF_LOADING"] = "SDK_START_OF_LOADING";
eventCodeEnum["SDK_END_OF_LOADING"] = "SDK_END_OF_LOADING";
eventCodeEnum["SDK_INTERNAL_ERROR"] = "SDK_INTERNAL_ERROR";
eventCodeEnum["SDK_CREATEPAYMENT_PARAMETER_ERROR"] = "SDK_CREATEPAYMENT_PARAMETER_ERROR";
eventCodeEnum["SDK_INIT_PARAMETER_ERROR"] = "SDK_INIT_PARAMETER_ERROR";
eventCodeEnum["SDK_CREATECOMPONENT_ERROR"] = "SDK_CREATECOMPONENT_ERROR";
eventCodeEnum["SDK_CALL_URL_ERROR"] = "SDK_CALL_URL_ERROR";
eventCodeEnum["SDK_CALL_URL_SUCCESS"] = "SDK_CALL_URL_SUCCESS";
return eventCodeEnum;
export var Target = /*#__PURE__*/function (Target) {
Target["BLANK"] = "_blank";
Target["SELF"] = "_self";
return Target;
}({});

@@ -1,5 +0,5 @@

import { Iselector, renderDisplayTypeEnum } from '../types';
import { createPaymentParams, IcreateComponent } from '../types';
/**
* @description context中需要包含app节点,用于插入selector中
* @description context中需要包含app节点,用于插入params.selector中
*/
export declare const createIframeNode: (context: any, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
export declare const createIframeNode: (context: any, params: createPaymentParams | IcreateComponent) => Promise<void>;
import { getType } from '.';
import { ERRORMESSAGE, EVENT } from "../constant";
import { messageName, renderDisplayTypeEnum } from "../types";
import { messageName } from "../types";
/**
* @description context中需要包含app节点,用于插入selector中
* @description context中需要包含app节点,用于插入params.selector中
*/
export var createIframeNode = function createIframeNode(context, selector, renderDisplayType) {
export var createIframeNode = function createIframeNode(context, params) {
return new Promise(function (resolve, reject) {
var dorpinDom = null;
if (getType(selector) === 'string') {
dorpinDom = document.querySelector(selector);
if (getType(params.selector) === 'string') {
dorpinDom = document.querySelector(params.selector);
}
if (dorpinDom === null) {
var error = {
code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
message: "Failed to execute 'querySelector' on 'Document': ".concat(selector, " is not a valid selector")
errorCode: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.errorCode,
errorMessage: "Failed to execute 'querySelector' on 'Document': ".concat(params.selector, " is not a valid selector")
};

@@ -29,3 +29,3 @@ reject(error);

}
if (renderDisplayType === renderDisplayTypeEnum.popup) dorpinDom.innerHTML = '';
dorpinDom.innerHTML = '';
if (context.app) {

@@ -32,0 +32,0 @@ dorpinDom.appendChild(context.app);

@@ -1,2 +0,2 @@

import { errorEnum } from '../types';
import { ERROR } from '../types';
/**

@@ -34,3 +34,3 @@ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.

traceId: string;
errorCode: errorEnum;
errorCode: ERROR;
resultStatus: any;

@@ -42,3 +42,3 @@ errorMessage?: undefined;

traceId: string;
errorCode: errorEnum;
errorCode: ERROR;
errorMessage: string;

@@ -55,4 +55,2 @@ result: {

declare const getDesignFontSize: () => number;
declare const amsSetSize: (event?: any, dom?: any) => void;
declare const addSetFontSizeEvent: () => void;
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, };

@@ -8,3 +8,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
import { errorEnum } from "../types";
import { ERROR } from "../types";
import { get } from "./get";

@@ -178,3 +178,3 @@

traceId: traceId,
errorCode: errorEnum.LOGIN,
errorCode: ERROR.LOGIN,
resultStatus: resultStatus

@@ -188,3 +188,3 @@ };

traceId: traceId,
errorCode: errorEnum.TIMEOUT,
errorCode: ERROR.TIMEOUT,
resultStatus: resultStatus

@@ -199,3 +199,3 @@ };

traceId: traceId,
errorCode: errorEnum.GATEWAY,
errorCode: ERROR.GATEWAY,
errorMessage: decodeURIComponent(tips || ''),

@@ -241,19 +241,2 @@ result: {

};
var amsSetSize = function amsSetSize(event, dom) {
try {
var componentContainerId = 'ams-component-container';
var _dom = dom || document.getElementById(componentContainerId);
_dom.style.fontSize = "".concat(getDesignFontSize(), "px");
innerHeight = window.innerHeight;
// eslint-disable-next-line no-empty
} catch (error) {}
};
var addSetFontSizeEvent = function addSetFontSizeEvent() {
window.removeEventListener('resize', amsSetSize);
window.removeEventListener('pageShow', amsSetSize);
window.removeEventListener('DOMContentLoaded', amsSetSize);
window.addEventListener('resize', amsSetSize);
window.addEventListener('pageShow', amsSetSize);
window.addEventListener('DOMContentLoaded', amsSetSize);
};
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, amsSetSize, addSetFontSizeEvent };
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize };
export var isLocalMock = function isLocalMock() {
return window.location.href.indexOf('LOCAL_MOCK=1') > -1;
var _window, _window$process, _window$process$env;
return ((_window = window) === null || _window === void 0 ? void 0 : (_window$process = _window.process) === null || _window$process === void 0 ? void 0 : (_window$process$env = _window$process.env) === null || _window$process$env === void 0 ? void 0 : _window$process$env.NODE_ENV) === 'MOCK' && window.location.href.indexOf('LOCAL_MOCK=1') > -1;
};

@@ -1,1 +0,1 @@

{"name":"@alipay/ams-checkout","version":"0.0.1693189296-dev.0","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}
{"name":"@alipay/ams-checkout","version":"0.0.1693912790-dev.0","description":"","author":"","main":"esm/index.js","module":"esm/index.js","typings":"esm/index.d.ts","files":["dist","esm","LEGAL.md","LICENSE","README.md"],"scripts":{"build":"father build","ci":"npm run lint","cov":"jest --coverage","format":"prettier --write --no-error-on-unmatched-pattern \"**/*.{js,jsx,ts,tsx,md,json,css,less}\"","lint":"eslint ./src","test":"jest"},"dependencies":{"axios":"^1.3.4","uuid":"^9.0.0"},"devDependencies":{"@babel/core":"^7.20.7","@babel/preset-env":"^7.20.2","@testing-library/jest-dom":"^5.1.1","@testing-library/react":"^9.5.0","@types/jest":"^29.2.4","@types/uuid":"^9.0.0","@typescript-eslint/parser":"^5.60.0","babel-jest":"^29.3.1","babel-loader":"^9.1.0","babel-plugin-import":"^1.13.0","eslint":"^8.36.0","father":"^4.2.3","jest":"^29.5.0","jest-environment-jsdom":"^29.3.1","prettier":"^2.8.4","prettier-plugin-organize-imports":"^3.2.3","prettier-plugin-packagejson":"^2.4.5","ts-jest":"^29.0.3","ts-node":"^10.9.1","typescript":"^4.9.5"},"engines":{},"publishConfig":{"access":"public"}}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc