@alipay/ams-checkout 0.0.1693912790-dev.3 → 0.0.1694400497-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/constant/index.d.ts +53 -32
  3. package/esm/constant/index.js +53 -32
  4. package/esm/core/component/index.d.ts +23 -16
  5. package/esm/core/component/index.js +155 -44
  6. package/esm/core/drop-in/index.d.ts +4 -11
  7. package/esm/core/drop-in/index.js +19 -19
  8. package/esm/core/instance/index.d.ts +6 -15
  9. package/esm/core/instance/index.js +32 -53
  10. package/esm/image/skeleton.svg +18 -0
  11. package/esm/index.d.ts +4 -10
  12. package/esm/index.js +8 -30
  13. package/esm/plugin/component/cashierApp.d.ts +2 -2
  14. package/esm/plugin/component/cashierApp.js +16 -15
  15. package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +4 -1
  16. package/esm/plugin/component/component.inline.style.js +38 -0
  17. package/esm/plugin/component/component.popup.style.d.ts +12 -0
  18. package/esm/plugin/component/component.popup.style.js +165 -0
  19. package/esm/plugin/component/index.d.ts +26 -33
  20. package/esm/plugin/component/index.js +243 -396
  21. package/esm/plugin/drop-in/index.d.ts +7 -9
  22. package/esm/plugin/drop-in/index.js +4 -3
  23. package/esm/request/index.d.ts +2 -9
  24. package/esm/request/index.js +15 -28
  25. package/esm/request/utils.d.ts +4 -4
  26. package/esm/request/utils.js +6 -4
  27. package/esm/service/index.d.ts +2 -2
  28. package/esm/types/index.d.ts +78 -51
  29. package/esm/types/index.js +85 -48
  30. package/esm/util/createIframeNode.d.ts +3 -3
  31. package/esm/util/createIframeNode.js +15 -8
  32. package/esm/util/get.js +7 -0
  33. package/esm/util/index.d.ts +8 -6
  34. package/esm/util/index.js +25 -11
  35. package/esm/util/mock.js +1 -2
  36. package/package.json +1 -1
  37. package/esm/plugin/component/component.style.js +0 -15
  38. package/esm/util/security.d.ts +0 -12
  39. package/esm/util/security.js +0 -107
@@ -2,8 +2,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2
2
  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; }
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
4
  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); }); }; }
5
- 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; }
6
- 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; }
7
5
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
6
  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); } }
9
7
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -17,48 +15,27 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
17
15
  * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
18
16
  */
19
17
  /* eslint-disable no-console */
20
- import { closeImg, COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
18
+ /* eslint-disable @typescript-eslint/no-explicit-any */
19
+ import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID } from "../../constant";
21
20
  import { queryPaymentInfo } from "../../service";
22
- import { componentSignEnum, messageName, productSceneEnum, Target } from "../../types";
23
- import { getDesignFontSize, getType, isJsonString, isPC, queryParse } from "../../util";
21
+ import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
22
+ import { getType, isJsonString, isPC } from "../../util";
24
23
  import { isLocalMock } from "../../util/mock";
25
24
  import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
- import { componentAddCSS } from "./component.style";
27
- import APDID from '@alipay/jshield-apdid';
28
- import { getSecurityHost, getAppname } from "../../util/security";
29
- var _ref = queryParse() || {},
30
- preinit = _ref.preinit,
31
- rebuild = _ref.rebuild,
32
- scene = _ref.scene,
33
- region = _ref.region;
25
+ import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
26
+ import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
34
27
  var _window = window,
35
28
  innerHeight = _window.innerHeight;
