Socket
Socket
Sign inDemoInstall

@alipay/ams-checkout

Package Overview
Dependencies
Maintainers
2
Versions
359
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.1691379784-dev.6 to 0.0.1691743027-dev.0

esm/image/skeleton.svg

72

esm/constant/index.d.ts

@@ -9,68 +9,76 @@ /**

DOMAIN_NOT_IN_WHITE_LIST: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
NOT_JSON_FORMAT: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
SDK_COMPATIBILITY_ISSUES: {
errorCode: string;
code: string;
BROWSER_NOT_SUPPORT_POSTMESSAGE: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
FAILED_TO_CREATE_IFRAME: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
};
INIT_PARAMETER_ERROR: {
errorCode: string;
code: string;
UI_MODE_NOT_SUPPORTED: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
ENVIRONMENT_ERROR: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
MODE_ERROR: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
LOCALE_ERROR: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
NET_MODE_NOT_SUPPORT: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
EVENT_ERROR: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
};
CREATEPAYMENT_PARAMETER_ERROR: {
errorCode: string;
code: string;
};
CONFIRMPAYMENT_PARAMETER_ERROR: {
errorCode: string;
code: string;
};
CREATECOMPONENT_ERROR: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
SINGLETON_COMPONENT_ERROR: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
LOAD_APP_TIMEOUT: {
code: string;
message: string;
};
};
SDK_CALL_URL_ERROR: {
errorCode: string;
code: string;
REDIRECT_ERROR: {
errorCode: string;
errorMessage: string;
code: string;
message: string;
};
};
SDK_SUBMIT_ERROR: {
code: string;
message: string;
};
};

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

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

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

@@ -9,67 +9,75 @@ /**

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

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

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

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

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

*/
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>;
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;
}

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

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(); }

