@alipay/ams-checkout 1.3.2 → 1.5.0

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 (40) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +1 -15
  3. package/esm/config/index.js +9 -62
  4. package/esm/config/request.d.ts +21 -0
  5. package/esm/config/request.js +67 -0
  6. package/esm/constant/index.d.ts +54 -32
  7. package/esm/constant/index.js +54 -32
  8. package/esm/core/component/index.d.ts +23 -9
  9. package/esm/core/component/index.js +161 -98
  10. package/esm/core/drop-in/index.d.ts +4 -4
  11. package/esm/core/drop-in/index.js +3 -3
  12. package/esm/core/instance/index.d.ts +6 -23
  13. package/esm/core/instance/index.js +31 -75
  14. package/esm/image/skeleton.svg +18 -0
  15. package/esm/index.d.ts +4 -10
  16. package/esm/index.js +8 -30
  17. package/esm/plugin/component/cashierApp.d.ts +5 -6
  18. package/esm/plugin/component/cashierApp.js +48 -64
  19. package/esm/plugin/component/{component.style.d.ts → component.inline.style.d.ts} +4 -1
  20. package/esm/plugin/component/component.inline.style.js +38 -0
  21. package/esm/plugin/component/component.popup.style.d.ts +12 -0
  22. package/esm/plugin/component/component.popup.style.js +163 -0
  23. package/esm/plugin/component/index.d.ts +30 -33
  24. package/esm/plugin/component/index.js +248 -349
  25. package/esm/plugin/drop-in/index.d.ts +3 -5
  26. package/esm/plugin/drop-in/index.js +3 -3
  27. package/esm/request/index.d.ts +2 -2
  28. package/esm/request/index.js +8 -7
  29. package/esm/request/utils.d.ts +3 -3
  30. package/esm/request/utils.js +4 -4
  31. package/esm/service/index.d.ts +2 -2
  32. package/esm/types/index.d.ts +96 -37
  33. package/esm/types/index.js +92 -52
  34. package/esm/util/createIframeNode.d.ts +3 -3
  35. package/esm/util/createIframeNode.js +8 -8
  36. package/esm/util/index.d.ts +6 -4
  37. package/esm/util/index.js +22 -5
  38. package/esm/util/mock.js +1 -2
  39. package/package.json +1 -1
  40. package/esm/plugin/component/component.style.js +0 -15
@@ -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,62 +15,44 @@ 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 { COMPONENTPLUGINID, ERRORMESSAGE, EVENT } from "../../constant";
18
+ 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
19
  import { queryPaymentInfo } from "../../service";
22
- import { componentNameEnum, messageName, Target } from "../../types";
23
- import { getDesignFontSize, getType, isJsonString, isPC } from "../../util";
20
+ import { componentSignEnum, eventCodeEnum, messageName, platformEnum, productSceneEnum, renderDisplayTypeEnum, targetEnum } from "../../types";
21
+ import { getType, isJsonString, isPC } from "../../util";
24
22
  import { isLocalMock } from "../../util/mock";
25
23
  import { createIframe, getAppDomain, getIframeUrl } from "./cashierApp";
26
- import { componentAddCSS } from "./component.style";
24
+ import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
25
+ import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup } from "./component.popup.style";
27
26
  var _window = window,
28
27
  innerHeight = _window.innerHeight;