36
- var amsSetSize = function amsSetSize(event, dom) {
37
- try {
38
- var _dom = dom || document.getElementById('ams-component-container');
39
- _dom.style.fontSize = "".concat(getDesignFontSize(), "px");
40
- innerHeight = window.innerHeight;
41
- // eslint-disable-next-line no-empty
42
- } catch (error) {}
43
- };
44
- var addEvent = function addEvent() {
45
- window.removeEventListener('resize', amsSetSize);
46
- window.removeEventListener('pageShow', amsSetSize);
47
- window.removeEventListener('DOMContentLoaded', amsSetSize);
48
- window.addEventListener('resize', amsSetSize);
49
- window.addEventListener('pageShow', amsSetSize);
50
- window.addEventListener('DOMContentLoaded', amsSetSize);
51
- };
52
- var mockupId = 'ams-component-mockup';
53
- var loadingId = 'ams-component-loading';
54
- var listenerPrefix = '_ams_sdk_component_listener';
55
29
  var ComponentApp = /*#__PURE__*/function () {
56
30
  function ComponentApp() {
57
31
  _classCallCheck(this, ComponentApp);
58
32
  _defineProperty(this, "app", void 0);
59
- _defineProperty(this, "appDomain", void 0);
60
33
  _defineProperty(this, "AMSSDK", void 0);
61
34
  _defineProperty(this, "platform", void 0);
35
+ _defineProperty(this, "_performanceData", []);
36
+ _defineProperty(this, "_loadAppPromiseResolve", null);
37
+ _defineProperty(this, "_isInitComponent", void 0);
38
+ _defineProperty(this, "appDomain", void 0);
62
39
  _defineProperty(this, "createIframeNode", void 0);
63
40
  _defineProperty(this, "_selector", void 0);
64
41
  _defineProperty(this, "_appVersion", void 0);
@@ -66,20 +43,17 @@ var ComponentApp = /*#__PURE__*/function () {
66
43
  _defineProperty(this, "_actionQueryPromise", null);
67
44
  _defineProperty(this, "_renderParams", null);
68
45
  _defineProperty(this, "_componentSign", componentSignEnum.NONE);
69
- _defineProperty(this, "_performanceData", []);
70
- _defineProperty(this, "_isInitComponent", void 0);
71
46
  _defineProperty(this, "_clickEventName", void 0);
72
- this._appVersion = '1.5.3';
47
+ _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
48
+ this._appVersion = '1.5.4';
73
49
  this._isInitComponent = false;
74
- this._selector = '#ams-component-section';
50
+ this._selector = "#".concat(COMPONENT_SECTION_ID);
75
51
  this.createIframeNode = function () {
76
52
  return Promise.resolve();
77
53
  };
78
- this.platform = isPC() ? 'desktop' : 'mobile';
79
- this._clickEventName = this.platform === 'mobile' ? 'touchend' : 'click';
54
+ this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
55
+ this._clickEventName = this.platform === platformEnum.mobile ? 'touchend' : 'click';
80
56
  this._isRetention = true;
81
- addEvent();
82
- this.createMountElement();
83
57
  this._performanceData.push({
84
58
  key: 'sdk_init',
85
59
  value: Date.now()
@@ -92,7 +66,7 @@ var ComponentApp = /*#__PURE__*/function () {
92
66
  _createClass(ComponentApp, [{
93
67
  key: "logoutPlugin",
94
68
  value: function logoutPlugin() {
95
- this.closeCashier();
69
+ this.cleanContainer(true);
96
70
  }
97
71
 
98
72
  /**
@@ -110,31 +84,8 @@ var ComponentApp = /*#__PURE__*/function () {
110
84
  */
111
85
  }, {
112
86
  key: "setRender",
113
- value: function setRender(createIframeNode) {
114
- this.createIframeNode = createIframeNode;
115
- }
116
- }, {
117
- key: "initAPSecurity",
118
- value: function initAPSecurity() {
119
- var _this$_renderParams, _this$_renderParams$p;
120
- if (componentSignEnum.CASHIER_PAYMENT_CARD !== this._componentSign) {
121
- return;
122
- }
123
- var securityConfig = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : (_this$_renderParams$p = _this$_renderParams.paymentSessionMetaData) === null || _this$_renderParams$p === void 0 ? void 0 : _this$_renderParams$p.securityConfig;
124
- if (!securityConfig) {
125
- return;
126
- }
127
- var appName = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.appName;
128
- var h5gateway = securityConfig === null || securityConfig === void 0 ? void 0 : securityConfig.h5gateway;
129
- if (preinit === 'true' || rebuild === 'true') {
130
- appName = getAppname(scene);
131
- h5gateway = getSecurityHost(region);
132
- }
133
- APDID.initToken(appName, {
134
- host: h5gateway
135
- }, function (success, tokenResult, msg) {
136
- console.log("initToken result tokenResult", JSON.stringify(tokenResult));
137
- });
87
+ value: function setRender(renderFunc) {
88
+ this.createIframeNode = renderFunc;
138
89
  }
139
90
 
140
91
  /**
@@ -143,87 +94,118 @@ var ComponentApp = /*#__PURE__*/function () {
143
94
  }, {
144
95
  key: "appendIframeNodes",
145
96
  value: function appendIframeNodes(componentSign, renderParams) {
146
- var _renderParams$appeara,
147
- _this = this;
148
- if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
97
+ var _this = this;
98
+ if (this._isInitComponent) {
99
+ this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
100
+ return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
101
+ }
149
102
  this._isInitComponent = true;
150
103
  this._renderParams = renderParams;
151
104
  this._componentSign = componentSign;
105
+ if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
106
+ this._renderDisplayType = renderParams.renderDisplayType;
107
+ var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
152
108
  this._performanceData.push({
153
109
  key: 'sdk_create_component',
154
110
  value: Date.now()
155
111
  });
156
- this.initAPSecurity();
157
- this.createRetentionPopup();
158
- this.createMockup();
159
- if ((renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading) !== false) {
160
- var mockup = document.getElementById(mockupId);
161
- if (mockup) {
162
- mockup.style.display = 'block';
163
- }
164
- this.showLoading();
112
+ this.dispatchToSDK(EVENT.eventCallback.name, {
113
+ code: eventCodeEnum.SDK_START_OF_LOADING
114
+ });
115
+ if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
116
+ var container = createInlineBaseElement(this._selector);
117
+ if (container) this.renderInlineLoading(renderParams, container);
118
+ }
119
+ if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
120
+ createBaseElement(this.platform, this.closeBtnFunc.bind(this));
121
+ createRetentionPopup(this.platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
122
+ createMockup();
123
+ this.renderPopupLoading(renderParams);
165
124
  }
166
- this.showCashier();
167
125
  this.createApp(renderParams);
168
- this.createActionQueryPromise();
169
- return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
170
- selector: this._selector
171
- })), this._actionQueryPromise]).catch(function () {
126
+ return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
127
+ return Promise.resolve();
128
+ }).catch(function (error) {
172
129
  _this._isInitComponent = false;
130
+ _this.cleanContainer();
131
+ return Promise.reject(error);
173
132
  });
174
133
  }
134
+ }, {
135
+ key: "renderInlineLoading",
136
+ value: function renderInlineLoading(renderParams, selector) {
137
+ var _renderParams$appeara;
138
+ var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
139
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
140
+ if (showLoading) addInlineLoading(selector, this.platform);
141
+ }
142
+ }, {
143
+ key: "renderPopupLoading",
144
+ value: function renderPopupLoading(renderParams) {
145
+ var _renderParams$appeara2;
146
+ var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
147
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
148
+ if (!showLoading) return;
149
+ var mockup = document.getElementById(MOCKUP_ID);
150
+ if (mockup) mockup.style.display = 'block';
151
+ addPopupLoading();
152
+ }
153
+ }, {
154
+ key: "_createLoadAppPromise",
155
+ value: function _createLoadAppPromise() {
156
+ var _this2 = this;
157
+ return new Promise(function (resolve, reject) {
158
+ _this2._loadAppPromiseResolve = resolve;
159
+ setTimeout(function () {
160
+ reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
161
+ }, LOADTIME_LIMIT);
162
+ }).catch(function (error) {
163
+ _this2.dispatchToSDK(EVENT.error.name, {
164
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
165
+ message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
166
+ });
167
+ return Promise.reject(error);
168
+ });
169
+ }
170
+
175
171
  /**
176
172
  * @description Interface request
177
173
  */
178
174
  }, {
179
175
  key: "createActionQueryPromise",
180
176
  value: function createActionQueryPromise() {
181
- var _this2 = this;
177
+ var _this3 = this;
182
178
  this._performanceData.push({
183
179
  key: 'sdk_action_query_start',
184
180
  value: Date.now()
185
181
  });
186
182
  this._actionQueryPromise = new Promise(function (resolve, reject) {
187
- var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3, _this2$_renderParams4, _this2$_renderParams5;
183
+ var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
188
184
  var params = {
189
- paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
190
- 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
185
+ paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
186
+ 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
191
187
  };
192
188
  /**
193
189
  * @description card
194
190
  */
195
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign) {
191
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
196
192
  params.paymentMethodType = 'CARD';
197
193
  }
198
- var needDeviceId = false;
199
- var waitTime = '3000';
200
- var securityConfig = (_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : (_this2$_renderParams5 = _this2$_renderParams4.paymentSessionMetaData) === null || _this2$_renderParams5 === void 0 ? void 0 : _this2$_renderParams5.securityConfig;
201
- if (componentSignEnum.CASHIER_PAYMENT_CARD === _this2._componentSign && securityConfig) {
202
- var _this2$_renderParams6, _this2$_renderParams7;
203
- var extendInfo = ((_this2$_renderParams6 = _this2._renderParams) === null || _this2$_renderParams6 === void 0 ? void 0 : (_this2$_renderParams7 = _this2$_renderParams6.paymentSessionMetaData) === null || _this2$_renderParams7 === void 0 ? void 0 : _this2$_renderParams7.extendInfo) || '';
204
- var info = JSON.parse(extendInfo);
205
- if ((info === null || info === void 0 ? void 0 : info.cardTokenPay) !== 'false') {
206
- var _this2$_renderParams8, _this2$_renderParams9, _this2$_renderParams10;
207
- needDeviceId = true;
208
- waitTime = (_this2$_renderParams8 = _this2._renderParams) === null || _this2$_renderParams8 === void 0 ? void 0 : (_this2$_renderParams9 = _this2$_renderParams8.paymentSessionMetaData) === null || _this2$_renderParams9 === void 0 ? void 0 : (_this2$_renderParams10 = _this2$_renderParams9.securityConfig) === null || _this2$_renderParams10 === void 0 ? void 0 : _this2$_renderParams10.tokenCollectTime;
209
- }
210
- }
211
-
212
194
  /**
213
195
  * @description easyPay
214
196
  */
215
- if (componentSignEnum.EASY_PAY_WALLET === _this2._componentSign) {
216
- var _this2$_renderParams11;
217
- var _ref2 = params.paymentSessionConfig || {},
218
- _ref2$productSceneVer = _ref2.productSceneVersion,
219
- productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
220
- _ref2$productScene = _ref2.productScene,
221
- productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
222
- var _ref3 = ((_this2$_renderParams11 = _this2._renderParams) === null || _this2$_renderParams11 === void 0 ? void 0 : _this2$_renderParams11.paymentSessionMetaData) || {},
223
- _ref3$action = _ref3.action,
224
- _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
225
- _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
226
- autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb;
197
+ if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
198
+ var _this3$_renderParams4;
199
+ var _ref = params.paymentSessionConfig || {},
200
+ _ref$productSceneVers = _ref.productSceneVersion,
201
+ productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
202
+ _ref$productScene = _ref.productScene,
203
+ productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
204
+ var _ref2 = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.paymentSessionMetaData) || {},
205
+ _ref2$action = _ref2.action,
206
+ _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
207
+ _ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
208
+ autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
227
209
  if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
228
210
  // if EASY_PAY 2.0 , no need to query payment request
229
211
  return resolve({
@@ -236,9 +218,9 @@ var ComponentApp = /*#__PURE__*/function () {
236
218
  * @author tianqiang
237
219
  * @description autoDebit
238
220
  */
239
- if (componentSignEnum.AUTO_DEBIT_WALLET === _this2._componentSign) {
240
- var _this2$_renderParams12, _this2$_renderParams13, _action$web, _action$wap;
241
- var action = ((_this2$_renderParams12 = _this2._renderParams) === null || _this2$_renderParams12 === void 0 ? void 0 : (_this2$_renderParams13 = _this2$_renderParams12.paymentSessionMetaData) === null || _this2$_renderParams13 === void 0 ? void 0 : _this2$_renderParams13.action) || {};
221
+ if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
222
+ var _this3$_renderParams5, _this3$_renderParams6, _action$web, _action$wap;
223
+ 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) || {};
242
224
  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;
243
225
  if (signType === 'SMS') {
244
226
  return resolve({
@@ -261,12 +243,10 @@ var ComponentApp = /*#__PURE__*/function () {
261
243
  });
262
244
  }
263
245
  queryPaymentInfo(params, {
264
- env: _this2.AMSSDK.options.env.environment,
265
- locale: _this2.AMSSDK.options.locale,
266
- needDeviceId: needDeviceId,
267
- waitTime: waitTime
246
+ env: _this3.AMSSDK.options.env.environment,
247
+ locale: _this3.AMSSDK.options.locale
268
248
  }).then(function (res) {
269
- _this2._performanceData.push({
249
+ _this3._performanceData.push({
270
250
  key: 'sdk_action_query_end',
271
251
  value: Date.now()
272
252
  });
@@ -274,26 +254,46 @@ var ComponentApp = /*#__PURE__*/function () {
274
254
  resolve(res);
275
255
  } else {
276
256
  resolve(res);
277
- _this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
278
257
  }
279
258
  }).catch(function (err) {
259
+ _this3.dispatchToSDK(EVENT.error.name, {
260
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
261
+ });
280
262
  reject(err);
281
- _this2.closeCashier();
282
263
  });
283
264
  });
265
+ return this._actionQueryPromise;
284
266
  }
285
267
  }, {
286
- key: "cleanApp",
287
- value: function cleanApp() {
268
+ key: "cleanElement",
269
+ value: function cleanElement() {
288
270
  try {
289
- this.app = null;
290
- this._removeEventListener();
271
+ var _document$getElementB;
272
+ // selector and container
291
273
  if (getType(this._selector) === 'string') {
292
- var dorpinDom = document.querySelector(this._selector);
293
- if (dorpinDom) dorpinDom.innerHTML = '';
274
+ var selectorDom = document.querySelector(this._selector);
275
+ if (selectorDom) selectorDom.innerHTML = '';
294
276
  }
295
- // eslint-disable-next-line no-empty
296
- } catch (error) {}
277
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
278
+ if (container) container === null || container === void 0 ? void 0 : container.remove();
279
+
280
+ // animation
281
+ (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style"))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
282
+
283
+ // mockup
284
+ var body = document.getElementsByTagName('body')[0];
285
+ body.style.overflow = 'auto';
286
+ var mockup = document.getElementById(MOCKUP_ID);
287
+ mockup === null || mockup === void 0 ? void 0 : mockup.remove();
288
+
289
+ // retentionPopup
290
+ this.removeRetentionPopup(this.platform);
291
+
292
+ // listener
293
+ this.removeEventListener();
294
+ } catch (error) {
295
+ console.error(error);
296
+ }
297
297
  }
298
298
 
299
299
  /**
@@ -322,7 +322,7 @@ var ComponentApp = /*#__PURE__*/function () {
322
322
  productSceneVersion: productSceneVersion,
323
323
  extendInfo: extendInfo
324
324
  });
325
- this.app = createIframe(this.AMSSDK.options.mode);
325
+ this.app = createIframe(this.AMSSDK.options.mode, this.platform);
326
326
  this.app.src = getIframeUrl({
327
327
  componentSign: this._componentSign,
328
328
  analytics: this.AMSSDK.options.analytics,
@@ -335,7 +335,7 @@ var ComponentApp = /*#__PURE__*/function () {
335
335
  });
336
336
 
337
337
  // Subscribe to messages from iframe
338
- this._addEventListener();
338
+ this.addEventListener();
339
339
  } catch (error) {
340
340
  this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
341
341
  stack: error
@@ -354,6 +354,8 @@ var ComponentApp = /*#__PURE__*/function () {
354
354
  if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
355
355
  return;
356
356
  }
357
+ // TODO
358
+ // 如果带有callback标识,则从map结构中取出callbackfunc,执行,执行后在map结构中删除
357
359
  this._handleAppMessage(data);
358
360
  } else {
359
361
  console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
@@ -363,7 +365,7 @@ var ComponentApp = /*#__PURE__*/function () {
363
365
  }, {
364
366
  key: "resizeListener",
365
367
  value: function resizeListener() {
366
- var cashier = document.getElementById('ams-component-container');
368
+ var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
367
369
  cashier.style.transition = 'none';
368
370
  this.dispatchToApp({
369
371
  context: {
@@ -380,19 +382,19 @@ var ComponentApp = /*#__PURE__*/function () {
380
382
  * @description Initialize subscription iframe message
381
383
  */
382
384
  }, {
383
- key: "_addEventListener",
384
- value: function _addEventListener() {
385
- this._removeEventListener();
386
- window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
387
- window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
388
- window.addEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
389
- window.addEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
385
+ key: "addEventListener",
386
+ value: function addEventListener() {
387
+ this.removeEventListener();
388
+ window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
389
+ window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
390
+ window.addEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
391
+ window.addEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
390
392
  }
391
393
  }, {
392
- key: "_removeEventListener",
393
- value: function _removeEventListener() {
394
- window.removeEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
395
- window.removeEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
394
+ key: "removeEventListener",
395
+ value: function removeEventListener() {
396
+ window.removeEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
397
+ window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
396
398
  }
397
399
 
398
400
  /**
@@ -401,7 +403,10 @@ var ComponentApp = /*#__PURE__*/function () {
401
403
  }, {
402
404
  key: "_handleAppMessage",
403
405
  value: function _handleAppMessage(data) {
404
- 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];
406
+ 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];
407
+ if (!eventKeyMap.includes(data.context.event)) {
408
+ return;
409
+ }
405
410
  if (data.context.event === EVENT.dismissLoading.name) {
406
411
  var _data$context$data;
407
412
  this.dispatchToSDK(EVENT.eventCallback.name, {
@@ -410,21 +415,19 @@ var ComponentApp = /*#__PURE__*/function () {
410
415
  });
411
416
  return;
412
417
  }
413
- if (!eventKeyMap.includes(data.context.event)) {
414
- return;
415
- }
416
418
  if (data.context.event === EVENT.launch.name) {
417
419
  this._performanceData.push({
418
420
  key: 'sdk_onLaunch',
419
421
  value: Date.now()
420
422
  });
423
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
421
424
  this.sendRenderEvent();
422
425
  return;
423
426
  }
424
427
  if (data.context.event === EVENT.sizeChanged.name) {
425
428
  this.handleSizeChanged(data);
426
429
  }
427
- if (data.context.event === EVENT.onClose.name) {
430
+ if (data.context.event === EVENT.close.name) {
428
431
  return this.closeBtnFunc();
429
432
  }
430
433
  if (data.context.event === EVENT.redirect.name) {
@@ -453,35 +456,35 @@ var ComponentApp = /*#__PURE__*/function () {
453
456
  }
454
457
 
455
458
  // The plug-in communicates with the sdk after processing
456
- this.dispatchToSDK(data.context.event, data.context.data);
459
+ this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
457
460
  }
458
461
  }, {
459
462
  key: "handleSizeChanged",
460
463
  value: function handleSizeChanged(data) {
461
464
  var _data$context$data2;
462
- if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) > 1) {
463
- var _document$getElementB;
464
- var mockup = document.getElementById(mockupId);
465
+ if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
466
+ var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
467
+ cashier.style.height = "".concat(data.context.data.height, "px");
468
+ if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
469
+ var _document$getElementB2;
470
+ var mockup = document.getElementById(MOCKUP_ID);
465
471
  if (mockup) {
466
- mockup.style.background = '#000000';
467
- mockup.style.opacity = '0.6';
472
+ mockup.style.background = 'rgb(0, 0, 0, 0.6)';
468
473
  mockup.style.display = 'block';
469
474
  }
470
- (_document$getElementB = document.getElementById(loadingId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
471
- var cashier = document.getElementById('ams-component-container');
472
- cashier.style.height = "".concat(data.context.data.height, "px");
475
+ (_document$getElementB2 = document.getElementById(LOADING_ID)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
473
476
  if (this.platform === 'desktop') {
474
- cashier.classList.add('ams-component-container-desktop-animation');
477
+ cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
475
478
  if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
476
479
  }
477
480
  if (this.platform === 'mobile') {
478
- cashier.classList.add('ams-component-container-mobile-animation');
479
- var animationStyleId = 'ams-component-container-mobile-animation-style';
481
+ cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
482
+ var animationStyleId = "".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style");
480
483
  var animationStyle = document.getElementById(animationStyleId);
481
484
  if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
482
485
 
483
486
  // 弹出和弹入动画
484
- 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 }");
487
+ var runkeyframes = "@keyframes ".concat(COMPONENT_CONTAINER_ID, "-slide-in {\n 0% {\n height: 1px;\n }\n 100% {\n height: ").concat(data.context.data.height, "px;\n }\n }\n @keyframes ").concat(COMPONENT_CONTAINER_ID, "-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 }");
485
488
  // 创建style标签
486
489
  var style = document.createElement('style');
487
490
  style.id = animationStyleId;
@@ -497,17 +500,18 @@ var ComponentApp = /*#__PURE__*/function () {
497
500
  cashier.style.transition = 'height 0.28s ease-in-out';
498
501
  }, 500);
499
502
  }
500
- this.app.style.height = "".concat(data.context.data.height, "px");
501
- this.app.style.width = '100%';
502
- this.app.style.border = '0';
503
- this.app.style.overflow = 'hidden';
504
503
  }
504
+ if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
505
+ var _document$getElementB3;
506
+ (_document$getElementB3 = document.getElementById(LOADING_ID)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
507
+ }
508
+ this.app.style.height = "".concat(data.context.data.height, "px");
509
+ this.app.style.opacity = '1';
505
510
  }
506
511
  }, {
507
512
  key: "handleRedirect",
508
513
  value: function handleRedirect(data) {
509
- var _this3 = this;
510
- this.closeCashier();
514
+ var _this4 = this;
511
515
  var _data = typeof data === 'string' ? {
512
516
  normalUrl: data
513
517
  } : {
@@ -517,37 +521,38 @@ var ComponentApp = /*#__PURE__*/function () {
517
521
  target: data === null || data === void 0 ? void 0 : data.target
518
522
  };
519
523
  var successCallback = function successCallback(type, url) {
520
- _this3.dispatchToSDK(EVENT.eventCallback.name, {
521
- code: 'SDK_CALL_URL_SUCCESS',
524
+ _this4.dispatchToSDK(EVENT.eventCallback.name, {
525
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
522
526
  message: "Successfully opened the app,".concat(type, ": ").concat(url)
523
527
  });
524
528
  };
525
529
  var failCallback = function failCallback() {
526
- _this3.dispatchToSDK(EVENT.eventCallback.name, {
527
- code: 'SDK_CALL_URL_ERROR',
530
+ _this4.dispatchToSDK(EVENT.eventCallback.name, {
531
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
528
532
  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)
529
533
  });
530
534
  };
531
535
 
532
536
  // 支持 target: _blank,新开tab页打开
533
- if (_data.target === Target.BLANK) {
537
+ if (_data.target === targetEnum.BLANK) {
534
538
  if (!_data.normalUrl) return failCallback();
535
539
  successCallback('normalUrl', _data.normalUrl);
536
540
  window.open(_data.normalUrl);
537
541
  return;
538
542
  }
543
+ this.cleanContainer();
539
544
  this.AMSSDK._redirect({
540
545
  applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
541
546
  }).then(function () {
542
547
  successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
543
548
  }).catch(function () {
544
- return _this3.AMSSDK._redirect({
549
+ return _this4.AMSSDK._redirect({
545
550
  schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
546
551
  });
547
552
  }).then(function () {
548
553
  successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
549
554
  }).catch(function () {
550
- return _this3.AMSSDK._redirect({
555
+ return _this4.AMSSDK._redirect({
551
556
  normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
552
557
  });
553
558
  }).then(function () {
@@ -558,62 +563,21 @@ var ComponentApp = /*#__PURE__*/function () {
558
563
  }
559
564
  }, {
560
565
  key: "handleDeclareInfo",
561
- value: function handleDeclareInfo(_ref4) {
562
- var _ref4$closeDialogData = _ref4.closeDialogData,
563
- closeDialogData = _ref4$closeDialogData === void 0 ? {} : _ref4$closeDialogData;
564
- try {
565
- if (closeDialogData) {
566
- var retentionTitle = document.getElementById('ams-component-retention-title');
567
- if (retentionTitle) {
568
- var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
569
- retentionTitle.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl = closeDialogData.title) === null || _closeDialogData$titl === void 0 ? void 0 : _closeDialogData$titl.fontSize, "px");
570
- retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
571
- retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
572
- }
573
- var retentionMessage = document.getElementById('ams-component-retention-sub-title');
574
- if (retentionMessage) {
575
- var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
576
- retentionMessage.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess = closeDialogData.message) === null || _closeDialogData$mess === void 0 ? void 0 : _closeDialogData$mess.fontSize, "px");
577
- retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
578
- retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
579
- }
580
- var remainBtn = document.getElementById('ams-component-retention-remain');
581
- if (remainBtn) {
582
- var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
583
- remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
584
- remainBtn.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO2 = closeDialogData.btnOK) === null || _closeDialogData$btnO2 === void 0 ? void 0 : _closeDialogData$btnO2.fontSize, "px");
585
- remainBtn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO3 = closeDialogData.btnOK) === null || _closeDialogData$btnO3 === void 0 ? void 0 : _closeDialogData$btnO3.fontColor;
586
- remainBtn.style.borderRadius = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO4 = closeDialogData.btnOK) === null || _closeDialogData$btnO4 === void 0 ? void 0 : _closeDialogData$btnO4.corner, "px");
587
- if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO5 = closeDialogData.btnOK) === null || _closeDialogData$btnO5 === void 0 ? void 0 : _closeDialogData$btnO5.type) === 'stroke') {
588
- var _closeDialogData$btnO6;
589
- remainBtn.style.border = "1px solid ".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO6 = closeDialogData.btnOK) === null || _closeDialogData$btnO6 === void 0 ? void 0 : _closeDialogData$btnO6.bg);
590
- } else remainBtn.style.backgroundColor = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO7 = closeDialogData.btnOK) === null || _closeDialogData$btnO7 === void 0 ? void 0 : _closeDialogData$btnO7.bg;
591
- }
592
- var leaveBrn = document.getElementById('ams-component-retention-leave');
593
- if (leaveBrn) {
594
- var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
595
- leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
596
- leaveBrn.style.fontSize = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC2 = closeDialogData.btnCancel) === null || _closeDialogData$btnC2 === void 0 ? void 0 : _closeDialogData$btnC2.fontSize, "px");
597
- leaveBrn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC3 = closeDialogData.btnCancel) === null || _closeDialogData$btnC3 === void 0 ? void 0 : _closeDialogData$btnC3.fontColor;
598
- leaveBrn.style.borderRadius = "".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC4 = closeDialogData.btnCancel) === null || _closeDialogData$btnC4 === void 0 ? void 0 : _closeDialogData$btnC4.corner, "px");
599
- if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC5 = closeDialogData.btnCancel) === null || _closeDialogData$btnC5 === void 0 ? void 0 : _closeDialogData$btnC5.type) === 'stroke') {
600
- var _closeDialogData$btnC6;
601
- leaveBrn.style.border = "1px solid ".concat(closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC6 = closeDialogData.btnCancel) === null || _closeDialogData$btnC6 === void 0 ? void 0 : _closeDialogData$btnC6.bg);
602
- } else leaveBrn.style.backgroundColor = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC7 = closeDialogData.btnCancel) === null || _closeDialogData$btnC7 === void 0 ? void 0 : _closeDialogData$btnC7.bg;
603
- }
604
- }
605
- } catch (error) {
606
- console.error(error);
607
- }
566
+ value: function handleDeclareInfo(_ref3) {
567
+ var _ref3$closeDialogData = _ref3.closeDialogData,
568
+ closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
569
+ _handleDeclareInfo({
570
+ closeDialogData: closeDialogData
571
+ });
608
572
  }
609
573
  }, {
610
574
  key: "handleCloseBtnShow",
611
575
  value: function handleCloseBtnShow(showClose) {
612
- var closeBlock = document.getElementById('asm-component-section-close-block');
576
+ var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
613
577
  if (showClose) {
614
- closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove('asm-component-close-block-hidden');
578
+ closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
615
579
  } else if (showClose === false) {
616
- closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add('asm-component-close-block-hidden');
580
+ closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
617
581
  }
618
582
  }
619
583
 
@@ -622,8 +586,9 @@ var ComponentApp = /*#__PURE__*/function () {
622
586
  */
623
587
  }, {
624
588
  key: "dispatchToSDK",
625
- value: function dispatchToSDK(event, data) {
626
- this.AMSSDK.eventCenter.emit(event, data);
589
+ value: function dispatchToSDK(event, data, eventCallbackId) {
590
+ this.AMSSDK._eventCenter.emit(event, data);
591
+ if (eventCallbackId) this.AMSSDK._eventCenter.emit(eventCallbackId, data);
627
592
  }
628
593
 
629
594
  /**
@@ -638,9 +603,11 @@ var ComponentApp = /*#__PURE__*/function () {
638
603
  appId: COMPONENTPLUGINID,
639
604
  instanceId: this.AMSSDK._instanceId
640
605
  });
606
+ // TODO 如果存在回调函数,则增加callBack标识,并存入map。map可以设置
641
607
  if (this.app && this.app.contentWindow) {
642
- this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
608
+ return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
643
609
  }
610
+ throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
644
611
  }
645
612
 
646
613
  /**
@@ -653,7 +620,7 @@ var ComponentApp = /*#__PURE__*/function () {
653
620
  for (var key in eventKeyMap) {
654
621
  // eslint-disable-next-line no-prototype-builtins
655
622
  if (eventKeyMap.hasOwnProperty(key)) {
656
- this.AMSSDK.eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
623
+ this.AMSSDK._eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
657
624
  }
658
625
  }
659
626
  }
@@ -665,7 +632,7 @@ var ComponentApp = /*#__PURE__*/function () {
665
632
  key: "sendRenderEvent",
666
633
  value: function () {
667
634
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
668
- var _this$_renderParams2, _this$_renderParams3, res;
635
+ var _this$_renderParams, _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, res;
669
636
  return _regeneratorRuntime().wrap(function _callee$(_context) {
670
637
  while (1) switch (_context.prev = _context.next) {
671
638
  case 0:
@@ -689,9 +656,11 @@ var ComponentApp = /*#__PURE__*/function () {
689
656
  event: 'renderComponent',
690
657
  data: {
691
658
  queryResult: res,
692
- sessionResult: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionMetaData,
693
- paymentSessionData: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.paymentSessionData,
659
+ sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
660
+ paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
694
661
  heightOfVisible: Math.max(innerHeight, window.innerHeight),
662
+ renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
663
+ appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
695
664
  envInfo: {
696
665
  screenHeight: screen.height,
697
666
  screenWidth: screen.width
@@ -724,198 +693,77 @@ var ComponentApp = /*#__PURE__*/function () {
724
693
  }
725
694
  return sendRenderEvent;
726
695
  }()
727
- }, {
728
- key: "showLoading",
729
- value: function showLoading() {
730
- var loading = document.createElement('div');
731
- loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
732
- loading.id = loadingId;
733
- loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
734
- loading.style.fontSize = "".concat(getDesignFontSize(), "px");
735
- var body = document.getElementsByTagName('body')[0];
736
- body === null || body === void 0 ? void 0 : body.appendChild(loading);
737
- }
738
-
739
- /**
740
- * @description show cashier
741
- */
742
- }, {
743
- key: "showCashier",
744
- value: function showCashier() {
745
- var cashier = document.getElementById('ams-component-container');
746
- cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("ams-component-container-hidden-".concat(this.platform));
747
- cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("ams-component-container-".concat(this.platform));
748
- }
749
-
750
696
  /**
751
697
  * @description close cashier
752
698
  */
753
699
  }, {
754
- key: "closeCashier",
755
- value: function closeCashier() {
756
- var _document$getElementB2;
700
+ key: "cleanContainer",
701
+ value: function cleanContainer() {
702
+ var _document$getElementB4,
703
+ _this5 = this;
757
704
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
705
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
758
706
  this._performanceData = [];
759
707
  this._isInitComponent = false;
760
- (_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
761
- this.hideComponentAndCleanDom(immediately);
762
- }
763
- }, {
764
- key: "hideComponentAndCleanDom",
765
- value: function hideComponentAndCleanDom() {
766
- var _this4 = this;
767
- var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
768
- var container = document.getElementById('ams-component-container');
769
- // size变化动画取消
770
- container.style.transition = '';
771
- container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform));
772
- container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform, "-animation"));
773
- container === null || container === void 0 ? void 0 : container.classList.add("ams-component-container-hidden-".concat(this.platform));
774
- var removeMockupAndApp = function removeMockupAndApp() {
775
- var _document$getElementB3;
776
- var body = document.getElementsByTagName('body')[0];
777
- body.style.overflow = 'auto';
778
- var mockup = document.getElementById(mockupId);
779
- mockup === null || mockup === void 0 ? void 0 : mockup.remove();
780
- if (container) container.style.height = '';
781
- (_document$getElementB3 = document.getElementById('ams-component-container-mobile-animation-style')) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
782
- _this4.removeRetentionPopup();
783
- _this4.cleanApp();
784
- };
785
- if (immediately) removeMockupAndApp();else {
708
+ this.app = null;
709
+ (_document$getElementB4 = document.getElementById(LOADING_ID)) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
710
+ this.hideComponentAnimation();
711
+ var mockup = document.getElementById(MOCKUP_ID);
712
+ mockup === null || mockup === void 0 ? void 0 : mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
713
+ if (immediately) this.cleanElement();else {
786
714
  setTimeout(function () {
787
- removeMockupAndApp();
715
+ _this5.cleanElement();
788
716
  }, 300);
789
717
  }
790
718
  }
719
+ }, {
720
+ key: "hideComponentAnimation",
721
+ value: function hideComponentAnimation() {
722
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
723
+ if (container) {
724
+ // size变化动画取消
725
+ container.style.transition = '';
726
+ container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform));
727
+ container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
728
+ container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.platform));
729
+ }
730
+ }
791
731
  }, {
792
732
  key: "closeBtnFunc",
793
733
  value: function closeBtnFunc() {
794
734
  // element && element.removeEventListener()
795
735
  if (this._isRetention) this.showRetentionPopup();else {
796
- this.closeCashier();
797
- this.dispatchToSDK(EVENT.onClose.name, {});
798
- }
799
- }
800
-
801
- /**
802
- * @description create mount node
803
- */
804
- }, {
805
- key: "createMountElement",
806
- value: function createMountElement() {
807
- componentAddCSS();
808
- var amsComponentContainer = document.createElement('div');
809
- amsComponentContainer.className = "ams-component-container-hidden-".concat(this.platform);
810
- amsComponentContainer.id = 'ams-component-container';
811
- amsSetSize(null, amsComponentContainer);
812
- document.body.appendChild(amsComponentContainer);
813
- var amsComponentSection = document.createElement('div');
814
- amsComponentSection.className = "ams-component-section-".concat(this.platform);
815
- amsComponentSection.id = this._selector.slice(1);
816
- amsComponentContainer.appendChild(amsComponentSection);
817
- this.createCloseBtn();
818
- }
819
- }, {
820
- key: "createCloseBtn",
821
- value: function createCloseBtn() {
822
- var _this5 = this;
823
- var container = document.getElementById('ams-component-container');
824
- // close btn
825
- var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"").concat(closeImg, "\"/>");
826
- var closeBlock = document.createElement('div');
827
- closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
828
- closeBlock.id = 'asm-component-section-close-block';
829
- closeBlock.innerHTML = closeBtnHTML;
830
- closeBlock.addEventListener(this._clickEventName, function () {
831
- _this5.closeBtnFunc();
832
- });
833
- if (container) container.appendChild(closeBlock);
834
- }
835
- }, {
836
- key: "createRetentionPopup",
837
- value: function createRetentionPopup() {
838
- // retention popup
839
- var retentionPopup = document.createElement('div');
840
- retentionPopup.id = 'ams-component-retention';
841
- retentionPopup.classList.add("ams-component-retention-".concat(this.platform));
842
- 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>");
843
- document.body.appendChild(retentionPopup);
844
- var remainBtn = document.getElementById('ams-component-retention-remain');
845
- if (remainBtn) {
846
- remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
847
- }
848
- var leaveBtn = document.getElementById('ams-component-retention-leave');
849
- if (leaveBtn) {
850
- leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
736
+ this.cleanContainer();
737
+ this.dispatchToSDK(EVENT.close.name, {});
851
738
  }
852
739
  }
853
740
  }, {
854
741
  key: "retentionPopupLeaveFunc",
855
742
  value: function retentionPopupLeaveFunc() {
856
- this.dispatchToSDK(EVENT.onClose.name, {});
857
- this.hideRetentionPopup();
858
- this.closeCashier();
743
+ this.dispatchToSDK(EVENT.close.name, {});
744
+ this.hideRetentionPopupFunc();
745
+ this.cleanContainer();
859
746
  }
860
747
  }, {
861
748
  key: "removeRetentionPopup",
862
- value: function removeRetentionPopup() {
863
- var _document$getElementB4;
864
- var remainBtn = document.getElementById('ams-component-retention-remain');
865
- if (remainBtn) {
866
- remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
867
- }
868
- var leaveBtn = document.getElementById('ams-component-retention-leave');
869
- if (leaveBtn) {
870
- leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
871
- }
872
- (_document$getElementB4 = document.getElementById('ams-component-retention')) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
749
+ value: function removeRetentionPopup(platform) {
750
+ _removeRetentionPopup(platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
873
751
  }
874
752
  }, {
875
753
  key: "showRetentionPopup",
876
754
  value: function showRetentionPopup() {
877
- var retentionPopup = document.getElementById('ams-component-retention');
878
- var container = document.getElementById('ams-component-container');
755
+ var retentionPopup = document.getElementById(COMPONENT_RETENTION_ID);
756
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
879
757
  if (retentionPopup) {
880
- container === null || container === void 0 ? void 0 : container.classList.add('ams-component-container-opacity');
881
- retentionPopup.classList.remove('ams-component-retention-hidden');
882
- retentionPopup.classList.add('ams-component-retention-show');
758
+ container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-opacity"));
759
+ retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-hidden"));
760
+ retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-show"));
883
761
  }
884
762
  }
885
763
  }, {
886
- key: "hideRetentionPopup",
887
- value: function hideRetentionPopup() {
888
- var retentionPopup = document.getElementById('ams-component-retention');
889
- var container = document.getElementById('ams-component-container');
890
- if (retentionPopup) {
891
- retentionPopup.classList.remove('ams-component-retention-show');
892
- retentionPopup.classList.add('ams-component-retention-hidden');
893
- setTimeout(function () {
894
- retentionPopup.classList.remove('ams-component-retention-hidden');
895
- container === null || container === void 0 ? void 0 : container.classList.remove('ams-component-container-opacity');
896
- }, 250);
897
- }
898
- }
899
- /**
900
- * @description create mockup
901
- */
902
- }, {
903
- key: "createMockup",
904
- value: function createMockup() {
905
- var body = document.getElementsByTagName('body')[0];
906
- body.style.overflow = 'hidden';
907
- var mockup = document.createElement('div');
908
- mockup.style.width = '100vw';
909
- mockup.style.height = '100vh';
910
- mockup.style.position = 'fixed';
911
- mockup.style.top = '0';
912
- mockup.style.left = '0';
913
- mockup.style.zIndex = '1000';
914
- mockup.style.background = '#ffffff';
915
- mockup.style.opacity = '0.5';
916
- mockup.style.display = 'none';
917
- mockup.id = mockupId;
918
- body.appendChild(mockup);
764
+ key: "hideRetentionPopupFunc",
765
+ value: function hideRetentionPopupFunc() {
766
+ hideRetentionPopup();
919
767
  }
920
768
  }, {
921
769
  key: "submitForm",
@@ -936,7 +784,6 @@ var ComponentApp = /*#__PURE__*/function () {
936
784
  form.setAttribute('action', attributes.action);
937
785
  form.setAttribute('method', 'post');
938
786
  body.appendChild(form);
939
- this.closeCashier(true);
940
787
  setTimeout(function () {
941
788
  form.submit();
942
789
  }, 0);