@@ -15,7 +29,8 @@ 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 } from "../../constant";
import { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
import ComponentApp from "../../plugin/component";
import { componentSignEnum, mode, networkMode, productSceneEnum } from "../../types";
import { componentSignEnum, modeEnum, networkModeEnum, productSceneEnum, renderDisplayTypeEnum } from "../../types";
import { isPC } from "../../util";
import { createIframeNode } from "../../util/createIframeNode";
import CoreInstance from "../instance/index";
var getComponentSign = function getComponentSign(params) {

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

};
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);
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("".concat(ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code, "\uFF1AAbnormal response data, interface failure, or unsupported payment method"));
}
_params.paymentSessionData = paymentSessionData;
_params.paymentSessionMetaData = parseData;
return Promise.resolve({
iframeNodesParams: _params,
componentSign: componentSign
});
};
/**
* @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);
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;
}
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"));
_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.CREATECOMPONENT_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);
}
_params.paymentSessionData = paymentSessionData;
_params.paymentSessionMetaData = parseData;
try {
var componentApp = _this._getPlugin(COMPONENTPLUGINID);
componentApp.appendIframeNodes(componentSign, _params).then(function () {
resolve();
}, {
key: "pluginAppendIframe",
value: function pluginAppendIframe(appendParams) {
try {
this.componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams).then(function () {
return Promise.resolve();
});
} 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, {
code: ERRORMESSAGE.CREATECOMPONENT_ERROR
});
return Promise.reject(error);
}).then(function (appendParams) {
return _this2.pluginAppendIframe(appendParams);
});
} 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, {
code: ERRORMESSAGE.CREATECOMPONENT_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, optionsParams } from '../../types';
import { createPaymentParams } from '../../types';
export declare const mixinDropInConstructor: (options: optionsParams, context: any) => void;

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

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

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

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

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

@@ -51,11 +51,2 @@ * @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 { environment, mode, networkMode, osType, terminalType } from "../../types/index";
import { environmentEnum, modeEnum, networkModeEnum, osTypeEnum, terminalTypeEnum } 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,6 +36,3 @@ _defineProperty(this, "_instanceId", void 0);

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

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

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

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

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

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

_moreEnv = _queryParse._moreEnv;
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);
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);
options.environment = 'prod';
}
this.options.env = {
terminalType: device.isMobile ? terminalType.WAP : terminalType.WEB,
terminalType: device.isMobile ? terminalTypeEnum.WAP : terminalTypeEnum.WEB,
environment: (options === null || options === void 0 ? void 0 : options.environment) || 'prod'
};
if (this.options.env.terminalType === terminalType.WAP) {
if (this.options.env.terminalType === terminalTypeEnum.WAP) {
// eslint-disable-next-line no-nested-ternary
this.options.env.osType = device.iOS ? osType.IOS : device.Android ? osType.ANDROID : osType.ELSE;
this.options.env.osType = device.iOS ? osTypeEnum.IOS : device.Android ? osTypeEnum.ANDROID : osTypeEnum.ELSE;
}

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

value: function _setMode(options) {
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.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.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;
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;
}

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

if (options !== null && options !== void 0 && options.onError) {
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.errorMessage);
if (getType(options.onError) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
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.errorMessage);
if (getType(options.onPaymentMethodSelected) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
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.errorMessage);
if (getType(options.onSizeChanged) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
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.errorMessage);
if (getType(options.onLog) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
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.errorMessage);
if (getType(options.onEventCallback) !== 'function') throw new Error(ERRORMESSAGE.INIT_PARAMETER_ERROR.EVENT_ERROR.message);
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.errorMessage);
this._overrideSubscription(EVENT.onClose.name, options.onClose, EVENT.onClose.uniqueKey);
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);
}

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

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

@@ -236,26 +235,5 @@ 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);
}
}]);

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

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

*/
import { IcreateComponentFunc } from './core/component/index';
import { IconfirmPaymentFunc, IcreatePaymentFunc } from './core/drop-in/index';
import AMSSDK from './core/instance';
import { optionsParams } from './types';
import { AMSComponent } from './core/component/index';
import { IoptionsParams } from './types';
export * from './types';
export declare class AMSCheckout extends AMSSDK {
createComponent: IcreateComponentFunc;
createPayment: IcreatePaymentFunc;
confirmPayment: IconfirmPaymentFunc;
constructor(options: optionsParams);
export declare class AMSCheckout extends AMSComponent {
}
export declare class AMSAutoDebit extends AMSCheckout {
constructor(options: optionsParams);
constructor(options: IoptionsParams);
}
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"); } }

@@ -12,5 +14,2 @@ 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); }
/**

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

*/
import { createComponent, mixinComponentConstructor } from "./core/component/index";
import { confirmPayment, createPayment, mixinDropInConstructor, _subscribeFromCheckoutPlugin } from "./core/drop-in/index";
import AMSSDK from "./core/instance";
import { AMSComponent } from "./core/component/index";
export * from "./types";
export var AMSCheckout = /*#__PURE__*/function (_AMSSDK) {
_inherits(AMSCheckout, _AMSSDK);
export var AMSCheckout = /*#__PURE__*/function (_AMSComponent) {
_inherits(AMSCheckout, _AMSComponent);
var _super = _createSuper(AMSCheckout);
function AMSCheckout(options) {
var _this;
function AMSCheckout() {
_classCallCheck(this, AMSCheckout);
_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 _super.apply(this, arguments);
}
return _createClass(AMSCheckout);
}(AMSSDK);
}(AMSComponent);
export var AMSAutoDebit = /*#__PURE__*/function (_AMSCheckout) {

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

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

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

@@ -88,21 +88,14 @@ 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,
shadow: environment === 'sandbox' || _sandbox === 'true' ? 'true' : 'false',
requestHost: requestHost,
groupId: groupId,
LOCAL_MOCK: LOCAL_MOCK
refUrl: window.location.href
});
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';
};

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

*/
export var createIframe = function createIframe(mode) {
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';
};
var iframe = document.createElement('iframe');
var iframeId = getIframeId(mode);
var iframeId = getIframeId();
var none = '0';

@@ -117,0 +117,0 @@ var width = '100%';

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

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

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