29
- var amsSetSize = function amsSetSize(event, dom) {
30
- try {
31
- var _dom = dom || document.getElementById('ams-component-container');
32
- _dom.style.fontSize = "".concat(getDesignFontSize(), "px");
33
- innerHeight = window.innerHeight;
34
- // eslint-disable-next-line no-empty
35
- } catch (error) {}
36
- };
37
- var addEvent = function addEvent() {
38
- window.removeEventListener('resize', amsSetSize);
39
- window.removeEventListener('pageShow', amsSetSize);
40
- window.removeEventListener('DOMContentLoaded', amsSetSize);
41
- window.addEventListener('resize', amsSetSize);
42
- window.addEventListener('pageShow', amsSetSize);
43
- window.addEventListener('DOMContentLoaded', amsSetSize);
44
- };
45
- var mockupId = 'ams-component-mockup';
46
- var loadingId = 'ams-component-loading';
47
- var listenerPrefix = '_ams_sdk_component_listener';
48
28
  var ComponentApp = /*#__PURE__*/function () {
49
29
  function ComponentApp() {
50
30
  _classCallCheck(this, ComponentApp);
51
31
  _defineProperty(this, "app", void 0);
52
- _defineProperty(this, "appDomain", void 0);
53
32
  _defineProperty(this, "AMSSDK", void 0);
54
33
  _defineProperty(this, "platform", void 0);
34
+ _defineProperty(this, "_performanceData", []);
35
+ _defineProperty(this, "_loadAppPromiseResolve", null);
36
+ _defineProperty(this, "_isInitComponent", void 0);
37
+ _defineProperty(this, "appDomain", void 0);
55
38
  _defineProperty(this, "createIframeNode", void 0);
56
39
  _defineProperty(this, "_selector", void 0);
57
40
  _defineProperty(this, "_appVersion", void 0);
58
41
  _defineProperty(this, "_isRetention", void 0);
59
42
  _defineProperty(this, "_actionQueryPromise", null);
60
43
  _defineProperty(this, "_renderParams", null);
61
- _defineProperty(this, "_componentName", '');
62
- _defineProperty(this, "_performanceData", []);
63
- _defineProperty(this, "_isInitComponent", void 0);
44
+ _defineProperty(this, "_componentSign", componentSignEnum.NONE);
64
45
  _defineProperty(this, "_clickEventName", void 0);
65
- this._appVersion = '1.3.1';
46
+ _defineProperty(this, "_renderDisplayType", renderDisplayTypeEnum.popup);
47
+ this._appVersion = '1.5.0';
66
48
  this._isInitComponent = false;
67
- this._selector = '#ams-component-section';
49
+ this._selector = "#".concat(COMPONENT_SECTION_ID);
68
50
  this.createIframeNode = function () {
69
51
  return Promise.resolve();
70
52
  };
71
- this.platform = isPC() ? 'desktop' : 'mobile';
72
- this._clickEventName = this.platform === 'mobile' ? 'touchend' : 'click';
53
+ this.platform = isPC() ? platformEnum.desktop : platformEnum.mobile;
54
+ this._clickEventName = this.platform === platformEnum.mobile ? 'touchend' : 'click';
73
55
  this._isRetention = true;
74
- addEvent();
75
- this.createMountElement();
76
56
  this._performanceData.push({
77
57
  key: 'sdk_init',
78
58
  value: Date.now()
@@ -85,7 +65,7 @@ var ComponentApp = /*#__PURE__*/function () {
85
65
  _createClass(ComponentApp, [{
86
66
  key: "logoutPlugin",
87
67
  value: function logoutPlugin() {
88
- this.closeCashier();
68
+ this.cleanContainer(true);
89
69
  }
90
70
 
91
71
  /**
@@ -103,8 +83,8 @@ var ComponentApp = /*#__PURE__*/function () {
103
83
  */
104
84
  }, {
105
85
  key: "setRender",
106
- value: function setRender(createIframeNode) {
107
- this.createIframeNode = createIframeNode;
86
+ value: function setRender(renderFunc) {
87
+ this.createIframeNode = renderFunc;
108
88
  }
109
89
 
110
90
  /**
@@ -112,89 +92,142 @@ var ComponentApp = /*#__PURE__*/function () {
112
92
  */
113
93
  }, {
114
94
  key: "appendIframeNodes",
115
- value: function appendIframeNodes(componentName, renderParams) {
116
- var _renderParams$appeara,
117
- _this = this;
118
- if (this._isInitComponent) return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
95
+ value: function appendIframeNodes(componentSign, renderParams) {
96
+ var _this = this;
97
+ if (this._isInitComponent) {
98
+ this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
99
+ return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
100
+ }
119
101
  this._isInitComponent = true;
120
102
  this._renderParams = renderParams;
121
- this._componentName = componentName;
103
+ this._componentSign = componentSign;
104
+ if (renderParams !== null && renderParams !== void 0 && renderParams.selector) this._selector = renderParams.selector;
105
+ this._renderDisplayType = renderParams.renderDisplayType;
106
+ var insertedNode = this._renderDisplayType === renderDisplayTypeEnum.inline ? "#".concat(COMPONENT_CONTAINER_ID) : this._selector;
122
107
  this._performanceData.push({
123
108
  key: 'sdk_create_component',
124
109
  value: Date.now()
125
110
  });
126
- this.createRetentionPopup();
127
- this.createMockup();
128
- if ((renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading) !== false) {
129
- var mockup = document.getElementById(mockupId);
130
- if (mockup) {
131
- mockup.style.display = 'block';
132
- }
133
- this.showLoading();
111
+ this.dispatchToSDK(EVENT.eventCallback.name, {
112
+ code: eventCodeEnum.SDK_START_OF_LOADING
113
+ });
114
+ if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
115
+ var container = createInlineBaseElement(this._selector);
116
+ if (container) this.renderInlineLoading(renderParams, container);
117
+ }
118
+ if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
119
+ createBaseElement(this.platform, this.closeBtnFunc.bind(this));
120
+ createRetentionPopup(this.platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
121
+ createMockup();
122
+ this.renderPopupLoading(renderParams);
134
123
  }
135
- this.showCashier();
136
124
  this.createApp(renderParams);
137
- this.createActionQueryPromise();
138
- return Promise.all([this.createIframeNode(this, _objectSpread(_objectSpread({}, renderParams), {}, {
139
- selector: this._selector
140
- })), this._actionQueryPromise]).catch(function () {
125
+ return Promise.all([this.createActionQueryPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
126
+ return Promise.resolve();
127
+ }).catch(function (error) {
141
128
  _this._isInitComponent = false;
129
+ _this.cleanContainer();
130
+ return Promise.reject(error);
131
+ });
132
+ }
133
+ }, {
134
+ key: "renderInlineLoading",
135
+ value: function renderInlineLoading(renderParams, selector) {
136
+ var _renderParams$appeara;
137
+ var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
138
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
139
+ if (showLoading) addInlineLoading(selector, this.platform);
140
+ }
141
+ }, {
142
+ key: "renderPopupLoading",
143
+ value: function renderPopupLoading(renderParams) {
144
+ var _renderParams$appeara2;
145
+ var showLoading = renderParams === null || renderParams === void 0 ? void 0 : (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
146
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
147
+ if (!showLoading) return;
148
+ var mockup = document.getElementById(MOCKUP_ID);
149
+ if (mockup) mockup.style.display = 'block';
150
+ addPopupLoading();
151
+ }
152
+ }, {
153
+ key: "_createLoadAppPromise",
154
+ value: function _createLoadAppPromise() {
155
+ var _this2 = this;
156
+ return new Promise(function (resolve, reject) {
157
+ _this2._loadAppPromiseResolve = resolve;
158
+ setTimeout(function () {
159
+ reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
160
+ }, LOADTIME_LIMIT);
161
+ }).catch(function (error) {
162
+ _this2.dispatchToSDK(EVENT.error.name, {
163
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code,
164
+ message: ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT.message
165
+ });
166
+ return Promise.reject(error);
142
167
  });
143
168
  }
169
+
144
170
  /**
145
171
  * @description Interface request
146
172
  */
147
173
  }, {
148
174
  key: "createActionQueryPromise",
149
175
  value: function createActionQueryPromise() {
150
- var _this2 = this;
176
+ var _this3 = this;
151
177
  this._performanceData.push({
152
178
  key: 'sdk_action_query_start',
153
179
  value: Date.now()
154
180
  });
155
181
  this._actionQueryPromise = new Promise(function (resolve, reject) {
156
- var _this2$_renderParams, _this2$_renderParams2, _this2$_renderParams3;
182
+ var _this3$_renderParams, _this3$_renderParams2, _this3$_renderParams3;
157
183
  var params = {
158
- paymentSessionData: _this2._renderParams && ((_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.paymentSessionData) || '',
159
- 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
184
+ paymentSessionData: _this3._renderParams && ((_this3$_renderParams = _this3._renderParams) === null || _this3$_renderParams === void 0 ? void 0 : _this3$_renderParams.paymentSessionData) || '',
185
+ 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
160
186
  };
161
- if (componentNameEnum.card === _this2._componentName) {
187
+ /**
188
+ * @description card
189
+ */
190
+ if (componentSignEnum.CASHIER_PAYMENT_CARD === _this3._componentSign) {
162
191
  params.paymentMethodType = 'CARD';
163
192
  }
164
- if (componentNameEnum.easyPay === _this2._componentName) {
165
- var _this2$_renderParams4;
166
- // if EASY_PAY 2.0 , no need to query payment request
193
+ /**
194
+ * @description easyPay
195
+ */
196
+ if (componentSignEnum.EASY_PAY_WALLET === _this3._componentSign) {
197
+ var _this3$_renderParams4;
167
198
  var _ref = params.paymentSessionConfig || {},
168
199
  _ref$productSceneVers = _ref.productSceneVersion,
169
200
  productSceneVersion = _ref$productSceneVers === void 0 ? '' : _ref$productSceneVers,
170
201
  _ref$productScene = _ref.productScene,
171
202
  productScene = _ref$productScene === void 0 ? '' : _ref$productScene;
172
- var _ref2 = ((_this2$_renderParams4 = _this2._renderParams) === null || _this2$_renderParams4 === void 0 ? void 0 : _this2$_renderParams4.paymentSessionMetaData) || {},
203
+ var _ref2 = ((_this3$_renderParams4 = _this3._renderParams) === null || _this3$_renderParams4 === void 0 ? void 0 : _this3$_renderParams4.paymentSessionMetaData) || {},
173
204
  _ref2$action = _ref2.action,
174
205
  _ref2$action2 = _ref2$action === void 0 ? {} : _ref2$action,
175
206
  _ref2$action2$autoDeb = _ref2$action2.autoDebitWithToken,
176
207
  autoDebitWithToken = _ref2$action2$autoDeb === void 0 ? false : _ref2$action2$autoDeb;
177
- if (productScene === 'EASY_PAY' && productSceneVersion === '2.0' && !autoDebitWithToken) {
178
- // make queryResult no data we setAppStateData in antom-web-checkout app,
179
- // eslint-disable-next-line no-promise-executor-return
208
+ if (productScene === productSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
209
+ // if EASY_PAY 2.0 , no need to query payment request
180
210
  return resolve({
181
- message: 'sdk no need to make query request'
211
+ message: 'sdk no need to make query request',
212
+ success: true
182
213
  });
183
214
  }
184
215
  }
185
216
  /**
186
217
  * @author tianqiang
187
- * @description 代扣逻辑处理
218
+ * @description autoDebit
188
219
  */
189
- if (componentNameEnum.autoDebit === _this2._componentName) {
190
- var _this2$_renderParams5, _this2$_renderParams6, _action$web, _action$wap;
191
- 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) || {};
192
- 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) || '';
220
+ if (componentSignEnum.AUTO_DEBIT_WALLET === _this3._componentSign) {
221
+ var _this3$_renderParams5, _this3$_renderParams6, _action$web, _action$wap;
222
+ 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) || {};
223
+ 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;
193
224
  if (signType === 'SMS') {
194
225
  return resolve({
195
- message: 'sdk no need to make query request'
226
+ message: 'sdk no need to make query request',
227
+ success: true
196
228
  });
197
- } else if (!signType || signType !== 'REDIRECT') {
229
+ }
230
+ if (!signType || signType !== 'REDIRECT') {
198
231
  return resolve({
199
232
  success: false
200
233
  });
@@ -204,14 +237,15 @@ var ComponentApp = /*#__PURE__*/function () {
204
237
  // mock
205
238
  if (isLocalMock()) {
206
239
  return resolve({
207
- message: 'sdk no need to make query request'
240
+ message: 'sdk no need to make query request',
241
+ success: true
208
242
  });
209
243
  }
210
244
  queryPaymentInfo(params, {
211
- env: _this2.AMSSDK.options.env.environment,
212
- locale: _this2.AMSSDK.options.locale
245
+ env: _this3.AMSSDK.options.env.environment,
246
+ locale: _this3.AMSSDK.options.locale
213
247
  }).then(function (res) {
214
- _this2._performanceData.push({
248
+ _this3._performanceData.push({
215
249
  key: 'sdk_action_query_end',
216
250
  value: Date.now()
217
251
  });
@@ -219,26 +253,46 @@ var ComponentApp = /*#__PURE__*/function () {
219
253
  resolve(res);
220
254
  } else {
221
255
  resolve(res);
222
- _this2.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR);
223
256
  }
224
257
  }).catch(function (err) {
258
+ _this3.dispatchToSDK(EVENT.error.name, {
259
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
260
+ });
225
261
  reject(err);
226
- _this2.closeCashier();
227
262
  });
228
263
  });
264
+ return this._actionQueryPromise;
229
265
  }
230
266
  }, {
231
- key: "cleanApp",
232
- value: function cleanApp() {
267
+ key: "cleanElement",
268
+ value: function cleanElement() {
233
269
  try {
234
- this.app = null;
235
- this._removeEventListener();
270
+ var _document$getElementB;
271
+ // selector and container
236
272
  if (getType(this._selector) === 'string') {
237
- var dorpinDom = document.querySelector(this._selector);
238
- if (dorpinDom) dorpinDom.innerHTML = '';
273
+ var selectorDom = document.querySelector(this._selector);
274
+ if (selectorDom) selectorDom.innerHTML = '';
239
275
  }
240
- // eslint-disable-next-line no-empty
241
- } catch (error) {}
276
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
277
+ if (container) container === null || container === void 0 ? void 0 : container.remove();
278
+
279
+ // animation
280
+ (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style"))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
281
+
282
+ // mockup
283
+ var body = document.getElementsByTagName('body')[0];
284
+ body.style.overflow = 'auto';
285
+ var mockup = document.getElementById(MOCKUP_ID);
286
+ mockup === null || mockup === void 0 ? void 0 : mockup.remove();
287
+
288
+ // retentionPopup
289
+ this.removeRetentionPopup(this.platform);
290
+
291
+ // listener
292
+ this.removeEventListener();
293
+ } catch (error) {
294
+ console.error(error);
295
+ }
242
296
  }
243
297
 
244
298
  /**
@@ -263,14 +317,13 @@ var ComponentApp = /*#__PURE__*/function () {
263
317
  this.appDomain = getAppDomain({
264
318
  environment: environment,
265
319
  appVersion: this._appVersion,
266
- componentName: this._componentName,
320
+ componentSign: this._componentSign,
267
321
  productSceneVersion: productSceneVersion,
268
322
  extendInfo: extendInfo
269
323
  });
270
- this.app = createIframe(this.AMSSDK.options.mode);
324
+ this.app = createIframe(this.AMSSDK.options.mode, this.platform);
271
325
  this.app.src = getIframeUrl({
272
- componentName: this._componentName,
273
- appearance: (renderParams === null || renderParams === void 0 ? void 0 : renderParams.appearance) || {},
326
+ componentSign: this._componentSign,
274
327
  analytics: this.AMSSDK.options.analytics,
275
328
  productSceneVersion: productSceneVersion,
276
329
  environment: environment,
@@ -281,7 +334,7 @@ var ComponentApp = /*#__PURE__*/function () {
281
334
  });
282
335
 
283
336
  // Subscribe to messages from iframe
284
- this._addEventListener();
337
+ this.addEventListener();
285
338
  } catch (error) {
286
339
  this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
287
340
  stack: error
@@ -300,6 +353,8 @@ var ComponentApp = /*#__PURE__*/function () {
300
353
  if (data.name !== messageName.APP_TO_SDK && data.name !== messageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) {
301
354
  return;
302
355
  }
356
+ // TODO
357
+ // 如果带有callback标识,则从map结构中取出callbackfunc,执行,执行后在map结构中删除
303
358
  this._handleAppMessage(data);
304
359
  } else {
305
360
  console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
@@ -309,7 +364,7 @@ var ComponentApp = /*#__PURE__*/function () {
309
364
  }, {
310
365
  key: "resizeListener",
311
366
  value: function resizeListener() {
312
- var cashier = document.getElementById('ams-component-container');
367
+ var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
313
368
  cashier.style.transition = 'none';
314
369
  this.dispatchToApp({
315
370
  context: {
@@ -326,19 +381,19 @@ var ComponentApp = /*#__PURE__*/function () {
326
381
  * @description Initialize subscription iframe message
327
382
  */
328
383
  }, {
329
- key: "_addEventListener",
330
- value: function _addEventListener() {
331
- window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
332
- window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
333
- this._removeEventListener();
334
- window.addEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
335
- window.addEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
384
+ key: "addEventListener",
385
+ value: function addEventListener() {
386
+ this.removeEventListener();
387
+ window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
388
+ window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
389
+ window.addEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
390
+ window.addEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
336
391
  }
337
392
  }, {
338
- key: "_removeEventListener",
339
- value: function _removeEventListener() {
340
- window.removeEventListener('message', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId)]);
341
- window.removeEventListener('resize', window["".concat(listenerPrefix, "_").concat(this.AMSSDK._instanceId, "_resize")]);
393
+ key: "removeEventListener",
394
+ value: function removeEventListener() {
395
+ window.removeEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
396
+ window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
342
397
  }
343
398
 
344
399
  /**
@@ -347,7 +402,10 @@ var ComponentApp = /*#__PURE__*/function () {
347
402
  }, {
348
403
  key: "_handleAppMessage",
349
404
  value: function _handleAppMessage(data) {
350
- 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];
405
+ 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];
406
+ if (!eventKeyMap.includes(data.context.event)) {
407
+ return;
408
+ }
351
409
  if (data.context.event === EVENT.dismissLoading.name) {
352
410
  var _data$context$data;
353
411
  this.dispatchToSDK(EVENT.eventCallback.name, {
@@ -356,21 +414,19 @@ var ComponentApp = /*#__PURE__*/function () {
356
414
  });
357
415
  return;
358
416
  }
359
- if (!eventKeyMap.includes(data.context.event)) {
360
- return;
361
- }
362
417
  if (data.context.event === EVENT.launch.name) {
363
418
  this._performanceData.push({
364
419
  key: 'sdk_onLaunch',
365
420
  value: Date.now()
366
421
  });
422
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
367
423
  this.sendRenderEvent();
368
424
  return;
369
425
  }
370
426
  if (data.context.event === EVENT.sizeChanged.name) {
371
427
  this.handleSizeChanged(data);
372
428
  }
373
- if (data.context.event === EVENT.onClose.name) {
429
+ if (data.context.event === EVENT.close.name) {
374
430
  return this.closeBtnFunc();
375
431
  }
376
432
  if (data.context.event === EVENT.redirect.name) {
@@ -405,29 +461,29 @@ var ComponentApp = /*#__PURE__*/function () {
405
461
  key: "handleSizeChanged",
406
462
  value: function handleSizeChanged(data) {
407
463
  var _data$context$data2;
408
- if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) > 1) {
409
- var _document$getElementB;
410
- var mockup = document.getElementById(mockupId);
464
+ if (((_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.height) <= 1) return;
465
+ var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
466
+ cashier.style.height = "".concat(data.context.data.height, "px");
467
+ if (this._renderDisplayType === renderDisplayTypeEnum.popup) {
468
+ var _document$getElementB2;
469
+ var mockup = document.getElementById(MOCKUP_ID);
411
470
  if (mockup) {
412
- mockup.style.background = '#000000';
413
- mockup.style.opacity = '0.6';
471
+ mockup.style.background = 'rgb(0, 0, 0, 0.6)';
414
472
  mockup.style.display = 'block';
415
473
  }
416
- (_document$getElementB = document.getElementById(loadingId)) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
417
- var cashier = document.getElementById('ams-component-container');
418
- cashier.style.height = "".concat(data.context.data.height, "px");
474
+ (_document$getElementB2 = document.getElementById(LOADING_ID)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
419
475
  if (this.platform === 'desktop') {
420
- cashier.classList.add('ams-component-container-desktop-animation');
476
+ cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
421
477
  if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
422
478
  }
423
479
  if (this.platform === 'mobile') {
424
- cashier.classList.add('ams-component-container-mobile-animation');
425
- var animationStyleId = 'ams-component-container-mobile-animation-style';
480
+ cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
481
+ var animationStyleId = "".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style");
426
482
  var animationStyle = document.getElementById(animationStyleId);
427
483
  if (animationStyle) animationStyle === null || animationStyle === void 0 ? void 0 : animationStyle.remove();
428
484
 
429
485
  // 弹出和弹入动画
430
- 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 }");
486
+ 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 }");
431
487
  // 创建style标签
432
488
  var style = document.createElement('style');
433
489
  style.id = animationStyleId;
@@ -443,17 +499,18 @@ var ComponentApp = /*#__PURE__*/function () {
443
499
  cashier.style.transition = 'height 0.28s ease-in-out';
444
500
  }, 500);
445
501
  }
446
- this.app.style.height = "".concat(data.context.data.height, "px");
447
- this.app.style.width = '100%';
448
- this.app.style.border = '0';
449
- this.app.style.overflow = 'hidden';
450
502
  }
503
+ if (this._renderDisplayType === renderDisplayTypeEnum.inline) {
504
+ var _document$getElementB3;
505
+ (_document$getElementB3 = document.getElementById(LOADING_ID)) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
506
+ }
507
+ this.app.style.height = "".concat(data.context.data.height, "px");
508
+ this.app.style.opacity = '1';
451
509
  }
452
510
  }, {
453
511
  key: "handleRedirect",
454
512
  value: function handleRedirect(data) {
455
- var _this3 = this;
456
- this.closeCashier();
513
+ var _this4 = this;
457
514
  var _data = typeof data === 'string' ? {
458
515
  normalUrl: data
459
516
  } : {
@@ -463,37 +520,38 @@ var ComponentApp = /*#__PURE__*/function () {
463
520
  target: data === null || data === void 0 ? void 0 : data.target
464
521
  };
465
522
  var successCallback = function successCallback(type, url) {
466
- _this3.dispatchToSDK(EVENT.eventCallback.name, {
467
- code: 'SDK_CALL_URL_SUCCESS',
523
+ _this4.dispatchToSDK(EVENT.eventCallback.name, {
524
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
468
525
  message: "Successfully opened the app,".concat(type, ": ").concat(url)
469
526
  });
470
527
  };
471
528
  var failCallback = function failCallback() {
472
- _this3.dispatchToSDK(EVENT.eventCallback.name, {
473
- code: 'SDK_CALL_URL_ERROR',
529
+ _this4.dispatchToSDK(EVENT.eventCallback.name, {
530
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
474
531
  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)
475
532
  });
476
533
  };
477
534
 
478
535
  // 支持 target: _blank,新开tab页打开
479
- if (_data.target === Target.BLANK) {
536
+ if (_data.target === targetEnum.BLANK) {
480
537
  if (!_data.normalUrl) return failCallback();
481
538
  successCallback('normalUrl', _data.normalUrl);
482
539
  window.open(_data.normalUrl);
483
540
  return;
484
541
  }
542
+ this.cleanContainer();
485
543
  this.AMSSDK._redirect({
486
544
  applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
487
545
  }).then(function () {
488
546
  successCallback('applinkUrl', _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
489
547
  }).catch(function () {
490
- return _this3.AMSSDK._redirect({
548
+ return _this4.AMSSDK._redirect({
491
549
  schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
492
550
  });
493
551
  }).then(function () {
494
552
  successCallback('schemeUrl', _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
495
553
  }).catch(function () {
496
- return _this3.AMSSDK._redirect({
554
+ return _this4.AMSSDK._redirect({
497
555
  normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
498
556
  });
499
557
  }).then(function () {
@@ -507,59 +565,18 @@ var ComponentApp = /*#__PURE__*/function () {
507
565
  value: function handleDeclareInfo(_ref3) {
508
566
  var _ref3$closeDialogData = _ref3.closeDialogData,
509
567
  closeDialogData = _ref3$closeDialogData === void 0 ? {} : _ref3$closeDialogData;
510
- try {
511
- if (closeDialogData) {
512
- var retentionTitle = document.getElementById('ams-component-retention-title');
513
- if (retentionTitle) {
514
- var _closeDialogData$titl, _closeDialogData$titl2, _closeDialogData$titl3;
515
- 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");
516
- retentionTitle.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl2 = closeDialogData.title) === null || _closeDialogData$titl2 === void 0 ? void 0 : _closeDialogData$titl2.fontColor;
517
- retentionTitle.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$titl3 = closeDialogData.title) === null || _closeDialogData$titl3 === void 0 ? void 0 : _closeDialogData$titl3.text;
518
- }
519
- var retentionMessage = document.getElementById('ams-component-retention-sub-title');
520
- if (retentionMessage) {
521
- var _closeDialogData$mess, _closeDialogData$mess2, _closeDialogData$mess3;
522
- 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");
523
- retentionMessage.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess2 = closeDialogData.message) === null || _closeDialogData$mess2 === void 0 ? void 0 : _closeDialogData$mess2.fontColor;
524
- retentionMessage.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$mess3 = closeDialogData.message) === null || _closeDialogData$mess3 === void 0 ? void 0 : _closeDialogData$mess3.text;
525
- }
526
- var remainBtn = document.getElementById('ams-component-retention-remain');
527
- if (remainBtn) {
528
- var _closeDialogData$btnO, _closeDialogData$btnO2, _closeDialogData$btnO3, _closeDialogData$btnO4, _closeDialogData$btnO5, _closeDialogData$btnO7;
529
- remainBtn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO = closeDialogData.btnOK) === null || _closeDialogData$btnO === void 0 ? void 0 : _closeDialogData$btnO.text;
530
- 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");
531
- remainBtn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO3 = closeDialogData.btnOK) === null || _closeDialogData$btnO3 === void 0 ? void 0 : _closeDialogData$btnO3.fontColor;
532
- 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");
533
- if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnO5 = closeDialogData.btnOK) === null || _closeDialogData$btnO5 === void 0 ? void 0 : _closeDialogData$btnO5.type) === 'stroke') {
534
- var _closeDialogData$btnO6;
535
- 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);
536
- } 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;
537
- }
538
- var leaveBrn = document.getElementById('ams-component-retention-leave');
539
- if (leaveBrn) {
540
- var _closeDialogData$btnC, _closeDialogData$btnC2, _closeDialogData$btnC3, _closeDialogData$btnC4, _closeDialogData$btnC5, _closeDialogData$btnC7;
541
- leaveBrn.innerHTML = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC = closeDialogData.btnCancel) === null || _closeDialogData$btnC === void 0 ? void 0 : _closeDialogData$btnC.text;
542
- 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");
543
- leaveBrn.style.color = closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC3 = closeDialogData.btnCancel) === null || _closeDialogData$btnC3 === void 0 ? void 0 : _closeDialogData$btnC3.fontColor;
544
- 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");
545
- if ((closeDialogData === null || closeDialogData === void 0 ? void 0 : (_closeDialogData$btnC5 = closeDialogData.btnCancel) === null || _closeDialogData$btnC5 === void 0 ? void 0 : _closeDialogData$btnC5.type) === 'stroke') {
546
- var _closeDialogData$btnC6;
547
- 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);
548
- } 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;
549
- }
550
- }
551
- } catch (error) {
552
- console.error(error);
553
- }
568
+ _handleDeclareInfo({
569
+ closeDialogData: closeDialogData
570
+ });
554
571
  }
555
572
  }, {
556
573
  key: "handleCloseBtnShow",
557
574
  value: function handleCloseBtnShow(showClose) {
558
- var closeBlock = document.getElementById('asm-component-section-close-block');
575
+ var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
559
576
  if (showClose) {
560
- closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove('asm-component-close-block-hidden');
577
+ closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
561
578
  } else if (showClose === false) {
562
- closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add('asm-component-close-block-hidden');
579
+ closeBlock === null || closeBlock === void 0 ? void 0 : closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
563
580
  }
564
581
  }
565
582
 
@@ -569,7 +586,7 @@ var ComponentApp = /*#__PURE__*/function () {
569
586
  }, {
570
587
  key: "dispatchToSDK",
571
588
  value: function dispatchToSDK(event, data) {
572
- this.AMSSDK.eventCenter.emit(event, data);
589
+ this.AMSSDK._eventCenter.emit(event, data);
573
590
  }
574
591
 
575
592
  /**
@@ -584,9 +601,11 @@ var ComponentApp = /*#__PURE__*/function () {
584
601
  appId: COMPONENTPLUGINID,
585
602
  instanceId: this.AMSSDK._instanceId
586
603
  });
604
+ // TODO 如果存在回调函数,则增加callBack标识,并存入map。map可以设置
587
605
  if (this.app && this.app.contentWindow) {
588
- this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
606
+ return this.app.contentWindow.postMessage(JSON.stringify(data), this.appDomain);
589
607
  }
608
+ throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
590
609
  }
591
610
 
592
611
  /**
@@ -599,7 +618,7 @@ var ComponentApp = /*#__PURE__*/function () {
599
618
  for (var key in eventKeyMap) {
600
619
  // eslint-disable-next-line no-prototype-builtins
601
620
  if (eventKeyMap.hasOwnProperty(key)) {
602
- this.AMSSDK.eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
621
+ this.AMSSDK._eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
603
622
  }
604
623
  }
605
624
  }
@@ -611,7 +630,7 @@ var ComponentApp = /*#__PURE__*/function () {
611
630
  key: "sendRenderEvent",
612
631
  value: function () {
613
632
  var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
614
- var _this$_renderParams, _this$_renderParams2, res;
633
+ var _this$_renderParams, _this$_renderParams2, _this$_renderParams3, _this$_renderParams4, res;
615
634
  return _regeneratorRuntime().wrap(function _callee$(_context) {
616
635
  while (1) switch (_context.prev = _context.next) {
617
636
  case 0:
@@ -638,6 +657,8 @@ var ComponentApp = /*#__PURE__*/function () {
638
657
  sessionResult: (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData,
639
658
  paymentSessionData: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
640
659
  heightOfVisible: Math.max(innerHeight, window.innerHeight),
660
+ renderDisplayType: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.renderDisplayType,
661
+ appearance: (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.appearance,
641
662
  envInfo: {
642
663
  screenHeight: screen.height,
643
664
  screenWidth: screen.width
@@ -670,198 +691,77 @@ var ComponentApp = /*#__PURE__*/function () {
670
691
  }
671
692
  return sendRenderEvent;
672
693
  }()
673
- }, {
674
- key: "showLoading",
675
- value: function showLoading() {
676
- var loading = document.createElement('div');
677
- loading === null || loading === void 0 ? void 0 : loading.classList.add(loadingId);
678
- loading.id = loadingId;
679
- loading.innerHTML = '<div class="line"><div></div><div></div><div></div><div></div></div>';
680
- loading.style.fontSize = "".concat(getDesignFontSize(), "px");
681
- var body = document.getElementsByTagName('body')[0];
682
- body === null || body === void 0 ? void 0 : body.appendChild(loading);
683
- }
684
-
685
- /**
686
- * @description show cashier
687
- */
688
- }, {
689
- key: "showCashier",
690
- value: function showCashier() {
691
- var cashier = document.getElementById('ams-component-container');
692
- cashier === null || cashier === void 0 ? void 0 : cashier.classList.remove("ams-component-container-hidden-".concat(this.platform));
693
- cashier === null || cashier === void 0 ? void 0 : cashier.classList.add("ams-component-container-".concat(this.platform));
694
- }
695
-
696
694
  /**
697
695
  * @description close cashier
698
696
  */
699
697
  }, {
700
- key: "closeCashier",
701
- value: function closeCashier() {
702
- var _document$getElementB2;
698
+ key: "cleanContainer",
699
+ value: function cleanContainer() {
700
+ var _document$getElementB4,
701
+ _this5 = this;
703
702
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
703
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
704
704
  this._performanceData = [];
705
705
  this._isInitComponent = false;
706
- (_document$getElementB2 = document.getElementById(loadingId)) === null || _document$getElementB2 === void 0 ? void 0 : _document$getElementB2.remove();
707
- this.hideComponentAndCleanDom(immediately);
708
- }
709
- }, {
710
- key: "hideComponentAndCleanDom",
711
- value: function hideComponentAndCleanDom() {
712
- var _this4 = this;
713
- var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
714
- var container = document.getElementById('ams-component-container');
715
- // size变化动画取消
716
- container.style.transition = '';
717
- container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform));
718
- container === null || container === void 0 ? void 0 : container.classList.remove("ams-component-container-".concat(this.platform, "-animation"));
719
- container === null || container === void 0 ? void 0 : container.classList.add("ams-component-container-hidden-".concat(this.platform));
720
- var removeMockupAndApp = function removeMockupAndApp() {
721
- var _document$getElementB3;
722
- var body = document.getElementsByTagName('body')[0];
723
- body.style.overflow = 'auto';
724
- var mockup = document.getElementById(mockupId);
725
- mockup === null || mockup === void 0 ? void 0 : mockup.remove();
726
- if (container) container.style.height = '';
727
- (_document$getElementB3 = document.getElementById('ams-component-container-mobile-animation-style')) === null || _document$getElementB3 === void 0 ? void 0 : _document$getElementB3.remove();
728
- _this4.removeRetentionPopup();
729
- _this4.cleanApp();
730
- };
731
- if (immediately) removeMockupAndApp();else {
706
+ this.app = null;
707
+ (_document$getElementB4 = document.getElementById(LOADING_ID)) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
708
+ this.hideComponentAnimation();
709
+ var mockup = document.getElementById(MOCKUP_ID);
710
+ mockup === null || mockup === void 0 ? void 0 : mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
711
+ if (immediately) this.cleanElement();else {
732
712
  setTimeout(function () {
733
- removeMockupAndApp();
713
+ _this5.cleanElement();
734
714
  }, 300);
735
715
  }
736
716
  }
717
+ }, {
718
+ key: "hideComponentAnimation",
719
+ value: function hideComponentAnimation() {
720
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
721
+ if (container) {
722
+ // size变化动画取消
723
+ container.style.transition = '';
724
+ container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform));
725
+ container === null || container === void 0 ? void 0 : container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
726
+ container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.platform));
727
+ }
728
+ }
737
729
  }, {
738
730
  key: "closeBtnFunc",
739
731
  value: function closeBtnFunc() {
740
732
  // element && element.removeEventListener()
741
733
  if (this._isRetention) this.showRetentionPopup();else {
742
- this.closeCashier();
743
- this.dispatchToSDK(EVENT.onClose.name, {});
744
- }
745
- }
746
-
747
- /**
748
- * @description create mount node
749
- */
750
- }, {
751
- key: "createMountElement",
752
- value: function createMountElement() {
753
- componentAddCSS();
754
- var amsComponentContainer = document.createElement('div');
755
- amsComponentContainer.className = "ams-component-container-hidden-".concat(this.platform);
756
- amsComponentContainer.id = 'ams-component-container';
757
- amsSetSize(null, amsComponentContainer);
758
- document.body.appendChild(amsComponentContainer);
759
- var amsComponentSection = document.createElement('div');
760
- amsComponentSection.className = "ams-component-section-".concat(this.platform);
761
- amsComponentSection.id = this._selector.slice(1);
762
- amsComponentContainer.appendChild(amsComponentSection);
763
- this.createCloseBtn();
764
- }
765
- }, {
766
- key: "createCloseBtn",
767
- value: function createCloseBtn() {
768
- var _this5 = this;
769
- var container = document.getElementById('ams-component-container');
770
- // close btn
771
- var closeBtnHTML = "<img class='asm-component-close-btn-".concat(this.platform, "' src=\"https://cdn.marmot-cloud.com/storage/2023/5/18/1692a487-99b5-4314-9d6f-e9814bc1ca41.svg\"/>");
772
- var closeBlock = document.createElement('div');
773
- closeBlock.classList.add("asm-component-close-block-".concat(this.platform), 'asm-component-close-block-hidden');
774
- closeBlock.id = 'asm-component-section-close-block';
775
- closeBlock.innerHTML = closeBtnHTML;
776
- closeBlock.addEventListener(this._clickEventName, function () {
777
- _this5.closeBtnFunc();
778
- });
779
- if (container) container.appendChild(closeBlock);
780
- }
781
- }, {
782
- key: "createRetentionPopup",
783
- value: function createRetentionPopup() {
784
- // retention popup
785
- var retentionPopup = document.createElement('div');
786
- retentionPopup.id = 'ams-component-retention';
787
- retentionPopup.classList.add("ams-component-retention-".concat(this.platform));
788
- 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>");
789
- document.body.appendChild(retentionPopup);
790
- var remainBtn = document.getElementById('ams-component-retention-remain');
791
- if (remainBtn) {
792
- remainBtn.addEventListener(this._clickEventName, this.hideRetentionPopup.bind(this));
793
- }
794
- var leaveBtn = document.getElementById('ams-component-retention-leave');
795
- if (leaveBtn) {
796
- leaveBtn.addEventListener(this._clickEventName, this.retentionPopupLeaveFunc.bind(this));
734
+ this.cleanContainer();
735
+ this.dispatchToSDK(EVENT.close.name, {});
797
736
  }
798
737
  }
799
738
  }, {
800
739
  key: "retentionPopupLeaveFunc",
801
740
  value: function retentionPopupLeaveFunc() {
802
- this.dispatchToSDK(EVENT.onClose.name, {});
803
- this.hideRetentionPopup();
804
- this.closeCashier();
741
+ this.dispatchToSDK(EVENT.close.name, {});
742
+ this.hideRetentionPopupFunc();
743
+ this.cleanContainer();
805
744
  }
806
745
  }, {
807
746
  key: "removeRetentionPopup",
808
- value: function removeRetentionPopup() {
809
- var _document$getElementB4;
810
- var remainBtn = document.getElementById('ams-component-retention-remain');
811
- if (remainBtn) {
812
- remainBtn.removeEventListener(this._clickEventName, this.hideRetentionPopup);
813
- }
814
- var leaveBtn = document.getElementById('ams-component-retention-leave');
815
- if (leaveBtn) {
816
- leaveBtn.removeEventListener(this._clickEventName, this.retentionPopupLeaveFunc);
817
- }
818
- (_document$getElementB4 = document.getElementById('ams-component-retention')) === null || _document$getElementB4 === void 0 ? void 0 : _document$getElementB4.remove();
747
+ value: function removeRetentionPopup(platform) {
748
+ _removeRetentionPopup(platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
819
749
  }
820
750
  }, {
821
751
  key: "showRetentionPopup",
822
752
  value: function showRetentionPopup() {
823
- var retentionPopup = document.getElementById('ams-component-retention');
824
- var container = document.getElementById('ams-component-container');
753
+ var retentionPopup = document.getElementById(COMPONENT_RETENTION_ID);
754
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
825
755
  if (retentionPopup) {
826
- container === null || container === void 0 ? void 0 : container.classList.add('ams-component-container-opacity');
827
- retentionPopup.classList.remove('ams-component-retention-hidden');
828
- retentionPopup.classList.add('ams-component-retention-show');
756
+ container === null || container === void 0 ? void 0 : container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-opacity"));
757
+ retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-hidden"));
758
+ retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-show"));
829
759
  }
830
760
  }
831
761
  }, {
832
- key: "hideRetentionPopup",
833
- value: function hideRetentionPopup() {
834
- var retentionPopup = document.getElementById('ams-component-retention');
835
- var container = document.getElementById('ams-component-container');
836
- if (retentionPopup) {
837
- retentionPopup.classList.remove('ams-component-retention-show');
838
- retentionPopup.classList.add('ams-component-retention-hidden');
839
- setTimeout(function () {
840
- retentionPopup.classList.remove('ams-component-retention-hidden');
841
- container === null || container === void 0 ? void 0 : container.classList.remove('ams-component-container-opacity');
842
- }, 250);
843
- }
844
- }
845
- /**
846
- * @description create mockup
847
- */
848
- }, {
849
- key: "createMockup",
850
- value: function createMockup() {
851
- var body = document.getElementsByTagName('body')[0];
852
- body.style.overflow = 'hidden';
853
- var mockup = document.createElement('div');
854
- mockup.style.width = '100vw';
855
- mockup.style.height = '100vh';
856
- mockup.style.position = 'fixed';
857
- mockup.style.top = '0';
858
- mockup.style.left = '0';
859
- mockup.style.zIndex = '1000';
860
- mockup.style.background = '#ffffff';
861
- mockup.style.opacity = '0.5';
862
- mockup.style.display = 'none';
863
- mockup.id = mockupId;
864
- body.appendChild(mockup);
762
+ key: "hideRetentionPopupFunc",
763
+ value: function hideRetentionPopupFunc() {
764
+ hideRetentionPopup();
865
765
  }
866
766
  }, {
867
767
  key: "submitForm",
@@ -882,7 +782,6 @@ var ComponentApp = /*#__PURE__*/function () {
882
782
  form.setAttribute('action', attributes.action);
883
783
  form.setAttribute('method', 'post');
884
784
  body.appendChild(form);
885
- this.closeCashier(true);
886
785
  setTimeout(function () {
887
786
  form.submit();
888
787
  }, 0);