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