*/
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() {
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 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 style = document.createElement('style');

@@ -16,2 +26,21 @@ style.type = 'text/css';

document.head.appendChild(style);
}
};
var inlineComponentCss = "#ams-checkout-component-desktop{\n border-radius: 8px;\n}\n#".concat(loadingId, "{\n width: 100%;\n flex: 1;\n}\n.inline-loading{\n width: 100%;\n height: auto;\n object-fit: contain;\n box-sizing: border-box;\n}\n.inline-loading-mobile{\n padding: 0 0.16em;\n}\n.inline-loading-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;
var inlineClassName = 'inline-loading';
if (platform === platformEnum.desktop) loading.innerHTML = "<svg class=\"".concat(inlineClassName, " ").concat(inlineClassName, "-").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(inlineClassName, " ").concat(inlineClassName, "-").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 ");
var selectorDom = document.querySelector(_selector);
if (selectorDom) selectorDom.appendChild(loading);
var loadingDom = document.getElementById(loadingId);
amsSetSize(null, loadingDom);
};
import type AMSCheckout from '../../core/instance';
import type { IappendIframeNodesParams, IcreateComponent } from '../../types';
import { CashierSdkActionQueryResult, componentSignEnum } from '../../types';
import type { IappendIframeNodesParams, Iselector } from '../../types';
import { CashierSdkActionQueryResult, componentSignEnum, platformEnum, renderDisplayTypeEnum } from '../../types';
type IrenderFuncParams = (context: ComponentApp, selector: Iselector, renderDisplayType: renderDisplayTypeEnum) => Promise<void>;
export default class ComponentApp {

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

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

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

private _actionQueryPromise;
private _loadAppPromiseResolve;
private _renderParams;

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

private _clickEventName;
private _renderDisplayType;
constructor();

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

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

@@ -80,11 +85,11 @@ * @description Interface request

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

@@ -95,3 +100,3 @@ private closeBtnFunc;

*/
private createMountElement;
private createBaseElement;
private createCloseBtn;

@@ -109,1 +114,2 @@ private createRetentionPopup;

}
export {};

@@ -5,4 +5,2 @@ 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"); } }

@@ -23,28 +21,18 @@ 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, productSceneEnum, Target } from "../../types";
import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
import { componentSignEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
import { addSetFontSizeEvent, amsSetSize, getDesignFontSize, getType, isJsonString, isPC } from "../../util";
import { isLocalMock } from "../../util/mock";
import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
import { componentAddCSS } from "./component.style";
import { componentAddCSS, inlineComponentAddCss, showInlineLoading } from "./component.style";
var _window = window,
innerHeight = _window.innerHeight;
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 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 loadTimeLimit = 15000;
var ComponentApp = /*#__PURE__*/function () {

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

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

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

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

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

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

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

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

@@ -122,8 +110,12 @@

value: function appendIframeNodes(componentSign, renderParams) {
var _renderParams$appeara,
_this = this;
if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
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);
}
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;
this._performanceData.push({

@@ -133,20 +125,54 @@ key: 'sdk_create_component',

});
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.inline) {
var inlineBaseStyle = document.getElementById(inlineBaseStyleId);
if (!inlineBaseStyle) inlineComponentAddCss();
}
this.showCashier();
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
this.createBaseElement();
this.setContainerClass();
this.createRetentionPopup();
this.createMockup();
}
this.renderLoading(renderParams);
this.createApp(renderParams);
this.createActionQueryPromise();
return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
selector: this._selector
})), this._actionQueryPromise]).catch(function () {
return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, this._selector, this._renderDisplayType), this.createLoadAppPromise()]).catch(function (error) {
_this._isInitComponent = false;
_this.cleanContainer();
return Promise.reject(error);
});
}
}, {
key: "renderLoading",
value: function renderLoading(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.inline) {
return showInlineLoading(this._selector, this.platform);
}
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);
});
}
/**

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

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

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

this._actionQueryPromise = new Promise(function (resolve, reject) {
var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
var params = {
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
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
};

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

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

@@ -181,4 +207,4 @@ }

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

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

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

@@ -207,5 +233,5 @@ _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$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) || {};
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) || {};
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;

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

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

@@ -245,9 +271,11 @@ 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;
}

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

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

@@ -295,3 +325,3 @@

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

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

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

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

value: function _handleAppMessage(data) {
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];
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];
if (data.context.event === EVENT.dismissLoading.name) {

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

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

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

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

@@ -437,3 +468,4 @@ }

var _data$context$data2;
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) > 1) {
if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
var _document$getElementB;

@@ -447,11 +479,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');
var cashier = document.getElementById(componentContainerId);
cashier.style.height = "".concat(data.context.data.height, "px");
if (this.platform === 'desktop') {
cashier.classList.add('ams-component-container-desktop-animation');
cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
}
if (this.platform === 'mobile') {
cashier.classList.add('ams-component-container-mobile-animation');
var animationStyleId = 'ams-component-container-mobile-animation-style';
cashier.classList.add("".concat(componentContainerId, "-").concat(this.platform, "-animation"));
var animationStyleId = "".concat(componentContainerId, "-").concat(this.platform, "-animation-style");
var animationStyle = document.getElementById(animationStyleId);

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

// 弹出和弹入动画
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 }");
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 }");
// 创建style标签

@@ -478,7 +510,11 @@ 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.width = '100%';
this.app.style.border = '0';
this.app.style.overflow = 'hidden';
}

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

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

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

var successCallback = function successCallback(type, url) {
_this3.dispatchToSDK(EVENT.eventCallback.name, {
_this4.dispatchToSDK(EVENT.eventCallback.name, {
code: 'SDK_CALL_URL_SUCCESS',

@@ -507,3 +542,3 @@ message: "Successfully opened the app,".concat(type, ": ").concat(url)

var failCallback = function failCallback() {
_this3.dispatchToSDK(EVENT.eventCallback.name, {
_this4.dispatchToSDK(EVENT.eventCallback.name, {
code: 'SDK_CALL_URL_ERROR',

@@ -515,3 +550,3 @@ 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)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -649,3 +686,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));
}

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

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

@@ -690,2 +727,4 @@ 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: {

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

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

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

}, {
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));
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));
}

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

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

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

value: function hideComponentAndCleanDom() {
var _this4 = this;
var _this5 = this;
var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
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 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 removeMockupAndApp = function removeMockupAndApp() {
var _document$getElementB3;
var _document$getElementB4;
var body = document.getElementsByTagName('body')[0];

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

if (container) container.style.height = '';
(_document$getElementB3 = document.getElementById('ams-component-container-mobile-animation-style')) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
_this4.removeRetentionPopup();
_this4.cleanApp();
(_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();
};

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

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

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

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

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

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

@@ -826,12 +870,12 @@ this.createCloseBtn();

value: function createCloseBtn() {
var _this5 = this;
var container = document.getElementById('ams-component-container');
var _this6 = this;
var container = document.getElementById(componentContainerId);
// close btn
var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
var closeBtnHTML = "<img class='".concat(componentCloseBlockId, "-btn-").concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
var closeBlock = document.createElement('div');
closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
closeBlock.id = 'asm-component-section-close-block';
closeBlock.classList.add("".concat(componentCloseBlockId, "-").concat(this.platform), "".concat(componentCloseBlockId, "-hidden"));
closeBlock.id = componentCloseBlockId;
closeBlock.innerHTML = closeBtnHTML;
closeBlock.addEventListener(this._clickEventName, function () {
_this5.closeBtnFunc();
_this6.closeBtnFunc();
});

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

var retentionPopup = document.createElement('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>");
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>");
document.body.appendChild(retentionPopup);
var remainBtn = document.getElementById('ams-component-retention-remain');
var remainBtn = document.getElementById("".concat(componentRetentionId, "-remain"));
if (remainBtn) {
remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
}
var leaveBtn = document.getElementById('ams-component-retention-leave');
var leaveBtn = document.getElementById("".concat(componentRetentionId, "-leave"));
if (leaveBtn) {

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

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

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

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

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

value: function showRetentionPopup() {
var retentionPopup = document.getElementById('ams-component-retention');
var container = document.getElementById('ams-component-container');
var retentionPopup = document.getElementById(componentRetentionId);
var container = document.getElementById(componentContainerId);
if (retentionPopup) {
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');
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"));
}

@@ -897,11 +941,11 @@ }

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

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

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

@@ -952,0 +995,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 = 'checkout-component';
id = 'ams-checkout-component';
break;

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

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

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

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

*/
export declare function request<T>(requestData: Record<string, any> | undefined, options: RequestConfig): Promise<T>;
export declare function request<T>(requestData: Record<string, any> | undefined, options: IrequestConfig): 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 { ERROR } from "../types";
import { errorEnum } from "../types";
import { get } from "../util/get";

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

success: false,
errorCode: ERROR.SYSTEM,
errorCode: errorEnum.SYSTEM,
errorMessage: ''
});
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? ERROR.TIMEOUT : '';
timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.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 { ERROR } from '../types';
import { errorEnum } 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: ERROR;
errorCode: errorEnum;
resultStatus: any;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}
export interface env {
osType?: osType;
terminalType: terminalType;
export interface Ienv {
osType?: osTypeEnum;
terminalType: terminalTypeEnum;
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: {
errorMessage: string;
errorCode: string;
code: string;
message: 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: {

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

export type callOnSizeChanged = (state: {
width: string;
height: string;
width: number;
height: number;
}) => void;
export type callOnLog = (state: {
code: string;
message: 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 declare enum messageName {

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

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

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

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

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

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

@@ -224,6 +255,2 @@ baseURL?: string;

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

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

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

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

}({});
export var checkoutDisplay = /*#__PURE__*/function (checkoutDisplay) {
checkoutDisplay["horizon"] = "horizon";
checkoutDisplay["vertical"] = "vertical";
return checkoutDisplay;
export var checkoutDisplayEnum = /*#__PURE__*/function (checkoutDisplayEnum) {
checkoutDisplayEnum["horizon"] = "horizon";
checkoutDisplayEnum["vertical"] = "vertical";
return checkoutDisplayEnum;
}({});
export var mode = /*#__PURE__*/function (mode) {
mode["dropin"] = "dropin";
mode["component"] = "component";
return mode;
export var modeEnum = /*#__PURE__*/function (modeEnum) {
modeEnum["dropin"] = "dropin";
modeEnum["component"] = "component";
return modeEnum;
}({});
export var networkMode = /*#__PURE__*/function (networkMode) {
networkMode["proxy"] = "proxy";
networkMode["session"] = "session";
return networkMode;
export var networkModeEnum = /*#__PURE__*/function (networkModeEnum) {
networkModeEnum["proxy"] = "proxy";
networkModeEnum["session"] = "session";
return networkModeEnum;
}({});
export var environment = /*#__PURE__*/function (environment) {
environment["sandbox"] = "sandbox";
environment["prod"] = "prod";
environment["light_sandbox"] = "light_sandbox";
return environment;
export var environmentEnum = /*#__PURE__*/function (environmentEnum) {
environmentEnum["sandbox"] = "sandbox";
environmentEnum["prod"] = "prod";
environmentEnum["light_sandbox"] = "light_sandbox";
return environmentEnum;
}({});
export var osType = /*#__PURE__*/function (osType) {
osType["IOS"] = "IOS";
osType["ANDROID"] = "ANDROID";
osType["ELSE"] = "ELSE";
return osType;
export var osTypeEnum = /*#__PURE__*/function (osTypeEnum) {
osTypeEnum["IOS"] = "IOS";
osTypeEnum["ANDROID"] = "ANDROID";
osTypeEnum["ELSE"] = "ELSE";
return osTypeEnum;
}({});
export var terminalType = /*#__PURE__*/function (terminalType) {
terminalType["WEB"] = "WEB";
terminalType["WAP"] = "WAP";
terminalType["APP"] = "APP";
terminalType["MINI_APP"] = "MINI_APP";
return terminalType;
export var terminalTypeEnum = /*#__PURE__*/function (terminalTypeEnum) {
terminalTypeEnum["WEB"] = "WEB";
terminalTypeEnum["WAP"] = "WAP";
terminalTypeEnum["APP"] = "APP";
terminalTypeEnum["MINI_APP"] = "MINI_APP";
return terminalTypeEnum;
}({});
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) {

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

}({});
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 targetEnum = /*#__PURE__*/function (targetEnum) {
targetEnum["BLANK"] = "_blank";
targetEnum["SELF"] = "_self";
return targetEnum;
}({});
export var Target = /*#__PURE__*/function (Target) {
Target["BLANK"] = "_blank";
Target["SELF"] = "_self";
return Target;
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;
}({});

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

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

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

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

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

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

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

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

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

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

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

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

declare const getDesignFontSize: () => number;
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize, };
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 };

@@ -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 { ERROR } from "../types";
import { errorEnum } from "../types";
import { get } from "./get";

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

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

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

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

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

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

@@ -234,9 +234,24 @@ result: {

};
var designSize = 390;
var maxFontSize = 130;
var getDesignFontSize = function getDesignFontSize() {
var screenWidth = document.documentElement.clientWidth;
var currentFontSize = isPC() ? maxFontSize : screenWidth * 100 / designSize;
return Math.min(currentFontSize, maxFontSize);
var currentFontSize = isPC() ? 100 : screenWidth * 100 / 390;
return Math.min(currentFontSize, 100);
};
export { getType, EventCenter, getViewPort, getOrigin, serialize, isJsonString, isDom, device, fomatGetwayError, safeJson, isPC, queryParse, getDesignFontSize };
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 var isLocalMock = function isLocalMock() {
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;
return window.location.href.indexOf('LOCAL_MOCK=1') > -1;
};

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

{"name":"@alipay/ams-checkout","version":"0.0.1691379784-dev.6","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.1691743027-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